Exemplo n.º 1
0
    void  OnTriggerEnter2D(Collider2D other)
    {
        if (other.tag == "Finish" && iamIlive == true)
        {
            Instantiate(fire_magic, transform.position, Quaternion.identity);
            iamIlive = false;
            anim.SetInteger("animstate", 2);

            //play sound of dead
            pl_s_enmy.Dead();

            Destroy(gameObject);
            Destroy(other.gameObject);
        }



        if (other.tag == "Finish1" && iamIlive == true)
        {
            iamIlive = false;

            //play sound of dead
            pl_s_enmy.Dead();

            this.GetComponent <CircleCollider2D>().enabled = false;
            this.GetComponent <BoxCollider2D>().enabled    = false;
            this.GetComponent <Rigidbody2D>().gravityScale = 0f;
            this.GetComponent <Rigidbody2D>().mass         = 0f;


            player_Standing = false;
            iam_die         = true;
            if (!clone.activeInHierarchy)
            {
                clone.transform.position = transform.position;
                clone.SetActive(true);
                clone.transform.parent = this.transform;
            }
            anim.SetInteger("animstate", 2);
            Destroy(gameObject, 2);
            Destroy(other.gameObject);
        }
    }
Exemplo n.º 2
0
    void  OnTriggerEnter2D(Collider2D other)
    {
        if (other.tag == "Finish" && iamIlive == true)
        {
            Instantiate(fire_magic, transform.position, Quaternion.identity);
            iamIlive = false;
            anim.SetInteger("animstate", 2);
            pl_s_enmy.Dead();


            folowNow = false;
            for (int i = 0; i < Random.Range(2, 6); i++)
            {
                var t = transform;
                t.TransformPoint(0, -100, 0);

                GameObject floss = (GameObject)Instantiate(coin, t.position, Quaternion.identity);

                var body2d = floss.GetComponent <Rigidbody2D>();
                body2d.AddForce(Vector3.up * Random.Range(3000, 5000));
                body2d.AddForce(Vector3.right * Random.Range(-1000, 1000));
            }
            GameObject etem = etems[Random.Range(0, etems.Length)];
            GameObject kass = (GameObject)Instantiate(etem, transform.position, Quaternion.identity);
            kass.GetComponent <Rigidbody2D>().AddForce(Vector2.up * 2000);
            Destroy(gameObject);
            Destroy(other.gameObject);
        }



        if (other.tag == "Finish1" && iamIlive == true)
        {
            Destroy(other.gameObject);
            pl_s_enmy.Dead();

            this.GetComponent <CircleCollider2D>().enabled = false;
            this.GetComponent <BoxCollider2D>().enabled    = false;
            this.GetComponent <Rigidbody2D>().gravityScale = 0f;
            this.GetComponent <Rigidbody2D>().mass         = 0f;

            iamIlive = false;
            anim.SetInteger("animstate", 2);
            //bash nhaydo dm mn haieraki
            if (!clone.activeInHierarchy)
            {
                clone.transform.position = transform.position;
                clone.SetActive(true);
                clone.transform.parent = this.transform;
            }

            Destroy(gameObject, 2);
            folowNow = false;
            for (int i = 0; i < Random.Range(2, 6); i++)
            {
                var t = transform;
                t.TransformPoint(0, -100, 0);

                GameObject floss = (GameObject)Instantiate(coin, t.position, Quaternion.identity);

                var body2d = floss.GetComponent <Rigidbody2D> ();
                body2d.AddForce(Vector3.up * Random.Range(3000, 5000));
                body2d.AddForce(Vector3.right * Random.Range(-1000, 1000));
            }
            GameObject etem = etems[Random.Range(0, etems.Length)];
            GameObject kass = (GameObject)Instantiate(etem, transform.position, Quaternion.identity);
            kass.GetComponent <Rigidbody2D> ().AddForce(Vector2.up * 2000);
        }
    }