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); }
// Effecteur RAMASSER public void Ramasser(int position, Environnement env) { // Console.WriteLine("Effecteur ramasser"); // Notifier l'environnement qu'on ramasse un bijou dans la pièce X _message = Tuple.Create(Action.RAMASSER, position); Environnement.fileAction.Enqueue(_message); }
protected override void OnPaint(PaintEventArgs e) { base.OnPaint(e); Brush b = new SolidBrush(Color.White); Pen p = new Pen(b, 5f); for (int x = 0; x <= numOfCells; ++x) { g.DrawLine(p, 0, x * cellSize, numOfCells * cellSize, x * cellSize); g.DrawLine(p, x * cellSize, 0, x * cellSize, numOfCells * cellSize); } //Coordonnees posAgent = Agent.Instance.Coordonnees; Coordonnees posAgent = Agent.Instance.Coordonnees; Brush b2 = new SolidBrush(Color.Gold); g.FillRectangle(b2, posAgent.X * cellSize, posAgent.Y * cellSize, cellSize, cellSize); Environnement env = Environnement.Instance; label1.Text = "Score : " + env.getScore(); drawInCell(p, env.Chambres); }
private void Start() { levelManager = GameManager.Instance.levelManager; environment = GameManager.Instance.levelManager.environnement; environnement = levelManager.environnement; soundHandler = GameManager.Instance.soundHandler; levelManager.submarineEntitiesInScene.Add(this); levelManager.enemyEntitiesInScene.Add(this); _transform = transform; coords.position = Coordinates.ConvertWorldToVector2(_transform.position); currentSeaLevel = SeaLevel.submarine; PickRandomInterrestPoint(); ship = Object.FindObjectOfType <Ship>(); subZoneAngleWidth12 = 360 / subZone12Subdivision; subZoneAngleWidth3 = 360 / (subZone12Subdivision * subZone3SubSubdivision); for (int i = 0; i < levelManager.submarineEntitiesInScene.Count; i++) { if (levelManager.submarineEntitiesInScene[i].GetType() != typeof(Submarine)) { bioElements.Add(levelManager.submarineEntitiesInScene[i].transform); } } }
// Effecteur ASPIRER public void Aspirer(int position, Environnement env) { // Console.WriteLine("Effecteur aspirer"); // Notifier l'environnement qu'on aspire la pièce X _message = Tuple.Create(Action.ASPIRER, position); Environnement.fileAction.Enqueue(_message); }
public static Environnement getUniqueEnv() { if (uniqueEnv == null) { uniqueEnv = new Environnement(); uniqueEnv.currentId = 0; } return uniqueEnv; }
public static EnvironnementModel ToEnvironnementModel(this Environnement environnement) { return(new EnvironnementModel { Etiquette = new EtiquetteModel { Id = environnement.Id, Nom = environnement.Nom }, Ordre = environnement.Ordre }); }
/// <summary> /// Methode qui cree l'agent et l'environnement en fonction des parametres passes sur le premier ecran. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Go(object sender, RoutedEventArgs e) { Debut.Visibility = Visibility.Hidden; Lecanvas.Visibility = Visibility.Visible; BoutonsS.Visibility = Visibility.Visible; Stats.Visibility = Visibility.Visible; Manoir.Visibility = Visibility.Visible; Env = new Environnement(5, 5, int.Parse(TpsActualisation.Text), int.Parse(pourcenP.Text), int.Parse(pourcenB.Text)); Aspirateur = new Agent(int.Parse(EnergieMax.Text), int.Parse(EnergiePAct.Text), int.Parse(TpsAction.Text), Informe, Env); }
public void evolution() { foreach (GameObject env in __environnement) { Environnement envir = env.GetComponent <Environnement>(); foreach (Espece e in envir.especes) { reproductionAndDeath(envir, e); } } }
public void Load() { //Si le fichier d'inventaire sérialisé existe alors on le deserialise sous forme d'inventaire if (File.Exists(Application.persistentDataPath + "/inventaireInfo.dat")) { BinaryFormatter bf = new BinaryFormatter(); FileStream file = File.Open(Application.persistentDataPath + "/inventaireInfo.dat", FileMode.Open); InfosInventaire inventaireData = (InfosInventaire)bf.Deserialize(file); Inventaire.Instance.qteBois = inventaireData.qteBois; Inventaire.Instance.qtePierre = inventaireData.qtePierre; Inventaire.Instance.qteMetal = inventaireData.qteMetal; Inventaire.Instance.qteNourriture = inventaireData.qteNourriture; Inventaire.Instance.armes = inventaireData.armes; Inventaire.Instance.armures = inventaireData.armures; Inventaire.Instance.qtePierreToAdd = inventaireData.qtePierreToAdd; Inventaire.Instance.qteBoisToAdd = inventaireData.qteBoisToAdd; Inventaire.Instance.qteMetalToAdd = inventaireData.qteMetalToAdd; Inventaire.Instance.qteNourritureToAdd = inventaireData.qteNourritureToAdd; file.Close(); } //Si le fichier d'environnement sérialisé existe alors on le deserialise sous forme d'environnement else if (File.Exists(Application.persistentDataPath + "/environnementInfo.dat")) { BinaryFormatter bf = new BinaryFormatter(); FileStream file = File.Open(Application.persistentDataPath + "/environnementInfo.dat", FileMode.Open); Environnement environnementData = (Environnement)bf.Deserialize(file); Environnement.Instance.SaisonCourante = environnementData.SaisonCourante; Environnement.Instance.JoursPasses = environnementData.JoursPasses; Environnement.Instance.JoursPassesDansLaSaison = environnementData.JoursPassesDansLaSaison; file.Close(); } //Si le fichier de campement sérialisé existe alors on le deserialise sous forme de campement else if (File.Exists(Application.persistentDataPath + "/campementInfo.dat")) { BinaryFormatter bf = new BinaryFormatter(); FileStream file = File.Open(Application.persistentDataPath + "/campementInfo.dat", FileMode.Open); InfosCampement campementData = (InfosCampement)bf.Deserialize(file); CampementData.Instance.batiments = campementData.batiments; CampementData.Instance.soldats = campementData.soldats; CampementData.Instance.missionsDisponible = campementData.missions; CampementData.Instance.nbSurvivant = campementData.nbSurvivant; CampementData.Instance.survivantContent = campementData.survivantContent; CampementData.Instance.nbSurvivantNonOccupé = campementData.nbSurvivantNonOccupe; file.Close(); } }
private void Awake() { if (instance == null) { DontDestroyOnLoad(this.gameObject); instance = this; JoursPasses = 0; saisonCourante = "Ete"; if (Instance != null && Instance != this) { Destroy(this.gameObject); return; } } }
public void GenerateNewEnvironnement() { GameObject go = new GameObject(); go.name = "(new)Generated Enviro"; go.AddComponent(typeof(Environnement)); Environnement enviro = go.GetComponent <Environnement>(); //Change Map Limit enviro.limit = limit; if (editZones.Count != 0) { //Create Each Zone storage space enviro.zones = new Zone[editZones.Count]; //For each Zone for (int i = 0; i < editZones.Count; i++) { //Zone Info enviro.zones[i].name = editZones[i].name; enviro.zones[i].windDir = editZones[i].windDir; enviro.zones[i].debugColor = editZones[i].color; if (editZones[i].points.Count != 0) { //Create Points storage space enviro.zones[i].points = new Vector2[editZones[i].points.Count]; for (int j = 0; j < editZones[i].points.Count; j++) { enviro.zones[i].points[j] = new Vector2(editZones[i].points[j].position.x, editZones[i].points[j].position.z); } } else { Debug.LogWarning("Il n'y a pas de point dans la Zone" + i); } } } else { Debug.LogError("Il n'y a pas de zone"); } this.enviro = enviro; }
public Environnement NewEnvironnement() { Environnement enviro = new Environnement(); //Change Map Limit enviro.limit = limit; if (editZones.Count != 0) { //Create Each Zone storage space enviro.zones = new Zone[editZones.Count]; //For each Zone for (int i = 0; i < editZones.Count; i++) { //Zone Info enviro.zones[i].name = editZones[i].name; enviro.zones[i].windDir = editZones[i].windDir; enviro.zones[i].debugColor = editZones[i].color; if (editZones[i].points.Count != 0) { //Create Points storage space enviro.zones[i].points = new Vector2[editZones[i].points.Count]; for (int j = 0; j < editZones[i].points.Count; j++) { enviro.zones[i].points[j] = new Vector2(editZones[i].points[j].position.x, editZones[i].points[j].position.z); } } else { Debug.LogWarning("Il n'y a pas de point dans la Zone" + i); } } } else { Debug.LogError("Il n'y a pas de zone"); } if (this.enviro != null) { this.enviro = enviro; } return(enviro); }
static void Main() { Application.SetCompatibleTextRenderingDefault(false); Application.EnableVisualStyles(); form = new Form1(); form.BackColor = Color.Black; env = Environnement.Instance; agent = Agent.Instance; t = new Thread(env.generateStuff); t2 = new Thread(agent.run); t.Start(); Thread.Sleep(1000); t2.Start(); Application.Run(form); }
IEnumerator DropFlash(PlayerOceanEntity user) { float timer = 0; float distance = 0; Environnement currentEnviro = GameManager.Instance.levelManager.environnement; Zone testedZone = currentEnviro.zones[currentEnviro.ZoneIn(user.coords.position) - 1]; FlashFeedback flashFeedback = (FlashFeedback)feedbackBehavior; flashFeedback.DropFlash(dropDuration, new Vector3(currentUser.transform.position.x, currentUser.transform.position.y + heightOffset, currentUser.transform.position.z)); Helicopter helicopter = (Helicopter)user; helicopter.isDroppingFlash = true; //Wait the drop duration before apply effect //Insert Somehow feedback of drop here while (timer < dropDuration) { yield return(new WaitForFixedUpdate()); timer += Time.deltaTime; } helicopter.isDroppingFlash = false; //Test all submarine in the scene //If they are in winning range Win the game (need method implementation to win In GameManager probably) //If they are in extended range show submarine trail for the specified time (need method impletation for that in Submarine) foreach (Submarine submarine in levelManager.enemyEntitiesInScene) { distance = Mathf.Abs(Vector2.Distance(submarine.coords.position, user.coords.position)); if (distance <= winningRange) { GameManager.Instance.uiHandler.victoryScreenManager.Victory(true); } else if (distance <= extendedRange && testedZone.state != ZoneState.SeaTurbulent) { submarine.MaterialChangedByFlash(revealDuration); } } }
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 override void OnInspectorGUI() { Environnement enviro = (Environnement)target; base.OnInspectorGUI(); GUILayout.Space(20); //Environnement using (new GUILayout.HorizontalScope()) { if (GUILayout.Button("Generate EnviroColor Texture", GUILayout.Height(40))) { enviro.GenerateTextureColor(); } if (GUILayout.Button("Generate EnviroData Texture", GUILayout.Height(40))) { enviro.GenerateTextureData(); } } }
private double seuil = 1; // seuil de variation pour déclencher une modification de nbaction /* Constructeur a utiliser pour placer un agent dans un environnement*/ public Agent(Environnement env, AlgoExploration exploration) { _environnement = env; }
public int[] ObserverCarte(Environnement env) { return(env.getCarte()); }
public int ObserverPerformance(Environnement env) { return(env.getMesurePerformance()); }
public static void GenerateZoneDataTexture(Environnement map, string name) { //generate the path string path = TextureGenerator.PathAsking(name); if (path == null || path == string.Empty) { Debug.Log("SeaTexture creation have been cancel"); return; } #region Set the Texture size //detail level must be a multiple of 4 int detailLevel = 12; if (detailLevel % 4 != 0) { Debug.LogError("DetailLevel must be a multiple of 4"); return; } float inverseDetail = (float)1f / detailLevel; //Determine quel coté est le plus long bool maxIsX = map.limit.size.x > map.limit.size.y; float mapMaxLenght = maxIsX ? map.limit.size.x : map.limit.size.y; int textureSize = Mathf.CeilToInt(mapMaxLenght * detailLevel); float textNormalizer = (float)1f / textureSize; float borderEmptySpace = (maxIsX ? map.limit.size.x - map.limit.size.y : map.limit.size.y - map.limit.size.x) * 0.5f; #endregion //Creating The texture Texture2D texture = TextureGenerator.CreateTexture(textureSize); float textStartPosX = map.limit.offSet.x + map.limit.leftBorder; float textStartPosY = map.limit.offSet.y + map.limit.downBorder; if (maxIsX) { textStartPosY -= borderEmptySpace; } else { textStartPosX -= borderEmptySpace; } //Set les couleurs de chaques zone List <Color> zoneColor = new List <Color>() { Color.black, Color.red, Color.green, Color.blue }; if (map.zones.Length != 0) { zoneColor.RemoveRange(1, 3); for (int i = 0; i < map.zones.Length; i++) { float waveStrenght = 0; float colorIntensity = 0; switch (map.zones[i].state) { case ZoneState.SeaCalm: waveStrenght = 0.3f; colorIntensity = 0.5f; break; case ZoneState.SeaWay: waveStrenght = 0.5f; colorIntensity = 0.3f; break; case ZoneState.SeaTurbulent: waveStrenght = 1f; colorIntensity = 1f; break; case ZoneState.WindyZone: waveStrenght = 0.7f; colorIntensity = 0.7f; break; default: break; } zoneColor.Add( new Color( map.zones[i].windDir * 0.5f, //R = direction du vent waveStrenght, //G = Wave Height colorIntensity, //B = Color Intensity 1)); } } Color tempColor; //Send Data in for (int x = 0; x < textureSize; x++) { for (int y = 0; y < textureSize; y++) { tempColor = zoneColor[map.ZoneIn(new Vector2(textStartPosX + (x * inverseDetail), textStartPosY + (y * inverseDetail)))]; texture.SetPixel(x, y, tempColor); } } texture.Apply(); //texture = TextureGenerator.Blur(texture, 1); //Check for copy TextureGenerator.DeleteCopy(path); //create the asset TextureGenerator.TextureToAssetPNG(path, texture); //Debug.log the test TextureGenerator.TestTextureAtPath(path); }
public static void GenerateSeaTexture(Environnement map, string name) { //generate the path string path = TextureGenerator.PathAsking(name); if (path == null || path == string.Empty) { Debug.Log("SeaTexture creation have been cancel"); return; } //Set les couleurs de chaques zone List <Color> zoneColor = new List <Color>() { Color.red, Color.green, Color.blue }; if (map.zones.Length != 0) { zoneColor.RemoveRange(0, 2); for (int i = 0; i < map.zones.Length; i++) { zoneColor.Add(map.zones[i].debugColor); } } #region Set the Texture size //detail level must be a multiple of 4 int detailLevel = 12; if (detailLevel % 4 != 0) { Debug.LogError("DetailLevel must be a multiple of 4"); return; } float inverseDetail = (float)1f / detailLevel; //Determine quel coté est le plus long bool maxIsX = map.limit.size.x > map.limit.size.y; float mapMaxLenght = maxIsX ? map.limit.size.x : map.limit.size.y; int textureSize = Mathf.CeilToInt(mapMaxLenght * detailLevel); float textNormalizer = (float)1f / textureSize; float borderEmptySpace = (maxIsX ? map.limit.size.x - map.limit.size.y : map.limit.size.y - map.limit.size.x) * 0.5f; #endregion //Creating The texture Texture2D texture = TextureGenerator.CreateTexture(textureSize); float textStartPosX = map.limit.offSet.x + map.limit.leftBorder; float textStartPosY = map.limit.offSet.y + map.limit.downBorder; if (maxIsX) { textStartPosY -= borderEmptySpace; } else { textStartPosX -= borderEmptySpace; } Color tempColor = Color.grey; //Send Data in for (int x = 0; x < textureSize; x++) { for (int y = 0; y < textureSize; y++) { texture.SetPixel(x, y, tempColor); } } texture.Apply(); //Check for copy TextureGenerator.DeleteCopy(path); //create the asset TextureGenerator.TextureToAssetPNG(path, texture); //Debug.log the test TextureGenerator.TestTextureAtPath(path); }
private void OnEnable() { m_Environnement = (Environnement)target; }
public void Init() => _environnement = new Environnement();
private void SimulationCanvas_Loaded(object sender, RoutedEventArgs e) { _Environnement = new Environnement((sender as Canvas).ActualWidth, (sender as Canvas).ActualHeight); }
public static SelectListItem ToSelectListItem(this Environnement environnement) { return(new SelectListItem { Value = environnement.Id.ToString(), Text = environnement.Nom }); }