public void LoadContent(ContentManager content, string mapID) { this.content = new ContentManager(content.ServiceProvider, "Content"); fileManager = new FileManager(); tile = new List<Vector2>(); layer = new List<List<Vector2>>(); tileMap = new List<List<List<Vector2>>>(); attributes = new List<List<string>>(); contents = new List<List<string>>(); fileManager.LoadContent("Load/Maps/" + mapID + ".txt", attributes, contents, "Layers"); for (int i = 0; i < attributes.Count; i++) { for (int j = 0; j < attributes[i].Count; j++) { switch (attributes[i][j]) { case "TileSet": tileSet = this.content.Load<Texture2D>("TileSets/" + contents[i][j]); break; case "TileDimensions": string[] split = contents[i][j].Split(','); tileDimensions = new Vector2(int.Parse(split[0]), int.Parse(split[1])); break; case "StartLayer": for (int k = 0; k < contents[i].Count; k++) { split = contents[i][k].Split(','); tile.Add(new Vector2(int.Parse(split[0]), int.Parse(split[1]))); } if (tile.Count > 0) { layer.Add(tile); tile = new List<Vector2>(); } break; case "EndLayer": if (layer.Count > 0) { tileMap.Add(layer); } layer = new List<List<Vector2>>(); break; } } } }
public override void LoadContent(ContentManager Content, InputManager inputManager) { base.LoadContent(Content, inputManager); if (font == null) { font = this.content.Load<SpriteFont>("Font1"); } imageNumber = 0; fileManager = new FileManager(); animation = new List<Animation>(); fAnimation = new FadeAnimation(); images = new List<Texture2D>(); fileManager.LoadContent("Load/Splash.txt", attributes, contents); for (int i = 0; i < attributes.Count; i++) { for (int j = 0; j < attributes[i].Count; j++) { switch(attributes[i][j]) { default: case "Image": images.Add(this.content.Load<Texture2D>("SplashScreen/" + contents[i][j])); animation.Add(new FadeAnimation()); break; case "Sound": break; } } } for (int i = 0; i < animation.Count; i++) { animation[i].LoadContent(content, images[i], "", Vector2.Zero); //in case image is different size than viewport // ImageWidth / 2 * scale - (imageWidth /2) // ImageHeight / 2 * scale - (imageHeight / 2) animation[i].Scale = 1f; //can scale images here in splash screen animation[i].IsActive = true; } }
public void LoadContent(ContentManager content, string mapID) { fileManager = new FileManager(); attributes = new List<List<string>>(); contents = new List<List<string>>(); collisionMap = new List<List<string>>(); row = new List<string>(); fileManager.LoadContent("Load/Maps/" + mapID + ".txt", attributes, contents, "Collision"); for (int i = 0; i < contents.Count; i++) { for (int j = 0; j < contents[i].Count; j++) { row.Add(contents[i][j]); } collisionMap.Add(row); row = new List<string>(); } }
public override void LoadContent(ContentManager content, InputManager input) { base.LoadContent(content, input); fileManager = new FileManager(); moveAnimation = new Animation(); Vector2 tempFrames = Vector2.Zero; moveSpeed = 100f; fileManager.LoadContent("Load/Player.txt", attributes, contents); for (int i = 0; i < attributes.Count; i++) { for (int j = 0; j < attributes[i].Count; j++) { switch (attributes[i][j]) { case "Health": health = int.Parse(contents[i][j]); break; case "Frames": string[] frames = contents[i][j].Split(' '); tempFrames = new Vector2(int.Parse(frames[0]), int.Parse(frames[1])); break; case "Image": image = this.content.Load<Texture2D>(contents[i][j]); break; case "Position": frames = contents[i][j].Split(' '); position = new Vector2(int.Parse(frames[0]), int.Parse(frames[1])); break; } } } moveAnimation.Frames = new Vector2(3, 4); moveAnimation.LoadContent(content, image, "", position); }
public void LoadContent(Map map, string layerID) { tiles = new List<List<Tile>>(); attributes = new List<List<string>>(); contents = new List<List<string>>(); fileManager = new FileManager(); motion = new List<string>(); solid = new List<string>(); content = new ContentManager(ScreenManager.Instance.Content.ServiceProvider, "Content"); fileManager.LoadContent("Load/Maps/" + map.ID + ".txt", attributes, contents, layerID); int indexY = 0; for (int i = 0; i < attributes.Count; i++) { for (int j = 0; j < attributes[i].Count; j++) { switch (attributes[i][j]) { case "TileSet": tileSheet = content.Load<Texture2D>("TileSets/" + contents[i][j]); break; case "Solid": solid.Add(contents[i][j]); break; case "Motion": motion.Add(contents[i][j]); break; case "StartLayer": List<Tile> tempTiles = new List<Tile>(); Tile.Motion tempMotion = Tile.Motion.Static; Tile.State tempState; for (int k = 0; k < contents[i].Count; k++) { string[] split = contents[i][k].Split(','); tempTiles.Add(new Tile()); if (solid.Contains(contents[i][k])) { tempState = Tile.State.Solid; } else { tempState = Tile.State.Passive; } foreach (string m in motion) { getMotion = m.Split(':'); if (getMotion[0] == contents[i][k]) { tempMotion = (Tile.Motion)Enum.Parse(typeof(Tile.Motion), getMotion[1]); break; } } tempTiles[k].SetTile(tempState, tempMotion, new Vector2(k * 32, indexY * 32), tileSheet, new Rectangle(int.Parse(split[0]) * 32, int.Parse(split[1]) * 32, 32, 32)); } tiles.Add(tempTiles); indexY++; break; } } } }
public void LoadContent(ContentManager content, string id) { this.content = new ContentManager(content.ServiceProvider, "Content"); menuItems = new List<string>(); menuImages = new List<Texture2D>(); animation = new List<Animation>(); animationTypes = new List<string>(); attributes = new List<List<string>>(); contents = new List<List<string>>(); linkType = new List<string>(); linkID = new List<string>(); position = Vector2.Zero; fileManager = new FileManager(); fAnimation = new FadeAnimation(); ssAnimation = new SpriteSheetAnimation(); itemNumber = 0; fileManager.LoadContent("Load/Menus.txt", attributes, contents, id); for (int i = 0; i < attributes.Count; i++) { for (int j = 0; j < attributes[i].Count; j++) { switch (attributes[i][j]) { case "Font": font = this.content.Load<SpriteFont>(contents[i][j]); break; case "Item": menuItems.Add(contents[i][j]); break; case "Image": menuImages.Add(this.content.Load<Texture2D>(contents[i][j])); break; case "Axis": axis = int.Parse(contents[i][j]); break; case "Position": string[] temp = contents[i][j].Split(' '); position = new Vector2(float.Parse(temp[0]), float.Parse(temp[1])); break; case "Source": temp = contents[i][j].Split(' '); source = new Rectangle(int.Parse(temp[0]), int.Parse(temp[1]), int.Parse(temp[2]), int.Parse(temp[3])); break; case "Animation": animationTypes.Add(contents[i][j]); break; case "Align": align = contents[i][j]; break; case "LinkType": linkType.Add(contents[i][j]); break; case "LinkID": linkID.Add(contents[i][j]); break; } } } SetMenuItems(); SetAnimations(); }