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)
        {
            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.º 3
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.º 4
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.º 5
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.º 6
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.º 7
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;
        }
    }
Ejemplo n.º 8
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;
        }
    }
Ejemplo n.º 9
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.º 10
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>";
            }
        }
    }
Ejemplo n.º 11
0
 private void Start()
 {
     if (!initial)
     {
         StaticInits.Start();
         SaveLoad.Start();
         new ControlPanel();
         new PlayerCharacter();
         SaveLoad.LoadAlMighty();
         StaticInits.MODFOLDER = "Undertale Disbelief Papyrus";
         StaticInits.ENCOUNTER = "by Cezar Andrade";
         StartCoroutine(LaunchMod());
     }
 }
Ejemplo n.º 12
0
 /// <summary>
 /// Control checking.
 /// </summary>
 void Update()
 {
     if (Input.GetKeyDown(KeyCode.F4))
     {
         Screen.fullScreen = !Screen.fullScreen;
     }
     else if (Input.GetKeyDown(KeyCode.F9))
     {
         UserDebugger.instance.gameObject.SetActive(!UserDebugger.instance.gameObject.activeSelf);
     }
     else if (Input.GetKeyDown(KeyCode.Escape))
     {
         Application.LoadLevel("ModSelect");
         StaticInits.Reset();
     }
 }
Ejemplo n.º 13
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.º 14
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());
 }
Ejemplo n.º 15
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.º 16
0
    // Use this for initialization
    void Start()
    {
        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();
        MisriHalek       = GameObject.Find("MisriHalek").GetComponent <Image>();
        MainText         = FindObjectOfType <Text>();
        MainAudio        = Camera.main.GetComponent <AudioSource>();
        SubAudio         = GameObject.Find("SubAudio").GetComponent <AudioSource>();
        MainSprite       = ((LuaSpriteController)SpriteUtil.MakeIngameSprite("empty", "none", -1).UserData.Object);
        MainSprite.alpha = 0;
        MainSprite.SetPivot(.5f, 0);
        MainSprite.absy = 260;

        Sprite[] sprs = Resources.LoadAll <Sprite>("Sprites/Punder");
        foreach (Sprite spr in sprs)
        {
            Sprites.Add(spr.name, spr);
        }
        AudioClip[] adcs = Resources.LoadAll <AudioClip>("Audios");
        foreach (AudioClip adc in adcs)
        {
            Audios.Add(adc.name, adc);
        }
        MainAudio.clip = Audios["MisriHalek"];
        MainAudio.loop = false;
        MainAudio.Play();
        //MainAudio.time = 137;
        clipSampleData = new float[sampleDataLength];
    }
