Beispiel #1
0
 private void OnCollisionEnter(Collision col)
 {
     if (hit == false)
     {
         hit = true;
         if (col.gameObject.CompareTag("Stage") || col.gameObject.CompareTag("Wall"))
         {
             bounceAble--;
             if (bounceAble < 0)
             {
                 DestroyBullet(this.gameObject);
             }
             else
             {
                 SEManager.PlayBounceBulletSound();
             }
         }
         if (col.gameObject.CompareTag("DestroyableObject"))
         {
             DestroyByAttack dos = col.gameObject.GetComponent <DestroyByAttack>();
             dos.hitBullet();
             DestroyBullet(this.gameObject);
         }
         if (col.gameObject.CompareTag("Bullet") || col.gameObject.CompareTag("EnemyBullet") || col.gameObject.CompareTag("SpecialBullet"))
         {
             DestroyBullet(this.gameObject);
         }
         if (col.gameObject.CompareTag("Enemy"))
         {
             //Debug.Log(col.gameObject);
             try
             {
                 if (!shooterHitAble && shooterTank.GetInstanceID() == col.gameObject.GetInstanceID())
                 {
                     Debug.Log("発射直後の自分の弾に当たろうとした");
                 }
                 else
                 {
                     this.DestroyEnemy(col.gameObject);
                 }
             }
             catch (NullReferenceException e)
             {
                 Debug.Log(e);
             }
         }
         if (col.gameObject.CompareTag("Player"))
         {
             try
             {
                 if (!shooterHitAble && shooterTank.GetInstanceID() == col.gameObject.GetInstanceID())
                 {
                     Debug.Log("発射直後の自分の弾に当たろうとした");
                 }
                 else
                 {
                     this.PlayerDestroy(col.gameObject);
                 }
             }
             catch (NullReferenceException e)
             {
                 Debug.Log(e);
             }
         }
     }
 }