Ejemplo n.º 1
0
        public override void Update(double time, Game game)
        {
            //selector animation
            if (timePassed > timePerSelectorAnim)
            {
                selectorAnim++;
                selector.localPositions.Clear();
                for (int i = 0; i < 10; i++)
                {
                    selectorAnimation((selectorAnim + i) % 36);
                }
                if (selectorAnim > 36)
                {
                    selectorAnim = 0;
                }
                timePassed = 0;
            }
            timePassed += time;

            if (speedup)
            {
                if (speedupTimePassed > timeForSpeedup)
                {
                    timePerSelectorAnim = selectorAnimTick;
                    speedupTimePassed   = 0;
                    speedup             = false;
                }
                else
                {
                    float easeAmount = Ease.Exponential.In(speedupTimePassed / timeForSpeedup);
                    timePerSelectorAnim = Ease.Lerp(fastSelectorAnimTick, selectorAnimTick, easeAmount);
                }
                speedupTimePassed += (float)time;
            }


            if (menuSection == MenuSection.songSelect)
            {
                if (game.InputInstance.ButtonStates[Input.ButtonKind.Down] == Input.ButtonState.Press)
                {
                    if (selected < count)
                    {
                        selected++;
                    }
                    else
                    {
                        selected = 0;
                    }
                    containerHandler.AnimUp();
                    chartInfoVisual.UpdateChart(songs[selected].chart);
                    menuMusic.SelectNoise(songs[selected]);
                    speedup           = true;
                    speedupTimePassed = 0;
                }
                if (game.InputInstance.ButtonStates[Input.ButtonKind.Up] == Input.ButtonState.Press)
                {
                    if (selected > 0)
                    {
                        selected--;
                    }
                    else
                    {
                        selected = count;
                    }

                    containerHandler.AnimDown();
                    chartInfoVisual.UpdateChart(songs[selected].chart);
                    menuMusic.SelectNoise(songs[selected]);
                    speedup           = true;
                    speedupTimePassed = 0;
                }

                //a little out animation!


                if (game.InputInstance.ButtonStates[Input.ButtonKind.Confirm] == Input.ButtonState.Press)
                {
                    game.ChartToLoad = songs[selected].chartName;
                    game.SceneManagerInstance.LoadScene(6);
                }
                if (game.InputInstance.ButtonStates[Input.ButtonKind.Left] == Input.ButtonState.Press || game.InputInstance.ButtonStates[Input.ButtonKind.Right] == Input.ButtonState.Press)
                {
                    menuSection = MenuSection.optSelect;
                    hideSelector();
                    optionSelected = optSelections.options;
                    selectOpt();
                }
            }
            else if (menuSection == MenuSection.optSelect)
            {
                //else if is so juuuust in case, switching cant be at the same time as trying to press one of these
                if (game.InputInstance.ButtonStates[Input.ButtonKind.Left] == Input.ButtonState.Press)
                {
                    if (optionSelected == optSelections.quit)
                    {
                        optionSelected = optSelections.options;
                        selectOpt();
                    }
                    else if (optionSelected == optSelections.options)
                    {
                        menuSection = MenuSection.songSelect;
                        hideOptSelector();
                        showSelector();
                    }


                    //this line can check for either right now as there is only two options. I dont see any case where there would be more.
                }
                else if (game.InputInstance.ButtonStates[Input.ButtonKind.Right] == Input.ButtonState.Press)
                {
                    if (optionSelected == optSelections.options)
                    {
                        selectQuit();
                        optionSelected = optSelections.quit;
                    }
                    else if (optionSelected == optSelections.quit)
                    {
                        hideOptSelector();
                        showSelector();
                        menuSection = MenuSection.songSelect;
                    }
                }
                else if (game.InputInstance.ButtonStates[Input.ButtonKind.Confirm] == Input.ButtonState.Press)
                {
                    //follow through with the selectiooooon
                    if (optionSelected == optSelections.quit)
                    {
                        //THIS SHOULD BE THE ONLY PLACE IN THE CODE WHERE THIS LINE IS EVER WRITTEN. IF ITS ANYWHERE ELSE BAD THINGS COULD HAPPEN
                        Game.GameLoopLives = false;
                        game.Running       = false;
                    }
                    else if (optionSelected == optSelections.options)
                    {
                        game.SceneManagerInstance.LoadScene(4);
                    }
                }
            }
        }