Ejemplo n.º 17
0
    public void SwitchState(UIState state)
    {
        //Pre-state
        if (parentStateCall)
        {
            parentStateCall = false;
            encounter.script.Call("EnteringState", new DynValue[] { DynValue.NewString(state.ToString()), DynValue.NewString(this.state.ToString()) });
            parentStateCall = true;

            if (childStateCalled)
            {
                childStateCalled = false;
                return;
            }
        }
        else
        {
            childStateCalled = true;
        }

        // TODO Quick and dirty addition to add some humor to the Run away command.
        // Will be removed without question.
        if (musicPausedFromRunning)
        {
            Camera.main.GetComponent <AudioSource>().UnPause();
            musicPausedFromRunning = false;
        }
        // END DEBUG

        // below: actions based on ending a previous state, or actions that affect multiple states
        if (this.state == UIState.DEFENDING && state != UIState.DEFENDING)
        {
            encounter.endWave();
        }

        if (state != UIState.ENEMYDIALOGUE && state != UIState.DEFENDING)
        {
            ArenaSizer.instance.Resize(ArenaSizer.UIWidth, ArenaSizer.UIHeight);
            PlayerController.instance.invulTimer = 0.0f;
            PlayerController.instance.setControlOverride(true);
        }

        if (this.state == UIState.ENEMYSELECT && action == Actions.FIGHT)
        {
            foreach (LifeBarController lbc in arenaParent.GetComponentsInChildren <LifeBarController>())
            {
                Destroy(lbc.gameObject);
            }
        }

        if (state == UIState.DEFENDING || state == UIState.ENEMYDIALOGUE)
        {
            textmgr.destroyText();
            PlayerController.instance.SetPosition(320, 160, false);
            PlayerController.instance.GetComponent <Image>().enabled = true;
            fightBtn.overrideSprite = null;
            actBtn.overrideSprite   = null;
            itemBtn.overrideSprite  = null;
            mercyBtn.overrideSprite = null;
            textmgr.setPause(true);
        }

        if (this.state == UIState.ENEMYDIALOGUE)
        {
            TextManager[] textmen = FindObjectsOfType <TextManager>();
            foreach (TextManager textman in textmen)
            {
                if (textman.gameObject.name.StartsWith("DialogBubble")) // game object name is hardcoded as it won't change
                {
                    Destroy(textman.gameObject);
                }
            }
        }

        this.state = state;
        switch (state)
        {
        case UIState.ATTACKING:
            textmgr.destroyText();
            PlayerController.instance.GetComponent <Image>().enabled = false;
            fightUI.Init(encounter.enabledEnemies[selectedEnemy]);
            break;

        case UIState.ACTIONSELECT:
            PlayerController.instance.setControlOverride(true);
            PlayerController.instance.GetComponent <Image>().enabled = true;
            setPlayerOnAction(action);
            textmgr.setPause(ArenaSizer.instance.isResizeInProgress());
            textmgr.setCaller(encounter.script);     // probably not necessary due to ActionDialogResult changes
            textmgr.setText(new RegularMessage(encounter.EncounterText));
            break;

        case UIState.ACTMENU:
            string[] actions = new string[encounter.enabledEnemies[selectedEnemy].ActCommands.Length];
            for (int i = 0; i < actions.Length; i++)
            {
                actions[i] = encounter.enabledEnemies[selectedEnemy].ActCommands[i];
            }

            selectedAction = 0;
            setPlayerOnSelection(selectedAction);
            textmgr.setText(new SelectMessage(actions, false));
            break;

        case UIState.ITEMMENU:
            string[] items = getInventoryPage(0);
            selectedItem = 0;
            setPlayerOnSelection(0);
            textmgr.setText(new SelectMessage(items, false));

            /*ActionDialogResult(new TextMessage[] {
             *  new TextMessage("Can't open inventory.\nClogged with pasta residue.", true, false),
             *  new TextMessage("Might also be a dog.\nIt's ambiguous.",true,false)
             * }, UIState.ENEMYDIALOG);*/
            break;

        case UIState.MERCYMENU:
            selectedMercy = 0;
            string[] mercyopts = new string[1 + (encounter.CanRun ? 1 : 0)];
            mercyopts[0] = "Spare";
            foreach (EnemyController enemy in encounter.enabledEnemies)
            {
                if (enemy.CanSpare)
                {
                    mercyopts[0] = "[starcolor:ffff00][color:ffff00]" + mercyopts[0] + "[color:ffffff]";
                    break;
                }
            }
            if (encounter.CanRun)
            {
                mercyopts[1] = "Flee";
            }
            setPlayerOnSelection(0);
            textmgr.setText(new SelectMessage(mercyopts, true));
            break;

        case UIState.ENEMYSELECT:
            string[] names         = new string[encounter.enabledEnemies.Length];
            string[] colorPrefixes = new string[names.Length];
            for (int i = 0; i < encounter.enabledEnemies.Length; i++)
            {
                names[i] = encounter.enabledEnemies[i].Name;
                if (encounter.enabledEnemies[i].CanSpare)
                {
                    colorPrefixes[i] = "[color:ffff00]";
                }
            }

            textmgr.setText(new SelectMessage(names, true, colorPrefixes));
            if (action == Actions.FIGHT)
            {
                int maxWidth = (int)initialHealthPos.x;
                for (int i = 0; i < encounter.enabledEnemies.Length; i++)
                {
                    int mNameWidth = UnitaleUtil.fontStringWidth(textmgr.Charset, "* " + encounter.enabledEnemies[i].Name) + 50;
                    if (mNameWidth > maxWidth)
                    {
                        maxWidth = mNameWidth;
                    }
                }
                for (int i = 0; i < encounter.enabledEnemies.Length; i++)
                {
                    LifeBarController lifebar = Instantiate(Resources.Load <LifeBarController>("Prefabs/HPBar"));
                    lifebar.transform.SetParent(textmgr.transform);
                    RectTransform lifebarRt = lifebar.GetComponent <RectTransform>();
                    lifebarRt.anchoredPosition = new Vector2(maxWidth, initialHealthPos.y - i * textmgr.Charset.LineSpacing);
                    lifebarRt.sizeDelta        = new Vector2(90, lifebarRt.sizeDelta.y);
                    lifebar.setFillColor(Color.green);
                    float hpFrac = (float)encounter.enabledEnemies[i].HP / (float)encounter.enabledEnemies[i].getMaxHP();
                    lifebar.setInstant(hpFrac);
                }
            }

            if (selectedEnemy >= encounter.enabledEnemies.Length)
            {
                selectedEnemy = 0;
            }
            setPlayerOnSelection(selectedEnemy * 2);     // single list so skip right row by multiplying x2
            break;

        case UIState.DEFENDING:
            ArenaSizer.instance.Resize((int)encounter.ArenaSize.x, (int)encounter.ArenaSize.y);
            PlayerController.instance.setControlOverride(false);
            encounter.nextWave();
            // ActionDialogResult(new TextMessage("This is where you'd\rdefend yourself.\nBut the code was spaghetti.", true, false), UIState.ACTIONSELECT);
            break;

        case UIState.DIALOGRESULT:
            PlayerController.instance.GetComponent <Image>().enabled = false;
            break;

        case UIState.ENEMYDIALOGUE:
            PlayerController.instance.GetComponent <Image>().enabled = true;
            ArenaSizer.instance.Resize(155, 130);
            encounter.CallOnSelfOrChildren("EnemyDialogueStarting");
            monDialogues = new TextManager[encounter.enabledEnemies.Length];
            for (int i = 0; i < encounter.enabledEnemies.Length; i++)
            {
                string[] msgs = encounter.enabledEnemies[i].GetDefenseDialog();
                if (msgs == null)
                {
                    UserDebugger.warn("Entered ENEMYDIALOGUE, but no current/random dialogue was set for " + encounter.enabledEnemies[i].Name);
                    SwitchState(UIState.DEFENDING);
                    break;
                }
                GameObject    speechBub = Instantiate(SpriteFontRegistry.BUBBLE_OBJECT);
                RectTransform enemyRt   = encounter.enabledEnemies[i].GetComponent <RectTransform>();
                TextManager   sbTextMan = speechBub.GetComponent <TextManager>();
                monDialogues[i] = sbTextMan;
                sbTextMan.setCaller(encounter.enabledEnemies[i].script);
                Image speechBubImg = speechBub.GetComponent <Image>();
                SpriteUtil.SwapSpriteFromFile(speechBubImg, encounter.enabledEnemies[i].DialogBubble);
                Sprite speechBubSpr = speechBubImg.sprite;
                // TODO improve position setting/remove hardcoding of position setting
                speechBub.transform.SetParent(encounter.enabledEnemies[i].transform);
                speechBub.GetComponent <RectTransform>().anchoredPosition = encounter.enabledEnemies[i].DialogBubblePosition;
                sbTextMan.setOffset(speechBubSpr.border.x, -speechBubSpr.border.w);
                sbTextMan.setFont(SpriteFontRegistry.Get(SpriteFontRegistry.UI_MONSTERTEXT_NAME));
                sbTextMan.setEffect(new RotatingEffect(sbTextMan));

                MonsterMessage[] monMsgs = new MonsterMessage[msgs.Length];
                for (int j = 0; j < monMsgs.Length; j++)
                {
                    monMsgs[j] = new MonsterMessage(msgs[j]);
                }

                sbTextMan.setTextQueue(monMsgs);
                speechBub.GetComponent <Image>().enabled = true;
            }
            break;

        case UIState.DONE:
            StaticInits.Reset();
            Application.LoadLevel("ModSelect");
            break;
        }
    }
