void UpdateNetworkPlayer(byte[] data, int id) { foreach (NetworkPlayerComponent p in players) { if (p.id == id) { p.ReceiveData((NetworkPlayerData)SerializationToolkit.ByteArrayToObject(data)); return; } } }
void ReceiveEndInteraction(byte[] data, int objectId) { if (objectId < 0) { Debug.LogError("invalid object ID"); } SerializableRigidbody rb = (SerializableRigidbody)SerializationToolkit.ByteArrayToObject(data); nvrPool[objectId].EndInteraction(nvrPool[objectId].AttachedHand); nvrPool[objectId].Rigidbody.velocity = rb.velocity.Deserialize(); nvrPool[objectId].Rigidbody.angularVelocity = rb.angularVelocity.Deserialize(); }
void ReceiveBeginInteraction(byte[] data, bool rightHand, int objectId, int playerId) { if (objectId < 0) { Debug.LogError("invalid object ID"); } SerializableTransform t = (SerializableTransform)SerializationToolkit.ByteArrayToObject(data); GameObject hand = NetworkPlayerManager.Instance.GetNetworkPlayerHand(playerId, rightHand); nvrPool[objectId].transform.position = hand.transform.position + t.position.Deserialize(); nvrPool[objectId].transform.rotation = t.rotation.Deserialize(); nvrPool[objectId].BeginInteraction(hand.GetComponent <NVRHand>()); }
public void ReceiveRegisterHit(byte[] data) { HitInfo info = (HitInfo)SerializationToolkit.ByteArrayToObject(data); globalHited = true; if (OnJoustHit != null) { OnJoustHit.Invoke(info); } Fade.Instance.StartFade(0.4f, 0.1f); StartCoroutine(UnFade()); Instantiate(blood, info.hitPoint.Deserialize(), Quaternion.identity); }
void FixedUpdate() { if (!PhotonNetwork.connected) { return; } NetworkPlayerData data = new NetworkPlayerData( new Vector3[] { NVRPlayer.Instance.Head.transform.position, NVRPlayer.Instance.RightHand.transform.position, NVRPlayer.Instance.LeftHand.transform.position }, new Quaternion[] { NVRPlayer.Instance.Head.transform.rotation, NVRPlayer.Instance.RightHand.transform.rotation, NVRPlayer.Instance.LeftHand.transform.rotation }); BinaryFormatter formatter = new BinaryFormatter(); byte[] serializedData = SerializationToolkit.ObjectToByteArray(data); photonView.RPC("UpdateNetworkPlayer", PhotonTargets.Others, serializedData, personalID); }
void FixedUpdate() { if (!PhotonNetwork.inRoom) { return; } NetworkPlayerData data = new NetworkPlayerData( new Vector3[] { NVRPlayer.Instance.transform.position, NVRPlayer.Instance.Head.transform.localPosition, NVRPlayer.Instance.RightHand.transform.localPosition, NVRPlayer.Instance.LeftHand.transform.localPosition, NVRPlayer.Instance.Torso.transform.localPosition }, new Quaternion[] { NVRPlayer.Instance.transform.rotation, NVRPlayer.Instance.Head.transform.localRotation, NVRPlayer.Instance.RightHand.transform.localRotation, NVRPlayer.Instance.LeftHand.transform.localRotation, NVRPlayer.Instance.Torso.transform.localRotation }); byte[] serializedData = SerializationToolkit.ObjectToByteArray(data); photonView.RPC("UpdateNetworkPlayer", PhotonTargets.Others, serializedData, playerID); }
public void callHit(HitInfo info) { if (localHited || !_active) { return; } localHited = true; globalHited = true; lastHit = (LimbType)info.limbHit; float multiplier = 1; switch (lastHit) { case LimbType.Head: multiplier = 3; break; case LimbType.Hand: multiplier = 1; break; case LimbType.Torso: multiplier = 2; break; } if (lastHit == LimbType.None) { return; } photonView.RPC("CalculateScore", PhotonTargets.All, NetworkPlayerManager.Instance.playerID, multiplier); photonView.RPC("ReceiveRegisterHit", PhotonTargets.Others, SerializationToolkit.ObjectToByteArray(info)); if (OnJoustHit != null) { OnJoustHit.Invoke(info); } Instantiate(blood, info.hitPoint.Deserialize(), Quaternion.identity); }
public void SendEndInterraction(NVRInteractable item) { SerializableRigidbody rb = new SerializableRigidbody(item.Rigidbody); photonView.RPC("ReceiveEndInteraction", PhotonTargets.Others, SerializationToolkit.ObjectToByteArray(rb), GetObjectID(item)); }
public void SendBeginInterraction(NVRInteractable item, NVRHand hand) { SerializableTransform t = new SerializableTransform(item.transform.position - hand.transform.position, item.transform.rotation); photonView.RPC("ReceiveBeginInteraction", PhotonTargets.Others, SerializationToolkit.ObjectToByteArray(t), hand.IsRight, GetObjectID(item), NetworkPlayerManager.Instance.personalID); }