Пример #1
0
        public override void Tourner(ref Barre barre, ref Table grille)
        {
            // Sauvegarde des précédents emplacements
            List<int> emplacements = new List<int>();
            Barre b = new BarreL();
            int precposition = position;

            foreach (var emp in barre.emplacement)
            {
                emplacements.Add(emp);
            }
            b.emplacement = emplacements;

            if (position == 0)
            {
                if (this.emplacement[0] - 9 > 0)
                {
                    this.emplacement[0] -= 9;
                    this.emplacement[2] += 9;
                    this.emplacement[3] += 18;
                    position++;
                }
            }
            else
            {
                if (this.emplacement[2] - 9 > 0 && this.emplacement[3] - 18 > 0)
                {
                    this.emplacement[0] += 9;
                    this.emplacement[2] -= 9;
                    this.emplacement[3] -= 18;
                    position = 0;
                }
            }
            // Vérification que le déménagement est correct
            if (grille.EmplacementDispo(this))
            {
                grille.write(ref b.emplacement, this);

            }
            else
            {
                this.emplacement = b.emplacement;
                this.position = precposition;
            }
        }
Пример #2
0
 public void Accelerer(ref Table grille)
 {
     this.Descendre(grille);
 }
Пример #3
0
        // Pour faire descendre une barre
        //vérifier le débordement sur un coté
        public bool Descendre(Table grille)
        {
            bool placementvalide = grille.EmplacementDispo(this);
            List<int> precemplacement = new List<int>();

            for (int i = 0; i < this.emplacement.Count; i++)
            {
                // Je copie la liste des emplacement dans la barre dans une liste afin de les garder en mémoire en cas de Fail
                precemplacement.Add(this.emplacement[i]);
                // J'effectue le deplacement sur la vrai liste
                this.emplacement[i] = this.emplacement[i] + 10;
            }
            // je verifie si tout est okay. Si oui, j'écris les nouveaux emplacement dans le tableau
            if (grille.EmplacementDispo(this))
            {

                grille.write(ref precemplacement, this);
                this.posInitiale = false;
                return true;

            }
            else
            {
                // Sinon, je remets tout comme avant grace a la liste copié auparavant
                this.emplacement = precemplacement;
                this.bloquer = true;

                grille.checkLigne();
                if (this.posInitiale)
                {
                    MainWindow.main.Termine.Text = "Partie Terminée";
                    Partie.stop();
                    MainWindow.main.GameOver.Visibility = System.Windows.Visibility.Visible;
                    MainWindow.main.ScoreNom.Visibility = Visibility.Collapsed;
                    MainWindow.main.ScoreScore.Visibility = Visibility.Collapsed;
                    MainWindow.main.ScoreNiveau.Visibility = Visibility.Collapsed;
                    MainWindow.main.labelScore.Visibility = Visibility.Collapsed;
                    MainWindow.main.labelScoreLevel.Visibility = Visibility.Collapsed;
                    MainWindow.main.labelScoreNom.Visibility = Visibility.Collapsed;
                }
                return false;
            }
        }
Пример #4
0
 public abstract void Tourner(ref Barre barre, ref Table grille);
Пример #5
0
        public bool Gauche(ref Table grille)
        {
            // Je vérifie qu'on essaye pas de deplacer un objet non bloqué
            if (!this.bloquer)
            {
                bool placementvalide = grille.EmplacementDispo(this);

                List<int> precemplacement = new List<int>();

                for (int i = 0; i < this.emplacement.Count; i++)
                {
                    // Je copie la liste des emplacement dans la barre dans une liste afin de les garder en mémoire en cas de Fail
                    precemplacement.Add(this.emplacement[i]);
                    // J'effectue le deplacement sur la vrai liste
                    this.emplacement[i] = this.emplacement[i] - 1;
                }

                // je verifie si tout est okay. Si oui, j'écris les nouveaux emplacement dans le tableau
                if (grille.EmplacementDispo(this) && grille.DepacementLargeur(this, precemplacement))
                {

                    grille.write(ref precemplacement, this);

                    return true;

                }
                else
                {
                    // Sinon, je remets tout comme avant grace a la liste copié auparavant
                    this.emplacement = precemplacement;
                    return false;
                }

            }
            return false;
        }
Пример #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);
                }
            }
        }
Пример #7
0
        public void destroy()
        {
            messageTimer.Stop();

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

            da = new DoubleAnimation();
            da.From = 0;
            da.To = 0;
            da.Duration = new Duration(TimeSpan.FromSeconds(1));
            da.RepeatBehavior = RepeatBehavior.Forever;
            rt = new RotateTransform();
            main.gameGrid.RenderTransform = rt;
            rt.BeginAnimation(RotateTransform.AngleProperty, da);

            this.read = false;
            this.grille = null;
            this.main = null;
            this.tabRect = null;
            this.test = null;
            Score.listeScore = new List<Score>();
        }
Пример #8
0
 public override void Tourner(ref Barre barre, ref Table grille)
 {
 }