Ejemplo n.º 18
0
    // Update is called once per frame
    void Update()
    {
        if (!started)
        {
            return;
        }

        if (internalTimer > breakHeartAfter)
        {
            AudioSource.PlayClipAtPoint(heartbreak, Camera.main.transform.position, 0.75f);
            brokenHeartPrefab = Instantiate(brokenHeartPrefab);
            brokenHeartPrefab.transform.SetParent(this.gameObject.transform);
            brokenHeartPrefab.GetComponent <RectTransform>().position = heartPos;
            brokenHeartPrefab.GetComponent <Image>().color            = heartColor;
            gameObject.GetComponent <Image>().enabled = false;
            breakHeartAfter = 999.0f;
        }

        if (internalTimer > explodeHeartAfter)
        {
            AudioSource.PlayClipAtPoint(heartsplode, Camera.main.transform.position, 0.75f);
            brokenHeartPrefab.GetComponent <Image>().enabled = false;
            heartShardInstances = new RectTransform[6];
            heartShardRelocs    = new Vector2[6];
            heartShardCtrl      = new LuaSpriteController[6];
            for (int i = 0; i < heartShardInstances.Length; i++)
            {
                heartShardInstances[i] = Instantiate(heartShardPrefab).GetComponent <RectTransform>();
                heartShardCtrl[i]      = new LuaSpriteController(heartShardInstances[i].GetComponent <Image>());
                heartShardInstances[i].transform.SetParent(this.gameObject.transform);
                heartShardInstances[i].GetComponent <RectTransform>().position = heartPos;
                heartShardInstances[i].GetComponent <Image>().color            = heartColor;
                heartShardRelocs[i] = UnityEngine.Random.insideUnitCircle * 100.0f;
                heartShardCtrl[i].Set(heartShardAnim[0]);
                heartShardCtrl[i].SetAnimation(heartShardAnim, 1 / 5f);
            }
            explodeHeartAfter = 999.0f;
        }

        if (internalTimer > gameOverAfter)
        {
            gameOverMusic.Play();
            gameOverAfter = 999.0f;
        }

        if (internalTimer > fluffybunsAfter)
        {
            gameOverTxt.setHorizontalSpacing(7);
            gameOverTxt.setTextQueue(new TextMessage[] {
                new TextMessage("", false, false), // initial blank message to force pressing Z
                new TextMessage("[color:ffffff][voice:v_fluffybuns][waitall:2]You cannot give\nup just yet...", false, false),
                new TextMessage("[color:ffffff][voice:v_fluffybuns][waitall:2]" + PlayerCharacter.Name + "!\n[w:15]Stay determined...", false, false),
                new TextMessage("", false, false), // ending with a double blank message, because the text manager is considered complete
                new TextMessage("", false, false)  // when you're on the last line, and the last line is done writing out too - we fade at this point
            });
            fluffybunsAfter = 999.0f;
        }

        for (int i = 0; i < heartShardInstances.Length; i++)
        {
            heartShardInstances[i].position += (Vector3)heartShardRelocs[i] * Time.deltaTime;
            heartShardRelocs[i].y           -= 100f * Time.deltaTime;
        }

        if (!done)
        {
            gameOverImage.color = new Color(1, 1, 1, gameOverFadeTimer);
            if (gameOverAfter >= 999.0f && gameOverFadeTimer < 1.0f)
            {
                gameOverFadeTimer += Time.deltaTime / 2;
                if (gameOverFadeTimer >= 1.0f)
                {
                    gameOverFadeTimer = 1.0f;
                    done = true;
                }
            }
            internalTimer += Time.deltaTime; // this is actually dangerous because done can be true before everything's done if timers are modified
        }
        else if (!exiting && !gameOverTxt.allLinesComplete())
        {
            // Note: [noskip] only affects the UI controller's ability to skip, so we have to redo that here.
            if (InputUtil.Pressed(GlobalControls.input.Confirm) && gameOverTxt.lineComplete())
            {
                gameOverTxt.nextLine();
            }
        }
        else if (!exiting && gameOverTxt.allLinesComplete())
        {
            exiting           = true;
            gameOverFadeTimer = 1.0f;
        }
        else if (exiting && gameOverFadeTimer > 0.0f)
        {
            gameOverImage.color = new Color(1, 1, 1, gameOverFadeTimer);
            if (gameOverFadeTimer > 0.0f)
            {
                gameOverFadeTimer -= Time.deltaTime / 2;
                if (gameOverFadeTimer <= 0.0f)
                {
                    gameOverFadeTimer = 0.0f;
                }
            }
        }
        else if (exiting)
        {
            // repurposing the timer as a reset delay
            gameOverFadeTimer -= Time.deltaTime;
            if (gameOverMusic.volume - Time.deltaTime > 0.0f)
            {
                gameOverMusic.volume -= Time.deltaTime;
            }
            else
            {
                gameOverMusic.volume = 0.0f;
            }

            if (gameOverFadeTimer < -1.5f)
            {
                StaticInits.Reset();
                Destroy(this.gameObject);
                Application.LoadLevel("ModSelect");
            }
        }
    }
