Example #1
0
        /// <summary>
        /// Closes the help screen and returns to the previous screen.
        /// </summary>
        /// <param name="argument"></param>
        /// <returns></returns>
        public CommandOutput closeHelp(string argument)
        {
            CommandOutput output;

            if (currentView == ViewType.Help)
            {
                output = enableView(viewBeforeHelp);
            }
            else
            {
                output = new CommandOutput(false, "Did you mean \"exit\"?", "Failed trying to close help from outside of help.");
            }
            return(output);
        }
Example #2
0
        /// <summary>
        /// Opens the help screen.
        /// </summary>
        /// <param name="argument"></param>
        /// <returns></returns>
        public CommandOutput openHelp(string argument)
        {
            CommandOutput output;

            if (currentView != ViewType.Help)
            {
                viewBeforeHelp = currentView;
                output         = enableView(ViewType.Help);
            }
            else
            {
                output = new CommandOutput(false, "Type \"close\" to return.", "Failed trying to access help from help.");
            }
            return(output);
        }
        /// <summary>
        /// Starts the game.
        /// </summary>
        /// <param name="argument"></param>
        /// <returns></returns>
        public CommandOutput startGame(string argument)
        {
            CommandOutput output;

            if (ViewManager.Instance.currentView == ViewManager.ViewType.Menu)
            {
                viewModel.startNewGame(playerID);
                ViewManager.Instance.enableView(ViewManager.ViewType.Scene);
                output = new CommandOutput(true, "Game Started.", "display update");
            }
            else
            {
                output = new CommandOutput(false, "Game already started.", "Could not make new game as one is already in progress.");
            }
            return(output);
        }
Example #4
0
        private void handleInput(string arg)
        {
            // Turn input string into system input
            Command command = InputManager.checkInput(playerInput.text);

            if (command.Valid)
            {
                CommandOutput output = command.act();
                outputBoxText.text = output.Message;
                if (!output.Success)
                {
                    Debug.Log(output.SystemMessage);
                }

                if (output.SystemMessage == "display update")
                {
                    if (currentView == ViewType.Scene)
                    {
                        GameViewManager.Instance.updateSceneInformation();
                    }
                    else if (currentView == ViewType.Inventory)
                    {
                        GameViewManager.Instance.updateInventoryInformation();
                    }
                }
            }
            else
            {
                outputBoxText.text = "Unrecognised command.";
            }

            // Ready textbox for next input
            playerInput.text = "";
#if !UNITY_ANDROID
            /*
             * We only want to reselect the input field if the control scheme is keyboard e.g. the desktop versions
             * On the android version, touch controls mean that reselecting the input field after every command
             * will hide the game display behind the android keyboard at all times. Android users will probably
             * be more confortable pressing the input field every time they want to enter a command, since they're
             * already tapping on the screen to type. Desktop users would have to move their hand to the mouse if
             * the input field was not reselected, so for them it's preferable to have it reselected after every
             * command.
             */
            playerInput.ActivateInputField();
#endif
        }
Example #5
0
        /// <summary>
        /// Changes the active view in the game.
        /// </summary>
        /// <param name="argument"></param>
        /// <returns></returns>
        public CommandOutput changeGameView(string argument)
        {
            CommandOutput output;

            if (argument.Equals("inventory") || argument.Equals("items"))
            {
                output = enableView(ViewType.Inventory);
            }
            else if (argument.Equals("scene") || argument.Equals("room"))
            {
                output = enableView(ViewType.Scene);
            }
            else
            {
                output = new CommandOutput(false, string.Format("{0} is unknown.", argument), "Could not change view.");
            }

            return(output);
        }
Example #6
0
        /// <summary>
        /// Returns to the menu from the game.
        /// </summary>
        /// <param name="argument"></param>
        /// <returns></returns>
        public CommandOutput exitGame(string argument)
        {
            CommandOutput output;

            if (currentView == ViewType.Menu)
            {
                output = new CommandOutput(true, "Returning to menu.", "");
                LoginManager.logout(GameViewManager.Instance.playerID);
                enableView(ViewType.Login);
            }
            else if (currentView == ViewType.Scene || currentView == ViewType.Inventory)
            {
                enableView(ViewType.Menu);
                GameViewManager.Instance.ViewModel.endGame();
                output = new CommandOutput(true, "Returned to menu.", "The game was ended.");
            }
            else
            {
                output = new CommandOutput(false, "Did you mean \"close\"", "Can't exit from the help view.");
            }
            return(output);
        }
        /// <summary>
        /// Continues the player's last played game.
        /// </summary>
        /// <param name="argument"></param>
        /// <returns></returns>
        public CommandOutput continueGame(string argument)
        {
            CommandOutput output;
            bool          canContinue;

            if (ViewManager.Instance.currentView == ViewManager.ViewType.Menu)
            {
                canContinue = viewModel.startOldGame(playerID);
                ViewManager.Instance.enableView(ViewManager.ViewType.Scene);
                if (canContinue)
                {
                    output = new CommandOutput(true, "Loaded last game.", "display update");
                }
                else
                {
                    output = new CommandOutput(true, "No game to load, started new.", "display update");
                }
            }
            else
            {
                output = new CommandOutput(false, "Game already started.", "Could not make new game as one is already in progress.");
            }
            return(output);
        }