98 lines
2.3 KiB
C#
98 lines
2.3 KiB
C#
using QFramework.Example;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Runtime.CompilerServices;
|
|
using UnityEngine;
|
|
namespace QFramework
|
|
{
|
|
|
|
|
|
public class DragPanelAction: IAction
|
|
{
|
|
public System.Action OnFinished
|
|
{
|
|
get; set;
|
|
}
|
|
|
|
public ulong ActionID
|
|
{
|
|
get; set;
|
|
}
|
|
public ActionStatus Status
|
|
{
|
|
get; set;
|
|
}
|
|
public bool Deinited
|
|
{
|
|
get; set;
|
|
}
|
|
public bool Paused
|
|
{
|
|
get; set;
|
|
}
|
|
private DragPanelAction()
|
|
{
|
|
}
|
|
private static readonly SimpleObjectPool<DragPanelAction> mPool =
|
|
new SimpleObjectPool<DragPanelAction>(() => new(), null, 10);
|
|
Dictionary<string, string> datas;
|
|
|
|
public static DragPanelAction Allocate(Dictionary<string, string> datas, System.Action onDelayFinish = null)
|
|
{
|
|
var retNode = mPool.Allocate();
|
|
retNode.ActionID = ActionKit.ID_GENERATOR++;
|
|
retNode.Deinited = false;
|
|
retNode.Reset();
|
|
retNode.datas = datas;
|
|
return retNode;
|
|
}
|
|
public void Deinit()
|
|
{
|
|
if (!Deinited)
|
|
{
|
|
Deinited = true;
|
|
mPool.Recycle(this);
|
|
}
|
|
}
|
|
|
|
public void OnExecute(float dt)
|
|
{
|
|
}
|
|
|
|
public void OnFinish()
|
|
{
|
|
// Debug.Log("Action OnFinish???");
|
|
}
|
|
|
|
|
|
public void OnStart()
|
|
{
|
|
DragPanelData data = new DragPanelData();
|
|
|
|
|
|
|
|
//ÍÏ×§¶ÔÏó£¬
|
|
data.DragItemName = datas.ContainsKey("DragItemName") ? datas["DragItemName"] : string.Empty;
|
|
|
|
data.HieraNames = datas.ContainsKey("HieraNames") ? datas["HieraNames"] : string.Empty;
|
|
data.TargetObjs = datas.ContainsKey("TargetObjs") ? datas["TargetObjs"] : string.Empty;
|
|
|
|
data.FinishedEvent = datas.ContainsKey("FinishedEvent") ? datas["FinishedEvent"] : string.Empty;
|
|
|
|
|
|
|
|
UIKit.OpenPanelAsync<DragPanel>(uiData: data, canvasLevel: UILevel.Common).ToAction().StartGlobal(() =>
|
|
{
|
|
this.Finish();
|
|
});
|
|
|
|
}
|
|
|
|
public void Reset()
|
|
{
|
|
Status = ActionStatus.NotStart;
|
|
Paused = false;
|
|
}
|
|
|
|
}
|
|
} |