예제 #1
0
    void Update()
    {
        float h = Input.GetAxis("Horizontal");

        if (h <= -0.5f && priorH > -0.5f)
        {
            sound.PlayRandomSound();
            yes = true;
            UpdateText();
        }
        else if (h >= 0.5f && priorH < 0.5f)
        {
            sound.PlayRandomSound();
            yes = false;
            UpdateText();
        }

        priorH = h;

        if (Input.GetButtonDown("Jump"))
        {
            SceneManager.LoadScene(yes ? "Game" : "Menu");
        }
    }
예제 #2
0
    void Update()
    {
        float h = Input.GetAxis("Horizontal");
        float v = Input.GetAxis("Vertical");

        if (h <= -0.5f && priorH > -0.5f)
        {
            if (menuIndex == 1)
            {
                sound.PlayRandomSound();
                GameState.problemIndex--;
                if (GameState.problemIndex < 0)
                {
                    GameState.problemIndex += problemMenuVals.Length;
                }
            }
            else if (menuIndex == 2)
            {
                sound.PlayRandomSound();
                GameState.speedIndex--;
                if (GameState.speedIndex < 0)
                {
                    GameState.speedIndex += speedMenuVals.Length;
                }
            }
            UpdateText();
        }
        else if (h >= 0.5f && priorH < 0.5f)
        {
            if (menuIndex == 1)
            {
                sound.PlayRandomSound();
                GameState.problemIndex = (GameState.problemIndex + 1) % problemMenuVals.Length;
            }
            else if (menuIndex == 2)
            {
                sound.PlayRandomSound();
                GameState.speedIndex = (GameState.speedIndex + 1) % speedMenuVals.Length;
            }
            UpdateText();
        }

        if (v <= -0.5f && priorV > -0.5f)
        {
            sound.PlayRandomSound();
            menuIndex = (menuIndex + 1) % MENU_ITEM_COUNT;
            UpdateText();
        }
        else if (v >= 0.5f && priorV < 0.5f)
        {
            sound.PlayRandomSound();
            menuIndex--;
            if (menuIndex < 0)
            {
                menuIndex += MENU_ITEM_COUNT;
            }
            UpdateText();
        }

        priorH = h;
        priorV = v;

        if (Input.GetButtonDown("Jump"))
        {
            if (menuIndex == 3)
            {
                Application.Quit();
            }
            else if (menuIndex == 0)
            {
                // Set problems
                switch (GameState.problemIndex)
                {
                case 0:
                    GameState.problemGenerator = new Addition1();
                    break;

                case 1:
                    GameState.problemGenerator = new Addition2();
                    break;

                case 2:
                    GameState.problemGenerator = new Subtraction1();
                    break;

                case 3:
                    GameState.problemGenerator = new Subtraction2();
                    break;

                case 4:
                    GameState.problemGenerator = new Multiplication1();
                    break;

                case 5:
                    GameState.problemGenerator = new Division1();
                    break;

                case 6:
                    GameState.problemGenerator = new Multiple1();
                    break;

                case 7:
                    GameState.problemGenerator = new Comparison1();
                    break;

                case 8:
                    GameState.problemGenerator = new Primes1();
                    break;

                case 9:
                    GameState.problemGenerator = new AllProblems();
                    break;
                }

                // Set speed
                float[] speeds = { GameState.SLOW_SCROLL_SPEED, GameState.NORMAL_SCROLL_SPEED, GameState.FAST_SCROLL_SPEED };
                GameState.runningSpeed = speeds[GameState.speedIndex];

                SceneManager.LoadScene("Game");
            }
        }
    }