Exemple #1
0
 private void findRobot(TextBox tb, ComboBox cb)
 {
     if (System.IO.File.Exists(tb.Text))
     {
         cb.Items.Clear();
         cb.Items.AddRange(LibraryRobotFactory.FindTypes(tb.Text).Select(x => x.Name).ToArray());
         if (cb.Items.Count > 0)
         {
             cb.SelectedIndex = 0;
         }
     }
 }
Exemple #2
0
        private void startGame()
        {
            var settings = Settings.Load();

            if (!LibraryRobotFactory.IsTypeValid(settings.PlayerBlueDll, settings.PlayerBlueTypeName) ||
                !LibraryRobotFactory.IsTypeValid(settings.PlayerRedDll, settings.PlayerRedTypeName) ||
                !MapLoader.IsMapValid(settings.MapName))
            {
                showOptions();
                settings = Settings.Load();
            }


            lock (_syncLockObj) {
                if (_gameController != null && _gameController is GameController)
                {
                    ((GameController)_gameController).Dispose();
                    _gameController = null;
                }


                //_gameController = new GameController(new RoslynRobotFactory(@"C:\HexCodeCore\AlexRobot\MaveBot.cs"),
                //                                 new RoslynRobotFactory(@"C:\HexCodeCore\AlexRobot\MaveBot.cs"));

                int rndSeed = chkRandomSeed.Checked ? new Random().Next() : int.Parse(txtSeed.Text);

                if (chkRandomSeed.Checked)
                {
                    txtSeed.Text = rndSeed.ToString();
                }

                _gameController = new GameController(new LibraryRobotFactory(settings.PlayerRedDll, settings.PlayerRedTypeName),
                                                     new LibraryRobotFactory(settings.PlayerBlueDll, settings.PlayerBlueTypeName), rndSeed);


                ((GameController)_gameController).TimeoutsEnabled = _timeouts;
                //Map bigMap2 = MapLoader.LoadMap("BigMap2");
                ((GameController)_gameController).Map = MapLoader.LoadMap(settings.MapName);

                //_gameController = ReplayController.LoadReplay(@"C:\HexCodeCore\HexCode.Client\bin\Debug\netcoreapp3.1\Replays\MaveBot_VS_MaveBot_20200326T123957.hcrep");

                _gameController.StartGame();
                fillComboBox(_gameController);
            }
            skControl1.Invalidate();
            changeTimerSpeed();
        }