Exemplo n.º 1
0
    // Use this for initialization
    void Start()
    {
        barravida = GameObject.Find("barravida");
        Player    = GameObject.FindGameObjectWithTag("Player");
        spr       = Player.GetComponent <SpriteRenderer>();

        Enemy  = GameObject.FindGameObjectWithTag("Enemy");
        Enemy2 = GameObject.FindGameObjectWithTag("Enemy2");
        Enemy3 = GameObject.FindGameObjectWithTag("Enemy3");
        Enemy4 = GameObject.FindGameObjectWithTag("Enemy4");
        Vida   = GameObject.FindGameObjectWithTag("Vida");

        player1 = Player.GetComponent <Rigidbody2D>();
        enemy1  = Enemy.GetComponent <Rigidbody2D>();

        player = Player.GetComponent <Animator>();

        playercontroller = GameObject.FindGameObjectWithTag("Player").GetComponent <PlayerController>();
        rango            = GameObject.Find("Zombie1").GetComponent <Rango>();
        playerattack     = GameObject.FindGameObjectWithTag("Player").GetComponent <PlayerAttack>();
        bebe             = GameObject.Find("Bebe1").GetComponent <Bebe>();
        pod = GameObject.Find("ZombiePodrido").GetComponent <ZombiePodrido>();

        GameControl.veces_morir++;

        Analytics.CustomEvent("muerte", new Dictionary <string, object>
        {
            { "nivel", GameControl.nivel },
            { "posicion_level_4", Player.transform.position.x },
            { "cantidad", GameControl.veces_morir },
        });

        barravida.SetActive(true);
    }
Exemplo n.º 2
0
    public void TakeDamage(float amount)
    {
        hp = Mathf.Clamp(hp - amount, 0f, maxHp);
        vida.transform.localScale = new Vector2(hp / maxHp, 1);

        Invoke("Colore", 0.3f);

        Player.GetComponent <SpriteRenderer>().color = Color.red;

        if (vida.transform.localScale.x == 0)

        {
            perder.SetActive(true);

            foreach (GameObject Zombie1 in Enemy)
            {
                anim2  = Zombie1.GetComponent <Animator>();
                enemy1 = Zombie1.GetComponent <Rigidbody2D>();
                rango  = Zombie1.GetComponent <Rango>();

                anim2.SetBool("Ataque", false);
                anim2.SetBool("DentrodelRango", false);


                rango.enabled = false;

                Zombie1.GetComponent <BoxCollider2D>().enabled  = false;
                enemy1.GetComponent <Rigidbody2D>().constraints = RigidbodyConstraints2D.FreezeAll;
            }

            foreach (GameObject Bebe1 in Enemy2)
            {
                bebeanim = Bebe1.GetComponent <Animator>();
                bebe1    = Bebe1.GetComponent <Rigidbody2D>();
                bebe     = Bebe1.GetComponent <Bebe>();

                bebeanim.SetBool("Ataque", false);
                bebeanim.SetBool("DentrodelRango", false);

                bebe.enabled = false;

                Bebe1.GetComponent <BoxCollider2D>().enabled   = false;
                bebe1.GetComponent <Rigidbody2D>().constraints = RigidbodyConstraints2D.FreezeAll;
            }

            foreach (GameObject Rugbier1 in Enemy3)
            {
                rugbanim = Rugbier1.GetComponent <Animator>();
                rugbier1 = Rugbier1.GetComponent <Rigidbody2D>();
                rugbier  = Rugbier1.GetComponent <Rugbier>();

                rugbanim.SetBool("Ataque", false);
                rugbanim.SetBool("DentrodelRango", false);

                Rugbier1.GetComponent <BoxCollider2D>().enabled   = false;
                rugbier1.GetComponent <Rigidbody2D>().constraints = RigidbodyConstraints2D.FreezeAll;
            }

            foreach (GameObject ZombiePodr in Enemy4)
            {
                podanim = ZombiePodr.GetComponent <Animator>();
                pod     = ZombiePodr.GetComponent <ZombiePodrido>();

                podanim.SetBool("Ataque", false);
                podanim.SetBool("DentrodelRango", false);

                pod.enabled = false;
            }



            anim.SetBool("Dead", true);
            anim.SetBool("Revivir", false);

            playercontroller.enabled = false;
            playerattack.enabled     = false;

            player.GetComponent <Rigidbody2D>().constraints = RigidbodyConstraints2D.FreezeAll;
        }
    }