Exemplo n.º 1
0
    // Update is called once per frame
    void Update()
    {
        GlobalControls.lastTitle = true;
        if (GlobalControls.input.Confirm == UndertaleInput.ButtonState.PRESSED && phase == 0)
        {
            phase++;
            Camera.main.GetComponent <AudioSource>().Stop();
            StopCoroutine(TitlePhase1());
        }
        else if (phase == 1)
        {
            if (!initPhase)
            {
                initPhase = true;

                Camera.main.GetComponent <AudioSource>().clip = AudioClipRegistry.GetMusic("mus_menu");
                Camera.main.GetComponent <AudioSource>().Play();
                try {
                    if (!SaveLoad.Load())
                    {
                        SceneManager.LoadScene("EnterName");
                    }
                    else
                    {
                        GameObject.Find("PressEnterOrZ").SetActive(false);
                        GameObject.Find("Title").SetActive(false);
                        GameObject.Find("Title (1)").SetActive(false);
                        GameObject.Find("Back1").SetActive(false);
                        GameObject.Find("TextManagerName").GetComponent <TextManager>().SetHorizontalSpacing(2);
                        GameObject.Find("TextManagerLevel").GetComponent <TextManager>().SetHorizontalSpacing(2);
                        GameObject.Find("TextManagerTime").GetComponent <TextManager>().SetHorizontalSpacing(2);
                        GameObject.Find("TextManagerMap").GetComponent <TextManager>().SetHorizontalSpacing(2);
                        GameObject.Find("TextManagerName").GetComponent <TextManager>().SetTextQueue(new TextMessage[] { new TextMessage("[noskipatall]" + PlayerCharacter.instance.Name, false, true) });
                        GameObject.Find("TextManagerLevel").GetComponent <TextManager>().SetTextQueue(new TextMessage[] { new TextMessage("[noskipatall]" + (GlobalControls.crate ? "VL" : "LV") +
                                                                                                                                          PlayerCharacter.instance.LV, false, true) });
                        GameObject.Find("TextManagerTime").GetComponent <TextManager>().SetTextQueue(new TextMessage[] { new TextMessage("[noskipatall]" + UnitaleUtil.TimeFormatter(SaveLoad.savedGame.playerTime), false, true) });
                        GameObject.Find("TextManagerMap").GetComponent <TextManager>().SetTextQueue(new TextMessage[] { new TextMessage("[noskipatall]" + SaveLoad.savedGame.lastScene, false, true) });
                        tmName.SetTextQueue(new TextMessage[] { new TextMessage(PlayerCharacter.instance.Name, false, true) });
                        diff = calcTotalLength(tmName);
                        tmName.SetEffect(new ShakeEffect(tmName));
                    }
                } catch {
                    GlobalControls.allowWipeSave = true;
                    if (GlobalControls.crate)
                    {
                        UnitaleUtil.DisplayLuaError(StaticInits.ENCOUNTER, "U USED AN ODL VERSOIN OF CFY? IT ISN'T COMAPTIBEL.\n\n"
                                                    + "DELEET UR SAVE OT NOT HVAE DA ERRRO AGAIN. HREE: <b>\n"
                                                    + Application.persistentDataPath + "/save.gd</b>\n\n"
                                                    + "OR <b>PERS R NWO</b> TO DELEET SAV N CLOSE YCF.\n\n\n"
                                                    + "IF MOAR PORBLMES, TELL EM! :D\n\n");
                    }
                    else
                    {
                        UnitaleUtil.DisplayLuaError(StaticInits.ENCOUNTER, "Have you saved on a previous or newer version of CYF? Your save isn't compatible with this version.\n\n"
                                                    + "To fix this, you must delete your save file. It can be found here: \n<b>"
                                                    + Application.persistentDataPath + "/save.gd</b>\n\n"
                                                    + "Or, you can <b>Press R now</b> to delete your save and close CYF.\n\n\n"
                                                    + "Tell me if you have any more problems, and thanks for following my fork! ^^\n\n");
                    }
                }
            }
            else
            {
                if (GlobalControls.input.Right == UndertaleInput.ButtonState.PRESSED || GlobalControls.input.Left == UndertaleInput.ButtonState.PRESSED)
                {
                    setColor(choiceLetter == 2 ? 2 : (choiceLetter + 1) % 2);
                }
                if (GlobalControls.input.Up == UndertaleInput.ButtonState.PRESSED || GlobalControls.input.Down == UndertaleInput.ButtonState.PRESSED)
                {
                    setColor(choiceLetter == 2 ? 0 : 2);
                }
                else if (GlobalControls.input.Confirm == UndertaleInput.ButtonState.PRESSED)
                {
                    switch (choiceLetter)
                    {
                    case 0:
                        phase = -1;
                        StartCoroutine(LoadGame());
                        break;

                    case 1:
                        phase = 2;
                        GameObject.Find(firstPhaseEventNames[choiceLetter]).GetComponent <SpriteRenderer>().color = new Color(1, 1, 1, 1);
                        GameObject.Find("CanvasReset").transform.position = new Vector3(320, 240, -500);
                        setColor(0, 2);
                        break;

                    case 2:
                        SceneManager.LoadScene("EnterName");
                        break;
                    }
                }
            }
        }
        else if (phase == 2)
        {
            if (tmName.transform.localScale.x < 3)
            {
                tmName.transform.localScale    = new Vector3(tmName.transform.localScale.x + 0.01f, tmName.transform.localScale.y + 0.01f, 1);
                tmName.transform.localPosition = new Vector3(actualX - (((tmName.transform.localScale.x - 1) * diff) / 2),
                                                             actualY - (((tmName.transform.localScale.x - 1) * diff) / 6), tmName.transform.localPosition.z);
            }
            if (GlobalControls.input.Right == UndertaleInput.ButtonState.PRESSED || GlobalControls.input.Left == UndertaleInput.ButtonState.PRESSED)
            {
                setColor((choiceLetter + 1) % 2, 2);
            }
            else if (GlobalControls.input.Confirm == UndertaleInput.ButtonState.PRESSED)
            {
                if (choiceLetter == 1)
                {
                    Camera.main.GetComponent <AudioSource>().Stop();
                    Camera.main.GetComponent <AudioSource>().PlayOneShot(AudioClipRegistry.GetSound("intro_holdup"));
                    phase = -1;
                    StartCoroutine(NewGame());
                }
                else
                {
                    phase = 1;
                    GameObject.Find(secondPhaseEventNames[choiceLetter]).GetComponent <SpriteRenderer>().color = new Color(1, 1, 1, 1);
                    GameObject.Find("CanvasReset").transform.position = new Vector3(320, 240, 50);
                    tmName.transform.localPosition = new Vector3(actualX, actualY, tmName.transform.localPosition.z);
                    tmName.transform.localScale    = new Vector3(1, 1, 1);
                    setColor(0);
                }
            }
        }
    }