/// <summary> /// Displays available buildings in currently selected branch /// </summary> private void ShowBranch() { //Collection of valid buildings List <Buildings> validBuildings = new List <Buildings>(); ClearBranch(); //Clear window from buildings //Get set of valid buildings foreach (Buildings b in branch.GetBuildings()) { //Upgrade if (upgrade && (b.GetGrade() == buildingLogic.ActualBuilding.GetGrade() || ((b.GetBranch() == buildingLogic.ActualBuilding.GetBranch() || buildingLogic.ActualBuilding.GetBranch() == Branches.NONE) && b.GetGrade() == buildingLogic.ActualBuilding.GetGrade() + 1)) && b != buildingLogic.ActualBuilding) { validBuildings.Add(b); } //Downgrade else if (!upgrade && b.GetGrade() == buildingLogic.ActualBuilding.GetGrade() - 1 && b != buildingLogic.ActualBuilding) { validBuildings.Add(b); } } //Display branch name gameObject.transform.Find("Branch").GetComponent <Text>().text = string.Format("Odvětví: {0}", branch.GetName()); //Display valid buildings for (int selectionIdx = 0; selectionIdx < validBuildings.Count; selectionIdx++) { gameObject.transform.Find("Selection" + selectionIdx).Find("Name").GetComponent <Text>().text = validBuildings[selectionIdx].GetName(); DisplayProductionConsumption(selectionIdx, validBuildings[selectionIdx]); } displayedBuildings = validBuildings; }