Esempio n. 1
0
        private void worm1_MouseEnter_1(object sender, MouseEventArgs e)
        {
            Worm          w   = (Worm)sender;
            StringBuilder txt = new StringBuilder("This is ");

            txt.Append(w.Name);
            if (w.IsEnabled == false)
            {
                if (w.Name == selectedWorm1.Name)
                {
                    txt.Append(" already selected for Joe");
                    textBox1.Text = txt.ToString();
                    return;
                }
                else if (w.Name == selectedWorm2.Name)
                {
                    txt.Append(" already selected for Bob");
                    textBox1.Text = txt.ToString();
                    return;
                }
                else if (w.Name == selectedWorm3.Name)
                {
                    txt.Append(" already selected for Al");
                    textBox1.Text = txt.ToString();
                    return;
                }
                else
                {
                    txt.Append(", You will get your Bet x ");
                    txt.Append(betfactorsMap[w.Name].ToString());
                    textBox1.Text = txt.ToString();
                    return;
                }
            }

            w.border.BorderThickness = new Thickness(2, 2, 2, 2);
            w.border.BorderBrush     = Brushes.LightCoral;

            txt.Append(", You will get your Bet x ");
            txt.Append(betfactorsMap[w.Name].ToString());
            textBox1.Text = txt.ToString();
        }
Esempio n. 2
0
        private void ResetGame()
        {
            sb.Children.Remove(da);
            DoubleAnimation da1 = new DoubleAnimation(750, 0, TimeSpan.FromSeconds(1));

            YellowWorm.BeginAnimation(Canvas.LeftProperty, da1);
            RedWorm.BeginAnimation(Canvas.LeftProperty, da1);
            WoodWorm.BeginAnimation(Canvas.LeftProperty, da1);
            GreenWorm.BeginAnimation(Canvas.LeftProperty, da1);


            WormCompletedCount   = 0;
            CurrentGameState1    = GameStates.SelectWorm;
            CurrentGameState2    = GameStates.SelectWorm;
            CurrentGameState3    = GameStates.SelectWorm;
            YellowWorm.IsEnabled = RedWorm.IsEnabled = WoodWorm.IsEnabled = GreenWorm.IsEnabled = true;
            WinnerTimes          = new StringBuilder();
            winnerWorm           = null;
            textBox1.Text        = "Start again with new bets. \n and Proceed further.";
            WinnerTimes.Clear();

            betfactorsMap = new Dictionary <string, int>();
            betfactorsMap.Add(YellowWorm.Name, rnd.Next(3, 6));
            betfactorsMap.Add(RedWorm.Name, rnd.Next(3, 6));
            betfactorsMap.Add(WoodWorm.Name, rnd.Next(3, 6));
            betfactorsMap.Add(GreenWorm.Name, rnd.Next(3, 6));

            if (bettor1 < betAmount1)
            {
                betAmount1 = bettor1;
            }
            if (bettor2 < betAmount2)
            {
                betAmount2 = bettor2;
            }
            if (bettor3 < betAmount3)
            {
                betAmount3 = bettor3;
            }
        }
Esempio n. 3
0
        //bet
        //private void Button_Click_2(object sender, RoutedEventArgs e)
        //{
        //    if (CurrentGameState != GameStates.SelectBet)
        //    {
        //        System.Windows.MessageBox.Show("You cannot place bet. please follow message below");
        //        return;
        //    }

        //    Button b = (Button)sender;

        //    switch (b.Name)
        //    {
        //        case "bet1":
        //            betAmount = 25;
        //            break;
        //        case "bet2":
        //            betAmount = 50;
        //            break;
        //        case "bet3":
        //            betAmount = 75;
        //            break;
        //        case "bet4":
        //            betAmount = 100;
        //            break;
        //    }

        //    CurrentGameState = GameStates.ReadyToStart;
        //    DisplayStateMessage();
        //}

        private void worm1_MouseLeftButtonDown_1(object sender, MouseButtonEventArgs e)
        {
            if (bets1.IsChecked == true)
            {
                if (CurrentGameState1 != GameStates.SelectWorm)
                {
                    System.Windows.MessageBox.Show("You cannot select worm now. please follow message below");
                    return;
                }
            }
            else if (bets2.IsChecked == true)
            {
                if (CurrentGameState2 != GameStates.SelectWorm)
                {
                    System.Windows.MessageBox.Show("You cannot select worm now. please follow message below");
                    return;
                }
            }
            else if (bets3.IsChecked == true)
            {
                if (CurrentGameState3 != GameStates.SelectWorm)
                {
                    System.Windows.MessageBox.Show("You cannot select worm now. please follow message below");
                    return;
                }
            }
            else
            {
                System.Windows.MessageBox.Show("Please select your player first to initiate game.");
                return;
            }

            Worm w = (Worm)sender;

            switch (bettor)
            {
            case selectedbettor.joe:
                forname           = "Joe";
                CurrentGameState1 = GameStates.SelectBet;
                selectedWorm1     = w;
                w.IsEnabled       = false;
                break;

            case selectedbettor.bob:
                forname           = "Bob";
                CurrentGameState2 = GameStates.SelectBet;
                selectedWorm2     = w;
                w.IsEnabled       = false;
                break;

            case selectedbettor.al:
                forname           = "Al";
                CurrentGameState3 = GameStates.SelectBet;
                selectedWorm3     = w;
                w.IsEnabled       = false;
                break;
            }

            StringBuilder txt = new StringBuilder("You Placed Bet on Worm");

            txt.Append(w.Name);
            txt.Append(" for " + forname);
            textBox1.Text = txt.ToString();
            DisplayStateMessage();
        }