/// <summary>
        /// ctor
        /// </summary>
        /// <param name="coordinates">coordinates class</param>
        /// <param name="map">mapobejct array</param>
        public MapObjectCoordinates(Coordinates coordinates, MapObject[] map)
        {
            _center = map[coordinates.Center];
            _north = map[coordinates.North];
            _south = map[coordinates.South];
            _east = map[coordinates.East];
            _west = map[coordinates.West];
            _northWest = map[coordinates.NorthWest];
            _northEast = map[coordinates.NorthEast];
            _southWest = map[coordinates.SouthWest];
            _southEast = map[coordinates.SouthEast];

            List = new[] { _center, _north, _south, _east, _west, _northEast, _northWest, _southEast, _southWest };
        }
Exemplo n.º 2
0
        private static void SmoothWorker(AreaColor area,AreaColor center, MapObject mapObject, Random random, int index)
        {
            if (area.Type == TypeColor.WaterCoast || area.Type == TypeColor.Water || mapObject.Occupied != 0) return;

            var k = (sbyte)random.Next(center.CoastSmoothCircles[index].From, center.CoastSmoothCircles[index].To);
            if(mapObject.Altitude > k)
                mapObject.Altitude = k;
        }
Exemplo n.º 3
0
        private static void NorthEastSmooth
            (Coordinates coordinates,
            int xmax,
            int ymax,
            int stride,
            AreaColor[] bitmap,
            MapObject[] mapobjects,
            Random random)
        {
            for (int i = 0; i < bitmap[coordinates.Center].CoastSmoothCircles.Count; i++)
            {
                var coordnew = new Coordinates(i + 1, i + 1, coordinates.X, coordinates.Y, stride, xmax * ymax);
                var areacoloronew = new AreaColorCoordinates(coordnew, bitmap);
                var mapobjectCoordnew = new MapObjectCoordinates(coordnew, mapobjects);


                SmoothWorker(areacoloronew.East, areacoloronew.Center, mapobjectCoordnew.East, random, i);
                SmoothWorker(areacoloronew.North, areacoloronew.Center, mapobjectCoordnew.North, random, i);
                SmoothWorker(areacoloronew.NorthEast, areacoloronew.Center, mapobjectCoordnew.NorthEast, random, i);
            }
        }
Exemplo n.º 4
0
        ///// <summary>
        ///// Class costructor
        ///// </summary>
        ///// <param name="map">map cached previusly</param>
        ///// <param name="alt">map altitude cached</param>
        ///// <param name="x">max x of the map</param>
        ///// <param name="y">max y of the map</param>
        ///// <param name="index">index of the map</param>
        //public MapMaker(Color[] map, Color[] alt, int x, int y, int index)
        //{

        //    _bitmap = map;
        //    var x1 = x + 10;
        //    var y1 = y + 10;
        //    var lenght = x1 * y1;
        //    #region InitArrays

        //    _mapObjects = new MapObject[lenght];
        //    _bitmapZ = new sbyte[lenght];
        //    for (int i = 0; i < alt.Length; i++)
        //    {
        //        _bitmapZ[i] = CalculateHeightValue(alt[i]);

        //    }

        //    for (int i = 0; i < _mapObjects.Length; i++)
        //    {
        //        _mapObjects[i] = new MapObject();
        //    }
        //    #endregion

        //    _X = x;
        //    _Y = y;

        //    MulDirectory = "";
        //    mapIndex = index;
        //    _stride = _X;
        //    Random = new Random(DateTime.Now.Millisecond);

        //    AutomaticZMode = true;
        //}


        public MapMaker(sbyte[] altitude, AreaColor[] colors, int x, int y, int index)
        {
            var x1 = x + 10;
            var y1 = y + 10;
            var lenght = x1*y1;


            #region Init Arrays

            _mapObjects = new MapObject[lenght];
            _bitmapZ = new sbyte[lenght];
            _bitmapAreaColor = new AreaColor[lenght];


            for (int i = 0; i < altitude.Length; i++)
            {
                _bitmapZ[i] = altitude[i];
                _bitmapAreaColor[i] = colors[i];
            }

            for (int i = 0; i < lenght; i++)
            {
                _mapObjects[i] = new MapObject();
            }

            #endregion //init arrays


            _X = x;
            _Y = y;
            MulDirectory = "";
            mapIndex = index;
            _stride = _X;
        }