Пример #1
0
 private void CheckIfAllEnemiesDefeated()
 {
     if (enemiesShown < 1)
     {
         if (!gameIsTurnBased)
         {
             StopGameClock();
         }
         MessageBox.Show("You have defeated the enemies on this level.");
         game.NewLevel(random);
         if (game.Level > 10)
         {
             if (!gameIsTurnBased)
             {
                 StopGameClock();
             }
             this.Dispose();
             this.Close();
         }
         SetLevelLabel();
         UpdateCharacters();
         if (!gameIsTurnBased)
         {
             StartGameClock();
         }
     }
 }
Пример #2
0
 private void Form1_Load(object sender, EventArgs e)
 {
     game = new Game(new Rectangle(78, 57, 420, 155));
     game.NewLevel(random);
     Text = "The Quest - Level " + game.Level;
     UpdateCharacters();
 }
Пример #3
0
 public Form1()
 {
     InitializeComponent();
     game = new Game(new Rectangle(150, 120, 840, 350));
     game.NewLevel(random);
     UpdateCharacters();
 }
Пример #4
0
        public void UpdateGame()
        {
            int enemiesShown = UpdateCharacters();

            if (enemiesShown < 1)
            {
                MessageBox.Show("You have defeated the enemies on this level");
                _game.NewLevel(_random);
                UpdateCharacters();
            }
        }
Пример #5
0
 private void Form1_Load_1(object sender, EventArgs e)
 {
     game = new Game(new Rectangle(100, 80, 620, 200));
     game.NewLevel(random);
     UpdateCharacters();
     pictureBoxes.Add(bowItem);
     pictureBoxes.Add(swordItem);
     pictureBoxes.Add(maceItem);
     pictureBoxes.Add(bluePotionItem);
     pictureBoxes.Add(redPotionItem);
 }
Пример #6
0
        private void Form1_Load(object sender, EventArgs e)
        {
            //those values depend from the actual screen size
            game = new Game(new Rectangle(78, 57, 420, 155));

            game.NewLevel(random);
            UpdateCharacters();
            MessageBox.Show("1.\t Muovi il personaggio nella direzione desiderata (MOVE)\n" +
                            "2.\tRaccogli le armi (ricordati di equipaggiarle!\n" +
                            "3.\tAvvicinati al nemico (HINT: per colpirlo devi essere ben allineato)\n" +
                            "4.\tAttacca nella direzione desiderata (ATTACK)", "Benvenuto!");

            groupBox2.Visible = false;


            MessageBox.Show("Level " + game.Level.ToString() + "!");
        }
Пример #7
0
        private void Form1_Load(object sender, EventArgs e)
        {
            // Set offset of top-left corner of icon to center
            iconOffset.X = player.Width / 2;
            iconOffset.Y = player.Height / 2;

            // Initialize game object
            game = new Game(new Rectangle(78 + iconOffset.X, 57 + iconOffset.Y, 423, 161));
            game.NewLevel(random);

            // Set characters in the game
            UpdateCharacters();

            // Initialize controls
            RemoveAllInventorySelections();
            SetMoveDirections();
            SetAttackDirections();
            SetLevelLabel();
            grpbBoxPlayStyle.Visible = false;
            actionTimer.Interval     = gameSpeed;
        }
