Esempio n. 1
0
        /// <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
                //
                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.DisplayListOfSpaceTimeLocation();
                    break;

                case TravelerAction.LookAround:
                    _gameConsoleView.DisplayLookAround();
                    break;

                case TravelerAction.Travel:
                    //
                    // get new location choice and update the current location property
                    //
                    _gameTraveler.SpaceTimeLocationID = _gameConsoleView.DisplayGetNextSpaceTimeLocation();
                    _currentLocation = _gameUniverse.GetSpaceTimeLocationById(_gameTraveler.SpaceTimeLocationID);

                    if (_currentLocation.CommonName == "Gelandria")
                    {
                        _gameTraveler.SpaceTimeLocationID = _gameConsoleView.DisplayGelandria();
                        _currentLocation = _gameUniverse.GetSpaceTimeLocationById(_gameTraveler.SpaceTimeLocationID);
                    }

                    UpdateHealth();
                    //
                    // set the game play screen to the current location info format
                    //
                    _gameConsoleView.DisplayGamePlayScreen("Current Location", Text.CurrentLocationInfo(_currentLocation), ActionMenu.MainMenu, "");
                    break;

                case TravelerAction.Exit:
                    _playingGame = false;
                    break;

                case TravelerAction.TravelerLocationsVisited:
                    _gameConsoleView.DisplayLocationsVisited();
                    break;

                default:
                    break;
                }
            }

            //
            // close the application
            //
            Environment.Exit(1);
        }