Пример #1
0
        /**
         * Es wird versucht, ob man die aktuelle Figur nach links verschieben kann
         */
        public bool left()
        {
            lock (App.myLock)
            {
                Point[] newPoints = new Point[4];
                for (int i = 0; i < points.Length; i++)
                {
                    newPoints[i] = new Point(points[i].X - 1, points[i].Y);
                }
                board.clearPoints(points);
                if (this.ghostPoints != null)
                {
                    board.clearPoints(this.ghostPoints);
                }

                bool doFit = doPointsFit(newPoints);
                if (doFit)
                {
                    points = newPoints;
                }
                Point[] fallenPoints = simulatedFall();
                this.ghostPoints = fallenPoints;
                board.writeCell(points, fallenPoints, color, board.getFallenPreviewColor());
                return(doFit);
            }
        }
Пример #2
0
        /**
         * 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);
                        }
                    }
                }
            });
        }