public void Update(GtUserActionsListener pUser1ActionsListener)
        {
            //KeyPressed is used to control key press (keeping down is ignored)

            #region Reset KeyPressed if key is up

            if (pUser1ActionsListener.CurrentKeyboardState.IsKeyUp(Keys.Left))
            {
                KeyPressed[Keys.Left] = false;
            }

            if (pUser1ActionsListener.CurrentKeyboardState.IsKeyUp(Keys.Right))
            {
                KeyPressed[Keys.Right] = false;
            }

            if (pUser1ActionsListener.CurrentKeyboardState.IsKeyUp(Keys.Escape))
            {
                KeyPressed[Keys.Escape] = false;
            }

            #endregion

            #region Change Velocity

            if (pUser1ActionsListener.CurrentKeyboardState.IsKeyDown(Keys.Left) && !KeyPressed[Keys.Left])
            {
                if (this.VelocityValue > 30.0m)
                {
                    this.VelocityValue = this.VelocityValue - 5m;
                }

                KeyPressed[Keys.Left] = true;
            }
            if (pUser1ActionsListener.CurrentKeyboardState.IsKeyDown(Keys.Right) && !KeyPressed[Keys.Right])
            {
                if (this.VelocityValue < 100.0m)
                {
                    this.VelocityValue = this.VelocityValue + 5m;
                }

                KeyPressed[Keys.Right] = true;
            }

            #endregion

            if (pUser1ActionsListener.CurrentKeyboardState.IsKeyDown(Keys.Escape))
            {
                //this.fGameRoundState = EnumGameRoundState.Aborted;
                this.GameRoundState = EnumGameRoundState.Finished;
            }
        }
