public void analyze(MsgParam msg, WarServerNpcMgr npcMgr) { WarAnimParam warParam = msg as WarAnimParam; if (warParam != null && warParam.described != null) { SelfDescribed des = warParam.described; int castor = des.srcEnd.param1; int sufferer = des.srcEnd.param2; ServerNPC bCast = npcMgr.GetNPCByUniqueID(castor); ServerNPC bSuf = npcMgr.GetNPCByUniqueID(sufferer); if (bCast != null && bSuf != null) { Pair pair = new Pair() { CastorNum = bCast.data.num, KilledNum = bCast.data.num, }; killingInfo.Add(pair); } } }
public void OnHappen(MsgParam msg, WarServerNpcMgr npcMgr) { //TODO : do something WarAnimParam warParam = msg as WarAnimParam; if (warParam != null && warParam.described != null) { //杀死人,described只有一个元素 SelfDescribed described = warParam.described; if (described.srcEnd != null) { /// /// 杀死别人,自己身上的Buff和Trigger消失 /// int casterId = described.srcEnd.param1; //int sufferId = described.srcEnd.param2; if (casterId == HangUpNpcId) { /// /// 概率上的检测 /// bool happed = PseudoRandom.getInstance().happen(cfg.Prob); if (happed) { OnEnd(); } } } } }
/// 1.英雄 > 召唤兽 > 小兵 > 防御塔 > 建筑 (英雄使用) public void SortByPriority(IEnumerable <ServerNPC> unPriority, WarServerNpcMgr npcMgr, List <List <ServerNPC> > HasPriority) { //已经排好序的 if (HasPriority == null) { HasPriority = new List <List <ServerNPC> >(); } else { HasPriority.Clear(); } for (int i = 0; i < 5; ++i) { HasPriority.Add(null); } foreach (ServerNPC npc in unPriority) { NPCConfigData cfg = npc.data.configData; ExistFlag totest = LifeNpcType2ExistFlag(cfg.type, cfg.bldType); /// /// 如果属于不关心的类型,则丢弃 /// if (totest == ExistFlag.None) { continue; } base.addNpcByPriority(npc, (byte)totest, HasPriority); } }
/// <summary> /// /// </summary> /// <returns>The NPC rectangle.</returns> /// <param name="area">Area.</param> /// <param name="camp">Camp.</param> /// <param name="NpcSource">Npc source.</param> public static IEnumerable <ServerNPC> GetNPCPolygon(Polygon area, CAMP camp, WarServerNpcMgr NpcSource) { IEnumerable <ServerNPC> filter = NpcSource.getCampBnpc(camp); filter = filter.Where(n => area.PositionInPolygon(n.transform.position)); return(filter); }
/// <summary> /// Suffer the specified caster, target and damage. /// 收到伤害的时候,没有返回值. /// </summary> /// <param name="caster">释放者</param> /// <param name="target">目标者</param> /// <param name="damage">伤害值</param> public void Suffer(ServerNPC caster, ServerNPC sufferer, SelfDescribed des, WarServerNpcMgr npcMgr) { //拿到算子 InjuryOp sufOp = OperatorMgr.instance.getImplement <InjuryOp>(EffectOp.Injury); handled = new Dmg { dmgValue = des.targetEnd.param1, dmgType = (SkillTypeClass)des.targetEnd.param3, isCritical = des.targetEnd.param2 == 1, hitCls = (HurtHitClass)Enum.ToObject(typeof(HurtHitClass), des.targetEnd.param4), }; //TODO: find buff EffectConfigData[] help = null; suf = sufOp.toSuffer(ref handled, sufferer.data, caster.data, help); /// ///更多的事情发生了,比如护盾,吸血,反弹 /// report(caster.UniqueID, sufferer.UniqueID, suf, npcMgr); /// /// --------- 最终结算 -------- /// sufferer.data.rtData.curHp -= (int)handled.dmgValue; /// /// --------- 通知Trigger,OnKilled ---------- /// toTriggerMsg(caster, sufferer, npcMgr); }
public void OnHappen(MsgParam msg, WarServerNpcMgr npcMgr) { WarAnimParam warParam = msg as WarAnimParam; if (warParam != null && warParam.described != null) { SelfDescribed described = warParam.described; if (described.srcEnd != null) { /// /// 每次被攻击几率对周围造成伤害 /// int casterId = described.srcEnd.param1; int sufferId = described.srcEnd.param2; //不能自己打自己也反弹 if (sufferId == casterId) { return; } if (sufferId == HangUpNpcId) { //选择自己和目标 //目标也是自己 ServerNPC castor = npcMgr.GetNPCByUniqueID(sufferId); List <ServerNPC> targets = new List <ServerNPC>(); targets.Add(castor); warMgr.triMgr.trigCastor.cast(castor, targets, cfg); } } } }
public void OnHappen(MsgParam msg, WarServerNpcMgr npcMgr) { WarAnimParam warParam = msg as WarAnimParam; if (warParam != null && warParam.described != null) { SelfDescribed described = warParam.described; if (described.srcEnd != null && described.srcEnd.param1 > 0) { //转发消息 ServerNPC tag = npcMgr.TagNpc("Trigger"); switch (described.act) { case Verb.LineEnemy: warParam.cmdType = WarMsg_Type.LineEnemy; //创建一个触发器 warMgr.triMgr.CreateTrigger(described.src, described.srcEnd.param1, null); npcMgr.SendMessageAsync(tag.UniqueID, tag.UniqueID, msg); break; } } } }
public void Suffer(ServerNPC caster, ServerNPC sufferer, SelfDescribed des, WarServerNpcMgr npcMgr) { //拿到算子 InjuryOp CoreS = OperatorMgr.instance.getImplement <InjuryOp>(EffectOp.Injury); //TODO: find buff EffectConfigData[] help = null; handled = new Treat { treatValue = des.targetEnd.param1, treatType = (SkillTypeClass)des.targetEnd.param3, isCritical = des.targetEnd.param2 == 1, }; SufTreat res = CoreS.toSufferTreat(ref handled, sufferer.data, caster.data, help); if (res.isCureProtectioin) { //TODO : add Info here. } /// /// 最终结果的计算 /// NPCRuntimeData rtdata = sufferer.data.rtData; rtdata.curHp += (int)handled.treatValue; rtdata.curHp = rtdata.curHp > rtdata.totalHp ? rtdata.totalHp : rtdata.curHp; }
//清理逻辑 void clearDeadNpcStatus(MsgParam msg, WarServerNpcMgr npcMgr) { WarAnimParam warMsg = msg as WarAnimParam; if (warMsg != null && warMsg.described != null) { int deadNpcId = warMsg.described.srcEnd.param2; ServerNPC npc = npcMgr.GetNPCByUniqueID(deadNpcId); ServerLifeNpc life = npc as ServerLifeNpc; if (life != null) { life.curStatus = NpcStatus.None; /// /// ---- 解除挂载的Trigger ---- /// WarServerManager.Instance.triMgr.RemoveAllTrigger(deadNpcId); /// /// ---- 解除挂载的Buff ---- /// WarServerManager.Instance.bufMgr.rmAllBuff(deadNpcId); //--- 解除仇恨信息 ---- life.clearHatred(); } } }
//shared in suffer public static EffectSelector get(WarServerNpcMgr npcMgr) { if (efSelector == null) { efSelector = new EffectSelector(npcMgr); } return(efSelector); }
void HookNpcOnAttack(WarAnimParam warParam, WarServerNpcMgr npcMgr) { ServerNPC caster = npcMgr.GetNPCByUniqueID(warParam.Sender); ServerNPC suffer = npcMgr.GetNPCByUniqueID(warParam.Receiver); SufferHookEffect hookSuf = warMgr.sufMgr.getImplement <SufferHookEffect>(EffectOp.HookNpc); hookSuf.Suffer(caster, suffer, warParam.described, npcMgr); }
public void SortByPriority(IEnumerable <ServerNPC> unPriority, WarServerNpcMgr npcMgr, List <List <ServerNPC> > HasPriority) { //已经排好序的 if (HasPriority == null) { HasPriority = new List <List <ServerNPC> >(); } else { HasPriority.Clear(); } for (int i = 0; i < 8; ++i) { HasPriority.Add(null); } foreach (ServerNPC npc in unPriority) { ExistFlag toTest = ExistFlag.None; /// /// 挑选出关心的 敌方英雄,敌方召唤物, 敌方小兵 /// NPCConfigData cfg = npc.data.configData; bool careHero = cfg.type.check(LifeNPCType.Hero); bool careSummoner = cfg.type.check(LifeNPCType.Summon); bool careMinion = cfg.type.check(LifeNPCType.Soldier); bool careBuilding = cfg.type.check(LifeNPCType.Build); bool care = careHero || careSummoner || careMinion || careBuilding; if (care == false) { continue; } if (careHero) { toTest = NPCToFlag(npc, npcMgr, LifeNPCType.Hero); } if (careSummoner) { toTest = NPCToFlag(npc, npcMgr, LifeNPCType.Summon); } if (careMinion) { toTest = NPCToFlag(npc, npcMgr, LifeNPCType.Soldier); } if (careBuilding) { toTest = NPCToFlag(npc, npcMgr, LifeNPCType.Build); } base.addNpcByPriority(npc, (byte)toTest, HasPriority); } }
/// <summary> /// Suffer the specified caster, sufferer, des and npcMgr. /// </summary> /// <param name="caster">Caster.</param> /// <param name="sufferer">Sufferer.</param> /// <param name="des">SelfDescribed src = arg1, target = arg2 </param> /// <param name="npcMgr">Npc mgr.</param> public void Suffer(ServerNPC caster, ServerNPC sufferer, SelfDescribed des, WarServerNpcMgr npcMgr) { WarMsgParam warMsg = new WarMsgParam(); warMsg.Sender = caster.UniqueID; warMsg.Receiver = sufferer.UniqueID; warMsg.arg1 = des.src; warMsg.arg2 = des.target; HandleOnAttack(warMsg, npcMgr); }
/// <summary> /// 目前这里会监听战斗结束的消息 /// /// </summary> /// <param name="msg">Message.</param> public void OnHappen(MsgParam msg, WarServerNpcMgr npcMgr) { //最后检测,其他优先检测 NeheQiaoModeComplete(msg, npcMgr); //数据监测 StatictisInSkill.instance.analyze(msg, npcMgr); //清理逻辑 clearDeadNpcStatus(msg, npcMgr); OnEnd(); }
public void Suffer(ServerNPC caster, ServerNPC sufferer, SelfDescribed des, WarServerNpcMgr npcMgr) { int CasterId = caster.UniqueID; int SufferId = sufferer.UniqueID; int idx = des.targetEnd.param2; bool finalTar = des.targetEnd.param3 == SufferId; bool maxDis = des.targetEnd.param4 == 1; bool returnback = des.targetEnd.param5 == 1; int effectId = des.targetEnd.param1; HandleOnAttack(CasterId, SufferId, idx, finalTar, maxDis, returnback, effectId, npcMgr); }
public void OnHappen(MsgParam msg, WarServerNpcMgr npcMgr) { if (msg != null) { ServerNPC castor = npcMgr.GetNPCByUniqueID(msg.Sender); ServerNPC target = npcMgr.GetNPCByUniqueID(msg.Receiver); List <ServerNPC> itor = new List <ServerNPC>(); itor.Add(target); warMgr.triMgr.trigCastor.cast(castor, itor, cfg); } }
/// <summary> /// 获取特定的KindOfNPC,敌友方,有效状态的, 是建筑物还是什么的 活着的NPC /// </summary> /// <returns>ServerNPC 列表</returns> /// <param name="caster">Caster.</param> /// <param name="NpcSource">Npc source.</param> /// <param name="kind">KindOfNPC</param> /// <param name="target">TargetClass</param> /// <param name="TarStatusInCfg">NpcStatus</param> /// <param name="type">LifeNPCType.</param> public static IEnumerable <ServerNPC> GetNPCValideStatus(ServerNPC caster, WarServerNpcMgr NpcSource, KindOfNPC kind, TargetClass target, NpcStatus TarStatusInCfg, LifeNPCType type = LifeNPCType.SkTarAll) { // 临时枚举器 IEnumerable <ServerNPC> Itor1 = null; CAMP camp = CAMP.None; if (target.AnySame(TargetClass.Friendly)) { camp = caster.Camp; } else if (target.AnySame(TargetClass.Hostile)) { camp = caster.Camp.Hostile(); } else { //全阵营 camp = CAMP.All; } Itor1 = NpcSource.getCampBnpc(camp); if (kind == KindOfNPC.Life) { Itor1 = Itor1.Where(n => (n.WhatKindOf() == kind) && (type.check(((ServerLifeNpc)n).WhatTypeOf))); } else if (kind == KindOfNPC.NonLife) { Itor1 = Itor1.Where(n => n.WhatKindOf() == kind); } /// /// --- 筛选出有效状态的NPC ---- /// Itor1 = Itor1.Where(n => { ServerLifeNpc lifeTar = n as ServerLifeNpc; if (lifeTar != null) { return(!lifeTar.curStatus.AnySame(TarStatusInCfg)); } else { return(true); } }); return(Itor1); }
void BulletNPCCreator(WarAnimParam warParam, WarServerNpcMgr npcMgr) { ServerNPC caster = npcMgr.GetNPCByUniqueID(warParam.Sender); ServerNPC suffer = npcMgr.GetNPCByUniqueID(warParam.Receiver); SelfDescribed des = new SelfDescribed() { src = warParam.arg1, target = warParam.arg2, }; SufferBulletEffect bulletSuf = warMgr.sufMgr.getImplement <SufferBulletEffect>(EffectOp.Bullet_NPC); bulletSuf.Suffer(caster, suffer, des, npcMgr); }
/// <summary> /// 触发条件满足,或者说感兴趣的事情发生了。 /// 但是是不是要真的处理什么逻辑,还不一定 /// </summary> /// <param name="msg">Message</param> /// <param name="npcMgr">Npc mgr.</param> public void OnHappen(MsgParam msg, WarServerNpcMgr npcMgr) { checkList.Clear(); WarAnimParam warParam = msg as WarAnimParam; if (warParam != null && warParam.described != null) { SelfDescribed des = warParam.described; Pair pair = new Pair(); pair.castor = npcMgr.GetNPCByUniqueID(des.src); pair.target = npcMgr.GetNPCByUniqueID(des.target); checkList.Add(pair); } }
//奈河桥的模式 public void NeheQiaoModeComplete(MsgParam msg, WarServerNpcMgr npcMgr) { NeHeQiaoNpcMgr mgr = npcMgr as NeHeQiaoNpcMgr; if (mgr != null) { ServerNPC selfBase = mgr.SelfMilitaryBase; ServerNPC enemyBase = mgr.EnemyMilitaryBase; WarAnimParam warMsg = msg as WarAnimParam; if (warMsg != null && warMsg.described != null) { int deadNpcId = warMsg.described.srcEnd.param2; WarMsg_Type enemyRes = WarMsg_Type.Lose; WarMsg_Type selfRes = WarMsg_Type.Lose; if (deadNpcId == selfBase.UniqueID) { //我方基地死亡 enemyRes = WarMsg_Type.Win; } else if (deadNpcId == enemyBase.UniqueID) { //敌方基地死亡 selfRes = WarMsg_Type.Win; } /// /// ------ 确实是基地死亡了 ----------- /// if (enemyRes != WarMsg_Type.Lose || selfRes != WarMsg_Type.Lose) { WarCampMsg eParam = new WarCampMsg(); eParam.SendCamp = CAMP.Enemy; eParam.ReceCamp = CAMP.Enemy; eParam.cmdType = enemyRes; mgr.SendMessageAsync(CAMP.Enemy, CAMP.Enemy, eParam, false); WarCampMsg sParam = new WarCampMsg(); sParam.SendCamp = CAMP.Player; sParam.ReceCamp = CAMP.Player; sParam.cmdType = selfRes; mgr.SendMessageAsync(CAMP.Player, CAMP.Player, sParam, false); } } } }
public void OnHappen(MsgParam msg, WarServerNpcMgr npcMgr) { WarAnimParam warParam = msg as WarAnimParam; if (warParam != null && warParam.described != null) { //转发消息 ServerNPC tag = npcMgr.TagNpc("Trigger"); SelfDescribed described = warParam.described; if (described.srcEnd != null) { warParam.cmdType = WarMsg_Type.CounterAttack; npcMgr.SendMessageAsync(tag.UniqueID, tag.UniqueID, warParam); } } }
public void OnHappen(MsgParam msg, WarServerNpcMgr npcMgr) { //TODO : do something WarAnimParam warParam = msg as WarAnimParam; if (warParam != null && warParam.described != null) { SelfDescribed described = warParam.described; if (described.srcEnd != null) { //转发消息 ServerNPC tag = npcMgr.TagNpc("Trigger"); warParam.cmdType = WarMsg_Type.RmBufIfKilling; npcMgr.SendMessageAsync(tag.UniqueID, tag.UniqueID, warParam); } } }
public void OnHappen(MsgParam msg, WarServerNpcMgr npcMgr) { WarAnimParam warParam = msg as WarAnimParam; if (warParam != null) { switch (warParam.OP) { case EffectOp.Bullet_NPC: BulletNPCCreator(warParam, npcMgr); break; case EffectOp.HookNpc: HookNpcOnAttack(warParam, npcMgr); break; } } }
public override void Awake() { base.Awake(); warServerMgr = WarServerManager.Instance; npcMgr = warServerMgr.npcMgr; chaPool = warServerMgr.realServer.monitor.CharactorPool; animMsg = new IpcNpcAnimMsg(); hpMsg = new IpcNpcHpMsg(); skMsg = new IpcSkillMsg(); animState = gameObject.AddComponent <ServerNpcAnimState>(); if (animState != null) { broadcast = animState.OnNewStateReceived; animState.cachedNpc = this; } }
ExistFlag toExistType(ServerNPC npc, WarServerNpcMgr npcMgr) { NPCConfigData cfg = npc.data.configData; ExistFlag flag = LifeNpcType2ExistFlag(cfg.type, cfg.bldType); if (flag == ExistFlag.Hero) { if (npc.TargetID != -1) { ServerNPC npcTar = npcMgr.GetNPCByUniqueID(npc.TargetID); if (npcTar != null) { flag = ExistFlag.HeroTar; } } } return(flag); }
void Awake() { Instance = this; npcMgr = new ServerNpcMgrFactory().getNpcMgr(); npcMgr.Init(); creator = new ServerCreator(this); sufMgr = EffectSufferMgr.instance; npcSkill = SkillCastor.Instance; npcSkill.init(npcMgr); triMgr = TriggerMgr.Instance; triMgr.Init(npcMgr); bufMgr = BuffMgr.Instance; bufMgr.init(npcMgr, triMgr); StartCoroutine(checkClientUIReady()); }
public void SortByPriority(IEnumerable <ServerNPC> unPriority, WarServerNpcMgr npcMgr, List <List <ServerNPC> > HasPriority) { //已经排好序的 if (HasPriority == null) { HasPriority = new List <List <ServerNPC> >(); } else { HasPriority.Clear(); } for (int i = 0; i < 6; ++i) { HasPriority.Add(null); } foreach (ServerNPC npc in unPriority) { ExistFlag toTest = toExistType(npc, npcMgr); base.addNpcByPriority(npc, (byte)toTest, HasPriority); } }