Beispiel #1
0
        /// <summary>
        /// 数据的初始化
        /// </summary>
        /// <param name="go">Go.</param>
        /// <param name="num">Number.</param>
        /// <param name="id">Identifier.</param>
        /// <param name="camp">Camp.</param>
        void DynamicDataInit(GameObject go, int num, CAMP camp, int Id)
        {
            ClientNPC curHero = go.GetComponent <ClientNPC>();

            ///
            /// 填充阵营
            ///
            curHero.Camp = camp;

            ///
            /// 填充NPC数据
            ///
            NPCData       dynamicData = new NPCData();
            NPCConfigData econfig     = NpcModel.get(num);

            dynamicData.rtData     = new NPCRuntimeData(econfig);
            dynamicData.configData = econfig;
            dynamicData.btData     = new NPCBattleData();
            curHero.data           = dynamicData;

            if (Id != 0)
            {
                curHero.UniqueID = Id;
                cliNpcMgr.SignExistID(curHero);
            }
            else
            {
                ///
                /// 向WarClientNpcManager注册
                ///
                cliNpcMgr.SignID(curHero);
            }
        }
Beispiel #2
0
        /// <summary>
        /// 创建NPC, 使用初始化好的数据
        /// </summary>
        /// <param name="num">Number.</param>
        /// <param name="id">Identifier.</param>
        /// <param name="camp">Camp.</param>
        public ClientNPC Load(CAMP camp, NPCData initedData, GameObject WarPoint)
        {
                        #if DEBUG
            Utils.Assert(initedData == null, "NpcLoad can't be null ");
                        #endif

            NPCConfigData configData = initedData.configData;

            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 = " + configData.ID);
                return(null);
            }

            GameObject go = GameObject.Instantiate(obj) as GameObject;
            UnityUtils.AddChild_Reverse(go, WarPoint);
            ///
            /// 填充数据
            ///
            InitedData(go, camp, initedData);

            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;
                    npc.broadcast = animState.OnNewStateReceived;
                }
                cliNpcMgr.CreateNpcUI(npc);
            }

            return(npc);
        }
Beispiel #3
0
        /// <summary>
        /// 数据的初始化
        /// </summary>
        /// <param name="go">Go.</param>
        /// <param name="camp">Camp.</param>
        /// <param name="initedData">Inited data.</param>
        void InitedData(GameObject go, CAMP camp, NPCData initedData)
        {
            ClientNPC curHero = go.GetComponent <ClientNPC>();

            ///
            /// 填充阵营
            ///
            curHero.Camp = camp;

            ///
            /// 填充NPC数据
            ///
            NPCData dynamicData = initedData;

            dynamicData.btData = new NPCBattleData();

            curHero.data = dynamicData;

            ///
            /// 向WarClientNpcManager注册
            ///
            cliNpcMgr.SignID(curHero);
        }
Beispiel #4
0
 public abstract void EmitEffect(ClientNPC _from, ClientNPC _target, bool _needUpdate);
Beispiel #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);
        }