/** 计算对单个单位的伤害(范围伤害值) */ public int toCalculateDamage(AttackData data, int damageType, int[] damages, int attackValue, bool isCrit, AttributeDataLogic attackerAttribute, AttributeDataLogic targetAttribute, Unit attacker, Unit target) { int damageValue; switch (damageType) { case SkillDamageType.PhysicsDamage: case SkillDamageType.MagicDamage: case SkillDamageType.HolyDamage: { damageValue = calculateDamage(damages, attackValue, isCrit, attackerAttribute, targetAttribute, attacker, target, data); } break; case SkillDamageType.HpAdd: { damageValue = attackValue; if (!target.fight.getStatusLogic().cantBeHeal()) { int healV = targetAttribute.getAddRatioResult(AttributeType.HealAddPercent, damageValue); targetAttribute.addOneAttribute(AttributeType.Hp, healV); } } break; case SkillDamageType.MpAdd: { damageValue = attackValue; targetAttribute.addOneAttribute(AttributeType.Mp, damageValue); } break; case SkillDamageType.MpSub: { damageValue = attackValue; targetAttribute.subOneAttribute(AttributeType.Mp, damageValue); } break; default: { damageValue = calculateDamage(damages, attackValue, isCrit, attackerAttribute, targetAttribute, attacker, target, data); } break; } return(damageValue); }
/** 每秒十次 */ public void onPiece(int delay) { if (!_buffDatas.isEmpty()) { //是客户端驱动 if (_parent.isSelfDriveAttackHapen()) { //先触发间隔 if (!_intervalActions.isEmpty()) { AttributeDataLogic attributeLogic = _parent.attribute; foreach (BuffIntervalActionData v in _intervalActions) { v.timePass += delay; if (v.timePass >= v.delay) { v.timePass -= v.delay; switch (v.type) { case BuffIntervalActionType.Attack: { //触发一次 _parent.doBuffIntervalAttack(v); } break; case BuffIntervalActionType.AddAttribute: { if (!_parent.isDriveAll()) { return; } attributeLogic.addOneAttribute(v.key, v.value); } break; case BuffIntervalActionType.AddAttributeVar: { if (!_parent.isDriveAll()) { return; } attributeLogic.addOneAttribute(v.key, _parent.getSkillVarValueT(v.value, v.adderInstanceID)); } break; } } } } } foreach (BuffData data in _buffDatas) { //有持续时间 if (data.lastTime > 0) { if ((data.lastTime -= delay) <= 0) { data.lastTime = 0; //本端驱动才移除 if (_parent.isDriveAll()) { buffOver(data); } } } } } }