public void Mourrir(PersonnageAbstrait unPerso) { System.Windows.Application.Current.Dispatcher.Invoke( DispatcherPriority.Normal, (Action) delegate() { unPerso.ListEtape.Add(new Etape(0, "Je meurs.......", unPerso.Position.X, unPerso.Position.Y)); PersonnagesMortList.Add(unPerso); PersonnagesList.Remove(unPerso); meteo.ListObservateur.Remove(unPerso); ListObservateur.Remove(unPerso); if (unPerso.Equals(reine)) { List <PersonnageAbstrait> princesses = PersonnagesList.Where(x => x.GetType().Equals(typeof(Princesse))).ToList(); if (princesses.Count > 0) { Princesse nouvelleReine = (Princesse)princesses[0]; coordMaison.X = nouvelleReine.Position.X; coordMaison.Y = nouvelleReine.Position.Y; reine = Reine.RemplacerReine(nouvelleReine); PersonnagesList.Remove(nouvelleReine); PersonnagesList.Add(reine); } else { reine = null; } } } ); }
/// <summary> /// Actualise les informations de la fourmi /// </summary> /// <param name="perso"></param> public void Actualise(PersonnageAbstrait perso) { Reine = (Reine)perso; Vie = Reine.Vie; Oeufs = Reine.Oeuf; System.Diagnostics.Debug.WriteLine("[Observateur Reine] : " + " Vie: " + Vie + " Oeufs: " + Oeufs); }
public override void AjouterReine() { if (PersonnagesList.Where(x => x.GetType().Equals(typeof(Reine))).Count() == 0) { reine = (Reine)Fabrique.CreerReine("La reine", coordMaison); PersonnagesList.Add(reine); } }
public Plateau() { echiquier = new Piece[8, 8]; pN1 = new Pion(false); pN2 = new Pion(false); pN3 = new Pion(false); pN4 = new Pion(false); pN5 = new Pion(false); pN6 = new Pion(false); pN7 = new Pion(false); pN8 = new Pion(false); pB1 = new Pion(true); pB2 = new Pion(true); pB3 = new Pion(true); pB4 = new Pion(true); pB5 = new Pion(true); pB6 = new Pion(true); pB7 = new Pion(true); pB8 = new Pion(true); cavN1 = new Cavalier(false); cavN2 = new Cavalier(false); cavB1 = new Cavalier(true); cavB2 = new Cavalier(true); fouN1 = new Fou(false); fouN2 = new Fou(false); fouB1 = new Fou(true); fouB2 = new Fou(true); tourN1 = new Tour(false); tourN2 = new Tour(false); tourB1 = new Tour(true); tourB2 = new Tour(true); reineN = new Reine(false); reineB = new Reine(true); roiN = new Roi(false); roiB = new Roi(true); roiB.Couleur = true; initierPlateau(echiquier); }
public void AjouteReine(Reine f) { fourmilliere.PersonnageAbstraitList.Add(f); }
public override void TourSuivant() { if (!ReineMorte()) { if (reine.sousAttaque == false) { if (Etat != "normal") { Etat = "normal"; Notify(); } } if (reine.sousAttaque == true) { Etat = "attaque"; Notify(); reine.sousAttaque = false; } if (TourActuel % 10 == 0) { meteoChange(); } reine = (Reine)PersonnagesList.Where(x => x.GetType().Equals(typeof(Reine))).FirstOrDefault(); if (reine.OeufPondu != null) { List <ObjetAbstrait> morceaux = ObjetList.Where(x => x.GetType().Equals(typeof(MorceauNourriture)) && x.Position.toString().Equals(reine.Position.toString())).ToList(); if (morceaux.Count > 0) { ObjetList.Remove(morceaux[0]); ObjetList.Add(reine.OeufPondu); } } reine.OeufPondu = null; foreach (Oeuf unOeuf in ObjetList.Where(x => x.GetType().Equals(typeof(Oeuf))).ToList()) { if (unOeuf.Age > Oeuf.DureeAvantEclosion - 1) { PersonnageAbstrait fourmi = unOeuf.fourmiARetourner; fourmi.Nom += PersonnagesList.Count; AjouterFourmi(fourmi); ObjetList.Remove(unOeuf); } } foreach (Pheromone unePheromone in ObjetList.Where(x => x.GetType().Equals(typeof(Pheromone))).ToList()) { if (unePheromone.Dureevie < 1) { ObjetList.Remove(unePheromone); } } foreach (Nourriture nourriture in ObjetList.Where(x => x.GetType().Equals(typeof(Nourriture))).ToList()) { if (nourriture.ListMorceaux.Count < 1 || nourriture.Dureevie < 1) { ObjetList.Remove(nourriture); } } foreach (ObjetAbstrait unObjet in ObjetList) { unObjet.TourPasse(meteo); } Repositioner(); FournirAcces(); foreach (PersonnageAbstrait unInsecte in PersonnagesList.ToList()) { unInsecte.Avance1Tour(DimensionX, DimensionY, TourActuel); if (unInsecte.GetType().Equals(typeof(Ouvriere)) && unInsecte.TransporteNourriture == true) { if (unInsecte.Position.toString().Equals(coordMaison.toString())) { Ouvriere ouvriere = (Ouvriere)unInsecte; MorceauNourriture morceau = ouvriere.DeposeMorceau(); ObjetList.Add(morceau); } Coordonnees coordonnees = new Coordonnees(unInsecte.Position.X, unInsecte.Position.Y); Pheromone unPheromone = new Pheromone("pheromone", coordonnees); ObjetList.Add(unPheromone); } } List <PersonnageAbstrait> persosMorts = PersonnagesList.Where(x => x.PV < 1).ToList(); foreach (PersonnageAbstrait persomort in persosMorts) { Mourrir(persomort); } if (Hazard.Next(1, 7) == 1) { AjouteNourriture(); } if (TourActuel % 50 == 0) { for (int i = 0; i < Config.nbrTermites; i++) { AjouterTermite(); } } TourActuel++; } }
public void ChargerReine(Reine reinec) { reine = Reine.Instance(reinec); coordMaison.X = reine.Position.X; coordMaison.Y = reine.Position.Y; }