示例#1
0
 private void panelChecker_SelectPiece(object sender, SelectPieceArgs e)
 {
     if (_gs.IsWolf)
     {
         e.ValidMoves = _gs.GetValidWolfMoves();
     }
     else
     {
         e.ValidMoves = _gs.GetValidSheepMoves(e.SelectedPiece);
     }
 }
示例#2
0
        private void UpdateSelected(Pos?selected, bool refresh)
        {
            if (_selectedPiece == null && selected == null)
            {
                return;
            }

            if (selected != null && _selectedPiece != null && selected.Value.Equals(_selectedPiece.Value))
            {
                //click on selected piece
                //  -wolf : do nothing
                //  -sheep : unselect
                if (_gameState.IsWolf)
                {
                    return;
                }

                _selectedPiece = null;
            }
            else
            {
                _selectedPiece = selected;
            }

            if (_selectedPiece != null)
            {
                if (SelectPiece != null)
                {
                    SelectPieceArgs e = new SelectPieceArgs(_selectedPiece.Value);
                    SelectPiece(this, e);
                    _validMoves = e.ValidMoves;
                }
            }
            else
            {
                _validMoves = null;
            }

            if (refresh)
            {
                Invalidate();
            }
        }