/// <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 Pickup(GameBoard board, Player player) { bool noWeapons = weaponsInCell.Count < 1; bool noFood = foodInCell.Count < 1; if (!noFood) { Console.WriteLine("Food name: Effect:"); Console.WriteLine("__________________________________________"); foreach (Food item in foodInCell) { Console.WriteLine(item.Info + $"{item.HPIncrease} "); } } if (!noWeapons) { Console.WriteLine("Weapon name: Attack Power:"); Console.WriteLine("__________________________________________"); foreach (Weapons item in weaponsInCell) { Console.WriteLine(item.Info + $"{item.AttackPower} "); } } Console.WriteLine("Choose:"); if (!noFood) { Console.WriteLine("0. for food"); } if (!noWeapons) { Console.WriteLine("1. for weapons"); } Console.WriteLine("type C and press enter to go back"); string answer = Console.ReadLine(); if (answer == "0") { Console.WriteLine("Food name: Effect:"); Console.WriteLine("__________________________________________"); int counter = 0; foreach (Food item in foodInCell) { Console.WriteLine(counter + "." + item.Info + $"{item.HPIncrease} "); counter++; } counter = 0; Console.WriteLine("Pick the number of the food you want"); answer = Console.ReadLine(); Food pickedFood = foodInCell[Convert.ToInt32(answer)]; board.inventory.AddToInventory(new Food((pickedFood.Position), pickedFood.Name, pickedFood.Info, pickedFood.Weight, pickedFood.HPIncrease)); board.cells[pickedFood.Position.Row, pickedFood.Position.Col] = new BoardCells((char)Chars.path, true, new Position(pickedFood.Position.Row, pickedFood.Position.Col)); foodInInventory.Add(pickedFood); board.pickItems.Remove(pickedFood); board.itemList.Remove(pickedFood); board.food.Remove(pickedFood); } if (answer == "1") { Console.WriteLine("Weapon name: Effect: Attack Power:"); Console.WriteLine("__________________________________________"); int counter = 0; foreach (Weapons item in weaponsInCell) { Console.WriteLine(counter + "." + item.Info + $"{item.AttackPower} + ${item.Durability}"); counter++; } counter = 0; Console.WriteLine("Pick the number of the weapon you want"); answer = Console.ReadLine(); Weapons pickedWeapon = weaponsInCell[Convert.ToInt32(answer)]; board.inventory.AddToInventory(new Weapons((pickedWeapon.Position), pickedWeapon.Name, pickedWeapon.Info, pickedWeapon.Weight, pickedWeapon.AttackPower, pickedWeapon.Durability)); weaponsInInventory.Add(pickedWeapon); board.pickItems.Remove(pickedWeapon); board.itemList.Remove(pickedWeapon); board.weapons.Remove(pickedWeapon); } foodInCell.Clear(); weaponsInCell.Clear(); Console.Clear(); }
/// <summary> /// this method allows us to drop an item we currently hold /// </summary> /// <param name="board">current level board</param> /// <param name="player">current player</param> internal void Drop(GameBoard board, Player player) { // write the information regaerding the food Console.WriteLine("Food name: Effect:"); Console.WriteLine("__________________________________________"); foreach (Food item in foodInInventory) { Console.WriteLine(item.Info + $"{item.HPIncrease} "); } // write the information regaerding the weapons Console.WriteLine("Weapon name: Attack Power:"); Console.WriteLine("__________________________________________"); foreach (Weapons item in weaponsInInventory) { Console.WriteLine(item.Info + $"{item.AttackPower} "); } // ask user for input Console.WriteLine("Choose:"); Console.WriteLine("0. for food"); Console.WriteLine("1. for weapons"); Console.WriteLine("press enter to go back"); // get user input string answer = Console.ReadLine(); // check user input and access the food list if (answer == "0") { Console.WriteLine("Food name: Effect:"); Console.WriteLine("__________________________________________"); foreach (Food item in foodInInventory) { Console.WriteLine(item.Info + $"{item.HPIncrease} "); } // ask for user input again Console.WriteLine("Pick the number of the food you want"); answer = Console.ReadLine(); // selected food to drop Food pickedFood = foodInInventory[Convert.ToInt32(answer)]; // add item to board lists again board.pickItems.Add(new Food((player.Position), pickedFood.Name, pickedFood.Info, pickedFood.Weight, pickedFood.HPIncrease)); board.itemList.Add(new Items(player.Position, pickedFood.Name, pickedFood.Info, pickedFood.Weight)); board.food.Add(new Food(player.Position, pickedFood.Name, pickedFood.Info, pickedFood.Weight, pickedFood.HPIncrease)); board.cells[player.Position.Row, player.Position.Col] = new BoardCells((char)pickedFood.Name, true); // remove item from inventory lists foodInInventory.Remove(pickedFood); // so the player loses a turn player.HealthChange(-1); Console.Clear(); } // access the weapon's list if (answer == "1") { // print out the information regarding each weapon Console.WriteLine("Weapon name: Attack Power:"); Console.WriteLine("__________________________________________"); foreach (Weapons item in weaponsInInventory) { Console.WriteLine(item.Info + $"{item.AttackPower} "); } // ask user for input Console.WriteLine("Pick the number of the weapon you want"); answer = Console.ReadLine(); Weapons pickedWeapon = weaponsInInventory [Convert.ToInt32(answer)]; // add the weapon to the board lists board.pickItems.Add(new Weapons((pickedWeapon.Position), pickedWeapon.Name, pickedWeapon.Info, pickedWeapon.Weight, pickedWeapon.AttackPower, pickedWeapon.Durability)); board.itemList.Add(new Items(pickedWeapon.Position, pickedWeapon.Name, pickedWeapon.Info, pickedWeapon.Weight)); board.weapons.Add(new Weapons(pickedWeapon.Position, pickedWeapon.Name, pickedWeapon.Info, pickedWeapon.Weight, pickedWeapon.AttackPower, pickedWeapon.Durability)); board.cells[pickedWeapon.Position.Row, pickedWeapon.Position.Col] = new BoardCells((char)pickedWeapon.Name, true); // remove the weapon from inventory weaponsInInventory.Remove(pickedWeapon); // so the player loses a turn player.HealthChange(-1); Console.Clear(); } }
/// <summary> /// this method allows us to pick up an item from the board and place /// it in our inventory if we have space /// </summary> /// <param name="board">current level's board</param> /// <param name="player">player</param> internal void Pickup(GameBoard board, Player player) { // print out information regarding the food Console.WriteLine("Food name: Effect:"); Console.WriteLine("__________________________________________"); foreach (Food item in board.food) { if (item.FallenInto(board.player)) { Console.WriteLine(item.Info + $"{item.HPIncrease} "); } } // print out information regarding the weapons Console.WriteLine("Weapon name: Attack Power:"); Console.WriteLine("__________________________________________"); foreach (Weapons item in board.weapons) { if (item.FallenInto(board.player)) { Console.WriteLine(item.Info + $"{item.AttackPower} "); } } Console.WriteLine("Choose:"); Console.WriteLine("0. for food"); Console.WriteLine("1. for weapons"); Console.WriteLine("press enter to go back"); string answer = Console.ReadLine(); // enter the list regarding the food if (answer == "0") { Console.WriteLine("Food name: Effect:"); Console.WriteLine("__________________________________________"); foreach (Food item in board.food) { if (item.FallenInto(board.player)) { Console.WriteLine(item.Info + $"{item.HPIncrease} "); } } Console.WriteLine("Pick the number of the food you want"); string answeri = Console.ReadLine(); Food pickedFood = board.food[Convert.ToInt32(answeri)]; board.inventory.AddToInventory(new Food((pickedFood.Position), pickedFood.Name, pickedFood.Info, pickedFood.Weight, pickedFood.HPIncrease)); // remove food from all the lists regarding the board board.pickItems.Remove(pickedFood); board.itemList.Remove(pickedFood); board.food.Remove(pickedFood); // so the player loses a turn player.HealthChange(-1); } // to enter the list regarding the weapons if (answer == "1") { Console.WriteLine("Weapon name: " + " AttackPower: Durability:"); Console.WriteLine("__________________________________________"); foreach (Weapons item in board.weapons) { if (item.FallenInto(board.player)) { Console.WriteLine(item.Info + $"{item.AttackPower}" + $" " + $"{item.Durability}"); } } Console.WriteLine("Pick the number of the weapom you want"); string answeri = Console.ReadLine(); Weapons pickedWeapon = board.weapons[Convert.ToInt32(answeri)]; board.inventory.AddToInventory(new Weapons((pickedWeapon.Position), pickedWeapon.Name, pickedWeapon.Info, pickedWeapon.Weight, pickedWeapon.AttackPower, pickedWeapon.Durability)); // remove the item from all the lists within the board board.pickItems.Remove(pickedWeapon); board.itemList.Remove(pickedWeapon); board.weapons.Remove(pickedWeapon); // so the player loses a turn player.HealthChange(-1); } else { Console.WriteLine("invalid input"); } // so the player loses a turn player.HealthChange(-1); Console.Clear(); }
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)); }