public ChestButton(Chunk chunk, Vector2 vector, Inventory inventory)
            : base(vector,"      ", chunk.getColor())
        {
            setAction(new SetLootInventoryAction(inventory, chunk));

            this.chunk = chunk;
        }
        public SquareChestChunk(int chunkPos, int baseHeight)
            : base(chunkPos, baseHeight)
        {
            inventory = new Inventory();
            inventory.add(ItemFactoryManager.getInstance().createWeapon());
            inventory.add(ItemFactoryManager.getInstance().generateHealthPotion());
            chestButton = new ChestButton(this, Vector2.Zero, inventory);

            Random rand = new Random(new Guid().GetHashCode());

            int bonus = rand.Next(8);

            if (bonus == 6)
            {
                inventory.add(ItemFactoryManager.getInstance().generateAmmoPack());
            }
            else if (bonus == 3)
            {
                inventory.add(ItemFactoryManager.getInstance().generateHealthPotion());
            }
        }
 public SetLootInventoryAction(Inventory inventory, Chunk chunk)
 {
     this.inventory = inventory;
     this.chunk = chunk;
 }
示例#4
0
 public bool isInInventory(Inventory inventory)
 {
     return ItemFactoryManager.getInstance().getItemInventoryHash(this).Equals(inventory.getInventoryHash());
 }
 /// <summary>
 /// Sets the current inventory being read from.
 /// </summary>
 /// <param name="loot"></param>
 public void setLootInventory(Inventory loot)
 {
     otherInventory = loot;
     refreshInventories();
 }
 public SquareChestChunk(int chunkPos, int baseHeight, String inventory)
     : base(chunkPos, baseHeight)
 {
     this.inventory = new Inventory(10, inventory);
     chestButton = new ChestButton(this, Vector2.Zero, this.inventory);
 }
        //moves the item to the inventory
        public bool moveItem(Item item, Inventory inventory)
        {
            item.activateEffects(false);
            item.activateEffects(true);
            int itemCount = inventoryToItems[inventory.getInventoryHash()].Count;
            if (itemCount < inventory.getMaximumSize())
                return moveItem(item, inventory.getInventoryHash());

            return false;
        }
 //creates weapon, puts it into the inventory
 public Item createWeapon(String XMLFile, Inventory inventory)
 {
     Item result = createWeapon(XMLFile);
     moveItem(result, inventory);
     return result;
 }
        //creates the random weapon and puts into inventory
        public Item createWeapon(Inventory inventory)
        {
            String itemHash = generateRandomHash();

            //create the weapon
            items[itemHash] = itemFactory.createWeapon(itemHash);

            inventory.add(items[itemHash]);

            return items[itemHash];
        }
 //creates the item, puts it into the inventory
 public Item createItem(String XMLFile, Inventory inventory)
 {
     return createItem(XMLFile, inventory.getInventoryHash());
 }