Exemple #1
0
        // méthode de fabrication d'une Fourmi
        public Fourmi MakeFourmi(int type)
        {
            Fourmi f = null;

            switch (type)
            {
                case TYPE_CHASSEUSE:
                    f = new Chasseuse(type, "hunter_" + _id);
                    _nbrChasseuses++;
                    break;

                case TYPE_NOURRICE:
                    f = new Nourrice(type, "nurse_" + _id);
                    _nbrNourrices++;
                    break;

                case TYPE_OUVRIERE:
                    f = new Ouvriere(type, "worker_" + _id);
                    _nbrOuvrieres++;
                    break;

                case TYPE_QUEEN:
                    f = new Queen(type, "Kyukyuni_" + _id);
                    break;
            }

            _listFourmis.Add(f);

            _id++;

            return f;
        }
Exemple #2
0
        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++;
            }
        }