public void setTile(Tile tile) { this.tile = tile; if (this.isValid) { this.isValid = tile.passable; } }
public Cell(Tile t) { this.setTile(t); }
/// <summary> /// Parses the xml string for the Tile information. /// </summary> /// <param name="xml">The string containing the xml data.</param> private void parseTilesXML(string xml) { XmlReader reader = XmlReader.Create(new StringReader(xml)); // While not at the end of the file. while (reader.ReadToFollowing("Tile")) { string type = reader.GetAttribute("type"); // read type attribute string passableStr = reader.GetAttribute("passable"); // read passable attribute string indexStr = reader.GetAttribute("index"); // read index attribute // Convert passableStr into a bool. bool passable = true; if (passableStr.ToUpper().Equals("FALSE")) { passable = false; } // Convert indexStr into a string. int index = -1; index = Int32.Parse(indexStr); // Create a new Tile and add it to the list. tileTypes.Add(type); Tile tile = new Tile(type, passable, index); tiles.Add(tile); tileDict.Add(type, tile); Bitmap bm = new Bitmap(TILES_DIRECTORY + type + ".png"); bitmaps.Add(type, bm); } reader.Close(); }