예제 #1
0
        public static void DownloadAllBundle(Action <string> onComplete, string tag = null)
        {
            _onComplete = onComplete;
            _tag        = tag;

            _releasePath = "";

            ResIndex resIndex = GetIndexFile(ResPath.AllResources);

            if (resIndex == null)
            {
                onComplete?.Invoke(tag);
                return;
            }

            ResPack resPack = resIndex.packageDict[ResPath.AllResources];

            if (resPack.packageType == FileType.Zip)
            {
                ResItem item = new ResItem()
                {
                    Md5  = resPack.packageMd5,
                    Path = AppConfig.Instance.assetsServer + "/" + AppConfig.Instance.version + "/" +
                           resPack.downloadPath,
                    Size     = resPack.packageSize,
                    FileType = resPack.packageType
                };

                DownloadManager.Load(item, AssetLoader.ExternalDownloadPath + "/" + resPack.downloadPath,
                                     OnCompleteFullLoading, OnFullLoadingError, OnProgressFullLoading);

                LoadingProgress.Instance.Show(resPack.packageSize);
                LoadingProgress.Instance.SetPercent(0);
            }
        }
예제 #2
0
        public static void DownLoadBackEndCacheQueue(Dictionary <string, CacheVo> cacheVoDic,
                                                     Action <string> onComplete = null, string tag = null, Action <string> onError = null)
        {
            _tag     = tag;
            _onError = onError;

            _onComplete = onComplete;

            ResIndex resIndex = GetIndexFile(ResPath.Backend);

            _backendPackQueue = new Queue <ResPack>();

            foreach (var v in resIndex.packageDict)
            {
                if (cacheVoDic.ContainsKey(v.Key))
                {
                    _backendPackQueue.Enqueue(v.Value);
                }
            }

            if (_backendPackQueue.Count > 0)
            {
                DownloadBackEndCache();
            }
        }
예제 #3
0
    static void GenerateIndexFile(string destDir, string language, string moduleName, string indexFileName,
                                  string releasePath, string packagePath, bool useSubDir = true, FileType fileType = FileType.Zip,
                                  bool ignoreItems = false)
    {
        releasePath = "AssetBundles/" + SystemTag + "/" + releasePath;

        ResIndex resIndex = new ResIndex();

        resIndex.language    = language;
        resIndex.belong      = moduleName;
        resIndex.packageDict = new Dictionary <string, ResPack>();

        string[] dirs = new string[] { destDir };

        if (useSubDir)
        {
            dirs = Directory.GetDirectories(destDir);
        }

        for (int i = 0; i < dirs.Length; i++)
        {
            ResPack resPack = new ResPack();
            resPack.id = new FileInfo(dirs[i]).Name;

            if (ignoreItems == false)
            {
                resPack.items = new List <ResItem>();
                string[] files = Directory.GetFiles(dirs[i]);
                for (int j = 0; j < files.Length; j++)
                {
                    string   filePath = files[j];
                    FileInfo fileInfo = new FileInfo(filePath);
                    ResItem  resItem  = new ResItem();
                    resItem.Path = fileInfo.Name;
                    resItem.Md5  = MD5Util.Get(filePath);
                    resItem.Size = fileInfo.Length;
                    resPack.items.Add(resItem);
                }
            }

            resPack.packageType = fileType;
            if (fileType == FileType.Zip)
            {
                resPack.packageMd5   = MD5Util.Get(packagePath + "/" + resPack.id + ".zip");
                resPack.packageSize  = new FileInfo(packagePath + "/" + resPack.id + ".zip").Length;
                resPack.downloadPath = GetPackageStorePath() + "/" + resIndex.belong + "/" + resPack.id + ".zip";
            }
            else
            {
                resPack.downloadPath = GetPackageStorePath() + "/" + resIndex.belong;
            }

            resPack.releasePath = releasePath;
            resIndex.packageDict.Add(resPack.id, resPack);
        }

        string json = JsonConvert.SerializeObject(resIndex, Formatting.Indented);

        FileUtil.SaveFileText(OutputPath, indexFileName + ".json", json);
    }
예제 #4
0
        public static void DownloadExtendCache(Action <string> onComplete = null, string tag = null, Action <string> onError = null)
        {
            _onComplete = onComplete;
            _onError    = onError;
            _tag        = tag;

            ResIndex resIndex = GetIndexFile(ResPath.Extend);
            ResPack  resPack  = resIndex.packageDict[ResPath.Extend];

            _releasePath = resPack.releasePath;
            if (resPack.packageType == FileType.Zip)
            {
                ResItem item = new ResItem()
                {
                    Md5  = resPack.packageMd5,
                    Path = AppConfig.Instance.assetsServer + "/" + AppConfig.Instance.version + "/" +
                           resPack.downloadPath,
                    Size     = resPack.packageSize,
                    FileType = resPack.packageType
                };

                DownloadManager.Load(item, AssetLoader.ExternalDownloadPath + "/" + resPack.downloadPath,
                                     OnCompleteFullLoading, OnError, OnProgressFullLoading);
                LoadingProgress.Instance.Show(resPack.packageSize);
                LoadingProgress.Instance.SetPercent(0);
            }
        }
예제 #5
0
        public static void DownloadEvoCardAll(Action <string> onComplete = null, string tag = null)
        {
            _onComplete = onComplete;
            _tag        = tag;

            ResIndex resIndex = GetIndexFile(ResPath.EvoCardPackageIndex);

            DownloadManager.Clear();

            ResPack resPack = resIndex.packageDict["EvoCard"];

            _releasePath = resPack.releasePath;
            if (resPack.packageType == FileType.Zip)
            {
                ResItem item = new ResItem()
                {
                    Md5  = resPack.packageMd5,
                    Path = AppConfig.Instance.assetsServer + "/" + AppConfig.Instance.version + "/" +
                           resPack.downloadPath,
                    Size     = resPack.packageSize,
                    FileType = resPack.packageType
                };

                _downloadingWindow          = PopupManager.ShowWindow <DownloadingWindow>(Constants.DownloadingWindowPath);
                _downloadingWindow.Content  = I18NManager.Get("Download_Downloading");
                _downloadingWindow.Progress = I18NManager.Get("Download_Progress", 0);
                DownloadManager.Load(item, AssetLoader.ExternalDownloadPath + "/" + resPack.downloadPath,
                                     OnCompleteEvoCard,
                                     OnErrorEvoCard, OnProgress);
            }
        }
