106 lines
2.9 KiB
C#
106 lines
2.9 KiB
C#
using QFramework.Example;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using Unity.VisualScripting;
|
|
using UnityEngine;
|
|
|
|
namespace QFramework
|
|
{
|
|
internal class CameraSwitchAction : IAction
|
|
{
|
|
public System.Action OnFinished { get; set; }
|
|
|
|
|
|
private CameraSwitchAction()
|
|
{
|
|
}
|
|
|
|
private static readonly SimpleObjectPool<CameraSwitchAction> mPool =
|
|
new SimpleObjectPool<CameraSwitchAction>(() => new CameraSwitchAction(), null, 10);
|
|
|
|
|
|
Dictionary<string, string> datas;
|
|
public static CameraSwitchAction Allocate(Dictionary<string, string> dict, System.Action OnFinished = null)
|
|
{
|
|
var retNode = mPool.Allocate();
|
|
retNode.ActionID = ActionKit.ID_GENERATOR++;
|
|
retNode.Deinited = false;
|
|
retNode.Reset();
|
|
retNode.OnFinished = OnFinished;
|
|
retNode.datas = dict;
|
|
return retNode;
|
|
}
|
|
|
|
|
|
public ulong ActionID { get; set; }
|
|
public ActionStatus Status { get; set; }
|
|
|
|
public void OnStart()
|
|
{
|
|
UICameraSwitchData data = new UICameraSwitchData();
|
|
|
|
if (datas.ContainsKey("nearDevice"))
|
|
{
|
|
GameObject obj = DeviceController.Instance.GetDeviceObj(datas["nearDevice"]);
|
|
data.nearPos = obj.Position();
|
|
data.nearRot = obj.EulerAngles();
|
|
|
|
}
|
|
else
|
|
{
|
|
data.nearPos = Utility.GetVector3FromStrArray(datas["nearPos"]);
|
|
data.nearRot = Utility.GetVector3FromStrArray(datas["nearRot"]);
|
|
|
|
}
|
|
|
|
if (datas.ContainsKey("normalDevice"))
|
|
{
|
|
GameObject obj = DeviceController.Instance.GetDeviceObj(datas["normalDevice"]);
|
|
data.normalPos = obj.Position();
|
|
data.normalRot = obj.EulerAngles();
|
|
}
|
|
else
|
|
{
|
|
data.normalPos = Utility.GetVector3FromStrArray(datas["normalPos"]);
|
|
data.normalRot = Utility.GetVector3FromStrArray(datas["normalRot"]);
|
|
}
|
|
|
|
bool.TryParse(datas["isNear"], out data.isNear);
|
|
float.TryParse(datas["nearTime"], out data.nearTime);
|
|
float.TryParse(datas["normalTime"], out data.normalTime);
|
|
|
|
UIKit.OpenPanelAsync<UICameraSwitch>(uiData: data, canvasLevel: UILevel.RightBottom).ToAction().StartGlobal(() => this.Finish());
|
|
}
|
|
|
|
public void OnExecute(float dt)
|
|
{
|
|
|
|
}
|
|
|
|
public void OnFinish()
|
|
{
|
|
}
|
|
|
|
public void Reset()
|
|
{
|
|
Status = ActionStatus.NotStart;
|
|
Paused = false;
|
|
}
|
|
|
|
public bool Paused { get; set; }
|
|
|
|
public void Deinit()
|
|
{
|
|
if (!Deinited)
|
|
{
|
|
OnFinished = null;
|
|
Deinited = true;
|
|
mPool.Recycle(this);
|
|
}
|
|
}
|
|
|
|
public bool Deinited { get; set; }
|
|
}
|
|
|
|
|
|
} |