public override void OnCollision(Entity e) { //collision detection with enemy result in player being sent to start of map Type type = e.GetType(); if (type == typeof(Enemy)) { health--; fileManager = new FileManager(); fileManager.LoadContent("Load/Maps/Map1.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 "PlayerPosition": string[] split = fileManager.Contents[i][j].Split(','); position = new Vector2(float.Parse(split[0]), float.Parse(split[1])); 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> >(); layerNumber = 0; 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(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> > >(); layerNumber = 0; // setting up the filename and identifier for map1.txt fileManager.LoadContent("Load/Maps/" + mapID + ".txt", "Layers"); // switch case for the different ltype indexing within the map1.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 "TileSet": tileSet = this.content.Load <Texture2D>("TileSets/" + fileManager.Contents[i][j]); break; case "TileDimensions": string[] split = fileManager.Contents[i][j].Split(','); tileDimensions = new Vector2(int.Parse(split[0]), int.Parse(split[1])); break; case "StartLayer": for (int k = 0; k < fileManager.Contents[i].Count; k++) { split = fileManager.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 input) { this.input = input; 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("xnaplatformer." + entityType); entities.Add((Entity)Activator.CreateInstance(newClass)); entities[i].LoadContent(Content, fileManager.Attributes[i], fileManager.Contents[i], this.input); } }
public void LoadContent(ContentManager content, string mapID) { fileManager = new FileManager(); collisionMap = new List <List <string> >(); row = new List <string>(); fileManager.LoadContent("Load/Maps/" + mapID + ".txt", "Collision"); for (int i = 0; i < fileManager.Contents.Count; i++) { for (int j = 0; j < fileManager.Contents[i].Count; j++) { row.Add(fileManager.Contents[i][j]); } collisionMap.Add(row); row = new List <string>(); } }
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>(); // filename for the splashscreen images fileManager.LoadContent("Load/Splash.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 "Image": images.Add(this.content.Load <Texture2D>(fileManager.Contents[i][j])); animation.Add(new FadeAnimation()); break; } } } for (int i = 0; i < fileManager.Attributes.Count; i++) { // loading in image and dimensions animation[i].LoadContent(content, images[i], "", new Vector2(ScreenManager.Instance.Dimensions.X / 2 - images[i].Width / 2, ScreenManager.Instance.Dimensions.Y / 2 - images[i].Height / 2)); animation[i].Scale = 1.0f; animation[i].IsActive = true; } }
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(); fade = new List <FadeAnimation>(); images = new List <Texture2D>(); fileManager.LoadContent("Load/Splash.cme", attributes, contents); for (int i = 0; i < attributes.Count; i++) { for (int j = 0; j < attributes[i].Count; j++) { switch (attributes[i][j]) { case "Image": images.Add(this.content.Load <Texture2D>(contents[i][j])); fade.Add(new FadeAnimation()); break; } } } for (int i = 0; i < attributes.Count; i++) { fade[i].LoadContent(content, images[i], "", new Vector2(ScreenManager.Instance.Dimensions.X / 2 - images[i].Width / 2, ScreenManager.Instance.Dimensions.Y / 2 - images[i].Height / 2)); fade[i].Scale = 1.0f; fade[i].IsActive = true; } }
public void LoadContent(Map map, string layerID) { tiles = new List <Tile>(); motion = new List <string>(); solid = new List <string>(); fileManager = new FileManager(); content = new ContentManager(ScreenManager.Instance.Content.ServiceProvider, "Content"); // setting up the filename and identifier for map1.txt fileManager.LoadContent("Load/Maps/" + map.ID + ".txt", layerID); int indexY = 0; // switch case for the different values within the map1.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 "TileSet": tileSheet = content.Load <Texture2D>("TileSets/" + fileManager.Contents[i][j]); break; case "Solid": solid.Add(fileManager.Contents[i][j]); break; case "Motion": motion.Add(fileManager.Contents[i][j]); break; case "NullTile": nullTile = 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++) { // settings for wether the tiles will be solid or passive if (fileManager.Contents[i][k] != nullTile) { string[] split = fileManager.Contents[i][k].Split(','); tiles.Add(new Tile()); if (solid.Contains(fileManager.Contents[i][k])) { tempState = Tile.State.Solid; } else { tempState = Tile.State.Passive; } foreach (string m in motion) { // settings for motion of the tiles 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 * 32, indexY * 32), tileSheet, new Rectangle(int.Parse(split[0]) * 32, int.Parse(split[1]) * 32, 32, 32)); } } indexY++; break; } } } }
public void LoadContent(ContentManager content, string id) { this.content = new ContentManager(content.ServiceProvider, "Content"); menuItems = new List <string>(); animationTypes = new List <string>(); linkType = new List <string>(); linkID = new List <string>(); menuImages = new List <Texture2D>(); animation = new List <List <Animation> >(); attributes = new List <List <string> >(); contents = new List <List <string> >(); itemNumber = 0; position = Vector2.Zero; fileManager = new FileManager(); fileManager.LoadContent("Load/Menu.cme", 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(); }
public void LoadContent(Map map, string layerID) { tiles = new List <Tile>(); attributes = new List <List <string> >(); contents = new List <List <string> >(); motion = new List <string>(); solid = new List <string>(); fileManager = new FileManager(); 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 "NullTile": nullTile = contents[i][j]; break; case "StartLayer": Tile.Motion tempMotion = Tile.Motion.Static; Tile.State tempState; for (int k = 0; k < contents[i].Count; k++) { if (contents[i][k] != nullTile) { string[] split = contents[i][k].Split(','); tiles.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; } } tiles[tiles.Count - 1].SetTile(tempState, tempMotion, new Vector2(k * TileDimensions.X, indexY * TileDimensions.X), tileSheet, //tile dimensions are here new Rectangle(int.Parse(split[0]) * 16, int.Parse(split[1]) * 16, 16, 16)); } } indexY++; break; } } } }
public void LoadContent(ContentManager content, string id) { this.content = new ContentManager(content.ServiceProvider, "Content"); menuItems = new List <string>(); animationTypes = new List <string>(); linkType = new List <string>(); linkID = new List <string>(); menuImages = new List <Texture2D>(); animation = new List <Animation>(); itemNumber = 0; fAnimation = new FadeAnimation(); ssAnimation = new SpriteSheetAnimation(); position = Vector2.Zero; fileManager = new FileManager(); // loading in the filename for Menu.txt fileManager.LoadContent("Load/Menu.txt", id); // switch case for the menu types and values 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": menuItems.Add(fileManager.Contents[i][j]); break; case "Image": menuImages.Add(this.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 "Source": temp = fileManager.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(fileManager.Contents[i][j]); break; case "Align": align = fileManager.Contents[i][j]; break; case "LinkType": linkType.Add(fileManager.Contents[i][j]); break; case "LinkID": linkID.Add(fileManager.Contents[i][j]); break; } } } SetMenuItems(); SetAnimations(); }