public bool LoadScene(string xmldir) { XDocument doc = XDocument.Load(xmldir); { XName customDir = XName.Get("CustomType"); var definitions = doc.Document.Descendants(customDir); foreach (var def in definitions) { for (int i = 0; i < customTypes.Count; i++) { XName name = XName.Get(customTypes[i].name); // customTypes[i].Loader(def.Descendants(name), this); } } } { var rigidbodies = doc.Document.Descendants("RigidBodies"); foreach (var rigidset in rigidbodies) { var definitions = rigidset.Descendants("Geometry"); foreach (var geomdef in definitions) { string texturedir = geomdef.Attribute("Texture").Value; bool dynamic = geomdef.Attribute("Dynamic").Value == "true"; float width = float.Parse(geomdef.Attribute("Width").Value, CultureInfo.InvariantCulture); float height = float.Parse(geomdef.Attribute("Height").Value, CultureInfo.InvariantCulture); float posx = float.Parse(geomdef.Attribute("PosX").Value, CultureInfo.InvariantCulture); float posy = float.Parse(geomdef.Attribute("PosY").Value, CultureInfo.InvariantCulture); string type = geomdef.Attribute("ActorType").Value; if (type == "Box") { PhysicSprite sprite = new PhysicSprite(new Vector2(width, height), new Vector2(posx, posy), dynamic, world, texturedir); AddNode(sprite); } } } } return true; }
public void LoadRigidBodies(XElement elements) { List<Sprite> sprites = CreateSprites(elements); List<JabActor> bodies = CreateBodies(elements); for (int i = 0; i < sprites.Count; i++) { PhysicSprite s = new PhysicSprite(); s.Body = bodies[i]; s.Sprite = sprites[i]; s.Body.UserData = s; AddNode(s); } }