Ejemplo n.º 1
0
        public float GetDamage(SpaceObject target)
        {
            if (target == owner && age < friendlyFireImmunityTime)
                return 0;

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