public void OnMapDataReceived(MapGenerator.MapData mapData)
 {
     meshRenderer.sharedMaterial.mainTexture = TextureGenerator.TextureFromColorMap(
         mapData.colormap, MapGenerator.MapChunkSize, MapGenerator.MapChunkSize
         );
     mapGen.RequestMeshData(OnMeshDataReceived, mapData);
 }
Esempio n. 2
0
        } //Constructor

        public override MapGenerator.MapData Generate(MapGenerator.RoomsDataCollection rooms, int mapWidth, int mapHeight)
        {
            // Make sure there are rooms and there is map data, if not then ... return failure.
            if (rooms == null || rooms.Count == 0 || mapWidth <= 0 || mapHeight <= 0)
            {
                return(null);
            }

            // Resize the map to what we need.
            MapGenerator.MapData results = new MapGenerator.MapData(mapWidth, mapHeight);

            // Create the instance to the randomizer.
            MapHelpers.SetRandomSeed(this.Options.Seed);

            // (Step 1) Place the initial rooms to start out with.
            MapHelpers.PlotRandomRooms(results, rooms, MapHelpers.ComputeRandomRoomsCount(mapWidth, mapHeight, this.Options.RandomRoomsPercentage), this.Options.IgnoreBoundries, this.Options.SubsetID, this.Options.IncludeRooms, !this.Options.IncludeRooms, this.Options.Pattern, true);

            // (Step 2) Create the passages to connect each room together.
            MapHelpers.ConnectPathsets(results, rooms, this.Options.IgnoreBoundries, this.Options.SubsetID);

            // (Step 3) if(there is any left over path sets, remove them.
            //MapHelpers.RemoveAllSmallPathSets(results)

            // Remove the map data.
            return(results);
        } //Generate
Esempio n. 3
0
 public void Setup()
 {
     generator.GenerateMapDataAsync(new Vector2(chunkCoordinate.x * terrain.UnscaledChunkSize, chunkCoordinate.y * terrain.UnscaledChunkSize), (MapGenerator.MapData data) =>
     {
         this.data = data;
     });
 }
        } //Constructor

        public override MapGenerator.MapData Generate(MapGenerator.RoomsDataCollection rooms, int mapWidth, int mapHeight)
        {
            // Make sure there is rooms and map data, if not then ... exit.
            if (rooms == null || rooms.Count == 0 || mapWidth <= 0 || mapHeight <= 0)
            {
                return(null);
            }

            // Clear and resize the map.
            MapGenerator.MapData results = new MapGenerator.MapData(mapWidth, mapHeight);

            // Create the instance to the randomizer.
            MapHelpers.SetRandomSeed(this.Options.Seed);

            // (Step 1) Fill the map with random matching tiles.
            FillWithRandomTiles(results, rooms, this.Options.IgnoreBoundries, this.Options.SubsetID, this.Options.IncludeRooms, this.Options.IncludePassages, this.Options.Pattern);

            // (Step 2) Decide what to do with the unconnected tiles ...
            if (this.Options.UnconnectedTilesAction == UnconnectedTilesActions.ConnectAll)
            {
                // ... Connect all unconnected tiles.
                MapHelpers.ConnectPathsets(results, rooms, this.Options.IgnoreBoundries, this.Options.SubsetID);
            }
            else if (this.Options.UnconnectedTilesAction == UnconnectedTilesActions.RemoveSmallerSets)
            {
                // ... Remove all unconnected tiles.
                MapHelpers.RemoveAllSmallPathSets(results);
            }

            // Remove the map data.
            return(results);
        } //Generate
Esempio n. 5
0
    public void LoadTheProgress()
    {
        Debug.Log("try to load");
        StoredData data = SaveData.LoadGame();

        if (data != null)
        {
            Debug.Log("not null");
            if (data.canBeContinued)
            {
                Debug.Log("can load");
                continueButton.SetActive(true);

                mapGenerator.maxBricksAtXaxis = data.mapWidth;
                mapGenerator.maxBricksAtYaxis = data.mapHeight;
                GameplayManager.Instance.SetScoreValue(data.currentScore);
                GameplayManager.Instance.SetHealthValue(data.hp);
                mapGenerator.PositionAllBricks(data.coords);
                MapGenerator.MapData mapData = new MapGenerator.MapData();
                mapData.seed        = data.seed;
                mapData.fillPercent = data.fillPercent;
                mapGenerator.generatedMaps.Add(mapData);
            }
            else
            {
                continueButton.SetActive(false);
            }
        }
        else
        {
            continueButton.SetActive(false);
        }
    }
        } //Generate

        private static void FillWithRandomTiles(MapGenerator.MapData map, MapGenerator.RoomsDataCollection rooms, bool ignoreBoundries = false, string subSetID = "", bool allowRooms = true, bool allowPassages = true, Bitmap pattern = null)
        {
            for (int row = 1; row <= map.Height; row++)
            {
                for (int column = 1; column <= map.Width; column++)
                {
                    MapHelpers.PlotRandomRoom(map, rooms, column, row, ignoreBoundries, subSetID, allowRooms, allowPassages, pattern, false);
                } //column
            }     //row
        }         //FillWithRandomTiles
Esempio n. 7
0
 void OnMapDataReceived(MapGenerator.MapData mapData)
 {
     //绘制地图
     mapGenerator.RequesMeshData(mapData, OnMeshDataReceived);
 }