public Level2(Window window, Canvas canvas, Player player, bool load) { this.load = load; if (load) { Level2.loadLevel2(canvas, window, player); } this.window = window; this.canvas = canvas; this.player = player; this.player.updateCurrentLevel(2); enemies = new List <Enemies>(); }
private void saveBtn_Click(object sender, RoutedEventArgs e) { // MessageBox.Show(""+LoadLevels.getStaticPlayer().getCurrentLevel()); //MessageBox.Show("" + player.getCurrentLevel()); if (loaded) { if (LoadLevels.getStaticPlayer().getCurrentLevel() == 1) { lv1.saveLevel1(); } else if (LoadLevels.getStaticPlayer().getCurrentLevel() == 2) { Level2.saveLevel2(this.player, true); } else if (LoadLevels.getStaticPlayer().getCurrentLevel() == 3) { Level3.saveLevel3(this.player, true); } else if (LoadLevels.getStaticPlayer().getCurrentLevel() == 4) { Level4.saveLevel4(this.player, true); } } else { if (player.getCurrentLevel() == 1) { lv1.saveLevel1(); } else if (player.getCurrentLevel() == 2) { Level2.saveLevel2(this.player, false); } else if (player.getCurrentLevel() == 3) { Level3.saveLevel3(this.player, false); } else if (player.getCurrentLevel() == 4) { Level4.saveLevel4(this.player, false); } } }
private void ShootUpdate(object sender, EventArgs e) { BackToMainWindown(); //------------------------------- for (int i = 0; i < ships.Count; i++) { if (ships[i].IsDead() == true) { arr1.Remove(i); } } for (int i = 0; i < commanders.Count; i++) { if (commanders[i].IsDead() == true) { arr2.Remove(i); } } //-------------------------------- Random rand = new Random(); int num1 = rand.Next(ships.Count);//8 if (arr1.Contains(num1)) { arr1.Remove(num1); exists1 = true; } if (exists1 == true) { if (ships[num1].IsDead() == true) { arr1.Remove(num1); } else { if (ships[num1].isShoot() == false) { ships[num1].Shoot(10); } } exists1 = false; } //------------------------------------ int num2 = rand.Next(4); if (arr2.Contains(num2)) { exists2 = true; arr2.Remove(num2); } if (exists2 == true) { if (commanders[num2].IsDead() == true) { arr2.Remove(num2); } else { if (commanders[num2].isShoot() == false) { commanders[num2].Shoot(20); } } exists2 = false; } //---------------------------------------- if (enemies.Count == 0 && currentLevel == 1) { timerRandomShoot.Stop(); Level2 lv2 = new Level2(this.window, this.canvas, this.player); lv2.setLoad(true); lv2.Play(); } else if (this.enemies.Count == 0 && currentLevel == 2) { if (round < 3) { round++; Level2 lv2 = new Level2(this.window, this.canvas, this.player); lv2.setRound(round); lv2.setLoad(true); lv2.Play(); } else { if (round == 3) { Level3 lv3 = new Level3(this.window, this.canvas, this.player); lv3.Play(); } } } }
/// <summary> /// The shootUpdate method controls randomly the /// shooting of the enemies. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void ShootUpdate(object sender, EventArgs e) { //remove enemies destroyed from the arr1 or arr2 list //------------------------------- for (int i = 0; i < ships.Length; i++) { if (ships[i].IsDead() == true) { arr1.Remove(i); } } for (int i = 0; i < commanders.Length; i++) { if (commanders[i].IsDead() == true) { arr2.Remove(i); } } //-------------------------------- Random rand = new Random(); int num1 = rand.Next(ships.Length);//8 if (arr1.Contains(num1)) { arr1.Remove(num1); exists1 = true; } if (exists1 == true) { if (ships[num1].IsDead() == true) { arr1.Remove(num1); } else { if (ships[num1].isShoot() == false) { ships[num1].Shoot(10); } } exists1 = false; } //------------------------------------ int num2 = rand.Next(4); if (arr2.Contains(num2)) { exists2 = true; arr2.Remove(num2); } if (exists2 == true) { if (commanders[num2].IsDead() == true) { arr2.Remove(num2); } else { if (commanders[num2].isShoot() == false) { commanders[num2].Shoot(20); } } exists2 = false; } //---------------------------------------- if (this.enemies.Count == 0) { timerRandomShoot.Stop(); this.canvas.Children.Remove(lv1Pic); Level2 lv2 = new Level2(this.window, this.canvas, this.player); lv2.Play(); } }