// This is an earlier version of the method below. public void explore(Maze themaze3, MoveablePlayer themoveableplayer3) { 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(); } //switch (playerposition) { //case "[-]": // break; // break; } System.Threading.Thread.Sleep(20); } }
// 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); }
// The playermovements method handles all of the player's movements in explorable areas. public void playermovements(Maze themaze2, MoveablePlayer themoveableplayer2) { ConsoleKey TheKey; do { ConsoleKeyInfo thekey = ReadKey(true); TheKey = thekey.Key; } while (KeyAvailable); //ConsoleKeyInfo thekey = ReadKey(true); //ConsoleKey TheKey = thekey.Key; switch (TheKey) { case ConsoleKey.UpArrow: if (themaze2.ispositionwalkable(themoveableplayer2.x, themoveableplayer2.y - 1)) { themoveableplayer2.y -= 1; } break; case ConsoleKey.DownArrow: if (themaze2.ispositionwalkable(themoveableplayer2.x, themoveableplayer2.y + 1)) { themoveableplayer2.y += 1; } break; case ConsoleKey.LeftArrow: if (themaze2.ispositionwalkable(themoveableplayer2.x - 1, themoveableplayer2.y)) { themoveableplayer2.x -= 1; } break; case ConsoleKey.RightArrow: if (themaze2.ispositionwalkable(themoveableplayer2.x + 1, themoveableplayer2.y)) { themoveableplayer2.x += 1; } break; default: break; } }
// 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); }
// This method creates an explorable area tutorial private void tutorial() { NpcLines("Greetings! Before you begin the game, you'll have to complete this tutorial which is based on explorable areas.", false, false, true, "Explorable Area"); NpcLines("Important Information:\r\n\r\n- Doors/exits may look different in different exploreable areas but they will always be green.\r\n\r\n- Npc characters may look different in different explorable areas but they will always be blue.\r\n\r\n- Items may look different in different explorable areas but they will always be yellow.\r\n\r\n", false, false, true, "Explorable Area"); NpcLines("Important Information:\r\n\r\n- Use your arrow keys to navigate throughout explorable areas.\r\n\r\n- In order to interract with an item or door, walk onto the space that it resides on. This method works for npc characters as well.\r\n\r\n", false, false, true, "Explorable Area"); NpcLines("Lastly, you will be represented by this: ^ (in cyan)\r\n\r\n", false, false, true, "Explorable Area"); NpcLines("In order to complete this tutorial, you must utilize some of the basic functions that you have just learned to naviagte through an explorable area.", false, false, true, "Explorable Area"); string[,] tutorial = { { "*", "*", "*", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", "*", "*", "*" }, { "*", "*", "*", " ", " ", " ", "*", "*", " ", "*", "*", "*", " ", "*", "*", " ", " ", "*" }, { " ", " ", " ", " ", " ", " ", "*", "*", " ", "*", "*", "*", " ", " ", "*", " ", " ", "*" }, { "*", "*", "*", "*", "*", "*", "*", "*", " ", " ", "*", "*", " ", " ", " ", " ", " ", "*" }, { "*", "*", "*", "*", "*", "*", "*", "*", " ", " ", "*", "*", " ", "*", "*", "", " ", "[-]" }, { "*", "*", "*", "*", "*", "*", "*", "*", "*", "*", "*", "*", "*", "*", "*", "*", "*", "*" } }; newMaze = new Maze(tutorial); newmoveableplayer = new MoveablePlayer(0, 2); explore(newMaze, newmoveableplayer); }
// 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); } }
// createarea() is a method that draws exlorable areas and spawns characters in them. public void createarea(Maze themaze1, MoveablePlayer themoveableplayer1) { Clear(); themaze1.Create(); themoveableplayer1.Spawn(); }