/// <summary> /// get a action menu choice from the user /// </summary> /// <returns>action menu choice</returns> public TravelerAction GetActionMenuChoice(Menu menu) { TravelerAction choosenAction = TravelerAction.None; Console.CursorVisible = false; // // create an array of valid keys from menu dictionary // char[] validKeys = menu.MenuChoices.Keys.ToArray(); // // validate key pressed as in MenuChoices dictionary // char keyPressed; do { ConsoleKeyInfo keyPressedInfo = Console.ReadKey(true); keyPressed = keyPressedInfo.KeyChar; } while (!validKeys.Contains(keyPressed)); choosenAction = menu.MenuChoices[keyPressed]; Console.CursorVisible = true; return(choosenAction); }
/// <summary> /// display the correct menu/sub-menu and get the next traveler action /// </summary> /// <returns>traveler action</returns> private TravelerAction GetNextTravelerAction() { TravelerAction travelerActionChoice = TravelerAction.None; switch (ActionMenu.currentMenu) { case ActionMenu.CurrentMenu.MainMenu: travelerActionChoice = _gameConsoleView.GetActionMenuChoice(ActionMenu.MainMenu); break; case ActionMenu.CurrentMenu.ObjectMenu: travelerActionChoice = _gameConsoleView.GetActionMenuChoice(ActionMenu.ObjectMenu); break; case ActionMenu.CurrentMenu.NpcMenu: travelerActionChoice = _gameConsoleView.GetActionMenuChoice(ActionMenu.NpcMenu); break; case ActionMenu.CurrentMenu.TravelerMenu: travelerActionChoice = _gameConsoleView.GetActionMenuChoice(ActionMenu.TravelerMenu); break; case ActionMenu.CurrentMenu.AdminMenu: travelerActionChoice = _gameConsoleView.GetActionMenuChoice(ActionMenu.AdminMenu); break; default: break; } return(travelerActionChoice); }
/// <summary> /// get a action menu choice from the user /// </summary> /// <returns>action menu choice</returns> public TravelerAction GetActionMenuChoice(Menu menu) { TravelerAction choosenAction = TravelerAction.None; // // TODO validate menu choices // ConsoleKeyInfo keyPressedInfo = Console.ReadKey(); char keyPressed = keyPressedInfo.KeyChar; choosenAction = menu.MenuChoices[keyPressed]; return(choosenAction); }
/// <summary> /// get a action menu choice from the user /// </summary> /// <returns>action menu choice</returns> public TravelerAction GetActionMenuChoice(Menu menu) { TravelerAction choosenAction = TravelerAction.None; char[] validKeys = menu.MenuChoices.Keys.ToArray(); char KeyPressed; do { ConsoleKeyInfo keyPressedInfo = Console.ReadKey(true); KeyPressed = keyPressedInfo.KeyChar; } while (!validKeys.Contains(KeyPressed)); choosenAction = menu.MenuChoices[KeyPressed]; return(choosenAction); }
/// <summary> /// get a action menu choice from the user /// </summary> /// <returns>action menu choice</returns> public TravelerAction GetActionMenuChoice(Menu menu, ConsoleKeyInfo keyPressedInfo, string gameMapString) { TravelerAction chosenAction = TravelerAction.None; // // create an array of valid keys from menu dictionary // char[] validKeys = menu.MenuChoices.Keys.ToArray(); // // validate key pressed as in MenuChoices dictionary // char keyPressed; keyPressed = keyPressedInfo.KeyChar; do { if (!validKeys.Contains(keyPressed)) { DisplayMessage("That's not a valid key! Try again or press a movement key to return to the map."); keyPressedInfo = Console.ReadKey(true); keyPressed = keyPressedInfo.KeyChar; } if ((keyPressedInfo.Key == ConsoleKey.UpArrow) || (keyPressedInfo.Key == ConsoleKey.DownArrow) || (keyPressedInfo.Key == ConsoleKey.LeftArrow) || (keyPressedInfo.Key == ConsoleKey.RightArrow)) { DisplayRedrawMap("Current Location", gameMapString, ActionMenu.MapMenu, ""); chosenAction = TravelerAction.None; return(chosenAction); } } while (!validKeys.Contains(keyPressed)); chosenAction = menu.MenuChoices[keyPressed]; return(chosenAction); }
/// <summary> /// method to manage the application setup and game loop /// </summary> private void ManageGameLoop() { TravelerAction travelerActionChoice = TravelerAction.None; // // display splash screen // _playingGame = _gameConsoleView.DisplaySpashScreen(); // // player chooses to quit // if (!_playingGame) { Environment.Exit(1); } // // display introductory message // _gameConsoleView.DisplayGamePlayScreen("Quest Intro", Text.MissionIntro(), ActionMenu.MissionIntro, ""); _gameConsoleView.GetContinueKey(); // // initialize the mission traveler // InitializeMission(); // // prepare game play screen // _currentLocation = _gameUniverse.GetSpaceTimeLocationById(_gameTraveler.SpaceTimeLocationId); _gameConsoleView.DisplayGamePlayScreen("Current Location", Text.CurrentLocationInfo(_currentLocation), ActionMenu.MainMenu, ""); // // game loop // while (_playingGame) { // // process all flags, events, and stats // UpdateGameStatus(); // // get next game action from player // travelerActionChoice = GetNextTravelerAction(); // // choose an action based on the player's menu choice // switch (travelerActionChoice) { case TravelerAction.None: break; case TravelerAction.TravelerInfo: _gameConsoleView.DisplayTravelerInfo(); break; case TravelerAction.LookAround: _gameConsoleView.DisplayLookAround(); break; case TravelerAction.Travel: TravelAction(); break; case TravelerAction.TravelerLocationsVisited: _gameConsoleView.DisplayLocationsVisited(); break; case TravelerAction.LookAt: LookAtAction(); break; case TravelerAction.PickUp: PickUpAction(); break; case TravelerAction.PutDown: PutDownAction(); break; case TravelerAction.Inventory: _gameConsoleView.DisplayInventory(); break; case TravelerAction.TalkTo: TalkToAction(); break; case TravelerAction.ListSpaceTimeLocations: _gameConsoleView.DisplayListOfSpaceTimeLocations(); break; case TravelerAction.ListGameObjects: _gameConsoleView.DisplayListOfAllGameObjects(); break; case TravelerAction.ListNonplayerCharacters: _gameConsoleView.DisplayListOfAllNpcObjects(); break; case TravelerAction.TravelerMenu: ActionMenu.currentMenu = ActionMenu.CurrentMenu.TravelerMenu; _gameConsoleView.DisplayGamePlayScreen("Traveler Menu", "Select an operation from the menu.", ActionMenu.TravelerMenu, ""); break; case TravelerAction.ObjectMenu: ActionMenu.currentMenu = ActionMenu.CurrentMenu.ObjectMenu; _gameConsoleView.DisplayGamePlayScreen("Object Menu", "Select an operation from the menu.", ActionMenu.ObjectMenu, ""); break; case TravelerAction.NonplayerCharacterMenu: ActionMenu.currentMenu = ActionMenu.CurrentMenu.NpcMenu; _gameConsoleView.DisplayGamePlayScreen("NPC Menu", "Select an operation from the menu.", ActionMenu.NpcMenu, ""); break; case TravelerAction.AdminMenu: ActionMenu.currentMenu = ActionMenu.CurrentMenu.AdminMenu; _gameConsoleView.DisplayGamePlayScreen("Admin Menu", "Select an operation from the menu.", ActionMenu.AdminMenu, ""); break; case TravelerAction.ReturnToMainMenu: ActionMenu.currentMenu = ActionMenu.CurrentMenu.MainMenu; _gameConsoleView.DisplayGamePlayScreen("Current Location", Text.CurrentLocationInfo(_currentLocation), ActionMenu.MainMenu, ""); break; case TravelerAction.Exit: _playingGame = false; break; default: break; } } // // close the application // Environment.Exit(1); }
/// <summary> /// method to manage the application setup and game loop /// </summary> private void ManageGameLoop() { TravelerAction travelerActionChoice = TravelerAction.None; // // display splash screen // _playingGame = _gameConsoleView.DisplaySpashScreen(); // // player chooses to quit // if (!_playingGame) { Environment.Exit(1); } // // display introductory message // _gameConsoleView.DisplayGamePlayScreen("Mission Intro", Text.MissionIntro(), ActionMenu.MissionIntro, ""); _gameConsoleView.GetContinueKey(); // // initialize the mission traveler // InitializeMission(); // // prepare game play screen // _gameConsoleView.DisplayGamePlayScreen("Current Location", Text.CurrrentLocationInfo(), ActionMenu.MainMenu, ""); // // game loop // while (_playingGame) { // // get next game action from player // travelerActionChoice = _gameConsoleView.GetActionMenuChoice(ActionMenu.MainMenu); // // choose an action based on the player's menu choice // switch (travelerActionChoice) { case TravelerAction.None: break; case TravelerAction.TravelerInfo: _gameConsoleView.DisplayTravelerInfo(); break; case TravelerAction.Exit: _playingGame = false; break; default: break; } } // // close the application // Environment.Exit(1); }
/// <summary> /// get the action choice from the user /// </summary> public TravelerAction DisplayGetTravelerActionChoice() { TravelerAction travelerActionChoice = TravelerAction.None; bool usingMenu = true; while (usingMenu) { // // set up display area // ConsoleUtil.HeaderText = "Time Traveler Actions"; ConsoleUtil.DisplayReset(); Console.CursorVisible = false; // // display the menu // ConsoleUtil.DisplayMessage("What would you like to do (Type Letter)?"); Console.WriteLine(); Console.WriteLine( "\t" + "**************************" + Environment.NewLine + "\t" + "Time Traveler Actions" + Environment.NewLine + "\t" + "**************************" + Environment.NewLine + "\t" + "A. Look Around" + Environment.NewLine + "\t" + "B. Look At" + Environment.NewLine + "\t" + "C. Pick Up Item" + Environment.NewLine + "\t" + "D. Pick Up Treasure" + Environment.NewLine + "\t" + "E. Put Down Item" + Environment.NewLine + "\t" + "F. Put Down Treasure" + Environment.NewLine + "\t" + "G. Travel" + Environment.NewLine + "\t" + Environment.NewLine + "\t" + "**************************" + Environment.NewLine + "\t" + "Time Traveler Information" + Environment.NewLine + "\t" + "**************************" + Environment.NewLine + "\t" + "H. Display General Time Traveler Information" + Environment.NewLine + "\t" + "I. Display Time Traveler Inventory" + Environment.NewLine + "\t" + "J. Display Time Traveler Treasure" + Environment.NewLine + "\t" + Environment.NewLine + "\t" + "**************************" + Environment.NewLine + "\t" + "Game Information" + Environment.NewLine + "\t" + "**************************" + Environment.NewLine + "\t" + "K. Display All Year Destinations" + Environment.NewLine + "\t" + "L. Display All Game Items" + Environment.NewLine + "\t" + "M. Display All Game Treasures" + Environment.NewLine + "\t" + Environment.NewLine + "\t" + "**************************" + Environment.NewLine + "\t" + "Q. Quit" + Environment.NewLine); // // get and process the user's response // note: ReadKey argument set to "true" disables the echoing of the key press // ConsoleKeyInfo userResponse = Console.ReadKey(true); switch (userResponse.KeyChar) { case 'A': case 'a': travelerActionChoice = TravelerAction.LookAround; usingMenu = false; break; case 'B': case 'b': travelerActionChoice = TravelerAction.LookAt; usingMenu = false; break; case 'C': case 'c': travelerActionChoice = TravelerAction.PickUpItem; usingMenu = false; break; case 'D': case 'd': travelerActionChoice = TravelerAction.PickUpTreasure; usingMenu = false; break; case 'E': case 'e': travelerActionChoice = TravelerAction.PutDownItem; usingMenu = false; break; case 'F': case 'f': travelerActionChoice = TravelerAction.PutDownTreasure; usingMenu = false; break; case 'G': case 'g': travelerActionChoice = TravelerAction.Travel; usingMenu = false; break; case 'H': case 'h': travelerActionChoice = TravelerAction.TravelerInfo; usingMenu = false; break; case 'I': case 'i': travelerActionChoice = TravelerAction.TravelerInventory; usingMenu = false; break; case 'J': case 'j': travelerActionChoice = TravelerAction.TravelerTreasure; usingMenu = false; break; case 'K': case 'k': travelerActionChoice = TravelerAction.ListYearDestinations; usingMenu = false; break; case 'L': case 'l': travelerActionChoice = TravelerAction.ListItems; usingMenu = false; break; case 'M': case 'm': travelerActionChoice = TravelerAction.ListTreasures; usingMenu = false; break; case 'Q': case 'q': travelerActionChoice = TravelerAction.Exit; usingMenu = false; break; default: Console.WriteLine( "It appears you have selected an incorrect choice." + Environment.NewLine + "Press any key to continue or the ESC key to quit the application."); userResponse = Console.ReadKey(true); if (userResponse.Key == ConsoleKey.Escape) { usingMenu = false; } break; } } Console.CursorVisible = true; return(travelerActionChoice); }
/// <summary> /// method to manage the application setup and game loop /// </summary> private void ManageGameLoop() { TravelerAction travelerActionChoice = TravelerAction.None; // // display splash screen // _playingGame = _gameConsoleView.DisplaySpashScreen(); // // player chooses to quit // if (!_playingGame) { Environment.Exit(1); } // // display introductory message // _gameConsoleView.DisplayGamePlayScreen("Mission Intro", Text.MissionIntro(), ActionMenu.MissionIntro, ""); _gameConsoleView.GetContinueKey(); // // initialize the mission traveler // InitializeMission(); // // prepare game play screen // _currentLocation = _gameUniverse.GetSpaceTimeLocationById(_gameTraveler.SpaceTimeLocationID); _gameConsoleView.DisplayGamePlayScreen("Current Location", Text.CurrrentLocationInfo(), ActionMenu.MainMenu, ""); // // game loop // while (_playingGame) { // // process all flags, events, and stats // UpdateGameStatus(); // // get next game action from player // travelerActionChoice = _gameConsoleView.GetActionMenuChoice(ActionMenu.MainMenu); // // choose an action based on the player's menu choice // switch (travelerActionChoice) { case TravelerAction.None: break; case TravelerAction.TravelerInfo: _gameConsoleView.DisplayTravelerInfo(); break; case TravelerAction.ListSpaceTimeLocations: _gameConsoleView.DisplayListOfSpaceTimeLocations(); break; case TravelerAction.LookAround: _gameConsoleView.DisplayLookAround(); break; case TravelerAction.Travel: int requestedSpaceTimeLocationID; SpaceTimeLocation requestedLocation; do { requestedSpaceTimeLocationID = _gameConsoleView.DisplayGetNextSpaceTimeLocation(); requestedLocation = _gameUniverse.GetSpaceTimeLocationById(requestedSpaceTimeLocationID); } while (_gameTraveler.ExperiencePoints < requestedLocation.ReqExperiencePoints); _gameTraveler.SpaceTimeLocationID = requestedSpaceTimeLocationID; _currentLocation = requestedLocation; _gameConsoleView.DisplayGamePlayScreen("Current Location", Text.CurrentLocationInfo(_currentLocation), ActionMenu.MainMenu, ""); break; case TravelerAction.TravelerLocationsVisited: _gameConsoleView.DisplayLocationsVisited(); break; case TravelerAction.Exit: _playingGame = false; break; default: break; } } // // close the application // Environment.Exit(1); }
/// <summary> /// get the action choice from the user /// </summary> public TravelerAction DisplayGetTravelerActionChoice() { TravelerAction travelerActionChoice = TravelerAction.None; bool usingMenu = true; while (usingMenu) { // // set up display area // ConsoleUtil.HeaderText = " Time Traveler Actions"; ConsoleUtil.DisplayReset(); Console.CursorVisible = false; // // display the menu // ConsoleUtil.DisplayMessage("Choose what you would like to do by choosing a number from the menu."); Console.WriteLine(); Console.WriteLine( "\t" + "1. Look Around" + Environment.NewLine + "\t" + "2. Travel" + Environment.NewLine + "\t" + "3. Display All Years" + Environment.NewLine + "\t" + "4. Display Traveler Info" + Environment.NewLine + "\t" + "E. Exit" + Environment.NewLine); // // get and process the user's response // note: ReadKey argument set to "true" disables the echoing of the key press // ConsoleKeyInfo userResponse = Console.ReadKey(true); switch (userResponse.KeyChar) { case '1': travelerActionChoice = TravelerAction.LookAround; usingMenu = false; break; case '2': travelerActionChoice = TravelerAction.Travel; usingMenu = false; break; case '3': travelerActionChoice = TravelerAction.ListYearDestinations; usingMenu = false; break; case '4': travelerActionChoice = TravelerAction.TravlerInfo; usingMenu = false; break; case 'E': case 'e': travelerActionChoice = TravelerAction.Exit; usingMenu = false; break; default: Console.WriteLine( "It appears you have selected an incorrect choice." + Environment.NewLine + "Press any key to continue or the ESC key to quit the application."); userResponse = Console.ReadKey(true); if (userResponse.Key == ConsoleKey.Escape) { usingMenu = false; } break; } } Console.CursorVisible = true; return(travelerActionChoice); }
/// <summary> /// method to manage the application setup and game loop /// </summary> private void ManageGameLoop() { TravelerAction travelerActionChoice = TravelerAction.None; // // display splash screen // _playingGame = _gameConsoleView.DisplaySpashScreen(); // // player chooses to quit // if (!_playingGame) { Environment.Exit(1); } // // display introductory message // _gameConsoleView.DisplayGamePlayScreen("Mission Intro", Text.MissionIntro(), ActionMenu.MissionIntro, ""); _gameConsoleView.GetContinueKey(); // // initialize the mission traveler // InitializeMission(); // // prepare game play screen // _gameConsoleView.DisplayGamePlayScreen("Current Location", Text.CurrrentLocationInfo(), ActionMenu.MainMenu, ""); _currentLocation = _gameShip.GetLocationByID(_gameTraveler.LocationID); // // game loop // while (_playingGame) { // //process flags, events, stats // UpdateGameStatus(); // //get action choice // travelerActionChoice = _gameConsoleView.GetActionMenuChoice(ActionMenu.MainMenu); // // get next game action from player // if (ActionMenu.currentMenu == ActionMenu.CurrentMenu.MainMenu) { travelerActionChoice = _gameConsoleView.GetActionMenuChoice(ActionMenu.MainMenu); } else if (ActionMenu.currentMenu == ActionMenu.CurrentMenu.AdminMenu) { travelerActionChoice = _gameConsoleView.GetActionMenuChoice(ActionMenu.AdminMenu); } // // choose an action based on the user's menu choice // switch (travelerActionChoice) { case TravelerAction.None: break; case TravelerAction.TravelerInfo: _gameConsoleView.DisplayTravelerInfo(); break; case TravelerAction.ListLocations: _gameConsoleView.DisplayListOfLocations(); break; case TravelerAction.Travel: // // new location choice and update current location // _gameTraveler.LocationID = _gameConsoleView.DisplayGetNextLocation(); _currentLocation = _gameShip.GetLocationByID(_gameTraveler.LocationID); // // set screen to current location format // _gameConsoleView.DisplayGamePlayScreen("Current Location", Text.CurrentLocationInfo(_currentLocation), ActionMenu.MainMenu, ""); break; case TravelerAction.TravelerLocationsVisited: _gameConsoleView.DisplayLocationsVisited(); break; case TravelerAction.LookAt: LookAtAction(); break; case TravelerAction.LookAround: _gameConsoleView.DisplayLookAround(); break; case TravelerAction.ListGameObjects: _gameConsoleView.DisplayListOfAllGameObjects(); break; case TravelerAction.Inventory: _gameConsoleView.DisplayInventory(); break; case TravelerAction.PickUp: PickUpAction(); break; case TravelerAction.PutDown: PutDownAction(); break; case TravelerAction.AdminMenu: ActionMenu.currentMenu = ActionMenu.CurrentMenu.AdminMenu; _gameConsoleView.DisplayGamePlayScreen("Admin Menu", "Select an Opertation from the menu.", ActionMenu.AdminMenu, ""); break; case TravelerAction.ReturnToMainMenu: ActionMenu.currentMenu = ActionMenu.CurrentMenu.MainMenu; _gameConsoleView.DisplayGamePlayScreen("Current Location", Text.CurrentLocationInfo(_currentLocation), ActionMenu.MainMenu, ""); break; case TravelerAction.Exit: _playingGame = false; break; default: break; } } // // close the application // Environment.Exit(1); }
/// <summary> /// method to manage the application setup and game loop /// </summary> private void ManageGameLoop() { TravelerAction travelerActionChoice = TravelerAction.None; // // display splash screen // _playingGame = _gameConsoleView.DisplaySpashScreen(); // // player chooses to quit // if (!_playingGame) { Environment.Exit(1); } // // display introductory message // _gameConsoleView.DisplayGamePlayScreen("Mission Intro", Text.MissionIntro(), ActionMenu.MissionIntro, ""); _gameConsoleView.GetContinueKey(); // // initialize the mission traveler // InitializeMission(); // // store initial map layout in 2D array // // string[,] gameMapArray = _gameMap.drawMap(); _gameMap.MapLayout = _gameMap.drawMap(); // // convert initial map array to string // string gameMapString = _gameMap.convertMapToString(_gameMap.MapLayout); // // create array to hold player row and col coords // then get initial player position int[] currentPlayerMapPosition = new int[2]; currentPlayerMapPosition = _gameMap.getCurrentPosition(_gameMap.MapLayout); MapLocation currentPlayerRoom; // // print the map // // _gameConsoleView.DisplayGamePlayScreen("Current Location", gameMapString, ActionMenu.MapMenu, ""); _gameTimer.Start(); // // game loop // while (_playingGame) { // player controls ConsoleKeyInfo keyInfo; keyInfo = Console.ReadKey(true); // validate keys // if not valid key - error message // check for player movement key TODO -> validate and make sure player isn't in menu if ((keyInfo.Key == ConsoleKey.UpArrow) || (keyInfo.Key == ConsoleKey.DownArrow) || (keyInfo.Key == ConsoleKey.LeftArrow) || (keyInfo.Key == ConsoleKey.RightArrow)) { // get the players current position currentPlayerMapPosition = _gameMap.getCurrentPosition(_gameMap.MapLayout); currentPlayerRoom = _gameMap.getCurrentRoom(currentPlayerMapPosition); // check if the player has entered a certain room and then modify a metric bool hasVisited = _gameConsoleView.checkPlayerVisited("Engine Room 2"); if (currentPlayerRoom.Name == "Engine Room 2") { if (!hasVisited) { timeRemaining -= 10; _gameConsoleView.DisplayMessage("The alien heard you! 10 Less seconds to escape!! Press any key to continue..."); Console.ReadKey(); } } // get the icon for the desired tile int [] nextTile = _gameMap.getTile(_gameMap.MapLayout, currentPlayerMapPosition, keyInfo.Key); // check if player has reached end of game tile if ((nextTile[0]) == 18 && (nextTile[1] == 44)) { _gameTimer.Stop(); _gameConsoleView.DisplayGameSuccessScreen(timeRemaining); } // refactor update map to check if desired position is available or if there is an NPC or item etc. // refactor update map to return bool //bool validTile = _gameMap.validateCellType(_gameMap.MapLayout, currentPlayerMapPosition, keyInfo.Key); // // determine object in cell type // if (_gameMap.MapLayout[nextTile[0], nextTile[1]] == "#") { _gameConsoleView.DisplayInputErrorMessage("That's a wall! You can't go that way!"); } else if (_gameMap.MapLayout[nextTile[0], nextTile[1]] == "-") { // check if new location and update locations visited list if so MapLocation currentMapRoom = _gameMap.getCurrentRoom(currentPlayerMapPosition); if (!_gameTraveler.LocationsVisited.Contains(currentMapRoom)) { _gameTraveler.LocationsVisited.Add(currentMapRoom); } // update the game map array _gameMap.MapLayout = _gameMap.updateMap(_gameMap.MapLayout, currentPlayerMapPosition, keyInfo.Key); // update the game map string gameMapString = _gameMap.convertMapToString(_gameMap.MapLayout); // display updated map _gameConsoleView.DisplayRedrawMap("Current Location", gameMapString, ActionMenu.MapMenu, ""); } else if ((_gameMap.MapLayout[nextTile[0], nextTile[1]] == "|") || (_gameMap.MapLayout[nextTile[0], nextTile[1]] == "_")) { int[] doorCoords = new int[2]; doorCoords[0] = nextTile[0]; doorCoords[1] = nextTile[1]; bool hasKey = false; foreach (TravelerObject travelerObject in _gameTraveler.Inventory) { if (travelerObject.Type == TravelerObjectType.Key) { foreach (MapObject door in UniverseObjects.mapObjects) { // check if the door coordinates correspond to the coordinates of the next tile if ((door.Coords[0] == doorCoords[0]) && (door.Coords[1] == doorCoords[1])) { // // check if the key unlocks id matches the door id if (travelerObject.UnlocksId == door.Id) { hasKey = true; //Console.WriteLine("asdf asd aSD"); // player has key to open door _gameMap.MapLayout[nextTile[0], nextTile[1]] = "@"; // update the game map array _gameMap.MapLayout = _gameMap.updateMap(_gameMap.MapLayout, currentPlayerMapPosition, keyInfo.Key); // update the game map string gameMapString = _gameMap.convertMapToString(_gameMap.MapLayout); _gameConsoleView.DisplayRedrawMap("Current Location", gameMapString, ActionMenu.MapMenu, ""); } } } } } if (!hasKey) { _gameConsoleView.DisplayInputErrorMessage("You need a key to unlock this door!"); } // check if object is key //command.Parameters.AddWithValue(kvp.Key, kvp.Value); } else if (_gameMap.MapLayout[nextTile[0], nextTile[1]] == "K") { int[] keyCoords = new int[2]; keyCoords[0] = nextTile[0]; keyCoords[1] = nextTile[1]; foreach (TravelerObject key in UniverseObjects.gameObjects) { if (key.Coords != null) { if ((key.Coords[0] == keyCoords[0]) && (key.Coords[1] == keyCoords[1])) { _gameConsoleView.DisplayGameObjectInfo(key, nextTile, _gameMap.MapLayout); } } else { return; } } } else { int[] npcCoords = new int[2]; npcCoords[0] = nextTile[0]; npcCoords[1] = nextTile[1]; // display the NPC menu foreach (NPC npc in _gameUniverse.Npcs) { // check if the coordinates match if ((npc.Coords[0] == npcCoords[0]) && (npc.Coords[1] == npcCoords[1])) { if (npc.Icon == _gameMap.MapLayout[nextTile[0], nextTile[1]]) { if (npc is ISpeak) { // display greeting _gameConsoleView.DisplayTalkTo(npc); } if (npc is IGiveItem) { _gameConsoleView.DisplayItemReceived(npc); } if (npc is IModifyMap) { _gameConsoleView.DisplayNpcModifyMap(npc, _gameMap.MapLayout); } ActionMenu.currentMenu = ActionMenu.CurrentMenu.MapMenu; _gameConsoleView.DisplayRedrawMap("Current Location", gameMapString, ActionMenu.MapMenu, ""); // // call function to handle NPC interaction // npcInteraction(npc); // } } } } } else { if (ActionMenu.currentMenu == ActionMenu.CurrentMenu.MapMenu) { travelerActionChoice = _gameConsoleView.GetActionMenuChoice(ActionMenu.MapMenu, keyInfo, gameMapString); } else if (ActionMenu.currentMenu == ActionMenu.CurrentMenu.MainMenu) { travelerActionChoice = _gameConsoleView.GetActionMenuChoice(ActionMenu.MainMenu, keyInfo, gameMapString); } else if (ActionMenu.currentMenu == ActionMenu.CurrentMenu.NPCMenu) { travelerActionChoice = _gameConsoleView.GetActionMenuChoice(ActionMenu.NpcMenu, keyInfo, gameMapString); } else if (ActionMenu.currentMenu == ActionMenu.CurrentMenu.AdminMenu) { travelerActionChoice = _gameConsoleView.GetActionMenuChoice(ActionMenu.AdminMenu, keyInfo, gameMapString); } switch (travelerActionChoice) { case TravelerAction.None: break; case TravelerAction.TalkTo: //_gameConsoleView.DisplayTalkTo(npc); break; case TravelerAction.ReturnToMap: ActionMenu.currentMenu = ActionMenu.CurrentMenu.MapMenu; _gameConsoleView.DisplayRedrawMap("Current Location", gameMapString, ActionMenu.MapMenu, ""); break; case TravelerAction.TravelerInfo: _gameConsoleView.DisplayTravelerInfo(); ActionMenu.currentMenu = ActionMenu.CurrentMenu.MainMenu; break; case TravelerAction.LookAround: _gameConsoleView.DisplayLookAround(_gameMap.MapLayout); ActionMenu.currentMenu = ActionMenu.CurrentMenu.MainMenu; break; case TravelerAction.AdminMenu: ActionMenu.currentMenu = ActionMenu.CurrentMenu.AdminMenu; _gameConsoleView.DisplayGamePlayScreen("Admin Menu", "Select an operation from the menu.", ActionMenu.AdminMenu, ""); break; case TravelerAction.Inventory: _gameConsoleView.DisplayInventory(); ActionMenu.currentMenu = ActionMenu.CurrentMenu.MainMenu; break; case TravelerAction.ListAllNpcs: _gameConsoleView.DisplayListOfNPCs(); ActionMenu.currentMenu = ActionMenu.CurrentMenu.AdminMenu; break; case TravelerAction.ListGameObjects: _gameConsoleView.DisplayListAllGameObjects(); ActionMenu.currentMenu = ActionMenu.CurrentMenu.AdminMenu; break; case TravelerAction.ListLocationsVisited: _gameConsoleView.DisplayLocationsVisited(); ActionMenu.currentMenu = ActionMenu.CurrentMenu.AdminMenu; break; case TravelerAction.ListAllLocations: _gameConsoleView.DisplayListAllMapLocations(); ActionMenu.currentMenu = ActionMenu.CurrentMenu.AdminMenu; break; case TravelerAction.Exit: _playingGame = false; break; default: break; } } } // // close the application // Environment.Exit(1); }