private void BuildBuildingOption(BuildingSlot bs) { //Create the UI: GameObject panelBuildingDetails = (GameObject)Instantiate(panelBuildingDetailsPrefab); panelBuildingDetails.transform.SetParent(content.transform); BuildingOption buildingOption = panelBuildingDetails.GetComponent <BuildingOption>(); //Get the BuildingOption script and set Gameplay values: buildingOption.buildingSlotInfos = bs; buildingOption.setBuildingName(bs.Name); buildingOption.setBuildingSprite(Resources.Load <Sprite>(bs.Image)); int numberOfResourcesNeedeed = bs.Resources.Resource.Count; for (int i = 0; i < numberOfResourcesNeedeed; i++) { GameObject panelResourcesNeededGo = panelResourcesNeededGo = (GameObject)Instantiate(panelResourcesNeedeedPrefab); panelResourcesNeededGo.transform.SetParent(panelBuildingDetails.transform); panelResourcesNeededGo.transform.localPosition = new Vector2(200 + (i * 80), -20); buildingOption.addPanelResourcesNeeded(panelResourcesNeededGo.GetComponent <PanelResourceNeeded>()); BuildingResource br = bs.Resources.Resource[i]; buildingOption.addResource((UsableObject)Activator.CreateInstance(Type.GetType(br.Text), 4), Convert.ToInt32(br.Quantity)); } //Populate the UI: buildingOption.populateUI(); }
// =================== // = GET/SET METHODS = // =================== public void setPrerequisite(BuildingOption prerequisite) { this.prerequisite = prerequisite; }