// This will be the scene that will happen for a fight public static string FightScene(ref Monster monster, ref Player player) { Console.Clear(); while (monster.health > 0) { Console.WriteLine($"Hello, {player.name} you have been caught by {monster.name} now you must fight to make it out alive.\n\n"); Console.Write($"Actions:\nStrike - you will strike your weapon at {monster.name}.\nStatus - shows yours and {monster.name} stats.\nHeal - this will be used to heal yourself.\n" + $"Eat - this will allow you to eat.\n\n\nWhat action you like to take? "); string message = Console.ReadLine().ToLower(); Console.WriteLine(); switch (message) { case "strike": Strike(ref player, ref monster); break; case "status": Status(ref player, ref monster); break; case "heal": Heal(ref player); break; case "eat": Eat(ref player); break; default: Console.WriteLine("You typed an invalid action try again."); break; } if (player.health <= 0) { return("failed"); } Thread.Sleep(1500); Console.Clear(); } monster = null; player.level++; player.coins++; FileSetup.CoinWrite(Game.coinFile, ref player); FileSetup.LevelWrite(Game.levelFile, ref player); FileSetup.PlayerFileWrite(ref player, Game.playerFile); return("success"); }
// User will use this to explore the monster public static void MonsterExplore() { Random random = new Random(); Monster[] tempArrayMonster = new Monster[monsters.Length]; int i = 0; int count = 0; Tools. Shuffle(ref player.storage); Tools.ShuffleDamage(ref player); foreach (Item item in player.storage) { if (item == null) { count++; } else { if (item.itemType != ItemType.WEAPON) { count++; } } } if (count < player.storage.Length) { bool monsterActive = false; foreach (Monster monster in monsters) { if (monster != null && monster.level <= player.level) { tempArrayMonster[i] = monster; monsterActive = true; } i++; } // Checks if the monster is exists if (monsterActive) { int num = random.Next() % tempArrayMonster.Length; int counter = 0; foreach (Monster monster in tempArrayMonster) { if (monster != null && monster.level <= player.level) { break; } counter++; } // Turns the monster to null if it matches the tempMonstersName try { Monster tempMonster = tempArrayMonster[counter]; string tempMonsterName = tempMonster.name; if (tempMonster != null) { Action.FightScene(ref tempMonster, ref player); } for (int x = 0; x < monsters.Length; x++) { if (monsters[x] != null) { if (monsters[x].name == tempMonsterName) { monsters[x] = null; } } } Tools.Shuffle(ref monsters); FileSetup.MonsterFileWrite(ref monsters, monsterFile); FileSetup.LevelWrite(levelFile, ref player); } catch (NullReferenceException e) { Console.WriteLine($"Hello, {player.name} we could not find a monster to kill. Please try again. "); Thread.Sleep(2500); } } else { Console.WriteLine($"Hello, {player.name} we could not find a monster to kill. Please try again. "); Thread.Sleep(2500); } } else { Console.WriteLine($"Hello, {player.name} you currently don't have any items that you can adventure with."); Thread.Sleep(2500); } }