public BattlePlayerData(MapPlayerData mapPlayerData, BattlePlayer owner) : base(null, null) { Name = mapPlayerData.Name; Level = mapPlayerData.Level; HP = mapPlayerData.HP; MaxHP = mapPlayerData.MaxHP; MP = mapPlayerData.MP; MaxMP = mapPlayerData.MaxMP; HeadIcon = mapPlayerData.HeadIcon; MapSkillID = mapPlayerData.MapSkillID; BattleSkillID = mapPlayerData.BattleSkillID; UsingCharacter = mapPlayerData.UsingCharacter; Food = mapPlayerData.Food; MaxFood = mapPlayerData.MaxFood; Gold = mapPlayerData.Gold; SkillId = mapPlayerData.BattleSkillID; ClassData = mapPlayerData.ClassData; //玩家的行动值初始 AP = MaxAP = 0; CardList.Clear(); EquipList.Capacity = (mapPlayerData.EquipList.Count); for (int i = 0; i < mapPlayerData.EquipList.Count; i++) { List <int> actions = mapPlayerData.EquipList[i].Data.ActionTypes; for (int j = 0; j < actions.Count; j++) { if (actions[i] == (int)BattleActionType.AddEquipment) { EquipList.Add(new BattleEquipData(mapPlayerData.EquipList[j].Data.ActionParams[0], owner)); break; } } } CardList.Capacity = mapPlayerData.CardList.Count; for (int i = 0; i < mapPlayerData.CardList.Count; i++) { CardList.Add(new BattleCardData(mapPlayerData.CardList[i].CardId, owner)); } BuffList.Capacity = mapPlayerData.BuffList.Count; for (int i = 0; i < mapPlayerData.BuffList.Count; i++) { BuffList.Add(new BattleBuffData(mapPlayerData.BuffList[i].Data.ActionParams[0], -1, 0, new BattleCardData(mapPlayerData.BuffList[i].CardId, owner), owner, owner)); } CurrentCardList.Capacity = CardList.Count; for (int i = 0; i < CardList.Count; i++) { CurrentCardList.Add(new BattleCardData(CardList[i].CardId, owner)); } }
public void NewBuff(int Id, bool charge = true) { GuildBuffInfo info = Envir.FindGuildBuffInfo(Id); if (info == null) { return; } GuildBuff buff = new GuildBuff() { Id = Id, Info = info, Active = true, }; buff.ActiveTimeRemaining = buff.Info.TimeLimit; if (charge) { ChargeForBuff(buff); } BuffList.Add(buff); List <GuildBuff> NewBuff = new List <GuildBuff> { buff }; SendServerPacket(new ServerPackets.GuildBuffList { ActiveBuffs = NewBuff }); //now tell everyone our new sparepoints for (int i = 0; i < Ranks.Count; i++) { for (int j = 0; j < Ranks[i].Members.Count; j++) { if (Ranks[i].Members[j].Player != null) { SendGuildStatus((PlayerObject)Ranks[i].Members[j].Player); } } } NeedSave = true; RefreshAllStats(); }
public void AddBuff(IBuff b) { lock (_buffsLock) { if (!Buffs.ContainsKey(b.Name)) { if (HasBuff(b.Name)) { var buff = GetBuffsWithName(b.Name)[0]; Buffs.Add(b.Name, buff); return; } Buffs.Add(b.Name, b); BuffList.Add(b); if (!b.IsHidden) { _game.PacketNotifier.NotifyNPC_BuffAdd2(b); } b.ActivateBuff(); } else if (b.BuffAddType == BuffAddType.REPLACE_EXISTING) { var prevbuff = Buffs[b.Name]; prevbuff.DeactivateBuff(); RemoveBuff(b.Name); BuffList.Remove(prevbuff); RemoveBuffSlot(b); BuffSlots[prevbuff.Slot] = b; b.SetSlot(prevbuff.Slot); Buffs.Add(b.Name, b); BuffList.Add(b); if (!b.IsHidden) { _game.PacketNotifier.NotifyNPC_BuffReplace(b); } b.ActivateBuff(); } else if (b.BuffAddType == BuffAddType.RENEW_EXISTING) { Buffs[b.Name].ResetTimeElapsed(); if (!b.IsHidden) { _game.PacketNotifier.NotifyNPC_BuffReplace(Buffs[b.Name]); } RemoveStatModifier(Buffs[b.Name].GetStatsModifier()); // TODO: Replace with a better method that unloads -> reloads all data of a script Buffs[b.Name].ActivateBuff(); } else if (b.BuffAddType == BuffAddType.STACKS_AND_OVERLAPS) { if (Buffs[b.Name].StackCount >= Buffs[b.Name].MaxStacks) { var tempbuffs = GetBuffsWithName(b.Name); var oldestbuff = tempbuffs[0]; oldestbuff.DeactivateBuff(); RemoveBuff(b.Name); BuffList.Remove(oldestbuff); RemoveBuffSlot(oldestbuff); tempbuffs = GetBuffsWithName(b.Name); BuffSlots[oldestbuff.Slot] = tempbuffs[0]; Buffs.Add(oldestbuff.Name, tempbuffs[0]); BuffList.Add(b); if (!b.IsHidden) { if (Buffs[b.Name].BuffType == BuffType.COUNTER) { _game.PacketNotifier.NotifyNPC_BuffUpdateNumCounter(Buffs[b.Name]); } else { _game.PacketNotifier.NotifyNPC_BuffUpdateCount(b, b.Duration, b.TimeElapsed); } } b.ActivateBuff(); return; } BuffList.Add(b); Buffs[b.Name].IncrementStackCount(); GetBuffsWithName(b.Name).ForEach(buff => buff.SetStacks(Buffs[b.Name].StackCount)); if (!b.IsHidden) { if (b.BuffType == BuffType.COUNTER) { _game.PacketNotifier.NotifyNPC_BuffUpdateNumCounter(Buffs[b.Name]); } else { _game.PacketNotifier.NotifyNPC_BuffUpdateCount(b, b.Duration, b.TimeElapsed); } } b.ActivateBuff(); } else if (Buffs[b.Name].BuffAddType == BuffAddType.STACKS_AND_RENEWS) { RemoveBuffSlot(b); Buffs[b.Name].ResetTimeElapsed(); Buffs[b.Name].IncrementStackCount(); if (!b.IsHidden) { if (Buffs[b.Name].BuffType == BuffType.COUNTER) { _game.PacketNotifier.NotifyNPC_BuffUpdateNumCounter(Buffs[b.Name]); } else { _game.PacketNotifier.NotifyNPC_BuffUpdateCount(Buffs[b.Name], Buffs[b.Name].Duration, Buffs[b.Name].TimeElapsed); } } RemoveStatModifier(Buffs[b.Name].GetStatsModifier()); // TODO: Replace with a better method that unloads -> reloads all data of a script Buffs[b.Name].ActivateBuff(); } } }
/// <summary> /// Add a new buff to the agent /// </summary> public void AddNewBuff(Buff buff) { BuffList.Add(buff); }
public void AddBuff(int buffID, int sourceID, float modifyTimer, bool isServerSend) { BuffInfo info = GameTable.BuffTableAsset.Lookup(buffID); if (null == info) { return; } if (IsDisable(info)) { return; } float length = info.BuffDuration; if (length != 0) {//不是无限的 length += modifyTimer; } Buff buff = new Buff(buffID, !info.IsNotRemoveForDead, length, info.IsFirstWork, info.Period); foreach (var item in info.PropertyPercentList) { if (item != 0) { buff.IsCalcProperty = true; break; } } if (!buff.IsCalcProperty) { foreach (var item in info.PropertyValueList) { if (item != 0) { buff.IsCalcProperty = true; break; } } } //play effect BuffEffectInfo beInfo = GameTable.BuffEffectTableAsset.Lookup(info.BuffEffectID); if (beInfo != null && !string.IsNullOrEmpty(beInfo.EffectName)) { Vector3 offset = new Vector3(beInfo.OffsetX, beInfo.OffsetY, beInfo.OffsetZ); string bone = beInfo.PlayBoneT; if (beInfo.IsSpecialPoint) { if (m_target.Type == ActorType.enNPC) { NPC npc = m_target as NPC; if (npc.GetNpcType() == ENNpcType.enBOSSNPC) { bone = beInfo.SpecialPointBoneT; } } } MainGame.Singleton.StartCoroutine(Coroutine_Load(buff, beInfo.EffectName, 0, bone, beInfo.IsAdhered, offset)); } BuffList.Add(buff); foreach (var item in info.BuffResultList) { if (buff.IsExsit(item.ID)) {//buff中不能存在多个相同的IBuffEffect continue; } IBuffEffect buffEffect = BattleFactory.Singleton.GetBattleContext().CreateBuffEffect(item.ID); if (null == buffEffect) { continue; } buffEffect.TargetID = m_target.ID; buffEffect.SourceID = sourceID; buffEffect.BuffID = buffID; buffEffect.BuffEffectID = info.BuffEffectID; buff.AddBuffEffect(buffEffect); buffEffect.OnGetBuffEffect(); } buff.UpdateFastFilterFlag(); if (buff.IsCalcProperty && !isServerSend) { BuffResult(); } else { RefreshBuffGraphics(); } }