Esempio n. 1
0
        public byte[] generateMap(generationOptions options, int width, int height)
        {
            mRand = new Random(options.RandomSeed);

            mMapType = options.LayoutType;
            mWidth   = width;
            mHeight  = height;

            byte[] b = new byte[width * height];

            List <Point> startingLocations = new List <Point>();
            List <Point> battleLocations   = new List <Point>();
            List <Point> interestLocations = new List <Point>();

            generateLocations(mMapType, width, height, ref startingLocations, ref battleLocations, ref interestLocations);
            generateConnectivityGraph(startingLocations, battleLocations, interestLocations);


            for (int i = 0; i < startingLocations.Count; i++)
            {
                drawCircle(startingLocations[i], options.BaseAreaWidth, options.BaseAreaWidth, ref b);
                for (int k = 0; k < battleLocations.Count; k++)
                {
                    drawLine(startingLocations[i], battleLocations[k], options.MainPathWidth, ref b);
                }
            }
            for (int i = 0; i < interestLocations.Count; i++)
            {
                drawCircle(interestLocations[i], options.InterestAreaWidth, options.InterestAreaWidth, ref b);
            }
            for (int i = 0; i < battleLocations.Count; i++)
            {
                drawCircle(battleLocations[i], options.InterestAreaWidth, options.InterestAreaWidth, ref b);
            }



            addNoiseToMap(ref b, options.RandomSeed, options.ClampStep);
            peterbMap(ref b, options.RandomSeed);


            flipMap(options, ref b);

            int smoothAmt = 4;

            for (int i = 0; i < smoothAmt; i++)
            {
                smoothFilter(ref b, mWidth, mHeight);
            }

            mRand = null;

            return(b);
        }
Esempio n. 2
0
        void flipMap(generationOptions options, ref byte[] map)
        {
            if (options.AllowHorizontalFlip)
            {
                if (mRand.NextDouble() > options.HorizontalFlipFrequency)
                {
                    flipMapHorizontal(ref map);
                }
            }

            if (options.AllowVerticalFlip)
            {
                if (mRand.NextDouble() > options.VerticalFlipFrequency)
                {
                    flipMapVertical(ref map);
                }
            }
        }