Exemple #1
0
        private void UpdateRain()
        {
            if (Game.GameTime.IsOnPause)
            {
                RainFallParticleSystem.Pause(true);
                RainExplosionParticleSystem.Pause(true);
                RainMistParticleSystem.Pause(true);

                volume = Mathf.Lerp(volume, 0.0f, Time.deltaTime * VolumeChangeSpeed);
                audioSourceRainCurrent.AudioSource.volume = volume;
                audioSourceRainLight.AudioSource.volume   = volume;
                audioSourceRainMedium.AudioSource.volume  = volume;
                audioSourceRainHeavy.AudioSource.volume   = volume;
            }
            else
            {
                RainFallParticleSystem.Play(true);
                RainExplosionParticleSystem.Play(true);
                RainMistParticleSystem.Play(true);
                volume = Mathf.Lerp(volume, 0.5f, Time.deltaTime * VolumeChangeSpeed);
                audioSourceRainCurrent.AudioSource.volume = volume;
                audioSourceRainLight.AudioSource.volume   = volume;
                audioSourceRainMedium.AudioSource.volume  = volume;
                audioSourceRainHeavy.AudioSource.volume   = volume;
            }
            // keep rain and mist above the player
            if (RainFallParticleSystem != null)
            {
                if (FollowCamera)
                {
                    var s = RainFallParticleSystem.shape;
                    s.shapeType = ParticleSystemShapeType.ConeVolume;
                    RainFallParticleSystem.transform.position = Camera.transform.position;
                    RainFallParticleSystem.transform.Translate(0.0f, RainHeight, RainForwardOffset);
                    RainFallParticleSystem.transform.rotation = Quaternion.Euler(0.0f, Camera.transform.rotation.eulerAngles.y, 0.0f);
                    if (RainMistParticleSystem != null)
                    {
                        var s2 = RainMistParticleSystem.shape;
                        s2.shapeType = ParticleSystemShapeType.HemisphereShell;
                        Vector3 pos = Camera.transform.position;
                        pos.y += RainMistHeight;
                        RainMistParticleSystem.transform.position = pos;
                    }
                }
                else
                {
                    var s = RainFallParticleSystem.shape;
                    s.shapeType = ParticleSystemShapeType.Box;
                    if (RainMistParticleSystem != null)
                    {
                        var s2 = RainMistParticleSystem.shape;
                        s2.shapeType = ParticleSystemShapeType.Box;
                        Vector3 pos = RainFallParticleSystem.transform.position;
                        pos.y += RainMistHeight;
                        pos.y -= RainHeight;
                        RainMistParticleSystem.transform.position = pos;
                    }
                }
            }
        }
Exemple #2
0
 protected override void Start()
 {
     RainFallParticleSystem.Play();
     base.Start();
 }