Пример #1
0
 public void CastSk(params Object[] args)
 {
     if (castor != null && param != null)
     {
         WarSrcAnimParam srcParam = param as WarSrcAnimParam;
         if (srcParam != null)
         {
             SelfDescribed sd = srcParam.described;
             if (sd != null)
             {
                 EndResult result = sd.targetEnd;
                 if (result != null)
                 {
                     WarServerManager mgr = WarServerManager.Instance;
                     int       target     = result.param3;
                     ServerNPC npc        = mgr.npcMgr.GetNPCByUniqueID(target);
                     if (npc != null)
                     {
                         Vector3 dir = npc.transform.position;
                         dir.y = castor.transform.position.y;
                         dir   = dir - castor.transform.position;
                         Quaternion rot = Quaternion.LookRotation(dir, Vector3.up);
                         castor.transform.rotation = rot;
                         LeanTween.cancel(castor.gameObject);
                         LeanTween.move(castor.gameObject, npc.transform.position, 0.2f);
                         castor.SendNpcMoveMsg(true);
                     }
                 }
             }
         }
     }
 }
Пример #2
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;
        }
Пример #3
0
        public void CastSk(params Object[] args)
        {
            if (castor != null && param != null)
            {
                WarSrcAnimParam srcParam = param as WarSrcAnimParam;
                if (srcParam != null)
                {
                    SelfDescribed sd = srcParam.described;
                    if (sd != null)
                    {
                        EndResult result = sd.srcEnd;
//                        float x = result.param8;
//                        float z = result.param9;
                        Vector3 pos = Vector3.zero;
//                        castor.transform.position = pos;
//                        castor.SendNpcMoveMsg(true);
                        if (castor is ServerLifeNpc)
                        {
                            ServerLifeNpc sCastor = castor as ServerLifeNpc;
                            sCastor.HitAnimReset();
                        }
                        int clearFlag = result.param1;
                        if (clearFlag == 0)
                        {
                            ServerNPC npc = castor.getOneChildNpc(result.param2);
                            if (npc != null)
                            {
                                pos   = npc.transform.position;
                                pos.y = 0.1f;
                                castor.transform.position = pos;
                                castor.SendNpcMoveMsg(true);
                                castor.removeChild(npc);
                                WarServerManager mgr = WarServerManager.Instance;
                                IpcDestroyNpcMsg msg = new IpcDestroyNpcMsg();
                                msg.id = npc.UniqueID;
                                mgr.realServer.proxyCli.NpcDestroy(msg);
                                UnityEngine.GameObject.Destroy(npc.gameObject);
                            }
                        }
                    }
                }
            }
        }
Пример #4
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;
            }
        }
Пример #5
0
        public void CastSk(params Object[] args)
        {
            if (castor != null && param != null)
            {
                WarSrcAnimParam srcParam = param as WarSrcAnimParam;
                if (srcParam != null)
                {
                    SelfDescribed sd = srcParam.described;
                    if (sd != null)
                    {
                        EndResult result = sd.targetEnd;
                        if (result != null)
                        {
                            int modelId             = result.param3;
                            VirtualNpcLoader loader = Core.ResEng.getLoader <VirtualNpcLoader>();

                            Transform tran = castor.transform;
                            Vector3   pos  = tran.position + tran.rotation * Vector3.forward;
                            pos.y = 0.1f;

                            GameObject obj = loader.LoadBulletNpc(modelId, castor.Camp, pos, tran.rotation);
                            Physics.IgnoreCollision(castor.collider, obj.collider);

                            if (obj != null)
                            {
                                ServerBulletNpc npc = obj.GetComponent <ServerBulletNpc>();
                                {
                                    SendCrtBulletMsg(npc);
                                    castor.addChildNpc(npc);
                                    npc.Init(castor, param);
                                }
                            }
                        }
                    }
                }
            }
        }
Пример #6
0
        public virtual void OnNewUIStateReceived(WarTarAnimParam param)
        {
            if (param != null)
            {
                if (param.OP == EffectOp.ExchangeNpcAttri || param.OP == EffectOp.Injury)
                {
                    return;
                }

                SelfDescribed sd = param.described;
                if (sd != null && sd.target == cachedNpc.UniqueID && sd.srcEnd != null)
                {
                    EndResult     src    = sd.srcEnd;
                    int           srcId  = sd.src;
                    int           target = sd.target;
                    int           action = src.param2;
                    int           op     = src.param3;
                    NpcEffectInfo info   = new NpcEffectInfo()
                    {
                        ClientID  = DeviceInfo.GUID,
                        from      = srcId,
                        to        = target,
                        hitAction = action,
                        Op        = op,
                    };
                    animMsg.nextAnim = WarMsg_Type.OnEffect.ToString();
                    animMsg.uniqueId = cachedNpc.UniqueID;
                    animMsg.data     = JSON.Instance.ToJSON(info);

                    if (serMgr != null)
                    {
                        serMgr.realServer.proxyCli.NPCAnim(animMsg);
                    }
                }
            }
        }
