public float GetRightMaxPos() { if (furthestRight != float.MinValue) { return(furthestRight); } float carFurthestRight = float.MinValue; for (int i = 0; i < nodes.Count; i++) { if (nodes[i] is PhysicSprite) { PhysicSprite s = nodes[i] as PhysicSprite; if (s.Body.BodyState == JabActor.BodyType.DYNAMIC) { float rightMostRect = s.GetRectangle().Right; rightMostRect = s.PosX;// Camera.Get.ScreenToWorld(new Vector2(rightMostRect, 0)).X; if (rightMostRect > carFurthestRight) { carFurthestRight = rightMostRect; } } } } furthestRight = carFurthestRight; //carFurthestRight += 1000; return(carFurthestRight); }
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); } }
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); }