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

            crtCase.RetirerCreature(fourmi);
            destCase.AjouterCreature(fourmi);
        }
예제 #2
0
 private void VerifierVieFourmi(Fourmi fourmiAVerifier)
 {
     if (fourmiAVerifier.Vie < 0)
     {
         SupprimerFourmi(fourmiAVerifier);
     }
 }
예제 #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);
        }
예제 #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());
            }
        }
예제 #5
0
        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]);
            }
        }
예제 #6
0
 public void Detach(Fourmi observer)
 {
     observateurList.Remove(observer);
 }
예제 #7
0
 public void Attach(Fourmi observer)
 {
     observateurList.Add(observer);
 }
예제 #8
0
 public Case GetCaseFromFourmi(Fourmi fourmi)
 {
     return(CasesList.Where(c => c.GetCreaturesSurCase().Contains(fourmi)).First());
 }
예제 #9
0
 public void SupprimerFourmi(Fourmi fourmiAsupprimer)
 {
     plateauManager.GetCaseFromFourmi(fourmiAsupprimer).RetirerCreature(fourmiAsupprimer);
     FourmisList.Remove(fourmiAsupprimer);
 }
예제 #10
0
파일: Case.cs 프로젝트: xTeddyR/Fourmiliere
 public void RetirerCreature(Fourmi creature)
 {
     creaturesSurCase.Remove(creature);
 }
예제 #11
0
파일: Case.cs 프로젝트: xTeddyR/Fourmiliere
 public void AjouterCreature(Fourmi creature)
 {
     creaturesSurCase.Add(creature);
 }