Exemple #1
0
        public static void Test(int width, int height, int depth)
        {
            List <MapData> mapDatas = new List <MapData> {
                new Example1(),
                new Example2(),
                new Example3(),
            };

            /* Random random = new Random();
             * GenericBuffer<bool> buffer = GenericBuffer<bool>.MakeGenericBufferBySize(width, height);
             * MapData mapData = Utility.Choice(mapDatas);
             * MapNode mapNode = new MapNode(buffer.Center, mapData);
             *
             * if (mapNode.Generate(mapDatas, buffer, depth, random) == false){
             *      throw new Exception("mapNode.Generate() was failed!");
             * }
             *
             * Debug.DumpBuffer(buffer); */

            MapGenerator mapGenerator = new MapGenerator(mapDatas);
            MapNode      mapNode      = mapGenerator.Generate(width, height, depth);

            if (mapNode == null)
            {
                throw new Exception("mapNode.Generate() was failed!");
            }

            GenericBuffer <bool> buffer = GenericBuffer <bool> .MakeGenericBufferBySize(width, height);

            mapNode.WriteTo(buffer);
            Debug.DumpBuffer(buffer);
        }
Exemple #2
0
        public virtual MapNode Generate(int width, int height, int depth, Position pos)
        {
            GenericBuffer <bool> buffer = GenericBuffer <bool> .MakeGenericBufferBySize(width, height);

            MapData mapData = ChoiceRandomMapData();
            MapNode mapNode = new MapNode(pos, mapData);

            if (mapNode.Generate(MapDatas, buffer, depth, Random) == false)
            {
                return(null);
            }
            return(mapNode);
        }