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.
111 lines
3.7 KiB
111 lines
3.7 KiB
using AX.MessageSystem; |
|
using System; |
|
using System.Collections; |
|
using System.Collections.Generic; |
|
using UnityEngine; |
|
|
|
public class FCGSPControl : ObjDoubleClick |
|
{ |
|
public bool IsWartering; |
|
public Transform particle; |
|
private long id; |
|
private void Awake() |
|
{ |
|
int num = int.Parse(name.Substring(4,name.Length-4)); |
|
|
|
////if (gameObject.name.Split('_').Length > 0) |
|
//{ |
|
id = 1990199019901990 + num;//(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); |
|
} |
|
// Start is called before the first frame update |
|
void Start() |
|
{ |
|
particle = transform.GetComponentInChildren<ParticleControlOfType>(true).transform; |
|
MessageDispatcher.AddListener("ReplayFrame", ReplayFrameZDSP); |
|
MessageDispatcher.AddListener("ReplayEvent", ReplayEventZDSP); |
|
Debug.Log(particle.name); |
|
} |
|
|
|
private void OnDestroy() |
|
{ |
|
MessageDispatcher.RemoveListener("ReplayFrame", ReplayFrameZDSP); |
|
MessageDispatcher.RemoveListener("ReplayEvent", ReplayEventZDSP); |
|
} |
|
|
|
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); |
|
} |
|
} |
|
void SetData(ZDSPData data) |
|
{ |
|
id = data.id; |
|
GetComponent<BaseGameObjInfo>().gameObjID = data.id; |
|
IsWartering = data.isWatering; |
|
particle.GetComponent<ParticleControlOfType>().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); |
|
} |
|
// Update is called once per frame |
|
void Update() |
|
{ |
|
|
|
} |
|
public override void ClickFunc() |
|
{ |
|
base.ClickFunc(); |
|
Debug.Log(111); |
|
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); |
|
} |
|
public ZDSPData GetData() |
|
{ |
|
return new ZDSPData() |
|
{ |
|
name = gameObject.name, |
|
id = this.id, |
|
isWatering = IsWartering, |
|
scale = particle.GetComponent<ParticleControlOfType>().GetScaleValue(), |
|
//xRoate = Body.localEulerAngles.z, |
|
// yRoate = Pao.localEulerAngles.x |
|
}; |
|
} |
|
}
|
|
|