Example #1
0
        /// <summary>
        /// Play music.
        /// </summary>
        /// <param name="fileName">The file name.</param>
        /// <param name="loop">Looping flag.</param>
        public static void MusicPlay(string fileName, bool loop)
        {
            Init();

            if (musicSound != null && string.Compare(musicSound.Name, fileName, true) == 0)
            {
                return;
            }

            MusicStop();

            if (!string.IsNullOrEmpty(fileName) && VirtualFile.Exists(fileName))
            {
                SoundMode mode = SoundMode.Stream;
                if (loop)
                {
                    mode |= SoundMode.Loop;
                }

                musicSound = SoundWorld.Instance.SoundCreate(fileName, mode);

                if (musicSound != null)
                {
                    musicChannel = SoundWorld.Instance.SoundPlay(musicSound, musicChannelGroup, .5f);
                }
            }
        }
 protected override void CommonInit(int uniqueId)
 {
     base.CommonInit(uniqueId);
     m_channelTypeStr = Dummy;
     m_virtualChannel = GetChannel(0);
     ChangeChannels();
     UIUtils.AddVirtualTextureCount();
     m_channelTypeStr = Dummy;
 }
Example #3
0
 protected override void OnDestroy()
 {
     if (motorSoundChannel != null)
     {
         motorSoundChannel.Stop();
         motorSoundChannel = null;
     }
     base.OnDestroy();
 }
Example #4
0
 protected override void OnDestroy()
 {
     //things we should do when helli has been destroyed
     if (rotorSoundChannel != null)
     {
         rotorSoundChannel.Stop();
         rotorSoundChannel = null;
     }
     base.OnDestroy();
 }
Example #5
0
        private void EngineOff()
        {
            //turning off some stuff when you are getting out of jet

            if (rotorSoundChannel != null)
            {
                rotorSoundChannel.Stop();
                rotorSoundChannel = null;
            }
        }
Example #6
0
 protected override void OnDestroy()
 {
     //things we should do when jet destroys
     if (rotorSoundChannel != null)
     {
         rotorSoundChannel.Stop();
         rotorSoundChannel = null;
     }
     base.OnDestroy();
 }
Example #7
0
        private void TickSound()
        {
            bool lastMotorOn = AKJetOn;

            AKJetOn = Intellect != null && Intellect.IsActive();

            //sound on, off
            if (AKJetOn != lastMotorOn)
            {
                if (AKJetOn)
                {
                    Sound sound = SoundWorld.Instance.SoundCreate(Type.SoundOn, SoundMode.Mode3D);
                    if (sound != null)
                    {
                        soundOnChannel = SoundWorld.Instance.SoundPlay(sound, EngineApp.Instance.DefaultSoundChannelGroup, .7f, true);
                        if (soundOnChannel != null)
                        {
                            soundOnChannel.Position = Position;
                            soundOnChannel.Pause    = false;
                        }
                    }
                    //SoundPlay3D(Type.SoundOn, .7f, true);
                }
                else
                {
                    EngineOff();
                    SoundPlay3D(Type.SoundOff, 0.7f, true);
                }
            }

            string needSoundName = null;

            if (AKJetOn)
            {
                needSoundName = Type.SoundIdle;
            }
            if (needSoundName != currentRotorSoundName)
            {
                currentRotorSoundName = needSoundName;

                if (!string.IsNullOrEmpty(needSoundName))
                {
                    Sound sound = SoundWorld.Instance.SoundCreate(needSoundName,
                                                                  SoundMode.Mode3D | SoundMode.Loop);

                    if (sound != null)
                    {
                        rotorSoundChannel = SoundWorld.Instance.SoundPlay(
                            sound, EngineApp.Instance.DefaultSoundChannelGroup, 1, true);
                        rotorSoundChannel.Position = Position;
                        rotorSoundChannel.Pause    = false;
                    }
                }
            }
        }
Example #8
0
        protected override void OnDestroy()
        {
            if (motorSoundChannel != null)
            {
                motorSoundChannel.Stop();
                motorSoundChannel = null;
            }

            ShutdownTracksAnimation();

            base.OnDestroy();
        }
Example #9
0
        /// <summary>
        /// Stop music.
        /// </summary>
        public static void MusicStop()
        {
            if (musicChannel != null)
            {
                musicChannel.Stop();
                musicChannel = null;
            }

            if (musicSound != null)
            {
                musicSound.Dispose();
                musicSound = null;
            }
        }
Example #10
0
        /// <summary>
        /// Stop music.
        /// </summary>
        public static void MusicStop()
        {
            if (musicChannel != null)
            {
                musicChannel.Stop();
                musicChannel = null;
            }

            if (musicSound != null)
            {
                musicSound.Dispose();
                musicSound = null;
            }
        }
Example #11
0
        private void MohiOff()
        {
            //turning off some stuff when you are getting out of helli
            GearedMotor main = PhysicsModel.GetMotor("hellimain") as GearedMotor;
            GearedMotor back = PhysicsModel.GetMotor("helliback") as GearedMotor;

            main.Enabled = false;
            back.Enabled = false;

            if (rotorSoundChannel != null)
            {
                rotorSoundChannel.Stop();
                rotorSoundChannel = null;
            }
        }
Example #12
0
        public SelectSubChannelDlg(VirtualFixture pFixture, VirtualChannel pChannel)
        {
            mFixture = pFixture;
            mChannel = pChannel;

            InitializeComponent();

            this.treeView1.ImageList = new ImageList();
            string FilePath = System.Environment.CurrentDirectory + "\\icons\\white.ico";
            Icon   ico      = new Icon(FilePath);

            this.treeView1.ImageList.Images.Add(ico);

            LoadTree();
        }
        new void ShowDefaults()
        {
            EditorGUI.BeginChangeCheck();
            m_virtualPreset = ( VirtualPreset )EditorGUILayoutEnumPopup(VirtualPresetStr, m_virtualPreset);
            if (EditorGUI.EndChangeCheck())
            {
                ChangeChannels();
            }

            EditorGUI.BeginChangeCheck();
            m_selectedChannelInt = EditorGUILayoutPopup(VirtualChannelStr, m_selectedChannelInt, m_channelTypeStr);
            if (EditorGUI.EndChangeCheck())
            {
                m_virtualChannel = GetChannel(m_selectedChannelInt);
            }
        }
