public static GetBorderPoints ( float x, float y, float w, float h ) : ICollection |
||
x | float | |
y | float | |
w | float | |
h | float | |
Résultat | ICollection |
public static ICollection<Vec2> GetBorderPoints(float x, float y, float w, float h)
{
List<Vec2> points = new List<Vec2> ();
int left = GetLeftBorder (x);
int right = GetRightBorder (w);
int lower = GetLowerBorder (y);
int upper = GetUpperBorder (h);
for (int i = left; i <= right; i++) {
points.Add (new Vec2 (i, lower));
points.Add (new Vec2 (i, upper));
}
for (int j = lower - 1; j < upper; j++) {
points.Add (new Vec2 (left, j));
points.Add (new Vec2 (right, j));
}
return points;
}
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); }