Пример #1
0
        /// <summary>
        /// Generate a TestTerrain
        /// </summary>
        /// <param name="x">Size X</param>
        /// <param name="y">Size Y</param>
        /// <returns>Completed GameMap</returns>
        public GameMap GenerateTestTerran(int x, int y)
        {
            LandMassGenerator lmg      = new LandMassGenerator();
            PointGroup        ocean    = lmg.GenerateOcean(x, y);
            PointGroup        LandMass = new PointGroup();
            PointGroup        IceCaps  = new PointGroup();
            PointGroup        Deserts  = new PointGroup();
            PointGroup        Swamp    = new PointGroup();
            MapConsolidator   mc       = new MapConsolidator();

            //***LandMass***
            //right side of planet
            LandMass.AddRange(lmg.GenerateContinent(x / 4, y / 4, 10, 20, 20));        //Canada region
            LandMass.AddRange(lmg.GenerateContinent(x / 2, y / 4, 4, 10, 10));         //Greenland Region
            LandMass.AddRange(lmg.GenerateContinent(x / 4, y / 3, 7, 20, 30));         //North America region
            LandMass.AddRange(lmg.GenerateContinent(x / 4, y / 2, 4, 10, 10));         //Centeral America Region
            LandMass.AddRange(lmg.GenerateContinent(x / 4, y * 3 / 4, 7, 20, 20));     //South America region
            //left side of planet
            LandMass.AddRange(lmg.GenerateContinent(x * 3 / 4, y / 4, 10, 20, 30));    //Siberia Region
            LandMass.AddRange(lmg.GenerateContinent(x * 2 / 3, y / 3, 4, 10, 10));     //Europe Region
            LandMass.AddRange(lmg.GenerateContinent(x * 2 / 3, y * 2 / 3, 7, 20, 20)); //Africa Region
            LandMass.AddRange(lmg.GenerateContinent(x * 3 / 4, y * 3 / 4, 3, 10, 10)); //Australia Region
            LandMass.AddRange(lmg.GenerateContinent(x * 7 / 8, y / 2, 7, 10, 10));     //Asian Region
            //South Pole
            LandMass.AddRange(lmg.GenerateContinent(x / 2, y, 3, 10, 10));             //South pole land
            IceCaps.AddRange(lmg.GenerateIceCaps(x, y));                               //Ice Caps
            //***LandMass SubRegions***
            //Deserts
            Deserts.AddRange(lmg.GenerateDesert(LandMass, 20, 10));
            Deserts.AddRange(lmg.GenerateDesert(LandMass, 20, 10));
            //Swamps
            Swamp.AddRange(lmg.GenerateSwamp(LandMass, 20, 10));
            Swamp.AddRange(lmg.GenerateSwamp(LandMass, 20, 10));

            LandMass = MapWrap(LandMass, x);
            LandMass = mc.ConsolidateGroupPoints(new List <PointGroup> {
                ocean, LandMass, Deserts, Swamp
            });

            LandMass.AddRange(IceCaps);
            return(ColorMap(LandMass, x, y));
            //return LandMass;
        }
Пример #2
0
        /// <summary>
        /// Generate the IceCaps
        /// </summary>
        /// <param name="sizex"></param>
        /// <param name="sizey"></param>
        /// <returns></returns>
        public PointGroup GenerateIceCaps(int sizex, int sizey)
        {
            int miny = sizey / 8;
            int maxy = sizey * 7 / 8;
            PointGroupGenerator pgg = new PointGroupGenerator();

            PointGroup caps = new PointGroup();

            caps.AddRange(pgg.GenerateBox(0, 0, sizex, miny, (sizex + sizey) * 2, MapTerrain.Ice));
            caps.AddRange(pgg.GenerateBox(0, maxy, sizex, sizey, (sizex + sizey) * 2, MapTerrain.Ice));

            foreach (MapPoint mp in caps)
            {
                mp.Terrain = IceOrOcean(mp.Y, sizey);
            }
            PointGroup newpointgroup = new PointGroup();

            newpointgroup.AddRangeAlpha(caps, MapTerrain.Ocean);
            return(newpointgroup);
        }
Пример #3
0
        /// <summary>
        /// Generate a continent
        /// </summary>
        /// <param name="x">X start</param>
        /// <param name="y">Y start</param>
        /// <param name="clusters">Number of clusters</param>
        /// <param name="clustersize">distance between cluster center nodes</param>
        /// <param name="clusterpoints">Number of points in each cluster.</param>
        /// <returns>Continent</returns>
        public PointGroup GenerateContinent(int x, int y, int clusters, int clustersize, int clusterpoints)
        {
            PointGroupGenerator pgg          = new PointGroupGenerator();
            PointGroup          clusternodes = pgg.GenerateCluster(x, y, clusters, MapTerrain.Plains, clustersize);
            PointGroup          landmass     = new PointGroup();

            foreach (MapPoint mp in clusternodes)
            {
                landmass.AddRange(pgg.GenerateCluster(mp.X, mp.Y, clusterpoints, MapTerrain.Plains, 5));
            }
            return(landmass);
        }
