public void EndGameOver()
 {
     if (!GlobalControls.modDev)
     {
         SaveLoad.Load(false);
     }
     if (!UnitaleUtil.IsOverworld)
     {
         UIController.EndBattle(true);
         Destroy(gameObject);
         if (GlobalControls.modDev)
         {
             SceneManager.LoadScene("ModSelect");
         }
     }
     else
     {
         EndGameOverRevive();
     }
     if (!GlobalControls.modDev)
     {
         TPHandler tp = Instantiate(Resources.Load <TPHandler>("Prefabs/TP On-the-fly"));
         tp.sceneName = LuaScriptBinder.Get(null, "PlayerMap").String;
         tp.position  = new Vector3((float)LuaScriptBinder.Get(null, "PlayerPosX").Number, (float)LuaScriptBinder.Get(null, "PlayerPosY").Number, LuaScriptBinder.Get(null, "PlayerPosZ") == null ? 0 : (float)LuaScriptBinder.Get(null, "PlayerPosZ").Number);
         tp.direction = 2;
         tp.noFadeIn  = true;
         tp.noFadeOut = false;
         GameObject.DontDestroyOnLoad(tp);
         tp.LaunchTPInternal();
     }
 }
Exemple #2
0
    [MoonSharpHidden] public LuaPlayerOW()
    {
        TPHandler tp = Resources.Load <TPHandler>("Prefabs/TP On-the-fly");

        if (tp != null && tp.ToString().ToLower() != "null")
        {
            tpOnTheFlyPrefab = tp;
        }
    }
    public void EndGameOver()
    {
        if (!GlobalControls.modDev)
        {
            SaveLoad.Load(false);
        }
        if (!UnitaleUtil.IsOverworld)
        {
            UIController.EndBattle(true);
            Destroy(gameObject);
            if (GlobalControls.modDev)
            {
                SceneManager.LoadScene("ModSelect");
            }
            else
            {
                foreach (string str in NewMusicManager.audioname.Keys)
                {
                    if (str == "StaticKeptAudio")
                    {
                        NewMusicManager.Stop(str);
                        ((AudioSource)NewMusicManager.audiolist[str]).clip = null;
                        ((AudioSource)NewMusicManager.audiolist[str]).time = 0;
                    }
                }
            }
        }
        else
        {
            EndGameOverRevive();
        }
        if (!GlobalControls.modDev)
        {
            TPHandler tp = Instantiate(Resources.Load <TPHandler>("Prefabs/TP On-the-fly"));
            tp.sceneName = LuaScriptBinder.Get(null, "PlayerMap").String;

            if (UnitaleUtil.MapCorrespondanceList.ContainsValue(tp.sceneName))
            {
                foreach (KeyValuePair <string, string> entry in UnitaleUtil.MapCorrespondanceList)
                {
                    if (entry.Value == tp.sceneName)
                    {
                        tp.sceneName = entry.Key;
                        break;
                    }
                }
            }

            tp.position  = new Vector3((float)LuaScriptBinder.Get(null, "PlayerPosX").Number, (float)LuaScriptBinder.Get(null, "PlayerPosY").Number, LuaScriptBinder.Get(null, "PlayerPosZ") == null ? 0 : (float)LuaScriptBinder.Get(null, "PlayerPosZ").Number);
            tp.direction = 2;
            tp.noFadeIn  = true;
            tp.noFadeOut = false;
            GameObject.DontDestroyOnLoad(tp);
            tp.LaunchTPInternal();
        }
    }
Exemple #4
0
    public void Teleport(string mapName, float posX, float posY, int direction = 0, bool NoFadeIn = false, bool NoFadeOut = false)
    {
        TPHandler tp = Object.Instantiate(Resources.Load <TPHandler>("Prefabs/TP On-the-fly"));

        tp.sceneName          = mapName;
        tp.position           = new Vector2(posX, posY);
        tp.direction          = direction;
        tp.noFadeIn           = NoFadeIn;
        tp.noFadeOut          = NoFadeOut;
        tp.transform.position = PlayerOverworld.instance.gameObject.transform.position;
        EventManager.instance.EndEvent();
    }
