public Edge(KevinBarrier parent, Vector2 a, Vector2 b) { Parent = parent; Visible = true; A = a; B = b; Min = new Vector2(Math.Min(a.X, b.X), Math.Min(a.Y, b.Y)); Max = new Vector2(Math.Max(a.X, b.X), Math.Max(a.Y, b.Y)); Normal = (b - a).SafeNormalize(); Perpendicular = -Normal.Perpendicular(); Length = (a - b).Length(); }
public void Track(KevinBarrier block) { list.Add(block); if (tiles == null) { levelTileBounds = (Scene as Level).TileBounds; tiles = new VirtualMap <bool>(levelTileBounds.Width, levelTileBounds.Height, emptyValue: false); } for (int i = (int)block.X / 8; i < block.Right / 8f; i++) { for (int j = (int)block.Y / 8; j < block.Bottom / 8f; j++) { tiles[i - levelTileBounds.X, j - levelTileBounds.Y] = true; } } dirty = true; }
public void Untrack(KevinBarrier block) { list.Remove(block); if (list.Count <= 0) { tiles = null; } else { for (int i = (int)block.X / 8; i < block.Right / 8f; i++) { for (int j = (int)block.Y / 8; j < block.Bottom / 8f; j++) { tiles[i - levelTileBounds.X, j - levelTileBounds.Y] = false; } } } dirty = true; }