//make a loop to hold player movement and other values public static bool GameLoop(Adventurer adventurer, Universe universe) { Random random = new Random(); int encounter = 0; bool playing = true; bool win = false; TextBoxViews.DisplayPlayerInfo(adventurer); TextBoxViews.DisplayHeader(); Console.CursorVisible = false; while (playing) { TextBoxViews.DisplayPosition(adventurer); playing = Map.movement(adventurer, universe); Map.CheckPosition(adventurer, universe); encounter = random.Next(1, 30); if (encounter < 2 && adventurer.MapLocation == Humanoid.Location.MainWorld) { Slime slime = new Slime(); Slime.InitializeNewSlime(slime); playing = Battle.BattleLoop(adventurer, universe, slime); } if (universe.TripleTrouble[0].Defeated && universe.TripleTrouble[1].Defeated && universe.TripleTrouble[2].Defeated) { adventurer.playerWin = true; playing = false; } if (adventurer.diedOnFinal) { playing = false; } } return(win); }
//#------------------------------The actual game-------------------------- static int GameLoop(Player player, Slime slime, Ally ally) { ScreenWindows.DisplayTextBoxPlayer(); Random random = new Random(); int end = 2; Console.Clear(); ScreenWindows.DisplayGameScreen(); ScreenWindows.DisplayTextBoxPlayer(); int KingEncounter = 0; bool kingKilled = false; int nothing = 0; while ((player.Health > 0) && !kingKilled) { Thread.Sleep(1000); Console.SetCursorPosition(27, 32); Console.Write("You walk down a cave corridor..."); int slimechance = random.Next(1, 4); Console.SetCursorPosition(27, 33); Thread.Sleep(2000); if (slimechance == 1) { Console.Write("A slime Attacks!"); Thread.Sleep(1000); Slime.InitializeNewSlime(slime, ally); ScreenWindows.DisplaySlime(slime); BattleLoop(player, slime, ally); nothing = 0; } if (slimechance == 2) { Thread.Sleep(2000); Slime.InitializeNewSlime(slime, ally); Console.Write($"You have spotted a {slime.Color} slime minding its own buisness"); Thread.Sleep(1000); ScreenWindows.DisplaySlime(slime); SlimePassive(player, slime, ally); nothing = 0; } else if (slimechance == 3) { Console.Write("You got lucky and encountered no slimes"); Thread.Sleep(1000); nothing++; } else { Console.Write("Nothing happend and you move on"); nothing++; } if (nothing > 5) { Console.WriteLine("A slime dropped onto your head and suprized you"); BattleLoop(player, slime, ally); nothing = 0; } if (KingEncounter > 20) { ScreenWindows.ClearPlayerTextBox(); Console.SetCursorPosition(27, 33); Console.Write("You feel an intense presense up ahead"); for (int dot = 0; dot < 4; dot++) { Console.Write("."); Thread.Sleep(1000); } Console.SetCursorPosition(27, 34); Console.Write("You get a glimpse of a regal slime hiding behind"); Console.SetCursorPosition(27, 35); Console.Write("a nearby pillar... you enter the room filled with"); Console.SetCursorPosition(27, 36); Console.Write("a powerful presence."); ScreenWindows.DisplayContinuePrompt(103, 38); slime.KingSlime = true; Slime.InitializeNewSlime(slime, ally); BattleLoop(player, slime, ally); kingKilled = true; end = 3; } KingEncounter++; Thread.Sleep(2500); ScreenWindows.ClearPlayerTextBox(); Console.ForegroundColor = ConsoleColor.Gray; ScreenWindows.ClearSlime(); } return(end); }
/// <summary> /// lets you talk to NPC's /// Cycles through set text each npc has /// </summary> /// <param name="adventurer"></param> /// <param name="universe"></param> public static void NPCTalk(Adventurer adventurer, Universe universe) { int xPos = adventurer.Xpos; int yPos = adventurer.Ypos; if (adventurer.InaHouse && adventurer.InHouseName == House.houseName.Market) { switch (adventurer.LookDirection) { case Humanoid.Direction.LEFT: xPos -= 2; break; case Humanoid.Direction.RIGHT: xPos++; break; case Humanoid.Direction.UP: yPos--; break; case Humanoid.Direction.DOWN: yPos++; break; default: break; } } else { switch (adventurer.LookDirection) { case Humanoid.Direction.LEFT: xPos--; break; case Humanoid.Direction.RIGHT: xPos++; break; case Humanoid.Direction.UP: yPos--; break; case Humanoid.Direction.DOWN: yPos++; break; default: break; } } bool trig = true; string text = "There is no-one to talk with in front of you, Are you going insane?"; foreach (NPC npc in universe.NPCList) { if (npc.Xpos == xPos && npc.Ypos == yPos) { TextBoxViews.RedrawBox(universe, 7); TextBoxViews.WriteToNpcNameBox(npc.Name); text = npc.messages[npc.listCurrent]; npc.listCurrent++; if (npc.MapLocation == adventurer.MapLocation) { if (npc.Name == "Merchant") { TextBoxViews.MerchantMessage(universe, adventurer); trig = false; QuestTrigger(adventurer, universe, Adventurer.Quest.GoShopping); } else if (npc.Name == "OLD MAN") { QuestTrigger(adventurer, universe, Adventurer.Quest.MeetTheOldMan); } else if (npc.Name == "Cerri") { if (adventurer.ItemsDictionary[Item.Items.Parcel] >= 1) { TextBoxViews.WriteToMessageBox(universe, "Oh? You found my parcel! Thank you!"); adventurer.ItemsDictionary[Item.Items.Parcel]--; TextBoxViews.WriteToMessageBox(universe, "Here is a few Health potions for your troubles."); adventurer.ItemsDictionary[Item.Items.HealthPotion] += 2; trig = false; QuestTrigger(adventurer, universe, Adventurer.Quest.DeliverTheParcel); } } else if (npc.Name == "Arista") { adventurer.Health = adventurer.MaxHealth; } } else if (adventurer.InHouseName == npc.InHouseName) { if (npc.Name == "Merchant") { TextBoxViews.MerchantMessage(universe, adventurer); trig = false; QuestTrigger(adventurer, universe, Adventurer.Quest.GoShopping); } else if (npc.Name == "OLD MAN") { QuestTrigger(adventurer, universe, Adventurer.Quest.MeetTheOldMan); } else if (npc.Name == "Cerri") { if (adventurer.ItemsDictionary[Item.Items.Parcel] >= 1) { TextBoxViews.WriteToMessageBox(universe, "Oh? You found my parcel! Thank you!"); adventurer.ItemsDictionary[Item.Items.Parcel]--; TextBoxViews.WriteToMessageBox(universe, "Here is a few Health potions for your troubles."); adventurer.ItemsDictionary[Item.Items.HealthPotion] += 2; trig = false; QuestTrigger(adventurer, universe, Adventurer.Quest.DeliverTheParcel); } } else if (npc.Name == "Arista") { adventurer.Health = adventurer.MaxHealth; } } if (npc.listCurrent >= npc.listMax) { npc.listCurrent = 0; } TextBoxViews.RemoveBox(universe, 7); TextBoxViews.RemoveContent(universe, 7); } } if (adventurer.MapLocation == Humanoid.Location.Cave) { foreach (var enemy in universe.TripleTrouble) { if (!enemy.Defeated && (enemy.Ypos == yPos) && (enemy.Xpos == xPos)) { TextBoxViews.WriteToMessageBox(universe, "I will Beat you!!!"); enemy.Defeated = true; Slime slime = new Slime(); Slime.InitializeNewSlime(slime, true); adventurer.diedOnFinal = !Battle.BattleLoop(adventurer, universe, slime); } } } if (trig) { TextBoxViews.WriteToMessageBox(universe, text); } }