Beispiel #1
0
 /// <summary>
 /// Changes the turn after a combat move has finished checking for hit or miss
 /// </summary>
 /// <param name="ability">The ability.</param>
 /// <param name="hit">The hit.</param>
 public void ChangeTurn(string ability, string hit)
 {
     GameObject.FindGameObjectWithTag("Player").GetComponent <WarriorClass>().chargeAmount--;
     //If the ability was Slam and it hit (or crit)
     if (ability == "Slam" && (hit == "Hit" || hit == "Crit"))
     {
         //Inform the Player that the enemy is stunned
         DialogueScript.CombatTextPlayer("Your foe seems stunned by your shield!");
         DialogueScript.CombatTextPlayer("Quickly strike again before he regains his whereabouts!");
         //Return the state to Combat, add one to Turn counter and activate input
         GameTurnController.CurrentState = GameTurnController.PlayerState.Combat;
         CurrentTurn++;
         InterfaceScript.ActivateInput();
         return;
     }
     //Else, if the ability was null (i.e. missed)
     if (ability == null)
     {
         //Change state to Enemy turn, do 0 damage and add one to turn counter
         GameTurnController.CurrentState = GameTurnController.PlayerState.EnemyCombatTurn;
         StartCoroutine(DoDamage(0, "null"));
         CurrentTurn++;
         return;
     }
     //Otherwise, just change to enemy turn and add one to turn counter
     GameTurnController.CurrentState = GameTurnController.PlayerState.EnemyCombatTurn;
     CurrentTurn++;
 }
Beispiel #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();
    }
Beispiel #3
0
 internal bool OnCooldown(string function)
 {
     if (CooldownList.Any(s => s.Equals(function, StringComparison.CurrentCultureIgnoreCase)))
     {
         DialogueScript.ErrorText("You're currently cooling down from using that ability.");
         InterfaceScript.ActivateInput();
         return(true);
     }
     return(false);
 }
Beispiel #4
0
    void FinishTurn()
    {
        if (currentHp < lastTurnHp)
        {
            cowardness++;
        }                           //if it lost hp this turn, make it more likley to block
        if (currentHp <= 0)         //if it has no hp
        {
            if (enemyName != "Boss")
            {
                Animate();
            }                                                //die
            else
            {
                DialogueScript.CombatTextEnemy("NO YOU FOILED MY PLANS! BUT I WILL BE BACK!");
            }
            switch (enemyName)
            {
            case "D":
                GetComponent <Animator>().SetBool("TrollDeath", true);
                break;

            case "S":
                GetComponent <Animator>().SetTrigger("DeathAnimationTrigger");
                break;
            }
            Invoke("EndOfMe", 2f);             //get deadededed
        }

        if (hasRegen == true && currentHp < maxHp && currentHp > 0) //if it has regen, and it hp is less than max, and more than 0
        {
            currentHp += regenSpeed;                                //if the enemy has regen, add regen to health
            DialogueScript.CombatTextEnemy("Some of the " + enemyName + "s wounds close up!");
        }
        if (currentHp > maxHp)
        {
            currentHp = maxHp;
        }                               //if health exeeds max health set it to max health
        lastTurnHp = currentHp;         //ends the turn, and stores how much hp this used to have

        if (PlayerPrefs.GetInt("Health") <= 0)
        {
            KillPlayer();
        }                                                                        //if the player has 0 hp kill it

        CurrentTurn++;                                                           //add to current turn
        GameTurnController.CurrentState = GameTurnController.PlayerState.Combat; //change turn
        InterfaceScript.ActivateInput();
    }
Beispiel #5
0
 public void GettingLoot(string potionType)
 {
     StopCoroutine("ActivatingCommands");
     ClearCommandPool();
     if (LootedPermPotion)
     {
         DialogueScript.GameInformationText("You looted a " + potionType + " potion!");
         DialogueScript.GameInformationText("If you want to use it, write yes! Otherwise write anything else.");
         InterfaceScript.IsGettingLoot = true;
         InterfaceScript.ActivateInput();
         GameTurnController.CurrentState = GameTurnController.PlayerState.PlayerTurn;
         return;
     }
     StartChain();
 }
Beispiel #6
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();
    }
Beispiel #7
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;
     }
 }
