Example #1
0
 void OnDateEvent(GameMsg msg, int connection)
 {
     switch (msg.type)
     {
     case GameMsg.MsgType.JoinGameRsp:
     {
         JoinGameRsp rsp = msg.content as JoinGameRsp;
         if (rsp != null && rsp.success)
         {
             //加载场景
             UnityHelper.LoadSceneAsync(StringAssets.gamePlaySceneName, LoadingTask.SwitchGameScene);
         }
     }
     break;
     }
 }
Example #2
0
 void OnJoinGameReq(JoinGameReq req, Connection conn)
 {
     if (conn.state == ConnState.Connected)
     {
         JoinGameRsp rsp = new JoinGameRsp();
         if (inGameClientPlayerCount >= 4)
         {
             rsp.success = false;
         }
         else
         {
             if (req.name != null)
             {  //名字有效
                 rsp.success     = true;
                 conn.state      = ConnState.WaitForReady;
                 conn.playerName = req.name;
                 inGameClientPlayerCount++;
             }
         }
         Server.SendMessage(new GameMsg(GameMsg.MsgType.JoinGameRsp, rsp), conn.connId, UnityEngine.Networking.QosType.ReliableSequenced);
     }
 }