Example #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++;
 }
Example #2
0
    /// <summary>
    /// Called after an ability is used, places abilites on cooldown and checks if the player hits.
    /// </summary>
    /// <param name="ability">The ability.</param>
    /// <param name="cd">The cd.</param>
    /// <param name="damage">The damage.</param>
    public void EndOfTurn(string ability, int cd, int damage)
    {
        //Make sure the script has a reference to the GameTurnController
        if (!GameTurnController)
        {
            GameTurnController = GameObject.FindGameObjectWithTag("GameController").GetComponent <GameTurnController>();
        }
        switch (ability)
        {
        case "Thrust":
            GetComponent <Animator>().SetTrigger("PlayerThrust");
            break;

        case "Slash":
        case "StrainSlash":
            GetComponent <Animator>().SetTrigger("PlayerSlash");
            break;

        case "Block":
            GetComponent <Animator>().SetTrigger("PlayerBlock");
            break;

        case "Slam":
            GetComponent <Animator>().SetTrigger("PlayerSDash");
            break;
        }
        //Check if the Player hits
        string hit = CalculateHit();
        //Get a reference to the enemy
        GameObject enemyGameObject = CommandScript.GetRaycastObject();

        switch (hit)
        {
        //If missing
        case "Miss":
            //Inform the Player and let the enemy know
            if (ability != "Block" && ability != "ShieldBlock")
            {
                DialogueScript.CombatTextPlayer("You missed the enemy!");
                enemyGameObject.GetComponent <EnemyScript>().PlayerMissed();
            }
            break;

        //If hit
        case "Hit":
            //Call the function to do damage and place the ability on cooldown
            StartCoroutine(DoDamage(damage, ability));
            AddToCooldownList(ability, cd);
            break;

        //Or if it's a crit
        case "Crit":
            //Call the damage function and give it twice the amount of damage, then set ability cooldown
            StartCoroutine(DoDamage(damage * 2, ability));
            AddToCooldownList(ability, cd);
            break;
        }
        //Change the turn
        ChangeTurn(ability, hit);
    }
Example #3
0
 public void Thrust(string arg)
 {
     if (OnCooldown("thrust"))
     {
         return;
     }
     DialogueScript.CombatTextPlayer("You thrust your weapon towards the enemy.");
     EndOfTurn("Thrust", 4, 15);
 }
Example #4
0
 public void Slash(string arg)
 {
     if (OnCooldown("slash"))
     {
         return;
     }
     DialogueScript.CombatTextPlayer("You slash wildly at the enemy");
     EndOfTurn("Slash", 1, 7);
 }
Example #5
0
    private IEnumerator Attacking()
    {
        //Make sure that if the player is still moving/rotating, this function won't start until movement is done
        while (MovementHappening)
        {
            yield return(new WaitForEndOfFrame());
        }
        //Get what is in front of the Player, if it's nothing inform and return
        GameObject hit = GetRaycastObject();

        if (hit == null)
        {
            DialogueScript.ErrorText("There's nothing right in front of you");
            yield break;
        }
        if (hit.transform.tag == "Enemy")
        {
            GameObject.Find("Canvas").GetComponent <InterfaceScript>().ChangeCommandPool("off");
            //Get the sound from the weapon and do the initial attack
            GameObject.FindGameObjectWithTag("Weapon").GetComponent <AudioSource>().Play();
            int damageDone = PlayerPrefs.GetInt("Level") + PlayerPrefs.GetInt("Strength");
            //Give the damage to the enemy, then show it on the GUI
            hit.transform.GetComponent <EnemyScript>().CheckHealth(damageDone, "initial");
            GameObject.FindGameObjectWithTag("UI").GetComponent <InterfaceScript>().ShowDamage(damageDone);
            //Change to enemy turn
            hit.transform.GetComponent <EnemyScript>().GotAttacked(transform.gameObject);
            GameTurnController.CurrentState = GameTurnController.PlayerState.EnemyCombatTurn;
            CombatCommands.Target           = hit.transform.gameObject;
            //Inform the player that they are in combat, and clear any extra commands they have used
            DialogueScript.CombatTextPlayer("You've engaged the foe in front of you!");
            ClearCommandPool();
            //Pause the torch countdown while in combat (and it's not the tutorial level)
            if (SceneManager.GetActiveScene().name != "Tutorial")
            {
                LevelScript.PauseTorches(true);
            }
        }
        else
        {
            DialogueScript.ErrorText("You can't attack that.");
        }
    }
Example #6
0
 public void Execute()
 {
     if (OnCooldown("execute"))
     {
         return;
     }
     lastMove = "Execute";
     if (Target != null)
     {
         if (Target.GetComponent <EnemyScript>().BaseHealth < (Target.GetComponent <EnemyScript>().StartingHealth / 2))
         {
             DialogueScript.CombatTextPlayer("You perform a hard-hitting Execute on your weakened target!");
             //EndOfTurn("Execute", 3, (Target.GetComponent<EnemyScript>().BaseHealth/2));
             EndOfTurn("Execute", 3, (PlayerPrefs.GetInt("Strength") * 5));
         }
     }
     else
     {
         throw new UnityException("There's no target.");
     }
 }
Example #7
0
 public void Rekt(string arg)
 {
     DialogueScript.CombatTextPlayer("You cheat and teabag the enemy.");
     EndOfTurn("Rekt", 1, 10000);
 }