コード例 #1
0
    private void OnTriggerEnter(Collider other)
    {
        if (other.gameObject.CompareTag("Enemy"))
        {
            Rotura rotura = other.gameObject.GetComponent <Rotura>();

            Instantiate(GameController.gamecontroller.particulas, transform.position, transform.rotation);

            rotura.Romper();
        }
        else if (other.gameObject.CompareTag("Player") && enemigo != null)
        {
            Debug.Log("asdasd");
            switch (enemigo)
            {
            case "red":
                GameController.muertescript.ModificarTexto("Te han asesinado");
                break;

            case "yellow":
                GameController.muertescript.ModificarTexto("Has sufrido un accidente");

                break;

            case "blue":
                GameController.muertescript.ModificarTexto("Moriste triste y solo");

                break;

            case "green":
                GameController.muertescript.ModificarTexto("Tus deudas se pagan caras");

                break;

            case "white":
                GameController.muertescript.ModificarTexto("Muerto por sobredosis");

                break;

            case "black":
                GameController.muertescript.ModificarTexto("No soportaste la muerte de tu familia");

                break;

            case "grey":
                GameController.muertescript.ModificarTexto("Una enfermedad ha podido contigo");

                break;
            }
            GameController.imagen2.SetActive(true);
        }
    }
コード例 #2
0
    /// <summary>
    /// Si choca con el enemigo lo mata
    /// </summary>
    /// <param name="collision"></param>
    private void OnCollisionEnter(Collision collision)
    {
        if (collision.gameObject.CompareTag("Enemy") && collision.relativeVelocity.magnitude < 15)
        {
            Rotura rotura = collision.gameObject.GetComponent <Rotura>();

            if (!rotura.enemigo.muerto)
            {
                Instantiate(GameController.gamecontroller.particulas, transform.position, transform.rotation);
            }

            rotura.Romper();
        }
    }