/// <summary>
        ///
        /// </summary>
        /// <param name="conn"></param>
        /// <param name="protocoBase"></param>
        public void Register(TCP conn, ProtocolBase protocoBase)
        {
            ProtocolBytes protoco = (ProtocolBytes)protocoBase;

            object[] vs        = protoco.GetDecode();
            string   protoName = vs[0].ToString();
            string   strFromat = "[收到注册协议]" + conn.GetAddress();

            protoco = new ProtocolBytes();
            protoco.SetProtocol(Fursion_Protocol.Register);
            UserData UD       = JsonConvert.DeserializeObject <UserData>(vs[1].ToString());
            string   Openid   = UD.Openid;
            string   NickName = UD.NickNeam;

            Console.WriteLine(strFromat + "   " + Openid + "   " + NickName);
            var reg = DataMgr.instance.Register(Openid, NickName, UD);

            if (reg)                //
            {
                protoco.AddData(0); //
            }
            else
            {
                protoco.AddData(1);
                conn.Send(protoco);
                return;
            }
            conn.Send(protoco);
            Console.WriteLine("**&&**&&**");
        }
Example #2
0
        /// <summary>
        /// 加入队伍
        /// </summary>
        /// <param name="TeamOpenid"></param>
        /// <param name="player"></param>
        public void IntoTeam(string TeamOpenid, Player player)
        {
            ProtocolBytes RecpToJoin = new ProtocolBytes();

            RecpToJoin.SetProtocol(Fursion_Protocol.Team_IntoTeam);
            if (!TeamDict.ContainsKey(TeamOpenid))
            {
                RecpToJoin.AddData(TeamDict[TeamOpenid].GetTeamInfo(-1));
                player.Conn.Send(RecpToJoin);
                return;
            }
            else if (TeamDict[TeamOpenid].EffectivePlayerNumber() == TeamDict[TeamOpenid].PresetPlayerMax)
            {
                RecpToJoin.AddData(TeamDict[TeamOpenid].GetTeamInfo(1));
                player.Conn.Send(RecpToJoin);
                return;
            }
            else if (TeamDict[TeamOpenid].CheckPlayerInTeam(player.Openid))
            {
                RecpToJoin.AddData(TeamDict[TeamOpenid].GetTeamInfo(11));
                player.Send(RecpToJoin);
                return;
            }
            TeamDict[TeamOpenid].JoinTeam(player);
            player.TeamOpenid = TeamDict[TeamOpenid].TeamOpenid;
            RecpToJoin.AddData(TeamDict[TeamOpenid].GetTeamInfo(0));
            player.Send(RecpToJoin);//发送给加入者
            ProtocolBytes Broid = new ProtocolBytes();

            Broid.SetProtocol(Fursion_Protocol.Team_IntoTeam);
            Broid.AddData(TeamDict[TeamOpenid].GetTeamInfo(0));
            TeamDict[TeamOpenid].BordCast(Broid);//广播给队伍成员
        }
