/************************************************************** Notifier **************************************************************/ public void NotifyBoardChanged(BoardEventArgs bea) { if (BoardChanged != null) { BoardChanged(this, bea); } }
/** * Errechnet die zu löschenden Zeilen und löscht sie */ public void collapse(List <int> linesToRemove) { linesToRemove.Sort(delegate(int a, int b) { return(a.CompareTo(b)); }); for (int i = 0; i < linesToRemove.Count; i++) { shiftToLine(linesToRemove[i]); } for (int i = 0; i < linesToRemove.Count; i++) { lines++; } BoardEventArgs bae = new BoardEventArgs(getBoardData()); bae.removedLines = linesToRemove; NotifyBoardChanged(bae); if (linesToRemove.Count > 0) { addScore(calcScore(linesToRemove)); setLines(lines); } }
/************************************************************** Notifier **************************************************************/ public void NotifyBoardChanged(BoardEventArgs bea) { if (BoardChanged != null) BoardChanged(this, bea); }
/** * Errechnet die zu löschenden Zeilen und löscht sie */ public void collapse(List<int> linesToRemove) { linesToRemove.Sort(delegate(int a, int b) { return a.CompareTo(b); }); for (int i = 0; i < linesToRemove.Count; i++) { shiftToLine(linesToRemove[i]); } for (int i = 0; i < linesToRemove.Count; i++) { lines++; } BoardEventArgs bae = new BoardEventArgs(getBoardData()); bae.removedLines = linesToRemove; NotifyBoardChanged(bae); if (linesToRemove.Count > 0) { addScore(calcScore(linesToRemove)); setLines(lines); } }
/** * 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); } } } }); }