XNA Tile Collisions using "Tiled"

I don't know if any of you know XNA, but I decided to give it a whirl anyhow.

Alright, so I'm a newbie to XNA and C# in general. I got this Tile Map system from this place. It uses the .tmx (in reality just a renamed XML file) outputted by a program called Tiled, which is a 2D Map Editor.

Here's the Tile Map class:
  1.  
  2. using System;
  3. using System.Collections;
  4. using System.Collections.Generic;
  5. using System.Linq;
  6. using System.Text;
  7. using System.Xml;
  8. using System.Xml.Schema;
  9. using Microsoft.Xna.Framework.Graphics;
  10. using Microsoft.Xna.Framework.Content;
  11. using Microsoft.Xna.Framework;
  12. using System.IO;
  13. using System.IO.Compression;
  14.  
  15. namespace RPGExperiment
  16. {
  17.     public class Tileset
  18.     {
  19.         public class TilePropertyList : Dictionary<string, string>
  20.         {
  21.         }
  22.  
  23.         public string Name;
  24.         public int FirstTileID;
  25.         public int TileWidth;
  26.         public int TileHeight;
  27.         public Dictionary<int, TilePropertyList> TileProperties = new Dictionary<int, TilePropertyList>();
  28.         public string Image;
  29.         protected Texture2D _Texture;
  30.         protected int _TexWidth, _TexHeight;
  31.  
  32.         internal static Tileset Load(XmlReader reader)
  33.         {
  34.             var result = new Tileset();
  35.  
  36.             result.Name = reader.GetAttribute("name");
  37.             result.FirstTileID = int.Parse(reader.GetAttribute("firstgid"));
  38.             result.TileWidth = int.Parse(reader.GetAttribute("tilewidth"));
  39.             result.TileHeight = int.Parse(reader.GetAttribute("tileheight"));
  40.  
  41.             int currentTileId = -1;
  42.  
  43.             while (reader.Read())
  44.             {
  45.                 var name = reader.Name;
  46.  
  47.                 switch (reader.NodeType)
  48.                 {
  49.                     case XmlNodeType.Element:
  50.                         switch (name)
  51.                         {
  52.                             case "image":
  53.                                 result.Image = reader.GetAttribute("source");
  54.                                 break;
  55.                             case "tile":
  56.                                 currentTileId = int.Parse(reader.GetAttribute("id"));
  57.                                 break;
  58.                             case "property":
  59.                                 {
  60.                                     TilePropertyList props;
  61.                                     if (!result.TileProperties.TryGetValue(currentTileId, out props))
  62.                                     {
  63.                                         props = new TilePropertyList();
  64.                                         result.TileProperties[currentTileId] = props;
  65.                                     }
  66.  
  67.                                     props[reader.GetAttribute("name")] = reader.GetAttribute("value");
  68.                                 } break;
  69.                         }
  70.                        
  71.                         break;
  72.                     case XmlNodeType.EndElement:
  73.                         break;
  74.                 }
  75.             }
  76.  
  77.             return result;
  78.         }
  79.  
  80.         public TilePropertyList GetTileProperties(int index)
  81.         {
  82.             index -= FirstTileID;
  83.  
  84.             if (index < 0)
  85.                 return null;
  86.  
  87.             TilePropertyList result = null;
  88.             TileProperties.TryGetValue(index, out result);
  89.  
  90.             return result;
  91.         }
  92.  
  93.         public Texture2D Texture
  94.         {
  95.             get
  96.             {
  97.                 return _Texture;
  98.             }
  99.             set
  100.             {
  101.                 _Texture = value;
  102.                 _TexWidth = value.Width;
  103.                 _TexHeight = value.Height;
  104.             }
  105.         }
  106.  
  107.         internal bool MapTileToRect(int index, ref Rectangle rect)
  108.         {
  109.             index -= FirstTileID;
  110.  
  111.             if (index < 0)
  112.                 return false;
  113.  
  114.             int rowSize = _TexWidth / TileWidth;
  115.             int row = index / rowSize;
  116.             int numRows = _TexHeight / TileHeight;
  117.             if (row >= numRows)
  118.                 return false;
  119.  
  120.             int col = index % rowSize;
  121.  
  122.             rect.X = col * TileWidth;
  123.             rect.Y = row * TileHeight;
  124.             rect.Width = TileWidth;
  125.             rect.Height = TileHeight;
  126.             return true;
  127.         }
  128.     }
  129.  
  130.     public class Layer
  131.     {
  132.         public SortedList<string, string> Properties = new SortedList<string, string>();
  133.         internal struct TileInfo
  134.         {
  135.             public Texture2D Texture;
  136.             public Rectangle Rectangle;
  137.         }
  138.  
  139.         public string Name;
  140.         public int Width, Height;
  141.         public float Opacity = 1;
  142.         public int[] Tiles;
  143.         internal TileInfo[] _TileInfoCache = null;
  144.  
  145.         internal static Layer Load(XmlReader reader)
  146.         {
  147.             var result = new Layer();
  148.  
  149.             if (reader.GetAttribute("name") != null)
  150.                 result.Name = reader.GetAttribute("name");
  151.             if (reader.GetAttribute("width") != null)
  152.                 result.Width = int.Parse(reader.GetAttribute("width"));
  153.             if (reader.GetAttribute("height") != null)
  154.                 result.Height = int.Parse(reader.GetAttribute("height"));
  155.             if (reader.GetAttribute("opacity") != null)
  156.                 result.Opacity = float.Parse(reader.GetAttribute("opacity"));
  157.  
  158.             result.Tiles = new int[result.Width * result.Height];
  159.  
  160.             while (!reader.EOF)
  161.             {
  162.                 var name = reader.Name;
  163.  
  164.                 switch (reader.NodeType)
  165.                 {
  166.                     case XmlNodeType.Element:
  167.                         switch (name)
  168.                         {
  169.                             case "data":
  170.                                 {
  171.                                     if (reader.GetAttribute("encoding") != null)
  172.                                     {
  173.                                         var encoding = reader.GetAttribute("encoding");
  174.                                         var compressor = reader.GetAttribute("compression");
  175.                                         switch (encoding)
  176.                                         {
  177.                                             case "base64":
  178.                                                 {
  179.                                                     int dataSize = (result.Width * result.Height * 4) + 1024;
  180.                                                     var buffer = new byte[dataSize];
  181.                                                     reader.ReadElementContentAsBase64(buffer, 0, dataSize);
  182.  
  183.                                                     Stream stream = new MemoryStream(buffer, false);
  184.                                                     if (compressor == "gzip")
  185.                                                         stream = new GZipStream(stream, CompressionMode.Decompress, false);
  186.  
  187.                                                     using (stream)
  188.                                                     using (var br = new BinaryReader(stream))
  189.                                                     {
  190.                                                         for (int i = 0; i < result.Tiles.Length; i++)
  191.                                                             result.Tiles[i] = br.ReadInt32();
  192.                                                     }
  193.  
  194.                                                     continue;
  195.                                                 };
  196.  
  197.                                             default:
  198.                                                 throw new Exception("Unrecognized encoding.");
  199.                                         }
  200.                                     }
  201.                                     else
  202.                                     {
  203.                                         using (var st = reader.ReadSubtree())
  204.                                         {
  205.                                             int i = 0;
  206.                                             while (!st.EOF)
  207.                                             {
  208.                                                 switch (st.NodeType)
  209.                                                 {
  210.                                                     case XmlNodeType.Element:
  211.                                                         if (st.Name == "tile")
  212.                                                         {
  213.                                                             if (i < result.Tiles.Length)
  214.                                                             {
  215.                                                                 result.Tiles[i] = int.Parse(st.GetAttribute("gid"));
  216.                                                                 i++;
  217.                                                             }
  218.                                                         }
  219.  
  220.                                                         break;
  221.                                                     case XmlNodeType.EndElement:
  222.                                                         break;
  223.                                                 }
  224.  
  225.                                                 st.Read();
  226.                                             }
  227.                                         }
  228.                                     }
  229.                                     Console.WriteLine("It made it!");
  230.                                 } break;
  231.                             case "properties":
  232.                                 {
  233.                                     using (var st = reader.ReadSubtree())
  234.                                     {
  235.                                         while (!st.EOF)
  236.                                         {
  237.                                             switch (st.NodeType)
  238.                                             {
  239.                                                 case XmlNodeType.Element:
  240.                                                     if (st.Name == "property")
  241.                                                     {
  242.                                                         st.Read();
  243.                                                         if (st.GetAttribute("name") != null)
  244.                                                         {
  245.                                                             result.Properties.Add(st.GetAttribute("name"), st.GetAttribute("value"));
  246.                                                         }
  247.                                                     }
  248.  
  249.                                                     break;
  250.                                                 case XmlNodeType.EndElement:
  251.                                                     break;
  252.                                             }
  253.  
  254.                                             st.Read();
  255.                                         }
  256.                                     }
  257.                                 } break;
  258.                         }
  259.  
  260.                         break;
  261.                     case XmlNodeType.EndElement:
  262.                         break;
  263.                 }
  264.  
  265.                 reader.Read();
  266.             }
  267.  
  268.             return result;
  269.         }
  270.  
  271.         public int GetTile(int x, int y)
  272.         {
  273.             if ((x < 0) || (y < 0) || (x >= Width) || (y >= Height))
  274.                 throw new InvalidOperationException();
  275.  
  276.             int index = (y * Width) + x;
  277.             return Tiles[index];
  278.         }
  279.  
  280.         protected void BuildTileInfoCache(IList<Tileset> tilesets)
  281.         {
  282.             Rectangle rect = new Rectangle();
  283.             var cache = new List<TileInfo>();
  284.             int i = 1;
  285.  
  286.         next:
  287.             for (int t = 0; t < tilesets.Count; t++)
  288.             {
  289.                 if (tilesets[t].MapTileToRect(i, ref rect))
  290.                 {
  291.                     cache.Add(new TileInfo
  292.                     {
  293.                         Texture = tilesets[t].Texture,
  294.                         Rectangle = rect
  295.                     });
  296.                     i += 1;
  297.                     goto next;
  298.                 }
  299.             }
  300.  
  301.             _TileInfoCache = cache.ToArray();
  302.         }
  303.  
  304.         public void Draw(SpriteBatch batch, IList<Tileset> tilesets, Rectangle rectangle, Vector2 viewportPosition, int tileWidth, int tileHeight)
  305.         {
  306.             int i = 0;
  307.             Vector2 destPos = new Vector2(rectangle.Left, rectangle.Top);
  308.             Vector2 viewPos = viewportPosition;
  309.  
  310.             int minX = (int)Math.Floor(viewportPosition.X / tileWidth);
  311.             int minY = (int)Math.Floor(viewportPosition.Y / tileHeight);
  312.             int maxX = (int)Math.Ceiling((rectangle.Width + viewportPosition.X) / tileWidth);
  313.             int maxY = (int)Math.Ceiling((rectangle.Height + viewportPosition.Y) / tileHeight);
  314.  
  315.             if (minX < 0)
  316.                 minX = 0;
  317.             if (minY < 0)
  318.                 minY = 0;
  319.             if (maxX >= Width)
  320.                 maxX = Width - 1;
  321.             if (maxY >= Height)
  322.                 maxY = Height - 1;
  323.  
  324.             if (viewPos.X > 0)
  325.             {
  326.                 viewPos.X = ((int)Math.Floor(viewPos.X)) % tileWidth;
  327.             }
  328.             else
  329.             {
  330.                 viewPos.X = (float)Math.Floor(viewPos.X);
  331.             }
  332.  
  333.             if (viewPos.Y > 0)
  334.             {
  335.                 viewPos.Y = ((int)Math.Floor(viewPos.Y)) % tileHeight;
  336.             }
  337.             else
  338.             {
  339.                 viewPos.Y = (float)Math.Floor(viewPos.Y);
  340.             }
  341.  
  342.             TileInfo info = new TileInfo();
  343.             if (_TileInfoCache == null)
  344.                 BuildTileInfoCache(tilesets);
  345.  
  346.             for (int y = minY; y <= maxY; y++)
  347.             {
  348.                 destPos.X = rectangle.Left;
  349.  
  350.                 for (int x = minX; x <= maxX; x++)
  351.                 {
  352.                     i = (y * Width) + x;
  353.                     int index = Tiles[i] - 1;
  354.  
  355.                     if ((index >= 0) && (index < _TileInfoCache.Length))
  356.                     {
  357.                         info = _TileInfoCache[index];
  358.                         batch.Draw(info.Texture, destPos - viewPos, info.Rectangle, new Color(Color.White, this.Opacity));
  359.                     }
  360.  
  361.                     destPos.X += tileWidth;
  362.                 }
  363.  
  364.                 destPos.Y += tileHeight;
  365.             }
  366.         }
  367.     }
  368.  
  369.     public class ObjectGroup
  370.     {
  371.         public SortedList<string, Object> Objects = new SortedList<string, Object>();
  372.         public SortedList<string, string> Properties = new SortedList<string, string>();
  373.  
  374.         public string Name;
  375.         public int Width, Height, X, Y;
  376.         float Opacity = 1;
  377.  
  378.         internal static ObjectGroup Load(XmlReader reader)
  379.         {
  380.             var result = new ObjectGroup();
  381.  
  382.             if (reader.GetAttribute("name") != null)
  383.                 result.Name = reader.GetAttribute("name");
  384.             if (reader.GetAttribute("width") != null)
  385.                 result.Width = int.Parse(reader.GetAttribute("width"));
  386.             if (reader.GetAttribute("height") != null)
  387.                 result.Height = int.Parse(reader.GetAttribute("height"));
  388.             if (reader.GetAttribute("x") != null)
  389.                 result.X = int.Parse(reader.GetAttribute("x"));
  390.             if (reader.GetAttribute("y") != null)
  391.                 result.Y = int.Parse(reader.GetAttribute("y"));
  392.             if (reader.GetAttribute("opacity") != null)
  393.                 result.Opacity = float.Parse(reader.GetAttribute("opacity"));
  394.  
  395.             while (!reader.EOF)
  396.             {
  397.                 var name = reader.Name;
  398.  
  399.                 switch (reader.NodeType)
  400.                 {
  401.                     case XmlNodeType.Element:
  402.                         switch (name)
  403.                         {
  404.                             case "object":
  405.                                 {
  406.                                     using (var st = reader.ReadSubtree())
  407.                                     {
  408.                                         st.Read();
  409.                                         var objects = Object.Load(st);
  410.                                         result.Objects.Add(objects.Name, objects);
  411.                                     }
  412.                                 } break;
  413.                             case "properties":
  414.                                 {
  415.                                     using (var st = reader.ReadSubtree())
  416.                                     {
  417.                                         while (!st.EOF)
  418.                                         {
  419.                                             switch (st.NodeType)
  420.                                             {
  421.                                                 case XmlNodeType.Element:
  422.                                                     if (st.Name == "property")
  423.                                                     {
  424.                                                         st.Read();
  425.                                                         if (st.GetAttribute("name") != null)
  426.                                                         {
  427.                                                             result.Properties.Add(st.GetAttribute("name"), st.GetAttribute("value"));
  428.                                                         }
  429.                                                     }
  430.  
  431.                                                     break;
  432.                                                 case XmlNodeType.EndElement:
  433.                                                     break;
  434.                                             }
  435.  
  436.                                             st.Read();
  437.                                         }
  438.                                     }
  439.                                 } break;
  440.                         }
  441.  
  442.                         break;
  443.                     case XmlNodeType.EndElement:
  444.                         break;
  445.                 }
  446.  
  447.                 reader.Read();
  448.             }
  449.  
  450.             return result;
  451.         }
  452.  
  453.         public void Draw(Map result, SpriteBatch batch, Rectangle rectangle, Vector2 viewportPosition)
  454.         {
  455.             foreach (var objects in Objects.Values)
  456.             {
  457.                 if (objects.Texture != null)
  458.                 {
  459.                     objects.Draw(batch, rectangle, new Vector2(this.X * result.TileWidth, this.Y * result.TileHeight), viewportPosition, this.Opacity);
  460.                 }
  461.             }
  462.         }
  463.     }
  464.  
  465.     public class Object
  466.     {
  467.         public SortedList<string, string> Properties = new SortedList<string, string>();
  468.  
  469.         public string Name, Image;
  470.         public int Width, Height, X, Y;
  471.  
  472.         protected Texture2D _Texture;
  473.         protected int _TexWidth, _TexHeight;
  474.  
  475.         public Texture2D Texture
  476.         {
  477.             get
  478.             {
  479.                 return _Texture;
  480.             }
  481.             set
  482.             {
  483.                 _Texture = value;
  484.                 _TexWidth = value.Width;
  485.                 _TexHeight = value.Height;
  486.             }
  487.         }
  488.  
  489.         internal static Object Load(XmlReader reader)
  490.         {
  491.             var result = new Object();
  492.  
  493.             result.Name = reader.GetAttribute("name");
  494.             result.X = int.Parse(reader.GetAttribute("x"));
  495.             result.Y = int.Parse(reader.GetAttribute("y"));
  496.             result.Width = int.Parse(reader.GetAttribute("width"));
  497.             result.Height = int.Parse(reader.GetAttribute("height"));
  498.  
  499.             while (!reader.EOF)
  500.             {
  501.                 switch (reader.NodeType)
  502.                 {
  503.                     case XmlNodeType.Element:
  504.                         if (reader.Name == "properties")
  505.                         {
  506.                             using (var st = reader.ReadSubtree())
  507.                             {
  508.                                 while (!st.EOF)
  509.                                 {
  510.                                     switch (st.NodeType)
  511.                                     {
  512.                                         case XmlNodeType.Element:
  513.                                             if (st.Name == "property")
  514.                                             {
  515.                                                 st.Read();
  516.                                                 if (st.GetAttribute("name") != null)
  517.                                                 {
  518.                                                     result.Properties.Add(st.GetAttribute("name"), st.GetAttribute("value"));
  519.                                                 }
  520.                                             }
  521.  
  522.                                             break;
  523.                                         case XmlNodeType.EndElement:
  524.                                             break;
  525.                                     }
  526.  
  527.                                     st.Read();
  528.                                 }
  529.                             }
  530.                         }
  531.                         if (reader.Name == "image")
  532.                         {
  533.                             result.Image = reader.GetAttribute("source");
  534.                         }
  535.  
  536.                         break;
  537.                     case XmlNodeType.EndElement:
  538.                         break;
  539.                 }
  540.  
  541.                 reader.Read();
  542.             }
  543.  
  544.             return result;
  545.         }
  546.  
  547.         public void Draw(SpriteBatch batch, Rectangle rectangle, Vector2 offset, Vector2 viewportPosition, float opacity)
  548.         {
  549.             Vector2 viewPos = viewportPosition;
  550.  
  551.             int minX = (int)Math.Floor(viewportPosition.X);
  552.             int minY = (int)Math.Floor(viewportPosition.Y);
  553.             int maxX = (int)Math.Ceiling((rectangle.Width + viewportPosition.X));
  554.             int maxY = (int)Math.Ceiling((rectangle.Height + viewportPosition.Y));
  555.  
  556.             if (this.X + offset.X + this.Width > minX && this.X + offset.X < maxX)
  557.                 if (this.Y + offset.Y + this.Height > minY && this.Y + offset.Y < maxY)
  558.                 {
  559.                     int x = (int)(this.X + offset.X - viewportPosition.X);
  560.                     int y = (int)(this.Y + offset.Y - viewportPosition.Y);
  561.                     batch.Draw(_Texture, new Rectangle(x, y, this.Width, this.Height), new Rectangle(0, 0, _Texture.Width, _Texture.Height), new Color(Color.White, opacity));
  562.                 }
  563.         }
  564.     }
  565.  
  566.     public class Map
  567.     {
  568.         public SortedList<string, Tileset> Tilesets = new SortedList<string, Tileset>();
  569.         public SortedList<string, Layer> Layers = new SortedList<string, Layer>();
  570.         public SortedList<string, ObjectGroup> ObjectGroups = new SortedList<string, ObjectGroup>();
  571.         public SortedList<string, string> Properties = new SortedList<string, string>();
  572.         public int Width, Height;
  573.         public int TileWidth, TileHeight;
  574.  
  575.         public static Map Load(string filename, ContentManager content)
  576.         {
  577.             var result = new Map();
  578.             XmlReaderSettings settings = new XmlReaderSettings();
  579.             settings.ProhibitDtd = false;
  580.  
  581.             using (var stream = System.IO.File.OpenText(filename))
  582.             using (var reader = XmlReader.Create(stream, settings))
  583.                 while (reader.Read())
  584.                 {
  585.                     var name = reader.Name;
  586.  
  587.                     switch (reader.NodeType)
  588.                     {
  589.                         case XmlNodeType.DocumentType:
  590.                             if (name != "map")
  591.                                 throw new Exception("Invalid map format");
  592.                             break;
  593.                         case XmlNodeType.Element:
  594.                             switch (name)
  595.                             {
  596.                                 case "map":
  597.                                     {
  598.                                         result.Width = int.Parse(reader.GetAttribute("width"));
  599.                                         result.Height = int.Parse(reader.GetAttribute("height"));
  600.                                         result.TileWidth = int.Parse(reader.GetAttribute("tilewidth"));
  601.                                         result.TileHeight = int.Parse(reader.GetAttribute("tileheight"));
  602.                                     } break;
  603.                                 case "tileset":
  604.                                     {
  605.                                         using (var st = reader.ReadSubtree())
  606.                                         {
  607.                                             st.Read();
  608.                                             var tileset = Tileset.Load(st);
  609.                                             result.Tilesets.Add(tileset.Name, tileset);
  610.                                         }
  611.                                     } break;
  612.                                 case "layer":
  613.                                     {
  614.                                         using (var st = reader.ReadSubtree())
  615.                                         {
  616.                                             st.Read();
  617.                                             var layer = Layer.Load(st);
  618.                                             result.Layers.Add(layer.Name, layer);
  619.                                         }
  620.                                     } break;
  621.                                 case "objectgroup":
  622.                                     {
  623.                                         using (var st = reader.ReadSubtree())
  624.                                         {
  625.                                             st.Read();
  626.                                             var objectgroup = ObjectGroup.Load(st);
  627.                                             result.ObjectGroups.Add(objectgroup.Name, objectgroup);
  628.                                         }
  629.                                     } break;
  630.                                 case "properties":
  631.                                     {
  632.                                         using (var st = reader.ReadSubtree())
  633.                                         {
  634.                                             while (!st.EOF)
  635.                                             {
  636.                                                 switch (st.NodeType)
  637.                                                 {
  638.                                                     case XmlNodeType.Element:
  639.                                                         if (st.Name == "property")
  640.                                                         {
  641.                                                             st.Read();
  642.                                                             if (st.GetAttribute("name") != null)
  643.                                                             {
  644.                                                                 result.Properties.Add(st.GetAttribute("name"), st.GetAttribute("value"));
  645.                                                             }
  646.                                                         }
  647.  
  648.                                                         break;
  649.                                                     case XmlNodeType.EndElement:
  650.                                                         break;
  651.                                                 }
  652.  
  653.                                                 st.Read();
  654.                                             }
  655.                                         }
  656.                                     } break;
  657.                             }
  658.                             break;
  659.                         case XmlNodeType.EndElement:
  660.                             break;
  661.                         case XmlNodeType.Whitespace:
  662.                             break;
  663.                     }
  664.                 }
  665.  
  666.             foreach (var tileset in result.Tilesets.Values)
  667.             {
  668.                 tileset.Texture = content.Load<Texture2D>(
  669.                     Path.Combine(Path.GetDirectoryName(tileset.Image), Path.GetFileNameWithoutExtension(tileset.Image))
  670.                 );
  671.             }
  672.  
  673.             foreach (var objects in result.ObjectGroups.Values)
  674.             {
  675.                 foreach (var item in objects.Objects.Values)
  676.                 {
  677.                     if (item.Image != null)
  678.                     {
  679.                         item.Texture = content.Load<Texture2D>
  680.                         (
  681.                             Path.Combine
  682.                             (
  683.                                 Path.GetDirectoryName(item.Image),
  684.                                 Path.GetFileNameWithoutExtension(item.Image)
  685.                             )
  686.                         );
  687.                     }
  688.                 }
  689.             }
  690.  
  691.             return result;
  692.         }
  693.  
  694.         public void Draw(SpriteBatch batch, Rectangle rectangle, Vector2 viewportPosition)
  695.         {
  696.             foreach (Layer layers in Layers.Values)
  697.             {
  698.                 layers.Draw(batch, Tilesets.Values, rectangle, viewportPosition, TileWidth, TileHeight);
  699.             }
  700.  
  701.             foreach (var objectgroups in ObjectGroups.Values)
  702.             {
  703.                 objectgroups.Draw(this, batch, rectangle, viewportPosition);
  704.             }
  705.         }
  706.     }
  707. }
  708.  
