//CONSTRUCTORS public Level(string name) { DungeonGenerator.DungeonGenerator dng = new DungeonGenerator.DungeonGenerator(21, 55, 10, 70, 80, new RoomGenerator(10, 3, 6, 3, 6)); int[,] intMap = DungeonGenerator.DungeonGenerator.ExpandToTiles(dng.Generate()); char[,] tempmap = Map.GenerateCharMap(intMap); _name = name; _map = new Map(tempmap, 1, 5); _entities = new List<LivingObject>(); _entrance = null; _exit = null; GenerateMonsters(10); GenerateItems(5); }
private Point CreateExit(string lvlName) { List<Point> startingPosList = Map.GenerateListOfStartingLocations(_map.map); Point startingPos = Map.SelectRandomEmptyLocation(startingPosList); _exit = new StairWay(startingPos, Enums.StairWaysType.DOWN, lvlName, new Point()); _map.addObjectAt(startingPos.X + _map.getOffsetX(), startingPos.Y + _map.getOffsetY(), _exit); return startingPos; }
public void GoUpDownStair() { if (GC.PC.ActualStamina < 1) { Game.topTextArea.AddMessage(Game.Lang[StringName.TIRED_TEXT]); return; } MapTile tile; StairWay stair = new StairWay(); StairWay newStair = new StairWay(); Level lvl = new Level(); Point newPos = new Point(); bool stairs = false; string lvlname; tile = GC.CurrentMap.getMapTile(GC.PC.getX(),GC.PC.getY()); //check if stairs are on same tile as player foreach (Object o in tile._objects) { if (o.getType() == ObjectType.O_STAIRWAY) { stairs = true; stair = o as StairWay; } } if (!stairs) { if (dir.Key == ConsoleKey.OemPeriod) { topTextArea.AddMessage("There is no stairs leading downwards"); } else if (dir.Key == ConsoleKey.OemComma) { topTextArea.AddMessage("There is no stairs leading upwards"); } } else { //check if we selected proper key if (dir.Key == ConsoleKey.OemPeriod && stair.Type != StairWaysType.DOWN) { topTextArea.AddMessage("There is no stairs leading downwards"); return; } if (dir.Key == ConsoleKey.OemComma && stair.Type != StairWaysType.UP) { topTextArea.AddMessage("There is no stairs leading upwards"); return; } //remove player from current location tile.removeObject(GC.PC); //get position of stairs on next level //get name of next level lvlname = stair.LevelName; foreach (Level l in GC.WorldLevels) { if (l.Name == lvlname) { lvl = l; break; } } //get stairs from new level if (dir.Key == ConsoleKey.OemPeriod) { newStair = lvl.Entrance; newStair.hasBeenSeen(); } else if (dir.Key == ConsoleKey.OemComma) { newStair = lvl.Exit; newStair.hasBeenSeen(); } newPos = newStair.Position; //set new level's map as current GC.CurrentMap = lvl.Map; //set current level GC.CurrentLevel = lvl; //set new entity list from new level GC.Entities = lvl.EntityList; //set player at new map GC.CurrentMap.addObjectAt(newPos.X + GC.CurrentMap.getOffsetX(), newPos.Y + GC.CurrentMap.getOffsetY(), GC.PC); //use stamina every 5 minutes (ie 30 rounds) if not in comabt if (Game.GC.turnCounter != 0 && Game.GC.turnCounter % 30 == 0) { GC.PC.ActualStamina -= 1; } Game.bottomPanel.needUpdate = true; ClearMap(); GC.CurrentMap.draw(); } }