Exemplo n.º 1
0
    /// <summary>
    /// Activates the instant command.
    /// </summary>
    /// <param name="instantCommand">The instant command.</param>
    /// <returns></returns>
    public IEnumerator ActivateInstantCommand(string instantCommand)
    {
        //Change the state to CommandChain
        if (GameTurnController.CurrentState == GameTurnController.PlayerState.PlayerTurn)
        {
            GameTurnController.CurrentState = GameTurnController.PlayerState.CommandChain;
        }
        //Deactivate the input and run the command through the dissecting script
        InterfaceScript.DeActivateInput();
        DissectingScript.DissectPlayerInput(instantCommand, 2);
        //For the commands that needs it (like Rest), wait until they are done before moving on
        if (MovementCommands.MovementHappening)
        {
            while (MovementCommands.MovementHappening)
            {
                yield return(new WaitForEndOfFrame());
            }
        }

        yield return(new WaitForSeconds(0.2f));

        //Check if it is dark, and check of rest was used which will take up the entire turn then move to enemyturn
        if (LevelScript.Darkness)
        {
            LevelScript.DarknessHealthLoss();
        }
        if (instantCommand.ToUpper() == "REST")
        {
            if (CheckForEnemies() == 0 || SceneManager.GetActiveScene().name == "Level20")
            {
                DialogueScript.GameInformationText("It's your turn.");
                GameTurnController.CurrentState = GameTurnController.PlayerState.PlayerTurn;
                InterfaceScript.ActivateInput();
                yield break;
            }
            DialogueScript.GameInformationText("Enemies are moving.");
            GameTurnController.CurrentState = GameTurnController.PlayerState.EnemyTurn;
            yield break;
        }
        //Or return to playerturn and activate the input
        if (GameTurnController.CurrentState == GameTurnController.PlayerState.CommandChain)
        {
            GameTurnController.CurrentState = GameTurnController.PlayerState.PlayerTurn;
        }
        InterfaceScript.ActivateInput();
    }
Exemplo n.º 2
0
    /// <summary>
    /// IEnumerator that will go through the command chain until it is done, then reset everything that needs resetting to be ready for next turn.
    /// This is called from the function Start in the in-game commands list
    /// </summary>
    /// <returns></returns>
    public IEnumerator ActivatingCommands()
    {
        GameTurnController.CurrentState = GameTurnController.PlayerState.CommandChain;
        int textToRemove = 0;

        InterfaceScript.DeActivateInput();
        if (DialogueScript.CommandHistoryList.Count > 0)
        {
            foreach (string s in DialogueScript.CommandHistoryList)
            {
                DialogueScript.MovementText("You perform " + s);
                DissectingScript.DissectPlayerInput(s, 2);
                InterfaceScript.CommandPoolTexts[textToRemove].color = Color.green;
                if (MovementCommands.MovementHappening)
                {
                    while (MovementCommands.MovementHappening)
                    {
                        yield return(new WaitForEndOfFrame());
                    }
                }
                if (MetObstacle)
                {
                    DialogueScript.MovementText("You appear too disoriented to continue.");
                    MetObstacle = false;
                    break;
                }
                if (
                    CommandListScript.EmoteList.Any(
                        x =>
                        string.Equals(InterfaceScript.CommandPoolTexts[textToRemove].text, x,
                                      StringComparison.CurrentCultureIgnoreCase)))
                {
                    InterfaceScript.CommandPoolTexts[textToRemove].text = "";
                    textToRemove++;
                    yield return(new WaitForSeconds(1.7f));
                }
                else
                {
                    InterfaceScript.CommandPoolTexts[textToRemove].text = "";
                    textToRemove++;
                    yield return(new WaitForSeconds(0.7f));
                }
            }
        }
        ClearCommandPool();
        if (LevelScript.Darkness)
        {
            LevelScript.DarknessHealthLoss();
        }
        if (GameTurnController.CurrentState == GameTurnController.PlayerState.Combat ||
            GameTurnController.CurrentState == GameTurnController.PlayerState.EnemyCombatTurn)
        {
            yield break;
        }
        if (SceneManager.GetActiveScene().name == "Tutorial")
        {
            GameTurnController.CurrentState = GameTurnController.PlayerState.PlayerTurn;
            InterfaceScript.ActivateInput();
            yield break;
        }
        if (LevelFinished)
        {
            GameTurnController.CurrentState = GameTurnController.PlayerState.PlayerTurn;
            yield break;
        }
        if (CheckForEnemies() == 0 || SceneManager.GetActiveScene().name == "Level20")
        {
            DialogueScript.GameInformationText("It's your turn.");
            GameTurnController.CurrentState = GameTurnController.PlayerState.PlayerTurn;
            InterfaceScript.ActivateInput();
            yield break;
        }

        DialogueScript.GameInformationText("Enemies are moving.");
        GameTurnController.CurrentState = GameTurnController.PlayerState.EnemyTurn;
    }