Exemple #1
0
 public static bool Load(bool loadGlobals = true)
 {
     if (File.Exists(Application.persistentDataPath + "/save.gd"))
     {
         Debug.Log("We found a save at this location : " + Application.persistentDataPath + "/save.gd");
         BinaryFormatter bf          = new BinaryFormatter();
         FileStream      file        = File.Open(Application.persistentDataPath + "/save.gd", FileMode.Open);
         GameState       currentGame = (GameState)bf.Deserialize(file);
         currentGame.LoadGameVariables(loadGlobals);
         file.Close();
         return(true);
     }
     else
     {
         LuaScriptBinder.Set(null, "PlayerPosX", MoonSharp.Interpreter.DynValue.NewNumber(GlobalControls.beginPosition.x));
         LuaScriptBinder.Set(null, "PlayerPosY", MoonSharp.Interpreter.DynValue.NewNumber(GlobalControls.beginPosition.y));
         string mapName2;
         if (UnitaleUtil.MapCorrespondanceList.ContainsKey("test2"))
         {
             mapName2 = UnitaleUtil.MapCorrespondanceList["test2"];
         }
         else
         {
             mapName2 = "test2";
         }
         LuaScriptBinder.Set(null, "PlayerMap", MoonSharp.Interpreter.DynValue.NewString(mapName2));
         Debug.Log("There's no save to load.");
         return(false);
     }
 }
 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();
     }
 }
    public void UpdateVariables()
    {
        AlMightyVariablesNum.Clear();
        AlMightyVariablesStr.Clear();
        AlMightyVariablesBool.Clear();
        try {
            foreach (string key in LuaScriptBinder.GetAlMightyDictionary().Keys)
            {
                DynValue dv;
                LuaScriptBinder.GetAlMightyDictionary().TryGetValue(key, out dv);
                if (dv != null)
                {
                    switch (dv.Type)
                    {
                    case DataType.Number:  AlMightyVariablesNum.Add(key, dv.Number);   break;

                    case DataType.String:  AlMightyVariablesStr.Add(key, dv.String);   break;

                    case DataType.Boolean: AlMightyVariablesBool.Add(key, dv.Boolean); break;

                    default:               UnitaleUtil.WriteInLogAndDebugger("SaveLoad: This DynValue can't be added to the save because it is unserializable."); break;
                    }
                }
            }
        } catch { /* ignored */ }
    }
Exemple #4
0
    public void SaveGameVariables()
    {
        try {
            LuaScriptBinder.Set(null, "PlayerPosX", DynValue.NewNumber(GameObject.Find("Player").transform.position.x));
            LuaScriptBinder.Set(null, "PlayerPosY", DynValue.NewNumber(GameObject.Find("Player").transform.position.y));
            LuaScriptBinder.Set(null, "PlayerPosZ", DynValue.NewNumber(GameObject.Find("Player").transform.position.z));
        } catch {
            LuaScriptBinder.Set(null, "PlayerPosX", DynValue.NewNumber(SaveLoad.savedGame.playerVariablesNum["PlayerPosX"]));
            LuaScriptBinder.Set(null, "PlayerPosY", DynValue.NewNumber(SaveLoad.savedGame.playerVariablesNum["PlayerPosY"]));
            LuaScriptBinder.Set(null, "PlayerPosZ", DynValue.NewNumber(SaveLoad.savedGame.playerVariablesNum["PlayerPosZ"]));
        }

        playerHeader = CYFAnimator.specialPlayerHeader;

        string mapName;

        if (UnitaleUtil.MapCorrespondanceList.ContainsKey(SceneManager.GetActiveScene().name))
        {
            mapName = UnitaleUtil.MapCorrespondanceList[SceneManager.GetActiveScene().name];
        }
        else if (GlobalControls.nonOWScenes.Contains(SceneManager.GetActiveScene().name) || GlobalControls.isInFight)
        {
            mapName = SaveLoad.savedGame.lastScene;
        }
        else
        {
            mapName = SceneManager.GetActiveScene().name;
        }
        lastScene = mapName;

        soundDictionary = MusicManager.hiddenDictionary;
        controlpanel    = ControlPanel.instance;
        player          = PlayerCharacter.instance;

        inventory.Clear();
        foreach (UnderItem item in Inventory.inventory)
        {
            inventory.Add(item.Name);
        }

        try {
            foreach (string key in LuaScriptBinder.GetSavedDictionary().Keys)
            {
                DynValue dv;
                LuaScriptBinder.GetSavedDictionary().TryGetValue(key, out dv);
                switch (dv.Type)
                {
                case DataType.Number: playerVariablesNum.Add(key, dv.Number); break;

                case DataType.String: playerVariablesStr.Add(key, dv.String); break;

                case DataType.Boolean: playerVariablesBool.Add(key, dv.Boolean); break;

                default: UnitaleUtil.WriteInLogAndDebugger("SaveLoad: This DynValue can't be added to the save because it is unserializable."); break;
                }
            }
        } catch { }

        mapInfos = GlobalControls.MapData;
    }
Exemple #5
0
 public ScriptWrapper(/*bool overworld = false*/)
 {
     script = LuaScriptBinder.BoundScript(/*overworld*/);
     Bind("_getv", (Func <Script, string, DynValue>) this.GetVar);
     script.DoString(toDoString, null, scriptname);
     instances.Add(this);
 }
Exemple #6
0
    IEnumerator NewGame()
    {
        SpriteRenderer blank = GameObject.Find("Blank").GetComponent <SpriteRenderer>();

        while (blank.color.a <= 1)
        {
            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);
            }
            blank.color = new Color(blank.color.r, blank.color.g, blank.color.b, blank.color.a + 0.003f);
            yield return(0);
        }
        while (Camera.main.GetComponent <AudioSource>().isPlaying)
        {
            yield return(0);
        }
        PlayerCharacter.instance.Reset(false);
        LuaScriptBinder.ClearVariables();
        GlobalControls.GameMapData.Clear();
        Inventory.inventory.Clear();
        GameObject.DontDestroyOnLoad(gameObject);
        UnitaleUtil.ResetOW();
        SceneManager.LoadScene("TransitionOverworld");
        yield return(0);

        //yield return Application.isLoadingLevel;
        if (GameObject.Find("Main Camera"))
        {
            GameObject.Destroy(GameObject.Find("Main Camera"));
        }
        GameObject.Destroy(gameObject);
    }
 public static void ExitOverworld(bool totalUnload = true)
 {
     foreach (string str in NewMusicManager.audiolist.Keys)
     {
         if (((AudioSource)NewMusicManager.audiolist[str]) != null && str != "src")
         {
             GameObject.Destroy(((AudioSource)NewMusicManager.audiolist[str]).gameObject);
         }
     }
     NewMusicManager.audiolist.Clear();
     NewMusicManager.audioname.Clear();
     GameObject.Destroy(GameObject.Find("Player"));
     GameObject.Destroy(GameObject.Find("Canvas OW"));
     GameObject.Destroy(GameObject.Find("Canvas Two"));
     if (GameOverBehavior.gameOverContainerOw)
     {
         GameObject.Destroy(GameOverBehavior.gameOverContainerOw);
     }
     StaticInits.MODFOLDER   = "@Title";
     StaticInits.Initialized = false;
     StaticInits.InitAll();
     UnitaleUtil.ResetOW(true);
     PlayerCharacter.instance.Reset();
     Inventory.inventory.Clear();
     Inventory.RemoveAddedItems();
     ScriptWrapper.instances.Clear();
     GlobalControls.isInFight = false;
     GlobalControls.isInShop  = false;
     LuaScriptBinder.scriptlist.Clear();
     LuaScriptBinder.ClearBattleVar();
     LuaScriptBinder.Clear();
     GameObject.Destroy(GameObject.Find("Main Camera OW"));
 }
    /// <summary>
    /// Changes the Discord Rich Presence visibility setting.
    /// </summary>
    /// <param name="spd">Added so the setting can be written out at init time without changing it.</param>
    /// <returns>The name of the current setting.</returns>
    public static string ChangeVisibilitySetting(int spd)
    {
        curr_setting += spd;
        if (curr_setting >= settingNames.Length)
        {
            curr_setting = 0;
        }

        if (spd > 0)
        {
            LuaScriptBinder.SetAlMighty(null, "CYFDiscord", DynValue.NewNumber(curr_setting), true);
        }

        switch (curr_setting)
        {
        case 0:
            StartModSelect(false);
            break;

        case 1:
            activity.Details          = "";
            activity.State            = "";
            activity.Timestamps.Start = 0;
            activity.Timestamps.End   = 0;
            UpdatePresence(true);
            break;

        default:
            Clear();
            break;
        }

        return(GlobalControls.crate ? Temmify.Convert(settingNames[curr_setting]) : settingNames[curr_setting]);
    }
