예제 #1
0
        //start button handler
        private void Button_Click_1(object sender, RoutedEventArgs e)
        {
            if (0 == Start.Content.ToString().CompareTo("Reset"))
            {
                ResetGame();
                Start.Content = "Start";
                return;
            }



            if (CurrentGameState1 != GameStates.ReadyToStart && CurrentGameState2 != GameStates.ReadyToStart && CurrentGameState3 != GameStates.ReadyToStart)
            {
                String s = "Game is not ready to Start!, Please Follow The Message Below";
                System.Windows.MessageBox.Show(s);
                return;
            }



            da = new DoubleAnimation(0, 750, TimeSpan.FromSeconds(rnd.Next(10, 15) % 15));
            da.AccelerationRatio = rnd.NextDouble();
            da.Completed        += da_Completed;
            da.Name = "YellowWorm";
            YellowWorm.BeginAnimation(Canvas.LeftProperty, da);

            da = new DoubleAnimation(0, 750, TimeSpan.FromSeconds(rnd.Next(10, 15) % 15));
            da.AccelerationRatio = rnd.NextDouble();
            da.Completed        += da_Completed;
            da.Name = "RedWorm";
            RedWorm.BeginAnimation(Canvas.LeftProperty, da);

            da = new DoubleAnimation(0, 750, TimeSpan.FromSeconds(rnd.Next(10, 15) % 15));
            da.AccelerationRatio = rnd.NextDouble();
            da.Completed        += da_Completed;
            da.Name = "WoodWorm";
            WoodWorm.BeginAnimation(Canvas.LeftProperty, da);

            da = new DoubleAnimation(0, 750, TimeSpan.FromSeconds(rnd.Next(10, 15) % 15));
            da.AccelerationRatio = rnd.NextDouble();
            da.Completed        += da_Completed;
            da.Name = "GreenWorm";
            GreenWorm.BeginAnimation(Canvas.LeftProperty, da);
        }
예제 #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;
            }
        }