82 lines
2.1 KiB
C#
82 lines
2.1 KiB
C#
using QFramework.Example;
|
|
using System;
|
|
using UnityEngine;
|
|
|
|
namespace QFramework
|
|
{
|
|
internal class ResultTipAction : IAction
|
|
{
|
|
public System.Action OnFinished { get; set; }
|
|
|
|
|
|
private ResultTipAction()
|
|
{
|
|
}
|
|
|
|
private static readonly SimpleObjectPool<ResultTipAction> mPool =
|
|
new SimpleObjectPool<ResultTipAction>(() => new ResultTipAction(), null, 10);
|
|
|
|
public string txt;
|
|
public string isRight;
|
|
public string finishedEvent;
|
|
public static ResultTipAction Allocate(string txt, string isRight, string finishedEvent, System.Action OnFinished = null)
|
|
{
|
|
var retNode = mPool.Allocate();
|
|
retNode.ActionID = ActionKit.ID_GENERATOR++;
|
|
retNode.Deinited = false;
|
|
retNode.Reset();
|
|
retNode.txt = txt;
|
|
retNode.isRight = isRight;
|
|
retNode.finishedEvent = finishedEvent;
|
|
retNode.OnFinished = OnFinished;
|
|
return retNode;
|
|
}
|
|
|
|
|
|
public ulong ActionID { get; set; }
|
|
public ActionStatus Status { get; set; }
|
|
|
|
public void OnStart()
|
|
{
|
|
UIResultTipData data = new UIResultTipData();
|
|
data.label = txt;
|
|
bool.TryParse(isRight, out data.isRight);
|
|
if (string.IsNullOrEmpty(finishedEvent) == false)
|
|
{
|
|
data.callback = () => StringEventSystem.Global.Send(finishedEvent);
|
|
}
|
|
UIKit.OpenPanelAsync<UIResultTip>(uiData: data, canvasLevel: UILevel.PopUI).ToAction().StartGlobal(() => 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; }
|
|
}
|
|
|
|
|
|
} |