Exemple #9
0
    public void LoadGameVariables(bool loadGlobals = true)
    {
        GlobalControls.MapData = mapInfos;

        if (loadGlobals)
        {
            LuaScriptBinder.Clear();
        }
        foreach (string key in playerVariablesNum.Keys)
        {
            if (loadGlobals || key.Contains("PlayerPos"))
            {
                double a;
                playerVariablesNum.TryGetValue(key, out a);
                LuaScriptBinder.Set(null, key, DynValue.NewNumber(a));
            }
        }
        if (loadGlobals)
        {
            foreach (string key in playerVariablesStr.Keys)
            {
                string a;
                playerVariablesStr.TryGetValue(key, out a);
                LuaScriptBinder.Set(null, key, DynValue.NewString(a));
            }

            foreach (string key in playerVariablesBool.Keys)
            {
                bool a;
                playerVariablesBool.TryGetValue(key, out a);
                LuaScriptBinder.Set(null, key, DynValue.NewBoolean(a));
            }
        }

        Inventory.inventory.Clear();
        foreach (string str in inventory)
        {
            Inventory.inventory.Add(new UnderItem(str));
        }

        PlayerCharacter.instance      = player;
        ControlPanel.instance         = controlpanel;
        MusicManager.hiddenDictionary = soundDictionary;

        string mapName;

        if (UnitaleUtil.MapCorrespondanceList.ContainsValue(lastScene))
        {
            mapName = UnitaleUtil.MapCorrespondanceList.FirstOrDefault(x => x.Value == lastScene).Key;
        }
        else
        {
            mapName = lastScene;
        }
        GlobalControls.lastScene = mapName;

        LuaScriptBinder.Set(null, "PlayerMap", DynValue.NewString(mapName));
        CYFAnimator.specialPlayerHeader = playerHeader;
    }
    public ScriptWrapper(/*bool overworld = false*/)
    {
        script = LuaScriptBinder.BoundScript(/*overworld*/);
        this.Bind("_getv", (Func <Script, string, DynValue>) this.GetVar);
        string toDoString = "setmetatable({}, {__index=function(t, name) return _getv(name) end}) ";

        script.DoString(toDoString, null, scriptname);
        instances.Add(this);
    }
