Esempio n. 1
0
        private void UpdateCards()
        {
            LayoutRoot.Children.Clear();
            //foreach (var child in LayoutRoot.Children)
            //{
            //    if (child is SlotControl)
            //    {
            //        LayoutRoot.Children.Remove(child);
            //    }

            //}


            if (Hand.Cards != null)
            {
                for (int i = 0; i < Hand.Cards.Count; i++)
                {
                    //Card theCard = Cards[i];

                    //if (theCard != null)
                    //if (theCard.Value > 5)
                    //{
                    //    threeC threeClubs = new threeC();
                    //    threeClubs.SetValue(Canvas.LeftProperty, 5d);
                    //    threeClubs.SetValue(Canvas.TopProperty, i * 25d);

                    //    LayoutRoot.Children.Add(threeClubs);
                    //}

                    CardControl     cardControl = new CardControl();
                    double          angle       = GetRandomNumber(-3d, 3d);
                    RotateTransform transform   = new RotateTransform()
                    {
                        Angle = angle
                    };
                    //   cardControl.RenderTransform = transform;
                    // cardControl.InitializeCard(c, null);
                    cardControl.Card = Hand.Cards[i];
                    //     cardControl.InitializeCard();
                    cardControl.SetValue(Canvas.LeftProperty, -10d);

                    if (i == 0)
                    {
                        cardControl.SetValue(Canvas.TopProperty, 1 * 15d);
                    }
                    else
                    {
                        cardControl.SetValue(Canvas.TopProperty, (10d + (i * 25d)));
                    }



                    LayoutRoot.Children.Add(cardControl);
                }
            }
            scorePopper1.HandScore = Hand.Total;
        }
Esempio n. 2
0
        private void AddCard()
        {
            var gestureListener = toolkit.GestureService.GetGestureListener(this);

            gestureListener.Tap -= new EventHandler <toolkit.GestureEventArgs>(GestureListener_Tap);

            CardControl cardControl = new CardControl();

            cardControl.Card = Hand.Cards.Last();


            double          angle     = GetRandomNumber(-3d, 3d);
            RotateTransform transform = new RotateTransform()
            {
                Angle = angle
            };

            cardControl.RenderTransform = transform;

            //     cardControl.InitializeCard();
            cardControl.SetValue(Canvas.LeftProperty, 0d);


            cardControl.SetValue(Canvas.TopProperty, (10d + (lastCardPosition)));
            lastCardPosition = lastCardPosition + 25d;
            LayoutRoot.Children.Add(cardControl);

            Random rand = new Random();

            if (rand.Next(0, 2) == 0)
            {
                using (var stream = TitleContainer.OpenStream("sounds/deal.wav"))
                {
                    var effect = SoundEffect.FromStream(stream);
                    FrameworkDispatcher.Update();
                    effect.Play();
                }
            }

            else
            {
                using (var stream = TitleContainer.OpenStream("sounds/deal1.wav"))
                {
                    var effect = SoundEffect.FromStream(stream);
                    FrameworkDispatcher.Update();
                    effect.Play();
                }
            }



            scorePopper1.HandScore = Hand.Total;


            gestureListener.Tap += new EventHandler <toolkit.GestureEventArgs>(GestureListener_Tap);

            if (scorePopper1.HandScore == 21)
            {
                foreach (var s in LayoutRoot.Children.OfType <CardControl>())
                {
                    using (var stream = TitleContainer.OpenStream("sounds/bleep.wav"))
                    {
                        var effect = SoundEffect.FromStream(stream);
                        FrameworkDispatcher.Update();
                        effect.Play();
                    }

                    s.FlipCard();
                    //turn off ability to add cards

                    gestureListener.Tap -= new EventHandler <toolkit.GestureEventArgs>(GestureListener_Tap);
                }
            }

            if (scorePopper1.HandScore > 21)
            {
                theBorder.Opacity      = .5;
                bustControl.Visibility = Visibility.Visible;
                bustControl.Throb.Begin();
                //turn off ability to add cards

                gestureListener.Tap -= new EventHandler <toolkit.GestureEventArgs>(GestureListener_Tap);

                using (var stream = TitleContainer.OpenStream("sounds/break.wav"))
                {
                    var effect = SoundEffect.FromStream(stream);
                    FrameworkDispatcher.Update();
                    effect.Play();
                }
            }
        }