public void SelectItem(int ind) { CraftableItem item = selectedItems[ind]; currentSelectedItem = item; SelectedItem.Find("Background/NameBG/ItemName").GetComponent <Text>().text = item.ItemName; UpdateProfessionInterface(); }
private void ClearCraftingReagents() { Transform reagentTransform = SelectedItem.Find("Background/AttributeBG/Bottom"); for (int i = reagentTransform.childCount - 1; i >= 0; i--) { DestroyImmediate(reagentTransform.GetChild(i).gameObject); } }
public void UpdateProfessionInterface() { if (currentSelectedItem != null && (currentSelectedItem.MyCraftedItemType == CraftedItemType.WEAPON || currentSelectedItem.MyCraftedItemType == CraftedItemType.ARMOR)) { CraftedEquipment item2 = (currentSelectedItem as CraftedEquipment); if (item2 == null) { return; } SelectedItem.Find("Background/AttributeBG/Top/ItemValues").GetComponent <Text>().text = item2.dexterityMin + " - " + item2.dexterityMax + "\n" + item2.mightMin + " - " + item2.mightMax + "\n" + item2.intelligenceMin + " - " + item2.intelligenceMax + "\n"; if (currentSelectedItem.MyCraftedItemType == CraftedItemType.ARMOR) { SelectedItem.Find("Background/Icon").GetComponent <Image>().sprite = item2.Icon; } else if (currentSelectedItem.MyCraftedItemType == CraftedItemType.WEAPON) { SelectedItem.Find("Background/Icon").GetComponent <Image>().sprite = (currentSelectedItem as CraftedWeapon).Icon; } ClearCraftingReagents(); Transform reagentTransform = SelectedItem.Find("Background/AttributeBG/Bottom"); SelectedItem.Find("Background/Actions/CraftButton").GetComponent <Button>().interactable = true; foreach (Reagent r in item2.RequiredReagents) { GameObject cardRef = Instantiate(reagentCard, reagentTransform, false); int ownedReagent = Player_Accessor_Script.InventoryScript.GetResourceQuantity(r.ReagentName); if (ownedReagent > -1) { Text nameComp = cardRef.transform.Find("Name").GetComponent <Text>(); Text quantityComp = cardRef.transform.Find("Quantity").GetComponent <Text>(); nameComp.text = r.ReagentName; quantityComp.text = ownedReagent + "/" + r.ReagentQuantity; SelectedItem.Find("Background/Actions/CraftButton").GetComponent <Button>().interactable = true; if (ownedReagent < r.ReagentQuantity) { nameComp.color = Color.red; quantityComp.color = Color.red; SelectedItem.Find("Background/Actions/CraftButton").GetComponent <Button>().interactable = false; } } else { Text nameComp = cardRef.transform.Find("Name").GetComponent <Text>(); Text quantityComp = cardRef.transform.Find("Quantity").GetComponent <Text>(); nameComp.color = Color.red; nameComp.text = "???"; quantityComp.color = Color.red; quantityComp.text = 0 + "/" + r.ReagentQuantity; SelectedItem.Find("Background/Actions/CraftButton").GetComponent <Button>().interactable = false; } } } else if (currentSelectedItem != null && currentSelectedItem.MyCraftedItemType == CraftedItemType.REAGENT) { CraftableReagent item2 = (currentSelectedItem as CraftableReagent); if (item2 == null) { return; } SelectedItem.Find("Background/AttributeBG/Top/ItemValues").GetComponent <Text>().text = ""; SelectedItem.Find("Background/Icon").GetComponent <Image>().sprite = item2.Icon; ClearCraftingReagents(); Transform reagentTransform = SelectedItem.Find("Background/AttributeBG/Bottom"); SelectedItem.Find("Background/Actions/CraftButton").GetComponent <Button>().interactable = true; foreach (Reagent r in item2.RequiredReagents) { GameObject cardRef = Instantiate(reagentCard, reagentTransform, false); int ownedReagent = Player_Accessor_Script.InventoryScript.GetResourceQuantity(r.ReagentName); if (ownedReagent > -1) { Text nameComp = cardRef.transform.Find("Name").GetComponent <Text>(); Text quantityComp = cardRef.transform.Find("Quantity").GetComponent <Text>(); nameComp.text = r.ReagentName; quantityComp.text = ownedReagent + "/" + r.ReagentQuantity; SelectedItem.Find("Background/Actions/CraftButton").GetComponent <Button>().interactable = true; if (ownedReagent < r.ReagentQuantity) { nameComp.color = Color.red; quantityComp.color = Color.red; SelectedItem.Find("Background/Actions/CraftButton").GetComponent <Button>().interactable = false; } } else { print(r.ReagentName); Text nameComp = cardRef.transform.Find("Name").GetComponent <Text>(); Text quantityComp = cardRef.transform.Find("Quantity").GetComponent <Text>(); nameComp.color = Color.red; nameComp.text = "???"; quantityComp.color = Color.red; quantityComp.text = 0 + "/" + r.ReagentQuantity; SelectedItem.Find("Background/Actions/CraftButton").GetComponent <Button>().interactable = false; } } } }
public void ResetSelectedItem() { SelectedItem.Find("Background/NameBG/ItemName").GetComponent <Text>().text = ""; SelectedItem.Find("Background/AttributeBG/Top/ItemValues").GetComponent <Text>().text = ""; }