Exemple #1
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 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);
            }
        }