using AX.MessageSystem; using System; using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.EventSystems; public class BlizzardCannonControl : BaseTransformChange { public GameObject part1; public GameObject water; public GameObject tai; public ParticleControlOfType waterControl; protected override void Awake() { base.Awake(); part1 = TransformHelper.FindChild(transform, "paokou").gameObject; water = TransformHelper.FindChild(transform, "Hose").gameObject; tai = TransformHelper.FindChild(transform, "tai").gameObject; waterControl = TransformHelper.FindChild(transform, "WaterStraight").GetComponentInChildren(); waterControl.gameObject.SetActive(false); } protected override void D(IMessage obj) { var gameObjID = (long)obj.Sender; if (gameObjID == GetComponent().GameObjID) { transform.Rotate(0, Time.deltaTime * 40, 0, Space.Self); AddRecordADEvent(); } } protected override void A(IMessage obj) { var gameObjID = (long)obj.Sender; if (gameObjID == GetComponent().GameObjID) { transform.Rotate(0, -Time.deltaTime * 40, 0, Space.Self); AddRecordADEvent(); } } protected override void J(IMessage obj) { var gameObjID = (long)obj.Sender; if (gameObjID == GetComponent().GameObjID) { if ((part1.transform.localEulerAngles.x < 20 && part1.transform.localEulerAngles.x >= 0) || (part1.transform.localEulerAngles.x <= 360 && part1.transform.localEulerAngles.x >180)) { part1.transform.Rotate(-Time.deltaTime * 40, 0, 0, Space.Self); AddRecordUJEvent(); } } } protected override void U(IMessage obj) { var gameObjID = (long)obj.Sender; if (gameObjID == GetComponent().GameObjID) { if ((part1.transform.localEulerAngles.x > 285 && part1.transform.localEulerAngles.x <= 360) || (part1.transform.localEulerAngles.x >= 0 && part1.transform.localEulerAngles.x < 180)) { part1.transform.Rotate(Time.deltaTime * 40, 0, 0, Space.Self); AddRecordUJEvent(); } } } protected override void PressureDown(IMessage obj) { var gameObjID = (long)obj.Sender; if (gameObjID == GetComponent().GameObjID) { waterControl.Decrease(1f); AddRecordEvent(RecordEventType.WaterSprayMinus); } } protected override void PressureUp(IMessage obj) { var gameObjID = (long)obj.Sender; if (gameObjID == GetComponent().GameObjID) { waterControl.Increase(1f); AddRecordEvent(RecordEventType.WaterSprayPlus); } } public float GetWaterScale() { return waterControl.GetScaleValue(); } public void SetWaterScale(float value) { waterControl.SetScaleValue(value); } private void AddRecordUJEvent() { if (ReplaySetting.PlayStatus == PlayStatus.isEditor && RecordManager.Instance.recordStatus == RecordStatus.normal) { var eventData = new EventData(); eventData.time = RecordManager.Instance.RecordTimer; eventData.cloneObjType = GetComponent().gameObjType; eventData.eventType = RecordEventType.WaterSprayU; RecordSprayerRotation data = new RecordSprayerRotation(); data.gameObjID = GetComponent().gameObjID; data.rotation = part1.transform.localEulerAngles; eventData.json = JsonUtility.ToJson(data); RecordManager.Instance.jsonData.eventDataList.Add(eventData); } } private void AddRecordADEvent() { if (ReplaySetting.PlayStatus == PlayStatus.isEditor && RecordManager.Instance.recordStatus == RecordStatus.normal) { var eventData = new EventData(); eventData.time = RecordManager.Instance.RecordTimer; eventData.cloneObjType = GetComponent().gameObjType; eventData.eventType = RecordEventType.WaterSprayA; RecordSprayerRotation data = new RecordSprayerRotation(); data.gameObjID = GetComponent().gameObjID; data.rotation = transform.localEulerAngles; eventData.json = JsonUtility.ToJson(data); RecordManager.Instance.jsonData.eventDataList.Add(eventData); } } protected override void ReplayEvent(IMessage obj) { var eventData = (EventData)obj.Data; if (eventData.eventType == RecordEventType.WaterSprayU) { RecordSprayerRotation data = JsonUtility.FromJson(eventData.json); if (data.gameObjID == GetComponent().gameObjID) { part1.transform.localEulerAngles = data.rotation; } } else if (eventData.eventType == RecordEventType.WaterSprayA) { RecordSprayerRotation data = JsonUtility.FromJson(eventData.json); if (data.gameObjID == GetComponent().gameObjID) { transform.localEulerAngles = data.rotation; } } else if (eventData.eventType == RecordEventType.WaterSprayPlus) { if (eventData.json == gameObject.name) { waterControl.Increase(1f); } } else if (eventData.eventType == RecordEventType.WaterSprayMinus) { if (eventData.json == gameObject.name) { waterControl.Decrease(1f); } } } }