public Boolean IndexExists(Point p) { if (p.X < 0 || p.X >= mapWidth) return false; if (p.Y < 0 || p.Y >= mapHeight) return false; return true; }