Exemplo n.º 1
0
        void Update()
        {
            float expend = _energyExpendSpeed * Time.deltaTime;

            if (_effect.activeSelf)
            {
                // 灯开着的时候, 驾驶员关闭了开关或没能量了都需要关灯
                if (!_controller.isLightOn || !_controller.isEnergyEnough(expend))
                {
                    _effect.SetActive(false);
                }
                else
                {
                    // 主控端消耗能量
                    if (_controller.isPlayerHost)
                    {
                        _controller.ExpendEnergy(expend);
                    }
                }
            }
            else
            {
                // 灯关着的时候, 驾驶员打开了开关并且有能量才可以打开
                if (_controller.isLightOn && _controller.isEnergyEnough(expend))
                {
                    _effect.SetActive(true);
                }
            }
        }
Exemplo n.º 2
0
        void FixedUpdate()
        {
            float expend = _energyExpendSpeed * Time.deltaTime;

            if (_effect.activeSelf)
            {
                // 推进器开着的时候, 驾驶员关闭了开关 | 没能量 都需要关闭
                if (!_controller.isJetting || !_controller.isEnergyEnough(expend))
                {
                    _effect.SetActive(false);
                }
                else
                {
                    _controller.rigidbody.AddForce(transform.forward * _pushForce * _controller.speedScale);

                    // 主控端消耗能量
                    if (_controller.isPlayerHost)
                    {
                        _controller.ExpendEnergy(expend);
                    }
                }

                _sound.volume = _volume * SystemSettingData.Instance.AbsEffectVolume;
            }
            else
            {
                // 推进器关着的时候, 驾驶员打开了开关 & 有能量 才可以打开
                if (_controller.isJetting && _controller.isEnergyEnough(expend))
                {
                    _effect.SetActive(true);

                    _sound.volume = _volume * SystemSettingData.Instance.AbsEffectVolume;
                    _sound.time   = 0f;
                    _sound.Play();
                }

                _sound.volume -= _volume * Time.deltaTime * SystemSettingData.Instance.AbsEffectVolume;
            }
        }