Ejemplo n.º 1
0
    /// <summary>
    /// Build function for debug only, with given coordinates.
    /// </summary>
    /// <param name="_building"></param>
    /// <param name="coord"></param>
    public void Build(Building _building, Coord coord)
    {
        Building building = Object.Instantiate(_building, Tools.GetWorldPosition(coord, _building.GetSize()), Quaternion.identity, transform);

        building.SetCoord(coord);
        building.data = DatabaseManager.FindBuildingData(building.dataId);
        GridManager.instance.UpdateBuilding(building, UpdateType.NEW);
        SessionManager.AddBuildingInstance(building);
    }
Ejemplo n.º 2
0
    /// <summary>
    /// Builds given building to the grid.
    /// </summary>
    /// <param name="_building">Non-instanced building selected by build menu.</param>
    public void Build(Building _building)
    {
        Coord    coord    = GridManager.instance.FindRandomArea(_building);
        Building building = Instantiate(_building, Tools.GetWorldPosition(coord, _building.GetSize()), Quaternion.identity, transform);

        building.SetCoord(coord);
        building.data           = DatabaseManager.FindBuildingData(building.dataId);
        building.data.buildCost = SessionManager.availableBuildings[_building].buildCost;

        GridManager.instance.UpdateBuilding(building, UpdateType.NEW);
        SessionManager.AddBuildingInstance(building);
        SessionManager.ChangeCategoryCount(building.GetCategory(), 1);
        ApplyInterestToBuildingCategory(building.GetCategory());
        ChangeRemainingOfBuilding(_building, -1);
        SessionManager.instance.SaveSession();

        InputManager.instance.OnSelectBuilding(building);
    }