Exemplo n.º 1
0
    public void AddBuildingToGrid(HouseConstructor building)
    {
        Chunk chunk = GetChunkByPos(building.building.BuildingCenter);

        chunk.buildings.Add(building);
        building.gameObject.SetActive(false);
    }
Exemplo n.º 2
0
    public void BuildCity()
    {
        city = Parser.GetBuildingsFromJSON(Application.dataPath + "/CityBloc/Scripts/" + geojsonFile.name + ".json");

        Vector2 cityCenter = new Vector2();
        int     nb         = 0;

        for (int i = 0; i < city.Count; i++)
        {
            for (int j = 0; j < city[i].points.Count; j++)
            {
                cityCenter += city[i].points[j];
                nb++;
            }
        }
        cityCenter /= nb;


        for (int i = 0; i < city.Count; i++)
        {
            HouseConstructor house = Instantiate(houseConstructorPrefab, new Vector3((city[i].points[0].x - cityCenter.x) / 10000, 0, (city[i].points[0].y - cityCenter.y) / 10000), Quaternion.identity);
            house.building   = city[i];
            house.cityCenter = cityCenter;
            house.Construct();
        }
    }
Exemplo n.º 3
0
    public void BuildCity()
    {
        city = ParserGML.GetBuildingsFromGML(path);

        //Calculate build center
        Vector3 cityCenter = new Vector3();
        int     nb         = 0;

        for (int i = 0; i < city.Count; i++)
        {
            for (int j = 0; j < city[i].points.Count; j++)
            {
                cityCenter += city[i].points[j];
                nb++;
            }
        }
        cityCenter /= nb;

        //Build houses
        for (int i = 0; i < city.Count; i++)
        {
            HouseConstructor house = Instantiate(houseConstructorPrefab, new Vector3((city[i].points[0].x - cityCenter.x) / 100, 0, (city[i].points[0].y - cityCenter.y) / 100), Quaternion.identity, this.transform);
            buildingInstiate.Add(house.gameObject);
            house.building   = city[i];
            house.cityCenter = cityCenter;
            house.Construct();
            house.gameObject.AddComponent <MeshCollider>().convex = true;
        }
    }