private static void InitFight() { if (world[player.X, player.Y].Monster != null) { //Console.WriteLine("There is a monster in the room! Woho!"); world[player.X, player.Y].Monster.Fight(player); // monster mot player if (player.Health != 0) { player.Fight(world[player.X, player.Y].Monster); // player mot monster } if (world[player.X, player.Y].Monster.Health == 0) { if (world[player.X, player.Y].Monster.Name == "Skeleton") { world[player.X, player.Y].Monster.Name = "Pile of bones"; } else { world[player.X, player.Y].Monster.Name = "Zombie remains"; } player.Backpack.Add(world[player.X, player.Y].Monster); world[player.X, player.Y].Monster = null; Monster.MonsterCount--; } } }
private void RoomEvent() { Room room = world[player.X, player.Y]; if (room.Chest != null) // INTE KLAR!! { Console.Clear(); Console.WriteLine("You found a chest!"); Console.ReadKey(); do { Console.Clear(); DisplayFight(room.Chest, room.Chest.Fight(player)); Console.ReadKey(); } while (room.Chest.Health > 0); room.Chest.Pickup(player); room.Chest = null; } else if (room.Item != null) { room.Item.Pickup(player); room.Item = null; } else if (room.Monster != null) { Console.Clear(); Console.WriteLine("FIGHT!!!"); Console.ReadKey(true); do { Console.Clear(); DisplayFight(room.Monster, room.Monster.Fight(player)); Console.ReadKey(true); if (player.Health > 0 && room.Monster.Health > 0) { Console.Clear(); DisplayFight(room.Monster, player.Fight(room.Monster)); Console.ReadKey(true); } } while (room.Monster.Health > 0 && player.Health > 0); if (room.Monster.Health <= 0) { room.Monster.Pickup(player); room.Monster = null; Monster.MonsterCount--; } } }
private void SearchRoom() { Room currentRoom = world[player.X, player.Y]; Monster monster = currentRoom.Monster; if (currentRoom.Monster != null) { player.Fight(monster); monster.Fight(player); if (monster.Health <= 0) { Console.WriteLine($"You have slain a {monster.Name.ToString().ToLower()}"); player.PickUp(monster); currentRoom.Monster = null; Console.ReadKey(); } } else if (currentRoom.Item != null) { player.PickUp(currentRoom.Item); currentRoom.Item = null; } }
private void AskForMovement() { ConsoleKeyInfo keyInfo = Console.ReadKey(); int newX = player.X; int newY = player.Y; bool isValidMove = true; //Om spelaren håller sig inom rummets gränser switch (keyInfo.Key) { case ConsoleKey.RightArrow: newX++; break; case ConsoleKey.LeftArrow: newX--; break; case ConsoleKey.UpArrow: newY--; break; case ConsoleKey.DownArrow: newY++; break; default: isValidMove = false; break; } if (isValidMove && newX >= 0 && newX < world.GetLength(0) && newY >= 0 && newY < world.GetLength(1)) { player.X = newX; player.Y = newY; Room r = world[player.X, player.Y]; BackpackCollector(r); if (r.Monster != null) { Console.WriteLine($"You have met a {r.Monster.CharacterName}."); Console.WriteLine($"Select an item"); BackPackInventory(); string itemChoice = Console.ReadLine().ToLower(); bool weaponIsValid = false; switch (itemChoice) { case "k": //Hur välja knife? foreach (var item in player.BackPack) { if (item.Name == "Knife") { Console.WriteLine($"{item.Name} is equiped"); player.Strength = player.Strength + item.ExtraStrength; player.BackPack.Remove(item); weaponIsValid = true; break; } } if (weaponIsValid == false) { Console.WriteLine("You can not find you knife. /n Lets use our fists!"); } break; case "s": break; case "b": break; default: Console.WriteLine("You are a real warrior using your hands!"); break; } Console.ReadLine(); while (player.Health > 0 && r.Monster.Health > 0) { player.Fight(r.Monster); Console.WriteLine($"You hit {r.Monster.CharacterName} with {player.Strength} BP"); Console.WriteLine($"{r.Monster.CharacterName} health: {r.Monster.Health} HP."); Console.ReadLine(); if (r.Monster.Health > 0) { r.Monster.Fight(player); Console.WriteLine($"{r.Monster.CharacterName} hit you with {r.Monster.Strength} BP."); Console.WriteLine($"{player.CharacterName} health: {player.Health} HP."); Console.ReadLine(); } } if (r.Monster.Health <= 0) { Console.WriteLine($"You have slayed {r.Monster.CharacterName}, you are Victorius!!!"); Console.ReadLine(); player.Strength = random.Next(5, defaultStrength); r.Monster = null; // Monstret har dött! } } } }
private void AskForMovement() { ConsoleKeyInfo keyInfo = Console.ReadKey(); int newX = player.X; int newY = player.Y; bool isValidMove = true; //Om spelaren håller sig inom rummets gränser switch (keyInfo.Key) { case ConsoleKey.RightArrow: newX++; break; case ConsoleKey.LeftArrow: newX--; break; case ConsoleKey.UpArrow: newY--; break; case ConsoleKey.DownArrow: newY++; break; default: isValidMove = false; break; } if (isValidMove && newX >= 0 && newX < world.GetLength(0) && newY >= 0 && newY < world.GetLength(1)) { player.X = newX; player.Y = newY; Room r = world[player.X, player.Y]; BackpackCollector(r); if (r.Monster != null) { Console.WriteLine($"You have met a {r.Monster.CharacterName}."); Console.WriteLine($"Select an item"); Console.WriteLine("BACKPACK INVENTORY:"); foreach (var item in player.BackPack) { Console.WriteLine($"- {item.Name}"); } string itemChoice = Console.ReadLine().ToLower(); switch (itemChoice) { case "K": player.Strength += r.Item.ExtraStrength; //Hur välja knife? Console.WriteLine($"{player.Strength}"); Console.ReadLine(); break; default: break; } Console.ReadLine(); while (player.Health > 0 && r.Monster.Health > 0) { player.Fight(r.Monster); Console.WriteLine($"You hit {r.Monster.CharacterName} with {player.Strength} BP"); Console.WriteLine($"{r.Monster.CharacterName} health: {r.Monster.Health} HP."); Console.ReadLine(); if (r.Monster.Health > 0) { r.Monster.Fight(player); Console.WriteLine($"{r.Monster.CharacterName} hit you with {r.Monster.Strength} BP."); Console.WriteLine($"{player.CharacterName} health: {player.Health} HP."); Console.ReadLine(); } } if (r.Monster.Health <= 0) { Console.WriteLine($"You have slayed {r.Monster.CharacterName}, you are Victorius!!!"); Console.ReadLine(); r.Monster = null; // Monstret har dött! } } } }