Beispiel #1
0
        public override void OnAwake()
        {
            loader          = Core.ResEng.getLoader <VirtualNpcLoader>();
            mWarPoint       = GameObject.FindGameObjectWithTag("WarServer");
            freshGroupModel = Core.Data.getIModelConfig <FreshGroupModel>();
            freshPoolModel  = Core.Data.getIModelConfig <FreshPoolModel>();
            AiLoader        = Core.ResEng.getLoader <AILoader>();

            myHero  = gameObject.GetComponent <BNPC>();
            curPool = freshPoolModel.GetNPCFreshPool(myHero.dataInScene.freshParam.freshPoolID);

            crtMsg            = new IpcCreateNpcMsg();
            crtMsg.npclist    = new CrtHero[1];
            crtMsg.npclist[0] = new CrtHero();

            hpMsg = new IpcNpcHpMsg();
        }
Beispiel #2
0
        /// <summary>
        /// 创建npc缓存, 服务通知后创建缓存
        /// </summary>
        public void CreateNpcCache()
        {
            List <NPCInSceneData> freshPtList = GetFreshPtList();

            if (freshPtList != null && freshPtList.Count > 0)
            {
                FreshPoolModel  poolModel = Core.Data.getIModelConfig <FreshPoolModel>();
                FreshGroupModel gropModel = Core.Data.getIModelConfig <FreshGroupModel>();
                for (int i = 0; i < freshPtList.Count; i++)
                {
                    int          poolId = freshPtList [i].freshParam.freshPoolID;
                    NPCFreshPool pool   = poolModel.GetNPCFreshPool(poolId);
                    if (pool != null)
                    {
                        for (int j = 0; j < pool.freshPool.Count; j++)
                        {
                            NPCFreshGroup grop = gropModel.GetFreshGroup(pool.freshPool [j]);
                            if (grop != null)
                            {
                                for (int m = 0; m < grop.freshGroup.Count; m++)
                                {
                                    ClientNPC npcsript = Npcloader.Load(grop.freshGroup[m], -1, freshPtList[i].camp, WarPoint);

                                    npcsript.data.rtData.curHp = 0;
                                    npcsript.dataInScene       = freshPtList[i];
                                    npcsript.data.btData.way   = freshPtList[i].way;

                                    npcsript.gameObject.SetActive(false);

                                    //加入缓存中
                                    warMgr.npcMgr.SignDeadNpcCache(npcsript);
                                }
                            }
                        }
                    }
                }
            }
        }