bool IsWater(TileType[,] tiles, int x, int y) { if (x < 0 || x > tiles.GetUpperBound(0)) return false; if (y < 0 || y > tiles.GetUpperBound(1)) return false; return tiles[x, y] == TileType.Water; }