Example #1
0
        private async Task DealAnimation(HandsFromServer hfs, double duration = Double.MaxValue)
        {
            if (duration == Double.MaxValue)
            {
                duration = MainPage.AnimationSpeeds.Medium;
            }
            CardView card;
            List <Task <Object> > tasks = new List <Task <object> >();

            for (int i = 0; i < 6; i++)
            {
                card = hfs.PlayerCards[i];
                card.BoostZindex();
                card.Owner = Owner.Player;
                GridDeck.MoveCardToTarget(card, GridPlayer, tasks, duration, true);
                card       = hfs.ComputerCards[i];
                card.Owner = Owner.Computer;
                card.BoostZindex();
                GridDeck.MoveCardToTarget(card, GridComputer, tasks, duration, true);
            }

            await Task.WhenAll(tasks);

            await GridPlayer.FlipAllCards(CardOrientation.FaceUp, duration);

            for (int i = 0; i < 6; i++)
            {
                GridPlayer.Items[i].ResetZIndex();
                GridComputer.Items[i].ResetZIndex();
            }

            hfs.SharedCard.BoostZindex(ZIndexBoost.SmallBoost);
        }
Example #2
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);
        }
Example #3
0
        public async Task AddCardsToGrid()
        {
            int row = 0;
            int col = 0;

            GridDeck.SetCardSize(Deck.Cards[0]);
            LayoutRoot.UpdateLayout();


            foreach (CardView card in Deck.Cards)
            {
                GridDeck.SetCardSize(card);
                card.Reset();
                card.HorizontalAlignment = HorizontalAlignment.Left;
                card.VerticalAlignment   = VerticalAlignment.Top;
                Grid.SetRow(card, row);
                Grid.SetColumn(card, col);
                Grid.SetRowSpan(card, 8);         //this is required so the cards don't get clipped
                Grid.SetColumnSpan(card, 8);      //this is required so the cards don't get clipped
                Canvas.SetZIndex(card, 100 + card.Index);
                if (LayoutRoot.Children.Contains(card) == false)
                {
                    GridDeck.Items.Add(card);
                    LayoutRoot.Children.Add(card);
                }
            }
            List <Task <object> > taskList = new List <Task <object> >();

            ScatterCards(GridDeck.Items, 0, taskList);
            await Task.WhenAll(taskList);

            await PostUpdateAllCards(MainPage.AnimationSpeeds.Slow, true);
        }
Example #4
0
        public void MoveCards(List <Task <object> > taskList, List <CardView> destinationList, CardContainer destinationContainer)
        {
            double duration = MainPage.AnimationSpeeds.Fast;

            foreach (CardView card in destinationList)
            {
                GridDeck.MoveCardToTarget(taskList, card, destinationContainer, duration, false, true);
            }
        }
Example #5
0
        private async void Deck_Card_PointerReleased(object sender, PointerRoutedEventArgs e)
        {
            CardView userCard = (CardView)sender;

            foreach (CardView card in GridDeck.Items)
            {
                card.PointerReleased -= this.Deck_Card_PointerReleased;
            }

            await userCard.SetOrientation(CardOrientation.FaceUp);

            userCard.BoostZindex();
            await userCard.AnimateScale(2.0, MainPage.AnimationSpeeds.Medium);

            CardView compCard = null;
            Random   r        = new Random();

            do
            {
                int index = r.Next(GridDeck.Items.Count - 1);
                compCard = GridDeck.Items[index] as CardView;
            } while (compCard.Rank == userCard.Rank);

            await compCard.SetOrientation(CardOrientation.FaceUp);

            compCard.BoostZindex();
            await compCard.AnimateScale(2.0, MainPage.AnimationSpeeds.Medium);

            string message = String.Format("\nYou selected the {0}\nThe Computer Selected the {1}\n{2} won the deal.",
                                           userCard.DisplayName, compCard.DisplayName,
                                           compCard.Rank < userCard.Rank ? "The Computer" : "You");

            await HintWindow_ShowAndWait(message);

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

            userCard.SetOrientation(CardOrientation.FaceDown, taskList);
            userCard.AnimateScale(taskList, 1.0, MainPage.AnimationSpeeds.Medium);
            compCard.SetOrientation(CardOrientation.FaceDown, taskList);
            compCard.AnimateScale(taskList, 1.0, MainPage.AnimationSpeeds.Medium);

            userCard.ResetZIndex();
            compCard.ResetZIndex();


            GridDeck.UpdateCardLayout(taskList, MainPage.AnimationSpeeds.Medium, true);
            await Task.WhenAll(taskList);

            await _stateMachine.StartGame((compCard.Rank < userCard.Rank)?PlayerType.Computer : PlayerType.Player, Deck);

            MainPage.Current.EnableAppBarButtons(true);

            /// _btnNewGame.IsEnabled = true;
        }
Example #6
0
        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);
        }