private void load(string filename)
        {
            try
            {
                Model.Behaviortrees.Clear();
                var doc = new XmlDocument();
                doc.Load(filename);
                foreach (XmlElement n in doc.SelectNodes("//Behaviortree"))
                {
                    var behaviortree = new Behaviortree.Behaviortree();
                    behaviortree.Name = n.GetAttribute("name");
                    behaviortree.Root = loadBehavior(n.ChildNodes[0] as XmlElement);
                    if (behaviortree.Root == null)
                    {
                        behaviortree.Root = new Decorator();
                    }
                    Model.Behaviortrees.Add(behaviortree);
                }

                Model.Units.Clear();
                foreach (XmlElement n in doc.SelectNodes("//Unit"))
                {
                    var unit = new Unit();
                    unit.Behavior = Model.FindBehaviortreeByName(n.GetAttribute("behavior"));
                    unit.World    = Model;
                    unit.Position = new Vector(double.Parse(n.GetAttribute("x")), double.Parse(n.GetAttribute("y")));
                    unit.Type     = (UnitTypes)Enum.Parse(typeof(UnitTypes), n.GetAttribute("type"));
                    Model.Units.Add(unit);
                }
            }
            catch (Exception ex)
            {
            }
        }
 private void addRandom()
 {
     //for (int i = 0; i < 100; ++i)
     {
         var unit = new Unit {
             World = Model
         };
         unit.Position = new Vector(random.Next(-100, +100), random.Next(-100, +100));
         unit.Selected = true;
         unit.Type     = UnitType;
         unit.Behavior = Model.FindBehaviortreeByName("Random Mover");
         Model.Units.Add(unit);
     }
 }