public void EnemyAtack() {//controle do ataque d inimigo if ((Gamecontroller.PlayerTransform.position.x - transform.position.x <= 5 && !IsLookLeft) || (transform.position.x - Gamecontroller.PlayerTransform.position.x <= 5 && IsLookLeft)) { Gamecontroller.PlaySFX(Gamecontroller.SfxAtack); NpcAnimator.SetTrigger("Atack"); CanAtack = false; } }
public void OnTriggerEnter(Collider collision) {//controle de colisção com os ataques da personagem if (collision.CompareTag("HitBoxCollider") && !IsHit && !IsDead) { IsHit = true; IsWalking = false; switch (gameObject.tag) { case "Enemy": //se for um inimigo comum EnemyTotalLife -= 1; Gamecontroller.EnemyHeartController((int)EnemyTotalLife); Gamecontroller.TimerEnemyBar = 3f; break; case "Boss": //se for um chefe o dano é menor EnemyTotalLife -= 0.5f; Gamecontroller.BossHeartController(EnemyTotalLife); break; } Gamecontroller.PlaySFX(Gamecontroller.SfxDamageTaken); if (EnemyTotalLife <= 0)//verifica se a vida zerou para a animação de morte { IsDead = true; if (gameObject.CompareTag("Boss")) { Gamecontroller.PlaySFX(Gamecontroller.SfxBossDead); } else { Gamecontroller.PlaySFX(Gamecontroller.SfxEnemyDead); } NpcAnimator.SetTrigger("IsDead"); } else//se a vida não zerou inicia a animação de ter tomado dano { NpcAnimator.SetTrigger("Hitted"); IsHit = false; } } }