using QFramework.Example; using System; using UnityEngine; namespace QFramework { internal class HintAction : IAction { public string txt; float time = -1; bool showIcon = true; string audio; public System.Action OnFinished { get; set; } private HintAction() { } private static readonly SimpleObjectPool mPool = new SimpleObjectPool(() => new HintAction(), null, 10); public static HintAction Allocate(string txt, string time = "", string icon = "true", string audio = "", System.Action OnFinished = null) { var retNode = mPool.Allocate(); retNode.ActionID = ActionKit.ID_GENERATOR++; retNode.Deinited = false; retNode.Reset(); retNode.txt = txt; float.TryParse(time, out retNode.time); bool.TryParse(icon, out retNode.showIcon); retNode.audio = audio; retNode.OnFinished = OnFinished; return retNode; } public ulong ActionID { get; set; } public ActionStatus Status { get; set; } public void OnStart() { UIHintData data = new UIHintData(); data.txt = txt; data.time = time; data.isShowIcon = showIcon; data.audio = audio; UIKit.OpenPanelAsync(uiData: data, canvasLevel: UILevel.PopUI).ToAction().StartGlobal(() => { if (data.time != -1) { ActionKit.Delay(data.time, () => this.Finish()).StartGlobal(); } else { this.Finish(); } }); } public void OnExecute(float dt) { } public void OnFinish() { } public void Reset() { Status = ActionStatus.NotStart; Paused = false; } public bool Paused { get; set; } public void Deinit() { if (!Deinited) { OnFinished = null; Deinited = true; mPool.Recycle(this); } } public bool Deinited { get; set; } } }