示例#1
0
        public float GetDamage(SpaceObject target)
        {
            if (target == owner && age < friendlyFireImmunityTime)
                return 0;

            return damage;
        }
示例#2
0
        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);
        }
示例#3
0
 public void OnHitSpaceObject(SpaceObject target)
 {
     if (destroyOnHit)
         OnDestroy();
 }
示例#4
0
 public bool CanHit(SpaceObject target)
 {
     if (target == owner && age < friendlyFireImmunityTime)
         return false;
     return true;
 }