Example #1
0
    // Update is called once per frame
    void Update()
    {
        if (isDead || player == null || playerController.isDead || !playerController.CanMove())
        {
            return;
        }

        //武器位置冻结
        if (weaponStandardAction.isActionFreeze)
        {
            weaponStandardAction.FreezeAction();
        }
        else
        {
            //不打断正在进行的动作
            weaponStandardAction.continueAction();
            if (weaponStandardAction.isActionOver)
            {
                float distance = (player.transform.position - transform.position).magnitude;
                if (weaponStandardAction.isPreAttackPosture() && distance < 4)
                {
                    //攻击
                    weaponStandardAction.Attack();
                    StartCoroutine(AttackActionCooldown());
                }
                else if (attackCooldownOver && distance < 5)
                {
                    //靠近玩家准备攻击
                    weaponStandardAction.PreAttack();
                }
                else if (changeCooldownOver && distance < 8)
                {
                    //切换姿态
                    ChangeAction();
                    StartCoroutine(ChangeActionCooldown());
                }

                transform.LookAt(player.transform);
                if (playerController.CanMove() && !playerController.isOutFirstCircle)
                {
                    //靠近玩家
                    if (distance > 2.5)
                    {
                        transform.Translate(Vector3.forward * moveSpeed * Time.deltaTime);
                    }
                    else if (distance < 1.5)
                    {
                        transform.Translate(Vector3.back * moveSpeed / 2 * Time.deltaTime);
                    }
                }
            }
        }
    }
Example #2
0
    void Update()
    {
        if (!CanMove())
        {
            return;
        }

        if (getGameManager().pressR2Refresh)
        {
            checkPressR(false);
        }

        if (isDead)
        {
            checkPressR(true);
            return;
        }

        Move();
        Rotate();

        //武器位置冻结
        if (weaponStandardAction.isActionFreeze)
        {
            weaponStandardAction.FreezeAction();
        }
        else
        {
            //不打断正在进行的动作
            weaponStandardAction.continueAction();
            if (weaponStandardAction.isActionOver)
            {
                WeaponAction();
            }
        }
    }