Exemple #11
0
    // Use this for initialization
    void Start()
    {
        if (!SaveLoad.started)
        {
            StaticInits.Start();
            SaveLoad.Start();
            new ControlPanel();
            new PlayerCharacter();
            #if UNITY_STANDALONE_WIN || UNITY_EDITOR_WIN
            if (GlobalControls.crate)
            {
                Misc.WindowName = ControlPanel.instance.WinodwBsaisNmae;
            }
            else
            {
                Misc.WindowName = ControlPanel.instance.WindowBasisName;
            }
            #endif
            SaveLoad.LoadAlMighty();
            LuaScriptBinder.Set(null, "ModFolder", MoonSharp.Interpreter.DynValue.NewString("@Title"));
            UnitaleUtil.AddKeysToMapCorrespondanceList();
        }
        Camera.main.GetComponent <AudioSource>().clip = AudioClipRegistry.GetMusic("mus_intro");
        Camera.main.GetComponent <AudioSource>().Play();
        if (imagePaths.Length != textsToDisplay.Length)
        {
            throw new Exception("You need to have the same number of images and lines of text.");
        }
        text = GameObject.FindObjectOfType <TextManager>();
        img  = GameObject.Find("CutsceneImages").GetComponent <Image>();
        text.SetVerticalSpacing(6);
        text.SetHorizontalSpacing(6);
        if (SpriteRegistry.Get("Intro/mask") != null)
        {
            mask = true;
            GameObject.Find("Mask").GetComponent <Image>().sprite = SpriteRegistry.Get("Intro/mask");
            GameObject.Find("Mask").GetComponent <Image>().color  = new Color(1, 1, 1, 1);
        }

        TextMessage[] mess = new TextMessage[textsToDisplay.Length];
        for (int i = 0; i < mess.Length; i++)
        {
            mess[i] = new TextMessage("[waitall:2]" + textsToDisplay[i], false, false);
        }
        text.SetTextQueue(mess);
        img.sprite = SpriteRegistry.Get("Intro/" + imagePaths[0]);
        img.SetNativeSize();
        if (specialEffects[0] != string.Empty)
        {
            try { ApplyEffect((Effect)Enum.Parse(typeof(Effect), specialEffects[currentIndex].ToUpper())); }
            catch { UnitaleUtil.DisplayLuaError("IntroManager", "The effect " + specialEffects[currentIndex] + " doesn't exist."); }
        }
        if (goToNextDirect[0] == "Y")
        {
            timer = 0.5f;
        }
    }
    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();
        }
    }
    private void PrepareWave()
    {
        DynValue nextWaves = script.GetVar("nextwaves");

        waves     = new ScriptWrapper[nextWaves.Table.Length];
        waveNames = new string[waves.Length];
        int currentWaveScript = 0;

        try {
            List <int> indexes = new List <int>();
            for (int i = 0; i < waves.Length; i++)
            {
                currentWaveScript = i;
                DynValue ArenaStatus = UserData.Create(ArenaManager.luaStatus);
                waves[i] = new ScriptWrapper()
                {
                    script = LuaScriptBinder.BoundScript()
                };
                waves[i].script.Globals.Set("Arena", ArenaStatus);
                waves[i].script.Globals["EndWave"]             = (Action)EndWaveTimer;
                waves[i].script.Globals["State"]               = (Action <Script, string>)UIController.SwitchStateOnString;
                waves[i].script.Globals["CreateProjectile"]    = (Func <Script, string, float, float, string, DynValue>)CreateProjectile;
                waves[i].script.Globals["CreateProjectileAbs"] = (Func <Script, string, float, float, string, DynValue>)CreateProjectileAbs;
                if (nextWaves.Table.Get(i + 1).Type != DataType.String)
                {
                    UnitaleUtil.DisplayLuaError(StaticInits.ENCOUNTER, "Non-string value encountered in nextwaves table");
                    return;
                }
                else
                {
                    waveNames[i] = nextWaves.Table.Get(i + 1).String;
                }
                waves[i].script.Globals["wavename"] = nextWaves.Table.Get(i + 1).String;
                try {
                    waves[i].DoString(ScriptRegistry.Get(ScriptRegistry.WAVE_PREFIX + nextWaves.Table.Get(i + 1).String));
                    indexes.Add(i);
                } catch (InterpreterException ex) { UnitaleUtil.DisplayLuaError(nextWaves.Table.Get(i + 1).String + ".lua", ex.DecoratedMessage); } catch (Exception ex) {
                    if (!GlobalControls.retroMode && !ScriptRegistry.dict.ContainsKey(ScriptRegistry.WAVE_PREFIX + nextWaves.Table.Get(i + 1).String))
                    {
                        UnitaleUtil.DisplayLuaError(StaticInits.ENCOUNTER, "The wave " + nextWaves.Table.Get(i + 1).String + " doesn't exist.");
                    }
                    else
                    {
                        UnitaleUtil.DisplayLuaError("<UNKNOWN LOCATION>", ex.Message + "\n\n" + ex.StackTrace);
                    }
                }
            }
            Table luaWaveTable = new Table(null);
            for (int i = 0; i < indexes.Count; i++)
            {
                luaWaveTable.Set(i + 1, UserData.Create(waves[indexes[i]]));
            }
            script.SetVar("Wave", DynValue.NewTable(luaWaveTable));
        } catch (InterpreterException ex) { UnitaleUtil.DisplayLuaError(nextWaves.Table.Get(currentWaveScript + 1).String + ".lua", ex.DecoratedMessage); }
    }
    public void Awake()
    {
        if (!awakened)
        {
            StaticInits.Start();
            SaveLoad.Start();
            new ControlPanel();
            new PlayerCharacter();
            SaveLoad.LoadAlMighty();
            LuaScriptBinder.Set(null, "ModFolder", DynValue.NewString("@Title"));

            UnitaleUtil.AddKeysToMapCorrespondanceList();

            //Use AlMightyGlobals to load Crate Your Frisk, Safe Mode, Retromode and Fullscreen mode preferences

            if (LuaScriptBinder.GetAlMighty(null, "CrateYourFrisk") != null && LuaScriptBinder.GetAlMighty(null, "CrateYourFrisk").Boolean)
            {
                crate = true;
            }
            #if UNITY_STANDALONE_WIN || UNITY_EDITOR_WIN
            Misc.WindowName = crate ? ControlPanel.instance.WinodwBsaisNmae : ControlPanel.instance.WindowBasisName;
            #endif

            //Check if safe mode has a stored preference that is a boolean
            if (LuaScriptBinder.GetAlMighty(null, "CYFSafeMode") != null &&
                LuaScriptBinder.GetAlMighty(null, "CYFSafeMode").Type == DataType.Boolean)
            {
                ControlPanel.instance.Safe = LuaScriptBinder.GetAlMighty(null, "CYFSafeMode").Boolean;
            }

            //Check if retro mode has a stored preference that is a boolean
            if (LuaScriptBinder.GetAlMighty(null, "CYFRetroMode") != null &&
                LuaScriptBinder.GetAlMighty(null, "CYFRetroMode").Type == DataType.Boolean)
            {
                retroMode = LuaScriptBinder.GetAlMighty(null, "CYFRetroMode").Boolean;
            }

            //Check if fullscreen mode has a stored preference that is a boolean
            if (LuaScriptBinder.GetAlMighty(null, "CYFPerfectFullscreen") != null &&
                LuaScriptBinder.GetAlMighty(null, "CYFPerfectFullscreen").Type == DataType.Boolean)
            {
                ScreenResolution.perfectFullscreen = LuaScriptBinder.GetAlMighty(null, "CYFPerfectFullscreen").Boolean;
            }

            //Check if window scale has a stored preference that is a number
            if (LuaScriptBinder.GetAlMighty(null, "CYFWindowScale") != null &&
                LuaScriptBinder.GetAlMighty(null, "CYFWindowScale").Type == DataType.Number)
            {
                ScreenResolution.windowScale = (int)LuaScriptBinder.GetAlMighty(null, "CYFWindowScale").Number;
            }

            awakened = true;
        }
    }
 void LoadScene(Scene scene, LoadSceneMode mode)
 {
     if (LuaScriptBinder.GetAlMighty(null, "CrateYourFrisk") != null)
     {
         crate = LuaScriptBinder.GetAlMighty(null, "CrateYourFrisk").Boolean;
     }
     else
     {
         crate = false;
     }
 }
    private void Start()
    {
        if (!initial)
        {
            StaticInits.Start();
            SaveLoad.Start();
            new ControlPanel();
            new PlayerCharacter();
            #if UNITY_STANDALONE_WIN || UNITY_EDITOR_WIN
            if (GlobalControls.crate)
            {
                Misc.WindowName = ControlPanel.instance.WinodwBsaisNmae;
            }
            else
            {
                Misc.WindowName = ControlPanel.instance.WindowBasisName;
            }
            #endif
            SaveLoad.LoadAlMighty();
            LuaScriptBinder.Set(null, "ModFolder", DynValue.NewString("@Title"));

            UnitaleUtil.AddKeysToMapCorrespondanceList();

            initial = true;
        }

        if (LuaScriptBinder.GetAlMighty(null, "CrateYourFrisk") != null)
        {
            if (LuaScriptBinder.GetAlMighty(null, "CrateYourFrisk").Boolean)
            {
                GameObject.Find("Image").GetComponent <Image>().enabled     = false;
                GameObject.Find("Image (1)").GetComponent <Image>().enabled = true;

                /*GameObject.Find("Description").GetComponent<Text>().text = "CRATE YOUR FRISK IS A FERE AND SUPER KEWL EJNINE!!!!1!!\n" +
                 *                                                         "GO ON WWW.REDIDT.CMO/R/UNITLAE. FOR UPDTAES!!!!!\n" +
                 *                                                         "NO RELESLING HERE!!! IT'S RFEE!!!\n" +
                 *                                                         "OR TUBY FEX WILL BE ANGER!!!\n\n" +
                 *                                                         "U'LL HVAE A BED TMIE!!!";
                 * GameObject.Find("Description (1)").GetComponent<Text>().text = "NU FEAUTRES IN EXAMPLES MODS!!!!! CHEKC IT OTU!!!!!\n" +
                 *                                                             "REALLY!!!\n" +
                 *                                                             "IF U DAD A # IN AN ECNOUNTRE NAME IT'LL NTO BE CHOSE NI\n" +
                 *                                                             "ENCONUTERS ON THE PAMS!!!! SO COLO!!!";*/
                GameObject.Find("Description").GetComponent <Text>().text     = "GO TO /R/UNITLAE. FOR UPDTAES!!!!!";
                GameObject.Find("Description (1)").GetComponent <Text>().text = "NO RELESLING HERE!!! IT'S RFEE!!! " +
                                                                                "OR TUBY FEX WILL BE ANGER!!! " +
                                                                                "U'LL HVAE A BED TMIE!!!";
                GameObject.Find("Description (2)").GetComponent <Text>().text = "SPACE OR KLIK TO\n<color='#ff0000'>PALY MODS!!!!!</color>";
                GameObject.Find("Description (3)").GetComponent <Text>().text = "PRSES O TO\n<color='#ffff00'>OOVERWURL!!!!!</color>";
                GameObject.Find("Description (4)").GetComponent <Text>().text = "<b><color='red'>KNOW YUOR CODE</color> R U'LL HVAE A BED TMIE!!!</b>";
            }
        }
    }
