Exemple #1
0
        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            // TODO: Add your initialization logic here

            _graphics.ToggleFullScreen();
            _battleEngine.Load(new[] { "ExampleScripts\\LRBot.cs", "ExampleScripts\\ExampleBot.cs", "ExampleScripts\\LRBot.cs" });

            // Determine proper scaling ratio from the robots world coordinates to the screen coordinates
            _scaleX = (double)_graphics.GraphicsDevice.Viewport.Width / Arena.ArenaWidth;
            _scaleY = (double)_graphics.GraphicsDevice.Viewport.Height / Arena.ArenaHeight;

            // TODO Log settings

            base.Initialize();
        }
Exemple #2
0
        /// <summary>
        /// No options other than paths/filenames to the C# source
        /// for each robot
        /// </summary>
        /// <param name="args"></param>
        static void Main(string[] args)
        {
            if (args.Length == 0)
            {
                Console.WriteLine("You must provide the robot files you want to compile");
                return;
            }

            Init();

            // Load, compile and instantiate the robots given on the command line
            if (_battleEngine.Load(args))
            {
                // Execute battle until one is left standing
                while (true)
                {
                    if (!_battleEngine.Execute())
                    {
                        // Display winner
                        return;
                    }

                    _cycles++;
                    UpdateDisplay();

                    // Check for quit 'Q' key
                    if (Console.KeyAvailable)
                    {
                        ConsoleKeyInfo consoleKeyInfo = Console.ReadKey(true);

                        if (consoleKeyInfo.Key == ConsoleKey.Q)
                        {
                            return;
                        }
                    }

                    Thread.Sleep(20);
                }
            }

            foreach (var error in _battleEngine.Errors)
            {
                Console.WriteLine(error);
            }

            return;
        }
Exemple #3
0
        /// <summary>
        ///
        /// </summary>
        private void Start()
        {
            if (_gameRunning)
            {
                return;
            }

            // Begin battle
            if (_scripts.Length == 0)
            {
                MessageBox.Show(@"You must first open up some robot scripts", @"Error");
                return;
            }

            if (_battleEngine.Load(_scripts))
            {
                _gameRunning = true;
                _gameEventTimer.Start();
            }
        }