示例#1
0
    public void AddConstructedBuilding(Building building)
    {
        constructedBuildings.Add(building);
        BuildingType type = building.GetStats().type;

        if (type == BuildingType.residential)
        {
            residentialBuildings.Add(building.gameObject.GetComponent <ResidentialBuilding>());
        }
        else if (type == BuildingType.industrial)
        {
            industrialBuildings.Add(building.gameObject.GetComponent <IndustrialBuilding>());
        }
        else if (type == BuildingType.commercial)
        {
            commercialBuildings.Add(building.gameObject.GetComponent <CommercialBuilding>());
        }
        else if (type == BuildingType.infrastructure)
        {
            InfrastructureBuilding infrastructureBuilding = building.GetComponent <InfrastructureBuilding>();
            AddInfrastructureBuilding(infrastructureBuilding, infrastructureBuilding.InfrastructureType());
        }

        if (building.gameObject.GetComponent <WorkPlace>() != null)
        {
            workPlaces.Add(building.gameObject.GetComponent <WorkPlace>());
        }
    }
示例#2
0
    void AddInfrastructureBuilding(InfrastructureBuilding building, InfrastructureService type)
    {
        switch (type)
        {
        case InfrastructureService.water:
            waterProductionBuildings.Add(building);
            break;

        case InfrastructureService.power:
            powerProductionBuildings.Add(building);
            break;

        case InfrastructureService.health:
            break;

        case InfrastructureService.education:
            break;

        case InfrastructureService.gas:
            break;

        case InfrastructureService.safety:
            break;

        case InfrastructureService.parks:
            break;

        default:
            break;
        }
    }
示例#3
0
    public ulong GetNewID(InfrastructureBuilding building) //So far, only parks, police stations and schools require IDs and are limited in number.
    {
        InfrastructureService type = building.InfrastructureType();
        ulong newID = 0;

        switch (type)
        {
        case InfrastructureService.parks:
            newID = parkIDHandler.AssignNewBuilding(building.gameObject.GetComponent <Park_1>());
            break;

        case InfrastructureService.safety:
            newID = policeIDHandler.AssignNewBuilding(building.gameObject.GetComponent <PoliceStation_1>());
            break;

        case InfrastructureService.education:
            newID = schoolIDHandler.AssignNewBuilding(building.gameObject.GetComponent <School_1>());
            break;

        default:
            break;
        }

        return(newID);
    }