Ejemplo n.º 1
0
        private int GenerateDepthSide(int limit1, int limit2, MapSliders sliders)
        {
            //var depth = (limit1 + limit2) / 2;

            int delta       = Math.Abs(limit1 - limit2) / 2;
            int overweight  = delta * sliders.OverheightTh / 1000 + sliders.OverheightLn;
            int underweight = delta * sliders.UnderheightTh / 1000 + sliders.UnderheightLn;
            int slide       = Randomizer.Next(overweight + underweight - sliders.MinimumDistance) - underweight;

            slide = slide + ((slide > 0)?sliders.MinimumDistance / 2: -sliders.MinimumDistance / 2);
            return((limit1 + limit2) / 2 + slide);
            //return (limit1 + limit2) / 2 + Randomizer.Next(sliders.Overheight + sliders.Underheight) - sliders.Underheight;
        }
Ejemplo n.º 2
0
        private int GenerateDepthMid(int limit1, int limit2, int limit3, int limit4, MapSliders sliders)
        {
            int middle = (limit1 + limit2 + limit3 + limit4) / 4;

            int deltaO = Max(limit1, limit2, limit3, limit4) - middle;
            int deltaU = middle - Min(limit1, limit2, limit3, limit4);

            int overweight  = deltaO * sliders.OverheightTh / 1000 + sliders.OverheightLn;
            int underweight = deltaU * sliders.UnderheightTh / 1000 + sliders.UnderheightLn;

            return(middle + Randomizer.Next(overweight + underweight) - underweight);

            return((limit1 + limit2 + limit3 + limit4) / 4);
        }
Ejemplo n.º 3
0
        private void GenerateMap(int left, int top, int right, int bottom, MapSliders sliders)
        {
            var lt = MapTiles[top, left].Terrain.Depth;
            var lb = MapTiles[bottom, left].Terrain.Depth;
            var rt = MapTiles[top, right].Terrain.Depth;
            var rb = MapTiles[bottom, right].Terrain.Depth;

            int midV = (top + bottom) / 2;
            int midH = (left + right) / 2;


            if (MapTiles[midV, left] == null)
            {
                MapTiles[midV, left] = GenerateTile(GenerateDepthSide(lt, lb, sliders));//Mid Left
            }
            if (MapTiles[midV, right] == null)
            {
                MapTiles[midV, right] = GenerateTile(GenerateDepthSide(rt, rb, sliders));//Mid Right
            }
            if (MapTiles[top, midH] == null)
            {
                MapTiles[top, midH] = GenerateTile(GenerateDepthSide(lt, rt, sliders));//Mid Top
            }
            if (MapTiles[bottom, midH] == null)
            {
                MapTiles[bottom, midH] = GenerateTile(GenerateDepthSide(lb, rb, sliders));//Mid Bottom
            }
            //MapTiles[midV, midH] = GenerateTile(GenerateDepthMid(lt, lb, rt, rb, sliders));//Mid
            MapTiles[midV, midH] = GenerateTile(GenerateDepthMid(
                                                    MapTiles[midV, left].Terrain.Depth,
                                                    MapTiles[midV, right].Terrain.Depth,
                                                    MapTiles[top, midH].Terrain.Depth,
                                                    MapTiles[bottom, midH].Terrain.Depth, sliders));//Mid

            if ((bottom - top) > 2)
            {
                var newSliders = sliders.Next(left, top);
                GenerateMap(left, top, midH, midV, newSliders);
                GenerateMap(midH, top, right, midV, newSliders);
                GenerateMap(left, midV, midH, bottom, newSliders);
                GenerateMap(midH, midV, right, bottom, newSliders);
            }
        }
Ejemplo n.º 4
0
            internal MapSliders Next(int x, int y)
            {
                var result = new MapSliders()
                {
                    //UnderheightTh = (int)(Math.Sqrt(UnderheightTh) * 24), OverheightTh = (int)(Math.Sqrt(OverheightTh) * 24),
                    //UnderheightTh = (int)Math.Pow(UnderheightTh, (double)98 / 100),//* 80 / 100,
                    UnderheightTh = UnderheightTh * 75 / 100,
                    //OverheightTh = (int)Math.Pow(OverheightTh, (double)98 / 100),//OverheightTh * 80 / 100,
                    OverheightTh = OverheightTh * 75 / 100,
                    //UnderheightLn = (int)Math.Pow(UnderheightLn, (double)90 / 100),//UnderheightLn * 00 / 100,
                    UnderheightLn = UnderheightLn * 45 / 100,
                    //UnderheightLn = UnderheightLn - 4000,
                    //OverheightLn = (int)Math.Pow(OverheightLn, (double)90 / 100),//OverheightLn * 00 / 100,
                    OverheightLn = OverheightLn * 45 / 100,
                    //OverheightLn = OverheightLn - 4000,
                    //MinimumDistance = (int)Math.Pow(MinimumDistance, (double)00 / 100),//OverheightLn * 00 / 100,
                    MinimumDistance = MinimumDistance * 00 / 100,
                };

                result.Init();
                return(result);
            }