Пример #8
0
        public void UpdateCharacters()
        {
            // update the player's position and stats
            player.Visible       = true;
            player.Location      = game.PlayerLocation;
            playerHitPoints.Text = game.PlayerHitPoints.ToString();

            // update enemy's location and hit points.
            bool showBat      = false;
            bool showGhost    = false;
            bool showGhoul    = false;
            int  enemiesShown = 0;

            foreach (Enemy enemy in game.Enemies)
            {
                if (enemy is Bat)
                {
                    batPic.Location   = enemy.Location;
                    batHitPoints.Text = enemy.HitPoints.ToString();
                    if (enemy.HitPoints > 0)
                    {
                        showBat = true;
                        enemiesShown++;
                    }
                }
                if (enemy is Ghost)
                {
                    ghostPic.Location   = enemy.Location;
                    ghostHitPoints.Text = enemy.HitPoints.ToString();
                    if (enemy.HitPoints > 0)
                    {
                        showGhost = true;
                        enemiesShown++;
                    }
                }
                if (enemy is Ghoul)
                {
                    ghoulPic.Location   = enemy.Location;
                    ghoulHitPoints.Text = enemy.HitPoints.ToString();
                    if (enemy.HitPoints > 0)
                    {
                        showGhoul = true;
                        enemiesShown++;
                    }
                }
            }
            if (showBat)
            {
                batPic.Visible = true;
            }
            else
            {
                batPic.Visible = false;
            }
            if (showGhost)
            {
                ghostPic.Visible = true;
            }
            else
            {
                ghostPic.Visible = false;
            }
            if (showGhoul)
            {
                ghoulPic.Visible = true;
            }
            else
            {
                ghoulPic.Visible = false;
            }

            // update weaponInRoom' picturebox
            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.Location = game.WeaponInRoom.Location;
            if (game.WeaponInRoom.PickedUp)
            {
                weaponControl.Visible = false;
            }
            else
            {
                weaponControl.Visible = true;
            }

            //check inventory picturebox
            if (game.CheckPlayerInventory("Sword"))
            {
                inventorySword.Visible = true;
            }
            else
            {
                inventorySword.Visible = false;
            }
            if (game.CheckPlayerInventory("Bow"))
            {
                inventoryBow.Visible = true;
            }
            else
            {
                inventoryBow.Visible = false;
            }
            if (game.CheckPlayerInventory("Mace"))
            {
                inventoryMace.Visible = true;
            }
            else
            {
                inventoryMace.Visible = false;
            }
            if (game.CheckPlayerInventory("Blue Potion"))
            {
                inventoryBluePotion.Visible = true;
            }
            else
            {
                inventoryBluePotion.Visible = false;
            }
            if (game.CheckPlayerInventory("Red Potion"))
            {
                inventoryRedPotion.Visible = true;
            }
            else
            {
                inventoryRedPotion.Visible = false;
            }
            switch (game.EquipWeapon())
            {
            case "Sword":
                inventorySword.BorderStyle = BorderStyle.FixedSingle;
                break;

            case "Bow":
                inventoryBow.BorderStyle = BorderStyle.FixedSingle;
                break;

            case "Mace":
                inventoryMace.BorderStyle = BorderStyle.FixedSingle;
                break;

            case "Blue Potion":
                inventoryBluePotion.BorderStyle = BorderStyle.FixedSingle;
                break;

            case "Red Potion":
                inventoryRedPotion.BorderStyle = BorderStyle.FixedSingle;
                break;
            }

            //update attack button
            if ((inventoryBluePotion.BorderStyle == BorderStyle.FixedSingle) && inventoryBluePotion.Visible == true)
            {
                attackUp.Text       = "Drink";
                attackRight.Visible = false;
                attackLeft.Visible  = false;
                attackDown.Visible  = false;
            }
            else
            {
                attackUp.Text       = "↑";
                attackRight.Visible = true;
                attackLeft.Visible  = true;
                attackDown.Visible  = true;
            }

            if (game.PlayerHitPoints <= 0)
            {
                timer1.Stop();
                MessageBox.Show("You died!");
                Application.Exit();
            }

            if (enemiesShown < 1)
            {
                timer1.Stop();
                MessageBox.Show("You have defeated the enemies on this level");
                game.NewLevel(random);
                this.Text = "The Quest - Level " + game.Level;
                timer1.Start();
                UpdateCharacters();
            }
        }
Пример #9
0
        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++;
                    }
                }
                if (enemy is Ghost)
                {
                    ghost.Location      = enemy.Location;
                    ghostHitPoints.Text = enemy.HitPoints.ToString();
                    if (enemy.HitPoints > 0)
                    {
                        showGhost = true;
                        enemiesShown++;
                    }
                }
                if (enemy is Ghoul)
                {
                    ghoul.Location      = enemy.Location;
                    ghoulHitPoints.Text = enemy.HitPoints.ToString();
                    if (enemy.HitPoints > 0)
                    {
                        showGhoul = true;
                        enemiesShown++;
                    }
                }
            }

            if (!showBat)
            {
                bat.Visible       = false;
                batHitPoints.Text = "";
            }
            else
            {
                bat.Visible = true;
            }

            if (!showGhost)
            {
                ghost.Visible       = false;
                ghostHitPoints.Text = "";
            }
            else
            {
                ghost.Visible = true;
            }

            if (!showGhoul)
            {
                ghoul.Visible       = false;
                ghoulHitPoints.Text = "";
            }
            else
            {
                ghoul.Visible = true;
            }

            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 "Blue Potion":
                weaponControl = bluePotion; break;

            case "Bow":
                weaponControl = bow; break;

            case "Red Potion":
                weaponControl = redPotion; break;

            case "Mace":
                weaponControl = mace; break;

            default:
                break;
            }
            weaponControl.Location = game.WeaponInRoom.Location;
            if (game.WeaponInRoom.PickedUp)
            {
                weaponControl.Visible = false;
            }
            else
            {
                weaponControl.Visible = true;
            }

            if (game.CheckPlayerInventory("Sword"))
            {
                swordIcon.Visible = true;
                if (!game.IsEquippedWeaponNull())
                {
                    if (game.GetEquippedWeaponName() == "Sword")
                    {
                        swordIcon.BorderStyle = BorderStyle.FixedSingle;
                    }
                }
            }

            if (game.CheckPlayerInventory("Blue Potion"))
            {
                bluePotionIcon.Visible = true;
            }
            else
            {
                bluePotionIcon.Visible = false;
            }

            if (game.CheckPlayerInventory("Bow"))
            {
                bowIcon.Visible = true;
            }

            if (game.CheckPlayerInventory("Red Potion"))
            {
                redPotionIcon.Visible = true;
            }
            else
            {
                redPotionIcon.Visible = false;
            }

            if (game.CheckPlayerInventory("Mace"))
            {
                maceIcon.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.Level > 6)
                {
                    Application.Exit();
                }
                else
                {
                    game.NewLevel(random);
                    UpdateCharacters();
                }
            }
        }
