Пример #1
0
 public void Remove()
 {
     if (!isactive)
     {
         return;
     }
     Transform[] pcs = UnitaleUtil.GetFirstChildren(p.transform);
     for (int i = 1; i < pcs.Length; i++)
     {
         try { pcs[i].GetComponent <Projectile>().ctrl.Remove(); }
         catch { new LuaSpriteController(pcs[i].GetComponent <Image>()).Remove(); }
     }
     lastX    = x;
     lastY    = y;
     lastAbsX = absx;
     lastAbsY = absy;
     if (p.gameObject.GetComponent <KeyframeCollection>() != null)
     {
         Object.Destroy(p.gameObject.GetComponent <KeyframeCollection>());
     }
     p.gameObject.GetComponent <Mask>().enabled       = false;
     p.gameObject.GetComponent <RectMask2D>().enabled = false;
     spr.StopAnimation();
     BulletPool.instance.Requeue(p);
     p = null;
 }
Пример #2
0
    public static void CreateLayer(string name, string relatedTag = "BasisNewest", bool before = false)
    {
        if (name == null)
        {
            return;
        }
        else if (GameObject.Find("Canvas/" + name + "Layer") != null)
        {
            throw new CYFException("CreateLayer: The layer \"" + name + "\" already exists. Please use a different name.");
        }
        else if (relatedTag != "VeryHighest" && relatedTag != "VeryLowest" && relatedTag != "BasisNewest" && GameObject.Find("Canvas/" + relatedTag + "Layer") == null)
        {
            throw new CYFException("CreateLayer: Tried to make a new layer " + (before ? "below" : "above") + " the layer \"" + relatedTag + "\", but it didn't exist.");
        }

        GameObject go       = new GameObject(name + "Layer", typeof(RectTransform));
        string     testName = relatedTag + "Layer";

        Transform[] rts = UnitaleUtil.GetFirstChildren(GameObject.Find("Canvas").transform);
        if (relatedTag != "VeryHighest" && relatedTag != "VeryLowest")
        {
            if (relatedTag == "BasisNewest")
            {
                testName = "BelowArenaLayer";
            }
            for (int j = 0; j < rts.Length; j++)
            {
                if (rts[j].name == testName)
                {
                    go.transform.SetParent(GameObject.Find("Canvas").transform, true);
                    go.transform.SetSiblingIndex(j + (before ? 0 : 1));
                    break;
                }
            }
        }
        else
        {
            go.transform.SetParent(GameObject.Find("Canvas").transform, true);
            if (relatedTag == "VeryHighest")
            {
                go.transform.SetAsLastSibling();
            }
            else if (relatedTag == "VeryLowest")
            {
                go.transform.SetAsFirstSibling();
            }
        }

        go.GetComponent <RectTransform>().anchorMax = new Vector2(0, 0);
        go.GetComponent <RectTransform>().anchorMin = new Vector2(0, 0);
        go.GetComponent <RectTransform>().sizeDelta = new Vector2(1, 1);
        go.transform.position = new Vector2(0, 0);
    }
Пример #3
0
    public static bool CreateLayer(string name, string relatedTag = "BasisNewest", bool before = false)
    {
        string canvas = UnitaleUtil.IsOverworld ? "Canvas Two/" : "Canvas/";

        if (name == null || GameObject.Find(canvas + name + "Layer") != null)
        {
            return(false);
        }
        if (relatedTag != "VeryHighest" && relatedTag != "VeryLowest" && relatedTag != "BasisNewest" && GameObject.Find(canvas + relatedTag + "Layer") == null)
        {
            return(false); // throw new CYFException("CreateLayer: Tried to make a new layer " + (before ? "below" : "above") + " the layer \"" + relatedTag + "\", but it didn't exist.");
        }
        GameObject go       = new GameObject(name + "Layer", typeof(RectTransform));
        string     testName = relatedTag + "Layer";

        Transform[] rts = UnitaleUtil.GetFirstChildren(GameObject.Find(canvas).transform);
        if (relatedTag != "VeryHighest" && relatedTag != "VeryLowest")
        {
            if (relatedTag == "BasisNewest")
            {
                testName = "BelowArenaLayer";
            }
            for (int j = 0; j < rts.Length; j++)
            {
                if (rts[j].name != testName)
                {
                    continue;
                }
                go.transform.SetParent(GameObject.Find(canvas).transform, true);
                go.transform.SetSiblingIndex(j + (before ? 0 : 1));
                break;
            }
        }
        else
        {
            go.transform.SetParent(GameObject.Find(canvas).transform, true);
            switch (relatedTag)
            {
            case "VeryHighest": go.transform.SetAsLastSibling();  break;

            case "VeryLowest":  go.transform.SetAsFirstSibling(); break;
            }
        }

        go.GetComponent <RectTransform>().anchorMax = new Vector2(0, 0);
        go.GetComponent <RectTransform>().anchorMin = new Vector2(0, 0);
        go.GetComponent <RectTransform>().sizeDelta = new Vector2(1, 1);
        go.transform.position = new Vector2(0, 0);
        return(true);
    }
 public void Remove()
 {
     if (isactive)
     {
         Transform[] pcs = UnitaleUtil.GetFirstChildren(p.transform);
         for (int i = 1; i < pcs.Length; i++)
         {
             try { pcs[i].GetComponent <Projectile>().ctrl.Remove(); }
             catch { new LuaSpriteController(pcs[i].GetComponent <Image>()).Remove(); }
         }
         lastX    = x;
         lastY    = y;
         lastAbsX = absx;
         lastAbsY = absy;
         spr.StopAnimation();
         BulletPool.instance.Requeue(p);
         p = null;
     }
 }