Example #3
0
        /// <summary>
        /// 创建队伍
        /// </summary>
        /// <param name="player"></param>
        /// <param name="vs"></param>
        public void CreateTeam(Player player, object[] vs)
        {
            if (player.TeamOpenid != null)
            {
                return;
            }
            CreatTeamApply apply     = JsonConvert.DeserializeObject <CreatTeamApply>(vs[1].ToString());
            ProtocolBytes  CreatRecp = new ProtocolBytes();

            CreatRecp.SetProtocol(Fursion_Protocol.Team_CreateTeam);
            try
            {
                TeamBase Team = new TeamBase
                {
                    TeamOpenid   = FursionTools.GetFursionGUID(),//给队伍添加唯一识别符
                    TeamType     = apply.TeamType,
                    TeamMode     = apply.TeamMode,
                    MasterOpenid = player.Openid
                };
                switch (Team.TeamType)
                {
                case TeamType.One: Team.PresetPlayerMax = 1; break;

                case TeamType.Three: Team.PresetPlayerMax = 3; break;

                case TeamType.Five: Team.PresetPlayerMax = 5; break;
                }
                switch (Team.TeamMode)
                {
                case TeamMode.Custom: Team.PresetPlayerMax *= 2; break;
                }
                Team.Players = new Player[Team.PresetPlayerMax];
                Team.JoinTeam(player);//将创建者加入队伍
                player.TeamOpenid = Team.TeamOpenid;
                player.GameReady  = true;
                TeamDict.Add(Team.TeamOpenid, Team);//将队伍加入全服队伍列表
                //switch (Team.TeamInfo.PresetPlayerMax)
                //{
                //    case 1: OnePlayerTeamDict.Add(Team.TeamInfo.TeamOpenid, Team); break;
                //    case 2: TwoPlayerTeamDict.Add(Team.TeamInfo.TeamOpenid, Team); break;
                //    case 3: ThreePlayerTeamDict.Add(Team.TeamInfo.TeamOpenid, Team); break;
                //    case 5: FivePlayerTeamDict.Add(Team.TeamInfo.TeamOpenid, Team); break;
                //    default: break;
                //}
                CreatRecp.AddData(Team.GetTeamInfo(0));
                player.Send(CreatRecp);
            }
            catch (Exception e)
            {
                CreatRecp.AddData(1);
                player.Send(CreatRecp);
                Console.WriteLine("CreateTeam  " + e.Message);
            }
        }
        public void JSONTEST(TCP conn, ProtocolBase protocoBase)
        {
            Friend friend  = new Friend();
            string jsonstr = JsonConvert.SerializeObject(friend);

            Console.WriteLine("JSON测试    " + jsonstr);
            ProtocolBytes bytes = new ProtocolBytes();

            bytes.AddData("JSONTEST");
            bytes.AddData(jsonstr);
            conn.Send(bytes);
        }
Example #5
0
        private void FriendMSGSend(object obj)
        {
            NewMSG newMSG = (NewMSG)obj;

            Console.WriteLine(newMSG.MSGText);
            ProtocolBytes MSG = new ProtocolBytes();

            MSG.AddData("MSG");
            string MSGStr = JsonConvert.SerializeObject(newMSG);

            MSG.AddData(MSGStr);
            if (ClientMC.A.CTCD.ContainsKey(newMSG.Destination))
            {
                ClientMC.A.CTCD[newMSG.Destination].Send(MSG);
            }
        }
Example #6
0
        /// <summary>
        /// 广播加载进度
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void SendLoading(object sender, ElapsedEventArgs e)//广播进度并判断
        {
            bool          Temp  = true;
            ProtocolBytes bytes = new ProtocolBytes();

            bytes.SetProtocol(Fursion_Protocol.Loading);
            RoomInitInfo roomplayerInfo = new RoomInitInfo();

            foreach (Player player in MemberList.Values)
            {
                RoomPlayer roomPlayer = player.TempData.PlayerGameInfo;
                roomplayerInfo.RoomPlayers.Add(roomPlayer);
            }
            bytes.AddData(JsonConvert.SerializeObject(roomplayerInfo));
            foreach (Player player in MemberList.Values)
            {
                if (player != null && player.UDPClient != null)
                {
                    UDP.instance.SocketSend(bytes, player.UDPClient);
                }
            }
            foreach (Player player in MemberList.Values)
            {
                Temp &= player.TempData.PlayerGameInfo.LoadingProgressBool;
            }
            if (Temp)
            {
                ToStart();
            }
        }
