Esempio n. 1
0
    // Visualizacion sobre el recorrido que toma los zombie y los aldeanos

    IEnumerator Sateliteorbital()
    {
        zombie   = GameObject.FindGameObjectsWithTag("Zombie");
        aldeanos = GameObject.FindGameObjectsWithTag("Villager");
        // Informacion necesario sobre el aldeano
        foreach (GameObject item in aldeanos)
        {
            yield return(new WaitForEndOfFrame());

            villa.Ciudadanos componenteAldeano = item.GetComponent <villa.Ciudadanos>();
            if (componenteAldeano != null)
            {
                distanciaInical = Mathf.Sqrt(Mathf.Pow((item.transform.position.x - transform.position.x), 2) + Mathf.Pow((item.transform.position.y - transform.position.y), 2) + Mathf.Pow((item.transform.position.z - transform.position.z), 2));
                if (distanciaInical < 5f)
                {
                    tiempo                = 0;
                    informacionAldeano    = item.GetComponent <villa.Ciudadanos>().informacionAldeano;
                    TextodelVillager.text = "Hola soy un " + informacionAldeano.nombre + " y he cumpido " + informacionAldeano.edad.ToString() + " años";
                }
                if (tiempo > 3)
                {
                    TextodelVillager.text = " ";
                }
            }
        }
        //Datos necesarios sobre el Zombie.
        foreach (GameObject itemZ in zombie)
        {
            yield return(new WaitForEndOfFrame());

            zom.Zombie componenteZombie = itemZ.GetComponent <zom.Zombie>();
            if (componenteZombie != null)
            {
                distanciaFinal = 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 (distanciaFinal < 5f)
                {
                    tiempo              = 0;
                    informacionZombie   = itemZ.GetComponent <zom.Zombie>().informacionZombie;
                    TextodelZombie.text = "Grrrrrrrrrrrr Comida, comidaaaaa Grrr " + informacionZombie.gusto;
                }
                if (tiempo > 3)
                {
                    TextodelZombie.text = " ";
                }
            }
        }
        yield return(new WaitForSeconds(0.1f));

        StartCoroutine(Sateliteorbital());
    }
Esempio n. 2
0
            // Se le otorga toda la información necesaria al zombie
            void Start()
            {
                if (!enemigoss)
                {
                    edad = (int)Random.Range(15, 101);
                    informacionZombie = new InformaciondelZombie();
                    color             = Random.Range(0, 3);
                    Rigidbody Zom;
                    Zom                  = this.gameObject.AddComponent <Rigidbody>();
                    Zom.constraints      = RigidbodyConstraints.FreezeAll;
                    Zom.useGravity       = false;
                    this.gameObject.name = "Zombie";
                }
                else
                {
                    edad = informacionZombie.edad;
                    this.gameObject.name = informacionZombie.nombre;
                }
                StartCoroutine(buscaAldeanos());
                velocidadseguir     = 10 / edad;
                this.gameObject.tag = "Zombie";
                Sabor Sabor;

                Sabor = (Sabor)Random.Range(0, 5);
                gusto = Sabor.ToString();
                informacionZombie.gusto = gusto;
                if (color == 0)
                {
                    this.gameObject.GetComponent <Renderer>().material.color = UnityEngine.Color.cyan;
                }
                if (color == 1)
                {
                    this.gameObject.GetComponent <Renderer>().material.color = UnityEngine.Color.magenta;
                }
                if (color == 2)
                {
                    this.gameObject.GetComponent <Renderer>().material.color = UnityEngine.Color.green;
                }
            }