Ejemplo n.º 19
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;
    }
Ejemplo n.º 20
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();
    }
    // Use this for initialization
    void Start()
    {
        // Load CYF's save file
        StaticInits.Start();
        SaveLoad.Start();

        // Set up CYF's basic objects
        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
        // Load CYF's AlMighty save file
        SaveLoad.LoadAlMighty();

        // Store useful scene objects
        misriHalek = GameObject.Find("MisriHalek").GetComponent <Image>();
        mainText   = GameObject.Find("MainText").GetComponent <Text>();
        subText    = GameObject.Find("SubText").GetComponent <Text>();
        mainAudio  = Camera.main.GetComponent <AudioSource>();
        subAudio   = GameObject.Find("SubAudio").GetComponent <AudioSource>();

        // Load all resources needed for this animation to play
        Sprite[] punderSprs = Resources.LoadAll <Sprite>("Sprites/Punder");
        foreach (Sprite spr in punderSprs)
        {
            punderSprites.Add(spr.name, spr);
        }

        Sprite[] luSprs = Resources.LoadAll <Sprite>("Sprites/Lu");
        foreach (Sprite spr in luSprs)
        {
            luSprites.Add(spr.name, spr);
        }

        AudioClip[] adcs = Resources.LoadAll <AudioClip>("Audios");
        foreach (AudioClip adc in adcs)
        {
            audioFiles.Add(adc.name, adc);
        }

        // Create all sprites needed for the animation
        mainSprite       = (LuaSpriteController)SpriteUtil.MakeIngameSprite("empty", "Default", -1).UserData.Object;
        mainSprite.alpha = 0;
        mainSprite.SetPivot(.5f, 0);
        mainSprite.x = 0;
        mainSprite.y = 20;

        fadeSprite       = (LuaSpriteController)SpriteUtil.MakeIngameSprite("black", "Default", -1).UserData.Object;
        fadeSprite.alpha = 0;

        pauseSprite = (LuaSpriteController)SpriteUtil.MakeIngameSprite("empty", "Default", -1).UserData.Object;
        SetSprite(Resources.Load <Sprite>("Sprites/pause"), "", pauseSprite);
        pauseSprite.alpha = 0;

        subSprite   = (LuaSpriteController)SpriteUtil.MakeIngameSprite("empty", "Lu", -1).UserData.Object;
        subSprite.x = 0;
        subSprite.y = -400;
        SetSprite("HoldNormal0", false);

        // Preload all other audio files to prevent lag spikes
        foreach (AudioClip clip in audioFiles.Values)
        {
            mainAudio.clip = clip;
            mainAudio.Play();
        }
        mainAudio.clip = audioFiles["MisriHalek"];
        mainAudio.loop = false;
        mainAudio.Play();

        clipSampleData = new float[sampleDataLength];
    }