예제 #1
0
 public void StopParty()
 {
     game.destroy();
     foreach (var t in AllThreads)// a appeler au restart partie
     {
         t.Abort();
     }
     GameOver.Visibility = Visibility.Collapsed;
     game = null;
     gameGrid.Children.Clear();
     menu.Visibility = Visibility.Visible;
     ScoreNom.Visibility = Visibility.Collapsed;
     ScoreScore.Visibility = Visibility.Collapsed;
     ScoreNiveau.Visibility = Visibility.Collapsed;
     labelScore.Visibility = Visibility.Collapsed;
     labelScoreLevel.Visibility = Visibility.Collapsed;
     labelScoreNom.Visibility = Visibility.Collapsed;
     Termine.Foreground = new SolidColorBrush(Colors.Black);
     ScoreNiveau.Foreground = new SolidColorBrush(Colors.Black);
     ScoreNom.Foreground = new SolidColorBrush(Colors.Black);
     ScoreScore.Foreground = new SolidColorBrush(Colors.Black);
     nyan.Visibility = System.Windows.Visibility.Collapsed;
     image.Visibility = System.Windows.Visibility.Collapsed;
     fenetre.Background = new SolidColorBrush(Colors.LightBlue);
     main.tetris.Visibility = Visibility.Visible;
     ScoreNom.Text = " ";
     ScoreScore.Text = " ";
     ScoreNiveau.Text = " ";
     main.ScoreActuel.Foreground = new SolidColorBrush(Colors.Black);
     main.score.Foreground = new SolidColorBrush(Colors.Black);
 }
예제 #2
0
        private void play_Click(object sender, RoutedEventArgs e)
        {
            Level level = new Level();
            if (level1.IsChecked == true) {
                level = new Level()
                {
                    backgroundimage = "",
                    numero = 1,
                    backgroundcolor = Colors.LightBlue,
                    Couleurs = new List<Color>()
            { Colors.DarkSlateGray, Colors.DarkRed, Colors.Blue, Colors.Maroon, Colors.DeepSkyBlue,
            Colors.DarkMagenta, Colors.Goldenrod, Colors.MediumTurquoise,Colors.MediumSlateBlue,
            Colors.PowderBlue,Colors.SandyBrown,Colors.SaddleBrown,Colors.DeepSkyBlue},
                decrement = 0,
                    musique = "level1.mp3",
                    timer = 500,
                    fill = new List<Color> { Colors.White }
                };
            }
            if (level2.IsChecked == true)
            {
                level = new Level()
                {
                    numero = 2,
                    backgroundcolor = Colors.LightBlue,
                    Couleurs = new List<Color>{ Colors.DarkSlateGray, Colors.DarkRed, Colors.Blue, Colors.Maroon, Colors.DeepSkyBlue,
            Colors.DarkMagenta, Colors.Goldenrod, Colors.MediumTurquoise,Colors.MediumSlateBlue,
            Colors.PowderBlue,Colors.SandyBrown,Colors.SaddleBrown,Colors.DeepSkyBlue},
                    decrement = 0,
                    musique = "level2.mp3",
                    timer = 60,
                    fill = new List<Color> { Colors.White }
                };
            }

            if (level3.IsChecked == true)
            {
                level = new Level()
                {
                    backgroundimage = "",
                    numero = 3,
                    backgroundcolor = Colors.LightBlue,
                    Couleurs = new List<Color>{ Colors.DarkSlateGray, Colors.DarkRed, Colors.Blue, Colors.Maroon, Colors.DeepSkyBlue,
            Colors.DarkMagenta, Colors.Goldenrod, Colors.MediumTurquoise,Colors.MediumSlateBlue,
            Colors.PowderBlue,Colors.SandyBrown,Colors.SaddleBrown,Colors.DeepSkyBlue},
                    decrement = 1,
                    musique = "level3.mp3",
                    timer = 100,
                    fill = new List<Color> { Colors.White }
                };
            }

            if (level4.IsChecked == true)
            {
                level = new Level()
                {
                    backgroundimage = "",
                    numero = 4,
                    backgroundcolor = Colors.Black,
                    Couleurs = new List<Color>{ Colors.Red, Colors.Yellow, Colors.Orange, Colors.Purple, Colors.Green, Colors.Blue},
                    decrement = 0,
                    musique = "aCat.mp3",
                    timer = 100,
                    fill = new List<Color> { Colors.White }
                };
            }

            if (level5.IsChecked == true)
            {
                level = new Level()
                {
                    backgroundimage = "",
                    numero = 5,
                    backgroundcolor = Colors.Black,
                    Couleurs = new List<Color> {Colors.White},
                    decrement = 1,
                    musique = "Inversed.mp3",

                    timer = 200,
                    fill = new List<Color> { Colors.Red, Colors.Yellow, Colors.Orange, Colors.Cyan, Colors.Purple, Colors.Green, Colors.Blue },
                };
            }

            menu.Visibility = Visibility.Collapsed;
            ScoreNom.Visibility = Visibility.Visible;
            ScoreScore.Visibility = Visibility.Visible;
            ScoreNiveau.Visibility = Visibility.Visible;
            labelScore.Visibility = Visibility.Visible;
            labelScoreLevel.Visibility = Visibility.Visible;
            labelScoreNom.Visibility = Visibility.Visible;
            game = new Partie(main, level);
        }
