Exemple #1
0
        public RMGPath(RoadMapGen map, RMTile start, RMTile end)
        {
            this.map    = map;
            this.width  = map.width;
            this.height = map.height;
            nodes       = new RMGNode[width, height];
            for (int x = 0; x < width; x += 1)
            {
                for (int y = 0; y < height; y += 1)
                {
                    nodes[x, y] = new RMGNode(map, x, y);
                }
            }

            for (int x = 0; x < width; x += 1)
            {
                for (int y = 0; y < height; y += 1)
                {
                    RMGNode n = nodes[x, y];

                    n.neighbours[0] = getNode(x - 1, y);
                    n.neighbours[1] = getNode(x + 1, y);
                    n.neighbours[2] = getNode(x, y - 1);
                    n.neighbours[3] = getNode(x, y + 1);
                }
            }



            this.start = getNode(start.x, start.y);
            this.end   = getNode(end.x, end.y);

            //Debug.Log("end = " + end);
        }
Exemple #2
0
        public RMGNode(RoadMapGen map, int x, int y)
        {
            this.x = x;
            this.y = y;

            this.tile  = map.GetTile(x, y);
            moveFactor = tile.GetMovementFactor();
        }
Exemple #3
0
        private static void MakeBuildings(RoadMapGen roadmap)
        {
            for (int y = 2; y < roadmap.height; y += BLOCK_WIDTH)
            {
                roadmap.SearchForBuildings(y, 1);
                roadmap.SearchForBuildings(y + (BLOCK_WIDTH - 3), -1);
            }

            for (int x = 2; x < roadmap.width; x += BLOCK_WIDTH)
            {
                roadmap.SearchForBuildingsX(x, 1);
                roadmap.SearchForBuildingsX(x + (BLOCK_WIDTH - 3), -1);
            }
            roadmap.ProcBuildings();

            //roadmap.SetBuildingEdges();
        }
Exemple #4
0
        public static RoadMapGen Generate(int widthInTiles, int heightInTiles, int numGroundTileTypes)
        {
            RoadMapGen roadmap = new RoadMapGen();

            roadmap.rng                = new System.Random();
            roadmap.width              = widthInTiles;
            roadmap.height             = heightInTiles;
            roadmap.numGroundTileTypes = numGroundTileTypes;

            roadmap.tiles = new RMTile[roadmap.width, roadmap.height];

            for (int x = 0; x < roadmap.width; x += 1)
            {
                for (int y = 0; y < roadmap.height; y += 1)
                {
                    roadmap.tiles[x, y] = new RMTile(roadmap, x, y);
                }
            }

            roadmap.MakeRoads();
            MakeBuildings(roadmap);
            roadmap.UpdateTiles();

            for (int i = 0; i < 10; i += 1)
            {
                //roadmap.TryWave(TYPE.GROUND_SAND);
                //roadmap.TryWave(TYPE.GROUND_GRASS);
                for (int j = 0; j < roadmap.numGroundTileTypes; j += 1)
                {
                    roadmap.TryWave(UnityEngine.Random.Range(0, roadmap.numGroundTileTypes));
                    roadmap.SmoothMap(2, 4);
                }
                roadmap.SmoothMap(6, 4);
            }

            roadmap.TryWater();
            //roadmap.SmoothMap(3, 4);



            roadmap.SaveToPng();


            return(roadmap);
        }
Exemple #5
0
 public RMTile(RoadMapGen map, int x, int y)
 {
     this.x   = x;
     this.y   = y;
     this.map = map;
 }