///<summary> ///Adds a Strength to the BattleEntity. ///</summary> ///<param name="physAttribute">The PhysicalAttribute the BattleEntity is strong against.</param> ///<param name="strengthHolder">The data for the Strength.</param> public void AddStrength(PhysicalAttributes physAttribute, StrengthHolder strengthHolder) { if (HasStrength(physAttribute) == false) { Strengths.Add(physAttribute, new List <StrengthHolder>()); } Strengths[physAttribute].Add(strengthHolder); Debug.Log($"Added strength value of {strengthHolder.Value} to {Entity.Name} for the {physAttribute} PhysicalAttribute!"); }
/// <summary> /// Retrieves the total Strength this BattleEntity has against all PhysicalAttributes found on a victim. /// </summary> /// <param name="attacker">The BattleEntity this one is attacking.</param> /// <returns>A StrengthHolder with information about how much additional damage this BattleEntity will do to the victim.</returns> public StrengthHolder GetTotalStrength(BattleEntity victim) { StrengthHolder totalStrength = StrengthHolder.Default; PhysicalAttributes[] victimAttributes = victim.EntityProperties.GetAllPhysAttributes(); for (int i = 0; i < victimAttributes.Length; i++) { StrengthHolder attributeStrength = GetStrength(victimAttributes[i]); totalStrength.Value += attributeStrength.Value; } return(totalStrength); }
/// <summary> /// Gets this entity's total strength to a particular PhysicalAttribute. /// </summary> /// <param name="physAttribute">The PhysicalAttribute to test a strength towards.</param> /// <returns>A copy of the StrengthHolder associated with the element if found, otherwise default strength data.</returns> private StrengthHolder GetStrength(PhysicalAttributes physAttribute) { if (HasStrength(physAttribute) == false) { //Debug.Log($"{Entity.Name} does not have a strength for {physAttribute}"); return(StrengthHolder.Default); } StrengthHolder strengthHolder = default(StrengthHolder); //Get the total strength Strengths[physAttribute].ForEach((strength) => { strengthHolder.Value += strength.Value; }); return(strengthHolder); }
/// <summary> /// Removes a Strength from the BattleEntity. /// </summary> /// <param name="physAttribute">The PhysicalAttribute the BattleEntity is strong against.</param> public void RemoveStrength(PhysicalAttributes physAttribute, StrengthHolder strengthHolder) { if (HasStrength(physAttribute) == false) { Debug.LogWarning($"{Entity.Name} does not have a strength for {physAttribute}"); return; } bool removed = Strengths[physAttribute].Remove(strengthHolder); if (Strengths[physAttribute].Count == 0) { Strengths.Remove(physAttribute); } if (removed == true) { Debug.Log($"Removed strength value of {strengthHolder.Value} from the {physAttribute} PhysicalAttribute on {Entity.Name}!"); } }
protected override void OnCalculate(InteractionParamHolder damageInfo, InteractionResult curResult, ContactResultInfo curContactResult) { StrengthHolder totalStrength = StepResult.AttackerResult.Entity.EntityProperties.GetTotalStrength(StepResult.VictimResult.Entity); StepResult.VictimResult.TotalDamage += totalStrength.Value; }