Exemple #1
0
        private async Task AnimateAllCardsBackToDeck(double duration = Double.MaxValue)
        {
            CountControl.Hide();
            if (duration == Double.MaxValue)
            {
                duration = MainPage.AnimationSpeeds.Medium;
            }

            // flip the cards and then move them for a nice affect

            List <Task <object> > list = new List <Task <object> >();

            GridPlayer.FlipAllCards(CardOrientation.FaceDown, list);
            GridPlayer.MoveAllCardsToTarget(GridDeck, list, duration);

            GridCrib.FlipAllCards(CardOrientation.FaceDown, list);
            GridCrib.MoveAllCardsToTarget(GridDeck, list, duration);

            GridPlayedCards.FlipAllCards(CardOrientation.FaceDown, list);
            GridPlayedCards.MoveAllCardsToTarget(GridDeck, list, duration);

            GridComputer.FlipAllCards(CardOrientation.FaceDown, list);
            GridComputer.MoveAllCardsToTarget(GridDeck, list, duration);

            foreach (CardView card in GridDeck.Items)
            {
                card.Reset();
            }

            GridDeck.UpdateCardLayout(list, duration, false);

            await Task.WhenAll(list);
        }
Exemple #2
0
        private async Task AnimateCribCardsToOwner(PlayerType owner)
        {
            CardContainer cribOwner = GridPlayer;

            if (owner == PlayerType.Computer)
            {
                cribOwner = GridComputer;
            }

            List <Task <Object> > tasks = new List <Task <object> >();

            //
            //  return player and computer cards to the deck

            GridPlayer.FlipAllCards(CardOrientation.FaceDown, tasks);
            GridPlayer.MoveAllCardsToTarget(GridDeck, tasks, MainPage.AnimationSpeeds.Medium, true);
            GridComputer.FlipAllCards(CardOrientation.FaceDown, tasks);
            GridComputer.MoveAllCardsToTarget(GridDeck, tasks, MainPage.AnimationSpeeds.Medium, true);


            //
            //  move crib cards back to player
            GridCrib.MoveAllCardsToTarget(cribOwner, tasks, MainPage.AnimationSpeeds.Medium, true);
            cribOwner.FlipAllCards(CardOrientation.FaceUp, tasks);
            await Task.WhenAll(tasks);
        }
        private async Task OnCountResetUpdateUi()
        {
            CountControl.UpdateLayout();

            await GridPlayedCards.UpdateCardLayout();

            await GridComputer.UpdateCardLayout();

            await GridPlayer.UpdateCardLayout();

            if (Settings.HitContinueOnGo == true)
            {
                await HintWindow_ShowAndWait("Go!\n\nHit Continue.");
            }
            else
            {
                await Task.Delay(1000);
            }
            foreach (CardView c in GridPlayedCards.Items)
            {
                c.SetOrientationAsync(CardOrientation.FaceDown, MainPage.AnimationSpeeds.Medium);
            }
            UpdateCount(0);
            CountControl.UpdateLayout();
        }
Exemple #4
0
        private async Task AnimateSelectComputerCribCards(List <CardView> cards)
        {
            if (GridComputer.Items.Count == 0)
            {
                return;
            }
            List <Task <Object> > tasks = new List <Task <object> >();

            GridComputer.MoveCardToTarget(cards[1], GridPlayedCards, tasks);
            GridComputer.MoveCardToTarget(cards[0], GridPlayedCards, tasks);
            await Task.WhenAll(tasks);
        }
        public async void UpdateAllCardGrids(double duration = Double.MaxValue, bool rotate = false)
        {
            foreach (CardView card in Deck.Cards)
            {
                GridDeck.SetCardSize(card);
            }

            List <Task <object> > taskList = new List <Task <object> >();

            GridDeck.UpdateCardLayout(taskList, duration, rotate);
            GridPlayer.UpdateCardLayout(taskList, duration, rotate);
            GridComputer.UpdateCardLayout(taskList, duration, rotate);
            GridPlayedCards.UpdateCardLayout(taskList, duration, rotate);
            GridCrib.UpdateCardLayout(taskList, duration, rotate);
            await Task.WhenAll(taskList);
        }
        public async Task OnCountCard(CardView card, PlayerType currentPlayer, CountingData countingData)
        {
            string message = "";

            if (countingData.Score > 0)
            {
                message = String.Format("{0} Scored Points\n\n{1}", currentPlayer == PlayerType.Player ? "You" : "The Computer", countingData.ScoreStory.Format());
                if (currentPlayer == PlayerType.Player)
                {
                    _pointsPlayerCountedThisTurn++;
                }
                else
                {
                    _pointsComputerCountedThisTurn++;
                }
            }
            if (currentPlayer == PlayerType.Computer)
            {
                //
                //  if it is the player, the card gets moved there via drag and drop
                await GridComputer.MoveCardToTarget(card, GridPlayedCards, MainPage.AnimationSpeeds.Medium);
            }


            if (card.Orientation == CardOrientation.FaceDown)
            {
                await card.SetOrientation(CardOrientation.FaceUp);
            }


            if (countingData.Score > 0)
            {
                await AddToScoreHistory(GridPlayedCards.Items, countingData.ScoreStory, currentPlayer);
            }


            UpdateCount(countingData.CurrentCount);


            if (countingData.ResetCount) // the card we just dropped hit 31 or a Go
            {
                UpdateCount(countingData.CountBeforeReset);
                await OnCountResetUpdateUi();
            }


            if (countingData.NextPlayer == PlayerType.Player)
            {
                GridPlayer.MaxSelected = 1;
                message += "Your Turn.\nDrag and drop one card into the middle window";
            }
            else
            {
                GridPlayer.MaxSelected = 0;
            }

            if (message != "")
            {
                ShowHintWindowAsync(true, false, message);
            }
        }