File tree Expand file tree Collapse file tree 13 files changed +105
-105
lines changed
Tutorials/learn-monogame-2d/src
15-Audio-Controller/MonoGameLibrary/Audio
16-Working-With-SpriteFonts/MonoGameLibrary/Audio
17-Scenes/MonoGameLibrary/Audio
18-Texture-Wrapping/MonoGameLibrary/Audio
19-User-Interface-Fundamentals/MonoGameLibrary/Audio
20-Implementing-UI-With-Gum/MonoGameLibrary/Audio
21-Customizing-Gum-UI/MonoGameLibrary/Audio
22-Snake-Game-Mechanics/MonoGameLibrary/Audio
23-Completing-The-Game/MonoGameLibrary/Audio
24-Shaders/MonoGameLibrary/Audio
25-Packaging-Game/MonoGameLibrary/Audio
26-Publish-To-Itch/MonoGameLibrary/Audio
27-Conclusion/MonoGameLibrary/Audio Expand file tree Collapse file tree 13 files changed +105
-105
lines changed Original file line number Diff line number Diff line change @@ -100,18 +100,18 @@ public AudioController()
100100 /// </summary>
101101 public void Update ( )
102102 {
103- int index = 0 ;
104-
105- while ( index < _activeSoundEffectInstances . Count )
103+ for ( int i = _activeSoundEffectInstances . Count - 1 ; i >= 0 ; i -- )
106104 {
107- SoundEffectInstance instance = _activeSoundEffectInstances [ index ] ;
105+ SoundEffectInstance instance = _activeSoundEffectInstances [ i ] ;
108106
109- if ( instance . State == SoundState . Stopped && ! instance . IsDisposed )
107+ if ( instance . State == SoundState . Stopped )
110108 {
111- instance . Dispose ( ) ;
112- _activeSoundEffectInstances . RemoveAt ( index ) ;
109+ if ( ! instance . IsDisposed )
110+ {
111+ instance . Dispose ( ) ;
112+ }
113+ _activeSoundEffectInstances . RemoveAt ( i ) ;
113114 }
114- index ++ ;
115115 }
116116 }
117117
Original file line number Diff line number Diff line change @@ -100,18 +100,18 @@ public AudioController()
100100 /// </summary>
101101 public void Update ( )
102102 {
103- int index = 0 ;
104-
105- while ( index < _activeSoundEffectInstances . Count )
103+ for ( int i = _activeSoundEffectInstances . Count - 1 ; i >= 0 ; i -- )
106104 {
107- SoundEffectInstance instance = _activeSoundEffectInstances [ index ] ;
105+ SoundEffectInstance instance = _activeSoundEffectInstances [ i ] ;
108106
109- if ( instance . State == SoundState . Stopped && ! instance . IsDisposed )
107+ if ( instance . State == SoundState . Stopped )
110108 {
111- instance . Dispose ( ) ;
112- _activeSoundEffectInstances . RemoveAt ( index ) ;
109+ if ( ! instance . IsDisposed )
110+ {
111+ instance . Dispose ( ) ;
112+ }
113+ _activeSoundEffectInstances . RemoveAt ( i ) ;
113114 }
114- index ++ ;
115115 }
116116 }
117117
Original file line number Diff line number Diff line change @@ -100,18 +100,18 @@ public AudioController()
100100 /// </summary>
101101 public void Update ( )
102102 {
103- int index = 0 ;
104-
105- while ( index < _activeSoundEffectInstances . Count )
103+ for ( int i = _activeSoundEffectInstances . Count - 1 ; i >= 0 ; i -- )
106104 {
107- SoundEffectInstance instance = _activeSoundEffectInstances [ index ] ;
105+ SoundEffectInstance instance = _activeSoundEffectInstances [ i ] ;
108106
109- if ( instance . State == SoundState . Stopped && ! instance . IsDisposed )
107+ if ( instance . State == SoundState . Stopped )
110108 {
111- instance . Dispose ( ) ;
112- _activeSoundEffectInstances . RemoveAt ( index ) ;
109+ if ( ! instance . IsDisposed )
110+ {
111+ instance . Dispose ( ) ;
112+ }
113+ _activeSoundEffectInstances . RemoveAt ( i ) ;
113114 }
114- index ++ ;
115115 }
116116 }
117117
Original file line number Diff line number Diff line change @@ -100,18 +100,18 @@ public AudioController()
100100 /// </summary>
101101 public void Update ( )
102102 {
103- int index = 0 ;
104-
105- while ( index < _activeSoundEffectInstances . Count )
103+ for ( int i = _activeSoundEffectInstances . Count - 1 ; i >= 0 ; i -- )
106104 {
107- SoundEffectInstance instance = _activeSoundEffectInstances [ index ] ;
105+ SoundEffectInstance instance = _activeSoundEffectInstances [ i ] ;
108106
109- if ( instance . State == SoundState . Stopped && ! instance . IsDisposed )
107+ if ( instance . State == SoundState . Stopped )
110108 {
111- instance . Dispose ( ) ;
112- _activeSoundEffectInstances . RemoveAt ( index ) ;
109+ if ( ! instance . IsDisposed )
110+ {
111+ instance . Dispose ( ) ;
112+ }
113+ _activeSoundEffectInstances . RemoveAt ( i ) ;
113114 }
114- index ++ ;
115115 }
116116 }
117117
Original file line number Diff line number Diff line change @@ -100,18 +100,18 @@ public AudioController()
100100 /// </summary>
101101 public void Update ( )
102102 {
103- int index = 0 ;
104-
105- while ( index < _activeSoundEffectInstances . Count )
103+ for ( int i = _activeSoundEffectInstances . Count - 1 ; i >= 0 ; i -- )
106104 {
107- SoundEffectInstance instance = _activeSoundEffectInstances [ index ] ;
105+ SoundEffectInstance instance = _activeSoundEffectInstances [ i ] ;
108106
109- if ( instance . State == SoundState . Stopped && ! instance . IsDisposed )
107+ if ( instance . State == SoundState . Stopped )
110108 {
111- instance . Dispose ( ) ;
112- _activeSoundEffectInstances . RemoveAt ( index ) ;
109+ if ( ! instance . IsDisposed )
110+ {
111+ instance . Dispose ( ) ;
112+ }
113+ _activeSoundEffectInstances . RemoveAt ( i ) ;
113114 }
114- index ++ ;
115115 }
116116 }
117117
Original file line number Diff line number Diff line change @@ -100,18 +100,18 @@ public AudioController()
100100 /// </summary>
101101 public void Update ( )
102102 {
103- int index = 0 ;
104-
105- while ( index < _activeSoundEffectInstances . Count )
103+ for ( int i = _activeSoundEffectInstances . Count - 1 ; i >= 0 ; i -- )
106104 {
107- SoundEffectInstance instance = _activeSoundEffectInstances [ index ] ;
105+ SoundEffectInstance instance = _activeSoundEffectInstances [ i ] ;
108106
109- if ( instance . State == SoundState . Stopped && ! instance . IsDisposed )
107+ if ( instance . State == SoundState . Stopped )
110108 {
111- instance . Dispose ( ) ;
112- _activeSoundEffectInstances . RemoveAt ( index ) ;
109+ if ( ! instance . IsDisposed )
110+ {
111+ instance . Dispose ( ) ;
112+ }
113+ _activeSoundEffectInstances . RemoveAt ( i ) ;
113114 }
114- index ++ ;
115115 }
116116 }
117117
Original file line number Diff line number Diff line change @@ -100,18 +100,18 @@ public AudioController()
100100 /// </summary>
101101 public void Update ( )
102102 {
103- int index = 0 ;
104-
105- while ( index < _activeSoundEffectInstances . Count )
103+ for ( int i = _activeSoundEffectInstances . Count - 1 ; i >= 0 ; i -- )
106104 {
107- SoundEffectInstance instance = _activeSoundEffectInstances [ index ] ;
105+ SoundEffectInstance instance = _activeSoundEffectInstances [ i ] ;
108106
109- if ( instance . State == SoundState . Stopped && ! instance . IsDisposed )
107+ if ( instance . State == SoundState . Stopped )
110108 {
111- instance . Dispose ( ) ;
112- _activeSoundEffectInstances . RemoveAt ( index ) ;
109+ if ( ! instance . IsDisposed )
110+ {
111+ instance . Dispose ( ) ;
112+ }
113+ _activeSoundEffectInstances . RemoveAt ( i ) ;
113114 }
114- index ++ ;
115115 }
116116 }
117117
Original file line number Diff line number Diff line change @@ -97,21 +97,21 @@ public AudioController()
9797
9898 /// <summary>
9999 /// Updates this audio controller
100- /// </summary>
100+ /// </summary>
101101 public void Update ( )
102102 {
103- int index = 0 ;
104-
105- while ( index < _activeSoundEffectInstances . Count )
103+ for ( int i = _activeSoundEffectInstances . Count - 1 ; i >= 0 ; i -- )
106104 {
107- SoundEffectInstance instance = _activeSoundEffectInstances [ index ] ;
105+ SoundEffectInstance instance = _activeSoundEffectInstances [ i ] ;
108106
109- if ( instance . State == SoundState . Stopped && ! instance . IsDisposed )
107+ if ( instance . State == SoundState . Stopped )
110108 {
111- instance . Dispose ( ) ;
112- _activeSoundEffectInstances . RemoveAt ( index ) ;
109+ if ( ! instance . IsDisposed )
110+ {
111+ instance . Dispose ( ) ;
112+ }
113+ _activeSoundEffectInstances . RemoveAt ( i ) ;
113114 }
114- index ++ ;
115115 }
116116 }
117117
Original file line number Diff line number Diff line change @@ -100,18 +100,18 @@ public AudioController()
100100 /// </summary>
101101 public void Update ( )
102102 {
103- int index = 0 ;
104-
105- while ( index < _activeSoundEffectInstances . Count )
103+ for ( int i = _activeSoundEffectInstances . Count - 1 ; i >= 0 ; i -- )
106104 {
107- SoundEffectInstance instance = _activeSoundEffectInstances [ index ] ;
105+ SoundEffectInstance instance = _activeSoundEffectInstances [ i ] ;
108106
109- if ( instance . State == SoundState . Stopped && ! instance . IsDisposed )
107+ if ( instance . State == SoundState . Stopped )
110108 {
111- instance . Dispose ( ) ;
112- _activeSoundEffectInstances . RemoveAt ( index ) ;
109+ if ( ! instance . IsDisposed )
110+ {
111+ instance . Dispose ( ) ;
112+ }
113+ _activeSoundEffectInstances . RemoveAt ( i ) ;
113114 }
114- index ++ ;
115115 }
116116 }
117117
Original file line number Diff line number Diff line change @@ -100,18 +100,18 @@ public AudioController()
100100 /// </summary>
101101 public void Update ( )
102102 {
103- int index = 0 ;
104-
105- while ( index < _activeSoundEffectInstances . Count )
103+ for ( int i = _activeSoundEffectInstances . Count - 1 ; i >= 0 ; i -- )
106104 {
107- SoundEffectInstance instance = _activeSoundEffectInstances [ index ] ;
105+ SoundEffectInstance instance = _activeSoundEffectInstances [ i ] ;
108106
109- if ( instance . State == SoundState . Stopped && ! instance . IsDisposed )
107+ if ( instance . State == SoundState . Stopped )
110108 {
111- instance . Dispose ( ) ;
112- _activeSoundEffectInstances . RemoveAt ( index ) ;
109+ if ( ! instance . IsDisposed )
110+ {
111+ instance . Dispose ( ) ;
112+ }
113+ _activeSoundEffectInstances . RemoveAt ( i ) ;
113114 }
114- index ++ ;
115115 }
116116 }
117117
You can’t perform that action at this time.
0 commit comments