Example #7
0
        /// <summary>
        /// 组队邀请
        /// </summary>
        /// <param name="player"></param>
        /// <param name="vs"></param>
        public void TeamInvitation(Player player, object[] vs)
        {
            InviationReceipt receipt = JsonConvert.DeserializeObject <InviationReceipt>(vs[1].ToString());

            if (!TeamDict.ContainsKey(receipt.TeamOpenid))
            {
                return;
            }
            ProtocolBytes ret = new ProtocolBytes();

            ret.SetProtocol(Fursion_Protocol.Team_RetInit);
            foreach (Player Ply in TeamDict[receipt.TeamOpenid].Players)
            {
                if (Ply != null)
                {
                    if (receipt.ReceiverId == Ply.Openid)
                    {
                        ret.AddData(1);
                        player.Send(ret);
                        return;
                    }
                }
            }
            if (FriendMC.OnlinePlayerList.ContainsKey(receipt.ReceiverId))
            {
                ProtocolBytes Inret = new ProtocolBytes();
                Inret.SetProtocol(Fursion_Protocol.Team_TeamInvitation);
                receipt.InviterData = player.UserData;
                Inret.AddData(receipt);
                FriendMC.OnlinePlayerList[receipt.ReceiverId].Send(Inret);
                Console.WriteLine("Send end");
            }
        }
Example #8
0
        public void GetINFO(object O)
        {
            string     serverinfoStr;
            ServerInfo serverinfo = new ServerInfo();

            ServerConn[]  ServerArr = new ServerConn[OnlineServer.Count];
            object[]      vs        = (object[])O;
            ProtocolBytes bytes     = (ProtocolBytes)vs[0];
            TCP           conn      = (TCP)vs[1];
            int           i         = 0;

            foreach (ServerConn SC in OnlineServer)
            {
                ServerArr[i] = SC;
                i++;
            }
            for (int a = 0; a < ServerArr.Length - 1; a++)
            {
                for (int b = a + 1; b < ServerArr.Length; b++)
                {
                    if (ServerArr[a].UNitl > ServerArr[b].UNitl)
                    {
                        ServerConn Temp = ServerArr[a];
                        ServerArr[a] = ServerArr[b];
                        ServerArr[b] = Temp;
                    }
                }
            }
            if (ServerArr.Length == 0)
            {
                bytes.AddData(1);
                conn.Send(bytes);
                "MSG_Server: 没有启动".ColorWord(ConsoleColor.DarkRed);
                return;
            }
            bytes.AddData(0);
            serverinfo.IP           = ServerArr[0].IP;
            serverinfo.Port         = ServerArr[0].Port;
            serverinfo.ServerVrsion = ServerArr[0].Server_Vrsion;
            serverinfoStr           = JsonConvert.SerializeObject(serverinfo);

            Console.WriteLine("ToClient " + serverinfo.IP + " " + serverinfo.Port.ToString());
            bytes.AddData(serverinfoStr);
            bytes.AddData(conn.Player.ReConnectCheckCode);
            conn.Send(bytes);
        }
Example #9
0
        /// <summary>
        /// 向成员更新队伍信息
        /// </summary>
        public void UpdateTeam()
        {
            ProtocolBytes UpdateRe = new ProtocolBytes();

            UpdateRe.SetProtocol(Fursion_Protocol.Team_UpdateTeam);
            UpdateRe.AddData(GetTeamInfo(0));
            BordCast(UpdateRe);
        }
Example #10
0
        public void DelBlackList(Player player, object[] vs)
        {
            string        TarID = vs[FriendVar.TargetID].ToString();
            ProtocolBytes bytes = new ProtocolBytes();

            bytes.SetProtocol(Fursion_Protocol.Friend_AddApply);
            if (DataMgr.instance.DelBlackFriend(player.Openid, TarID))
            {
                bytes.AddData(0);
                player.Send(bytes);
            }
            else
            {
                bytes.AddData(1);
                player.Send(bytes);
            }
        }
        public static void FalseCheckOpenid(TCP conn)
        {
            ProtocolBytes RetBytes = new ProtocolBytes();

            RetBytes.SetProtocol(Fursion_Protocol.CheckOpenid);
            RetBytes.AddData(1);
            conn.Send(RetBytes);
        }
