Beispiel #1
0
        virtual public Vector2 CalcBottomLeft(IGridSpace <TPoint> grid)
        {
            if (!grid.Any())
            {
                return(Vector2.zero);
            }

            var rawGrid       = grid.Select(point => InverseGridPointTransform(point));
            var rawGridAsList = rawGrid as IList <TPoint> ?? rawGrid.ToList();
            var firstPoint    = rawGridAsList.First();

            var halfCellDimensions = GetCellDimensions(firstPoint) / 2;
            var worldPoint         = GridToWorld(firstPoint);

            var minX = worldPoint.x - halfCellDimensions.x;
            var minY = worldPoint.y - halfCellDimensions.y;

            foreach (var point in rawGridAsList.ButFirst())
            {
                halfCellDimensions = GetCellDimensions(point) / 2;
                worldPoint         = GridToWorld(point);

                minX = Mathf.Min(minX, worldPoint.x - halfCellDimensions.x);
                minY = Mathf.Min(minY, worldPoint.y - halfCellDimensions.y);
            }

            return(new Vector2(minX, minY));
        }
Beispiel #2
0
        public Vector2 CalcAnchorDimensions(IGridSpace <TPoint> grid)
        {
            if (!grid.Any())
            {
                return(Vector2.zero);
            }
            var rawGrid       = grid.Select(point => InverseGridPointTransform(point));
            var rawGridAsList = rawGrid as IList <TPoint> ?? rawGrid.ToList();
            var firstPoint    = rawGridAsList.First();

            var worldPoint = GridToWorld(firstPoint);

            var minX = worldPoint.x;
            var maxX = worldPoint.x;
            var minY = worldPoint.y;
            var maxY = worldPoint.y;

            foreach (var point in rawGridAsList.ButFirst())
            {
                worldPoint = GridToWorld(point);

                minX = Mathf.Min(minX, worldPoint.x);
                maxX = Mathf.Max(maxX, worldPoint.x);
                minY = Mathf.Min(minY, worldPoint.y);
                maxY = Mathf.Max(maxY, worldPoint.y);
            }

            var width  = maxX - minX;
            var height = maxY - minY;

            return(new Vector2(width, height));
        }
Beispiel #3
0
 public ArchimedeanSpiralMap(Vector2 cellDimensions, IGridSpace <LinePoint> grid)
     : base(cellDimensions)
 {
     lookUpWorld = grid.Select(p => this[p]).ToArray();
     lookUpGrid  = grid.ToArray();
     notInGrid   = grid.Last().Translate(LinePoint.Right);
 }