Пример #1
0
 private void OnTriggerEnter2D(Collider2D other)
 {
     if (other.gameObject.layer == 12 && Time.time - this.lastTimeHit > this.hitDelay)
     {
         Debug.Log("I'm Hit!");
         ui.Damage();
         Animator.SetBool("HitAnimation", true);
         other.GetComponent <BulletScript>().Hit();
         if (ui.currentHealth == 0)
         {
             Destroy(this.gameObject, 1.0f);
             LevelSel.LevelDone(false);
         }
         this.lastTimeHit = Time.time;
     }
     if (other.gameObject.layer == 13)
     {
         other.GetComponent <PickupScript>().Hit();
         if (ui.currentHealth != 3)
         {
             Debug.Log("I'm Healing!");
             ui.Heal();
         }
     }
     if (other.gameObject.layer == 11)
     {
         Debug.Log("Collision with enemy");
         if (Time.time - this.lastTimeHit > this.hitDelay && other.gameObject.GetComponent <EnemyScript>().alive)
         {
             ui.Damage();
             this.lastTimeHit = Time.time;
             Animator.SetBool("HitAnimation", true);
         }
         if (ui.currentHealth == 0)
         {
             Destroy(this.gameObject, 1.0f);
         }
     }
 }