2024-12-14 18:27:59 +08:00

63 lines
1.3 KiB
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using QFramework;
using System;
using QFramework.Example;
using DG.Tweening;
public class SetVarAction : 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<SetVarAction> mPool =
new SimpleObjectPool<SetVarAction>(() => new SetVarAction(), null, 10);
string key;
float value;
public static SetVarAction Allocate(string key, string value, System.Action onDelayFinish = null)
{
var retNode = mPool.Allocate();
retNode.ActionID = ActionKit.ID_GENERATOR++;
retNode.Deinited = false;
retNode.Reset();
retNode.key = key;
float.TryParse(value, out retNode.value);
return retNode;
}
public void Deinit()
{
if (!Deinited)
{
Deinited = true;
mPool.Recycle(this);
}
}
public void OnExecute(float dt)
{
}
public void OnFinish()
{
}
public void OnStart()
{
VarController.Instance.Set(key, value);
this.Finish();
}
public void Reset()
{
Status = ActionStatus.NotStart;
Paused = false;
}
}