Example #14
0
        private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.RowIndex < 0 || e.ColumnIndex < 0)
            {
                return;
            }

            if (dataGridView1.Columns[e.ColumnIndex].Name == "col_Copy")
            {
                VirtualChannel chan = (VirtualChannel)dataGridView1.Rows[e.RowIndex].Tag;
                if (chan.VirtualType == VirtualChannelType.Copy)
                {
                    SelectSubChannelDlg dlg = new SelectSubChannelDlg((VirtualFixture)mFixture, chan);
                    dlg.ShowDialog(this);
                }
            }
        }
        public override void ReadFromString(ref string[] nodeParams)
        {
            base.ReadFromString(ref nodeParams);
            string textureName = GetCurrentParam(ref nodeParams);

            m_defaultValue        = AssetDatabase.LoadAssetAtPath <Texture>(textureName);
            m_isNormalMap         = Convert.ToBoolean(GetCurrentParam(ref nodeParams));
            m_defaultTextureValue = ( TexturePropertyValues )Enum.Parse(typeof(TexturePropertyValues), GetCurrentParam(ref nodeParams));
            m_autocastMode        = ( AutoCastType )Enum.Parse(typeof(AutoCastType), GetCurrentParam(ref nodeParams));
            m_virtualPreset       = ( VirtualPreset )Enum.Parse(typeof(VirtualPreset), GetCurrentParam(ref nodeParams));
            m_selectedChannelInt  = Convert.ToInt32(GetCurrentParam(ref nodeParams));
            ChangeChannels();
            m_virtualChannel = GetChannel(m_selectedChannelInt);

            m_forceNodeUpdate = true;

            ConfigFromObject(m_defaultValue);
            ConfigureInputPorts();
            ConfigureOutputPorts();
        }
Example #16
0
        /// <summary>
        /// Play music.
        /// </summary>
        /// <param name="fileName">The file name.</param>
        /// <param name="loop">Looping flag.</param>
        public static void MusicPlay( string fileName, bool loop )
        {
            Init();

            if( musicSound != null && string.Compare( musicSound.Name, fileName, true ) == 0 )
                return;

            MusicStop();

            if( !string.IsNullOrEmpty( fileName ) && VirtualFile.Exists( fileName ) )
            {
                SoundMode mode = SoundMode.Stream;
                if( loop )
                    mode |= SoundMode.Loop;

                musicSound = SoundWorld.Instance.SoundCreate( fileName, mode );

                if( musicSound != null )
                    musicChannel = SoundWorld.Instance.SoundPlay( musicSound, musicChannelGroup, .5f );
            }
        }
Example #17
0
        public override void ReadFromString(ref string[] nodeParams)
        {
            base.ReadFromString(ref nodeParams);
            string defaultTextureGUID = GetCurrentParam(ref nodeParams);

            //m_defaultValue = AssetDatabase.LoadAssetAtPath<Texture>( textureName );
            if (UIUtils.CurrentShaderVersion() > 14101)
            {
                m_defaultValue = AssetDatabase.LoadAssetAtPath <Texture>(AssetDatabase.GUIDToAssetPath(defaultTextureGUID));
                string materialTextureGUID = GetCurrentParam(ref nodeParams);
                m_materialValue = AssetDatabase.LoadAssetAtPath <Texture>(AssetDatabase.GUIDToAssetPath(materialTextureGUID));
            }
            else
            {
                m_defaultValue = AssetDatabase.LoadAssetAtPath <Texture>(defaultTextureGUID);
            }
            m_isNormalMap         = Convert.ToBoolean(GetCurrentParam(ref nodeParams));
            m_defaultTextureValue = ( TexturePropertyValues )Enum.Parse(typeof(TexturePropertyValues), GetCurrentParam(ref nodeParams));
            m_autocastMode        = ( AutoCastType )Enum.Parse(typeof(AutoCastType), GetCurrentParam(ref nodeParams));
            m_virtualPreset       = ( VirtualPreset )Enum.Parse(typeof(VirtualPreset), GetCurrentParam(ref nodeParams));
            m_selectedChannelInt  = Convert.ToInt32(GetCurrentParam(ref nodeParams));
            ChangeChannels();
            m_virtualChannel = GetChannel(m_selectedChannelInt);

            //m_forceNodeUpdate = true;

            //ConfigFromObject( m_defaultValue );
            if (m_materialValue == null)
            {
                ConfigFromObject(m_defaultValue);
            }
            else
            {
                CheckTextureImporter(true, true);
            }
            ConfigureInputPorts();
            ConfigureOutputPorts();
        }
