public float GetDamage(SpaceObject target) { if (target == owner && age < friendlyFireImmunityTime) return 0; return damage; }
public float GetImpactDamage(SpaceObject target) { // Don't damage other asteroids if (target is Asteroid) return 0; // Play an impact sound var speed = target.GetComponent<Rigidbody2D>().velocity.magnitude; var impactStrength = speed / GameSettings.instance.maxShipSpeed; if (impactStrength > 0) Sounds.PlayOneShot("AsteroidCollision", impactStrength * 2f); // Do damage based on speed if (speed < GameSettings.instance.minImpactDamageSpeed) return 0; return Mathf.Lerp(GameSettings.instance.minAsteroidImpactDamage, GameSettings.instance.maxAsteroidImpactDamage, impactStrength); }
public void OnHitSpaceObject(SpaceObject target) { if (destroyOnHit) OnDestroy(); }
public bool CanHit(SpaceObject target) { if (target == owner && age < friendlyFireImmunityTime) return false; return true; }