Example #1
0
 private void Update()
 {
     if ((gameObject.transform.position.x - Gamecontroller.PlayerTransform.position.x < 30) && !IsFollow)
     {//alem de iniciar a perseguição ao heroi também toca uma udio próprio
         Gamecontroller.PlaySFX(Gamecontroller.SfxBossAwake);
         IsFollow = true;
         Gamecontroller.BossBar.SetActive(true);//ativa a barra de vida especial de chefe
     }
 }
    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;
            }
        }
    }
    private void SickOut()
    {//retirar o objeto contaminado e chamando a animação própria
        PersonSR.color = Color.white;

        Speed = 20;

        int Rand = Random.Range(0, 50);

        if (Rand < 25)
        {
            Horizontal = -1;
        }
        else
        {
            Horizontal = 1;
        }

        Vertical = 0.0f;
        this.gameObject.layer = LayerMask.NameToLayer("MovingOut");
        Gamecontroller.PlaySFX(Gamecontroller.SfxRescue);
        NpcAnimator.SetBool("IsRescued", IsRescued);
    }