예제 #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));
        }
예제 #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);
        }
예제 #3
0
파일: CellLayer.cs 프로젝트: wytsep/OpenRA
        // Resolve an array index from cell coordinates
        int Index(CPos cell)
        {
            var uv = Map.CellToMap(Shape, cell);

            return(Index(uv.X, uv.Y));
        }
예제 #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);
        }
예제 #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);
        }