Beispiel #1
0
        public Animation(float speed, AtomicMove move, Piece piece, float tileSize)
        {
            this.speed    = speed;
            this.move     = move;
            this.piece    = piece;
            this.tileSize = tileSize;

            start  = new Vector2f(move.GetSource().GetFile() * tileSize, (7 - move.GetSource().GetRank()) * tileSize);
            dir    = new Vector2f(move.GetDestination().GetFile() * tileSize, (7 - move.GetDestination().GetRank()) * tileSize) - start;
            length = (float)Math.Sqrt(dir.X * dir.X + dir.Y * dir.Y) / tileSize;
        }
Beispiel #2
0
        private void ExecuteAtomicMove(AtomicMove move)
        {
            Location source      = move.GetSource();
            Location destination = move.GetDestination();

            Piece piece     = Get(source);
            Piece destPiece = Get(destination);

            if (destPiece != null)
            {
                capturedPieces.Push(destPiece);
                move.Capture();

                if (destPiece.GetPieceColor().IsWhite())
                {
                    whitePieces.Remove(destPiece);
                }
                else
                {
                    blackPieces.Remove(destPiece);
                }
            }

            Set(destination, piece);
            Set(source, null);
            piece.Do(move);
            Update();
        }
Beispiel #3
0
        private void ExecuteAtomicMoveReversed(AtomicMove move)
        {
            Location source      = move.GetDestination();
            Location destination = move.GetSource();

            Piece piece = Get(source);

            Set(destination, piece);
            piece.Undo(move);
            if (move.DidCapture())
            {
                Piece destPiece = capturedPieces.Pop();
                Add(destPiece);
            }
            else
            {
                Set(source, null);
            }
            Update();
        }
Beispiel #4
0
 public virtual void Do(AtomicMove move)
 {
     this.location = move.GetDestination();
 }