diff --git a/Assets/Pokedex.cs b/Assets/Pokedex.cs index 89cf7da..e725b9c 100644 --- a/Assets/Pokedex.cs +++ b/Assets/Pokedex.cs @@ -7,39 +7,29 @@ using System.Threading.Tasks; public class Pokedex : MonoBehaviour { public TextMeshProUGUI PokeText; - public int PokeTemps = 10; - private bool PokeBool = false; - public bool ArretDéfilement = false; - + public int PokeTemps = 5; + private bool ArretDéfilement = false; + private string PokeSubDescription; public async void PokeDescription(int PokeNumero) { - if (PokeBool == false) + ArretDéfilement = false; + PokeSubDescription = GetComponent().items[PokeNumero].description; + PokeText.text = null; + for (int i = 0; i < PokeSubDescription.Length; i++) { - string PokeSubDescription = GetComponent().items[PokeNumero].description; - PokeText.text = null; - PokeBool = true; - for (int i = 0; i < PokeSubDescription.Length; i++) + if (ArretDéfilement == true) { - if (ArretDéfilement == true) - { - ArretDéfilement = false; - PokeBool = false; - return; - } - PokeText.text += PokeSubDescription[i]; - await Task.Delay(PokeTemps); - + return; } - PokeBool = false; + PokeText.text += PokeSubDescription[i]; + await Task.Delay(PokeTemps); } - } public void UpdateMissionText() { ArretDéfilement = true; PokeText.text = GetComponent().GetMissionText(); - ArretDéfilement = false; } } diff --git a/Assets/Script/InventoryManager.cs b/Assets/Script/InventoryManager.cs index bf95d85..7262f58 100644 --- a/Assets/Script/InventoryManager.cs +++ b/Assets/Script/InventoryManager.cs @@ -17,11 +17,16 @@ public class InventoryManager : MonoBehaviour public TreeItem[] items = new TreeItem[15]; public Plot[] plots = new Plot[25]; - private int draggedPosition = -1; + public int draggedPosition = -1; private Vector3 defaultPos; private Vector2Int selectorPos; + private void Start() + { + InventorySlot.manager = this; + } + private void Update() { if (Input.GetKey(KeyCode.Mouse0)) diff --git a/Assets/Script/InventorySlot.cs b/Assets/Script/InventorySlot.cs index eb0cac4..8d0a25c 100644 --- a/Assets/Script/InventorySlot.cs +++ b/Assets/Script/InventorySlot.cs @@ -3,19 +3,22 @@ using UnityEngine.EventSystems; public class InventorySlot : MonoBehaviour, IPointerDownHandler, IPointerEnterHandler, IPointerExitHandler { + public static InventoryManager manager; + public void OnPointerDown(PointerEventData eventData) { - GameObject.Find("GameManager").GetComponent().StartDraggin(int.Parse(transform.parent.name.Substring(6, 2)) - 1); + manager.StartDraggin(int.Parse(transform.parent.name.Substring(6, 2)) - 1); } public void OnPointerEnter(PointerEventData eventData) { - - GameObject.Find("GameManager").GetComponent().PokeDescription(int.Parse(transform.parent.name.Substring(6, 2)) - 1); + if(manager.draggedPosition == -1) + GameObject.Find("GameManager").GetComponent().PokeDescription(int.Parse(transform.parent.name.Substring(6, 2)) - 1); } public void OnPointerExit(PointerEventData eventData) { - GameObject.Find("GameManager").GetComponent().UpdateMissionText(); + if (manager.draggedPosition == -1) + GameObject.Find("GameManager").GetComponent().UpdateMissionText(); } }