Stop() public method

public Stop ( AudioStopOptions options ) : void
options AudioStopOptions
return void
示例#1
0
 public void Stop(AudioStopOptions options)
 {
     lock (activeCues)
     {
         while (activeCues.Count > 0)
         {
             Cue curCue = activeCues[0];
             curCue.Stop(options);
         }
         activeCues.Clear();
         if (options == AudioStopOptions.Immediate)
         {
             lock (dyingCues)
             {
                 while (dyingCues.Count > 0)
                 {
                     Cue curCue = dyingCues[0];
                     curCue.Stop(AudioStopOptions.Immediate);
                 }
                 dyingCues.Clear();
             }
         }
         foreach (List <Cue> count in cueInstanceCounts.Values)
         {
             count.Clear();
         }
         foreach (AudioCategory ac in subCategories)
         {
             ac.Stop(options);
         }
     }
 }
示例#2
0
 public void Stop(AudioStopOptions options)
 {
     while (activeCues.Count > 0)
     {
         Cue curCue = activeCues[0];
         curCue.Stop(options);
         curCue.SetVariable("NumCueInstances", 0);
         cueInstanceCounts[curCue.Name] -= 1;
     }
     activeCues.Clear();
 }
示例#3
0
 private SoundManager()
 {
     _audioEngine = new AudioEngine("Content/Sounds/TetrisGame.xgs");
     _waveBank = new WaveBank(_audioEngine, "Content/Sounds/WaveBank.xwb");
     _soundBank = new SoundBank(_audioEngine, "Content/Sounds/SoundBank.xsb");
     _audioEngine.Update();
     _currentMusic = _soundBank.GetCue("m_Silence");
     _currentMusic.Stop(AudioStopOptions.Immediate);
     _currentSounds = new Cue[20];
     SetMusicVolume(100);
     SetSoundVolume(100);
 }
示例#4
0
 public void Stop(AudioStopOptions options)
 {
     lock (activeCues)
     {
         while (activeCues.Count > 0)
         {
             Cue curCue = activeCues[0];
             curCue.Stop(options);
         }
         activeCues.Clear();
         foreach (List <Cue> count in cueInstanceCounts.Values)
         {
             count.Clear();
         }
     }
 }
示例#5
0
        public override void Apply(Cue cue, XACTClip track, float elapsedTime)
        {
            StopEvent evt = (StopEvent)Event;

            AudioStopOptions stopOptions = evt.StopOptions;

            switch (evt.Scope)
            {
            case XACTClip.StopEventScope.Cue:
                cue.Stop(stopOptions);
                break;

            case XACTClip.StopEventScope.Track:
                /* FIXME: Need to stop this and ONLY this track
                 * track.Stop(stopOptions);
                 */
                break;
            }

            Played = true;
        }
示例#6
0
        public GameOverScreen(PlayerIndex p1Index, PlayerIndex? p2Index, Player p1, Player p2, Cue actionBgm)
            : base("Game Over")
        {
            this.p1Index = p1Index;
            this.p2Index = p2Index;
            this.p1 = p1;
            this.p2 = p2;

            if (actionBgm.IsPlaying) actionBgm.Stop(AudioStopOptions.Immediate);

            MenuEntry share = new MenuEntry("Share Highscore");
            MenuEntry restart = new MenuEntry("Restart Game");
            MenuEntry back = new MenuEntry("Exit to Menu");

            share.Selected += ShareSelected;
            restart.Selected += RestartSelected;
            back.Selected += BackSelected;

            MenuEntries.Add(restart);
            MenuEntries.Add(share);
            MenuEntries.Add(back);
        }
        public void Restart()
        {
            firstPlayerHasJoined = false;
            App.Instance.Model.AddPlayer += new EventHandler<SurfaceTower.Model.EventArguments.PlayerArgs>(OnAddPlayer);
            App.Instance.Model.RemovePlayer += new EventHandler<SurfaceTower.Model.EventArguments.PlayerArgs>(OnRemovePlayer);
            App.Instance.Model.NewEnemy += new EventHandler<SurfaceTower.Model.EventArguments.EnemyArgs>(OnNewEnemy);
            App.Instance.Model.Tower.ZeroHealth += new EventHandler(Tower_ZeroHealth);

            heartbeatCue = soundBank.GetCue("Hearbeat");
            introCue = soundBank.GetCue("Intro");
            introCue.Play();

            audioEngine.GetCategory("Music").SetVolume(MelodyPlayer.musicVolume);
            audioEngine.GetCategory("Drums").SetVolume(DrumPlayer.drumVolume);
            
            if(heartbeatCue.IsPlaying)
                heartbeatCue.Stop(AudioStopOptions.Immediate);

            if(heartbeatOnlyMode)
                heartbeatOnlyMode = false;

            if (outroCue != null && outroCue.IsPlaying)
                outroCue.Stop(AudioStopOptions.Immediate);
        }
