示例#1
0
 public GameRoom_Leave(Client User, XmlDocument Packet)
     : base(User, Packet)
 {
     Room = User.Player.RoomPlayer.Room;
     if (Room != null)
     {
         Room.Players.Users.RemoveAll((Client a) => a == User);
         User.Player.RoomPlayer.Room = null;
         if (Room.RoomMaster.UserId == User.Player.UserID)
         {
             Client[] array = (from Attribute in Room.Players.Users.ToList()
                               orderby Attribute.Player.Experience
                               select Attribute).ToArray();
             if (array.Length != 0)
             {
                 Room.RoomMaster.Revision++;
                 Room.RoomMaster.UserId = array[0].Player.UserID;
             }
         }
         if (Room.CustomParams.AutoTeamBalance)
         {
             Room.AutoBalanceProcess();
         }
         else
         {
             Room.Sync(User);
         }
     }
     if (base.Packet != null)
     {
         Process();
     }
 }
示例#2
0
 public GameRoom_Join(Client User, XmlDocument Packet)
     : base(User, Packet)
 {
     try
     {
         if (User.Player.RoomPlayer.Room != null)
         {
             new GameRoom_Leave(User, null);
         }
         Room = User.Channel.GameRoomList.Find((GameRoom Attribute) => Attribute.Core.RoomId == long.Parse(Query.Attributes["room_id"].InnerText));
         if (Room == null)
         {
             new StanzaException(User, base.Packet, 2);
             return;
         }
         if (Room.KickedUsers.Contains(User.Player.UserID))
         {
             new StanzaException(User, base.Packet, 2);
             return;
         }
         if (Room.Players.Users.Count >= Room.CustomParams.MaxPlayers)
         {
             new StanzaException(User, base.Packet, 4);
             return;
         }
         byte num = (byte)Room.Players.Users.Count((Client Attribute) => Attribute.Player.RoomPlayer.TeamId == Teams.WARFACE);
         byte b   = (byte)Room.Players.Users.Count((Client Attribute) => Attribute.Player.RoomPlayer.TeamId == Teams.BLACKWOOD);
         if (num > b)
         {
             User.Player.RoomPlayer.TeamId = Teams.BLACKWOOD;
         }
         else
         {
             User.Player.RoomPlayer.TeamId = Teams.WARFACE;
         }
         User.Player.RoomPlayer.Room = Room;
         Room.Players.Users.Add(User);
         Process();
         if (Room.CustomParams.AutoTeamBalance)
         {
             Room.AutoBalanceProcess();
         }
         else
         {
             Room.Sync(User);
         }
     }
     catch { }
 }
示例#3
0
 public GameRoom_OnKicked(Client User, Reason Reason = Reason.KickedByUser)
     : base(User, null)
 {
     Room       = User.Player.RoomPlayer.Room;
     KickReason = Reason;
     Room.KickedUsers.Add(User.Player.UserID);
     Room.Players.Users.RemoveAll((Client a) => a == User);
     User.Player.RoomPlayer.Room = null;
     if (Room.CustomParams.AutoTeamBalance)
     {
         Room.AutoBalanceProcess();
     }
     else
     {
         Room.Sync();
     }
     Process();
 }
