Example #1
0
 void KillPlayer()
 {
     DialogueScript.CombatTextEnemy("The Enemy strikes a mortal blow and the world is darkening....");
     GameObject.FindGameObjectWithTag("ScriptHolder").GetComponent <LevelFader>().SceneFinished = true;        //fade to darkness
     GameObject.FindGameObjectWithTag("UI").GetComponent <InterfaceScript>().DeActivateInput();
     GetComponent <EnemyScript>().Invoke("PlayerDead", 3);
 }
Example #2
0
    IEnumerator WildAttack()
    {
        int damage = Random.Range(Mathf.CeilToInt(strenght * 1.5f), Mathf.RoundToInt(strenght * 2.5f));           //some damage

        GameObject.FindGameObjectWithTag("Player").GetComponent <WarriorClass>().storedDamage = damage;           //used for counterattack

        DialogueScript.CombatTextEnemy("The enraged " + enemyName.ToLower() + attackPattern + " at you wildly."); //what did the enemy do
        if (lastPlayerCommand == "ShieldBlock")
        {
            yield return(new WaitForSeconds(2f));

            DialogueScript.CombatTextEnemy("You try to block the enraged " + enemyName.ToLower() + " but the attacks are too random.");
        }
        yield return(new WaitForSeconds(3f));

        Animate();
        if (Random.Range(0, 2) == 0)
        {
            DialogueScript.CombatTextEnemy("The enraged " + enemyName.ToLower() + " hits! And " + attackPattern + " you for " + damage + " damage!"); //what did the enemy do
            PlayerPrefs.SetInt("Health", PlayerPrefs.GetInt("Health") - damage);                                                                      //damage the player
            GameObject.FindGameObjectWithTag("Player").GetComponent <WarriorClass>().storedDamage = damage;
        }
        else
        {
            DialogueScript.CombatTextEnemy("The enraged " + enemyName.ToLower() + " misses you!");            //writes
            yield return(new WaitForSeconds(3f));

            DialogueScript.CombatTextEnemy("In the missed attack, the enraged " + enemyName.ToLower() + " damages itself."); //writes
            currentHp -= 10;                                                                                                 //self damage
            GameObject.FindGameObjectWithTag("Player").GetComponent <WarriorClass>().storedDamage = 0;
        }
        FinishTurn();
    }
Example #3
0
    IEnumerator Darken()
    {
        if (GameObject.Find("ScriptHolder").GetComponent <LevelScript>().TorchNumber == 0)        //if all torches are dead, don't do anything but speak
        {
            DialogueScript.CombatTextEnemy("The darkness is the best isn't it?");
        }
        else
        {
            int randomText = Random.Range(0, 3);            //for picking a text

            if (randomText == 1)
            {
                DialogueScript.CombatTextEnemy("Dagur shall stay here forever!");
            }
            else if (randomText == 2)
            {
                DialogueScript.CombatTextEnemy("The sun will never rise!");
            }
            else
            {
                DialogueScript.CombatTextEnemy("Let there be darkness!");
            }

            yield return(new WaitForSeconds(3));

            DialogueScript.GameInformationText("One of the torches flickers");
            GameObject.Find("ScriptHolder").GetComponent <LevelScript>().TorchCountdown += 20;      //add to the tourchcounter
            GameObject.Find("ScriptHolder").GetComponent <LevelScript>().TorchCounter();            //dim one light
        }

        FinishTurn();
    }
Example #4
0
 public void CounterAttack()
 {
     if (OnCooldown("counterattack"))
     {
         return;
     }
     if (PlayerPrefs.GetInt("Level") < 6)
     {
         DialogueScript.ErrorText("Oh, that is something you havn't learnt to do yet.");
         DialogueScript.CombatTextEnemy("The enemy sees an opening, and stikes!");
         ChangeTurn(null, null);
         return;
     }
     if (lastMove != "ShieldBlock")
     {
         DialogueScript.ErrorText("You need to block first!");
     }
     else
     {
         int cm = PlayerPrefs.GetInt("Level");
         if (cm > 3)
         {
             cm = 3;
         }                                 //cant do more than three times stored damage
         DialogueScript.GameInformationText("You see an opening, and strike!");
         EndOfTurn("CounterAttack", 1, Random.Range(storedDamage, storedDamage * cm));
     }
     //Do a quick attack for x damage after blocking an attack
     lastMove     = "CounterAttack";
     storedDamage = 0;
 }
Example #5
0
 public void Cleave()
 {
     if (OnCooldown("cleave"))
     {
         return;
     }
     lastMove = "Cleave";
     //Do a vertical cleave for x damage
     if (PlayerPrefs.GetInt("Level") < 4)
     {
         DialogueScript.ErrorText("You're not quite sure how to do that yet.");
         DialogueScript.ErrorText("Maybe after a couple more battles");
         DialogueScript.CombatTextEnemy("You space out a bit, and the enemy strikes!");
         ChangeTurn(null, null);
         return;
     }
     if (chargeAmount <= 0)
     {
         DialogueScript.GameInformationText("You fill up with rage.");
         DialogueScript.GameInformationText("Next turn you can do the attack!");
         EndOfTurn("Cleave", 1, 0);
         chargeAmount = 3;
     }
     else
     {
         chargeAmount = 0;
         DialogueScript.GameInformationText("You strike the enemy with a heavy hit!");
         EndOfTurn("Cleave", 3, Random.Range(PlayerPrefs.GetInt("Strength") + chargeAmount, PlayerPrefs.GetInt("Strenght") + PlayerPrefs.GetInt("Level") + chargeAmount));
     }
 }