示例#8
0
 /// <summary>
 /// Stops a sound immediately.
 /// </summary>
 /// <param name="cue">The handle of the sound to stop.</param>
 public static void stopCue(Cue cue)
 {
     cue.Stop(AudioStopOptions.Immediate);
 }
示例#9
0
        public void ChangeGameState(GameState state, int level)
        {
            if(splashDelay < 0){
            currentGameState = state;
            CancelPowerUps();

            switch (currentGameState)
            {
                case GameState.START:
                    splashDelay = 10;
                    splashScreen.SetData("Welcome to space Defender!",
                        GameState.START);
                    modelManager.Enabled = false;
                    modelManager.Visible = false;
                    splashScreen.Enabled = true;
                    splashScreen.Visible = true;
                    startMenu.Visible = false;
                    startMenu.Enabled = false;
                    break;

                case GameState.LEVEL_CHANGE:
                    splashScreen.SetData("Level " + (level + 1),
                        GameState.LEVEL_CHANGE);
                    modelManager.Enabled = false;
                    modelManager.Visible = false;
                    splashScreen.Enabled = true;
                    splashScreen.Visible = true;

                    //Stop the sound track look
                    trackCue.Stop(AudioStopOptions.Immediate);
                    break;

                case GameState.PLAY:
                    modelManager.Enabled = true;
                    modelManager.Visible = true;
                    splashScreen.Enabled = false;
                    splashScreen.Visible = false;

                    if (trackCue.IsPlaying)
                        trackCue.Stop(AudioStopOptions.Immediate);

                    //To play a stopped cue, get the cue from the sound back a gian
                    trackCue = soundBank.GetCue("Tracks");
                    trackCue.Play();
                    break;

                case GameState.END:
                    splashScreen.SetData("Game Over.\nLevel: " + (level + 1) +
                        "\nScore: " + score, GameState.END);
                    modelManager.Enabled = false;
                    modelManager.Visible = false;
                    splashScreen.Enabled = true;
                    splashScreen.Visible = true;

                    //Stop the sound loop
                    trackCue.Stop(AudioStopOptions.Immediate);
                    break;

                case GameState.PAUSE:
                    splashScreen.SetData("Game Paused",
                        GameState.PAUSE);
                    modelManager.Enabled = false;
                    modelManager.Visible = false;
                    splashScreen.Enabled = true;
                    splashScreen.Visible = true;

                    //Stop the sound track look
                    trackCue.Stop(AudioStopOptions.Immediate);
                    break;

                case GameState.MENU:
                    splashDelay = 10;
                    modelManager.Enabled = false;
                    modelManager.Visible = false;
                    splashScreen.Enabled = false;
                    splashScreen.Visible = false;
                    startMenu.Visible = true;
                    startMenu.Enabled = true;
                    about.Visible = false;
                    about.Enabled = false;
                    instructions.Visible = false;
                    instructions.Enabled = false;
                    break;

                case GameState.ABOUT:
                    splashDelay = 10;
                    modelManager.Enabled = false;
                    modelManager.Visible = false;
                    splashScreen.Enabled = false;
                    splashScreen.Visible = false;
                    startMenu.Visible = false;
                    startMenu.Enabled = false;
                    about.Visible = true;
                    about.Enabled = true;
                    break;

                case GameState.INSTRUCTIONS:
                    splashDelay = 10;
                    modelManager.Enabled = false;
                    modelManager.Visible = false;
                    splashScreen.Enabled = false;
                    splashScreen.Visible = false;
                    startMenu.Visible = false;
                    startMenu.Enabled = false;
                    about.Visible = false;
                    about.Enabled = false;
                    instructions.Visible = true;
                    instructions.Enabled = true;
                    break;
            }
            }
        }
