88 lines
2.3 KiB
C#
88 lines
2.3 KiB
C#
using QFramework.Example;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
namespace QFramework
|
|
{
|
|
internal class ImageTipAction : IAction
|
|
{
|
|
public System.Action OnFinished { get; set; }
|
|
|
|
|
|
private ImageTipAction()
|
|
{
|
|
}
|
|
|
|
private static readonly SimpleObjectPool<ImageTipAction> mPool =
|
|
new SimpleObjectPool<ImageTipAction>(() => new ImageTipAction(), null, 10);
|
|
Dictionary<string, string> datas;
|
|
public static ImageTipAction Allocate(Dictionary<string, string> datas, System.Action OnFinished = null)
|
|
{
|
|
var retNode = mPool.Allocate();
|
|
retNode.ActionID = ActionKit.ID_GENERATOR++;
|
|
retNode.Deinited = false;
|
|
retNode.Reset();
|
|
retNode.OnFinished = OnFinished;
|
|
retNode.datas = datas;
|
|
return retNode;
|
|
}
|
|
|
|
|
|
public ulong ActionID { get; set; }
|
|
public ActionStatus Status { get; set; }
|
|
|
|
public void OnStart()
|
|
{
|
|
UIImageTipData data = new UIImageTipData();
|
|
data.imgPath = datas.ContainsKey("path") ? datas["path"] : string.Empty;
|
|
if (datas.ContainsKey("size"))
|
|
{
|
|
data.size = Utility.GetVector2FromStrArray(datas["size"]);
|
|
}
|
|
if (datas.ContainsKey("isDrag"))
|
|
{
|
|
bool.TryParse(datas["isDrag"], out data.isDrag);
|
|
}
|
|
if (datas.ContainsKey("position"))
|
|
{
|
|
data.position = Utility.GetVector2FromStrArray(datas["position"]);
|
|
}
|
|
UIKit.OpenPanelAsync<UIImageTip>(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; }
|
|
}
|
|
|
|
|
|
} |