Esempio n. 1
0
        private void playerDataReceived(string msg)
        {
            PTK.ArenaObservable.PlayerData   playerData = new PTK.ArenaObservable.PlayerData();
            PTK.ArenaObservable.PlayerData[] objs       = playerData.FromJson <PTK.ArenaObservable.PlayerData>(msg);

            BMSByte bmsByte = new BMSByte();

            foreach (var data in objs)
            {
                bmsByte = bmsByte.Clone(System.Convert.FromBase64String(data.BMSData), 0);
                Binary frame = new Binary(Networker.Time.Timestep, false, bmsByte, Receivers.Target, 0, true);

                if (data.UID != ansuzClient.UID)
                {
                    Debug.Log("other playerDataReceived :" + data.BMSData);
                    switch (data.RequestID)
                    {
                    case (int)PTK.AnsuzRequestID.CreatePlayer:
                        NetworkObject.Factory.NetworkCreateObject(Networker, 3, (uint)data.UID, frame, CreateObjects);

                        /// and create current frame to new one
                        MainThreadManager.Run(() =>
                        {
                            if (OwnPlayer != null && OwnPlayer.networkObject != null)
                            {
                                OwnPlayer.networkObject.firstFrame = true;
                            }
                        });
                        break;

                    default:
                        Debug.Log("not definition request" + data.RequestID);
                        break;
                    }
                }
                frame = null;
            }
            bmsByte    = null;
            playerData = null;
        }