private void UpdateCharacters() { player.Location = game.PlayerLocation; playerHitPoints.Text = game.PlayerHitPoints.ToString(); int enemiesShown = 0; foreach (Enemy enemy in game.Enemies) { if (enemy is Bat) { bat.Location = enemy.Location; batHitPoints.Text = enemy.HitPoints.ToString(); if (enemy.HitPoints > 0) { bat.Visible = true; enemiesShown++; } else { bat.Visible = false; batHitPoints.Text = "0"; } } if (enemy is Ghost) { ghost.Location = enemy.Location; ghostHitPoints.Text = enemy.HitPoints.ToString(); if (enemy.HitPoints > 0) { ghost.Visible = true; enemiesShown++; } else { ghost.Visible = false; ghostHitPoints.Text = "0"; } } if (enemy is Gnoul) { gnoul.Location = enemy.Location; gnoulHitPoints.Text = enemy.HitPoints.ToString(); if (enemy.HitPoints > 0) { gnoul.Visible = true; enemiesShown++; } else { gnoul.Visible = false; gnoulHitPoints.Text = "0"; } } } 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 "Red Potion": weaponControl = redPotion; break; case "Blue Potion": weaponControl = bluePotion; break; case "Mace": weaponControl = mace; break; } if (game.CheckPlayerInventory("Sword")) { swordInv.Visible = true; } if (game.CheckPlayerInventory("Bow")) { bowInv.Visible = true; } if (game.CheckPlayerInventory("Red Potion")) { if ((game.CheckPotionInventory("Red Potion")) == false) { redPotionInv.Visible = true; } else { redPotionInv.Visible = false; } } if (game.CheckPlayerInventory("Blue Potion")) { if ((game.CheckPotionInventory("Blue Potion")) == false) { bluePotionInv.Visible = true; } else { RemovePotionFromInventory("Blue Potion"); } } if (game.CheckPlayerInventory("Mace")) { maceInv.Visible = true; } if (weaponControl != null) { weaponControl.Location = game.WeaponInRoom.Location; if (game.WeaponInRoom.PickedUp) { weaponControl.Visible = false; } else { weaponControl.Visible = true; } } if (game.PlayerHitPoints <= 0) { MessageBox.Show("You died"); DialogResult playAgain = MessageBox.Show("Would you like to Play again", "Play Again", MessageBoxButtons.YesNo); if (playAgain == DialogResult.Yes) { Application.Restart(); } else { Application.Exit(); } } if (enemiesShown < 1) { MessageBox.Show("You have defeated the enemies on this level"); game.NewLevel(random); UpdateCharacters(); } }