public virtual void Awake() { window = GetComponent <UIWindow>(); pool = new InventoryPool <InventoryContextMenuItem>(contextMenuItemPrefab, 8); window.OnShow += window_OnWindowShow; }
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 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); } }; }
public virtual void Awake() { pool = new InventoryPool <NoticeMessageUI>(noticeRowPrefab, maxMessages); }