示例#1
0
    void OnCollisionStay2D(Collision2D coll)
    {
        Vector2 collPos = coll.gameObject.transform.position;
        Vector2 rbPos   = rigid_fire.position;


        if (coll.gameObject.tag == "goomba" || coll.gameObject.tag == "KoopaTroopa")
        {
            gC.add_coin();
            gC.addScore(200);
            gC.subFireCount(1);
            Destroy(coll.gameObject);
            Destroy(this.gameObject);
        }
        foreach (ContactPoint2D hitPos in coll.contacts)
        {
            if (hitPos.normal.y > 0)
            {
                col_bottom = true;
            }

            if (hitPos.normal.x != 0)
            {
                gC.subFireCount(1);
                Destroy(this.gameObject);
            }
        }
    }
示例#2
0
 void Update()
 {
     if (anim.GetCurrentAnimatorStateInfo(0).normalizedTime > 0.4 && !anim.IsInTransition(0))
     {
         rb.velocity = new Vector2(0, 0);
     }
     if (anim.GetCurrentAnimatorStateInfo(0).normalizedTime > 1 && !anim.IsInTransition(0))
     {
         gC.add_coin();
         Destroy(this.gameObject);
     }
 }