예제 #1
0
        private async Task AnimationEndHand(PlayerType dealer)
        {
            var taskList = new List <Task>();

            var cribOwnerGrid = dealer == PlayerType.Computer ? _cgComputer : _cgPlayer;

            taskList.AddRange(AnimateFlipAllCards(cribOwnerGrid.Cards, CardOrientation.FaceDown, true));
            taskList.AddRange(CardGrid.AnimateMoveAllCards(cribOwnerGrid, _cgDeck, MOVE_CARDS_ANIMATION_DURATION, 0,
                                                           AnimateMoveOptions.MoveSequentlyEndingAtZero, false));
            await Task.WhenAll(taskList);
        }
예제 #2
0
        public async Task AnimateMoveCribCardsBackToOwner(PlayerType dealer)
        {
            //
            //  when we open a game in the state GameState.ScorePlayerCrib, we will have already
            //  moved the crib back to the player -- so there are no cards in the crib.
            //  check for this and abort if there are no cards in the crib

            if (_cgCrib.Cards.Count == 0)
            {
                return;
            }

            var taskList = new List <Task>();

            taskList.AddRange(AnimateFlipAllCards(_cgComputer.Cards, CardOrientation.FaceDown, true));
            taskList.AddRange(AnimateFlipAllCards(_cgPlayer.Cards, CardOrientation.FaceDown, true));
            await Task.WhenAll(taskList);

            taskList.Clear();
            var newTaskList = CardGrid.AnimateMoveAllCards(_cgComputer, _cgDeck, MOVE_CARDS_ANIMATION_DURATION, 0,
                                                           AnimateMoveOptions.StackAtZero, false);

            if (newTaskList != null)
            {
                taskList.AddRange(newTaskList);
            }
            newTaskList = CardGrid.AnimateMoveAllCards(_cgPlayer, _cgDeck, MOVE_CARDS_ANIMATION_DURATION, 0, AnimateMoveOptions.StackAtZero, false);
            if (newTaskList != null)
            {
                taskList.AddRange(newTaskList);
            }

            if (taskList.Count > 0)
            {
                await Task.WhenAll(taskList);

                taskList.Clear();
            }

            var cribOwnerGrid = dealer == PlayerType.Computer ? _cgComputer : _cgPlayer;

            taskList = CardGrid.AnimateMoveAllCards(_cgCrib, cribOwnerGrid, MOVE_CARDS_ANIMATION_DURATION, 0,
                                                    AnimateMoveOptions.MoveSequentlyEndingAtZero, false);
            if (taskList != null)
            {
                taskList.AddRange(newTaskList);
                await Task.WhenAll(taskList);

                taskList.Clear();
            }

            taskList = AnimateFlipAllCards(_cgCrib.Cards, CardOrientation.FaceUp,
                                           true);
            if (taskList != null)
            {
                await Task.WhenAll(taskList);

                taskList.Clear();
            }

            CardGrid.TransferAllCards(_cgComputer, _cgDeck, true);
            CardGrid.TransferAllCards(_cgPlayer, _cgDeck, true);
            CardGrid.TransferAllCards(_cgCrib, cribOwnerGrid, false);
        }