Exemplo n.º 1
0
 void OnCollisionEnter2D(Collision2D col)
 {
     if (playerInCar == true && rb.velocity.magnitude > 1)
     {
         //Debug.Log ("CAR COLLIDED WITH " + col.gameObject.name);
         if (col.gameObject.GetComponent <NPCController> () == true)
         {
             NPCController npc = col.gameObject.GetComponent <NPCController> ();
             npc.knockOutNPC();
             //Debug.Log ("Dealt " + Mathf.RoundToInt (100 * rb.velocity.magnitude).ToString () + " Damage to NPC");
             npc.myHealth.dealDamage(Mathf.RoundToInt(100 * rb.velocity.magnitude), true);
         }
         else if (col.gameObject.GetComponent <DoorScript> () == true)
         {
             DoorScript ds = col.gameObject.GetComponent <DoorScript> ();
             ds.largeImpactOnDoor(100);
         }
         else if (col.gameObject.transform.parent != null && col.gameObject.transform.parent.GetComponent <WindowNew> () == true)
         {
             WindowNew wn = col.gameObject.transform.parent.GetComponent <WindowNew> ();
             wn.destroyWindow();
         }
         dealDamage(100);
     }
 }