Beispiel #8
0
    /// <summary>
    /// Dissects the player input.
    /// </summary>
    /// <param name="input">The input.</param>
    /// <param name="version">The version.</param>
    public void DissectPlayerInput(string input, int version)
    {
        //Run the input through a function to remove any additional whitespace. This removes both start and end whitespace, and also between words.
        string trimmedInput = TrimInput(input);

        //Split the input into an array of strings
        string[] fullInput = trimmedInput.Split(null);
        //Since "use" is such a common commando to use in text-based games, notify the player as soon as possible about how it won't work here.
        if (fullInput[0].Equals("use", StringComparison.CurrentCultureIgnoreCase))
        {
            _dialogueScript.ErrorText("I'm terribly sorry, but \"use\" is not a valid commando here.");
            _interfaceScript.ActivateInput();
            return;
        }
        //Iterate through the various command lists and see if the Player is using a variation of the actual function
        foreach (List <string> list in _commandListScript.ValidCommandsList)
        {
            for (int i = 0; i < list.Count; i++)
            {
                if (string.Equals(list[i], fullInput[0], StringComparison.CurrentCultureIgnoreCase) && list[i] != list[0])
                {
                    fullInput[0] = list[0];
                }
            }
        }
        //Get the type and object to look for the function in. Also check if it's a special tutorial function
        bool ifTutorial = GetCommandTypeObject(fullInput[0]);
        //Find the function in the selected script
        MethodInfo function = _type.GetMethod(fullInput[0],
                                              BindingFlags.Public | BindingFlags.Instance | BindingFlags.IgnoreCase | BindingFlags.NonPublic);

        //Make sure a function has been found
        if (function == null)
        {
            _dialogueScript.ErrorText("invalid");
            _interfaceScript.ActivateInput();
            return;
        }
        if (_commandListScript.CombatCommands.Contains(trimmedInput.ToUpper()) &&
            _gameTurnController.CurrentState != GameTurnController.PlayerState.Combat)
        {
            _dialogueScript.ErrorText("You're not in combat right now.");
            _interfaceScript.ActivateInput();
            return;
        }
        //After finding the function, if it was a tutorial or instant one, execute it and return
        if ((ifTutorial || _instantCommands.Contains(fullInput[0].ToUpper())) && version == 1)
        {
            _commandsScript.StartInstant(trimmedInput);
            return;
        }
        //Check if the Player has given a valid function and arguments
        bool foundFunction = GameObject.Find("ScriptHolder").GetComponent <InputValidation>().ValidFunctionInput(fullInput);

        //If 1 is given, the input should be validated and saved
        if (version == 1)
        {
            //If false is returned, feedback is given via the function, so just return
            if (!foundFunction)
            {
                _interfaceScript.ActivateInput();
                return;
            }
            //Otherwise, save the input into the command log and inform the Player
            _dialogueScript.SaveIntoCommandLog(trimmedInput);
            //Also reactivate the input.
            _interfaceScript.ActivateInput();
        }
        //If 2 is given, execute the function
        if (version == 2)
        {
            if (!foundFunction)
            {
                _interfaceScript.ActivateInput();
                return;
            }
            ExecuteFunction(function, fullInput);
        }
    }
Beispiel #9
0
    /// <summary>
    /// Print out a list of argument
    /// </summary>
    /// <param name="arg">The argument.</param>
    new public void List(string arg)
    {
        CheckString("List", arg);
        if (NoInput)
        {
            return;
        }
        if (arg.ToUpper() == "ALIAS")
        {
            //Make sure that the Player has actually saved an alias
            if (CommandListScript.AliasDictionary.Count != 0)
            {
                //Inform the Player that these are the aliases created
                DialogueScript.GameInformationText(
                    "Here's a list of aliases. ");
                //Iterate through the dictionary and print out each alias alongside the function
                foreach (string s in CommandListScript.AliasDictionary.Keys)
                {
                    string value = CommandListScript.AliasDictionary[s];
                    DialogueScript.MovementText(s + " : " + value);
                }
            }
            else
            {
                DialogueScript.ErrorText("No aliases saved.");
            }
        }

        if (arg.ToUpper() == "COMMANDS")
        {
            StringBuilder builtString = new StringBuilder();
            foreach (var list in CommandListScript.ValidCommandsList)
            {
                foreach (string s in list)
                {
                    builtString.Append(s).Append(" | ");
                }
            }
            foreach (string s in CommandListScript.CommandsList)
            {
                builtString.Append(s).Append(" | ");
            }
            foreach (string s in CommandListScript.CombatCommands)
            {
                builtString.Append(s).Append(" | ");
            }
            InterfaceScript.PlaceText(builtString.ToString(), new Color(0, 255, 200), 15);
        }

        if (string.Equals(arg, "emotes", StringComparison.CurrentCultureIgnoreCase))
        {
            var builtString = new StringBuilder();
            foreach (string s in CommandListScript.EmoteList)
            {
                builtString.Append(s).Append(" - ");
            }
            InterfaceScript.PlaceText(builtString.ToString(), new Color(0, 255, 200), 15);
        }
        if (GameTurnController.CurrentState == GameTurnController.PlayerState.Combat)
        {
            InterfaceScript.ActivateInput();
        }
    }
Beispiel #10
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;
    }
Beispiel #11
0
 void Start()
 {
     CommandListScript.UpdateAllCommandsList();
     InterfaceScript.ActivateInput();
     InterfaceScript.LevelText.text = LevelScript.LevelCounter.ToString();
 }