/// <summary> /// This Function sets up a level with its specific objects to make a /// level for the game /// </summary> /// <param name="player"> Get player for level</param> /// <param name="exit"> Get an exit point for level</param> /// <param name="map"> set a map to show objects of level</param> /// <param name="items"> For the storation of items</param> /// <param name="grabItems"> To grab items on level</param> /// <param name="traps"> Set traps on level</param> /// <param name="foods"> Set food on level</param> /// <param name="weapons"> Set weapons on level</param> /// <param name="enemies"> Set enemies on level</param> /// <param name="RowSize"> Get row on level </param> /// <param name="ColSize"> get col on level</param> /// <param name="cells"> get the cells from level</param> internal void Setup(Player player, CurrentMapObjects exit, CurrentMapObjects map, List <CurrentMapObjects> items, List <Items> grabItems, List <Trap> traps, List <Food> foods, List <Weapons> weapons, List <Enemy> enemies, int RowSize, int ColSize, BoardCells[,] cells) { // Max size of objects in Levels int maxTrapsInLvl = Linear(Current, Diff, 2); int maxItemsInLvl = Linear(Current, Diff, 2); int maxEnemiesInLvl = Linear(Current, Diff, 2); //Add objects to item list items.Add(exit); items.Add(map); // Generate a random numb of objects in level int numberOfTraps = rnd.Next(maxTrapsInLvl); int numberOfItems = rnd.Next(maxItemsInLvl); int numberOfEnemies = rnd.Next(maxEnemiesInLvl); // Set random Traps around on map and put a trap with its specific // information about the object and add it to its lists for (int i = 0; i < numberOfTraps; i++) { int row = rnd.Next(RowSize); int col = rnd.Next(ColSize); Trap trap = new Trap((new Position(row, col)), Chars.trap, $"this is a trap! watch out!", rnd.Next(100)); traps.Add(trap); items.Add(trap); } // Set random Items around the map and put a map with its specific // information about the object and add it to its lists for (int i = 0; i < numberOfItems; i++) { Position foodPosition; Position weaponPosition; do { foodPosition = new Position(rnd.Next(RowSize), rnd.Next(ColSize)); }while (foodPosition.Row == exit.Position.Row && foodPosition.Col == exit.Position.Col); do { weaponPosition = new Position(rnd.Next(RowSize), rnd.Next(ColSize)); }while (weaponPosition.Row == exit.Position.Row && weaponPosition.Col == exit.Position.Col); Food food = new Food(foodPosition, Chars.food, " An apple a day keeps god astray", rnd.Next(10), rnd.Next(100)); Weapons weapon = new Weapons(weaponPosition, Chars.weapon, "dagger", rnd.Next(10), rnd.Next(100), rnd.Next(10)); items.Add(food); grabItems.Add(food); foods.Add(food); items.Add(weapon); grabItems.Add(weapon); weapons.Add(weapon); } // Set random enemies around the map and put them with its specific // information about the object and add it to its list for (int i = 0; i < numberOfEnemies; i++) { int row = rnd.Next(RowSize); int col = rnd.Next(ColSize); Position enemyPosition; do { enemyPosition = new Position(row, col); }while (enemyPosition.Row == exit.Position.Row && enemyPosition.Col == exit.Position.Col); Enemy enemy = new Enemy((new Position(row, col)), Chars.enemy, " A wild enemy has appeared!", rnd.Next(100)); enemies.Add(enemy); items.Add(enemy); } // empty cells so the player can't see what's on the map immediately for (int i = 0; i < RowSize; i++) { for (int j = 0; j < ColSize; j++) { cells[i, j] = new BoardCells((char)Chars.empty, false); } } cells[player.Position.Row, player.Position.Col] = new BoardCells(player.name, false); }
internal void Setup(Player player, CurrentMapObjects exit, CurrentMapObjects map, List <CurrentMapObjects> items, List <Items> grabItems, List <Trap> traps, List <Food> foods, List <Weapons> weapons, List <Enemy> enemies, int RowSize, int ColSize, BoardCells[,] cells) { // Max size of objects in Levels int maxTrapsInLvl = Linear(Current, Diff, 2); int maxItemsInLvl = Linear(Current, Diff, 2); int maxEnemiesInLvl = Linear(Current, Diff, 2); //Add objects to item list items.Add(exit); items.Add(map); // int numberOfTraps = rnd.Next(maxTrapsInLvl); int numberOfItems = rnd.Next(maxItemsInLvl); int numberOfEnemies = rnd.Next(maxEnemiesInLvl); // Set random Traps around on map for (int i = 0; i < numberOfTraps; i++) { int row = rnd.Next(RowSize); int col = rnd.Next(ColSize); Trap trap = new Trap((new Position(row, col)), Chars.trap, $"this is a trap! watch out!", rnd.Next(100)); traps.Add(trap); items.Add(trap); } // Set random Items around the map for (int i = 0; i < numberOfItems; i++) { int row = rnd.Next(RowSize); int col = rnd.Next(ColSize); Food food = new Food((new Position(row, col)), Chars.food, " An apple a day keeps god astray", rnd.Next(10), rnd.Next(100)); Weapons weapon = new Weapons((new Position(row, col)), Chars.weapon, "dagger", rnd.Next(10), rnd.Next(100), rnd.Next(10)); items.Add(food); grabItems.Add(food); foods.Add(food); items.Add(weapon); grabItems.Add(weapon); weapons.Add(weapon); } // Set random enemies around the map for (int i = 0; i < numberOfEnemies; i++) { int row = rnd.Next(RowSize); int col = rnd.Next(ColSize); Enemy enemy = new Enemy((new Position(row, col)), Chars.enemy, " A wild enemy has appeared!", rnd.Next(100)); enemies.Add(enemy); items.Add(enemy); } for (int i = 0; i < RowSize; i++) { for (int j = 0; j < ColSize; j++) { cells[i, j] = new BoardCells((char)Chars.empty, false, new Position(i, j)); } } cells[player.Position.Row, player.Position.Col] = new BoardCells(player.name, false, new Position(player.Position.Row, player.Position.Col)); }