Esempio n. 1
0
        public void LoadMonster(int mapID, Action callback, Action <int> process = null)
        {
            var models = new List <int>();

            foreach (var item in MogoUtils.GetSpaceLevelID(mapID))
            {
                models.AddRange(MogoUtils.GetSpawnPointMonsterID(item));
            }
            //if (process != null)
            //    process(80);
            if (models.Count > 0)
            {
                var sw = new System.Diagnostics.Stopwatch();
                sw.Start();
                var monstersList = models.Select(x => AvatarModelData.dataMap.Get(x).prefabName).Distinct();
                var ms           = monstersList.ToArray();
                //Debug.LogWarning("[Info] pre load resource" + ms.PackArray());
                SubAssetCacheMgr.GetCharacterResourcesAutoRelease(ms, (obj) =>
                {
                    sw.Stop();
                    //Debug.LogInfo("preload Monster time: " + sw.ElapsedMilliseconds);
                    //LoadFX(monstersList, callback, process);
                    if (callback != null)
                    {
                        callback();
                    }
                }, (progress) =>
                {
                    if (process != null)
                    {
                        process((int)(5 * progress + 90));
                    }
                });
            }
            else
            {
                if (callback != null)
                {
                    callback();
                }
            }
        }