Beispiel #1
0
            public override void Generate(Random rand, int prob)
            {
                this.North = GetBlockAt(this.X, this.Y - 1);
                if (North == null && rand.Next(0, 100) < prob && IsInsideCity(this.X, this.Y - 1))
                {
                    North = new StreetBlock(rand, this.IdSeed, Generator.Orientation.Vertical, City, this.X, this.Y - 1);
                    North.Generate(rand, prob - 1);
                }

                this.South = GetBlockAt(this.X, this.Y + 1);
                if (South == null && rand.Next(0, 100) < prob && IsInsideCity(this.X, this.Y + 1))
                {
                    South = new StreetBlock(rand, this.IdSeed, Generator.Orientation.Vertical, City, this.X, this.Y + 1);
                    South.Generate(rand, prob - 1);
                }

                this.East = GetBlockAt(this.X + 1, this.Y);
                if (East == null && rand.Next(0, 100) < prob && IsInsideCity(this.X + 1, this.Y))
                {
                    East = new StreetBlock(rand, this.IdSeed, Generator.Orientation.Horizontal, City, this.X + 1, this.Y);
                    East.Generate(rand, prob - 1);
                }

                this.West = GetBlockAt(this.X - 1, this.Y);
                if (West == null && rand.Next(0, 100) < prob && IsInsideCity(this.X - 1, this.Y))
                {
                    West = new StreetBlock(rand, this.IdSeed, Generator.Orientation.Horizontal, City, this.X - 1, this.Y);
                    West.Generate(rand, prob - 1);
                }
            }
Beispiel #2
0
            public void GenerateCityBuildings(Random rand)
            {
                for (int y = 0; y < City.GetLength(1); y++)
                {
                    for (int x = 0; x < City.GetLength(0); x++)
                    {
                        Block block = City[x, y];

                        if (block == null)
                        {
                            StreetBlock a = GetBlockAt(x - 1, y) as StreetBlock;
                            StreetBlock b = GetBlockAt(x + 1, y) as StreetBlock;
                            StreetBlock c = GetBlockAt(x, y + 1) as StreetBlock;
                            StreetBlock d = GetBlockAt(x, y - 1) as StreetBlock;

                            if (a != null || b != null || c != null || d != null)
                            {
                                CityBuildingBlock newBlock = new CityBuildingBlock(rand, this.IdSeed, City, x, y);

                                newBlock.North = GetBlockAt(x, y - 1);
                                newBlock.South = GetBlockAt(x, y + 1);
                                newBlock.East  = GetBlockAt(x + 1, y);
                                newBlock.West  = GetBlockAt(x - 1, y);
                            }
                        }
                    }
                }
            }