private void UpdateCharacters() { Hero.Location = game.PlayerLocation; PlayerHP.Text = game.PlayerHitPoints.ToString(); bool showbat = false; bool showghost = false; bool showghoul = false; int enemiesShown = 0; foreach (Enemy enemies in game.Enemies) { if (enemies is Bat) { Bat.Location = enemies.Location; BatHP.Text = enemies.HitPoints.ToString(); if (!enemies.Dead) { showbat = true; enemiesShown++; } } if (enemies is Ghost) { Ghost.Location = enemies.Location; GhostHP.Text = enemies.HitPoints.ToString(); if (!enemies.Dead) { showghost = true; enemiesShown++; } } if (enemies is Ghoul) { Ghoul.Location = enemies.Location; GhoulHP.Text = enemies.HitPoints.ToString(); if (!enemies.Dead) { showghoul = true; enemiesShown++; } } } Sword.Visible = false; Bow.Visible = false; RedPotion.Visible = false; BluePotion.Visible = false; Mace.Visible = false; Control weaponControl = null; switch (game.WeaponInRoom.Name) { case "Sword": weaponControl = Sword; break; case "Bow": weaponControl = Bow; break; case "Mace": weaponControl = Mace; break; case "Blue Potion": weaponControl = BluePotion; break; case "Red Potion": weaponControl = RedPotion; break; } weaponControl.Visible = true; weaponControl.Location = game.WeaponInRoom.Location; if (game.WeaponInRoom.pickedUp) { weaponControl.Visible = false; } else { weaponControl.Visible = true; } if (game.PlayerHitPoints <= 0) { MessageBox.Show("U died"); Application.Exit(); } Bat.Visible = showbat; Ghost.Visible = showghost; Ghoul.Visible = showghoul; game.CheckPlayerEquipment(weaponControl.Name); Weapon1.Visible = false; Weapon2.Visible = false; Weapon3.Visible = false; bluePotionInEq.Visible = false; RedPotionInEq.Visible = false; foreach (string name in game.PlayerWeapons) { if (name == "Sword") { Weapon1.Visible = true; } if (name == "Bow") { Weapon2.Visible = true; } if (name == "Mace") { Weapon3.Visible = true; } if (name == "Blue Potion") { bluePotionInEq.Visible = true; } if (name == "Red Potion") { RedPotionInEq.Visible = true; } } if (enemiesShown < 1) { MessageBox.Show("You defeat all enemies on this level"); game.NewLevel(random); UpdateCharacters(); } }