コード例 #1
0
        void TasClient_BattleUserLeft(object sender, BattleUserEventArgs e)
        {
            var userName = e.UserName;

            if (userName == Program.Conf.LobbyPlayerName)
            {
                minimapFuncBox.Visible = false; //hide buttons when leaving game
                playerListItems.Clear();
                playerBox.Items.Clear();
            }
            if (PlayerListItems.Any(i => i.UserName == userName))
            {
                RemoveUser(userName);
                AddLine(new LeaveLine(userName));
            }
        }
コード例 #2
0
        protected override void SortByTeam()
        {
            if (filtering || Program.TasClient.MyBattle == null)
            {
                return;
            }

            var newList = new List <PlayerListItem>();

            foreach (var us in PlayerListItems)
            {
                newList.Add(us);
            }

            if (missionSlots != null)
            {
                foreach (var slot in missionSlots.Where(s => s.IsHuman))
                {
                    var playerListItem =
                        newList.FirstOrDefault(p => p.UserBattleStatus != null && !p.UserBattleStatus.IsSpectator && p.UserBattleStatus.TeamNumber == slot.TeamID);
                    if (playerListItem == null)
                    {
                        newList.Add(new PlayerListItem {
                            SlotButton = slot.TeamName, MissionSlot = slot
                        });
                    }
                    else
                    {
                        playerListItem.MissionSlot = slot;
                    }
                }
            }

            var nonSpecs      = PlayerListItems.Where(p => p.UserBattleStatus != null && !p.UserBattleStatus.IsSpectator);
            var existingTeams = nonSpecs.GroupBy(i => i.UserBattleStatus.AllyNumber).Select(team => team.Key).ToList();

            foreach (var bot in Program.TasClient.MyBattle.Bots)
            {
                var missionSlot = GetSlotByTeamID(bot.TeamNumber);
                newList.Add(new PlayerListItem
                {
                    BotBattleStatus = bot, SortCategory = bot.AllyNumber * 2 + 1, AllyTeam = bot.AllyNumber, MissionSlot = missionSlot
                });
                existingTeams.Add(bot.AllyNumber);
            }

            // add section headers
            if (PlayerListItems.Any(i => i.UserBattleStatus != null && i.UserBattleStatus.IsSpectator))
            {
                newList.Add(new PlayerListItem {
                    Button = "Spectators", SortCategory = 100, IsSpectatorsTitle = true, Height = 25
                });
            }

            var buttonTeams = existingTeams.Distinct();

            if (missionSlots != null)
            {
                buttonTeams = buttonTeams.Concat(missionSlots.Select(s => s.AllyID)).Distinct();
            }
            foreach (var team in buttonTeams)
            {
                int numPlayers = nonSpecs.Where(p => p.UserBattleStatus.AllyNumber == team).Count();
                int numBots    = Program.TasClient.MyBattle.Bots.Where(p => p.AllyNumber == team).Count();
                int numTotal   = numPlayers + numBots;

                var allianceName = "Team " + (team + 1) + (numTotal > 3?"  (" + numTotal + ")":"");
                if (missionSlots != null)
                {
                    var slot = missionSlots.FirstOrDefault(s => s.AllyID == team);
                    if (slot != null)
                    {
                        allianceName = slot.AllyName;
                    }
                }
                newList.Add(new PlayerListItem {
                    Button = allianceName, SortCategory = team * 2, AllyTeam = team, Height = 25
                });
            }

            newList = newList.OrderBy(x => x.ToString()).ToList();


            playerBox.BeginUpdate();
            playerBox.Items.Clear();
            foreach (var item in newList)
            {
                playerBox.Items.Add(item);
            }
            playerBox.EndUpdate();
        }
コード例 #3
0
        protected override void SortByTeam()
        {
            if (filtering || Program.TasClient.MyBattle == null)
            {
                return;
            }

            var newList = new List <PlayerListItem>();

            foreach (var us in PlayerListItems)
            {
                newList.Add(us);
            }


            var nonSpecs      = PlayerListItems.Where(p => p.UserBattleStatus != null && !p.UserBattleStatus.IsSpectator);
            var existingTeams = nonSpecs.GroupBy(i => i.UserBattleStatus.AllyNumber).Select(team => team.Key).ToList();

            foreach (var bot in Program.TasClient.MyBattle.Bots.Values)
            {
                newList.Add(new PlayerListItem
                {
                    BotBattleStatus = bot, SortCategory = bot.AllyNumber * 2 + 1 + (int)PlayerListItem.SortCats.Uncategorized, AllyTeam = bot.AllyNumber
                });
                existingTeams.Add(bot.AllyNumber);
            }

            // add section headers
            if (PlayerListItems.Any(i => i.UserBattleStatus != null && i.UserBattleStatus.IsSpectator))
            {
                newList.Add(new PlayerListItem {
                    Button = "Spectators", SortCategory = (int)PlayerListItem.SortCats.SpectatorTitle, IsSpectatorsTitle = true, Height = 25
                });
            }

            var buttonTeams = existingTeams.Distinct();

            foreach (var team in buttonTeams)
            {
                int numPlayers = nonSpecs.Where(p => p.UserBattleStatus.AllyNumber == team).Count();
                int numBots    = Program.TasClient.MyBattle.Bots.Values.Where(p => p.AllyNumber == team).Count();
                int numTotal   = numPlayers + numBots;

                var allianceName = "Team " + (team + 1) + (numTotal > 3 ? $"  ({numTotal})" : "");
                if (Program.TasClient.MyBattle?.Mode != AutohostMode.None)
                {
                    allianceName = team == 0 ? $"Players ({numTotal})"  : "Bots";
                }

                newList.Add(new PlayerListItem {
                    Button = allianceName, SortCategory = team * 2 + (int)PlayerListItem.SortCats.Uncategorized, AllyTeam = team, Height = 25
                });
            }

            newList = newList.OrderBy(x => x.GetSortingKey()).ToList();


            playerBox.BeginUpdate();
            int currentScroll = playerBox.TopIndex;

            playerBox.Items.Clear();
            foreach (var item in newList)
            {
                playerBox.Items.Add(item);
            }

            playerBox.TopIndex = currentScroll;
            playerBox.EndUpdate();
        }