Пример #1
0
        ////////////////////////////////////////////////////////////////////////
        ///
        /// @fn protected void resetConfig()
        /// @brief Reset des points et aux configurations de partie.
        /// @return Aucune.
        ///
        ////////////////////////////////////////////////////////////////////////
        protected void resetConfig()
        {
            billesEnJeu = 0;
            FonctionsNatives.resetNombreBillesCourantes();
            nombreDeBillesGagnes  = 0;
            nombreDeBillesUtilise = 0;
            pointsPartie          = 0;
            pointsTotale          = 0;
            pointsGagnerPartie    = FonctionsNatives.obtenirPointsGagnerPartie();
            pointsGagnerBille     = FonctionsNatives.obtenirPointsGagnerBille();
            nombreBillesInit      = FonctionsNatives.obtenirNombreDeBilles();
            billesDisponibles     = nombreBillesInit;
            label_nbGagnes.Text   = nombreDeBillesGagnes.ToString();
            setProprietes();
            if (!firstStart)
            {
                Program.myCustomConsole.Update();
            }
            FonctionsNatives.bouclerSon(bgm, bgm.Length);
            FonctionsNatives.ajusterVolume(bgm, bgm.Length, 90);
            StringBuilder billeSound = new StringBuilder("rolling");

            FonctionsNatives.ajusterVolume(billeSound, billeSound.Length, 100);
            FonctionsNatives.jouerSon(bgm, bgm.Length);
        }
