예제 #1
0
    // flag 用于判断,当前格挡状态是成功还是失败
    public void endParry(bool flag)
    {
        if (flag)
        {
            // 格挡成功
            PlayerAudioCtrl.getInstance().play(PlayerAudioData.PARRY_CLIP, () => {
                if (!_firstSuccess)
                {
                    _owner.setState(PlayerState.Idle);
                }
            });

            // 成功格挡次数 + 1
            _parrySuccessCount++;
            if (getSwordRemainCount() == 1)
            {
                PlayerAudioCtrl.getInstance().play(PlayerAudioData.SWORD_WILL_BREAK_CLIP);
            }

            // 播放初次格挡成功音效
            if (_firstSuccess)
            {
                PlayerAudioCtrl.getInstance().play(PlayerAudioData.ESCAPE_CLIP, () => {
                    _firstSuccess = false;
                    _owner.setState(PlayerState.Idle);
                });
            }

            _isParry = false;
            ProjectUtils.Log("Parry Success");
        }
        else
        {
            PlayerAudioCtrl.getInstance().play(PlayerAudioData.HURT_CLIP, () => {
                if (_owner.getLife() != 2)
                {
                    _owner.setLife(-1);
                }
            });

            if (_owner.getLife() == 2)
            {
                PlayerAudioCtrl.getInstance().play(PlayerAudioData.EXCITATION_CLIP, () => {
                    _owner.setState(PlayerState.Idle);
                    _owner.setLife(-1);
                });
            }

            _isParry = false;
            ProjectUtils.Log("Parry Failed");
        }

        _owner.switchGestureToMove();
        _sliderBar.value       = 0;
        _sliderFillImage.color = Color.white;
    }