예제 #6
0
        public static bool IsNeedDownLoad(int chapter)
        {
            bool     isNeed   = false;
            ResIndex resIndex = GetIndexFile(ResPath.MainStoryIndex);

            if (resIndex == null)
            {
                return(isNeed);
            }

            if (resIndex.packageDict.ContainsKey(chapter.ToString()))
            {
                ResPack resPack = resIndex.packageDict[chapter.ToString()];

                foreach (var resItem in resPack.items)
                {
                    FileInfo fileInfo =
                        new FileInfo(AssetLoader.ExternalHotfixPath + "/" + resPack.releasePath + "/" + resItem.Path);
                    if (fileInfo.Exists == false || fileInfo.Length != resItem.Size)
                    {
                        isNeed = true;
                        break;
                    }
                }
            }

            return(isNeed);
        }
예제 #7
0
        public static void DownloadLoveDiaryCache(string musicId, Action <string> onComplete = null, Action onCancel = null, string tag = null)
        {
            _onComplete        = onComplete;
            _onLoveDiaryCancel = onCancel;
            _tag = tag;

            ResIndex resIndex = GetIndexFile(ResPath.Special);

            string packKey = "lovediary";

            if (!resIndex.packageDict.ContainsKey(packKey))
            {
                FlowText.ShowMessage(I18NManager.Get("Download_ErrorLoveDiary") + musicId);
                _onLoveDiaryCancel?.Invoke();
                return;
            }

            DownloadManager.Clear();
            ResPack resPack = resIndex.packageDict[packKey.ToString()];
            string  resPath = "music/mainplay/" + musicId + ".music";
            var     rm      = resPack.items.Find((m) => { return(m.Path == resPath); });

            if (rm == null)
            {
                return;
            }

            _releasePath = resPack.releasePath;
            if (resPack.packageType == FileType.Original)
            {
                ResItem item = new ResItem()
                {
                    Md5  = rm.Md5,
                    Path = AppConfig.Instance.assetsServer + "/" + AppConfig.Instance.version + "/" +
                           resPack.downloadPath + "/" + resPath,
                    Size     = rm.Size,
                    FileType = resPack.packageType
                };

                //_downloadingWindow = PopupManager.ShowWindow<DownloadingWindow>(Constants.DownloadingWindowPath);
                //_downloadingWindow.Content = I18NManager.Get("Download_Downloading");
                //_downloadingWindow.Progress = I18NManager.Get("Download_Progress", 0);

                string storePath = AssetLoader.ExternalHotfixPath + "/" + _releasePath + "/" + resPath;
                Debug.Log(storePath);
                var downItem = DownloadManager.Load(item, storePath, OnCompleteLoveDiary,
                                                    OnErrorLoveDiary, null, OnErrorLoveDiary);
                //_downloadingWindow.WindowActionCallback = evt =>
                //{
                //    if (evt == WindowEvent.Cancel)
                //    {
                //        onCancel?.Invoke();
                //        downItem.Cancel();
                //    }
                //};
            }
        }
예제 #8
0
    private static void DeleteFile(ResIndex resIndex)
    {
        string path = PackageManager.GetPackageDir() + "/" + resIndex.belong;

        if (Directory.Exists(path))
        {
            Directory.Delete(path, true);
        }
    }
예제 #9
0
        private static ResIndex GetIndexFile(string path)
        {
            IndexFileService service = new IndexFileService();

            service.SetPath(AssetLoader.GetIndexFilePath(path)).Execute();

            ResIndex resIndex = (ResIndex)service.GetData();

            return(resIndex);
        }
예제 #10
0
    private static void CreateAllDownloadJsonAndZip()
    {
        //压缩文件
        string packagePath = PackageManager.OutputPath + ResPath.AllResources;

        if (Directory.Exists(packagePath))
        {
            Directory.Delete(packagePath, true);
        }
        Directory.CreateDirectory(packagePath);

        string zipFileName = packagePath + "/" + ResPath.AllResources + ".zip";

        string destDir = PackageManager.GetPackageDir() + "/" + ResPath.AllResources;

        string[] files = Directory.GetFiles(destDir, "*", SearchOption.AllDirectories);

        EditorUtility.DisplayProgressBar("压缩", "正在压缩文件(" + Path.GetFileName(packagePath), 1);

        List <string> pathInZipList = new List <string>();

        for (int i = 0; i < files.Length; i++)
        {
            string str = Path.GetDirectoryName(files[i]);
            str = str.Replace("\\", "/");
            str = str.Replace(PackageManager.GetPackageDir().Replace("\\", "/") + "/" + ResPath.AllResources + "/", "");
            pathInZipList.Add(str + "/");
        }

        ZipUtil.CreateZip(files, zipFileName, pathInZipList.ToArray(), 0);

        EditorUtility.ClearProgressBar();

        //生成Index文件
        ResIndex resIndex = new ResIndex();

        resIndex.language    = PackageManager.Language;
        resIndex.belong      = ResPath.AllResources;
        resIndex.packageDict = new Dictionary <string, ResPack>();

        ResPack resPack = new ResPack();

        resPack.id           = ResPath.AllResources;
        resPack.items        = new List <ResItem>();
        resPack.packageType  = FileType.Zip;
        resPack.packageMd5   = MD5Util.Get(packagePath + "/" + resPack.id + ".zip");
        resPack.packageSize  = new FileInfo(packagePath + "/" + resPack.id + ".zip").Length;
        resPack.downloadPath = PackageManager.GetPackageStorePath() + "/" + resIndex.belong + "/" + resPack.id + ".zip";
        resIndex.packageDict.Add(resPack.id, resPack);

        string json = JsonConvert.SerializeObject(resIndex, Formatting.Indented);

        FileUtil.SaveFileText(PackageManager.OutputPath, ResPath.AllResources + ".json", json);
    }
