Beispiel #1
0
 protected override void OnNetvrkWriteSyncStream(netvrkStream stream)
 {
     stream.Write(player.position);
     stream.Write(player.rotation.eulerAngles.y);
     stream.Write(head.position);
     stream.Write(head.rotation);
     stream.Write(leftHand.position);
     stream.Write(leftHand.rotation);
     stream.Write(rightHand.position);
     stream.Write(rightHand.rotation);
 }
Beispiel #2
0
 protected override void OnNetvrkReadSyncStream(netvrkStream stream)
 {
     playerNewPos    = (Vector3)stream.Read(typeof(Vector3));
     playerNewRot    = Quaternion.Euler(0, (float)stream.Read(typeof(float)), 0);
     headNewPos      = (Vector3)stream.Read(typeof(Vector3));
     headNewRot      = (Quaternion)stream.Read(typeof(Quaternion));
     leftHandNewPos  = (Vector3)stream.Read(typeof(Vector3));
     leftHandNewRot  = (Quaternion)stream.Read(typeof(Quaternion));
     rightHandNewPos = (Vector3)stream.Read(typeof(Vector3));
     rightHandNewRot = (Quaternion)stream.Read(typeof(Quaternion));
 }
Beispiel #3
0
        private void UnpackSync(byte[] buffer)
        {
            ushort objId = BitConverter.ToUInt16(buffer, 1);

            byte[] tmpBuffer = new byte[buffer.Length - 3];
            Buffer.BlockCopy(buffer, 3, tmpBuffer, 0, tmpBuffer.Length);

            netvrkStream stream = new netvrkStream(tmpBuffer);

            object[] objs = { stream };
            objList[objId].syncMethod.Invoke(objList[objId].syncScript, objs);
        }
Beispiel #4
0
 private IEnumerator SyncLoop()
 {
     while (true)
     {
         if (netView.isMine)
         {
             netvrkStream stream = netView.GetStream();
             OnNetvrkWriteSyncStream(stream);
             netView.WriteSyncStream(stream, sendMethod);
         }
         yield return(new WaitForSeconds(1 / syncPerSec));
     }
 }
Beispiel #5
0
 public static void WriteSyncStream(netvrkStream stream, netvrkSendMethod sendMethod)
 {
     byte[] buffer = stream.GetStreamData();
     byte[] bytes2 = new byte[buffer.Length + 3];
     byte[] objId  = BitConverter.GetBytes(stream.ObjId);
     bytes2[0] = (byte)eventCode.Sync;
     bytes2[1] = objId[0];
     bytes2[2] = objId[1];
     Buffer.BlockCopy(buffer, 0, bytes2, 3, buffer.Length);
     for (int i = 0; i < playerList.Count; i++)
     {
         SteamNetworking.SendP2PPacket(playerList[i].SteamId, bytes2, (uint)bytes2.Length, netvrkToP2pSend(sendMethod), 0);
     }
 }
Beispiel #6
0
 protected override void OnNetvrkReadSyncStream(netvrkStream stream)
 {
     newPos = (Vector3)stream.Read(typeof(Vector3));
     newRot = (Quaternion)stream.Read(typeof(Quaternion));
 }
Beispiel #7
0
 protected override void OnNetvrkWriteSyncStream(netvrkStream stream)
 {
     stream.Write(transform.position);
     stream.Write(transform.rotation);
 }
Beispiel #8
0
        public static netvrkStream GetStream(ushort objId)
        {
            netvrkStream stream = new netvrkStream(objId);

            return(stream);
        }
Beispiel #9
0
 public void WriteSyncStream(netvrkStream stream, netvrkSendMethod sendMethod)
 {
     netvrkManager.WriteSyncStream(stream, sendMethod);
 }
Beispiel #10
0
 protected abstract void OnNetvrkReadSyncStream(netvrkStream stream);
Beispiel #11
0
 protected abstract void OnNetvrkWriteSyncStream(netvrkStream stream);