Ejemplo n.º 1
0
        // public interface
        public void Clear()
        {
            // reset internal state of board
            for (int i = 0; i < this.numRows; i++)
            {
                for (int j = 0; j < this.numColumns; j++)
                {
                    this.board[i, j].Color = CellColor.LightGray;
                    this.board[i, j].State = CellState.Free;
                }
            }

            // update view
            ViewCellList list = new ViewCellList();

            for (int i = 0; i < this.numRows; i++)
            {
                for (int j = 0; j < this.numColumns; j++)
                {
                    ViewCell cell = new ViewCell();
                    cell.Color = CellColor.LightGray;
                    cell.Point = new CellPoint()
                    {
                        X = j, Y = i
                    };
                    list.Add(cell);
                }
            }
            this.OnBoardChanged(list);
        }
Ejemplo n.º 2
0
 public override void UpdateModifiedCellList(ViewCellList list, CellColor color)
 {
     list.Add(new ViewCell(color, new CellPoint()
     {
         X = this.anchorPoint.X, Y = this.anchorPoint.Y
     }));
     list.Add(new ViewCell(color, new CellPoint()
     {
         X = this.anchorPoint.X + 1, Y = this.anchorPoint.Y
     }));
     list.Add(new ViewCell(color, new CellPoint()
     {
         X = this.anchorPoint.X, Y = this.anchorPoint.Y + 1
     }));
     list.Add(new ViewCell(color, new CellPoint()
     {
         X = this.anchorPoint.X + 1, Y = this.anchorPoint.Y + 1
     }));
 }
Ejemplo n.º 3
0
        private void CopySingleRow(ViewCellList list, int row)
        {
            for (int j = 0; j < this.numColumns; j++)
            {
                // create cell to update view
                ViewCell cell = new ViewCell();
                cell.Color = this.board[row, j].Color;
                cell.Point = new CellPoint()
                {
                    X = j, Y = row + 1
                };
                list.Add(cell);

                // finally copy block one row down ...
                // Note: TetrisCell is a 'struct', so '=' works fine --
                // In case of a reference type: Clone needed (deep copy) !!!
                this.board[row + 1, j] = this.board[row, j];
            }
        }
Ejemplo n.º 4
0
 public override void UpdateModifiedCellList(ViewCellList list, CellColor color)
 {
     if (this.rotation == RotationAngle.Degrees_0)
     {
         list.Add(new ViewCell(color, new CellPoint()
         {
             X = this.anchorPoint.X - 1, Y = this.anchorPoint.Y + 1
         }));
         list.Add(new ViewCell(color, new CellPoint()
         {
             X = this.anchorPoint.X, Y = this.anchorPoint.Y + 1
         }));
         list.Add(new ViewCell(color, new CellPoint()
         {
             X = this.anchorPoint.X, Y = this.anchorPoint.Y
         }));
         list.Add(new ViewCell(color, new CellPoint()
         {
             X = this.anchorPoint.X + 1, Y = this.anchorPoint.Y
         }));
     }
     else if (this.rotation == RotationAngle.Degrees_90)
     {
         list.Add(new ViewCell(color, new CellPoint()
         {
             X = this.anchorPoint.X - 1, Y = this.anchorPoint.Y - 1
         }));
         list.Add(new ViewCell(color, new CellPoint()
         {
             X = this.anchorPoint.X - 1, Y = this.anchorPoint.Y
         }));
         list.Add(new ViewCell(color, new CellPoint()
         {
             X = this.anchorPoint.X, Y = this.anchorPoint.Y
         }));
         list.Add(new ViewCell(color, new CellPoint()
         {
             X = this.anchorPoint.X, Y = this.anchorPoint.Y + 1
         }));
     }
     else if (this.rotation == RotationAngle.Degrees_180)
     {
         list.Add(new ViewCell(color, new CellPoint()
         {
             X = this.anchorPoint.X - 1, Y = this.anchorPoint.Y
         }));
         list.Add(new ViewCell(color, new CellPoint()
         {
             X = this.anchorPoint.X, Y = this.anchorPoint.Y
         }));
         list.Add(new ViewCell(color, new CellPoint()
         {
             X = this.anchorPoint.X, Y = this.anchorPoint.Y - 1
         }));
         list.Add(new ViewCell(color, new CellPoint()
         {
             X = this.anchorPoint.X + 1, Y = this.anchorPoint.Y - 1
         }));
     }
     else if (this.rotation == RotationAngle.Degrees_270)
     {
         list.Add(new ViewCell(color, new CellPoint()
         {
             X = this.anchorPoint.X, Y = this.anchorPoint.Y - 1
         }));
         list.Add(new ViewCell(color, new CellPoint()
         {
             X = this.anchorPoint.X, Y = this.anchorPoint.Y
         }));
         list.Add(new ViewCell(color, new CellPoint()
         {
             X = this.anchorPoint.X + 1, Y = this.anchorPoint.Y
         }));
         list.Add(new ViewCell(color, new CellPoint()
         {
             X = this.anchorPoint.X + 1, Y = this.anchorPoint.Y + 1
         }));
     }
 }