using UnityEngine; using UnityEngine.UI; using ZXKFramework; namespace DongWuYiXue.DaoNiaoShu { public class ArrowPanel : UIBase { public override string GroupName => "ArrowPanel"; public override string Name => "ArrowPanel"; public GameObject[] arrow; Text tipText; Coroutine coroutine; Coroutine coroutine2; public override void Init(IUIManager uictrl) { base.Init(uictrl); tipText = transform.FindFirst("Txt"); } public void ShowArrow(Transform v, string Txt, int arrowType, int showTime, int hideTime = 3) { HideAllArrow(); coroutine = Game.Instance.IEnumeratorManager.Run(showTime, () => { tipText.text = Txt; SetActive(true); arrow[arrowType].gameObject.SetActive(true); arrow[arrowType].transform.position = Camera.main.WorldToScreenPoint(v.position); coroutine2 = Game.Instance.IEnumeratorManager.Run(hideTime, () => { HideArrow(); }); }); } public void ShowArrow(string txt,Vector2 v, int arrowType, int showTime, int hideTime = 3) { HideAllArrow(); coroutine = Game.Instance.IEnumeratorManager.Run(showTime, () => { tipText.text = txt; SetActive(true); arrow[arrowType].gameObject.SetActive(true); arrow[arrowType].GetComponent().anchoredPosition = v; coroutine2 = Game.Instance.IEnumeratorManager.Run(hideTime, () => { HideArrow(); }); }); } public void ShowArrow(Vector2 v, int arrowType, int showTime, int hideTime = 3) { HideAllArrow(); coroutine = Game.Instance.IEnumeratorManager.Run(showTime, () => { SetActive(true); arrow[arrowType].gameObject.SetActive(true); arrow[arrowType].GetComponent().anchoredPosition = v; coroutine2 = Game.Instance.IEnumeratorManager.Run(hideTime, () => { HideArrow(); }); }); } public override void Hide() { base.Hide(); Game.Instance.IEnumeratorManager.Stop(coroutine); Game.Instance.IEnumeratorManager.Stop(coroutine2); } public void HideArrow() { Game.Instance.IEnumeratorManager.Stop(coroutine); Game.Instance.IEnumeratorManager.Stop(coroutine2); SetActive(false); } public void HideAllArrow() { for (int i = 0; i < arrow.Length; i++) { arrow[i].SetActive(false); } } } }