Esempio n. 1
0
 internal void Update()
 {
     _onWaterEnterRipplesSoundEffect.Update();
     _onWaterEnterRipplesParticleEffect.Update();
     _onWaterExitRipplesSoundEffect.Update();
     _onWaterExitRipplesParticleEffect.Update();
 }
        internal void Update()
        {

#if UNITY_EDITOR
            if (!Application.isPlaying)
                return;
#endif

            _soundEffect.Update();
            _particleEffect.Update();
        }
        internal void Update()
        {
#if UNITY_EDITOR
            if (!Application.isPlaying)
            {
                return;
            }
#endif

            _onWaterEnterRipplesSoundEffect.Update();
            _onWaterEnterRipplesParticleEffect.Update();
            _onWaterExitRipplesSoundEffect.Update();
            _onWaterExitRipplesParticleEffect.Update();
        }
Esempio n. 4
0
 internal void Update()
 {
     _soundEffect.Update();
     _particleEffect.Update();
 }
Esempio n. 5
0
        internal void Update()
        {
#if UNITY_EDITOR
            if (!Application.isPlaying)
            {
                return;
            }
#endif

            _soundEffect.Update();
            _particleEffect.Update();

            if (!_isActive || (!_updateWhenOffscreen && !_mainModule.IsWaterVisible))
            {
                return;
            }

            _elapsedTime += Time.deltaTime;

            if (_elapsedTime >= _currentInterval)
            {
                if (_randomizeRipplesSourcePositions)
                {
                    RandomizeIndices();
                }

                int surfaceVerticesCount = _meshModule.SurfaceVerticesCount;
                int startIndex           = _simulationModule.IsUsingCustomBoundaries ? 1 : 0;
                int endIndex             = _simulationModule.IsUsingCustomBoundaries ? surfaceVerticesCount - 2 : surfaceVerticesCount - 1;

                Vector3[] vertices   = _meshModule.Vertices;
                float[]   velocities = _simulationModule.Velocities;

                bool playSoundEffect    = _soundEffect.IsActive;
                bool playParticleEffect = _particleEffect.IsActive;

                for (int i = 0, imax = _ripplesSourcesIndices.Count; i < imax; i++)
                {
                    int index = _ripplesSourcesIndices[i];

                    float disturbance = _randomizeDisturbance ? Random.Range(_minimumDisturbance, _maximumDisturbance) : _disturbance;

                    disturbance *= _simulationModule.StiffnessSquareRoot;

                    velocities[index] -= disturbance;

                    if (_smoothRipples)
                    {
                        float smoothedDisturbance = disturbance * _smoothingFactor;
                        int   previousIndex, nextIndex;
                        previousIndex = index - 1;
                        nextIndex     = index + 1;

                        if (previousIndex >= startIndex)
                        {
                            velocities[previousIndex] -= smoothedDisturbance;
                        }

                        if (nextIndex <= endIndex)
                        {
                            velocities[nextIndex] -= smoothedDisturbance;
                        }
                    }

                    if (_soundEffect.IsActive || _particleEffect.IsActive)
                    {
                        Vector3 spawnPosition = _mainModule.TransformLocalToWorld(vertices[index]);

                        if (playParticleEffect)
                        {
                            _particleEffect.PlayParticleEffect(spawnPosition);
                        }

                        if (playSoundEffect)
                        {
                            float disturbanceFactor = Mathf.InverseLerp(_minimumDisturbance, _maximumDisturbance, disturbance);
                            _soundEffect.PlaySoundEffect(spawnPosition, disturbanceFactor);
                        }
                    }
                }

                _currentInterval = _randomizeTimeInterval ? Random.Range(_minimumTimeInterval, _maximumTimeInterval) : _timeInterval;
                _elapsedTime     = 0f;

                _simulationModule.MarkVelocitiesArrayAsChanged();
            }
        }