Пример #10
0
 private void Dungeon_Load(object sender, EventArgs e)
 {
     game = new Game(new Rectangle(78, 57, 420, 155));
     game.NewLevel(random);
     UpdateCharacters();
 }
Пример #11
0
 private void theQuest_Load(object sender, EventArgs e)
 {
     game = new Game(new Rectangle(72, 57, 400, 155));
     game.NewLevel(random);
     UpdateCharacters();
 }
 private void frmTheQuest_Load(object sender, EventArgs e)
 {
     game = new Game(new Rectangle(78, 57, 420, 155));
     game.NewLevel(random);
     UpdateCharacters();
 }
Пример #13
0
        private void UpdateCharacters()
        {
            //Update player's position and stats
            player.Location = game.PlayerLocation;
            playerHP.Text   = game.PlayerHitPoints.ToString();

            bool showBat    = false;
            bool showGhost  = false;
            bool showGhoul  = false;
            int  enemyShown = 0;

            //Update enemy's positions and stats;
            foreach (Enemy enemy in game.Enemies)
            {
                if (enemy is Bat)
                {
                    bat.Location = enemy.Location;
                    batHP.Text   = enemy.HitPoints.ToString();
                    if (enemy.HitPoints > 0)
                    {
                        showBat = true;
                        enemyShown++;
                    }
                    if (!showBat)
                    {
                        bat.Visible = false;
                        batHP.Text  = "";
                    }
                    else
                    {
                        bat.Visible = true;
                    }
                }

                if (enemy is Ghost)
                {
                    ghost.Location = enemy.Location;
                    ghostHP.Text   = enemy.HitPoints.ToString();
                    if (enemy.HitPoints > 0)
                    {
                        showGhost = true;
                        enemyShown++;
                    }
                    if (!showGhost)
                    {
                        ghost.Visible = false;
                        ghostHP.Text  = "";
                    }
                    else
                    {
                        ghost.Visible = true;
                    }
                }

                if (enemy is Ghoul)
                {
                    ghoul.Location = enemy.Location;
                    ghoulHP.Text   = enemy.HitPoints.ToString();
                    if (enemy.HitPoints > 0)
                    {
                        showGhoul = true;
                        enemyShown++;
                    }
                    if (!showGhoul)
                    {
                        ghoul.Visible = false;
                        ghoulHP.Text  = "";
                    }
                    else
                    {
                        ghoul.Visible = true;
                    }
                }
            }

            //Update weapon's pictureboxes
            swordField.Visible      = false;
            bowField.Visible        = false;
            redPotionField.Visible  = false;
            bluePotionField.Visible = false;
            maceField.Visible       = false;

            Control weaponControl = null;

            if (game.WeaponInRoom != null)
            {
                switch (game.WeaponInRoom.Name)
                {
                case "Sword":
                    weaponControl = swordField; break;

                case "Bow":
                    weaponControl = bowField; break;

                case "Red Potion":
                    weaponControl = redPotionField; break;

                case "Blue Potion":
                    weaponControl = bluePotionField; break;

                case "Mace":
                    weaponControl = maceField; break;

                default:
                    break;
                }

                weaponControl.Visible = true;
            }

            swordInventory.Visible      = false;
            bowInventory.Visible        = false;
            bluePotionInventory.Visible = false;
            redPotionInventory.Visible  = false;
            maceInventory.Visible       = false;

            //Check inventory
            if (game.CheckPlayerInventory("Sword"))
            {
                swordInventory.Visible = true;
            }

            if (game.CheckPlayerInventory("Bow"))
            {
                bowInventory.Visible = true;
            }

            if (game.CheckPlayerInventory("Blue Potion"))
            {
                bluePotionInventory.Visible = true;
            }

            if (game.CheckPlayerInventory("Red Potion"))
            {
                redPotionInventory.Visible = true;
            }

            if (game.CheckPlayerInventory("Mace"))
            {
                maceInventory.Visible = true;
            }

            //Check if player's already picked up the weapon
            if (weaponControl != null)
            {
                weaponControl.Location = game.WeaponInRoom.Location;

                if (game.WeaponInRoom.PickedUp)
                {
                    weaponControl.Visible = false;
                }
                else
                {
                    weaponControl.Visible = true;
                }
            }
            //Check if player died
            if (game.PlayerHitPoints <= 0)
            {
                MessageBox.Show("You died!", "Game over!");
                Application.Exit();
            }

            //Check for level up
            if (enemyShown < 1)
            {
                MessageBox.Show("You have defeated the enemies on this level");

                game.NewLevel(random);
                MessageBox.Show("Level " + game.Level.ToString() + "!");
                UpdateCharacters();
            }
        }
