/** * Affichage des fonctionnalités */ public void copiFonc() { cboFonctionnalite1.Items.Clear(); cboFonctionnalite2.Items.Clear(); for (int i = 0; i < listfonctionnalite.Count; i++) { Fonctionnalites f = (Fonctionnalites)listfonctionnalite[i]; cboFonctionnalite1.Items.Add(f.getNom() + " (" + f.getNvConnaissNecces() + ")"); cboFonctionnalite2.Items.Add(f.getNom() + " (" + f.getNvConnaissNecces() + ")"); cboFonctionnalite3.Items.Add(f.getNom() + " (" + f.getNvConnaissNecces() + ")"); } }
/** * Fait faire les tâches aux personnages */ public static void tache(Personnage p, List <Fonctionnalites> listeTache) { string afficher = ""; for (int i = 0; i < listfonctionnalite.Count; i++) { Fonctionnalites ajout = (Fonctionnalites)listfonctionnalite[i]; afficher += "\n" + ajout.getNom(); } if (afficher != "") { //MessageBox.Show(afficher); } String texte = ""; // Parcours de toutes les fonctionalités pour que le perso p les fasse /***************** A FAIRE ****************/ foreach (Fonctionnalites f in listeTache) { // MessageBox.Show("NORMAL"); p.faireAction(f); } string fonc = ""; foreach (Fonctionnalites f in listeTache) { // Si la fonction est finie on l'enleve de la liste et on affiche qui l'a fini if (f.getStatus() == true) { frmJeu.setAvancement(f.getPourcentNote() + (float)frmJeu.getAvancement()); texte += f.getNom() + " " + f.getPaDepense() + "/" + f.getPaNecess() + " Terminé par " + p.getPrenom() + "\n"; //listfonctionnalite.Remove(f); listtransmise.Remove(f); fonc = f.getNom(); } else { texte += f.getNom() + " " + f.getPaDepense() + "/" + f.getPaNecess() + " " + p.getPrenom() + "\n"; } } // SUPPRESION DANS LA LISTE DES FONCTIONNALITES LES FONCTION FINIES if (fonc != "") { for (int i = 0; i < listeTache.Count; i++) { if (listeTache[i].getNom() == fonc) { listeTache.RemoveAt(i); } } } // ENVOIE DU TEXTE A AFFICHER DANS LE FRMJEU frmJeu.remplir(texte); }
/** * Assignation des personnages aux User_Controls, affichage de tous les labels et des progress bar * qui sont générés dynamiquement. */ public frmJeu(Personnage p1, Personnage p2, Personnage p3, Personnage p4, int tourmax) { InitializeComponent(); nbTourMax = tourmax; int screenWidth = Screen.PrimaryScreen.Bounds.Width; int screenHeight = Screen.PrimaryScreen.Bounds.Height; this.Size = new Size(screenWidth, screenHeight); lblTacheReal.Size = new Size(((screenWidth - lblTacheReal.Location.X) - lblTacheReal.Size.Width) + lblTacheReal.Size.Width, lblTacheReal.Size.Height - 5); pnlProgressBarTache.Size = new Size(((screenWidth - pnlProgressBarTache.Location.X) - pnlProgressBarTache.Size.Width) + pnlProgressBarTache.Size.Width, pnlProgressBarTache.Size.Height - 5); panel2.Size = new Size(screenWidth, panel2.Height); foreach (Fonctionnalites f in ControleurJeu.getListeFonctionnalite()) { if (f.getPaDepense() < f.getPaNecess() && f.getStatus() == false) { lstTache.Items.Add(f.getNom() + " (" + f.getNvConnaissNecces() + ")"); } } lstTache.AllowDrop = true; uC_Personnage1.AllowDrop = true; uC_Personnage2.AllowDrop = true; uC_Personnage3.AllowDrop = true; uC_Personnage4.AllowDrop = true; this.Refresh(); listPersonnage.Clear(); crunchBool = false; ArrayList listPerso = ControleurJeu.getListePersonnage(); listPersonnage.Add(p1); listPersonnage.Add(p2); listPersonnage.Add(p3); listPersonnage.Add(p4); initUC(uC_Personnage1, p1); initUC(uC_Personnage2, p2); initUC(uC_Personnage3, p3); initUC(uC_Personnage4, p4); foreach (Object o in Controls) { if (o is UC_Personnage) { UC_Personnage uC_Perso = new UC_Personnage(); uC_Perso.Enabled = true; } } ArrayList listTache = ControleurJeu.getListeFonctionnalite(); int posBas = 5; Fonctionnalites fPrecedent = null; //Initialisation ProgressBar pour chaque tache for (int i = 0; i <= listTache.Count - 1; i++) { Bunifu.Framework.UI.BunifuProgressBar progressBar = new Bunifu.Framework.UI.BunifuProgressBar(); Label l = new Label(); Fonctionnalites f = (Fonctionnalites)listTache[i]; if (f.getNom() != "Formation") { if (fPrecedent == null || f.getType() != fPrecedent.getType()) { posBas += 25; Label lblaffichageType = new Label(); lblaffichageType.Text = f.getType(); lblaffichageType.Location = new System.Drawing.Point(0, posBas); lblaffichageType.Font = new System.Drawing.Font("Cooper Black", 19F, System.Drawing.FontStyle.Underline, System.Drawing.GraphicsUnit.Point, ((byte)(0))); lblaffichageType.Size = new System.Drawing.Size(200, 45); lblaffichageType.Tag = 10; //permet d'identifier les labels titres posBas += 50; pnlProgressBarTache.Controls.Add(lblaffichageType); } fPrecedent = f; //remet à jour la fonctionnalités précédente l.Font = new System.Drawing.Font("Cooper Black", 10F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); l.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; l.BackColor = pnlProgressBarTache.BackColor; l.Location = new System.Drawing.Point(0, posBas); l.Size = new System.Drawing.Size(220, 20); l.Text = f.getNom(); if (f.getType() == "Spécification") { l.ForeColor = Color.DarkRed; } if (f.getType() == "Concevoir") { l.ForeColor = Color.Green; } if (f.getType() == "Développer") { l.ForeColor = Color.Purple; } if (f.getType() == "Recette") { l.ForeColor = Color.DarkGray; } if (f.getType() == "Livraison") { l.ForeColor = Color.Maroon; } progressBar.BackColor = System.Drawing.Color.Silver; progressBar.BorderRadius = 5; progressBar.ProgressColor = System.Drawing.Color.Teal; progressBar.Size = new System.Drawing.Size(pnlProgressBarTache.Width - 200, 20); progressBar.Location = new System.Drawing.Point(l.Location.X + 200, l.Location.Y); progressBar.Tag = i; progressBar.Value = 0; pnlProgressBarTache.Controls.Add(progressBar); pnlProgressBarTache.Controls.Add(l); posBas += 25; } } }
/** * 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; } } } } } } } } }