Example #2
0
        public void Update(GtUserActionsListener pUser1ActionsListener)
        {
            switch (this.CurrentScreen)
            {
            case EnumGameScreen.Undefined:
                this.CurrentScreen = EnumGameScreen.Main;
                this.AudioEffects.PlaySongTheme();

                break;

            case EnumGameScreen.Main:
                //Main => Menu
                if ((pUser1ActionsListener.IsKeyDownNow(Keys.Enter)) ||
                    (pUser1ActionsListener.CurrentGamePadState.IsButtonDown(Buttons.Start)))
                {
                    this.CurrentScreen          = EnumGameScreen.Menu;
                    this.MenuScreenSelectedItem = EnumMenuScreenItems.QuickPlay;

                    this.AudioEffects.StopSongTheme();
                    this.AudioEffects.PlayDoubleHit();
                }

                break;

            case EnumGameScreen.Menu:
                //Menu => ChooseSong
                if ((pUser1ActionsListener.IsKeyDownNow(Keys.Enter)) ||
                    (pUser1ActionsListener.CurrentGamePadState.IsButtonDown(Buttons.A)))
                {
                    switch (this.MenuScreenSelectedItem)
                    {
                    case EnumMenuScreenItems.QuickPlay:
                        try
                        {
                            this.AudioEffects.PlayDoubleHit();

                            LoadSongList();

                            this.CurrentScreen = EnumGameScreen.ChooseSong;
                        }
                        catch (Exception e)
                        {
                            //TODO: Show the error message (connection timeout, for example)

                            throw e;
                        }

                        break;

                    case EnumMenuScreenItems.Tune:
                        this.CurrentScreen = EnumGameScreen.Tune;
                        break;

                    case EnumMenuScreenItems.Quit:
                        this.CurrentScreen = EnumGameScreen.Quit;
                        break;
                    }

                    this.AudioEffects.PlayDoubleHit();
                }

                //change menu option - down
                if ((pUser1ActionsListener.IsKeyDownNow(Keys.Down)) ||
                    (pUser1ActionsListener.CurrentGamePadState.IsButtonDown(Buttons.DPadDown)))
                {
                    switch (this.MenuScreenSelectedItem)
                    {
                    case EnumMenuScreenItems.QuickPlay:
                        this.MenuScreenSelectedItem = EnumMenuScreenItems.Tune;
                        this.AudioEffects.PlaySingleHit();
                        break;

                    case EnumMenuScreenItems.Tune:
                        this.MenuScreenSelectedItem = EnumMenuScreenItems.Quit;
                        this.AudioEffects.PlaySingleHit();
                        break;

                    case EnumMenuScreenItems.Quit:
                        //nothing - this is the last one.
                        break;
                    }
                }

                //change menu option - up
                if ((pUser1ActionsListener.IsKeyDownNow(Keys.Up)) ||
                    (pUser1ActionsListener.CurrentGamePadState.IsButtonDown(Buttons.DPadUp)))
                {
                    switch (this.MenuScreenSelectedItem)
                    {
                    case EnumMenuScreenItems.QuickPlay:
                        //nothing - this is the first one.
                        break;

                    case EnumMenuScreenItems.Tune:
                        this.MenuScreenSelectedItem = EnumMenuScreenItems.QuickPlay;
                        this.AudioEffects.PlaySingleHit();
                        break;

                    case EnumMenuScreenItems.Quit:
                        this.MenuScreenSelectedItem = EnumMenuScreenItems.Tune;
                        this.AudioEffects.PlaySingleHit();
                        break;
                    }
                }

                break;

            case EnumGameScreen.Tune:
                //Tune => Menu (back)
                if ((pUser1ActionsListener.IsKeyDownNow(Keys.Escape)) ||
                    (pUser1ActionsListener.CurrentGamePadState.IsButtonDown(Buttons.B)))
                {
                    this.CurrentScreen          = EnumGameScreen.Menu;
                    this.MenuScreenSelectedItem = EnumMenuScreenItems.Tune;
                    this.AudioEffects.PlayDoubleHit();
                    break;
                }

                break;

            case EnumGameScreen.ChooseSong:

                //ChooseSong => Main (back)
                if ((pUser1ActionsListener.IsKeyDownNow(Keys.Escape)) ||
                    (pUser1ActionsListener.CurrentGamePadState.IsButtonDown(Buttons.B)))
                {
                    this.CurrentScreen          = EnumGameScreen.Menu;
                    this.MenuScreenSelectedItem = EnumMenuScreenItems.QuickPlay;
                    this.AudioEffects.PlayDoubleHit();
                    break;
                }

                //Change selected song - Next
                if ((pUser1ActionsListener.IsKeyDownNow(Keys.Down)) ||
                    (pUser1ActionsListener.CurrentGamePadState.IsButtonDown(Buttons.DPadDown)))
                {
                    if (this.SelectedSongIndex < (this.SongList.Count - 1))
                    {
                        this.SelectedSongIndex++;
                        this.AudioEffects.PlaySingleHit();
                    }
                    break;
                }

                //Change selected song - Prior
                if ((pUser1ActionsListener.IsKeyDownNow(Keys.Up)) ||
                    (pUser1ActionsListener.CurrentGamePadState.IsButtonDown(Buttons.DPadUp)))
                {
                    if (this.SelectedSongIndex > 0)
                    {
                        this.SelectedSongIndex--;
                        this.AudioEffects.PlaySingleHit();
                    }
                    break;
                }


                //ChooseSong => PlayingSong
                if ((pUser1ActionsListener.IsKeyDownNow(Keys.Enter)) ||
                    (pUser1ActionsListener.CurrentGamePadState.IsButtonDown(Buttons.A)))
                {
                    if (this.SelectedSong != null)
                    {
                        this.AudioEffects.PlayDoubleHit();

                        this.CurrentScreen = EnumGameScreen.PlayingSong;

                        this.fFileLoader.DownloadSong(this.SelectedSong);

                        this.SongPlayer.SetupSong(
                            this.SelectedSong.AudioFileName,
                            this.SelectedSong.TimeSignature);

                        this.SongPlayer.LoadStream();

                        this.GameRoundController.InitializeProperties();

                        var song          = this.SelectedSong;
                        var tickDataTable = this.fFileLoader.LoadTickDataTable(ref song);

                        this.GameRoundController.SetupSong(1,
                                                           this.SongPlayer,
                                                           song.Artist,
                                                           song.Album,
                                                           song.Song,
                                                           song.Pitch,
                                                           //new GtSceneGuitar(tickDataTable, pNumberOfVisibleBeats: 5));
                                                           new GtSceneGuitar(tickDataTable, pNumberOfVisibleBeats: 7));

                        this.GameRoundController.PlaySong();
                    }
                    break;
                }


                break;

            case EnumGameScreen.PlayingSong:
                if (pUser1ActionsListener.IsKeyDownNow(Keys.Space))
                {
                    switch (this.GameRoundController.GameRoundState)
                    {
                    case EnumGameRoundState.Playing:
                        this.GameRoundController.GameRoundState = EnumGameRoundState.Paused;
                        this.AudioEffects.PlaySingleHit();
                        break;

                    case EnumGameRoundState.Paused:
                        this.GameRoundController.GameRoundState = EnumGameRoundState.Playing;
                        this.AudioEffects.PlaySingleHit();
                        break;

                    case EnumGameRoundState.Finished:
                        this.GameRoundController.GameRoundState = EnumGameRoundState.Playing;
                        break;
                    }
                }

                if (pUser1ActionsListener.IsKeyDownNow(Keys.Escape))
                {
                    switch (this.GameRoundController.GameRoundState)
                    {
                    case EnumGameRoundState.Playing:
                        this.GameRoundController.GameRoundState = EnumGameRoundState.Aborting;
                        this.AudioEffects.PlaySingleHit();
                        break;

                    //case EnumGameRoundState.Paused:
                    //    this.GameRoundController.GameRoundState = EnumGameRoundState.Playing;
                    //    break;

                    case EnumGameRoundState.Finished:

                        this.CurrentScreen = EnumGameScreen.ChooseSong;

                        //reset the SongPlayer in order to play another song
                        if (this.SongPlayer != null)
                        {
                            this.SongPlayer.Dispose();
                            this.SongPlayer = new SongPlayer();
                        }

                        this.AudioEffects.PlayDoubleHit();
                        break;
                    }
                }


                if (pUser1ActionsListener.IsKeyDownNow(Keys.Enter))
                {
                    switch (this.GameRoundController.GameRoundState)
                    {
                    case EnumGameRoundState.Finished:

                        this.CurrentScreen = EnumGameScreen.ChooseSong;

                        //reset the SongPlayer in order to play another song
                        if (this.SongPlayer != null)
                        {
                            this.SongPlayer.Dispose();
                            this.SongPlayer = new SongPlayer();
                        }

                        this.AudioEffects.PlayDoubleHit();
                        break;
                    }
                }


                this.GameRoundController.Update(pUser1ActionsListener);

                break;
            }
        }