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.
93 lines
3.0 KiB
93 lines
3.0 KiB
using System.Collections; |
|
using System.Collections.Generic; |
|
using UnityEngine; |
|
using AX.MessageSystem; |
|
using System; |
|
using AX.NetworkSystem; |
|
|
|
public class ObjRotate : MonoBehaviour { |
|
|
|
public float rotateSpeed = 60; |
|
// Use this for initialization |
|
void Start () { |
|
|
|
} |
|
|
|
// 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); |
|
} |
|
|
|
private void LeftRotate(IMessage obj) |
|
{ |
|
if (SelectedObjs.selectedObj == gameObject) |
|
{ |
|
transform.Rotate(0, -Time.deltaTime * rotateSpeed, 0, Space.World); |
|
|
|
//旋转同步 |
|
if (GameSettings.othersSettings.mode!=Mode.DisasterManagement) |
|
{ |
|
var arg = new ObjRotateSyncData(); |
|
arg.SendUserID = CurrentUserInfo.mySelf.Id; |
|
arg.gameObjID = gameObject.GetComponent<BaseGameObjInfo>().gameObjID; |
|
arg.rotate = new Vector3(0, -Time.deltaTime * rotateSpeed, 0); |
|
arg.space = Space.World; |
|
NetworkManager.Default.SendAsync("OBJ_ROTATE_SYNC", arg); |
|
} |
|
|
|
} |
|
} |
|
|
|
private void RightRotate(IMessage obj) |
|
{ |
|
if (SelectedObjs.selectedObj == gameObject) |
|
{ |
|
transform.Rotate(0, Time.deltaTime * rotateSpeed, 0, Space.World); |
|
//旋转同步 |
|
if (GameSettings.othersSettings.mode != Mode.DisasterManagement) |
|
{ |
|
var arg = new ObjRotateSyncData(); |
|
arg.SendUserID = CurrentUserInfo.mySelf.Id; |
|
arg.gameObjID = gameObject.GetComponent<BaseGameObjInfo>().gameObjID; |
|
arg.rotate = new Vector3(0, Time.deltaTime * rotateSpeed, 0); |
|
arg.space = Space.World; |
|
NetworkManager.Default.SendAsync("OBJ_ROTATE_SYNC", arg); |
|
} |
|
|
|
} |
|
} |
|
|
|
private void UpRotate(IMessage obj) |
|
{ |
|
throw new NotImplementedException(); |
|
} |
|
|
|
private void DownRotate(IMessage obj) |
|
{ |
|
throw new NotImplementedException(); |
|
} |
|
}
|
|
|