Beispiel #1
0
        public override void Update(GameTime gameTime)
        {
            base.Update(gameTime);

            if (ParentShip.RigidBody.LinearVelocity.LengthSquared() > 1)
            {
                if (soundEffectInstance == null || soundEffectInstance.State == SoundState.Stopped)
                {
                    soundEffectInstance        = EngineSoundEffect.CreateInstance();
                    soundEffectInstance.Volume = Options.SFXVolume;
                    soundEffectInstance.Play();
                }
            }
            else
            {
                if (soundEffectInstance != null)
                {
                    soundEffectInstance.Stop();
                }

                soundEffectInstance = null;
            }

            EngineBlaze.Update(gameTime);
        }
Beispiel #2
0
        public static EngineSoundEffect CopyEngineSoundEffect(EngineSoundEffect template, EngineSoundEffect target)
        {
            target.m_minPitch = template.m_minPitch;
            target.m_minRange = template.m_minRange;
            target.m_pitchAccelerationMultiplier = template.m_pitchAccelerationMultiplier;
            target.m_pitchSpeedMultiplier        = template.m_pitchSpeedMultiplier;
            target.m_position = template.m_position;
            target.m_range    = template.m_range;
            target.m_rangeAccelerationMultiplier = template.m_rangeAccelerationMultiplier;
            target.m_rangeSpeedMultiplier        = template.m_rangeSpeedMultiplier;
            target.m_audioInfo = template.m_audioInfo;

            return(target);
        }
        public static EffectInfo CreateEffectObject(Transform parent)
        {
            EngineSoundEffect defaultEngineSound = VehicleEffectsMod.FindEffect("Train Movement") as EngineSoundEffect;

            if (defaultEngineSound != null)
            {
                GameObject obj = new GameObject(effectName);
                obj.transform.parent = parent;

                EngineSoundEffect newSoundEffect = Util.CopyEngineSoundEffect(defaultEngineSound, obj.AddComponent <EngineSoundEffect>());
                newSoundEffect.name = effectName;



                // Create a copy of audioInfo
                AudioInfo audioInfo = UnityEngine.Object.Instantiate(defaultEngineSound.m_audioInfo) as AudioInfo;

                audioInfo.name     = effectName;
                audioInfo.m_volume = 0.8f;

                // Load new audio clip

                var clip = Util.LoadAudioClipFromModDir("Sounds/rolling-stock-moving.ogg");

                if (clip != null)
                {
                    audioInfo.m_clip = clip;
                }
                else
                {
                    return(null);
                }

                newSoundEffect.m_audioInfo = audioInfo;


                //defaultEngineSound.m_audioInfo = audioInfo;


                return(newSoundEffect);
            }
            else
            {
                Logging.LogError("Could not find default train sound effect!");
                return(null);
            }
        }