Пример #1
0
    public override void Execute(GameObject gameObject)
    {
        AT_Enemy enemy = gameObject.GetComponent <AT_Enemy>();

        if (enemy.IsTargetWithinAttackDistance())
        {
            StopCoroutine(Chase(enemy));
            enemy.GetAgent().velocity  = Vector3.zero;
            enemy.GetAgent().isStopped = true;
            enemy.GetStateMachine().SetState(AttackState.Instance);
        }
        else
        {
            enemy.MoveTowardsTargetPosition();
        }
    }
Пример #2
0
    public override void Execute(GameObject gameObject = null)
    {
        AT_Enemy enemy = gameObject.GetComponent <AT_Enemy>();

        if (!enemy.IsTargetWithinAttackDistance() && !enemy.isAttacking)
        {
            enemy.GetStateMachine().SetState(ChaseState.Instance);
        }
        else
        {
            if (!enemy.isAttacking)
            {
                enemy.MyAnimator.SetTrigger("Attack");
                int attack = Random.Range(1, 4);
                enemy.MyAnimator.SetTrigger("Attack" + attack);
                enemy.StartCoroutine("WaitForNextAttack");
            }
        }
    }