Exemple #1
0
 //初始化Buff
 private void InitBuff(ServerNPC npc)
 {
     //初始化buff
     if (npc.dataInScene.buffs != null && npc.dataInScene.buffs.Length > 0)
     {
         for (int j = 0; j < npc.dataInScene.buffs.Length; j++)
         {
             BuffCtorParam buffParam = new BuffCtorParam();
             buffParam.bufNum    = npc.dataInScene.buffs [j];
             buffParam.fromNpcId = npc.UniqueID;
             buffParam.toNpcId   = npc.UniqueID;
             buffParam.origin    = OriginOfBuff.Alone;
             buffParam.initLayer = 1;
             WarSMgr.bufMgr.createBuff(buffParam);
         }
     }
 }
Exemple #2
0
        /// <summary>
        /// 创建NPC身上的buff, 最简单的添加逻辑, 只适合在给泉水添加buff等简单情况下的逻辑
        /// </summary>
        /// <returns>The buff.</returns>
        /// <param name="bufNum">Buffer number.</param>
        /// <param name="npcId">Npc identifier.</param>
        /// <param name="level">Level.</param>
        public RtBufData createBuff(BuffCtorParam param)
        {
            allocIdx++;
            RtBufData buf = new RtBufData(param.bufNum, allocIdx, param.fromNpcId,
                                          param.toNpcId, param.origin, param.initLayer, param.duration, param.level);

            //加入管理
            OnWork[allocIdx] = buf;

            //挂在Npc上
            ServerNPC npc = WarServerManager.Instance.npcMgr.GetNPCByUniqueID(param.toNpcId);

            npc.addBuff(allocIdx);

            ///
            /// ---- 注册释放方法 ----
            ///
            buf.RegisterFunc(bfCastor.FirstCast, BuffPhase.Start);
            buf.RegisterFunc(bfCastor.cast, BuffPhase.Cycle);
            buf.RegisterFunc(bfCastor.EndCast, BuffPhase.End);
            buf.RegisterFunc(bfCastor.EndCastStep2, BuffPhase.End);

            ///
            /// ---- 需要创建Trigger ------
            ///

            int[] triIds = buf.BuffCfg.TriggerIDList;
            if (triIds != null)
            {
                int cnt = triIds.Length;
                if (cnt > 0)
                {
                    for (int i = 0; i < cnt; ++i)
                    {
                        trigMgr.CreateTrigger(param.toNpcId, triIds[i], buf);
                    }
                }
            }

            return(buf);
        }
Exemple #3
0
        /// <summary>
        /// 创建buff,更加通用的处理逻辑
        /// 也许并不创建Buff
        /// </summary>
        /// <returns>The buff.</returns>
        /// <param name="param">Parameter.</param>
        public RtBufData createBuff(BuffCtorParamEx param)
        {
                        #if DEBUG
            Utils.Assert(param.cfg == null, "param.cfg == null");
                        #endif

            int           casterID  = param.fromNpcId;
            int           tarID     = param.toNpcId;
            int           buffID    = param.cfg.Param1;
            float         customDur = param.cfg.Param2 * Consts.OneThousand;
            DotHotDurType durType   = (DotHotDurType)Enum.ToObject(typeof(DotHotDurType), param.cfg.Param3);
            int           Layers    = param.cfg.Param4;

            SkBufferModel  bfModel = Core.Data.getIModelConfig <SkBufferModel>();
            BuffConfigData BuffCfg = bfModel.get(buffID);


            List <RtBufData> TarBuff = new List <RtBufData>();
            foreach (RtBufData buf in OnWork.Values)
            {
                if (buf != null && buf.HangUpNpcID == tarID)
                {
                    TarBuff.Add(buf);
                }
            }

            ///
            /// 1. 判定要创建的buff是否有Group ID 作为主键 的冲突,
            ///    但是释放者的ID必须不相同
            ///

            //buff的分组
            List <RtBufData> Conflict = new List <RtBufData>();
            int groupId = BuffCfg.BuffGroup;
            foreach (RtBufData buf in TarBuff)
            {
                if (buf != null)
                {
                    if (buf.CastorNpcID != casterID && buf.BuffCfg.BuffGroup == groupId)
                    {
                        Conflict.Add(buf);
                    }
                }
            }

            //删除冲突
            if (Conflict.Count > 0)
            {
                int cnt = Conflict.Count;
                for (int i = 0; i < cnt; ++i)
                {
                    RtBufData d = Conflict[i];
                    rmBuff(d.ID, d.HangUpNpcID);
                }
            }


            ///
            /// 2. 判定Buff ID和CasterID 作为主键来决定是否有冲突
            ///
            Conflict.Clear();
            foreach (RtBufData buf in TarBuff)
            {
                if (buf != null)
                {
                    if (buf.CastorNpcID == casterID && buf.BuffCfg.ID == buffID)
                    {
                        Conflict.Add(buf);
                    }
                }
            }

            int       confcnt     = Conflict.Count;
            bool      hasConflict = confcnt > 0;
            RtBufData createOne   = null;

            if (hasConflict)
            {
                //不删除冲突
                for (int i = 0; i < confcnt; ++i)
                {
                    RtBufData d = Conflict[i];
                    //冲突的buff时间处理,
                    switch (durType)
                    {
                    //刷新Buff的时间
                    case DotHotDurType.Fixture:
                        d.setCustomeDuration(d.BuffCfg.Duration);
                        break;

                    case DotHotDurType.Increase:
                        d.setCustomeDurAddtion(customDur);
                        break;

                    case DotHotDurType.Leaveit:
                        break;
                    }

                    //冲突的Buff的层数处理
                    d.setMoreLayer(Layers);
                }

                createOne = Conflict[0];
            }
            else
            {
                //创建Buff
                BuffCtorParam ctor = new BuffCtorParam()
                {
                    bufNum    = buffID,
                    fromNpcId = casterID,
                    toNpcId   = param.toNpcId,
                    //buff的起源
                    origin = OriginOfBuff.BornWithSkill,
                    //初始的层数(默认1)
                    initLayer = 1,
                    //等级(忽略)
                    level = -1,
                    //自定义duration(默认填-1F)
                    duration = Consts.USE_BUFF_CONFIG_DURATION,
                };

                createOne = createBuff(ctor);
            }


            return(createOne);
        }
Exemple #4
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);
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }