예제 #1
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;
    }
예제 #2
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);
     }
 }
예제 #3
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;
    }
예제 #4
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;
        }
    }
예제 #5
0
    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;
        }
    }
예제 #6
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));
    }
예제 #7
0
    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>";
            }
        }
    }
예제 #8
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");
    }
예제 #9
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());
 }
예제 #10
0
    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();
    }
예제 #11
0
    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));
    }
예제 #12
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;
    }