Пример #5
0
    public static void CreateLayer(string name, string relatedTag = "BasisNewest", bool before = false)
    {
        GameObject go       = new GameObject(name + "Layer", typeof(RectTransform));
        string     testName = relatedTag + "Layer";

        Transform[] rts = UnitaleUtil.GetFirstChildren(GameObject.Find("Canvas").transform);
        if (relatedTag != "VeryHighest" && relatedTag != "VeryLowest")
        {
            if (relatedTag == "BasisNewest")
            {
                testName = "BelowArenaLayer";
            }
            for (int j = 0; j < rts.Length; j++)
            {
                if (rts[j].name == testName)
                {
                    go.transform.SetParent(GameObject.Find("Canvas").transform, true);
                    go.transform.SetSiblingIndex(j + (before ? 0 : 1));
                    break;
                }
            }
        }
        else
        {
            go.transform.SetParent(GameObject.Find("Canvas").transform, true);
            if (relatedTag == "VeryHighest")
            {
                go.transform.SetAsLastSibling();
            }
            else if (relatedTag == "VeryLowest")
            {
                go.transform.SetAsFirstSibling();
            }
        }

        go.GetComponent <RectTransform>().anchorMax = new Vector2(0, 0);
        go.GetComponent <RectTransform>().anchorMin = new Vector2(0, 0);
        go.GetComponent <RectTransform>().sizeDelta = new Vector2(1, 1);
        go.transform.position = new Vector2(0, 0);
    }
Пример #6
0
    public static void CreateLayer(string name, string relatedTag = "BasisNewest", bool before = false)
    {
        GameObject go = new GameObject(name + "Layer", typeof(RectTransform));
        int        index = -1;  bool wentIn = false; string testName = relatedTag + "Layer";

        Transform[] rts = UnitaleUtil.GetFirstChildren(GameObject.Find("Canvas").transform);
        if (relatedTag == "BasisNewest")
        {
            testName = "BelowArenaLayer";
        }
        if (relatedTag != "VeryHighest" && relatedTag != "VeryLowest")
        {
            for (int j = 0; j < rts.Length; j++)
            {
                try {
                    if (rts[j].name == testName || wentIn)
                    {
                        wentIn = true;
                        if (relatedTag == "BasisNewest" && rts[j].name.Contains("Layer") && !rts[j].name.Contains("Audio"))
                        {
                            continue;
                        }
                        wentIn = false;
                        index  = j;
                        if (before)
                        {
                            rts[j].SetParent(null, true);
                        }
                    }
                    else if (index != -1)
                    {
                        rts[j].SetParent(null, true);
                    }
                } catch { }
            }
        }

        go.transform.SetParent(GameObject.Find("Canvas").transform, true);

        if (index != -1)
        {
            if (before)
            {
                index--;
            }
            for (int j = index; j < rts.Length; j++)
            {
                try {
                    if (rts[j].gameObject.name == "Text")
                    {
                        rts[j].SetParent(GameObject.Find("Debugger").transform);
                        continue;
                    }
                    rts[j].SetParent(GameObject.Find("Canvas").transform, true);
                } catch { }
            }
        }
        if (relatedTag == "VeryHighest")
        {
            go.transform.SetAsLastSibling();
        }
        else if (relatedTag == "VeryLowest")
        {
            go.transform.SetAsFirstSibling();
        }
        go.GetComponent <RectTransform>().anchorMax = new Vector2(0, 0);
        go.GetComponent <RectTransform>().anchorMin = new Vector2(0, 0);
        go.GetComponent <RectTransform>().sizeDelta = new Vector2(1, 1);
        go.transform.position = new Vector2(0, 0);
    }
Пример #7
0
    /// <summary>
    /// Makes the buttons for the mod selection screen.
    /// </summary>
    private void modFolderSelection()
    {
        if (GlobalControls.crate)
        {
            GameObject.Find("Text").GetComponent <Text>().text = "MDO SELECTRO (CILCK + DARG TO SEE OTRHE MODS)";
        }
        DirectoryInfo di = new DirectoryInfo(System.IO.Path.Combine(FileLoader.DataRoot, "Mods"));

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

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

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

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

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

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

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

                    but4.gameObject.name = "Safemode";
                    but4.transform.SetParent(GameObject.Find("Canvas").transform);
                    but4.GetComponent <RectTransform>().sizeDelta = new Vector2(300, but3.GetComponent <RectTransform>().sizeDelta.y);
                    but4.GetComponent <RectTransform>().position  = new Vector2(325, 400);
                    if (ControlPanel.instance.Safe)
                    {
                        but4.GetComponentInChildren <Text>().text = "Safe mode: On";
                    }
                    else
                    {
                        but4.GetComponentInChildren <Text>().text = "Safe mode: Off";
                    }
                    but4.onClick.AddListener(() => {
                        ControlPanel.instance.Safe = !ControlPanel.instance.Safe;
                        if (ControlPanel.instance.Safe)
                        {
                            but4.GetComponentInChildren <Text>().text = "Safe mode: On";
                        }
                        else
                        {
                            but4.GetComponentInChildren <Text>().text = "Safe mode: Off";
                        }
                    });
                    break;
                }
            }
        }
    }