private void runButton_Click(object sender, EventArgs e) { if (robotListCheckedListBox.CheckedItems.Count > 0) { var checkedRobots = robotListCheckedListBox.CheckedItems.OfType <FileInfo>(); // or Cast, whatever var names = RobocodeEngineRunner.CompileAssembly(checkedRobots); var engineParams = new RobocodeEngineParams { GunCoolingRate = double.Parse(coolRateTextBox.Text, _culture), NumRounds = (int)roundsNumericUpDown.Value, InactivityTime = (int)inactiveNumericUpDown.Value, HideNames = hideNamesCheckBox.Checked, Resolution = Utility.GetResolution(resolutionComboBox.Text), RobotNames = names }; _th = new Thread(() => _engine.Run(engineParams)) { IsBackground = true }; _th.Start(); } else { MessageBox.Show("Необходимо выбрать хотя бы одного робота.", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
public void Run(RobocodeEngineParams engineParams) { _engine = new RobocodeEngine(Utility.RobocodeDir); // Event handlers _engine.BattleCompleted += BattleCompleted; _engine.BattleMessage += BattleMessage; _engine.BattleError += BattleError; // Setup _engine.Visible = true; var battlefieldSize = new BattlefieldSpecification(engineParams.Resolution.Width, engineParams.Resolution.Height); var selectedRobots = _engine.GetLocalRepository(engineParams.RobotNames); var battleSpec = new BattleSpecification(engineParams.NumRounds, engineParams.InactivityTime, engineParams.GunCoolingRate, engineParams.HideNames, battlefieldSize, selectedRobots); // Run battle _engine.RunBattle(battleSpec, true); }