Пример #4
0
        /// <summary>
        /// Consolidate MapPoints, destroyes overlap.
        /// </summary>
        /// <param name="lpg">List of PointGroups to consolidate.</param>
        /// <returns>Consolidated MapPoints.</returns>
        public PointGroup ConsolidateGroupPoints(List <PointGroup> lpg)
        {
            PointGroup ConsolidatedPoints = new PointGroup();
            PointGroup removegroup        = new PointGroup();

            foreach (PointGroup pg in lpg)
            {
                for (int i = 0; i < ConsolidatedPoints.Count; i++)
                {
                    if (pg.InBounds(ConsolidatedPoints[i], 5))
                    {
                        removegroup.Add(ConsolidatedPoints[i]);
                    }
                }
                foreach (MapPoint mp in removegroup)
                {
                    ConsolidatedPoints.Remove(mp);
                }
                removegroup.Clear();
                ConsolidatedPoints.AddRange(pg);
            }
            return(ConsolidatedPoints);
        }
Пример #5
0
        public GameMap GenerateTerran()
        {
            PointGroup Land   = new PointGroup();
            PointGroup Desert = new PointGroup();
            PointGroup Swamp  = new PointGroup();
            PointGroup Ocean  = new PointGroup();

            LandMassGenerator lmg = new LandMassGenerator();
            MapConsolidator   mc  = new MapConsolidator();

            //Left Side of Planet
            DrawLandMassStartEvent?.Invoke(this, "Continents");
            Land.AddRange(lmg.GenerateContinent(SizeX / 4, SizeY / 4, MediumContinentPoints, MediumContinentSize, MediumContinentClusterPoints));         //North America
            Land.AddRange(lmg.GenerateContinent(SizeX / 4, SizeY / 2, SmallContinentPoints, SmallContinentSize, SmallContinentClusterPoints));            //Central America
            Land.AddRange(lmg.GenerateContinent(SizeX / 4, SizeY * 3 / 4, MediumContinentPoints, MediumContinentSize, MediumContinentClusterPoints));     //South America
            //Right Side of Planet
            Land.AddRange(lmg.GenerateContinent(SizeX * 7 / 8, SizeY / 4, HugeContinentPoints, HugeContinentSize, HugeContinentClusterPoints));           //Asia
            Land.AddRange(lmg.GenerateContinent(SizeX * 2 / 3, SizeY / 2, SmallContinentPoints, SmallContinentSize, SmallContinentClusterPoints));        //Europe
            Land.AddRange(lmg.GenerateContinent(SizeX * 2 / 3, SizeY * 3 / 4, MediumContinentPoints, MediumContinentSize, MediumContinentClusterPoints)); //Africa
            Land.AddRange(lmg.GenerateContinent(SizeX * 3 / 4, SizeY * 3 / 4, SmallContinentPoints, SmallContinentSize, SmallContinentClusterPoints));    //Oceania
            DrawLandMassFinishEvent?.Invoke(this, "Continents");
            //Deserts
            DrawLandMassStartEvent?.Invoke(this, "Desert");
            Desert.AddRange(lmg.GenerateDesert(Land, IslandPoints));
            Desert.AddRange(lmg.GenerateDesert(Land, IslandPoints));
            Desert.AddRange(lmg.GenerateDesert(Land, IslandPoints));
            DrawLandMassFinishEvent?.Invoke(this, "Desert");
            //Swamp
            DrawLandMassStartEvent?.Invoke(this, "Swamp");
            Swamp.AddRange(lmg.GenerateSwamp(Land, IslandPoints));
            Swamp.AddRange(lmg.GenerateSwamp(Land, IslandPoints));
            Swamp.AddRange(lmg.GenerateSwamp(Land, IslandPoints));
            DrawLandMassFinishEvent?.Invoke(this, "Swamp");
            //Ocean
            DrawLandMassStartEvent?.Invoke(this, "Ocean");
            Ocean.AddRange(lmg.GenerateOcean(SizeX, SizeY));
            DrawLandMassFinishEvent?.Invoke(this, "Ocean");
            //SouthPole
            DrawLandMassStartEvent?.Invoke(this, "Polar caps");
            Land.AddRange(lmg.GenerateContinent(SizeX / 2, SizeY, SmallContinentPoints, SmallContinentSize, SmallContinentClusterPoints)); //Antartica Land
            Land.AddRange(lmg.GenerateIceCaps(SizeX, SizeY));
            DrawLandMassFinishEvent?.Invoke(this, "Polar caps");

            DrawLandMassStartEvent?.Invoke(this, "Consildated Map");
            Land = mc.ConsolidateGroupPoints(new List <PointGroup>()
            {
                Ocean, Land, Desert, Swamp
            });
            DrawLandMassFinishEvent?.Invoke(this, "Consildated Map");

            DrawLandMassStartEvent?.Invoke(this, "Wrap Map");
            Land = MapWrap(Land, SizeX);
            DrawLandMassFinishEvent?.Invoke(this, "Wrap Map");

            DrawLandMassStartEvent?.Invoke(this, "Color map");
            GameMap gamemap = ColorMap(Land, SizeX, SizeY);

            DrawLandMassFinishEvent?.Invoke(this, "Color map");

            return(gamemap);
        }