public void ActionHandle(BuffHandlerVar buffHandlerVar) { if (!buffHandlerVar.GetBufferValue(out BufferValue_TargetUnits targetUnits)) { return; } Buff_AddBuff addBuff = (Buff_AddBuff)buffHandlerVar.data; addBuff.buffGroup.sourceUnitId = buffHandlerVar.source.Id; foreach (var v in targetUnits.targets) { //未造成伤害就不给予效果 if (buffHandlerVar.GetBufferValue(out BufferValue_AttackSuccess attackSuccess)) { if (attackSuccess.successDic.ContainsKey(v.Id)) { if (!attackSuccess.successDic[v.Id]) { continue; } } } BuffMgrComponent buffMgr = v.GetComponent <BuffMgrComponent>(); buffMgr.AddBuffGroup(addBuff.buffGroup.BuffGroupId, addBuff.buffGroup); } }
static void AddEffectCache(EffectCacheComponent effectCacheComponent, AudioCacheComponent audioCacheComponent, ActiveSkillComponent skillComponent) { foreach (var skill in skillComponent.skillList) { ActiveSkillData skillData = Game.Scene.GetComponent <SkillConfigComponent>().GetActiveSkill(skill.Key); Game.Scene.GetComponent <ResourcesComponent>().LoadBundle(skillData.skillAssetsABName.StringToAB()); GameObject skillAssetsPrefabGo = Game.Scene.GetComponent <ResourcesComponent>().GetAsset(skillData.skillAssetsABName.StringToAB(), skillData.skillAssetsABName) as GameObject; var buffList = skillData.GetAllBuffs(BuffIdType.EmitObj, BuffIdType.HitEffect, BuffIdType.PlayEffect, BuffIdType.PlaySound, BuffIdType.AddBuff); if (buffList.Count > 0) { //循环检测每一个Buff,看是否是播放特效的,如果是,那就找到对应的Buff 缓存起来 foreach (var buff in buffList) { AddEffectCache(effectCacheComponent, buff, skillAssetsPrefabGo); AddAudioCache(audioCacheComponent, buff, skillAssetsPrefabGo); if (buff.GetBuffIdType() == BuffIdType.AddBuff) { Buff_AddBuff buff_AddBuffOnSkillEnd = (Buff_AddBuff)buff; if (buff_AddBuffOnSkillEnd.buffGroup.buffList == null) { continue; } foreach (var buff_onSkillEnd in buff_AddBuffOnSkillEnd.buffGroup.buffList) { AddEffectCache(effectCacheComponent, buff_onSkillEnd, skillAssetsPrefabGo); AddAudioCache(audioCacheComponent, buff_onSkillEnd, skillAssetsPrefabGo); } } } } } }