Beispiel #1
0
    protected override void Update()
    {
        Vector3 direction = enemyAttack.TargetPosition - this.transform.position;
        float   distance  = direction.magnitude;

        move.SetDirectionVector(Vector3.zero);

        if (distance <= lookRadius)
        {
            Rotate(direction.x, direction.z);
            if (distance <= enemyAttack.AttackRadius)
            {
                if (Time.time >= nextTimeToAttack)
                {
                    enemyAttack.AttackTarget();
                    nextTimeToAttack = Time.time + enemyAttack.AttackRate;
                }
            }
            else
            {
                direction.Normalize();
                direction.y = 0f;
                move.SetDirectionVector(direction);
            }
        }
        else
        {
            RandomMovement();
        }

        RandomJump();
    }
 private void AttackPlayer()
 {
     currentState = EnemyState.attacking;
     attack.AttackTarget(pjBoy.gameObject);
     StopMovement();
     currentState = EnemyState.onTimeout;
     Invoke("LiftTimeout", timeoutAfterAttack);
 }
Beispiel #3
0
    public void Update()
    {
        if (visibleTargets == null)
        {
            return;
        }

        if (visibleTargets.Count > 0)
        {
            foreach (Transform t in visibleTargets)
            {
                attackEnemy.AttackTarget(t);
            }
        }
    }