// The adviceconvo method gives the player a chance to obtain useful advice. // It is called by the explore method when certain conditions are met. public void adviceconvo(Player theplayer3, AdventureGameItem theadvice) { NpcLines("Aaron", "Greetings."); PlayerLines("Hello", theplayer3); NpcLines("Aaron", "Would you like some advice?"); PlayerLines("Sure, why not. What oddly specific thing would you like in return for this advice?", theplayer3); NpcLines("Aaron", "The advice is free friend. All you must do is choose to accept it."); string adviceprompt = "What is your choice?"; string[] decisions = { "Accept the advice", "Deny the advice" }; Menu advicemenu = new Menu(decisions, adviceprompt); int advicedecision = advicemenu.Run(); if (advicedecision == 0) { Clear(); theplayer3.fourthitem = false; theplayer3.hasadvice = true; theplayer3.ReceiveItem(theadvice); NpcLines("Aaron", "Cool. Here's the advice: the lemonade in this kingdom is not very good."); NpcLines("*Advice has been added into your inventory.*", false, true); PlayerLines("Thank you. That is very useful information.", theplayer3); NpcLines("Aaron", "Yup. No problem. Bye bye now. Have a nice day."); PlayerLines("Thank you", theplayer3); Kingdom secondkingdom = new Kingdom("A Kingdom", 1, theplayer3); } else if (advicedecision == 1) { Clear(); theplayer3.fourthitem = false; NpcLines("Aaron", "Ok bye."); Kingdom secondkingdom = new Kingdom("A Kingdom", 1, theplayer3); } }
// This constructor instantiates three items and passes //them to the explore method which places them within a corresponding explorable area. public Kingdom(string name, int expn, Player ThePlayer) : base(name, expn) { AdventureGameItem aherossword = new AdventureGameItem("A hero's sword", "Legendary"); AdventureGameItem advice = new AdventureGameItem("Advice", "Legendary"); theplayer = ThePlayer; string[,] kingdomarea = Maze.areacreator("Kingdomarea.txt"); newmaze = new Maze(kingdomarea); newmoveableplayer = new MoveablePlayer(31, 2); newgame = new Game(false); newgame.explore(newmaze, newmoveableplayer, theplayer, aherossword, advice, advice); }
// private bool isnotsecondtime; // This constructor instantiates three items and passes //them to the explore method which places them within a corresponding explorable area. public Cave(string name, int ExpareaNumber, Player ThePlayer) : base(name, ExpareaNumber) { AdventureGameItem firstitem = new AdventureGameItem("A silver coin", "common"); AdventureGameItem watch = new AdventureGameItem("An old watch", "common"); AdventureGameItem Aherosshield = new AdventureGameItem("A hero's shield", "Legendary"); item1 = firstitem; theplayer = ThePlayer; string[,] cavearea = Maze.areacreator("TheCave.txt"); newmaze = new Maze(cavearea); newmoveableplayer = new MoveablePlayer(2, 15); newgame = new Game(false); newgame.explore(newmaze, newmoveableplayer, theplayer, item1, watch, Aherosshield); //ExploreTheCave(theplayer); }
// The caveconversation method is called by the explore method when certain conditions are met. // Once initiated, the caveconversation method gives the player a chance to gain a shield (a hero's shield). // The hero's shield is one of the items that is required to win the game. private void caveconversation(Player theplayercaveconvo, AdventureGameItem theshield) { NpcLines("Marcus", "Hi."); PlayerLines("Hello", theplayercaveconvo); NpcLines("Marcus", "Would you like a shield?"); PlayerLines("Why would I need a shield?", theplayercaveconvo); NpcLines("Marcus", "You never know man, life is crazy."); PlayerLines("That is true.", theplayercaveconvo); string prompt = "Do you want the shield?"; string[] choices = { "Yes", "No" }; Menu caveconvo = new Menu(choices, prompt); int selection = caveconvo.Run(); if (selection == 0) { Clear(); NpcLines("Marcus", "Cool. All you have to do is fill in the blank of the following sentence."); string prompt1 = "The ______ strike, though seemingly meaningless, will always be the key to victory."; string[] answers = { "first", "third", "last" }; Menu convoquestion = new Menu(answers, prompt1); int answer = convoquestion.Run(); if (answer == 0) { NpcLines("Marcus", "I'm sorry that's the wrong answer."); PlayerLines("Aw man.", theplayercaveconvo); NpcLines("Marcus", "If you still want the shield, you can have it. I just can't give it to you for free."); PlayerLines("Could I maybe try to answer some other question for it?", theplayercaveconvo); NpcLines("Marcus", "No."); PlayerLines("Why not?", theplayercaveconvo); NpcLines("Marcus", "Those are the rules."); PlayerLines("Ok I guess. Well...I don't have a lot of money. What's your price?", theplayercaveconvo); NpcLines("Marcus", "Do you happen to have a rare coin?"); PlayerLines("Well, yeah but my friend Talthorius gave it to me.", theplayercaveconvo); NpcLines("Marcus", "I'll accept that as a payment."); PlayerLines("That's an oddly specific request. What if I need it later?", theplayercaveconvo); NpcLines("Marcus", "That sounds like a you problem.Lol."); PlayerLines("Did you just say lol? Wait a minute! Is that you Talthorius?!", theplayercaveconvo); NpcLines("Marcus", "Nope, I'm definitely not Talthorius pretending to be someone else right now. My name is Marcus.\r\n\r\nDo you want the shield or not?\r\n"); string prompt2 = "What is your decision?"; string[] finalchoices = { "Lose your rare coin", "Lose your chance at obtaining the shield" }; Menu thedecision = new Menu(finalchoices, prompt2); int finalselection = thedecision.Run(); if (finalselection == 0) { theplayercaveconvo.RemoveItem(1); theplayercaveconvo.ReceiveItem(theshield); theplayercaveconvo.hasitem1 = true; theplayercaveconvo.thirditem = false; theplayercaveconvo.hasrarecoin = false; NpcLines("Marcus", "Sweet. Thanks. Here you go. Bye bye now.\r\n\r\n*A hero's shield has been added into your inventory.*\r\n\r\nA rare coin has been removed from your inventory.*\r\n"); Cave secondcave = new Cave("A Cave", 1, theplayercaveconvo); } else if (finalselection == 1) { NpcLines("Marcus", "Ok bye."); theplayercaveconvo.thirditem = false; Cave secondcave = new Cave("A Cave", 1, theplayercaveconvo); } } else if (answer == 1) { theplayercaveconvo.ReceiveItem(theshield); theplayercaveconvo.thirditem = false; theplayercaveconvo.hasitem1 = true; NpcLines("Marcus", "Nice. That's the right answer. Here you go. Bye bye now.\r\n\r\n*A hero's shield has been added into your inventory.*\r\n"); Cave secondcave = new Cave("A Cave", 1, theplayercaveconvo); } else if (answer == 2) { NpcLines("Marcus", "I'm sorry that's the wrong answer."); PlayerLines("Aw man.", theplayercaveconvo); NpcLines("Marcus", "If you still want the shield, you can have it. I just can't give it to you for free."); PlayerLines("Could I maybe try to answer some other question for it?", theplayercaveconvo); NpcLines("Marcus", "No."); PlayerLines("Why not?", theplayercaveconvo); NpcLines("Marcus", "Those are the rules."); PlayerLines("Ok I guess. Well...I don't have a lot of money. What's your price?", theplayercaveconvo); NpcLines("Marcus", "Do you happen to have a rare coin?"); PlayerLines("Well, yeah but my friend Talthorius gave it to me.", theplayercaveconvo); NpcLines("Marcus", "I'll accept that as a payment."); PlayerLines("That's an oddly specific request. What if I need it later?", theplayercaveconvo); NpcLines("Marcus", "That sounds like a you problem.Lol."); PlayerLines("Did you just say lol? Wait a minute! Is that you Talthorius?!", theplayercaveconvo); NpcLines("Marcus", "Nope, I'm definitely not Talthorius pretending to be someone else right now. My name is Marcus.\r\n\r\nDo you want the shield or not?\r\n"); string prompt2 = "What is your decision?"; string[] finalchoices = { "Lose your rare coin", "Lose your chance at obtaining the shield" }; Menu thedecision = new Menu(finalchoices, prompt2); int finalselection1 = thedecision.Run(); if (finalselection1 == 0) { theplayercaveconvo.RemoveItem(1); theplayercaveconvo.ReceiveItem(theshield); theplayercaveconvo.hasitem1 = true; theplayercaveconvo.thirditem = false; theplayercaveconvo.hasrarecoin = false; NpcLines("Marcus", "Sweet. Thanks. Here you go. Bye bye now.\r\n\r\n*A hero's shield has been added into your inventory.*\r\n\r\nA rare coin has been removed from your inventory.*\r\n"); Cave secondcave = new Cave("A Cave", 1, theplayercaveconvo); } else if (finalselection1 == 1) { NpcLines("Marcus", "Ok bye."); theplayercaveconvo.thirditem = false; Cave secondcave = new Cave("A Cave", 1, theplayercaveconvo); } } } else if (selection == 1) { Clear(); NpcLines("Marcus", "Ok bye"); Cave secondcave = new Cave("A Cave", 1, theplayercaveconvo); } }
// Th explore method serves as the operating mechanism behind the all of the game's explorable areas. // It calls all of the necessary methods and triggers all of the reactions that happen as a result of the player's actions. public void explore(Maze themaze3, MoveablePlayer themoveableplayer3, Player exploreplayer, AdventureGameItem item1, AdventureGameItem item2, AdventureGameItem item3) { while (true) { createarea(themaze3, themoveableplayer3); playermovements(themaze3, themoveableplayer3); string playerposition = themaze3.gatherposition(themoveableplayer3.x, themoveableplayer3.y); if (playerposition == "[-]") { Clear(); break; } else if (playerposition == "~") { Clear(); // WriteLine("Test"); //ReadKey(); if (exploreplayer.firstitem) { exploreplayer.ReceiveItem(item2); NpcLines($"*{item2.name} has been added into your inventory. Level: {item2.modifier}*", false, true); exploreplayer.firstitem = false; } else { NpcLines("*This item has already been added into your inventory.*", false, true); } Cave secondcave = new Cave("A Cave", 1, exploreplayer); } else if (playerposition == "$") { Clear(); if (exploreplayer.seconditem) { exploreplayer.ReceiveItem(item1); NpcLines($"*{item1.name} has been added into your inventory. Level: {item1.modifier}*", false, true); exploreplayer.seconditem = false; } else { NpcLines("*This item has already been added into your inventory.*", false, true); } Cave secondcave = new Cave("A Cave", 1, exploreplayer); } else if (playerposition == "o") { Clear(); if (exploreplayer.thirditem) { caveconversation(exploreplayer, item3); } else { NpcLines("You have already completed this conversation.", false, true); Cave secondcave = new Cave("A Cave", 1, exploreplayer); } } else if (playerposition == "=") { Clear(); SecondMenu(exploreplayer); } else if (playerposition == "{") { Clear(); if (exploreplayer.hasitem2 == false) { exploreplayer.ReceiveItem(item1); exploreplayer.hasitem2 = true; NpcLines($"*{item1.name} has been added into your inventory. Level: {item1.modifier}*", false, true); } else { NpcLines("*This item has already been added into your inventory.*", false, true); } Kingdom secondKingdom = new Kingdom("A Kingdom", 1, exploreplayer); } else if (playerposition == "O") { Clear(); if (exploreplayer.fourthitem) { adviceconvo(exploreplayer, item2); } else { NpcLines("You have already completed this conversation.", false, true); Kingdom secondKingdom = new Kingdom("A Kingdom", 1, exploreplayer); } } else if (playerposition == "0") { Clear(); if (exploreplayer.hasitem1 == true && exploreplayer.hasitem2 == true && exploreplayer.hasadvice == true) { if (exploreplayer.hasrarecoin) { exploreplayer.gameover = true; NpcLines("Greetings once again traveler.", true); PlayerLines("Talthorius?? What are you doing here?", exploreplayer); NpcLines("You have passed the test traveler! You succeeded in not losing sight of what was given to you!", true); PlayerLines("Are you talking about that coin that you gave me?", exploreplayer); NpcLines("Yup. In order to celebrate your accomplishment, we've decided to share something with you.", true); PlayerLines("Who is we?", exploreplayer); NpcLines("Worry not traveler. All will be revealed soon.", true); PlayerLines("Ok.", exploreplayer); NpcLines("Now, for the news that we have for you..Actually, you know what. Would you like some lemonade first?", true); string drinkchoice = "What is your decision?"; string[] lastdecision = { "No", "Yes" }; Menu thirdmenu = new Menu(lastdecision, drinkchoice); int drinkselection = thirdmenu.Run(); if (drinkselection == 0) { NpcLines("Excellent! You have passed the final test!", true); PlayerLines("Sweet.", exploreplayer); if (exploreplayer.hascompass) { NpcLines("At the beginning of the game, you chose the compass.", true); NpcLines("That compass was given to you by your mother. She enchanted it with love and magical energy. If you follow it you will never be lost.", true); PlayerLines("You're right! I remember now!....Wait why can't I remember anything about the other items?", exploreplayer); NpcLines("As I have said, all will be revealed in due time traveler. There is always more to learn.", true); PlayerLines("Ok I think I finally understand. What am I supposed to do now?", exploreplayer); NpcLines("You must do the only thing that there is to do traveler: move forward... Specifically, towards the door that's behind me.", true); PlayerLines("What's behind the door?", exploreplayer); NpcLines("I don't know traveler, I guess you'll just have to find out.", true); PlayerLines("Ok I think I'm ready.", exploreplayer); NpcLines("I think you're ready too traveler. Goodbye for now.", true); exploreplayer.hasitem2 = false; Kingdom secondKingdom = new Kingdom("A Kingdom", 1, exploreplayer); } else if (exploreplayer.hashelmet) { NpcLines("At the beginning of the game, you chose the helmet.", true); NpcLines("That helmet was previosuly owned by a very good friend of yours. He crafted it with the finest metals known to man. It will completely protect you from any kind of enemy. ", true); PlayerLines("You're right! I remember now!....Wait why can't I remember anything about the other items?", exploreplayer); NpcLines("As I have said, all will be revealed in due time traveler. There is always more to learn.", true); PlayerLines("Ok I think I finally understand. What am I supposed to do now?", exploreplayer); NpcLines("You must do the only thing that there is to do traveler: move forward... Specifically, towards the door that's behind me.", true); PlayerLines("What's behind the door?", exploreplayer); NpcLines("I don't know traveler, I guess you'll just have to find out.", true); PlayerLines("Ok I think I'm ready.", exploreplayer); NpcLines("I think you're ready too traveler. Goodbye for now.", true); exploreplayer.hasitem2 = false; Kingdom secondKingdom = new Kingdom("A Kingdom", 1, exploreplayer); } else if (exploreplayer.hasshield) { NpcLines("At the beginning of the game, you chose the shield.", true); NpcLines("That shield was given to you by your. The front of it bares the symbol of the resistance. Upon being raised to the sky, it will send a signal to every resistance member, alive or dead.", true); PlayerLines("You're right! I remember now!....Wait why can't I remember anything about the other items? ", exploreplayer); NpcLines("As I have said, all will be revealed in due time traveler. There is always more to learn.", true); PlayerLines("Ok I think I finally understand. What am I supposed to do now?", exploreplayer); NpcLines("You must do the only thing that there is to do traveler: move forward... Specifically, towards the door that's behind me.", true); PlayerLines("What's behind the door?", exploreplayer); NpcLines("I don't know traveler, I guess you'll just have to find out.", true); PlayerLines("Ok I think I'm ready.", exploreplayer); NpcLines("I think you're ready too traveler. Goodbye for now.", true); exploreplayer.hasitem2 = false; Kingdom secondKingdom = new Kingdom("A Kingdom", 1, exploreplayer); } } else if (drinkselection == 1) { NpcLines("Unfortunately, you have failed the final test. Goodbye.", false, true); Environment.Exit(0); } } else { NpcLines("Greetings once again traveler.", true); PlayerLines("Talthorius?? What are you doing here?", exploreplayer); NpcLines("Why'd you have to do it traveler? Why?", true); PlayerLines("What are you talking about?", exploreplayer); NpcLines("You lost sight of what was given to you.", true); PlayerLines("Wait are you talking about that coin?", exploreplayer); NpcLines("I tried to talk them out of it but the rules are the rules.", true); PlayerLines("What are you talking about?", exploreplayer); NpcLines("Until next time traveler...", true); PlayerLines("Noooooooooo", exploreplayer); Environment.Exit(0); } } else { NpcLines("You don't have all of the items that you need in order to interract with this npc.", false, true); NpcLines("If you have not already visited the Cave. You need to restart the game and try again.", false, true); NpcLines("On the other hand, you may have finished the game. Try to exit through the green door in this level and see if the game allows you to leave.", false, true); Kingdom secondKingdom = new Kingdom("A Kingdom", 1, exploreplayer); } } else if (playerposition == "%") { if (exploreplayer.gameover) { Clear(); string theend = "Congratulations! You have completed the game!"; string[] lastchoices = { "Credits", "End the game" }; Menu lastmenu = new Menu(lastchoices, theend); int lastchoice = lastmenu.Run(); if (lastchoice == 0) { Clear(); WriteLine("Credits:\r\n"); WriteLine(@"The Compass: https://ascii.co.uk/art/compass"); WriteLine(@"The Helmet: https://ascii.co.uk/art/helmet"); WriteLine(@"The Shield: https://www.asciiart.eu/weapons/shields"); ReadKey(); Environment.Exit(0); } else if (lastchoice == 1) { Clear(); WriteLine("Goodbye."); Environment.Exit(0); } } else { NpcLines("You have not met all of the requirements that are needed in order to end the game.", false, true); NpcLines("If you have not already visited the Cave. You need to restart the game and try again.", false, true); Kingdom secondKingdom = new Kingdom("A Kingdom", 1, exploreplayer); } } //switch (playerposition) // /{ //case "[-]": // break; // break; // } System.Threading.Thread.Sleep(20); } }