Пример #14
0
        public void UpdateCharacters()
        {
            playerImage.Location = new Point(game.PlayerLocation.X - 25, game.PlayerLocation.Y - 25);
            playerHitPoints.Text = game.PlayerHitPoints.ToString();
            playerImage.Visible  = true;

            batHitPoints.Text   = null;
            ghostHitPoints.Text = null;
            ghoulHitPoints.Text = null;
            bat.Visible         = false;
            ghost.Visible       = false;
            ghoul.Visible       = false;

            bool showBat      = false;
            bool showGhost    = false;
            bool showGhoul    = false;
            int  enemiesShown = 0;

            foreach (Enemy enemy in game.Enemies)
            {
                if (enemy is Bat)
                {
                    if (enemy.HitPoints > 0)
                    {
                        bat.Location      = new Point(enemy.Location.X - 25, enemy.Location.Y - 25);
                        batHitPoints.Text = enemy.HitPoints.ToString();
                        showBat           = true;
                        enemiesShown++;
                    }
                }



                if (enemy is Ghost)
                {
                    if (enemy.HitPoints > 0)
                    {
                        ghost.Location      = new Point(enemy.Location.X - 25, enemy.Location.Y - 25);
                        ghostHitPoints.Text = enemy.HitPoints.ToString();
                        showGhost           = true;
                        enemiesShown++;
                    }
                }

                if (enemy is Ghoul)
                {
                    if (enemy.HitPoints > 0)
                    {
                        ghoul.Location      = new Point(enemy.Location.X - 25, enemy.Location.Y - 25);
                        ghoulHitPoints.Text = enemy.HitPoints.ToString();
                        showGhoul           = true;
                        enemiesShown++;
                    }
                }

                if (showBat)
                {
                    bat.Visible = true;
                }

                if (showGhost)
                {
                    ghost.Visible = true;
                }

                if (showGhoul)
                {
                    ghoul.Visible = true;
                }
            }

            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;
            }

            weaponControl.Location = new Point(weaponControl.Location.X - 25, weaponControl.Location.Y - 25);

            weaponControl.Visible = true;

            swordItem.Visible      = false;
            bowItem.Visible        = false;
            maceItem.Visible       = false;
            bluePotionItem.Visible = false;
            redPotionItem.Visible  = false;

            if (game.CheckPlayerInventory("Sword"))
            {
                swordItem.Visible = true;
            }
            if (game.CheckPlayerInventory("Bow"))
            {
                bowItem.Visible = true;
            }
            if (game.CheckPlayerInventory("Mace"))
            {
                maceItem.Visible = true;
            }
            if (game.CheckPlayerInventory("Blue Potion"))
            {
                bluePotionItem.Visible = true;
            }
            if (game.CheckPlayerInventory("Red Potion"))
            {
                redPotionItem.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();
            }

            if (enemiesShown < 1)
            {
                MessageBox.Show("You have defeated the enemies on this level");
                game.NewLevel(random);
                UpdateCharacters();
            }
        }
Пример #15
0
 private void Form1_Load(object sender, EventArgs e)
 {
     game = new Game(new Rectangle(120, 90, 640, 230));
     game.NewLevel(random);
     UpdateCharacters();
 }
