static void ExecuterQuandInactif(object sender, EventArgs e) { FonctionsNatives.Message message; while (!FonctionsNatives.PeekMessage(out message, IntPtr.Zero, 0, 0, 0)) { TimeSpan currentTime = chrono.Elapsed; TimeSpan elapsedTime = currentTime - dernierTemps; dernierTemps = currentTime; tempsAccumule += elapsedTime; if (tempsAccumule >= tempsEcouleVoulu) { lock (unLock) { if (modeEditeur != null && peutAfficher) { modeEditeur.MettreAJour((double)tempsAccumule.Ticks / TimeSpan.TicksPerSecond); } else if (partieRapide != null && peutAfficher) { partieRapide.MettreAJour((double)tempsAccumule.Ticks / TimeSpan.TicksPerSecond); } } tempsAccumule = TimeSpan.Zero; } } }
//////////////////////////////////////////////////////////////////////// /// /// @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); }
static void Main(string[] args) { if (args.Length != 0) { if (args[0] == "testsC++") { if (FonctionsNatives.executerTests()) { System.Console.WriteLine("Échec d'un ou plusieurs tests."); } else { System.Console.WriteLine("Tests réussis."); } System.Console.WriteLine("\nAppuyez sur une touche pour quitter."); System.Console.ReadKey(); return; } } chrono.Start(); Application.Idle += ExecuterQuandInactif; Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); menuPrincipal = new MenuPrincipal(); Application.Run(menuPrincipal); }
//////////////////////////////////////////////////////////////////////// /// /// @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"); }
//////////////////////////////////////////////////////////////////////// /// /// @fn private void CreerBille() /// @brief Creation d'une nouvelle bille. /// @return Aucune. /// //////////////////////////////////////////////////////////////////////// private void CreerBille() { StringBuilder bille = new StringBuilder("bille"); FonctionsNatives.creerObjet(bille, bille.Capacity); nombreDeBillesUtilise++; }
//////////////////////////////////////////////////////////////////////// /// /// @fn private void EtablirTouchesEtAI(int playerType) /// @brief Etablit les touches de jeu et active ou non l'AI selon le mode choisi. /// @param[in] playerType : Type de joueur (Solo, 2P, AI). /// @return Aucune. /// //////////////////////////////////////////////////////////////////////// private void EtablirTouchesEtAI(int playerType) { if (playerType == 1) { touches = new Touches(FonctionsNatives.obtenirTouchePGJ1(), FonctionsNatives.obtenirTouchePGJ1(), FonctionsNatives.obtenirTouchePDJ1(), FonctionsNatives.obtenirTouchePDJ1(), FonctionsNatives.obtenirToucheRessort()); FonctionsNatives.activerAI(false); } else if (playerType == 2) { touches = new Touches(FonctionsNatives.obtenirTouchePGJ1(), FonctionsNatives.obtenirTouchePGJ2(), FonctionsNatives.obtenirTouchePDJ1(), FonctionsNatives.obtenirTouchePDJ2(), FonctionsNatives.obtenirToucheRessort()); FonctionsNatives.activerAI(false); } else if (playerType == 3) { // Le 1337 est la pour rendre l'acces aux touches de joueur 2 invalide touches = new Touches(FonctionsNatives.obtenirTouchePGJ1(), 1337, FonctionsNatives.obtenirTouchePDJ1(), 1337, FonctionsNatives.obtenirToucheRessort()); FonctionsNatives.activerAI(true); } }
//////////////////////////////////////////////////////////////////////// /// /// @fn public InitialiserConfigurations() /// @brief Initialisation des configurations par defaut de la partie. /// /// @return Aucune. /// //////////////////////////////////////////////////////////////////////// private void InitialiserConfigurations() { string tempConfig = FonctionsNatives.obtenirDerniereCampagne(); configurations = tempConfig.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); if (configurations[0] == "UN") { RB_Solo.Checked = true; } else if (configurations[0] == "DEUX") { RB_Multi.Checked = true; } else if (configurations[0] == "AI") { RB_AI.Checked = true; } for (int i = 1; i < configurations.Length; i++) { if (File.Exists(Application.StartupPath + @"\zones\" + configurations[i] + ".xml")) { pathMap = new StringBuilder(Application.StartupPath + @"\zones\" + configurations[i] + ".xml"); int diff = FonctionsNatives.obtenirDifficulte(pathMap, pathMap.Capacity); var item1 = new ListViewItem(new[] { configurations[i], diff.ToString() }); ZonesChoisis.Items.Add(item1); } else { pathMap = new StringBuilder(Application.StartupPath + @"\zones\default.xml"); int diff = FonctionsNatives.obtenirDifficulte(pathMap, pathMap.Capacity); var item1 = new ListViewItem(new[] { "default", diff.ToString() }); ZonesChoisis.Items.Add(item1); } } }
//////////////////////////////////////////////////////////////////////// /// /// @fn public override bool traiterKeyUp(KeyEventArgs e) /// @brief Traiter le changement d'etat suite a une action du clavier. /// /// @param[in] sender : Objet duquel provient un evenement. /// @param[in] e : evenement qui lance la fonction. /// /// @return True ou false selon la reussite des operations. /// //////////////////////////////////////////////////////////////////////// public override bool traiterKeyUp(object sender, KeyEventArgs e) { if (e.KeyValue == parent_.getTouches().PGJ1) { FonctionsNatives.desactiverPalettesGJ1(); } if (e.KeyValue == parent_.getTouches().PDJ1) { FonctionsNatives.desactiverPalettesDJ1(); } if (e.KeyValue == parent_.getTouches().PGJ2) { FonctionsNatives.desactiverPalettesGJ2(); } if (e.KeyValue == parent_.getTouches().PDJ2) { FonctionsNatives.desactiverPalettesDJ2(); } if (e.KeyValue == parent_.getTouches().Ressort) { FonctionsNatives.relacherRessort(); } return(true); }
//////////////////////////////////////////////////////////////////////// /// /// @fn public virtual bool traiterKeyDown(object sender, KeyEventArgs e) /// @brief Traiter le changement d'etat suite a une action du clavier. /// /// @param[in] sender : Objet duquel provient un evenement. /// @param[in] e : evenement qui lance la fonction. /// /// @return True ou false selon la reussite des operations. /// //////////////////////////////////////////////////////////////////////// public virtual bool traiterKeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Left) { FonctionsNatives.translater(-10, 0); } else if (e.KeyCode == Keys.Right) { FonctionsNatives.translater(10, 0); } else if (e.KeyCode == Keys.Up) { FonctionsNatives.translater(0, 10); } else if (e.KeyCode == Keys.Down) { FonctionsNatives.translater(0, -10); } if ((e.KeyData == Keys.Subtract || e.KeyCode == Keys.OemMinus)) { FonctionsNatives.zoomOut(); parent_.currentZoom = FonctionsNatives.obtenirZoomCourant(); } if ((e.KeyData == Keys.Add || e.KeyCode == Keys.Oemplus && e.Modifiers == Keys.Shift)) { FonctionsNatives.zoomIn(); parent_.currentZoom = FonctionsNatives.obtenirZoomCourant(); } return(false); }
//////////////////////////////////////////////////////////////////////// /// /// @fn public EtatJeuJouer(ModeJeu modeJeu) /// @brief Constructeur par parametre de l'etat. /// /// param[in] modeJeu : Mode de jeu associe a l'etat. /// /// @return Aucune (constructeur). /// //////////////////////////////////////////////////////////////////////// public EtatJeuJouer(ModeJeu modeJeu) : base(modeJeu) { parent_.setVisibilityMenuStrip(false); FonctionsNatives.modePause(false); parent_.setPeutAnimer(true); }
//////////////////////////////////////////////////////////////////////// /// /// @fn private void Quitter() /// @brief Quitte le mode Jeu. /// /// @return Aucune. /// //////////////////////////////////////////////////////////////////////// public void Quitter() { FonctionsNatives.arreterToutSons(); // resetConfig(); Program.myCustomConsole.Hide(); this.Close(); }
//////////////////////////////////////////////////////////////////////// /// /// @fn private void ModeJeu_Deactivate(object sender, EventArgs e) /// @brief Desactiver les palettes lorsqu'on sort de la form /// @param[in] sender : Objet duquel provient un evenement. /// @param[in] e : evenement qui lance la fonction. /// @return Aucune. /// //////////////////////////////////////////////////////////////////////// private void ModeJeu_Deactivate(object sender, EventArgs e) { FonctionsNatives.desactiverPalettesDJ1(); FonctionsNatives.desactiverPalettesDJ2(); FonctionsNatives.desactiverPalettesGJ1(); FonctionsNatives.desactiverPalettesGJ2(); }
public void MettreAJour(double tempsInterAffichage) { try { this.Invoke((MethodInvoker) delegate { int etatActuel = etatZoneActuelle(); //si la zone est réussi if (etatActuel == 1) { //Vérifie si il reste encore des zones a jouer dans la campagne if (configCampagne_.indiceZoneActuel_ < configCampagne_.quantiteZones_) { chargerProchaineZone(); } else { //Campagne termine //afficher un message de victoire: réussi ce niveau var result = MessageBox.Show("Voulez vous rejouer cette campagne? ", "Félicitation! Vous avez terminé la Campagne. ", MessageBoxButtons.YesNo); //si l'utilisateur décide de rejouer, on if (result == DialogResult.Yes) { libererZoneActuel(); chargerZone(configCampagne_.zones_[0]); } else { this.Close(); } } } //si la zone est échoué else if (etatActuel == -1) { //Campagne termine (echec) var result = MessageBox.Show("Voulez vous rejouer cette campagne? ", "Échec! Vous avez perdu. ", MessageBoxButtons.YesNo); //si l'utilisateur décide de rejouer, on if (result == DialogResult.Yes) { libererZoneActuel(); chargerZone(configCampagne_.zones_[0]); } else { this.Close(); } } //si la zone n'est pas terminé: continue FonctionsNatives.animer(tempsInterAffichage); FonctionsNatives.dessinerOpenGL(); }); } catch (Exception) { } }
//////////////////////////////////////////////////////////////////////// /// /// @fn static public void InitialiserAnimation() /// @brief Initialise openGL et l'animation. /// @return Aucune. /// //////////////////////////////////////////////////////////////////////// public void InitialiserAnimation() { this.DoubleBuffered = false; this.StartPosition = FormStartPosition.WindowsDefaultBounds; FonctionsNatives.initialiserOpenGL(panel_GL.Handle); FonctionsNatives.populateUsines(); FonctionsNatives.dessinerOpenGL(); }
private void partieSimpleClosed(object sender, FormClosedEventArgs e) { Program.menuPrincipal.Show(); FonctionsNatives.desactiverSon(); FonctionsNatives.affichageTexte(); panel2.SetBounds(panel2.Bounds.X, panel2.Bounds.Y, 1214, 753, BoundsSpecified.Location); this.Close(); }
//////////////////////////////////////////////////////////////////////// /// /// @fn public void RecommencerPartie() /// @brief Recommence la partie. /// @return Aucune. /// //////////////////////////////////////////////////////////////////////// public void RecommencerPartie() { resetConfig(); FonctionsNatives.purgeAll(); FonctionsNatives.ouvrirXML(map, map.Capacity); FonctionsNatives.resetNombreBillesCourantes(); FonctionsNatives.construireListesPalettes(); FonctionsNatives.mettreAJourListeBillesEtNoeuds(); }
private void menuPrincipalToolStripMenuItem_Click(object sender, EventArgs e) { this.DialogResult = DialogResult.No; Program.menuPrincipal.Show(); FonctionsNatives.desactiverSon(); FonctionsNatives.affichageTexte(); panel2.SetBounds(panel2.Bounds.X, panel2.Bounds.Y, 1214, 753, BoundsSpecified.Location); this.Close(); }
//////////////////////////////////////////////////////////////////////// /// /// @fn public EtatEditeurCreation(Editeur form) /// @brief Constructeur par parametre de l'etat. /// /// param[in] form : Form associee a l'etat. /// /// @return Aucune (constructeur). /// //////////////////////////////////////////////////////////////////////// public EtatEditeurCreation(Editeur form) : base(form) { form_.annulerModif(); FonctionsNatives.sauvegarderHistorique(); form_.deselection(); form_.outilCourant("Creation"); form_.trackCursor(true); form_.creationObjet(); }
private void PartieCampagne_FormClosed(object sender, System.Windows.Forms.FormClosedEventArgs e) { //TODO:: problems HERE too!!!!!! FonctionsNatives.releaseVisiteurs(); FonctionsNatives.libererOpenGL(); //FonctionsNatives.reinitialiser(); Program.menuPrincipal.Show(); this.Dispose(); }
//////////////////////////////////////////////////////////////////////// /// /// @fn private void setProprietes() /// @brief Affichage des proprietes dans les labels correspondants. /// @return Aucune. /// //////////////////////////////////////////////////////////////////////// private void setProprietes() { IntPtr config = FonctionsNatives.obtenirProprietes(map, map.Capacity); Marshal.Copy(config, proprietes, 0, 5); label_nbPointsButC.Text = proprietes[0].ToString(); label_nbPointsButT.Text = proprietes[1].ToString(); label_nbPointsCible.Text = proprietes[2].ToString(); label_nbWin.Text = proprietes[3].ToString(); label_nbPointsBille.Text = proprietes[4].ToString(); }
private void Close_Click(object sender, EventArgs e) { if (Always_Button.Checked) { MessageBox.Show("You are in 'Always show mode', please uncheck boxe to exit.", "CLOSING DENIED", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } this.Hide(); FonctionsNatives.bloquerAffichageGlobal(0); }
//////////////////////////////////////////////////////////////////////// /// /// @fn private void PartieRapide_FormClosing(object sender, EventArgs e) /// @brief Evenement lorsqu'on ferme la form PartieRapide. /// @param[in] sender : Objet duquel provient un evenement. /// @param[in] e : evenement qui lance la fonction. /// @return Aucune. /// //////////////////////////////////////////////////////////////////////// private void PartieRapide_FormClosing(object sender, FormClosingEventArgs e) { FonctionsNatives.arreterToutSons(); lock (Program.unLock) { FonctionsNatives.libererOpenGL(); Program.peutAfficher = false; Program.tempBool = false; } Program.myCustomConsole.Hide(); }
//////////////////////////////////////////////////////////////////////// /// /// @fn public Show() /// @brief Affiche la Console. /// /// @return Aucune /// //////////////////////////////////////////////////////////////////////// public void Show() { if (cConsole == null) { return; } if (FonctionsNatives.obtenirAffichageGlobal() == 1) { cConsole.Show(); } }
private void comboBoxZones_SelectionChangeCommitted(object sender, EventArgs e) { string path = ((ComboBoxItem)comboBoxZones.SelectedItem).Value; string nom = ((ComboBoxItem)comboBoxZones.SelectedItem).ToString(); int difficulte = FonctionsNatives.obtenirDifficulte(path.ToCharArray(0, path.Length)); //actualisation de la zone actuelle zoneRapide.actualiserZone(path, nom, difficulte); buttonDebuter.Enabled = true; }
//////////////////////////////////////////////////////////////////////// /// /// @fn public override bool traiterKeyPress(KeyEventArgs e) /// @brief Traiter le changement d'etat suite a une action du clavier. /// /// @param[in] sender : Objet duquel provient un evenement. /// @param[in] e : evenement qui lance la fonction. /// /// @return True ou false selon la reussite des operations. /// //////////////////////////////////////////////////////////////////////// public override bool traiterKeyPress(object sender, KeyPressEventArgs e) { if (Char.ToLower(e.KeyChar) == 'b') { toggleDebugOutput(); } else if (Char.ToLower(e.KeyChar) == 'j') { //Console.WriteLine("LUMIERE AMBIANTE"); parent_.toggleAmbiantLight(); FonctionsNatives.spotLight(0, parent_.getAmbiantLight()); } else if (Char.ToLower(e.KeyChar) == 'k') { //Console.WriteLine("LUMIERE DIRECTE"); parent_.toggleDirectLight(); FonctionsNatives.spotLight(1, parent_.getDirectLight()); } else if (Char.ToLower(e.KeyChar) == 'l') { //Console.WriteLine("LUMIERE SPOTS"); parent_.toggleSpotLight(); FonctionsNatives.spotLight(2, parent_.getSpotLight()); } else if (Char.ToLower(e.KeyChar) == 'h' && Program.playerName.ToUpper() == "ADMIN") { parent_.AfficherInformations(); } else if (e.KeyChar == (char)8) { // RELOAD DE LA MAP parent_.RecommencerPartie(); if (Program.mMenu.modeJeuMain != null) { Program.myCustomConsole.Show(); Program.mMenu.modeJeuMain.Focus(); } } else if (e.KeyChar == (char)27) { //Console.WriteLine("¨METTRE EN PAUSE"); parent_.pauseGame(); } else if (Char.ToLower(e.KeyChar) == 'f') { parent_.FullScreenChange(); } return(true); }
public PartieRapide(ZoneDeJeux zone, ConfigurationPartie config) { FonctionsNatives.reinitialiser(); this.MouseWheel += new MouseEventHandler(panel1_MouseWheel); InitializeComponent(); InitialiserAnimation(); configSimple_ = config; zone_ = zone; FonctionsNatives.affichageTexte(); InitialiserZone(); panel2.Size = new System.Drawing.Size(1214, 753); }
/// <summary> /// Fonction appeller lorsque la molette de la souris est activee /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void panel1_MouseWheel(object sender, MouseEventArgs e) { if (e.Delta < 0) { FonctionsNatives.zoomOut(); } else { FonctionsNatives.zoomIn(); } //panel1.Invalidate(); }
//////////////////////////////////////////////////////////////////////// /// /// @fn public override bool traiterRoulette(object sender, MouseEventArgs e) /// @brief Traiter le changement d'etat suite a une action de la roulette de souris. /// /// @param[in] sender : Objet duquel provient un evenement. /// @param[in] e : evenement qui lance la fonction. /// /// @return True ou false selon la reussite des operations. /// //////////////////////////////////////////////////////////////////////// public override bool traiterRoulette(object sender, MouseEventArgs e) { if (e.Delta > 0) { FonctionsNatives.zoomIn(); } else if (e.Delta < 0) { FonctionsNatives.zoomOut(); } parent_.setCurrentZoom(FonctionsNatives.obtenirZoomCourant()); return(false); }
public override bool traiterMouseMove(object sender, MouseEventArgs e) { if (e.Button == MouseButtons.Right) { double deltaX = (-(parent_.currentP.X - parent_.previousP.X)) * 100.0 / parent_.panelWidth; double deltaY = ((parent_.currentP.Y - parent_.previousP.Y)) * 100.0 / parent_.panelHeight; FonctionsNatives.translater(deltaX, deltaY); parent_.previousP = new Point(parent_.currentP.X, parent_.currentP.Y); parent_.currentP = new Point(e.X, e.Y); } return(true); }
//////////////////////////////////////////////////////////////////////// /// /// @fn public void AfficherInformations() /// @brief Afficher les informations de la partie. /// @return Aucune. /// //////////////////////////////////////////////////////////////////////// public void AfficherInformations() { bool estVisible = InfoPanel.Visible; InfoPanel.Visible = !InfoPanel.Visible; if (!estVisible) { FonctionsNatives.updateText(informations, informations.Capacity, new StringBuilder(""), 0); } else { FonctionsNatives.updateText(new StringBuilder(""), 0, informations, informations.Capacity); } }