Beispiel #1
0
        public void FireSoundPlay(iActiveSoundObject soundPlayed)
        {
            OnSoundPlayDelegate temp = OnSoundPlay;

            if (temp != null)
            {
                temp(soundPlayed);
            }
        }
Beispiel #2
0
        public void FireSoundStop(iActiveSoundObject soundStopped)
        {
            OnSoundStopDelegate temp = OnSoundStop;

            if (temp != null)
            {
                temp(soundStopped);
            }
        }
        void usedriver_OnSoundStop(iActiveSoundObject objstop)
        {
            if (objstop == playedsound)
            {
                SetStopState();
                usedriver.OnSoundStop -= usedriver_OnSoundStop;

            }
        }
        private void tsPlaysound_DropDownOpening(object sender, EventArgs e)
        {
            ToolStripDropDownItem source = sender as ToolStripDropDownItem;
            if (source == null) return;
            if (!soundlistInit || KeyboardInfo.IsPressed(Keys.ShiftKey))
            {
                soundlistInit = true;
                source.DropDown.Items.Clear();

                var stopall = new ToolStripMenuItem("Stop", null, (o, ev) => { if (menuplayingsound != null) menuplayingsound.Stop(); });
                source.DropDown.Items.Add(stopall);
                source.DropDown.Items.Add(new ToolStripSeparator());

                foreach (var iterate in BCBlockGameState.Soundman.SoundSources.Keys)
                {
                    var newitem = new ToolStripMenuItem(iterate, null, (obj, earg) =>
            {
            var sourceobject = (((ToolStripDropDownItem)obj).Tag as iSoundSourceObject);

            menuplayingsound = sourceobject.Play(false, 1.0f);

            });
                    newitem.Tag = BCBlockGameState.Soundman.SoundSources[iterate];

                    source.DropDown.Items.Add(newitem);

                }

            }
        }
 private void SetStopState()
 {
     playedsound.Stop();
     cmdPlayStop.Invoke((MethodInvoker)(() => { cmdPlayStop.Text = "&Play"; }));
     if (PositionUpdateTimer != null)
     {
         PositionUpdateTimer.Dispose();
         PositionUpdateTimer = null;
     }
     playedsound = null;
     playingsound = null;
     //File.Delete(mTempFilename);
     BCBlockGameState.QueueDelete(mTempFilename);
     mTempFilename = "";
 }
        private void cmdPlayStop_Click(object sender, EventArgs e)
        {
            String useext = txtFileType.Text;
            //If currently playing; stop. Otherwise, play the sound data in LoadedSoundData.
            if (playingsound == null && LoadedSoundData !=null)
            {

                usedriver = BCBlockGameState.Soundman.Driver;
                mTempFilename = BCBlockGameState.GetTempFile(useext);
                //write the sounddata to that file.
                FileStream writesound = new FileStream(mTempFilename, FileMode.Create);
                writesound.Write(LoadedSoundData, 0, LoadedSoundData.Length);
                writesound.Close();
                //load a sound object from the current Driver...
                usedriver.OnSoundStop += new OnSoundStopDelegate(usedriver_OnSoundStop);

                playingsound = usedriver.LoadSound(mTempFilename);

                playedsound = playingsound.Play(false);

                cmdPlayStop.Text = "&Stop";
                //start the PositionUpdate Timer.
                PositionUpdateTimer = new Timer((w) => BeginInvoke((MethodInvoker)(() => { UpdateSoundPos(); })),null,0,250);

            }
            else
            {
                PositionUpdateTimer.Dispose();
                PositionUpdateTimer = null;
                playedsound.Stop();
                // usedriver_OnSoundStop(playedsound);
                cmdPlayStop.Text = "&Play";
                SetStopState();
            }
        }
Beispiel #7
0
 public void FireSoundStop(iActiveSoundObject soundStopped)
 {
     OnSoundStopDelegate temp = OnSoundStop;
     if (temp != null)
         temp(soundStopped);
 }
