Exemplo n.º 1
0
        protected override void Update(GameTime gameTime)
        {
            switch (CurrentGameState)
            {
            case GameState.MainMenu:                                                //Check for Clicks in Main Menu
                if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)
                {
                    this.Exit();
                }
                while (TouchPanel.IsGestureAvailable)
                {
                    GestureSample gesture = TouchPanel.ReadGesture();

                    switch (gesture.GestureType)
                    {
                    case (GestureType.Tap):
                        if (createBeatmapsButton.checkClick(gesture))
                        {
                            this.CurrentGameState = GameState.SongLoadMenu;         // actual
                            this.menuIdentifier   = GameState.BeatmapCreator;
                            //this.CurrentGameState = GameState.TestMenu; //testing purposes
                            loadMenu      = new SongLoadMenu(this.Content);
                            BeatTimerList = new List <BeatTimerData>();        //Actual
                            //MediaPlayer.Play(munchymonk); //debug
                        }
                        ;
                        if (playBeatmapsButton.checkClick(gesture))
                        {
                            endTime = 9999999;
                            this.CurrentGameState = GameState.SongLoadMenu;
                            this.menuIdentifier   = GameState.Playing;
                            loadMenu = new SongLoadMenu(this.Content);
                        }
                        ;
                        break;
                    }
                }
                break;

            case GameState.SongLoadMenu:
                if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)
                {
                    CurrentGameState = GameState.MainMenu;
                    break;
                }
                while (TouchPanel.IsGestureAvailable)
                {
                    GestureSample gesture = TouchPanel.ReadGesture();

                    switch (gesture.GestureType)
                    {
                    case (GestureType.Tap):
                        switch (loadMenu.checkClick(gesture.Position))
                        {
                        //case GameState.Playing:
                        //    this.BeatTimerList = xmlConverter.loadBeatmapXML(DataSaver.SelectedXml());
                        //    this.LoadLateContent();
                        //    //MediaPlayer.Play(munchymonk);

                        //    CurrentGameState = GameState.Playing;
                        //    break;

                        case GameState.XMLLoadMenu:
                            if (menuIdentifier == GameState.Playing)
                            {
                                this.CurrentGameState = GameState.XMLLoadMenu;
                                loadMenu = new XMLLoadMenu(this.Content);
                            }
                            else
                            {
                                this.CurrentGameState = GameState.BeatmapCreator;
                                MediaPlayer.Play(DataSaver.SelectedSong());
                            }
                            break;

                        case GameState.MainMenu:
                            this.CurrentGameState = GameState.MainMenu;
                            break;
                        }

                        break;
                    }
                }
                break;

            case GameState.XMLLoadMenu:
                if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)
                {
                    CurrentGameState = GameState.MainMenu;
                    break;
                }
                while (TouchPanel.IsGestureAvailable)
                {
                    GestureSample gesture = TouchPanel.ReadGesture();

                    switch (gesture.GestureType)
                    {
                    case (GestureType.Tap):
                        switch (loadMenu.checkClick(gesture.Position))
                        {
                        case GameState.Playing:             //debug

                            this.BeatTimerList = xmlConverter.loadBeatmapXML(DataSaver.SelectedXml());
                            this.LoadLateContent();
                            MediaPlayer.Play(DataSaver.SelectedSong());
                            PointGenerator.ResetPoints();
                            CurrentGameState = GameState.Playing;
                            break;

                        case GameState.SongLoadMenu:
                            this.CurrentGameState = GameState.SongLoadMenu;
                            loadMenu = new SongLoadMenu(this.Content);
                            break;

                        case GameState.MainMenu:
                            this.CurrentGameState = GameState.MainMenu;
                            break;
                        }

                        break;
                    }
                }
                break;


            case GameState.Playing:                                                 //Check for Beat klicks
                if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)
                {
                    CurrentGameState = GameState.MainMenu;
                    MediaPlayer.Stop();
                    break;
                }
                while (TouchPanel.IsGestureAvailable)
                {
                    GestureSample gesture = TouchPanel.ReadGesture();

                    switch (gesture.GestureType)
                    {
                    case (GestureType.Tap):
                        checkIntersect(gesture.Position);
                        break;
                    }
                }
                if ((long)MediaPlayer.PlayPosition.TotalMilliseconds >= endTime)
                {
                    MediaPlayer.Stop();
                    CurrentGameState = GameState.ScoreMenu;
                }

                break;

            case GameState.BeatmapCreator:                                          //Check for Taps to create Beatmap
                if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)
                {
                    CurrentGameState = GameState.MainMenu;
                    MediaPlayer.Stop();
                    break;
                }
                TouchCollection touchcol = TouchPanel.GetState();
                foreach (TouchLocation touchlocation in touchcol)
                {
                    if (touchlocation.State == TouchLocationState.Released && isHeld)
                    {
                        int heldTime = (int)MediaPlayer.PlayPosition.TotalMilliseconds - gameTimeSinceHolding;

                        debugstring1 = "Held for: " + heldTime;
                        BeatTimerList.Add(new BeatTimerData(gameTimeSinceHolding, new Vector2(0, 0), new Vector2(0, 0), heldTime, false, true));     //Adds a Shaker reference with the start time as the screen was touched and the total shaker time as the touch was held.
                        isHeld = false;
                    }
                }

                while (TouchPanel.IsGestureAvailable)
                {
                    GestureSample gesture = TouchPanel.ReadGesture();

                    switch (gesture.GestureType)
                    {
                    case (GestureType.Tap):
                        if (returnToMainMenuButton.checkClick(gesture))
                        {
                            MediaPlayer.Stop();
                            this.CurrentGameState = GameState.SaveMenu;
                            Guide.BeginShowKeyboardInput(
                                PlayerIndex.One,
                                "Saving Beatmap",
                                "Title of Beatmap",
                                "",
                                saveBeatmapAs, null);
                            //this.LoadLateContent();
                        }
                        else
                        {
                            BeatTimerList.Add(new BeatTimerData((int)MediaPlayer.PlayPosition.TotalMilliseconds - 1100, gesture.Position, new Vector2(0, 0), 0, false, false));
                        };
                        break;

                    case (GestureType.Hold):

                        gameTimeSinceHolding = (int)MediaPlayer.PlayPosition.TotalMilliseconds - 1000;
                        debugstring2         = "held since: " + gameTimeSinceHolding + " since holding";
                        isHeld = true;
                        break;
                    }
                }
                break;

            case GameState.ScoreMenu:
                while (TouchPanel.IsGestureAvailable)
                {
                    GestureSample gesture = TouchPanel.ReadGesture();

                    switch (gesture.GestureType)
                    {
                    case (GestureType.Tap):
                        if (returnToMainMenuButton.checkClick(gesture))
                        {
                            this.CurrentGameState = GameState.MainMenu;
                        }
                        break;
                    }
                }
                break;
            }

            base.Update(gameTime);
        }