Ejemplo n.º 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();
        }
Ejemplo n.º 2
0
        public BotManager(BotRunner runner)
        {
            buffer = new InvocationBuffer();
            reservedList = new List<VTankBot>();

            BotRunner = runner;
            WaitTimeReconnect = 5000;

            BotRunner.OnCrash += new BotRunner.Disconnect((bot) =>
            {
                buffer.Enqueue(new Invocation.InvocationTarget(HandleCrash),
                    bot, WaitTimeReconnect);
            });

            BotRunner.OnBotStateChange += new BotRunner.BotStateChange(BotRunner_OnBotStateChange);
            needsBalance = false;
        }
Ejemplo n.º 3
0
        public void Dispose()
        {
            Shutdown();

            if (buffer != null)
            {
                IEvent[] events = buffer.PopAll();
                if (events != null && events.Length > 0)
                {
                    foreach (IEvent evt in events)
                    {
                        evt.Dispose();
                    }
                }
            }

            BotRunner = null;
            clientCallback = null;
            clockCallback = null;
            buffer = null;
            Game = null;
            Player = null;
        }
Ejemplo n.º 4
0
 /// <summary>
 /// Constructs the client interface.
 /// </summary>
 /// <param name="runner">Runner running this bot.</param>
 /// <param name="bot">Bot which will receive events.</param>
 public ClientI(BotRunner runner, VTankBot bot, EventBuffer buffer)
 {
     BotRunner   = runner;
     Bot         = bot;
     this.buffer = buffer;
 }
Ejemplo n.º 5
0
        public static void Main(string[] args)
        {
            bool loadGUI = true;
            string configFile = DefaultConfigFile;
            if (args.Length > 1)
            {
                // Command-line arguments exist.
                for (int i = 0; i < args.Length; ++i)
                {
                    if (args[i] == "-c" || args[i] == "--config-file")
                    {
                        // Argument: custom configuration file.
                        if (args.Length >= i + 1)
                        {
                            PrintUsage("-c", "filename");
                        }

                        configFile = args[i + 1];
                        ++i;
                    }

                    else if (args[i] == "-ng" || args[i] == "--nogui" || args[i] == "nogui")
                    {
                        // Argument: Hide the GUI.
                        loadGUI = false;
                    }
                }
            }

            try
            {
                WeaponLoader.LoadFiles();
                BotRunner runner = new BotRunner();

                if (loadGUI)
                {
                    try
                    {
                        Application.Run(new MainWindow(configFile, runner));
                    }
                    catch (Exception e)
                    {
                        MessageBox.Show("Error: " + e.Message, "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        Environment.Exit(1);
                    }
                }
                else
                {
                    runner.Parse(configFile);
                    runner.Start(true);
                }
            }
            catch (Exception e)
            {
                Console.Error.WriteLine("Error!");
                Console.Error.WriteLine(e);
                Console.Error.WriteLine(e.StackTrace);

                throw;
            }
        }
Ejemplo n.º 6
0
 /// <summary>
 /// Constructs the client interface.
 /// </summary>
 /// <param name="runner">Runner running this bot.</param>
 /// <param name="bot">Bot which will receive events.</param>
 public ClientI(BotRunner runner, VTankBot bot, EventBuffer buffer)
 {
     BotRunner = runner;
     Bot = bot;
     this.buffer = buffer;
 }