. Your map tiles are 64x64 but your player is 32x32 so a movement by 1 unit is not going to work.
look at the draw code, thats not a problem for now.
Your map tiles are 64x64 but your player is 32x32 so a movement by 1 unit is not going to work.
(map.grid[X, Y + 1] != 2) //does not check if Y+1 is out of range (((Y + 1) >= map.grid.GetLength(1) ? 2 : map.grid[X, Y + 1]) != 2) //I'm sure some of these brackets are unnecessary but I like to be sure while prototyping code.
(Y + 1) >= map.grid.GetLength(1) ?
will check if (Y + 1) is more than or equal to the length of array dimension 1.
2 : map.grid[X, Y + 1]
if true it will return 2 so everything outside of the greed will be treated as if it was water.
if false return map.grid[X, Y+1]
check if the returned value is not equal to 2.
do this with the other directions replacing Y + 1 and [X, Y + 1] with whatever is necessary for the direction you intend to move.
if your moving in - directions you need to use something like this (for moving in -X direction in this example)
(X - 1) < 0 ?
always remember when its possible to query outside of the array, make sure you check to see if the desired query is more than the array length or less than the array minimum.
if there's something else wrong I haven't looked through your code to see it, but I noticed this right away and considered it a problem.