public void LoadContent(ContentManager content, String id) { this.content = new ContentManager(content.ServiceProvider, "Content"); images = new List<Texture2D>(); imageNumber = 0; fileManager = new FileManager(); fileManager.LoadContent("Load/GUIs.txt", id); position = new List<Vector2>(); scale = new List<Vector2>(); sourceRect = new List<Rectangle>(); for (int i = 0; i < fileManager.Attributes.Count; i++) { for (int j = 0; j < fileManager.Attributes[i].Count; j++) { switch (fileManager.Attributes[i][j]) { case "Images": images.Add(this.content.Load<Texture2D>(fileManager.Contents[i][j])); sourceRect.Add(new Rectangle(0, 0, images[i].Width, images[i].Height)); break; case "Position": string[] temp = fileManager.Contents[i][j].Split(','); posTemp = new Vector2(float.Parse(temp[0]), float.Parse(temp[1])); break; case "Scale": temp = fileManager.Contents[i][j].Split(','); scale.Add(new Vector2(float.Parse(temp[0]) * ScreenManager.Instance.ScreenScale.X, float.Parse(temp[1]) * ScreenManager.Instance.ScreenScale.Y)); break; case "Align": temp = fileManager.Contents[i][j].Split(','); if (temp[0] == "Center") { align = temp[1]; if (align == "X") { position.Add(new Vector2((ScreenManager.Instance.Dimensions.X - images[i].Width * scale[i].X) / 2, posTemp.Y)); } else if (align == "Y") { position.Add(new Vector2(posTemp.X, (ScreenManager.Instance.Dimensions.Y - images[i].Height * scale[i].Y) / 2)); } } else { position.Add(posTemp); } break; } } } }
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 void LoadContent(string entityType, ContentManager Content, string fileName, string identifier, InputManager inputManager) { this.inputManager = inputManager; entities = new List<Entity>(); fileManager = new FileManager(); if (identifier == String.Empty) fileManager.LoadContent(fileName); else fileManager.LoadContent(fileName, identifier); for (int i = 0; i < fileManager.Attributes.Count; i++) { Type newClass = Type.GetType("TM2." + entityType); entities.Add((Entity)Activator.CreateInstance(newClass)); entities[i].LoadContent(Content, fileManager.Attributes[i], fileManager.Contents[i], this.inputManager); } }
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 inputManager) { base.LoadContent(Content, inputManager); font = this.content.Load<SpriteFont>("CreditsScreen/Coolvetica Rg"); gui = new GUIManager(); gui.LoadContent(Content, "Credits"); audio = new AudioManager(); audio.LoadContent(Content, "Credits"); dul = false; fileManager = new FileManager(); fileManager.LoadContent("Load/Credits.txt"); for (int i = 0; i < fileManager.Attributes.Count; i++) { for (int j = 0; j < fileManager.Attributes[i].Count; j++) { switch (fileManager.Attributes[i][j]) { case "Videos" : video = this.content.Load<Video>(fileManager.Contents[i][j]); videoPlayer = new VideoPlayer(); videoPlayer.Play(video); videoPlayer.IsLooped = true; videoPlayer.Pause(); break; } } } audio.PlaySong(0, true); audio.FadeSong(1.0f, new TimeSpan(0, 0, 0, 1)); }
public override void UnloadContent() { base.UnloadContent(); fileManager = null; videoPlayer.Stop(); content.Unload(); }
public void LoadContent(Map map, string layerID) { tiles = new List<Tile>(); motion = new List<string>(); solid = new List<string>(); platform = new List<string>(); fileManager = new FileManager(); content = new ContentManager(ScreenManager.Instance.Content.ServiceProvider, "Content"); font = content.Load<SpriteFont>("Coolvetica Rg"); fileManager.LoadContent("Load/Maps/" + map.ID + ".txt", layerID); int indexY = 0; for (int i = 0; i < fileManager.Attributes.Count; i++) { for (int j = 0; j < fileManager.Attributes[i].Count; j++) { switch (fileManager.Attributes[i][j]) { case "TileSet" : tileSheet = content.Load<Texture2D>("TileSets/" + fileManager.Contents[i][j]); break; case "TileDimensions": string[] split = fileManager.Contents[i][j].Split(','); this.tileDimensions = new Vector2(int.Parse(split[0]), int.Parse(split[1])); break; case "MapDimensions": string[] split2 = fileManager.Contents[i][j].Split(','); this.mapDimensions = new Vector2(int.Parse(split2[0]), int.Parse(split2[1])); break; case "Solid": solid.Add(fileManager.Contents[i][j]); break; case "Platform": platform.Add(fileManager.Contents[i][j]); break; case "NullTile": nullTile = fileManager.Contents[i][j]; break; case "Motion": motion.Add(fileManager.Contents[i][j]); break; case "StartLayer": Tile.Motion tempMotion = Tile.Motion.Static; Tile.State tempState; for (int k = 0; k < fileManager.Contents[i].Count; k++) { if (fileManager.Contents[i][k] != nullTile) { split = fileManager.Contents[i][k].Split(','); tiles.Add(new Tile()); if (solid.Contains(fileManager.Contents[i][k])) tempState = Tile.State.Solid; else if (platform.Contains(fileManager.Contents[i][k])) tempState = Tile.State.Platform; else tempState = Tile.State.Passive; foreach (string m in motion) { getMotion = m.Split(':'); if (getMotion[0] == fileManager.Contents[i][k]) { tempMotion = (Tile.Motion)Enum.Parse(typeof(Tile.Motion), getMotion[1]); break; } } tiles[tiles.Count - 1].SetTile(tempState, tempMotion, new Vector2(k * (int)TileDimensions.X, indexY * (int)TileDimensions.Y), tileSheet, new Rectangle(int.Parse(split[0]) * (int)TileDimensions.X, int.Parse(split[1]) * (int)TileDimensions.Y, (int)TileDimensions.X, (int)TileDimensions.Y)); } } indexY++; break; } } } }
public void LoadContent(ContentManager content, string id) { this.content = new ContentManager(content.ServiceProvider, "Content"); optionsItems = new List<string>(); optionsImages = new List<Texture2D>(); animation = new List<List<Animation>>(); animationTypes = new List<string>(); attributes = new List<List<string>>(); contents = new List<List<string>>(); linkID = new List<string>(); linkType = new List<string>(); variable = new List<int>(); itemNumber = 0; optionNumber = 0; position = Vector2.Zero; limits = Vector2.Zero; fileManager = new FileManager(); fileManager.LoadContent("Load/options.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": optionsItems.Add(contents[i][j]); break; case "Image": optionsImages.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; case "Limits": temp = contents[i][j].Split(','); limits = new Vector2(int.Parse(temp[0]), int.Parse(temp[1])); break; case "Variable": temp = contents[i][j].Split(','); variable.Add(int.Parse(temp[1])); break; } } } SetoptionsItems(); SetAnimations(); }
public void LoadContent(ContentManager content, string id) { content = new ContentManager(content.ServiceProvider, "Content"); songs = new List<Song>(); fileManager = new FileManager(); fileManager.LoadContent("Load/Audio.txt", id); for (int i = 0; i < fileManager.Attributes.Count; i++) { for (int j = 0; j < fileManager.Attributes[i].Count; j++) { switch (fileManager.Attributes[i][j]) { case "Songs": String[] temp = fileManager.Contents[i][j].Split(','); song = content.Load<Song>(temp[1]); songs.Add(song); break; } } } }
public override void LoadContent(ContentManager Content, InputManager inputManager) { base.LoadContent(Content, inputManager); splashItems = new List<string>(); splashImages = new List<Texture2D>(); Animation = new List<Animation>(); fAnimation = new FadeAnimation(); fAnimation.DefaultAlpha = 0.001f; ssAnimation = new SpriteSheetAnimation(); animationTypes = new List<string>(); alpha = new List<float>(); itemNumber = 0; position = Vector2.Zero; align = "Center"; fileManager = new FileManager(); fileManager.LoadContent("Load/Splash.txt"); audio = new AudioManager(); audio.LoadContent(content, "Splash"); audio.PlaySong(0); audio.MusicVolume = 0.0f; audio.FadeSong(1.0f, new TimeSpan(0,0,1)); for (int i = 0; i < fileManager.Attributes.Count; i++) { for (int j = 0; j < fileManager.Attributes[i].Count; j++) { switch (fileManager.Attributes[i][j]) { case "Font": font = this.content.Load<SpriteFont>(fileManager.Contents[i][j]); break; case "Item": splashItems.Add(fileManager.Contents[i][j]); break; case "Image": splashImages.Add(content.Load<Texture2D>(fileManager.Contents[i][j])); break; case "Axis": axis = int.Parse(fileManager.Contents[i][j]); break; case "Position": string[] temp = fileManager.Contents[i][j].Split(' '); position = new Vector2(float.Parse(temp[0]), float.Parse(temp[1])); break; case "Animation": animationTypes.Add(fileManager.Contents[i][j]); break; case "Alpha": alpha.Add(float.Parse(fileManager.Contents[i][j])); break; case "FadeSpeed": fadeSpeed = float.Parse(fileManager.Contents[i][j]); break; case "Align": align = fileManager.Contents[i][j]; break; } } } SetSplashItems(); SetAnimations(); }
public override void UnloadContent() { base.UnloadContent(); fileManager = null; inputManager = null; attributes.Clear(); contents.Clear(); this.content.Unload(); }
public void UnloadContent() { fileManager = null; fileManager.Attributes = null; fileManager.Contents = null; images = null; position = null; posTemp = Vector2.Zero; align = null; scale = null; sourceRect = null; content.Unload(); }