Пример #1
0
        public object Clone()
        {
            var clone = new TetriBricksGame();
            foreach (BrickColumn bc in Columns)
            {
                var bcClone = new BrickColumn();
                foreach (Brick b in bc.Bricks)
                {
                    var bClone = new Brick(b.Row, b.Column, b.Color);
                    bcClone.Bricks.Add(bClone);
                }
                clone.Columns.Add(bcClone);
            }

            return clone;
        }
        public void CreateNewGame(int rows, int columns)
        {
            _moveHistory.Clear();

            var game = new TetriBricksGame();

            for (int i = 0; i < rows; i++)
            {
                var bc = new BrickColumn();
                //bc.Game = game;
                for (int j = 0; j < columns; j++)
                {
                    bc.Bricks.Add(new Brick(i, j, GetRandomColor()));
                }
                game.Columns.Add(bc);
            }
            _moveHistory.Add((TetriBricksGame) game.Clone());
            _currentMove = 0;
        }