コード例 #1
0
        /// Creates a new Shape according to the given nextShape and adds a listener for the JoinPile event
        public void DeployNewShape(ShapeProxy nextShape)
        {
            IShape shape = nextShape.current;

            if (shape is ShapeL)
            {
                current = new ShapeL(board);
            }
            else if (shape is ShapeI)
            {
                current = new ShapeI(board);
            }
            else if (shape is ShapeS)
            {
                current = new ShapeS(board);
            }
            else if (shape is ShapeZ)
            {
                current = new ShapeZ(board);
            }
            else if (shape is ShapeT)
            {
                current = new ShapeT(board);
            }
            else if (shape is ShapeO)
            {
                current = new ShapeO(board);
            }
            else
            {
                current = new ShapeJ(board);
            }

            current.JoinPile += joinPileHandler;
        }
コード例 #2
0
ファイル: Board.cs プロジェクト: jeegnathebug/Tetris
        /// <summary>
        /// Initializes a new instance of the <see cref="Board"/> class.
        /// </summary>
        /// <param name="shapeFactory">The <see cref="ShapeFactory"/>.</param>
        public Board()
        {
            board = new Color[10, 20];
            for (int i = 0; i < 10; i++)
            {
                for (int j = 0; j < 20; j++)
                {
                    board[i, j] = Color.Black;
                }
            }

            ShapeProxy proxy = new ShapeProxy(this);
            shapeFactory = proxy;
            shape = proxy;

            // Event handler
            shape.JoinPile += new JoinPileHandler(addToPile);

            shapeFactory.DeployNewShape();
        }