海淀天下城电子沙盘单机版
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

258 lines
9.8 KiB

using AX.InputSystem;
using AX.MessageSystem;
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
[Serializable]
public class ZDSPData
{
public string name;
public long id;
public bool isWatering;
public float HRoate;
public float VRoate;
public RotateAxis HAxis;
public RotateAxis VAxis;
public float scale;
}
public class ZDSPControl : ObjDoubleClick
{
//public bool IsWartering;
//public Transform Body;
//public Transform Pao;
//private ZDSPParticle particle;
//private long id;
//private void Awake()
//{
// if (gameObject.name.Split('_').Length > 0)
// {
// id = 1990199019901990 + (long.Parse)(gameObject.name.Split('_')[1]);
// GetComponent<BaseGameObjInfo>().gameObjID = id;
// gameObject.name = id.ToString();
// }
// EntitiesManager.Instance.AddEntity(id, gameObject);
// if (!SelectedObjs.gameObjs.Contains(gameObject))
// SelectedObjs.gameObjs.Add(gameObject);
//}
//private void Start()
//{
// Body = transform.Find("PaoShen");
// Pao = Body.transform.Find("PaoGuan");
// // particle = Pao.transform.Find("WaterStraight").GetComponent<ZDSPParticle>();
// particle = transform.GetComponentInChildren<ZDSPParticle>();
// Debug.Log(particle.name);
// MessageDispatcher.AddListener("EQUALS_COMMAND", PressureUp);
// MessageDispatcher.AddListener("MINUS_COMMAND", PressureDown);
// MessageDispatcher.AddListener("U_COMMAND", U);
// MessageDispatcher.AddListener("J_COMMAND", J);
// MessageDispatcher.AddListener("H_COMMAND", H);
// MessageDispatcher.AddListener("K_COMMAND", K);
// MessageDispatcher.AddListener("ReplayFrame", ReplayFrameZDSP);
// MessageDispatcher.AddListener("ReplayEvent", ReplayEventZDSP);
//}
//public ZDSPData GetData()
//{
// return new ZDSPData()
// {
// name = gameObject.name,
// id = this.id,
// isWatering = IsWartering,
// scale = particle.GetScaleValue(),
// xRoate = Body.localEulerAngles.z,
// yRoate = Pao.localEulerAngles.x
// };
//}
//void SetData(ZDSPData data)
//{
// id = data.id;
// GetComponent<BaseGameObjInfo>().gameObjID = data.id;
// IsWartering = data.isWatering;
// particle.SetScaleValue(data.scale);
// Body.localEulerAngles = new Vector3(Body.localEulerAngles.x, Body.localEulerAngles.y, data.xRoate);
// Pao.localEulerAngles = new Vector3(data.yRoate, Pao.localEulerAngles.y, Pao.localEulerAngles.z);
// if (IsWartering)
// particle.gameObject.SetActive(true);
// else
// particle.gameObject.SetActive(false);
//}
//private void ReplayEventZDSP(IMessage obj)
//{
// var eventData = (EventData)obj.Data;
// if (eventData.eventType == RecordEventType.ZDSP)
// {
// ZDSPData data = JsonUtility.FromJson<ZDSPData>(eventData.json);
// if (data.name == gameObject.name)
// SetData(data);
// }
//}
//private void ReplayFrameZDSP(IMessage obj)
//{
// var objectData = (ObjectData)obj.Data;
// if (objectData.cloneObjType == CloneObjType.ZDSP)
// {
// ZDSPData data = JsonUtility.FromJson<ZDSPData>(objectData.json);
// if (data.name == gameObject.name)
// SetData(data);
// }
//}
//private void PressureDown(IMessage obj)
//{
// if (IsWartering && SelectedObjs.selectedObj == gameObject && ReplaySetting.PlayStatus != PlayStatus.isReplay)
// particle.Decrease(0.1f);
// RecordEvent.AddEventData(CloneObjType.None, RecordEventType.ZDSP, JsonUtility.ToJson(GetData()));
//}
//private void PressureUp(IMessage obj)
//{
// if (IsWartering && SelectedObjs.selectedObj == gameObject && ReplaySetting.PlayStatus != PlayStatus.isReplay)
// particle.Increase(0.1f);
// RecordEvent.AddEventData(CloneObjType.None, RecordEventType.ZDSP, JsonUtility.ToJson(GetData()));
//}
//private void K(IMessage obj)
//{
// if (SelectedObjs.selectedObj == gameObject && ReplaySetting.PlayStatus != PlayStatus.isReplay)
// {
// var gameObjID = (long)obj.Sender;
// if (GetComponent<BaseGameObjInfo>().gameObjID == gameObjID)
// {
// var speed = ((WeightCmdArgs)obj.Data).Weight;
// speed = speed * 2;
// float x = Body.localEulerAngles.x;
// float y = Body.localEulerAngles.y;
// float z = Body.localEulerAngles.z;
// z = CheckValue(z);
// z += speed;
// if (z >= 360)
// {
// z -= 360;
// }
// if (z <= -360)
// {
// z += 360;
// }
// Body.localEulerAngles = new Vector3(x, y, z);
// RecordEvent.AddEventData(CloneObjType.None, RecordEventType.ZDSP, JsonUtility.ToJson(GetData()));
// }
// }
//}
//private void H(IMessage obj)
//{
// if (SelectedObjs.selectedObj == gameObject && ReplaySetting.PlayStatus != PlayStatus.isReplay)
// {
// var gameObjID = (long)obj.Sender;
// if (GetComponent<BaseGameObjInfo>().gameObjID == gameObjID)
// {
// var speed = ((WeightCmdArgs)obj.Data).Weight;
// speed = speed * 2;
// float x = Body.localEulerAngles.x;
// float y = Body.localEulerAngles.y;
// float z = Body.localEulerAngles.z;
// z = CheckValue(z);
// z -= speed;
// if (z >= 360)
// {
// z -= 360;
// }
// if (z <= -360)
// {
// z += 360;
// }
// Body.localEulerAngles = new Vector3(x, y, z);
// RecordEvent.AddEventData(CloneObjType.None, RecordEventType.ZDSP, JsonUtility.ToJson(GetData()));
// }
// }
//}
//private void J(IMessage obj)
//{
// if (SelectedObjs.selectedObj == gameObject && ReplaySetting.PlayStatus != PlayStatus.isReplay)
// {
// var gameObjID = (long)obj.Sender;
// if (GetComponent<BaseGameObjInfo>().gameObjID == gameObjID)
// {
// var speed = ((WeightCmdArgs)obj.Data).Weight;
// speed = speed * 2;
// float x = Pao.localEulerAngles.x;
// float y = Pao.localEulerAngles.y;
// float z = Pao.localEulerAngles.z;
// x = CheckValue(x);
// x -= speed;
// x = Mathf.Clamp(x, 15, 90);
// Pao.localEulerAngles = new Vector3(x, y, z);
// RecordEvent.AddEventData(CloneObjType.None, RecordEventType.ZDSP, JsonUtility.ToJson(GetData()));
// }
// }
//}
//private void U(IMessage obj)
//{
// if (SelectedObjs.selectedObj == gameObject && ReplaySetting.PlayStatus != PlayStatus.isReplay)
// {
// var gameObjID = (long)obj.Sender;
// if (GetComponent<BaseGameObjInfo>().gameObjID == gameObjID)
// {
// var speed = ((WeightCmdArgs)obj.Data).Weight;
// speed = speed * 2;
// float x = Pao.localEulerAngles.x;
// float y = Pao.localEulerAngles.y;
// float z = Pao.localEulerAngles.z;
// x = CheckValue(x);
// x += speed;
// x = Mathf.Clamp(x, 15, 90);
// Pao.localEulerAngles = new Vector3(x, y, z);
// RecordEvent.AddEventData(CloneObjType.None, RecordEventType.ZDSP, JsonUtility.ToJson(GetData()));
// }
// }
//}
//private void OnDestroy()
//{
// MessageDispatcher.RemoveListener("EQUALS_COMMAND", PressureUp);
// MessageDispatcher.RemoveListener("MINUS_COMMAND", PressureDown);
// MessageDispatcher.RemoveListener("U_COMMAND", U);
// MessageDispatcher.RemoveListener("J_COMMAND", J);
// MessageDispatcher.RemoveListener("H_COMMAND", H);
// MessageDispatcher.RemoveListener("K_COMMAND", K);
// MessageDispatcher.RemoveListener("ReplayFrame", ReplayFrameZDSP);
// MessageDispatcher.RemoveListener("ReplayEvent", ReplayEventZDSP);
// EntitiesManager.Instance.RemoveEntity(id, gameObject);
//}
//public override void ClickFunc()
//{
// base.ClickFunc();
// if (!IsWartering)
// ResourceLoadWindow.Instance.LoadTipWindow("开启喷水?", () =>
// {
// IsWartering = true;
// particle.gameObject.SetActive(true);
// RecordEvent.AddEventData(CloneObjType.None, RecordEventType.ZDSP, JsonUtility.ToJson(GetData()));
// }, null);
// else
// ResourceLoadWindow.Instance.LoadTipWindow("关闭喷水?", () =>
// {
// IsWartering = false;
// particle.gameObject.SetActive(false);
// RecordEvent.AddEventData(CloneObjType.None, RecordEventType.ZDSP, JsonUtility.ToJson(GetData()));
// }, null);
//}
///// <summary>
///// 换算原始角度值为显式值
///// </summary>
///// <param name="x">获取的原始角度值</param>
///// <returns></returns>
//protected float CheckValue(float x)
//{
// if (x >= 180 && x <= 360)
// {
// x = x - 360;
// }
// return x;
// //举例:假如获取到的localEulerAngles.x = 300,则在显示面板其显示的值为-60=300-360,用此显式值计算
//}
}