public override void Enable(City city, GUIMaster gui) { this.selectedCity = city; this.selectedButton = null; base.Enable(city, gui); //Clear List Entries and Texts selectionTitle.text = ""; selectionDesc.text = ""; foreach (ProjectButton b in availableProjectList.GetComponentsInChildren <ProjectButton>()) { Destroy(b.transform.gameObject); } foreach (ProjectButton b in unavailableProjectsList.GetComponentsInChildren <ProjectButton>()) { Destroy(b.transform.gameObject); } //TODO: Implement automatic buttons //Populate project lists foreach (string projectID in selectedCity.construction.GetAvailableProjects()) { ProjectButton pb = Instantiate(projectButtonPrefab); pb.transform.SetParent(availableProjectList.transform); pb.ProjectSelector = this; pb.text.text = GlobalProjectDictionary.GetProjectData(projectID).Name; pb.ProjectID = projectID; } UpdateGUI(); }
public List <string> GetAvailableProjects() { List <string> list = new List <string>(); foreach (KeyValuePair <string, ProjectData> pair in GlobalProjectDictionary.GetAllProjects()) { //TODO: Fix selected project availability question //if (pair.Key != selectedProjectID) //{ bool available = pair.Value.WorkingPopPreReq <= city.workingPop && pair.Value.Employment <= city.idlePop; foreach (string req in pair.Value.ProjectPreReqs) { if (!completedProjects.Contains(req)) { available = false; break; } } if (available) { list.Add(pair.Key); } //} } return(list); }
public string GetDescription(City city, GameMaster game) { string output = "<b>" + Name + "</b>\n"; if (WorkingPopPreReq > 0 || ProjectPreReqs.Length > 0) { output += "Requirements:\n"; if (WorkingPopPreReq > 0) { output += "\tWorking Population: " + WorkingPopPreReq + "\n"; } foreach (string projectID in ProjectPreReqs) { output += "\t" + GlobalProjectDictionary.GetProjectData(projectID).Name + "\n"; } } output += "Cost:\n"; foreach (KeyValuePair <string, int> resource in project.GetResourceCost(city, game)) { output += "\t" + GlobalResourceDictionary.GetResourceData(resource.Key).name + " (" + resource.Value + ")\n"; } output += "Employs: " + Employment + "\n"; output += "<b>" + Type + "</b>\n"; output += "Description: \n" + project.GetDescription(); return(output); }
public void ConfirmProject() { Debug.Log("Project Selection Confirmed"); if (selectedButton != null) { //ProjectData project = GlobalProjectDictionary.GetProjectData(); Debug.Log("Project Selection Started"); ProjectData data = GlobalProjectDictionary.GetProjectData(selectedButton.ProjectID); IProject selection = data.Project; selectionManager.StartSelection(selection, this, selectedCity, gui); } }
public void SelectProject(ProjectButton b) { b.button.interactable = false; if (selectedButton != null) { selectedButton.button.interactable = true; } ProjectData p = GlobalProjectDictionary.GetProjectData(b.ProjectID); selectionTitle.text = p.Name; selectionDesc.text = p.GetDescription(selectedCity, gui.Game); selectedButton = b; confirmButton.interactable = p.IsConstructable(selectedCity, gui.Game); }
// TODO: formalize construction tick public void UpdateConstruction(GameMaster game) { if (selectedProjectID != null) { UpdateConstructionProgressCost(game); constructionProgress += constructionDev; //FOR TESTING--------------------------------------- //constructionProgress = requiredConstructionProgress; //-------------------------------------------------- //Project is completed if (constructionProgress >= requiredConstructionProgress) { project.Complete(city, game.World); int pop = GlobalProjectDictionary.GetProjectData(selectedProjectID).Employment; city.idlePop -= pop; city.workingPop += pop; CloseProject(); } } }
public string GetDescription(GUIMaster gui) { string output = (selectedProjectID == null ? "No Selected Construction Project" : GlobalProjectDictionary.GetProjectData(selectedProjectID).GetDescription(city, gui.Game)) + "\n"; if (project != null) { output += "\n" + project.GetSelectionInfo(gui); } output += "\n<b>Progress:</b> " + constructionProgress + "/" + requiredConstructionProgress; return(output); }