Ejemplo n.º 1
0
        public BoxTileMapSelection(Point origin, Size size, int gridWidth)
            : base(origin, gridWidth)
        {
            if (size.Width < 0 || size.Height < 0)
            {
                throw new ArgumentException();
            }

            Size     = size;
            Count    = Size.Width * Size.Height;
            MaxIndex = TileMap1D.GetTileIndex(
                Point.Add(origin, size),
                GridWidth);
        }
Ejemplo n.º 2
0
        protected TileMapSelection(Point origin, int gridWidth)
        {
            if (origin.X < 0 || origin.Y < 0)
            {
                throw new ArgumentException();
            }

            if (gridWidth <= 0)
            {
                throw new ArgumentOutOfRangeException(nameof(gridWidth));
            }

            Origin    = origin;
            GridWidth = gridWidth;
            MinIndex  = TileMap1D.GetTileIndex(Origin, GridWidth);
        }
Ejemplo n.º 3
0
        public EnumerableTileMapSelection(
            IEnumerable <Point> collection,
            int gridWidth)
            : base(GetFirst(collection), gridWidth)
        {
            List    = new List <Point>(collection);
            HashSet = new HashSet <Point>(List);
            List.Sort(Compare);

            MaxIndex = TileMap1D.GetTileIndex(
                List.LastOrDefault(),
                GridWidth);

            int Compare(Point left, Point right)
            {
                return(left.X != right.X ? left.X - right.X : left.Y - right.Y);
            }
        }
Ejemplo n.º 4
0
        public IEnumerable <T> EnumerateValues <T>(
            IReadOnlyList <T> list)
        {
            if (list is null)
            {
                throw new ArgumentNullException(nameof(list));
            }

            if (MinIndex < 0 || MaxIndex >= Count)
            {
                throw new InvalidOperationException();
            }

            foreach (var gridTile in this)
            {
                var index = TileMap1D.GetTileIndex(gridTile, GridWidth);
                yield return(list[index]);
            }
        }
Ejemplo n.º 5
0
        public override bool Contains(Point gridTile)
        {
            var index = TileMap1D.GetTileIndex(gridTile, GridWidth);

            return(index >= MinIndex && index <= MaxIndex);
        }