コード例 #1
0
ファイル: BotManager.cs プロジェクト: bburhans/vtank
        /// <summary>
        /// Gets a list of currently online players.
        /// </summary>
        /// <param name="includeBots">If true, the bots ran by this bot runner are
        /// included in the list. If false, they are excluded.</param>
        /// <returns>List of tank names of online players. The list is null if the
        /// online player list cannot be accessed.</returns>
        public List <Player> GetOnlinePlayers(bool includeBots)
        {
            List <VTankBot> bots = BotRunner.GetRunningBots();

            List <Player> result = new List <Player>();

            for (int i = 0; i < bots.Count; ++i)
            {
                VTankBot bot = bots[i];
                if (bot.GameServer != null && bot.GameServer.Connected)
                {
                    AIFramework.Util.GameTracker game = bot.Game;
                    List <Player> playerList          = game.GetPlayerList();
                    foreach (AIFramework.Bot.Game.Player player in playerList)
                    {
                        if (includeBots)
                        {
                            result.Add(player);
                        }
                        else
                        {
                            if (!ContainsTank(bots, player.Name))
                            {
                                result.Add(player);
                            }
                        }
                    }

                    break;
                }
            }

            return(result);
        }
コード例 #2
0
ファイル: VTankBot.cs プロジェクト: summer-of-software/vtank
        /// <summary>
        /// Constructs a VTankBot.
        /// </summary>
        /// <param name="runner">Parent bot runner.</param>
        /// <param name="server">Target Echelon server.</param>
        /// <param name="auth">Authentication information.</param>
        public VTankBot(BotRunner runner, TargetServer server, AuthInfo auth)
        {
            BotRunner = runner;
            ServerAddress = server;
            AuthInfo = auth;
            Game = new GameTracker(this);
            buffer = new EventBuffer();

            CreateMasterCommunicator();
        }