Example #12
0
        public void WroldMSGSend(object O)
        {
            NewMSG newMSG = (NewMSG)O;

            Console.WriteLine(newMSG.MSGText);
            ProtocolBytes MSG = new ProtocolBytes();

            MSG.AddData("MSG");
            string MSGStr = JsonConvert.SerializeObject(newMSG);

            MSG.AddData(MSGStr);
            Dictionary <string, ConnToClient> Online = ClientMC.A.CTCD;

            foreach (ConnToClient CTC in Online.Values)
            {
                CTC.Send(MSG);
            }
        }
Example #13
0
        public void Getserver()
        {
            ProtocolBytes bytes = new ProtocolBytes
            {
                Protocol = Fursion_Protocol.RetServer
            };

            bytes.AddData(ClientMC.A.Utilization());
            SendToMainServer(bytes);
        }
Example #14
0
        /// <summary>
        /// 添加好友
        /// </summary>
        /// <param name="player"></param>
        /// <param name="vs"></param>
        public void AddFriend(Player player, object[] vs)
        {
            string        TarID = vs[1].ToString();
            ProtocolBytes bytes = new ProtocolBytes();

            bytes.SetProtocol(Fursion_Protocol.Friend_AddApply);
            if (DataMgr.instance.AddFriend(player, TarID))
            {
                bytes.AddData(0);
                player.Send(bytes);
                Console.WriteLine("添加成功");
            }
            else
            {
                bytes.AddData(1);
                player.Send(bytes);
                Console.WriteLine("添加失败");
            }
        }
Example #15
0
        public void SendToMainServer(Fursion.Protocol.Fursion_Protocol fursion_Protocol, object O)
        {
            ProtocolBytes protocol = new ProtocolBytes
            {
                Protocol = fursion_Protocol
            };

            protocol.AddData(JsonConvert.SerializeObject(O));
            SendToMainServer(protocol);
        }
Example #16
0
        public void ApplyAddFriend(Player player, object[] vs)
        {
            string        TarID = vs[1].ToString();
            ProtocolBytes bytes = new ProtocolBytes();

            bytes.SetProtocol(Fursion_Protocol.Friend_AddApply);
            if (DataMgr.instance.AddApplyFriend(player, TarID))
            {
                bytes.AddData(0);
                player.Send(bytes);
                if (OnlinePlayerList.ContainsKey(TarID))
                {
                    ProtocolBytes byt = new ProtocolBytes();
                    byt.SetProtocol(Fursion_Protocol.Friend_UpdateList);
                    OnlinePlayerList[TarID].Send(byt);
                }
                Console.WriteLine("添加申请成功");
                if (OnlinePlayerList.ContainsKey(TarID))
                {
                    ProtocolBytes OnlneApply = new ProtocolBytes();
                    OnlneApply.SetProtocol(Fursion_Protocol.Friend_OnlineApply);
                    OnlneApply.AddData(player.Openid);
                    UserData UD    = DataMgr.instance.GetUserData(player.Openid);
                    string   UDStr = JsonConvert.SerializeObject(UD);
                    OnlneApply.AddData(UDStr);
                    OnlinePlayerList[TarID].Send(OnlneApply);
                    bytes.AddData(0);
                    player.Send(bytes);
                    return;
                }
            }
            else
            {
                bytes.AddData(1);
                player.Send(bytes);
                Console.WriteLine("添加申请失败");
            }
        }
Example #17
0
        /// <summary>
        /// 进入加载阶段
        /// </summary>
        /// <param name="roomInitInfo"></param>
        public void ToLoadingStage(RoomInitInfo roomInitInfo)
        {
            SelectTime.Dispose();
            ProtocolBytes protocol = new ProtocolBytes();

            protocol.SetProtocol(Fursion_Protocol.Loading);
            protocol.AddData(JsonConvert.SerializeObject(roomInitInfo));
            foreach (Player player1 in MemberList.Values)
            {
                UDP.instance.SocketSend(protocol, player1.UDPClient);
            }
            LoadTimer.Enabled           = true;
            MaxWaitLoadingTimer.Enabled = true;
        }
