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"); } }
public bool EquipTome(int itemLoc) { if (playerInv.items[itemLoc] is Tome) { if (equipedTome == null) { equipedTome = (Tome)playerInv.items[itemLoc]; playerInv.RemoveItem(itemLoc, 1); equipedTome.OnEquip(); } else { playerInv.AddItem(equipedTome); equipedTome.OnUnequip(); equipedTome = (Tome)playerInv.items[itemLoc]; equipedTome.OnEquip(); playerInv.RemoveItem(itemLoc, 1); } return(true); } else { return(false); } }
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)); } } }