Esempio n. 1
0
 void OnCollisionEnter2D(Collision2D col)
 {
     if (col.gameObject.tag == "Obstructcle")
     {
         //add force too gameObject and delete that item
         GameObject  gObj = col.gameObject;
         Obstructcle obs  = gObj.GetComponent <Obstructcle>();
         Vector2     diff = transform.position - gObj.transform.position;
         diff.y = 0;
         if (!IsBoost)
         {
             if (!IsStruggle)
             {
                 Damaged();
                 GameObject hpObj = GameObject.Instantiate(HPNortify) as GameObject;
                 hpObj.SetActive(true);
                 hpObj.transform.position = this.transform.position;
                 hpObj.GetComponent <HPNotification>().DecreaseLife(1);
                 Game4Global.BrokeCombo();
                 Game4Global.DecreaseLife();
             }
             GetComponent <Rigidbody2D>().velocity = Vector2.zero;
             GetComponent <Rigidbody2D>().AddForce(diff * 100);
         }
         else
         {
             GetComponent <Rigidbody2D>().velocity = Vector2.zero;
         }
         obs.Bounce(this.transform.position);
     }
 }
Esempio n. 2
0
 void OnTriggerEnter2D(Collider2D other)
 {
     if (other.tag == "Trash")
     {
         Destroy(this.gameObject);
         if (!IsEat)
         {
             Game4Global.BrokeCombo();
         }
     }
 }