예제 #1
0
        void makeUpData(WarCamp camp)
        {
            if (camp == WarCamp.FirstCamp || camp == WarCamp.SecondCamp)
            {
                List <RoomCharactor> chalist = null;
                bool exist = allCharactors.TryGetValue(camp, out chalist);
                if (exist)
                {
                    foreach (RoomCharactor charactor in chalist)
                    {
                        if (charactor.team is WrapperTeam)
                        {
                            continue;
                        }

                        WrapperTeam wTeam = new WrapperTeam()
                        {
                            dataTeam = new List <NPCData>(),
                        };

                        foreach (RoomNpc npc in charactor.team.team)
                        {
                            NPCConfigData config = Model.get(npc.NpcNum);
                            NPCData       data   = new NPCData()
                            {
                                configData = config,
                                rtData     = new NPCRuntimeData(config),
                            };
                            wTeam.dataTeam.Add(data);
                        }
                        wTeam.team = charactor.team.team;

                        charactor.team = wTeam;
                    }
                }
            }
        }
예제 #2
0
        /// <summary>
        /// 释放技能效果
        /// </summary>
        /// <param name="src">效果发起者</param>
        /// <param name="skTarget">技能选择的目标</param>
        /// <param name="target">技能先选择目标后,再次Effect选择后的目标</param>
        /// <param name="skDirectHurt">是否是技能的直接伤害</param>
        /// <param name="container">所有数据展现的容器,本次Effect施法的效果会依次加入</param>
        public void Cast(ServerNPC src, IEnumerable <ServerNPC> skTarget, IEnumerable <ServerNPC> target, bool skDirectHurt, List <MsgParam> container)
        {
                        #if DEBUG
            Utils.Assert(cfg == null, "Effect Configure is null in SwitchNpcEffect.");
                        #endif

            int       SwitchToId = cfg.Param1;
            UVec3     Locale     = src.transform.position;
            NPCAIType AI         = (NPCAIType)Enum.ToObject(typeof(NPCAIType), cfg.Param2);

            //数据源
            CtorNpcSource datasrc  = (CtorNpcSource)Enum.ToObject(typeof(CtorNpcSource), cfg.Param3);
            int           chargeOf = cfg.Param4;
            float         duration = cfg.Param5 * Consts.OneThousand;

            //参数10,是否继承普通攻击
            bool inheritNorAtk = cfg.Param10 == 0;

            NPCConfigData  npcCfg = null;
            NPCRuntimeData npcRt  = null;

            //获取参数配置
            NPCModel model = Core.Data.getIModelConfig <NPCModel>();
            switch (datasrc)
            {
            case CtorNpcSource.NPC_Castor_Init:
                npcCfg = src.data.configData.ShallowCopy();
                break;

            case CtorNpcSource.NPC_Castro_Cur:
                npcCfg = src.data.configData.ShallowCopy();
                npcRt  = src.data.rtData.ShallowCopy();
                break;

            case CtorNpcSource.NPC_Table:
                npcCfg = model.get(SwitchToId);
                Utils.Assert(npcCfg == null, "Can't find NPC configure. NPC ID = " + SwitchToId);
                break;
            }

            if (inheritNorAtk == false)
            {
                NPCConfigData swtNpcCfg = model.get(SwitchToId);
                Utils.Assert(swtNpcCfg == null, "Can't find NPC configure. NPC ID = " + SwitchToId);
                npcCfg.ID        = SwitchToId;
                npcCfg.normalHit = swtNpcCfg.normalHit;
            }

            npcRt = npcRt ?? new NPCRuntimeData(npcCfg);

            //额外的属性修改
            NPCAttributeModel AttModel = Core.Data.getIModelConfig <NPCAttributeModel>();
            AttrbuteConfig    att1     = AttModel.get(cfg.Param6);
            AttrbuteConfig    att2     = AttModel.get(cfg.Param8);

            //参数
            float param1 = cfg.Param7 * Consts.OneThousand;
            float param2 = cfg.Param9 * Consts.OneThousand;

            //修正属性的值
            if (att1 != null)
            {
                if (att1.type == "int")
                {
                    npcRt.addIntegerValue(att1.note, param1);
                }
                else if (att1.type == "float")
                {
                    npcRt.addFloatValue(att1.note, param1);
                }
            }

            if (att2 != null)
            {
                if (att2.type == "int")
                {
                    npcRt.addIntegerValue(att2.note, param2);
                }
                else if (att2.type == "float")
                {
                    npcRt.addFloatValue(att2.note, param2);
                }
            }

            //Buff的列表
            int[] BuffIds = cfg.Param11;

            ///
            /// 统计信息
            ///
            WarSrcAnimParam SrcParam = new WarSrcAnimParam()
            {
                OP             = EffectOp.SwitchNpc,
                ShootAction    = skCfg.ShootAction,
                ShootEventTime = skCfg.ShootEventTime,
                ShootTime      = skCfg.ShootTime,
                described      = new SelfDescribed()
                {
                    src    = src.UniqueID,
                    target = src.UniqueID,
                    act    = Verb.Creature,
                    srcEnd = new EndResult {
                        param1 = SwitchToId,
                        param2 = (int)AI,
                        param3 = chargeOf,
                        param8 = duration,
                    },
                    targetEnd = null,
                },

                SkillId   = skCfg.ID,
                OringinOP = EffectOp.SwitchNpc,
            };

            SrcParam.described.srcEnd.obj = ctorToShowcase(npcRt, npcCfg, BuffIds, Locale);

            container.Add(SrcParam);
        }
