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.
122 lines
4.3 KiB
122 lines
4.3 KiB
using AX.MessageSystem; |
|
using System; |
|
using System.Collections; |
|
using System.Collections.Generic; |
|
using UnityEngine; |
|
|
|
public class FireRoate : MonoBehaviour |
|
{ |
|
public float rotateSpeed = 60; |
|
// Use this for initialization |
|
protected virtual void Start() |
|
{ |
|
MessageDispatcher.AddListener("ReplayEvent", ReplayEventRoate); |
|
} |
|
protected virtual void AddRecordEventRoage(RecordEventType type) |
|
{ |
|
if (ReplaySetting.PlayStatus == PlayStatus.isEditor && RecordManager.Instance.recordStatus == RecordStatus.normal) |
|
{ |
|
var eventData = new EventData(); |
|
eventData.time = RecordManager.Instance.RecordTimer; |
|
eventData.cloneObjType = GetComponent<BaseGameObjInfo>().gameObjType; |
|
eventData.eventType = type; |
|
eventData.json = gameObject.name; |
|
|
|
RecordManager.Instance.jsonData.eventDataList.Add(eventData); |
|
} |
|
} |
|
protected virtual void ReplayEventRoate(IMessage obj) |
|
{ |
|
var eventData = (EventData)obj.Data; |
|
if (eventData.json == gameObject.name) |
|
{ |
|
if (eventData.eventType == RecordEventType.LeftRotate) |
|
{ |
|
transform.Rotate(0, 0, -Time.deltaTime * rotateSpeed, Space.World); |
|
} |
|
else if (eventData.eventType == RecordEventType.RightRotate) |
|
{ |
|
transform.Rotate(0, 0, Time.deltaTime * rotateSpeed, Space.World); |
|
} |
|
else if (eventData.eventType == RecordEventType.UpRotate) |
|
{ |
|
transform.Rotate(-Time.deltaTime * rotateSpeed, 0, 0, Space.World); |
|
} |
|
else if (eventData.eventType == RecordEventType.DownRotate) |
|
{ |
|
transform.Rotate(Time.deltaTime * rotateSpeed, 0, 0, Space.World); |
|
} |
|
} |
|
} |
|
|
|
// Update is called once per frame |
|
void Update() |
|
{ |
|
|
|
} |
|
|
|
void OnEnable() |
|
{ |
|
MessageDispatcher.AddListener("LEFT_ROTATE_COMMAND", LeftRotate); |
|
MessageDispatcher.AddListener("RIGHT_ROTATE_COMMAND", RightRotate); |
|
MessageDispatcher.AddListener("UP_ROTATE_COMMAND", UpRotate); |
|
MessageDispatcher.AddListener("DOWN_ROTATE_COMMAND", DownRotate); |
|
} |
|
|
|
void OnDisable() |
|
{ |
|
MessageDispatcher.RemoveListener("LEFT_ROTATE_COMMAND", LeftRotate); |
|
MessageDispatcher.RemoveListener("RIGHT_ROTATE_COMMAND", RightRotate); |
|
MessageDispatcher.RemoveListener("UP_ROTATE_COMMAND", UpRotate); |
|
MessageDispatcher.RemoveListener("DOWN_ROTATE_COMMAND", DownRotate); |
|
} |
|
|
|
void OnDestroy() |
|
{ |
|
MessageDispatcher.RemoveListener("LEFT_ROTATE_COMMAND", LeftRotate); |
|
MessageDispatcher.RemoveListener("RIGHT_ROTATE_COMMAND", RightRotate); |
|
MessageDispatcher.RemoveListener("UP_ROTATE_COMMAND", UpRotate); |
|
MessageDispatcher.RemoveListener("DOWN_ROTATE_COMMAND", DownRotate); |
|
MessageDispatcher.RemoveListener("ReplayEvent", ReplayEventRoate); |
|
} |
|
|
|
protected virtual void LeftRotate(IMessage obj) |
|
{ |
|
if (SelectedObjs.selectedObj == gameObject) |
|
{ |
|
transform.Rotate(0, 0, -Time.deltaTime * rotateSpeed, Space.World); |
|
//transform.Rotate(-Time.deltaTime * rotateSpeed, 0, 0, Space.World); |
|
AddRecordEventRoage(RecordEventType.LeftRotate); |
|
} |
|
} |
|
|
|
protected virtual void RightRotate(IMessage obj) |
|
{ |
|
if (SelectedObjs.selectedObj == gameObject) |
|
{ |
|
transform.Rotate(0, 0, Time.deltaTime * rotateSpeed, Space.World); |
|
//transform.Rotate(Time.deltaTime * rotateSpeed, 0, 0, Space.World); |
|
AddRecordEventRoage(RecordEventType.RightRotate); |
|
} |
|
} |
|
|
|
protected virtual void UpRotate(IMessage obj) |
|
{ |
|
if (SelectedObjs.selectedObj == gameObject) |
|
{ |
|
transform.Rotate(-Time.deltaTime * rotateSpeed, 0, 0, Space.World); |
|
//transform.Rotate(0, 0, -Time.deltaTime * rotateSpeed, Space.World); |
|
AddRecordEventRoage(RecordEventType.UpRotate); |
|
} |
|
} |
|
|
|
protected virtual void DownRotate(IMessage obj) |
|
{ |
|
if (SelectedObjs.selectedObj == gameObject) |
|
{ |
|
transform.Rotate(Time.deltaTime * rotateSpeed, 0, 0, Space.World); |
|
//transform.Rotate(0, 0, Time.deltaTime * rotateSpeed, Space.World); |
|
AddRecordEventRoage(RecordEventType.DownRotate); |
|
} |
|
} |
|
}
|
|
|