Expand to see the code.


On to the problem, I'm trying to create a collision system by doing checks in the Input classes.
For example (pseudo-code ahoy!):
If the Player presses down:
#Check if the tile below has the property solid set to true or not.
##It doesn't? Okay, move down.

The thing is, I can't figure out how to check what tile is at a certain position, and how to retrieve the properties from it.

Any help will be appreciated.
That seems like a really complicated set of classes for a beginner. I would suggest writing one from scratch that loads from text files, just to get you started.

As for your checking dilemma, all you have to do is:

tileX = player.TileX
tileY = player.TileY + 1 // Check below

It looks like the code you are using stores tile information in a singular dimension. This kind of complicates things. In fact, I would need to see that code in action and really look at it before I could say much more about it, but I am too lazy atm.

The best way to learn is to start from the ground up. I suggest you use the Tile map tutorial from the Creators Club.

EDIT: Figured while I am here I should get some practice in. I'm creating a tutorial. I'll try to have it up within the next couple days.
I'll agree with OS here. Although it may take more time, you will learn much more by making one yourself. If you don't, unless you are already above the level of the code you're using (and you just want to save time), you are bound to run into more problems by trying to add your code on top of an existing one. On the side note, you can always look at RM's scripts to get an idea of a map structure.
I forgot I'd even posted a support topic here, I apoligize. I resolved the situation together with a friend. It was easier than I thought it would be.

Original thread: https://www.hbgames.org/forums/viewtopic.php?t=70072