}//end initializeGame public void nextLevel() { GameSetup gameSetup = new GameSetup(PlayArea); if (playerLives <= 3) { ++playerLives; lblLives.Content = "Lives: " + playerLives; } this.fireRate -= 200; this.aliens = gameSetup.createAliens(); }
}//end GamePlay public void initiaizeGame() { PlayArea.Children.Clear(); this.playerLives = INITIAL_PLAYER_LIVES; GameSetup gameSetup = new GameSetup(PlayArea); this.lblScore = new Label { Content = "Score: " + scoreVal, Width = 500, Height = 30, FontSize = 16, FontWeight = FontWeights.Bold, Foreground = Brushes.LimeGreen, Margin = new Thickness(0, 0, 60, 30), }; this.lblLives = new Label { Content = "Lives: " + playerLives, Width = 100, Height = 30, FontSize = 16, FontWeight = FontWeights.Bold, Foreground = Brushes.LimeGreen, Margin = new Thickness(PlayArea.Width - 160, 0, PlayArea.Width - 110, 30) }; this.lblLevel = new Label { Content = "Level: " + level, Width = 100, Height = 30, FontSize = 16, FontWeight = FontWeights.Bold, Foreground = Brushes.LimeGreen, Margin = new Thickness(PlayArea.Width / 2 - 50, 0, PlayArea.Width / 2 + 50, 30), }; PlayArea.Children.Add(lblScore); PlayArea.Children.Add(lblLives); PlayArea.Children.Add(lblLevel); this.segments = gameSetup.buildShields(); this.aliens = gameSetup.createAliens(); this.player = new Player(PlayArea); }//end initializeGame
}//end MoveAlien timer private void MoveMotherShip_Tick(object sender, EventArgs e) { ArrayList mShipToRemove = new ArrayList(); if (motherships.Count == 0) { GameSetup gameSetup = new GameSetup(PlayArea); int send = rng.Next(0, 1000); if (send >= 999) { this.motherships = gameSetup.createMotherships(); } //end send condition } //end if no motherships if (motherships.Count > 0) { foreach (Alien mothership in motherships) { if (mothership.reachedWall() == false) { mothership.moveMothership(); }//end mothership movement else { PlayArea.Children.Remove(mothership.image); mShipToRemove.Add(mothership); } //end if mothership has hit the right wall } //end move mothership } //end if mothership is spawned foreach (Alien mothership in mShipToRemove) { this.motherships.Remove(mothership); } }//end MoveMothership_Tick