public Objet AjouteObjet(int x, int y, string objet = "")
        {
            var myObjet = FabriqueSimulation.CreerFabrique("FabriqueObjet").CreerObjet(objet, x, y);

            plateauManager.GetCaseFromPosition(x, y).Objet = myObjet;
            return(myObjet);
        }
        public void AjouterFourmi(string nom, int x, int y, string comportement = "AttitudeAucune")
        {
            var fourmi = FabriqueSimulation.CreerFabrique("FabriqueFourmi").CreerFourmi(nom, x, y);

            fourmi.Comportement = FabriqueSimulation.CreerFabrique("FabriqueAttitude").CreerAttitude(comportement);
            plateauManager.GetCaseFromPosition(fourmi.Position.X, fourmi.Position.Y).AjouterCreature(fourmi);
            FourmisList.Add(fourmi);
        }
 public void LoadDataFromXML(string fileName)
 {
     using (XmlReader xmlReader = XmlReader.Create(fileName))
     {
         xmlReader.ReadToFollowing("Meteo");
         environnement.Meteo.Etat = (MeteoType)Enum.Parse(typeof(MeteoType), xmlReader.ReadElementContentAsString());
         xmlReader.ReadToFollowing("Heure");
         environnement.Heure.NbHeure = xmlReader.ReadElementContentAsInt();
         xmlReader.ReadToFollowing("Minute");
         environnement.Heure.NbMinute = xmlReader.ReadElementContentAsInt();
         xmlReader.ReadToFollowing("NbTours");
         FourmilliereModel.NbTours = xmlReader.ReadElementContentAsInt();
         var casesList = new List <Case>();
         while (xmlReader.ReadToFollowing("Case"))
         {
             xmlReader.ReadToFollowing("X");
             int x = xmlReader.ReadElementContentAsInt();
             xmlReader.ReadToFollowing("Y");
             int y      = xmlReader.ReadElementContentAsInt();
             var myCase = FabriqueSimulation.CreerFabrique("FabriqueCase").CreerCase(x, y);
             xmlReader.MoveToContent();
             if (xmlReader.NodeType == XmlNodeType.Element && xmlReader.Name == "Objet")
             {
                 xmlReader.ReadToFollowing("Type");
                 string typeObjet = xmlReader.ReadElementContentAsString();
                 xmlReader.ReadToFollowing("X");
                 int xObjet = xmlReader.ReadElementContentAsInt();
                 xmlReader.ReadToFollowing("Y");
                 int yObjet = xmlReader.ReadElementContentAsInt();
                 myCase.Objet = FabriqueSimulation.CreerFabrique("FabriqueObjet").CreerObjet(typeObjet, xObjet, yObjet);
                 xmlReader.MoveToContent();
             }
             while (xmlReader.NodeType == XmlNodeType.Element && xmlReader.Name == "Fourmi")
             {
                 xmlReader.ReadToFollowing("Nom");
                 string nomFourmi = xmlReader.ReadElementContentAsString();
                 xmlReader.ReadToFollowing("Vie");
                 int vieFourmi = xmlReader.ReadElementContentAsInt();
                 xmlReader.ReadToFollowing("X");
                 int xFourmi = xmlReader.ReadElementContentAsInt();
                 xmlReader.ReadToFollowing("Y");
                 int yFourmi = xmlReader.ReadElementContentAsInt();
                 xmlReader.ReadToFollowing("Attitude");
                 string attitudeFourmi = xmlReader.ReadElementContentAsString();
                 var    myFourmi       = FabriqueSimulation.CreerFabrique("FabriqueFourmi").CreerFourmi(nomFourmi, xFourmi, yFourmi);
                 myFourmi.Vie          = vieFourmi;
                 myFourmi.Comportement = FabriqueSimulation.CreerFabrique("FabriqueAttitude").CreerAttitude(attitudeFourmi);
                 myCase.AjouterCreature(myFourmi);
                 xmlReader.MoveToContent();
             }
             casesList.Add(myCase);
         }
         plateauManager.CasesList = casesList;
     }
 }
Exemple #4
0
 public void CreationDesCases()
 {
     CasesList = new List <Case>();
     for (int i = 0; i < Config.GRILLE_LARGEUR; i++)
     {
         for (int j = 0; j < Config.GRILLE_HAUTEUR; j++)
         {
             CasesList.Add(FabriqueSimulation.CreerFabrique("FabriqueCase").CreerCase(i, j));
         }
     }
 }
Exemple #5
0
        public Fourmi(string v, int x, int y)
        {
            this.Nom       = v;
            this.vie       = ConfigFourmi.VIE_FOURMI;
            ListEtape      = new ObservableCollection <Etape>();
            Position       = new Location(x, y);
            plateauManager = PlateauManager.Instance;
            Comportement   = FabriqueSimulation.CreerFabrique("FabriqueAttitude").CreerAttitude("AttitudeAucune");
            int nbEtapes = 0;

            for (int i = 0; i < nbEtapes; i++)
            {
                ListEtape.Add(new Etape());
            }
        }
Exemple #6
0
        public Fourmi()
        {
            this.Nom       = "";
            this.vie       = ConfigFourmi.VIE_FOURMI;
            ListEtape      = new ObservableCollection <Etape>();
            Position       = new Location(ConfigFourmi.FOURMILIERE_POSITION_X, ConfigFourmi.FOURMILIERE_POSITION_Y);
            plateauManager = PlateauManager.Instance;
            comportement   = FabriqueSimulation.CreerFabrique("FabriqueAttitude").CreerAttitude("AttitudeAucune");
            int nbEtapes = 0;

            for (int i = 0; i < nbEtapes; i++)
            {
                ListEtape.Add(new Etape());
            }
        }
        public override void ExecuteObjet(Objet destObjet)
        {
            var myCase = plateauManager.CasesList.Where(c => destObjet.Equals(c.Objet)).First();
            var fourmi = myCase.GetCreaturesSurCase()[0];

            switch (destObjet.ToString())
            {
            case "Baton":
                fourmi.Comportement = FabriqueSimulation.CreerFabrique("FabriqueAttitude").CreerAttitude("AttitudeCombattante");
                break;

            case "Panier":
                fourmi.Comportement = FabriqueSimulation.CreerFabrique("FabriqueAttitude").CreerAttitude("AttitudeCueilleuse");
                break;

            default:
                break;
            }
            myCase.Objet = null;
        }