Пример #1
0
            public void Initialize(PlayerFoleyAsset foley)
            {
                _time      = foley ? foley.breathing.GetInitialDelay() : 0f;
                _period    = 0f;
                _state     = 1;
                _pace      = 0f;
                _intensity = 0f;

                _setType      = BreathType.Normal;
                _setPace      = 0f;
                _setIntensity = 0f;
            }
Пример #2
0
            public bool Update(
                PlayerFoleyAsset foley, float intensity, BreathType type, bool isJumping,
                out AxelF.Patch asset, out float volume)
            {
                if (foley && _state != 0)
                {
                    float deltaTime = Time.deltaTime;

                    if (isJumping)
                    {
                        deltaTime = 0f; // infinite time dilation when jumping to synchronize landing
                    }
                    _intensity += (intensity - foley.breathing.intensityDampening) * deltaTime;
                    _intensity  = Mathf.Clamp01(_intensity);

                    _pace = Mathf.Lerp(
                        _pace, _intensity * _intensity * _intensity,
                        deltaTime * foley.breathing.intensityTransference);

                    _period = foley.breathing.GetBreathingPeriod() -
                              _intensity * foley.breathing.breathingPeriodIntensityFactor;

                    _time -= deltaTime / _period;

                    if (_time <= 0f)
                    {
                        if (inhaling)
                        {
                            _time         = foley.breathing.GetExhalePeriod();
                            _setType      = type;
                            _setPace      = _pace;
                            _setIntensity = _intensity;
                        }
                        else
                        {
                            _time  = foley.breathing.GetInhalePeriod();
                            _time -= _time * _setPace * foley.breathing.inhalePeriodPacingFactor;
                        }
                        asset  = foley.breathing.GetAsset(_setType, _setPace, _setIntensity, inhaling);
                        volume = foley.breathing.GetVolumeOverPace();
                        volume = Mathf.Clamp01(volume + _pace * volume);
                        _state = -_state;
                        return(true);
                    }
                }
                asset  = null;
                volume = 0f;
                return(false);
            }
Пример #3
0
        AxelF.Patch GetFootstepAsset(
            PlayerFoleyAsset foley, Vector3 position, PhysicMaterial physicalMaterial,
            float speedScalar, VegetationType type, bool landing = false)
        {
            var  footstep = default(PlayerFoleyAsset.Footstep);
            int  footstepIndex;
            bool validFootstep = false;

            if (physicalMaterial != null)
            {
                if (_materialMap.TryGetValue(physicalMaterial, out footstepIndex))
                {
                    footstep      = foley.footsteps[footstepIndex];
                    validFootstep = true;
                }
            }

            if (!validFootstep)
            {
                var terrainFoley = TerrainFoleyManager.current;
                footstepIndex = _foleyMap.GetFoleyIndexAtPosition(position, terrainFoley.splatMap);
                footstep      = foley.footsteps[footstepIndex];
                validFootstep = true;
            }

            Debug.Assert(validFootstep);

            bool running = speedScalar >= 0.7f;
            bool jogging = !running && speedScalar >= 0.2f;

            var asset =
                type == VegetationType.None ?
                (landing ? footstep.landing :
                 running ? footstep.running :
                 jogging ? footstep.jogging :
                 footstep.walking) :
                type == VegetationType.Undergrowth ?
                (running ? footstep.runningUndergrowth :
                 jogging ? footstep.joggingUndergrowth :
                 footstep.walkingUndergrowth) :
                null;

            return(asset);
        }