private Obstacle loadObstacle(XmlNode obstacleNode, StaticSpriteSheet spriteSheet) { string referenceName = obstacleNode.Attributes["referenceName"].Value; string displayName = obstacleNode.Attributes["displayName"].Value; Texture2D texture = spriteSheet.getTexture(referenceName); ObstacleSprite sprite = new ObstacleSprite(lhg, texture); Obstacle obstacle = new Obstacle(lhg, referenceName, displayName, sprite); return(obstacle); }
private List <Obstacle> loadObstacleGroup(XmlNode groupNode) { List <Obstacle> obstacles = new List <Obstacle>(); // Load the texture from the content stream string texturePath = groupNode.Attributes["texture"].Value; Texture2D texture = lhg.Content.Load <Texture2D>(texturePath); // Load the frames for each obstacle and create the sprite sheet // Each obstacle makes up a subtexture of the group sprite sheet List <SimpleFrame> frames = new List <SimpleFrame>(); string xpath = "obstacle/frame"; XmlNodeList frameNodes = groupNode.SelectNodes(xpath); if (frameNodes != null) { frames = loadFrames(frameNodes); StaticSpriteSheet spriteSheet = new StaticSpriteSheet(lhg, texturePath, texture, frames); lhg.Assets.addStaticSpriteSheet(spriteSheet); // Now that we have the sprite sheet, load each obstacle // Load the properties that will be for each obstacle ObstacleProperties properties = null; XmlNodeList groupChildren = groupNode.ChildNodes; foreach (XmlNode childNode in groupChildren) { switch (childNode.Name) { case "properties": properties = loadObstacleProperties(childNode); break; case "obstacle": Obstacle obstacle = loadObstacle(childNode, spriteSheet); obstacle.MyProperties = properties; obstacles.Add(obstacle); break; } } } return(obstacles); }
public void addStaticSpriteSheet(StaticSpriteSheet staticSpriteSheet) { this.staticSpriteSheets.Add(staticSpriteSheet); }