//not currently using the ogreActionChoice function private void UpdateGameStatus(OgreAction ogreActionChoice) { if (_gameOgre.SwampLocationID == 1) { _gameOgre.Health = 500; } if (_gameOgre.SwampLocationID == 5 && ogreActionChoice == OgreAction.TalkTo) { Dragon enemyDragon; enemyDragon = _gameKingdom.GetDragonByID(2); enemyDragon.Health = enemyDragon.Health - 100; _gameOgre.Health = _gameOgre.Health - 100; if (_gameOgre.Health == 0) { Console.WriteLine("You have died in battle. Bardul will now eat what remains of you."); Console.ReadLine(); _usingGame = false; } else if (_gameOgre.Health < 200) { Console.WriteLine("Your health is getting low. You should return to Silvara to heal."); Console.ReadLine(); } else if (enemyDragon.Health == 0 && _gameOgre.Health != 0) { Console.WriteLine("Hurry!! You have have defeated the evil Dragon and made the world a better place."); Console.ReadLine(); _usingGame = false; } } }
/// <summary> /// get the action choice from the user /// </summary> public OgreAction DisplayGetOgreActionChoice() { OgreAction ogreActionChoice = OgreAction.None; bool usingMenu = true; while (usingMenu) { // // set up display area // ConsoleUtil.HeaderText = "Ogre Action Choice"; 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" + "Ogre Actions" + Environment.NewLine + "\t" + "**************************" + Environment.NewLine + "\t" + "A. Look Around" + Environment.NewLine + "\t" + "B. Talk To" + Environment.NewLine + "\t" + "C. Look At" + Environment.NewLine + "\t" + "D. Pick Up Item" + Environment.NewLine + "\t" + "E. Pick Up Treasure" + Environment.NewLine + "\t" + "F. Put Down Item" + Environment.NewLine + "\t" + "G. Put Down Treasure" + Environment.NewLine + "\t" + "H. Travel" + Environment.NewLine + "\t" + Environment.NewLine + "\t" + "**************************" + Environment.NewLine + "\t" + "Traveler Information" + Environment.NewLine + "\t" + "**************************" + Environment.NewLine + "\t" + "I. Display General Ogre Info" + Environment.NewLine + "\t" + "J. Display Ogre Inventory" + Environment.NewLine + "\t" + "K. Display Ogre Treasures" + Environment.NewLine + "\t" + Environment.NewLine + "\t" + "**************************" + Environment.NewLine + "\t" + "Game Information" + Environment.NewLine + "\t" + "**************************" + Environment.NewLine + "\t" + "L. Display All Swamp Destinations" + Environment.NewLine + "\t" + "M. Display All Game Items" + Environment.NewLine + "\t" + "N. 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': ogreActionChoice = OgreAction.LookAround; usingMenu = false; break; case 'B': case 'b': ogreActionChoice = OgreAction.TalkTo; usingMenu = false; break; case 'C': case 'c': ogreActionChoice = OgreAction.LookAt; usingMenu = false; break; case 'D': case 'd': ogreActionChoice = OgreAction.PickUpItem; usingMenu = false; break; case 'E': case 'e': ogreActionChoice = OgreAction.PickUpTreasure; usingMenu = false; break; case 'F': case 'f': ogreActionChoice = OgreAction.PutDownItem; usingMenu = false; break; case 'G': case 'g': ogreActionChoice = OgreAction.PutDownTreasure; usingMenu = false; break; case 'H': case 'h': ogreActionChoice = OgreAction.Travel; usingMenu = false; break; case 'I': case 'i': ogreActionChoice = OgreAction.OgreInfo; usingMenu = false; break; case 'J': case 'j': ogreActionChoice = OgreAction.OgreInventory; usingMenu = false; break; case 'K': case 'k': ogreActionChoice = OgreAction.OgreTreasure; usingMenu = false; break; case 'L': case 'l': ogreActionChoice = OgreAction.ListSwampDestinations; usingMenu = false; break; case 'M': case 'm': ogreActionChoice = OgreAction.ListItems; usingMenu = false; break; case 'N': case 'n': ogreActionChoice = OgreAction.ListTreasures; usingMenu = false; break; case 'Q': case 'q': ogreActionChoice = OgreAction.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(ogreActionChoice); }
/// <summary> /// method to manage the application setup and control loop /// </summary> private void ManageGameLoop() { OgreAction ogreActionChoice = OgreAction.None; _gameConsoleView.DisplayWelcomeScreen(); InitializeMission(); // // game loop // while (_usingGame) { //not currently using the ogreActionChoice function UpdateGameStatus(ogreActionChoice); // // get a menu choice from the ConsoleView object // ogreActionChoice = _gameConsoleView.DisplayGetOgreActionChoice(); // // choose an action based on the user's menu choice // switch (ogreActionChoice) { case OgreAction.None: break; case OgreAction.LookAround: _gameConsoleView.DisplayLookAround(); break; case OgreAction.TalkTo: _gameConsoleView.DisplayTalkTo(); break; case OgreAction.LookAt: _gameConsoleView.DisplayLookAt(); break; case OgreAction.PickUpItem: int itemID; itemID = _gameConsoleView.DisplayPickUpItem(); Item PickedUpItem = new Item(); PickedUpItem = _gameKingdom.GetItemtByID(itemID); _gameOgre.OgresItems.Add(PickedUpItem); PickedUpItem.SwampLocationID = 0; break; case OgreAction.PickUpTreasure: int treasureID = _gameConsoleView.DisplayPickUpTreasure(); Treasure PickedUpTreasure = new Treasure(); PickedUpTreasure = _gameKingdom.GetTreasuretByID(treasureID); _gameOgre.OgresTreasures.Add(PickedUpTreasure); PickedUpTreasure.SwampLocationID = 0; break; case OgreAction.PutDownItem: int itemToPutDown = _gameConsoleView.DisplayPutDownItem(); Item ItemToDrop = new Item(); ItemToDrop = _gameKingdom.GetItemtByID(itemToPutDown); _gameOgre.OgresItems.Remove(ItemToDrop); ItemToDrop.SwampLocationID = _gameOgre.SwampLocationID; break; case OgreAction.PutDownTreasure: int treasureToPutDown = _gameConsoleView.DisplayPutDownTreasure(); Treasure TreasureToDrop = new Treasure(); TreasureToDrop = _gameKingdom.GetTreasuretByID(treasureToPutDown); _gameOgre.OgresTreasures.Remove(TreasureToDrop); TreasureToDrop.SwampLocationID = _gameOgre.SwampLocationID; break; case OgreAction.Travel: _gameOgre.SwampLocationID = _gameConsoleView.DisplayGetOgresNewDestination().SwampLocationID; break; case OgreAction.OgreInfo: _gameConsoleView.DisplayOgreInfo(); break; case OgreAction.OgreInventory: _gameConsoleView.DisplayOgreItems(); break; case OgreAction.OgreTreasure: _gameConsoleView.DisplayOgreTreasure(); break; case OgreAction.ListSwampDestinations: _gameConsoleView.DisplayListAllSwampDestinations(); break; case OgreAction.ListItems: _gameConsoleView.DisplayListAllGameItems(); break; case OgreAction.ListTreasures: _gameConsoleView.DisplayListAllGameTreasures(); break; case OgreAction.Exit: _usingGame = false; break; default: break; } } _gameConsoleView.DisplayExitPrompt(); // // close the application // Environment.Exit(1); }