public void PreviousLevel() { if (levelindex <= 0) { levelindex = 1; } else if (levelindex >= levels.Count) { levelindex = levels.Count; } else { foreach (Level l in levels) { Enumeration.LevelName levelName = (Enumeration.LevelName)Enum.Parse(typeof(Enumeration.LevelName), levelindex.ToString()); if (l.levelIndex == levelindex) { player.StartLevel(FindRoom(l.startroom)); } } levelindex -= 1; player.SpriteRoom.StartNewLife(graphicsDevice); } }
public Level(Maze Maze, string LevelNumber) { this.maze = Maze; this.levelName = (Enumeration.LevelName)Enum.Parse(typeof(Enumeration.LevelName), LevelNumber.ToString()); rooms = new List <Room>(); blockRoom = new Room(maze, this, PoP.CONFIG_PATH_CONTENT + PoP.CONFIG_PATH_ROOMS + "MAP_blockroom.xml", 0); blockRoom.roomName = "MAP_blockroom.xml"; }
public Level CurrentLevel() { foreach (Level l in levels) { Enumeration.LevelName levelName = (Enumeration.LevelName)Enum.Parse(typeof(Enumeration.LevelName), levelindex.ToString()); if (l.levelIndex == levelindex) { Currentlevelname = Enum.GetName(typeof(Enumeration.LevelName), l.levelIndex); return(l); } } return(null); }
private void StartLevelPoP(Enumeration.LevelName levelName) { levels = new List <Level>(); //DISABLED POP HAVE ONLY 1 LEVEL.... someone can be draw all levels?!? //if ((int)levelName >= levelsPoN.Count) //{ // levelName = Enumeration.LevelName.dungeon_demo; // levelIndex = (int)levelName; //} List <PopNet.Level> levelsPopNet = new List <PopNet.Level>(); var files = Directory .GetFiles(PoP.CONFIG_PATH_CONTENT + "/" + PoP.CONFIG_PATH_LEVELS + "/", "*.xml") .ToList(); foreach (object f in files) { Stream txtReader = Microsoft.Xna.Framework.TitleContainer.OpenStream(f.ToString()); System.Xml.Serialization.XmlSerializer ax = null; ax = new System.Xml.Serialization.XmlSerializer(typeof(PopNet.Level)); levelsPopNet.Add((PopNet.Level)ax.Deserialize(txtReader)); } //load all room for (int z = 0; z < levelsPopNet.Count(); z++) { Level level = new Level(this, levelsPopNet[z].levelName.ToString()); for (int y = 0; y < levelsPopNet[z].rows.Count(); y++) { for (int x = 0; x < levelsPopNet[z].rows[y].columns.Count(); x++) { if (levelsPopNet[z].rows[y].columns[x].FilePath == string.Empty) { levelsPopNet[z].rows[y].columns[x].FilePath = "MAP_blockroom.xml"; } Room room = new Room(this, level, PoP.CONFIG_PATH_CONTENT + PoP.CONFIG_PATH_ROOMS + levelsPopNet[z].rows[y].columns[x].FilePath, levelsPopNet[z].rows[y].columns[x].RoomIndex); room.roomStart = levelsPopNet[z].rows[y].columns[x].RoomStart; room.roomNumber = levelsPopNet[z].rows[y].columns[x].RoomIndex; room.roomName = levelsPopNet[z].rows[y].columns[x].FilePath; room.roomZ = z; room.roomX = x; room.roomY = y; level.rooms.Add(room); //Allocate room shortcut if (x - 1 >= 0) { room._RoomLeft = levelsPopNet[z].rows[y].columns[x - 1].RoomIndex; } if (x + 1 < levelsPopNet[z].rows[y].columns.Count()) { room._RoomRight = levelsPopNet[z].rows[y].columns[x + 1].RoomIndex; } if (y + 1 < levelsPopNet[z].rows.Count()) { room._RoomDown = levelsPopNet[z].rows[y + 1].columns[x].RoomIndex; } if (y - 1 >= 0) { room._RoomUp = levelsPopNet[z].rows[y - 1].columns[x].RoomIndex; } } } levels.Add(level); } // }
private void StartLevel(Enumeration.LevelName levelName) { levels = new List <Level>(); if ((int)levelName >= levelsApoplexy.Count) { levelName = Enumeration.LevelName.dungeon_demo; levelIndex = (int)levelName; } //load all room for (int z = 0; z < levelsApoplexy.Count(); z++) { if ((int)levelName != int.Parse(levelsApoplexy[z].number)) { continue; } Level level = new Level(this, levelsApoplexy[z].number); //int newX = 1; for (int y = 0; y < levelsApoplexy[z].rooms.Count(); y++) { Room room = new Room(this, level, levelsApoplexy[z], levelsApoplexy[z].rooms[y].tile, levelsApoplexy[z].rooms[y].number, levelsApoplexy[z].rooms[y].links, levelsApoplexy[z].rooms[y].guard, levelsApoplexy[z].events, levelsApoplexy[z].prince, levelsApoplexy[z].userdata.field[5].value); level.rooms.Add(room); } //i will associate events //ASSOCIATE EVENTS Apoplexy.@event eventPrec = null; foreach (Apoplexy.@event e in levelsApoplexy[z].events) { foreach (Room r in level.rooms) { if (r.roomNumber.ToString() == e.room) { foreach (Tile t in r.tiles) { float tileLocation = 10 * t.Coordinates.Y + t.Coordinates.X + 1; if (tileLocation == float.Parse(e.location)) { if (t.Type == Enumeration.TileType.gate) { if (eventPrec == null) { ((Gate)t).switchButtons.Add(int.Parse(e.number)); if (e.next == "1") { eventPrec = e; } } else { ((Gate)t).switchButtons.Add(int.Parse(eventPrec.number)); if (e.next != "1") { eventPrec = null; } } } else if (t.Type == Enumeration.TileType.exit) { if (eventPrec == null) { ((Exit)t).switchButtons.Add(int.Parse(e.number)); if (e.next == "1") { eventPrec = e; } } else { ((Exit)t).switchButtons.Add(int.Parse(eventPrec.number)); if (e.next != "1") { eventPrec = null; } } } } } } } } levels.Add(level); } }