87 lines
2.1 KiB
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using QFramework;
using System;
using QFramework.Example;
using System.Linq;
public class UIBackPackAction : IAction
{
public ulong ActionID
{
get; set;
}
public bool Deinited
{
get; set;
}
public bool Paused
{
get; set;
}
public ActionStatus Status
{
get; set;
}
private static readonly SimpleObjectPool<UIBackPackAction> mPool =
new SimpleObjectPool<UIBackPackAction>(() => new UIBackPackAction(), null, 10);
string devices;
string random;
string scrollSpeed;
string position;
public static UIBackPackAction Allocate(Dictionary<string, string> datas, System.Action onDelayFinish = null)
{
var retNode = mPool.Allocate();
retNode.ActionID = ActionKit.ID_GENERATOR++;
retNode.Deinited = false;
retNode.Reset();
retNode.devices = datas.ContainsKey("devices") ? datas["devices"] : "";
retNode.random = datas.ContainsKey("random") ? datas["random"] : "";
retNode.scrollSpeed = datas.ContainsKey("scrollSpeed") ? datas["scrollSpeed"] : "";
retNode.position = datas.ContainsKey("position") ? datas["position"] : "";
return retNode;
}
public void Deinit()
{
if (!Deinited)
{
Deinited = true;
mPool.Recycle(this);
}
}
public void OnExecute(float dt)
{
}
public void OnFinish()
{
}
public void OnStart()
{
UIBackPackData data = new UIBackPackData();
data.devices = devices.Split(',').ToList();
if (bool.TryParse(random, out data.random) == false)
{
data.random = false;
}
if (float.TryParse(scrollSpeed, out data.scrollSpeed) == false)
{
data.scrollSpeed = 25;
}
data.position = position;
UIKit.OpenPanelAsync<UIBackPack>(uiData: data, canvasLevel: UILevel.PopUI).ToAction().StartGlobal(() => this.Finish());
}
public void Reset()
{
Status = ActionStatus.NotStart;
Paused = false;
}
}