Пример #16
0
        public void UpdateCharacters()
        {
            //Update player position and stats
            playerIcon.Location = game.PlayerLocation;
            playerHP.Text       = game.PlayerHitPoints.ToString();
            playerIcon.Visible  = true;

            //Update enemies position and stats
            bool showBat      = false;
            bool showGhost    = false;
            bool showGhoul    = false;
            int  enemiesShown = 0;

            foreach (Enemy enemy in game.Enemies)
            {
                if (enemy is Bat)
                {
                    batIcon.Location = enemy.Location;
                    batHP.Text       = enemy.HitPoints.ToString();
                    if (enemy.HitPoints > 0)
                    {
                        showBat = true;
                        enemiesShown++;
                    }
                    if (showBat)
                    {
                        batIcon.Visible  = true;
                        batLabel.Visible = true;
                        batHP.Visible    = true;
                    }
                    else
                    {
                        batIcon.Visible  = false;
                        batLabel.Visible = false;
                        batHP.Visible    = false;
                    }
                }
                if (enemy is Ghost)
                {
                    ghostIcon.Location = enemy.Location;
                    ghostHP.Text       = enemy.HitPoints.ToString();
                    if (enemy.HitPoints > 0)
                    {
                        showGhost = true;
                        enemiesShown++;
                    }
                    if (showGhost)
                    {
                        ghostIcon.Visible  = true;
                        ghostLabel.Visible = true;
                        ghostHP.Visible    = true;
                    }
                    else
                    {
                        ghostIcon.Visible  = false;
                        ghostLabel.Visible = false;
                        ghostHP.Visible    = false;
                    }
                }
                if (enemy is Ghoul)
                {
                    ghoulIcon.Location = enemy.Location;
                    ghoulHP.Text       = enemy.HitPoints.ToString();
                    if (enemy.HitPoints > 0)
                    {
                        showGhoul = true;
                        enemiesShown++;
                    }
                    if (showGhoul)
                    {
                        ghoulIcon.Visible  = true;
                        ghoulLabel.Visible = true;
                        ghoulHP.Visible    = true;
                    }
                    else
                    {
                        ghoulIcon.Visible  = false;
                        ghoulLabel.Visible = false;
                        ghoulHP.Visible    = false;
                    }
                }
            }

            //Update pictureboxes for weapons
            swordIcon.Visible      = false;
            bowIcon.Visible        = false;
            maceIcon.Visible       = false;
            bluePotionIcon.Visible = false;
            redPotionIcon.Visible  = false;

            Control weaponControl = null;

            switch (game.WeaponInRoom.Name)
            {
            case "Sword":
                weaponControl = swordIcon;
                break;

            case "Bow":
                weaponControl = bowIcon;
                break;

            case "Mace":
                weaponControl = maceIcon;
                break;

            case "Blue Potion":
                weaponControl = bluePotionIcon;
                break;

            case "Red Potion":
                weaponControl = redPotionIcon;
                break;
            }
            weaponControl.Visible = true;

            //Set visibility for inventory options
            if (game.CheckPlayerInventory("Sword"))
            {
                weaponSword.Visible = true;
            }
            else
            {
                weaponSword.Visible = false;
            }
            if (game.CheckPlayerInventory("Bow"))
            {
                weaponBow.Visible = true;
            }
            else
            {
                weaponBow.Visible = false;
            }
            if (game.CheckPlayerInventory("Mace"))
            {
                weaponMace.Visible = true;
            }
            else
            {
                weaponMace.Visible = false;
            }
            if (game.CheckPlayerInventory("Blue Potion"))
            {
                weaponBluePotion.Visible = true;
            }
            else
            {
                weaponBluePotion.Visible = false;
            }
            if (game.CheckPlayerInventory("Red Potion"))
            {
                weaponRedPotion.Visible = true;
            }
            else
            {
                weaponRedPotion.Visible = false;
            }

            //See if player picked up weapon
            weaponControl.Location = game.WeaponInRoom.Location;
            if (game.WeaponInRoom.PickedUp)
            {
                weaponControl.Visible = false;
            }
            else
            {
                weaponControl.Visible = true;
            }

            //Did player die?
            if (game.PlayerHitPoints <= 0)
            {
                MessageBox.Show("You died!");
                Application.Exit();
            }

            //Did player defeat enemies?
            if (enemiesShown < 1)
            {
                MessageBox.Show("You have defeated your enemies! Get ready for the next level!");
                bool next = game.NewLevel(random);
                if (!next)
                {
                    Application.Exit();
                }
                else
                {
                    UpdateCharacters();
                }
            }
        }
