public void changeTo(Building.BuildingTypes change) { List <Dropdown.OptionData> options = BuildingMenu.options; for (int i = 0; i < options.Count; i++) { if (options[i].text == change.ToString()) { BuildingMenu.value = i; } } }
public void CopyTile(BuildableTile tileToCopy) { // Copy all necessary attributes of the tileToCopy // Can override this on inherited class to copy all attributes this.scale = tileToCopy.GetScale(); this.tileStages = tileToCopy.GetTileStages(); this.needsBuilt = tileToCopy.GetNeedsBuilt(); this.preBuiltPrefabs = tileToCopy.GetPreBuiltPrefabs(); this.requiredJob = tileToCopy.GetRequiredJobType(); this.bType = tileToCopy.GetBuildingType(); this.workers = new List <Villager>(); }
//Checks if the currently selected building type can be placed on the given tile and then instantiates an instance of the prefab private void PlaceBuildingOnTile(Tile t) { //if there is building prefab for the number input if (_selectedBuildingIndex != Building.BuildingTypes.Empty) { Building.BuildingTypes bt = _selectedBuildingIndex; changeBuildingSelection(ProductionBuilding.BuildingTypes.Empty); GameObject selectedBuilding = _buildingPrefabs.Dict[bt]; if (Building.Constructable(bt, t, this)) { TileCoverCleaner clean = t.gameObject.GetComponent <TileCoverCleaner>(); clean.setCoverInvisible(); GameObject temp = Instantiate(selectedBuilding, t.transform.position, t.transform.rotation); Building b = temp.GetComponent <Building>(); if (b == null) { b = temp.AddComponent(Building.buildingClassType[bt]) as Building; } b.Construct(bt, t, this); nm.updateTravelMap(t); } } }
void changeBuildingSelection(Building.BuildingTypes change) { _selectedBuildingIndex = change; selectPanel.changeTo(change); }