Exemple #1
0
        public void DeplacementCreature(Fourmi fourmi, Case destCase)
        {
            var crtCase = GetCaseFromFourmi(fourmi);

            crtCase.RetirerCreature(fourmi);
            destCase.AjouterCreature(fourmi);
        }
 private void VerifierVieFourmi(Fourmi fourmiAVerifier)
 {
     if (fourmiAVerifier.Vie < 0)
     {
         SupprimerFourmi(fourmiAVerifier);
     }
 }
Exemple #3
0
        /// <summary>
        /// Met à jour la position de la fourmi
        /// </summary>
        /// <param name="fourmi"></param>
        /// <param name="Destination"></param>
        public override void Avance(Fourmi fourmi, Location Destination)
        {
            Location Resultat = new Location()
            {
                X = fourmi.Position.X - Destination.X,
                Y = fourmi.Position.Y - Destination.Y
            };

            fourmi.Position.X += AjouterDeplacment(Resultat.X);
            fourmi.Position.Y += AjouterDeplacment(Resultat.Y);

            AfficherResultat(fourmi.Position, Destination);
        }
Exemple #4
0
        public override void Avance(Fourmi fourmi)
        {
            int  newX = fourmi.Position.X + Hasard.Next(3) - 1;
            int  newY = fourmi.Position.Y + Hasard.Next(3) - 1;
            bool flag = false;

            if (newX >= 0 && newX < dimesionX)
            {
                fourmi.Position.X = newX;
            }
            flag = true;
            if (newY >= 0 && newY < dimensionY)
            {
                fourmi.Position.Y = newY;
            }
            flag = true;
            if (flag)
            {
                plateauManager.DeplacementCreature(fourmi, plateauManager.CasesList.Where(c => c.Position.X == fourmi.Position.X && c.Position.Y == fourmi.Position.Y).First());
            }
        }
        public void TourSuivant()
        {
            nbTours++;
            Console.WriteLine("nbTours: " + nbTours);

            environnement.Heure.OnNouveauTour();

            GenererFourmiRouge();
            GenererObjets();

            for (int i = 0; i < FourmisList.Count; i++)
            {
                Fourmi actuel = FourmisList[i];

                if (FourmisList[i].Nom == "TestCourtChemin")
                {
                    Location dest = new Location {
                        X = 3,
                        Y = 1
                    };

                    courtChemin.Avance(actuel, dest);
                }
                else
                {
                    hazard.Avance(FourmisList[i]);
                }
                FourmisList[i].Vie--;
                VerifierVieFourmi(FourmisList[i]);

                var objet = plateauManager.GetCaseFromFourmi(FourmisList[i]).Objet;
                if (objet != null)
                {
                    FourmisList[i].Comportement.ExecuteObjet(objet);
                }
                VerifierVieFourmi(FourmisList[i]);
            }
        }
Exemple #6
0
 public void Detach(Fourmi observer)
 {
     observateurList.Remove(observer);
 }
Exemple #7
0
 public void Attach(Fourmi observer)
 {
     observateurList.Add(observer);
 }
Exemple #8
0
 public Case GetCaseFromFourmi(Fourmi fourmi)
 {
     return(CasesList.Where(c => c.GetCreaturesSurCase().Contains(fourmi)).First());
 }
 public void SupprimerFourmi(Fourmi fourmiAsupprimer)
 {
     plateauManager.GetCaseFromFourmi(fourmiAsupprimer).RetirerCreature(fourmiAsupprimer);
     FourmisList.Remove(fourmiAsupprimer);
 }
Exemple #10
0
 public void RetirerCreature(Fourmi creature)
 {
     creaturesSurCase.Remove(creature);
 }
Exemple #11
0
 public void AjouterCreature(Fourmi creature)
 {
     creaturesSurCase.Add(creature);
 }