//////////////////////////////////////////////////////////////////////// /// /// @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); } } }
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 private void bouton_ADD_Click(object sender, EventArgs e) /// @brief Gestion d'evenement lorsqu'on clique sur le bouton Ajouter. /// @param[in] sender : Objet duquel provient un evenement. /// @param[in] e : evenement qui lance la fonction. /// @return Aucune. /// //////////////////////////////////////////////////////////////////////// private void bouton_ADD_Click(object sender, EventArgs e) { pathMap = new StringBuilder(Application.StartupPath + @"\zones\" + fileNames + ".xml"); int diff = FonctionsNatives.obtenirDifficulte(pathMap, pathMap.Capacity); var item1 = new ListViewItem(new[] { fileNames, diff.ToString() }); ZonesChoisis.Items.Add(item1); if (ZonesChoisis.Items.Count < 2) { bouton_OK.Enabled = false; } else { bouton_OK.Enabled = true; } }
//////////////////////////////////////////////////////////////////////// /// /// @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()); } }
//////////////////////////////////////////////////////////////////////// /// /// @fn public PartieRapide() /// @brief Constructeur de la fenetre de Partie Rapide.. /// /// @return Aucune (constructeur). /// //////////////////////////////////////////////////////////////////////// public PartieRapide() { InitializeComponent(); // mapList = new StringBuilder(); filePaths = Directory.GetFiles(Application.StartupPath + @"\zones", "*.xml"); zonesCampagne = new List <string>(); foreach (string s in filePaths) { pathMap = new StringBuilder(s); diff = FonctionsNatives.obtenirDifficulte(pathMap, pathMap.Capacity); // fileNames = Path.GetFileName(s); fileNames = Path.GetFileNameWithoutExtension(s); //fileNames = fileNames.Remove(fileNames.Length - 4); var item1 = new ListViewItem(new[] { fileNames, diff.ToString() }); ZonesDisponibles.Items.Add(item1); } }
//////////////////////////////////////////////////////////////////////// /// /// @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()); }
/// <summary> /// charge une zone dans le combo box /// </summary> /// <param name="path">ptah de la zone</param> private ComboBoxItem chargerZone(string path, string nomFichier) { string pathAbsolut = Application.StartupPath + @"\zones\" + path; //si la zone existe charger zone if (File.Exists(pathAbsolut)) { if (pathAbsolut != string.Empty) { pathAbsolut += "\0"; } int difficulte = FonctionsNatives.obtenirDifficulte(pathAbsolut.ToCharArray(0, pathAbsolut.Length)); ComboBoxItem zoneValide = new ComboBoxItem(); zoneValide.Text = nomFichier + "(" + difficulte + ")"; zoneValide.Value = path; zoneValide.Difficulte = difficulte; return(zoneValide); } //pour le chargement de la campagne entérieur //loader default.xml si la zone n'est pas dans le fichier else { pathAbsolut = Application.StartupPath + @"\zones\default.xml"; string nomFichierDefault = getNomXML(pathAbsolut); if (pathAbsolut != string.Empty) { pathAbsolut += "\0"; } int difficulte = FonctionsNatives.obtenirDifficulte(pathAbsolut.ToCharArray(0, pathAbsolut.Length)); ComboBoxItem zoneDefault = new ComboBoxItem(); zoneDefault.Text = nomFichierDefault + "(:" + difficulte + ")"; zoneDefault.Value = "default.xml"; zoneDefault.Difficulte = difficulte; return(zoneDefault); } }
//////////////////////////////////////////////////////////////////////// /// /// @fn public Campagne() /// @brief Constructeur de la fenetre de demarrage. /// /// @return Aucune (constructeur). /// //////////////////////////////////////////////////////////////////////// public Campagne() { InitializeComponent(); // this.FormBorderStyle = FormBorderStyle.None; sortColumnAscend(1); mapList = new StringBuilder(); zonesCampagne = new List <string>(); filePaths = Directory.GetFiles(Application.StartupPath + @"\zones", "*.xml"); foreach (string s in filePaths) { pathMap = new StringBuilder(s); diff = FonctionsNatives.obtenirDifficulte(pathMap, pathMap.Capacity); // fileNames = Path.GetFileName(s); fileNames = Path.GetFileNameWithoutExtension(s); //fileNames = fileNames.Remove(fileNames.Length - 4); var item1 = new ListViewItem(new[] { fileNames, diff.ToString() }); ZonesDisponibles.Items.Add(item1); } pathMap = new StringBuilder(""); InitialiserConfigurations(); }