예제 #11
0
        /// <summary>
        /// 返回未下载的索引数值
        /// </summary>
        /// <returns>未下载的索引数值</returns>
        public static CacheVo CheckMainStoryCache(int chapter)
        {
            Stopwatch sw = Stopwatch.StartNew();

            CacheVo vo = new CacheVo();

            vo.ids = new List <int>();

            ResIndex resIndex = GetIndexFile(ResPath.MainStoryIndex);

            if (resIndex == null)
            {
                return(vo);
            }

            if (resIndex.packageDict.ContainsKey(chapter.ToString()) == false)
            {
                FlowText.ShowMessage(I18NManager.Get("Download_IndexNoExist") + chapter);
                return(vo);
            }

            ResPack resPack = resIndex.packageDict[chapter.ToString()];

            _releasePath = resPack.releasePath;
            foreach (var resItem in resPack.items)
            {
                FileInfo fileInfo =
                    new FileInfo(AssetLoader.ExternalHotfixPath + "/" + _releasePath + "/" + resItem.Path);

                if (fileInfo.Exists == false || fileInfo.Length != resItem.Size)
                {
                    vo.needDownload = true;
                    break;
                }
            }

            if (vo.needDownload)
            {
                vo.ids.Add(Convert.ToInt32(chapter));
            }

            vo.sizeList = new List <long>()
            {
                resPack.packageSize
            };

            Debug.LogError("CheckMainStoryCache 时间:" + sw.ElapsedMilliseconds);

            return(vo);
        }
예제 #12
0
        public static long GetDownloadAllSize()
        {
            ResIndex resIndex = GetIndexFile(ResPath.AllAudioIndex);

            if (resIndex != null)
            {
                ResPack resPack = resIndex.packageDict["AllAudio"];
                return(resPack.packageSize);
            }
            else
            {
                return(0);
            }
        }
예제 #13
0
        /// <summary>
        /// 返回未下载的索引数值
        /// </summary>
        /// <returns>未下载的索引数值</returns>
        public static CacheVo CheckPhoneCache()
        {
            Stopwatch sw = Stopwatch.StartNew();

            CacheVo vo = new CacheVo();

            vo.sizeList     = new List <long>();
            vo.ids          = new List <int>();
            _phoneCacheList = new List <int>();

            ResIndex resIndex = GetIndexFile(ResPath.PhoneAudioPackageIndex);

            if (resIndex == null)
            {
                return(vo);
            }

            foreach (var resPack in resIndex.packageDict)
            {
                string role = resPack.Key;
                _releasePath = resPack.Value.releasePath;
                bool isNeedDownload = false;
                foreach (var resItem in resPack.Value.items)
                {
                    FileInfo fileInfo =
                        new FileInfo(AssetLoader.ExternalHotfixPath + "/" + _releasePath + "/" + resItem.Path);

                    if (fileInfo.Exists == false || fileInfo.Length != resItem.Size)
                    {
                        vo.needDownload = true;
                        isNeedDownload  = true;
                        break;
                    }
                }

                vo.sizeList.Add(resPack.Value.packageSize);

                if (isNeedDownload)
                {
                    _phoneCacheList.Add(Convert.ToInt32(role));
                    vo.ids.Add(Convert.ToInt32(role));
                }
            }
            Debug.LogError("CheckPhoneCache 时间:" + sw.ElapsedMilliseconds);

            return(vo);
        }
예제 #14
0
        public static void DownloadLoveStoryCache(int cardId, Action <string> onComplete = null, string tag = null, Action <string> onCancle = null)
        {
            _onComplete = onComplete;
            _tag        = tag;

            ResIndex resIndex = GetIndexFile(ResPath.LoveStoryIndex);

            if (!resIndex.packageDict.ContainsKey(cardId.ToString()))
            {
                FlowText.ShowMessage(I18NManager.Get("Download_ErrorRole") + cardId);
                return;
            }

            DownloadManager.Clear();

            ResPack resPack = resIndex.packageDict[cardId.ToString()];

            _releasePath = resPack.releasePath;
            if (resPack.packageType == FileType.Zip)
            {
                ResItem item = new ResItem()
                {
                    Md5  = resPack.packageMd5,
                    Path = AppConfig.Instance.assetsServer + "/" + AppConfig.Instance.version + "/" +
                           resPack.downloadPath,
                    Size     = resPack.packageSize,
                    FileType = resPack.packageType
                };

                _downloadingWindow          = PopupManager.ShowWindow <DownloadingWindow>(Constants.DownloadingWindowPath);
                _downloadingWindow.Content  = I18NManager.Get("Download_Downloading");
                _downloadingWindow.Progress = I18NManager.Get("Download_Progress", 0);
                var downloadItem = DownloadManager.Load(item, AssetLoader.ExternalDownloadPath + "/" + resPack.downloadPath,
                                                        OnCompleteLoveStory,
                                                        OnErrorLoveStory, OnProgress);
                //downloadItems = downloadItem;
                _downloadingWindow.WindowActionCallback = evt =>
                {
                    if (evt == WindowEvent.Cancel)
                    {
                        downloadItem.Cancel();
                        onCancle?.Invoke(downloadItem.ErrorText);
                    }
                };
            }
        }