Example #18
0
        private void TickMotorSound()
        {
            bool lastMotorOn = motorOn;

            motorOn = Intellect != null && Intellect.IsActive();

            //sound on, off
            if (motorOn != lastMotorOn)
            {
                if (!firstTick && Health != 0)
                {
                    if (motorOn)
                    {
                        Sound sound = SoundWorld.Instance.SoundCreate(Type.SoundOn, SoundMode.Mode3D);
                        if (sound != null)
                        {
                            soundOnChannel = SoundWorld.Instance.SoundPlay(sound, EngineApp.Instance.DefaultSoundChannelGroup, .7f, true);
                            if (soundOnChannel != null)
                            {
                                soundOnChannel.Position = Position;
                                soundOnChannel.Pause    = false;
                            }
                        }
                        //SoundPlay3D(Type.SoundOn, .7f, true);
                    }
                    else
                    {
                        SoundPlay3D(Type.SoundOff, .7f, true);
                    }
                }
            }

            string needSoundName = null;

            if (motorOn && currentGear != null)
            {
                needSoundName = currentGear.SoundMotor;
            }

            if (needSoundName != currentMotorSoundName)
            {
                //change motor sound

                if (motorSoundChannel != null)
                {
                    motorSoundChannel.Stop();
                    motorSoundChannel = null;
                }

                currentMotorSoundName = needSoundName;

                if (!string.IsNullOrEmpty(needSoundName))
                {
                    Sound sound = SoundWorld.Instance.SoundCreate(needSoundName,
                                                                  SoundMode.Mode3D | SoundMode.Loop);

                    if (sound != null)
                    {
                        motorSoundChannel = SoundWorld.Instance.SoundPlay(
                            sound, EngineApp.Instance.DefaultSoundChannelGroup, .3f, true);
                        motorSoundChannel.Position = Position;
                        motorSoundChannel.Pause    = false;
                    }
                }
            }

            //update motor channel position and pitch
            if (motorSoundChannel != null)
            {
                Range speedRangeAbs = currentGear.SpeedRange;
                if (speedRangeAbs.Minimum < 0 && speedRangeAbs.Maximum < 0)
                {
                    speedRangeAbs = new Range(-speedRangeAbs.Maximum, -speedRangeAbs.Minimum);
                }
                Range pitchRange = currentGear.SoundMotorPitchRange;

                float speedAbs = Math.Abs(GetTracksSpeed());

                float speedCoef = 0;
                if (speedRangeAbs.Size() != 0)
                {
                    speedCoef = (speedAbs - speedRangeAbs.Minimum) / speedRangeAbs.Size();
                }
                MathFunctions.Clamp(ref speedCoef, 0, 1);

                float carpitch;
                //update channel
                if (!OnGround)
                {
                    if (Intellect.IsControlKeyPressed(GameControlKeys.Arrow_Up))
                    {
                        carpitch = pitchRange.Minimum + pitchRange.Size();
                    }
                    else
                    {
                        carpitch = pitchRange.Minimum;
                    }
                }
                else
                {
                    carpitch = pitchRange.Minimum + speedCoef * pitchRange.Size();
                }
                motorSoundChannel.Pitch    = carpitch;
                motorSoundChannel.Position = Position;
            }
        }
Example #19
0
 public static extern bool WTSVirtualChannelQuery(
     IntPtr hChannelHandle,
     VirtualChannel wtsvirtualclass,
     IntPtr ppBuffer,
     IntPtr pBytesReturned);
Example #20
0
File: Tank.cs Project: Eneth/GAO
        void TickMotorSound()
        {
            bool lastMotorOn = motorOn;
            motorOn = Intellect != null && Intellect.IsActive();

            //sound on, off
            if( motorOn != lastMotorOn )
            {
                if( !firstTick && Life != 0 )
                {
                    if( motorOn )
                        SoundPlay3D( Type.SoundOn, .7f, true );
                    else
                        SoundPlay3D( Type.SoundOff, .7f, true );
                }
            }

            string needSoundName = null;
            if( motorOn && currentGear != null )
                needSoundName = currentGear.SoundMotor;

            if( needSoundName != currentMotorSoundName )
            {
                //change motor sound

                if( motorSoundChannel != null )
                {
                    motorSoundChannel.Stop();
                    motorSoundChannel = null;
                }

                currentMotorSoundName = needSoundName;

                if( !string.IsNullOrEmpty( needSoundName ) )
                {
                    Sound sound = SoundWorld.Instance.SoundCreate( needSoundName,
                        SoundMode.Mode3D | SoundMode.Loop );

                    if( sound != null )
                    {
                        motorSoundChannel = SoundWorld.Instance.SoundPlay(
                            sound, EngineApp.Instance.DefaultSoundChannelGroup, .3f, true );
                        motorSoundChannel.Position = Position;
                        motorSoundChannel.Pause = false;
                    }
                }
            }

            //update motor channel position and pitch
            if( motorSoundChannel != null )
            {
                Range speedRangeAbs = currentGear.SpeedRange;
                if( speedRangeAbs.Minimum < 0 && speedRangeAbs.Maximum < 0 )
                    speedRangeAbs = new Range( -speedRangeAbs.Maximum, -speedRangeAbs.Minimum );
                Range pitchRange = currentGear.SoundMotorPitchRange;

                float speedAbs = Math.Max( Math.Abs( leftTrack.speed ), Math.Abs( rightTrack.speed ) );

                float speedCoef = 0;
                if( speedRangeAbs.Size() != 0 )
                    speedCoef = ( speedAbs - speedRangeAbs.Minimum ) / speedRangeAbs.Size();
                MathFunctions.Clamp( ref speedCoef, 0, 1 );

                //update channel
                motorSoundChannel.Pitch = pitchRange.Minimum + speedCoef * pitchRange.Size();
                motorSoundChannel.Position = Position;
            }
        }
Example #21
0
        void TickMotorSound()
        {
            bool lastMotorOn = motorOn;

            motorOn = Intellect != null && Intellect.IsActive();

            //sound on, off
            if (motorOn != lastMotorOn)
            {
                if (!firstTick && Life != 0)
                {
                    if (motorOn)
                    {
                        SoundPlay3D(Type.SoundOn, .7f, true);
                    }
                    else
                    {
                        SoundPlay3D(Type.SoundOff, .7f, true);
                    }
                }
            }

            string needSoundName = null;

            if (motorOn && currentGear != null)
            {
                needSoundName = currentGear.SoundMotor;
            }

            if (needSoundName != currentMotorSoundName)
            {
                //change motor sound

                if (motorSoundChannel != null)
                {
                    motorSoundChannel.Stop();
                    motorSoundChannel = null;
                }

                currentMotorSoundName = needSoundName;

                if (!string.IsNullOrEmpty(needSoundName))
                {
                    Sound sound = SoundWorld.Instance.SoundCreate(needSoundName,
                                                                  SoundMode.Mode3D | SoundMode.Loop);

                    if (sound != null)
                    {
                        motorSoundChannel = SoundWorld.Instance.SoundPlay(
                            sound, EngineApp.Instance.DefaultSoundChannelGroup, .3f, true);
                        motorSoundChannel.Position = Position;
                        motorSoundChannel.Pause    = false;
                    }
                }
            }
            //update motor channel position and pitch
            if (motorSoundChannel != null)
            {
                Range speedRangeAbs = currentGear.SpeedRange;
                if (speedRangeAbs.Minimum < 0 && speedRangeAbs.Maximum < 0)
                {
                    speedRangeAbs = new Range(-speedRangeAbs.Maximum, -speedRangeAbs.Minimum);
                }
                Range pitchRange = currentGear.SoundMotorPitchRange;

                Vec3  Velocity = forkliftBody.LinearVelocity * forkliftBody.Rotation.GetInverse();
                float speedAbs = Velocity.X * 1;

                float speedCoef = 0;
                if (speedRangeAbs.Size() != 0)
                {
                    speedCoef = (speedAbs - speedRangeAbs.Minimum) / speedRangeAbs.Size();
                }
                MathFunctions.Clamp(ref speedCoef, 0, 1);

                //update channel
                motorSoundChannel.Pitch    = pitchRange.Minimum + speedCoef * pitchRange.Size();
                motorSoundChannel.Position = Position;
            }
        }
Example #22
0
        private void TickSound()
        {
            bool lastMotorOn = HelliOn;
            HelliOn = Intellect != null && Intellect.IsActive();

            //sound on, off
            if (HelliOn != lastMotorOn)
            {
                if (HelliOn)
                {
                    Sound sound = SoundWorld.Instance.SoundCreate(Type.SoundOn, SoundMode.Mode3D);
                    if (sound != null)
                    {
                        soundOnChannel = SoundWorld.Instance.SoundPlay(sound, EngineApp.Instance.DefaultSoundChannelGroup, .7f, true);
                        if (soundOnChannel != null)
                        {
                            soundOnChannel.Position = Position;
                            soundOnChannel.Pause = false;
                        }
                    }
                    //SoundPlay3D(Type.SoundOn, .7f, true);
                }
                else
                {
                    MohiOff();
                    SoundPlay3D(Type.SoundOff, 0.7f, true);
                }
            }

            string needSoundName = null;
            if (HelliOn)
                needSoundName = Type.SoundIdle;
            if (needSoundName != currentRotorSoundName)
            {
                currentRotorSoundName = needSoundName;

                if (!string.IsNullOrEmpty(needSoundName))
                {
                    Sound sound = SoundWorld.Instance.SoundCreate(needSoundName,
                        SoundMode.Mode3D | SoundMode.Loop);

                    if (sound != null)
                    {
                        rotorSoundChannel = SoundWorld.Instance.SoundPlay(
                            sound, EngineApp.Instance.DefaultSoundChannelGroup, 1, true);
                        rotorSoundChannel.Position = Position;
                        rotorSoundChannel.Pause = false;
                    }
                }
            }
        }
Example #23
0
        private void MohiOff()
        {
            //turning off some stuff when you are getting out of helli
            GearedMotor main = PhysicsModel.GetMotor("hellimain") as GearedMotor;
            GearedMotor back = PhysicsModel.GetMotor("helliback") as GearedMotor;

            main.Enabled = false;
            back.Enabled = false;

            if (rotorSoundChannel != null)
            {
                rotorSoundChannel.Stop();
                rotorSoundChannel = null;
            }
        }
Example #24
0
        private void TickMotorSound()
        {
            bool lastMotorOn = motorOn;
            motorOn = Intellect != null && Intellect.IsActive();

            //sound on, off
            if (motorOn != lastMotorOn)
            {
                if (!firstTick && Life != 0)
                {
                    if (motorOn)
                    {
                        Sound sound = SoundWorld.Instance.SoundCreate(Type.SoundOn, SoundMode.Mode3D);
                        if (sound != null)
                        {
                            soundOnChannel = SoundWorld.Instance.SoundPlay(sound, EngineApp.Instance.DefaultSoundChannelGroup, .7f, true);
                            if (soundOnChannel != null)
                            {
                                soundOnChannel.Position = Position;
                                soundOnChannel.Pause = false;
                            }
                        }
                        //SoundPlay3D(Type.SoundOn, .7f, true);
                    }
                    else
                    {
                        SoundPlay3D(Type.SoundOff, .7f, true);
                    }
                }
            }

            string needSoundName = null;
            if (motorOn && currentGear != null)
                needSoundName = currentGear.SoundMotor;

            if (needSoundName != currentMotorSoundName)
            {
                //change motor sound

                if (motorSoundChannel != null)
                {
                    motorSoundChannel.Stop();
                    motorSoundChannel = null;
                }

                currentMotorSoundName = needSoundName;

                if (!string.IsNullOrEmpty(needSoundName))
                {
                    Sound sound = SoundWorld.Instance.SoundCreate(needSoundName,
                        SoundMode.Mode3D | SoundMode.Loop);

                    if (sound != null)
                    {
                        motorSoundChannel = SoundWorld.Instance.SoundPlay(
                            sound, EngineApp.Instance.DefaultSoundChannelGroup, .3f, true);
                        motorSoundChannel.Position = Position;
                        motorSoundChannel.Pause = false;
                    }
                }
            }

            //update motor channel position and pitch
            if (motorSoundChannel != null)
            {
                Range speedRangeAbs = currentGear.SpeedRange;
                if (speedRangeAbs.Minimum < 0 && speedRangeAbs.Maximum < 0)
                    speedRangeAbs = new Range(-speedRangeAbs.Maximum, -speedRangeAbs.Minimum);
                Range pitchRange = currentGear.SoundMotorPitchRange;

                float speedAbs = Math.Abs(GetWheelsSpeed());

                float speedCoef = 0;
                if (speedRangeAbs.Size() != 0)
                    speedCoef = (speedAbs - speedRangeAbs.Minimum) / speedRangeAbs.Size();
                MathFunctions.Clamp(ref speedCoef, 0, 1);

                float carpitch;
                //update channel

                /*bool onGround = LFWheel.onGround || RFWheel.onGround;
                if (!onGround)
                {
                    if (Intellect.IsControlKeyPressed(GameControlKeys.ArowUp))
                    {
                        carpitch = pitchRange.Minimum + pitchRange.Size();
                    }
                    else
                    {
                        carpitch = pitchRange.Minimum;
                    }
                }
                else*/
                {
                    carpitch = pitchRange.Minimum + speedCoef * pitchRange.Size();
                }
                motorSoundChannel.Pitch = carpitch;
                motorSoundChannel.Position = Position;
            }
        }
