Esempio n. 1
0
        public void GenerateNewMap(int maptype)
        {
            //actual height of land

            switch (maptype)
            {
            default:
                //set default 0
                InitialiseMapData();
                int[,] HeightData = InitialiseHeightData();

                //smoothing
                Smooth(ref HeightData, SmoothTimes);

                //now that we have height data-write to the tilemap
                SetMapDataFromHeight(HeightData);

                //trees add
                GenerateTrees(HeightData);

                bool[,] cellmap = CellAutomata.CellMap(Width, ChunkWidth, Height, CADepthCaves,
                                                       CACaveschance, CACaveSteps, CavesdeathLimit, CavesbirthLimit);

                //generateCaves
                GenerateCaves(cellmap);

                //treasure
                PlaceTreasuresInCaves(cellmap);
                break;
            }
            UpdateAllTiles();
        }
Esempio n. 2
0
        private void PlaceTreasuresInCaves(bool[,] cellmap)
        {
            //How hidden does a spot need to be for treasure?
            for (int x = 0; x < ChunkWidth * Width; x++)
            {
                for (int y = CADepthCaves; y < Height; y++)
                {
                    if (!cellmap[x, y])
                    {
                        int nbs = CellAutomata.countAliveNeighbours(cellmap, x, y, ChunkWidth, Width, Height);
                        if (nbs >= treasureHiddenLimit)
                        {
                            //Place chest

                            /*
                             * int cx = (x / Width);
                             * int xnew = x % Width;
                             * MapData[cx, xnew, y] = 4;
                             */
                        }
                    }
                }
            }
        }