VirtualFramework/Assets/Scripts/Actions/ShowScoreAction.cs

82 lines
2.0 KiB
C#

using QFramework.Example;
using System;
using System.Collections.Generic;
using UnityEngine;
namespace QFramework
{
internal class ShowScoreAction : IAction
{
public System.Action OnFinished { get; set; }
private ShowScoreAction()
{
}
private static readonly SimpleObjectPool<ShowScoreAction> mPool =
new SimpleObjectPool<ShowScoreAction>(() => new ShowScoreAction(), null, 10);
Dictionary<string, string> datas;
public static ShowScoreAction Allocate(Dictionary<string, string> datas, System.Action OnFinished = null)
{
var retNode = mPool.Allocate();
retNode.ActionID = ActionKit.ID_GENERATOR++;
retNode.Deinited = false;
retNode.Reset();
retNode.datas = datas;
retNode.OnFinished = OnFinished;
return retNode;
}
public ulong ActionID { get; set; }
public ActionStatus Status { get; set; }
public void OnStart()
{
UIScoreData data = new UIScoreData();
if (datas.ContainsKey("onlyCurModule"))
{
if (bool.TryParse(datas["onlyCurModule"], out data.onlyCurModule) == false)
{
data.onlyCurModule = false;
}
}
UIKit.OpenPanelAsync<UIScore>(canvasLevel: UILevel.PopUI, uiData: data).ToAction().StartGlobal(() => this.Finish());
}
public void OnExecute(float dt)
{
//this.Finish();
//OnFinished?.Invoke();
}
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; }
}
}