Пример #7
0
        void report(int CasterId, int SufferId, Suf suf, WarServerNpcMgr npcMgr)
        {
            //检测护盾
            if (suf.resDmgType.check(ResistanteClass.Protection))
            {
                if (suf.protectVal != null)
                {
                    //统计数据
                    SelfDescribed des = new SelfDescribed()
                    {
                        src    = CasterId,
                        target = SufferId,                         //SufferId 应该变为真实的护盾的NPC
                        act    = Verb.Punch,
                        srcEnd = null,
                    };

                    EndResult tarEnd = new EndResult();

                    Dmg protectDmg = suf.protectVal.Value;
                    tarEnd.param1 = (int)protectDmg.dmgValue;
                    tarEnd.param2 = protectDmg.isCritical ? 1 : 0;
                    tarEnd.param3 = (int)protectDmg.dmgType;
                    tarEnd.param4 = (int)HurtHitClass.None;

                    des.targetEnd = tarEnd;

                    WarTarAnimParam param = new WarTarAnimParam()
                    {
                        OP        = EffectOp.Injury,
                        OringinOP = EffectOp.Injury,
                        described = des,
                    };

                    npcMgr.SendMessageAsync(des.src, des.target, param);
                }
            }

            if (suf.resDmgType.check(ResistanteClass.Bloody) || suf.resDmgType.check(ResistanteClass.Rebound))
            {
                //反弹不为空
                if (suf.rebValue != null)
                {
                    //统计数据
                    SelfDescribed des = new SelfDescribed()
                    {
                        src    = SufferId,
                        target = CasterId,
                        act    = Verb.Punch,
                        srcEnd = null,
                    };

                    EndResult tarEnd = new EndResult();

                    Dmg rebDmg = suf.rebValue.Value;
                    tarEnd.param1 = (int)rebDmg.dmgValue;
                    tarEnd.param2 = rebDmg.isCritical ? 1 : 0;
                    tarEnd.param3 = (int)rebDmg.dmgType;
                    tarEnd.param4 = (int)HurtHitClass.None;

                    des.targetEnd = tarEnd;

                    WarTarAnimParam param = new WarTarAnimParam()
                    {
                        OP        = EffectOp.Injury,
                        OringinOP = EffectOp.Injury,
                        described = des,
                    };

                    npcMgr.SendMessageAsync(des.src, des.target, param);
                }

                //吸血不为空
                if (suf.bdyValue != null)
                {
                    //统计数据
                    SelfDescribed des = new SelfDescribed()
                    {
                        src    = SufferId,
                        target = CasterId,
                        act    = Verb.Recover,
                        srcEnd = null,
                    };

                    EndResult tarEnd = new EndResult();

                    Dmg bdyDmg = suf.bdyValue.Value;
                    tarEnd.param1 = (int)bdyDmg.dmgValue;
                    tarEnd.param2 = bdyDmg.isCritical ? 1 : 0;
                    tarEnd.param3 = (int)bdyDmg.dmgType;
                    tarEnd.param4 = (int)HurtHitClass.None;

                    des.targetEnd = tarEnd;

                    WarTarAnimParam param = new WarTarAnimParam()
                    {
                        OP        = EffectOp.Treat,
                        OringinOP = EffectOp.Treat,
                        described = des,
                    };

                    npcMgr.SendMessageAsync(des.src, des.target, param);
                }
            }
        }