Example #25
0
        void TickMotorSound()
        {
            bool last_motor_on = motor_on;

            motor_on = Intellect != null && Intellect.IsActive();

            //sound on, off
            if (motor_on != last_motor_on)
            {
                if (!first_tick && Health != 0)
                {
                    if (motor_on)
                    {
                        SoundPlay3D(Type.CONF.SoundOn, .7f, true);
                    }
                    else
                    {
                        SoundPlay3D(Type.CONF.SoundOff, .7f, true);
                    }
                }
            }

            string need_sound_name = null;

            if (motor_on && current_gears != null)
            {
                need_sound_name = current_gears.SoundMotor;
            }

            if (need_sound_name != current_motor_sound_name)
            {
                //change motor sound
                if (motor_sound_channel != null)
                {
                    motor_sound_channel.Stop();
                    motor_sound_channel = null;
                }

                current_motor_sound_name = need_sound_name;

                if (!string.IsNullOrEmpty(need_sound_name))
                {
                    Sound sound = SoundWorld.Instance.SoundCreate(
                        RelativePathUtils.ConvertToFullPath(Path.GetDirectoryName(Type.FilePath), need_sound_name),
                        SoundMode.Mode3D | SoundMode.Loop);

                    if (sound != null)
                    {
                        motor_sound_channel = SoundWorld.Instance.SoundPlay(
                            sound, EngineApp.Instance.DefaultSoundChannelGroup, .3f, true);
                        motor_sound_channel.Position = Position;
                        switch (Type.SoundRolloffMode)
                        {
                        case DynamicType.SoundRolloffModes.Logarithmic:
                            motor_sound_channel.SetLogarithmicRolloff(Type.SoundMinDistance, Type.SoundMaxDistance,
                                                                      Type.SoundRolloffLogarithmicFactor);
                            break;

                        case DynamicType.SoundRolloffModes.Linear:
                            motor_sound_channel.SetLinearRolloff(Type.SoundMinDistance, Type.SoundMaxDistance);
                            break;
                        }
                        motor_sound_channel.Pause = false;
                    }
                }
            }

            //update motor channel position and pitch
            if (motor_sound_channel != null)
            {
                Range speed_range_abs = current_gears.SpeedRange;
                if (speed_range_abs.Minimum < 0 && speed_range_abs.Maximum < 0)
                {
                    speed_range_abs = new Range(-speed_range_abs.Maximum, -speed_range_abs.Minimum);
                }
                Range pitch_range = current_gears.SoundMotorPitchRange;

                float speed_abs = (PhysicsModel.Bodies[0].LinearVelocity.Length() * 3600.0f / 1000.0f);

                float speed_coef = 0;
                if (speed_range_abs.Size() != 0)
                {
                    speed_coef = (speed_abs - speed_range_abs.Minimum) / speed_range_abs.Size();
                }
                MathFunctions.Clamp(ref speed_coef, 0, 1);

                //update channel
                motor_sound_channel.Pitch    = pitch_range.Minimum + speed_coef * pitch_range.Size();
                motor_sound_channel.Position = Position;
            }
        }
Example #26
0
 public static extern bool WTSVirtualChannelQuery(
     IntPtr hChannelHandle,
     VirtualChannel wtsvirtualclass,
     IntPtr ppBuffer,
     IntPtr pBytesReturned);
Example #27
0
        private void MohiOff()
        {
            //turning off some stuff when you are getting out of jet

            if (rotorSoundChannel != null)
            {
                rotorSoundChannel.Stop();
                rotorSoundChannel = null;
            }
        }
Example #28
0
        private void tickJetSound()
        {
            if (boosted && played == false)
            {
                if (!string.IsNullOrEmpty(Type.SoundJet))
                {
                    Sound sound = SoundWorld.Instance.SoundCreate(Type.SoundJet,
                        SoundMode.Mode3D | SoundMode.Loop);

                    if (sound != null)
                    {
                        JetSoundChannel = SoundWorld.Instance.SoundPlay(
                            sound, EngineApp.Instance.DefaultSoundChannelGroup, 0.7f, true);
                        JetSoundChannel.Position = Position;
                        JetSoundChannel.Pause = false;
                        played = true;
                    }
                }
            }
            else if (!boosted && JetSoundChannel != null)
            {
                JetSoundChannel.Stop();
                played = false;
            }
        }
