| | |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.Linq; |
| | | using UnityEngine; |
| | | |
| | | |
| | | public class BattleObjectBuffMgr |
| | | { |
| | | // private Dictionary<BuffBase, EffectPlayer> buffDict = new Dictionary<BuffBase, EffectPlayer>(); |
| | | // buffId, effectId, EffectPlayer |
| | | private Dictionary<uint, Dictionary<int, BattleEffectPlayer>> buffEffectDict = new Dictionary<uint, Dictionary<int, BattleEffectPlayer>>(); |
| | | |
| | | |
| | | // buffId, buffdata |
| | | private Dictionary<uint, HB428_tagSCBuffRefresh> buffDataDict = new Dictionary<uint, HB428_tagSCBuffRefresh>(); |
| | | |
| | | private BattleObject battleObject; |
| | | |
| | |
| | | // 删除buff |
| | | public void RemoveBuff(HB429_tagSCBuffDel vNetData) |
| | | { |
| | | HB428_tagSCBuffRefresh buffData = null; |
| | | |
| | | // buffBase.OnRemove(); |
| | | if (buffDataDict.TryGetValue(vNetData.BuffID, out buffData)) |
| | | { |
| | | buffDataDict.Remove(vNetData.BuffID); |
| | | } |
| | | |
| | | if (buffData != null) |
| | | { |
| | | Dictionary<int, BattleEffectPlayer> effectDict = null; |
| | | |
| | | if (buffEffectDict.TryGetValue(vNetData.BuffID, out effectDict)) |
| | | { |
| | | SkillConfig skillConfig = SkillConfig.Get((int)buffData.SkillID); |
| | | if (null != skillConfig) |
| | | { |
| | | BattleEffectPlayer effectPlayer = null; |
| | | if (effectDict.TryGetValue(skillConfig.EffectId, out effectPlayer)) |
| | | { |
| | | battleObject.battleField.battleEffectMgr.RemoveEffect(skillConfig.EffectId, effectPlayer); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | // 不做表现 |
| | | battleObject.heroInfoBar.RefreshBuff(buffDataDict.Values.ToList()); |
| | | } |
| | | |
| | | public void RefreshBuff(HB428_tagSCBuffRefresh vNetData) |
| | | { |
| | | bool isNew = false; |
| | | if (buffDataDict.ContainsKey(vNetData.BuffID)) |
| | | { |
| | | buffDataDict[vNetData.BuffID] = vNetData; |
| | | } |
| | | else |
| | | { |
| | | isNew = true; |
| | | buffDataDict.Add(vNetData.BuffID, vNetData); |
| | | } |
| | | |
| | | if (isNew) |
| | | { |
| | | BuffMountAction buffMountAction = new BuffMountAction(battleObject.battleField, battleObject, vNetData, () => |
| | | { |
| | | SkillConfig skillConfig = SkillConfig.Get((int)vNetData.SkillID); |
| | | if (null != skillConfig && skillConfig.EffectId > 0) |
| | | { |
| | | // Dictionary<uint, Dictionary<int, BattleEffectPlayer>> buffEffectDict |
| | | Dictionary<int, BattleEffectPlayer> effectDict = null; |
| | | if (buffEffectDict.TryGetValue(vNetData.BuffID, out effectDict)) |
| | | { |
| | | // 存在这个buffid的特效字典 |
| | | if (effectDict.ContainsKey(skillConfig.EffectId)) |
| | | { |
| | | Debug.LogError("已存在同样的buff特效 " + skillConfig.EffectId); |
| | | } |
| | | else |
| | | { |
| | | BattleEffectPlayer effect = battleObject.battleField.battleEffectMgr.PlayEffect(battleObject.ObjID, skillConfig.EffectId, battleObject.heroRectTrans, battleObject.Camp); |
| | | effectDict.Add(skillConfig.EffectId, effect); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | effectDict = new Dictionary<int, BattleEffectPlayer>(); |
| | | BattleEffectPlayer effect = battleObject.battleField.battleEffectMgr.PlayEffect(battleObject.ObjID, skillConfig.EffectId, battleObject.heroRectTrans, battleObject.Camp); |
| | | effectDict.Add(skillConfig.EffectId, effect); |
| | | buffEffectDict.Add(vNetData.BuffID, effectDict); |
| | | } |
| | | } |
| | | }); |
| | | battleObject.battleField.recordPlayer.PlayRecord(buffMountAction); |
| | | } |
| | | } |
| | | } |