public IEnumerator Start() { pool = new InventoryPool<InventoryUIItemWrapper>(wrapperPrefab, 8); queue = new Queue<ItemHolder>(8); destroyTimer = new WaitForSeconds(slideAnimation.length - 0.025f); offsetTimer = new WaitForSeconds(offsetTimerSeconds); foreach (var inv in InventoryManager.GetLootToCollections()) { inv.OnAddedItem += (items, amount, cameFromCollection) => { if (cameFromCollection == false) { queue.Enqueue(new ItemHolder() { item = items.FirstOrDefault(), stackSize = amount}); } }; } while (true) { if (queue.Count > 0) { ShowItem(queue.Peek().item, queue.Peek().stackSize); queue.Dequeue(); // Remove it } yield return offsetTimer; } }
public virtual void Awake() { window = GetComponent<UIWindow>(); pool = new InventoryPool<InventoryContextMenuItem>(contextMenuItemPrefab, 8); window.OnShow += window_OnWindowShow; }
public virtual void Awake() { pool = new InventoryPool<NoticeMessageUI>(noticeRowPrefab, maxMessages); }
public virtual void Awake() { if (blueprintCategoryPrefab != null) categoryPool = new InventoryPool<InventoryCraftingCategoryUI>(blueprintCategoryPrefab, 16); #if UNITY_EDITOR if (blueprintButtonPrefab == null) Debug.LogWarning("Blueprint button prefab is empty in CraftingWindowStandardUI", gameObject); if (blueprintRequiredItemPrefab == null) Debug.LogWarning("Blueprint required item prefab is empty in CraftingWindowStandardUI", gameObject); #endif blueprintPool = new InventoryPool<InventoryCraftingBlueprintUI>(blueprintButtonPrefab, 128); blueprintRequiredItemsPool = new InventoryPool<InventoryUIItemWrapper>(blueprintRequiredItemPrefab, 8); if (defaultCategoryID >= 0 && defaultCategoryID <= ItemManager.instance.craftingCategories.Length - 1) currentCategory = defaultCategory; if(blueprintMinCraftButton != null) { blueprintMinCraftButton.onClick.AddListener(() => { if(Input.GetKey(KeyCode.LeftShift)) blueprintCraftAmountInput.text = (GetCraftInputFieldAmount() - 10).ToString(); else blueprintCraftAmountInput.text = (GetCraftInputFieldAmount() - 1).ToString(); ValidateCraftInputFieldAmount(); }); } if(blueprintPlusCraftButton != null) { blueprintPlusCraftButton.onClick.AddListener(() => { if (Input.GetKey(KeyCode.LeftShift)) blueprintCraftAmountInput.text = (GetCraftInputFieldAmount() + 10).ToString(); else blueprintCraftAmountInput.text = (GetCraftInputFieldAmount() + 1).ToString(); ValidateCraftInputFieldAmount(); }); } blueprintCraftButton.onClick.AddListener(() => CraftItem(currentCategory, currentBlueprint, GetCraftInputFieldAmount())); window.OnShow += () => { if(currentCategory != null) SetCraftingCategory(currentCategory); if (currentBlueprint != null) SetBlueprint(currentBlueprint); }; window.OnHide += CancelActiveCraft; foreach (var col in InventoryManager.GetLootToCollections()) { col.OnAddedItem += (InventoryItemBase item, uint slot, uint amount) => { if(currentBlueprint != null) SetBlueprint(currentBlueprint); }; col.OnRemovedItem += (uint itemID, uint slot, uint amount) => { if (currentBlueprint != null) SetBlueprint(currentBlueprint); }; col.OnDroppedItem += (InventoryItemBase item, uint slot, GameObject droppedObj) => { CancelActiveCraft(); // If the user drops something. if (currentBlueprint != null) SetBlueprint(currentBlueprint); }; } InventoryManager.instance.inventory.OnGoldChanged += (float added) => { if (currentBlueprint != null) SetBlueprint(currentBlueprint); }; }
protected virtual void Awake() { currentTransform = GetComponent<RectTransform>(); defaultPivot = currentTransform.pivot; window = GetComponent<UIWindow>(); pool = new InventoryPool<InfoBoxRowUI>(infoBoxRowPrefab, 32); poolObjs = new InventoryPool(separatorPrefab, 8); poolCategoryBoxes = new InventoryPool(infoBoxCategory, 8); // Safety checks if (GetComponent<InventoryUIItemWrapperBase>() != null && GetComponent<InventoryUIItemWrapperStatic>() == null) { Debug.LogError("Using a InventoryUIItemWrapperBase in the InfoBoxUI, use an InventoryUIItemWrapperStatic instead.", transform); } }
public override void Awake() { //base.Awake(); if (blueprintCategoryPrefab != null) categoryPool = new InventoryPool<InventoryCraftingCategoryUI>(blueprintCategoryPrefab, 16); #if UNITY_EDITOR if (blueprintButtonPrefab == null) Debug.LogWarning("Blueprint button prefab is empty in CraftingWindowStandardUI", gameObject); if (blueprintRequiredItemPrefab == null) Debug.LogWarning("Blueprint required item prefab is empty in CraftingWindowStandardUI", gameObject); if(blueprintCraftButton == null) Debug.LogWarning("Blueprint craft button is requred", gameObject); #endif blueprintPool = new InventoryPool<InventoryCraftingBlueprintUI>(blueprintButtonPrefab, 128); blueprintRequiredItemsPool = new InventoryPool<InventoryUIItemWrapper>(blueprintRequiredItemPrefab, 8); if (craftingCategoryID >= 0 && craftingCategoryID <= ItemManager.instance.craftingCategories.Length - 1) currentCategory = craftingCategory; if(blueprintMinCraftButton != null) { blueprintMinCraftButton.onClick.AddListener(() => { if(Input.GetKey(KeyCode.LeftShift)) blueprintCraftAmountInput.text = (GetCraftInputFieldAmount() - 10).ToString(); else blueprintCraftAmountInput.text = (GetCraftInputFieldAmount() - 1).ToString(); ValidateCraftInputFieldAmount(); }); } if(blueprintPlusCraftButton != null) { blueprintPlusCraftButton.onClick.AddListener(() => { if (Input.GetKey(KeyCode.LeftShift)) blueprintCraftAmountInput.text = (GetCraftInputFieldAmount() + 10).ToString(); else blueprintCraftAmountInput.text = (GetCraftInputFieldAmount() + 1).ToString(); ValidateCraftInputFieldAmount(); }); } blueprintCraftButton.onClick.AddListener(() => CraftItem(currentCategory, currentBlueprint, GetCraftInputFieldAmount())); }
void Awake() { currentTransform = GetComponent<RectTransform>(); defaultPivot = currentTransform.pivot; window = GetComponent<UIWindow>(); pool = new InventoryPool<InfoBoxRowUI>(infoBoxRowPrefab, 32); poolObjs = new InventoryPool(separatorPrefab, 8); poolCategoryBoxes = new InventoryPool(infoBoxCategory, 8); }
public override void Awake() { equipSlotFields = container.GetComponentsInChildren<InventoryEquippableField>(true); characterStats = new Dictionary<string, List<InventoryEquipStatRowLookup>>(ItemManager.instance.equipStats.Length); base.Awake(); if (statusRowPrefab != null) rowsPool = new InventoryPool<InventoryEquipStatRowUI>(statusRowPrefab, 64); if (statusCategoryPrefab != null) categoryPool = new InventoryPool<InventoryEquipStatCategoryUI>(statusCategoryPrefab, 8); InventoryManager.AddEquipCollection(this, equipPriority); //UpdateCharacterStats(); OnSwappedItems += (fromCollection, fromSlot, toCollection, toSlot) => { if (fromCollection == toCollection) return; // Just moving inside collection, no need to re-do anything. if (toCollection[toSlot].item != null && fromCollection[fromSlot].item != null) { // Actually swapped item var item = fromCollection[fromSlot].item as EquippableInventoryItem; if(item != null) item.NotifyItemUnEquipped(); } if (toCollection == this) { // Move to this inventory UpdateCharacterStats(); var i = toCollection[toSlot].item as EquippableInventoryItem; if (i != null) { bool handled = i.HandleLocks(equipSlotFields[i.index], this); if (handled) { i.NotifyItemEquipped(equipSlotFields[i.index]); if (i.playOnEquip != null) InventoryUIUtility.AudioPlayOneShot(i.playOnEquip); } } } else if (fromCollection == this) { UpdateCharacterStats(); // Moved from this collection to -> toCollection var i = toCollection[toSlot].item as EquippableInventoryItem; if(i != null) i.NotifyItemUnEquipped(); } }; window.OnShow += () => { RepaintStats(); }; }
public override void Awake() { equipSlotFields = new InventoryEquippableField[items.Length]; for (int i = 0; i < items.Length; i++) equipSlotFields[i] = items[i].gameObject.GetComponent<InventoryEquippableField>(); characterStats = new Dictionary<string, List<InventoryCharacterStat>>(16); statsDataProviders = new List<ICharacterStatDataProvider>(2); base.Awake(); SetDefaultDataProviders(); PrepareCharacterStats(); if (isSharedCollection) InventoryManager.AddEquipCollection(this, collectionPriority); if (statusRowPrefab != null) rowsPool = new InventoryPool<InventoryEquipStatRowUI>(statusRowPrefab, 32); if (statusCategoryPrefab != null) categoryPool = new InventoryPool<InventoryEquipStatCategoryUI>(statusCategoryPrefab, 8); OnAddedItem += (itemsAdded, amount, cameFromCollection) => { foreach (var item in itemsAdded) ((EquippableInventoryItem)item).NotifyItemEquipped(equipSlotFields[item.index]); //RepaintStats(); //UpdateCharacterStats(); }; OnRemovedItem += (item, itemID, slot, amount) => { ((EquippableInventoryItem)item).NotifyItemUnEquipped(); //RepaintStats(); //UpdateCharacterStats(); }; OnSwappedItems += (collection, slot, toCollection, toSlot) => { if (collection == this) { //if (toCollection[toSlot].item != null) //((EquippableInventoryItem)toCollection[toSlot].item).HandleLocks(equipSlotFields[slot], collection, this); } else { if (toCollection[toSlot].item != null) ((EquippableInventoryItem)toCollection[toSlot].item).HandleLocks(equipSlotFields[toSlot], collection, this); } }; window.OnShow += RepaintAllStats; }