Exemple #5
0
    public void Teleport(string mapName, float posX, float posY, int direction = 0, bool NoFadeIn = false, bool NoFadeOut = false)
    {
        TPHandler tp = GameObject.Instantiate <TPHandler>(tpOnTheFlyPrefab);

        tp.sceneName          = mapName;
        tp.position           = new Vector2(posX, posY);
        tp.direction          = direction;
        tp.noFadeIn           = NoFadeIn;
        tp.noFadeOut          = NoFadeOut;
        tp.transform.position = PlayerOverworld.instance.gameObject.transform.position;
        EventManager.instance.EndEvent();
    }
    void TextInputManager()
    {
        if (GlobalControls.input.Cancel == UndertaleInput.ButtonState.PRESSED && !tmBigTalk.blockSkip && !tmBigTalk.LineComplete() && tmBigTalk.CanSkip())
        {
            tmBigTalk.SkipLine();
        }
        else if ((GlobalControls.input.Confirm == UndertaleInput.ButtonState.PRESSED || tmBigTalk.CanAutoSkipAll()) && tmBigTalk.LineComplete() && !tmBigTalk.AllLinesComplete())
        {
            tmBigTalk.NextLineText();
        }
        else if ((GlobalControls.input.Confirm == UndertaleInput.ButtonState.PRESSED || tmBigTalk.CanAutoSkipAll()) && tmBigTalk.AllLinesComplete())
        {
            switch (currentState)
            {
            case State.TALKINPROGRESS:
                ChangeState(State.TALK);
                utHeart.GetComponent <Image>().enabled = true;
                EnableBigText(false);
                break;

            case State.EXIT:
                if (script.GetVar("returnscene").Type != DataType.String)
                {
                    UnitaleUtil.DisplayLuaError("Exitting the Shop", "The variable \"returnscene\" must be a string.");
                    return;
                }

                if (script.GetVar("returnpos").Type != DataType.Table)
                {
                    UnitaleUtil.DisplayLuaError("Creating the Buy menu", "The variable \"returnpos\" must be a table.");
                    return;
                }
                else if (script.GetVar("returnpos").Table.Length < 2)
                {
                    UnitaleUtil.DisplayLuaError("Creating the Buy menu", "The variable \"returnpos\" must be a table with two numbers.");
                    return;
                }
                else if (script.GetVar("returnpos").Table.Get(1).Type != DataType.Number || script.GetVar("returnpos").Table.Get(2).Type != DataType.Number)
                {
                    UnitaleUtil.DisplayLuaError("Creating the Buy menu", "The variable \"returnpos\" must be a table with two numbers.");
                    return;
                }

                if (script.GetVar("returndir").Type != DataType.Number)
                {
                    UnitaleUtil.DisplayLuaError("Creating the Buy menu", "The variable \"returndir\" must be a number.");
                    return;
                }
                else if (script.GetVar("returndir").Number > 8 || script.GetVar("returndir").Number < 2 || script.GetVar("returndir").Number % 2 == 1)
                {
                    UnitaleUtil.DisplayLuaError("Creating the Buy menu", "The variable \"returndir\" must be either 2 (Down), 4 (Left), 6 (Right) or 8 (Up).");
                    return;
                }

                tmBigTalk.DestroyText();

                tp           = Instantiate(Resources.Load <TPHandler>("Prefabs/TP On-the-fly"));
                tp.sceneName = script.GetVar("returnscene").String;
                tp.position  = new Vector2((float)script.GetVar("returnpos").Table.Get(1).Number, (float)script.GetVar("returnpos").Table.Get(2).Number);
                tp.direction = (int)script.GetVar("returndir").Number;
                GameObject.DontDestroyOnLoad(tp);
                StartCoroutine(tp.LaunchTP());
                break;

            case State.INTERRUPT:
                utHeart.GetComponent <Image>().enabled = true;
                EnableBigText(false);
                ChangeState(interruptState);
                break;
            }
        }
    }
