示例#1
0
    private void Attack()
    {
        agent.isStopped = true;
        agent.velocity  = Vector3.zero;
        anim.Walk(false);

        attackTimer += Time.deltaTime;

        if (attackTimer > waitBeforeAttack)
        {
            agent.transform.LookAt(targetPos.position);

            if (Random.Range(0, 4) > 1)
            {
                if (Random.Range(0, 3) > 1)
                {
                    anim.Punch1();
                }
                else
                {
                    if (Random.Range(0, 3) < 1)
                    {
                        anim.Punch2();
                    }
                    else
                    {
                        anim.Punch3();
                    }
                }
            }
            else
            {
                anim.QuakeKick();
            }
            attackTimer = 0f;
        }


        if (Vector3.Distance(transform.position, targetPos.position) > attackDistance &&
            Vector3.Distance(transform.position, targetPos.position) < shootRadius)
        {
            enemyAttack = EnemyAttack.SHOOT;
        }

        else if (Vector3.Distance(transform.position, targetPos.position) > shootRadius)
        {
            enemyAttack = EnemyAttack.CHASE;
        }
    }
    } // chase

    void Attack()
    {
        agent.velocity  = Vector3.zero;
        agent.isStopped = true;
        enemyAnim.Walk(false);

        attackTimer += Time.deltaTime;
        if (attackTimer > waitBeforeAttack)
        {
            transform.LookAt(PlayerPos.position);
            if (Random.Range(0, 4) > 1)
            {
                if (Random.Range(0, 3) > 1)
                {
                    enemyAnim.Punch1();
                }
                else
                {
                    if (Random.Range(0, 3) < 1)
                    {
                        enemyAnim.Punch3();
                    }
                    else
                    {
                        enemyAnim.QuakeKick();
                    }
                }
            }
            else
            {
                enemyAnim.Punch2();
            }

            attackTimer = 0f;
        }


        if (Vector3.Distance(transform.position, PlayerPos.position) > attackDistance + waitBeforeChase)
        {
            enemyBehaviour  = EnemyAttackBehaviour.CHASE;
            agent.isStopped = false;
        }
    } // attack
    void Attack()
    {
        if (Input.GetKeyDown(KeyCode.K))
        {
            comboPunch++;
            attackTimer_Reset = true;
            currentTimer      = defaultAttack_Timer;

            if (comboPunch != ComboPunch.PUNCH_3)
            {
                if (comboPunch == ComboPunch.PUNCH_1)
                {
                    attackAnim.Punch1();
                }
                if (comboPunch == ComboPunch.PUNCH_2)
                {
                    attackAnim.Punch2();
                }
            }
        }

        if (Input.GetKeyDown(KeyCode.L))
        {
            if (comboPunch == ComboPunch.PUNCH_1)
            {
                return;
            }

            if (comboPunch == ComboPunch.PUNCH_2)
            {
                comboPunch++;
                attackTimer_Reset = true;
                currentTimer      = defaultAttack_Timer;
            }

            if (comboPunch == ComboPunch.PUNCH_3)
            {
                attackAnim.Punch3();
                comboFinished = true;
            }
        }
    }