Example #18
0
        public void FindUser(Player player, object[] vs)
        {
            ProtocolBytes bytes = new ProtocolBytes();

            bytes.SetProtocol(Fursion_Protocol.Friend_FindUser);
            string       NackName = vs[1].ToString();
            FindUserList FUL      = new FindUserList
            {
                UserList = DataMgr.instance.FindUser(NackName)
            };

            if (FUL.UserList.Count == 0)
            {
                bytes.AddData(1);
                player.Send(bytes);
                return;
            }
            string FULStr = JsonConvert.SerializeObject(FUL);

            bytes.AddData(0);
            bytes.AddData(FULStr);
            player.Send(bytes);
        }
Example #19
0
 public bool ToConnServer(string IP, int Prot)
 {
     try
     {
         socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
         IPAddress  IPAdd = IPAddress.Parse(IP);
         IPEndPoint IEP   = new IPEndPoint(IPAdd, Prot);
         socket.Connect(IEP);
         ToServerState = false;
         socket.BeginReceive(readbuff, buffCount, BUFFER_SIZE - buffCount, SocketFlags.None, ReceiveCb, readbuff);
         ProtocolBytes bytes = new ProtocolBytes();
         bytes.AddData(Var.ServerInfo);
         bytes.AddData(Server_Vrsion);
         bytes.AddData(ClientMC.A.LoadIP);
         bytes.AddData(ClientMC.A.LoadPort);
         SendToMainServer(bytes);
         return(true);
     }
     catch (Exception e)
     {
         Console.WriteLine(e.Message);
         return(false);
     }
 }
        public void Logout(TCP conn, ProtocolBase protocoBase)
        {
            ProtocolBytes protocoBytes = new ProtocolBytes();

            protocoBytes.SetProtocol(Fursion_Protocol.Logout);
            protocoBytes.AddData(0);
            if (conn.Player == null)
            {
                conn.Send(protocoBytes);
                NMC.instance.CloseTCP(conn);
            }
            else
            {
                conn.Send(protocoBytes);
                conn.Player.Logout();
            }
        }
Example #21
0
        public void UpdateRoomInfo()
        {
            ProtocolBytes UpdateInfo = new ProtocolBytes();

            UpdateInfo.SetProtocol(Fursion_Protocol.UpdateRoomInfo);
            RoomReceipt roominfo = new RoomReceipt();

            roominfo.RoomOpenid      = RoomOpenid;
            roominfo.RoomMode        = RoomMode;
            roominfo.RoomType        = RoomType;
            roominfo.RedTeamMembers  = GetTeamMemberInfo(RedTeam);
            roominfo.BlueTeamMemBers = GetTeamMemberInfo(BlueTeam);
            roominfo.RoomMembers     = RoomPlayerInfo();
            roominfo.JoinBool        = GetRoomMemberJoin();
            UpdateInfo.AddData(roominfo);
            TCPBroadCast(UpdateInfo);
        }
Example #22
0
        /// <summary>
        /// 下发开始协议,进入确认面板
        /// </summary>
        public void GoToConfirmStage()
        {
            ProtocolBytes JoinRoom = new ProtocolBytes();

            JoinRoom.SetProtocol(Fursion_Protocol.ConfirmEnter);
            RoomReceipt roomReceipt = new RoomReceipt();

            roomReceipt.RoomOpenid      = RoomOpenid;
            roomReceipt.RoomMode        = RoomMode;
            roomReceipt.RoomType        = RoomType;
            roomReceipt.RedTeamMembers  = GetTeamMemberInfo(RedTeam);
            roomReceipt.BlueTeamMemBers = GetTeamMemberInfo(BlueTeam);
            roomReceipt.RoomMembers     = RoomPlayerInfo();
            roomReceipt.JoinBool        = GetRoomMemberJoin();
            JoinRoom.AddData(roomReceipt);
            TCPBroadCast(JoinRoom);
            RightTimer.Enabled = true;
        }
