示例#1
0
 protected override void NetworkCallback(object message)
 {
     if (message.GetType().ToString().Equals("Network.NetworkMessage"))
     {
         Debug.Log("客户端接收");
         NetworkMessage nm = (NetworkMessage)message;
         if (nm.type == 13)
         {
             PlayerInfoMessage info = PlayerInfoMessage.GetMessage(nm.message);
             RoomSingle.AddPlayer(info);
             //Debug.Log("开始游戏");
             UIManager._Instance.CloseWindow(WindowName.WaitStartRoom);
             LoadSceneManager._Instance.LoadScene(SceneName.Mission1, StartGameCallBack);
             //NetworkManager._Instance.RemoveCallBack(13, GetNetworkMsgCallBack);
         }
         else if (nm.type == 10)
         {
             RoomPlayerInfoMessage info = RoomPlayerInfoMessage.GetMessage(nm.message);
             playerData.SetPlayerCanStart(info.playerIP, info.canStart);
             wait.UpdatePanel(playerData);
         }
         else if (nm.type == 15)
         {
             RoomPlayerInfoMessage info = RoomPlayerInfoMessage.GetMessage(nm.message);
             playerData.AddPlayerInfo(info.playerIP, info);
             wait.UpdatePanel(playerData);
         }
         else if (nm.type == 16)
         {
             RoomPlayerInfoMessage info = RoomPlayerInfoMessage.GetMessage(nm.message);
             playerData.RemovePlayerInfo(info.playerIP);
             RoomSingle.RemovePlayer(info.playerIP);
             wait.UpdatePanel(playerData);
         }
         else if (nm.type == 17)
         {
             PlayerInfoMessage info = PlayerInfoMessage.GetMessage(nm.message);
             RoomSingle.AddPlayer(info);
             playerData.SetPlayerCanStart(info.playerIP, true);
             wait.UpdatePanel(playerData);
         }
     }
 }
示例#2
0
        /// <summary>
        /// 更新玩家信息
        /// </summary>
        /// <param name="obj_arr"></param>
        void UpdateRoomPlayerMsgCallBack(params object[] obj_arr)
        {
            NetworkMessage    m    = (NetworkMessage)obj_arr[0];
            PlayerInfoMessage info = PlayerInfoMessage.GetMessage(m.message);

            playerData.SetPlayerCanStart(m.ip, true);
            NetworkManager._Instance.AddMessage(102, playerData);

            RoomSingle.AddPlayer(info);
            //向其他玩家发送玩家的装备情况
            foreach (var item in playerData.GetPlayersInfo().Keys)
            {
                SendPlayrMessageInfo(item, info);//只要接到玩家的进入游戏的信息,那么玩家就进入了准备状态
            }
            //向所有玩家发送玩家的状态更新
            //foreach (var item in playerData.GetPlayersInfo().Keys)
            //{
            //   SendUpdatePlayrInfo(item, new RoomPlayerInfoMessage("",true, m.ip));
            //}
        }