Exemplo n.º 1
0
 private void OnCollisionEnter2D(Collision2D collision)
 {
     if (collision.transform.name == "Enemy")
     {
         Transform tf = collision.transform;
         EnemyUnit eu = tf.GetComponent <EnemyUnit>();
         if (Random.Range(0, 6) == 0)
         {
             eu.Hit(dmgCritical);
         }
         else
         {
             eu.Hit(dmg);
         }
     }
     else if (collision.transform.name == "Player")
     {
         Transform  tf = collision.transform;
         PlayerUnit eu = tf.GetComponent <PlayerUnit>();
         if (Random.Range(0, 6) == 0)
         {
             eu.Hit(dmgCritical);
         }
         else
         {
             eu.Hit(dmg);
         }
     }
     op.Disable(gameObject);
 }