Пример #1
0
    // Deal with GUI components
    bool checkTouch(Vector3 pos)
    {
        Vector3    wp       = Camera.main.ScreenToWorldPoint(pos);
        Vector2    touchPos = new Vector2(wp.x, wp.y);
        Collider2D hit      = Physics2D.OverlapPoint(touchPos);

        if (hit != null && hit.transform.gameObject.tag == "GUI")
        {
            // Pause
            if (hit.transform.gameObject == pauseButton)
            {
                pauseScript.TogglePause();
            }
            // Resume from pause menu
            else if (hit.transform.gameObject == resumeButton)
            {
                pauseScript.Unpause();
            }
            else if (hit.transform.gameObject == restartButton)
            {
                // Unpause game
                pauseScript.Unpause();

                // Reload level
                SceneManager.LoadScene("Bruno");
            }
            else if (hit.transform.gameObject == mainMenuButton)
            {
                SceneManager.LoadScene("MainMenu");
            }
            return(true);
        }

        return(false);
    }
Пример #2
0
    // Update is called once per frame
    void Update()
    {
        // TODO: Hacky, but neccessary if we want accurate recording and not a real loading screen
        if (!firstStart)
        {
            recordDynamicState();
            firstStart = true;
        }

        updateLoopingSounds();

        CheckSwaps();

        if (inputReady)
        {
            foreach (ButtonToggleScript button in buttonsPressed)
            {
                button.TogglePressed();
            }
            buttonsPressed.Clear();
            foreach (MoveableScript m in needsSwap)
            {
                PerformSwap(m);
            }
            needsSwap.Clear();
            if (!WinScript.playerWin)
            {
                checkWin();
                checkFailState();
            }
            Direction dir = readInput();
            if (dir != Direction.NONE && !WinScript.playerWin)
            {
                inputReady = false;
                move(dir);
            }
        }
        else
        {
            inputReady = (!WinScript.playerWin && getAllDone());
            pauseReady = (!WinScript.playerWin);
        }
        if (pauseReady && checkPause())
        {
            pausescript.TogglePause();
            tutorial.enabled = !tutorial.enabled;
            tutorialCanvas.SetActive(!tutorialCanvas.activeInHierarchy);
        }
        else if (pauseReady && Input.GetKeyDown(KeyCode.Escape))
        {
            if (pausescript.paused)
            {
                LoadLevelSelect.LoadSceneEscFromPause();
            }
            else
            {
                pausescript.TogglePause();
                tutorial.enabled = !tutorial.enabled;
                tutorialCanvas.SetActive(!tutorialCanvas.activeInHierarchy);
            }
        }
        if (pausescript.paused)
        {
            showRestartConfirm = false;
            restartConfirmText.SetActive(false);
            inputReady = false;
        }
        handleRestart();
    }