/** * Permet d'activer une troisième combobox. Les personnages sont alors capable de travailler la nuit. * Attention, leur stress et leur fatigue augmente considérablement. * Valable qu'une seule fois dans la partie. */ private void btnCrunch_Click_1(object sender, EventArgs e) { frmCrunch frm = new frmCrunch(); frm.ShowDialog(); if (frm.DialogResult == DialogResult.OK) { btnCrunch.Enabled = false; foreach (Object o in Controls) { if (o is Panel) { Panel p = (Panel)o; foreach (Object c in p.Controls) { if (c is UC_Personnage) { UC_Personnage up = (UC_Personnage)c; if (up.getPersonnage().getMalade() == false) { up.crunchActive(); crunchBool = true; } } } } } } }
/** * Tour suivant : Calcul des attributs des personnages et mise à jour des User_Controls. * Vérification si le crunch est activé ou non, random qui détermine si un personnage * tombe malade. */ private void btnTourSuivant_Click(object sender, EventArgs e) { uC_Personnage1.arreterClignotant(); uC_Personnage2.arreterClignotant(); uC_Personnage3.arreterClignotant(); uC_Personnage4.arreterClignotant(); lblTour.Visible = true; btnReunion.Enabled = true; btnRepos.Enabled = true; if (crunchBool == true) { foreach (Object o in Controls) { if (o is Panel) { Panel p = (Panel)o; foreach (Object c in p.Controls) { if (c is UC_Personnage) { UC_Personnage up = (UC_Personnage)c; up.Enabled = true; up.crunchDesactive(); crunchBool = false; } } } } } // FIN SI DEADLINE OU TOUTES LES FONCTIONS SONT FINIES // A REVOIR ( VERIFIER SI LE POURCENTAGE DU PROJET == 100 --> FIN ) if ((nbTour >= nbTourMax) || ((ControleurJeu.verifierTacheTermine()))) { if (ControleurJeu.verifierTacheTermine()) { ControleurJeu.arreterJeu(rtbListeF.Text, 0); this.Close(); } ControleurJeu.arreterJeu(rtbListeF.Text); this.Close(); } // Pre remplissage de toutes les taches pour le tour actuel pour chaque perso foreach (Object o in Controls) { if (o is Panel) { Panel p = (Panel)o; foreach (Object c in p.Controls) { if (c is UC_Personnage) { UC_Personnage up = (UC_Personnage)c; up.remplirListeAffinite(); } } } } //modification des taches des user controls foreach (Object o in Controls) { if (o is Panel) { Panel p = (Panel)o; foreach (Object c in p.Controls) { if (c is UC_Personnage) { UC_Personnage up = (UC_Personnage)c; up.donnerTachePerso(); } } } } foreach (Object o in Controls) { if (o is Panel) { Panel p = (Panel)o; foreach (Object c in p.Controls) { if (c is UC_Personnage) { UC_Personnage up = (UC_Personnage)c; up.viderListeAffinite(); } } } } try { // REMPLISSAGE DEUXIEME "CONSOLE" rtbListeF.Text += "\nJournée " + nbTour.ToString() + ":\n"; rtbListeF.Text += s; s = ""; // MISE A ZERO DES COMBOBOX POUR NE PLUS AVOIR LES ANCIENS CHOIX foreach (Object o in Controls) { if (o is Panel) { Panel p = (Panel)o; foreach (Object c in p.Controls) { if (c is UC_Personnage) { UC_Personnage up = (UC_Personnage)c; up.cleanCBO(); } } } } ControleurJeu.nouveauTour(); this.augmenterNbTour(); //incremente nb de tour lblTour.Text = "Tour : " + nbTour.ToString() + " / " + nbTourMax.ToString(); ArrayList listPerso = ControleurJeu.getListePersonnage(); Personnage p1 = (Personnage)listPerso[0]; Personnage p2 = (Personnage)listPerso[1]; Personnage p3 = (Personnage)listPerso[2]; Personnage p4 = (Personnage)listPerso[3]; //mise a jour des persos apres avoir effectue les taches initUC(uC_Personnage1, p1); initUC(uC_Personnage2, p2); initUC(uC_Personnage3, p3); initUC(uC_Personnage4, p4); List <UC_Personnage> listUC = new List <UC_Personnage>(); listUC.Add(uC_Personnage1); listUC.Add(uC_Personnage2); listUC.Add(uC_Personnage3); listUC.Add(uC_Personnage4); uC_Personnage1.cleanCBO(); uC_Personnage2.cleanCBO(); uC_Personnage3.cleanCBO(); uC_Personnage4.cleanCBO(); Random rnd = new Random(); int alea = rnd.Next(20); if (alea <= 3) { UC_Personnage u = listUC[alea]; u.getPersonnage().setMalade(true); u.getPersonnage().setDisponible(false); } // FIN SI DEADLINE OU TOUTES LES FONCTIONS SONT FINIES // A REVOIR ( VERIFIER SI LE POURCENTAGE DU PROJET == 100 --> FIN ) } catch (NullReferenceException) { MessageBox.Show("Selectionnez Action"); } //Mettre à jour la liste des tâches à effectuer, c'est-à-dire que l'on vérifie si la tâche est complété ou non. Si c'est le cas alors on l'enlève de la liste lstTache.Items.Clear(); foreach (Fonctionnalites f in ControleurJeu.getListeFonctionnalite()) { if (f.getPaDepense() < f.getPaNecess() && f.getStatus() == false) { lstTache.Items.Add(f.getNom() + " (" + f.getNvConnaissNecces() + ")"); } } //Actualiser les progressBars pour chaque tache ArrayList listFonctionnalite = ControleurJeu.getListeFonctionnalite(); for (int i = 0; i <= listFonctionnalite.Count - 1; i++) { foreach (Object o in Controls) { if (o is Panel) { Panel p = (Panel)o; foreach (Object ob in p.Controls) { if (ob is Bunifu.Framework.UI.BunifuProgressBar) { Bunifu.Framework.UI.BunifuProgressBar pb = (Bunifu.Framework.UI.BunifuProgressBar)ob; if ((int)pb.Tag == i) { Fonctionnalites f = (Fonctionnalites)listFonctionnalite[i]; foreach (Fonctionnalites ft in ControleurJeu.getListeFonctionnalite()) { if (f.getNom() == ft.getNom()) { float val1 = (float)ft.getPaDepense(); float val2 = (float)ft.getPaNecess(); float res = (val1 / val2) * 100; if (res >= 100) { res = 100; } pb.Value = (int)res; } } } } } } } } }