Ejemplo n.º 1
0
        public void AddLootItem(int level, int lootPosX, int lootPosY)
        {
            for (int i = 0; i < lootItems.Count; i++)
            {
                if (lootItems[i].X == lootPosX && lootItems[i].Y == lootPosY)
                {
                    lootItems[i].X = -10;
                    lootItems[i].Y = -10;
                }
            }

            ItemType temp = Util.Choose(
                new ItemType[] { ItemType.Gold, ItemType.Weapon, ItemType.Armor, ItemType.Potion, ItemType.Ring, ItemType.Amulet, ItemType.Tome },
                new float[] { 0.2f, 0.15f, 0.15f, 0.2f, 0.15f, 0.1f, 0.05f }, Game.g.rng);

            level = Util.Choose(new int[] { level, level + 1 }, new float[] { 0.95f, 0.05f }, Game.g.rng);

            int  goldAmount = 0;
            bool gotGold    = false;

            if (temp == ItemType.Gold)
            {
                goldAmount = Game.g.rng.Next(10, 10 + (int)(level * 3.653));
                playerInv.currentGoldAmount += goldAmount;
                gotGold = true;
            }
            else if (temp == ItemType.Weapon)
            {
                playerInv.AddItem(Weapon.GenerateWeapon(level));
            }
            else if (temp == ItemType.Armor)
            {
                playerInv.AddItem(Armor.GenerateArmor(level));
            }
            else if (temp == ItemType.Ring)
            {
                playerInv.AddItem(Ring.GenerateRing(level));
            }
            else if (temp == ItemType.Amulet)
            {
                playerInv.AddItem(Amulet.GenerateAmulet(level));
            }
            else if (temp == ItemType.Potion)
            {
                playerInv.AddItem(Potion.GeneratePotion(level));
            }
            else if (temp == ItemType.Tome)
            {
                playerInv.AddItem(Tome.GenerateTome(level));
            }

            if (!gotGold)
            {
                Game.g.LogCombat("Picked up " + playerInv[playerInv.Count - 1]);
            }
            else
            {
                Game.g.LogCombat("Picked up " + goldAmount + " gold");
            }
        }
Ejemplo n.º 2
0
        public bool EquipAmulet(int itemLoc)
        {
            if (playerInv.items[itemLoc] is Amulet)
            {
                if (equipedAmulet == null)
                {
                    equipedAmulet = (Amulet)playerInv.items[itemLoc];
                    playerInv.RemoveItem(itemLoc, 1);
                    equipedAmulet.OnEquip();
                }
                else
                {
                    playerInv.AddItem(equipedAmulet);
                    equipedAmulet.OnUnequip();
                    equipedAmulet = (Amulet)playerInv.items[itemLoc];
                    equipedAmulet.OnEquip();
                    playerInv.RemoveItem(itemLoc, 1);
                }

                return(true);
            }
            else
            {
                return(false);
            }
        }
Ejemplo n.º 3
0
        public void Buy(int level)
        {
            if (playerInv.currentGoldAmount >= 100)
            {
                playerInv.currentGoldAmount -= 100;

                ItemType temp = Util.Choose(
                    new ItemType[] { ItemType.Gold, ItemType.Weapon, ItemType.Armor, ItemType.Potion, ItemType.Ring, ItemType.Amulet, ItemType.Tome },
                    new float[] { 0.0f, 0.15f, 0.15f, 0.3f, 0.15f, 0.15f, 0.10f }, Game.g.rng);

                level = Util.Choose(new int[] { level, level + 1 }, new float[] { 0.95f, 0.05f }, Game.g.rng);

                if (temp == ItemType.Weapon)
                {
                    playerInv.AddItem(Weapon.GenerateWeapon(level));
                }
                else if (temp == ItemType.Armor)
                {
                    playerInv.AddItem(Armor.GenerateArmor(level));
                }
                else if (temp == ItemType.Ring)
                {
                    playerInv.AddItem(Ring.GenerateRing(level));
                }
                else if (temp == ItemType.Amulet)
                {
                    playerInv.AddItem(Amulet.GenerateAmulet(level));
                }
                else if (temp == ItemType.Potion)
                {
                    playerInv.AddItem(Potion.GeneratePotion(level));
                }
                else if (temp == ItemType.Tome)
                {
                    playerInv.AddItem(Tome.GenerateTome(level));
                }
            }
        }