Ejemplo n.º 1
0
 public void SetWeapon(Weapon weapon)
 {
     try
     {
         if (this.Weapon == null)
         {
             this.Weapon = weapon;
         }
         else
         {
             throw new WeaponException("You already have weapon");
         }
     }
     catch (WeaponException)
     {
         if (this.Weapon.AttackPoints < weapon.AttackPoints)
         {
             this.Weapon = weapon;
         }
     }
 }
Ejemplo n.º 2
0
        private Item GetItem(int numOfItems)
        {
            var rngNum = RandomGenerator.Randomize(1, 100);
            var rarity = Rarity.GetRandomRarity();
            var rarityType = rarity.Keys.First();
            var rarityCoef = rarity.Values.First();
            var dropX = (int)this.Velocity.X + this.Width / (2 - numOfItems) - KufTheGame.ItemSize / 2;
            var dropY = (int)this.Velocity.Y + this.Height / 2 - KufTheGame.ItemSize / 2;

            if (rngNum <= 25)
            {
                var weaponType = RandomGenerator.GetRandomItem<Weapons>();
                var wep = new Weapon(dropX, dropY, KufTheGame.ItemSize, KufTheGame.ItemSize, rarityType, weaponType, 10 * rarityCoef);
                return wep;
            }

            if (rngNum > 25 && rngNum <= 65)
            {
                var armorType = RandomGenerator.GetRandomItem<Armors>();
                var armor =
                    new Armor(dropX, dropY, KufTheGame.ItemSize, KufTheGame.ItemSize, rarityType, armorType, 5 * rarityCoef);
                return armor;
            }

            if (rngNum > 65)
            {
                var rngPotionNum = RandomGenerator.Randomize(1, 100);
                if (rngPotionNum <= 40)
                {
                    var potion =
                        new ImmortalilyPotion(dropX, dropY, KufTheGame.ItemSize, KufTheGame.ItemSize, rarityType, (int)(150 * rarityCoef));
                    return potion;
                }

                if (rngPotionNum > 40)
                {
                    var potion =
                        new HealthPotion(dropX, dropY, KufTheGame.ItemSize, KufTheGame.ItemSize, rarityType, 10 * rarityCoef);
                    return potion;
                }
            }

            return null;
        }
Ejemplo n.º 3
0
 public void RemoveWeapon()
 {
     this.Weapon = null;
 }