Exemplo n.º 1
0
 void OnCollisionEnter2D(Collision2D col)
 {
     if (col.gameObject.GetComponent <PlayerController>() != null && !dead)
     {
         SoundManager.instance.RandomSfx(hornSound);
         if (!beenHitByPlayer)
         {
             StatsManager.instance.vehiclesDamaged++;
             beenHitByPlayer = true;
         }
         bubble.SayPreparedMessage(SpeechBubbleController.PreparedMessage.HITVEH);
         damaged = true;
         int damage = Mathf.RoundToInt(damageConstant * col.relativeVelocity.magnitude);
         health -= damage;
         if (health > 0)
         {
             StartCoroutine("Recover");
         }
         else
         {
             StopCoroutine("FollowPath");
             StatsManager.instance.vehiclesTotalled++;
             bubble.SayPreparedMessage(SpeechBubbleController.PreparedMessage.KILLVEH);
             dead = true;
         }
     }
 }
Exemplo n.º 2
0
 void OnTriggerEnter2D(Collider2D col)
 {
     if (col.gameObject.GetComponent <AIPedestrianController>() != null)
     {
         return;
     }
     if (col.name.StartsWith("Tilemap"))
     {
         return;
     }
     if (alive && col.gameObject.GetComponent <PlayerController>() != null)
     {
         SoundManager.instance.RandomSfx(splatSound);
         StatsManager.instance.pedestriansHit++;
         MessageManager.instance.SayPreparedMessage(MessageManager.PreparedMessage.KILL, 5);
         bubble.SayPreparedMessage(SpeechBubbleController.PreparedMessage.KILLPED);
     }
     anim.SetBool("Alive", false);
     alive = false;
 }