Example #29
0
        private void TickMotorSound()
        {
            bool lastMotorOn = motorOn;
            motorOn = Intellect != null && Intellect.IsActive();

            //sound on, off
            if (motorOn != lastMotorOn)
            {
                if (!firstTick && Health != 0)
                {
                    if (motorOn)
                    {
                        Sound sound = SoundWorld.Instance.SoundCreate(Type.SoundOn, SoundMode.Mode3D);
                        if (sound != null)
                        {
                            soundOnChannel = SoundWorld.Instance.SoundPlay(sound, EngineApp.Instance.DefaultSoundChannelGroup, .7f, true);
                            if (soundOnChannel != null)
                            {
                                soundOnChannel.Position = Position;
                                soundOnChannel.Pause = false;
                            }
                        }
                        //SoundPlay3D(Type.SoundOn, .7f, true);
                    }
                    else
                        SoundPlay3D(Type.SoundOff, .7f, true);
                    MapObjectAttachedMesh CT = GetFirstAttachedObjectByAlias("CT") as MapObjectAttachedMesh;
                    if (CT != null) CT.Visible = true;
                }
            }

            string needSoundName = null;
            if (motorOn && currentGear != null)
                needSoundName = currentGear.SoundMotor;

            if (needSoundName != currentMotorSoundName)
            {
                //change motor sound

                if (motorSoundChannel != null)
                {
                    motorSoundChannel.Stop();
                    motorSoundChannel = null;
                }

                currentMotorSoundName = needSoundName;

                if (!string.IsNullOrEmpty(needSoundName))
                {
                    Sound sound = SoundWorld.Instance.SoundCreate(needSoundName,
                        SoundMode.Mode3D | SoundMode.Loop);

                    if (sound != null)
                    {
                        motorSoundChannel = SoundWorld.Instance.SoundPlay(
                            sound, EngineApp.Instance.DefaultSoundChannelGroup, .3f, true);
                        motorSoundChannel.Position = Position;
                        motorSoundChannel.Pause = false;
                    }
                }
            }

            //update motor channel position and pitch
            if (motorSoundChannel != null)
            {
                Range speedRangeAbs = currentGear.SpeedRange;
                if (speedRangeAbs.Minimum < 0 && speedRangeAbs.Maximum < 0)
                    speedRangeAbs = new Range(-speedRangeAbs.Maximum, -speedRangeAbs.Minimum);
                Range pitchRange = currentGear.SoundMotorPitchRange;

                float speedAbs = Math.Abs(GetFootsSpeed());

                float speedCoef = 0;
                if (speedRangeAbs.Size() != 0)
                    speedCoef = (speedAbs - speedRangeAbs.Minimum) / speedRangeAbs.Size();
                MathFunctions.Clamp(ref speedCoef, 0, 1);

                //update channel
                motorSoundChannel.Pitch = pitchRange.Minimum + speedCoef * pitchRange.Size();
                motorSoundChannel.Position = Position;
            }

            //jumpjet sound

            if (boosted && played == false)
            {
                if (!string.IsNullOrEmpty(Type.SoundJet))
                {
                    Sound sound = SoundWorld.Instance.SoundCreate(Type.SoundJet,
                        SoundMode.Mode3D | SoundMode.Loop);

                    if (sound != null)
                    {
                        JetSoundChannel = SoundWorld.Instance.SoundPlay(
                            sound, EngineApp.Instance.DefaultSoundChannelGroup, 0.7f, true);
                        JetSoundChannel.Position = Position;
                        JetSoundChannel.Pause = false;
                        played = true;
                    }
                }
            }
            else if (!boosted && JetSoundChannel != null)
            {
                JetSoundChannel.Stop();
                played = false;
            }
        }
Example #30
0
            public override void OnUpdate()
            {
                int informationTypeIndex = ((EComboBox)PageControl.Controls["InformationType"]).
                                           SelectedIndex;

                StringBuilder text = new StringBuilder("");

                if (informationTypeIndex == 0)
                {
                    //loaded sounds

                    text.AppendFormat("Count: {0}\n", SoundWorld.Instance.Sounds.Count);
                    text.Append("\n");

                    foreach (Sound sound in SoundWorld.Instance.Sounds)
                    {
                        text.AppendFormat("{0}\n", sound);
                    }
                }
                else if (informationTypeIndex == 1)
                {
                    //virtual channels

                    int activeChannelCount = SoundWorld.Instance.ActiveVirtual2DChannels.Count +
                                             SoundWorld.Instance.ActiveVirtual3DChannels.Count;

                    text.AppendFormat("Active channels: {0}\n", activeChannelCount);
                    text.Append("\n");

                    for (int nChannels = 0; nChannels < 2; nChannels++)
                    {
                        IEnumerable <VirtualChannel> activeChannels = nChannels == 0 ?
                                                                      SoundWorld.Instance.ActiveVirtual2DChannels :
                                                                      SoundWorld.Instance.ActiveVirtual3DChannels;

                        foreach (VirtualChannel virtualChannel in activeChannels)
                        {
                            if (virtualChannel.CurrentRealChannel != null)
                            {
                                text.Append("Real - ");
                            }
                            else
                            {
                                text.Append("Virtual - ");
                            }

                            string soundName;

                            if (virtualChannel.CurrentSound.Name != null)
                            {
                                soundName = virtualChannel.CurrentSound.Name;
                            }
                            else
                            {
                                soundName = "DataBuffer";
                            }
                            text.AppendFormat("{0}  Volume {1}\n", soundName,
                                              virtualChannel.GetTotalVolume().ToString("F3"));
                        }
                    }
                }
                else
                {
                    //real channels

                    int freeCount   = 0;
                    int activeCount = 0;

                    for (int nRealChannels = 0; nRealChannels < 2; nRealChannels++)
                    {
                        IEnumerable <RealChannel> realChannels = nRealChannels == 0 ?
                                                                 SoundWorld.Instance.Real2DChannels : SoundWorld.Instance.Real3DChannels;
                        foreach (RealChannel realChannel in realChannels)
                        {
                            if (realChannel.CurrentVirtualChannel == null)
                            {
                                freeCount++;
                            }
                            else
                            {
                                activeCount++;
                            }
                        }
                    }

                    text.AppendFormat("Free channels: {0}\n", freeCount);
                    text.AppendFormat("Active channels: {0}\n", activeCount);
                    text.Append("\n");

                    bool last3d = false;

                    for (int nRealChannels = 0; nRealChannels < 2; nRealChannels++)
                    {
                        IEnumerable <RealChannel> realChannels = nRealChannels == 0 ?
                                                                 SoundWorld.Instance.Real2DChannels : SoundWorld.Instance.Real3DChannels;

                        foreach (RealChannel realChannel in realChannels)
                        {
                            VirtualChannel virtualChannel = realChannel.CurrentVirtualChannel;

                            if (!last3d && realChannel.Is3D)
                            {
                                last3d = true;
                                text.Append("\n");
                            }

                            text.AppendFormat("{0}: ", realChannel.Is3D ? "3D" : "2D");

                            if (virtualChannel != null)
                            {
                                string soundName;

                                if (virtualChannel.CurrentSound.Name != null)
                                {
                                    soundName = virtualChannel.CurrentSound.Name;
                                }
                                else
                                {
                                    soundName = "DataBuffer";
                                }

                                text.AppendFormat("{0}  Volume {1}\n", soundName,
                                                  virtualChannel.GetTotalVolume().ToString("F3"));
                            }
                            else
                            {
                                text.Append("Free\n");
                            }
                        }
                    }
                }

                PageControl.Controls["Information"].Text = text.ToString();
            }
