示例#1
0
 // FUNCTIONS //
 // init functions
 public void Init(Random rng, Point worldIndex, float[,] heightMap, bool containsDungeon)
 {
     WorldMapGeneration.GenerateForestMap(rng, this, worldIndex, heightMap);
     if (containsDungeon == true)
     {
         WorldMapGeneration.GenerateDungeonEntrance(this);
     }
     DetermineCost();
 }
示例#2
0
        // FUNCTIONS //

        public void GenerateWorldMap()
        {
            worldMap      = new MapTile[width, height];
            creatureTypes = DataReader.GetOverworldCreatureList();
            plantTypes    = DataReader.GetPlantList();

            Random rng = new Random(seed);

            SimplexNoise.Seed = this.seed;
            float scale = .005f;

            heightMap = SimplexNoise.Calc2D(tileWidth * width, tileHeight * height, scale);
            List <Point> potentialDungeons = new List <Point>();
            List <Point> dungeons          = new List <Point>();
            bool         dungeon           = false;

            WorldMapGeneration.GenerateRivers(rng, width, height, tileWidth, tileHeight, heightMap);

            for (int i = 0; i < width; i++)
            {
                for (int j = 0; j < height; j++)
                {
                    potentialDungeons.Add(new Point(i, j));
                }
            }
            for (int c = 0; c < 8; c++)
            {
                int index = rng.Next(0, potentialDungeons.Count);
                dungeons.Add(potentialDungeons[index]);
                potentialDungeons.RemoveAt(index);
            }

            for (int i = 0; i < width; i++)
            {
                for (int j = 0; j < height; j++)
                {
                    foreach (Point point in dungeons)
                    {
                        if (point.X == i && point.Y == j)
                        {
                            dungeon = true;
                        }
                    }
                    worldMap[i, j] = new MapTile(new Point(tileWidth, tileHeight), new Point(i, j), heightMap, plantTypes, creatureTypes, dungeon);
                    dungeon        = false;
                }
            }
            //for (int i = 1; i < 499; i++)
            //    for (int j = 1; j < 499; j++) {
            //        Point worldIndex = new Point( i / 100, j / 100 ), tilePosition = new Point( i % 100, j % 100 );
            //        worldMap[worldIndex.X, worldIndex.Y].Floor[tilePosition.X * 100 + tilePosition.Y].Explored = true;
            //        worldMap[worldIndex.X, worldIndex.Y].Blocks[tilePosition.X * 100 + tilePosition.Y].Explored = true;
            //    }
            OnFinishedGenerating(this, EventArgs.Empty);
        }