Beispiel #8
0
 public void FireSoundPlay(iActiveSoundObject soundPlayed)
 {
     OnSoundPlayDelegate temp = OnSoundPlay;
     if (temp != null)
         temp(soundPlayed);
 }
        public override void GameProc(IStateOwner pOwner)
        {
            if (ReplayData == null)
            {
                ReplayData = new StatefulReplay();
            }
            if (!FirstRun)
            {
                if (GameOptions.MusicEnabled)
                {
                    iActiveSoundObject musicplay = null;
                    if (pOwner.Settings.std.MusicOption == "<RANDOM>")
                    {
                        musicplay = Sounds.PlayMusic(pOwner.AudioThemeMan.BackgroundMusic.Key, pOwner.Settings.std.MusicVolume, true);
                    }
                    else
                    {
                        musicplay = Sounds.PlayMusic(pOwner.Settings.std.MusicOption, pOwner.Settings.std.MusicVolume, true);
                    }


                    if (musicplay != null)
                    {
                        musicplay.Tempo = 1f;
                    }
                    FirstRun = true;
                    GameHandler.PrepareField(this, pOwner);
                }
            }

            //update particles.

            FrameUpdate();
            if (pOwner.GameStartTime == DateTime.MinValue)
            {
                pOwner.GameStartTime = DateTime.Now;
            }
            if (pOwner.LastPausedTime != DateTime.MinValue)
            {
                pOwner.GameStartTime += (DateTime.Now - pOwner.LastPausedTime);
                pOwner.LastPausedTime = DateTime.MinValue;
                foreach (var iterate in PlayField.BlockGroups)
                {
                    iterate.LastFall           = pOwner.GetElapsedTime();
                    iterate.HighestHeightValue = 0;
                }
            }


            PlayField.AnimateFrame();
            HandleActiveGroups(pOwner);

            if (GameOvered)
            {
                //For testing: write out the replay data as a sequence of little images.
                //ReplayData.WriteStateImages("T:\\ReplayData");
                Sounds.StopMusic();
                pOwner.FinalGameTime = DateTime.Now - pOwner.GameStartTime;
                GameHandler.Statistics.TotalGameTime = pOwner.FinalGameTime;
                NextAngleOffset = 0;
                pOwner.EnqueueAction(() => { pOwner.CurrentState = new GameOverGameState(this, GameHandler.GetGameOverStatistics(this, pOwner)); });
            }

            if (PlayField.BlockGroups.Count == 0 && !SpawnWait && !pOwner.CurrentState.GameProcSuspended && !NoTetrominoSpawn)
            {
                SpawnWait = true;
                pOwner.EnqueueAction
                    (() =>
                {
                    SpawnNewTetromino(pOwner);
                    SpawnWait = false;
                });
            }
        }
Beispiel #10
0
 void Driver_OnSoundStop(iActiveSoundObject objstop)
 {
     if(PlayingSounds.Contains(objstop))
         PlayingSounds.Remove(objstop);
 }
Beispiel #11
0
 void Driver_OnSoundPlay(iActiveSoundObject objplay)
 {
     PlayingSounds.Add(objplay);
 }
 void mDriver_OnSoundStop(iActiveSoundObject objstop)
 {
     //	throw new NotImplementedException();
     if(objstop!=null)
     PlayingSounds.Remove(objstop);
 }
        public void StopMusic()
        {
            if (mPlayingMusic != null)
                mPlayingMusic.Stop();

            mPlayingMusic=null;
        }
        public iActiveSoundObject PlayMusic(String key,float volume,bool loop)
        {
            iSoundSourceObject getsource = GetSoundRnd(key);
            if (mPlayingMusic != null)
            {
                if (getsource == mPlayingMusicSource && mPlayingMusic.Paused)
                    mPlayingMusic.UnPause();
                else
                    mPlayingMusic.Stop();
            }

            iActiveSoundObject soundobj = getsource.Play(loop,volume);
            mPlayingMusicSource = getsource;
            mPlayingMusic = soundobj;
            return soundobj;
        }