Ejemplo n.º 1
0
    private IEnumerator FixBrickDelay(BrickController brick)
    {
        if (brick.SpeedFall == 0)
        {
            yield break;
        }

        if (FixedBrickBeforeEvent != null)
        {
            FixedBrickBeforeEvent(this, null);
        }

        brick.SpeedFall = 0;

        var boxes = brick.GetBoxes();

        brick.DetachBoxes();

        foreach (GameObject box in boxes)
        {
            var pos = box.transform.localPosition;

            var x = Mathf.RoundToInt(pos.x);
            var y = Mathf.RoundToInt(pos.y);

            if (x < 0 || x >= Size.x || y < 0)
            {
                Destroy(box);
                continue;
            }
            else if (y >= Size.y)
            {
                continue;
            }

            pos.x = x;
            pos.y = y;
            box.transform.localPosition = pos;

            _field[x, y] = box;
        }

        yield return(StartCoroutine(DestroyLines()));

        if (!GameOver())
        {
            NewBrick();
        }

        if (FixedBrickAfterEvent != null)
        {
            FixedBrickAfterEvent(this, null);
        }
    }
Ejemplo n.º 2
0
    private IEnumerator FixBrickDelay(BrickController brick)
    {
        if (brick.SpeedFall == 0)
            yield break;

        if (FixedBrickBeforeEvent != null)
            FixedBrickBeforeEvent(this, null);

        brick.SpeedFall = 0;

        var boxes = brick.GetBoxes();
        brick.DetachBoxes();

        foreach (GameObject box in boxes)
        {
            var pos = box.transform.localPosition;

            var x = Mathf.RoundToInt(pos.x);
            var y = Mathf.RoundToInt(pos.y);

            if (x < 0 || x >= Size.x || y < 0)
            {
                Destroy(box);
                continue;
            }
            else if (y >= Size.y)
                continue;

            pos.x = x;
            pos.y = y;
            box.transform.localPosition = pos;

            _field[x, y] = box;
        }

        yield return StartCoroutine(DestroyLines());

        if (!GameOver())
            NewBrick();

        if (FixedBrickAfterEvent != null)
            FixedBrickAfterEvent(this, null);
    }