private void Form1_Load(object sender, EventArgs e) { AddInventoryBoxes(); game = new Game(new Rectangle(78, 57, 420, 155)); game.NewLevel(random); UpdateCharacters(); }
private void Form1_Load(object sender, EventArgs e) { game = new Game(new Rectangle(12, 12, 655, 383)); game.NewLevel(random); UpdateCharacters(); defaultButtonColor = buttonCtrl[0].BackColor; }
private void Form1_Load(object sender, EventArgs e) { game = new Game(new Rectangle(100, 65, 560, 175)); game.NewLevel(random); UpdateCharacters(); playerHitPointsLBL.Text = game.PlayerHitPoints.ToString(); }
private void UpdateCharacters() { UpdatePlayer(); int enemiesShown = UpdateEnemiesAndReturnEnemiesShown(); Control weaponControl = DisplayWeaponInRoom(); DisplayInventory(); weaponControl.Location = game.WeaponInRoom.Location; if (game.WeaponInRoom.PickedUp) { weaponControl.Visible = false; } else { weaponControl.Visible = true; } if (game.PlayerHitPoints <= 0) { MessageBox.Show("You ded"); Application.Exit(); } if (enemiesShown < 1) { MessageBox.Show("You have defeated the enemies on this level"); game.NewLevel(random); if (!game.Victory) { UpdateCharacters(); } } }
private void Form1_Load(object sender, EventArgs e) { PlayerText = new Label(); PlayerText.Text = "Player"; PlayerHP = new Label(); PlayerHP.Text = ""; BatText = new Label(); BatText.Text = "Bat"; BatHP = new Label(); BatHP.Text = ""; GhostText = new Label(); GhostText.Text = "Ghost"; GhostHP = new Label(); GhostHP.Text = ""; GhoulText = new Label(); GhoulText.Text = "Ghoul"; GhoulHP = new Label(); GhoulHP.Text = ""; table.Controls.Add(PlayerText, 0, 0); table.Controls.Add(PlayerHP, 1, 0); table.Controls.Add(BatText, 0, 1); table.Controls.Add(BatHP, 1, 1); table.Controls.Add(GhostText, 0, 2); table.Controls.Add(GhostHP, 1, 2); table.Controls.Add(GhoulText, 0, 3); table.Controls.Add(GhoulHP, 1, 3); game = new Game(new Rectangle(78, 57, 420, 155)); player = new Player(game, game.PlayerLocation); game.NewLevel(random); UpdateCharacters(); }
public MainForm() { InitializeComponent(); game = new Game(new Rectangle(76, 56, 460, 170)); game.NewLevel(random); UpdateCharacters(); }
private void QuestGame_Load(object sender, EventArgs e) { _game = new Game(new Rectangle(125, 94, 700, 280)); _game.NewLevel(_random); UpdateCharacters(); SetTheLevel(); }
private void UpdateCharacters() { labelPlayerHitPoints.Text = _game.PlayerHitPoints.ToString(); pictureBoxPlayer.Location = _game.PlayerLocation; int enemiesShown = 0; enemiesShown = CountEnemies(); Control weaponControl = null; SetPictureBoxVisibility(); weaponControl = SetVisibilityToWeaponInRoom(weaponControl); weaponControl.Visible = true; CheckPlayerInventory(); weaponControl.Location = _game.WeaponInRoom.Location; if (_game.WeaponInRoom.PickedUp) { weaponControl.Visible = false; } else { weaponControl.Visible = true; weaponControl.Location = _game.WeaponInRoom.Location; } if (_game.PlayerHitPoints <= 0) { MessageBox.Show("You died", "System..."); Application.Exit(); } if (enemiesShown < 1) { MessageBox.Show("You have defeated the enemies on this level"); _game.NewLevel(_random); UpdateCharacters(); } }
private void UpdateCharacters() { PlayerSprite.Location = game.PlayerLocation; PlayerHitPoints.Text = game.PlayerHitPoints.ToString(); List <bool> enemyList = new List <bool>(Enumerable.Repeat <bool>(false, 3)); int enemyFlag = 0; for (int i = 0; i < game.Enemies.Count; ++i) { UpdateEnemy(ref enemyFlag, ref enemyList, game.Enemies[i]); } //Math.Pow(2, 3); List <bool> weaponList = new List <bool>(Enumerable.Repeat <bool>(false, 5)); int weaponFlag = 0; for (int i = 0; i < game.WeaponsInRoom.Count; ++i) { Weapon weapon = game.WeaponsInRoom[i]; UpdateWeaponCtrl(ref weaponFlag, ref weaponList, weapon); } if (game.PlayerHitPoints <= 0) { if (MessageBox.Show("죽었습니다.") == DialogResult.OK) { Application.Exit(); } } if (game.Enemies.Count < 1) { MessageBox.Show("적을 죽였습니다. 다음 레벨로 갑시다!"); game.NewLevel(random); UpdateCharacters(); } }
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(); } }
private void Form1_Load(object sender, EventArgs e) { game = new Game(new Rectangle(100, 73, 560, 185)); game.NewLevel(random); UpdateCharacters(); }
public void UpdateCharacters() { player.Location = game.PlayerLocation; playerHitPoints.Text = game.PlayerHitPoints.ToString(); bool showBat = false; bool showGhost = false; bool showGhoul = false; int enemiesShown = 0; // more code to go here... foreach (Enemy enemy in game.Enemies) { if (enemy is Bat) { bat.Location = enemy.Location; batHitPoints.Text = enemy.HitPoints.ToString(); if (enemy.Dead) { batHitPoints.Text = "Dead"; } if (enemy.HitPoints > 0) { showBat = true; enemiesShown++; } } else if (enemy is Ghost) { ghost.Location = enemy.Location; ghostHitPoints.Text = enemy.HitPoints.ToString(); if (enemy.Dead) { batHitPoints.Text = "Dead"; } if (enemy.HitPoints > 0) { showGhost = true; enemiesShown++; } } else if (enemy is Ghoul) { ghoul.Location = enemy.Location; ghoulHitPoints.Text = enemy.HitPoints.ToString(); if (enemy.Dead) { batHitPoints.Text = "Dead"; } if (enemy.HitPoints > 0) { showGhoul = true; enemiesShown++; } } } // etc... player.Visible = true; bat.Visible = showBat; ghost.Visible = showGhost; ghoul.Visible = showGhoul; sword.Visible = false; bow.Visible = false; mace.Visible = false; bluePotion.Visible = false; redPotion.Visible = false; Control weaponControl = null; switch (game.WeaponInRoom.Name) { case "Sword": weaponControl = sword; if (game.WeaponInRoom.PickedUp) { swordInv.Visible = true; } break; case "Bow": weaponControl = bow; if (game.WeaponInRoom.PickedUp) { bowInv.Visible = true; } break; case "Mace": weaponControl = mace; if (game.WeaponInRoom.PickedUp) { maceInv.Visible = true; } break; case "Red Potion": weaponControl = redPotion; if (game.CheckPlayerInventory("Red Potion")) { redPotionInv.Visible = true; } break; case "Blue Potion": weaponControl = bluePotion; if (game.CheckPlayerInventory("Blue Potion")) { bluePotionInv.Visible = true; } break; } 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(); } if (enemiesShown < 1) { MessageBox.Show("You have defeated the enemies on this level"); if (game.NewLevel(random)) { MessageBox.Show("Congratulations! You have completed the game."); Application.Exit(); } else { UpdateCharacters(); } } }
private void Form1_Load(object sender, EventArgs e) { game = new Game(new Rectangle(90, 50, 620, 265)); game.NewLevel(random); UpdateCharacters(); }
public void UpdateCharacters() { player.Location = game.PlayerLocation; playerHitPoints.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) { bat.Location = enemy.Location; batHitPoints.Text = enemy.HitPoints.ToString(); if (enemy.HitPoints > 0) { showBat = true; enemiesShown++; } } else if (enemy is Ghost) { ghost.Location = enemy.Location; ghostHitPoints.Text = enemy.HitPoints.ToString(); if (enemy.HitPoints > 0) { showGhost = true; enemiesShown++; } } else if (enemy is Ghoul) { ghoul.Location = enemy.Location; ghoulHitPoints.Text = enemy.HitPoints.ToString(); if (enemy.HitPoints > 0) { showGhoul = true; enemiesShown++; } } } sword.Visible = false; bow.Visible = false; redPotion.Visible = false; bluePotion.Visible = false; mace.Visible = false; iSword.Visible = false; iBow.Visible = false; iRedPotion.Visible = false; iBluePotion.Visible = false; iMace.Visible = false; Control weaponControl = new Control(); switch (game.WeaponInRoom.Name) { case "Sword": weaponControl = sword; break; case "Bow": weaponControl = bow; break; case "Mace": weaponControl = mace; break; case "RedPotion": weaponControl = redPotion; break; case "BluePotion": weaponControl = bluePotion; break; } weaponControl.Visible = true; if (game.CheckPlayerInventory("Sword")) { iSword.Visible = true; } if (game.CheckPlayerInventory("Mace")) { iMace.Visible = true; } if (game.CheckPlayerInventory("Bow")) { iBow.Visible = true; } if (game.CheckPlayerInventory("RedPotion")) { iRedPotion.Visible = true; } if (game.CheckPlayerInventory("BluePotion")) { iBluePotion.Visible = true; } if (showBat) { bat.Visible = true; } else { bat.Visible = false; } if (showGhost) { ghost.Visible = true; } else { ghost.Visible = false; } if (showGhoul) { ghoul.Visible = true; } else { ghoul.Visible = false; } 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(); } if (enemiesShown < 1) { MessageBox.Show("You have defeated the enemies on this level"); game.NewLevel(random); UpdateCharacters(); } }
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(); } }
public void UpdateCharacters() { playerPic.Location = game.PlayerLocation; playerHP.Text = game.PlayerHitPoints.ToString(); bool showBat = false; bool showGhost = false; bool showGhoul = false; int enemiesShown = 0; // populate hitpoint fields foreach (Enemy enemy in game.Enemies) { if (enemy is Bat) { batPic.Location = enemy.Location; batHP.Text = enemy.HitPoints.ToString(); if (enemy.HitPoints > 0) { showBat = true; enemiesShown++; } else { showBat = false; } } if (enemy is Ghost) { ghostPic.Location = enemy.Location; ghostHP.Text = enemy.HitPoints.ToString(); if (enemy.HitPoints > 0) { showGhost = true; enemiesShown++; } else { showGhoul = false; } } if (enemy is Ghoul) { ghoulPic.Location = enemy.Location; ghoulHP.Text = enemy.HitPoints.ToString(); if (enemy.HitPoints > 0) { showGhoul = true; enemiesShown++; } else { showGhoul = false; } } } // set visibility for enemies and hitpoint field batPic.Visible = label4.Visible = batHP.Visible = showBat; ghostPic.Visible = label5.Visible = ghostHP.Visible = showGhost; ghoulPic.Visible = label6.Visible = ghoulHP.Visible = showGhoul; sword.Visible = bow.Visible = mace.Visible = bluePotion.Visible = redPotion.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 "Red Potion": weaponControl = redPotion; break; case "Blue Potion": weaponControl = bluePotion; break; } weaponControl.Visible = true; weaponControl.Location = game.WeaponInRoom.Location; if (game.WeaponInRoom.PickedUp) { weaponControl.Visible = false; } else { weaponControl.Visible = true; } // death if (game.PlayerHitPoints <= 0) { MessageBox.Show("You died.", "You lose!"); Application.Exit(); } // check level advancement if (enemiesShown < 1) { MessageBox.Show("You have defeated all enemies on this level.", "Level clear!"); game.NewLevel(random); UpdateCharacters(); } // update character inventory if (game.CheckPlayerInventory("Bow")) { invBow.Visible = true; } if (game.CheckPlayerInventory("Sword")) { invSword.Visible = true; } if (game.CheckPlayerInventory("Mace")) { invMace.Visible = true; } if (game.CheckPlayerInventory("Red Potion")) { invRed.Visible = true; } else { invRed.Visible = false; } if (game.CheckPlayerInventory("Blue Potion")) { invBlue.Visible = true; } else { invBlue.Visible = false; } if (game.EquippedWeapon != null) { if (game.EquippedWeapon.Name != "Blue Potion" && game.EquippedWeapon.Name != "Red Potion") { TurnOnArrows(); } } }
private void Form1_Load(object sender, EventArgs e) { game = new Game(new Rectangle(78, 57, 420, 155)); game.NewLevel(random); UpdateCharacters(); }
private void UpdateCharacters() { ChangeEquippedWeaponBoxColor(); //set player label hitPoints playerHitPoints.Text = game.PlayerHitPoints.ToString(); //set picture box's location to player's location dPlayerBox.Location = game.PlayerLocation; //show dPlayerBox.Visible = true; int enemiesShown = 0; //an object that references the weapon in the room's picture box ChangeEquippedWeaponBoxColor(); //loop through enemies in the game foreach (Enemy enemy in game.enemies) { if (enemy is Bat) { dBatBox.Visible = true; dBatBox.Location = enemy.Location; batHitPoints.Text = enemy.HitPoints.ToString(); enemiesShown++; } if (enemy is Ghost) { dGhostBox.Visible = true; dGhostBox.Location = enemy.Location; ghostHitPoints.Text = enemy.HitPoints.ToString(); enemiesShown++; } if (enemy is Ghoul) { dGhoulBox.Visible = true; dGhoulBox.Location = enemy.Location; ghoutHitPoints.Text = enemy.HitPoints.ToString(); enemiesShown++; } } AreEnemiesDead(); if (!game.weaponInRoom.PickedUp) { switch (game.weaponInRoom.Name) { case "Sword": dSwordBox.Visible = true; dSwordBox.Location = game.weaponInRoom.Location; weaponInRoomBox = dSwordBox; break; case "Bow": dBowBox.Visible = true; dBowBox.Location = game.weaponInRoom.Location; weaponInRoomBox = dBowBox; break; case "Mace": dMaceBox.Visible = true; dMaceBox.Location = game.weaponInRoom.Location; weaponInRoomBox = dMaceBox; break; case "Blue Potion": dBluePotionBox.Visible = true; dBluePotionBox.Location = game.weaponInRoom.Location; weaponInRoomBox = dBluePotionBox; break; case "Red Potion": dRedPotionBox.Visible = true; dRedPotionBox.Location = game.weaponInRoom.Location; weaponInRoomBox = dRedPotionBox; break; } } if (game.weaponInRoom.PickedUp && potionUsed == false) { weaponInRoomBox.Visible = false; if (game.weaponInRoom.Name == "Sword") { swordBox.Visible = true; } else if (game.weaponInRoom.Name == "Bow") { quiverBox.Visible = true; } else if (game.weaponInRoom.Name == "Mace") { maceaBox.Visible = true; } else if (game.weaponInRoom.Name == "Red Potion") { redPotionBox.Visible = true; } else if (game.weaponInRoom.Name == "Blue Potion") { bluePotionBox.Visible = true; } } //if your hitpoints reach zero quit game if (game.PlayerHitPoints <= 0) { MessageBox.Show("You Died"); Application.Exit(); } //if enemy count drops below 1 if (game.enemies.Count < 1) { MessageBox.Show("You killed all enemies on this level"); //if player didn't pick up weapon on level, set that weapon's box invisible weaponInRoomBox.Visible = false; game.NewLevel(random); potionUsed = false; UpdateCharacters(); } }