Esempio n. 1
0
    private void Update()
    {
        caos = Convert.ToInt32(GameManager.instance.CaosActual());

        if (caos >= caosConelqueCambia && !cambio1Vez)
        {
            if (zonas.Length > 0)
            {
                zonas[0].SetActive(false);
            }
            enemigo.CambioPatron(nuevoPuntos);
            cambio1Vez = true;
        }

        if (cambio1Vez && !cambio2vez)
        {
            llegado = enemigo.Hellegado();

            if (llegado)
            {
                if (zonas.Length != 0)
                {
                    zonas[0].SetActive(true);
                }
                enemigo.CambioPatron(fin);
                cambio2vez = true;
            }
        }
    }
Esempio n. 2
0
    private void OnTriggerEnter2D(Collider2D other)
    {
        if (other.tag == "Player")
        {
            RaycastHit2D ray = Physics2D.Raycast(transform.position, other.transform.position - transform.position);
            Debug.DrawRay(transform.position, other.transform.position - transform.position, Color.red, 10f);
            Debug.Log(ray.transform.tag);

            if (!enemigo.activeSelf && ray.transform.tag == "Player")
            {
                GameObject poolSombras = GameObject.Find("SombrasPool");
                GameObject silueta     = Instantiate <GameObject>(sombra, other.transform.position, other.transform.rotation, poolSombras.transform);
                Transform  aux         = silueta.transform;
                GameManager.instance.ReproducirSonido("Seguridad");

                Transform[] rutaNueva = new Transform[rutaPatrulla.Length + 1];
                for (int i = 0; i < rutaPatrulla.Length; i++)
                {
                    rutaNueva[i] = rutaPatrulla[i];
                }
                rutaNueva[rutaNueva.Length - 1] = aux;

                enemigo.SetActive(true);
                movEnemy.CambioPatron(rutaNueva);
            }
        }
    }