Exemple #17
0
    /// <summary>
    /// Launch the GameOver screen
    /// </summary>
    [CYFEventFunction] public void GameOver(DynValue deathText = null, string deathMusic = null)
    {
        PlayerCharacter.instance.HP = PlayerCharacter.instance.MaxHP;

        /*Transform rt = GameObject.Find("Player").GetComponent<Transform>();
         * rt.position = new Vector3(rt.position.x, rt.position.y, -1000);*/
        string[] deathTable = null;

        if (deathText != null && deathText.Type != DataType.Void)
        {
            switch (deathText.Type)
            {
            case DataType.Table: {
                deathTable = new string[deathText.Table.Length];
                for (int i = 0; i < deathText.Table.Length; i++)
                {
                    deathTable[i] = deathText.Table[i + 1].ToString();
                }
                break;
            }

            case DataType.String: deathTable = new[] { deathText.String }; break;

            default:              throw new CYFException("General.GameOver: deathText needs to be a table or a string.");
            }
        }

        PlayerOverworld.instance.enabled = false;

        // Stop the "kept audio" if it is playing
        if (PlayerOverworld.audioKept == UnitaleUtil.GetCurrentOverworldAudio())
        {
            PlayerOverworld.audioKept.Stop();
            PlayerOverworld.audioKept.clip = null;
            PlayerOverworld.audioKept.time = 0;
        }

        //Saves our most recent map and position to control where the player respawns
        string mapName = UnitaleUtil.MapCorrespondanceList.ContainsKey(SceneManager.GetActiveScene().name) ? UnitaleUtil.MapCorrespondanceList[SceneManager.GetActiveScene().name] : SceneManager.GetActiveScene().name;

        LuaScriptBinder.Set(null, "PlayerMap", DynValue.NewString(mapName));

        Transform tf = GameObject.Find("Player").transform;

        LuaScriptBinder.Set(null, "PlayerPosX", DynValue.NewNumber(tf.position.x));
        LuaScriptBinder.Set(null, "PlayerPosY", DynValue.NewNumber(tf.position.y));
        LuaScriptBinder.Set(null, "PlayerPosZ", DynValue.NewNumber(tf.position.z));

        Object.FindObjectOfType <GameOverBehavior>().StartDeath(deathTable, deathMusic);

        appliedScript.Call("CYFEventNextCommand");
    }
Exemple #18
0
    public void LoadGameVariables(bool loadGlobals = true)
    {
        GlobalControls.TempGameMapData = tempMapInfos;
        GlobalControls.GameMapData     = mapInfos;

        foreach (string key in playerVariablesNum.Keys)
        {
            if (!loadGlobals && !key.Contains("PlayerPos"))
            {
                continue;
            }
            double a;
            playerVariablesNum.TryGetValue(key, out a);
            LuaScriptBinder.Set(null, key, DynValue.NewNumber(a));
        }
        if (loadGlobals)
        {
            foreach (string key in playerVariablesStr.Keys)
            {
                string a;
                playerVariablesStr.TryGetValue(key, out a);
                LuaScriptBinder.Set(null, key, DynValue.NewString(a));
            }

            foreach (string key in playerVariablesBool.Keys)
            {
                bool a;
                playerVariablesBool.TryGetValue(key, out a);
                LuaScriptBinder.Set(null, key, DynValue.NewBoolean(a));
            }
        }

        Inventory.inventory.Clear();
        foreach (string str in inventory)
        {
            Inventory.inventory.Add(new UnderItem(str));
        }

        ItemBox.items.Clear();
        foreach (string str in boxContents)
        {
            ItemBox.items.Add(new UnderItem(str));
        }

        PlayerCharacter.instance      = player;
        ControlPanel.instance         = controlpanel;
        MusicManager.hiddenDictionary = soundDictionary;

        string mapName = UnitaleUtil.MapCorrespondanceList.ContainsValue(lastScene) ? UnitaleUtil.MapCorrespondanceList.FirstOrDefault(x => x.Value == lastScene).Key : lastScene;

        LuaScriptBinder.Set(null, "PlayerMap", DynValue.NewString(mapName));
    }
Exemple #19
0
 // Use this for initialization
 void Start()
 {
     if (!SaveLoad.started)
     {
         StaticInits.Start();
         SaveLoad.Start();
         new ControlPanel();
         new PlayerCharacter();
         #if UNITY_STANDALONE_WIN || UNITY_EDITOR
         if (GlobalControls.crate)
         {
             Misc.WindowName = ControlPanel.instance.WinodwBsaisNmae;
         }
         else
         {
             Misc.WindowName = ControlPanel.instance.WindowBasisName;
         }
         #endif
         SaveLoad.LoadAlMighty();
         LuaScriptBinder.Set(null, "ModFolder", MoonSharp.Interpreter.DynValue.NewString("Title"));
         UnitaleUtil.AddKeysToMapCorrespondanceList();
     }
     GameObject firstCamera = GameObject.Find("Main Camera");
     firstCamera.SetActive(false);
     if (GameObject.Find("Main Camera"))
     {
         GameObject.Destroy(firstCamera);
     }
     else
     {
         firstCamera.SetActive(true);
     }
     tmName = GameObject.Find("TextManagerResetName").GetComponent <TextManager>();
     tmName.SetHorizontalSpacing(2);
     tmName.SetFont(SpriteFontRegistry.Get(SpriteFontRegistry.UI_DEFAULT_NAME));
     diff    = calcTotalLength(tmName);
     actualX = tmName.transform.localPosition.x;
     actualY = tmName.transform.localPosition.y;
     if (GlobalControls.crate)
     {
         GameObject.Find("Title").GetComponent <SpriteRenderer>().enabled     = false;
         GameObject.Find("Title (1)").GetComponent <SpriteRenderer>().enabled = true;
     }
     GameObject.DontDestroyOnLoad(Camera.main.gameObject);
     StartCoroutine(TitlePhase1());
 }
