VirtualFramework/Assets/Scripts/Actions/ReSetZhanShiCameraAction.cs

91 lines
1.8 KiB
C#

using DG.Tweening;
using QFramework;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class ReSetZhanShiCameraAction : 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<ReSetZhanShiCameraAction> mPool =
new SimpleObjectPool<ReSetZhanShiCameraAction>(() => new ReSetZhanShiCameraAction(), null, 10);
Vector3 pos;
float time;
string path;
public static ReSetZhanShiCameraAction Allocate(string path, Vector3 pos, float time, System.Action onDelayFinish = null)
{
var retNode = mPool.Allocate();
retNode.ActionID = ActionKit.ID_GENERATOR++;
retNode.Deinited = false;
retNode.Reset();
retNode.pos = pos;
retNode.time = time;
retNode.path = path;
return retNode;
}
public void Deinit()
{
if (!Deinited)
{
Deinited = true;
mPool.Recycle(this);
}
}
public void OnExecute(float dt)
{
}
public void OnFinish()
{
}
public void OnStart()
{
GameObject obj = null;
#if VR
if (path == "FlyCamera")
{
obj = UIRoot.Instance.transform.Find("ZFrame").gameObject;
}
#endif
obj = Utility.FindObj(path);
if (obj == null)
{
Debug.LogError($"ûÓÐÕÒµ½Â·¾¶{path}");
return;
}
obj.transform.DOMove(pos, time).onComplete = () => this.Finish(); ;
}
public void Reset()
{
Status = ActionStatus.NotStart;
Paused = false;
}
}