예제 #1
0
        /// <summary>
        /// Damage this damageable.
        /// </summary>
        /// <param name="damage">The damage amount.</param>
        /// <param name="hitPoint">The world position where the damage occurred.</param>
        public virtual void Damage(float damage, Vector3 hitPoint, HealthModifierType healthModifierType, Transform damageSourceRootTransform)
        {
            if (destroyed)
            {
                return;
            }

            if (isDamageable)
            {
                // Reduce the health
                currentHealth -= damage;

                // Destroy
                if (currentHealth <= 0)
                {
                    currentHealth = 0;
                    Destroy();
                }
                // Damage
                else
                {
                    // Call the damage event
                    onDamaged.Invoke(damage, hitPoint, healthModifierType, damageSourceRootTransform);
                }
            }
        }
예제 #2
0
        /// <summary>
        /// Heal this damageable.
        /// </summary>
        /// <param name="healing">The healing amount.</param>
        /// <param name="hitPoint">The world position where the healing occurred.</param>
        public virtual void Heal(float healing, Vector3 hitPoint, HealthModifierType healthModifierType, Transform damageSourceRootTransform)
        {
            if (destroyed)
            {
                return;
            }

            if (isHealable)
            {
                // Add the health
                currentHealth = Mathf.Clamp(currentHealth + healing, 0, healthCapacity);

                // Update the container status
                if (currentHealth > 0 && destroyed && canHealAfterDestroyed)
                {
                    Restore(false);
                }

                onHealed.Invoke(healing, hitPoint, healthModifierType, damageSourceRootTransform);
            }
        }
예제 #3
0
 protected virtual void OnDamageableModuleHealed(float healing, Vector3 hitPoint, HealthModifierType healthModifierType, Transform damageSourceRootTransform)
 {
     onDamageableModuleHealed.Invoke(healing, hitPoint, healthModifierType, damageSourceRootTransform);
 }
예제 #4
0
 /// <summary>
 /// Heal this damageable.
 /// </summary>
 /// <param name="healing">The healing amount.</param>
 /// <param name="hitPoint">The world position where the healing occurred.</param>
 public virtual void Heal(float healing, Vector3 hitPoint, HealthModifierType healthModifierType, Transform damageSourceRootTransform)
 {
     onHealed.Invoke(healing, hitPoint, healthModifierType, damageSourceRootTransform);
 }
예제 #5
0
 /// <summary>
 /// Damage this damageable.
 /// </summary>
 /// <param name="damage">The damage amount.</param>
 /// <param name="hitPoint">The world position where the damage occurred.</param>
 public virtual void Damage(float damage, Vector3 hitPoint, HealthModifierType healthModifierType, Transform damageSourceRootTransform)
 {
     onDamaged.Invoke(damage, hitPoint, healthModifierType, damageSourceRootTransform);
 }
예제 #6
0
 /// <summary>
 /// Called when the shield is healed;
 /// </summary>
 /// <param name="healValue">The amount of healing.</param>
 /// <param name="hitPosition">World space hit position.</param>
 public virtual void OnHealed(float healValue, Vector3 hitPosition, HealthModifierType healthModifierType, Transform damageSourceRootTransform)
 {
     ShowEffect(healValue * healEffectMultiplier, hitPosition, healEffectColor);
 }