예제 #15
0
        private void ReadSetFileToDataSet()
        {
            //todo: abstract this out so it can build any named row
            List <ResIndex> dataRows = GetGameSetRows();

            for (int i = 0; i < dataRows.Count; i++)
            {
                ResIndex r = dataRows[i];
                //ResIndex row = dataRows.Find(r => r.name == "SFRAME");
                //int next_idx = dataRows.FindIndex(i => i.name == r.name) + 1;
                int dataSize;

                if (i + 1 >= dataRows.Count) //last one
                {
                    dataSize = this._rawData.Length - r.offset;
                }
                else
                {
                    dataSize = dataRows[i + 1].offset - r.offset;
                }


                byte[] sframeData;
                sframeData = new ArraySegment <byte>(this._rawData, r.offset, dataSize).ToArray();
                string tempFile = r.name + ".dbf";

                using (FileStream wfs = new FileStream(this._workingPath + "\\dbf\\" + tempFile, FileMode.Create))
                    wfs.Write(sframeData, 0, dataSize);

                string connex = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" +
                                this._workingPath + "\\dbf" + ";Extended Properties=dBase III";

                using (OleDbConnection dbfFile = new OleDbConnection(connex))
                {
                    OleDbCommand cmd = new OleDbCommand("SELECT * FROM [" + tempFile + ']', dbfFile);
                    using (OleDbDataAdapter adapter = new OleDbDataAdapter(cmd))
                    {
                        DataTable table = new DataTable(r.name);
                        dbfFile.Open();
                        adapter.Fill(table);
                        this.Databases.Tables.Add(table);
                    }
                }
            }
        }
예제 #16
0
        public static CacheVo CheckAppStartCache()
        {
            Stopwatch sw = Stopwatch.StartNew();

            CacheVo vo = new CacheVo();

            FileMark fm = new FileMark(AssetLoader.ExternalHotfixPath, ResPath.AppStart);

            if (fm.IsMatch)
            {
                return(vo);
            }

            ResIndex resIndex = GetIndexFile(ResPath.AppStart);

            if (resIndex == null)
            {
                return(vo);
            }

            ResPack resPack = resIndex.packageDict[ResPath.AppStart];

            _releasePath = resPack.releasePath;
            foreach (var resItem in resPack.items)
            {
                FileInfo fileInfo =
                    new FileInfo(AssetLoader.ExternalHotfixPath + "/" + _releasePath + "/" + resItem.Path);

                if (fileInfo.Exists == false || fileInfo.Length != resItem.Size)
                {
                    vo.needDownload = true;
                    break;
                }
            }

            vo.sizeList = new List <long>()
            {
                resPack.packageSize
            };

            Debug.LogError("CheckAppStartCache 时间:" + sw.ElapsedMilliseconds);

            return(vo);
        }
예제 #17
0
        public static CacheVo CheckExtendCache()
        {
            Stopwatch sw = Stopwatch.StartNew();

            CacheVo vo = new CacheVo();

            ResIndex resIndex = GetIndexFile(ResPath.Extend);

            if (resIndex == null)
            {
                return(vo);
            }

            if (IsDownloadMarked())
            {
                return(vo);
            }

            if (resIndex.packageDict.ContainsKey(ResPath.Extend) == false)
            {
                FlowText.ShowMessage(I18NManager.Get("Download_IndexNoExist"));
                return(vo);
            }

            ResPack resPack = resIndex.packageDict[ResPath.Extend];

            _releasePath = resPack.releasePath;

            FileMark fm = new FileMark(AssetLoader.ExternalHotfixPath, ResPath.Backend);

            if (fm.IsMatch == false)
            {
                vo.needDownload = true;
            }

            vo.sizeList = new List <long>()
            {
                resPack.packageSize
            };

            Debug.LogError("CheckExtend 时间:" + sw.ElapsedMilliseconds);

            return(vo);
        }
예제 #18
0
        public static bool IsLoveDiaryNeedDown(string musicId)
        {
            Stopwatch sw       = Stopwatch.StartNew();
            ResIndex  resIndex = GetIndexFile(ResPath.Special);

            if (resIndex == null)
            {
                return(false);
            }
            Debug.LogError(musicId);
            string packKey = "lovediary";

            if (resIndex.packageDict.ContainsKey(packKey) == false)
            {
                FlowText.ShowMessage(I18NManager.Get("Download_IndexNoExist") + packKey);
                return(false);
            }

            ResPack resPack = resIndex.packageDict[packKey.ToString()];

            _releasePath = resPack.releasePath;


            string resPath = "music/mainplay/" + musicId + ".music";
            var    rm      = resPack.items.Find((m) => { return(m.Path == resPath); });

            if (rm == null)
            {
                return(false);
            }


            string storePath = AssetLoader.ExternalHotfixPath + "/" + _releasePath + "/" + rm.Path;

            Debug.Log("IsLoveDiaryNeedDown::" + storePath);
            FileInfo fileInfo =
                new FileInfo(storePath);

            if (fileInfo.Exists == false)
            {
                return(true);
            }
            return(false);
        }
예제 #19
0
    private static void CopyFile(ResIndex resIndex)
    {
        foreach (var pack in resIndex.packageDict)
        {
            foreach (var item in pack.Value.items)
            {
                string destDir = PackageManager.GetPackageDir() + "/" + pack.Value.id + "/" + item.Path;

                FileInfo fileInfo = new FileInfo(destDir);
                destDir = fileInfo.DirectoryName;

                if (Directory.Exists(destDir) == false)
                {
                    Directory.CreateDirectory(destDir);
                }

                File.Copy(BundlePath + item.Path, fileInfo.FullName);
            }
        }
    }