Exemple #20
0
    IEnumerator LoadGame()
    {
        GameObject.DontDestroyOnLoad(gameObject);
        SceneManager.LoadScene("TransitionOverworld");
        yield return(0);

        //yield return Application.isLoadingLevel;
        //GameObject.Find("Player").transform.position = new Vector3(;
        StaticInits.MODFOLDER   = LuaScriptBinder.Get(null, "ModFolder").String;
        StaticInits.Initialized = false;
        StaticInits.InitAll();
        if (GameObject.Find("Main Camera"))
        {
            GameObject.Destroy(GameObject.Find("Main Camera"));
        }
        GameObject.Destroy(gameObject);
    }
    // Use this for initialization
    public static void Start()
    {
        // Creates the object that manages the Rich Presence Commands. The first argument is the APPID, the second tells the libraries if Discord must be started or not.
        try {
            discord         = new Discord.Discord(711497963771527219, (ulong)CreateFlags.NoRequireDiscord);
            activityManager = discord.GetActivityManager();
            isActive        = true;
        } catch (Exception) {
            isActive = false;
        }

        // Gets Discord Visibility Setting
        if (LuaScriptBinder.GetAlMighty(null, "CYFDiscord") == null)
        {
            curr_setting = 0;
        }
        else
        {
            curr_setting = (int)LuaScriptBinder.GetAlMighty(null, "CYFDiscord").Number;
        }

        // Creates the activity objects that will be modified and used as needed
        activity = new Activity {
            Name       = GlobalControls.crate ? ControlPanel.instance.WinodwBsaisNmae : ControlPanel.instance.WindowBasisName,
            Details    = "", // The top row
            State      = "", // The second row
            Timestamps =     // The timer
            {
                Start = 0,
                End   = 0
            },
            Assets =   // The CYF Logo
            {
                LargeImage = "cyf_logo",
                LargeText  = ControlPanel.instance.WindowBasisName
            }
        };

        // Set initial activity properties and status
        ChangeVisibilitySetting(0);
        oldTime = GetCurrentTime();
        ClearTime(true);
        StartTitle();
    }
    void Awake()
    {
        if (!awakened)
        {
            SceneManager.sceneLoaded += LoadScene;

            // use AlMightyGlobals to load Safe Mode, Retromode and Fullscreen mode preferences

            // check if safe mode has a stored preference that is a boolean
            if (LuaScriptBinder.GetAlMighty(null, "CYFSafeMode") != null &&
                LuaScriptBinder.GetAlMighty(null, "CYFSafeMode").Type == DataType.Boolean)
            {
                ControlPanel.instance.Safe = LuaScriptBinder.GetAlMighty(null, "CYFSafeMode").Boolean;
            }

            // check if retro mode has a stored preference that is a boolean
            if (LuaScriptBinder.GetAlMighty(null, "CYFRetroMode") != null &&
                LuaScriptBinder.GetAlMighty(null, "CYFRetroMode").Type == DataType.Boolean)
            {
                retroMode = LuaScriptBinder.GetAlMighty(null, "CYFRetroMode").Boolean;
            }

            // check if fullscreen mode has a stored preference that is a boolean
            if (LuaScriptBinder.GetAlMighty(null, "CYFPerfectFullscreen") != null &&
                LuaScriptBinder.GetAlMighty(null, "CYFPerfectFullscreen").Type == DataType.Boolean)
            {
                perfectFullscreen = LuaScriptBinder.GetAlMighty(null, "CYFPerfectFullscreen").Boolean;
            }

            // check if window scale has a stored preference that is a number
            if (LuaScriptBinder.GetAlMighty(null, "CYFWindowScale") != null &&
                LuaScriptBinder.GetAlMighty(null, "CYFWindowScale").Type == DataType.Number)
            {
                windowScale = (int)LuaScriptBinder.GetAlMighty(null, "CYFWindowScale").Number;
            }

            awakened = true;
        }
    }
    public void LoadVariables()
    {
        foreach (string key in AlMightyVariablesNum.Keys)
        {
            double a;
            AlMightyVariablesNum.TryGetValue(key, out a);
            LuaScriptBinder.SetAlMighty(null, key, DynValue.NewNumber(a), false);
        }

        foreach (string key in AlMightyVariablesStr.Keys)
        {
            string a;
            AlMightyVariablesStr.TryGetValue(key, out a);
            LuaScriptBinder.SetAlMighty(null, key, DynValue.NewString(a), false);
        }

        foreach (string key in AlMightyVariablesBool.Keys)
        {
            bool a;
            AlMightyVariablesBool.TryGetValue(key, out a);
            LuaScriptBinder.SetAlMighty(null, key, DynValue.NewBoolean(a), false);
        }
    }
    private void prepareWave()
    {
        DynValue nextWaves = script.GetVar("nextwaves");

        waves     = new Script[nextWaves.Table.Length];
        waveNames = new string[waves.Length];
        int currentWaveScript = 0;

        try
        {
            for (int i = 0; i < waves.Length; i++)
            {
                currentWaveScript = i;
                waves[i]          = LuaScriptBinder.boundScript();
                DynValue ArenaStatus = UserData.Create(ArenaSizer.luaStatus);
                waves[i].Globals.Set("Arena", ArenaStatus);
                waves[i].Globals["State"]               = (Action <string>)UIController.instance.SwitchStateOnString;
                waves[i].Globals["CreateProjectile"]    = (Func <Script, string, float, float, DynValue>)CreateProjectile;
                waves[i].Globals["CreateProjectileAbs"] = (Func <Script, string, float, float, DynValue>)CreateProjectileAbs;
                waves[i].Globals["EndWave"]             = (Action)endWaveTimer;
                if (nextWaves.Table.Get(i + 1).Type != DataType.String)
                {
                    UnitaleUtil.displayLuaError(StaticInits.ENCOUNTER, "Non-string value encountered in nextwaves table");
                    return;
                }
                else
                {
                    waveNames[i] = nextWaves.Table.Get(i + 1).String;
                }
                waves[i].DoString(ScriptRegistry.Get(ScriptRegistry.WAVE_PREFIX + nextWaves.Table.Get(i + 1).String));
            }
        }
        catch (InterpreterException ex)
        {
            UnitaleUtil.displayLuaError(nextWaves.Table.Get(currentWaveScript + 1).String + ".lua", ex.DecoratedMessage);
        }
    }
    private void Start()
    {
        bool isStart = false;

        // Set timestamp for Overworld to calculate total play time
        GlobalControls.overworldTimestamp = Time.time - (SaveLoad.savedGame != null ? SaveLoad.savedGame.playerTime : 0f);
        // Forcefully disable retromode if it is on
        if (GlobalControls.retroMode)
        {
            GlobalControls.retroMode = false;
            try {
                LuaScriptBinder.SetAlMighty(null, "CYFRetroMode", DynValue.NewBoolean(false), true);
            } catch {}
        }

        GameOverBehavior.gameOverContainerOw = GameObject.Find("GameOverContainer");
        GameOverBehavior.gameOverContainerOw.SetActive(false);
        if (GameObject.Find("GameOverContainer"))
        {
            GameObject.Destroy(GameOverBehavior.gameOverContainerOw);
            GameOverBehavior.gameOverContainerOw = GameObject.Find("GameOverContainer");
            GameOverBehavior.gameOverContainerOw.SetActive(false);
        }
        GameObject.DontDestroyOnLoad(GameOverBehavior.gameOverContainerOw);

        if (LuaScriptBinder.Get(null, "PlayerPosX") == null || LuaScriptBinder.Get(null, "PlayerPosY") == null || LuaScriptBinder.Get(null, "PlayerPosZ") == null)
        {
            LuaScriptBinder.Set(null, "PlayerPosX", DynValue.NewNumber(BeginningPosition.x));
            LuaScriptBinder.Set(null, "PlayerPosY", DynValue.NewNumber(BeginningPosition.y));
            LuaScriptBinder.Set(null, "PlayerPosZ", DynValue.NewNumber(0));
        }
        if (GameObject.Find("Main Camera"))
        {
            GameObject.Destroy(GameObject.Find("Main Camera"));
        }
        //Used only for the 1st scene
        if (LuaScriptBinder.Get(null, "PlayerMap") == null)
        {
            isStart = true;
            SaveLoad.Start();

            GlobalControls.lastTitle = false;
            string mapName2;
            if (UnitaleUtil.MapCorrespondanceList.ContainsKey(FirstLevelToLoad))
            {
                mapName2 = UnitaleUtil.MapCorrespondanceList[FirstLevelToLoad];
            }
            else
            {
                mapName2 = FirstLevelToLoad;
            }
            LuaScriptBinder.Set(null, "PlayerMap", DynValue.NewString(mapName2));

            StaticInits.MODFOLDER = "";

            /*StaticInits.Initialized = false;
             * GameObject.Find("Main Camera OW").GetComponent<StaticInits>().initAll();*/
            GlobalControls.realName = PlayerCharacter.instance.Name;
        }
        //Check if there is two Main Camera OW objects
        GameObject temp = GameObject.Find("Main Camera OW");

        temp.SetActive(false);
        if (GameObject.Find("Main Camera OW"))
        {
            GameObject.Destroy(GameObject.Find("Main Camera OW"));
        }
        temp.SetActive(true);

        // After battle tweaks
        ControlPanel.instance.FrameBasedMovement = false;
        if (GlobalControls.realName != null)
        {
            PlayerCharacter.instance.Name = GlobalControls.realName;
        }

        //GameObject.Destroy(gameObject);

        GameObject.DontDestroyOnLoad(GameObject.Find("Canvas OW"));
        GameObject.DontDestroyOnLoad(GameObject.Find("Canvas Two"));
        GameObject.DontDestroyOnLoad(GameObject.Find("Player").transform.parent.gameObject);
        GameObject.DontDestroyOnLoad(GameObject.Find("Main Camera OW"));
        string mapName;

        if (!isStart)
        {
            try {
                if (UnitaleUtil.MapCorrespondanceList.ContainsValue(LuaScriptBinder.Get(null, "PlayerMap").String))
                {
                    mapName = UnitaleUtil.MapCorrespondanceList.FirstOrDefault(x => x.Value == LuaScriptBinder.Get(null, "PlayerMap").String).Key;
                }
                else
                {
                    mapName = LuaScriptBinder.Get(null, "PlayerMap").String;
                }
            } catch { mapName = LuaScriptBinder.Get(null, "PlayerMap").String; }
        }
        else
        {
            mapName = FirstLevelToLoad;
        }

        if (!FileLoader.SceneExists(mapName))
        {
            UnitaleUtil.DisplayLuaError("TransitionOverworld", "The map named \"" + mapName + "\" doesn't exist.");
            return;
        }
        if (GlobalControls.nonOWScenes.Contains(mapName))
        {
            UnitaleUtil.DisplayLuaError("TransitionOverworld", "Sorry, but \"" + mapName + "\" is not the name of an overworld scene.");
            return;
        }
        SceneManager.LoadScene(mapName);
        GameObject.Find("Don't show it again").GetComponent <Image>().color = new Color(0, 0, 0, 0);
        StartCoroutine(GetIntoDaMap("transitionoverworld", null));
    }
    /// <summary>
    /// Makes the buttons for the mod selection screen.
    /// </summary>
    private void modFolderSelection()
    {
        if (GlobalControls.crate)
        {
            GameObject.Find("Text").GetComponent <Text>().text = "MDO SELECTRO (CILCK + DARG TO SEE OTRHE MODS)";
        }
        DirectoryInfo di = new DirectoryInfo(System.IO.Path.Combine(FileLoader.DataRoot, "Mods"));

        DirectoryInfo[] modDirs   = di.GetDirectories();
        int             numButton = 0;

        foreach (DirectoryInfo modDir in modDirs)
        {
            if (modDir.Name == "0.5.0_SEE_CRATE")
            {
                continue;
            }
            Button c = Instantiate(b);
            c.transform.SetParent(GameObject.Find("Content").transform);
            RectTransform crt = c.GetComponent <RectTransform>();
            crt.anchoredPosition = new Vector2(5, 0 - 40 * numButton);
            c.GetComponentInChildren <Text>().text = modDir.Name;
            string mdn = modDir.Name; // create a new object in memory because the reference to moddir in the anonymous function gets f****d
            c.onClick.AddListener(() => { StaticInits.MODFOLDER = mdn; Debug.Log("Selecting directory " + mdn); SceneManager.LoadScene("EncounterSelect"); });
            numButton++;
        }

        if (GlobalControls.modDev)
        {
            Transform[] tfs = UnitaleUtil.GetFirstChildren(GameObject.Find("Canvas").transform, true);
            foreach (Transform tf in tfs)
            {
                if (tf.gameObject.name == "devMod")
                {
                    tf.gameObject.SetActive(true);
                    if (GlobalControls.crate)
                    {
                        GameObject.Find("Text2").GetComponent <Text>().text = "MODEDV MODE HREE!!!\nIZI MDO TSETING!!!\nGAD LUKC!!!!!1!!";
                    }

                    Button but = Instantiate(bs), but2 = Instantiate(bs), but3 = Instantiate(bs), but4 = Instantiate(bs);

                    but.gameObject.name = "ResetRG";
                    but.transform.SetParent(GameObject.Find("Canvas").transform);
                    but.GetComponent <RectTransform>().sizeDelta = new Vector2(150, but.GetComponent <RectTransform>().sizeDelta.y);
                    but.GetComponent <RectTransform>().position  = new Vector2(325, 200);
                    but.GetComponentInChildren <Text>().text     = "Reset RealGlobals";
                    but.onClick.AddListener(() => {
                        LuaScriptBinder.ClearVariables();
                        if (GlobalControls.crate)
                        {
                            GameObject.Find("Text3").GetComponent <Text>().text = "REELGOLBELZ\nDELEET!!!!!";
                        }
                        else
                        {
                            GameObject.Find("Text3").GetComponent <Text>().text = "RealGlobals\nerased!";
                        }
                    });

                    but2.gameObject.name = "ResetAM";
                    but2.transform.SetParent(GameObject.Find("Canvas").transform);
                    but2.GetComponent <RectTransform>().sizeDelta = new Vector2(150, but2.GetComponent <RectTransform>().sizeDelta.y);
                    but2.GetComponent <RectTransform>().position  = new Vector2(475, 200);
                    but2.GetComponentInChildren <Text>().text     = "Reset AlMighty";
                    but2.onClick.AddListener(() => {
                        LuaScriptBinder.ClearAlMighty();
                        if (GlobalControls.crate)
                        {
                            GameObject.Find("Text4").GetComponent <Text>().text = "ALMEIGHTIZ\nDELEET!!!!!";
                        }
                        else
                        {
                            GameObject.Find("Text4").GetComponent <Text>().text = "AlMighty\nerased!";
                        }
                    });

                    but3.gameObject.name = "Retromode";
                    but3.transform.SetParent(GameObject.Find("Canvas").transform);
                    but3.GetComponent <RectTransform>().sizeDelta = new Vector2(300, but3.GetComponent <RectTransform>().sizeDelta.y);
                    but3.GetComponent <RectTransform>().position  = new Vector2(325, 440);
                    if (GlobalControls.retroMode)
                    {
                        but3.GetComponentInChildren <Text>().text = "0.2.1a retrocompatibility: On";
                    }
                    else
                    {
                        but3.GetComponentInChildren <Text>().text = "0.2.1a retrocompatibility: Off";
                    }
                    but3.onClick.AddListener(() => {
                        GlobalControls.retroMode = !GlobalControls.retroMode;
                        if (GlobalControls.retroMode)
                        {
                            but3.GetComponentInChildren <Text>().text = "0.2.1a retrocompatibility: On";
                        }
                        else
                        {
                            but3.GetComponentInChildren <Text>().text = "0.2.1a retrocompatibility: Off";
                        }
                    });

                    but4.gameObject.name = "Safemode";
                    but4.transform.SetParent(GameObject.Find("Canvas").transform);
                    but4.GetComponent <RectTransform>().sizeDelta = new Vector2(300, but3.GetComponent <RectTransform>().sizeDelta.y);
                    but4.GetComponent <RectTransform>().position  = new Vector2(325, 400);
                    if (ControlPanel.instance.Safe)
                    {
                        but4.GetComponentInChildren <Text>().text = "Safe mode: On";
                    }
                    else
                    {
                        but4.GetComponentInChildren <Text>().text = "Safe mode: Off";
                    }
                    but4.onClick.AddListener(() => {
                        ControlPanel.instance.Safe = !ControlPanel.instance.Safe;
                        if (ControlPanel.instance.Safe)
                        {
                            but4.GetComponentInChildren <Text>().text = "Safe mode: On";
                        }
                        else
                        {
                            but4.GetComponentInChildren <Text>().text = "Safe mode: Off";
                        }
                    });
                    break;
                }
            }
        }
    }
