Exemplo n.º 1
0
        /// <summary>Execute this command.</summary>
        public override void Do()
        {
            clone = new TerrainClone((TerrainClone)piece);

            model.AnimationManager.LaunchAnimationSequence(
                new MoveToFrontOfBoardAnimation(clone.Stack, boardAfter),
                new MoveStackInstantlyAnimation(clone.Stack, positionAfter));
        }
Exemplo n.º 2
0
 /// <summary>Execute this command.</summary>
 public override void Do()
 {
     preventConflict(stack);
     if (stack.Pieces[0] is ITerrainPrototype)
     {
         clone = new TerrainClone((TerrainPrototype)stack.Pieces[0]);
         model.AnimationManager.LaunchAnimationSequence(
             new MoveToFrontOfBoardAnimation(clone.Stack, stack.Board),
             new MoveStackInstantlyAnimation(clone.Stack, positionAfter));
     }
     else
     {
         side = stack.Pieces[0].Side;
         model.AnimationManager.LaunchAnimationSequence(
             new DetachStacksAnimation(new IStack[] { stack }, new Side[] { side }),
             new MoveToFrontOfBoardAnimation(stack, stack.Board),
             new MoveStackInstantlyAnimation(stack, positionAfter));
     }
 }
Exemplo n.º 3
0
        /// <summary>Execute this command.</summary>
        public override void Do()
        {
            if (stackAfter != null)
            {
                preventConflict(stackBefore, stackAfter);
            }
            else
            {
                preventConflict(stackBefore);
            }

            PlayerHand playerHand = (PlayerHand)model.CurrentGameBox.CurrentGame.GetPlayerHand(playerGuid);

            insertionIndex = (playerHand != null ? playerHand.Count : 0);

            List <IAnimation> animations = new List <IAnimation>(4);

            if (playerHand == null)
            {
                animations.Add(new AddPlayerHandAnimation(playerGuid));
            }

            if (piece is ITerrainPrototype)
            {
                if (stackAfter != null)
                {
                    preventConflict(stackAfter);
                    // does the hand already contain an identical clone?
                    for (int i = 0; i < stackAfter.Pieces.Length; ++i)
                    {
                        ITerrainClone handPiece = stackAfter.Pieces[i] as ITerrainClone;
                        if (handPiece != null && handPiece.Prototype == piece)
                        {
                            // yes -> simply move the piece to the new insertion index
                            animations.Add(new RearrangePlayerHandAnimation(playerHand, i, insertionIndex));
                            model.AnimationManager.LaunchAnimationSequence(animations.ToArray());
                            return;
                        }
                    }
                }
                // add the piece
                clone       = new TerrainClone((TerrainPrototype)piece);
                stackBefore = clone.Stack;
                sideBefore  = piece.Side;
            }
            else
            {
                sideBefore = piece.Side;
                animations.Add(new DetachStacksAnimation(new IStack[] { stackBefore }, new Side[] { sideBefore }));
            }
            animations.Add(new MoveToFrontOfBoardAnimation(stackBefore, piece.CounterSection.CounterSheet));
            animations.Add(new MoveStackToHandAnimation(stackBefore));
            if (stackAfter == null)
            {
                animations.Add(new FillPlayerHandAnimation(playerGuid, stackBefore));
            }
            else
            {
                animations.Add(new MergeStacksAnimation(stackAfter, stackBefore, insertionIndex));
            }
            model.AnimationManager.LaunchAnimationSequence(animations.ToArray());
        }