104 lines
3.4 KiB
C#
104 lines
3.4 KiB
C#
using System;
|
|
using UnityEngine;
|
|
using UnityEngine.Events;
|
|
using UnityEngine.UI;
|
|
using ZXKFramework;
|
|
namespace YiLiao.XinFeiTingZhen
|
|
{
|
|
public class ArrowPanel : UIBase
|
|
{
|
|
public override string GroupName => "ArrowPanel";
|
|
public override string Name => "ArrowPanel";
|
|
GameObject tip;
|
|
GameObject bg;
|
|
Text txt;
|
|
Button btn;
|
|
Coroutine coroutine;
|
|
Coroutine coroutine2;
|
|
Vector2 v1;
|
|
bool v1_bool;
|
|
Transform v2;
|
|
bool v2_bool;
|
|
public override void Init(IUIManager uictrl)
|
|
{
|
|
base.Init(uictrl);
|
|
txt = transform.FindFirst<Text>("指引文字");
|
|
tip = transform.FindFirst("文字提示");
|
|
bg = transform.FindFirst("黑色背景");
|
|
btn = transform.FindFirst<Button>("指引按钮");
|
|
}
|
|
|
|
public void ShowTip(string str,Vector2 v, bool mask, int delayShowTime, int duration, int fontsize, UnityAction action)
|
|
{
|
|
coroutine = Game.Instance.IEnumeratorManager.Run(delayShowTime, () => {
|
|
bg.SetActive(mask);
|
|
SetActive(true);
|
|
tip.SetActive(true);
|
|
tip.GetComponent<RectTransform>().anchoredPosition = v;
|
|
v1 = v;
|
|
v1_bool = true;
|
|
txt.text = str;
|
|
txt.fontSize = fontsize;
|
|
btn.onClick.RemoveAllListeners();
|
|
btn.onClick.AddListener(() => {
|
|
SetActive(false);
|
|
action?.Invoke();
|
|
});
|
|
if (duration != 0)
|
|
{
|
|
coroutine2 = Game.Instance.IEnumeratorManager.Run(duration, () => {
|
|
SetActive(false);
|
|
action?.Invoke();
|
|
});
|
|
}
|
|
});
|
|
}
|
|
|
|
public void ShowTip(string str, Transform v, bool mask, int delayShowTime, int duration,int fontsize, UnityAction action)
|
|
{
|
|
coroutine = Game.Instance.IEnumeratorManager.Run(delayShowTime, () => {
|
|
bg.SetActive(mask);
|
|
SetActive(true);
|
|
tip.SetActive(true);
|
|
tip.transform.position = Camera.main.WorldToScreenPoint(v.position);
|
|
v2 = v;
|
|
v2_bool = true;
|
|
txt.text = str;
|
|
txt.fontSize = fontsize;
|
|
btn.onClick.RemoveAllListeners();
|
|
btn.onClick.AddListener(() => {
|
|
SetActive(false);
|
|
action?.Invoke();
|
|
});
|
|
if(duration != 0)
|
|
{
|
|
coroutine2 = Game.Instance.IEnumeratorManager.Run(duration, () => {
|
|
SetActive(false);
|
|
action?.Invoke();
|
|
});
|
|
}
|
|
});
|
|
}
|
|
|
|
private void Update()
|
|
{
|
|
if (v1_bool)
|
|
{
|
|
tip.GetComponent<RectTransform>().anchoredPosition = v1;
|
|
}
|
|
if (v2_bool)
|
|
{
|
|
tip.transform.position = Camera.main.WorldToScreenPoint(v2.position);
|
|
}
|
|
}
|
|
|
|
public override void Hide()
|
|
{
|
|
base.Hide();
|
|
Game.Instance.IEnumeratorManager.Stop(coroutine);
|
|
Game.Instance.IEnumeratorManager.Stop(coroutine2);
|
|
v1_bool = false;
|
|
v2_bool = false;
|
|
}
|
|
}
|
|
} |