예제 #1
0
 private void OnCollisionEnter2D(Collision2D collision)
 {
     if (collision.gameObject.tag == "brick" && counter == 0)
     {
         //Destroy(collision.gameObject);
         velo.y  = -velo.y;
         counter = 1;
         brick   = collision.gameObject.GetComponent <BrickController>();;
         brick.SetHitPoints(brick.GetHitPoints() - 1);
     }
     if (counter == 0 && collision.gameObject.tag == "UpperWall")
     {
         velo.y  = -velo.y;
         counter = 1;
     }
     else if (counter == 0 && collision.gameObject.CompareTag("Player"))
     {
         velo.y = -velo.y;
         float deviateValue;
         deviateValue  = transform.position.x - collision.gameObject.transform.position.x;
         deviateValue /= collision.collider.bounds.size.x / 2f;
         deviateValue *= deviateFactor;
         velo.x       += deviateValue;
         counter       = 1;
     }
     if (collision.gameObject.tag == "walls" && counter == 0)
     {
         velo.x = -velo.x;
     }
 }