Exemple #27
0
	virtual protected LuaTable BindLuaScript(string scriptName)
	{
		luaScriptBinder = new LuaScriptBinder(scriptName);
		return luaScriptBinder.Bind();
	}
Exemple #28
0
    private static bool awakened;                                                                                                                                 // Used to only run Awake() once

    public void Awake()
    {
        if (awakened)
        {
            return;
        }
        // Create all singletons (classes that only have one instance across the entire app)
        StaticInits.Start();
        SaveLoad.Start();
        new ControlPanel();
        new PlayerCharacter();
        // Load AlMighty globals
        SaveLoad.LoadAlMighty();
        LuaScriptBinder.Set(null, "ModFolder", DynValue.NewString("@Title"));

        // Load map names for the overworld
        UnitaleUtil.AddKeysToMapCorrespondanceList();

        // Use AlMightyGlobals to load Crate Your Frisk, Safe Mode, Retromode and Fullscreen mode preferences
        // CrateYourFrisk
        if (LuaScriptBinder.GetAlMighty(null, "CrateYourFrisk") != null && LuaScriptBinder.GetAlMighty(null, "CrateYourFrisk").Boolean)
        {
            crate = true;
        }
        #if UNITY_STANDALONE_WIN || UNITY_EDITOR_WIN
        Misc.WindowName = crate ? ControlPanel.instance.WinodwBsaisNmae : ControlPanel.instance.WindowBasisName;
        #endif

        // Check if safe mode has a stored preference that is a boolean
        if (LuaScriptBinder.GetAlMighty(null, "CYFSafeMode") != null &&
            LuaScriptBinder.GetAlMighty(null, "CYFSafeMode").Type == DataType.Boolean)
        {
            ControlPanel.instance.Safe = LuaScriptBinder.GetAlMighty(null, "CYFSafeMode").Boolean;
        }

        // Check if retro mode has a stored preference that is a boolean
        if (LuaScriptBinder.GetAlMighty(null, "CYFRetroMode") != null &&
            LuaScriptBinder.GetAlMighty(null, "CYFRetroMode").Type == DataType.Boolean)
        {
            retroMode = LuaScriptBinder.GetAlMighty(null, "CYFRetroMode").Boolean;
        }

        // Check if fullscreen mode has a stored preference that is a boolean
        if (LuaScriptBinder.GetAlMighty(null, "CYFPerfectFullscreen") != null &&
            LuaScriptBinder.GetAlMighty(null, "CYFPerfectFullscreen").Type == DataType.Boolean)
        {
            ScreenResolution.perfectFullscreen = LuaScriptBinder.GetAlMighty(null, "CYFPerfectFullscreen").Boolean;
        }

        // Check if window scale has a stored preference that is a number
        if (LuaScriptBinder.GetAlMighty(null, "CYFWindowScale") != null &&
            LuaScriptBinder.GetAlMighty(null, "CYFWindowScale").Type == DataType.Number)
        {
            ScreenResolution.windowScale = (int)LuaScriptBinder.GetAlMighty(null, "CYFWindowScale").Number;
        }

        // Start Discord RPC (also checks for an AlMightyGlobal within)
        DiscordControls.Start();

        awakened = true;
    }
