コード例 #1
0
 private void ProcessHit(DamageDealer damageDealer)
 {
     current_health -= damageDealer.GetDamage();
     UnityFunctions.CameraShake();
     damageDealer.Hit();
     if (current_health <= 0)
     {
         current_health = 0;
     }
     this.SendAlert(enum_status.Danger, this.name + " is taking Damage!");
 }
コード例 #2
0
    public void DamageShip(float damage_f = 0)
    {
        Rigidbody2D rb = GetComponentInParent <Rigidbody2D>();

        if (damage_f > 0)
        {
            //************************
            //Shake camera if dieectly
            //************************
            UnityFunctions.CameraShake();
            this.current_health -= damage_f * total_upgrade_damage_resistance;
        }
        else
        {
            float kernetic_energy1 = UnityFunctions.Calc_Kinetic_Energy(rb);
            //*****************************************
            //Shake camera if we are hit by a explosion
            //*****************************************
            UnityFunctions.CameraShake(0.2f, (kernetic_energy1 * 0.05f));
            this.current_health -= (kernetic_energy1 * 0.05f) * total_upgrade_damage_resistance;
        }
        this.SendAlert(enum_status.Danger, this.name + " is taking Damage!");
    }