// Use to process your families. protected override void onProcess(int familiesUpdateCount) { foreach (GameObject go in _SecreterGO) { if (go.GetComponent <Secreter>() != null && go.GetComponent <Secreter>().type.Equals("Anticorps")) { Debug.Log("Anticorps"); Secreter sr = go.GetComponent <Secreter> (); sr.reloadProgress += Time.deltaTime; int NombreMaxSecretionSecreter = sr.NombreMaxSecretion; int NombreActuelleSecreter = sr.NombreActuelle; if (NombreActuelleSecreter == NombreMaxSecretionSecreter) { new WaitForSecondsRealtime(30f); NombreActuelleSecreter = 0; } Bounds SecreteurSize = go.GetComponent <Renderer>().bounds; if (NombreActuelleSecreter < NombreMaxSecretionSecreter && sr.reloadProgress >= sr.reloadTime) { float x = Random.Range(SecreteurSize.min.x, SecreteurSize.max.x); float y = Random.Range(SecreteurSize.min.y, SecreteurSize.max.y); float z = 0.0f; Vector3 ElementPosition = new Vector3(x, y, z); if (go.GetComponent <Specialisation> () != null && go.GetComponent <Specialisation> ().type.Equals("Bacterie")) { GameObject Element = GameObjectManager.instantiatePrefab(sr.type); Element.transform.position = ElementPosition; NombreActuelleSecreter = NombreActuelleSecreter + 1; GameObjectManager.addComponent(Element, typeof(Specialisation), new { type = "Bacterie" }); GameObjectManager.addComponent(Element, typeof(Ralentir)); } if (go.GetComponent <Specialisation> () != null && go.GetComponent <Specialisation> ().type.Equals("Virus")) { GameObject Element = GameObjectManager.instantiatePrefab(sr.type); Element.transform.position = ElementPosition; NombreActuelleSecreter = NombreActuelleSecreter + 1; GameObjectManager.addComponent(Element, typeof(Specialisation), new { type = "Virus" }); GameObjectManager.addComponent(Element, typeof(Ralentir)); GameObjectManager.addComponent(Element, typeof(Agglutinué)); } sr.reloadProgress = 0; } } if (go.GetComponent <Secreter>() != null && go.GetComponent <Secreter>().type.Equals("Toxine")) { Secreter sr = go.GetComponent <Secreter> (); sr.reloadProgress += Time.deltaTime; int NombreMaxSecretionSecreter = sr.NombreMaxSecretion; int NombreActuelleSecreter = sr.NombreActuelle; if (NombreActuelleSecreter == NombreMaxSecretionSecreter) { new WaitForSecondsRealtime(300f); NombreActuelleSecreter = 0; } Bounds SecreteurSize = go.GetComponent <Renderer>().bounds; if (NombreActuelleSecreter < NombreMaxSecretionSecreter && sr.reloadProgress >= sr.reloadTime) { float x = Random.Range(SecreteurSize.min.x - 0.5f, SecreteurSize.max.x + 0.5f); float y = Random.Range(SecreteurSize.min.y - 0.5f, SecreteurSize.max.y + 0.5f); float z = 0.0f; Vector3 ElementPosition = new Vector3(x, y, z); GameObject Element = GameObjectManager.instantiatePrefab(sr.type); Element.transform.position = ElementPosition; NombreActuelleSecreter = NombreActuelleSecreter + 1; sr.reloadProgress = 0; } } } }
// Use to process your families. protected override void onProcess(int familiesUpdateCount) { foreach (GameObject go in _triggeredGO) { bool tokill = false; //On vérifie tous les cas ou on peut mourrir, soit un infection par un virus etc... Infecteur virusC = go.GetComponent <Infecteur> (); HP hp1 = go.gameObject.GetComponentInChildren <HP> (); IsApoptose isApoptose = go.GetComponent <IsApoptose>(); IsAbsorbe isAbsorbe = go.GetComponent <IsAbsorbe> (); IsInfecte infecte = go.GetComponent <IsInfecte> (); Leucocyte leucocyte = go.GetComponent <Leucocyte> (); Secreter secreter = go.GetComponent <Secreter> (); if (virusC != null && virusC.hasInfect) // mort des virus une fois qu'ils ont infecté qlqu'un { Debug.Log("MORT : virus a infecté " + go); tokill = true; //GameObjectManager.destroyGameObject (go); } if (hp1 != null && hp1.hp <= 0) // mort de toute entitées quand elle a plus d'HP { Debug.Log("MORT : plus d'hp " + go); tokill = true; //GameObjectManager.destroyGameObject (go); } if (isApoptose != null) // MORT APOPTOSE { Debug.Log("MORT : apoptose " + go); tokill = true; //GameObjectManager.destroyGameObject (go); } if (isAbsorbe != null) // MORT absorbé { Debug.Log("MORT : absorbé " + go); tokill = true; //GameObjectManager.destroyGameObject (go); } if (leucocyte != null && tokill) { bound = go.GetComponent <Renderer>().bounds; for (int i = 0; i < 3; i++) { float x = Random.Range(bound.min.x - 0.5f, bound.max.x + 0.5f); float y = Random.Range(bound.min.y - 0.5f, bound.max.y + 0.5f); float z = 0.0f; Vector3 toxPosition = new Vector3(x, y, z); vir = GameObjectManager.instantiatePrefab("Dechet"); vir.transform.position = toxPosition; } } if (secreter != null && tokill) { bound = go.GetComponent <Renderer>().bounds; float x = Random.Range(bound.max.x, bound.max.x + 0.5f); float y = Random.Range(bound.max.y, bound.max.y + 0.5f); float z = 0.0f; Vector3 toxPosition = new Vector3(x, y, z); vir = GameObjectManager.instantiatePrefab("Dechet"); //vir.transform.position = toxPosition; } if (infecte != null && isAbsorbe == null && isApoptose == null && tokill) { Debug.Log("dlibere VIrus : absorbé " + go); bound = go.GetComponent <Renderer>().bounds; for (int i = 0; i < 5; i++) { float x = Random.Range(bound.min.x, bound.max.x); float y = Random.Range(bound.min.y, bound.max.y); float z = 0.0f; Vector3 toxPosition = new Vector3(x, y, z); vir = GameObjectManager.instantiatePrefab("Virus"); vir.transform.position = toxPosition; } } if (tokill) { //if(go.gameObject.transform.parent.gameObject) // GameObjectManager.destroyGameObject (go.gameObject.transform.parent.gameObject); //else GameObjectManager.destroyGameObject(go); } } }