/// <summary> /// 动态添加 /// </summary> public void AddResultValue(eBuffEffectType type, float value) { if (null == Owner) { return; } float tempValue = value; switch (type) { case eBuffEffectType.影响生命: Owner.ChangeHP((int)tempValue, Caster); if (tempValue < 0) { Owner.UpdateEnmityList(Caster.Id, (int)tempValue); Owner.SendFlutterInfo((int)eFlutterInfoType.BuffReduceHp, BuffId, Level, -1 * (int)tempValue, Caster); } else if (tempValue > 0) { Owner.SendFlutterInfo((int)eFlutterInfoType.BuffAddHp, BuffId, Level, -1 * (int)tempValue, Caster); } break; case eBuffEffectType.影响技能加成: float attackTotal = Caster.FinalRoleValue.Atk * tempValue; float defendTotal = Owner.FinalRoleValue.GetDef(Caster.ElemType); tempValue = AttackImpact.ComputeAttackImpact(attackTotal, defendTotal, eHitType.Hit, Caster, Owner); Owner.ChangeHP(-1 * (int)tempValue, Caster); Owner.SendFlutterInfo((int)eFlutterInfoType.BuffReduceHp, BuffId, Level, (int)tempValue, Caster); break; } }
/// <summary> /// 添加buff效果 /// </summary> public void AddBufferEffect(eBuffEffectType type, Buff buff) { if (!mBufferEffects.ContainsKey(type)) { mBufferEffects[type] = new List <Buff>(); } mBufferEffects[type].Add(buff); }
public float GetEffectValue(eBuffEffectType type) { if (!mAllEffectValue.ContainsKey(type)) { return(0); } return(mAllEffectValue[type]); }
/// <summary> /// 更新buff影响属性 /// </summary> /// <param name="type"></param> public void UpdateBufferEffect(eBuffEffectType type) { if (!mBufferEffects.ContainsKey(type)) { return; } foreach (var buff in mBufferEffects[type]) { buff.ReComputeAffectValue(); } }
/// <summary> /// 移除指定类型的所有buff效果 /// </summary> public bool RemoveBufferEffect(eBuffEffectType type) { if (!mBufferEffects.ContainsKey(type)) { return(false); } List <Buff> buffers = mBufferEffects[type]; for (var i = 0; i < buffers.Count; i++) { DeleteBuffer(buffers[i].Id); } buffers.Clear(); return(true); }
/// <summary> /// 将buff效果类型转换为技能属性类型 /// </summary> public static eSkillAttrIndex BufferTypeTranslate(eBuffEffectType type) { switch (type) { case eBuffEffectType.影响生命: return(eSkillAttrIndex.HP); case eBuffEffectType.影响生命百分比: return(eSkillAttrIndex.HPRate); } if (type >= eBuffEffectType.影响生命上限百分比 && type <= eBuffEffectType.影响移动速度百分比) { return((eSkillAttrIndex)((int)eSkillAttrIndex.MaxHPRate + (int)(type - eBuffEffectType.影响生命上限百分比))); } return(eSkillAttrIndex.None); }
/// <summary> /// 重新计算影响值 /// </summary> public void ReComputeAffectValue() { foreach (var p in mEffectValue) { if (p.value == 0) { continue; } eBuffEffectType type = (eBuffEffectType)p.type; float tempValue = p.value; SetEffectValue(type, tempValue); if (LogicType == eBuffLogicType.Fixed) { BuffMgr.RefreshAffectValue(type); } } }
/// <summary> /// 刷新buff影响属性 /// </summary> /// <param name="type"></param> public void RefreshAffectValue(eBuffEffectType type) { float tempValue = 0; foreach (var buff in mBuffers.Values) { if (buff.LogicType == eBuffLogicType.Fixed) { tempValue += buff.GetEffectValue(type); } } switch (type) { case eBuffEffectType.影响生命百分比: mOwner.SetAttrBasePer(eValueType.Buff, eSkillAttrIndex.HPRate, tempValue); break; case eBuffEffectType.影响生命上限百分比: mOwner.SetAttrBasePer(eValueType.Buff, eSkillAttrIndex.MaxHPRate, tempValue); break; case eBuffEffectType.影响移动速度百分比: mOwner.SetAttrBasePer(eValueType.Buff, eSkillAttrIndex.SpeedRate, tempValue); break; case eBuffEffectType.影响攻击力百分比: mOwner.SetAttrBasePer(eValueType.Buff, eSkillAttrIndex.AtkRate, tempValue); break; case eBuffEffectType.影响闪避百分比: mOwner.SetAttrBasePer(eValueType.Buff, eSkillAttrIndex.DodgeRate, tempValue); break; case eBuffEffectType.影响命中百分比: mOwner.SetAttrBasePer(eValueType.Buff, eSkillAttrIndex.HitRate, tempValue); break; case eBuffEffectType.影响防御百分比: mOwner.SetAttrBasePer(eValueType.Buff, eSkillAttrIndex.Def_All, tempValue); break; } mOwner.UpdateAttr(); }
/// <summary> /// 注册buff影响类型 /// </summary> public void RegisteBuffEffectType() { foreach (var p in mEffectValue) { eBuffEffectType type = (eBuffEffectType)p.type; if (type == eBuffEffectType.Unknown || p.value == 0) { continue; } if (type == eBuffEffectType.免疫控制) { Owner.PlayerStatus.AddImmunityType((int)eImmunityType.眩晕); Owner.PlayerStatus.AddImmunityType((int)eImmunityType.击跪); Owner.PlayerStatus.AddImmunityType((int)eImmunityType.击飞); } } ReComputeAffectValue(); }
/// <summary> /// 设置buff实际影响值 /// </summary> public void SetEffectValue(eBuffEffectType type, float value) { mAllEffectValue[type] = value; }