示例#10
0
文件: Audio.cs 项目: bradleat/trafps
 public Cue Stop(Cue cue)
 {
     cue.Stop(AudioStopOptions.AsAuthored);
     return cue;
 }
示例#11
0
文件: Game1.cs 项目: CS583/3D-Game
        public void ChangeGameState(GameState state, int level)
        {
            currentGameState = state;
            CancelPowerUps();

            switch (currentGameState)
            {
                case GameState.LEVEL_CHANGE:
                    splashScreen.SetData("Level " + (level + 1),
                        GameState.LEVEL_CHANGE);
                    modelManager.Enabled = false;
                    modelManager.Visible = false;
                    splashScreen.Enabled = true;
                    splashScreen.Visible = true;

                    //Stop the sound track look
                    trackCue.Stop(AudioStopOptions.Immediate);
                    break;

                case GameState.PLAY:
                    modelManager.Enabled = true;
                    modelManager.Visible = true;
                    splashScreen.Enabled = false;
                    splashScreen.Visible = false;

                    if (trackCue.IsPlaying)
                        trackCue.Stop(AudioStopOptions.Immediate);

                    //To play a stopped cue, get the cue from the sound back a gian
                    trackCue = soundBank.GetCue("Tracks");
                    trackCue.Play();
                    break;

                case GameState.END:
                    splashScreen.SetData("Game Over.\nLevel: " + (level + 1) +
                        "\nScore: " + score, GameState.END);
                    modelManager.Enabled = false;
                    modelManager.Visible = false;
                    splashScreen.Enabled = true;
                    splashScreen.Visible = true;

                    //Stop the sound loop
                    trackCue.Stop(AudioStopOptions.Immediate);
                    break;

            }
        }
示例#12
0
        /// <summary>
        /// stops the sound
        /// </summary>
        /// <param name="cue">playing sound</param>
        public bool StopSound(Cue cue)
        {
            if (soundOn == false || cue == null)
                return false;

            if (cue.IsPaused || cue.IsPlaying)
            {
                cue.Stop(AudioStopOptions.Immediate);
                return true;
            }

            return false;
        }
示例#13
0
 private void CloseSoundMain()
 {
     if (engineSound != null)
     {
         engineSound = soundBank.GetCue(bgmname);
         engineSound.Stop(AudioStopOptions.AsAuthored);
         waveBank.Dispose();
         soundBank.Dispose();
         engineSound.Dispose();
         audioEngine.Update();
     }
 }
示例#14
0
 /// <summary>
 /// Immediatly stops the sound currently playing.
 /// </summary>
 /// <param name="cue">The sound to be stopped</param>
 public static void StopSound(Cue cue)
 {
     cue.Stop(AudioStopOptions.AsAuthored);
 }
示例#15
0
 public void StopCue(Cue cue, AudioStopOptions options = AudioStopOptions.AsAuthored)
 {
     if (!cue.IsStopped)
     {
         cue.Stop(options);
     }
 }