Example #31
0
        protected override void OnDestroy()
        {
            if (motorSoundChannel != null)
            {
                motorSoundChannel.Stop();
                motorSoundChannel = null;
            }

            base.OnDestroy();
        }
Example #32
0
File: Tank.cs Project: whztt07/SDK
        protected override void OnDestroy()
        {
            if( motorSoundChannel != null )
            {
                motorSoundChannel.Stop();
                motorSoundChannel = null;
            }

            if( towerTurnChannel != null )
            {
                towerTurnChannel.Stop();
                towerTurnChannel = null;
            }

            ShutdownTracksTextureAnimation();
            ShutdownWheelsSkeletonAnimation();

            base.OnDestroy();
        }
Example #33
0
 protected override void OnDestroy()
 {
     //things we should do when helli has been destroyed
     if (rotorSoundChannel != null)
     {
         rotorSoundChannel.Stop();
         rotorSoundChannel = null;
     }
     base.OnDestroy();
 }
Example #34
0
File: Tank.cs Project: whztt07/SDK
        void TickMotorSound()
        {
            bool lastMotorOn = motorOn;
            motorOn = Intellect != null && Intellect.IsActive();

            //sound on, off
            if( motorOn != lastMotorOn )
            {
                if( !firstTick && Health != 0 )
                {
                    if( motorOn )
                        SoundPlay3D( Type.SoundOn, .7f, true );
                    else
                        SoundPlay3D( Type.SoundOff, .7f, true );
                }
            }

            string needSoundName = null;
            if( motorOn && currentGear != null )
                needSoundName = currentGear.SoundMotor;

            if( needSoundName != currentMotorSoundName )
            {
                //change motor sound

                if( motorSoundChannel != null )
                {
                    motorSoundChannel.Stop();
                    motorSoundChannel = null;
                }

                currentMotorSoundName = needSoundName;

                if( !string.IsNullOrEmpty( needSoundName ) )
                {
                    Sound sound = SoundWorld.Instance.SoundCreate(
                        RelativePathUtils.ConvertToFullPath( Path.GetDirectoryName( Type.FilePath ), needSoundName ),
                        SoundMode.Mode3D | SoundMode.Loop );

                    if( sound != null )
                    {
                        motorSoundChannel = SoundWorld.Instance.SoundPlay(
                            sound, EngineApp.Instance.DefaultSoundChannelGroup, .3f, true );
                        motorSoundChannel.Position = Position;
                        switch( Type.SoundRolloffMode )
                        {
                        case DynamicType.SoundRolloffModes.Logarithmic:
                            motorSoundChannel.SetLogarithmicRolloff( Type.SoundMinDistance, Type.SoundMaxDistance,
                                Type.SoundRolloffLogarithmicFactor );
                            break;
                        case DynamicType.SoundRolloffModes.Linear:
                            motorSoundChannel.SetLinearRolloff( Type.SoundMinDistance, Type.SoundMaxDistance );
                            break;
                        }
                        motorSoundChannel.Pause = false;
                    }
                }
            }

            //update motor channel position and pitch
            if( motorSoundChannel != null )
            {
                Range speedRangeAbs = currentGear.SpeedRange;
                if( speedRangeAbs.Minimum < 0 && speedRangeAbs.Maximum < 0 )
                    speedRangeAbs = new Range( -speedRangeAbs.Maximum, -speedRangeAbs.Minimum );
                Range pitchRange = currentGear.SoundMotorPitchRange;

                float speedAbs = Math.Max( Math.Abs( leftTrack.speed ), Math.Abs( rightTrack.speed ) );

                float speedCoef = 0;
                if( speedRangeAbs.Size() != 0 )
                    speedCoef = ( speedAbs - speedRangeAbs.Minimum ) / speedRangeAbs.Size();
                MathFunctions.Clamp( ref speedCoef, 0, 1 );

                //update channel
                motorSoundChannel.Pitch = pitchRange.Minimum + speedCoef * pitchRange.Size();
                motorSoundChannel.Position = Position;
            }
        }
Example #35
0
 protected override void OnDestroy()
 {
     //things we should do when jet destroys
     if (rotorSoundChannel != null)
     {
         rotorSoundChannel.Stop();
         rotorSoundChannel = null;
     }
     base.OnDestroy();
 }
