public static bool AddBuff(SkillObj tarObj, SkillObj srcObj, int newBuffId, BattleReason reason) { if (tarObj == null) { return false; } var buffConfig = tarObj.GetBuffConfig(newBuffId); if(buffConfig == null) { return false; } var buffSuperpositionLogicId = tarObj.GetBuffSuperpositionLogicId(buffConfig); if (!BuffSuperpositionLogics.ContainsKey(buffSuperpositionLogicId)) { return false; } BuffSuperpositionLogic buffSuperpositionLogic = BuffSuperpositionLogics[buffSuperpositionLogicId]; var buffRet = buffSuperpositionLogic.OnBuffSuperposition(tarObj, srcObj, reason, buffConfig); BuffInfo_New buff = buffRet.buff; if(buffRet.bType == BuffSuperpositionType.Refresh) { var buffLogicId = tarObj.GetBuffLogicId(buffConfig); if (!BuffLogics.ContainsKey(buffLogicId)) { return false; } BuffLogic buffLogic = BuffLogics[buffLogicId]; buffLogic.InitBuffInfo(tarObj, srcObj, reason, buff, buffConfig, false); } else if(buffRet.bType == BuffSuperpositionType.Add) { var buffLogicId = tarObj.GetBuffLogicId(buffConfig); if (!BuffLogics.ContainsKey(buffLogicId)) { return false; } BuffLogic buffLogic = BuffLogics[buffLogicId]; buffLogic.InitBuffInfo(tarObj, srcObj, reason, buff, buffConfig); //先从src方进行修正 if (srcObj != null) { var srcSkillList = srcObj.GetSkillList(); var srcBuffList = srcObj.GetBuffList(); if (srcSkillList != null) { foreach (var skillInfo in srcSkillList) { int skillId = srcObj.GetSkillID(skillInfo); SkillConfig_New skillConfig = srcObj.GetSkillConfig(skillId); var logic = GetSkillLogic(skillInfo, srcObj); logic.OnSendBuff(tarObj, srcObj, buff, skillInfo, skillConfig); } } if (srcBuffList != null) { foreach (var buffInfo in srcBuffList) { int buffId = srcObj.GetBuffID(buffInfo); BuffConfig_New srcBuffConfig = srcObj.GetBuffConfig(buffId); var logic = GetBuffLogic(buffInfo, srcObj); logic.OnSendBuff(tarObj, srcObj, buff, buffInfo, srcBuffConfig); } } } { var tarSkillList = tarObj.GetSkillList(); var tarBuffList = tarObj.GetBuffList(); if (tarSkillList != null) { foreach (var skillInfo in tarSkillList) { int skillId = tarObj.GetSkillID(skillInfo); SkillConfig_New skillConfig = tarObj.GetSkillConfig(skillId); var logic = GetSkillLogic(skillInfo, tarObj); logic.OnAttachBuff(tarObj, srcObj, buff, skillInfo, skillConfig); } } if (tarBuffList != null) { foreach (var buffInfo in tarBuffList) { int buffId = tarObj.GetBuffID(buffInfo); BuffConfig_New tarBuffConfig = tarObj.GetBuffConfig(buffId); var logic = GetBuffLogic(buffInfo, tarObj); logic.OnAttachBuff(tarObj, srcObj, buff, buffInfo, tarBuffConfig); } } } buffLogic.OnAttach(tarObj, srcObj, buff, buffConfig); tarObj.AddTempBuffList(buff); } tarObj.NotifyBuffInfo(buff, BattleInfoNotifyType.All_Buff, BattleNotifyTime.TickEnd); return true; }
public static bool AddBuff(SkillObj tarObj, SkillObj srcObj, int newBuffId, BattleReason reason) { if (tarObj == null) { return(false); } var buffConfig = tarObj.GetBuffConfig(newBuffId); if (buffConfig == null) { return(false); } var buffSuperpositionLogicId = tarObj.GetBuffSuperpositionLogicId(buffConfig); if (!BuffSuperpositionLogics.ContainsKey(buffSuperpositionLogicId)) { return(false); } BuffSuperpositionLogic buffSuperpositionLogic = BuffSuperpositionLogics[buffSuperpositionLogicId]; var buffRet = buffSuperpositionLogic.OnBuffSuperposition(tarObj, srcObj, reason, buffConfig); BuffInfo_New buff = buffRet.buff; if (buffRet.bType == BuffSuperpositionType.Refresh) { var buffLogicId = tarObj.GetBuffLogicId(buffConfig); if (!BuffLogics.ContainsKey(buffLogicId)) { return(false); } BuffLogic buffLogic = BuffLogics[buffLogicId]; buffLogic.InitBuffInfo(tarObj, srcObj, reason, buff, buffConfig, false); } else if (buffRet.bType == BuffSuperpositionType.Add) { var buffLogicId = tarObj.GetBuffLogicId(buffConfig); if (!BuffLogics.ContainsKey(buffLogicId)) { return(false); } BuffLogic buffLogic = BuffLogics[buffLogicId]; buffLogic.InitBuffInfo(tarObj, srcObj, reason, buff, buffConfig); //先从src方进行修正 if (srcObj != null) { var srcSkillList = srcObj.GetSkillList(); var srcBuffList = srcObj.GetBuffList(); if (srcSkillList != null) { foreach (var skillInfo in srcSkillList) { int skillId = srcObj.GetSkillID(skillInfo); SkillConfig_New skillConfig = srcObj.GetSkillConfig(skillId); var logic = GetSkillLogic(skillInfo, srcObj); logic.OnSendBuff(tarObj, srcObj, buff, skillInfo, skillConfig); } } if (srcBuffList != null) { foreach (var buffInfo in srcBuffList) { int buffId = srcObj.GetBuffID(buffInfo); BuffConfig_New srcBuffConfig = srcObj.GetBuffConfig(buffId); var logic = GetBuffLogic(buffInfo, srcObj); logic.OnSendBuff(tarObj, srcObj, buff, buffInfo, srcBuffConfig); } } } { var tarSkillList = tarObj.GetSkillList(); var tarBuffList = tarObj.GetBuffList(); if (tarSkillList != null) { foreach (var skillInfo in tarSkillList) { int skillId = tarObj.GetSkillID(skillInfo); SkillConfig_New skillConfig = tarObj.GetSkillConfig(skillId); var logic = GetSkillLogic(skillInfo, tarObj); logic.OnAttachBuff(tarObj, srcObj, buff, skillInfo, skillConfig); } } if (tarBuffList != null) { foreach (var buffInfo in tarBuffList) { int buffId = tarObj.GetBuffID(buffInfo); BuffConfig_New tarBuffConfig = tarObj.GetBuffConfig(buffId); var logic = GetBuffLogic(buffInfo, tarObj); logic.OnAttachBuff(tarObj, srcObj, buff, buffInfo, tarBuffConfig); } } } buffLogic.OnAttach(tarObj, srcObj, buff, buffConfig); tarObj.AddTempBuffList(buff); } tarObj.NotifyBuffInfo(buff, BattleInfoNotifyType.All_Buff, BattleNotifyTime.TickEnd); return(true); }