void Start() { if (!infectado) { años = Random.Range(15, 101); info_Zomb = new Info_Zomb(); asigna = Random.Range(0, 3); Rigidbody Zom; Zom = gameObject.AddComponent <Rigidbody>(); Zom.constraints = RigidbodyConstraints.FreezeAll; Zom.useGravity = false; gameObject.name = "Zombie"; } else { años = info_Zomb.años; gameObject.name = info_Zomb.apodo; } StartCoroutine(localizar_Ald()); Daño = GameObject.FindGameObjectWithTag("Hero").GetComponent <Hero>(); vel_Persecucion = 10 / años; this.gameObject.tag = "Zombie"; Extremidades bodyparts; bodyparts = (Extremidades)Random.Range(0, 5); deseo = bodyparts.ToString(); info_Zomb.gusto = deseo; this.gameObject.GetComponent <Renderer>().material.color = Color.magenta; }
IEnumerator BuscaEntidades() { zombie = GameObject.FindGameObjectsWithTag("Zombie"); aldeanos = GameObject.FindGameObjectsWithTag("Aldeano"); foreach (GameObject objeto in aldeanos) { yield return(new WaitForEndOfFrame()); Pueblo.Pueblerino componenteAldeano = objeto.GetComponent <Pueblo.Pueblerino>(); if (componenteAldeano != null) { trecho1 = Mathf.Sqrt(Mathf.Pow((objeto.transform.position.x - transform.position.x), 2) + Mathf.Pow((objeto.transform.position.y - transform.position.y), 2) + Mathf.Pow((objeto.transform.position.z - transform.position.z), 2)); if (trecho1 < 5f) { time = 0; info_Ald = objeto.GetComponent <Pueblo.Pueblerino>().info_Ald; total_Ald.text = "Hola soy un " + info_Ald.apodo + " y he cumpido " + info_Ald.años.ToString() + " años"; } if (time > 3) { total_Ald.text = " "; } } } foreach (GameObject itemZ in zombie) { yield return(new WaitForEndOfFrame()); Zomb.Zombie componenteZombie = itemZ.GetComponent <Zomb.Zombie>(); if (componenteZombie != null) { trecho2 = Mathf.Sqrt(Mathf.Pow((itemZ.transform.position.x - transform.position.x), 2) + Mathf.Pow((itemZ.transform.position.y - transform.position.y), 2) + Mathf.Pow((itemZ.transform.position.z - transform.position.z), 2)); if (trecho2 < 5f) { time = 0; info_Zomb = itemZ.GetComponent <Zomb.Zombie>().info_Zomb; total_Zomb.text = "Grrrrrrrrrrrr Comida, comidaaaaa Grrr " + info_Zomb.sabor; } if (time > 3) { total_Zomb.text = " "; } } } yield return(new WaitForSeconds(0.1f)); StartCoroutine(BuscaEntidades()); }
void Start() { if (!infectado) { años = Random.Range(15, 101); info_Zomb = new Info_Zomb(); color_Zomb = Random.Range(0, 3); Rigidbody infectados; infectados = gameObject.AddComponent <Rigidbody>(); infectados.constraints = RigidbodyConstraints.FreezeAll; infectados.useGravity = false; gameObject.name = "Zombie"; } else { años = info_Zomb.años; gameObject.name = info_Zomb.apodo; } StartCoroutine(localizar_Ald()); vel_Seguir = 10 / años; gameObject.tag = "Zombie"; Deseo Deseo; Deseo = (Deseo)Random.Range(0, 5); deseo = Deseo.ToString(); info_Zomb.sabor = deseo; if (color_Zomb == 0) { gameObject.GetComponent <Renderer>().material.color = Color.magenta; } if (color_Zomb == 1) { gameObject.GetComponent <Renderer>().material.color = Color.green; } if (color_Zomb == 2) { gameObject.GetComponent <Renderer>().material.color = Color.cyan; } }