示例#16
0
 private void StopSoundMainSE(string se)
 {
     if (engineSound2 != null)
     {
         engineSound2 = soundBank2.GetCue(se);
         engineSound2.Stop(AudioStopOptions.AsAuthored);
         waveBank2.Dispose();
         soundBank2.Dispose();
         engineSound2.Dispose();
         audioEngine.Update();
         engineSound2 = null;
     }
 }
示例#17
0
 public void Stop(Cue cue)
 {
     cue.Stop(AudioStopOptions.Immediate);
 }
示例#18
0
        /// <summary>
        /// Begin playing the music and beat tracking.
        /// </summary>
        public void play()
        {
            tick.Reset();
            ResetBeats();

            try
            {
            #if WINDOWS
                // System.Diagnostic.Debug.WriteLine("Playing: " + track.IsPlaying +
                    //"\n Stopped: " + track.IsStopped +
                    //"\n Stopping: " + track.IsStopping +
                    //"\n Prepared: " + track.IsPrepared +
                    //"\n Preparing: " + track.IsPreparing +
                    //"\n Created: " + track.IsCreated;
            #endif
                //if (!track.IsPlaying)//Sometimes track.IsPlaying is true although track.IsDisposed is also true
                {
                    track = soundBank.GetCue(currentTrack);
                    track.Play();
                }
            }
            catch (Exception e)
            {
                //System.Diagnostics.Debug.WriteLine(e.Message);
                if (track.IsPlaying)
                {
                    track.Stop(AudioStopOptions.Immediate);
                }
                track = soundBank.GetCue(currentTrack);
                while (track.IsPreparing)
                {
                }
                track.Play();
            }
            tick.Start();
            shouldPlay = true;
        }
示例#19
0
        public virtual void Update(DodgerX gameobject, GameTime gameTime)
        {
            if (prevmousestate == null) prevmousestate = Mouse.GetState();
            ElapseCounter += gameTime.ElapsedGameTime;
            if (ElapseCounter > SpawnObjectDelay)
            {

                ElapseCounter = ElapseCounter - SpawnObjectDelay;
                for (int i = 0; i < 2; i++)
                {
                    AttackingObject ao = new AttackingObject(new Vector2(0, 0), new Vector2(0, 0),
                                                             gameobject.attackerTexture);
                    ao.SetRandomStartPosition(gameobject, 8);

                    grd.Attackers.Add(ao);
                }

            }
            _grd.Update(gameobject, gameTime);
            MenuSelect = DodgerX.soundBank.GetCue("MenuSel");
            //Update the selected item based on the mouse position.
            MenuStateItem foundhit = null;
            foreach (var msi in MenuItems)
            {

                if (msi.HitTest(gameobject, new Vector2(Mouse.GetState().X, Mouse.GetState().Y)))
                {
                    foundhit = msi;
                    break;
                }

            }
            if (SelectedItem != foundhit)
            {
                if (MenuSelect.IsPlaying) MenuSelect.Stop(AudioStopOptions.AsAuthored);
                try
                {
                    MenuSelect.Play();
                } catch
                {
                }
            }
            SelectedItem = foundhit;
            Debug.Print("SelectedItem is now " + (SelectedItem==null?"Null":SelectedItem.Caption));

            if (SelectedItem != null)
            {

                if (Mouse.GetState().LeftButton == ButtonState.Pressed && prevmousestate.Value.LeftButton==ButtonState.Released)
                {

                    //gameobject.CurrentState = SelectedItem.AdvanceState;
                    InvokeClick(SelectedItem,gameobject);
                    SelectedItem.AdvanceRoutine(SelectedItem, gameobject);

                }

            }

            prevmousestate = Mouse.GetState();
        }
示例#20
0
 /// <summary>
 /// Stops a previously playing cue
 /// </summary>
 /// <param name="cue">The cue to stop that you got returned from Play(sound)
 /// </param>
 public static void Stop(Cue cue)
 {
     if (cue != null)
     {
         cue.Stop(AudioStopOptions.Immediate);
     }
 }