private void PlayPauseButton_MouseDown(object sender, MouseButtonEventArgs e) { Shape playButton = (Shape)GameHelper.FindCanvasChild(playPauseButton, "playButtonModel"); Canvas pauseButton = (Canvas)GameHelper.FindCanvasChild(playPauseButton, "pauseButtonModel"); if (playButton.Visibility == Visibility.Visible) { if (mazeBuilder.IsRunning) { mazeBuilder.Stop(); Grid.UpdateNodes(); PathFinder.FindPath(EnemySpawnPosition, EnemyTargetPosition); } if (PathFinder.Path.Count == 0) { MessageBox.Show("No path was found.", "Path not found!"); mazeBuilder.Start(); return; } WaveSpawner.Start(wavesCleared); UnPause(); playButton.Visibility = Visibility.Hidden; pauseButton.Visibility = Visibility.Visible; } else if (pauseButton.Visibility == Visibility.Visible) { Pause(); playButton.Visibility = Visibility.Visible; pauseButton.Visibility = Visibility.Hidden; } }
private void ResetGame() { wavesCleared = 0; playerCash = startingCash; playerGoldText.Text = startingCash.ToString(); PlayerTank.HitPoints = 10; playerHealthText.Text = PlayerTank.HitPoints.ToString(); currentLevelText.Text = "Level :" + (wavesCleared + 1); mazeBuilder.Reset(); WaveSpawner.Reset(); ShowPlayButton(); Pause(); GameOver = false; Grid.UpdateNodes(); mazeBuilder.Start(); }
private void InitializeObjects() { collidableGameObjects = new List <ICollidableGameObject>(); updatingObjects = new List <IUpdate>(); enemies = new List <Enemy>(); Grid = new Grid(this); Rand = new Random(); PlayerTank = new Tank(this); AddGameObject(PlayerTank); PathFinder = new PathFinder(Grid); mazeBuilder = new MazeBuilder(this); WaveSpawner = new WaveSpawner(this); EnemySpawnPosition = new Point(GameHelper.LeftOfGame, GameHelper.TopOfGame); EnemyTargetPosition = new Point(GameHelper.RightOfGame, GameHelper.BottomOfGame); ExplosionParticlePool = new ExplosionParticlePool(this, 400); }