Esempio n. 1
0
 public static Tile Parse(XElement elem)
 {
     #if DEBUG1
     try
     {
     #endif
     Tile t = new Tile();
     foreach (XAttribute attr in elem.Attributes())
     {
         if (attr.Name == "Type")
         {
             t.Type = (TileTypes)Enum.Parse(typeof(TileTypes), attr.Value);
         }
         else if (attr.Name == "InstanceName")
         {
             t.InstanceName = attr.Value;
         }
         else if (attr.Name == "Collision")
         {
             t.Traversable = bool.Parse(attr.Value);
         }
         else if (attr.Name == "Theme")
         {
             t.Theme = (Element)Enum.Parse(typeof(Element), attr.Value);
         }
         else if (attr.Name == "Orientation")
         {
             t.Orientation = (Orientations)Enum.Parse(typeof(Orientations), attr.Value);
         }
         else if (attr.Name == "GridCell")
         {
             t.GridCell = Index2D.Parse(attr.Value);
         }
     }
     return t;
     #if DEBUG1
     }
     catch (Exception e)
     {
         Console.WriteLine(e.GetBaseException().Message);
         return null;
     }
     #endif
 }
 public Tile(Frostbyte.Tile t):this()
 {
     InitializeComponent();
     this.t = t;
     Active = true;
     InMenu = false;
     Grid.SetColumn(this, t.GridCell.X);
     Grid.SetRow(this, t.GridCell.Y);
     DataContext = this;
 }