Example #23
0
        public void SendTest(object sender, ElapsedEventArgs e)
        {
            ProtocolBytes LogicFrameStr = new ProtocolBytes();

            LogicFrameStr.SetProtocol(Fursion_Protocol.LockStep);
            lock (NowLogicFrame.instructFrames)
            {
                Console.WriteLine(JsonConvert.SerializeObject(NowLogicFrame));
                LogicFrameStr.AddData(JsonConvert.SerializeObject(NowLogicFrame));
            }
            foreach (EndPoint endPoint in UDP_ClientList)
            {
                Console.WriteLine(LogicFrameStr.bytes.Length);
                UDP.instance.SocketSend(LogicFrameStr, endPoint);
            }
            NowLogicFrame = new LogicFrame();
            S_Farmid++;
            NowLogicFrame.LogicFrameID = S_Farmid;
        }
Example #24
0
 public static bool Kickoff(String Openid, bool T)
 {
     TCP[] conns = NMC.instance.tcps;
     for (int i = 0; i < conns.Length; i++)
     {
         if (conns[i] == null)
         {
             continue;
         }
         if (!conns[i].isUse)
         {
             continue;
         }
         if (conns[i].Player == null)
         {
             continue;
         }
         if (conns[i].Player.Openid == Openid)//防止重复登录
         {
             if (conns[i].Player.NowState == PlayerState.None)
             {
                 return(!conns[i].Player.Logout());
             }
             lock (conns[i].Player)
             {
                 if (T)
                 {
                     ProtocolBytes Logout = new ProtocolBytes();
                     Logout.AddData(ProtocolConst.Logout);
                     conns[i].Player.Send(Logout);
                     return(!conns[i].Player.Logout());
                 }
                 else
                 {
                     return(true);
                 }
             }
         }
     }
     return(false);
 }
Example #25
0
        public void RetFriendList(Friend friend, Player player)
        {
            AddOnlinePlayer(player.Openid, player, friend);
            if (friend.GoodList.Keys.Count != 0)
            {
                foreach (string id in friend.GoodList.Keys)
                {
                    friend.GoodList[id].data = DataMgr.instance.GetUserData(id);
                    if (OnlinePlayerList.ContainsKey(id))
                    {
                        friend.GoodList[id].OnlineState = true;
                    }
                }
            }
            if (friend.ApplyList.Keys.Count != 0)
            {
                foreach (string id in friend.ApplyList.Keys)
                {
                    friend.ApplyList[id].data = DataMgr.instance.GetUserData(id);
                }
            }
            if (friend.BlackList.Keys.Count != 0)
            {
                foreach (string id in friend.BlackList.Keys)
                {
                    friend.BlackList[id].data = DataMgr.instance.GetUserData(id);
                }
            }
            string FriendListStr = JsonConvert.SerializeObject(friend);

            Console.WriteLine(FriendListStr);
            ProtocolBytes bytes = new ProtocolBytes();

            bytes.SetProtocol(Fursion_Protocol.Friend_GetFriendListInfo);
            bytes.AddData(FriendListStr);
            player.Send(bytes);
        }
        public static void TrueCheckOpenid(TCP conn, LoginReceipt receipt, bool ISReConn)
        {
            ProtocolBytes RetBytes = new ProtocolBytes();

            RetBytes.SetProtocol(Fursion_Protocol.CheckOpenid);
            if (receipt.OnlineRec)
            {
                if (Player.Kickoff(receipt.UserOpenid, false))
                {
                    RetBytes.AddData(2);
                    conn.Send(RetBytes);
                    return;
                }
            }
            else
            {
                if (Player.Kickoff(receipt.UserOpenid, true))
                {
                    RetBytes.AddData(2);
                    conn.Send(RetBytes);
                    return;
                }
            }
            PlayerData playerData = DataMgr.instance.GetPlayerData(receipt.UserOpenid);

            if (playerData == null)
            {
                RetBytes.AddData(-1);
                conn.Send(RetBytes);
                return;
            }
            conn.Player = new Player(receipt.UserOpenid, conn)
            {
                Data = playerData
            };
            conn.Player.NowDeviceUID = receipt.DeviceUID;
            RetBytes.AddData(0);//Success
            conn.Player.UserData = DataMgr.instance.GetUserData(conn.Player.Openid);
            Friend friend = FriendMC.A.InitFriendListInfo(conn.Player);

            if (friend.GoodList.Keys.Count != 0)
            {
                ProtocolBytes onlineRet = new ProtocolBytes();
                onlineRet.SetProtocol(Fursion_Protocol.Friend_OnlineNotice);
                onlineRet.AddData(conn.Player.Openid);
                foreach (string id in friend.GoodList.Keys)
                {
                    if (FriendMC.OnlinePlayerList.ContainsKey(id))
                    {
                        FriendMC.OnlinePlayerList[id].Send(onlineRet);
                    }
                }
            }
            string FriendListStr = JsonConvert.SerializeObject(friend);

            RetBytes.AddData(FriendListStr);
            ServerMC.This.GetServerInfo(RetBytes, conn);
            if (ISReConn)
            {
                ProtocolBytes Ret = new ProtocolBytes();
                Ret.SetProtocol(Fursion_Protocol.ReConnectRet);
                conn.Send(Ret);
            }
            Console.WriteLine("登录成功******发送   ");
        }
