protected virtual void RepaintStats() { if (window.isVisible == false || statusRowPrefab == null || statusCategoryPrefab == null) { return; } // Get rid of the old categoryPool.DestroyAll(); rowsPool.DestroyAll(); // Maybe make a pool for the items? See some spikes... foreach (var stat in characterStats) { // stat.Key is category // stat.Value is all items in category var cat = categoryPool.Get(); //cat.gameObject.SetActive(window.isVisible); cat.SetCategory(stat.Key); cat.transform.SetParent(statsContainer); cat.transform.localPosition = new Vector3(cat.transform.localPosition.x, cat.transform.localPosition.y, 0.0f); foreach (var s in stat.Value) { var obj = rowsPool.Get(); //obj.gameObject.SetActive(window.isVisible); //var obj = GameObject.Instantiate<InventoryEquipStatRow>(statusRowPrefab); obj.SetRow(s.statName, s.finalValueString); obj.transform.SetParent(cat.container); obj.transform.localPosition = Vector3.zero; // UI Layout will handle it. } } }
protected virtual void SetBlueprint(InventoryCraftingBlueprint blueprint) { if (window.isVisible == false) { return; } // Set all the details for the blueprint. if (blueprintTitle != null) { blueprintTitle.text = blueprint.name; } if (blueprintDescription != null) { blueprintDescription.text = blueprint.description; } if (blueprintIcon != null) { blueprintIcon.item = blueprint.itemResult; blueprintIcon.item.currentStackSize = (uint)blueprint.itemResultCount; blueprintIcon.Repaint(); blueprintIcon.item.currentStackSize = 1; // Reset } if (blueprintCraftProgressSlider) { blueprintCraftProgressSlider.value = 0.0f; // Reset } if (blueprintCraftCostText != null) { if (InventoryManager.instance.inventory.gold < blueprint.craftCostPrice) { blueprintCraftCostText.color = itemsNotAvailableColor; } else { blueprintCraftCostText.color = itemsAvailableColor; } blueprintCraftCostText.text = InventorySettingsManager.instance.currencyFormatter.Format(blueprint.craftCostPrice); } blueprintRequiredItemsPool.DestroyAll(); foreach (var item in blueprint.requiredItems) { var ui = blueprintRequiredItemsPool.Get(); item.item.currentStackSize = (uint)item.amount; ui.transform.SetParent(blueprintRequiredItemsContainer); ui.item = item.item; if (InventoryManager.GetItemCount(item.item.ID, currentCategory.alsoScanBankForRequiredItems) >= item.amount) { ui.icon.color = itemsAvailableColor; } else { ui.icon.color = itemsNotAvailableColor; } ui.Repaint(); item.item.currentStackSize = 1; // Reset } }
public virtual void SetCraftingCategory(InventoryCraftingCategory category) { categoryPool.DestroyAll(); blueprintPool.DestroyAll(); currentCategory = category; if (blueprintCraftAmountInput != null) { blueprintCraftAmountInput.text = "1"; // Reset } CancelActiveCraft(); // Just in case if (currentCategoryTitle != null) { currentCategoryTitle.text = currentCategory.name; } if (currentCategoryDescription != null) { currentCategoryDescription.text = currentCategory.description; } if (noBlueprintSelectedPage != null) { noBlueprintSelectedPage.Show(); } if (blueprintCraftPage == null && currentCategory.blueprints.Length > 0) { SetBlueprint(currentCategory.blueprints[0]); // Select first blueprint } int lastItemCategory = -1; foreach (var b in currentCategory.blueprints) { if (b.playerLearnedBlueprint == false) { continue; } var blue = blueprintPool.Get(); blue.transform.SetParent(blueprintsContainer); blue.Set(b); if (blueprintCategoryPrefab != null) { if (lastItemCategory != b.itemResult.category.ID) { lastItemCategory = (int)b.itemResult.category.ID; var uiCategory = categoryPool.Get(); uiCategory.Set(b.itemResult.category.name); uiCategory.transform.SetParent(blueprintsContainer); blue.transform.SetParent(uiCategory.container); } } var bTemp = b; // Store capture list, etc. blue.button.onClick.AddListener(() => { currentBlueprint = bTemp; SetBlueprint(currentBlueprint); CancelActiveCraft(); // Just in case if (blueprintCraftPage != null && blueprintCraftPage.isVisible == false) { blueprintCraftPage.Show(); } }); } }