public void DrawFrame(SpriteBatch spriteBatch, Camera camera) { float x, y; // TOP y = position.Y; for (x = position.X; x < position.X + gridSize; x += 10.0f) { spriteBatch.Draw(tex, camera.RelativePosition(new Vector2(x, y)), Color.White); } // BOTTOM y = position.Y + gridSize; for (x = position.X; x < position.X + gridSize; x += 10.0f) { spriteBatch.Draw(tex, camera.RelativePosition(new Vector2(x, y)), Color.White); } // LEFT x = position.X; for (y = position.Y; y < position.Y + gridSize; y += 10.0f) { spriteBatch.Draw(tex, camera.RelativePosition(new Vector2(x, y)), Color.White); } // RIGHT x = position.X + gridSize; for (y = position.Y; y < position.Y + gridSize; y += 10.0f) { spriteBatch.Draw(tex, camera.RelativePosition(new Vector2(x, y)), Color.White); } if (topLeft != null) topLeft.DrawFrame(spriteBatch, camera); if (topRight != null) topRight.DrawFrame(spriteBatch, camera); if (bottomLeft != null) bottomLeft.DrawFrame(spriteBatch, camera); if (bottomRight != null) bottomRight.DrawFrame(spriteBatch, camera); }
public void DrawIntersected(Rectangle rect, SpriteBatch spriteBatch, Camera camera) { if (rect.Contains(boundRect)) { DrawFrame(spriteBatch, camera); } else if (rect.Intersects(boundRect)) { if (topLeft != null) topLeft.DrawIntersected(rect, spriteBatch, camera); if (topRight != null) topRight.DrawIntersected(rect, spriteBatch, camera); if (bottomLeft != null) bottomLeft.DrawIntersected(rect, spriteBatch, camera); if (bottomRight != null) bottomRight.DrawIntersected(rect, spriteBatch, camera); } }