Пример #1
0
        // board specific methods
        public override void Update(CellState state)
        {
            CellColor  color = (state == CellState.Free) ? CellColor.LightGray : this.color;
            TetrisCell cell  = new TetrisCell()
            {
                Color = color, State = state
            };

            // update model
            this.board[this.anchorPoint.Y, this.anchorPoint.X]         = cell;
            this.board[this.anchorPoint.Y, this.anchorPoint.X + 1]     = cell;
            this.board[this.anchorPoint.Y + 1, this.anchorPoint.X]     = cell;
            this.board[this.anchorPoint.Y + 1, this.anchorPoint.X + 1] = cell;
        }
Пример #2
0
        // board specific methods
        public override void Update(CellState state)
        {
            CellColor  color = (state == CellState.Free) ? CellColor.LightGray : this.color;
            TetrisCell cell  = new TetrisCell()
            {
                Color = color, State = state
            };

            // update model
            if (this.rotation == RotationAngle.Degrees_0)
            {
                this.board[this.anchorPoint.Y + 1, this.anchorPoint.X - 1] = cell;
                this.board[this.anchorPoint.Y + 1, this.anchorPoint.X]     = cell;
                this.board[this.anchorPoint.Y, this.anchorPoint.X]         = cell;
                this.board[this.anchorPoint.Y, this.anchorPoint.X + 1]     = cell;
            }
            else if (this.rotation == RotationAngle.Degrees_90)
            {
                this.board[this.anchorPoint.Y - 1, this.anchorPoint.X - 1] = cell;
                this.board[this.anchorPoint.Y, this.anchorPoint.X - 1]     = cell;
                this.board[this.anchorPoint.Y, this.anchorPoint.X]         = cell;
                this.board[this.anchorPoint.Y + 1, this.anchorPoint.X]     = cell;
            }
            else if (this.rotation == RotationAngle.Degrees_180)
            {
                this.board[this.anchorPoint.Y, this.anchorPoint.X - 1]     = cell;
                this.board[this.anchorPoint.Y, this.anchorPoint.X]         = cell;
                this.board[this.anchorPoint.Y - 1, this.anchorPoint.X]     = cell;
                this.board[this.anchorPoint.Y - 1, this.anchorPoint.X + 1] = cell;
            }
            else if (this.rotation == RotationAngle.Degrees_270)
            {
                this.board[this.anchorPoint.Y - 1, this.anchorPoint.X]     = cell;
                this.board[this.anchorPoint.Y, this.anchorPoint.X]         = cell;
                this.board[this.anchorPoint.Y, this.anchorPoint.X + 1]     = cell;
                this.board[this.anchorPoint.Y + 1, this.anchorPoint.X + 1] = cell;
            }
        }