/// <summary> /// Если размер мира 1*1 в зависимости от сида генерим тот или иной тестовый мир, иначе генерим по чсестному /// </summary> public Surface() { Ambient = new FColor(1f, 1f, 1f, 0.9f).Multiply(1.0f); switch (Constants.WORLD_MAP_SIZE) { case 1: var r1 = new TestSurfaceGenerator1x1(World.Rnd); m_worldMap = r1.Generate(); City = new SuperCity(this, new Point(0, 0)); break; case 2: var r2 = new TestSurfaceGenerator2x2(World.Rnd); m_worldMap = r2.Generate(); City = new SuperCity(this, new Point(0, 0)); break; default: var worldMapGenerator = new WorldMapGenerator(Constants.WORLD_MAP_SIZE, World.Rnd); m_worldMap = worldMapGenerator.Generate(); if (Constants.WORLD_MAP_SIZE > 31) { var cityBlockIds = worldMapGenerator.FindCityPlace((int)Math.Sqrt(Constants.WORLD_MAP_SIZE) / 2).ToArray(); foreach (var id in cityBlockIds) { m_worldMap[id.X, id.Y] = EMapBlockTypes.CITY; } City = new SuperCity(this, cityBlockIds.Select(_point => new Point(_point.X - Constants.WORLD_MAP_SIZE / 2, _point.Y - Constants.WORLD_MAP_SIZE / 2)).ToArray()); } break; } }
protected override MapBlock GenerateBlock(Point _blockId) { var block = SurfaceBlockGenerator.GenerateBlock(_blockId, this); var rnd = new Random(block.RandomSeed); var baseType = GetBlockType(_blockId); if (baseType == EMapBlockTypes.CITY) { City.GenerateCityBlock(block, rnd, this); } var trees = EssenceHelper.GetAllThings <Tree>().ToArray(); var shrubs = EssenceHelper.GetAllThings <Shrub>().ToArray(); foreach (var point in new Rct(0, 0, Constants.MAP_BLOCK_SIZE, Constants.MAP_BLOCK_SIZE).AllPoints) { switch (block.Map[point.X, point.Y]) { case ETerrains.FOREST: switch (rnd.Next(10)) { case 0: case 1: block.AddEssence(shrubs.RandomItem(rnd), point); break; case 2: case 3: case 4: block.AddEssence(trees.RandomItem(rnd), point); break; } break; case ETerrains.SHRUBS: switch (rnd.Next(7)) { case 0: case 1: case 2: case 3: block.AddEssence(shrubs.RandomItem(rnd), point); break; case 4: block.AddEssence(trees.RandomItem(rnd), point); break; } break; } } if (Constants.WORLD_MAP_SIZE == 1) { TestSurfaceGenerator1x1.Fill(block, Constants.WORLD_SEED, baseType); } else { GenerateRandomItems(rnd, block); } return(block); }