public void maj(List <Nourriture> listn) { foreach (Nourriture n in listn) { if (target == null) { if (n.etat == true && n.avarie == false) { StrategieCourante = new Faim("Faim"); target = n; break; } else if (n.etat == false || n.avarie == true) { StrategieCourante = new Immobile("Immobile"); target = null; } } else { Nourriture nearest = closest(this, listn); if (nearest.etat == true && nearest.avarie == false) { StrategieCourante = new Faim("Faim"); target = nearest; break; } else if (nearest.etat == false || nearest.avarie == true) { StrategieCourante = new Immobile("Immobile"); target = null; } } } }
public Pigeon(string nom) { this.nom = nom; StrategieCourante = new Immobile("immobile"); X = Hazard.Next(1, 20); Y = Hazard.Next(1, 20); //thread = new Thread(new ThreadStart(this.RunThread)); }
public void maj(List <Human> listh)//tant que des hulains sont présent, les mouvement sont impossible { foreach (Human h in listh) { if (h.etat != false) { double dist = Math.Sqrt(Distance2Human(this, h)); if (dist <= RANGE) { detecte = true; } else { detecte = false; } if (detecte) { StrategieCourante = new Fuite("fuite"); target2 = h; } } } }