public void OnCollisionEnter(Collision col) { //Debug.Log("GunBulletCollisionHandler:OnCollisionEnter() - (" + col.gameObject.tag + ") transform.position = " + transform.position); float damage = objController.damage; if (col.gameObject.tag == "Projectile") { EnemyMissileController enemy = col.gameObject.GetComponent <EnemyMissileController>(); if (enemy != null) { enemy.TakeDamage(damage); GameInfoManager.Instance.IncrementDamageDealt(damage); GameInfoManager.Instance.IncrementScore(); GameInfoManager.Instance.IncrementEnemyMissilesHit(); } } else if (col.gameObject.tag == "EnemyPlane") { EnemyPlaneController enemy = col.gameObject.GetComponent <EnemyPlaneController>(); if (enemy != null) { enemy.TakeDamage(damage); GameInfoManager.Instance.IncrementDamageDealt(damage); GameInfoManager.Instance.IncrementScore(); } } objController.ExpireMe(); }
public virtual void OnCollisionEnter(Collision col) { //Debug.Log("MissileCollisionHandler:OnCollisionEnter() - (" + col.gameObject.tag + ") transform.position = " + transform.position); float damage = controller.damage; if (col.gameObject.tag == "Projectile") { EnemyMissileController enemy = col.gameObject.GetComponent <EnemyMissileController>(); if (enemy != null) { float proximity = (transform.position - enemy.transform.position).magnitude; float effect = 1 - (proximity / controller.damageRadius); float damageAmount = (damage * effect); damageAmount = Mathf.Clamp(damageAmount, 1.0f, damage); enemy.TakeDamage(damage); GameInfoManager.Instance.IncrementDamageDealt(damage); GameInfoManager.Instance.IncrementScore(); GameInfoManager.Instance.IncrementEnemyMissilesHit(); } } else if (col.gameObject.tag == "EnemyPlane") { EnemyPlaneController enemy = col.gameObject.GetComponent <EnemyPlaneController>(); if (enemy != null) { float proximity = (transform.position - enemy.transform.position).magnitude; float effect = 1 - (proximity / controller.damageRadius); float damageAmount = (damage * effect); damageAmount = Mathf.Clamp(damageAmount, 1.0f, damage); enemy.TakeDamage(damage); GameInfoManager.Instance.IncrementDamageDealt(damage); GameInfoManager.Instance.IncrementScore(); } } controller.ExpireMe(); }