Exemple #1
0
 static void SetCornerLamps(CityBlock cityBlock)
 {
     for (int x = 0; x < cityBlock.size.x; x++)
     {
         for (int y = 0; y < cityBlock.size.y; y++)
         {
             var pavement = cityBlock.GetPavementTile(x, y);
             if (pavement == PavementPiece.CORNER_NW)
             {
                 cityBlock.SetMiscTile(x, y, MiscPiece.STREET_LAMP_CORNER_NW);
             }
             else if (pavement == PavementPiece.CORNER_SW)
             {
                 cityBlock.SetMiscTile(x, y, MiscPiece.STREET_LAMP_CORNER_SW);
             }
             else if (pavement == PavementPiece.CORNER_SE)
             {
                 cityBlock.SetMiscTile(x, y, MiscPiece.STREET_LAMP_CORNER_SE);
             }
             else if (pavement == PavementPiece.CORNER_NE)
             {
                 cityBlock.SetMiscTile(x, y, MiscPiece.STREET_LAMP_CORNER_NE);
             }
         }
     }
 }
Exemple #2
0
        static void SetBuildingsOnPavement(CityBlock cityBlock)
        {
            for (int x = 0; x < cityBlock.size.x; x++)
            {
                for (int y = 0; y < cityBlock.size.y; y++)
                {
                    var pavement = cityBlock.GetPavementTile(x, y);

                    if (pavement == PavementPiece.CORNER_NW)
                    {
                        cityBlock.SetBuildingTile(x, y, BuildingPiece.CORNER_NW);
                    }
                    else if (pavement == PavementPiece.CORNER_SW)
                    {
                        cityBlock.SetBuildingTile(x, y, BuildingPiece.CORNER_SW);
                    }
                    else if (pavement == PavementPiece.CORNER_SE)
                    {
                        cityBlock.SetBuildingTile(x, y, BuildingPiece.CORNER_SE);
                    }
                    else if (pavement == PavementPiece.CORNER_NE)
                    {
                        cityBlock.SetBuildingTile(x, y, BuildingPiece.CORNER_NE);
                    }
                    else if (pavement == PavementPiece.SIDE_S)
                    {
                        cityBlock.SetBuildingTile(x, y, BuildingPiece.SIDE_S);
                    }
                    else if (pavement == PavementPiece.SIDE_N)
                    {
                        cityBlock.SetBuildingTile(x, y, BuildingPiece.SIDE_N);
                    }
                    else if (pavement == PavementPiece.SIDE_W)
                    {
                        cityBlock.SetBuildingTile(x, y, BuildingPiece.SIDE_W);
                    }
                    else if (pavement == PavementPiece.SIDE_E)
                    {
                        cityBlock.SetBuildingTile(x, y, BuildingPiece.SIDE_E);
                    }
                }
            }
        }
Exemple #3
0
        public void Load(CityBlock cityBlock)
        {
            SetupDictionaries();

            // delete old city block (if any)
            if (loadedCityBlockHolder == null)
            {
                loadedCityBlockHolder = transform.Find(HOLDER_NAME);
            }
            if (loadedCityBlockHolder != null)
            {
                DestroyImmediate(loadedCityBlockHolder.gameObject);
            }

            // load new city block
            loadedCityBlock = cityBlock;

            // create holder
            loadedCityBlockHolder        = new GameObject(HOLDER_NAME).transform;
            loadedCityBlockHolder.parent = transform;

            for (int x = 0; x < loadedCityBlock.size.x; x++)
            {
                for (int y = 0; y < loadedCityBlock.size.y; y++)
                {
                    // create road entities
                    {
                        var type = loadedCityBlock.GetRoadTile(x, y);
                        if (type != RoadPiece.NONE)
                        {
                            var       prefab = roadPrefabs[type];
                            Transform road   = Instantiate(prefab) as Transform;
                            road.position += CoordToPosition(x, y, pieceWidth);
                            road.parent    = loadedCityBlockHolder;
                        }
                    }

                    // create pavement entities
                    {
                        var type = loadedCityBlock.GetPavementTile(x, y);
                        if (type != PavementPiece.NONE)
                        {
                            var       prefab   = pavementPrefabs[type];
                            Transform pavement = Instantiate(prefab) as Transform;
                            pavement.position += CoordToPosition(x, y, pieceWidth);
                            pavement.parent    = loadedCityBlockHolder;
                        }
                    }

                    // create building entities
                    {
                        var type = loadedCityBlock.GetBuildingTile(x, y);
                        if (type != BuildingPiece.NONE)
                        {
                            var       prefab   = buildingPrefabs[type];
                            Transform building = Instantiate(prefab) as Transform;
                            building.position += CoordToPosition(x, y, pieceWidth);
                            building.parent    = loadedCityBlockHolder;
                        }
                    }

                    // create misc entities
                    {
                        var type = loadedCityBlock.GetMiscTile(x, y);
                        if (type != MiscPiece.NONE)
                        {
                            var       prefab = miscPrefabs[type];
                            Transform misc   = Instantiate(prefab) as Transform;
                            misc.position += CoordToPosition(x, y, pieceWidth);
                            misc.parent    = loadedCityBlockHolder;
                        }
                    }
                }
            }
        }