예제 #1
0
        /// <summary>
        ///     Creates a nee tile map
        /// </summary>
        /// <param name="chunksize">The lenght of each side of a chunk. Must be greater than two.</param>
        public TileMap(int chunksize)
        {
            if (chunksize <= 2)
            {
                throw new ArgumentException("Chunksize must be greater than 2.", nameof(chunksize));
            }

            _map  = new TileChunk <T>(chunksize);
            _size = new ChunckSize(chunksize);
        }
예제 #2
0
        public T this[int x, int y]
        {
            get
            {
                (int xMajor, int xminor) = TranslateCoordinate(x);
                (int yMajor, int yminor) = TranslateCoordinate(y);

                IRecursiveTileMap <T> submap = _submap[xMajor, yMajor];

                return(submap == null ? default : submap[xminor, yminor]);
            }
            set
            {
                (int xMajor, int xminor) = TranslateCoordinate(x);
                (int yMajor, int yminor) = TranslateCoordinate(y);

                IRecursiveTileMap <T> submap = _submap[xMajor, yMajor] ?? (_submap[xMajor, yMajor] = GenerateSubmap());

                submap[xminor, yminor] = value;
            }
        }
예제 #3
0
 public RecursiveTileMap(IRecursiveTileMap <T> center, int submapSize) : this((byte)((center as RecursiveTileMap <T>)?.Level + 1 ?? 1), submapSize)
 {
     _submap[_submapSize / 2, _submapSize / 2] = center;
 }