Example #27
0
        private void HangMsg(ProtocolBase protoc, EndPoint Client)
        {
            ProtocolBytes Data = (ProtocolBytes)protoc;

            object[] dat     = Data.GetDecode();
            string   MsgName = Data.Protocol.ToString();

            Console.WriteLine(MsgName);
            if (Data.Protocol == Fursion_Protocol.UDPInit)
            {
                lock (valuePairs)
                {
                    string openid         = dat[1].ToString();
                    Thread bindingPlayerT = new Thread(new ParameterizedThreadStart(BindingPlayer))
                    {
                        Name = "BindingPlayer"
                    };
                    object[] vs = new object[] { openid, Client };
                    bindingPlayerT.Start(vs);
                    //FriendMC.A.OnlinePlayerList[openid].UDPClient = Client;
                    //FriendMC.A.OnlinePlayerList[openid].room.P_UDP_IP.Add(Client);
                    //valuePairs.Add(Client, FriendMC.A.OnlinePlayerList[openid]);
                }
            }
            else if (Data.Protocol == Fursion_Protocol.SelectMode)
            {
                lock (valuePairs)
                {
                    SelectModel selectModel = JsonConvert.DeserializeObject <SelectModel>(dat[1].ToString());
                    if (valuePairs.ContainsKey(Client))
                    {
                        valuePairs[Client].TempData.PlayerGameInfo.SelectModelNumber = selectModel.SelectedModel;
                    }
                }
            }
            else if (Data.Protocol == Fursion_Protocol.LockSelect)
            {
                lock (valuePairs)
                {
                    valuePairs[Client].TempData.PlayerGameInfo.LockSelect = true;
                    valuePairs[Client].Room.LockSelect();
                }
            }
            else if (Data.Protocol == Fursion_Protocol.SynTest)
            {
                SynTest.The.P_UDP_IP.Add(clientEnd);
                SynTest.The.Start();
                Console.WriteLine(SynTest.The.P_UDP_IP.Count);
            }
            else if (Data.Protocol == Fursion_Protocol.SynTestInstruct)
            {
                InstructFrame instruct = JsonConvert.DeserializeObject <InstructFrame>(dat[1].ToString());
                SynTest.The.mGR.PackageLogicFrame(instruct);
            }
            else if (Data.Protocol == Fursion_Protocol.LockStep_Instruct)
            {
                lock (valuePairs)
                {
                    InstructFrame instruct = JsonConvert.DeserializeObject <InstructFrame>(dat[1].ToString());
                    if (valuePairs.ContainsKey(Client))
                    {
                        valuePairs[Client].Room.LSM.PackageLogicFrame(instruct);
                    }
                }
            }
            else if (Data.Protocol == Fursion_Protocol.Loading)
            {
                lock (valuePairs)
                {
                    if (valuePairs.ContainsKey(Client))
                    {
                        valuePairs[Client].Room.LoadingMethod(valuePairs[Client], dat);
                    }
                }
            }
            else
            {
                ProtocolBytes send = new ProtocolBytes();
                send.AddData(" From server " + MsgName);
                SocketSend(send, clientEnd);
            }
        }
