public List <Object> get(string xmlContainer) { if (!active) { return(null); } mDoc.Load(mFilename); XmlNode nodeRoot = mDoc.DocumentElement.GetElementsByTagName(xmlContainer)[0]; if (nodeRoot == null) { return(null); } XmlNodeList nodeList = nodeRoot.ChildNodes; if (nodeList.Count <= 0) { return(null); } List <Object> objects = new List <Object>(); foreach (XmlElement node in nodeList) { Object obj = new Object(); if (node.LocalName == Objects.ObjectDictionary_Moveable.UNBREAKABLE.ToString()) { obj = new MoveableObject(); } else if (node.LocalName == Objects.ObjectDictionary_Moveable.BREAKABLE.ToString()) { obj = new BreakableObject(); } else if (node.LocalName == Objects.ObjectDictionary_Moveable.EXPLOSIVE.ToString()) { obj = new ExplosiveObject(); } if (!obj.GetAdditionalAttributes(node)) { continue; } objects.Add(obj); } return(objects); }
/* Updates the object description box appropriately */ private void listview_moveableObjectList_SelectionChanged(object sender, SelectionChangedEventArgs e) { if (listview_moveableObjectList.SelectedItem != null) { grid_objectDescription.Visibility = Visibility.Visible; Object typeCollector = listview_moveableObjectList.SelectedItem as Object; string description; if (typeCollector.Type == Objects.ObjectDictionary_Moveable.UNBREAKABLE) { typeCollector = new MoveableObject(listview_moveableObjectList.SelectedItem as MoveableObject); description = (listview_moveableObjectList.SelectedItem as MoveableObject).Print(maxDescriptionLength); } else if (typeCollector.Type == Objects.ObjectDictionary_Moveable.BREAKABLE) { typeCollector = new BreakableObject(listview_moveableObjectList.SelectedItem as BreakableObject); description = (listview_moveableObjectList.SelectedItem as BreakableObject).Print(maxDescriptionLength); } else if (typeCollector.Type == Objects.ObjectDictionary_Moveable.EXPLOSIVE) { typeCollector = new ExplosiveObject(listview_moveableObjectList.SelectedItem as ExplosiveObject); description = (listview_moveableObjectList.SelectedItem as ExplosiveObject).Print(maxDescriptionLength); } else { typeCollector = new Object(listview_moveableObjectList.SelectedItem as Object); description = typeCollector.Print(maxDescriptionLength); } label_descriptionList.Text = description; if (map_canvas.IsEnabled) { AddObjectToMap(typeCollector); } } else { grid_objectDescription.Visibility = Visibility.Hidden; } }
public MoveableObject(MoveableObject cpy) : base(cpy.Name, cpy.Sprite_filename) { mType = Objects.ObjectDictionary_Moveable.UNBREAKABLE; mMass = cpy.Mass; }