Пример #17
0
        private void UpdateCharacters()
        {
            player.Location         = game.PlayerLocation;
            lblPlayerHitPoints.Text = game.PlayerHitPoints.ToString();

            int enemiesShown = 0;

            bat.Visible   = false;
            ghost.Visible = false;
            ghoul.Visible = false;

            lblBatHitPoints.Text   = "0";
            lblGhostHitPoints.Text = "0";
            lblGhoulHitPoints.Text = "0";

            foreach (Enemy enemy in game.Enemies)
            {
                if (enemy is Bat)
                {
                    if (!enemy.Dead)
                    {
                        bat.Visible          = true;
                        bat.Location         = enemy.Location;
                        lblBatHitPoints.Text = enemy.HitPoints.ToString();
                        enemiesShown++;
                    }
                    else
                    {
                        bat.Visible          = false;
                        lblBatHitPoints.Text = "0";
                    }
                }
                if (enemy is Ghost)
                {
                    if (!enemy.Dead)
                    {
                        ghost.Location         = enemy.Location;
                        ghost.Visible          = true;
                        lblGhostHitPoints.Text = enemy.HitPoints.ToString();
                        enemiesShown++;
                    }
                    else
                    {
                        ghost.Visible          = false;
                        lblGhostHitPoints.Text = "0";
                    }
                }
                if (enemy is Ghoul)
                {
                    if (!enemy.Dead)
                    {
                        ghoul.Location         = enemy.Location;
                        ghoul.Visible          = true;
                        lblGhoulHitPoints.Text = enemy.HitPoints.ToString();
                        enemiesShown++;
                    }
                    else
                    {
                        ghoul.Visible          = false;
                        lblGhoulHitPoints.Text = "0";
                    }
                }
            }

            sword.Visible      = false;
            bow.Visible        = false;
            mace.Visible       = false;
            bomb.Visible       = false;
            redPotion.Visible  = false;
            bluePotion.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 "Bomb":
                weaponControl = bomb;
                break;

            case "Blue Potion":
                weaponControl = bluePotion;
                break;

            case "Red Potion":
                weaponControl = redPotion;
                break;

            default:
                break;
            }
            weaponControl.Visible = true;

            if (game.CheckPlayerInventory("Sword"))
            {
                inventorySwordPictureBox.Visible = true;
            }
            else
            {
                inventorySwordPictureBox.Visible = false;
            }

            if (game.CheckPlayerInventory("Bow"))
            {
                inventoryBowPictureBox.Visible = true;
            }
            else
            {
                inventoryBowPictureBox.Visible = false;
            }

            if (game.CheckPlayerInventory("Mace"))
            {
                inventoryMacePictureBox.Visible = true;
            }
            else
            {
                inventoryMacePictureBox.Visible = false;
            }

            if (game.CheckPlayerInventory("Bomb"))
            {
                inventoryBombPictureBox.Visible = true;
            }
            else
            {
                inventoryBombPictureBox.Visible = false;
            }

            if (game.CheckPlayerInventory("Blue Potion"))
            {
                inventoryBluePotionPictureBox.Visible = true;
            }
            else
            {
                inventoryBluePotionPictureBox.Visible = false;
            }

            if (game.CheckPlayerInventory("Red Potion"))
            {
                inventoryRedPotionPictureBox.Visible = true;
            }
            else
            {
                inventoryRedPotionPictureBox.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 enemy on this level");
                game.NewLevel(random);
                UpdateCharacters();
            }
        }
Пример #18
0
        public void UpdateCharacters()
        {
            player.Location      = game.PlayerLocation;
            playerHitPoints.Text =
                game.PlayerHitPoints.ToString();

            bool showBat      = false;
            bool showGhost    = false;
            bool showGhoul    = false;
            int  enemiesShown = 0;

            // Check if enemies are still alive.  If so, set their show variable to true.
            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++;
                    }
                }

                if (enemy is Ghost)
                {
                    ghost.Location      = enemy.Location;
                    ghostHitPoints.Text = enemy.HitPoints.ToString();
                    if (enemy.HitPoints > 0)
                    {
                        showGhost = true;
                        enemiesShown++;
                    }
                }

                if (enemy is Ghoul)
                {
                    ghoul.Location      = enemy.Location;
                    ghoulHitPoints.Text = enemy.HitPoints.ToString();
                    if (enemy.HitPoints > 0)
                    {
                        showGhoul = true;
                        enemiesShown++;
                    }
                }
            }

            //Sets visibility of enemy objects based on conditions above
            if (showBat == false)
            {
                bat.Visible          = false;
                batHitPoints.Visible = false;
                batLabel.Visible     = false;
            }
            else
            {
                bat.Visible          = true;
                batHitPoints.Visible = true;
                batLabel.Visible     = true;
            }

            if (showGhost == false)
            {
                ghost.Visible          = false;
                ghostHitPoints.Visible = false;
                ghostLabel.Visible     = false;
            }
            else
            {
                ghost.Visible          = true;
                ghostHitPoints.Visible = true;
                ghostLabel.Visible     = true;
            }

            if (showGhoul == false)
            {
                ghoul.Visible          = false;
                ghoulHitPoints.Visible = false;
                ghoulLabel.Visible     = false;
            }
            else
            {
                ghoul.Visible          = true;
                ghoulHitPoints.Visible = true;
                ghoulLabel.Visible     = false;
            }

            // Makes weapon icons invisible in game window
            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;
            }
            weaponControl.Visible = true;

            //Setting intitial attack button text and visibility
            attackUp.Text       = "↑";
            attackRight.Visible = true;
            attackDown.Visible  = true;
            attackLeft.Visible  = true;

            //Setting weapon inventory visibility in game window
            if (game.CheckPlayerInventory("Sword"))
            {
                swordInventory.Visible = true;
            }
            else
            {
                swordInventory.Visible = false;
            }

            if (game.CheckPlayerInventory("Bow"))
            {
                bowInventory.Visible = true;
            }
            else
            {
                bowInventory.Visible = false;
            }

            if (game.CheckPlayerInventory("Mace"))
            {
                maceInventory.Visible = true;
            }
            else
            {
                maceInventory.Visible = false;
            }

            if (game.CheckPlayerInventory("Blue Potion"))
            {
                bluePotionInventory.Visible = true;
            }
            else
            {
                bluePotionInventory.Visible = false;
            }

            if (game.CheckPlayerInventory("Red Potion"))
            {
                redPotionInventory.Visible = true;
            }
            else
            {
                redPotionInventory.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 && game.Level < 8)
            {
                MessageBox.Show("You have defeated the enemies on this level");
                game.NewLevel(random);
                UpdateCharacters();
            }
        }
