public void reproductionAndDeath(Environnement env, Espece esp) { float rate = esp.reproductionRate; Specificite[] dim = env.specificites; Caractere[] augm = esp.caractere; /*Specificite[] dim = { }; * Array.Copy(env.specificites,dim,env.specificites.Length); * Caractere[] augm = { }; * Array.Copy(esp.caractere, augm, esp.caractere.Length);*/ foreach (Specificite d in dim) { foreach (Caractere a in augm) { if (Array.Exists(d.counter, x => x == a)) { rate = rate - d.facteur * dampening + a.facteur * dampening; break; } else { rate -= d.facteur * dampening; } } } foreach (Caractere a in augm) { if (a.type == "Reproduction") { rate += a.facteur * dampening; } } esp.population = Convert.ToInt64(esp.population * rate); }
//retourne un tableau de taille en fonction de l'espece //[petit, moyen, grand] float[] getScale(Espece espece) { float[] tab = new float[3]; switch (espece) { case Espece.Paquerette: tab[0] = 10; tab[1] = 12; tab[2] = 15; break; case Espece.Rose: tab[0] = 3; tab[1] = 4; tab[2] = 5; break; case Espece.Tulipe: tab[0] = 1; tab[1] = 1.5f; tab[2] = 2; break; } return(tab); }
public ActionResult Create(Espece esp) { if (ModelState.IsValid) { using (IDal dal = new Dal()) { if (!dal.IsRaceExisting(esp.race)) { int id = dal.CreateSpec(esp); if (id != 0) { Response.StatusCode = 201; return(RedirectToAction("Index")); } else { Response.StatusCode = 503; ViewData["DBError"] = "Erreur pendant le traitement dans la base de données. Veuillez réessayer plus tard."; return(View(esp)); } } else { Response.StatusCode = 409; ViewData["InUse"] = "Cette race existe déjà !"; return(View(esp)); } } } return(View(esp)); }
// Use to process your families. protected override void onProcess(int familiesUpdateCount) { Espece e = _especes.First().GetComponent <Espece>(); GameObject genCnt = GameObject.Find("GenCounter"); if (_player.Count > 0) { genCnt.GetComponent <Text>().text = "Génération : " + Convert.ToString(_player.First().GetComponentInChildren <GameVariables>().generation); } }
public void setFlower(Espece espece, Couleur couleur, Taille taille, string constante) { _espece = espece; _couleur = couleur; _taille = taille; _const = constante; _x = -42; _y = -42; Element = null; objToSpawn = null; }
public ActionResult Edit(int?id, Espece esp) { if (ModelState.IsValid && id != null) { using (IDal dal = new Dal()) { dal.EditSpecies((int)id, esp); Response.StatusCode = 205; return(RedirectToAction("Index")); } } return(View(esp)); }
public void openDetailMenu(Espece e) { if (panelDetail == null) { panelDetail = GameObject.Instantiate(OiseauPanelBluePrintDetail, canvas.transform); panelDetail.transform.position = new Vector3(-(canvas.transform.position.x / 2), -(canvas.transform.position.y / 2), 0); if (e.sprite != null) { foreach (Image im in panelDetail.GetComponentsInChildren <Image>()) { if (im.name == "ImageOiseau") { im.sprite = e.sprite; } } } foreach (Text t in panelDetail.GetComponentsInChildren <Text>()) { if (t.name == "TextName") { t.text = "Name : " + e.name; } if (t.name == "TextPopulation") { t.text = "Population : " + Convert.ToString(e.population); } if (t.name == "TextEnvironnement") { t.text = "Environnement : a remplir"; } if (t.name == "TextCaractere") { string str = "Caractere : \n"; foreach (Caractere c in e.caractere) { str += "-" + c.name + "\n"; str += "\t Type : " + c.type + "\n"; str += "\t Facteur : " + Convert.ToString(c.facteur) + "\n"; str += "\t Propagation dans l'espece : " + Convert.ToString(c.pourcentagePopulation) + "\n"; } t.text = str; } } } }
public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } else { using (IDal dal = new Dal()) { Espece spec = dal.GetSpecById((int)id); if (spec == null) { return(HttpNotFound()); } return(View(spec)); } } }
private void btndelete_Click(object sender, EventArgs e) { if (MessageBox.Show("Etes-vous sûr de vouloir supprimer cet espèce ?", "Supprimer?", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { int codeParametrage = Convert.ToInt32(textcode.Text.Trim()); string libelle = textlibelle.Text.Trim(); if (MessageBox.Show("Etes-vous sûr de vouloir supprimer ce type?", "Supprimer?", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { Espece es = db.Especes.ToList <DAL.Espece>().Where(w => w.CodeEspece == codeParametrage).FirstOrDefault(); GenericRepository <Espece> espece = new GenericRepository <Espece>(db); espece.Delete(es); } db.SaveChanges(); Clear(); especeDataGrid(); MessageBox.Show("espèce supprimé "); } }
public GenerationDonnees() { GameObject player = GameObject.Find("Player"); GameObject envs = GameObject.Find("Environnements"); GameObject spec = GameObject.Find("Specificites"); GameObject esps = GameObject.Find("Especes"); GameObject carac = GameObject.Find("Caracteres"); //Initialisation du premier environnement Caractere volant = new Caractere(); volant.name = "Vol"; volant.facteur = 3; volant.type = "Defense"; volant.pourcentagePopulation = 100; Caractere plume = new Caractere(); plume.name = "Plumes Colorées"; plume.facteur = 1; plume.type = "Reproduction"; plume.pourcentagePopulation = 100; Espece pigeon = new Espece(); pigeon.name = "Pigeon"; pigeon.population = 10; pigeon.reproductionRate = 1.15f; pigeon.caractere.SetValue(volant, 0); Specificite predateur = new Specificite(); predateur.name = "Lion"; predateur.facteur = 3; predateur.counter.SetValue(volant, 0); predateur.type = "Mortalite"; Environnement premier = new Environnement(); premier.name = "Plaine tranquille"; premier.specificites.SetValue(predateur, 0); premier.especes.SetValue(pigeon, 0); Debug.Log("Done"); }
public void setFlowerFromElem(Element elem) { string espece = CultureInfo.CurrentCulture.TextInfo.ToTitleCase(elem.GetFleur().ToLower()); string couleur = CultureInfo.CurrentCulture.TextInfo.ToTitleCase(elem.GetCouleur().ToLower()); string taille = CultureInfo.CurrentCulture.TextInfo.ToTitleCase(elem.GetTaille().ToLower()); _const = elem.GetNom(); Element = elem; //_x = (float)elem.GetX(); //_y = (float)elem.GetY(); _x = -42; _y = -42; if (elem.GetNom() == null) { _const = "none"; } if (string.Compare(couleur, "Blanc") == 0) { couleur = "Blanche"; } switch (taille) { case "Grand": taille = "Grande"; break; case "Moyen": taille = "Moyenne"; break; case "Petit": taille = "Petite"; break; } _espece = (Espece)System.Enum.Parse(typeof(Espece), espece); _couleur = (Couleur)System.Enum.Parse(typeof(Couleur), couleur); _taille = (Taille)System.Enum.Parse(typeof(Taille), taille); }
// Use to process your families. protected override void onProcess(int familiesUpdateCount) { GameObject text = GameObject.Find("Affichage"); Espece e = _especes.First().GetComponent <Espece>(); string t = ""; if (e) { t = Convert.ToString(e.name) + " : Population de" + Convert.ToString(e.population) + "oiseaux \n"; Debug.Log(e.name); } else { t = ""; } text.GetComponent <Text>().text = t; GameObject genCnt = GameObject.Find("GenCounter"); genCnt.GetComponent <Text>().text = "Génération : " + Convert.ToString(_player.First().GetComponent <GameVariables>().generation); }