Ejemplo n.º 1
0
    /// <summary>
    /// Checks if you pressed one of the things the disclaimer tells you to. It's pretty straightforward.
    /// </summary>
    private void Update()
    {
        // Try to hook on to the game window when the user interacts
        #if UNITY_STANDALONE_WIN || UNITY_EDITOR_WIN
        if (Input.GetMouseButtonDown(0) || Input.GetKeyDown(KeyCode.Space) || Input.GetKeyDown(KeyCode.O) || Input.GetKeyDown(KeyCode.F4) ||
            Input.GetKeyDown(KeyCode.Return) && (Input.GetKey(KeyCode.LeftAlt) || Input.GetKey(KeyCode.RightAlt)))      // LAlt/RAlt + Enter
        {
            Misc.RetargetWindow();
        }
        #endif

        if (!ScreenResolution.hasInitialized)
        {
            return;
        }
        if (Input.GetKeyDown(KeyCode.O))
        {
            StaticInits.MODFOLDER   = StaticInits.EDITOR_MODFOLDER;
            StaticInits.Initialized = false;
            StaticInits.InitAll();
            GlobalControls.modDev = false;
            SceneManager.LoadScene("Intro");
            Destroy(this);
        }
        else if (Input.GetKeyDown(KeyCode.Space) || Input.GetMouseButtonDown(0) || Input.GetKeyDown(KeyCode.Return))
        {
            StartCoroutine(ModSelect());
        }
    }
Ejemplo n.º 2
0
    IEnumerator LaunchMod()
    {
        // First: make sure the mod is still here and can be opened
        if (!(new DirectoryInfo(Path.Combine(FileLoader.DataRoot, "Mods/" + modDirs[CurrentSelectedMod].Name + "/Lua/Encounters/"))).Exists ||
            !File.Exists(Path.Combine(FileLoader.DataRoot, "Mods/" + modDirs[CurrentSelectedMod].Name + "/Lua/Encounters/" + StaticInits.ENCOUNTER + ".lua")))
        {
            HandleErrors();
            yield break;
        }

        // Dim the background to indicate loading
        GameObject.Find("ModBackground").GetComponent <Image>().color = new Color(1f, 1f, 1f, 0.1875f);

        // Store the current position of the scrolly bit
        encounterListScroll = encounterBox.transform.Find("ScrollCutoff/Content").gameObject.GetComponent <RectTransform>().anchoredPosition.y;

        yield return(new WaitForEndOfFrame());

        StaticInits.Initialized = false;
        try {
            StaticInits.InitAll();
            Debug.Log("Loading " + StaticInits.ENCOUNTER);
            GlobalControls.isInFight = true;
            SceneManager.LoadScene("Battle");
        } catch {
            GameObject.Find("ModBackground").GetComponent <Image>().color = new Color(1f, 1f, 1f, 0.25f);
        }
    }
Ejemplo n.º 3
0
    private IEnumerator LaunchMod()
    {
        // First: make sure the mod is still here and can be opened
        if (!new DirectoryInfo(Path.Combine(FileLoader.DataRoot, "Mods/" + modDirs[CurrentSelectedMod].Name + "/Lua/Encounters/")).Exists ||
            !File.Exists(Path.Combine(FileLoader.DataRoot, "Mods/" + modDirs[CurrentSelectedMod].Name + "/Lua/Encounters/" + StaticInits.ENCOUNTER + ".lua")))
        {
            HandleErrors();
            yield break;
        }

        // Dim the background to indicate loading
        ModBackground.GetComponent <Image>().color = new Color(1f, 1f, 1f, 0.1875f);

        // Store the current position of the scrolly bit
        encounterListScroll = content.GetComponent <RectTransform>().anchoredPosition.y;

        yield return(new WaitForEndOfFrame());

        StaticInits.Initialized = false;
        try {
            StaticInits.InitAll(true);
            if (UnitaleUtil.firstErrorShown)
            {
                throw new Exception();
            }
            Debug.Log("Loading " + StaticInits.ENCOUNTER);
            GlobalControls.isInFight = true;
            DiscordControls.StartBattle(modDirs[CurrentSelectedMod].Name, StaticInits.ENCOUNTER);
            SceneManager.LoadScene("Battle");
        } catch (Exception e) {
            ModBackground.GetComponent <Image>().color = new Color(1f, 1f, 1f, 0.25f);
            Debug.LogError("An error occured while loading a mod:\n" + e.Message + "\n\n" + e.StackTrace);
        }
    }
