Beispiel #1
0
    private void LookForTarget()
    {
        if (rb2d != null && health > 0)
        {
            RaycastHit2D hit2D = Physics2D.Raycast(transform.position + offset, transform.TransformDirection(rb2d.velocity),
                                                   eyes_Range, eyes_Layer);
            if (hit2D.collider != null)
            {
                if (hit2D.collider.CompareTag("Player") && !attacking && !isWiggleOn)
                {
                    // print("see");
                    hasSpotedPlayer = true;
                    RandomSec       = Random.Range(wiggleMinTime, wiggleMaxTime);
                    target          = hit2D.collider.gameObject;
                    enemySoundManager.PlayOneSound("Snore");
                    state = stateMachine.Wiggle;
                }
            }
            else if (hit2D.collider == null && !isFlying && !isWiggleOn)
            {
                if (target != null && hasSpotedPlayer)
                {
                    animator.SetBool("isAttacking", false);
                    targetLastSeen_posX = target.transform.position.x;
                    state = stateMachine.Chase;
                    return;
                }
                chaseTimer     = 0;
                moveSpeed      = Mathf.Lerp(moveSpeed, 1f, 5f * Time.deltaTime);
                animator.speed = Mathf.Lerp(moveSpeed, 1f, 5f * Time.deltaTime);
                animator.SetBool("isAttacking", false);


                state = stateMachine.roming;
                // print(animator.GetBool("isAttacking"));
            }
            else if (hit2D.collider == null && isFlying)
            {
                state = stateMachine.Flying;
            }
        }
        else
        {
            state = stateMachine.death;
        }
    }
Beispiel #2
0
 public void PlayOneSoundEvaporate()
 {
     enemySoundManager.PlayOneSound("Evaporate");
 }
 public void PlayIdleSoundOne()
 {
     enemySoundManager.PlayOneSound("Idle 1");
 }