Example #36
0
File: Tank.cs Project: whztt07/SDK
        void TickTowerTurn()
        {
            //update direction
            if( towerLocalDirection != needTowerLocalDirection )
            {
                Radian turnSpeed = Type.TowerTurnSpeed;

                SphereDir needDirection = needTowerLocalDirection;
                SphereDir direction = towerLocalDirection;

                //update horizontal direction
                float diffHorizontalAngle = needDirection.Horizontal - direction.Horizontal;
                while( diffHorizontalAngle < -MathFunctions.PI )
                    diffHorizontalAngle += MathFunctions.PI * 2;
                while( diffHorizontalAngle > MathFunctions.PI )
                    diffHorizontalAngle -= MathFunctions.PI * 2;

                if( diffHorizontalAngle > 0 )
                {
                    if( direction.Horizontal > needDirection.Horizontal )
                        direction.Horizontal -= MathFunctions.PI * 2;
                    direction.Horizontal += turnSpeed * TickDelta;
                    if( direction.Horizontal > needDirection.Horizontal )
                        direction.Horizontal = needDirection.Horizontal;
                }
                else
                {
                    if( direction.Horizontal < needDirection.Horizontal )
                        direction.Horizontal += MathFunctions.PI * 2;
                    direction.Horizontal -= turnSpeed * TickDelta;
                    if( direction.Horizontal < needDirection.Horizontal )
                        direction.Horizontal = needDirection.Horizontal;
                }

                //update vertical direction
                if( direction.Vertical < needDirection.Vertical )
                {
                    direction.Vertical += turnSpeed * TickDelta;
                    if( direction.Vertical > needDirection.Vertical )
                        direction.Vertical = needDirection.Vertical;
                }
                else
                {
                    direction.Vertical -= turnSpeed * TickDelta;
                    if( direction.Vertical < needDirection.Vertical )
                        direction.Vertical = needDirection.Vertical;
                }

                if( direction.Equals( needTowerLocalDirection, .001f ) )
                    towerLocalDirection = direction;

                towerLocalDirection = direction;
            }

            //update tower turn sound
            {
                bool needSound = !towerLocalDirection.Equals( needTowerLocalDirection,
                    new Degree( 2 ).InRadians() );

                if( needSound )
                {
                    if( towerTurnChannel == null && !string.IsNullOrEmpty( Type.SoundTowerTurn ) )
                    {
                        Sound sound = SoundWorld.Instance.SoundCreate(
                            RelativePathUtils.ConvertToFullPath( Path.GetDirectoryName( Type.FilePath ), Type.SoundTowerTurn ),
                            SoundMode.Mode3D | SoundMode.Loop );

                        if( sound != null )
                        {
                            towerTurnChannel = SoundWorld.Instance.SoundPlay(
                                sound, EngineApp.Instance.DefaultSoundChannelGroup, .3f, true );
                            towerTurnChannel.Position = Position;
                            switch( Type.SoundRolloffMode )
                            {
                            case DynamicType.SoundRolloffModes.Logarithmic:
                                towerTurnChannel.SetLogarithmicRolloff( Type.SoundMinDistance, Type.SoundMaxDistance,
                                    Type.SoundRolloffLogarithmicFactor );
                                break;
                            case DynamicType.SoundRolloffModes.Linear:
                                towerTurnChannel.SetLinearRolloff( Type.SoundMinDistance, Type.SoundMaxDistance );
                                break;
                            }
                            towerTurnChannel.Pause = false;
                        }
                    }

                    if( towerTurnChannel != null )
                        towerTurnChannel.Position = Position;
                }
                else
                {
                    if( towerTurnChannel != null )
                    {
                        towerTurnChannel.Stop();
                        towerTurnChannel = null;
                    }
                }
            }
        }
Example #37
0
File: Tank.cs Project: Eneth/GAO
        void TickTowerTurn()
        {
            //update direction
            if( towerLocalDirection != needTowerLocalDirection )
            {
                Radian turnSpeed = Type.TowerTurnSpeed;

                SphereDir needDirection = needTowerLocalDirection;
                SphereDir direction = towerLocalDirection;

                //update horizontal direction
                float diffHorizontalAngle = needDirection.Horizontal - direction.Horizontal;
                while( diffHorizontalAngle < -MathFunctions.PI )
                    diffHorizontalAngle += MathFunctions.PI * 2;
                while( diffHorizontalAngle > MathFunctions.PI )
                    diffHorizontalAngle -= MathFunctions.PI * 2;

                if( diffHorizontalAngle > 0 )
                {
                    if( direction.Horizontal > needDirection.Horizontal )
                        direction.Horizontal -= MathFunctions.PI * 2;
                    direction.Horizontal += turnSpeed * TickDelta;
                    if( direction.Horizontal > needDirection.Horizontal )
                        direction.Horizontal = needDirection.Horizontal;
                }
                else
                {
                    if( direction.Horizontal < needDirection.Horizontal )
                        direction.Horizontal += MathFunctions.PI * 2;
                    direction.Horizontal -= turnSpeed * TickDelta;
                    if( direction.Horizontal < needDirection.Horizontal )
                        direction.Horizontal = needDirection.Horizontal;
                }

                //update vertical direction
                if( direction.Vertical < needDirection.Vertical )
                {
                    direction.Vertical += turnSpeed * TickDelta;
                    if( direction.Vertical > needDirection.Vertical )
                        direction.Vertical = needDirection.Vertical;
                }
                else
                {
                    direction.Vertical -= turnSpeed * TickDelta;
                    if( direction.Vertical < needDirection.Vertical )
                        direction.Vertical = needDirection.Vertical;
                }

                if( direction.Equals( needTowerLocalDirection, .001f ) )
                    towerLocalDirection = direction;

                towerLocalDirection = direction;
            }

            //update tower turn sound
            {
                bool needSound = !towerLocalDirection.Equals( needTowerLocalDirection,
                    new Degree( 2 ).InRadians() );

                if( needSound )
                {
                    if( towerTurnChannel == null && !string.IsNullOrEmpty( Type.SoundTowerTurn ) )
                    {
                        Sound sound = SoundWorld.Instance.SoundCreate( Type.SoundTowerTurn,
                            SoundMode.Mode3D | SoundMode.Loop );

                        if( sound != null )
                        {
                            towerTurnChannel = SoundWorld.Instance.SoundPlay(
                                sound, EngineApp.Instance.DefaultSoundChannelGroup, .3f, true );
                            towerTurnChannel.Position = Position;
                            towerTurnChannel.Pause = false;
                        }
                    }

                    if( towerTurnChannel != null )
                        towerTurnChannel.Position = Position;
                }
                else
                {
                    if( towerTurnChannel != null )
                    {
                        towerTurnChannel.Stop();
                        towerTurnChannel = null;
                    }
                }
            }
        }
Example #38
0
        protected override void OnDestroy()
        {
            if (motorSoundChannel != null)
            {
                motorSoundChannel.Stop();
                motorSoundChannel = null;
            }

            ShutdownTracksAnimation();

            base.OnDestroy();
        }