public void UpdateCharacters() { PlayerSprite.Location = game.PlayerLocation; PlayerHitPoints.Text = game.PlayerHitPoints.ToString(); int enemiesShown = 0; foreach (Enemy enemy in game.Enemies) { if (enemy is Bat) { if (UpdateEnemySprite(enemy, BatSprite, BatHitPoints)) { enemiesShown++; } } if (enemy is Ghost) { if (UpdateEnemySprite(enemy, GhostSprite, GhostHitPoints)) { enemiesShown++; } } if (enemy is Ghoul) { if (UpdateEnemySprite(enemy, GhoulSprite, GhoulHitPoints)) { enemiesShown++; } } } SwordSprite.Visible = false; BowSprite.Visible = false; MaceSprite.Visible = false; RedPotionSprite.Visible = false; BluePotionSprite.Visible = false; if (game.WeaponInRoom != null) { Control weaponControl = null; switch (game.WeaponInRoom.Name) { case "Sword": weaponControl = SwordSprite; break; case "Bow": weaponControl = BowSprite; break; case "Mace": weaponControl = MaceSprite; break; case "Red Potion": weaponControl = RedPotionSprite; break; case "Blue Potion": weaponControl = BluePotionSprite; break; } if (game.WeaponInRoom.PickedUp) { weaponControl.Visible = false; } else { weaponControl.Visible = true; weaponControl.Location = game.WeaponInRoom.Location; } } SwordInvSprite.Visible = false; BowInvSprite.Visible = false; MaceInvSprite.Visible = false; RedPotionInvSprite.Visible = false; BluePotionInvSprite.Visible = false; if (game.CheckPlayerInventory("Sword")) { SwordInvSprite.Visible = true; } if (game.CheckPlayerInventory("Bow")) { BowInvSprite.Visible = true; } if (game.CheckPlayerInventory("Mace")) { MaceInvSprite.Visible = true; } if (game.CheckPlayerInventory("Red Potion")) { if (!game.CheckPotionUsed("Red Potion")) { RedPotionInvSprite.Visible = true; } } if (game.CheckPlayerInventory("Blue Potion")) { if (!game.CheckPotionUsed("Blue Potion")) { BluePotionInvSprite.Visible = true; } } if (game.PlayerHitPoints <= 0) { MessageBox.Show("You died"); Application.Exit(); } if (enemiesShown < 1) { MessageBox.Show("You have defeated the enemies on this level"); game.NewLevel(random); UpdateCharacters(); } }