コード例 #1
0
 void ResumeCue(MySoundCue? cue)
 {
     if (cue != null && cue.Value.IsValid && cue.Value.IsPaused)
     {
         cue.Value.Resume();
     }
 }
コード例 #2
0
ファイル: MySoundCue.cs プロジェクト: Bunni/Miner-Wars-2081
 public bool IsSame(MySoundCue cue)
 {
     return m_cue == cue.m_cue && m_version == cue.m_version;
 }
コード例 #3
0
 void PauseCue(MySoundCue? cue)
 {
     if (cue != null && cue.Value.IsPlaying)
     {
         cue.Value.Pause();
     }
 }
コード例 #4
0
ファイル: MyAudio.cs プロジェクト: Bunni/Miner-Wars-2081
        //  Updates pitch of a cue (this is per instance pitch, not all sounds pitch). Pitch values are in interval <-1..+1>.
        //  IMPORTANT: Every cue for which we want to set pitch needs to have RPC for it. This can be done in XACT.
        public static void UpdateCuePitch(MySoundCue? cue, float pitch)
        {
            if (m_canPlay == false) return;
            if (cue == null) return;
            CheckCue(cue.Value);

            cue.Value.SetVariable(MyCueVariableEnum.Pitch, pitch);
        }
コード例 #5
0
ファイル: MySmallShip.cs プロジェクト: Bunni/Miner-Wars-2081
 //  Weapons sounds are unified per miner ship (two or more weapons of same type and shooting simultanously will produce only one sound)
 public void UnifiedWeaponCueSet(MySoundCuesEnum cueEnum, MySoundCue? value)
 {
     m_unifiedWeaponCues[(int)cueEnum] = value;
 }
コード例 #6
0
ファイル: MyAudio.cs プロジェクト: Bunni/Miner-Wars-2081
        //  Updates pitch of a cue (this is per instance pitch, not all sounds pitch). Volume values are in interval <0..1..2> -> same as for master pitch (see below).
        //  IMPORTANT: Every cue for which we want to set pitch needs to have RPC for it. This can be done in XACT.
        public static void UpdateCueAmbVolume(MySoundCue? cue, float volume)
        {
            if (m_canPlay == false) return;
            if (cue == null) return;
            CheckCue(cue.Value);

            cue.Value.SetVariable(MyCueVariableEnum.AmbVolume, volume);
        }
コード例 #7
0
ファイル: MyAudio.cs プロジェクト: Bunni/Miner-Wars-2081
        //  Updates pitch of a cue (this is per instance pitch, not all sounds pitch). Rotation speed values are in interval <0..100> -> it's normalized rotation speed
        //  IMPORTANT: Every cue for which we want to set pitch needs to have RPC for it. This can be done in XACT.
        public static void UpdateCueRotationSpeed(MySoundCue? cue, float rotationSpeed)
        {
            if (m_canPlay == false) return;
            if (cue == null) return;
            CheckCue(cue.Value);

            cue.Value.SetVariable(MyCueVariableEnum.RotatingSpeed, rotationSpeed);
        }
コード例 #8
0
ファイル: MyAudio.cs プロジェクト: Bunni/Miner-Wars-2081
        public static void UpdateCuePosition(MySoundCue cue, Vector3 position, Vector3 forward, Vector3 up, Vector3 velocity)
        {
            if (m_canPlay == false) return;
            if (!cue.IsValid) return;
            if (!cue.Is3D) return;
            CheckCue(cue);

            if (!MyFakes.OPTIMIZATION_FOR_300_SMALLSHIPS)
            {
                CalculateOcclusion(cue, position);
            }

            m_helperEmitter.UpdateValues(ref position, ref forward, ref up, ref velocity);

            cue.Apply3D(m_listener, m_helperEmitter);
        }
コード例 #9
0
ファイル: MyAudio.cs プロジェクト: Bunni/Miner-Wars-2081
        public static void CalculateOcclusion(MySoundCue cue, Vector3 position)
        {
            // Occlusions are disabled
            return;

            if (MyFakes.OPTIMIZATION_FOR_300_SMALLSHIPS) return;
            if (m_canPlay == false) return;
            CheckCue(cue);

            MyCueParameters cueParams = m_cueParameters[(int)cue.CueEnum].Value;
            if (!cueParams.UseOcclusion) return;
            if (MyMinerGame.TotalGamePlayTimeInMilliseconds - cueParams.LastUpdate < MyAudioConstants.OCCLUSION_INTERVAL) return;
            cueParams.LastUpdate = MyMinerGame.TotalGamePlayTimeInMilliseconds;

            float distance = Vector3.Distance(MyCamera.Position, position);
            if ((distance <= cueParams.MaxDistance) && (distance > MyMwcMathConstants.EPSILON))
            {
                cue.SetVariable(MyCueVariableEnum.Occluder, CalculateOcclusion(ref position));
            }
        }
コード例 #10
0
ファイル: MyAudio.cs プロジェクト: Bunni/Miner-Wars-2081
 //  Updates the position and velocity settings of a 3D cue
 public static void UpdateCuePosition(MySoundCue? cue, Vector3 position, Vector3 forward, Vector3 up, Vector3 velocity)
 {
     if (cue.HasValue == false) return;
     UpdateCuePosition(cue.Value, position, forward, up, velocity);
 }
コード例 #11
0
ファイル: MyAudio.cs プロジェクト: Bunni/Miner-Wars-2081
 private static void CheckCue(MySoundCue cue)
 {
     Debug.Assert(cue.IsValid, "This method can't be called with this cue, because cue is disposed");
 }
コード例 #12
0
        void PlayLoopSound(ref MySoundCue? sound, MySoundCuesEnum? soundCue)
        {
            if (soundCue != null)
            {
                if (m_starting && sound.HasValue && sound.Value.IsPlaying)
                {
                    m_starting = false;
                    m_playing = true;
                }
                if (sound == null || (m_playing && !sound.Value.IsPlaying))
                {
                    m_playing = false;

                    sound = MyAudio.AddCue3D(
                        soundCue.Value,
                        m_kinematicPartOwner.WorldMatrix.Translation,
                        Vector3.Forward,
                        Vector3.Forward,
                        Vector3.Zero);

                    m_starting = sound != null;
                }
            }
        }
コード例 #13
0
 protected void StopSound(ref MySoundCue? soundToStop, MySoundCue? except) 
 {
     bool stopSound = soundToStop != null && (except == null || except.Value.IsSame(soundToStop.Value));
     if (stopSound) 
     {
         if (soundToStop.Value.IsPlaying) 
         {
             soundToStop.Value.Stop(SharpDX.XACT3.StopFlags.Immediate);                    
         }
         soundToStop = null;
     }
 }
コード例 #14
0
 protected void StopKinematicSounds(MySoundCue? except = null)
 {
     StopSound(ref m_startSound, except);
     StopSound(ref m_loopSound, except);
     StopSound(ref m_loopDamagedSound, except);
     StopSound(ref m_endSound, except);
 }