示例#1
0
 public ChessmanControl(ChessmanBase chessman)
 {
     _chessman = chessman;
     if (!chessman.IsRed)
     {
         ChessColor = Brushes.Blue;
     }
 }
示例#2
0
        internal void MoveChessman(ChessPoint point, ChessmanBase chessman)
        {
            ChessmanBase oldChessman = _chessmanMap[point.X, point.Y];

            _chessmanMap[chessman.Location.X, chessman.Location.Y] = null;
            _chessmanMap[point.X, point.Y] = chessman;

            if (ChessMoved != null)
            {
                ChessMoved(point, chessman.Location, chessman, oldChessman);
            }
        }
示例#3
0
        void chessboard_ChessMoved(ChessPoint newPoint, ChessPoint oldPoint, ChessmanBase newChessman, ChessmanBase oldChessman)
        {
            _lastMoveChessman = _chessmanBaseDic[newChessman];

            soundPlayer.Play();
            //置换
            IsRedTurn = !IsRedTurn;

            //移动动画
            _chessmanBaseDic[newChessman].RenderTransform = _moveTransform;

            DoubleAnimation xAnimation = new DoubleAnimation((newPoint.X - oldPoint.X) * CellWidth, _moveDuration, FillBehavior.Stop);

            _moveTransform.BeginAnimation(TranslateTransform.XProperty, xAnimation);

            DoubleAnimation yAnimation = new DoubleAnimation((newPoint.Y - oldPoint.Y) * CellWidth, _moveDuration, FillBehavior.Stop);

            EventHandler tempAction = default(EventHandler);

            tempAction = delegate
            {
                _chessmanBaseDic[newChessman].ClearValue(UIElement.RenderTransformProperty);
                _chessmanBaseDic[newChessman].isSelected = false;
                _currentChessmanControl = null;
                if (oldChessman != null)
                {
                    ChessmanCollection.Remove(_chessmanBaseDic[oldChessman]);
                }

                //更新
                this.InvalidateArrange();
                //移除本身
                yAnimation.Completed -= tempAction;
            };

            yAnimation.Completed += tempAction;

            _moveTransform.BeginAnimation(TranslateTransform.YProperty, yAnimation);
        }
示例#4
0
 internal void SetDefalutChessman(ChessPoint point, ChessmanBase chessman)
 {
     _chessmanMap[point.X, point.Y] = chessman;
 }