/** * Figur kann nicht weiter fallen, * entweder wird neue Figur erzeugt oder man ist Gameover */ private void FigureIsFallen(Point[] previousPoints) { ghostPoints = null; board.writeCell(points, color); bool gameOver = false; /*Pruefen ob GameOver*/ for (int i = 0; i < points.Length; i++) { if (points[i].Y < 0) { gameOver = true; App.getInstance().gameOver(); } } if (!gameOver) { App.getInstance().NotifyFigureFallen(previousPoints, points, color); List <int> linesToRemove = getLinesToRemove(); /*Hier werden die zu loeschenden Zeilen geloescht*/ board.collapse(linesToRemove); /*Setzt Vorschaufigur als aktuelle Figur und generiert neue Vorschau*/ board.setCurrentFigure(board.getPreviewFigure()); board.setPreviewFigure(board.generateRandomFigure()); board.getCurrentFigure().newOnBoard(); } }
/** * Jede Ă„nderungen auf dem Board wird durch diese Methode verarbeitet */ public void OnBoardChanged(object sender, BoardEventArgs bea) { Dispatcher.BeginInvoke(delegate { if (iv.rootContainer.Child == this) { Color[,] data = bea.boardData; if (bea.removedLines.Count > 0) { if (mod == 3) { animBoardRotate.To = animBoardRotate.To + 180; boardRotateSB.Begin(); } if (hardFall) { animateRemovedLinesHard(bea.removedLines); } else { animateRemovedLinesSoft(bea.removedLines); } } foreach (FrameworkElement frameWorkElement in boardGrid.Children) { Rectangle rect = (Rectangle)frameWorkElement; int x = Grid.GetColumn(frameWorkElement); int y = Grid.GetRow(frameWorkElement); Color currentCellColor = data[x, y]; if (currentCellColor == boardModel.getBoardColor()) { rect.Fill = new SolidColorBrush(Colors.Transparent); } else if (currentCellColor == boardModel.getFallenPreviewColor()) { rect.Fill = getBrushByColor(boardModel.getFallenPreviewColor()); } else { rect.Fill = getBrushByColor(currentCellColor); } } Util.Point[] previewPoints = boardModel.getPreviewFigure().getPoints(); List <Rectangle> previewRectangles = getPreOrMemBoardRectangles(previewPoints, previewGrid); foreach (FrameworkElement frameWorkElement in previewGrid.Children) { Rectangle rect = (Rectangle)frameWorkElement; rect.Fill = new SolidColorBrush(Colors.Transparent); } Color currentPreviewFigureColor = boardModel.getPreviewFigure().getColor(); foreach (Rectangle rect in previewRectangles) { rect.Fill = getBrushByColor(currentPreviewFigureColor); } if (boardModel.getMemoryFigure() != null) { clearMemoryBoard(); Util.Point[] memoryPoints = boardModel.getMemoryFigure().getPoints(); List <Rectangle> memoryRectangles = getPreOrMemBoardRectangles(memoryPoints, memoryGrid); Color currentMemoryFigureColor = boardModel.getMemoryFigure().getColor(); foreach (Rectangle rect in memoryRectangles) { rect.Fill = getBrushByColor(currentMemoryFigureColor); } } } }); }