public void SlideTo(int x, int y, EndOffAnimationDelegate callBack) { tx = x; ty = y; sx = Canvas.GetLeft(background); sy = Canvas.GetTop(background); dx = (tx - sx) / SLIDE_STEPS; dy = (ty - sy) / SLIDE_STEPS; step = 0; this.callBack = callBack; mode = SLIDE; }
private void DropPieces() { EndOffAnimationDelegate dropCallBack = new EndOffAnimationDelegate(DropEnded); // Slide all pieces down, use callback to fill in new and run a checkMatches for (int ix = 0; ix < columns; ix++) { for (int iy = rows - 1; iy >= 0; iy--) { if (board[ix, iy] == null) { for (int i = iy - 1; i >= 0; i--) { if (board[ix, i] != null) { board[ix, iy] = board[ix, i]; board[ix, i] = null; board[ix, iy].SlideTo(boardX + ix * (pieceSize + pieceGap), boardY + iy * (pieceSize + pieceGap), dropCallBack); dropCallBack = null; break; } } } } } if (dropCallBack != null) dropCallBack(null); }