80 lines
1.7 KiB
C#
Raw Normal View History

2024-12-14 18:27:59 +08:00
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using QFramework;
using System;
using QFramework.Example;
using DG.Tweening;
public class MoveAction : 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<MoveAction> mPool =
new SimpleObjectPool<MoveAction>(() => new MoveAction(), null, 10);
Vector3 pos;
float time;
string path;
2024-12-31 17:27:27 +08:00
public static MoveAction Allocate(string path, Vector3 pos, float time, System.Action onDelayFinish = null)
2024-12-14 18:27:59 +08:00
{
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()
{
2025-01-03 17:00:55 +08:00
GameObject obj = null;
#if VR
if (path == "FlyCamera")
{
obj = UIRoot.Instance.transform.Find("ZFrame").gameObject;
}
#endif
2025-03-20 13:21:32 +08:00
obj = Utility.FindObj(path);
2024-12-31 17:27:27 +08:00
if (obj == null)
{
Debug.LogError($"û<><C3BB><EFBFBD>ҵ<EFBFBD>·<EFBFBD><C2B7>{path}");
return;
}
2024-12-14 18:27:59 +08:00
obj.transform.DOMove(pos, time).onComplete = () => this.Finish(); ;
}
public void Reset()
{
Status = ActionStatus.NotStart;
Paused = false;
}
}