Пример #2
0
        ////////////////////////////////////////////////////////////////////////
        ///
        /// @fn public ZoneInfo(string nomZone, string difficulte, bool win)
        /// @brief Constructeur par parametre de la fenetre Partie Terminee.
        /// @param[in] nomZone : Nom de la zone affichee.
        /// @param[in] difficulte : difficulte de la zone de jeu
        /// @param[in] win : Indique si on a gagne la partie precedente.
        /// @return Aucune (constructeur).
        ///
        ////////////////////////////////////////////////////////////////////////
        public ZoneInfo(string nomZone, string difficulte, bool win)
        {
            InitializeComponent();
            this.Icon            = Properties.Resources.Pinball;
            this.WindowState     = FormWindowState.Normal;
            this.FormBorderStyle = FormBorderStyle.None;
            StringBuilder zoneProps = new StringBuilder(Application.StartupPath + @"\zones\" + nomZone + ".xml");
            IntPtr        config    = FonctionsNatives.obtenirProprietes(zoneProps, zoneProps.Capacity);

            Marshal.Copy(config, proprietes, 0, 5);
            if (win)
            {
                labelWin.Text = "Vous avez gagné!";
                FonctionsNatives.jouerSon(winSound, winSound.Length, false);
            }
            else
            {
                labelWin.Text = "Début de la partie";
            }
            time           = 5;
            timer1.Enabled = true;

            timer1.Interval       = 25;
            timer1.Tick          += new EventHandler(DecrementProgressBar);
            label_Zone.Text       = nomZone;
            label_Difficulte.Text = difficulte;
            label_Points.Text     = proprietes[3].ToString();
            label_Bille.Text      = proprietes[4].ToString();
            screenShot.SizeMode   = PictureBoxSizeMode.StretchImage;
            screenShot.Image      = Image.FromFile(Application.StartupPath + @"\zones\" + nomZone + ".jpg");
        }
Пример #3
0
 ////////////////////////////////////////////////////////////////////////
 ///
 /// @fn private void ProchainePartie()
 /// @brief Chargement de la prochaine partie.
 /// @return Aucune.
 ///
 ////////////////////////////////////////////////////////////////////////
 private void ProchainePartie()
 {
     FonctionsNatives.arreterToutSons();
     boolTemp   = false;
     peutAnimer = false;
     map        = new StringBuilder(myMaps[currentZone]);
     nextMap    = new StringBuilder(map.ToString());
     nextMap.Remove(nextMap.Length - 4, 4);
     System.Threading.Thread.Sleep(500);
     zInfo = new ZoneInfo(Path.GetFileName(nextMap.ToString()), FonctionsNatives.obtenirDifficulte(map, map.Capacity).ToString(), true);
     Program.myCustomConsole.Hide();
     this.Hide();
     zInfo.ShowDialog();
     this.Show();
     Program.myCustomConsole.Show();
     if (Program.mMenu.modeJeuMain != null)
     {
         FonctionsNatives.arreterToutSons();
         Program.myCustomConsole.Show();
         Program.mMenu.modeJeuMain.Focus();
     }
     FonctionsNatives.ouvrirXML(map, map.Capacity);
     FonctionsNatives.construireListesPalettes();
     FonctionsNatives.resetNombreDePointsDePartie();
     FonctionsNatives.resetNombreBillesCourantes();
     FonctionsNatives.mettreAJourListeBillesEtNoeuds();
     currentZone++;
     peutAnimer = true;
     boolTemp   = true;
     FonctionsNatives.bouclerSon(bgm, bgm.Length);
     FonctionsNatives.ajusterVolume(bgm, bgm.Length, 90);
     FonctionsNatives.jouerSon(bgm, bgm.Length);
     /// La création de l'état s'occupe d'appeler resetConfig
     etat = new EtatJeuDebutDePartie(this);
     // Il faut changer le mode car le traitement de début est fini
     etat           = new EtatJeuJouer(this);
     label_Nom.Text = "Nom: " + Path.GetFileNameWithoutExtension(map.ToString());
     if (nbZones == 1)
     {
         this.Text = "Partie Rapide: " + Path.GetFileNameWithoutExtension(map.ToString());
     }
     if (nbZones > 1)
     {
         this.Text = "Campagne: " + Path.GetFileNameWithoutExtension(map.ToString());
     }
 }
Пример #4
0
 ////////////////////////////////////////////////////////////////////////
 ///
 /// @fn private void ModeJeu_VisibleChanged(object sender, EventArgs e)
 /// @brief Fonction qui fait de quoi lorsqu'on met le mode Jeu visible.
 /// @param[in] sender : Objet duquel provient un evenement.
 /// @param[in] e : evenement qui lance la fonction.
 /// @return Aucune.
 ///
 ////////////////////////////////////////////////////////////////////////
 private void ModeJeu_VisibleChanged(object sender, EventArgs e)
 {
     if (this.Visible == true)
     {
         FonctionsNatives.jouerSon(Program.couvercle, Program.couvercle.Length);
         Program.myCustomConsole.reStart();
         Program.myCustomConsole.Update();
         Program.myCustomConsole.Show();
         if (Program.mMenu.modeJeuMain != null)
         {
             Program.mMenu.modeJeuMain.Focus();
         }
     }
     else
     {
         Program.myCustomConsole.Hide();
         // FonctionsNatives.arreterToutSons();
     }
 }
Пример #5
0
        ////////////////////////////////////////////////////////////////////////
        ///
        /// @fn private void FinCampagne(bool active, nbPoints)
        /// @brief Desactivation d'options en fin de campagne.
        /// @param[in] active : valeur d'activation.
        /// @param[in] nbPoints : nombre de points gagne.
        /// @return Aucune.
        ///
        ////////////////////////////////////////////////////////////////////////
        private void FinCampagne(bool active, int nbPoints)
        {
            if (active)
            {
                FonctionsNatives.jouerSon(winSound, winSound.Length);
            }

            FonctionsNatives.arreterToutSons();
            Program.myCustomConsole.Hide();
            peutAnimer = false;
            boolTemp   = false;
            gameOver   = new PartieTerminee(active, nbPoints);
            Program.myCustomConsole.Hide();
            gameOver.ShowDialog(this);
            if (Program.mMenu.modeJeuMain != null)
            {
                Program.myCustomConsole.Show();
                Program.mMenu.modeJeuMain.Focus();
            }
        }
Пример #6
0
        ////////////////////////////////////////////////////////////////////////
        ///
        /// @fn private void RecommencerTout()
        /// @brief Reinitialise la campagne ou la partie rapide lorsqu'on termine.
        ///
        /// @return Aucune.
        ///
        ////////////////////////////////////////////////////////////////////////
        public void RecommencerTout()
        {
            if (gameOver.Enabled)
            {
                gameOver.Hide();
            }

            pointsPartie = 0;
            currentZone  = 0;
            map          = new StringBuilder(myMaps[0]);
            nextMap      = new StringBuilder(map.ToString());
            nextMap.Remove(nextMap.Length - 4, 4);
            Program.myCustomConsole.Hide();
            this.Hide();
            zInfo = new ZoneInfo(Path.GetFileName(nextMap.ToString()), FonctionsNatives.obtenirDifficulte(map, map.Capacity).ToString(), false);
            zInfo.ShowDialog();
            this.Show();
            if (Program.mMenu.modeJeuMain != null)
            {
                Program.myCustomConsole.Show();
                Program.mMenu.modeJeuMain.Focus();
            }
            FonctionsNatives.ouvrirXML(map, map.Capacity);
            FonctionsNatives.resetNombreDePointsDePartie();
            FonctionsNatives.resetNombreBillesCourantes();
            FonctionsNatives.construireListesPalettes();
            currentZone = 1;
            peutAnimer  = true;
            boolTemp    = true;
            FonctionsNatives.jouerSon(bgm, bgm.Length);
            /// La création de l'état s'occupe d'appeler resetConfig
            etat = new EtatJeuDebutDePartie(this);
            // Il faut changer le mode car le traitement de début est fini
            etat = new EtatJeuJouer(this);

            // gameOver.Close();
            gameOver.Dispose();
            label_Nom.Text = "Nom: " + Path.GetFileNameWithoutExtension(map.ToString());
        }
Пример #7
0
        ////////////////////////////////////////////////////////////////////////
        ///
        /// @fn public void MettreAJour(double tempsInterAffichage)
        /// @brief Mise a jour du panneau OpenGL.
        /// @param[in] tempsInterAffichage : Objet duquel provient un evenement.
        /// @return Aucune.
        ///
        ////////////////////////////////////////////////////////////////////////
        public void MettreAJour(double tempsInterAffichage)
        {
            try
            {
                this.Invoke((MethodInvoker) delegate
                {
                    FonctionsNatives.refreshText(panel_GL.Size.Width, panel_GL.Size.Height);
                    if (peutAnimer)
                    {
                        FonctionsNatives.animer(tempsInterAffichage);
                        if (Program.compteurFrames == 0)
                        {
                            pointsPartie = FonctionsNatives.obtenirNombreDePointsDePartie();
                            // TODO Exemple a delete
                            StringBuilder precedentText = Points;
                            Points = new StringBuilder("Points : " + pointsPartie.ToString());
                            FonctionsNatives.updateText(precedentText, precedentText.Capacity, Points, Points.Capacity);
                            // FIN DE L'EXEMPLE
                        }
                    }
                    if (Program.compteurFrames == 0)
                    {
                        FonctionsNatives.dessinerOpenGL();
                    }
                    billesEnJeu       = FonctionsNatives.obtenirNombreBillesCourante();
                    billesPerdus      = FonctionsNatives.obtenirNombreBillesPerdus();
                    billesDisponibles = nombreBillesInit + nombreDeBillesGagnes - billesPerdus - billesEnJeu;
                    if (billesEnJeu < nombreBillesMax && (billesDisponibles > 0))
                    {
                        // Wait a certain time
                        CreerBille();
                    }
                    if (billesDisponibles == 0 && boolTemp && billesEnJeu == 0)
                    {
                        if (nbZones == 1)
                        {
                            FinCampagne(false, pointsPartie);
                        }
                        else
                        {
                            FinCampagne(false, -5);
                        }
                    }
                    if (pointsPartie >= nombreDeBillesGagnes * pointsGagnerBille + pointsGagnerBille)
                    {
                        FonctionsNatives.jouerSon(newBallSFX, newBallSFX.Length);
                        nombreDeBillesGagnes++;
                        label_nbGagnes.Text = nombreDeBillesGagnes.ToString();
                    }

                    label_nbPoints.Text = pointsPartie.ToString();
                    if (billesDisponibles >= 0)
                    {
                        label_nbBilles.Text         = billesDisponibles.ToString();
                        StringBuilder precedentText = Billes;
                        Billes = new StringBuilder("Billes : " + billesDisponibles.ToString());
                        FonctionsNatives.updateText(precedentText, precedentText.Capacity, Billes, Billes.Capacity);
                    }
                    if (pointsPartie >= pointsGagnerPartie && boolTemp && (nbZones > 1))
                    {
                        if (currentZone >= nbZones)
                        {
                            FinCampagne(true, -5);
                        }
                        else
                        {
                            ProchainePartie();
                        }
                    }
                    if (currentZoom <= 0)
                    {
                        FonctionsNatives.resetZoom();
                        currentZoom = FonctionsNatives.obtenirZoomCourant();
                    }
                });
            }
            catch (Exception)
            {
            }
        }