예제 #1
0
 void OnCollisionEnter2D(Collision2D coll)
 {
     if (coll.gameObject.tag == "PlayerBullet")
     {
         BulletScript bullet = coll.gameObject.GetComponent <BulletScript> ();
         currentHealth -= bullet.damage;
         Vector3 damagePosition = new Vector3(transform.position.x,
                                              transform.position.y + GetComponent <SpriteRenderer> ().sprite.bounds.extents.y,
                                              transform.position.z);
         bullet.DisplayDamage(damagePosition);
     }        /* else if (coll.gameObject.tag == "Player" && (Time.time-lastDamageTime > damageDelay)) {
               *     PlatformerCharacter2D player = coll.gameObject.GetComponent<PlatformerCharacter2D>();
               *     player.TakeDamage (damage);
               *     lastDamageTime = Time.time;
               * }*/
 }
예제 #2
0
 void OnCollisionEnter2D(Collision2D coll)
 {
     if (coll.gameObject.tag == "PlayerBullet")
     {
         BulletScript bullet = coll.gameObject.GetComponent <BulletScript> ();
         currentHealth -= bullet.damage;
         Vector3 damagePosition = new Vector3(transform.position.x,
                                              transform.position.y - GetComponentInChildren <SpriteRenderer> ().sprite.bounds.extents.y,
                                              transform.position.z);
         bullet.DisplayDamage(damagePosition, true);
     }
     else if (coll.gameObject.tag == "Player")
     {
         PlayerScript player = coll.gameObject.GetComponent <PlayerScript>();
         player.TakeDamage(meleeDamage);
     }
 }