Exemplo n.º 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;
            }
        }
Exemplo n.º 2
0
        public bool DepacementLargeur(Barre atest, List<int> precemplacement)
        {
            for (int i = 0; i < atest.emplacement.Count; i++)
            {
                // Je vérifie que les déplacement en largeur reste bien sur la même ligne
                if (atest.emplacement[i] / 10 != precemplacement[i] / 10)
                    return false;
            }

            return true;
        }
Exemplo n.º 3
0
 public abstract void Tourner(ref Barre barre, ref Table grille);
Exemplo n.º 4
0
        public bool EmplacementDispo(Barre test)
        {
            // Je tourne chaque emplacement de la barre a check
            List<int> precemplacement = new List<int>();

            foreach (int emplacement in test.emplacement)
            {
                // Si l'emplacement est en dehors des limites du tableau, je return false

                if (emplacement >= 180)
                    return false;
                if (emplacement < 0)
                    return false;

                // Sinon si l'emplacement du tableau est vide ou corresponds déja a la même barre, alors je continue le foreach
                else if (this.tableau[emplacement] == null || this.tableau[emplacement] == test)
                {
                    precemplacement.Add(emplacement);
                }

                // Sinon, je retourne faux
                else
                    return false;
            }

            precemplacement = precemplacement.OrderByDescending(k => k).ToList();

            foreach (int emplacement in test.emplacement)
            {
                if (precemplacement.Contains(emplacement + 1))
                {
                    if ((emplacement + 1) / 10 != emplacement / 10)
                        return false;
                }
            }
            return true;
        }
Exemplo n.º 5
0
        public void write(ref List<int> precbarre, Barre barre)
        {
            foreach (int emplacement in precbarre)
            {
                this.tableau[emplacement] = null;
            }

            foreach (int emplacement in barre.emplacement)
            {
                this.tableau[emplacement] = barre;
            }
        }
Exemplo n.º 6
0
 // Cette fonction me permet de descendre emplacement par emplacement une barre. Necessaire lorsque une barre est désagrégé.
 public int descendreCut(Barre desc, int emp)
 {
     while ((emp + 10) < 180 && (this.tableau[emp + 10] == null))
     {
         emp = emp + 10;
     }
     return emp;
 }
Exemplo n.º 7
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);
                }
            }
        }
Exemplo n.º 8
0
        private void messageTimer_Tick(object sender, EventArgs e)
        {
            if (level.numero == 4)
                grille.vibrate();
            main.banniere.Content = "";
            test.Descendre(grille);
            main.Timer.Content = DateTime.Now.Second;

            if (test.bloquer)
            {
                // Si test est bloqué, car il a touché un autre objet, alors on recréer une barre
                test = Barre.Create();
            }

            grille.fillGrid(tabRect);
        }
Exemplo n.º 9
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>();
        }
Exemplo n.º 10
0
 public override void Tourner(ref Barre barre, ref Table grille)
 {
 }