From 370f0e99db662cc39d20e52b40577889ef62de5b Mon Sep 17 00:00:00 2001 From: JianMiau Date: Mon, 29 Aug 2022 11:23:07 +0800 Subject: [PATCH] [del] HUD --- assets/Script/Engine/CatanEngine/TableV3.meta | 13 + assets/Script/Engine/Component.meta | 13 + assets/Script/Engine/Data.meta | 13 + .../Script/Engine/HUD/AssetBundleMamager.ts | 456 --------------- .../Engine/HUD/AssetBundleMamager.ts.meta | 10 - assets/Script/Engine/HUD/HUDM.ts | 425 -------------- assets/Script/Engine/HUD/HUDM.ts.meta | 10 - .../Engine/HUDV2/AssetBundleMamagerV2.ts | 522 ------------------ .../Engine/HUDV2/AssetBundleMamagerV2.ts.meta | 10 - assets/Script/Engine/HUDV2/Enum_Loading.ts | 72 --- .../Script/Engine/HUDV2/Enum_Loading.ts.meta | 10 - assets/Script/Engine/HUDV2/GameData_HUD.ts | 43 -- .../Script/Engine/HUDV2/GameData_HUD.ts.meta | 10 - assets/Script/Engine/Timer.meta | 13 + assets/Script/Engine/Utils.meta | 13 + tslint.json | 218 ++++---- 16 files changed, 170 insertions(+), 1681 deletions(-) create mode 100644 assets/Script/Engine/CatanEngine/TableV3.meta create mode 100644 assets/Script/Engine/Component.meta create mode 100644 assets/Script/Engine/Data.meta delete mode 100644 assets/Script/Engine/HUD/AssetBundleMamager.ts delete mode 100644 assets/Script/Engine/HUD/AssetBundleMamager.ts.meta delete mode 100644 assets/Script/Engine/HUD/HUDM.ts delete mode 100644 assets/Script/Engine/HUD/HUDM.ts.meta delete mode 100644 assets/Script/Engine/HUDV2/AssetBundleMamagerV2.ts delete mode 100644 assets/Script/Engine/HUDV2/AssetBundleMamagerV2.ts.meta delete mode 100644 assets/Script/Engine/HUDV2/Enum_Loading.ts delete mode 100644 assets/Script/Engine/HUDV2/Enum_Loading.ts.meta delete mode 100644 assets/Script/Engine/HUDV2/GameData_HUD.ts delete mode 100644 assets/Script/Engine/HUDV2/GameData_HUD.ts.meta create mode 100644 assets/Script/Engine/Timer.meta create mode 100644 assets/Script/Engine/Utils.meta diff --git a/assets/Script/Engine/CatanEngine/TableV3.meta b/assets/Script/Engine/CatanEngine/TableV3.meta new file mode 100644 index 0000000..793825a --- /dev/null +++ b/assets/Script/Engine/CatanEngine/TableV3.meta @@ -0,0 +1,13 @@ +{ + "ver": "1.1.3", + "uuid": "c12c11f7-2e17-4727-a114-d4b19dfbe650", + "importer": "folder", + "isBundle": false, + "bundleName": "", + "priority": 1, + "compressionType": {}, + "optimizeHotUpdate": {}, + "inlineSpriteFrames": {}, + "isRemoteBundle": {}, + "subMetas": {} +} \ No newline at end of file diff --git a/assets/Script/Engine/Component.meta b/assets/Script/Engine/Component.meta new file mode 100644 index 0000000..1f0bf4b --- /dev/null +++ b/assets/Script/Engine/Component.meta @@ -0,0 +1,13 @@ +{ + "ver": "1.1.3", + "uuid": "63dab366-ead1-4057-a9c2-a2548219328e", + "importer": "folder", + "isBundle": false, + "bundleName": "", + "priority": 1, + "compressionType": {}, + "optimizeHotUpdate": {}, + "inlineSpriteFrames": {}, + "isRemoteBundle": {}, + "subMetas": {} +} \ No newline at end of file diff --git a/assets/Script/Engine/Data.meta b/assets/Script/Engine/Data.meta new file mode 100644 index 0000000..745e802 --- /dev/null +++ b/assets/Script/Engine/Data.meta @@ -0,0 +1,13 @@ +{ + "ver": "1.1.3", + "uuid": "edf98a7e-294c-4e7a-8a53-c0b10ea75a45", + "importer": "folder", + "isBundle": false, + "bundleName": "", + "priority": 1, + "compressionType": {}, + "optimizeHotUpdate": {}, + "inlineSpriteFrames": {}, + "isRemoteBundle": {}, + "subMetas": {} +} \ No newline at end of file diff --git a/assets/Script/Engine/HUD/AssetBundleMamager.ts b/assets/Script/Engine/HUD/AssetBundleMamager.ts deleted file mode 100644 index 7d826bf..0000000 --- a/assets/Script/Engine/HUD/AssetBundleMamager.ts +++ /dev/null @@ -1,456 +0,0 @@ -import BusinessTypeSetting from "../../_BusinessTypeSetting/BusinessTypeSetting"; -import LocalStorageData from "../Data/LocalStorageData"; -import Enum_Loading from "../HUDV2/Enum_Loading"; -import HUDM from "./HUDM"; - -export default class AssetBundleMamager { - //#region static 屬性 - - private static _instance: AssetBundleMamager = null; - public static get Instance(): AssetBundleMamager { return AssetBundleMamager._instance; } - - //#endregion - - //#region public 屬性 - - public HUGroup: Map = new Map(); - - /** 本地VerList */ - public LocalVerList: Enum_Loading.VerListObj = null; - - /** 遠端VerList */ - public RemoteVerList: Enum_Loading.VerListObj = null; - - public DownloadList_Preview: Object = {}; - - /** IsChangeBundleUrl */ - public IsChangeBundleUrl: boolean = false; - - //#endregion - - //#region Lifecycle - - constructor() { - AssetBundleMamager._instance = this; - CC_PREVIEW && this._initdownloadList_Preview(); - } - - //#endregion - - //#region Custom Function - - /** - * 取得Bundle - * @param {string} BundleName Bundle名稱 - * @param {string} Version 版號 - * @return {cc.AssetManager.Bundle} Bundle - */ - public *GetBundle(BundleName: string, Version: string = ""): IterableIterator { - let bundle: cc.AssetManager.Bundle = cc.assetManager.getBundle(BundleName); - if (bundle) { - return bundle; - } - - // options是可选参数,引擎会根据保留字段 进行对应的操作,这里添加了version和onFileProgress,可用来记录热更资源版本和下载进度 - let options: any = null; - - let BundleUrl: string = BundleName; - if (cc.sys.isNative && !this.LocalVerList[BundleName].UseLocal) { - BundleUrl = `${(jsb.fileUtils ? jsb.fileUtils.getWritablePath() : "/")}Bundle/${BundleName}/remote/${BundleName}`; - options = { - version: Version - }; - } - - cc.assetManager.loadBundle(BundleUrl, options, (err: Error, resp: cc.AssetManager.Bundle) => { - if (err) { - cc.error(err); - bundle = null; - } - bundle = resp; - }); - while (typeof bundle === "undefined") { - yield null; - } - - return bundle; - } - - /** - * 更新Bundle - * @param {HUDM} HUDName HUD - */ - public *UpdateBundle(HUDName: HUDM | string, onFileProgress?: (finish: number, total: number, item: string) => void): IterableIterator { - let HUD: HUDM; - if (HUDName instanceof HUDM) { - HUD = HUDName; - } else { - HUD = this.GetHUD(HUDName); - } - let UpdateingData: Enum_Loading.UpdateingDataObj = yield* HUD.HUD(onFileProgress); - if (UpdateingData.IsUpdatecomplete) { - this.LocalVerList[HUD.BundleName] = this.RemoteVerList[HUD.BundleName]; - this.LocalVerList[HUD.BundleName]["UseLocal"] = false; - LocalStorageData.Instance.LocalVerList = JSON.stringify(this.LocalVerList); - } - return UpdateingData; - } - - /** - * 更新Bundle - * @param {HUDM} HUDName HUD - */ - public *RetryUpdateBundle(HUDName: HUDM | string, onFileProgress?: (finish: number, total: number, item: string) => void): IterableIterator { - let HUD: HUDM; - if (HUDName instanceof HUDM) { - HUD = HUDName; - } else { - HUD = this.GetHUD(HUDName); - } - let UpdateingData: Enum_Loading.UpdateingDataObj = yield* HUD.RetryDownLoadFailedAssets(); - return UpdateingData; - } - - /** - * 從Bundle取得資源 - * @param {cc.AssetManager.Bundle | string} BundleName Bundle名稱 - * @param {string} SourceName 資源名稱 - * @param {string} type 資源型別 - * @return {any} Source - */ - public *GetBundleSource(BundleName: cc.AssetManager.Bundle | string, SourceName: string, type?: string | Bundle_Source_Type, onFileProgress?: (finish: number, total: number, item: cc.AssetManager.RequestItem) => void): IterableIterator { - let bundle: cc.AssetManager.Bundle; - let source: any; - if (BundleName instanceof cc.AssetManager.Bundle) { - bundle = BundleName; - } else { - bundle = cc.assetManager.getBundle(BundleName); - if (!bundle) { - cc.error(`GetBundleSource Error BundleName: ${BundleName}`); - return null; - } - } - - switch (type) { - case Bundle_Source_Type.Scene: { - bundle.loadScene(SourceName, onFileProgress, function (err: Error, scene: cc.SceneAsset): void { - if (err) { - cc.error(err); - return null; - } - // cc.director.runScene(scene); - source = scene; - }); - break; - } - - case Bundle_Source_Type.Json: { - bundle.load(SourceName, onFileProgress, function (err: Error, json: cc.JsonAsset): void { - if (err) { - cc.error(err); - return null; - } - // source = JSON.parse(json["_nativeAsset"]); - source = json; - }); - break; - } - - case Bundle_Source_Type.Prefab: { - bundle.load(SourceName, cc.Prefab, onFileProgress, function (err: Error, prefab: cc.Asset): void { - if (err) { - cc.error(err); - return null; - } - // source = JSON.parse(json["_nativeAsset"]); - source = prefab; - }); - break; - } - - default: - bundle.load(SourceName, function (err: Error, any: any): void { - if (err) { - cc.error(err); - return null; - } - source = any; - }); - break; - } - - while (typeof source === "undefined") { - yield null; - } - return source; - } - - /** - * 釋放Bundle - * @param {string} slotID slotID - */ - public *BundleRelease(slotID: number): IterableIterator { - let gameName: string = `Game_${slotID}`; - let sceneName: string = `Slot${slotID}`; - let bundle: cc.AssetManager.Bundle = cc.assetManager.getBundle(gameName); - if (!bundle) { - cc.log(`BundleRelease Error BundleName: ${gameName}`); - return; - } - - // let bundles: cc.AssetManager.Cache = cc.assetManager.bundles; - // let cacheDir: string = cc.assetManager.cacheManager.cacheDir; - // let cachedFiles: Object = cc.assetManager.cacheManager.cachedFiles; - - yield* this.DelBundleCache(bundle); - yield* this.DelOthersCache(slotID); - bundle.release(sceneName, cc.SceneAsset); - cc.assetManager.removeBundle(bundle); - cc.sys.garbageCollect(); - } - - /** - * 從Bundle刪除暫存資源 - * @param {string} BundleName Bundle名稱 - */ - public *DelBundleCache(BundleName: cc.AssetManager.Bundle | string): IterableIterator { - if (!CC_JSB) { - return; - } - let bundle: cc.AssetManager.Bundle; - let source: any; - if (BundleName instanceof cc.AssetManager.Bundle) { - bundle = BundleName; - } else { - bundle = cc.assetManager.getBundle(BundleName); - if (!bundle) { - // cc.error(`GetBundleSource Error BundleName: ${BundleName}`); - // return; - bundle = yield* AssetBundleMamager.Instance.GetBundle(BundleName, this.RemoteVerList[BundleName].Version); - } - } - - let _map: Object = bundle["_config"].assetInfos._map; - for (let map of Object.keys(_map)) { - let path: string = _map[map].path; - if (!path) { - break; - } - source = yield* AssetBundleMamager.Instance.GetBundleSource(bundle, path); - cc.assetManager.cacheManager.removeCache(source.nativeUrl); - bundle.release(path); - // return; - } - } - - /** - * 從cachedFiles刪除暫存資源 - * @param {number} slotID slotID - */ - public *DelOthersCache(slotID: number): IterableIterator { - if (!CC_JSB) { - return; - } - let cachedFiles: Object = cc.assetManager.cacheManager.cachedFiles["_map"]; - let delcache_group: string[] = [`shared/jsons`, `Slot/Slot${slotID}`, "sounds/Slot/Default", `${BusinessTypeSetting.FolderUrlBundle}project.manifest`, "submit.txt"]; - for (let cached of Object.keys(cachedFiles)) { - for (var i: number = 0; i < delcache_group.length; ++i) { - let delcache: string = delcache_group[i]; - if (cached.includes(delcache)) { - cc.assetManager.cacheManager.removeCache(cached); - // console.log(`removeCache: ${cached}`); - break; - } - } - } - } - - public GetHUD(BundleName: HUDM | string): HUDM { - let HUD: HUDM; - if (BundleName instanceof HUDM) { - HUD = BundleName; - } else { - if (!this.HUGroup.has(BundleName)) { - HUD = new HUDM(BundleName); - this.HUGroup.set(BundleName, HUD); - } else { - HUD = this.HUGroup.get(BundleName); - } - HUD = this.HUGroup.get(BundleName); - } - return HUD; - } - - /** 刪除全部暫存資源 */ - public ClearAllCache(): void { - cc.assetManager.cacheManager.clearCache(); - cc.game.restart(); - } - - - public *CheckBundleNeedHUD(BundleName: HUDM | string): IterableIterator { - let HUD: HUDM; - if (BundleName instanceof HUDM) { - HUD = BundleName; - } else { - HUD = this.GetHUD(BundleName); - } - if (!this.LocalVerList[HUD.BundleName]) { - this.LocalVerList[HUD.BundleName] = new Enum_Loading.BundleDataObj(); - let apkVersion: string = this.RemoteVerList[HUD.BundleName].ApkVersion; - if (apkVersion && apkVersion !== "0") { - this.LocalVerList[HUD.BundleName].UseLocal = true; - this.LocalVerList[HUD.BundleName].Version = apkVersion; - } - LocalStorageData.Instance.LocalVerList = JSON.stringify(this.LocalVerList); - } else { - if (this.RemoteVerList[HUD.BundleName].Version === this.RemoteVerList[HUD.BundleName].ApkVersion) { - this.LocalVerList[HUD.BundleName] = this.RemoteVerList[HUD.BundleName]; - this.LocalVerList[HUD.BundleName].UseLocal = true; - } - } - let UpdateData: Enum_Loading.NeedUpdateDataObj = new Enum_Loading.NeedUpdateDataObj(); - if (this.LocalVerList[HUD.BundleName].UseLocal) { - UpdateData.IsNeedUpdate = AssetBundleMamager.Instance.versionCompareHandle(this.LocalVerList[HUD.BundleName].Version, this.RemoteVerList[HUD.BundleName].Version) < 0 ? true : false; - if (UpdateData.IsNeedUpdate) { - UpdateData = yield* HUD.CheckUpdate(); - } - } else { - UpdateData = yield* HUD.CheckUpdate(); - } - return UpdateData; - } - - // public *CheckBundleNeedHUD(BundleName: string): IterableIterator { - // if (!this.LocalVerList[BundleName]) { - // this.LocalVerList[BundleName] = new Enum_Loading.BundleDataObj(); - // let apkVersion: string = this.RemoteVerList[BundleName].ApkVersion; - // if (apkVersion && apkVersion !== "0") { - // this.LocalVerList[BundleName].UseLocal = true; - // this.LocalVerList[BundleName].Version = apkVersion; - // } - // LocalStorageData.Instance.LocalVerList = JSON.stringify(this.LocalVerList); - // } - // let IsUpdate: boolean = AssetBundleMamager.Instance.versionCompareHandle(this.LocalVerList[BundleName].Version, this.RemoteVerList[BundleName].Version) < 0 ? true : false; - // return IsUpdate; - // } - - public CheckGameNeedUpdate(GameID: number): boolean { - let IsUpdate: boolean = false; - let bundleName: string = `Game_${GameID}`; - if (!this.RemoteVerList[bundleName]) { - this.RemoteVerList[bundleName] = new Enum_Loading.BundleDataObj(); - this.RemoteVerList[bundleName].HasBundle = false; - LocalStorageData.Instance.RemoteVerList = JSON.stringify(this.RemoteVerList); - IsUpdate = true; - } - if (!this.LocalVerList[bundleName]) { - this.LocalVerList[bundleName] = new Enum_Loading.BundleDataObj(); - let apkVersion: string = this.RemoteVerList[bundleName].ApkVersion; - if (apkVersion && apkVersion !== "0") { - this.LocalVerList[bundleName].UseLocal = true; - this.LocalVerList[bundleName].Version = apkVersion; - } - LocalStorageData.Instance.LocalVerList = JSON.stringify(this.LocalVerList); - } - if (CC_PREVIEW) { - return this._getIsDownload_Preview(GameID); - } - if (IsUpdate) { - return IsUpdate; - } - IsUpdate = AssetBundleMamager.Instance.versionCompareHandle(this.LocalVerList[bundleName].Version, this.RemoteVerList[bundleName].Version) < 0 ? true : false; - return IsUpdate; - } - - /** - * 比對版號(熱更能從1.0.0更新到2.0.0,從2.0.0回退到1.0.0) - * 官方提供的版本比較函數,只有服務端版本>客戶端版本時,才會進行更新。所以不能從2.0.0回退到1.0.0版本。 - * @param {string} versionA 本地版號 - * @param {string} versionB 遠程版號 - * @return {number} num = -1 須更新 - * @return {number} num = 0 不須更新 - */ - public versionCompareHandle(versionA: string, versionB: string): number { - // console.log("Ver A " + versionA + "VerB " + versionB); - var vA: string[] = versionA.split("."); - var vB: string[] = versionB.split("."); - - // 長度不相等,則進行更新 - if (vA.length !== vB.length) { - return -1; - } - - for (var i: number = 0; i < vA.length; ++i) { - var a: number = +vA[i]; - var b: number = +vB[i] || 0; - if (a === b) { - // 數字相同,則跳過 - continue; - } else { - // 數字不同,則進行更新 - return -1; - } - } - - // 長度相等且數字相等,則不更新 - return 0; - } - - //#endregion - - //#region DownloadList_Preview - - private _initdownloadList_Preview(): void { - this.DownloadList_Preview = JSON.parse(LocalStorageData.Instance.DownloadList_Preview); - this.DownloadList_Preview = this.DownloadList_Preview ? this.DownloadList_Preview : {}; - } - - private _getIsDownload_Preview(slotID: number): boolean { - if (!this.DownloadList_Preview[slotID]) { - this.SetIsDownload_Preview(slotID, false); - } - return !this.DownloadList_Preview[slotID]; - } - - public SetIsDownload_Preview(slotID: number, isDownload: boolean = true): void { - this.DownloadList_Preview[slotID] = isDownload; - LocalStorageData.Instance.DownloadList_Preview = JSON.stringify(this.DownloadList_Preview); - } - - //#endregion -} - -//#region enum - -/** Bundle資源類型 */ -export enum Bundle_Source_Type { - /** Json */ - Json = "json", - - /** Scene */ - Scene = "scene", - - /** Prefab */ - Prefab = "prefab" -} - -//#endregion - -//#region 廢棄 Function - -// /** -// * 從Bundle刪除暫存資源 -// * @param {string} BundleName Bundle名稱 -// */ -// public *DelBundleCache(BundleName: cc.AssetManager.Bundle | string): IterableIterator { -// if (!CC_JSB) { -// return; -// } -// let WritablePath: string = `${jsb.fileUtils.getWritablePath()}gamecaches/${BundleName}`; -// if (jsb.fileUtils.isDirectoryExist(WritablePath)) { -// jsb.fileUtils.removeDirectory(WritablePath); -// } -// } - -//#endregion \ No newline at end of file diff --git a/assets/Script/Engine/HUD/AssetBundleMamager.ts.meta b/assets/Script/Engine/HUD/AssetBundleMamager.ts.meta deleted file mode 100644 index b228b49..0000000 --- a/assets/Script/Engine/HUD/AssetBundleMamager.ts.meta +++ /dev/null @@ -1,10 +0,0 @@ -{ - "ver": "1.1.0", - "uuid": "97a0b2c9-72f8-4797-874a-263e4558f765", - "importer": "typescript", - "isPlugin": false, - "loadPluginInWeb": true, - "loadPluginInNative": true, - "loadPluginInEditor": false, - "subMetas": {} -} \ No newline at end of file diff --git a/assets/Script/Engine/HUD/HUDM.ts b/assets/Script/Engine/HUD/HUDM.ts deleted file mode 100644 index d79bc71..0000000 --- a/assets/Script/Engine/HUD/HUDM.ts +++ /dev/null @@ -1,425 +0,0 @@ -import BusinessTypeSetting from "../../_BusinessTypeSetting/BusinessTypeSetting"; -import Enum_Loading from "../HUDV2/Enum_Loading"; -import AssetBundleMamager from "./AssetBundleMamager"; - -const { ccclass, property } = cc._decorator; - -/** HUDManager */ -@ccclass -export default class HUDM extends cc.Component { - - //#region static 屬性 - - private static _instance: HUDM = null; - public static get Instance(): HUDM { return HUDM._instance; } - - //#endregion - - //#region static 屬性 - - public BundleName: string = ""; - - //#endregion - - //#region private 屬性 - - private _am: jsb.AssetsManager; - private _onFileProgress: (finish: number, total: number, item: string) => void; - private _updateListener: any; - private _checkListener: any; - private _versionCompareHandle: any = null; - private _needUpdateData: Enum_Loading.NeedUpdateDataObj = null; - private _updateingData: Enum_Loading.UpdateingDataObj = null; - private _updating: boolean = false; - private _canRetry: boolean = false; - private _isChangeUrl: boolean = false; - private _path: string = "Bundle"; - private _customManifest: string = ""; - private _storagePath: string = ""; - - //#endregion - - //#region Lifecycle - - constructor(...params: any[]) { - super(); - - if (!cc.sys.isNative) { - return; - } else if (params.length === 0) { - return; - } - HUDM._instance = this; - - this.BundleName = params[0]; - // let packageUrl: string = params[1]; - // let BundleData: Enum_Loading.BundleDataObj = AssetBundleMamager.Instance.RemoteVerList[this.BundleName]; - // let packageUrl: string = BundleData.BundleUrl; - let packageUrl: string = `${BusinessTypeSetting.UsePatch}${BusinessTypeSetting.FolderUrlBundle}${this.BundleName}`; - - this._customManifest = JSON.stringify({ - "packageUrl": packageUrl, - "remoteManifestUrl": `${packageUrl}/project.manifest`, - "remoteVersionUrl": `${packageUrl}/version.json`, - "version": "0.0.0", - }); - - this._storagePath = `${(jsb.fileUtils ? jsb.fileUtils.getWritablePath() : "./")}${this._path}/${this.BundleName}`; - - // 本地熱更目錄下已存在project.manifest,則直接修改已存在的project.manifest - if (AssetBundleMamager.Instance.IsChangeBundleUrl) { - if (jsb.fileUtils.isFileExist(this._storagePath + "/project.manifest")) { - this._isChangeUrl = true; - this._modifyAppLoadUrlForManifestFile(this._storagePath, packageUrl); - } - } - - this._versionCompareHandle = function (versionA: string, versionB: string): number { - // console.log("Ver A " + versionA + "VerB " + versionB); - var vA: string[] = versionA.split("."); - var vB: string[] = versionB.split("."); - - // 長度不相等,則進行更新 - if (vA.length !== vB.length) { - return -1; - } - - for (var i: number = 0; i < vA.length; ++i) { - var a: number = +vA[i]; - var b: number = +vB[i] || 0; - if (a === b) { - // 數字相同,則跳過 - continue; - } else { - // 數字不同,則進行更新 - return -1; - } - } - - // 長度相等且數字相等,則不更新 - return 0; - }; - this._initAssetManaget(); - } - private _initAssetManaget(): void { - // - this._am = new jsb.AssetsManager("", this._storagePath, this._versionCompareHandle); - - // Setup the verification callback, but we don't have md5 check function yet, so only print some message - // Return true if the verification passed, otherwise return false - this._am.setVerifyCallback(function (path: any, asset: { compressed: any; md5: any; path: any; size: any; }): boolean { - // When asset is compressed, we don't need to check its md5, because zip file have been deleted. - var compressed: any = asset.compressed; - // Retrieve the correct md5 value. - var expectedMD5: string = asset.md5; - // asset.path is relative path and path is absolute. - var relativePath: string = asset.path; - // The size of asset file, but this value could be absent. - var size: any = asset.size; - if (compressed) { - // panel.info.string = "Verification passed : " + relativePath; - // cc.log("onLoad -> Verification passed : " + relativePath); - return true; - } else { - // panel.info.string = "Verification passed : " + relativePath + ' (' + expectedMD5 + ')'; - // cc.log("onLoad -> setVerifyCallbackVerification passed : " + relativePath + " (" + expectedMD5 + ")"); - return true; - } - }); - - if (cc.sys.os === cc.sys.OS_ANDROID) { - // Some Android device may slow down the download process when concurrent tasks is too much. - // The value may not be accurate, please do more test and find what's most suitable for your game. - // this._am.setMaxConcurrentTask(10); - this._am["setMaxConcurrentTask"](10); - // this.panel.info.string = "Max concurrent tasks count have been limited to 2"; - // cc.log("onLoad -> Max concurrent tasks count have been limited to 10"); - } - } - - private _modifyAppLoadUrlForManifestFile(filePath: string, newBundleUrl: string): void { - let allpath: string[] = [filePath, filePath + "_temp"]; - let manifestname: string[] = ["project.manifest", "project.manifest.temp"]; - for (var i: number = 0; i < allpath.length; ++i) { - let path: string = `${allpath[i]}/${manifestname[i]}`; - if (jsb.fileUtils.isFileExist(path)) { - // console.log(`[HUD] modifyAppLoadUrlForManifestFile: 有下載的manifest文件,直接修改熱更地址`); - // 修改project.manifest - let projectManifest: string = jsb.fileUtils.getStringFromFile(path); - let projectManifestObj: any = JSON.parse(projectManifest); - projectManifestObj.packageUrl = newBundleUrl; - projectManifestObj.remoteManifestUrl = newBundleUrl + "/project.manifest"; - projectManifestObj.remoteVersionUrl = newBundleUrl + "/version.json"; - let afterString: string = JSON.stringify(projectManifestObj); - let isWrittenProject: boolean = jsb.fileUtils.writeStringToFile(afterString, path); - // // 更新數據庫中的新請求地址,下次如果檢測到不一致就重新修改 manifest 文件 - // if (isWrittenProject) { - // LocalStorageData.Instance.BundleUrl = BusinessTypeSetting.UsePatch; - // } - // console.log("[HUD] 修改是否成功,project.manifest:", isWrittenProject); - // console.log("[HUD] 修改後文件:", projectManifestObj.packageUrl, projectManifestObj.remoteManifestUrl, projectManifestObj.remoteVersionUrl); - } - } - } - //#endregion - - - public *CheckUpdate(): IterableIterator { - this._needUpdateData = null; - if (this._updating) { - // this.panel.info.string = 'Checking or updating ...'; - console.error("checkUpdate -> Checking or updating ..."); - return; - } - - if (this._am.getState() === jsb.AssetsManager.State.UNINITED) { - let manifest: jsb.Manifest = new jsb.Manifest(this._customManifest, this._storagePath); - this._am.loadLocalManifest(manifest, this._storagePath); - } - if (!this._am.getLocalManifest() || !this._am.getLocalManifest().isLoaded()) { - // this.tipsLabel.string = "Failed to load local manifest ..."; - console.error("checkUpdate -> Failed to load local manifest ..."); - return; - } - this._am.setEventCallback(this.checkCb.bind(this)); - - this._am.checkUpdate(); - this._updating = true; - - while (this._needUpdateData === null) { - yield null; - } - - let newBundleUrl: string = `${BusinessTypeSetting.UsePatch}${BusinessTypeSetting.FolderUrlBundle}${this.BundleName}`; - this._modifyAppLoadUrlForManifestFile(this._storagePath, newBundleUrl); - this._initAssetManaget(); - - let manifest: jsb.Manifest = new jsb.Manifest(this._customManifest, this._storagePath); - this._am.loadLocalManifest(manifest, this._storagePath); - if (!this._am.getLocalManifest() || !this._am.getLocalManifest().isLoaded()) { - // this.tipsLabel.string = "Failed to load local manifest ..."; - console.error("checkUpdate -> Failed to load local manifest ..."); - return; - } - - // 更新動態路徑後再跑一次 - this._am.setEventCallback(this.checkCb.bind(this)); - - this._needUpdateData = null; - this._am.checkUpdate(); - this._updating = true; - while (this._needUpdateData === null) { - yield null; - } - if (this._isChangeUrl && (!this._needUpdateData.IsNeedUpdate || this._needUpdateData.TotalBytes === "0 B")) { - if (jsb.fileUtils.isFileExist(this._storagePath)) { - let isremoveDirectory: boolean = jsb.fileUtils.removeDirectory(this._storagePath); - let isremoveDirectory_temp: boolean = jsb.fileUtils.removeDirectory(this._storagePath + "_temp"); - if (isremoveDirectory_temp) { - console.log(`removeDirectory: ${this._storagePath}_temp`); - } - if (isremoveDirectory) { - console.log(`removeDirectory: ${this._storagePath}`); - this._needUpdateData = null; - this._initAssetManaget(); - this._needUpdateData = yield* this.CheckUpdate(); - } - } - } - return this._needUpdateData; - } - - private checkCb(event: jsb.EventAssetsManager): void { - var failed: boolean = false; - switch (event.getEventCode()) { - case jsb.EventAssetsManager.ERROR_NO_LOCAL_MANIFEST: - // this.tipsLabel.string = "No local manifest file found, HUD skipped."; - console.error("checkCb -> No local manifest file found, HUD skipped."); - failed = true; - break; - case jsb.EventAssetsManager.ERROR_DOWNLOAD_MANIFEST: - case jsb.EventAssetsManager.ERROR_PARSE_MANIFEST: - // this.tipsLabel.string = "Fail to download manifest file, HUD skipped."; - console.error("checkCb -> Fail to download manifest file, HUD skipped."); - failed = true; - break; - case jsb.EventAssetsManager.ALREADY_UP_TO_DATE: - // this.tipsLabel.string = "Already up to date with the latest remote version."; - // cc.log("checkCb -> Already up to date with the latest remote version."); - this._needUpdateData = new Enum_Loading.NeedUpdateDataObj(false); - break; - case jsb.EventAssetsManager.NEW_VERSION_FOUND: - // this.downloadLabel.node.active = true; - // this.downloadLabel.string = "New version found, please try to update." + event.getTotalBytes(); - // this.panel.checkBtn.active = false; - // this.panel.fileProgress.progress = 0; - // this.panel.byteProgress.progress = 0; - // cc.log("checkCb -> New version found, please try to update." + event.getTotalBytes()); - this._needUpdateData = new Enum_Loading.NeedUpdateDataObj(true, this._bytesToSize(event.getTotalBytes())); - break; - default: - return; - } - - this._am.setEventCallback(null); - this._checkListener = null; - this._updating = false; - - if (failed) { - // - } - } - - public *HUD(onFileProgress?: (finish: number, total: number, item: string) => void): IterableIterator { - this._updateingData = null; - if (this._am && !this._updating) { - this._am.setEventCallback(this._updateCb.bind(this)); - - if (this._am.getState() === jsb.AssetsManager.State.UNINITED) { - let manifest: jsb.Manifest = new jsb.Manifest(this._customManifest, this._storagePath); - this._am.loadLocalManifest(manifest, this._storagePath); - } - - this._onFileProgress = onFileProgress ? onFileProgress : null; - this._am.update(); - this._updating = true; - - while (this._updateingData === null) { - yield null; - } - - return this._updateingData; - } else { - return new Enum_Loading.UpdateingDataObj(false); - } - } - - private _updateCb(event: jsb.EventAssetsManager): void { - var needRestart: boolean = false; - var failed: boolean = false; - switch (event.getEventCode()) { - case jsb.EventAssetsManager.ERROR_NO_LOCAL_MANIFEST: - // this.panel.info.string = 'No local manifest file found, HUD skipped.'; - cc.log("updateCb -> No local manifest file found, HUD skipped."); - failed = true; - break; - case jsb.EventAssetsManager.UPDATE_PROGRESSION: - // this.panel.byteProgress.progress = event.getPercent(); - // this.panel.fileProgress.progress = event.getPercentByFile(); - // this.panel.fileLabel.string = event.getDownloadedFiles() + ' / ' + event.getTotalFiles(); - // this.tipsLabel.string = event.getDownloadedBytes() + " / " + event.getTotalBytes(); - - // cc.log("updateCb -> " + event.getDownloadedBytes() + " / " + event.getTotalBytes()); - // var msg: string = event.getMessage(); - // if (msg) { - // // this.panel.info.string = 'Updated file: ' + msg; - // cc.log("updateCb -> Updated file: " + msg); - // console.log("updateCb -> " + event.getPercent() / 100 + "% : " + msg); - // } - - var msg: string = event.getMessage(); - if (this._onFileProgress) { - this._onFileProgress(event.getDownloadedBytes(), event.getTotalBytes(), msg ? msg : ""); - } - break; - case jsb.EventAssetsManager.ERROR_DOWNLOAD_MANIFEST: - case jsb.EventAssetsManager.ERROR_PARSE_MANIFEST: - // this.panel.info.string = 'Fail to download manifest file, HUD skipped.'; - console.error("updateCb -> Fail to download manifest file, HUD skipped."); - failed = true; - break; - case jsb.EventAssetsManager.ALREADY_UP_TO_DATE: - // this.panel.info.string = 'Already up to date with the latest remote version.'; - console.error("updateCb -> Already up to date with the latest remote version."); - failed = true; - break; - case jsb.EventAssetsManager.UPDATE_FINISHED: - // this.tipsLabel.string = "更新完成. " + event.getMessage(); - // cc.log("updateCb -> 更新完成. " + event.getMessage()); - this._updateingData = new Enum_Loading.UpdateingDataObj(true); - needRestart = true; - break; - case jsb.EventAssetsManager.UPDATE_FAILED: - // this.panel.info.string = 'Update failed. ' + event.getMessage(); - console.error("updateCb -> Update failed. " + event.getMessage()); - // this.panel.retryBtn.active = true; - this._canRetry = true; - this._updateingData = new Enum_Loading.UpdateingDataObj(false); - this._updating = false; - break; - case jsb.EventAssetsManager.ERROR_UPDATING: - // this.panel.info.string = 'Asset update error: ' + event.getAssetId() + ', ' + event.getMessage(); - console.error("updateCb -> Asset update error: " + event.getAssetId() + ", " + event.getMessage()); - break; - case jsb.EventAssetsManager.ERROR_DECOMPRESS: - // this.panel.info.string = event.getMessage(); - console.error("updateCb -> " + event.getMessage()); - break; - default: - break; - } - - if (failed) { - this._am.setEventCallback(null); - this._updateListener = null; - this._updating = false; - } - - // 測試先不restart 之後看情況 - // if (needRestart) { - // this._am.setEventCallback(null); - // this._updateListener = null; - // // Prepend the manifest's search path - // var searchPaths: string[] = jsb.fileUtils.getSearchPaths(); - - // // var newPaths = this._am.getLocalManifest().getSearchPaths(); - // // cc.log("newPath."+JSON.stringify(newPaths)); - // // Array.prototype.unshift.apply(searchPaths, newPaths); - - // cc.sys.localStorage.setItem("HUDSearchPaths", JSON.stringify(searchPaths)); - - // jsb.fileUtils.setSearchPaths(searchPaths); - - // cc.audioEngine.stopAll(); - // cc.game.restart(); - // } - } - - public *RetryDownLoadFailedAssets(): IterableIterator { - if (!this._updating && this._canRetry) { - this._updateingData = null; - // this.panel.retryBtn.active = false; - this._canRetry = false; - - // this.panel.info.string = 'Retry failed Assets...'; - // cc.log("retry -> Retry failed Assets..."); - this._am.downloadFailedAssets(); - - while (this._updateingData === null) { - yield null; - } - - return this._updateingData; - } else { - console.error(`retry -> error updating: ${this._updating}, canRetry: ${this._canRetry}`); - this._updateingData = new Enum_Loading.UpdateingDataObj(false); - } - } - - private _bytesToSize(bytes: number): string { - if (bytes === 0) { - return "0 B"; - } - let k: number = 1024; - let sizes: string[] = ["B", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"]; - let i: number = Math.floor(Math.log(bytes) / Math.log(k)); - return (bytes / Math.pow(k, i)).toPrecision(3) + " " + sizes[i]; - } - - protected onDestroy(): void { - if (this._updateListener) { - this._am.setEventCallback(null); - this._updateListener = null; - } - } -} diff --git a/assets/Script/Engine/HUD/HUDM.ts.meta b/assets/Script/Engine/HUD/HUDM.ts.meta deleted file mode 100644 index cd48b0e..0000000 --- a/assets/Script/Engine/HUD/HUDM.ts.meta +++ /dev/null @@ -1,10 +0,0 @@ -{ - "ver": "1.1.0", - "uuid": "dd9501f7-957a-4e62-8630-d43f62d171d1", - "importer": "typescript", - "isPlugin": false, - "loadPluginInWeb": true, - "loadPluginInNative": true, - "loadPluginInEditor": false, - "subMetas": {} -} \ No newline at end of file diff --git a/assets/Script/Engine/HUDV2/AssetBundleMamagerV2.ts b/assets/Script/Engine/HUDV2/AssetBundleMamagerV2.ts deleted file mode 100644 index 83fad84..0000000 --- a/assets/Script/Engine/HUDV2/AssetBundleMamagerV2.ts +++ /dev/null @@ -1,522 +0,0 @@ -import BusinessTypeSetting from "../../_BusinessTypeSetting/BusinessTypeSetting"; -import { CoroutineV2 } from "../CatanEngine/CoroutineV2/CoroutineV2"; -import LocalStorageData from "../Data/LocalStorageData"; -import Enum_Loading from "./Enum_Loading"; - -export default class AssetBundleMamagerV2 { - //#region static 屬性 - - private static _instance: AssetBundleMamagerV2 = null; - public static get Instance(): AssetBundleMamagerV2 { return AssetBundleMamagerV2._instance; } - - //#endregion - - //#region public 屬性 - - /** 本地VerList */ - public LocalVerList: Enum_Loading.VerListObj = null; - - /** 遠端VerList */ - public RemoteVerList: JSON = null; - - public DownloadList_Preview: Object = {}; - - /** 快取資源 */ - public CachedFiles: Map = new Map(); - - //#endregion - - //#region Lifecycle - - constructor() { - AssetBundleMamagerV2._instance = this; - CC_PREVIEW && this._initdownloadList_Preview(); - } - - //#endregion - - //#region 清除資料 - - /** 判斷更改編譯版號.清除BUNDLE記錄 */ - public CheckCompileVersion(): void { - let oldCompileVersion: string = LocalStorageData.Instance.CompileVersion; - let newCompileVersion: string = BusinessTypeSetting.COMPILE_VERSION; - if (oldCompileVersion && oldCompileVersion !== newCompileVersion) { - this.ClearBundleData(); - console.log("change compile version."); - } - LocalStorageData.Instance.CompileVersion = BusinessTypeSetting.COMPILE_VERSION; - } - - /** 判斷更改PATCH環境.清除BUNDLE記錄 */ - public CheckChangePatchUrl(): void { - let oldBundleUrl: string = LocalStorageData.Instance.BundleUrl; - let newBundleUrl: string = BusinessTypeSetting.UsePatch; - if (oldBundleUrl && oldBundleUrl !== newBundleUrl) { - this.ClearBundleData(); - console.log("change patch url."); - } - LocalStorageData.Instance.BundleUrl = BusinessTypeSetting.UsePatch; - } - - /** 清除Bundle資料 */ - public ClearBundleData(): void { - cc.sys.localStorage.removeItem("LocalVerList"); - cc.sys.localStorage.removeItem("RemoteVerList"); - cc.assetManager.bundles.clear(); - if (CC_JSB) { - cc.assetManager.cacheManager.clearCache(); - console.log("clear bundle data."); - } - } - - /** 清除所有資料重啟 */ - public ClearAppDataToRestart(): void { - cc.sys.localStorage.clear(); - cc.assetManager.bundles.clear(); - if (CC_JSB) { - cc.assetManager.cacheManager.clearCache(); - cc.game.restart(); - } else { - window.location.reload(); - } - } - - //#endregion - - //#region Custom Function - - /** - * 取得Bundle - * @param {string} BundleName Bundle名稱 - * @param {string} Version 版號 - * @return {cc.AssetManager.Bundle} Bundle - */ - public *GetBundle(BundleName: string): IterableIterator { - let self: this = this; - let bundle: cc.AssetManager.Bundle | boolean = cc.assetManager.getBundle(BundleName); - if (bundle) { - yield* this.GetDepsBundle(bundle.deps); - return bundle; - } - /** 判斷是不是要下載新版本 */ - let isNeedUpdate: boolean = this.IsNeedUpdate(BundleName); - if (isNeedUpdate) { - // 下載新版本前需要先清除暫存 - console.log(`removeCache: ${BundleName}`); - this.DelBundleCache(BundleName); - this.LocalVerList[BundleName].UseLocal = false; - } - /** Bundle路徑 */ - let BundleUrl: string = BusinessTypeSetting.GetRemoteFileUrl(BundleName); - if (CC_DEV) { - // CC_DEVBundle路徑為: BundleName - // if (BundleName.indexOf("Script") != -1) { - BundleUrl = `${BundleName}`; - // } else { - // BundleUrl = "http://192.168.7.57/bj_casino/test/" + BundleName; - // } - } else if (this.LocalVerList[BundleName].UseLocal) { - // 本地Bundle路徑為: assets/assets/${BundleName} - BundleUrl = `assets/${BundleName}`; - } - if (CC_DEV) { - cc.assetManager.loadBundle(BundleUrl, (err: Error, resp: cc.AssetManager.Bundle) => { - if (err) { - console.error(err); - bundle = null; - return; - } - bundle = resp; - }); - while (typeof bundle === "undefined") { - yield null; - } - } else if (BundleName.includes("Script")) { - bundle = yield* self.loadScriptBundle(BundleUrl); - } else { - if (CC_JSB && !this.LocalVerList[BundleName].UseLocal) { - let bundlePath: string = `${jsb.fileUtils.getWritablePath()}gamecaches/${BundleName}/`; - if (!jsb.fileUtils.isFileExist(bundlePath)) { - cc.assetManager.cacheManager["makeBundleFolder"](BundleName); - } - } - bundle = yield* self.loadUIBundle(BundleUrl); - } - if (bundle) { - yield* this.GetDepsBundle((bundle).deps); - if (isNeedUpdate) { - // 下載成功後更改本地Bundle版本 - self.LocalVerList[BundleName].Version = self.RemoteVerList[BundleName]; - LocalStorageData.Instance.LocalVerList = JSON.stringify(self.LocalVerList); - } - } - return bundle; - } - - /** - * 從Bundle取得資源 - * @param {string} BundleUrl Bundle路徑 - */ - public *loadScriptBundle(BundleUrl: string): IterableIterator { - let fileName: string = `index.${CC_DEBUG ? "js" : "jsc"}`; - let fileUrl: string = `${BundleUrl}/${fileName}`; - let run: boolean = true; - let isSuceess: boolean = false; - cc.assetManager.loadScript(fileUrl, (err: Error) => { - if (err) { - console.error(`[Error] ${fileUrl}載入失敗 err: ${err}`); - run = false; - return; - } - isSuceess = true; - run = false; - }); - while (run) { - yield null; - } - return isSuceess; - } - - /** - * 從Bundle取得資源 - * @param {string} BundleUrl Bundle路徑 - */ - public *loadUIBundle(BundleUrl: string): IterableIterator { - let fileName: string = "config.json"; - let fileUrl: string = `${BundleUrl}/${fileName}`; - let data: any; - let run: boolean = true; - cc.assetManager.loadRemote(fileUrl, (err: Error, res: cc.JsonAsset) => { - if (err) { - console.error(`[Error] ${fileUrl}載入失敗 err: ${err}`); - return; - } - data = res.json; - run = false; - }); - while (run) { - yield null; - } - let bundle: cc.AssetManager.Bundle = new cc.AssetManager.Bundle(); - data.base = `${BundleUrl}/`; - bundle.init(data); - return bundle; - } - - /** - * 取得Bundle - * @param {string} BundleName Bundle名稱 - * @param {string} Version 版號 - * @return {cc.AssetManager.Bundle} Bundle - */ - public *GetDepsBundle(deps: string[]): IterableIterator { - if (!deps || deps.length <= 2) { - return; - } - let self: this = this; - let GetBundle_F_Arr: IterableIterator[] = []; - for (const bundleName of deps) { - if (!["main", "internal"].includes(bundleName)) { - let GetBundle_F: IterableIterator = function* (): IterableIterator { - yield* self.GetBundle(bundleName); - }(); - GetBundle_F_Arr.push(GetBundle_F); - } - } - yield CoroutineV2.Parallel(...GetBundle_F_Arr).Start(); - } - - /** - * 從Bundle取得資源 - * @param {number} slotID slotID - * @param {Function} onFileProgress onFileProgress - */ - public *PreloadBundleScene(slotID: number, onFileProgress?: (finish: number, total: number, item: cc.AssetManager.RequestItem) => void): IterableIterator { - let BundleName: string = `Game_${slotID}`; - let SourceName: string = `Slot${slotID}`; - let run: boolean = true; - let UpdateingData: Enum_Loading.UpdateingDataObj = new Enum_Loading.UpdateingDataObj(false); - let bundle: cc.AssetManager.Bundle = yield* AssetBundleMamagerV2.Instance.GetBundle(BundleName); - if (!bundle) { - console.error(`GetBundleSource Error BundleName: ${BundleName}`); - return UpdateingData; - } - - bundle.preloadScene(SourceName, onFileProgress, function (error: Error): void { - if (error) { - console.error(error); - run = false; - return; - } - UpdateingData.IsUpdatecomplete = true; - run = false; - }); - - while (run) { - yield null; - } - return UpdateingData; - } - - /** - * 從Bundle取得資源 - * @param {cc.AssetManager.Bundle | string} BundleName Bundle名稱 - * @param {string} SourceName 資源名稱 - * @param {string} type 資源型別 - * @return {any} Source - */ - public *GetBundleSource(BundleName: cc.AssetManager.Bundle | string, SourceName: string, type?: string | Bundle_Source_Type, onFileProgress?: (finish: number, total: number, item: cc.AssetManager.RequestItem) => void): IterableIterator { - let bundle: cc.AssetManager.Bundle; - let source: any; - if (BundleName instanceof cc.AssetManager.Bundle) { - bundle = BundleName; - } else { - bundle = yield* AssetBundleMamagerV2.Instance.GetBundle(BundleName); - if (!bundle) { - cc.error(`GetBundleSource Error BundleName: ${BundleName}`); - return null; - } - } - - switch (type) { - case Bundle_Source_Type.Scene: { - bundle.loadScene(SourceName, onFileProgress, function (err: Error, scene: cc.SceneAsset): void { - if (err) { - cc.error(err); - return null; - } - // cc.director.runScene(scene); - source = scene; - }); - break; - } - - case Bundle_Source_Type.Json: { - bundle.load(SourceName, onFileProgress, function (err: Error, json: cc.JsonAsset): void { - if (err) { - cc.error(err); - return null; - } - // source = JSON.parse(json["_nativeAsset"]); - source = json; - }); - break; - } - - case Bundle_Source_Type.Prefab: { - bundle.load(SourceName, cc.Prefab, onFileProgress, function (err: Error, prefab: cc.Asset): void { - if (err) { - cc.error(err); - return null; - } - // source = JSON.parse(json["_nativeAsset"]); - source = prefab; - }); - break; - } - - default: - bundle.load(SourceName, function (err: Error, any: any): void { - if (err) { - cc.error(err); - return null; - } - source = any; - }); - break; - } - - while (typeof source === "undefined") { - yield null; - } - return source; - } - - /** - * 從Bundle取得資源(不卡協成) - * @param {string} bundleName bundleName - * @param {string} sourcePath Bundle資料夾下的路徑 - */ - public static GetBundleSourceV2(bundleName: cc.bundleName | string, sourcePath: string): cc.Prefab { - let bundle: cc.AssetManager.Bundle = cc.assetManager.getBundle(bundleName); - if (!bundle) { - cc.error(`GetBundleSourceV2 getBundle error bundleName: ${bundleName}`); - return null; - } - let source: cc.Prefab = bundle.get(sourcePath, cc.Prefab); - if (!source) { - cc.error(`GetBundleSourceV2 bundle.get error bundleName: ${bundleName}, sourcePath: ${sourcePath}`); - return null; - } - return source; - } - - /** - * 釋放Bundle - * @param {string} slotID slotID - */ - public *BundleRelease(slotID: number): IterableIterator { - let gameName: string = `Game_${slotID}`; - let sceneName: string = `Slot${slotID}`; - let bundle: cc.AssetManager.Bundle = cc.assetManager.getBundle(gameName); - if (!bundle) { - cc.log(`BundleRelease Error BundleName: ${gameName}`); - return; - } - this.ReleaseSlotCache(slotID); - } - - /** - * 從cachedFiles刪除暫存資源 - * @param {string} BundleName Bundle名稱 - */ - public DelBundleCache(BundleName: string): void { - if (CC_BUILD && cc.sys.isNative) { - let cachedFiles: Object = cc.assetManager.cacheManager.cachedFiles["_map"]; - let delcache: string = BusinessTypeSetting.GetRemoteFileUrl(BundleName) + "/"; - for (let cached of Object.keys(cachedFiles)) { - if (cached.includes(delcache)) { - cc.assetManager.cacheManager.removeCache(cached); - // console.log(`removeCache: ${cached}`); - } - } - } - } - - /** - * 從cachedFiles釋放暫存資源 - * @param {number} slotID slotID - */ - public ReleaseSlotCache(slotID: number): void { - if (!CC_JSB) { - return; - } - let delcachedKeys: string[] = []; - let cachedFiles: Map = this.CachedFiles; - let delcache_group: string[] = [`shared/jsons`, `Slot/Slot${slotID}`, "sounds/Slot/Default", "submit.txt"]; - cachedFiles.forEach((cached: cc.Asset, key: string, map: Map) => { - for (var i: number = 0; i < delcache_group.length; ++i) { - let delcache: string = delcache_group[i]; - if (key.includes(delcache)) { - cc.assetManager.releaseAsset(cached); - delcachedKeys.push(key); - break; - } - } - }); - for (var i: number = 0; i < delcachedKeys.length; ++i) { - this.CachedFiles.delete(delcachedKeys[i]); - } - } - - /** - * 判斷要不要更新 - * @param {string} BundleName Bundle名稱 - */ - public IsNeedUpdate(BundleName: string): boolean { - let isNeedUpdate: boolean; - // 判斷本地有無Bundle資料 - if (this.LocalVerList[BundleName] && !this.LocalVerList[BundleName].HasBundle) { - if (this.RemoteVerList[BundleName]) { - // 改成有包過Bundle了,重新走下面流程 - this.LocalVerList[BundleName] = null; - } else { - return true; - } - } - - if (!this.LocalVerList[BundleName]) { - // 本地無Bundle資料需要新增 - this.LocalVerList[BundleName] = new Enum_Loading.BundleDataObj(); - LocalStorageData.Instance.LocalVerList = JSON.stringify(this.LocalVerList); - } - let version: string = this.RemoteVerList[BundleName]; - if (!version) { - // !version代表還沒包Bundle - this.LocalVerList[BundleName].HasBundle = false; - LocalStorageData.Instance.LocalVerList = JSON.stringify(this.LocalVerList); - return true; - } else if (version === "0") { - // version === "0" 代表要使用本體Bundle - this.LocalVerList[BundleName].UseLocal = true; - this.LocalVerList[BundleName].Version = "0"; - LocalStorageData.Instance.LocalVerList = JSON.stringify(this.LocalVerList); - } - isNeedUpdate = AssetBundleMamagerV2.Instance.versionCompareHandle(this.LocalVerList[BundleName].Version, this.RemoteVerList[BundleName]) !== 0 ? true : false; - return isNeedUpdate; - } - - /** - * 比對版號(熱更能從1.0.0更新到2.0.0,從2.0.0回退到1.0.0) - * 官方提供的版本比較函數,只有服務端版本>客戶端版本時,才會進行更新。所以不能從2.0.0回退到1.0.0版本。 - * @param {string} versionA 本地版號 - * @param {string} versionB 遠程版號 - * @return {number} num = -1 須更新 - * @return {number} num = 0 不須更新 - */ - public versionCompareHandle(versionA: string, versionB: string): number { - // console.log("Ver A " + versionA + "VerB " + versionB); - var vA: string[] = versionA.split("."); - var vB: string[] = versionB.split("."); - - // 長度不相等,則進行更新 - if (vA.length !== vB.length) { - return -1; - } - - for (var i: number = 0; i < vA.length; ++i) { - var a: number = +vA[i]; - var b: number = +vB[i] || 0; - if (a === b) { - // 數字相同,則跳過 - continue; - } else { - // 數字不同(且版號比目標低),則進行更新 - return a - b; - } - } - - // 長度相等且數字相等,則不更新 - return 0; - } - - //#endregion - - //#region DownloadList_Preview - - private _initdownloadList_Preview(): void { - this.DownloadList_Preview = JSON.parse(LocalStorageData.Instance.DownloadList_Preview); - this.DownloadList_Preview = this.DownloadList_Preview ? this.DownloadList_Preview : {}; - } - - public GetIsDownload_Preview(slotID: number): boolean { - if (!this.DownloadList_Preview[slotID]) { - this.SetIsDownload_Preview(slotID, false); - } - return this.DownloadList_Preview[slotID]; - } - - public SetIsDownload_Preview(slotID: number, isDownload: boolean = true): void { - this.DownloadList_Preview[slotID] = isDownload; - LocalStorageData.Instance.DownloadList_Preview = JSON.stringify(this.DownloadList_Preview); - } - - //#endregion -} - -//#region enum - -/** Bundle資源類型 */ -export enum Bundle_Source_Type { - /** Json */ - Json = "json", - - /** Scene */ - Scene = "scene", - - /** Prefab */ - Prefab = "prefab" -} - -//#endregion \ No newline at end of file diff --git a/assets/Script/Engine/HUDV2/AssetBundleMamagerV2.ts.meta b/assets/Script/Engine/HUDV2/AssetBundleMamagerV2.ts.meta deleted file mode 100644 index 0d4d64e..0000000 --- a/assets/Script/Engine/HUDV2/AssetBundleMamagerV2.ts.meta +++ /dev/null @@ -1,10 +0,0 @@ -{ - "ver": "1.1.0", - "uuid": "383b4628-2b2a-4de4-8aca-913015e91cae", - "importer": "typescript", - "isPlugin": false, - "loadPluginInWeb": true, - "loadPluginInNative": true, - "loadPluginInEditor": false, - "subMetas": {} -} \ No newline at end of file diff --git a/assets/Script/Engine/HUDV2/Enum_Loading.ts b/assets/Script/Engine/HUDV2/Enum_Loading.ts deleted file mode 100644 index 839d0c2..0000000 --- a/assets/Script/Engine/HUDV2/Enum_Loading.ts +++ /dev/null @@ -1,72 +0,0 @@ -const { ccclass, property } = cc._decorator; -export module Enum_Loading { - - //#region Enum - - //#endregion - - //#region Class - - // /** BaseBundle資料 */ - // @ccclass("BaseBundleObj") - // export class BaseBundleObj { - // @property({ displayName: "Bundle名稱", tooltip: "Bundle名稱" }) - // public BundleName: string = ""; - - // @property({ displayName: "優先度", tooltip: "優先度", type: cc.Integer }) - // public Priority: number = 1; - // } - - class BundleDictionary { - [x: string]: T; - } - - /** VerList資料 */ - @ccclass("VerListObj") - export class VerListObj extends BundleDictionary { - } - - /** Bundle資料 */ - @ccclass("BundleDataObj") - export class BundleDataObj { - public Version: string = "0"; - - public ApkVersion: string = "0"; - - public UseLocal: boolean = false; - - /** 有沒有包到Bundle */ - public HasBundle: boolean = true; - } - - /** Bundle資料 */ - @ccclass("NeedUpdateDataObj") - export class NeedUpdateDataObj { - - /** 是否需要更新 */ - public IsNeedUpdate: boolean; - - /** 更新大小 */ - public TotalBytes: string; - - constructor(...params: any[]) { - this.IsNeedUpdate = params[0]; - this.TotalBytes = params[1] ? params[1] : null; - } - } - - /** Bundle資料 */ - @ccclass("UpdateingDataObj") - export class UpdateingDataObj { - - /** 是否更新完成 */ - public IsUpdatecomplete: boolean; - - constructor(...params: any[]) { - this.IsUpdatecomplete = params[0]; - } - } - - //#endregion -} -export default Enum_Loading; \ No newline at end of file diff --git a/assets/Script/Engine/HUDV2/Enum_Loading.ts.meta b/assets/Script/Engine/HUDV2/Enum_Loading.ts.meta deleted file mode 100644 index 5363453..0000000 --- a/assets/Script/Engine/HUDV2/Enum_Loading.ts.meta +++ /dev/null @@ -1,10 +0,0 @@ -{ - "ver": "1.1.0", - "uuid": "573d847e-893c-4fa2-8bd2-41918709fcf4", - "importer": "typescript", - "isPlugin": false, - "loadPluginInWeb": true, - "loadPluginInNative": true, - "loadPluginInEditor": false, - "subMetas": {} -} \ No newline at end of file diff --git a/assets/Script/Engine/HUDV2/GameData_HUD.ts b/assets/Script/Engine/HUDV2/GameData_HUD.ts deleted file mode 100644 index 22c0caa..0000000 --- a/assets/Script/Engine/HUDV2/GameData_HUD.ts +++ /dev/null @@ -1,43 +0,0 @@ - -const { ccclass, property } = cc._decorator; - -export module GameData_HUD { - - //#region Enum - - /** BundleName */ - export enum BundleName { - /** CommonSound */ - CommonSound = "CommonSound", - CommonLanguageTexture = "CommonLanguageTexture", - Common = "Common", - ResourceItem = "ResourceItem", - MainControl = "MainControl", - Login = "Login", - Lobby = "Lobby", - BindAccount = "BindAccount", - Shop = "Shop", - Vip = "Vip", - Ad = "Ad", - SettingPanel = "SettingPanel", - PlayerInfo = "PlayerInfo", - Rank = "Rank", - Chat = "Chat", - Gift = "Gift", - Activity = "Activity", - Mail = "Mail", - GettingPanel = "GettingPanel", - Backpack = "Backpack", - Game_GetCoin = "Game_GetCoin", - Game_BigWinJackpot = "Game_BigWinJackpot", - Game_BottomUI_BJ = "Game_BottomUI_BJ", - Game_BottomUI_SD = "Game_BottomUI_SD", - SlotCommom = "SlotCommom", - TableCommon = "TableCommon", - FishCommon = "FishCommon", - ActivityMission = "ActivityMission" - } - - //#endregion -} -export default GameData_HUD; \ No newline at end of file diff --git a/assets/Script/Engine/HUDV2/GameData_HUD.ts.meta b/assets/Script/Engine/HUDV2/GameData_HUD.ts.meta deleted file mode 100644 index 7dbaad5..0000000 --- a/assets/Script/Engine/HUDV2/GameData_HUD.ts.meta +++ /dev/null @@ -1,10 +0,0 @@ -{ - "ver": "1.1.0", - "uuid": "e85368d6-e018-430e-bf1d-6ecd2973c6a8", - "importer": "typescript", - "isPlugin": false, - "loadPluginInWeb": true, - "loadPluginInNative": true, - "loadPluginInEditor": false, - "subMetas": {} -} \ No newline at end of file diff --git a/assets/Script/Engine/Timer.meta b/assets/Script/Engine/Timer.meta new file mode 100644 index 0000000..9460ca5 --- /dev/null +++ b/assets/Script/Engine/Timer.meta @@ -0,0 +1,13 @@ +{ + "ver": "1.1.3", + "uuid": "fd4b4720-4e75-4bfe-a27c-1520c3f18eb0", + "importer": "folder", + "isBundle": false, + "bundleName": "", + "priority": 1, + "compressionType": {}, + "optimizeHotUpdate": {}, + "inlineSpriteFrames": {}, + "isRemoteBundle": {}, + "subMetas": {} +} \ No newline at end of file diff --git a/assets/Script/Engine/Utils.meta b/assets/Script/Engine/Utils.meta new file mode 100644 index 0000000..e31dc66 --- /dev/null +++ b/assets/Script/Engine/Utils.meta @@ -0,0 +1,13 @@ +{ + "ver": "1.1.3", + "uuid": "eba93305-455d-4d2d-a914-db71bc7f0022", + "importer": "folder", + "isBundle": false, + "bundleName": "", + "priority": 1, + "compressionType": {}, + "optimizeHotUpdate": {}, + "inlineSpriteFrames": {}, + "isRemoteBundle": {}, + "subMetas": {} +} \ No newline at end of file diff --git a/tslint.json b/tslint.json index dd18020..0faaa68 100644 --- a/tslint.json +++ b/tslint.json @@ -1,115 +1,107 @@ { - "rules": { - "ban": [ - true, - [ - "_", - "extend" - ], - [ - "_", - "isNull" - ], - [ - "_", - "isDefined" - ] - ], - "class-name": false, - "comment-format": [ - true, - "check-space" - ], - "curly": true, - "eofline": false, - "forin": false, - "indent": [ - true, - 4 - ], - "interface-name": [ - true, - "never-prefix" - ], - "jsdoc-format": true, - "label-position": true, - "label-undefined": true, - "max-line-length": [ - false, - 140 - ], - "no-arg": true, - "no-bitwise": false, - "no-console": [ - true, - "debug", - "info", - "time", - "timeEnd", - "trace" - ], - "no-construct": true, - "no-debugger": true, - "no-duplicate-key": true, - "no-duplicate-variable": true, - "no-empty": true, - // "no-eval": true, - "no-string-literal": false, - "no-trailing-comma": true, - "no-trailing-whitespace": true, - "no-unused-expression": false, - "no-unused-variable": true, - "no-unreachable": true, - "no-use-before-declare": false, - "one-line": [ - true, - "check-open-brace", - "check-catch", - "check-else", - "check-whitespace" - ], - "quotemark": [ - true, - "double" - ], - "radix": true, - "semicolon": [ - true, - "always" - ], - "triple-equals": [ - true, - "allow-null-check" - ], - "typedef": [ - true, - "call-signature", - "parameter", - "property-declaration", - "variable-declaration" - ], - "typedef-whitespace": [ - true, - { - "call-signature": "nospace" - }, - { - "index-signature": "space" - } - ], - "use-strict": [ - true, - "check-module", - "check-function" - ], - "variable-name": false, - "whitespace": [ - false, - "check-branch", - "check-decl", - "check-operator", - "check-separator", - "check-type" - ] - } + "defaultSeverity": "warning", + "rules": { + "ban": [ + true, + [ + "_", + "extend" + ], + [ + "_", + "isNull" + ], + [ + "_", + "isDefined" + ] + ], + "class-name": false, + "comment-format": [ + true, + "check-space" + ], + "curly": true, + "eofline": false, + "forin": false, + "indent": [ + true, + 4 + ], + "interface-name": [ + true, + "never-prefix" + ], + "jsdoc-format": true, + "label-position": true, + "max-line-length": [ + false, + 140 + ], + "no-arg": true, + "no-bitwise": false, + "no-console": [ + true, + "debug", + "info", + "time", + "timeEnd", + "trace" + ], + "no-construct": true, + "no-debugger": true, + "no-duplicate-variable": true, + "no-empty": true, + // "no-eval": true, + "no-string-literal": false, + "no-trailing-whitespace": true, + "no-unused-expression": false, + "no-unused-variable": true, + "no-use-before-declare": false, + "one-line": [ + true, + "check-open-brace", + "check-catch", + "check-else", + "check-whitespace" + ], + "quotemark": [ + true, + "double" + ], + "radix": true, + "semicolon": [ + true, + "always" + ], + "triple-equals": [ + true, + "allow-null-check" + ], + "typedef": [ + true, + "call-signature", + "parameter", + "property-declaration", + "variable-declaration" + ], + "typedef-whitespace": [ + true, + { + "call-signature": "nospace" + }, + { + "index-signature": "space" + } + ], + "variable-name": false, + "whitespace": [ + false, + "check-branch", + "check-decl", + "check-operator", + "check-separator", + "check-type" + ] + } } \ No newline at end of file