Exemplo n.º 1
0
    /// <summary>
    /// Control checking, and way more.
    /// </summary>
    void Update()
    {
        #if UNITY_STANDALONE_WIN
        if (fullscreenSwitch == 1)
        {
            StartCoroutine(RepositionWindow());
        }
        if (fullscreenSwitch > 0)
        {
            fullscreenSwitch--;
        }
        #endif

        stopScreenShake = false;
        if (isInFight || UnitaleUtil.IsOverworld)
        {
            frame++;
        }

        string sceneName = SceneManager.GetActiveScene().name;

        if (sceneName == "ModSelect")
        {
            lastSceneUnitale = true;
        }
        else
        {
            lastSceneUnitale = false;
        }

        // Activate Debugger
        if (UserDebugger.instance && Input.GetKeyDown(KeyCode.F9))
        {
            if (UserDebugger.instance.gameObject.activeSelf)
            {
                GameObject.Find("Text").transform.SetParent(UserDebugger.instance.gameObject.transform);
            }
            UserDebugger.instance.gameObject.SetActive(!UserDebugger.instance.gameObject.activeSelf);
            Camera.main.GetComponent <FPSDisplay>().enabled = UserDebugger.instance.gameObject.activeSelf;
            // Activate Hitbox Debugger
        }
        else if (isInFight && Input.GetKeyDown(KeyCode.H) && sceneName != "Error" && UserDebugger.instance.gameObject.activeSelf)
        {
            GameObject.Find("Main Camera").GetComponent <ProjectileHitboxRenderer>().enabled = !GameObject.Find("Main Camera").GetComponent <ProjectileHitboxRenderer>().enabled;
        }
        // Exit a battle or the Error scene
        else if (Input.GetKeyDown(KeyCode.Escape) && (canTransOW.Contains(sceneName) || isInFight))
        {
            if (isInFight && LuaEnemyEncounter.script.GetVar("unescape").Boolean&& sceneName != "Error")
            {
                return;
            }
            if (sceneName == "Error" && !modDev)
            {
                UnitaleUtil.ExitOverworld();
                SceneManager.LoadScene("Disclaimer");
                GameObject.Destroy(GameObject.Find("SpritePivot"));
                return;
            }

            if (GameOverBehavior.gameOverContainer)
            {
                if (GameOverBehavior.gameOverContainer.activeInHierarchy)
                {
                    GameObject.FindObjectOfType <GameOverBehavior>().EndGameOver();
                }
                else
                {
                    UIController.EndBattle();
                }
            }
            else
            {
                UIController.EndBattle();
            }
            //StaticInits.Reset();
            //Open the Menu in the Overworld
        }
        else if (input.Menu == UndertaleInput.ButtonState.PRESSED && !nonOWScenes.Contains(sceneName) && !isInFight && !isInShop && (!GameOverBehavior.gameOverContainerOw || !GameOverBehavior.gameOverContainerOw.activeInHierarchy))
        {
            if (!PlayerOverworld.instance.PlayerNoMove && EventManager.instance.script == null && !PlayerOverworld.instance.menuRunning[2] && !PlayerOverworld.instance.menuRunning[4] && (GameObject.Find("FadingBlack") == null || GameObject.Find("FadingBlack").GetComponent <Fading>().alpha <= 0))
            {
                StartCoroutine(PlayerOverworld.LaunchMenu());
            }
            //Wipe save and close CYF in the Error scene if save failed to load
        }
        else if (sceneName == "Error" && allowWipeSave && Input.GetKeyDown(KeyCode.R))
        {
            System.IO.File.Delete(Application.persistentDataPath + "/save.gd");
            Application.Quit();
        }

        if (isInFight)
        {
            switch (fleeIndex)
            {
            case 0:
                if (Input.GetKeyDown(KeyCode.F))
                {
                    fleeIndex++;
                }
                break;

            case 1:
                if (Input.GetKeyDown(KeyCode.L))
                {
                    fleeIndex++;
                }
                else if (Input.anyKeyDown)
                {
                    fleeIndex = 0;
                }
                break;

            case 2:
                if (Input.GetKeyDown(KeyCode.E))
                {
                    fleeIndex++;
                }
                else if (Input.anyKeyDown)
                {
                    fleeIndex = 0;
                }
                break;

            case 3:
                if (Input.GetKeyDown(KeyCode.E))
                {
                    fleeIndex++;
                }
                else if (Input.anyKeyDown)
                {
                    fleeIndex = 0;
                }
                break;

            case 4:
                if (Input.GetKeyDown(KeyCode.S))
                {
                    fleeIndex = -1; UIController.instance.SuperFlee();
                }
                else if (Input.anyKeyDown)
                {
                    fleeIndex = 0;
                }
                break;
            }
        }
        if (ScreenResolution.hasInitialized)
        {
            if (Input.GetKeyDown(KeyCode.F4) ||      // F4
                (Input.GetKeyDown(KeyCode.Return) &&
                 (Input.GetKey(KeyCode.LeftAlt) ||   // LAlt  + Enter
                  Input.GetKey(KeyCode.RightAlt))))  // RAlt  + Enter
            {
                ScreenResolution.SetFullScreen(!Screen.fullScreen);
                if (!Screen.fullScreen)
                {
                    StartCoroutine(UpdateMonitorSize());
                }
            }
        }
    }