Ejemplo n.º 4
0
 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"));
 }
Ejemplo n.º 5
0
    IEnumerator LaunchMod()
    {
        // First: make sure the mod is still here and can be opened
        if (!(new DirectoryInfo(Path.Combine(FileLoader.DataRoot, "Mods/" + StaticInits.MODFOLDER + "/Lua/Encounters/"))).Exists ||
            !File.Exists(Path.Combine(FileLoader.DataRoot, "Mods/" + StaticInits.MODFOLDER + "/Lua/Encounters/" + StaticInits.ENCOUNTER + ".lua")))
        {
            Debug.LogWarning("Error detected! Mod or Encounter not found!");
            Application.Quit();
            yield break;
        }/**/

        yield return(new WaitForEndOfFrame());

        StaticInits.Initialized = false;
        try
        {
            StaticInits.InitAll();
            Debug.Log("Loading: " + StaticInits.ENCOUNTER);
            GlobalControls.isInFight = true;
            SceneManager.LoadScene("Battle");
        }
        catch
        {
            Debug.LogError("it doesnt work");
        }
    }
Ejemplo n.º 6
0
    IEnumerator LaunchMod()
    {
        // first: make sure the mod is still here and can be opened
        if (!(new DirectoryInfo(Path.Combine(FileLoader.DataRoot, "Mods/" + modDirs[CurrentSelectedMod].Name + "/Lua/Encounters/"))).Exists)
        {
            HandleErrors();
            yield break;
        }

        // dim the background to indicate loading
        GameObject.Find("ModBackground").GetComponent <Image>().color = new Color(1f, 1f, 1f, 0.1875f);

        // store the current position of the scrolly bit
        encounterListScroll = encounterBox.transform.Find("ScrollCutoff/Content").gameObject.GetComponent <RectTransform>().anchoredPosition.y;

        yield return(new WaitForEndOfFrame());

        /*int width = Screen.width;
         * int height = Screen.height;
         * Texture2D tex = new Texture2D(width, height, TextureFormat.RGB24, false);
         * tex.ReadPixels(new Rect(0, 0, width, height), 0, 0);
         * tex.Apply();
         * GlobalControls.texBeforeEncounter = tex;*/
        //byte[] bytes = tex.EncodeToPNG();
        //File.WriteAllBytes(Application.dataPath + "/ItsAVeryHackyWayToMakeTransitionsIKnowThanksYouCanDeleteThisFileIfYouWantTo.png", bytes);
        StaticInits.Initialized = false;
        StaticInits.InitAll();
        Debug.Log("Loading " + StaticInits.ENCOUNTER);
        GlobalControls.isInFight = true;
        SceneManager.LoadScene("Battle");
    }
Ejemplo n.º 7
0
 /// <summary>
 /// Sends the player back to the title screen, making him lose his progression
 /// </summary>
 [CYFEventFunction] public void TitleScreen()
 {
     NewMusicManager.DestroyChannel("StaticKeptAudio");
     GameObject.Destroy(GameObject.Find("Player"));
     GameObject.Destroy(GameObject.Find("Canvas OW"));
     StaticInits.MODFOLDER   = "@Title";
     StaticInits.Initialized = false;
     StaticInits.InitAll();
     GameObject.Destroy(GameObject.Find("Main Camera OW"));
     SceneManager.LoadScene("TitleScreen");
 }
Ejemplo n.º 8
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);
    }
Ejemplo n.º 9
0
    IEnumerator LaunchMod()
    {
        yield return(new WaitForEndOfFrame());

        int       width  = Screen.width;
        int       height = Screen.height;
        Texture2D tex    = new Texture2D(width, height, TextureFormat.RGB24, false);

        tex.ReadPixels(new Rect(0, 0, width, height), 0, 0);
        tex.Apply();
        GlobalControls.texBeforeEncounter = tex;
        //byte[] bytes = tex.EncodeToPNG();
        //File.WriteAllBytes(Application.dataPath + "/ItsAVeryHackyWayToMakeTransitionsIKnowThanksYouCanDeleteThisFileIfYouWantTo.png", bytes);
        StaticInits.Initialized = false;
        StaticInits.InitAll();
        Debug.Log("Loading " + StaticInits.ENCOUNTER);
        GlobalControls.isInFight = true;
        SceneManager.LoadScene("Battle");
    }
Ejemplo n.º 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();
    }