Beispiel #1
0
        public Table(MainWindow main, List<Rectangle> tabRect, Level lvl)
        {
            this.lvl = lvl;
            var left = 1;
            var top = 1;

            this.windows = main;

            for (int i = 1; i < 181; i++)
            {
                var rect = new Rectangle();
                rect.Height = 20;
                rect.Width = 20;
                rect.Stroke = new SolidColorBrush(Colors.LightGray);
                rect.Tag = i - 1;
                Canvas.SetLeft(rect, left * 20);
                Canvas.SetTop(rect, top * 20);
                main.gameGrid.Children.Add(rect);
                tabRect.Add(rect);

                if (i % 10 == 0 && i != 0)
                {
                    top++;
                    left = 1;
                }
                else
                {
                    left++;
                }
            }
        }
Beispiel #2
0
 public TetrisWell(Level level)
 {
     this.level = level;
     well = level.Content.Load<Texture2D>("well");
     unit = level.Content.Load<Texture2D>("unit");
     wellOrigin = new Vector2(wellBoundary, 0);
     ResetWell();
 }
Beispiel #3
0
        public Block(Level level, Vector2 wellPosition)
        {
            this.wellPosition = wellPosition;
            this.level = level;
            unit = level.Content.Load<Texture2D>("unit");
            nextBoard = level.Content.Load<Texture2D>("nextBoard");
            soundBlockRotate = level.Content.Load<SoundEffect>("Audio/blockRotate");
            soundBlockMoveLeft = level.Content.Load<SoundEffect>("Audio/blockMoveLeft");
            soundBlockMoveRight = level.Content.Load<SoundEffect>("Audio/blockMoveRight");
            soundLineKill = level.Content.Load<SoundEffect>("Audio/lineKill");
            soundGameOver = level.Content.Load<SoundEffect>("Audio/gameOver");

            shapeColor = new Color[7];
            StartPosition = wellPosition + new Vector2(3 * unit.Width, 0);
            DefineShape();
            GetNewShape();
        }
Beispiel #4
0
 public void LoadGame()
 {
     MediaPlayer.Play(song);
     level = new Level(Services);
 }
        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);
        }
Beispiel #6
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);
                }
            }
        }