Example #1
0
        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();
                        }
                    }
                }
            }
        }
Example #2
0
        void Report(MsgParam result)
        {
            if (outLog)
            {
                ConsoleEx.DebugLog("Msg is sending now : = " + fastJSON.JSON.Instance.ToJSON(result));
            }
            valid = false;
            WarAnimParam warParam = result as WarAnimParam;

            warParam.cmdType = WarMsg_Type.UseSkill;

            if (warParam.described != null)
            {
                SelfDescribed decribed = warParam.described;
                //如果不是自己则发送消息出去
                if (decribed.target != UniqueId)
                {
                    npcMgr.SendMessageAsync(UniqueId, decribed.target, result);
                }
                else
                {
                    //否则,自己给自己的消息就直接转过去
                    WarMsgParam param = result as WarMsgParam;
                    if (param != null && broadcast != null)
                    {
                        broadcast(param);
                    }
                }
            }

            skMsg.index    = result.arg1;
            skMsg.uniqueID = UniqueId;
            skMsg.baseCD   = runSkMd.getRuntimeSkill((short)skMsg.index).skillCfg.BaseCD;
            WarServerManager.Instance.realServer.proxyCli.NpcSkillCD(skMsg);
        }
Example #3
0
        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;
                    }
                }
            }
        }
        //清理逻辑
        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();
                }
            }
        }
Example #6
0
        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);
                }
            }
        }
        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);
        }
Example #8
0
        /// <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);
            }
        }
        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);
        }
        //奈河桥的模式
        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);
                    }
                }
            }
        }
Example #11
0
        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);
                }
            }
        }
Example #12
0
        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;
                }
            }
        }
Example #14
0
        void reportAtk(List <MsgParam> sequnce)
        {
            int cnt = sequnce.Count;

            ///永远Cnt都大于0
            if (cnt > 0)
            {
                if (outLog)
                {
                    ConsoleEx.DebugLog("atk sequnce = " + fastJSON.JSON.Instance.ToJSON(sequnce), ConsoleEx.RED);
                }

                for (int i = 0; i < cnt; ++i)
                {
                    WarAnimParam warParam = sequnce[i] as WarAnimParam;

                    if (warParam.described != null)
                    {
                        //自己给自己的消息就直接转过去
                        if (broadcast != null)
                        {
                            broadcast(warParam);
                        }
                    }
                }
            }
            else
            {
                WarAnimParam param = new WarAnimParam();
                param.Sender   = UniqueId;
                param.Receiver = 0;
                param.cmdType  = WarMsg_Type.Attack;
                param.OP       = EffectOp.Injury;
                //自己给自己的消息就直接转过去
                if (broadcast != null)
                {
                    broadcast(param);
                }
            }
        }
Example #15
0
        /// <summary>
        /// 派发出去消息
        /// </summary>
        /// <param name="outMsg">Out message.</param>
        void dispatchMsg(List <MsgParam> outMsg, RtSkData skill)
        {
            if (outMsg != null && outMsg.Count > 0)
            {
                int count = outMsg.Count;

                for (int i = 0; i < count; ++i)
                {
                    MsgParam     msg    = outMsg[i];
                    WarAnimParam warMsg = msg as WarAnimParam;
                    warMsg.cmdType = WarMsg_Type.UseBuff;
                    warMsg.SkillId = skill == null ? -1 : skill.Num;

                    if (warMsg != null && warMsg.described != null)
                    {
                        SelfDescribed des = warMsg.described;
                                                #if DEBUG
                        ConsoleEx.DebugLog("Buff Msg is going out : " + fastJSON.JSON.Instance.ToJSON(des), ConsoleEx.YELLOW);
                                                #endif
                        msgMgr.SendMessageAsync(des.src, des.target, warMsg);
                    }
                }
            }
        }
Example #16
0
        //发送给Trigger的数据
        void toTriggerMsg(ServerNPC caster, ServerNPC sufferer, WarServerNpcMgr npcMgr)
        {
            ServerNPC tri = npcMgr.TagNpc("Trigger");

            NPCData        sfData = sufferer.data;
            NPCRuntimeData sfRt   = sfData.rtData;

            if (sfRt.curHp > 0)
            {
                /// TODO: add OnAttack,在释放出添加, 不在这里

                /// TODO: add BeAttack
                SelfDescribed des = new SelfDescribed()
                {
                    srcEnd = new EndResult()
                    {
                        param1 = caster.UniqueID,
                        param2 = sufferer.UniqueID,
                    },
                    targetEnd = null,
                };
                WarAnimParam param = new WarAnimParam()
                {
                    cmdType   = WarMsg_Type.BeAttacked,
                    described = des,
                };

                npcMgr.SendMessageAsync(sufferer.UniqueID, tri.UniqueID, param);
            }

            if (sfRt.curHp <= 0)
            {
                /// TODO: add OnKilled
                SelfDescribed des = new SelfDescribed()
                {
                    srcEnd = new EndResult()
                    {
                        param1 = caster.UniqueID,
                        param2 = sufferer.UniqueID,
                    },
                    targetEnd = null,
                };
                WarAnimParam param = new WarAnimParam()
                {
                    cmdType   = WarMsg_Type.OnKilled,
                    described = des,
                };

                npcMgr.SendMessageAsync(sufferer.UniqueID, tri.UniqueID, param);

                /// TODO: add BeKilled
                SelfDescribed des2 = new SelfDescribed()
                {
                    srcEnd = new EndResult()
                    {
                        param1 = caster.UniqueID,
                        param2 = sufferer.UniqueID,
                    },
                    targetEnd = null,
                };
                WarAnimParam param2 = new WarAnimParam()
                {
                    cmdType   = WarMsg_Type.BeKilled,
                    described = des2,
                };

                npcMgr.SendMessageAsync(sufferer.UniqueID, tri.UniqueID, param2);
            }
        }