예제 #3
0
        public Partie(MainWindow main, Level level)
        {
            ScoresPartie = new Score();
            ScoresPartie.Read(level.numero);
            this.enregistré = false;
            this.main = main;
            this.level = level;

            main.tetris.Visibility = Visibility.Collapsed;
            Barre.Couleurs = level.Couleurs;
            main.fenetre.Background = new SolidColorBrush(level.backgroundcolor);

            if (level.backgroundcolor == Colors.Black)
            {
                main.Termine.Foreground = new SolidColorBrush(Colors.White);
                main.ScoreNiveau.Foreground = new SolidColorBrush(Colors.White);
                main.ScoreNom.Foreground = new SolidColorBrush(Colors.White);
                main.ScoreScore.Foreground = new SolidColorBrush(Colors.White);
                main.labelScore.Foreground = new SolidColorBrush(Colors.White);
                main.labelScoreLevel.Foreground = new SolidColorBrush(Colors.White);
                main.labelScoreNom.Foreground = new SolidColorBrush(Colors.White);
                main.ScoreActuel.Foreground = new SolidColorBrush(Colors.White);
                main.score.Foreground = new SolidColorBrush(Colors.White);
            }
            else
            {
                main.Termine.Foreground = new SolidColorBrush(Colors.Black);
                main.ScoreNiveau.Foreground = new SolidColorBrush(Colors.Black);
                main.ScoreNom.Foreground = new SolidColorBrush(Colors.Black);
                main.ScoreScore.Foreground = new SolidColorBrush(Colors.Black);
                main.labelScore.Foreground = new SolidColorBrush(Colors.Black);
                main.labelScoreLevel.Foreground = new SolidColorBrush(Colors.Black);
                main.labelScoreNom.Foreground = new SolidColorBrush(Colors.Black);
                main.ScoreActuel.Foreground = new SolidColorBrush(Colors.Black);
                main.score.Foreground = new SolidColorBrush(Colors.Black);
            }

            if (level.numero == 4) {
                main.nyan.Visibility = System.Windows.Visibility.Visible;
                main.image.Visibility = System.Windows.Visibility.Visible;
            }

            test = Barre.Create(); // Test est la barre qui sera en cours de placement
            tabRect = new List<Rectangle>(180);
            main.banniere.Content = "GooOOoooo";
            this.grille = new Table(main, tabRect, level);
            messageTimer = new DispatcherTimer();
            messageTimer.Tick += new EventHandler(messageTimer_Tick);
            messageTimer.Interval = new TimeSpan(0, 0, 0, 0, level.timer);
            messageTimer.Start();

            Thread myThread = new Thread(() => playSong());
            MainWindow.AllThreads.Add(myThread);
            myThread.Start();
            partie = this;

            if(level.numero == 3)
            {
                da= new DoubleAnimation();
                da.From = 0;
                da.To = 360;
                da.Duration = new Duration(TimeSpan.FromSeconds(3));
                da.RepeatBehavior = RepeatBehavior.Forever;
                rt = new RotateTransform(360, main.gameGrid.Width / 2, main.gameGrid.Height / 2);
                main.gameGrid.RenderTransform = rt;
                rt.BeginAnimation(RotateTransform.AngleProperty, da);

            }
            if(level.numero == 5)
            {
                main.gameGrid.RenderTransform = new RotateTransform(180,main.gameGrid.Width /2, main.gameGrid.Height / 2);

                for (int i = 0; i < tabRect.Count; i++)
                {
                        tabRect[i].Fill = new SolidColorBrush(Colors.Black);
                }
            }
        }