// 造成伤害 public static void ApplyDamage(BattleUnit caster, BattleUnit victim, AbilityDamageType damageType, AbilityDamageFlag damageFlag, AbilityValueSource damageValueSource, string configName) { int casterLevel = caster.GetLevel(); BattleProperty casterProperty = caster.GetProperty(); BattleProperty victimProperty = victim.GetProperty(); float abilityValue = damageValueSource.GetAbilityValue(casterLevel, casterProperty, victimProperty); float finalDamage = CalcDamageByDamageType(abilityValue, damageType, casterProperty, victimProperty); // 护盾 // 吸血 victim.UpdateHP(-finalDamage); BattleLog.LogRpgBattleAttacker(BattleLogic.instance.logicFrame, caster, victim, configName, finalDamage); }
/// <summary> /// 初始化该结构. /// </summary> /// <param name="attacker">技能效果等的发起者.</param> /// <param name="skillCommonID">发起者使用的技能ID(非技能发起填入uint.MaxValue).</param> /// <param name="structMadeByRandEvent">该结构是否由randevent创造(检测并避免randevent循环产生效果).</param> public AttackerAttrImpl(BattleUnit attacker, uint skillCommonID, bool structMadeByRandEvent) { mStructMadeByRandEvent = structMadeByRandEvent; mSkillCommonID = skillCommonID; if (attacker != null) { mAttackerID = attacker.InstanceID; mAttackerName = attacker.GetName(); mAttackerRadius = attacker.GetRadius(); mAttackerLeague = attacker.GetLeague(); mEffectStartPosition = mAttackerPosition = attacker.GetPosition(); mEffectStartDirection = mAttackerDirection = attacker.GetDirection(); mLevel = attacker.GetLevel(); mDamage = (uint)attacker.GetPropertyValue((int)PropertyTypeEnum.PropertyTypeDamage); mCriticalLevel = (uint)attacker.GetPropertyValue((int)PropertyTypeEnum.PropertyTypeCrticalLV); mSummonerID = attacker.SummonerID; mSummonerName = attacker.SummonerName; mSummonerLevel = attacker.SummonerLevel; } }