/// <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.CurrentLocationInfo(_currentLocation), ActionMenu.MainMenu, ""); // // game loop // while (_playingGame) { // // process all flags, events, and stats // UpdateGameStatus(); // // 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 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.ListSpaceTimeLocations: _gameConsoleView.DisplayListOfSpaceTimeLocations(); break; case TravelerAction.ListGameObjects: _gameConsoleView.DisplayListOfAllGameObjects(); 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 // _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> /// 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); }
/// <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> /// method to manage the application setup and game loop /// </summary> private void ManageGameLoop() { PlayerAction travelerActionChoice = PlayerAction.None; // // display splash screen // _playingGame = _gameConsoleView.DisplaySplashScreen(); // // player chooses to quit // if (!_playingGame) { Environment.Exit(1); } // // display introductory message // _gameConsoleView.DisplayGamePlayScreen("Game Introduction", Text.CharacterCreation(), ActionMenu.MissionIntro, ""); _gameConsoleView.GetContinueKey(); _playerCharacter.LocationValue = TheZlandProject.Models.Area.Sanctuary; _playerCharacter.HealthValue = 10; _playerCharacter.MaxHealthValue = 10; _playerCharacter.AttackValue = 2; // // initialize the mission traveler // InitializeMission(); List <GameLocation> _listOfLocation = new List <GameLocation>(); ListOfLocations Instantiate = new ListOfLocations(); List <Character> ListOfNPC = ListOfAllNPC.InstantiateNPCLIst(); _listOfLocation = Instantiate.IntitializeGameLocationList(); List <TheZlandProject.GameObject> listOfAllGameObjects = new List <TheZlandProject.GameObject>(); listOfAllGameObjects = ListOfGameObjects.IntitializeGameObjectList(); _playerCharacter.Inventory = listOfAllGameObjects; List <Area> ListOfPlacesVisited = new List <Area>(); // // prepare game play screen // _gameConsoleView.DisplayGamePlayScreen("Current Location: " + _playerCharacter.LocationValue, Text.CurrrentLocationInfo(_playerCharacter), ActionMenu.MainMenu, ""); // // game loop // travelerActionChoice = _gameConsoleView.GetActionMenuChoice(ActionMenu.MainMenu); Random playerRandomEncounter = new Random(); while (_playingGame) { // // get next game action from player int randomBattle = 0; randomBattle = playerRandomEncounter.Next(1, 101); int probOfEncounter = 90; // // choose an action based on the player's menu choice // switch (travelerActionChoice) { case PlayerAction.None: travelerActionChoice = _gameConsoleView.GetActionMenuChoice(ActionMenu.MainMenu); break; case PlayerAction.Heal: _gameConsoleView.Heal(_playerCharacter); travelerActionChoice = PlayerAction.Return; break; case PlayerAction.Act: _gameConsoleView.DisplayGamePlayScreen("Current Location: " + _playerCharacter.LocationValue, Text.CurrrentLocationInfo(_playerCharacter), ActionMenu.Act, ""); travelerActionChoice = _gameConsoleView.GetActionMenuChoice(ActionMenu.Act); break; case PlayerAction.Options: _gameConsoleView.DisplayGamePlayScreen("Current Location: " + _playerCharacter.LocationValue, Text.CurrrentLocationInfo(_playerCharacter), ActionMenu.OptionMenu, ""); travelerActionChoice = _gameConsoleView.GetActionMenuChoice(ActionMenu.OptionMenu); break; case PlayerAction.Travel: if (randomBattle >= probOfEncounter) { _gameConsoleView.Battle(_playerCharacter); travelerActionChoice = PlayerAction.Return; } else { _playerCharacter = _gameConsoleView.DisplayTravelMenu(_playerCharacter, _listOfLocation, ListOfPlacesVisited, listOfAllGameObjects); travelerActionChoice = PlayerAction.Return; } break; case PlayerAction.TalkTo: _gameConsoleView.DisplayTalkTo(_playerCharacter, ListOfNPC); travelerActionChoice = PlayerAction.Return; break; case PlayerAction.PlayerInfo: _gameConsoleView.DisplayPlayerInformation(); travelerActionChoice = _gameConsoleView.GetActionMenuChoice(ActionMenu.PlayerInformation); break; case PlayerAction.EditPlayer: _playerCharacter = _gameConsoleView.DisplayEditPlayer(_playerCharacter); travelerActionChoice = _gameConsoleView.GetActionMenuChoice(ActionMenu.MainMenu); break; case PlayerAction.LookAround: _playerCharacter = _gameConsoleView.LookAround(_playerCharacter, listOfAllGameObjects); travelerActionChoice = _gameConsoleView.GetActionMenuChoice(ActionMenu.LookAround); break; case PlayerAction.LookAt: _gameConsoleView.LookAt(_playerCharacter, listOfAllGameObjects); travelerActionChoice = _gameConsoleView.GetActionMenuChoice(ActionMenu.ReturnOnly); break; case PlayerAction.PickUpItem: _playerCharacter = _gameConsoleView.PickUpItem(_playerCharacter, listOfAllGameObjects); travelerActionChoice = PlayerAction.Return; break; case PlayerAction.PutDownItem: _playerCharacter = _gameConsoleView.PutDownItem(_playerCharacter, listOfAllGameObjects); travelerActionChoice = PlayerAction.Return; break; case PlayerAction.AdminMenu: _gameConsoleView.DisplayAdminMenu(); travelerActionChoice = _gameConsoleView.GetActionMenuChoice(ActionMenu.AdminMenu); break; case PlayerAction.DisplayAllObjects: _gameConsoleView.DisplayAllGameObjects(listOfAllGameObjects); travelerActionChoice = _gameConsoleView.GetActionMenuChoice(ActionMenu.ReturnOnly); break; case PlayerAction.DisplayAllNPC: _gameConsoleView.DisplayAllNPC(ListOfNPC); travelerActionChoice = _gameConsoleView.GetActionMenuChoice(ActionMenu.ReturnOnly); break; case PlayerAction.DisplayPlayerInventory: _gameConsoleView.DisplayPlayerInventory(_playerCharacter); travelerActionChoice = _gameConsoleView.GetActionMenuChoice(ActionMenu.ReturnOnly); break; case PlayerAction.DisplayLocationsVisited: _gameConsoleView.DisplayAllPlacesVisited(ListOfPlacesVisited); travelerActionChoice = _gameConsoleView.GetActionMenuChoice(ActionMenu.ReturnOnly); break; case PlayerAction.DisplayAllLocations: _gameConsoleView.DisplayAllLocations(_listOfLocation); travelerActionChoice = _gameConsoleView.GetActionMenuChoice(ActionMenu.ReturnOnly); break; case PlayerAction.Return: _gameConsoleView.DisplayCurrentLocation(_playerCharacter); travelerActionChoice = _gameConsoleView.GetActionMenuChoice(ActionMenu.MainMenu); break; case PlayerAction.Exit: _playingGame = false; break; default: break; } } // // close the application // _gameConsoleView.DisplayClosingScreen(); Environment.Exit(1); }