Esempio n. 1
0
        /// <summary>
        /// 监视消息
        /// </summary>
        public void Watching(MsgParam msg)
        {
            if (msg == null)
            {
                return;
            }

            WarMsgParam warMsg = msg as WarMsgParam;

            if (warMsg != null)
            {
                List <ITriggerItem> list = null;
                bool care = OnWork.TryGetValue(warMsg.cmdType, out list);
                if (care)
                {
                    workingCache.Clear();
                    workingCache.AddRange(list);
                    int count = workingCache.Count;
                    if (count > 0)
                    {
                        for (int i = 0; i < count; ++i)
                        {
                            ITriggerItem handler = workingCache[i];
                            handler.OnHappen(msg, npcMgr);
                        }
                    }
                }
            }
        }
Esempio n. 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);
        }
Esempio n. 3
0
        public virtual void On_ManualInput(WarMsgParam param)
        {
            if (canMove)
            {
                animMsg.nextAnim = WarMsg_Type.Running.ToString();
                animMsg.uniqueId = cachedNpc.UniqueID;
                if (serMgr != null)
                {
                    serMgr.realServer.proxyCli.NPCAnim(animMsg);
                }

                STATE      = NpcAnimState.Run;
                SetHandler = RunHandle;

                string msg = param.param as string;
                if (msg != null)
                {
                    NpcAnimInfo    info = JSON.Instance.ToObject <NpcAnimInfo>(msg);
                    QuaternionWrap wrap = JSON.Instance.ToObject <QuaternionWrap>(info.data);
                    if (wrap != null)
                    {
                        Quaternion qua = QuaternionWrap.WrapToQuaternion(wrap);
                        cachedTran.rotation = qua;
                    }
                }
            }
        }
Esempio n. 4
0
 public void Init(ServerNPC parent, WarMsgParam param)
 {
     owner = parent;
     wmMgr = WarServerManager.Instance;
     tran  = transform;
     if (param is WarSrcAnimParam)
     {
         WarSrcAnimParam wp = param as WarSrcAnimParam;
         sphereParam = wp;
         WarTarAnimParam[] tars = wp.InjureTar;
         speed  = wp.described.targetEnd.param8;
         maxDis = wp.described.targetEnd.param9;
         if (tars != null && tars.Length > 0)
         {
             SelfDescribed sd = tars[0].described;
             npcId = sd.targetEnd.param5;
             if (wmMgr != null)
             {
                 target = wmMgr.npcMgr.GetNPCByUniqueID(npcId);
                 if (target != null && parent.outLog)
                 {
                     Debug.Log("Sphere target : " + target.name);
                 }
             }
         }
         else
         {
             target = null;
         }
     }
     inited = true;
 }
Esempio n. 5
0
 public override void On_Suffer(WarMsgParam param)
 {
     if (skill2_Obj != null)
     {
         Destroy(skill2_Obj);
     }
     base.On_Suffer(param);
 }
Esempio n. 6
0
        public virtual void OnNewStateReceived(WarMsgParam param)
        {
            if (param is WarSrcAnimParam)
            {
                switch (param.cmdType)
                {
                case WarMsg_Type.ManualInput:
                    On_ManualInput(param);
                    break;

                case WarMsg_Type.Stand:
                    On_Stand(param);
                    break;

                case WarMsg_Type.Running:
                    On_Run(param);
                    break;

                case WarMsg_Type.Attack:
                    On_Attack(param);
                    break;

                case WarMsg_Type.UseSkill:
                    On_CastSkill(param);
                    break;

                case WarMsg_Type.UseBuff:
                    On_CastBuff(param);
                    break;

                case WarMsg_Type.UseTrigger:
                    On_CastTrigger(param);
                    break;

                case WarMsg_Type.BeKilled:
                    On_Killed(param);
                    break;

                case WarMsg_Type.Respawn:
                    On_Respawn(param);
                    break;

                case WarMsg_Type.Idle:
                    On_Idle(param);
                    break;

                case WarMsg_Type.Destroy:
                    On_Destroy(param);
                    break;
                }
            }
            else if (param is WarTarAnimParam)
            {
                WarTarAnimParam tarParam = param as WarTarAnimParam;
                OnNewUIStateReceived(tarParam);
            }
        }
Esempio n. 7
0
 public virtual void On_Suffer(WarMsgParam param)
 {
     STATE = NpcAnimState.Suffer;
     ResetActiveAnimState();
     OnSwitchRun(false);
     OnSwitchAnimatorLayerWeight(1, 0);
     animator.SetBool("isSuffer", true);
     animator.CrossFade("Suffer", 0f);
 }
Esempio n. 8
0
        /// <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);
        }
Esempio n. 9
0
 public virtual void On_Run(WarMsgParam param)
 {
     if (STATE != NpcAnimState.Killed)
     {
         STATE      = NpcAnimState.Run;
         SetHandler = RunHandle;
         OnSwitchRun(true);
         OnSwitchAnimatorLayerWeight(1, 1);
         StopAllCoroutines();
     }
 }
Esempio n. 10
0
        //npc位移消息
        public void NPCMove(IpcNpcMoveMsg msg)
        {
            //ConsoleEx.DebugLog(war.Side.ToString() + " Sub Received : NPCMove.", ConsoleEx.YELLOW);
            WarMsgParam param = new WarMsgParam();

            param.Sender   = msg.uniqueId;
            param.Receiver = msg.uniqueId;
            param.cmdType  = WarMsg_Type.Move;
            param.param    = msg;
            WarClientManager.Instance.npcMgr.SendMessageAsync(msg.uniqueId, msg.uniqueId, param);
        }
Esempio n. 11
0
 public override void OnHandleMessage(MsgParam param)
 {
     base.OnHandleMessage(param);
     if (broadcast != null)
     {
         WarMsgParam msg = param as WarMsgParam;
         if (msg != null)
         {
             broadcast(msg);
         }
     }
 }
Esempio n. 12
0
 public override void On_Destroy(WarMsgParam param)
 {
     if (param.cmdType == WarMsg_Type.Destroy)
     {
         if (child != null)
         {
             child = Instantiate(child, transform.position, transform.rotation) as GameObject;
             Destroy(child, 2f);
         }
         Destroy(gameObject);
     }
 }
Esempio n. 13
0
 public virtual void On_Destroy(WarMsgParam param)
 {
     STATE            = NpcAnimState.Destroying;
     canNextAnim      = false;
     SetHandler       = null;
     animMsg.nextAnim = WarMsg_Type.Destroy.ToString();
     animMsg.uniqueId = cachedNpc.UniqueID;
     if (serMgr != null)
     {
         serMgr.realServer.proxyCli.NPCAnim(animMsg);
     }
     Destroy(gameObject);
 }
Esempio n. 14
0
 public virtual void On_Run(WarMsgParam param)
 {
     if (STATE != NpcAnimState.Run && canMove)
     {
         STATE            = NpcAnimState.Run;
         SetHandler       = RunHandle;
         animMsg.nextAnim = WarMsg_Type.Running.ToString();
         animMsg.uniqueId = cachedNpc.UniqueID;
         if (serMgr != null)
         {
             serMgr.realServer.proxyCli.NPCAnim(animMsg);
         }
     }
 }
Esempio n. 15
0
 public virtual void On_Effect(WarMsgParam param)
 {
     if (param != null)
     {
         string        m_str = param.param as string;
         NpcEffectInfo info  = JSON.Instance.ToObject <NpcEffectInfo>(m_str);
         if (info != null && info.to == cachedNpc.UniqueID)
         {
             Effect3DModelConfigData ecd = Core.Data.getIModelConfig <Effect3DModel>().get(info.hitAction);
             if (ecd != null)
             {
                 GameObject obj = null;
                 string     key = info.from + "_" + ecd.Start;
                 Debug.Log(key, gameObject);
                 if (info.Op == 0)
                 {
                     obj = WarEffectLoader.Load(ecd.Start);
                     if (obj != null)
                     {
                         obj = Instantiate(obj, cachedTran.position, cachedTran.rotation) as GameObject;
                         obj.transform.parent = cachedTran;
                         SkillEffectBase seb    = obj.GetComponent <SkillEffectBase>();
                         ClientNPC       srcNpc = cliMgr.npcMgr.GetNpc(info.from);
                         if (seb != null)
                         {
                             seb.EmitEffect(srcNpc, cachedNpc, false);
                         }
                         if (!uiEffectCache.ContainsKey(key))
                         {
                             uiEffectCache.Add(key, obj);
                         }
                     }
                     else
                     {
                         Debug.Log(string.Format("Fail to load effect obj with name:{0} from:{1} shootAction:{2}", ecd.Start, info.from));
                     }
                 }
                 else
                 {
                     if (uiEffectCache.TryGetValue(key, out obj))
                     {
                         uiEffectCache.Remove(key);
                         Destroy(obj);
                         obj = null;
                     }
                 }
             }
         }
     }
 }
