Пример #1
0
        public static void SidesOcean(HexagonCollection collection, WorldGenParamters world)
        {
            List <int> rows = new List <int>()
            {
                0, 1, world.MaxRows - 2, world.MaxRows - 1
            };

            foreach (int row in rows)
            {
                for (int col = 0; col < world.MaxCol; col++)
                {
                    collection.Get(row, col).Elevation = -500;
                }
            }

            List <int> cols = new List <int>()
            {
                0, world.MaxCol - 1
            };

            foreach (int col in cols)
            {
                for (int row = 0; row < world.MaxRows; row++)
                {
                    var hex = collection.Get(row, col);
                    hex.Elevation           = -500;
                    hex.Terrain.TerrainEnum = TerrainEnum.Grassland;
                }
            }
        }
Пример #2
0
        private static HexagonCollection MakeDefaultHexagons(int maxX, int maxY, bool wrapEastWest)
        {
            var hexList = new List <HexagonData>();

            for (int i = 0; i < maxX; i++)
            {
                for (int j = 0; j < maxY; j++)
                {
                    hexList.Add(new HexagonData()
                    {
                        Row       = i,
                        Col       = j,
                        Terrain   = Terrain.EnumMap[TerrainEnum.NoTerrain],
                        Elevation = 0
                    });
                }
            }

            var collection = new HexagonCollection(hexList, wrapEastWest, maxY);

            return(collection);
        }
Пример #3
0
        // Mutates the collection.
        public static void FillAll(HexagonCollection collection, int maxRow)
        {
            var seeds = collection.List().Where(h => h.Terrain.TerrainEnum != TerrainEnum.NoTerrain);

            if (!seeds.Any())
            {
                throw new InvalidOperationException("Needs seeds to generate.");
            }
            else
            {
                foreach (var seed in seeds)
                {
                    stack.Push(new RecursiveFillCommand()
                    {
                        collection = collection, hex = seed
                    });
                }
            }

            while (stack.Count > 0)
            {
                FillAllRecursive(stack.Pop(), maxRow);
            }
        }
Пример #4
0
 public static void CenterSeed(HexagonCollection collection, WorldGenParamters world)
 {
     collection.Get(world.MaxRows / 2, world.MaxCol / 2).Terrain = Terrain.EnumMap[TerrainEnum.Grassland];
 }
Пример #5
0
 public WorldController()
 {
     this.collection = TerrainController.GenerateWorld(parameters);
 }