GetBorderPoints() public static method

public static GetBorderPoints ( float x, float y, float w, float h ) : ICollection
x float
y float
w float
h float
return ICollection
コード例 #1
0
ファイル: EagerLoadingStrategy.cs プロジェクト: hnjm/tilemap
    public ICollection <Vec2> GetTilesToLoad(float x, float y, float w, float h, int m, int n)
    {
        ICollection <Vec2> visibleTiles = lazyLoader.GetTilesToLoad(x, y, w, h, m, n);
        List <Vec2>        tiles        = new List <Vec2> (visibleTiles);

        Rect    rect     = new Rect(x, y, w - x, h - y);
        Vector2 newPivot = new Vector2(x, y);
        Vector2 delta    = newPivot - lastPivot;
        Vector2 normal   = delta.normalized;

        lastPivot = newPivot;

        foreach (var point in MapUtil.GetBorderPoints(x, y, w, h))
        {
            Vector2 checkPoint = new Vector2(point.x + delta.x, point.y + delta.y);
            if (!rect.Contains(checkPoint))
            {
                foreach (var potentialPoint in GetPotentialTiles(point, normal))
                {
                    if (potentialPoint.x >= 0 && potentialPoint.x < m &&
                        potentialPoint.y >= 0 && potentialPoint.y < n)
                    {
                        tiles.Add(potentialPoint);
                    }
                }
            }
        }

        return(tiles);
    }