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
    public IEnumerator XDoDamage()
    {
        yield return(new WaitForSeconds(3));

        _dialogueScript.CombatTextEnemy("He seems to be considering his next strike...");
        yield return(new WaitForSeconds(1));

        switch (_enemyName)
        {
        case "D":
            GetComponent <Animator>().SetTrigger("Punch");
            break;

        case "S":
            GetComponent <Animator>().SetTrigger("StabAnimationTrigger");
            break;
        }
        yield return(new WaitForSeconds(1));

        int hit = Random.Range(0, 100);

        if (hit <= _chanceToHit)
        {
            //Remove the damage the enemy do from the Player
            PlayerPrefs.SetInt("Health", PlayerPrefs.GetInt("Health") - BaseDamage);
            //Inform the Player that they have taken x damage

            if (_playerScript.Health <= 0)
            {
                _dialogueScript.CombatTextEnemy("The Enemy strikes a mortal blow and the world is darkening....");
                GameObject.FindGameObjectWithTag("ScriptHolder").GetComponent <LevelFader>().SceneFinished = true;
                _uiScript.DeActivateInput();
                Invoke("PlayerDead", 3);
                yield break;
            }

            _dialogueScript.CombatTextEnemy("You have been hit for " + BaseDamage + "!");
        }
        else
        {
            _dialogueScript.CombatTextEnemy("He misses you!");
        }
        _gameTurnController.CurrentState = GameTurnController.PlayerState.Combat;
        _dialogueScript.GameInformationText("The battle presents an opening, strike with an ability now!");
        _uiScript.ActivateInput();
    }
Exemplo n.º 3
0
 void Update()
 {
     if (Input.GetKeyUp(KeyCode.Return))
     {
         if (GameTurnController.CurrentState == GameTurnController.PlayerState.EnemyCombatTurn ||
             GameTurnController.CurrentState == GameTurnController.PlayerState.CommandChain ||
             GameTurnController.CurrentState == GameTurnController.PlayerState.EnemyTurn)
         {
             DialogueScript.ErrorText("Can't do anything now.");
             InterfaceScript.DeActivateInput();
         }
         else if (GameTurnController.CurrentState == GameTurnController.PlayerState.Combat ||
                  GameTurnController.CurrentState == GameTurnController.PlayerState.PlayerTurn)
         {
             if (InterfaceScript.CommandInputField.text == "")
             {
                 DialogueScript.ErrorText("Nothing saved.");
                 InterfaceScript.ActivateInput();
                 return;
             }
             InterfaceScript.PlayerInput();
         }
     }
     //Make sure that if people hit their mouse buttons or escape, the input is still active
     if (Input.GetKeyUp(KeyCode.Mouse0) || Input.GetKeyUp(KeyCode.Mouse1) || Input.GetKeyUp(KeyCode.Escape))
     {
         InterfaceScript.ActivateInput();
     }
     //If Player hit the up-arrow, the last thing they wrote will be placed back into the input field
     if (Input.GetKeyUp(KeyCode.UpArrow) && (GameTurnController.CurrentState == GameTurnController.PlayerState.PlayerTurn ||
                                             GameTurnController.CurrentState == GameTurnController.PlayerState.Combat))
     {
         if (InterfaceScript.LastCommands == null)
         {
             return;
         }
         InterfaceScript.ActivateInput();
         InterfaceScript.CommandInputField.text = InterfaceScript.LastCommands;
         InterfaceScript.CommandInputField.MoveTextEnd(true);
         InterfaceScript.LastCommands = null;
     }
 }
Exemplo n.º 4
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;
    }