public MorceauNourriture DeposeMorceau() { AjouterEtape(0, "Je dépose de la nourriture à la reine.", Position.X, Position.Y); Morceau.Position = new Coordonnees(Position.X, Position.Y); MorceauNourriture morceauRendu = Morceau; Morceau = null; TransporteNourriture = false; this.StategieCourante = new Normal("Normal"); return(morceauRendu); }
public override void AnalyseSituation() { if (zone.ObjetList.Count > 0) { /*On ne prend pas la nourriture de la maison*/ if (zone.Position.X != this.Maison.X && zone.Position.Y != this.Maison.Y) { if (this.TransporteNourriture == false) { try { foreach (Nourriture unObjet in zone.ObjetList.Where(x => x.GetType().Equals(typeof(Nourriture)))) { if (unObjet.ListMorceaux.Count > 0) { this.Morceau = unObjet.Recolter(); AjouterEtape(0, "Je récolte un morceau de nourriture ! ", Position.X, Position.Y); this.StategieCourante = new Retour("Retour"); this.TransporteNourriture = true; } } } catch (Exception e) { e.ToString(); } } } } if (zone.PersonnageList.Count > 0) { foreach (PersonnageAbstrait unPerso in zone.PersonnageList) { if (unPerso.GetType().Equals(typeof(Guerriere))) { /*Indiquer chemin nourriture*/ } else if (unPerso.GetType().Equals(typeof(Termite))) { AjouterEtape(0, "Une termite m'attaque ! ", this.Position.X, this.Position.Y); } } } }
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++; } }