2024-12-16 15:45:19 +08:00
|
|
|
using QFramework.Example;
|
|
|
|
|
using System;
|
2024-12-23 11:30:18 +08:00
|
|
|
using System.Collections.Generic;
|
2024-12-16 15:45:19 +08:00
|
|
|
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);
|
|
|
|
|
|
2024-12-23 11:30:18 +08:00
|
|
|
|
|
|
|
|
Dictionary<string, string> datas;
|
|
|
|
|
public static CameraSwitchAction Allocate(Dictionary<string, string> dict, System.Action OnFinished = null)
|
2024-12-16 15:45:19 +08:00
|
|
|
{
|
|
|
|
|
var retNode = mPool.Allocate();
|
|
|
|
|
retNode.ActionID = ActionKit.ID_GENERATOR++;
|
|
|
|
|
retNode.Deinited = false;
|
|
|
|
|
retNode.Reset();
|
|
|
|
|
retNode.OnFinished = OnFinished;
|
2024-12-23 11:30:18 +08:00
|
|
|
retNode.datas = dict;
|
2024-12-16 15:45:19 +08:00
|
|
|
return retNode;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public ulong ActionID { get; set; }
|
|
|
|
|
public ActionStatus Status { get; set; }
|
|
|
|
|
|
|
|
|
|
public void OnStart()
|
|
|
|
|
{
|
|
|
|
|
UICameraSwitchData data = new UICameraSwitchData();
|
2024-12-23 11:30:18 +08:00
|
|
|
|
|
|
|
|
if (datas.ContainsKey("nearDevice"))
|
|
|
|
|
{
|
|
|
|
|
GameObject obj = DeviceController.Instance.GetDeviceObj(datas["nearDevice"]);
|
|
|
|
|
data.nearPos = obj.Position();
|
|
|
|
|
data.nearRot = obj.EulerAngles();
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2025-01-20 18:42:51 +08:00
|
|
|
if (datas.ContainsKey("nearPos"))
|
|
|
|
|
{
|
|
|
|
|
data.nearPos = Utility.GetVector3FromStrArray(datas["nearPos"]);
|
|
|
|
|
}
|
|
|
|
|
if (datas.ContainsKey("nearRot"))
|
|
|
|
|
{
|
|
|
|
|
data.nearRot = Utility.GetVector3FromStrArray(datas["nearRot"]);
|
|
|
|
|
}
|
2024-12-23 11:30:18 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (datas.ContainsKey("normalDevice"))
|
|
|
|
|
{
|
|
|
|
|
GameObject obj = DeviceController.Instance.GetDeviceObj(datas["normalDevice"]);
|
|
|
|
|
data.normalPos = obj.Position();
|
|
|
|
|
data.normalRot = obj.EulerAngles();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2025-01-20 18:42:51 +08:00
|
|
|
if (datas.ContainsKey("normalPos"))
|
|
|
|
|
{
|
|
|
|
|
data.normalPos = Utility.GetVector3FromStrArray(datas["normalPos"]);
|
|
|
|
|
}
|
|
|
|
|
if (datas.ContainsKey("normalRot"))
|
|
|
|
|
{
|
|
|
|
|
data.normalRot = Utility.GetVector3FromStrArray(datas["normalRot"]);
|
|
|
|
|
}
|
2024-12-23 11:30:18 +08:00
|
|
|
}
|
2025-03-24 14:32:22 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
if (datas.ContainsKey("vrPos"))
|
|
|
|
|
{
|
|
|
|
|
data.vrPos = Utility.GetVector3FromStrArray(datas["vrPos"]);
|
|
|
|
|
}
|
|
|
|
|
if (datas.ContainsKey("vrRot"))
|
|
|
|
|
{
|
|
|
|
|
data.vrRot = Utility.GetVector3FromStrArray(datas["vrRot"]);
|
|
|
|
|
}
|
|
|
|
|
|
2025-01-09 14:10:59 +08:00
|
|
|
if (datas.ContainsKey("isOn"))
|
|
|
|
|
{
|
|
|
|
|
data.isOn = datas["isOn"];
|
|
|
|
|
}
|
2025-03-24 14:32:22 +08:00
|
|
|
if (datas.ContainsKey("nearTime"))
|
|
|
|
|
{
|
|
|
|
|
float.TryParse(datas["nearTime"], out data.nearTime);
|
|
|
|
|
}
|
|
|
|
|
if (datas.ContainsKey("normalTime"))
|
|
|
|
|
{
|
|
|
|
|
float.TryParse(datas["normalTime"], out data.normalTime);
|
|
|
|
|
}
|
|
|
|
|
if (datas.ContainsKey("vrTime"))
|
|
|
|
|
{
|
|
|
|
|
float.TryParse(datas["vrTime"], out data.vrTime);
|
|
|
|
|
}
|
2024-12-23 11:30:18 +08:00
|
|
|
|
2024-12-16 15:45:19 +08:00
|
|
|
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; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|