Пример #8
0
        public virtual void On_CastSkill(WarMsgParam param)
        {
            if (STATE != NpcAnimState.Killed && !isCastSkill)
            {
//                WarSrcAnimParam srcParam = param as WarSrcAnimParam;
//                int index = param.arg1;
//                List<ISkImp> ops = null;
//                ISkImp sk = null;
//                if (!sk_Imps.TryGetValue(index, out ops))
//                {
//                    ops = new List<ISkImp>();
//                    sk_Imps.Add(index, ops);
//                }
//                sk = ops.Find(imp => imp.SkOp() == srcParam.OP);
//                if (sk == null)
//                {
//                    sk = SkImpFactory.getSkImp(srcParam.OP);
//                    ops.Add(sk);
//                }
//                sk.Reset();
//                sk.InitSk(cachedNpc, param);
//                sk.CastSk();
            }
            if (STATE != NpcAnimState.Killed && !isAttack && !isCastSkill)
            {
                WarSrcAnimParam srcParam = param as WarSrcAnimParam;
                Debug.Log(JSON.Instance.ToJSON(param));
                skParam = srcParam;
                if (srcParam != null)
                {
                    STATE = NpcAnimState.CastSkill;
                    Effect3DModelConfigData ecd = Core.Data.getIModelConfig <Effect3DModel>().get(srcParam.ShootAction);
                    if (ecd != null)
                    {
                        isCastSkill         = true;
                        canNextAnim         = false;
                        canTriggerEvent     = true;
                        animationTimer      = srcParam.ShootTime;
                        animationEventTimer = srcParam.ShootEventTime;
                        SetHandler          = Skill_Handle;

                        AnimationMsg msg = new AnimationMsg();
                        msg.animationTimer      = animationTimer;
                        msg.animationEventTimer = animationEventTimer;
                        msg.index         = param.arg1;
                        msg.ecd           = ecd;
                        msg.animationName = ecd.Anim;
                        msg.targetId      = 0;

                        if (srcParam.described != null && srcParam.OP == EffectOp.CtorNPC)
                        {
                            EndResult          result = srcParam.described.srcEnd;
                            CreatNpcDepandency cnd    = (CreatNpcDepandency)result.obj;
                            msg.objCrtV = cnd.TargetVector3;
                        }

                        WarTarAnimParam[] targets = skParam.InjureTar;
                        BNPC npc = null;
                        if (targets != null && targets.Length > 0)
                        {
                            msg.targetId = targets[0].described.target;
                            npc          = serMgr.npcMgr.GetNPCByUniqueID(targets[0].described.target);
                            if (npc != null)
                            {
                                lastTarget = "Target:" + targets[0].described.target;
                                Vector3 pos = npc.transform.position;
                                pos.y = cachedTran.position.y;
                                cachedTran.LookAt(pos);
                            }
                        }

                        string a_data = JSON.Instance.ToJSON(msg);

                        NpcAnimInfo info = new NpcAnimInfo()
                        {
                            ClientID  = DeviceInfo.GUID,
                            nextState = NpcAnimState.CastSkill,
                            data      = a_data,
                        };

                        animMsg.nextAnim = WarMsg_Type.UseSkill.ToString();
                        animMsg.uniqueId = cachedNpc.UniqueID;
                        animMsg.data     = JSON.Instance.ToJSON(info);

                        if (serMgr != null)
                        {
                            serMgr.realServer.proxyCli.NPCAnim(animMsg);
                        }
                    }
                    else
                    {
                        On_Stand(null);
                    }
                }
            }
        }
Пример #9
0
        public void CastSk(params Object[] args)
        {
            if (castor != null && param != null)
            {
                WarSrcAnimParam srcParam = param as WarSrcAnimParam;
                if (srcParam != null)
                {
                    SelfDescribed sd = srcParam.described;
                    if (sd != null)
                    {
                        EndResult          result = sd.srcEnd;
                        CreatNpcDepandency cnd    = (CreatNpcDepandency)result.obj;
                        if (cnd != null && cnd.TargetVector3 != null)
                        {
                            VirtualNpcLoader loader = Core.ResEng.getLoader <VirtualNpcLoader>();

                            GameObject obj = null;
                            Vector3    pos = Vector3.zero;
                            foreach (Vec3F v in cnd.TargetVector3)
                            {
                                pos = v.toUnityVec3();
                                int id = result.param1;
                                obj = loader.LoadNpcObj(id, castor.Camp, pos, Quaternion.LookRotation(Vector3.back));
                                if (obj != null)
                                {
                                    ServerNPC npc = obj.GetComponent <ServerNPC>();
                                    if (npc != null)
                                    {
                                        SendCrtNpcMsg(npc);
                                        castor.addChildNpc(npc);
                                        npc.data = cnd.Source;
                                        npc.Init(castor, srcParam);
                                        if (npc.collider != null)
                                        {
                                            npc.collider.enabled = cnd.IsCollide;
                                        }
                                        if (npc is LifeSummonNPC)
                                        {
                                            AttachAI(npc, result.param2);
                                        }
                                        if (cnd.Buff_IDs != null)
                                        {
                                            for (int i = 0; i < cnd.Buff_IDs.Length; i++)
                                            {
                                                BuffCtorParam bp = new BuffCtorParam();
                                                bp.bufNum    = cnd.Buff_IDs[i];
                                                bp.fromNpcId = castor.UniqueID;
                                                bp.toNpcId   = npc.UniqueID;
                                                bp.origin    = AW.Data.OriginOfBuff.Alone;
                                                bp.duration  = Consts.USE_BUFF_CONFIG_DURATION;
                                                bp.initLayer = 1;

                                                WarServerManager.Instance.bufMgr.createBuff(bp);
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }