/// <summary> /// 处理主动打击其他NPC的时候,触发的事情 /// </summary> /// <param name="CasterId">施法者ID</param> /// <param name="SufferId">撞击者ID</param> /// <param name="idx">几个被撞击者</param> /// <param name="finalTar">是否最终目标</param> /// <param name="maxDis">是否最大距离</param> /// <param name="returnback">返回原处</param> /// <param name="EffectId">效果ID</param> /// <param name="npcMgr">Npc mgr.</param> void HandleOnAttack(int CasterId, int SufferId, int idx, bool finalTar, bool maxDis, bool returnback, int EffectId, WarServerNpcMgr npcMgr) { ServerNPC caster = npcMgr.GetNPCByUniqueID(CasterId); ServerNPC suffer = npcMgr.GetNPCByUniqueID(SufferId); /// /// -------- 获取Effect的配置 ------- /// EffectModel efModel = Core.Data.getIModelConfig <EffectModel>(); EffectConfigData efCfg = efModel.get(EffectId); Utils.Assert(efCfg == null, "Can't find Effect Configure. effect ID = " + EffectId); if (efSelector == null) { efSelector = EffectSufferShared.get(npcMgr); } /// /// 先做技能 /// IEnumerable <ServerNPC> filter = efSelector.Select(caster, new List <ServerNPC> { suffer }, efCfg); if (filter.Any()) { //消失的时候,触发可能的位移 HookNpcDisappearType disappearType = (HookNpcDisappearType)Enum.ToObject(typeof(HookNpcDisappearType), efCfg.Param2); //HookNpcDmgType hookDmgType = (HookNpcDmgType) Enum.ToObject(typeof(HookNpcDmgType), efCfg.Param8); HookNpcMoveType moveType = (HookNpcMoveType)Enum.ToObject(typeof(HookNpcMoveType), efCfg.Param5); /// /// 一定会有伤害,之后,先判定是否消失,如果消失,则再次判定是否移动 /// /// /// ------- 开始运算BulletOp -------- /// OperatorMgr OpMgr = OperatorMgr.instance; BulletNpcOp op = OpMgr.getImplement <BulletNpcOp>(EffectOp.Bullet_NPC); Dmg dmg = op.toTargetDmg(caster.data, suffer.data, efCfg); int moveDirection = 0; bool dis = Disappear(disappearType, idx, finalTar, maxDis, returnback); if (dis) { moveDirection = (int)moveType; } SelfDescribed des = record(CasterId, SufferId, dmg, dis, moveDirection); WarTarAnimParam param = new WarTarAnimParam() { OP = EffectOp.Injury, OringinOP = EffectOp.HookNpc, described = des, }; ///发送消息 npcMgr.SendMessageAsync(CasterId, SufferId, param); } }
protected BaseEffect() { OpMgr = OperatorMgr.instance; }
/// <summary> /// 处理主动打击其他NPC的时候,触发的事情 /// </summary> void HandleOnAttack(MsgParam msg, WarServerNpcMgr npcMgr) { WarMsgParam warMsg = msg as WarMsgParam; if (warMsg != null) { if (efSelector == null) { efSelector = EffectSufferShared.get(npcMgr); } int CasterId = warMsg.Sender; int SufferId = warMsg.Receiver; int EffectId = warMsg.arg1; int FinalId = warMsg.arg2; //是否是最终目标 bool IsfinalTarget = SufferId == FinalId; /// /// -------- 获取Effect的配置 ------- /// EffectModel efModel = Core.Data.getIModelConfig <EffectModel>(); EffectConfigData efCfg = efModel.get(EffectId); Utils.Assert(efCfg == null, "Can't find Effect Configure. effect ID = " + EffectId); //半径 float radius = efCfg.Param9 * Consts.oneHundred; ServerNPC caster = npcMgr.GetNPCByUniqueID(CasterId); ServerNPC suffer = npcMgr.GetNPCByUniqueID(SufferId); /// /// ----------- 先坐第一步的选择和解析 ------------ /// IEnumerable <ServerNPC> filter = efSelector.Select(caster, new List <ServerNPC> { suffer }, efCfg); if (filter.Count() > 0) { BulletHurtType HurtType = (BulletHurtType)Enum.ToObject(typeof(BulletHurtType), efCfg.Param8); List <ServerNPC> targets = selectTarget(HurtType, suffer, IsfinalTarget, npcMgr, radius); int tarCnt = targets.Count; if (tarCnt > 0) { /// /// ------- 开始运算BulletOp -------- /// OperatorMgr OpMgr = OperatorMgr.instance; BulletNpcOp op = OpMgr.getImplement <BulletNpcOp>(EffectOp.Bullet_NPC); for (int i = 0; i < tarCnt; ++i) { ServerNPC target = targets[i]; //alive ? if (target.data.rtData.curHp > 0) { Dmg damage = op.toTargetDmg(caster.data, target.data, efCfg); SelfDescribed des = record(CasterId, SufferId, damage, i); WarTarAnimParam param = new WarTarAnimParam() { OP = EffectOp.Injury, OringinOP = EffectOp.Bullet_NPC, described = des, }; ///发送消息 npcMgr.SendMessageAsync(CasterId, SufferId, param); } } } } } }