예제 #3
0
        /// <summary>
        /// 释放技能效果
        /// </summary>
        /// <param name="src">效果发起者</param>
        /// <param name="skTarget">技能选择的目标, 无意义</param>
        /// <param name="target">技能先选择目标后,再次Effect选择后的目标</param>
        /// <param name="skDirectHurt">是否是技能的直接伤害, 这个没有伤害</param>
        /// <param name="container">所有数据展现的容器,本次Effect施法的效果会依次加入</param>
        public void Cast(ServerNPC src, IEnumerable <ServerNPC> skTarget, IEnumerable <ServerNPC> target, bool skDirectHurt, List <MsgParam> container)
        {
                        #if DEBUG
            Utils.Assert(skCfg == null, "Skill Configure is null in BulletNpcEffect routine.");
                        #endif

            WarSrcAnimParam SrcParam = new WarSrcAnimParam()
            {
                OP             = EffectOp.CtorNPC,
                ShootAction    = skCfg.ShootAction,
                ShootTime      = skCfg.ShootTime,
                ShootEventTime = skCfg.ShootEventTime,
            };

            int   CtorNpcId = cfg.Param1;
            float LifeTime  = cfg.Param2 * Consts.OneThousand;

            CtorNpcPos pos = (CtorNpcPos)Enum.ToObject(typeof(CtorNpcPos), cfg.Param3);

            //碰撞
            bool Collide = cfg.Param4 == 1;
            int  AI_ID   = cfg.Param5;

            int param_1 = cfg.Param8;
            int param_2 = cfg.Param10;

            //会有的Buff
            int[] BuffIDList = cfg.Param11;

            //数据源
            CtorNpcSource datasrc = (CtorNpcSource)Enum.ToObject(typeof(CtorNpcSource), cfg.Param6);

            //数据源的修正
            CtorNpcAttri attr_1 = (CtorNpcAttri)Enum.ToObject(typeof(CtorNpcAttri), cfg.Param7);
            CtorNpcAttri attr_2 = (CtorNpcAttri)Enum.ToObject(typeof(CtorNpcAttri), cfg.Param9);

            ///
            /// 获取数据源
            ///
            NPCData        data = new NPCData();
            NPCConfigData  cfgD = null;
            NPCRuntimeData rtD  = null;

            if (datasrc == CtorNpcSource.NPC_Table)
            {
                NPCModel model = Core.Data.getIModelConfig <NPCModel>();
                cfgD = model.get(CtorNpcId);
                Utils.Assert(cfgD == null, "Can't find NPC configure. NPC ID = " + CtorNpcId);
            }
            else if (datasrc == CtorNpcSource.NPC_Castro_Cur)
            {
                cfgD = src.data.configData;
                rtD  = src.data.rtData.ShallowCopy();
            }
            else if (datasrc == CtorNpcSource.NPC_Castor_Init)
            {
                cfgD = src.data.configData;
            }

            rtD = rtD ?? new NPCRuntimeData(cfgD);

            List <String> changed_1 = attr_1.SwitchTo();
            List <String> changed_2 = attr_2.SwitchTo();

            int cnt = changed_1.Count;
            if (cnt > 0)
            {
                for (int i = 0; i < cnt; ++i)
                {
                    rtD.setValue(changed_1[i], (Int32Fog)param_1);
                }
            }

            cnt = changed_2.Count;
            if (cnt > 0)
            {
                for (int i = 0; i < cnt; ++i)
                {
                    rtD.setValue(changed_2[i], (Int32Fog)param_2);
                }
            }

            data.configData = cfgD;
            data.rtData     = rtD;

            ///
            /// 获取目标位置
            ///
            List <UVec3> TargetVec3 = new List <UVec3>();
            if (pos == CtorNpcPos.Castor_Forward)
            {
                TargetVec3.Add(src.transform.forward);
            }
            else if (pos == CtorNpcPos.Target)
            {
                foreach (ServerNPC t in target)
                {
                    TargetVec3.Add(t.transform.position);
                }
            }
            else if (pos == CtorNpcPos.Castor_Surround)
            {
                TargetVec3.Add(src.transform.position);
            }


            ///
            /// ------ 获取统计信息 ------
            ///
            SelfDescribed des = new SelfDescribed()
            {
                src    = src.UniqueID,
                target = src.UniqueID,
                act    = Verb.Creature,
                srcEnd = new EndResult {
                    param1 = CtorNpcId,
                    param2 = AI_ID,
                    param8 = LifeTime,
                },
                targetEnd = null,
            };

            des.srcEnd.obj     = ctorToShowcase(Collide, data, BuffIDList, TargetVec3, src);
            SrcParam.SkillId   = skCfg.ID;
            SrcParam.described = des;

            container.Add(SrcParam);
        }
