public void DemolishActionSelected(string s) { //Debug.Log("DemolishActionSelected"); // Delete buttons //Debug.Log("Clear UI"); ClearUIObjects(); string txt = "Demolition\nTears down the current structure\n"; if (jobDescriptionText == null) { jobDescriptionText = UIElementFunctions.TextOnly(jobsPanel.transform, txt, new Vector3(180, -50), new Vector2(300, 100)); } else { jobDescriptionText.textGo.text = txt; } // Add prerequisites, colored, here // Buttons to make it go //Debug.Log("ResourceDropdownCreator"); resourceChoiceDropdown = ResourceDropdownCreator.CreateNoResourceDropdown(tileDetailUiPanel.transform, new Vector3(-200, -185), "Demolition", ManagerBase.domain, null); resourceChoiceDropdown.jobStartButton.buttonGo.onClick.AddListener(delegate() { StartDemolitionJobButton(); }); //Debug.Log("Done DemolishActionSelected"); }
public void BuildActionSelected(string s) { // Delete buttons ClearUIObjects(); BuildingDef buildingSelected = ManagerBase.buildingDefinitions[ManagerBase.buildingIndexOf[s]]; if (buildingSelected == null) { Debug.LogError("Should not have an unbuildable building here: " + s); } string txt = buildingSelected.name + "\n" + buildingSelected.description + "\n"; if (jobDescriptionText == null) { jobDescriptionText = UIElementFunctions.TextOnly(jobsPanel.transform, txt, new Vector3(180, -50), new Vector2(300, 100)); } else { jobDescriptionText.textGo.text = txt; } // Add prerequisites, colored, here // Figure out what the building needs resourceChoiceDropdown = ResourceDropdownCreator.CreateResourceChoiceDropdown(tileDetailUiPanel.transform, new Vector3(-200, -185), buildingSelected.resourcesToBuild, buildingSelected.name, ManagerBase.domain, buildingSelected.sprite); resourceChoiceDropdown.jobStartButton.buttonGo.onClick.AddListener(delegate() { StartConstructionJobButton(); }); }
public void NewJobActionSelected(System.Guid jobGuid) { JobDef jobSelected = JobQueries.ByGuid(ManagerBase.jobDefinitions, jobGuid); if (jobSelected == null) { Debug.LogError("Should not have an empty job here"); } string txt = jobSelected.name + "\n" + jobSelected.description + "\n"; if (jobDescriptionText == null) { jobDescriptionText = UIElementFunctions.TextOnly(jobsPanel.transform, txt, new Vector3(180, -50), new Vector2(300, 100)); } else { jobDescriptionText.textGo.text = txt; } // Add prerequisites, colored, here // Figure out what the building needs Sprite output1Sprite = ManagerBase.resourceDefinitions[ManagerBase.resourceIndexOf[jobSelected.outputName[0]]].image; if (jobSelected.inputResources.rqqList.Count > 0) // Has inputs { resourceChoiceDropdown = ResourceDropdownCreator.CreateResourceChoiceDropdown(tileDetailUiPanel.transform, new Vector3(-200, -185), jobSelected.inputResources, jobSelected.name, ManagerBase.domain, output1Sprite); } else { resourceChoiceDropdown = ResourceDropdownCreator.CreateNoResourceDropdown(tileDetailUiPanel.transform, new Vector3(-200, -185), jobSelected.name, ManagerBase.domain, output1Sprite); } resourceChoiceDropdown.jobStartButton.buttonGo.onClick.AddListener(delegate() { StartJobButton(jobSelected); }); }
private static ResourceDropdown Create(Transform parent, Vector3 localPosition, ResourceQuantityQualityList choiceRqqList, string taskName, Domain domain, bool isStatic) { GameObject newGo = new GameObject("Resource Dropdown"); ResourceDropdown resourceDropdown = newGo.AddComponent <ResourceDropdown>(); resourceDropdown.choiceRqqList = choiceRqqList; resourceDropdown.taskName = taskName; resourceDropdown.domain = domain; int resInd = 0; foreach (ResourceQuantityQuality rqq in choiceRqqList.rqqList) { Dictionary <string, Sprite> stringSprite = rqq.GetImageOptions(rqq.minTier); // Create the button resourceDropdown.elements.Add(UIElementFunctions.Dropdown(parent, null, "", localPosition, new Vector2(64, 64))); //resourceDropdown[resInd].transform.localPosition = localPosition; localPosition.x += imageSize * 3 / 2; resourceDropdown.elements[resInd].thisGo.name = "Resource Dropdown Item"; resourceDropdown.elements[resInd].childHeight = imageSize; int ind = 0; foreach (KeyValuePair <string, Sprite> entry in stringSprite) { ResourceNameQuantityQuality nqq = new ResourceNameQuantityQuality(entry.Key, QualityEnum.any, rqq.quantity); if (ind == 0) { resourceDropdown.elements[resInd].imageGo.sprite = entry.Value; resourceDropdown.elements[resInd].textGo.text = ""; resourceDropdown.elements[resInd].defName = entry.Key; } if (!isStatic) { resourceDropdown.elements[resInd].AddChild(); resourceDropdown.elements[resInd].children[ind].tooltipData = entry.Key; resourceDropdown.elements[resInd].children[ind].defName = entry.Key; resourceDropdown.elements[resInd].children[ind].imageGo.sprite = entry.Value; } if (!nqq.CheckResource(domain.stock)) { if (ind == 0) { resourceDropdown.elements[resInd].imageGo.color = Color.red; resourceDropdown.elements[resInd].allowed = false; } if (!isStatic) { resourceDropdown.elements[resInd].children[ind].imageGo.color = Color.red; resourceDropdown.elements[resInd].children[ind].buttonGo.interactable = false; resourceDropdown.elements[resInd].children[ind].allowed = false; } } if (!isStatic) { resourceDropdown.elements[resInd].children[ind].textGo.text = ""; } // Add a quantity text string quantityString = rqq.quantity.ToString(); CustomUIElement temp = UIElementFunctions.TextOnly(resourceDropdown.elements[resInd].thisGo.transform, quantityString, new Vector3(0, imageSize - 20), new Vector2(imageSize, 20F)); temp.textGo.alignment = TextAnchor.MiddleCenter; ind++; } resInd++; } return(resourceDropdown); }