public void UpdateCharacters() { PlayerPictureBox.Location = game.PLayerLocation; playerHitPointsLabel.Text = game.PlayerHitPoints.ToString(); bool showBat = false; bool showGhost = false; bool showGhoul = false; int enemiesShown = 0; foreach (Enemy enemy in game.Enemies) { if (enemy is Bat) { BatPictureBox.Location = enemy.Location; BatHitPointsLabel.Text = enemy.HitPoints.ToString(); if (enemy.HitPoints > 0) { showBat = true; enemiesShown++; } } if (enemy is Ghost) { GhostPictureBox.Location = enemy.Location; GhostHitPointsLabel.Text = enemy.HitPoints.ToString(); if (enemy.HitPoints > 0) { showGhost = true; enemiesShown++; } } if (enemy is Ghoul) { GhoulPictureBox.Location = enemy.Location; GhoulHitPointsLabel.Text = enemy.HitPoints.ToString(); if (enemy.HitPoints > 0) { showGhoul = true; enemiesShown++; } } } if (!showBat) { BatPictureBox.Visible = false; BatHitPointsLabel.Text = ""; } else { BatPictureBox.Visible = true; } if (!showGhost) { GhostPictureBox.Visible = false; GhostHitPointsLabel.Text = ""; } else { GhostPictureBox.Visible = true; } if (!showGhoul) { GhoulPictureBox.Visible = false; GhoulHitPointsLabel.Text = ""; } else { GhoulPictureBox.Visible = true; } BattleSwordPictureBox.Visible = false; BattleAxePictureBox.Visible = false; BattleMacePictureBox.Visible = false; BattleRedPotionPictureBox.Visible = false; BattleBluePotionPictureBox.Visible = false; Control weaponControl = null; switch (game.WeaponInRoom.Name) { case "Sword": weaponControl = BattleSwordPictureBox; break; case "Axe": weaponControl = BattleAxePictureBox; break; case "Mace": weaponControl = BattleMacePictureBox; break; case "Red potion": weaponControl = BattleRedPotionPictureBox; break; case "Blue potion": weaponControl = BattleBluePotionPictureBox; break; } weaponControl.Visible = true; if (game.ChekPlayerInventory("Mace")) { InventoryMacePictureBox.Visible = true; } if (game.ChekPlayerInventory("Axe")) { InventoryAxePictureBox.Visible = true; } if (game.ChekPlayerInventory("Sword")) { InventorySwordPictureBox.Visible = true; } if (game.ChekPlayerInventory("Red potion")) { InventoryRedPotionPictureBox.Visible = true; } if (game.ChekPlayerInventory("Blue potion")) { InventoryBluePotionPictureBox.Visible = true; } weaponControl.Location = game.WeaponInRoom.Location; if (game.WeaponInRoom.PickedUp) { weaponControl.Visible = false; } else { weaponControl.Visible = true; } if (game.PlayerHitPoints <= 0) { MessageBox.Show("You died"); Application.Exit(); } //else PlayerPictureBox.Visible = true; if (enemiesShown < 1) { MessageBox.Show("You have defeated the enemies of this level"); //if (game.Level > 7) //{ // MessageBox.Show("You won!"); // //if (DialogResult == DialogResult.OK) // Application.Exit(); //} game.NewLevel(random); UpdateCharacters(); } }