示例#4
0
        public GameRoom_UpdatePvP(Client User, XmlDocument Packet)
            : base(User, Packet)
        {
            GameRoom room = User.Player.RoomPlayer.Room;

            try
            {
                if (room.Mission.Map.FirstChild.Attributes["uid"].InnerText != this.Query.Attributes["mission_key"].InnerText)
                {
                    XmlDocument xmlDocument = Core.GameResources.Maps.Find((Predicate <XmlDocument>)(Attribute => Attribute.FirstChild.Attributes["uid"].InnerText == this.Query.Attributes["mission_key"].InnerText));
                    if (xmlDocument.FirstChild.Attributes["release_mission"].InnerText == "0")
                    {
                        StanzaException stanzaException = new StanzaException(User, Packet, 1);
                    }
                    else
                    {
                        room.Mission.Map = xmlDocument;
                        ++room.Mission.Revision;
                    }
                }
            }
            catch
            {
                this.ErrorId = 1;
                this.Process();
                return;
            }
            if (this.Query.Attributes["private"] != null)
            {
                room.Core.Private = this.Query.Attributes["private"].InnerText == "1";
            }
            if (this.Query.Attributes["round_limit"] != null && (this.Query.Attributes["round_limit"].InnerText == "6" || this.Query.Attributes["round_limit"].InnerText == "11" || this.Query.Attributes["round_limit"].InnerText == "16"))
            {
                room.CustomParams.RoundLimit = Convert.ToByte(this.Query.Attributes["round_limit"].InnerText);
            }
            if (this.Query.Attributes["friendly_fire"] != null)
            {
                room.CustomParams.FriendlyFire = this.Query.Attributes["friendly_fire"].InnerText == "1";
            }
            if (this.Query.Attributes["enemy_outlines"] != null)
            {
                room.CustomParams.EmenyOutlines = this.Query.Attributes["enemy_outlines"].InnerText == "1";
            }
            if (this.Query.Attributes["auto_team_balance"] != null)
            {
                room.CustomParams.AutoTeamBalance = this.Query.Attributes["auto_team_balance"].InnerText == "1";
            }
            if (this.Query.Attributes["dead_can_chat"] != null)
            {
                room.CustomParams.DeadCanChat = this.Query.Attributes["dead_can_chat"].InnerText == "1";
            }
            if (this.Query.Attributes["join_in_the_process"] != null)
            {
                room.CustomParams.JoinInProcess = this.Query.Attributes["join_in_the_process"].InnerText == "1";
            }
            if (this.Query.Attributes["max_players"] != null)
            {
                room.CustomParams.MaxPlayers = byte.Parse(this.Query.Attributes["max_players"].InnerText);
            }
            if (this.Query.Attributes["inventory_slot"] != null)
            {
                room.CustomParams.InventorySlot = int.Parse(this.Query.Attributes["inventory_slot"].InnerText);
            }
            if (this.Query.Attributes["locked_spectator_camera"] != null)
            {
                room.CustomParams.LockedSpectatorCamera = this.Query.Attributes["locked_spectator_camera"].InnerText == "1";
            }
            if (this.Query.Attributes["overtime_mode"] != null)
            {
                room.CustomParams.OvertimeMode = this.Query.Attributes["overtime_mode"].InnerText == "1";
            }
            if (this.Query["class_rifleman"] != null)
            {
                room.CustomParams.SoldierEnabled = this.Query["class_rifleman"].Attributes["enabled"].InnerText == "1";
            }
            if (this.Query["class_medic"] != null)
            {
                room.CustomParams.MedicEnabled = this.Query["class_medic"].Attributes["enabled"].InnerText == "1";
            }
            if (this.Query["class_engineer"] != null)
            {
                room.CustomParams.EngineerEnabled = this.Query["class_engineer"].Attributes["enabled"].InnerText == "1";
            }
            if (this.Query["class_sniper"] != null)
            {
                room.CustomParams.SniperEnabled = this.Query["class_sniper"].Attributes["enabled"].InnerText == "1";
            }
            ++room.CustomParams.Revision;
            if (!room.CustomParams.SoldierEnabled || !room.CustomParams.EngineerEnabled || (!room.CustomParams.SniperEnabled || !room.CustomParams.MedicEnabled))
            {
                foreach (Client client in room.Players.Users.ToArray())
                {
                    bool flag = false;
                    if (client.Player.CurrentClass == (byte)0 && !room.CustomParams.SoldierEnabled)
                    {
                        flag = true;
                    }
                    if (client.Player.CurrentClass == (byte)4 && !room.CustomParams.EngineerEnabled)
                    {
                        flag = true;
                    }
                    if (client.Player.CurrentClass == (byte)3 && !room.CustomParams.MedicEnabled)
                    {
                        flag = true;
                    }
                    if (client.Player.CurrentClass == (byte)2 && !room.CustomParams.SniperEnabled)
                    {
                        flag = true;
                    }
                    if (flag)
                    {
                        if (room.CustomParams.SoldierEnabled)
                        {
                            client.Player.CurrentClass = (byte)0;
                        }
                        if (room.CustomParams.EngineerEnabled)
                        {
                            client.Player.CurrentClass = (byte)4;
                        }
                        if (room.CustomParams.MedicEnabled)
                        {
                            client.Player.CurrentClass = (byte)3;
                        }
                        if (room.CustomParams.SniperEnabled)
                        {
                            client.Player.CurrentClass = (byte)2;
                        }
                    }
                }
            }
            if (room.CustomParams.AutoTeamBalance && room.Players.Users.Count != 1)
            {
                room.AutoBalanceProcess();
            }
            else
            {
                room.Sync(User);
            }
            this.Process();
        }
        public GameRoom_UpdatePvP(Client User, XmlDocument Packet)
            : base(User, Packet)
        {
            if (SQL.Handler.State == ConnectionState.Closed)
            {
                SQL.Handler.Open();
            }
            GameRoom room = User.Player.RoomPlayer.Room;

            try
            {
                if (room.Mission.Map.FirstChild.Attributes["uid"].InnerText != Query.Attributes["mission_key"].InnerText)
                {
                    XmlDocument xmlDocument = GameResources.Maps.Find((XmlDocument Attribute) => Attribute.FirstChild.Attributes["uid"].InnerText == Query.Attributes["mission_key"].InnerText);
                    if (xmlDocument.FirstChild.Attributes["release_mission"].InnerText == "0")
                    {
                        new StanzaException(User, Packet, 1);
                    }
                    else
                    {
                        room.Mission.Map = xmlDocument;
                        room.Mission.Revision++;
                    }
                }
            }
            catch
            {
                ErrorId = 1;
                Process();
                return;
            }
            if (Query.Attributes["private"] != null)
            {
                room.Core.Private = (Query.Attributes["private"].InnerText == "1");
            }
            if (Query.Attributes["friendly_fire"] != null)
            {
                room.CustomParams.FriendlyFire = (Query.Attributes["friendly_fire"].InnerText == "1");
            }
            if (Query.Attributes["enemy_outlines"] != null)
            {
                room.CustomParams.EmenyOutlines = (Query.Attributes["enemy_outlines"].InnerText == "1");
            }
            if (Query.Attributes["auto_team_balance"] != null)
            {
                room.CustomParams.AutoTeamBalance = (Query.Attributes["auto_team_balance"].InnerText == "1");
            }
            if (Query.Attributes["dead_can_chat"] != null)
            {
                room.CustomParams.DeadCanChat = (Query.Attributes["dead_can_chat"].InnerText == "1");
            }
            if (Query.Attributes["join_in_the_process"] != null)
            {
                room.CustomParams.JoinInProcess = (Query.Attributes["join_in_the_process"].InnerText == "1");
            }
            if (Query.Attributes["max_players"] != null)
            {
                room.CustomParams.MaxPlayers = byte.Parse(Query.Attributes["max_players"].InnerText);
            }
            if (Query.Attributes["inventory_slot"] != null)
            {
                room.CustomParams.InventorySlot = int.Parse(Query.Attributes["inventory_slot"].InnerText);
            }
            if (Query["class_rifleman"] != null)
            {
                room.CustomParams.SoldierEnabled = (Query["class_rifleman"].Attributes["enabled"].InnerText == "1");
            }
            if (Query["class_medic"] != null)
            {
                room.CustomParams.MedicEnabled = (Query["class_medic"].Attributes["enabled"].InnerText == "1");
            }
            if (Query["class_engineer"] != null)
            {
                room.CustomParams.EngineerEnabled = (Query["class_engineer"].Attributes["enabled"].InnerText == "1");
            }
            if (Query["class_sniper"] != null)
            {
                room.CustomParams.SniperEnabled = (Query["class_sniper"].Attributes["enabled"].InnerText == "1");
            }
            room.CustomParams.Revision++;
            if (!room.CustomParams.SoldierEnabled || !room.CustomParams.EngineerEnabled || !room.CustomParams.SniperEnabled || !room.CustomParams.MedicEnabled)
            {
                Client[] array = room.Players.Users.ToArray();
                foreach (Client client in array)
                {
                    bool flag = false;
                    if (client.Player.CurrentClass == 0 && !room.CustomParams.SoldierEnabled)
                    {
                        flag = true;
                    }
                    if (client.Player.CurrentClass == 4 && !room.CustomParams.EngineerEnabled)
                    {
                        flag = true;
                    }
                    if (client.Player.CurrentClass == 3 && !room.CustomParams.MedicEnabled)
                    {
                        flag = true;
                    }
                    if (client.Player.CurrentClass == 2 && !room.CustomParams.SniperEnabled)
                    {
                        flag = true;
                    }
                    if (flag)
                    {
                        if (room.CustomParams.SoldierEnabled)
                        {
                            client.Player.CurrentClass = 0;
                        }
                        if (room.CustomParams.EngineerEnabled)
                        {
                            client.Player.CurrentClass = 4;
                        }
                        if (room.CustomParams.MedicEnabled)
                        {
                            client.Player.CurrentClass = 3;
                        }
                        if (room.CustomParams.SniperEnabled)
                        {
                            client.Player.CurrentClass = 2;
                        }
                    }
                }
            }
            if (room.CustomParams.AutoTeamBalance)
            {
                room.AutoBalanceProcess();
            }
            else
            {
                room.Sync(User);
            }
            Process();
        }