Exemple #7
0
    // Use this for initialization
    void Start()
    {
        TPHandler tp = Resources.Load <TPHandler>("Prefabs/TP On-the-fly");

        if (tp != null && tp.ToString().ToLower() != "null")
        {
            tpOnTheFlyPrefab = tp;
        }
        FindObjectOfType <Fading>().BeginFade(-1);

        tmMain       = GameObject.Find("TextManager Main").GetComponent <TextManager>();
        tmChoice     = GameObject.Find("TextManager Choice").GetComponent <TextManager>();
        tmInfo       = GameObject.Find("TextManager Info").GetComponent <TextManager>();
        tmBigTalk    = GameObject.Find("TextManager BigTalk").GetComponent <TextManager>();
        tmGold       = GameObject.Find("TextManager Gold").GetComponent <TextManager>();
        tmItem       = GameObject.Find("TextManager Item").GetComponent <TextManager>();
        tmInfoParent = tmInfo.transform.parent.parent.gameObject;
        tmBigTalk.SetTextQueue(new TextMessage[] { new TextMessage("[noskipatall][novoice]", false, true) });
        utHeart = GameObject.Find("utHeart");
        EnableBigText(false);

        if (scriptName == null)
        {
            UnitaleUtil.DisplayLuaError("Creating the shop menu", "You must give a valid script name to the function General.EnterShop()");
            return;
        }

        script = new ScriptWrapper()
        {
            scriptname = scriptName
        };
        string scriptText = ScriptRegistry.Get(ScriptRegistry.SHOP_PREFIX + scriptName);

        if (scriptText == null)
        {
            UnitaleUtil.DisplayLuaError("Creating the shop menu", "You must give a valid script name to the function General.EnterShop()");
            return;
        }


        script.DoString(scriptText);
        script.SetVar("background", UserData.Create(new LuaSpriteController(GameObject.Find("Background").GetComponent <Image>())));
        script.script.Globals["Interrupt"]    = ((Action <DynValue, string>)Interrupt);
        script.script.Globals["CreateSprite"] = (Func <string, string, int, DynValue>)SpriteUtil.MakeIngameSprite;
        script.script.Globals["CreateLayer"]  = (Action <string, string, bool>)SpriteUtil.CreateLayer;
        script.script.Globals["CreateText"]   = (Func <Script, DynValue, DynValue, int, string, int, LuaTextManager>)LuaScriptBinder.CreateText;
        script.Call("Start");

        tmMain.SetCaller(script);
        tmChoice.SetCaller(script);
        tmInfo.SetCaller(script);
        tmBigTalk.SetCaller(script);

        tmMain.SetTextQueue(new TextMessage[] { new TextMessage("[noskipatall][linespacing:11]" + script.GetVar("maintalk").String, true, false) });
        tmChoice.SetTextQueue(new TextMessage[] { new TextMessage("[noskipatall][novoice][font:uidialoglilspace][linespacing:9]    Buy\n    Sell\n    Talk\n    Exit", false, true) });
        tmGold.SetTextQueue(new TextMessage[] { new TextMessage("[noskipatall][novoice]" + PlayerCharacter.instance.Gold + "G", false, true) });
        tmItem.SetTextQueue(new TextMessage[] { new TextMessage("[noskipatall][novoice]" + Inventory.inventory.Count + "/8", false, true) });
        tmInfo.SetTextQueue(new TextMessage[] { new TextMessage("[noskipatall][novoice]", false, true) });

        Camera.main.GetComponent <AudioSource>().clip = AudioClipRegistry.GetMusic(script.GetVar("music").String);
        Camera.main.GetComponent <AudioSource>().Play();
    }