예제 #1
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="item"></param>
 /// <returns>
 /// The address of the inventory slot the item has be placed in. Returns
 /// null if the item was not placed (i.e. inventory is full)
 /// </returns>
 public InventoryAddress Keep(Item item)
 {
     for (int page = 0; page < Storage.GetLength(0); page++)
     {
         for (int row = 0; row < Storage.GetLength(2); row++)
         {
             for (int col = 0; col < Storage.GetLength(1); col++)
             {
                 if (Storage[page, col, row] == null)
                 {
                     Storage[page, col, row] = item;
                     Inbox.Remove(item);
                     return(InventoryAddress.NewStorageAddress(page, col, row));
                 }
             }
         }
     }
     return(null);
 }
예제 #2
0
 private IAcceptsItems GetInventorySlot(InventoryAddress inventoryAddress)
 {
     if (inventoryAddress.InventorySection == InventorySection.Equipment)
     {
         return(EquipmentSlots[inventoryAddress.EquipmentIndex]);
     }
     else if (inventoryAddress.InventorySection == InventorySection.Storage)
     {
         if (inventoryAddress.StoragePage != CurrentStoragePage)
         {
             Debug.LogError("InventoryGUIController tried accessing a storage slot on an inactive page");
         }
         return(StorageSlots[inventoryAddress.StorageColumn, inventoryAddress.StorageRow]);
     }
     else
     {
         return(null);
     }
 }
예제 #3
0
    private void InitializeStorageSlots()
    {
        Vector2 sizeDelta = StorageContent.GetComponent <RectTransform>().sizeDelta;

        sizeDelta.y = GameManager.Instance.Player.Inventory.Storage.GetLength(2) * 74 - 10;
        StorageContent.GetComponent <RectTransform>().sizeDelta = sizeDelta;

        StorageSlots = new StorageSlotController[GameManager.Instance.Player.Inventory.Storage.GetLength(1), GameManager.Instance.Player.Inventory.Storage.GetLength(2)];
        for (int col = 0; col < StorageSlots.GetLength(0); col++)
        {
            for (int row = 0; row < StorageSlots.GetLength(1); row++)
            {
                GameObject newStorageSlot = Instantiate(StorageSlotPrefab, StorageContent.transform);
                newStorageSlot.GetComponent <RectTransform>().anchoredPosition = new Vector2(col * 74, -row * 74);
                InventoryAddress address = InventoryAddress.NewStorageAddress(CurrentStoragePage, col, row);
                newStorageSlot.GetComponent <StorageSlotController>().Initialize(this, address, GameManager.Instance.Player.Inventory.Storage[CurrentStoragePage, col, row]);
                StorageSlots[col, row] = newStorageSlot.GetComponent <StorageSlotController>();
            }
        }
    }
예제 #4
0
 private void Awake()
 {
     InventoryAddress = InventoryAddress.NewEquipmentAddress(EquipmentIndex);
 }