예제 #1
0
        /// <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();
        }
예제 #2
0
        public VTankBot Register(Type botType, AuthInfo authInfo, string tankName)
        {
            // TODO: User still can't specify custom server.
            VTankBot bot = (VTankBot)Activator.CreateInstance(botType,
                this, EchelonAddress, authInfo);
            bot.TankName = tankName;
            bots.Add(bot);

            return bot;
        }
예제 #3
0
        /// <summary>
        /// Add a bot to the runner.
        /// </summary>
        /// <param name="type"></param>
        /// <param name="username"></param>
        /// <param name="password"></param>
        public void AddBot(Type type, string username, string password)
        {
            List<VTankBot> bots = BotRunner.GetRunningBots();

            // Remove old bot if it exists.
            for (int i = 0; i < bots.Count; ++i)
            {
                VTankBot bot = bots[i];
                if (bot.AuthInfo.Username == username)
                {
                    Print("Removed duplicate bot {0}.", username);
                    BotRunner.Kill(bot);
                    break;
                }
            }

            AuthInfo auth = new AuthInfo(username, password);
            BotRunner.Register(type, auth, null);
            BotRunner.Start(false);

            Print("Added new bot, {0}.", username);

            if (OnBotChange != null)
                OnBotChange(null);
        }