Пример #19
0
        private void UpdateCharacters()
        {
            playerImg.Location = game.PlayerLocation;
            labelPlayerHP.Text = game.PlayerHitPoints.ToString();
            //Enemies
            bool showBat      = false;
            bool showGhost    = false;
            bool showGhoul    = false;
            int  enemiesShown = 0;

            foreach (Enemy enemy in game.Enemies)
            {
                if (enemy is Bat)
                {
                    batField.Location = enemy.Location;
                    labelBatHP.Text   = enemy.HitPoints.ToString();
                    if (enemy.HitPoints > 0)
                    {
                        showBat = true;
                        enemiesShown++;
                    }
                }
                if (enemy is Ghost)
                {
                    ghostField.Location = enemy.Location;
                    labelGhostHP.Text   = enemy.HitPoints.ToString();
                    if (enemy.HitPoints > 0)
                    {
                        showGhost = true;
                        enemiesShown++;
                    }
                }
                if (enemy is Ghoul)
                {
                    ghoulField.Location = enemy.Location;
                    labelGhoulHP.Text   = enemy.HitPoints.ToString();
                    if (enemy.HitPoints > 0)
                    {
                        showGhoul = true;
                        enemiesShown++;
                    }
                }
            }

            if (!showBat)
            {
                batField.Visible = false;
                labelBatHP.Text  = "";
            }
            else
            {
                batField.Visible = true;
            }
            if (!showGhost)
            {
                ghostField.Visible = false;
                labelGhostHP.Text  = "";
            }
            else
            {
                ghostField.Visible = true;
            }
            if (!showGhoul)
            {
                ghoulField.Visible = false;
                labelGhoulHP.Text  = "";
            }
            else
            {
                ghoulField.Visible = true;
            }

            //Weapons
            swordField.Visible      = false;
            bowField.Visible        = false;
            redPotionField.Visible  = false;
            bluePotionField.Visible = false;
            maceField.Visible       = false;
            Control weaponControl = null;

            switch (game.WeaponInRoom.Name)
            {
            case "Sword":
                weaponControl = swordField; break;

            case "Bow":
                weaponControl = bowField; break;

            case "Red Potion":
                weaponControl = redPotionField; break;

            case "Blue Potion":
                weaponControl = bluePotionField; break;

            case "Mace":
                weaponControl = maceField; break;

            default:
                break;
            }
            weaponControl.Visible = true;
            //Inventory
            swordInventory.Visible      = false;
            bowInventory.Visible        = false;
            maceInventory.Visible       = false;
            redPotionInventory.Visible  = false;
            bluePotionInventory.Visible = false;
            if (game.CheckPlayerInventory("Sword"))
            {
                swordInventory.Visible = true;
            }
            if (game.CheckPlayerInventory("Bow"))
            {
                bowInventory.Visible = true;
            }
            if (game.CheckPlayerInventory("Mace"))
            {
                maceInventory.Visible = true;
            }
            if (game.CheckPlayerInventory("Red Potion"))
            {
                redPotionInventory.Visible = true;
            }
            if (game.CheckPlayerInventory("Blue Potion"))
            {
                bluePotionInventory.Visible = true;
            }
            //Check if weapon was picked up
            weaponControl.Location = game.WeaponInRoom.Location;
            if (game.WeaponInRoom.PickedUp)
            {
                weaponControl.Visible = false;
            }
            else
            {
                weaponControl.Visible = true;
            }
            //Check if player died
            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();
            }
        }
Пример #20
0
        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();
            }
        }
Пример #21
0
        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();
            }
        }
Пример #22
0
 private void Form1_Load(object sender, EventArgs e)
 {
     game = new Game(new Rectangle(53, 40, 310, 115));
     game.NewLevel(random);
     UpdateCharacters();
 }
