Esempio n. 1
0
        /// <summary>Expand the specified region with an additional cordon. This may expand the region outside the map borders.</summary>
        public static CellRegion Expand(CellRegion region, int cordon)
        {
            var offset = new CVec(cordon, cordon);
            var tl     = Map.MapToCell(region.shape, Map.CellToMap(region.shape, region.TopLeft) - offset);
            var br     = Map.MapToCell(region.shape, Map.CellToMap(region.shape, region.BottomRight) + offset);

            return(new CellRegion(region.shape, tl, br));
        }
Esempio n. 2
0
        public CellRegion(TileShape shape, CPos topLeft, CPos bottomRight)
        {
            this.shape  = shape;
            TopLeft     = topLeft;
            BottomRight = bottomRight;

            mapTopLeft     = Map.CellToMap(shape, TopLeft);
            mapBottomRight = Map.CellToMap(shape, BottomRight);
        }
Esempio n. 3
0
        // Resolve an array index from cell coordinates
        int Index(CPos cell)
        {
            var uv = Map.CellToMap(Shape, cell);

            return(Index(uv.X, uv.Y));
        }
Esempio n. 4
0
        public bool Contains(CPos cell)
        {
            var uv = Map.CellToMap(shape, cell);

            return(uv.X >= mapTopLeft.X && uv.X <= mapBottomRight.X && uv.Y >= mapTopLeft.Y && uv.Y <= mapBottomRight.Y);
        }
Esempio n. 5
0
        // Resolve an array index from cell coordinates
        int Index(CPos cell)
        {
            var uv = Map.CellToMap(Shape, cell);

            return(uv.Y * Size.Width + uv.X);
        }