Пример #1
0
        private void DisplayInventory()
        {
            if (game.CheckPlayerInventory("Sword"))
            {
                inventorySwordPB.Visible = true;
            }

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

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

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

            if (game.CheckPlayerInventory("Red Potion"))
            {
                inventoryRedPotionPB.Visible = true;
            }
        }
Пример #2
0
 private void SelectInventoryItem(PictureBox item, string itemName, string weaponType)
 {
     if (_game.CheckPlayerInventory(itemName))
     {
         _game.Equip(itemName);
         RemoveInventoryBorders();
         item.BorderStyle = BorderStyle.FixedSingle;
         SetupAttackButtons(weaponType);
         RemoveInventoryBorders();
     }
 }
Пример #3
0
        private void UpdateInventory(string weaponName)
        {
            Control control = null;

            switch (weaponName)
            {
            case "Red Potion":
                control = RedPotionInvSprite;

                break;

            case "Blue Potion":
                control = BluePotionInvSprite;
                game.Equip("Blue Potion");
                break;

            case "Sword":
                control = SwordInvSprite;
                break;

            case "Bow":
                control = BowInvSprite;
                break;

            case "Mace":
                control = MaceInvSprite;
                break;
            }

            if (game.CheckPlayerInventory(weaponName))
            {
                control.Visible = true;
                if (weaponName == "Red Potion")
                {
                    game.Equip("Red Potion");
                }
                else if (weaponName == "Blue Potion")
                {
                    game.Equip("Blue Potion");
                }
            }
            if (game.PlayerEquippedWeapon != null)
            {
                if (game.PlayerEquippedWeapon.Name == weaponName)
                {
                    control.BackColor = Color.Blue;
                }
            }
        }
Пример #4
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;

            // 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();
                }
            }
        }
Пример #5
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++;
                    }
                }

                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();
            }
        }
Пример #6
0
 // if player clicks sword button
 void InvSwordClick(object sender, EventArgs e)
 {
     if (game.CheckPlayerInventory("Sword"))
     {
         SwapWeapons("Sword");
     }
 }