Example #6
0
    public void StrainSlash()
    {
        if (OnCooldown("strainslash"))
        {
            return;
        }
        lastMove = "StrainSlash";
        if (PlayerPrefs.GetInt("Level") < 8)
        {
            DialogueScript.ErrorText("While you grasp the consept, you still don't know how to do it");
            DialogueScript.CombatTextEnemy("The enemy sees your uncertainty, and strikes!");
            ChangeTurn(null, null);
            return;
        }

        if (PlayerPrefs.GetInt("Strength") > 5)
        {
            DialogueScript.GameInformationText("You strain yourself in the attack!");
            DialogueScript.GameInformationText("You feel weaker.");
            PlayerPrefs.SetInt("Strenght", PlayerPrefs.GetInt("Strenght") - 1);             //-1 permanent strenght
            EndOfTurn("StrainSlash", 3, Random.Range((PlayerPrefs.GetInt("Strength") + 1) * 2,
                                                     (PlayerPrefs.GetInt("Strenght") + 1 + PlayerPrefs.GetInt("Level")) * 2));
        }
        else
        {
            DialogueScript.GameInformationText("You are not strong enough for this anymore.");
            DialogueScript.GameInformationText("Try a different attack");
        }
    }
Example #7
0
 void Block()
 {
     if (cowardness > 17)
     {
         cowardness -= 3;
     }                                                                                            //make it less likley to block
     GameObject.FindGameObjectWithTag("Player").GetComponent <WarriorClass>().storedDamage = 0;   //so counterattack does 0 damage
     DialogueScript.CombatTextEnemy("The " + enemyName.ToLower() + " prepares for your attack."); //what did the enemy do
     isBlocking = true;                                                                           //saves last action
     FinishTurn();
 }
Example #8
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();
    }
Example #9
0
    void Swing()
    {
        int damage = Random.Range(Mathf.CeilToInt(strenght * 0.75f), Mathf.RoundToInt(strenght * 1.25f));      //some damage

        GameObject.FindGameObjectWithTag("Player").GetComponent <WarriorClass>().storedDamage = damage;        //used for counterattack
        if (lastPlayerCommand == "ShieldBlock")
        {
            DialogueScript.CombatTextEnemy("The " + enemyName.ToLower() + " " + attackPattern + " you, but you block the damage.");
        }
        else
        {
            PlayerPrefs.SetInt("Health", PlayerPrefs.GetInt("Health") - damage);                                                    //damage the player
            DialogueScript.CombatTextEnemy("The " + enemyName.ToLower() + " " + attackPattern + " you for " + damage + " damage!"); //damage done
        }
        Animate();
        FinishTurn();
    }
Example #10
0
    IEnumerator DoDamage(int damage, string ability)
    {
        if (!PlayerScript)
        {
            PlayerScript = GetComponent <Player>();
        }

        GameObject enemyGameObject = CommandScript.GetRaycastObject();
        var        enemyScript     = enemyGameObject.GetComponent <EnemyScript>();

        yield return(new WaitForSeconds(1));

        if (damage == 0)
        {
            enemyScript.PlayerMissed();
            yield break;
        }
        if (enemyGameObject.GetComponent <EnemyCombat>().isBlocking == false)
        {
            int damageDone = CalculateDamage(damage);
            GameObject.FindGameObjectWithTag("Weapon").GetComponent <AudioSource>().Play();
            if (enemyGameObject.name != "BallOfDarkness")
            {
                enemyGameObject.GetComponent <AudioSource>().Play();
            }
            if (ability == "Slam")
            {
                enemyScript.CheckHealth(damageDone, ability);
            }
            else
            {
                enemyScript.CheckHealth(damageDone, ability);
            }
            GameObject.FindGameObjectWithTag("UI").GetComponent <InterfaceScript>().ShowDamage(damageDone);
        }
        else
        {
            DialogueScript.CombatTextEnemy("The enemy blocks your attack");
            GameTurnController.CurrentState = GameTurnController.PlayerState.EnemyCombatTurn;
            enemyGameObject.GetComponent <EnemyCombat>().StartTurn();
        }
    }
Example #11
0
    public void Slam()
    {
        if (OnCooldown("slam"))
        {
            return;
        }
        lastMove = "Slam";
        int damageToWeapon = Random.Range(0, 2);

        if (PlayerPrefs.GetInt("Level") < 2)
        {
            DialogueScript.ErrorText("I think you're trying to do something you've not learned yet.");
            DialogueScript.CombatTextEnemy("Your confusing face makes the foe ready to strike.");
            ChangeTurn(null, null);
            return;
        }
        DialogueScript.GameInformationText("You slam your weapon hard into the enemy, stunning him!");
        if (PlayerPrefs.GetInt("StrenghtWeaponBuff") > 0 && damageToWeapon > 2)
        {
            PlayerPrefs.SetInt("StrengthWeaponBuff", PlayerPrefs.GetInt("StrenghtWeaponBuff") - damageToWeapon);
            DialogueScript.GameInformationText("Your weapon dulls in with your attack.");
        }
        EndOfTurn("Slam", 3, Random.Range(PlayerPrefs.GetInt("Strength") / 2, PlayerPrefs.GetInt("Strenght")));
    }