コード例 #1
0
    void Start()
    {
        nEnemy = Random.Range(5, limiteCreaciones); // DECIDE LA CANTIDAD DE ZOMBIES
        nAlly  = limiteCreaciones - nEnemy;         // CALCULA LAS ITERACIONES FALTANTES
        nAlly  = Random.Range(0, nAlly);            // SEGUN LAS ITERACIONES QUE FALTAN CREA EL RESTO EN ALDEANOS

        nombreAldeano = new string[20] {
            "Brayan", "Omaira", "Carlos", "Jorge", "Omar", "David", "Mr Pickles", "Kim Jo Il", "Kim Il Sun", "Hittler", "Satan", "Javier",
            "José", "Blador", "Cesar", "Augusto", "Sara", "Salome", "Ana", "Jairo"
        };

        Heroe salvacion = new Heroe(heroCube);       // CREA AL HEROE EN ESCENA DEBAJO DE LA DIRECTIONAL LIGHT

        for (int i = 0; i < nEnemy; i++)             // CICLO QUE CREA UN ZOMBIE POR CADA ITERACION
        {
            zombieColor = Random.Range(0, 3);        // DECIDE EL COLOR DEL ZOMBIE INVOCADO
            Zombie muerto = new Zombie(zombieColor); // CONSTRUCTOR QUE CREA AL ZOMBIE
        }

        for (int i = 0; i < nAlly; i++)                       // CICLO QUE CREA UN ALDEANO POR CADA ITERACION
        {
            pNombre       = Random.Range(0, 20);              // DECIDE AL AZAR EL NOMBRE DEL ALDEANO
            aldeanoNombre = nombreAldeano[pNombre];
            pEdad         = Random.Range(15, 100);            // DECIDE AL AZAR LA EDAD DEL ALDEANO

            Aldeano vivo = new Aldeano(aldeanoNombre, pEdad); // CONSTRUCTOR QUE CREA AL ALDEANO
        }
    }
コード例 #2
0
ファイル: Movimiento.cs プロジェクト: DanCG002/Taller2
 void OnCollisionEnter(Collision collision)
 {
     if (collision.collider.GetComponent <Aldeano>())
     {
         Aldeano c = collision.collider.GetComponent <Aldeano>();
         Debug.Log("Mi Nombre es :" + c.ObtenerCiudadanoInf().apodo + " y tengo " + c.ObtenerCiudadanoInf().años + " años");
     }
     if (collision.collider.GetComponent <Zombie>())
     {
         Zombie z = collision.collider.GetComponent <Zombie>();
         Debug.Log(" warrrrrrrr Soy un zombie y me gusta " + z.ObtenerZombieInfo().extremidad);
     }
 }
コード例 #3
0
 public void OnCollisionEnter(Collision collision)
 {
     /// si este game object coliciona con otro que tenga la tag Aldeano, va a imprimir por consola los respectivos datos del Aldeano
     if (collision.gameObject.tag == "Aldeano")
     {
         a = collision.gameObject.GetComponent <Aldeano>();
         Debug.Log("Hola soy " + a.villagerData.nombre + " y tengo " + a.villagerData.edad + " años");
     }
     /// si este game object coliciona con otro que tenga la tag Zombie, va a imprimir por consola los respectivos datos del Zombie
     if (collision.gameObject.tag == "Zombie")
     {
         z = collision.gameObject.GetComponent <Zombie>();
         Debug.Log("Waaaarrrr quiero comer " + z.zombieDatos.gusto);
     }
 }
コード例 #4
0
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.Mouse0))
        {
            seleccion1 = CheckHitMouse();
        }
        if (seleccion1 != null && Input.GetKeyDown(KeyCode.Mouse1))
        {
            seleccion2 = CheckHitMouse();
            if (seleccion1 != null && seleccion1.tag == "Aldeano" && seleccion2 != null && (seleccion2.tag == "Piso" || seleccion2.tag == "Pasto"))
            {
                RaycastHit hit;
                Ray        ray = Camera.main.ScreenPointToRay(Input.mousePosition);
                if (Physics.Raycast(ray, out hit, range))
                {
                    auxPosition = hit.point;
                }
            }
        }

        if (seleccion1 != null && seleccion2 != null)
        {
            if (seleccion1.tag == "Aldeano" && seleccion2.tag == "Mineral")
            {
                seleccion1.GetComponent <Aldeano>().SetObjetivoTrabajo(seleccion2);
                seleccion1.GetComponent <Aldeano>().trabajo = "Minar";
                seleccion1 = null;
                seleccion2 = null;
            }
            else if (seleccion1.tag == "Aldeano" && (seleccion2.tag == "Centro Urbano" || seleccion2.tag == "Deposito Minero"))
            {
                Aldeano aldeano = seleccion1.GetComponent <Aldeano>();
                if (aldeano != null && aldeano.GetOro() > 0)
                {
                    aldeano.GetComponent <Aldeano>().SetObjetivoTrabajo(seleccion2);
                    aldeano.GetComponent <Aldeano>().trabajo = "Llevar Oro";
                }
                else
                {
                    aldeano.GetComponent <Aldeano>().SetObjetivoTrabajo(seleccion2);
                    aldeano.GetComponent <Aldeano>().trabajo = "Mover Aldeano";
                }
                seleccion1 = null;
                seleccion2 = null;
            }
            else if (seleccion1.tag == "Aldeano" && (seleccion2.tag == "Piso" || seleccion2.tag == "Pasto"))
            {
                Aldeano aldeano     = seleccion1.GetComponent <Aldeano>();
                string  currentWork = aldeano.trabajo;
                if (currentWork == "Mover Aldeano")
                {
                    if (aldeano.GetObjetivoTrabajo() != null && aldeano.GetObjetivoTrabajo().tag == "Destruible")
                    {
                        Destroy(aldeano.GetObjetivoTrabajo());
                        aldeano.FinishPath();
                    }
                }
                aldeano.SetObjetivoTrabajo(Instantiate(auxObject, auxPosition, Quaternion.identity, auxParents.transform));
                aldeano.trabajo = "Mover Aldeano";
                seleccion1      = null;
                seleccion2      = null;
            }
        }
    }