Ejemplo n.º 1
0
 internal void GenerateGroundItems(ItemChest chest, ScrollingGrid grid)
 {
     if (displayInventory && chest != null)
     {
         currentChest = chest;
         Inventory inv = chest.Location.inventory;
         GroundLabel.SetActive(true);
         grid.gameObject.SetActive(true);
         grid.Clear();
         foreach (InventoryCategory ic in inv.Values)
         {
             foreach (Item item in ic.Values)
             {
                 CreateItemButton(item, grid);
             }
         }
         CreateCloseLabel(grid);
         grid.ResetPosition();
         grid.Reposition();
     }
     else
     {
         GroundLabel.SetActive(false);
         grid.Clear();
         RegenItemInfoGUI(null);
     }
 }
Ejemplo n.º 2
0
    public ItemChest SpawnItemChest()
    {
        ItemChest new_item_chest = Instantiate(item_chest, transform.parent.transform);

        new_item_chest.transform.position = transform.position;
        Destroy(gameObject);
        return(new_item_chest);
    }
Ejemplo n.º 3
0
 internal void PutInventory(Item i)
 {
     if (_chest == null)
     {
         _chest = (GameObject.Instantiate(BigBoss.Gooey.ChestPrefab,
                                          (Blocks[0].transform.position + BigBoss.Gooey.ChestPrefab.transform.position),
                                          BigBoss.Gooey.ChestPrefab.transform.localRotation) as GameObject).GetComponent <ItemChest>();
         //_chest.Location = this;
         _chest.init();
     }
     inventory.Add(i);
 }
Ejemplo n.º 4
0
 internal bool RemoveInventory(Item i)
 {
     if (_chest != null)
     {
         inventory.Remove(i);
         if (inventory.IsEmpty())
         {
             GameObject.Destroy(_chest.gameObject);
             _chest = null;
             return(true);
         }
     }
     return(false);
 }
    public static void Main(string[] args)
    {
        // Create some chests:
        ItemChest swordChest  = new ItemChest("Sword Chest");
        ItemChest armorChest  = new ItemChest("Armor Chest");
        ItemChest potionChest = new ItemChest("Potions");
        ItemChest otherItems  = new ItemChest("Misc.");

        // Create the chain of responsibility:
        ChestSorter swords  = new ChestSorter(swordChest, ItemType.Sword);
        ChestSorter armor   = new ChestSorter(armorChest, ItemType.Armor);
        ChestSorter potions = new ChestSorter(potionChest, ItemType.Potion);
        // Null sorter for item's that don't have an explicit chest:
        ChestSorter other = new NullSorter(otherItems);

        // Link the chains:
        swords.SetNext(armor);
        armor.SetNext(potions);
        potions.SetNext(other);

        // Pointer to the head of the list:
        // Implementation note: You can create another class to maintain all the sorting items!
        ChestSorter sortingMachine = swords;

        // Insert a few items into the sorting machine:
        sortingMachine.Handle(new EquipmentItem("Mighty Sword", ItemType.Sword));
        sortingMachine.Handle(new EquipmentItem("Potion of life", ItemType.Potion));
        sortingMachine.Handle(new EquipmentItem("Blade of infinity", ItemType.Sword));
        sortingMachine.Handle(new EquipmentItem("Hockey Pads", ItemType.Armor));
        sortingMachine.Handle(new EquipmentItem("Scroll of a thousand truths", ItemType.QuestItem));
        sortingMachine.Handle(new EquipmentItem("Isildur's Bane", ItemType.Ring));

        // Display all the chests' contents:
        sortingMachine.PrintChain();

        /*
         *  Output:
         *      Items in Sword Chest:
         *          Mighty Sword
         *          Blade of infinity
         *      Items in Armor Chest:
         *          Hockey Pads
         *      Items in Potions:
         *          Potion of life
         *      Items in Misc.:
         *          Scroll of a thousand truths
         *          Isildur's Bane
         */
    }
    public override void Init()
    {
        base.Init();

        foreach (Transform t in chest_spawns)
        {
            if (RNGSingleton.instance.room_gen_rng.GetFloat() < 0.67)
            {
                PickupChest new_chest = Instantiate(pickup_chest_prefab);
                new_chest.transform.position = t.position;
                new_chest.SetSpawnPickups(LootTablesSingleton.instance.regular_chest_loot.GetPilePickups(RNGSingleton.instance.loot_rng));
                new_chest.SetOpenToPlayer(true);
            }
            else
            {
                ItemChest new_chest = Instantiate(item_chest_prefab);
                new_chest.transform.position = t.position;
                new_chest.SetSpawnItem(ItemListSingleton.instance.GetRandomItem(RNGSingleton.instance.item_rng));
            }
        }
        timed_door.enabled = false;
        timed_door.SetTimerDisplay(countdown_length);
    }
 public ChestSorter(ItemChest chest, ItemType sortType)
 {
     this.chest    = chest;
     this.sortType = sortType;
 }
 public NullSorter(ItemChest chest) : base(chest, ItemType.Undefined)
 {
 }
Ejemplo n.º 9
0
 public void OpenGroundGUI(ItemChest chest)
 {
     displayInventory = true;
     GenerateGroundItems(chest, GroundItemsGrid);
 }