private void LoadGame() { var gameStatePath = resourcesDirectoryPath + "\\" + gameStateFileName; var gameLevelPath = resourcesDirectoryPath + "\\" + gameLevelFileName; gameShooter = new Game(); gameShooter.LoadGame(gameStatePath, gameLevelPath); statistics = gameShooter.GetStatistics(); textBoxStatistics.BeginInvoke(new InvokeDelegate(InvokeUpdateStatistics)); var map = gameShooter.GetMap(); mapImage = Drawer.DrawMap(map, mainField.Width, mainField.Height, rescaleFactor); bot = new Bot(1); bot.CreateMovingController(map); }
private void Start() { LoadGame(); var timer = new Stopwatch(); var botStep = GameActions.None; var gameStatePath = resourcesDirectoryPath + "\\" + gameStateFileName; timer.Start(); while (!stopGame) { while (!pauseGame) { if (timer.ElapsedMilliseconds > 100) { var map = gameShooter.GetMap(); botStep = bot.Decide(map); gameShooter.DoStep(0, playerStep); gameShooter.DoStep(1, botStep); gameShooter.DoPassiveActions(); mapImage = Drawer.DrawMap(map, mainField.Width, mainField.Height, rescaleFactor); mainField.BeginInvoke(new InvokeDelegate(InvokeUpdateImage)); if (gameShooter.IsLevelEnded()) { gameShooter.SaveGame(gameStatePath); LoadGame(); } playerStep = GameActions.None; botStep = GameActions.None; timer.Restart(); } } } }