예제 #20
0
        /// <summary>
        /// 获取到需要后台下载的包cachevo
        /// </summary>
        /// <returns></returns>
        public static long CheckCurBackEndCacheSize()
        {
            Stopwatch sw = Stopwatch.StartNew();

            ResIndex resIndex = GetIndexFile(ResPath.Backend);

            if (resIndex == null)
            {
                return(0);
            }

            if (resIndex.packageDict.Count == 0)
            {
                Debug.LogError("Download_IndexNoExist");
                return(0);
            }

            long allsize = 0;

            foreach (var v in resIndex.packageDict)
            {
                //要遍历几遍!
                CacheVo vo      = new CacheVo();
                ResPack resPack = v.Value;

                _releasePath = resPack.releasePath;
                vo.sizeList  = new List <long>()
                {
                    resPack.packageSize
                };

                FileMark fm = new FileMark(AssetLoader.ExternalHotfixPath, ResPath.Backend + "_" + v.Key);
                if (fm.IsMatch == false)
                {
                    allsize += resPack.packageSize;
                }
            }
            Debug.Log("CheckBackEnd===Size 时间:" + sw.ElapsedMilliseconds);

            return(allsize);
        }
예제 #21
0
        public static void UnzipBackend(Action <string> callback)
        {
            _tag = ResPath.Backend;

            _onComplete = callback;

            ResIndex resIndex = GetIndexFile(ResPath.Backend);

            _unzipIndex = 0;
            string[] keys = resIndex.packageDict.Keys.ToArray();
            string   key  = keys[_unzipIndex];

            UnzipBackendStep(resIndex.packageDict, key, OnBackendUnzipComplete);

            timerHandler = ClientTimer.Instance.AddCountDown("Upzip", Int64.MaxValue, 0.1f,
                                                             val =>
            {
                int progress = (int)((float)ZipUtil.CurrentSize / ZipUtil.TotalSize * 100);
                LoadingProgress.Instance.SetPercent(progress, true);
            }, null);
        }
예제 #22
0
        /// <summary>
        /// 获取到需要后台下载的包cachevo
        /// </summary>
        /// <returns></returns>
        public static Dictionary <string, CacheVo> CheckBackEndCacheDic(bool handlePackCount)
        {
            Stopwatch sw = Stopwatch.StartNew();
            Dictionary <string, CacheVo> cacheVodic = new Dictionary <string, CacheVo>();
            ResIndex resIndex = GetIndexFile(ResPath.Backend);

            if (resIndex == null)
            {
                return(cacheVodic);
            }

            if (resIndex.packageDict.Count == 0)
            {
                Debug.LogError("Download_IndexNoExist");
                return(cacheVodic);
            }

            if (IsDownloadMarked())
            {
                return(cacheVodic);
            }

            foreach (var v in resIndex.packageDict)
            {
                FileMark fm = new FileMark(AssetLoader.ExternalHotfixPath, ResPath.Backend + "_" + v.Key);
                if (fm.IsMatch == false)
                {
                    CacheVo vo = new CacheVo();
                    vo.needDownload = true;
                    cacheVodic.Add(v.Key, vo);
                }
            }

            if (handlePackCount)
            {
                LoadingProgress.Instance.AddPackCount(cacheVodic.Count);
            }

            return(cacheVodic);
        }
예제 #23
0
        public static CacheVo CheckLoveStoryCache(int cardId)
        {
            Stopwatch sw = Stopwatch.StartNew();

            CacheVo vo = new CacheVo();

            ResIndex resIndex = GetIndexFile(ResPath.LoveStoryIndex);

            if (resIndex == null || resIndex.packageDict.ContainsKey(cardId.ToString()) == false)
            {
                return(vo);
            }

            ResPack resPack = resIndex.packageDict[cardId.ToString()];

            _releasePath = resPack.releasePath;
            foreach (var resItem in resPack.items)
            {
                FileInfo fileInfo =
                    new FileInfo(AssetLoader.ExternalHotfixPath + "/" + _releasePath + "/" + resItem.Path);

                if (fileInfo.Exists == false || fileInfo.Length != resItem.Size)
                {
                    vo.needDownload = true;
                    break;
                }
            }

            vo.sizeList = new List <long>()
            {
                resPack.packageSize
            };

            Debug.LogError("CheckLoveStoryCache 时间:" + sw.ElapsedMilliseconds);

            return(vo);
        }
예제 #24
0
        public static void DownloadAllAudio(Action <string> onComplete = null, string tag = null)
        {
            _onComplete = onComplete;
            _tag        = tag;

            ResIndex resIndex = GetIndexFile(ResPath.AllAudioIndex);
            ResPack  resPack  = resIndex.packageDict["AllAudio"];

            _releasePath = resPack.releasePath;
            if (resPack.packageType == FileType.Zip)
            {
                ResItem item = new ResItem()
                {
                    Md5  = resPack.packageMd5,
                    Path = AppConfig.Instance.assetsServer + "/" + AppConfig.Instance.version + "/" +
                           resPack.downloadPath,
                    Size     = resPack.packageSize,
                    FileType = resPack.packageType
                };

                _downloadingWindow          = PopupManager.ShowWindow <DownloadingWindow>(Constants.DownloadingWindowPath);
                _downloadingWindow.Content  = I18NManager.Get("Download_Downloading");
                _downloadingWindow.Progress = I18NManager.Get("Download_Progress", 0);
                var downItem = DownloadManager.Load(item, AssetLoader.ExternalDownloadPath + "/" + resPack.downloadPath,
                                                    OnComplete,
                                                    OnError, OnProgressAll);

                _downloadingWindow.WindowActionCallback = evt =>
                {
                    if (evt == WindowEvent.Cancel)
                    {
                        downItem.Cancel();
                    }
                };
            }
        }
예제 #25
0
    private static void LoadIndexJson(string jsonPath, ref Dictionary <string, bool> fileDitc, bool exclude = false)
    {
        string str = FileUtil.ReadFileText(PackageManager.OutputPath + jsonPath + ".json");

        if (string.IsNullOrEmpty(str))
        {
            return;
        }

        ResIndex resIndex = JsonConvert.DeserializeObject <ResIndex>(str);

        int count = 0;

        foreach (var resPack in resIndex.packageDict)
        {
            string releasePath = resPack.Value.releasePath;
            foreach (var item in resPack.Value.items)
            {
                string key = releasePath + "/" + item.Path.ToLower();
                if (exclude)
                {
                    count++;
                    fileDitc.Remove(key);
                }
                else if (fileDitc.ContainsKey(key) == false)
                {
                    fileDitc.Add(key, true);
                }
            }
        }

        if (count > 0)
        {
            Debug.Log("<color='#660000>排除音频文件数量:" + count + "</color>");
        }
    }
예제 #26
0
        public static void DownloadEvoCard(int cardId, Action <string> onComplete = null, string tag = null)
        {
            _onComplete = onComplete;
            _tag        = tag;

            ResIndex resIndex = GetIndexFile(ResPath.EvoCardIndex);
            ResPack  resPack  = resIndex.packageDict["EvoCard"];

            string  id      = cardId + ".bytes";
            ResItem resItem = null;

            foreach (var item in resPack.items)
            {
                if (item.Path == id)
                {
                    resItem = item;
                    break;
                }
            }

            if (resItem == null)
            {
                FlowText.ShowMessage(I18NManager.Get("Download_IndexNoExist") + cardId);
            }
            else
            {
                resItem.Path = AppConfig.Instance.assetsServer + "/" + AppConfig.Instance.version + "/" +
                               resPack.downloadPath + "/" + id;

                _downloadingWindow          = PopupManager.ShowWindow <DownloadingWindow>(Constants.DownloadingWindowPath);
                _downloadingWindow.Content  = I18NManager.Get("Download_Downloading");
                _downloadingWindow.Progress = I18NManager.Get("Download_Progress", 0);
                DownloadManager.Load(resItem, AssetLoader.ExternalHotfixPath + "/" + resPack.releasePath + "/" + id,
                                     OnCompleteEvoCard, OnErrorEvoCard, OnProgress);
            }
        }
예제 #27
0
    static void CopyFile_AllAudio(BlackList blackList)
    {
        Stopwatch sw = Stopwatch.StartNew();

        string dir1 = GetPackageDir() + "/LoveStoryAudio";
        string dir2 = GetPackageDir() + "/StoryAudio";
        string dir3 = GetPackageDir() + "/PhoneAudio";

        string destDir = GetPackageDir() + "/AllAudio";

        if (Directory.Exists(destDir))
        {
            Directory.Delete(destDir, true);
        }

        Directory.CreateDirectory(destDir);

        string[] files = Directory.GetFiles(dir1, "*", SearchOption.AllDirectories);
        CopyFile(files, destDir + "/story/dubbing");

        files = Directory.GetFiles(dir2, "*", SearchOption.AllDirectories);
        CopyFile(files, destDir + "/story/dubbing");

        files = Directory.GetFiles(dir3, "*", SearchOption.AllDirectories);
        CopyFile(files, destDir + "/music/phonedialogs");

        //压缩文件
        string packagePath = OutputPath + "AllAudio";

        if (Directory.Exists(packagePath))
        {
            Directory.Delete(packagePath, true);
        }
        Directory.CreateDirectory(packagePath);

        string zipFileName = packagePath + "/AllAudio.zip";

        files = Directory.GetFiles(destDir, "*", SearchOption.AllDirectories);

        EditorUtility.DisplayProgressBar("压缩", "正在压缩文件(" + Path.GetFileName(packagePath), 1);

        List <string> pathInZipList = new List <string>();

        for (int i = 0; i < files.Length; i++)
        {
            string str = Path.GetDirectoryName(files[i]);
            str = str.Replace("\\", "/");
            str = str.Replace(GetPackageDir().Replace("\\", "/") + "/AllAudio/", "");
            pathInZipList.Add(str + "/");
        }

        ZipUtil.CreateZip(files, zipFileName, pathInZipList.ToArray(), 0);

        EditorUtility.ClearProgressBar();

        //生成Index文件
        string releasePath = "AssetBundles/" + SystemTag + "/";

        ResIndex resIndex = new ResIndex();

        resIndex.language    = Language;
        resIndex.belong      = "AllAudio";
        resIndex.packageDict = new Dictionary <string, ResPack>();

        files = Directory.GetFiles(destDir, "*", SearchOption.AllDirectories);
        ResPack resPack = new ResPack();

        resPack.id           = "AllAudio";
        resPack.items        = new List <ResItem>();
        resPack.packageType  = FileType.Zip;
        resPack.packageMd5   = MD5Util.Get(packagePath + "/" + resPack.id + ".zip");
        resPack.packageSize  = new FileInfo(packagePath + "/" + resPack.id + ".zip").Length;
        resPack.downloadPath = GetPackageStorePath() + "/" + resIndex.belong + "/" + resPack.id + ".zip";
        resPack.releasePath  = releasePath;
        resIndex.packageDict.Add(resPack.id, resPack);

        string json = JsonConvert.SerializeObject(resIndex, Formatting.Indented);

        FileUtil.SaveFileText(OutputPath, ResPath.AllAudioIndex + ".json", json);

        Debug.Log("<color='#00ff66'>CopyFile_AllAudio耗时:" + sw.ElapsedMilliseconds / 1000.0f + "</color>");
    }
