Exemplo n.º 1
0
    //=================================================================================================

    public void RefreshForms()
    {
        FormList.ClearOptions();
        List <Form>   forms   = MISC.LoadForms();
        List <string> options = new List <string>();

        for (int x = 0; x < forms.Count; x++)
        {
            options.Add(forms[x].Name);
        }

        FormList.AddOptions(options);
    }
Exemplo n.º 2
0
    public FormController SpawnForm(string Name = "")
    {
        FormController c = null;

        List <Form> forms = MISC.LoadForms();

        for (int x = 0; x < forms.Count; x++)
        {
            if (forms[x].Name == Name)
            {
                GameObject Cache = Instantiate(FormFrame);
                Cache.transform.SetParent(LevelFormContainer.transform);
                //Cache.name = "Form";
                Cache.name = forms[x].Name;

                FormController LEMFC = Cache.GetComponent <FormController>();
                if (LEMFC != null)
                {
                    LEMFC.FormPlan = forms[x];
                    RectTransform LEMFCRT = Cache.GetComponent <RectTransform>();
                    LEMFCRT.localScale       = new Vector3(0.5f, 0.5f, 0.5f);
                    LEMFCRT.anchoredPosition = Vector2.zero;
                    LEMFCRT.anchorMin        = new Vector2(0, 1);
                    LEMFCRT.anchorMax        = new Vector2(0, 1);
                    LEMFCRT.pivot            = new Vector2(0, 1);


                    FormsInLevel.Add(LEMFC);

                    return(LEMFC);
                }
                else
                {
                    Debug.LogError("[LVM] No Form Controller found!");
                }

                return(c);
            }
        }
        Debug.LogWarning("[LVM] Could not find form!");
        return(c);
    }
Exemplo n.º 3
0
    public static Sprite GenerateLevelSprite()
    {
        if (CurrentLevel == null)
        {
            return(null);
        }

        Form LevelForm = ScriptableObject.CreateInstance <Form>();

        LevelForm.Width  = 9;
        LevelForm.Height = 12;
        LevelForm.Resize(9, 9);

        minx = 5;
        miny = 5;
        maxx = 0;
        maxy = 0;

        LevelTilesShouldBe.Resize(9, 12);

        List <Form> forms = MISC.LoadForms();

        foreach (LevelData ld in CurrentLevel.Data)
        {
            for (int x = 0; x < forms.Count; x++)
            {
                if (forms[x].Name == ld.FormName)
                {
                    Form Cache = ScriptableObject.CreateInstance <Form>();
                    forms[x].CloneTo(Cache);

                    while (Cache.Rotated != ld.RotationState)
                    {
                        Cache.RotateRight();
                    }

                    for (int fy = 0; fy < Cache.Height; fy++)
                    {
                        for (int fx = 0; fx < Cache.Width; fx++)
                        {
                            SimpleTriforce CacheTri = new SimpleTriforce();
                            CacheTri = Cache.Get(fx, fy);
                            int realX = ld.x / 64 + fx;
                            int realY = ld.y / 64 * -1 + fy;

                            if (CacheTri.Type != SimpleTriforce.TriforceType.EMPTY)
                            {
                                if (LevelForm.Get(realX, realY).Type != SimpleTriforce.TriforceType.EMPTY)
                                {
                                    LevelForm.Set(realX, realY, new SimpleTriforce(SimpleTriforce.TriforceType.FILLED));
                                    LevelTilesShouldBe.Set(realX, realY, new SimpleTriforce(SimpleTriforce.TriforceType.FILLED));
                                }
                                else
                                {
                                    LevelForm.Set(realX, realY, CacheTri);
                                    LevelTilesShouldBe.Set(realX, realY, CacheTri);
                                }


                                if (realX < minx)
                                {
                                    minx = realX;
                                }
                                if (realY < miny)
                                {
                                    miny = realY;
                                }
                                if (realX + 1 > maxx)
                                {
                                    maxx = realX + 1;
                                }
                                if (realY + 1 > maxy)
                                {
                                    maxy = realY + 1;
                                }
                            }
                        }
                    }
                }
            }
        }
        Sprite retSprite = GenerateFormSprite(LevelForm);

        return(retSprite);
    }
Exemplo n.º 4
0
    public LEM_FormController SpawnForm(string Name = "")
    {
        LEM_FormController c = null;

        if (Name == "")
        {
            Name = FormList.options[FormList.value].text;
        }

        List <Form> forms = MISC.LoadForms();

        for (int x = 0; x < forms.Count; x++)
        {
            if (forms[x].Name == Name)
            {
                GameObject Cache = Instantiate(FormFrame);
                Cache.transform.SetParent(FormContainer.transform);
                Cache.name = "Form";

                LEM_FormController LEMFC = Cache.GetComponent <LEM_FormController>();
                if (LEMFC != null)
                {
                    LEMFC.FormPlan = forms[x];
                    RectTransform LEMFCRT = Cache.GetComponent <RectTransform>();
                    LEMFCRT.anchoredPosition = Vector2.zero;
                    LEMFCRT.anchorMin        = new Vector2(0, 1);
                    LEMFCRT.anchorMax        = new Vector2(0, 1);
                    LEMFCRT.pivot            = new Vector2(0, 1);
                    // return LEMFC;
                }
                else
                {
                    Debug.LogError("[LEM] No Form Controller found!");
                }


                Cache = Instantiate(FormButtonFrame);
                Cache.transform.SetParent(FormButtonContainer.transform);
                Cache.name = "BottomForm";

                LEM_BottomController LEMBC = Cache.GetComponent <LEM_BottomController>();
                if (LEMBC != null)
                {
                    LEMBC.FormPlan = forms[x];
                    RectTransform LEMFCRT = Cache.GetComponent <RectTransform>();
                    LEMFCRT.anchoredPosition = Vector2.zero;
                    LEMFCRT.anchorMin        = new Vector2(0, 1);
                    LEMFCRT.anchorMax        = new Vector2(0, 1);
                    LEMFCRT.pivot            = new Vector2(0, 1);
                    CurrentBottom            = LEMBC;
                    return(LEMFC);
                }
                else
                {
                    Debug.LogError("[LEM] No Form Controller found!");
                }

                return(c);
            }
        }

        Debug.LogWarning("[LEM] Could not find form!");
        return(c);
    }