Exemplo n.º 1
0
    public IEnumerator waitForFormLoad(string button, int state)
    {
        while (LevelM.Init == false)
        {
            yield return(new WaitForSeconds(0.5f));
        }
        int c1 = 0;
        int c2 = 0;

        if (state == 0)
        {
            int.TryParse("0" + button.Split(' ')[1], out c1);
        }
        int.TryParse("0" + button, out c2);


        if (state == 0)
        {
            LevelM.LoadLevel(c1 - 1);
        }
        if (state == 1)
        {
            LevelM.LoadLevel(c2 - 1);
        }
    }
    public void OnBeginDrag(PointerEventData eventData)
    {
        transform.SetSiblingIndex(transform.childCount);
        StartPosition = rectTransform.anchoredPosition;

        isDrag      = true;
        wasInBottom = true;
        if (isInFormContainer == false)
        {
            wasInBottom = false;
        }

        LevelM.RegenerateCurrentLevel();
    }
Exemplo n.º 3
0
    private void Start()
    {
        instance = this;

        //Loading Textures for Form
        Empty      = Resources.Load <Texture2D>("FormEditor/Shape_Empty");
        TriangleDL = Resources.Load <Texture2D>("FormEditor/Shape_TriangleDL");
        TriangleDR = Resources.Load <Texture2D>("FormEditor/Shape_TriangleDR");
        TriangleTL = Resources.Load <Texture2D>("FormEditor/Shape_TriangleTL");
        TriangleTR = Resources.Load <Texture2D>("FormEditor/Shape_TriangleTR");
        Square     = Resources.Load <Texture2D>("FormEditor/Shape_Square");

        LevelTilesShouldBe = ScriptableObject.CreateInstance <Form>();
        LevelTilesShouldBe.Resize(9, 12);
        //  LoadLevel(1);
        LevelTilesCurrent = ScriptableObject.CreateInstance <Form>();
        LevelTilesCurrent.Resize(9, 12);

        Init = true;
    }
    public void OnEndDrag(PointerEventData eventData)
    {
        float x = rectTransform.anchoredPosition.x;
        float y = rectTransform.anchoredPosition.y;


        System.Action <ITween <Vector3> > updateSize = (t) =>
        {
            gameObject.transform.localScale = t.CurrentValue;
        };

        if (isInFormContainer == false)
        {
            if (rectTransform.anchoredPosition.x < 0)
            {
                rectTransform.anchoredPosition = new Vector2(000, y);
            }
            if (rectTransform.anchoredPosition.y > 0)
            {
                rectTransform.anchoredPosition = new Vector2(x, 000);
            }
            if (rectTransform.anchoredPosition.x > 576 - FormBuild.Width * 32)
            {
                rectTransform.anchoredPosition = new Vector2(576 - FormBuild.Width * 32, y);
            }
            if (rectTransform.anchoredPosition.y < -832 + FormBuild.Height * 32)
            {
                rectTransform.anchoredPosition = new Vector2(x, -832 + FormBuild.Height * 32);
            }


            //Snap to Grid
            x = rectTransform.anchoredPosition.x;
            y = rectTransform.anchoredPosition.y;

            int xf = (int)Mathf.Round(x / 64);
            int yf = (int)Mathf.Round(y / 64);

            x = xf * 64 - 32;
            y = yf * 64 - 32;
            //x = xf * 32 + LevelM.LevelWUneven * 16;

            //y = yf * 32 + LevelM.LevelHUneven * 16;

            rectTransform.anchoredPosition = new Vector2(x, y);

            xpos = (int)x;
            ypos = (int)y;

            RealX = (xpos - (int)LevelM.LevelX) / 64 - 1;
            RealY = (ypos + (int)LevelM.LevelY + 235) / 64 * -1 - 2;

            if (LevelM.CheckNoCollision(this) == false)
            {
                if (wasInBottom == true)
                {
                    gameObject.transform.parent = GameObject.Find("ScaleThem").transform;
                    gameObject.Tween("SizeUp", Vector3.one, Vector3.one * 0.5f, 0.1f, TweenScaleFunctions.CubicEaseIn, updateSize);
                    isInFormContainer = true;
                    rectTransform.anchoredPosition = StartPosition;
                    xpos = (int)StartPosition.x;
                    ypos = (int)StartPosition.y;
                }
                else
                {
                    rectTransform.anchoredPosition = StartPosition;
                    xpos = (int)StartPosition.x;
                    ypos = (int)StartPosition.y;
                }
            }
        }
        else
        {
            if (x < 10)
            {
                x = 10;
            }
            if (x > 580 - FormBuild.Width * 32)
            {
                x = 580 - FormBuild.Width * 32;
            }
            if (y < -290 + FormBuild.Height * 32)
            {
                y = -290 + FormBuild.Height * 32;
            }
            rectTransform.anchoredPosition = new Vector2(x, y);
        }

        isDrag = false;
        LevelM.RegenerateCurrentLevel();
        this.transform.Find("shadow").GetComponent <Image>().enabled = false;
    }