예제 #28
0
    public static void CreateMultiZipAndJson(ExcelWorksheet worksheet, string resId)
    {
        Stopwatch sw = Stopwatch.StartNew();

        ResIndex resIndex = new ResIndex();

//        1内容	2筛选路径	3白名单	4黑名单 5ID
        var row = worksheet.Dimension.End.Row;

        List <BundleFilter> filterList = new List <BundleFilter>();
        BundleFilter        filter     = null;

        for (int i = 2; i < row; i++)
        {
            object date = worksheet.Cells[i, 2].Value;
            if (date != null)
            {
                filter = new BundleFilter();
                filterList.Add(filter);
                filter.DirPath = date.ToString().Replace("\\", "/");

                string rootFolder = filter.DirPath;

                rootFolder = PackageManager.GetAssetBundleDir() + "/" + rootFolder;

                filter.BlackList = new BlackList();
                filter.WhiteList = new WhiteList();

                filter.BlackList.RootFolder = rootFolder;
                filter.WhiteList.RootFolder = rootFolder;

                AddToNameList(filter.WhiteList, worksheet.Cells[i, 3].Value);
                AddToNameList(filter.BlackList, worksheet.Cells[i, 4].Value);

                filter.Id = worksheet.Cells[i, 5].Value.ToString();
            }
            else
            {
                AddToNameList(filter.WhiteList, worksheet.Cells[i, 3].Value);
                AddToNameList(filter.BlackList, worksheet.Cells[i, 4].Value);
            }
        }

        resIndex.belong      = resId;
        resIndex.language    = PackageManager.Language;
        resIndex.packageDict = new Dictionary <string, ResPack>();

        Debug.Log("<color='#00ff00'>" + resId + "时间1->" + sw.ElapsedMilliseconds + "</color>");

        DeleteFile(resIndex);

        Debug.Log("<color='#00ff00'>" + resId + "时间2.1->" + sw.ElapsedMilliseconds + "</color>");

        string packagePath = PackageManager.OutputPath + resId;

        if (Directory.Exists(packagePath))
        {
            Directory.Delete(packagePath, true);
        }
        Directory.CreateDirectory(packagePath);

        string releasePath = "AssetBundles/" + PackageManager.SystemTag;

        foreach (var bundleFilter in filterList)
        {
            List <FileInfo> files = bundleFilter.SearchFile();

            ResPack resPack = new ResPack();
            resPack.id           = bundleFilter.Id;
            resPack.releasePath  = releasePath;
            resPack.packageType  = FileType.Zip;
            resPack.downloadPath =
                PackageManager.GetPackageStorePath() + "/" + resIndex.belong + "/" + resPack.id + ".zip";
            resPack.items = new List <ResItem>();
            resIndex.packageDict.Add(resPack.id, resPack);

            foreach (var fileInfo in files)
            {
                ResItem resItem = new ResItem();
                resItem.Path = GetRelatePath(fileInfo.FullName);
                resItem.Md5  = MD5Util.Get(fileInfo.FullName);
                resItem.Size = fileInfo.Length;
                resPack.items.Add(resItem);

                CopyFile(fileInfo.FullName, PackageManager.GetPackageDir() + "/" + resId + "/" + resItem.Path);
            }
        }

        Debug.Log("<color='#00ff00'>" + resId + "时间2.2->" + sw.ElapsedMilliseconds + "</color>");

        foreach (var resPack in resIndex.packageDict)
        {
            string zipFileName = packagePath + "/" + resPack.Value.id + ".zip";

            List <string> fileList = new List <string>();
            string        rootPath = PackageManager.GetPackageDir().Replace("\\", "/") + "/" + resId + "/";
            foreach (var item in resPack.Value.items)
            {
                fileList.Add(rootPath + item.Path);
            }

            EditorUtility.DisplayProgressBar("压缩", "正在压缩文件(" + Path.GetFileName(packagePath) + ")", 1);

            List <string> pathInZipList = new List <string>();
            for (int i = 0; i < fileList.Count; i++)
            {
                string str = Path.GetDirectoryName(fileList[i]);
                str = str.Replace("\\", "/");
                str = str.Replace(
                    PackageManager.GetPackageDir().Replace("\\", "/") + "/" + resId + "/", "");

                pathInZipList.Add(str + "/");
            }

            ZipUtil.CreateZip(fileList.ToArray(), zipFileName, pathInZipList.ToArray(), 0);

            EditorUtility.ClearProgressBar();

            resPack.Value.packageMd5  = MD5Util.Get(zipFileName);
            resPack.Value.packageSize = new FileInfo(zipFileName).Length;
        }

        Debug.Log("<color='#00ff00'>" + resId + "时间3->" + sw.ElapsedMilliseconds + "</color>");

        string json = JsonConvert.SerializeObject(resIndex, Formatting.Indented);

        FileUtil.SaveFileText(PackageManager.OutputPath, resId + ".json", json);
    }
예제 #29
0
    public static void CreateSingleZipAndJson(ExcelWorksheet worksheet, string resId)
    {
        ResIndex resIndex = new ResIndex();

//        1内容	2筛选路径 3白名单 4黑名单
        var row = worksheet.Dimension.End.Row;

        List <BundleFilter> filterList = new List <BundleFilter>();
        BundleFilter        filter     = null;

        for (int i = 2; i < row; i++)
        {
            object date = worksheet.Cells[i, 2].Value;
            if (date != null)
            {
                filter = new BundleFilter();
                filterList.Add(filter);
                filter.DirPath = date.ToString();

                string rootFolder = filter.DirPath;

                rootFolder = PackageManager.GetAssetBundleDir() + "/" + rootFolder;

                filter.BlackList = new BlackList();
                filter.WhiteList = new WhiteList();

                filter.BlackList.RootFolder = rootFolder;
                filter.WhiteList.RootFolder = rootFolder;

                AddToNameList(filter.WhiteList, worksheet.Cells[i, 3].Value);
                AddToNameList(filter.BlackList, worksheet.Cells[i, 4].Value);
            }
            else
            {
                AddToNameList(filter.WhiteList, worksheet.Cells[i, 3].Value);
                AddToNameList(filter.BlackList, worksheet.Cells[i, 4].Value);
            }
        }

        resIndex.belong      = resId;
        resIndex.language    = PackageManager.Language;
        resIndex.packageDict = new Dictionary <string, ResPack>();

        Dictionary <string, FileInfo> fileDict = new Dictionary <string, FileInfo>();

        if (resId == ResPath.AppStart)
        {
            //把共享音频放到AppStart里面下载
            string root = PackageManager.GetAssetBundleDir();
            foreach (var id in PackageManager.sharedAudioDict)
            {
                FileInfo fileInfo = new FileInfo(root + "/story/dubbing/" + id.Key + ".bytes");
                string   key      = fileInfo.FullName.Replace("\\", "/");
                fileDict.Add(key, fileInfo);
            }
        }

        foreach (var bundleFilter in filterList)
        {
            List <FileInfo> files = bundleFilter.SearchFile();
            foreach (var fileInfo in files)
            {
                string key = fileInfo.FullName.Replace("\\", "/");
                if (!fileDict.ContainsKey(key))
                {
                    fileDict.Add(key, fileInfo);
                }
            }
        }

        ResPack resPack = new ResPack();

        resPack.id           = resIndex.belong;
        resPack.releasePath  = "AssetBundles/" + PackageManager.SystemTag;
        resPack.downloadPath = PackageManager.GetPackageStorePath() + "/" + resIndex.belong + "/" + resPack.id + ".zip";
        resPack.items        = new List <ResItem>();
        resPack.packageType  = FileType.Zip;
        resIndex.packageDict.Add(resPack.id, resPack);
        foreach (var fileInfo in fileDict)
        {
            ResItem resItem = new ResItem();
            resItem.Path = GetRelatePath(fileInfo.Value.FullName);
            resItem.Md5  = MD5Util.Get(fileInfo.Key);
            resItem.Size = fileInfo.Value.Length;
            resPack.items.Add(resItem);
        }

        DeleteFile(resIndex);
        CopyFile(resIndex);

        string packagePath = PackageManager.OutputPath + resPack.id;

        if (Directory.Exists(packagePath))
        {
            Directory.Delete(packagePath, true);
        }
        Directory.CreateDirectory(packagePath);

        string zipFileName = packagePath + "/" + resPack.id + ".zip";

        string destDir = PackageManager.GetPackageDir() + "/" + resPack.id;

        string[] fileList = Directory.GetFiles(destDir, "*", SearchOption.AllDirectories);

        EditorUtility.DisplayProgressBar("压缩", "正在压缩文件(" + Path.GetFileName(packagePath), 1);

        List <string> pathInZipList = new List <string>();

        for (int i = 0; i < fileList.Length; i++)
        {
            string str = Path.GetDirectoryName(fileList[i]);
            str = str.Replace("\\", "/");
            str = str.Replace(PackageManager.GetPackageDir().Replace("\\", "/") + "/" + resPack.id + "/", "");
            pathInZipList.Add(str + "/");
        }

        ZipUtil.CreateZip(fileList, zipFileName, pathInZipList.ToArray(), 0);

        EditorUtility.ClearProgressBar();

        resPack.packageMd5  = MD5Util.Get(zipFileName);
        resPack.packageSize = new FileInfo(zipFileName).Length;
        string json = JsonConvert.SerializeObject(resIndex, Formatting.Indented);

        FileUtil.SaveFileText(PackageManager.OutputPath, resId + ".json", json);
    }
예제 #30
0
    private static void CreateSpecial(ExcelWorksheet worksheet, string resId)
    {
        ResIndex resIndex = new ResIndex();

        resIndex.packageDict = new Dictionary <string, ResPack>();

//        1内容	2筛选路径	3白名单	4黑名单 5ID
        var row = worksheet.Dimension.End.Row;

        List <BundleFilter> filterList = new List <BundleFilter>();
        BundleFilter        filter     = null;

        for (int i = 2; i < row; i++)
        {
            object date = worksheet.Cells[i, 2].Value;
            if (date != null)
            {
                filter = new BundleFilter();
                filterList.Add(filter);
                filter.DirPath = date.ToString().Replace("\\", "/");

                string rootFolder = filter.DirPath;

                rootFolder = PackageManager.GetAssetBundleDir() + "/" + rootFolder;

                filter.BlackList = new BlackList();
                filter.WhiteList = new WhiteList();

                filter.BlackList.RootFolder = rootFolder;
                filter.WhiteList.RootFolder = rootFolder;

                AddToNameList(filter.WhiteList, worksheet.Cells[i, 3].Value);
                AddToNameList(filter.BlackList, worksheet.Cells[i, 4].Value);

                filter.Id = worksheet.Cells[i, 5].Value.ToString();
            }
            else
            {
                AddToNameList(filter.WhiteList, worksheet.Cells[i, 3].Value);
                AddToNameList(filter.BlackList, worksheet.Cells[i, 4].Value);
            }
        }

        Dictionary <string, FileInfo> fileDict = new Dictionary <string, FileInfo>();

        foreach (var bundleFilter in filterList)
        {
            List <FileInfo> files = bundleFilter.SearchFile();
            foreach (var fileInfo in files)
            {
                string key = fileInfo.FullName.Replace("\\", "/");
                if (!fileDict.ContainsKey(key))
                {
                    fileDict.Add(key, fileInfo);
                }
            }
            string releasePath = "AssetBundles/" + PackageManager.SystemTag;

            ResPack resPack = new ResPack();
            resPack.id           = bundleFilter.Id;
            resPack.downloadPath = PackageManager.GetPackageStorePath() + "/" + resId;
            resPack.releasePath  = releasePath;
            resPack.items        = new List <ResItem>();
            resIndex.packageDict.Add(resPack.id, resPack);
            foreach (var fileInfo in fileDict)
            {
                ResItem resItem = new ResItem();
                resItem.Path        = GetRelatePath(fileInfo.Value.FullName);
                resItem.Md5         = MD5Util.Get(fileInfo.Key);
                resItem.Size        = fileInfo.Value.Length;
                resPack.packageType = FileType.Original;
                resPack.items.Add(resItem);

                CopyFile(fileInfo.Value.FullName, PackageManager.OutputPath + resId + "/" + resItem.Path);
            }
        }

        string json = JsonConvert.SerializeObject(resIndex, Formatting.Indented);

        FileUtil.SaveFileText(PackageManager.OutputPath, resId + ".json", json);
    }