示例#1
0
 public void SetPlayer(Player player)
 {
     // Associate the new instance
     _player = player;
     player._grid.NextPieceChangedEvent += PostInvalidate;
     _nextPiece = new PieceView(player._grid._nextPiece, false);
 }
        public void ChangeProposedPiece()
        {
            if(_selectedPiece < Constants.NbProposedPiece)
            {
                // Change it in the model
                _player.ChangeProposedPiece(_selectedPiece);

                // Change it in the view
                _proposedPieces[_selectedPiece] = new PieceView(_player._proposedPieces[_selectedPiece], false);

                // Select a new piece in the same place
                selectPiece(_selectedPiece);

                Invalidate();
            }
        }
        public void SetPlayer(Player player)
        {
            // Associate the new instance
            _player = player;

            // Recreate the proposed pieces
            for(int i = 0; i < Constants.NbProposedPiece; i++)
            {
                _proposedPieces[i] = new PieceView(player._proposedPieces[i], false);
            }

            // Now we can select one piece to send to the other player
            selectPiece(0);
        }
示例#4
0
        public void Init(Grid grid)
        {
            // Associate the instance
            _grid = grid;

            // Create the associated PieceViews
            _fallingPieceView = new PieceView(_grid._fallingPiece, false);
            _shadowPieceView = new PieceView(_grid._shadowPiece, true);

            // Create the associated BlockViews
            _mapView = new BlockView[Constants.GridSizeX, Constants.GridSizeY];
            for (uint i = 0 ; i < _grid._map.GetLength(0) ; i++)
            {
                for (uint j = 0 ; j < _grid._map.GetLength(1) ; j++)
                {
                    _mapView[i,j] = new BlockView(_grid._map[i,j], false);
                }
            }

            _mutexView = new Mutex(false);
        }