Exemplo n.º 2
0
 /// <summary>
 /// Sends the player back to the title screen, making him lose his progression
 /// </summary>
 [CYFEventFunction] public void TitleScreen()
 {
     UnitaleUtil.ExitOverworld(false);
     SceneManager.LoadScene("TitleScreen");
     GameObject.Destroy(GameObject.Find("SpritePivot"));
 }
Exemplo n.º 3
0
    /// <summary>
    /// Run once per frame.
    /// </summary>
    private void Update()
    {
        // Update Discord RPC
        DiscordControls.Update();

        #if UNITY_STANDALONE_WIN
        // Reposition the window to the middle of the screen after exiting fullscreen
        if (fullscreenSwitch == 1)
        {
            StartCoroutine(RepositionWindow());
        }
        if (fullscreenSwitch > 0)
        {
            fullscreenSwitch--;
        }
        #endif

        // Frame counter used for logging purposes
        if (isInFight || UnitaleUtil.IsOverworld)
        {
            frame++;
        }

        string sceneName = SceneManager.GetActiveScene().name;

        // Activate Debugger
        if (UserDebugger.instance && Input.GetKeyDown(KeyCode.F9) && UserDebugger.instance.canShow)
        {
            UserDebugger.instance.gameObject.SetActive(!UserDebugger.instance.gameObject.activeSelf);
            Camera.main.GetComponent <FPSDisplay>().enabled = UserDebugger.instance.gameObject.activeSelf;
        }
        // Activate Hitbox Debugger
        else if (isInFight && Input.GetKeyDown(KeyCode.H) && sceneName != "Error" && UserDebugger.instance.gameObject.activeSelf)
        {
            gameObject.GetComponent <ProjectileHitboxRenderer>().enabled = !gameObject.GetComponent <ProjectileHitboxRenderer>().enabled;
        }
        // Exit a battle or the Error scene
        else if (Input.GetKeyDown(KeyCode.Escape) && (canTransOW.Contains(sceneName) || isInFight))
        {
            if (isInFight && EnemyEncounter.script.GetVar("unescape").Boolean&& sceneName != "Error")
            {
                return;
            }
            // The Error scene can only be exited if we entered the mod through the mod selection screen
            if (sceneName == "Error" && !modDev)
            {
                UnitaleUtil.ExitOverworld();
                SceneManager.LoadScene("Disclaimer");
                DiscordControls.StartTitle();
                Destroy(GameObject.Find("SpritePivot"));
                return;
            }

            if (GameOverBehavior.gameOverContainer)
            {
                if (GameOverBehavior.gameOverContainer.activeInHierarchy)
                {
                    FindObjectOfType <GameOverBehavior>().EndGameOver();
                }
                else
                {
                    UIController.EndBattle();
                }
            }
            else
            {
                UIController.EndBattle();
            }
        }
        // Open the Menu in the Overworld
        else if (input.Menu == UndertaleInput.ButtonState.PRESSED && !nonOWScenes.Contains(sceneName) && !isInFight && !isInShop && (!GameOverBehavior.gameOverContainerOw || !GameOverBehavior.gameOverContainerOw.activeInHierarchy))
        {
            if (!PlayerOverworld.instance.PlayerNoMove && EventManager.instance.script == null && !PlayerOverworld.instance.menuRunning[2] && !PlayerOverworld.instance.menuRunning[4] && (GameObject.Find("FadingBlack") == null || GameObject.Find("FadingBlack").GetComponent <Fading>().alpha <= 0))
            {
                StartCoroutine(PlayerOverworld.LaunchMenu());
            }
        }
        // Wipe save and close CYF in the Error scene if save failed to load
        else if (sceneName == "Error" && allowWipeSave && Input.GetKeyDown(KeyCode.R))
        {
            System.IO.File.Delete(Application.persistentDataPath + "/save.gd");
            Application.Quit();
        }

        // Enter fullscreen using given shortcuts
        if (!ScreenResolution.hasInitialized)
        {
            return;
        }
        if (!Input.GetKeyDown(KeyCode.F4) && (!Input.GetKeyDown(KeyCode.Return) || !Input.GetKey(KeyCode.LeftAlt) && !Input.GetKey(KeyCode.RightAlt)))
        {
            return;                                                                                                                                            // RAlt  + Enter
        }
        ScreenResolution.SetFullScreen(!Screen.fullScreen);
        if (!Screen.fullScreen)
        {
            StartCoroutine(UpdateMonitorSize());
        }
    }