Exemplo n.º 1
0
 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();
     }
 }
Exemplo n.º 2
0
    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();
        }
    }
Exemplo n.º 3
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);
    }
    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));
    }