protected virtual void Update() { if (damage == true) { if (cachedDamage == null) { cachedDamage = GetComponent <D2dDamage>(); } if (cachedDamage != null) { if (cachedDamage.Damage >= damageRequired) { // Fracturing will clone the current damageRequired value, so halve in now in case it gets split, and revert if it wasn't split var oldDamageRequired = damageRequired; damageRequired = cachedDamage.Damage * damageMultiplier; if (TryFracture() == false) { damageRequired = oldDamageRequired; } } } } }
private bool CheckMet() { if (damage == true) { if (cachedDamage == null) { cachedDamage = GetComponent <D2dDamage>(); } if (cachedDamage != null) { if (cachedDamage.Damage < damageMin || cachedDamage.Damage >= damageMax) { return(false); } } } if (alphaCount == true) { if (cachedDestructible == null) { cachedDestructible = GetComponent <D2dDestructible>(); } if (cachedDestructible != null) { if (cachedDestructible.AlphaCount < alphaCountMin || cachedDestructible.AlphaCount >= alphaCountMax) { return(false); } } } if (alphaRatio == true) { if (cachedDestructible == null) { cachedDestructible = GetComponent <D2dDestructible>(); } if (cachedDestructible != null) { if (cachedDestructible.AlphaRatio < alphaRatioMin || cachedDestructible.AlphaRatio >= alphaRatioMax) { return(false); } } } return(true); }
protected virtual void OnEnable() { if (cachedCollisionHandler == null) { cachedCollisionHandler = GetComponent <D2dCollisionHandler>(); } if (cachedDamage == null) { cachedDamage = GetComponent <D2dDamage>(); } cachedCollisionHandler.OnOverlap += Overlap; }