IEnumerator Gravity() { yield return(new WaitForSeconds(1 / fallSpeed)); if (activeShape != null) { activeShape.MovePiece(0, -1); routineGravity = Gravity(); StartCoroutine(routineGravity); } else { StopCoroutine(routineGravity); } }
public void MoveByCoordinates(int x, int y) { int currentX; int currentY; currentX = this.tile.x; currentY = this.tile.y; //Safety locks boundaries if (currentX + x < 0) { shape.MovePiece(1, 0); } else if (currentX + x > 13) { shape.MovePiece(-1, 0); } if (currentY + y < 0) { shape.MovePiece(0, 1); } else if (currentY + y > 20) { shape.MovePiece(0, -1); } //Safety lock pieces if (FindCoordinates(x, y).thing != null && FindCoordinates(x, y).thing.GetComponent <QuadradoScript>().shape != shape) { shape.MovePiece(-x, -y); } //Movement MoveToTile(FindCoordinates(x, y)); }