public static void UnserializePlayerState(CNetworkPlayer _cNetworkPlayer, CNetworkStream _cStream) { // Retrieve player actors head CPlayerHead cMyActorHead = CGamePlayers.GetPlayerActor(_cNetworkPlayer.PlayerId).GetComponent <CPlayerHead>(); // Write my head's x-rotation float fRotationX = _cStream.ReadFloat(); cMyActorHead.m_fHeadEulerX.Set(fRotationX); }
public static void UnserializePlayerState(CNetworkPlayer _cNetworkPlayer, CNetworkStream _cStream) { GameObject cPlayerActor = CGamePlayers.GetPlayerActor(_cNetworkPlayer.PlayerId); if (cPlayerActor != null) { //while (_cStream.HasUnreadData) { // Retrieve player actor motor CPlayerGroundMotor cPlayerActorMotor = cPlayerActor.GetComponent <CPlayerGroundMotor>(); ENetworkAction eNetworkAction = (ENetworkAction)_cStream.ReadByte(); switch (eNetworkAction) { case ENetworkAction.UpdateStates: { cPlayerActorMotor.m_uiMovementStates = _cStream.ReadByte(); if (cPlayerActor != CGamePlayers.SelfActor) { cPlayerActor.transform.eulerAngles = new Vector3(0.0f, _cStream.ReadFloat(), 0.0f); } else { _cStream.ReadFloat(); } cPlayerActorMotor.m_bStates.Set((byte)cPlayerActorMotor.m_uiMovementStates); } break; default: Debug.LogError(string.Format("Unknown network action ({0})", (byte)eNetworkAction)); break; } } } }
public static void UnserializeInbound(CNetworkPlayer _cPlayer, CNetworkStream _cStream) { TPlayerStates tPlayerStates = s_cInstance.m_mPlayerStates[_cPlayer.PlayerId]; tPlayerStates.ulPreviousInput = tPlayerStates.ulInput; tPlayerStates.ulInput = _cStream.ReadULong(); tPlayerStates.fPreviousMouseX = tPlayerStates.fMouseX; tPlayerStates.fPreviousMouseY = tPlayerStates.fMouseY; tPlayerStates.fMouseX = _cStream.ReadFloat(); tPlayerStates.fMouseY = _cStream.ReadFloat(); if (tPlayerStates.fPreviousMouseX != tPlayerStates.fMouseX) { s_cInstance.InvokeClientClientAxisEvent(EAxis.MouseX, _cPlayer.PlayerId, tPlayerStates.fMouseX); } if (tPlayerStates.fPreviousMouseY != tPlayerStates.fMouseY) { s_cInstance.InvokeClientClientAxisEvent(EAxis.MouseY, _cPlayer.PlayerId, tPlayerStates.fMouseY); } s_cInstance.ProcessClientEvents(_cPlayer.PlayerId, tPlayerStates); }
static public void UnserializeSliderEvents(CNetworkPlayer _cNetworkPlayer, CNetworkStream _cStream) { while (_cStream.HasUnreadData) { // Get the DUISlider and its network view CDUISlider duiSlider = CNetwork.Factory.FindObject(_cStream.ReadNetworkViewId()).GetComponent <CDUISlider>(); // Get the interaction notification ESliderNotificationType notification = (ESliderNotificationType)_cStream.ReadByte(); // Based on the notification type, update the clients of the event switch (notification) { case ESliderNotificationType.OnValueChange: float value = _cStream.ReadFloat(); duiSlider.SetSliderValue(value); break; default: break; } } }
public static void UnserializeIKTarget(CNetworkPlayer _cNetworkPlayer, CNetworkStream _cStream) { GameObject cPlayerActor = CGamePlayers.GetPlayerActor(_cNetworkPlayer.PlayerId); if (cPlayerActor != null) { CPlayerIKController cPlayerIKController = cPlayerActor.GetComponent <CPlayerIKController>(); ENetworkAction eNetworkAction = (ENetworkAction)_cStream.ReadByte(); switch (eNetworkAction) { case ENetworkAction.SetRightTransform: { Vector3 pos = new Vector3(); Vector3 rot = new Vector3(); pos.x = _cStream.ReadFloat(); pos.y = _cStream.ReadFloat(); pos.z = _cStream.ReadFloat(); cPlayerIKController.m_RightHandTarget.position = pos; rot.x = _cStream.ReadFloat(); rot.y = _cStream.ReadFloat(); rot.z = _cStream.ReadFloat(); cPlayerIKController.m_RightHandTarget.rotation = Quaternion.Euler(rot); cPlayerIKController.m_RightHandNetworkedPos.Set(cPlayerIKController.m_RightHandTarget.position); cPlayerIKController.m_RightHandNetworkedRot.Set(cPlayerIKController.m_RightHandTarget.rotation.eulerAngles); } break; case ENetworkAction.SetLeftTransform: { Vector3 pos = new Vector3(); Vector3 rot = new Vector3(); pos.x = _cStream.ReadFloat(); pos.y = _cStream.ReadFloat(); pos.z = _cStream.ReadFloat(); cPlayerIKController.m_LeftHandTarget.position = pos; rot.x = _cStream.ReadFloat(); rot.y = _cStream.ReadFloat(); rot.z = _cStream.ReadFloat(); cPlayerIKController.m_LeftHandTarget.rotation = Quaternion.Euler(rot); cPlayerIKController.m_RightHandNetworkedPos.Set(cPlayerIKController.m_LeftHandTarget.position); cPlayerIKController.m_RightHandNetworkedRot.Set(cPlayerIKController.m_LeftHandTarget.rotation.eulerAngles); } break; default: Debug.LogError(string.Format("Unknown network action ({0})", (byte)eNetworkAction)); break; } } }
public static void UnserializePlayerState(CNetworkPlayer _cNetworkPlayer, CNetworkStream _cStream) { GameObject cPlayerActor = CGamePlayers.GetPlayerActor(_cNetworkPlayer.PlayerId); if (cPlayerActor != null) { //while (_cStream.HasUnreadData) { // Retrieve player actor motor CPlayerGroundMotor cPlayerActorMotor = cPlayerActor.GetComponent<CPlayerGroundMotor>(); ENetworkAction eNetworkAction = (ENetworkAction)_cStream.ReadByte(); switch (eNetworkAction) { case ENetworkAction.UpdateStates: { cPlayerActorMotor.m_uiMovementStates = _cStream.ReadByte(); if (cPlayerActor != CGamePlayers.SelfActor) { cPlayerActor.transform.eulerAngles = new Vector3(0.0f, _cStream.ReadFloat(), 0.0f); } else { _cStream.ReadFloat(); } cPlayerActorMotor.m_bStates.Set((byte)cPlayerActorMotor.m_uiMovementStates); } break; default: Debug.LogError(string.Format("Unknown network action ({0})", (byte)eNetworkAction)); break; } } } }
public static void UnserializePlayerState(CNetworkPlayer _cNetworkPlayer, CNetworkStream _cStream) { // Retrieve player actors head CPlayerHead cMyActorHead = CGamePlayers.GetPlayerActor(_cNetworkPlayer.PlayerId).GetComponent<CPlayerHead>(); // Write my head's x-rotation float fRotationX = _cStream.ReadFloat(); cMyActorHead.m_fHeadEulerX.Set(fRotationX); }
static public void UnserializeSliderEvents(CNetworkPlayer _cNetworkPlayer, CNetworkStream _cStream) { while(_cStream.HasUnreadData) { // Get the DUISlider and its network view CDUISlider duiSlider = CNetwork.Factory.FindObject(_cStream.ReadNetworkViewId()).GetComponent<CDUISlider>(); // Get the interaction notification ESliderNotificationType notification = (ESliderNotificationType)_cStream.ReadByte(); // Based on the notification type, update the clients of the event switch(notification) { case ESliderNotificationType.OnValueChange: float value = _cStream.ReadFloat(); duiSlider.SetSliderValue(value); break; default:break; } } }
static public void UnserializeElementEvents(CNetworkPlayer _cNetworkPlayer, CNetworkStream _cStream) { while (_cStream.HasUnreadData) { // Get the DUIElement and its network view CDUIElement duiElement = CNetwork.Factory.FindObject(_cStream.ReadNetworkViewId()).GetComponent <CDUIElement>(); // Get the interaction notification EElementNotificationType notification = (EElementNotificationType)_cStream.ReadByte(); // Based on the notification type, update the clients of the event switch (notification) { case EElementNotificationType.OnClick: int click = _cStream.ReadInt(); NotifyOnEvent(_cNetworkPlayer, duiElement, notification, new object[] { click }); break; case EElementNotificationType.OnDoubleClick: int dClick = _cStream.ReadInt(); NotifyOnEvent(_cNetworkPlayer, duiElement, notification, new object[] { dClick }); break; case EElementNotificationType.OnPress: bool isPressed = _cStream.ReadByte() == 1 ? true : false; NotifyOnEvent(_cNetworkPlayer, duiElement, notification, new object[] { isPressed }); break; case EElementNotificationType.OnSelect: bool isSelected = _cStream.ReadByte() == 1 ? true : false; NotifyOnEvent(_cNetworkPlayer, duiElement, notification, new object[] { isSelected }); break; case EElementNotificationType.OnHover: bool isHovered = _cStream.ReadByte() == 1 ? true : false; NotifyOnEvent(_cNetworkPlayer, duiElement, notification, new object[] { isHovered }); break; case EElementNotificationType.OnDrag: float deltaX = _cStream.ReadFloat(); float deltaY = _cStream.ReadFloat(); NotifyOnEvent(_cNetworkPlayer, duiElement, notification, new object[] { deltaX, deltaY }); break; case EElementNotificationType.OnDragStart: NotifyOnEvent(_cNetworkPlayer, duiElement, notification, null); break; case EElementNotificationType.OnDragEnd: NotifyOnEvent(_cNetworkPlayer, duiElement, notification, null); break; case EElementNotificationType.OnScroll: float delta = _cStream.ReadFloat(); NotifyOnEvent(_cNetworkPlayer, duiElement, notification, new object[] { delta }); break; default: break; } } }
public static void UnserializeIKTarget(CNetworkPlayer _cNetworkPlayer, CNetworkStream _cStream) { GameObject cPlayerActor = CGamePlayers.GetPlayerActor(_cNetworkPlayer.PlayerId); if (cPlayerActor != null) { CPlayerIKController cPlayerIKController = cPlayerActor.GetComponent<CPlayerIKController>(); ENetworkAction eNetworkAction = (ENetworkAction)_cStream.ReadByte(); switch (eNetworkAction) { case ENetworkAction.SetRightTransform: { Vector3 pos = new Vector3(); Vector3 rot = new Vector3(); pos.x = _cStream.ReadFloat(); pos.y = _cStream.ReadFloat(); pos.z = _cStream.ReadFloat(); cPlayerIKController.m_RightHandTarget.position = pos; rot.x = _cStream.ReadFloat(); rot.y = _cStream.ReadFloat(); rot.z = _cStream.ReadFloat(); cPlayerIKController.m_RightHandTarget.rotation = Quaternion.Euler(rot); cPlayerIKController.m_RightHandNetworkedPos.Set(cPlayerIKController.m_RightHandTarget.position); cPlayerIKController.m_RightHandNetworkedRot.Set(cPlayerIKController.m_RightHandTarget.rotation.eulerAngles); } break; case ENetworkAction.SetLeftTransform: { Vector3 pos = new Vector3(); Vector3 rot = new Vector3(); pos.x = _cStream.ReadFloat(); pos.y = _cStream.ReadFloat(); pos.z = _cStream.ReadFloat(); cPlayerIKController.m_LeftHandTarget.position = pos; rot.x = _cStream.ReadFloat(); rot.y = _cStream.ReadFloat(); rot.z = _cStream.ReadFloat(); cPlayerIKController.m_LeftHandTarget.rotation = Quaternion.Euler(rot); cPlayerIKController.m_RightHandNetworkedPos.Set(cPlayerIKController.m_LeftHandTarget.position); cPlayerIKController.m_RightHandNetworkedRot.Set(cPlayerIKController.m_LeftHandTarget.rotation.eulerAngles); } break; default: Debug.LogError(string.Format("Unknown network action ({0})", (byte)eNetworkAction)); break; } } }