Exemple #29
0
 public ScriptWrapper()
 {
     script = LuaScriptBinder.boundScript();
     this.Bind("_getv", (Func <Script, string, DynValue>) this.GetVar);
     script.DoString("setmetatable({}, {__index=function(t, name) return _getv(name); end})");
 }
Exemple #30
0
    // Use this for initialization
    private void Start()
    {
        // add button functions

        // reset RealGlobals
        ResetRG.GetComponent <Button>().onClick.AddListener(() => {
            if (RealGlobalCooldown > 0)
            {
                LuaScriptBinder.ClearVariables();
                RealGlobalCooldown = 60 * 2;
                ResetRG.GetComponentInChildren <Text>().text = !GlobalControls.crate ? "Real Globals Erased!" : "REEL GOLBELZ DELEET!!!!!";
            }
            else
            {
                RealGlobalCooldown = 60 * 2;
                ResetRG.GetComponentInChildren <Text>().text = !GlobalControls.crate ? "Are you sure?" : "R U SUR???";
            }
        });

        // reset AlMightyGlobals
        ResetAG.GetComponent <Button>().onClick.AddListener(() => {
            if (AlMightyGlobalCooldown > 0)
            {
                LuaScriptBinder.ClearAlMighty();
                AlMightyGlobalCooldown = 60 * 2;
                ResetAG.GetComponentInChildren <Text>().text = !GlobalControls.crate ? "AlMighty Globals Erased!" : "ALMEIGHTIZ DELEET!!!!!";
            }
            else
            {
                AlMightyGlobalCooldown = 60 * 2;
                ResetAG.GetComponentInChildren <Text>().text = !GlobalControls.crate ? "Are you sure?" : "R U SUR???";
            }
        });

        // clear Save
        ClearSave.GetComponent <Button>().onClick.AddListener(() => {
            if (SaveCooldown > 0)
            {
                File.Delete(Application.persistentDataPath + "/save.gd");
                SaveCooldown = 60 * 2;
                ClearSave.GetComponentInChildren <Text>().text = !GlobalControls.crate ? "Save wiped!" : "RIP";
            }
            else
            {
                SaveCooldown = 60 * 2;
                ClearSave.GetComponentInChildren <Text>().text = !GlobalControls.crate ? "Are you sure?" : "R U SUR???";
            }
        });

        // toggle safe mode
        Safe.GetComponent <Button>().onClick.AddListener(() => {
            ControlPanel.instance.Safe = !ControlPanel.instance.Safe;

            // save Safe Mode preferences to AlMighties
            LuaScriptBinder.SetAlMighty(null, "CYFSafeMode", DynValue.NewBoolean(ControlPanel.instance.Safe), true);

            Safe.GetComponentInChildren <Text>().text = !GlobalControls.crate
                ? ("Safe mode: " + (ControlPanel.instance.Safe ? "On" : "Off"))
                : ("SFAE MDOE: " + (ControlPanel.instance.Safe ? "ON" : "OFF"));
        });
        Safe.GetComponentInChildren <Text>().text = !GlobalControls.crate
            ? ("Safe mode: " + (ControlPanel.instance.Safe ? "On" : "Off"))
            : ("SFAE MDOE: " + (ControlPanel.instance.Safe ? "ON" : "OFF"));

        // toggle retrocompatibility mode
        Retro.GetComponent <Button>().onClick.AddListener(() => {
            GlobalControls.retroMode = !GlobalControls.retroMode;

            // save RetroMode preferences to AlMighties
            LuaScriptBinder.SetAlMighty(null, "CYFRetroMode", DynValue.NewBoolean(GlobalControls.retroMode), true);

            Retro.GetComponentInChildren <Text>().text = !GlobalControls.crate
                ? ("Retrocompatibility Mode: " + (GlobalControls.retroMode ? "On" : "Off"))
                : ("RETORCMOAPTIILBIYT MOD: " + (GlobalControls.retroMode ? "ON" : "OFF"));
        });
        Retro.GetComponentInChildren <Text>().text = !GlobalControls.crate
            ? ("Retrocompatibility Mode: " + (GlobalControls.retroMode ? "On" : "Off"))
            : ("RETORCMOAPTIILBIYT MOD: " + (GlobalControls.retroMode ? "ON" : "OFF"));

        // toggle pixel-perfect fullscreen
        Fullscreen.GetComponent <Button>().onClick.AddListener(() => {
            ScreenResolution.perfectFullscreen = !ScreenResolution.perfectFullscreen;

            // save RetroMode preferences to AlMighties
            LuaScriptBinder.SetAlMighty(null, "CYFPerfectFullscreen", DynValue.NewBoolean(ScreenResolution.perfectFullscreen), true);

            Fullscreen.GetComponentInChildren <Text>().text = !GlobalControls.crate
                ? ("Blurless Fullscreen: " + (ScreenResolution.perfectFullscreen ? "On" : "Off"))
                : ("NOT UGLEE FULLSCREEN: " + (ScreenResolution.perfectFullscreen ? "ON" : "OFF"));
        });
        Fullscreen.GetComponentInChildren <Text>().text = !GlobalControls.crate
            ? ("Blurless Fullscreen: " + (ScreenResolution.perfectFullscreen ? "On" : "Off"))
            : ("NOT UGLEE FULLSCREEN: " + (ScreenResolution.perfectFullscreen ? "ON" : "OFF"));

        // change window scale
        Scale.GetComponent <Button>().onClick.AddListener(() => {
            double maxScale = System.Math.Floor(Screen.currentResolution.height / 480.0);
            if (ScreenResolution.windowScale < maxScale)
            {
                ScreenResolution.windowScale += 1;
            }
            else
            {
                ScreenResolution.windowScale = 1;
            }

            if (Screen.height != ScreenResolution.windowScale * 480 && !Screen.fullScreen)
            {
                ScreenResolution.SetFullScreen(false);
            }

            // save RetroMode preferences to AlMighties
            LuaScriptBinder.SetAlMighty(null, "CYFWindowScale", DynValue.NewNumber(ScreenResolution.windowScale), true);

            Scale.GetComponentInChildren <Text>().text = !GlobalControls.crate
                ? ("Window Scale: " + ScreenResolution.windowScale.ToString() + "x")
                : ("WEENDO STRECH: " + ScreenResolution.windowScale.ToString() + "X");
        });
        ScreenResolution.windowScale--;
        Scale.GetComponent <Button>().onClick.Invoke();

        // Discord Rich Presence
        // Change Discord Status Visibility
        Discord.GetComponent <Button>().onClick.AddListener(() => {
            Discord.GetComponentInChildren <Text>().text = (!GlobalControls.crate ? "Discord Display: " : "DEESCORD DESPLAY: ") + DiscordControls.ChangeVisibilitySetting(1);
        });
        Discord.GetComponentInChildren <Text>().text = (!GlobalControls.crate ? "Discord Display: " : "DEESCORD DESPLAY: ") + DiscordControls.ChangeVisibilitySetting(0);

        // exit
        Exit.GetComponent <Button>().onClick.AddListener(() => { SceneManager.LoadScene("ModSelect"); });

        // Crate Your Frisk
        if (!GlobalControls.crate)
        {
            return;
        }
        // labels
        GameObject.Find("OptionsLabel").GetComponent <Text>().text     = "OPSHUNS";
        GameObject.Find("DescriptionLabel").GetComponent <Text>().text = "MORE TXET";

        // buttons
        ResetRG.GetComponentInChildren <Text>().text   = "RESTE RELA GOLBALZ";
        ResetAG.GetComponentInChildren <Text>().text   = "RESTE ALMIGTY GOLBALZ";
        ClearSave.GetComponentInChildren <Text>().text = "WYPE SAV";
        Exit.GetComponentInChildren <Text>().text      = "EXIT TOO MAD SELCT";
    }
    public static IEnumerator GetIntoDaMap(string call, object[] neededArgs)
    {
        if (GameObject.Find("Main Camera OW"))
        {
            GameObject.Find("Main Camera OW").GetComponent <EventManager>().readyToReLaunch = true;
            GameObject.Find("Main Camera OW").tag = "MainCamera";
        }

        //Clear any leftover Sprite and Text objects that are no longer connected to any scripts
        foreach (Transform child in GameObject.Find("Canvas Two").transform)
        {
            if (!child.name.EndsWith("Layer"))
            {
                GameObject.Destroy(child.gameObject);
            }
            else
            {
                foreach (Transform child2 in child)
                {
                    GameObject.Destroy(child2.gameObject);
                }
            }
        }

        yield return(0);

        Camera.main.transparencySortMode = TransparencySortMode.CustomAxis;
        Camera.main.transparencySortAxis = new Vector3(0.0f, 1.0f, 1000000.0f);

        try { PlayerOverworld.instance.backgroundSize = GameObject.Find("Background").GetComponent <RectTransform>().sizeDelta *GameObject.Find("Background").GetComponent <RectTransform>().localScale.x; }
        catch { UnitaleUtil.WriteInLogAndDebugger("RectifyCameraPosition: The 'Background' GameObject is missing."); }

        EventManager.instance.onceReload = false;
        //Permits to reload the current data if needed
        MapInfos mi = GameObject.Find("Background").GetComponent <MapInfos>();

        if (StaticInits.MODFOLDER != mi.modToLoad)
        {
            StaticInits.MODFOLDER   = mi.modToLoad;
            StaticInits.Initialized = false;
            StaticInits.InitAll();
            LuaScriptBinder.Set(null, "ModFolder", DynValue.NewString(StaticInits.MODFOLDER));
            if (call == "transitionoverworld")
            {
                EventManager.instance.ScriptLaunched = false;
                EventManager.instance.script         = null;
            }
        }

        AudioSource audio = UnitaleUtil.GetCurrentOverworldAudio();

        if (mi.isMusicKeptBetweenBattles)
        {
            Camera.main.GetComponent <AudioSource>().Stop();
            Camera.main.GetComponent <AudioSource>().clip = null;
        }
        else
        {
            PlayerOverworld.audioKept.Stop();
            PlayerOverworld.audioKept.clip = null;
        }

        //Starts the music if there's no music
        if (audio.clip == null)
        {
            if (mi.music != "none")
            {
                audio.clip = AudioClipRegistry.GetMusic(mi.music);
                audio.time = 0;
                audio.Play();
            }
            else
            {
                audio.Stop();
            }
        }
        else
        {
            //Get the file's name with this...thing?
            string test = audio.clip.name.Replace('\\', '/').Split(new string[] { "/Audio/" }, System.StringSplitOptions.RemoveEmptyEntries)[1].Split('.')[0];
            if (test != mi.music)
            {
                if (mi.music != "none")
                {
                    audio.clip = AudioClipRegistry.GetMusic(mi.music);
                    audio.time = 0;
                    audio.Play();
                }
                else
                {
                    audio.Stop();
                }
            }
        }

        GameObject.Find("utHeart").GetComponent <Image>().color = new Color(GameObject.Find("utHeart").GetComponent <Image>().color.r,
                                                                            GameObject.Find("utHeart").GetComponent <Image>().color.g,
                                                                            GameObject.Find("utHeart").GetComponent <Image>().color.b, 0);
        PlayerOverworld.instance.cameraShift = Vector2.zero;
        if (call == "tphandler")
        {
            GameObject.Find("Player").transform.parent.position = (Vector2)neededArgs[0];
            PlayerOverworld.instance.gameObject.GetComponent <CYFAnimator>().movementDirection = ((TPHandler)neededArgs[1]).direction;
            ((TPHandler)neededArgs[1]).activated = false;
            GameObject.Destroy(((TPHandler)neededArgs[1]).gameObject);
        }

        if (GameObject.Find("Don't show it again"))
        {
            GameObject.Destroy(GameObject.Find("Don't show it again"));
        }
        StaticInits.SendLoaded();
    }