Пример #23
0
        public void UpdateCharacters()
        {
            //Update the player’s position and stats.
            playerIcon.Location  = game.PlayerLocation;
            playerHitPoints.Text = game.PlayerHitPoints.ToString();

            bool showBat   = false;
            bool showGhost = false;
            bool showGhoul = false;

            int enemiesShown = 0;

            batHitPoints.Visible   = false;
            batLabel.Visible       = false;
            ghostHitPoints.Visible = false;
            ghostLabel.Visible     = false;
            ghoulHitPoints.Visible = false;
            ghoulLabel.Visible     = false;


            //Update each enemy’s location and hit points

            foreach (Enemy enemy in game.Enemies)
            {
                if (enemy is Bat)
                {
                    batIcon.Location  = enemy.Location;
                    batHitPoints.Text = enemy.HitPoints.ToString();
                    if (enemy.HitPoints > 0)
                    {
                        showBat = true;
                        enemiesShown++;
                    }
                }

                if (enemy is Ghost)
                {
                    ghostIcon.Location  = enemy.Location;
                    ghostHitPoints.Text = enemy.HitPoints.ToString();
                    if (enemy.HitPoints > 0)
                    {
                        showGhost = true;
                        enemiesShown++;
                    }
                }

                if (enemy is Ghoul)
                {
                    ghoulIcon.Location  = enemy.Location;
                    ghoulHitPoints.Text = enemy.HitPoints.ToString();
                    if (enemy.HitPoints > 0)
                    {
                        showGhoul = true;
                        enemiesShown++;
                    }
                }
            }

            batHitPoints.Visible = showBat;
            batLabel.Visible     = showBat;
            batIcon.Visible      = showBat;

            ghostHitPoints.Visible = showGhost;
            ghostLabel.Visible     = showGhost;
            ghostIcon.Visible      = showGhost;

            ghoulHitPoints.Visible = showGhoul;
            ghoulLabel.Visible     = showGhoul;
            ghoulIcon.Visible      = showGhoul;


            //Update the weapon PictureBoxes

            swordIcon.Visible      = false;
            bowIcon.Visible        = false;
            redPotionIcon.Visible  = false;
            bluePotionIcon.Visible = false;
            maceIcon.Visible       = false;
            Control weaponControl = null;

            if (game.WeaponInRoom != null)
            {
                switch (game.WeaponInRoom.Name)
                {
                case "Sword":
                    weaponControl = swordIcon; break;

                case "Bow":
                    weaponControl = bowIcon; break;

                case "Mace":
                    weaponControl = maceIcon; break;

                case "Red Potion":
                    weaponControl = redPotionIcon; break;

                case "Blue Potion":
                    weaponControl = bluePotionIcon; break;
                }
            }

            if (weaponControl != null)
            {
                weaponControl.Visible = true;
            }


            //Set the Visible property on each inventory icon PictureBox
            inventorySword.Visible      = game.CheckPlayerInventory("Sword");
            inventoryBow.Visible        = game.CheckPlayerInventory("Bow");
            inventoryMace.Visible       = game.CheckPlayerInventory("Mace");
            inventoryRedPotion.Visible  = game.CheckPlayerInventory("Red Potion");
            inventoryBluePotion.Visible = game.CheckPlayerInventory("Blue Potion");

            if (game.CheckPlayerInventory("Sword") && game.PlayerWeapons.Count() == 1)
            {
                inventorySword.BorderStyle = BorderStyle.FixedSingle;
            }

            //The rest of the method does three things. First, it checks to see if the player’s already
            //picked up the weapon in the room, so it knows whether or not to display it. Then it
            //checks to see if the player died. And finally, it checks to see if the player’s defeated all of
            //the enemies. If he has, then the player advances to the next level.
            if (game.WeaponInRoom != 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");
                Application.Exit();
            }
            if (enemiesShown < 1)
            {
                MessageBox.Show("You have defeated the enemies on this level");
                game.NewLevel(random);
                if (game.Level <= 7)
                {
                    UpdateCharacters();
                }
            }
            this.Text = "The Quest: level " + game.Level;
        }
Пример #24
0
        private void Form1_Load(object sender, EventArgs e)
        {
            // Set offset of top-left corner of icon to center
            iconOffset.X = player.Width / 2;
            iconOffset.Y = player.Height / 2;

            // Initialize game object
            game = new Game(new Rectangle(78 + iconOffset.X, 57 + iconOffset.Y, 423, 161));
            game.NewLevel(random);

            // Set characters in the game
            UpdateCharacters();

            // Initialize controls
            RemoveAllInventorySelections();
            SetMoveDirections();
            SetAttackDirections();
            SetLevelLabel();
            grpbBoxPlayStyle.Visible = false;
            actionTimer.Interval = gameSpeed;
        }
Пример #25
0
 private void GUI_Load(object sender, EventArgs e)
 {
     _game = new Game(new Rectangle(78, 57, 420, 155));
     _game.NewLevel(_random);
     UpdateGame();
 }