protected virtual bool Drop() { if (isAnimationMode) return false; if (gameOver) return false; try { pile.DropBlock(row, col, block); //TODO: SimulateChain의 결과 처리하기 chainResult = pile.SimulateChain(); score += chainResult.Score; } finally { // swDrop.Restart(); animationMode = true; } return true; }
public ChainResult SimulateChain() { ChainResult chainResult = new ChainResult(); //initialize chainResult.SetOriginalBoard(board); chainResult.score = 0; bool flgContinue = false; do { List<int> removedLines = new List<int>(); List<Animation.Drop> dropCells = new List<Animation.Drop>(); flgContinue = CalcDrop(dropCells, board); //DONE : move all blocks down & add it to drop cells list //(2) clear full line for (int i = 0; i < ROW_SIZE + 3; i++) { int cnt = 0; for (int j = 0; j < COL_SIZE; j++) if (IsCellEmpty(i, j)) cnt++; if (cnt == 0) { for (int j = 0; j < COL_SIZE; j++) board[i, j] = new BlankCell(); removedLines.Add(i); flgContinue = true; } } chainResult.Add(new Animation.EraseDropPair(removedLines, dropCells)); //DONE : combine removedLines & drop cells list to make EraseDropPair //DONE : chainResult.animation 에 EraseDropPair 추가하기. chainResult.GetScore(removedLines.Count); //DONE : calculate score } while (flgContinue); return chainResult; }