Exemplo n.º 1
0
        public void OnData(int connectionId, int channelId, int receiveSize)
        {
            GameStatics.OnlineSession.NetBuffer.SeekZero();
            NetworkMessageID msgId = (NetworkMessageID)GameStatics.OnlineSession.NetBuffer.ReadInt();

            switch (msgId)
            {
            case (NetworkMessageID.PlayerRegistration):
                PlayerRegistrationMsg prm = new PlayerRegistrationMsg();
                prm.Deserialize(GameStatics.OnlineSession.NetBuffer);
                HandlePlayerRegistrationMsg(ref prm, connectionId);
                break;

            case (NetworkMessageID.PlayerAdd):
                PlayerAddMsg pam = new PlayerAddMsg();
                pam.Deserialize(GameStatics.OnlineSession.NetBuffer);
                HandlePlayerAddMsg(ref pam, connectionId);
                break;

            case (NetworkMessageID.SceneLoading):
                SceneLoadingMsg lsm = new SceneLoadingMsg();
                lsm.Deserialize(GameStatics.OnlineSession.NetBuffer);
                HandleLoadSceneMsg(ref lsm);
                break;
            }
        }
Exemplo n.º 2
0
 private void HandlePlayerRegistrationMsg(ref PlayerRegistrationMsg msg, int connectionId)
 {
     if (GameStatics.OnlineSession.Mode == OnlineSessionMode.Server)
     {
         if (AddPlayer(_playerIdCounter, false, connectionId, msg.PlayerName))
         {
             _playerIdCounter++;
         }
     }
 }
Exemplo n.º 3
0
 public void OnConnect(int connectionId)
 {
     if (GameStatics.OnlineSession.Mode == OnlineSessionMode.Client)
     {
         // Send msg to register name with server
         PlayerRegistrationMsg msg = new PlayerRegistrationMsg();
         msg.PlayerName = NameField.text;
         msg.Serialize(GameStatics.OnlineSession.NetBuffer);
         GameStatics.OnlineSession.SendBufferToServer(OnlineSession.ReliableSequencedChannelId);
     }
 }