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); } }
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); }