Example #28
0
 /// <summary>
 /// 退出队伍
 /// </summary>
 /// <param name="TeamOpenid"></param>
 /// <param name="player"></param>
 /// <param name="TargetOpenid"></param>
 public void ExitTeam(Player player)
 {
     if (player.TeamOpenid != null)
     {
         if (!TeamDict.ContainsKey(player.TeamOpenid))
         {
             ProtocolBytes ExitRet = new ProtocolBytes();
             ExitRet.SetProtocol(Fursion_Protocol.Team_SelfExit);
             TeamReceipt Receipt = new TeamReceipt
             {
                 ret = 0
             };
             ExitRet.AddData(Receipt);
             player.Send(ExitRet);//玩家不在队伍中,告知玩家不在队伍中
             return;
         }
         string TeamOpenid = player.TeamOpenid;
         for (int i = 0; i < TeamDict[TeamOpenid].Players.Length; i++)
         {
             if (TeamDict[TeamOpenid].Players[i] == player)
             {
                 ProtocolBytes ExitRet = new ProtocolBytes();
                 ExitRet.SetProtocol(Fursion_Protocol.Team_SelfExit);
                 TeamDict[TeamOpenid].Players[i] = null;
                 if (player.Openid == TeamDict[TeamOpenid].MasterOpenid)
                 {
                     player.TeamOpenid = null;
                     ExitRet.AddData(TeamDict[TeamOpenid].GetTeamInfo(0));
                     player.Send(ExitRet);
                     if (TeamDict[TeamOpenid].EffectivePlayerNumber() == 0)//
                     {
                         DestoryTeam(TeamOpenid);
                         return;
                     }
                     else
                     {
                         TeamDict[TeamOpenid].MasterOpenid = TeamDict[TeamOpenid].RetFastPlayerID();
                     }
                 }
                 else
                 {
                     player.TeamOpenid = null;
                     ExitRet.AddData(TeamDict[TeamOpenid].GetTeamInfo(0));
                     player.Send(ExitRet);
                 }
                 ProtocolBytes BordExitRet = new ProtocolBytes();
                 BordExitRet.SetProtocol(Fursion_Protocol.Team_ExitTeam);
                 BordExitRet.AddData(TeamDict[TeamOpenid].GetTeamInfo(0));
                 if (TeamDict.ContainsKey(TeamOpenid))
                 {
                     TeamDict[TeamOpenid].BordCast(BordExitRet);//广播给队伍里剩余人
                 }
                 return;
             }
         }
     }
     else
     {
         ProtocolBytes ExitRet = new ProtocolBytes();
         ExitRet.SetProtocol(Fursion_Protocol.Team_SelfExit);
         TeamReceipt Receipt = new TeamReceipt
         {
             ret = 0
         };
         ExitRet.AddData(Receipt);
         player.Send(ExitRet);//玩家不在队伍中,告知玩家不在队伍中
     }
 }