Ejemplo n.º 1
0
 public void ApplyDamage(float damage)
 {
     // if we died don't execute the rest of the code
     if (is_Dead)
     {
         return;
     }
     if (is_Player)
     {
         current_health -= damage;
         //player_script.playerHurt();
     }
     if (is_Scarab)
     {
         enemy_script.Damaged();
         current_health -= damage;
     }
     // Vemos si es boss y si no está haciendo alguno de sus ataques para quitarle vida
     if (is_Boss && !boss_Anim.GetAnim().GetCurrentAnimatorStateInfo(0).IsName("Smash Attack") && !boss_Anim.GetAnim().GetCurrentAnimatorStateInfo(0).IsName("Stab Attack"))
     {
         boss_Anim.TakeDamage();
         current_health -= damage;
     }
     if (current_health <= 0f)
     {
         if (is_Player)
         {
             Cursor.lockState = CursorLockMode.None;
             StartCoroutine(changeGameOverScene("gameOver"));
         }
         if (is_Scarab)
         {
             enemy_script.Dead();
         }
         if (is_Boss)
         {
             Debug.Log("BOSS DIES");
             StartCoroutine(changeGameOverScene("victory"));
             boss_Anim.Die();
         }
         is_Dead = true;
     }
 }
Ejemplo n.º 2
0
    void Update()
    {
        if (boss_Anim.GetAnim().GetCurrentAnimatorStateInfo(0).IsName("Idle"))
        {
            if (audio.clip != boss_audio)
            {
                audio.clip = boss_audio;
                audio.Play();
                audio.loop = true;
            }
        }
        if (boss_Anim.GetAnim().GetCurrentAnimatorStateInfo(0).IsName("Run Forward") || boss_Anim.GetAnim().GetCurrentAnimatorStateInfo(0).IsName("Return"))
        {
            if (audio.clip != walk_audio)
            {
                audio.clip = walk_audio;
                audio.Play();
                audio.loop = true;
            }
        }
        if (boss_Anim.GetAnim().GetCurrentAnimatorStateInfo(0).IsName("Stab Attack"))
        {
            if (audio.clip == pre_hit_audio)
            {
                audio.clip = hit_audio;
                audio.Play();
                Player.transform.GetChild(1).transform.GetComponent <HealthScript>().ApplyDamage(damage);
            }
            if (audio.clip != hit_audio)
            {
                audio.clip = pre_hit_audio;
                audio.Play();
                audio.loop = false;
            }
        }
        if (boss_Anim.GetAnim().GetCurrentAnimatorStateInfo(0).IsName("Smash Attack"))
        {
            if (audio.clip == pre_smash_audio)
            {
                audio.clip = smash_audio;
                audio.Play();
                Player.transform.GetChild(1).transform.GetComponent <HealthScript>().ApplyDamage(damage);
            }
            if (audio.clip != smash_audio)
            {
                audio.clip = pre_smash_audio;
                audio.Play();
                audio.loop = false;
            }
        }

        if (boss_Anim.GetAnim().GetCurrentAnimatorStateInfo(0).IsName("Die"))
        {
            if (audio.clip != hurt_audio)
            {
                audio.clip = hurt_audio;
                audio.Play();
                audio.loop = false;
                Destroy(gameObject, 1F);
            }
        }
    }