示例#1
0
        private void skidsound(bool SS)
        {
            bool  on_whell_sound      = LRWheel.onGround || RRWheel.onGround;
            float carspeed            = GetWheelsSpeed();
            MapObjectAttachedSound HB = GetAttachedObjectByAlias("Hand_brake") as MapObjectAttachedSound;

            if (HB == null)
            {
                return;
            }
            if (!SS)
            {
                HB.Volume = 0; return;
            }
            float hb = 0;

            MathFunctions.Clamp(ref hb, 0, 1);
            if (carspeed > 10 & on_whell_sound)
            {
                hb = carspeed / 30;
            }
            HB.Volume = hb;
        }
示例#2
0
        public void SoundPlay3D( string name, float priority, bool needAttach )
        {
            if( string.IsNullOrEmpty( name ) )
                return;

            if( EngineApp.Instance.DefaultSoundChannelGroup != null &&
                EngineApp.Instance.DefaultSoundChannelGroup.Volume == 0 )
                return;

            //2d sound mode for FPS Camera Player
            PlayerIntellect playerIntellect = PlayerIntellect.Instance;

            if( playerIntellect != null && playerIntellect.FPSCamera &&
                 playerIntellect.ControlledObject != null &&
                 playerIntellect.ControlledObject == GetParentUnit() )
            {
                Sound sound = SoundWorld.Instance.SoundCreate( name, 0 );
                if( sound != null )
                {
                    SoundWorld.Instance.SoundPlay( sound, EngineApp.Instance.DefaultSoundChannelGroup,
                        priority );
                }
                return;
            }

            //Default 3d mode
            {
                if( !needAttach )
                {
                    Sound sound = SoundWorld.Instance.SoundCreate( name, SoundMode.Mode3D );
                    if( sound == null )
                        return;

                    VirtualChannel channel = SoundWorld.Instance.SoundPlay( sound,
                        EngineApp.Instance.DefaultSoundChannelGroup, priority, true );
                    if( channel != null )
                    {
                        channel.Position = Position;
                        channel.Pause = false;
                    }
                }
                else
                {
                    MapObjectAttachedSound attachedSound = new MapObjectAttachedSound();
                    attachedSound.SetSoundName( name, false );
                    Attach( attachedSound );
                }
            }
        }
示例#3
0
文件: Dynamic.cs 项目: whztt07/SDK
        public void SoundPlay3D( string name, float priority, bool needAttach )
        {
            if( string.IsNullOrEmpty( name ) )
                return;

            if( EngineApp.Instance.DefaultSoundChannelGroup != null &&
                EngineApp.Instance.DefaultSoundChannelGroup.Volume == 0 )
                return;

            string nameFullPath = RelativePathUtils.ConvertToFullPath(
                Path.GetDirectoryName( Type.FilePath ), name );

            //2d sound mode for FPS Camera Player
            PlayerIntellect playerIntellect = PlayerIntellect.Instance;

            if( playerIntellect != null && playerIntellect.FPSCamera &&
                 playerIntellect.ControlledObject != null &&
                 playerIntellect.ControlledObject == GetParentUnit() )
            {
                Sound sound = SoundWorld.Instance.SoundCreate( nameFullPath, 0 );
                if( sound != null )
                {
                    SoundWorld.Instance.SoundPlay( sound, EngineApp.Instance.DefaultSoundChannelGroup,
                        priority );
                }
                return;
            }

            //Default 3d mode
            {
                if( !needAttach )
                {
                    Sound sound = SoundWorld.Instance.SoundCreate( nameFullPath, SoundMode.Mode3D );
                    if( sound == null )
                        return;

                    VirtualChannel channel = SoundWorld.Instance.SoundPlay( sound,
                        EngineApp.Instance.DefaultSoundChannelGroup, priority, true );
                    if( channel != null )
                    {
                        channel.Position = Position;
                        switch( Type.SoundRolloffMode )
                        {
                        case DynamicType.SoundRolloffModes.Logarithmic:
                            channel.SetLogarithmicRolloff( Type.SoundMinDistance, Type.SoundMaxDistance,
                                Type.SoundRolloffLogarithmicFactor );
                            break;
                        case DynamicType.SoundRolloffModes.Linear:
                            channel.SetLinearRolloff( Type.SoundMinDistance, Type.SoundMaxDistance );
                            break;
                        }
                        channel.Pause = false;
                    }
                }
                else
                {
                    MapObjectAttachedSound attachedSound = new MapObjectAttachedSound();
                    attachedSound.RolloffMode = (MapObjectAttachedSound.RolloffModes)Type.SoundRolloffMode;
                    attachedSound.MinDistance = Type.SoundMinDistance;
                    attachedSound.MaxDistance = Type.SoundMaxDistance;
                    attachedSound.RolloffLogarithmicFactor = Type.SoundRolloffLogarithmicFactor;
                    attachedSound.SetSoundName( nameFullPath, false );
                    Attach( attachedSound );
                }
            }
        }