Exemplo n.º 1
0
        private void UpdateWeaponCtrl(ref int weaponFlag, ref List <bool> list, Weapon weapon)
        {
            Control weaponCtrl = null;

            switch (weapon.Name)
            {
            case "Red Potion":
                weaponFlag += (int)TypeWeapon.REDPOTION;
                weaponCtrl  = RedPotionSprite;
                break;

            case "Blue Potion":
                weaponFlag += (int)TypeWeapon.BLUEPOTION;
                weaponCtrl  = BluePotionSprite;
                break;

            case "Sword":
                weaponFlag += (int)TypeWeapon.SWORD;
                weaponCtrl  = SwordSprite;
                break;

            case "Bow":
                weaponFlag += (int)TypeWeapon.BOW;
                weaponCtrl  = BowSprite;
                break;

            case "Mace":
                weaponFlag += (int)TypeWeapon.MACE;
                weaponCtrl  = MaceSprite;
                break;
            }

            if (game.WeaponsInRoom.Contains(weapon))
            {
                int idx = (int)Math.Log(weaponFlag, 2);
                if (weaponInRoomCtrl[idx].Visible == false)
                {
                    weaponInRoomCtrl[idx].Visible = true;
                }

                Rectangle playerRect = new Rectangle(PlayerSprite.Location, PlayerSprite.Size);
                Rectangle weaponRect = new Rectangle(weaponInRoomCtrl[idx].Location, weaponInRoomCtrl[idx].Size);
                Rectangle intersec   = Rectangle.Intersect(playerRect, weaponRect);
                if (intersec.IsEmpty == false)
                {
                    game.AcquireWeapon(weapon);
                    weaponInRoomCtrl[idx].Visible = false;
                    UpdateInventory(weapon.Name);
                }
            }
        }