예제 #1
0
    void Aggro()
    {
        navAgent.SetDestination(player.position);
        if (status.IsDead() || status.IsAggro())
        {
            return;
        }

        status.AggroOnPlayer();
        navAgent.Resume();
    }
예제 #2
0
    void Update()
    {
        if (status.IsDead())
        {
            Die();
        }
        else if (status.IsFrozen())
        {
            return;
        }
        else
        {
            if (lastShotTime > 0)
            {
                lastShotTime -= Time.deltaTime;
            }

            float distanceToPlayer = (transform.position - player.position).sqrMagnitude;
            if (distanceToPlayer < AggroDistance)
            {
                Aggro();
            }
            else
            {
                DeAggro();
            }

            if (lastShotTime <= 0 && status.IsAggro())
            {
                Shoot();
            }

            if (status.IsAggro())
            {
                transform.LookAt(new Vector3(player.position.x, transform.position.y, player.position.z));
            }
        }
    }