Пример #1
0
 void Update()
 {
     if (status.IsDead())
     {
         Die();
     }
     else
     {
         float distanceToPlayer = (new Vector2(transform.position.x, transform.position.z) - new Vector2(player.position.x, player.position.z)).sqrMagnitude;
         if (distanceToPlayer < AggroDistance)
         {
             Aggro();
         }
         else
         {
             DeAggro();
         }
     }
 }
Пример #2
0
 void OnTriggerEnter(Collider collider)
 {
     if (status.IsDead())
     {
         return;
     }
     if (collider.gameObject.tag == Helpers.Tags.Player)
     {
         collider.gameObject.GetComponent <PlayerDamageManager>().BumpedEnemy();
     }
 }
Пример #3
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));
            }
        }
    }