예제 #4
0
        public ServerNPC Load(int num, CAMP camp, GameObject WarPoint)
        {
            if (NpcModel == null)
            {
                NpcModel = Core.Data.getIModelConfig <NPCModel>();
            }

            NPCConfigData configData = NpcModel.get(num);

                        #if DEBUG
            Utils.Assert(configData == null, "Virtual Npc load can't find npc configure. NPC id = " + num);
                        #endif

            if (cached == null)
            {
                string path = SPath.Combine(ResourceSetting.PACKROOT, NPC);
                path   = SPath.Combine(path, VIRTUAL);
                cached = URes.Load(path);
            }

            GameObject go = GameObject.Instantiate(cached) as GameObject;
            UnityUtils.AddChild_Reverse(go, WarPoint);

            if (configData.type == LifeNPCType.Build)
            {
                go.layer = LayerMask.NameToLayer(Consts.LAYER_BUILD);
            }
            else
            {
                go.layer = LayerMask.NameToLayer(Consts.LAYER_NPC);
            }

            ServerNPC npc = null;
            if (configData.healthpoint > 0)
            {
                npc = go.AddComponent <ServerLifeNpc>();
            }
            else
            {
                npc = go.AddComponent <ServerNPC>();
            }

            //如果是可以移动的,添加寻路脚本
            if (configData.moveable == Moveable.Movable)
            {
                Seeker seek = go.AddComponent <Seeker>();
                seek.drawGizmos = false;

                AIPath pathFinding = go.AddComponent <AIPath>();

                pathFinding.speed                = configData.speed;
                pathFinding.slowdownDistance     = 0.0f;
                pathFinding.pickNextWaypointDist = 2;
                pathFinding.forwardLook          = 1f;

                FunnelModifier modifer = go.AddComponent <FunnelModifier>();
                modifer.Priority = 2;

                CharacterController box = go.AddComponent <CharacterController>();

                box.radius = configData.radius;
                box.height = 2;

                if (box.radius >= box.height)
                {
                    box.center = Vector3.up * box.radius;
                }
                else
                {
                    box.center = Vector3.up * box.height / 2;
                }
            }
            else if (configData.radius > 0)
            {
                CapsuleCollider cap = go.AddComponent <CapsuleCollider>();
                cap.radius = configData.radius;
                cap.height = 2;

                if (cap.radius >= cap.height)
                {
                    cap.center = Vector3.up * cap.radius;
                }
                else
                {
                    cap.center = Vector3.up * cap.height / 2;
                }

                NavmeshCut cut = go.AddComponent <NavmeshCut>();
                cut.type         = NavmeshCut.MeshType.Circle;
                cut.circleRadius = configData.radius;
                cut.height       = 10;
                cut.center       = Vector3.up * 5;
            }

            DynamicDataInit(npc, configData, camp);

            go.name = "NPC_" + configData.ID + "_" + npc.UniqueID;

            return(npc);
        }
예제 #5
0
        ///
        /// 先尝试从ObjLoader里面取,如果不存在则再去WeakObjLoader取
        ///
        /// 但是如果是自己队伍里NPC则必须使用ObjLoader去创建
        ///
        public ClientNPC Load(int num, int id, CAMP camp, GameObject WarPoint)
        {
            if (NpcModel == null)
            {
                NpcModel = Core.Data.getIModelConfig <NPCModel>();
            }

            NPCConfigData configData = NpcModel.get(num);

            if (configData == null)
            {
                ConsoleEx.DebugWarning("not find npc config data ::  " + num);
                return(null);
            }

            string path = Path.Combine(ResourceSetting.PACKROOT, NPC);

            path = Path.Combine(path, configData.model.ToString());

            //TODO: 是自己队伍里NPC则必须使用ObjLoader去创建

            bool cached = ObjLoader.hitCache(path);

            Object obj = null;

            if (cached)
            {
                obj = ObjLoader.Load(path);
            }
            else
            {
                obj = WeakObjLoader.Load(path);
            }
            if (obj == null)
            {
                ConsoleEx.DebugWarning(configData.model + " not find models. Npc Num = " + num);
                return(null);
            }

            GameObject go = GameObject.Instantiate(obj) as GameObject;

            UnityUtils.AddChild_Reverse(go, WarPoint);

            ///
            /// 数据的初始化过程
            ///
            DynamicDataInit(go, num, camp, id);

            ClientNPC npc = go.GetComponent <ClientNPC> ();

            if (npc != null)
            {
                go.name = "NPC_" + npc.data.configData.ID + "_" + npc.UniqueID;
                if (!string.IsNullOrEmpty(configData.controlScript))
                {
                    ClientNpcAnimState animState = go.AddComponent(configData.controlScript) as ClientNpcAnimState;
                    npc.animState         = animState;
                    animState.CachedNpc   = npc;
                    animState.AttackCount = configData.normalHit.Length;
                    npc.broadcast         = animState.OnNewStateReceived;
                }
                cliNpcMgr.CreateNpcUI(npc);
            }

            return(npc);
        }