Esempio n. 16
0
        IEnumerator CheckToSkill(WarMsgParam param)
        {
            val = 0f;
            while (cachedNpc.DisFromNextPos > 0.6f)
            {
                yield return(null);

                val -= 0.2f;
                if (val >= 0f && val <= 1f)
                {
                    animator.SetLayerWeight(1, val);
                }
            }
            OnSwitchRun(false);
            OnSwitchAnimatorLayerWeight(1, 0);

            STATE      = NpcAnimState.CastSkill;
            SetHandler = SkillHandle;
            string      m_str = param.param as string;
            NpcAnimInfo info  = JSON.Instance.ToObject <NpcAnimInfo>(m_str);

            if (info != null)
            {
                AnimationMsg msg = JSON.Instance.ToObject <AnimationMsg>(info.data);
                curMsg = msg;
                int index = msg.index;
                if (!string.IsNullOrEmpty(msg.animationName) && msg.animationName != "[]")
                {
                    animator.CrossFade(msg.animationName, 0.1f);
                }
                animationTimer      = msg.animationTimer - 0.02f;
                animationEventTimer = msg.animationEventTimer;
                canTriggerEvent     = true;
                if (index == 0)
                {
                    animator.SetBool("isSkill_1", true);
                    CreateEffect(NpcAnimEffect.Skill_1_Start);
                }
                else if (index == 1)
                {
                    animator.SetBool("isSkill_2", true);
                    CreateEffect(NpcAnimEffect.Skill_2_Start);
                }
                else if (index == 2)
                {
                    animator.SetBool("isSkill_3", true);
                    CreateEffect(NpcAnimEffect.Skill_3_Start);
                }
            }
        }
Esempio n. 17
0
 public virtual void On_Idle(WarMsgParam param)
 {
     if (STATE != NpcAnimState.Idle)
     {
         STATE            = NpcAnimState.Idle;
         SetHandler       = IdleHandle;
         canNextAnim      = false;
         animMsg.nextAnim = WarMsg_Type.Idle.ToString();
         animMsg.uniqueId = cachedNpc.UniqueID;
         if (serMgr != null)
         {
             serMgr.realServer.proxyCli.NPCAnim(animMsg);
         }
     }
 }
Esempio n. 18
0
 void HowToReport(List <MsgParam> MsgContainer, short pos, Action <MsgParam> Report)
 {
     //一个Effect产生了多条数据
     if (MsgContainer.Count > 0)
     {
         int count = MsgContainer.Count;
         for (int i = 0; i < count; ++i)
         {
             WarMsgParam warParam = (WarMsgParam)MsgContainer[i];
             //arg1代表第几个技能
             warParam.arg1    = pos;
             warParam.cmdType = WarMsg_Type.UseSkill;
             Report(warParam);
         }
     }
 }
Esempio n. 19
0
        public override void Init(ServerNPC owner, WarMsgParam param)
        {
            parent = owner;
            ConsoleEx.DebugLog(parent.name);
            wmMgr    = WarServerManager.Instance;
            UniqueId = wmMgr.npcMgr.SignID(this);
            Camp     = Camp.set(owner.Camp);
            WarSrcAnimParam wp = param as WarSrcAnimParam;

            if (wp != null)
            {
                SelfDescribed sd     = wp.described;
                EndResult     result = sd.srcEnd;
                lifeTime = result.param8;
            }
            inited = true;
        }
Esempio n. 20
0
 public void NpcDestroy(IpcDestroyNpcMsg msg)
 {
     AsyncTask.QueueOnMainThread(
         () => {
         int id = msg.id;
         WarClientManager mgr = WarClientManager.Instance;
         if (mgr != null)
         {
             ClientNPC npc = mgr.npcMgr.GetNpc(id);
             if (npc != null)
             {
                 WarMsgParam param = new WarMsgParam();
                 param.cmdType     = WarMsg_Type.Destroy;
                 mgr.npcMgr.SendMessageAsync(id, id, param);
             }
         }
     });
 }
Esempio n. 21
0
 //npc动画
 public void NPCAnim(IpcNpcAnimMsg msg)
 {
     //ConsoleEx.DebugLog(war.Side.ToString() + " Sub Received : NPCAnim.", ConsoleEx.YELLOW);
     AsyncTask.QueueOnMainThread(
         () => {
         WarMsgParam param = new WarMsgParam();
         param.cmdType     = (WarMsg_Type)Enum.Parse(typeof(WarMsg_Type), msg.nextAnim);
         if (!string.IsNullOrEmpty(msg.data))
         {
             param.param = msg.data;
         }
         WarClientManager mgr = WarClientManager.Instance;
         if (mgr != null)
         {
             mgr.npcMgr.SendMessageAsync(msg.uniqueId, msg.uniqueId, param);
         }
     });
 }
Esempio n. 22
0
        public virtual void On_Stand(WarMsgParam param)
        {
            if (STATE == NpcAnimState.Suffer)
            {
                animator.SetBool("isSuffer", false);
            }
            if (STATE != NpcAnimState.Killed && STATE != NpcAnimState.Stand)
            {
                isAnimating = false;
                STATE       = NpcAnimState.Stand;
                SetHandler  = StandHandle;
                ResetActiveAnimState();
//                StopCoroutine("OnSwitchRun");
//                StartCoroutine(OnSwitchRun(false, true));
                StopAllCoroutines();
                StartCoroutine(CheckToStand());
            }
        }
Esempio n. 23
0
 public virtual void On_Killed(WarMsgParam param)
 {
     if (STATE != NpcAnimState.Killed)
     {
         STATE            = NpcAnimState.Killed;
         animationTimer   = 0f;
         SetHandler       = KilledHandle;
         animMsg.nextAnim = WarMsg_Type.BeKilled.ToString();
         animMsg.uniqueId = cachedNpc.UniqueID;
         if (serMgr != null)
         {
             serMgr.realServer.proxyCli.NPCAnim(animMsg);
         }
         isAttack    = false;
         isCastSkill = false;
         cachedNpc.HitAnimReset();
         cachedNpc.curStatus = cachedNpc.curStatus.clear(NpcStatus.InSkill);
     }
 }
Esempio n. 24
0
        private void NpcMove(WarMsgParam param)
        {
            IpcNpcMoveMsg msg = param.param as IpcNpcMoveMsg;

            if (msg.forceMove)
            {
                tran.position = VectorWrap.ToVector3(msg.pos);
                tran.rotation = QuaternionWrap.ToQuaternion(msg.rotation);
                nextPos       = tran.position;
                nextRotate    = tran.rotation;
            }
            else
            {
                IsStartMove = true;
                movable     = true;
                nextPos     = VectorWrap.ToVector3(msg.pos);
                nextRotate  = QuaternionWrap.ToQuaternion(msg.rotation);
            }
        }
Esempio n. 25
0
 public virtual void On_Respawn(WarMsgParam param)
 {
     STATE      = NpcAnimState.Respawn;
     SetHandler = RespawnHandle;
     if (health != null)
     {
         health.value = 1f;
         if (isHero)
         {
             health.gameObject.SetActive(true);
         }
     }
     if (heroHealth != null)
     {
         heroHealth.value = 1f;
     }
     healthPoint = totalPoint;
     animator.SetBool("isDead", false);
 }
Esempio n. 26
0
        public override void OnHandleMessage(MsgParam param)
        {
            base.OnHandleMessage(param);


            if (param is WarTarAnimParam)
            {
                WarTarAnimParam effParam = param as WarTarAnimParam;
                switch (effParam.OP)
                {
                case EffectOp.Injury:
                    BeInjured(effParam);
                    break;

                case EffectOp.Treat:
                    BeTreated(effParam);
                    break;

                case EffectOp.ExchangeNpcAttri:
                    break;
                }
            }
            else if (param is WarSrcAnimParam)
            {
                WarSrcAnimParam src = param as WarSrcAnimParam;
                if (src.OP == EffectOp.ExchangeNpcAttri)
                {
                    Debug.Log("换血了");
                }
            }
            else if (param is WarMsgParam)
            {
                WarMsgParam warParam = param as WarMsgParam;

                switch (warParam.cmdType)
                {
                case WarMsg_Type.Win:
                case WarMsg_Type.Lose:
                    BattleOver();
                    break;
                }
            }
        }
Esempio n. 27
0
        public override void OnHandleMessage(MsgParam param)
        {
            base.OnHandleMessage(param);

            if (param is WarMsgParam)
            {
                WarMsgParam warParam = param as WarMsgParam;
                switch (warParam.cmdType)
                {
                case WarMsg_Type.Move:
                    NpcMove(warParam);
                    break;

                default:
                    if (broadcast != null)
                    {
                        broadcast(warParam);
                    }
                    break;
                }
            }
        }
Esempio n. 28
0
        /// <summary>
        /// Init the specified owner and param.
        /// </summary>
        /// <param name="owner">Owner.</param>
        /// <param name="param">Parameter.</param>
        public override void Init(ServerNPC owner, WarMsgParam param)
        {
            parent = owner;
            tran   = transform;
            wmMgr  = WarServerManager.Instance;
            Camp   = Camp.set(parent.Camp);

            WarSrcAnimParam srcParam = param as WarSrcAnimParam;

            if (srcParam != null)
            {
                SelfDescribed sd = srcParam.described;
                if (sd != null)
                {
                    EndResult result      = sd.targetEnd;
                    int       effectIndex = result.param2;
                    targetIndex = result.param5;
                    if (targetIndex > 0)
                    {
                        if (wmMgr != null)
                        {
                            target = wmMgr.npcMgr.GetNPCByUniqueID(targetIndex);
                        }
                    }
                    EffectConfigData effect = Core.Data.getIModelConfig <EffectModel>().get(effectIndex);
                    if (effect != null)
                    {
                        effectID      = effectIndex;
                        speed         = effect.Param3 / 1000f;
                        maxDis        = effect.Param4 / 1000;
                        damageType    = effect.Param8;
                        disappearType = effect.Param5;
                    }
//                    string msg = string.Format("[effect:{0} speed:{1} maxDis:{2} disappearType:{3} damageType:{4}]", effectID, speed, maxDis, disappearType, damageType);
//                    Debug.Log(msg);
                }
                inited = true;
            }
        }
Esempio n. 29
0
 public virtual void On_Killed(WarMsgParam param)
 {
     ClearUIObj();
     STATE = NpcAnimState.Killed;
     if (health != null)
     {
         health.value = 0f;
         health.gameObject.SetActive(false);
     }
     if (heroHealth != null)
     {
         heroHealth.value = 0f;
     }
     OnSwitchRun(false);
     OnSwitchAnimatorLayerWeight(1, 0);
     SetHandler = KilledHandle;
     animator.CrossFade("Die", 0f);
     animator.SetBool("isSuffer", false);
     animator.SetBool("isDead", true);
     animator.SetBool("isIdle", false);
     isAnimating = false;
 }
Esempio n. 30
0
        /// <summary>
        /// 收到发送过来的消息
        /// </summary>
        /// <param name="param">Parameter.</param>
        public virtual void OnHandleMessage(MsgParam param)
        {
            #if DEBUG
            if (param != null)
            {
                WarMsgParam msg   = param as WarMsgParam;
                bool        print = true;
                if (msg != null)
                {
                    IpcMsg ipc = msg.param as IpcMsg;
                    if (ipc != null && ipc.op == OP.NpcMove)
                    {
                        print = false;
                    }
                }

                if (print)
                {
                    ConsoleEx.DebugLog("Msg is Received : \n " + JSON.Instance.ToJSON(param));
                }
            }
            #endif
        }