void DisplayCategoryList() { List <string> CategoryList = new List <string>(); TechRecipe.ProcessorInfo TargetProcessorInfo = CallTechRecipe.GetProcessorRecipe(CallInstallableObjectAct.Info.Name); foreach (var ActorName in TargetProcessorInfo.ActorList) { if (!CallTechValue.GetActorPossible(ActorName)) { continue; } bool isDuplicate = false; foreach (var Item in CategoryList) { if (ActorName == Item) { isDuplicate = true; break; } } if (!isDuplicate) { CategoryList.Add(ActorName); } } int RowLimit = CategoryList.Count; if (RowLimit > CategoryCarrier.transform.childCount) { for (int i = CategoryCarrier.transform.childCount; i < RowLimit; i++) { GameObject.Instantiate(CategoryCarrier.transform.GetChild(0).gameObject, CategoryCarrier.transform); } } else if (RowLimit < CategoryCarrier.transform.childCount) { if (RowLimit == 0) { RowLimit = 1; } for (int i = CategoryCarrier.transform.childCount - 1; i >= RowLimit; i--) { Destroy(CategoryCarrier.transform.GetChild(i).gameObject); } } for (int i = 0; i < RowLimit; i++) { CategoryCarrier.transform.GetChild(i).gameObject.SetActive(false); } for (int i = 0; i < CategoryList.Count; i++) { CategoryCarrier.transform.GetChild(i).gameObject.SetActive(true); CategoryCarrier.transform.GetChild(i).GetChild(0).gameObject.GetComponent <Text>().text = " " + CategoryList[i]; } }
void DisplayProcessorList() { List <string> ItemList = new List <string>(); int RowLimit = 0; if (CategoryCarrier.transform.childCount > 1) { for (int i = 2; i < CategoryCarrier.transform.childCount; i++) { Destroy(CategoryCarrier.transform.GetChild(i).gameObject); } } CategoryCarrier.transform.GetChild(0).gameObject.SetActive(false); for (int i = ItemCarrier.transform.childCount - 1; i > 0; i--) { Destroy(ItemCarrier.transform.GetChild(i).gameObject); } foreach (var Facility in CallTechValue.FacilityList) { if (Facility.Type != "Processor" && Facility.Type != "Assembler") { continue; } TechRecipe.ProcessorInfo TargetProcessorRecipe = CallTechRecipe.GetProcessorRecipe(Facility.Name); if (TargetProcessorRecipe == null) { Debug.Log("There is no " + Facility.Name + " in System"); return; } foreach (var ActorName in TargetProcessorRecipe.ActorList) { if (!CallTechValue.GetActorPossible(ActorName)) { continue; } string TargetName = Facility.Name + "-" + ActorName; bool isDuplicate = false; foreach (var Item in ItemList) { if (TargetName == Item) { isDuplicate = true; break; } } if (!isDuplicate) { ItemList.Add(TargetName); } } } RowLimit = Mathf.CeilToInt((float)ItemList.Count / 3f); if (ItemList.Count == 0) { for (int i = 1; i < 3; i++) { ItemCarrier.transform.GetChild(0).GetChild(i).GetChild(0).gameObject.SetActive(false); } ItemCarrier.transform.GetChild(0).GetChild(0).GetChild(0).GetChild(0).gameObject.GetComponent <Image>().sprite = Resources.Load <Sprite>("GameSystem/InGameUI/Sprite/InsideEmptyCircle"); ItemCarrier.transform.GetChild(0).GetChild(0).GetChild(0).GetChild(1).gameObject.GetComponent <Text>().text = "None"; } else { for (int i = 0; i < 3; i++) { ItemCarrier.transform.GetChild(0).GetChild(i).GetChild(0).gameObject.SetActive(true); } for (int i = 0; i < RowLimit; i++) { if (i != 0) { GameObject.Instantiate(ItemCarrier.transform.GetChild(0).gameObject, ItemCarrier.transform); } int LeftItem = ItemList.Count - (i * 3) + 1; if (LeftItem < 3) { for (int j = 2; j >= LeftItem; j--) { ItemCarrier.transform.GetChild(i).GetChild(j).GetChild(0).gameObject.SetActive(false); } } for (int j = 0; j < 3; j++) { if (i == 0 && j == 0) { ItemCarrier.transform.GetChild(i).GetChild(j).GetChild(0).GetChild(0).gameObject.GetComponent <Image>().sprite = Resources.Load <Sprite>("GameSystem/InGameUI/Sprite/InsideEmptyCircle"); ItemCarrier.transform.GetChild(i).GetChild(j).GetChild(0).GetChild(1).gameObject.GetComponent <Text>().text = "None"; } else { if (i * 3 + j - 1 >= ItemList.Count) { break; } ItemCarrier.transform.GetChild(i).GetChild(j).GetChild(0).GetChild(0).gameObject.GetComponent <Image>().sprite = null; ItemCarrier.transform.GetChild(i).GetChild(j).GetChild(0).GetChild(1).gameObject.GetComponent <Text>().text = ItemList[i * 3 + j - 1]; } } } } CurrentCategory = ""; }