Exemplo n.º 1
0
        /// <summary>
        /// 退出房间的回调
        /// </summary>
        /// <param name="obj_arr"></param>
        void QuitRoomMsgCallBack(params object[] obj_arr)
        {
            NetworkMessage m = (NetworkMessage)obj_arr[0];

            playerData.RemovePlayerInfo(m.ip);
            NetworkManager._Instance.AddMessage(102, playerData);
            RoomSingle.RemovePlayer(m.ip);//装备情况删除
            //向所有玩家发送退出信息
            foreach (var item in playerData.GetPlayersInfo().Keys)
            {
                if (!item.Equals(NetworkTools.GetLocalIP()))
                {
                    SendRemovePlayrInfo(item, new RoomPlayerInfoMessage("", true, m.ip));
                }
            }
        }
Exemplo n.º 2
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);
         }
     }
 }