public Action <ICharacterClass, ICondition> GetConditionImplementationApply() { return((characterClass, condition) => { DamageReduction damageReduction = condition as DamageReduction; }); }
public void DamageReductionCanHaveATypeThatBypassTheDefense() { var dr = new DamageReduction("cold iron", 5); Assert.Equal(5, dr.TotalValue); Assert.Equal("cold iron", dr.BypassType); Assert.Equal("5/cold iron", dr.DisplayString()); }
public override string ToString() { var str = new StringBuilder(); str.AppendLine(String.Format("{0}[{1}]", Name, ItemTypeName)); str.AppendLine(ArmorType.ToString().Clean()); str.AppendLine(DamageReduction.ToString()); return(str.ToString()); }
/// <summary> /// RPC callback applying damage to the unit. Sent only to the unit's owner. /// </summary> [RPC] void ApplyDamageRPC(float damage) { if (currentHealth == 0f) { return; } // Decrease the damage using all available protection if (damage > 0f) { for (int i = mProtection.Count; i > 0;) { DamageReduction prot = mProtection[--i]; if (prot == null) { mProtection.RemoveAt(i); } else { damage = prot.OnAbsorbDamage(damage); if (damage == 0f) { break; } } } } // Decrease the hull's health currentHealth = Mathf.Clamp(currentHealth - damage, 0f, maxHealth); if (currentHealth > 0f) { // Inform others of the unit's current health if (NetworkManager.isMultiplayer) { mView.RPC("SetHealthRPC", RPCMode.Others, currentHealth, maxHealth); } } else // Once the health drops below zero, destroy the unit { // Instantiate an explosion prefab if (explosionPrefab != null) { NetworkManager.RemoteInstantiate(explosionPrefab, transform.position, Quaternion.identity, NetworkManager.gameChannel); } // Destroy this unit NetworkManager.RemoteDestroy(gameObject); } }
/// <summary> /// List sorting function. /// </summary> static int SortProtection(DamageReduction a, DamageReduction b) { if (a.layer < b.layer) { return(-1); } if (a.layer > b.layer) { return(1); } return(0); }
public void Initialize(ComponentContainer components) { sorcererLevels = components.Get <ClassLevel>(); coldResistance = new EnergyResistance(5, "cold"); nonLethal = new DamageReduction("- vs. nonlethal", 0); nonLethal.AddModifier(new DelegateStatModifier( nonLethal.Name, "level-up", () => { return(sorcererLevels.Level >= 9 ? 10 : 5); } )); components.Add(coldResistance); components.Add(nonLethal); }
public void RefreshMinLevelBindings() { Attack.RefreshPropertyBinding(nameof(Attack.MinValue)); CriticalDamage.RefreshPropertyBinding(nameof(CriticalDamage.MinValue)); CriticalChance.RefreshPropertyBinding(nameof(CriticalChance.MinValue)); AttackSpeed.RefreshPropertyBinding(nameof(AttackSpeed.MinValue)); Health.RefreshPropertyBinding(nameof(Health.MinValue)); Shields.RefreshPropertyBinding(nameof(Shields.MinValue)); DefensiveEssence.RefreshPropertyBinding(nameof(DefensiveEssence.MinValue)); DamageReduction.RefreshPropertyBinding(nameof(DamageReduction.MinValue)); Mining.RefreshPropertyBinding(nameof(Mining.MinValue)); Kills.RefreshPropertyBinding(nameof(Kills.MinValue)); Veterancy.RefreshPropertyBinding(nameof(Veterancy.MinValue)); Acceleration.RefreshPropertyBinding(nameof(Acceleration.MinValue)); }
/// <summary> /// List sorting function. /// </summary> static int SortProtection(DamageReduction a, DamageReduction b) { if (a.layer < b.layer) return -1; if (a.layer > b.layer) return 1; return 0; }
public void SometimesNoTypeWillBypassDefense() { var dr = new DamageReduction(1); Assert.Equal("1/-", dr.DisplayString()); }