コード例 #1
0
    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;
            }
        }
    }
コード例 #2
0
ファイル: BuildableTile.cs プロジェクト: JKneedler/Polis
 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>();
 }
コード例 #3
0
    //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);
            }
        }
    }
コード例 #4
0
 void changeBuildingSelection(Building.BuildingTypes change)
 {
     _selectedBuildingIndex = change;
     selectPanel.changeTo(change);
 }