├── .gitignore ├── .vscode ├── launch.json └── settings.json ├── FGUIProject ├── .objs │ ├── metas │ │ └── 8djn4yal │ │ │ └── fqpx0.info │ └── workspace.json ├── FGUIProject.fairy ├── assets │ └── test │ │ ├── TestUI.xml │ │ └── package.xml └── settings │ └── Publish.json ├── assets ├── project.manifest ├── project.manifest.meta ├── resources.meta ├── resources │ ├── configs.meta │ ├── configs │ │ ├── Sounds.json │ │ └── Sounds.json.meta │ ├── prefabs.meta │ ├── prefabs │ │ ├── TestUI.prefab │ │ └── TestUI.prefab.meta │ ├── sounds.meta │ ├── sounds │ │ ├── bgm.mp3 │ │ ├── bgm.mp3.meta │ │ ├── common_clicked.mp3 │ │ └── common_clicked.mp3.meta │ ├── textures.meta │ ├── ui.meta │ └── ui │ │ ├── test.bin │ │ └── test.bin.meta ├── scenes.meta ├── scenes │ ├── AppStart.fire │ ├── AppStart.fire.meta │ ├── Main.fire │ └── Main.fire.meta ├── scripts.meta ├── scripts │ ├── Global.ts │ ├── Global.ts.meta │ ├── app.meta │ ├── app │ │ ├── data.meta │ │ ├── data │ │ │ ├── EventCommon.ts │ │ │ ├── EventCommon.ts.meta │ │ │ ├── GameDataDef.ts │ │ │ ├── GameDataDef.ts.meta │ │ │ ├── proto.meta │ │ │ └── proto │ │ │ │ ├── person.d.ts │ │ │ │ ├── person.d.ts.meta │ │ │ │ ├── person.js │ │ │ │ └── person.js.meta │ │ ├── page.meta │ │ ├── page │ │ │ ├── TestFGUI.ts │ │ │ ├── TestFGUI.ts.meta │ │ │ ├── TestUI.ts │ │ │ └── TestUI.ts.meta │ │ ├── scene.meta │ │ └── scene │ │ │ ├── AppStart.ts │ │ │ ├── AppStart.ts.meta │ │ │ ├── Main.ts │ │ │ └── Main.ts.meta │ ├── base.meta │ ├── base │ │ ├── components.meta │ │ ├── components │ │ │ ├── FitUI.ts │ │ │ ├── FitUI.ts.meta │ │ │ ├── HotUpdate.ts │ │ │ ├── HotUpdate.ts.meta │ │ │ ├── ScreenCapture.ts │ │ │ └── ScreenCapture.ts.meta │ │ ├── core.meta │ │ ├── core │ │ │ ├── BaseComponent.ts │ │ │ ├── BaseComponent.ts.meta │ │ │ ├── SingleFactory.ts │ │ │ ├── SingleFactory.ts.meta │ │ │ ├── audio.meta │ │ │ ├── audio │ │ │ │ ├── AudioMananger.ts │ │ │ │ └── AudioMananger.ts.meta │ │ │ ├── data.meta │ │ │ ├── data │ │ │ │ ├── DataManager.ts │ │ │ │ ├── DataManager.ts.meta │ │ │ │ ├── LocalData.ts │ │ │ │ └── LocalData.ts.meta │ │ │ ├── event.meta │ │ │ ├── event │ │ │ │ ├── EventManager.ts │ │ │ │ └── EventManager.ts.meta │ │ │ ├── mvc.meta │ │ │ ├── mvc │ │ │ │ ├── Lifecycle.ts │ │ │ │ ├── Lifecycle.ts.meta │ │ │ │ ├── UIManager.ts │ │ │ │ ├── UIManager.ts.meta │ │ │ │ ├── ViewBase.ts │ │ │ │ └── ViewBase.ts.meta │ │ │ ├── storage.meta │ │ │ ├── storage │ │ │ │ ├── StorageManager.ts │ │ │ │ └── StorageManager.ts.meta │ │ │ ├── timer.meta │ │ │ └── timer │ │ │ │ ├── TimerManager.ts │ │ │ │ └── TimerManager.ts.meta │ │ ├── extensions.meta │ │ ├── extensions │ │ │ ├── expr-eval.meta │ │ │ ├── expr-eval │ │ │ │ ├── expr-eval.d.ts │ │ │ │ ├── expr-eval.d.ts.meta │ │ │ │ ├── expr-eval.min.js │ │ │ │ └── expr-eval.min.js.meta │ │ │ ├── fgui.meta │ │ │ ├── fgui │ │ │ │ ├── BaseView.ts │ │ │ │ ├── BaseView.ts.meta │ │ │ │ ├── BaseWindow.ts │ │ │ │ ├── BaseWindow.ts.meta │ │ │ │ ├── FGUIUtil.ts │ │ │ │ ├── FGUIUtil.ts.meta │ │ │ │ ├── fairygui.d.ts │ │ │ │ ├── fairygui.d.ts.meta │ │ │ │ ├── fairygui.js │ │ │ │ └── fairygui.js.meta │ │ │ ├── gzip.meta │ │ │ ├── gzip │ │ │ │ ├── pako.d.ts │ │ │ │ ├── pako.d.ts.meta │ │ │ │ ├── pako.min.js │ │ │ │ └── pako.min.js.meta │ │ │ ├── protobuf.meta │ │ │ ├── protobuf │ │ │ │ ├── protobuf.d.ts │ │ │ │ ├── protobuf.d.ts.meta │ │ │ │ ├── protobuf.min.js │ │ │ │ └── protobuf.min.js.meta │ │ │ ├── qrcode.meta │ │ │ └── qrcode │ │ │ │ ├── components.meta │ │ │ │ ├── components │ │ │ │ ├── QRCode.ts │ │ │ │ └── QRCode.ts.meta │ │ │ │ ├── qrcode.d.ts │ │ │ │ ├── qrcode.d.ts.meta │ │ │ │ ├── qrcode.js │ │ │ │ └── qrcode.js.meta │ │ ├── utils.meta │ │ └── utils │ │ │ ├── Base64.ts │ │ │ ├── Base64.ts.meta │ │ │ ├── BezierMaker.ts │ │ │ ├── BezierMaker.ts.meta │ │ │ ├── HttpUtil.ts │ │ │ ├── HttpUtil.ts.meta │ │ │ ├── polyfill.meta │ │ │ └── polyfill │ │ │ ├── atob&btoa.js │ │ │ ├── atob&btoa.js.meta │ │ │ ├── date.js │ │ │ ├── date.js.meta │ │ │ ├── hotfix.js │ │ │ ├── hotfix.js.meta │ │ │ ├── readme.md │ │ │ └── readme.md.meta │ ├── sdk.meta │ ├── sdk │ │ ├── CallbackManager.ts │ │ ├── CallbackManager.ts.meta │ │ ├── RecoderUtil.ts │ │ ├── RecoderUtil.ts.meta │ │ ├── SdkAdapterBase.ts │ │ ├── SdkAdapterBase.ts.meta │ │ ├── SdkManager.ts │ │ ├── SdkManager.ts.meta │ │ ├── platform.meta │ │ └── platform │ │ │ ├── AndroidAdapter.ts │ │ │ ├── AndroidAdapter.ts.meta │ │ │ ├── DefaultAdapter.ts │ │ │ ├── DefaultAdapter.ts.meta │ │ │ ├── IOSAdapter.ts │ │ │ ├── IOSAdapter.ts.meta │ │ │ ├── h5.meta │ │ │ └── h5 │ │ │ ├── BaiduAdapter.ts │ │ │ ├── BaiduAdapter.ts.meta │ │ │ ├── OppoAdapter.ts │ │ │ ├── OppoAdapter.ts.meta │ │ │ ├── QQAdapter.ts │ │ │ ├── QQAdapter.ts.meta │ │ │ ├── ToutiaoAdapter.ts │ │ │ ├── ToutiaoAdapter.ts.meta │ │ │ ├── VivoAdapter.ts │ │ │ ├── VivoAdapter.ts.meta │ │ │ ├── WechatAdapter.ts │ │ │ └── WechatAdapter.ts.meta │ ├── settings.meta │ └── settings │ │ ├── settings.js │ │ └── settings.js.meta ├── textures.meta └── textures │ ├── common.meta │ └── common │ ├── default.plist │ ├── default.plist.meta │ ├── default.png │ ├── default.png.meta │ ├── singleColor.png │ └── singleColor.png.meta ├── creator.d.ts ├── jsconfig.json ├── project.json ├── readme.md ├── settings ├── builder.json ├── builder.panel.json ├── project.json └── services.json ├── template-banner.png ├── template.json ├── tools ├── 工具-excel配置导出工具.7z ├── 脚本-protobufjs转ts.7z └── 脚本-热更新版本构建.7z └── tsconfig.json /.gitignore: -------------------------------------------------------------------------------- 1 | #///////////////////////////////////////////////////////////////////////////// 2 | # Fireball Projects 3 | #///////////////////////////////////////////////////////////////////////////// 4 | 5 | library/ 6 | temp/ 7 | local/ 8 | build/ 9 | 10 | #///////////////////////////////////////////////////////////////////////////// 11 | # Logs and databases 12 | #///////////////////////////////////////////////////////////////////////////// 13 | 14 | *.log 15 | *.sql 16 | *.sqlite 17 | 18 | #///////////////////////////////////////////////////////////////////////////// 19 | # files for debugger 20 | #///////////////////////////////////////////////////////////////////////////// 21 | 22 | *.sln 23 | *.csproj 24 | *.pidb 25 | *.unityproj 26 | *.suo 27 | 28 | #///////////////////////////////////////////////////////////////////////////// 29 | # OS generated files 30 | #///////////////////////////////////////////////////////////////////////////// 31 | 32 | .DS_Store 33 | ehthumbs.db 34 | Thumbs.db 35 | 36 | #///////////////////////////////////////////////////////////////////////////// 37 | # exvim files 38 | #///////////////////////////////////////////////////////////////////////////// 39 | 40 | *UnityVS.meta 41 | *.err 42 | *.err.meta 43 | *.exvim 44 | *.exvim.meta 45 | *.vimentry 46 | *.vimentry.meta 47 | *.vimproject 48 | *.vimproject.meta 49 | .vimfiles.*/ 50 | .exvim.*/ 51 | quick_gen_project_*_autogen.bat 52 | quick_gen_project_*_autogen.bat.meta 53 | quick_gen_project_*_autogen.sh 54 | quick_gen_project_*_autogen.sh.meta 55 | .exvim.app 56 | 57 | #///////////////////////////////////////////////////////////////////////////// 58 | # webstorm files 59 | #///////////////////////////////////////////////////////////////////////////// 60 | 61 | .idea/ 62 | 63 | #////////////////////////// 64 | # VS Code 65 | #////////////////////////// 66 | 67 | # .vscode/ 68 | # *.meta 69 | /assets-remote/ 70 | -------------------------------------------------------------------------------- /.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | // 使用 IntelliSense 了解相关属性。 3 | // 悬停以查看现有属性的描述。 4 | // 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387 5 | "version": "0.2.0", 6 | "configurations": [ 7 | 8 | { 9 | "type": "chrome", 10 | "request": "launch", 11 | "name": "启动 Chrome 并打开 localhost", 12 | "url": "http://localhost:7456", 13 | "webRoot": "${workspaceFolder}" 14 | } 15 | ] 16 | } -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "files.exclude": { 3 | "**/.git": true, 4 | "**/.svn": true, 5 | "**/.hg": true, 6 | "**/CVS": true, 7 | "**/.DS_Store": true, 8 | "**/*.meta": true 9 | }, 10 | } -------------------------------------------------------------------------------- /FGUIProject/.objs/metas/8djn4yal/fqpx0.info: -------------------------------------------------------------------------------- 1 | { 2 | "objectStatus": { 3 | "n0_jqsi": { 4 | "locked": true 5 | } 6 | } 7 | } -------------------------------------------------------------------------------- /FGUIProject/.objs/workspace.json: -------------------------------------------------------------------------------- 1 | { 2 | "libview.currentGroup": "", 3 | "auxline2": true, 4 | "auxline1": true, 5 | "libview.expandedNodes": [ 6 | "8djn4yal", 7 | "/" 8 | ], 9 | "libview.twoColumn": false, 10 | "doc.activeDoc": "ui://8djn4yalfqpx0", 11 | "doc.openedDocs": [ 12 | "ui://8djn4yalfqpx0" 13 | ], 14 | "libview.firstColumnWidth": 373, 15 | "canvasColor": 10066329, 16 | "backgroundColor": 6710886 17 | } -------------------------------------------------------------------------------- /FGUIProject/FGUIProject.fairy: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /FGUIProject/assets/test/TestUI.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /FGUIProject/assets/test/package.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /FGUIProject/settings/Publish.json: -------------------------------------------------------------------------------- 1 | { 2 | "atlasSetting":{ 3 | "paging":true, 4 | "sizeOption":"pot" 5 | }, 6 | "binaryFormat":true, 7 | "codeGeneration":{ 8 | "classNamePrefix":"UI_", 9 | "codePath":null, 10 | "codeType":"", 11 | "getMemberByName":false, 12 | "ignoreNoname":false, 13 | "memberNamePrefix":"m_", 14 | "packageName":null 15 | }, 16 | "compressDesc":true, 17 | "fileExtension":"bin", 18 | "packageCount":2, 19 | "path":"../assets/resources/ui" 20 | } -------------------------------------------------------------------------------- /assets/project.manifest: -------------------------------------------------------------------------------- 1 | {"packageUrl":"http://assets-remote.oss-cn-hangzhou.aliyuncs.com/hotupdate-test/assets-remote/","remoteManifestUrl":"http://assets-remote.oss-cn-hangzhou.aliyuncs.com/hotupdate-test/assets-remote/project.manifest","remoteVersionUrl":"http://assets-remote.oss-cn-hangzhou.aliyuncs.com/hotupdate-test/assets-remote/version.manifest","version":"1.0.0","assets":{"src/cocos2d-jsb.7f918.js":{"size":1852304,"md5":"1f45e531bc9adc66be29595053f7329b"},"src/project.a2024.js":{"size":119469,"md5":"11243c23a007bcb9e9ec1e464b0d33c6"},"src/settings.ec484.js":{"size":2267,"md5":"1c4843679d6da3b1367a1e89d5feb040"},"res/import/5d/5d46db5f-08cd-4070-abcb-cb24ce3f6094.2f459.json":{"size":63,"md5":"1f4592b3659c0e169ff817de62259291"},"res/import/ff/ffe86cad-7443-4df8-afa9-3e09dacab23f.635c4.json":{"size":59,"md5":"135c4bbafa06c3d072608e8776a83cdf"},"res/import/2f/2f637b37-dfc2-4af7-8fff-0f625b34ee7c.d3dee.json":{"size":63,"md5":"13deefad9ed87a6121751d8ceebd4687"},"res/import/65/654e4821-f78f-4ee0-89a5-69a4cabaae20.28464.json":{"size":63,"md5":"184643ed4986c04607d7a59e2e202a92"},"res/import/f7/f71c4cb4-ce52-48b0-8644-9917332cb8da.f5cba.json":{"size":174,"md5":"15cbac113e216b8c5abba187c6574a7d"},"res/import/7b/7b21811e-5e07-4a84-a482-c4b68c0dacba.536d3.json":{"size":62,"md5":"136d37c16ce7e4d5eecd80f52b2f3a85"},"res/import/18/189ad8f7-b0ce-4714-86e8-92a333262cc9.572cd.json":{"size":63,"md5":"172cd1a7574eff56ad8643345b6ec0d6"},"res/import/03/03b61aa61.ab6b1.json":{"size":2677,"md5":"1b6b11299d3bfff0a211aa790b503ab0"},"res/import/0b/0b42e8182.86719.json":{"size":15187,"md5":"1ceef1a1c7ba6bcce83fb9671606a868"},"res/import/06/06b4ab7a0.1f568.json":{"size":3684,"md5":"1f56879c83b09e868543a9b42be58944"},"res/import/04/0467b42ed.e84ab.json":{"size":292,"md5":"184ab1c65b4c3c6fe07f7f0d5d280f66"},"res/raw-assets/5d/5d46db5f-08cd-4070-abcb-cb24ce3f6094.c4342.manifest":{"size":3566,"md5":"143422f0a87d339cdf7eacf2158af61c"},"res/raw-assets/ff/ffe86cad-7443-4df8-afa9-3e09dacab23f.4db7e.wav":{"size":66436,"md5":"18ef170925aab6e26e2c6911d571c5a6"},"res/raw-assets/2f/2f637b37-dfc2-4af7-8fff-0f625b34ee7c.09059.binary":{"size":1001718,"md5":"19a50902caf4a086ea719e2c1304f80a"},"res/raw-assets/65/654e4821-f78f-4ee0-89a5-69a4cabaae20.d1a64.binary":{"size":40362,"md5":"18e264f5deb26788427dd8b12dc74369"},"res/raw-assets/40/40e96f10-45e9-4f29-ac63-2653d1b747c9.55ea4.png":{"size":37864,"md5":"169a0b857f7462f4dd0d00bb5231a721"},"res/raw-assets/a9/a99f5ba8-a67a-48f3-9cbf-da8ace54fb05.c8742.png":{"size":1398510,"md5":"1d93e709543e9617093c6cfd826eda2a"},"res/raw-assets/26/263f9093-f56a-481a-9668-90e509cae675.e5136.png":{"size":17197,"md5":"1825642f69b6fed137482bf89f8f1fd5"},"res/raw-assets/7b/7b21811e-5e07-4a84-a482-c4b68c0dacba.4ccdd.zip":{"size":3977,"md5":"1e15722b43c4adabe1217e5f6c37b453","compressed":true},"res/raw-assets/18/189ad8f7-b0ce-4714-86e8-92a333262cc9.1c39b.manifest":{"size":217,"md5":"1c39b3cea3ad825b0bd54f173a07ea7c"},"res/raw-assets/02/0275e94c-56a7-410f-bd1a-fc7483f7d14a.cea68.png":{"size":82,"md5":"1b8905d258c5d63118f37c48ec39dd22"},"res/raw-assets/cf/cfef78f1-c8df-49b7-8ed0-4c953ace2621.a4b59.png":{"size":1140,"md5":"119175db4987d7afeff1544698c384df"},"res/raw-assets/99/99170b0b-d210-46f1-b213-7d9e3f23098a.d1118.png":{"size":1177,"md5":"14a30d00fb6c7a7e5a92a06baa37f601"},"res/raw-assets/e8/e851e89b-faa2-4484-bea6-5c01dd9f06e2.90cf4.png":{"size":1082,"md5":"1e1303921bbbc30d934cb49a62e33f3e"},"res/raw-assets/b4/b43ff3c2-02bb-4874-81f7-f2dea6970f18.83fcc.png":{"size":1114,"md5":"19624805cb214b8d78d34a0c03dfbd00"},"res/raw-assets/71/71561142-4c83-4933-afca-cb7a17f67053.c06a9.png":{"size":1050,"md5":"12c8f8527cdbe8246b8223a54f409ca3"},"res/raw-assets/d8/d81ec8ad-247c-4e62-aa3c-d35c4193c7af.cdbc9.png":{"size":158,"md5":"1a40a2a1d71b196f1ffd326e9b2aac06"}},"searchPaths":["assets-remote"]} -------------------------------------------------------------------------------- /assets/project.manifest.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.1", 3 | "uuid": "5d46db5f-08cd-4070-abcb-cb24ce3f6094", 4 | "subMetas": {} 5 | } -------------------------------------------------------------------------------- /assets/resources.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.1", 3 | "uuid": "0c747981-1cc6-4ce2-8d86-0e17f87ae042", 4 | "isSubpackage": false, 5 | "subpackageName": "", 6 | "subMetas": {} 7 | } -------------------------------------------------------------------------------- /assets/resources/configs.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.1", 3 | "uuid": "15522337-5cc7-4019-b54e-53212be9f7aa", 4 | "isSubpackage": false, 5 | "subpackageName": "", 6 | "subMetas": {} 7 | } -------------------------------------------------------------------------------- /assets/resources/configs/Sounds.json: -------------------------------------------------------------------------------- 1 | { 2 | "types": 3 | ["S","S","B"], 4 | "fields": 5 | ["ID","Name","Loop"], 6 | "values": 7 | [ 8 | ["MUSIC_BGM","bgm.mp3","1"] 9 | ,["SOUND_CLICK","common_clicked.mp3","0"]] 10 | } -------------------------------------------------------------------------------- /assets/resources/configs/Sounds.json.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.0", 3 | "uuid": "dfca4410-6dfb-4923-b07a-6c286edb7dfd", 4 | "subMetas": {} 5 | } -------------------------------------------------------------------------------- /assets/resources/prefabs.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.1", 3 | "uuid": "a100e3b4-dd3b-4faf-938d-2466da388274", 4 | "isSubpackage": false, 5 | "subpackageName": "", 6 | "subMetas": {} 7 | } -------------------------------------------------------------------------------- /assets/resources/prefabs/TestUI.prefab.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.2.5", 3 | "uuid": "da94e4a9-79d4-423e-b78a-f8ea947e600b", 4 | "optimizationPolicy": "AUTO", 5 | "asyncLoadAssets": false, 6 | "readonly": false, 7 | "subMetas": {} 8 | } -------------------------------------------------------------------------------- /assets/resources/sounds.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.1", 3 | "uuid": "24f3ea6c-a8c2-48f6-8981-d14ca3bbdcd8", 4 | "isSubpackage": false, 5 | "subpackageName": "", 6 | "subMetas": {} 7 | } -------------------------------------------------------------------------------- /assets/resources/sounds/bgm.mp3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liuwenkai1023/ccc-frameworks/17851b2c22240e343fb7335c148aec8f75c0fb16/assets/resources/sounds/bgm.mp3 -------------------------------------------------------------------------------- /assets/resources/sounds/bgm.mp3.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "2.0.0", 3 | "uuid": "86d44655-267d-462d-bd9a-c46141cf27fd", 4 | "downloadMode": 0, 5 | "subMetas": {} 6 | } -------------------------------------------------------------------------------- /assets/resources/sounds/common_clicked.mp3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liuwenkai1023/ccc-frameworks/17851b2c22240e343fb7335c148aec8f75c0fb16/assets/resources/sounds/common_clicked.mp3 -------------------------------------------------------------------------------- /assets/resources/sounds/common_clicked.mp3.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "2.0.0", 3 | "uuid": "9f784ffd-9e28-4a90-b4ec-5f6cf401a598", 4 | "downloadMode": 0, 5 | "subMetas": {} 6 | } -------------------------------------------------------------------------------- /assets/resources/textures.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.1", 3 | "uuid": "0cc0aafd-4731-47ed-8408-bb9a8f2c76dd", 4 | "isSubpackage": false, 5 | "subpackageName": "", 6 | "subMetas": {} 7 | } -------------------------------------------------------------------------------- /assets/resources/ui.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.1", 3 | "uuid": "65ba624a-3fb2-4592-9407-44612ef85c0a", 4 | "isSubpackage": false, 5 | "subpackageName": "", 6 | "subMetas": {} 7 | } -------------------------------------------------------------------------------- /assets/resources/ui/test.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liuwenkai1023/ccc-frameworks/17851b2c22240e343fb7335c148aec8f75c0fb16/assets/resources/ui/test.bin -------------------------------------------------------------------------------- /assets/resources/ui/test.bin.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.0", 3 | "uuid": "c98edccc-74cd-4df9-8e93-2c5e3ce771e7", 4 | "subMetas": {} 5 | } -------------------------------------------------------------------------------- /assets/scenes.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.1", 3 | "uuid": "7c30c0bd-7c16-4213-82d3-919885f0e9dc", 4 | "isSubpackage": false, 5 | "subpackageName": "", 6 | "subMetas": {} 7 | } -------------------------------------------------------------------------------- /assets/scenes/AppStart.fire.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.2.5", 3 | "uuid": "fd830f1b-8e80-4223-a2f0-53865788f5ce", 4 | "asyncLoadAssets": false, 5 | "autoReleaseAssets": false, 6 | "subMetas": {} 7 | } -------------------------------------------------------------------------------- /assets/scenes/Main.fire.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.2.5", 3 | "uuid": "0d3fe9f6-df73-4116-a588-1fb85fc10446", 4 | "asyncLoadAssets": false, 5 | "autoReleaseAssets": false, 6 | "subMetas": {} 7 | } -------------------------------------------------------------------------------- /assets/scripts.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.1", 3 | "uuid": "dc553c5c-c94d-4601-a7df-d5980d75bff2", 4 | "isSubpackage": false, 5 | "subpackageName": "", 6 | "subMetas": {} 7 | } -------------------------------------------------------------------------------- /assets/scripts/Global.ts: -------------------------------------------------------------------------------- 1 | 2 | import ScreenCapture from "./base/components/ScreenCapture"; 3 | 4 | import { Base64 } from "./base/utils/Base64"; 5 | import { SdkManager } from "./sdk/SdkManager"; 6 | import { LocalData } from "./base/core/data/LocalData"; 7 | import { DataManager } from "./base/core/data/DataManager"; 8 | import { BaseComponent } from "./base/core/BaseComponent"; 9 | import { EventsManager } from "./base/core/event/EventManager"; 10 | import { AudioManager } from "./base/core/audio/AudioMananger"; 11 | import { TimerManager } from "./base/core/timer/TimerManager"; 12 | import { UIManager } from "./base/core/mvc/UIManager"; 13 | import { SingletonFactory } from "./base/core/SingleFactory"; 14 | import { LocalStorageManager } from "./base/core/storage/StorageManager"; 15 | import { CallbackManager } from "./sdk/CallbackManager"; 16 | 17 | 18 | /** 19 | * Utils 20 | */ 21 | export class Utils { 22 | Base64 = Base64; 23 | LocalData = SingletonFactory.getInstance(LocalData); 24 | DataManager = SingletonFactory.getInstance(DataManager); 25 | EventManager = SingletonFactory.getInstance(EventsManager); 26 | AudioManager = SingletonFactory.getInstance(AudioManager); 27 | TimerManager = SingletonFactory.getInstance(TimerManager); 28 | StorageManager = SingletonFactory.getInstance(LocalStorageManager); 29 | UIManager = SingletonFactory.getInstance(UIManager); 30 | } 31 | 32 | 33 | /** 34 | * App 快捷方法 35 | */ 36 | export class MyApp { 37 | 38 | Sdk = SingletonFactory.getInstance(SdkManager).adapter; 39 | Utils: Utils = SingletonFactory.getInstance(Utils); 40 | 41 | BaseComponent = BaseComponent; 42 | SingletonFactory = SingletonFactory; 43 | 44 | 45 | /** 46 | * 原生到脚本回调 47 | * @param callbackId 回调id 48 | * @param result 回调结果 49 | */ 50 | doCallbackFunc(callbackId: number, result: { errCode: number, data?: any, msg?: string }) { 51 | SingletonFactory.getInstance(CallbackManager).doCallbackFunc(callbackId, result); 52 | } 53 | 54 | /** 55 | * 截屏 56 | */ 57 | async screenCapture() { 58 | const screenCapture = cc.director.getScene().getComponentInChildren(ScreenCapture); 59 | return screenCapture.captureScreenAndSaveData(); 60 | } 61 | 62 | /** 63 | * toast提示消息 64 | * @param text 65 | * @param duration 66 | */ 67 | showToast(text: string, duration?: number) { 68 | SingletonFactory.getInstance(EventsManager).emit("SHOW_TOAST", { text: text, duration: duration }); 69 | } 70 | 71 | /** 72 | * 展示顶层Mask 73 | * @param show 74 | */ 75 | showMask(show: boolean) { 76 | const mask = cc.find("mask"); 77 | mask.active = show; 78 | mask.zIndex = cc.macro.MAX_ZINDEX; 79 | } 80 | 81 | /** 82 | * 垃圾回收 83 | */ 84 | triggerGC() { 85 | if (CC_WECHATGAME) { 86 | window['wx'].triggerGC(); 87 | } else if (CC_JSB) { 88 | cc.sys.garbageCollect(); 89 | } 90 | } 91 | 92 | /** 93 | * 格式化日期 94 | * @example App.formatDate(date, `yyyy-MM-dd hh:mm:ss`); 95 | * "M+"月份 "d+"日 "h+"小时 "m+"分 "s+"秒 "q+"季度 "S"毫秒 96 | * @param date 97 | * @param format 98 | */ 99 | formatDate(date: Date, format: string): string { 100 | return date['format'](format); 101 | } 102 | 103 | /** 104 | * 格式化数字(按一定的结构) 105 | * @param num 106 | * @param charList 107 | */ 108 | formatNum(num: number, charList: Array = ["", "k", "m", "b", "g", "t", "p", "e", "z", "y", "n", "d", "s"]) { 109 | let tempNum = num = Math.floor(Number(num)); 110 | let index = 0; 111 | while (tempNum / 1000 >= 1) { 112 | index++; 113 | tempNum = tempNum / 1000; 114 | } 115 | return Math.round(tempNum * 100) / 100 + charList[index]; 116 | } 117 | 118 | } 119 | 120 | /** 121 | * 定义Global变量 122 | */ 123 | declare global { 124 | export let App: MyApp; 125 | export let Utils: Utils; 126 | interface Window { 127 | App: MyApp; 128 | Utils: Utils; 129 | } 130 | } 131 | 132 | window.App = SingletonFactory.getInstance(MyApp); 133 | cc.macro.ENABLE_WEBGL_ANTIALIAS = true; -------------------------------------------------------------------------------- /assets/scripts/Global.ts.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.5", 3 | "uuid": "a67b4c0a-08e1-4ed6-b2c8-3d6713b34d45", 4 | "isPlugin": false, 5 | "loadPluginInWeb": true, 6 | "loadPluginInNative": true, 7 | "loadPluginInEditor": false, 8 | "subMetas": {} 9 | } -------------------------------------------------------------------------------- /assets/scripts/app.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.1", 3 | "uuid": "bb57a544-fec0-48d6-b644-3fe5df88b75d", 4 | "isSubpackage": false, 5 | "subpackageName": "", 6 | "subMetas": {} 7 | } -------------------------------------------------------------------------------- /assets/scripts/app/data.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.1", 3 | "uuid": "f46983b1-665e-4436-a059-af269b2e811f", 4 | "isSubpackage": false, 5 | "subpackageName": "", 6 | "subMetas": {} 7 | } -------------------------------------------------------------------------------- /assets/scripts/app/data/EventCommon.ts: -------------------------------------------------------------------------------- 1 | export enum EventCommon { 2 | DRAW_LINE_END = "DRAW_LINE_END", 3 | SHOW_TOAST = "SHOW_TOAST" 4 | } -------------------------------------------------------------------------------- /assets/scripts/app/data/EventCommon.ts.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.5", 3 | "uuid": "53669f0e-8250-4f40-9e08-44ed3dea9625", 4 | "isPlugin": false, 5 | "loadPluginInWeb": true, 6 | "loadPluginInNative": true, 7 | "loadPluginInEditor": false, 8 | "subMetas": {} 9 | } -------------------------------------------------------------------------------- /assets/scripts/app/data/GameDataDef.ts: -------------------------------------------------------------------------------- 1 | export let GameDataDef =[ 2 | // Name Type Default ResetDaliy Min Max 3 | ["GuideNum", "number", 1, false], 4 | ["Gold", "number", 500, false], 5 | ]; -------------------------------------------------------------------------------- /assets/scripts/app/data/GameDataDef.ts.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.5", 3 | "uuid": "835f6c28-7f95-4a1a-ad74-6d344b056b6a", 4 | "isPlugin": false, 5 | "loadPluginInWeb": true, 6 | "loadPluginInNative": true, 7 | "loadPluginInEditor": false, 8 | "subMetas": {} 9 | } -------------------------------------------------------------------------------- /assets/scripts/app/data/proto.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.1", 3 | "uuid": "f447fbb0-fc38-460b-a25a-2cd40c606a4d", 4 | "isSubpackage": false, 5 | "subpackageName": "", 6 | "subMetas": {} 7 | } -------------------------------------------------------------------------------- /assets/scripts/app/data/proto/person.d.ts: -------------------------------------------------------------------------------- 1 | import * as $protobuf from protobuf; 2 | /** Namespace user. */ 3 | export namespace user { 4 | 5 | /** Sex enum. */ 6 | enum Sex { 7 | male = 0, 8 | female = 1 9 | } 10 | 11 | /** Properties of a LoveGame. */ 12 | interface ILoveGame { 13 | 14 | /** LoveGame name */ 15 | name?: (string|null); 16 | 17 | /** LoveGame type */ 18 | type?: (string|null); 19 | } 20 | 21 | /** Represents a LoveGame. */ 22 | class LoveGame implements ILoveGame { 23 | 24 | /** 25 | * Constructs a new LoveGame. 26 | * @param [properties] Properties to set 27 | */ 28 | constructor(properties?: user.ILoveGame); 29 | 30 | /** LoveGame name. */ 31 | public name: string; 32 | 33 | /** LoveGame type. */ 34 | public type: string; 35 | 36 | /** 37 | * Creates a new LoveGame instance using the specified properties. 38 | * @param [properties] Properties to set 39 | * @returns LoveGame instance 40 | */ 41 | public static create(properties?: user.ILoveGame): user.LoveGame; 42 | 43 | /** 44 | * Encodes the specified LoveGame message. Does not implicitly {@link user.LoveGame.verify|verify} messages. 45 | * @param message LoveGame message or plain object to encode 46 | * @param [writer] Writer to encode to 47 | * @returns Writer 48 | */ 49 | public static encode(message: user.ILoveGame, writer?: $protobuf.Writer): $protobuf.Writer; 50 | 51 | /** 52 | * Encodes the specified LoveGame message, length delimited. Does not implicitly {@link user.LoveGame.verify|verify} messages. 53 | * @param message LoveGame message or plain object to encode 54 | * @param [writer] Writer to encode to 55 | * @returns Writer 56 | */ 57 | public static encodeDelimited(message: user.ILoveGame, writer?: $protobuf.Writer): $protobuf.Writer; 58 | 59 | /** 60 | * Decodes a LoveGame message from the specified reader or buffer. 61 | * @param reader Reader or buffer to decode from 62 | * @param [length] Message length if known beforehand 63 | * @returns LoveGame 64 | * @throws {Error} If the payload is not a reader or valid buffer 65 | * @throws {$protobuf.util.ProtocolError} If required fields are missing 66 | */ 67 | public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): user.LoveGame; 68 | 69 | /** 70 | * Decodes a LoveGame message from the specified reader or buffer, length delimited. 71 | * @param reader Reader or buffer to decode from 72 | * @returns LoveGame 73 | * @throws {Error} If the payload is not a reader or valid buffer 74 | * @throws {$protobuf.util.ProtocolError} If required fields are missing 75 | */ 76 | public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): user.LoveGame; 77 | 78 | /** 79 | * Verifies a LoveGame message. 80 | * @param message Plain object to verify 81 | * @returns `null` if valid, otherwise the reason why it is not 82 | */ 83 | public static verify(message: { [k: string]: any }): (string|null); 84 | 85 | /** 86 | * Creates a LoveGame message from a plain object. Also converts values to their respective internal types. 87 | * @param object Plain object 88 | * @returns LoveGame 89 | */ 90 | public static fromObject(object: { [k: string]: any }): user.LoveGame; 91 | 92 | /** 93 | * Creates a plain object from a LoveGame message. Also converts values to other types if specified. 94 | * @param message LoveGame 95 | * @param [options] Conversion options 96 | * @returns Plain object 97 | */ 98 | public static toObject(message: user.LoveGame, options?: $protobuf.IConversionOptions): { [k: string]: any }; 99 | 100 | /** 101 | * Converts this LoveGame to JSON. 102 | * @returns JSON object 103 | */ 104 | public toJSON(): { [k: string]: any }; 105 | } 106 | 107 | /** Properties of a UserInfo. */ 108 | interface IUserInfo { 109 | 110 | /** UserInfo name */ 111 | name?: (string|null); 112 | 113 | /** UserInfo age */ 114 | age?: (number|null); 115 | 116 | /** UserInfo game */ 117 | game?: (user.ILoveGame[]|null); 118 | 119 | /** UserInfo sex */ 120 | sex?: (user.Sex|null); 121 | } 122 | 123 | /** Represents a UserInfo. */ 124 | class UserInfo implements IUserInfo { 125 | 126 | /** 127 | * Constructs a new UserInfo. 128 | * @param [properties] Properties to set 129 | */ 130 | constructor(properties?: user.IUserInfo); 131 | 132 | /** UserInfo name. */ 133 | public name: string; 134 | 135 | /** UserInfo age. */ 136 | public age: number; 137 | 138 | /** UserInfo game. */ 139 | public game: user.ILoveGame[]; 140 | 141 | /** UserInfo sex. */ 142 | public sex: user.Sex; 143 | 144 | /** 145 | * Creates a new UserInfo instance using the specified properties. 146 | * @param [properties] Properties to set 147 | * @returns UserInfo instance 148 | */ 149 | public static create(properties?: user.IUserInfo): user.UserInfo; 150 | 151 | /** 152 | * Encodes the specified UserInfo message. Does not implicitly {@link user.UserInfo.verify|verify} messages. 153 | * @param message UserInfo message or plain object to encode 154 | * @param [writer] Writer to encode to 155 | * @returns Writer 156 | */ 157 | public static encode(message: user.IUserInfo, writer?: $protobuf.Writer): $protobuf.Writer; 158 | 159 | /** 160 | * Encodes the specified UserInfo message, length delimited. Does not implicitly {@link user.UserInfo.verify|verify} messages. 161 | * @param message UserInfo message or plain object to encode 162 | * @param [writer] Writer to encode to 163 | * @returns Writer 164 | */ 165 | public static encodeDelimited(message: user.IUserInfo, writer?: $protobuf.Writer): $protobuf.Writer; 166 | 167 | /** 168 | * Decodes a UserInfo message from the specified reader or buffer. 169 | * @param reader Reader or buffer to decode from 170 | * @param [length] Message length if known beforehand 171 | * @returns UserInfo 172 | * @throws {Error} If the payload is not a reader or valid buffer 173 | * @throws {$protobuf.util.ProtocolError} If required fields are missing 174 | */ 175 | public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): user.UserInfo; 176 | 177 | /** 178 | * Decodes a UserInfo message from the specified reader or buffer, length delimited. 179 | * @param reader Reader or buffer to decode from 180 | * @returns UserInfo 181 | * @throws {Error} If the payload is not a reader or valid buffer 182 | * @throws {$protobuf.util.ProtocolError} If required fields are missing 183 | */ 184 | public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): user.UserInfo; 185 | 186 | /** 187 | * Verifies a UserInfo message. 188 | * @param message Plain object to verify 189 | * @returns `null` if valid, otherwise the reason why it is not 190 | */ 191 | public static verify(message: { [k: string]: any }): (string|null); 192 | 193 | /** 194 | * Creates a UserInfo message from a plain object. Also converts values to their respective internal types. 195 | * @param object Plain object 196 | * @returns UserInfo 197 | */ 198 | public static fromObject(object: { [k: string]: any }): user.UserInfo; 199 | 200 | /** 201 | * Creates a plain object from a UserInfo message. Also converts values to other types if specified. 202 | * @param message UserInfo 203 | * @param [options] Conversion options 204 | * @returns Plain object 205 | */ 206 | public static toObject(message: user.UserInfo, options?: $protobuf.IConversionOptions): { [k: string]: any }; 207 | 208 | /** 209 | * Converts this UserInfo to JSON. 210 | * @returns JSON object 211 | */ 212 | public toJSON(): { [k: string]: any }; 213 | } 214 | } 215 | -------------------------------------------------------------------------------- /assets/scripts/app/data/proto/person.d.ts.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "2.0.0", 3 | "uuid": "1db718ca-f6e7-4bea-8f9a-b6654d63f357", 4 | "subMetas": {} 5 | } -------------------------------------------------------------------------------- /assets/scripts/app/data/proto/person.js.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.5", 3 | "uuid": "84c1be62-9293-45fe-8740-bbad0060480e", 4 | "isPlugin": false, 5 | "loadPluginInWeb": true, 6 | "loadPluginInNative": true, 7 | "loadPluginInEditor": false, 8 | "subMetas": {} 9 | } -------------------------------------------------------------------------------- /assets/scripts/app/page.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.1", 3 | "uuid": "35334019-0973-45a1-a531-f4519609dd13", 4 | "isSubpackage": false, 5 | "subpackageName": "", 6 | "subMetas": {} 7 | } -------------------------------------------------------------------------------- /assets/scripts/app/page/TestFGUI.ts: -------------------------------------------------------------------------------- 1 | import { BaseView } from "../../base/extensions/fgui/BaseView"; 2 | 3 | export class TestFGUI extends BaseView { 4 | 5 | pkgName = "test"; 6 | resName = "TestUI"; 7 | 8 | showEnterAndLeaveAnim = false; 9 | 10 | onCreate(view: fgui.GComponent) { 11 | } 12 | 13 | onShown() { 14 | super.onShown(); 15 | } 16 | 17 | onHide() { 18 | super.onHide(); 19 | } 20 | 21 | } -------------------------------------------------------------------------------- /assets/scripts/app/page/TestFGUI.ts.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.5", 3 | "uuid": "2e71334d-41a8-4bd4-a239-fa412a2d6d18", 4 | "isPlugin": false, 5 | "loadPluginInWeb": true, 6 | "loadPluginInNative": true, 7 | "loadPluginInEditor": false, 8 | "subMetas": {} 9 | } -------------------------------------------------------------------------------- /assets/scripts/app/page/TestUI.ts: -------------------------------------------------------------------------------- 1 | import { ViewBase } from "../../base/core/mvc/ViewBase"; 2 | import { HttpUtil } from "../../base/utils/HttpUtil"; 3 | import { user } from "../data/proto/person"; 4 | import { DataManager } from "../../base/core/data/DataManager"; 5 | import { AudioManager } from "../../base/core/audio/AudioMananger"; 6 | import { LocalStorageManager } from "../../base/core/storage/StorageManager"; 7 | import { TimerManager } from "../../base/core/timer/TimerManager"; 8 | import { Base64 } from "../../base/utils/Base64"; 9 | import { FGUIUtil } from "../../base/extensions/fgui/FGUIUtil"; 10 | import { TestFGUI } from "./TestFGUI"; 11 | 12 | 13 | export class TestUI extends ViewBase { 14 | 15 | static UIName = "TestUI"; 16 | static ResourcePath = "prefabs/TestUI"; 17 | 18 | private label: cc.Label; 19 | 20 | onLoad() { 21 | this.bindView("label", "testLabel", cc.Label); 22 | this.bindEvent("HELLO", this.sayHello.bind(this)); 23 | } 24 | 25 | start() { 26 | console.log("TestUI:测试代码"); 27 | this.Test(); 28 | this.initFGUI(); 29 | FGUIUtil.getUI(TestFGUI).show(); 30 | } 31 | 32 | initFGUI() { 33 | fgui.addLoadHandler(); 34 | fgui.UIConfig.modalLayerColor = new cc.Color(0, 0, 0, 180); 35 | fgui.GRoot.create(); 36 | fgui.GRoot.inst.node.zIndex = 99; 37 | } 38 | 39 | Test() { 40 | // /** 41 | // * Event Test 42 | // */ 43 | // this.scheduleOnce(() => { this.Event.emit("HELLO", "Hello, this is a event message."); }, 1); 44 | 45 | // /** 46 | // * HttpUtil Test 47 | // */ 48 | // HttpUtil.HttpPost("http://localhost:7456/", null, (res) => { }); 49 | // HttpUtil.HttpGet("http://localhost:7456/", null, (res) => { }); 50 | // HttpUtil.HttpDownload("http://localhost:7456", "test.html", (err, path) => { }); 51 | 52 | // /** 53 | // * Protobuf Test 54 | // */ 55 | // let userInfo = new user.UserInfo(); 56 | // userInfo.name = "ProtoMe"; 57 | // userInfo.age = 23; 58 | // userInfo.sex = user.Sex.male; 59 | // userInfo.game = [new user.LoveGame()] 60 | // let arrbuf = user.UserInfo.encode(userInfo).finish(); 61 | // let decode = user.UserInfo.decode(arrbuf); 62 | // console.log("userInfo", userInfo); 63 | // console.log("arraybuffer", arrbuf); 64 | // console.log("decode", decode); 65 | 66 | // /** 67 | // * Expression Evaluator Test 68 | // */ 69 | // let result = exprEval.Parser.evaluate('6 * x', { x: 7 }); 70 | // console.log("result = ", result); 71 | 72 | // /** 73 | // * Data Manager Test 74 | // */ 75 | // let dataMamager = App.SingletonFactory.getInstance(DataManager); 76 | // dataMamager.loadJsonData("config/Sounds", "Sounds", true, (config) => { 77 | // console.log(config); 78 | 79 | // /** 80 | // * AudioManager Test 81 | // */ 82 | // let bgm = dataMamager.getDataByNameAndId("Sounds", "MUSIC_BGM"); 83 | // App.SingletonFactory.getInstance(AudioManager).playMusic(bgm[`Name`]); 84 | // }); 85 | 86 | // /** 87 | // * Storage Test 88 | // */ 89 | // let localStorageManager = App.SingletonFactory.getInstance(LocalStorageManager); 90 | // localStorageManager.setObject("StorageTest", { x: 100, y: 100, name: "Storage Test" }); 91 | // console.log(localStorageManager.getObject("StorageTest")); 92 | 93 | // /** 94 | // * Timer Test 95 | // */ 96 | // let s = 0; 97 | // let handler = App.SingletonFactory.getInstance(TimerManager).runLoopTimer((dt: number) => { 98 | // console.log("Timer:", ++s, " dt =", dt); 99 | // s == 10 && App.SingletonFactory.getInstance(TimerManager).removeTimer(handler); 100 | // }, 1); 101 | 102 | // /** 103 | // * Gzip Test 104 | // */ 105 | // let encode = pako.gzip( 106 | // ` 107 | // 去ABCDEFGHIJKLMNOPQRSTUVWXYZ! 108 | // 我ABCDEFGHIJKLMNOPQRSTUVWXYZ@ 109 | // 恶ABCDEFGHIJKLMNOPQRSTUVWXYZ# 110 | // 人ABCDEFGHIJKLMNOPQRSTUVWXYZ¥ 111 | // 他ABCDEFGHIJKLMNOPQRSTUVWXYZ% 112 | // 有ABCDEFGHIJKLMNOPQRSTUVWXYZ…… 113 | // uABCDEFGHIJKLMNOPQRSTUVWXYZ& 114 | // iABCDEFGHIJKLMNOPQRSTUVWXYZ* 115 | // 哦ABCDEFGHIJKLMNOPQRSTUVWXYZ(` 116 | // ); 117 | // let decode2 = pako.ungzip(encode, { to: 'string' }); 118 | // let decode3 = pako.ungzip(encode); 119 | // console.log(decode2); 120 | // console.log("压缩前大小:", decode3.length); 121 | // console.log("压缩后大小:", encode.length); 122 | 123 | // /** 124 | // * Base64 Test 125 | // */ 126 | // let encodeB = Base64.encode("去微软推哦怕"); 127 | // let decodeB2 = Base64.decode(encodeB); 128 | // console.log(encodeB, '=>', decodeB2); 129 | 130 | } 131 | 132 | sayHello(data) { 133 | this.label.string = data; 134 | } 135 | 136 | } -------------------------------------------------------------------------------- /assets/scripts/app/page/TestUI.ts.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.5", 3 | "uuid": "d5b02fb2-b5d2-4665-925b-2cc0f11d9ab5", 4 | "isPlugin": false, 5 | "loadPluginInWeb": true, 6 | "loadPluginInNative": true, 7 | "loadPluginInEditor": false, 8 | "subMetas": {} 9 | } -------------------------------------------------------------------------------- /assets/scripts/app/scene.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.1", 3 | "uuid": "f6d82d57-b4cb-46c2-8d7c-95cde26289aa", 4 | "isSubpackage": false, 5 | "subpackageName": "", 6 | "subMetas": {} 7 | } -------------------------------------------------------------------------------- /assets/scripts/app/scene/AppStart.ts: -------------------------------------------------------------------------------- 1 | import { BaseComponent } from "../../base/core/BaseComponent"; 2 | import { UIManager } from "../../base/core/mvc/UIManager"; 3 | 4 | 5 | const { ccclass, property } = cc._decorator; 6 | 7 | @ccclass 8 | export class AppStart extends BaseComponent { 9 | 10 | private fadeTime: number; 11 | private targetTime: number; 12 | private currentTime: number; 13 | private preLoaded: boolean; 14 | 15 | onLoad() { 16 | this.initData(); 17 | // this.CCMaskHook(); 18 | // this.CCButtonHook(); 19 | } 20 | 21 | // CCMaskHook() { 22 | // let prototype = cc.Mask.prototype as any; 23 | // let onLoad = prototype.onLoad; 24 | // prototype.onLoad = function () { 25 | // onLoad.bind(this)(); 26 | // let canvasSize = cc.view.getCanvasSize(); 27 | // this._clearGraphics.rect(-canvasSize.width / 2, -canvasSize.height / 2, 3000, 3000); 28 | // this._clearGraphics.fill(); 29 | // } 30 | // } 31 | 32 | // CCButtonHook() { 33 | // let prototype = cc.Button.prototype as any; 34 | // let _onTouchEnded = prototype._onTouchEnded; 35 | // prototype._soundId = "SOUND_CLICK"; 36 | // prototype._onTouchEnded = function (event) { 37 | // _onTouchEnded.bind(this)(event); 38 | // // 播放通用按钮音效 39 | // }; 40 | // } 41 | 42 | initData() { 43 | this.fadeTime = .5; 44 | this.targetTime = 1.5; 45 | this.currentTime = 0; 46 | this.preLoaded = false; 47 | this.node.opacity = 0; 48 | this.node.runAction(cc.fadeIn(this.fadeTime)); 49 | // 加载本地数据 50 | // 加载配置 51 | } 52 | 53 | start() { 54 | cc.director.preloadScene("Main", null, () => { 55 | this.preLoaded = true; 56 | }); 57 | } 58 | 59 | update(dt: number) { 60 | this.currentTime += dt; 61 | if (this.preLoaded && this.currentTime >= this.targetTime) { 62 | cc.director.loadScene("Main"); 63 | this.preLoaded = false; 64 | } 65 | } 66 | 67 | onDestroy() { 68 | App.SingletonFactory.getInstance(UIManager).destoryAllUI(); 69 | } 70 | 71 | } -------------------------------------------------------------------------------- /assets/scripts/app/scene/AppStart.ts.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.5", 3 | "uuid": "b9fb7548-03a1-4612-90ed-ea0eed441266", 4 | "isPlugin": false, 5 | "loadPluginInWeb": true, 6 | "loadPluginInNative": true, 7 | "loadPluginInEditor": false, 8 | "subMetas": {} 9 | } -------------------------------------------------------------------------------- /assets/scripts/app/scene/Main.ts: -------------------------------------------------------------------------------- 1 | import { TestUI } from "../page/TestUI"; 2 | // import { UIManager } from "../../base/core/mvc/UIManager"; 3 | 4 | const { ccclass, property } = cc._decorator; 5 | 6 | @ccclass 7 | export class Main extends cc.Component { 8 | 9 | @property(cc.Node) 10 | uiNode: cc.Node = null; 11 | 12 | onLoad() { 13 | // App.SingletonFactory.getInstance(UIManager).showUI(TestUI); 14 | App.Utils.UIManager.showUI(TestUI, this.uiNode); 15 | } 16 | 17 | } -------------------------------------------------------------------------------- /assets/scripts/app/scene/Main.ts.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.5", 3 | "uuid": "0681a087-248d-444a-8f7e-6f81a3a48be4", 4 | "isPlugin": false, 5 | "loadPluginInWeb": true, 6 | "loadPluginInNative": true, 7 | "loadPluginInEditor": false, 8 | "subMetas": {} 9 | } -------------------------------------------------------------------------------- /assets/scripts/base.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.1", 3 | "uuid": "76a5f177-5d2e-425c-9ed5-1fa80fb6c6b3", 4 | "isSubpackage": false, 5 | "subpackageName": "", 6 | "subMetas": {} 7 | } -------------------------------------------------------------------------------- /assets/scripts/base/components.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.1", 3 | "uuid": "08bd765f-efeb-4074-ab25-e3936463155d", 4 | "isSubpackage": false, 5 | "subpackageName": "", 6 | "subMetas": {} 7 | } -------------------------------------------------------------------------------- /assets/scripts/base/components/FitUI.ts: -------------------------------------------------------------------------------- 1 | const { ccclass, property, executeInEditMode, menu, requireComponent } = cc._decorator; 2 | 3 | export enum FitUIPlatform { ANDROID, IOS, OTHER } 4 | 5 | export enum FitUIOrientation { HORIZONTAL, VERTICAL } 6 | 7 | const IsH = function () { return this.orientation == FitUIOrientation.HORIZONTAL }; 8 | const IsV = function () { return this.orientation == FitUIOrientation.VERTICAL }; 9 | 10 | @ccclass 11 | @menu("扩展组件/FitUI") 12 | @executeInEditMode 13 | @requireComponent(cc.Widget) 14 | export default class FitUI extends cc.Component { 15 | 16 | // Orientation 17 | @property({ displayName: "适配方向", type: cc.Enum(FitUIOrientation) }) 18 | orientation: FitUIOrientation = FitUIOrientation.VERTICAL; 19 | 20 | 21 | // Android 22 | @property({ displayName: "安卓设备", type: cc.Enum(FitUIPlatform) }) 23 | get a() { return FitUIPlatform.ANDROID; } 24 | 25 | @property({ displayName: "left", visible: IsH }) 26 | left: boolean = false; 27 | 28 | @property({ displayName: "right", visible: IsH }) 29 | right: boolean = false; 30 | 31 | @property({ displayName: "top", visible: IsV }) 32 | top: boolean = false; 33 | 34 | @property({ displayName: "bottom", visible: IsV }) 35 | bottom: boolean = false; 36 | 37 | 38 | // IOS 39 | @property({ displayName: "苹果设备", type: cc.Enum(FitUIPlatform) }) 40 | get i() { return FitUIPlatform.IOS; } 41 | 42 | @property({ displayName: "left", visible: IsH }) 43 | iLeft: boolean = false; 44 | 45 | @property({ displayName: "right", visible: IsH }) 46 | iRight: boolean = false; 47 | 48 | @property({ displayName: "top", visible: IsV }) 49 | iTop: boolean = false; 50 | 51 | @property({ displayName: "bottom", visible: IsV }) 52 | iBottom: boolean = false; 53 | 54 | 55 | // OTHER 56 | @property({ displayName: "其它设备", type: cc.Enum(FitUIPlatform) }) 57 | get o() { return FitUIPlatform.OTHER; } 58 | 59 | @property({ displayName: "left", visible: IsH }) 60 | oLeft: boolean = false; 61 | 62 | @property({ displayName: "right", visible: IsH }) 63 | oRight: boolean = false; 64 | 65 | @property({ displayName: "top", visible: IsV }) 66 | oTop: boolean = false; 67 | 68 | @property({ displayName: "bottom", visible: IsV }) 69 | oBottom: boolean = false; 70 | 71 | 72 | onLoad() { 73 | CC_EDITOR && this.getComponents(FitUI).length > 2 && this.node.removeComponent(this); 74 | (!CC_EDITOR) && this.applySettings(); 75 | } 76 | 77 | 78 | private applySettings() { 79 | let size = cc.view.getVisibleSize() 80 | let nPlatform = cc.sys.platform; 81 | let tSize = size.width / size.height; 82 | tSize = this.orientation == FitUIOrientation.VERTICAL ? tSize : 1 / tSize; 83 | let dSize = 0.56; // 只有全面屏需要适配 84 | if (tSize >= dSize) { 85 | this.updateFitStrategy(true, true); 86 | return; 87 | } else { 88 | this.orientation == FitUIOrientation.VERTICAL && this.updateFitStrategy(true, false); 89 | this.orientation == FitUIOrientation.HORIZONTAL && this.updateFitStrategy(false, true); 90 | } 91 | // nPlatform = cc.sys.IPHONE; 92 | let aRule = { top: this.top, left: this.left, right: this.right, bottom: this.bottom }; 93 | let iRule = { top: this.iTop, left: this.iLeft, right: this.iRight, bottom: this.iBottom }; 94 | let oRule = { top: this.oTop, left: this.oLeft, right: this.oRight, bottom: this.oBottom }; 95 | switch (nPlatform) { 96 | case cc.sys.ANDROID: 97 | this.fitPhone(aRule); 98 | break; 99 | case cc.sys.IPHONE: 100 | this.fitPhone(iRule); 101 | break; 102 | default: // 非原生 103 | if (!CC_JSB) { 104 | switch (cc.sys.os) { 105 | case cc.sys.OS_IOS: 106 | this.fitPhone(iRule); 107 | break; 108 | case cc.sys.OS_ANDROID: 109 | this.fitPhone(aRule); 110 | break; 111 | default: // 无法识别,按OTHER处理 112 | this.fitPhone(oRule) 113 | break; 114 | } 115 | } 116 | break; 117 | } 118 | } 119 | 120 | 121 | private fitPhone(rule: { top: boolean, left: boolean, right: boolean, bottom: boolean }) { 122 | // 分辨率 375 x 812 123 | let size = cc.view.getVisibleSize(); 124 | let height = this.orientation == FitUIOrientation.VERTICAL ? size.height : size.width 125 | let liuhaiHeight = height * 44 / 812; // 顶部刘海 126 | let bottomHeight = height * 34 / 812; // 底部安全区域 127 | // 适配 128 | switch (this.orientation) { 129 | case FitUIOrientation.VERTICAL: 130 | rule.top && this.updateWidget("top", liuhaiHeight); 131 | rule.bottom && this.updateWidget("bottom", bottomHeight); 132 | break; 133 | case FitUIOrientation.HORIZONTAL: 134 | rule.left && this.updateWidget("left", bottomHeight); 135 | rule.right && this.updateWidget("right", liuhaiHeight); 136 | break; 137 | default: 138 | break; 139 | } 140 | } 141 | 142 | 143 | private updateWidget(orientation: string, delta: number) { 144 | let widget = this.getComponent(cc.Widget); 145 | if (widget) { 146 | if (!widget[`default_${orientation}`]) { 147 | widget[`default_${orientation}`] = widget[`${orientation}`]; 148 | } 149 | widget[`${orientation}`] = widget[`default_${orientation}`] + delta; 150 | } 151 | } 152 | 153 | 154 | private updateFitStrategy(fitWidth: boolean, fitHeight: boolean) { 155 | // console.log(fitWidth, fitHeight); 156 | let canvas = this.node.getComponent(cc.Canvas); 157 | if (canvas) { 158 | canvas.fitWidth = fitWidth; 159 | canvas.fitHeight = fitHeight; 160 | // console.log("updateFitStrategy", canvas); 161 | canvas[`applySettings`](); 162 | } 163 | } 164 | 165 | // update (dt) {} 166 | } 167 | -------------------------------------------------------------------------------- /assets/scripts/base/components/FitUI.ts.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.5", 3 | "uuid": "1ceb7a66-d9b6-4917-9593-15d6374181e2", 4 | "isPlugin": false, 5 | "loadPluginInWeb": true, 6 | "loadPluginInNative": true, 7 | "loadPluginInEditor": false, 8 | "subMetas": {} 9 | } -------------------------------------------------------------------------------- /assets/scripts/base/components/HotUpdate.ts: -------------------------------------------------------------------------------- 1 | import { BaseComponent } from "../core/BaseComponent"; 2 | 3 | const { ccclass, property, menu } = cc._decorator; 4 | 5 | /** 6 | * 热更广播事件枚举 7 | */ 8 | export enum HotUpdateEventType { 9 | HOT_NEED, // 需要更新 10 | HOT_ERROE, // 更新出错 11 | HOT_PASSED, // 不需要更新,直接通过 12 | HOT_UPDATING, // 正在更新 13 | CHECK_UPDATE, // 通知进行检查更新 14 | START_UPDATE, // 通知开始进行更新 15 | RETRY_UPDATE // 通知尝试重新更新 16 | } 17 | 18 | @ccclass 19 | @menu("扩展组件/HotUpdate") 20 | export class HotUpdate extends BaseComponent { 21 | 22 | 23 | @property({ type: cc.Asset }) 24 | private manifestUrl: cc.Asset = null; 25 | 26 | private _updating: boolean = false; 27 | private _canRetry: boolean = false; 28 | private _storagePath: string = ''; 29 | 30 | private _assetManager = null; 31 | // private _failCount: number = 0; 32 | 33 | onInitData() { 34 | this.Event.on("CHECK_UPDATE", this.checkUpdate.bind(this)); 35 | this.Event.on("START_UPDATE", this.hotUpdate.bind(this)); 36 | this.Event.on("RETRY_UPDATE", this.retry.bind(this)); 37 | } 38 | 39 | onLoad() { 40 | if (!cc.sys.isNative) return; 41 | this._storagePath = ((jsb.fileUtils ? jsb.fileUtils.getWritablePath() : '/') + 'remote-assets'); 42 | this._assetManager = new jsb.AssetsManager('', this._storagePath, this.versionCompareHandle); 43 | this._assetManager.setVerifyCallback(this.assetsVerify.bind(this)); 44 | if (cc.sys.os === cc.sys.OS_ANDROID) { 45 | this._assetManager.setMaxConcurrentTask(2); 46 | } 47 | cc.log('远程资源的存储路径 : ' + this._storagePath); 48 | } 49 | 50 | 51 | start() { 52 | this.checkUpdate(); 53 | } 54 | 55 | 56 | /** 57 | * 检查更新回调 58 | */ 59 | private checkCb(event) { 60 | switch (event.getEventCode()) { 61 | case jsb.EventAssetsManager.ERROR_NO_LOCAL_MANIFEST: 62 | console.log("没有发现本地清单文件,跳过热更新."); 63 | this.Event.emit(HotUpdateEventType[HotUpdateEventType.HOT_PASSED], event); 64 | break; 65 | case jsb.EventAssetsManager.ERROR_DOWNLOAD_MANIFEST: 66 | case jsb.EventAssetsManager.ERROR_PARSE_MANIFEST: 67 | console.log("下载清单文件失败,跳过热更新."); 68 | this.Event.emit(HotUpdateEventType[HotUpdateEventType.HOT_ERROE], event); 69 | break; 70 | case jsb.EventAssetsManager.ALREADY_UP_TO_DATE: 71 | console.log("当前已经是最新版本."); 72 | this.Event.emit(HotUpdateEventType[HotUpdateEventType.HOT_PASSED], event); 73 | break; 74 | case jsb.EventAssetsManager.NEW_VERSION_FOUND: 75 | console.log('找到新版本,请尝试更新.'); 76 | this.Event.emit(HotUpdateEventType[HotUpdateEventType.HOT_NEED], event); 77 | break; 78 | default: 79 | return; 80 | } 81 | this._assetManager.setEventCallback(null); 82 | this._updating = false; 83 | } 84 | 85 | 86 | /** 87 | * 更新回调 88 | */ 89 | private updateCb(event) { 90 | var needRestart = false; 91 | var failed = false; 92 | switch (event.getEventCode()) { 93 | case jsb.EventAssetsManager.ERROR_NO_LOCAL_MANIFEST: 94 | failed = true; 95 | break; 96 | case jsb.EventAssetsManager.UPDATE_PROGRESSION: 97 | // console.log('正在更新.'); 98 | this.Event.emit(HotUpdateEventType[HotUpdateEventType.HOT_UPDATING], event); 99 | break; 100 | case jsb.EventAssetsManager.ERROR_DOWNLOAD_MANIFEST: 101 | case jsb.EventAssetsManager.ERROR_PARSE_MANIFEST: 102 | console.log('下载清单文件失败,跳过热更新.'); 103 | this.Event.emit(HotUpdateEventType[HotUpdateEventType.HOT_ERROE], event); 104 | failed = true; 105 | break; 106 | case jsb.EventAssetsManager.ALREADY_UP_TO_DATE: 107 | console.log('当前已经是最新版本.'); 108 | this.Event.emit("PASSED", event); 109 | failed = true; 110 | cc.game.restart(); 111 | break; 112 | case jsb.EventAssetsManager.UPDATE_FINISHED: 113 | console.log('更新完成. ' + event.getMessage()); 114 | this.Event.emit("FINISHED", event); 115 | needRestart = true; 116 | cc.game.restart(); 117 | break; 118 | case jsb.EventAssetsManager.UPDATE_FAILED: 119 | console.log('更新失败. ' + event.getMessage()); 120 | this.Event.emit(HotUpdateEventType[HotUpdateEventType.HOT_ERROE], event); 121 | this.Event.emit("HOT_ERROE", event); 122 | this._updating = false; 123 | this._canRetry = true; 124 | break; 125 | case jsb.EventAssetsManager.ERROR_UPDATING: 126 | console.log('资源更新错误: ' + event.getAssetId() + ', ' + event.getMessage()); 127 | break; 128 | case jsb.EventAssetsManager.ERROR_DECOMPRESS: 129 | console.log('资源更新错误: ' + event.getMessage()); 130 | break; 131 | default: 132 | break; 133 | } 134 | 135 | if (failed) { 136 | this._assetManager.setEventCallback(null); 137 | this._updating = false; 138 | } 139 | 140 | if (needRestart) { 141 | this._assetManager.setEventCallback(null); 142 | var searchPaths = jsb.fileUtils.getSearchPaths(); 143 | var newPaths = this._assetManager.getLocalManifest().getSearchPaths(); 144 | Array.prototype.unshift.apply(searchPaths, newPaths); 145 | cc.sys.localStorage.setItem('HotUpdateSearchPaths', JSON.stringify(searchPaths)); 146 | jsb.fileUtils.setSearchPaths(searchPaths); 147 | cc.audioEngine.stopAll(); 148 | cc.game.restart(); 149 | } 150 | } 151 | 152 | 153 | /** 154 | * 重新下载失败的资源 155 | */ 156 | private retry() { 157 | if (!this._updating && this._canRetry) { 158 | this._canRetry = false; 159 | console.log('重试失败的资源...'); 160 | this._assetManager.downloadFailedAssets(); 161 | } 162 | } 163 | 164 | 165 | /** 166 | * 检查更新 167 | */ 168 | private checkUpdate() { 169 | if (this._updating) { return; } 170 | this.loadLocalManifest(); 171 | if (!this._assetManager.getLocalManifest() || !this._assetManager.getLocalManifest().isLoaded()) { 172 | this.Event.emit("PASSED", { msg: "未能加载本地清单 ..." }); 173 | return; 174 | } 175 | this._assetManager.setEventCallback(this.checkCb.bind(this)); 176 | this._assetManager.checkUpdate(); 177 | this._updating = false; 178 | } 179 | 180 | 181 | /** 182 | * load对应清单文件 183 | */ 184 | private loadLocalManifest(): any { 185 | console.log("load清单文件") 186 | if (this._assetManager.getState() === jsb.AssetsManager.State.UNINITED) { 187 | // Resolve md5 url 188 | var url = this.manifestUrl.nativeUrl; 189 | if (cc.loader.md5Pipe) { 190 | url = cc.loader.md5Pipe.transformURL(url); 191 | } 192 | console.log("清单文件地址:", url); 193 | this._assetManager.loadLocalManifest(url); 194 | } 195 | } 196 | 197 | 198 | /** 199 | * 进行热更新 200 | */ 201 | private hotUpdate() { 202 | console.log("进行热更新"); 203 | console.log(this._assetManager, this._updating); 204 | if (this._assetManager && !this._updating) { 205 | this._assetManager.setEventCallback(this.updateCb.bind(this)); 206 | // load对应清单文件 207 | this.loadLocalManifest(); 208 | // this._failCount = 0; 209 | this._assetManager.update(); 210 | this._updating = true; 211 | } 212 | } 213 | 214 | 215 | /** 216 | * //设置你自己的版本比较处理器,版本和B是字符串版本 217 | * //如果返回值大于0,versionA大于B 218 | * //如果返回值为0,versionA等于B 219 | * //如果返回值小于0,则versionA小于B 220 | * @param versionA 221 | * @param versionB 222 | */ 223 | private versionCompareHandle(versionA, versionB) { 224 | if (versionA == versionB) return 0; 225 | // cc.log("JS Custom Version Compare: version A is " + versionA + ', version B is ' + versionB); 226 | var vA = versionA.split('.'); 227 | var vB = versionB.split('.'); 228 | for (var i = 0; i < vA.length; ++i) { 229 | var a = parseInt(vA[i]); 230 | var b = parseInt(vB[i] || 0); 231 | if (a === b) { continue; } 232 | else { return a - b; } 233 | } 234 | if (vB.length > vA.length) { return -1; } 235 | else { return 0; } 236 | }; 237 | 238 | 239 | /** 240 | * //设置验证回调,但我们还没有md5检查函数,所以只打印一些消息 241 | * //如果验证通过,返回true,否则返回false 242 | */ 243 | private assetsVerify(path, asset) { 244 | var compressed = asset.compressed; 245 | var expectedMD5 = asset.md5; 246 | var relativePath = asset.path; 247 | if (compressed) { 248 | console.log("验证通过了 : " + relativePath); 249 | return true; 250 | } 251 | else { 252 | console.log("验证通过了 : " + relativePath + ' (' + expectedMD5 + ')'); 253 | return true; 254 | } 255 | } 256 | 257 | update(dt?: number) { 258 | } 259 | 260 | onDestroy() { 261 | this._assetManager && this._assetManager.setEventCallback(null); 262 | } 263 | 264 | } 265 | -------------------------------------------------------------------------------- /assets/scripts/base/components/HotUpdate.ts.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.5", 3 | "uuid": "6486d882-e7cf-4964-9b42-cb966978e22d", 4 | "isPlugin": false, 5 | "loadPluginInWeb": true, 6 | "loadPluginInNative": true, 7 | "loadPluginInEditor": false, 8 | "subMetas": {} 9 | } -------------------------------------------------------------------------------- /assets/scripts/base/components/ScreenCapture.ts: -------------------------------------------------------------------------------- 1 | 2 | const { ccclass, property, executeInEditMode, menu } = cc._decorator; 3 | 4 | @ccclass 5 | @menu("扩展组件/ScreenCapture") 6 | export default class ScreenCapture extends cc.Component { 7 | 8 | @property(cc.Camera) 9 | camera: any = null; 10 | 11 | private renderTexture: cc.RenderTexture = null; 12 | private fullPath: string = null; 13 | 14 | 15 | start() { 16 | this.renderTexture = new cc.RenderTexture(); 17 | // gfx.RB_FMT_D24S8 18 | // gfx.RB_FMT_S8 19 | // gfx.RB_FMT_D16 20 | this.renderTexture.initWithSize(cc.winSize.width, cc.winSize.height, (cc).gfx.RB_FMT_S8); 21 | this.renderTexture.setPremultiplyAlpha(true); 22 | 23 | } 24 | 25 | 26 | /** 27 | * 同步截屏 28 | */ 29 | async captureScreenAndSaveData(saveName?: string): Promise { 30 | return await new Promise( 31 | (resolve, reject) => { 32 | if (this.fullPath) { 33 | resolve(this.fullPath); 34 | return; 35 | } 36 | const fileName = saveName || "screenshoot.png"; 37 | this.camera.targetTexture = this.renderTexture; 38 | this.camera["render"](); 39 | // this.renderTexture.setFlipY(false); 40 | let data = this.renderTexture.readPixels(); 41 | let width = this.renderTexture.width; 42 | let height = this.renderTexture.height; 43 | let picData = this.filpYImage(data, width, height); 44 | if (CC_JSB) { 45 | let fullPath = jsb.fileUtils.getWritablePath() + fileName; 46 | if (jsb.fileUtils.isFileExist(fullPath)) { 47 | jsb.fileUtils.removeFile(fullPath); 48 | } 49 | let success = jsb.saveImageData(picData, width, height, fullPath); 50 | if (success) { 51 | resolve(fullPath); 52 | this.fullPath = fullPath; 53 | cc.log("save image data success, file: " + fileName); 54 | } 55 | else { 56 | reject("save image data failed!"); 57 | cc.error("save image data failed!"); 58 | } 59 | return; 60 | } 61 | reject("save image data failed!"); 62 | } 63 | ); 64 | } 65 | 66 | 67 | /** 68 | * 反转图像数据 69 | */ 70 | filpYImage(data, width, height) { 71 | let picData = new Uint8Array(width * height * 4); 72 | let rowBytes = width * 4; 73 | for (let row = 0; row < height; row++) { 74 | let srow = height - 1 - row; 75 | let start = srow * width * 4; 76 | let reStart = row * width * 4; 77 | for (let i = 0; i < rowBytes; i++) { 78 | picData[reStart + i] = data[start + i]; 79 | } 80 | } 81 | return picData; 82 | } 83 | 84 | } 85 | -------------------------------------------------------------------------------- /assets/scripts/base/components/ScreenCapture.ts.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.5", 3 | "uuid": "2640d8d3-61f7-46c1-afeb-0aa169f706d0", 4 | "isPlugin": false, 5 | "loadPluginInWeb": true, 6 | "loadPluginInNative": true, 7 | "loadPluginInEditor": false, 8 | "subMetas": {} 9 | } -------------------------------------------------------------------------------- /assets/scripts/base/core.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.1", 3 | "uuid": "dd221858-af53-4a71-8c69-1e32caf5c956", 4 | "isSubpackage": false, 5 | "subpackageName": "", 6 | "subMetas": {} 7 | } -------------------------------------------------------------------------------- /assets/scripts/base/core/BaseComponent.ts: -------------------------------------------------------------------------------- 1 | import { EventsManager } from "./event/EventManager"; 2 | import { SingletonFactory } from "./SingleFactory"; 3 | 4 | /** 5 | * BaseComponent组件 6 | * 建议用户新建的组件脚本建立继承本组件 7 | */ 8 | export abstract class BaseComponent extends cc.Component { 9 | 10 | private _eventsManager: EventsManager; 11 | 12 | 13 | /** 14 | * 注册事件 15 | * @param eventName 事件名 16 | * @param handler 事件回调 17 | * @param once 是否为单次消耗事件 18 | */ 19 | public bindEvent(type: string, callback?: Function, once: boolean = false) { 20 | let handler = callback ? callback.bind(this) : (this[type] ? this[type].bind(this) : null); 21 | if (once) { 22 | return this.Event.once(type, handler, this); 23 | } 24 | return this.Event.on(type, handler, this); 25 | } 26 | 27 | 28 | /** 29 | * 绑定视图 30 | * @param variableName 变量名 31 | * @param nodePath 节点相对路径 32 | * @param component 绑定组件(component不为空将绑定为component) 33 | * @param referenceNode 相对节点(相对路径起点) 34 | */ 35 | public bindView(variableName: string, nodePath: string, component?: typeof cc.Component, referenceNode?: cc.Node) { 36 | let variable = this.findView(nodePath, referenceNode); 37 | if (variable && component) { 38 | variable = (variable).getComponent(component); 39 | } 40 | this[variableName] = variable; 41 | return variable; 42 | } 43 | 44 | 45 | /** 46 | * 按路径获取节点 47 | * @param sPath 相对路径 48 | * @param referenceNode 相对节点(相对路径起点) 49 | */ 50 | public findView(sPath: string, referenceNode: cc.Node = this.node) { 51 | return cc.find(sPath, referenceNode); 52 | } 53 | 54 | 55 | /** 56 | * EventsManager 57 | */ 58 | get Event() { 59 | if (!this._eventsManager) { 60 | this._eventsManager = SingletonFactory.getInstance(EventsManager); 61 | let onDestroy = this.onDestroy; 62 | this.onDestroy = () => { 63 | this.Event.offTarget(this); 64 | onDestroy && onDestroy(); 65 | }; 66 | } 67 | return this._eventsManager; 68 | } 69 | 70 | } -------------------------------------------------------------------------------- /assets/scripts/base/core/BaseComponent.ts.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.5", 3 | "uuid": "e45923b9-c8c6-4879-9ca8-993b0a1b9f68", 4 | "isPlugin": false, 5 | "loadPluginInWeb": true, 6 | "loadPluginInNative": true, 7 | "loadPluginInEditor": false, 8 | "subMetas": {} 9 | } -------------------------------------------------------------------------------- /assets/scripts/base/core/SingleFactory.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * 单例工厂 3 | */ 4 | export class SingletonFactory { 5 | 6 | private static instanceList: Map<{ new() }, Object> = new Map<{ new() }, Object>(); 7 | 8 | public static getInstance(c: { new(): T }): T { 9 | if (!SingletonFactory.instanceList.has(c)) { 10 | let obj = new c(); 11 | SingletonFactory.instanceList.set(c, obj); 12 | return obj; 13 | } 14 | return SingletonFactory.instanceList.get(c); 15 | } 16 | } -------------------------------------------------------------------------------- /assets/scripts/base/core/SingleFactory.ts.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.5", 3 | "uuid": "bbaada9e-4cb1-40f5-9ca0-725ebb86e113", 4 | "isPlugin": false, 5 | "loadPluginInWeb": true, 6 | "loadPluginInNative": true, 7 | "loadPluginInEditor": false, 8 | "subMetas": {} 9 | } -------------------------------------------------------------------------------- /assets/scripts/base/core/audio.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.1", 3 | "uuid": "60a24296-eb1c-4d6d-9a27-a72986ea07c9", 4 | "isSubpackage": false, 5 | "subpackageName": "", 6 | "subMetas": {} 7 | } -------------------------------------------------------------------------------- /assets/scripts/base/core/audio/AudioMananger.ts: -------------------------------------------------------------------------------- 1 | export class AudioManager { 2 | 3 | private _musicVolume: number = 1.0; 4 | 5 | private _effectVolume: number = 1.0; 6 | 7 | // private static _instance: AudioManager; 8 | 9 | constructor() { 10 | this.init(); 11 | } 12 | 13 | 14 | // /** 15 | // * 获取音频管理器 16 | // */ 17 | // static getInstance(): AudioManager { 18 | // if (!AudioManager._instance) { 19 | // AudioManager._instance = new AudioManager(); 20 | // } 21 | // return this._instance; 22 | // } 23 | 24 | 25 | /** 26 | * 初始化参数 27 | */ 28 | private init() { 29 | // 初始化音量值 30 | let musicVolume = cc.sys.localStorage.getItem("musicVolume"); 31 | let effectVolume = cc.sys.localStorage.getItem("effectVolume"); 32 | this.musicVolume = (musicVolume == null ? this.musicVolume : parseFloat(musicVolume)); 33 | this.effectVolume = (effectVolume == null ? this.effectVolume : parseFloat(effectVolume)); 34 | // 游戏进入后台时触发 35 | cc.game.on(cc.game.EVENT_HIDE, function () { 36 | this.pauseAll(); 37 | }.bind(this)); 38 | // 游戏进入前台时触发 39 | cc.game.on(cc.game.EVENT_SHOW, function () { 40 | this.resumeAll(); 41 | }.bind(this)); 42 | } 43 | 44 | 45 | /** 46 | * 获取音频地址URL 47 | * @param url 音频相对地址 48 | */ 49 | private getAudioUrl(url) { 50 | return cc.url.raw("resources/sounds/" + url); 51 | } 52 | 53 | 54 | /** 55 | * 播放音效 56 | * @param url 音频地址 57 | */ 58 | public playEffect(url) { 59 | let id; 60 | (cc.AudioClip)._loadByUrl(this.getAudioUrl(url), function (err, clip) { 61 | if (clip) { 62 | id = cc.audioEngine.playEffect(clip, false); 63 | } 64 | }); 65 | return id; 66 | } 67 | 68 | 69 | /** 70 | * 播放音乐 71 | * @param url 音频地址 72 | */ 73 | public playMusic(url) { 74 | let id; 75 | (cc.AudioClip)._loadByUrl(this.getAudioUrl(url), function (err, clip) { 76 | if (clip) { 77 | id = cc.audioEngine.playMusic(clip, true); 78 | } 79 | }); 80 | return id; 81 | } 82 | 83 | 84 | /** 85 | * 暂停播放的音频 86 | */ 87 | public pauseAll() { 88 | // console.log("cc.audioEngine.pauseAll"); 89 | cc.audioEngine.pauseAll(); 90 | } 91 | 92 | 93 | /** 94 | * 恢复播放暂停的音频 95 | */ 96 | public resumeAll() { 97 | // console.log("cc.audioEngine.resumeAll"); 98 | cc.audioEngine.resumeAll(); 99 | } 100 | 101 | 102 | /** 103 | * 定义_musicVolume的存取器 104 | */ 105 | get musicVolume() { 106 | return this._musicVolume; 107 | } 108 | 109 | set musicVolume(volume) { 110 | this._musicVolume = ((volume >= 0 || volume <= 1) ? volume : this._musicVolume); 111 | cc.audioEngine.setMusicVolume(this._musicVolume); 112 | cc.sys.localStorage.setItem("musicVolume", volume); 113 | } 114 | 115 | 116 | /** 117 | * 定义_effectVolume的存取器 118 | */ 119 | get effectVolume() { 120 | return this._effectVolume; 121 | } 122 | 123 | set effectVolume(volume) { 124 | this._effectVolume = ((volume >= 0 || volume <= 1) ? volume : this.effectVolume); 125 | cc.audioEngine.setEffectsVolume(this.effectVolume); 126 | cc.sys.localStorage.setItem("effectVolume", volume); 127 | } 128 | 129 | } 130 | -------------------------------------------------------------------------------- /assets/scripts/base/core/audio/AudioMananger.ts.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.5", 3 | "uuid": "d4f46114-ee55-464a-aff0-d9f6a94af997", 4 | "isPlugin": false, 5 | "loadPluginInWeb": true, 6 | "loadPluginInNative": true, 7 | "loadPluginInEditor": false, 8 | "subMetas": {} 9 | } -------------------------------------------------------------------------------- /assets/scripts/base/core/data.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.1", 3 | "uuid": "47811f2f-dba5-43ed-a0c5-52e81aaf3033", 4 | "isSubpackage": false, 5 | "subpackageName": "", 6 | "subMetas": {} 7 | } -------------------------------------------------------------------------------- /assets/scripts/base/core/data/DataManager.ts: -------------------------------------------------------------------------------- 1 | export class DataManager { 2 | 3 | // private _configList: Map>; 4 | private _configList: { [key: string]: { [key: string]: object } } = {}; 5 | 6 | constructor() { this.reset(); } 7 | 8 | 9 | /** 10 | * 清空配置表 11 | */ 12 | public reset() { 13 | this._configList = {}; 14 | } 15 | 16 | 17 | /** 18 | * 加载配置Json 19 | * @param configPath 配置存放路径 20 | * @param configName 配置文件名称 21 | * @param convertKey 是否使用ID作为key 22 | * @param handler 加载配置完成后回调 23 | */ 24 | public loadJsonData(configPath: string, configName: string, convertKey: boolean = false, handler: Function = null): void { 25 | cc.loader.loadRes(configPath, (error, contents) => { 26 | if (error) return; 27 | let config = {}; 28 | let types = >contents.json["types"]; 29 | let fields = >contents.json["fields"]; 30 | let valuesList = >contents.json["values"]; 31 | for (let idx in valuesList) { 32 | let values = valuesList[idx]; 33 | let object = {}; 34 | for (let i = 0; i < types.length; ++i) { 35 | let field = fields[i]; 36 | let type = types[i]; 37 | switch (type) { 38 | case "I": 39 | object[field] = Number(values[i]); 40 | break; 41 | case "B": 42 | object[field] = Number(values[i]) == 1; 43 | break; 44 | case "S": 45 | object[field] = values[i] + ""; 46 | break; 47 | } 48 | } 49 | if (convertKey == true) { 50 | let key = object["ID"]; 51 | config[`${key}`] = object; 52 | } else { 53 | config[`${idx}`] = object; 54 | } 55 | } 56 | this._configList[`${configName}`] = config; 57 | handler && handler(config); 58 | }); 59 | } 60 | 61 | 62 | /** 63 | * 获取配置 64 | * @param configName 配置名 65 | */ 66 | public getDataByName(configName: string): Object { 67 | return this._configList[`${configName}`]; 68 | } 69 | 70 | 71 | /** 72 | * 获取配置对应参数 73 | * @param configName 配置名 74 | * @param id 参数ID 75 | */ 76 | public getDataByNameAndId(configName: string, id: string) { 77 | let config = this._configList[`${configName}`]; 78 | if (config) { 79 | return config[`${id}`]; 80 | } 81 | } 82 | 83 | 84 | /** 85 | * 移除配置 86 | * @param configName 配置名 87 | */ 88 | public clearDataByName(configName: string): void { 89 | delete this._configList[`${configName}`]; 90 | } 91 | 92 | } -------------------------------------------------------------------------------- /assets/scripts/base/core/data/DataManager.ts.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.5", 3 | "uuid": "101b0453-06d5-412c-a523-9074b3b5853d", 4 | "isPlugin": false, 5 | "loadPluginInWeb": true, 6 | "loadPluginInNative": true, 7 | "loadPluginInEditor": false, 8 | "subMetas": {} 9 | } -------------------------------------------------------------------------------- /assets/scripts/base/core/data/LocalData.ts: -------------------------------------------------------------------------------- 1 | 2 | class DataDef { 3 | public _sName: string = ""; 4 | public _sType: string = ""; 5 | public _default: any = null; 6 | public _bResetDaliy: boolean = false; 7 | public _nMin: number = -0xFFFFFF; 8 | public _nMax: number = 0xFFFFFF; 9 | constructor(sName: string, sType: string, def: any, bResetDaliy = false, nMin: number = -0xFFFFFF, nMax: number = 0xFFFFFF) { 10 | this._sName = sName; 11 | this._sType = sType; 12 | this._default = def; 13 | this._bResetDaliy = bResetDaliy; 14 | this._nMin = nMin; 15 | this._nMax = nMax; 16 | } 17 | } 18 | 19 | 20 | export class LocalData { 21 | private _sGameData: string; 22 | private _tDataDef: { [sSub: string]: DataDef } = {}; 23 | private _tGameData: { [sPropName: string]: string | number } = {}; 24 | private _pOnLoadedCallback: () => void = null; 25 | 26 | // private static _Instance: LocalData = null; 27 | 28 | // constructor() { 29 | // } 30 | 31 | // public static GetInstance(): LocalData { 32 | // if (this._Instance == null) { 33 | // this._Instance = new LocalData() 34 | // } 35 | // return this._Instance; 36 | // } 37 | 38 | public AddDataDef(def: DataDef) { 39 | if (def != null && def._sName != null) { 40 | this._tDataDef[def._sName] = def; 41 | } 42 | } 43 | 44 | public AddDataDefEx(arr: Array) { 45 | this.AddDataDef(new DataDef(arr[0], arr[1], arr[2], arr[3], arr[4], arr[5])); 46 | } 47 | 48 | public SetDataDef(tData: Array) { 49 | for (let def of tData) { 50 | this._tDataDef[def._sName] = def; 51 | } 52 | } 53 | 54 | public SetDataDefEx(arr: Array>) { 55 | for (let i = 0; i < arr.length; ++i) { 56 | this.AddDataDefEx(arr[i]) 57 | } 58 | } 59 | 60 | public SetVal(sName: string, val: any) { 61 | let tProp = this._tDataDef[sName]; 62 | if (tProp != null) { 63 | this._tGameData[sName] = val; 64 | } 65 | } 66 | 67 | public GetVal(sName: string) { 68 | let tProp = this._tDataDef[sName]; 69 | if (tProp != null) { 70 | return this._tGameData[sName]; 71 | } 72 | }; 73 | 74 | public MofidyVal(sName: string, nNum: number) { 75 | let tDataConf = this._tDataDef[sName]; 76 | if (tDataConf != null && tDataConf._sType == "number") { 77 | let nNewVal = this._tGameData[sName] + nNum; 78 | nNewVal = (nNewVal > tDataConf._nMax) ? tDataConf._nMax : nNewVal; 79 | nNewVal = (nNewVal < tDataConf._nMin) ? tDataConf._nMin : nNewVal; 80 | this._tGameData[sName] = nNewVal; 81 | } 82 | } 83 | 84 | public LoadAllData() { 85 | // let sGameData = App.Utils.StorageManager.getObject("GameData"); 86 | let sGameData = localStorage.getItem("GameData"); 87 | this.DecodeGameData(sGameData); 88 | this.ResetDaliy(); 89 | }; 90 | 91 | public ResetDaliy() { 92 | let oNowTime = new Date(); 93 | let oTodayBeginDate = new Date(); 94 | oTodayBeginDate.setDate(oNowTime.getDate()); 95 | oTodayBeginDate.setHours(0, 0, 0, 0); 96 | let nTodayBeginTimeVal = oTodayBeginDate.getTime(); 97 | let nLastResetTime = this.GetVal("LastResetTime"); 98 | if ((nTodayBeginTimeVal - nLastResetTime) >= 86400000) { 99 | let tGameData = this._tGameData; 100 | if (tGameData != null) { 101 | for (let sAttri in this._tDataDef) { 102 | let tProConf = this._tDataDef[sAttri]; 103 | if (tProConf != null) { 104 | if (tGameData[sAttri] != null && tProConf._bResetDaliy) { 105 | this.SetVal(tProConf._sName, tProConf._default); 106 | } 107 | } 108 | } 109 | } 110 | this.SetVal("LastResetTime", nTodayBeginTimeVal) 111 | } 112 | } 113 | 114 | private DecodeGameData(sGameData: string) { 115 | if (sGameData == null || sGameData == "") { 116 | sGameData = "{}"; 117 | } 118 | let tProps = JSON.parse(sGameData); 119 | if (tProps == null) { 120 | tProps = {}; 121 | } 122 | for (let sAttri in this._tDataDef) { 123 | let tProConf = this._tDataDef[sAttri]; 124 | if (tProConf != null) { 125 | if (tProps[sAttri] != null) { 126 | this.SetVal(tProConf._sName, tProps[sAttri]); 127 | } else { 128 | this.SetVal(tProConf._sName, tProConf._default); 129 | } 130 | } 131 | } 132 | if (this._pOnLoadedCallback != null) { 133 | this._pOnLoadedCallback(); 134 | } 135 | } 136 | 137 | public SaveAllData() { 138 | let sGameDataStr = JSON.stringify(this._tGameData); 139 | if (sGameDataStr != null && this._sGameData != sGameDataStr) { 140 | this._sGameData = sGameDataStr; 141 | // App.Utils.StorageManager.setObject("GameData", this._tGameData); 142 | cc.sys.localStorage.setItem("GameData", sGameDataStr); 143 | } 144 | }; 145 | 146 | public ClearAllData() { 147 | this._tGameData = {}; 148 | this.SaveAllData(); 149 | } 150 | 151 | public OnAllDataLoaded(pCallback: () => void) { this._pOnLoadedCallback = pCallback }; 152 | } -------------------------------------------------------------------------------- /assets/scripts/base/core/data/LocalData.ts.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.5", 3 | "uuid": "dfe59786-1935-442d-85b0-3bd336825f0a", 4 | "isPlugin": false, 5 | "loadPluginInWeb": true, 6 | "loadPluginInNative": true, 7 | "loadPluginInEditor": false, 8 | "subMetas": {} 9 | } -------------------------------------------------------------------------------- /assets/scripts/base/core/event.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.1", 3 | "uuid": "74adffb9-ca05-4135-a196-f5aab7417688", 4 | "isSubpackage": false, 5 | "subpackageName": "", 6 | "subMetas": {} 7 | } -------------------------------------------------------------------------------- /assets/scripts/base/core/event/EventManager.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * 事件管理器 3 | */ 4 | export class EventsManager { 5 | 6 | // private static _instance: EventsManager; 7 | 8 | private _eventMap: EventMap = {}; 9 | 10 | constructor() { } 11 | 12 | 13 | // /** 14 | // * 获取事件管理器 15 | // */ 16 | // static getInstance(): EventsManager { 17 | // if (!EventsManager._instance) { 18 | // EventsManager._instance = new EventsManager() 19 | // } 20 | // return this._instance 21 | // } 22 | 23 | 24 | /** 25 | * 触发事件 26 | * @param eventName 需要响应的事件名 27 | * @param data 事件需要传递的数据 28 | * @param target 只触发target上的事件 29 | */ 30 | emit(eventName: string, data?: any | void, target: Object = null) { 31 | let events = this._eventMap[eventName]; 32 | if (!events) return; 33 | let removeEventList = []; 34 | for (const event of events) { 35 | if (event != null && event.eventName == eventName) { 36 | if (!target) { // 触发所有 37 | event.data = data; 38 | event.handler && event.handler(data, event); 39 | event.once && removeEventList.push(event); 40 | } 41 | if (target && target == event.target) { // 触发指定target 42 | event.data = data; 43 | event.handler && event.handler(data, event); 44 | event.once && removeEventList.push(event); 45 | } 46 | } 47 | } 48 | // 移除once 49 | for (const event of removeEventList) { 50 | let index = removeEventList.indexOf(event); 51 | events.splice(index, 1); 52 | } 53 | } 54 | 55 | 56 | /** 57 | * 注册事件 58 | * @param eventName 事件名 59 | * @param handler 事件回调 60 | * @param target 目标对象 61 | */ 62 | on(eventName: string, handler: Function, target: Object = null) { 63 | return this.register(eventName, handler, false, target); 64 | } 65 | 66 | 67 | /** 68 | * 注册单次事件,回调后移除 69 | * @param eventName 事件名 70 | * @param handler 事件回调 71 | * @param target 目标对象 72 | */ 73 | once(eventName: string, handler: Function, target: Object = null) { 74 | return this.register(eventName, handler, true, target); 75 | } 76 | 77 | 78 | /** 79 | * 移除事件 80 | * @param eventName 事件名或者事件对象。1> 当传入事件对象时只移除对应事件 2> 当传入事件名时移除所有同名的事件 81 | * @param target 当有target参数传入时,只移除对应target上的事件 82 | */ 83 | off(eventName: string | EventObject, target: Object = null) { 84 | this.unregister(eventName, target); 85 | } 86 | 87 | 88 | /** 89 | * 移除对应target上的所有事件 90 | * @param target 91 | */ 92 | offTarget(target: Object) { 93 | this.unregister(null, target); 94 | } 95 | 96 | 97 | // /** 98 | // * 注册事件 99 | // * @param eventName 事件名 100 | // * @param handler 事件回调 101 | // * @param once 是否为单次事件 102 | // * @param target 目标对象 103 | // */ 104 | private register(eventName: string, handler: Function, once: boolean = false, target: Object = null): EventObject { 105 | let event = { eventName: eventName, handler: handler, once: once, target: target }; 106 | if (!this._eventMap[event.eventName]) { 107 | this._eventMap[event.eventName] = []; 108 | } 109 | this._eventMap[event.eventName].push(event); 110 | return event; 111 | } 112 | 113 | 114 | // /** 115 | // * 移除事件 116 | // * @param eventName 事件名或者事件对象。1> 当传入事件对象时只移除对应事件 2> 当传入事件名时移除所有同名的事件 117 | // * @param target 当有target参数传入时,只移除对应target上的事件 118 | // */ 119 | private unregister(eventName: string | EventObject, target: Object = null) { 120 | let events = []; 121 | // 没有传入[事件名/事件对象] 122 | if (eventName == null) { 123 | target && this._unregisterByTarget(target);// 只传入[target],移除target上的所有事件 124 | return; 125 | } 126 | 127 | // 传入[事件名/事件对象] 128 | if (typeof eventName === 'string') { 129 | events = this._eventMap[eventName]; 130 | } else { 131 | events = [eventName]; 132 | } 133 | 134 | // 从事件列表里移除 135 | for (const event of events) { 136 | target && event.target == target && events.splice(events.indexOf(event), 1); // 移除在target上的事件 137 | (!target) && events.splice(events.indexOf(event), 1); // 移除 138 | } 139 | } 140 | 141 | 142 | // private _hasEvent(eventName: string, target: Object) { 143 | // } 144 | 145 | 146 | private _unregisterByTarget(target: Object) { 147 | for (const key in this._eventMap) { 148 | if (this._eventMap.hasOwnProperty(key)) { 149 | const events = this._eventMap[key]; 150 | for (const event of events) { 151 | event.target == target && events.splice(events.indexOf(event), 1); 152 | } 153 | } 154 | } 155 | } 156 | 157 | } 158 | 159 | export interface EventMap { [key: string]: Array }; 160 | export interface EventObject { eventName: string, handler: Function, once: boolean, target: Object, data?: Object }; -------------------------------------------------------------------------------- /assets/scripts/base/core/event/EventManager.ts.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.5", 3 | "uuid": "67fca383-d917-4e34-bf2c-cd45778f03c5", 4 | "isPlugin": false, 5 | "loadPluginInWeb": true, 6 | "loadPluginInNative": true, 7 | "loadPluginInEditor": false, 8 | "subMetas": {} 9 | } -------------------------------------------------------------------------------- /assets/scripts/base/core/mvc.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.1", 3 | "uuid": "837ae335-132d-4124-b9a4-bb9ad31542ce", 4 | "isSubpackage": false, 5 | "subpackageName": "", 6 | "subMetas": {} 7 | } -------------------------------------------------------------------------------- /assets/scripts/base/core/mvc/Lifecycle.ts: -------------------------------------------------------------------------------- 1 | import { ViewBase } from "./ViewBase"; 2 | import { UIManager } from "./UIManager"; 3 | import { SingletonFactory } from "../SingleFactory"; 4 | 5 | 6 | export class Lifecycle extends cc.Component { 7 | 8 | private viewBase: typeof ViewBase; 9 | 10 | init(viewBase: typeof ViewBase) { 11 | this.viewBase = viewBase; 12 | } 13 | 14 | onDestroy() { 15 | SingletonFactory.getInstance(UIManager).destoryUI(this.viewBase.UIName); 16 | this.viewBase = null; 17 | } 18 | 19 | } 20 | -------------------------------------------------------------------------------- /assets/scripts/base/core/mvc/Lifecycle.ts.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.5", 3 | "uuid": "e59ae161-9896-46e8-aa7b-82b302e12850", 4 | "isPlugin": false, 5 | "loadPluginInWeb": true, 6 | "loadPluginInNative": true, 7 | "loadPluginInEditor": false, 8 | "subMetas": {} 9 | } -------------------------------------------------------------------------------- /assets/scripts/base/core/mvc/UIManager.ts: -------------------------------------------------------------------------------- 1 | import { ViewBase } from "./ViewBase"; 2 | import { Lifecycle } from "./Lifecycle"; 3 | 4 | export class UIManager { 5 | 6 | // private static _instance: UIManager; 7 | 8 | private _seq: number = 0; 9 | private _seqS: number = 0; 10 | private _scene: cc.Node; 11 | private _UIMap: { [key: string]: UIMessageI }; 12 | 13 | private static prefabMap: { [key: string]: cc.Prefab } = {}; 14 | 15 | public isExist(stageClass) { 16 | return !!UIManager.prefabMap[stageClass.ResourcePath]; 17 | } 18 | 19 | constructor() { 20 | this.init(); 21 | } 22 | 23 | 24 | private init() { 25 | this._UIMap = {}; 26 | } 27 | 28 | 29 | // public static getInstance() { 30 | // if (!this._instance) { 31 | // this._instance = new UIManager(); 32 | // } 33 | // return this._instance; 34 | // } 35 | 36 | 37 | public showUI(viewBase: typeof ViewBase, parentNode?: cc.Node, callback?: Function) { 38 | const UIName = viewBase.UIName; 39 | this.UIMap[UIName] = !this.UIMap[UIName] ? { name: UIName, component: null, status: LoadEnum.NORMAL, canceled: false } : this.UIMap[UIName]; 40 | const UIMessage = this.UIMap[UIName]; 41 | switch (UIMessage.status) { 42 | case LoadEnum.LOADING: 43 | UIMessage.canceled && this.log(UIName, "loading restore...", "color:#bada55;"); 44 | UIMessage.canceled = false; 45 | break; 46 | case LoadEnum.LOADED: 47 | this.log(UIName, "already loaded", "color:#19A316;"); 48 | UIMessage.component.node.active = true; 49 | callback && callback(UIMessage.component); 50 | break; 51 | case LoadEnum.NORMAL: 52 | this.log(UIName, "loading start...", "color:rgb(4,192,0);"); 53 | UIMessage.status = LoadEnum.LOADING; 54 | // 存在缓存时直接使用缓存里的prefab 55 | if (UIManager.prefabMap[viewBase.ResourcePath]) { 56 | if (UIMessage.canceled) { 57 | UIMessage.status = LoadEnum.NORMAL; 58 | } else { 59 | this.initUI(viewBase, UIManager.prefabMap[viewBase.ResourcePath], parentNode) && callback && callback(UIMessage.component); 60 | } 61 | } else { // 否则手动进行加载 62 | cc.loader.loadRes(viewBase.ResourcePath, (err, res) => { 63 | if (UIMessage.canceled) { 64 | UIMessage.status = LoadEnum.NORMAL; 65 | } else { 66 | UIManager.prefabMap[viewBase.ResourcePath] = res; 67 | this.initUI(viewBase, res, parentNode) && callback && callback(UIMessage.component); 68 | } 69 | }); 70 | } 71 | break; 72 | } 73 | } 74 | 75 | 76 | private initUI(viewBase: typeof ViewBase, prefab: cc.Prefab, parentNode: cc.Node = cc.director.getScene()) { 77 | const UIMessage = this.UIMap[viewBase.UIName]; 78 | const UINode = cc.instantiate(prefab); 79 | if (UINode && parentNode && parentNode.isValid) { 80 | this.log(viewBase.UIName, "loaded", "color:rgb(4,192,0);"); 81 | UINode.setParent(parentNode); 82 | UIMessage.status = LoadEnum.LOADED; 83 | let component = UINode.getComponent(viewBase); 84 | if (!component) { 85 | component = UINode.addComponent(viewBase); 86 | } 87 | UINode.zIndex = viewBase.zIndex; 88 | (!UINode.getComponent(Lifecycle)) && UINode.addComponent(Lifecycle).init(viewBase); 89 | UIMessage.component = component; 90 | return true; 91 | } 92 | CC_DEBUG && console.log("Error:创建UI时出错", UIMessage.name); 93 | UIMessage.status = LoadEnum.NORMAL; 94 | return false; 95 | } 96 | 97 | 98 | public destoryUI(UIName: string) { 99 | if (this.UIMap.hasOwnProperty(UIName)) { 100 | const UIMessage = this.UIMap[UIName]; 101 | switch (UIMessage.status) { 102 | case LoadEnum.LOADING: 103 | this.log(UIName, "loading cancel...", "color:#FFC107"); 104 | UIMessage.canceled = true; 105 | return true; 106 | case LoadEnum.LOADED: 107 | this.log(UIName, "ui destoryed", "color:#F36"); 108 | if (UIMessage.component.isValid) { 109 | let lifecycle = UIMessage.component.node.getComponent(Lifecycle); 110 | lifecycle.onDestroy = function () { this.viewBase = null; } 111 | UIMessage.component.node.destroy(); 112 | }; 113 | delete this.UIMap[UIName]; 114 | cc.sys.garbageCollect(); 115 | return true; 116 | default: 117 | return true; 118 | } 119 | } 120 | return false; 121 | } 122 | 123 | 124 | public getUI(UIName): UIMessageI { 125 | if (this.UIMap.hasOwnProperty(UIName)) { 126 | const UIMessage = this.UIMap[UIName]; 127 | if (UIMessage.status == LoadEnum.LOADED) { 128 | return UIMessage; 129 | } 130 | } 131 | } 132 | 133 | 134 | public closeUI(UIName: string) { 135 | if (this.UIMap.hasOwnProperty(UIName)) { 136 | const UIMessage = this.UIMap[UIName]; 137 | if (UIMessage.status == LoadEnum.LOADED) { 138 | UIMessage.component.node.active = false; 139 | return true; 140 | } 141 | } 142 | return false; 143 | } 144 | 145 | 146 | public destoryAllUI() { 147 | for (const UIName in this.UIMap) { 148 | this.destoryUI(UIName); 149 | } 150 | } 151 | 152 | 153 | private log(UIName: string, status: string, color: string = `color: #000;`) { 154 | if (CC_DEBUG) { 155 | const seq = ++this._seq; 156 | const scene = cc.director.getScene(); 157 | this._scene = scene ? scene : this._scene; 158 | (!CC_JSB) && console.log(`[${seq}] %c[Scene${this._seqS}:${this._scene.name}][UI:${UIName}]%c -> %c${status}.`, `padding:1px 3px;border-radius:2px;border:1px solid #000a;`, ``, `padding:1px 3px;border-radius:2px;border:1px solid #000a;` + color); 159 | (CC_JSB) && console.log(`[${seq}][Scene${this._seqS}:${this._scene.name}][UI:${UIName}] -> ${status}.`); 160 | (!scene) && this._seqS++; 161 | } 162 | } 163 | 164 | 165 | get UIMap() { 166 | return this._UIMap; 167 | } 168 | 169 | } 170 | 171 | export enum LoadEnum { 172 | NORMAL, 173 | LOADING, 174 | LOADED 175 | } 176 | 177 | export interface UIMessageI { 178 | canceled: boolean, name: string, status: LoadEnum, component: ViewBase, scene?: cc.Scene 179 | } 180 | -------------------------------------------------------------------------------- /assets/scripts/base/core/mvc/UIManager.ts.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.5", 3 | "uuid": "f168abba-049f-4b40-b2e4-e648d3959618", 4 | "isPlugin": false, 5 | "loadPluginInWeb": true, 6 | "loadPluginInNative": true, 7 | "loadPluginInEditor": false, 8 | "subMetas": {} 9 | } -------------------------------------------------------------------------------- /assets/scripts/base/core/mvc/ViewBase.ts: -------------------------------------------------------------------------------- 1 | import { BaseComponent } from "../BaseComponent"; 2 | 3 | export class ViewBase extends BaseComponent { 4 | 5 | static zIndex = 1; 6 | 7 | static UIName = "UIComponent"; 8 | 9 | static ResourcePath = "prefab/TestUI"; 10 | 11 | 12 | protected onClickedBtnExit() { 13 | // App.Utils.UIManager.destoryUI(ViewBase.UIName); 14 | } 15 | 16 | } -------------------------------------------------------------------------------- /assets/scripts/base/core/mvc/ViewBase.ts.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.5", 3 | "uuid": "fe85a27b-2b6f-4a2b-8a65-0992784735e3", 4 | "isPlugin": false, 5 | "loadPluginInWeb": true, 6 | "loadPluginInNative": true, 7 | "loadPluginInEditor": false, 8 | "subMetas": {} 9 | } -------------------------------------------------------------------------------- /assets/scripts/base/core/storage.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.1", 3 | "uuid": "142a14fc-4990-49e8-a54f-159b5dbceb58", 4 | "isSubpackage": false, 5 | "subpackageName": "", 6 | "subMetas": {} 7 | } -------------------------------------------------------------------------------- /assets/scripts/base/core/storage/StorageManager.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * 本地存储管理 3 | */ 4 | export class LocalStorageManager { 5 | 6 | // private static _instance: LocalStorageManager; 7 | 8 | constructor() { }; 9 | 10 | // public static getInstance() { 11 | // if (!this._instance) { 12 | // this._instance = new LocalStorageManager(); 13 | // } 14 | // return this._instance; 15 | // } 16 | 17 | 18 | /** 19 | * 存储布尔值 20 | */ 21 | public setBool(key: string, value: boolean) { 22 | localStorage.setItem(key, value.toString()); 23 | } 24 | 25 | 26 | /** 27 | * 获取布尔值 28 | */ 29 | public getBool(key: string): boolean { 30 | return localStorage.getItem(key) == "false" ? false : true; 31 | } 32 | 33 | 34 | /** 35 | * 存储Number 36 | */ 37 | public setNumber(key: string, value: number) { 38 | localStorage.setItem(key, value.toString()); 39 | } 40 | 41 | 42 | /** 43 | * 获取Number 44 | */ 45 | public getNumber(key: string): number { 46 | return Number(localStorage.getItem(key)); 47 | } 48 | 49 | 50 | /** 51 | * 存储字符串 52 | */ 53 | public setString(key: string, value: string) { 54 | localStorage.setItem(key, value); 55 | } 56 | 57 | 58 | /** 59 | * 获取字符串 60 | */ 61 | public getString(key: string): string { 62 | return localStorage.getItem(key); 63 | } 64 | 65 | 66 | /** 67 | * 存储Object 68 | */ 69 | public setObject(key: string, value: Object) { 70 | let jsonStr = null; 71 | try { 72 | jsonStr = JSON.stringify(value); 73 | } catch (error) { 74 | console.error(error); 75 | return; 76 | } 77 | localStorage.setItem(key, jsonStr); 78 | } 79 | 80 | 81 | /** 82 | * 获取Object 83 | */ 84 | public getObject(key: string): Object { 85 | let object = null; 86 | try { 87 | object = JSON.parse(localStorage.getItem(key)); 88 | } catch (error) { 89 | console.error(error); 90 | } 91 | return object; 92 | } 93 | 94 | 95 | public clear() { 96 | localStorage.clear(); 97 | } 98 | } 99 | -------------------------------------------------------------------------------- /assets/scripts/base/core/storage/StorageManager.ts.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.5", 3 | "uuid": "aedb6f5f-fcb0-45e2-8abf-442a5464cd6f", 4 | "isPlugin": false, 5 | "loadPluginInWeb": true, 6 | "loadPluginInNative": true, 7 | "loadPluginInEditor": false, 8 | "subMetas": {} 9 | } -------------------------------------------------------------------------------- /assets/scripts/base/core/timer.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.1", 3 | "uuid": "748056b4-07ad-48eb-83db-b00521090017", 4 | "isSubpackage": false, 5 | "subpackageName": "", 6 | "subMetas": {} 7 | } -------------------------------------------------------------------------------- /assets/scripts/base/core/timer/TimerManager.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Timer工具 3 | */ 4 | export class TimerManager { 5 | 6 | // private static _instance: TimerManager; 7 | 8 | private static __id: number = new Date().getTime(); 9 | 10 | constructor() { 11 | this.init(); 12 | } 13 | 14 | 15 | // /** 16 | // * 获取Timer管理器 17 | // */ 18 | // public static getInstance(): TimerManager { 19 | // if (!TimerManager._instance) { 20 | // TimerManager._instance = new TimerManager() 21 | // } 22 | // return this._instance; 23 | // } 24 | 25 | 26 | /** 27 | * 初始化 28 | */ 29 | private init() { 30 | // cc.director.getScheduler().enableForTarget(this); 31 | this["_id"] = `Scheduler${TimerManager.__id++}`; 32 | } 33 | 34 | 35 | /** 36 | * 得到一个全新的TimerManager 37 | * 不怎么建议这样使用 38 | */ 39 | public new() { 40 | return new TimerManager(); 41 | } 42 | 43 | 44 | /** 45 | * Timer 46 | * @param handler 回调 47 | * @param interval 间隔时间 48 | * @param repeat 重复次数(实际运行repeat + 1次) 49 | * @param delay 延迟多少时间后开始执行 50 | */ 51 | public runTimer(handler: Function, interval: number, repeat: number, delay: number, pause: boolean) { 52 | return this.schedule(handler, interval, repeat, delay, pause); 53 | } 54 | 55 | 56 | /** 57 | * Timer延迟执行 58 | * @param handler 回调 59 | * @param delayTime 延迟时间 60 | */ 61 | public runDelayTimer(handler: Function, delayTime: number = 0.01) { 62 | return this.scheduleOnce(handler, delayTime); 63 | } 64 | 65 | 66 | /** 67 | * Timer循环执行 68 | * @param handler 回调 69 | * @param intervlTime 间隔时间 70 | * @param delay 延迟时间执行 71 | */ 72 | public runLoopTimer(handler: Function, intervlTime: number = 0.02, delay?: number) { 73 | return this.schedule(handler, intervlTime ? intervlTime : 0.02, cc.macro.REPEAT_FOREVER, delay ? delay : 0, false); 74 | } 75 | 76 | 77 | /** 78 | * 移除计时器Timer 79 | * @param handler 回调 80 | */ 81 | public removeTimer(handler: Function) { 82 | this.unschedule(handler); 83 | } 84 | 85 | 86 | /** 87 | * 移除所有Timer 88 | */ 89 | public removeAllTimers() { 90 | cc.director.getScheduler().unscheduleAllForTarget(this) 91 | // this._timers = []; 92 | } 93 | 94 | 95 | /** 96 | * 暂停所有计时器 97 | */ 98 | public pause() { 99 | cc.director.getScheduler().pauseTarget(this) 100 | } 101 | 102 | 103 | /** 104 | * 运行所有计时器 105 | */ 106 | public resume() { 107 | cc.director.getScheduler().resumeTarget(this) 108 | } 109 | 110 | 111 | /** 112 | * 单次调度 113 | * @param handler 114 | * @param delay 115 | */ 116 | private scheduleOnce(handler, delay) { 117 | this.schedule(handler, 0, 0, delay, false); 118 | return handler; 119 | } 120 | 121 | 122 | /** 123 | * Timer开始调度 124 | * @param handler 回调 125 | * @param interval 间隔时间 126 | * @param repeat 重复次数(实际运行repeat + 1次) 127 | * @param delay 延迟多少时间后开始执行 128 | * @param pause 是否暂停 129 | */ 130 | private schedule(handler: Function, interval: number, repeat: number, delay: number, pause: boolean) { 131 | cc.director.getScheduler().schedule(handler, this, interval, repeat, delay, pause); 132 | return handler; 133 | // this._timers.push(handler) 134 | } 135 | 136 | 137 | /** 138 | * 移除调度 139 | * @param handler 140 | */ 141 | private unschedule(handler) { 142 | if (!handler) return; 143 | cc.director.getScheduler().unschedule(handler, this); 144 | } 145 | 146 | } -------------------------------------------------------------------------------- /assets/scripts/base/core/timer/TimerManager.ts.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.5", 3 | "uuid": "42bcb1f1-dc1b-4935-a734-167995604284", 4 | "isPlugin": false, 5 | "loadPluginInWeb": true, 6 | "loadPluginInNative": true, 7 | "loadPluginInEditor": false, 8 | "subMetas": {} 9 | } -------------------------------------------------------------------------------- /assets/scripts/base/extensions.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.1", 3 | "uuid": "994c2300-9f37-49ec-b78c-4558ba1e651c", 4 | "isSubpackage": false, 5 | "subpackageName": "", 6 | "subMetas": {} 7 | } -------------------------------------------------------------------------------- /assets/scripts/base/extensions/expr-eval.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.1", 3 | "uuid": "be97bf2f-e840-4dd5-9ddb-2f5b83a3116b", 4 | "isSubpackage": false, 5 | "subpackageName": "", 6 | "subMetas": {} 7 | } -------------------------------------------------------------------------------- /assets/scripts/base/extensions/expr-eval/expr-eval.d.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * exprEval的简写 3 | * JavaScript中的数学表达式求值器 4 | */ 5 | declare var ee = exprEval; 6 | 7 | 8 | /** 9 | * exprEval 10 | * 可简写为ee 11 | * JavaScript中的数学表达式求值器 12 | */ 13 | declare namespace exprEval { 14 | export type Value = number 15 | | string 16 | | ((...args: Value[]) => Value) 17 | | { [propertyName: string]: Value }; 18 | 19 | export interface Values { 20 | [propertyName: string]: Value; 21 | } 22 | 23 | export interface ParserOptions { 24 | allowMemberAccess?: boolean; 25 | operators?: { 26 | add?: boolean, 27 | comparison?: boolean, 28 | concatenate?: boolean, 29 | conditional?: boolean, 30 | divide?: boolean, 31 | factorial?: boolean, 32 | logical?: boolean, 33 | multiply?: boolean, 34 | power?: boolean, 35 | remainder?: boolean, 36 | subtract?: boolean, 37 | sin?: boolean, 38 | cos?: boolean, 39 | tan?: boolean, 40 | asin?: boolean, 41 | acos?: boolean, 42 | atan?: boolean, 43 | sinh?: boolean, 44 | cosh?: boolean, 45 | tanh?: boolean, 46 | asinh?: boolean, 47 | acosh?: boolean, 48 | atanh?: boolean, 49 | sqrt?: boolean, 50 | log?: boolean, 51 | ln?: boolean, 52 | lg?: boolean, 53 | log10?: boolean, 54 | abs?: boolean, 55 | ceil?: boolean, 56 | floor?: boolean, 57 | round?: boolean, 58 | trunc?: boolean, 59 | exp?: boolean, 60 | length?: boolean, 61 | in?: boolean 62 | }; 63 | } 64 | 65 | export class Parser { 66 | constructor(options?: ParserOptions); 67 | functions: any; 68 | parse(expression: string): Expression; 69 | evaluate(expression: string, values?: Value): number; 70 | static parse(expression: string): Expression; 71 | static evaluate(expression: string, values?: Value): number; 72 | } 73 | 74 | export interface Expression { 75 | simplify(values?: Value): Expression; 76 | evaluate(values?: Value): any; 77 | substitute(variable: string, value: Expression | string | number): Expression; 78 | symbols(options?: { withMembers?: boolean }): string[]; 79 | variables(options?: { withMembers?: boolean }): string[]; 80 | toJSFunction(params: string, values?: Value): (...args: any[]) => number; 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /assets/scripts/base/extensions/expr-eval/expr-eval.d.ts.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "2.0.0", 3 | "uuid": "7d2eac02-ef12-4ce0-ab2f-67e989b13ead", 4 | "subMetas": {} 5 | } -------------------------------------------------------------------------------- /assets/scripts/base/extensions/expr-eval/expr-eval.min.js.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.5", 3 | "uuid": "5fea6bf5-43cc-444c-8ed2-3e6946a035b1", 4 | "isPlugin": true, 5 | "loadPluginInWeb": true, 6 | "loadPluginInNative": true, 7 | "loadPluginInEditor": true, 8 | "subMetas": {} 9 | } -------------------------------------------------------------------------------- /assets/scripts/base/extensions/fgui.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.1", 3 | "uuid": "f92e6578-8f9a-4114-8589-e1b232beb00b", 4 | "isSubpackage": false, 5 | "subpackageName": "", 6 | "subMetas": {} 7 | } -------------------------------------------------------------------------------- /assets/scripts/base/extensions/fgui/BaseView.ts: -------------------------------------------------------------------------------- 1 | import { BaseWindow } from "./BaseWindow"; 2 | import { FGUIUtil } from "./FGUIUtil"; 3 | 4 | /** 5 | * 基础视图(页面)类 6 | */ 7 | export abstract class BaseView extends BaseWindow { 8 | 9 | protected pkgName: string = ""; 10 | protected resName: string = ""; 11 | 12 | protected closeButtonName: string = "background/closeButton"; 13 | 14 | protected showEnterAndLeaveAnim: boolean = true; 15 | 16 | 17 | protected onInit(): void { 18 | this.contentPane = fgui.UIPackage.createObject(`${this.pkgName}`, `${this.resName}`).asCom; 19 | (!this.closeButton) && (this.closeButton = this.contentPane.getChild("closeButton")); 20 | (!this.closeButton) && (this.closeButton = this.findGObj(this.closeButtonName)); 21 | this.modal = true; 22 | this.contentPane.makeFullScreen(); 23 | this.onCreate(this.contentPane); 24 | // 延迟显示 25 | this.contentPane.alpha = 0; 26 | setTimeout(() => { 27 | this.contentPane.alpha = 1; 28 | }, 50); 29 | } 30 | 31 | 32 | doShowAnimation() { 33 | if (this.showEnterAndLeaveAnim) { 34 | const width = this.rootView.node.width; 35 | this.rootView.node.position = this.rootView.node.position.sub(cc.v2(width, 0)); 36 | this.rootView.node.runAction(cc.sequence([ 37 | cc.moveBy(0.2, cc.v2(width, 0)), 38 | cc.callFunc(() => { 39 | }) 40 | ])); 41 | } 42 | this.onShown(); 43 | } 44 | 45 | 46 | doHideAnimation() { 47 | if (this.showEnterAndLeaveAnim) { 48 | const width = this.rootView.node.width; 49 | this.rootView.node.runAction(cc.sequence([ 50 | cc.moveBy(0.15, cc.v2(-width, 0)), 51 | cc.callFunc(() => { 52 | this.hideImmediately(); 53 | this.rootView.node.position = this.rootView.node.position.add(cc.v2(width, 0)); 54 | }) 55 | ])); 56 | } else { 57 | this.hideImmediately(); 58 | } 59 | } 60 | 61 | 62 | openPage(baseViewClass: new () => BaseView) { 63 | FGUIUtil.getUI(baseViewClass).show(); 64 | } 65 | 66 | 67 | showDialog(baseWindowClass: new () => BaseWindow) { 68 | FGUIUtil.getUI(baseWindowClass).show(); 69 | } 70 | 71 | 72 | protected onShown() { 73 | this.bringToFront(); 74 | } 75 | 76 | 77 | protected onHide() { 78 | } 79 | 80 | } 81 | -------------------------------------------------------------------------------- /assets/scripts/base/extensions/fgui/BaseView.ts.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.5", 3 | "uuid": "23e30993-0c66-476c-8321-09ef1352a285", 4 | "isPlugin": false, 5 | "loadPluginInWeb": true, 6 | "loadPluginInNative": true, 7 | "loadPluginInEditor": false, 8 | "subMetas": {} 9 | } -------------------------------------------------------------------------------- /assets/scripts/base/extensions/fgui/BaseWindow.ts: -------------------------------------------------------------------------------- 1 | import { TimerManager } from "../../core/timer/TimerManager"; 2 | import { EventsManager } from "../../core/event/EventManager"; 3 | 4 | /** 5 | * 基础窗口类 6 | * 重写私有方法 _init 需要忽略报红 7 | */ 8 | export abstract class BaseWindow extends fgui.Window { 9 | 10 | private _timerManager: TimerManager; 11 | private _eventsManager: EventsManager; 12 | 13 | protected pkgName: string = ""; 14 | protected resName: string = ""; 15 | protected showEnterAndLeaveAnim: boolean = true; 16 | 17 | constructor() { 18 | super(); 19 | this._timerManager = App.Utils.TimerManager.new(); 20 | } 21 | 22 | get timer() { 23 | return this._timerManager; 24 | } 25 | 26 | get rootView() { 27 | return this.contentPane; 28 | } 29 | 30 | // 重写私有方法 _init 忽略报红 31 | private _init() { 32 | fgui.UIPackage.loadPackage(`ui/${this.pkgName}`, (err) => { 33 | super['_init'](); 34 | }); 35 | } 36 | 37 | 38 | protected onInit() { 39 | this.contentPane = fgui.UIPackage.createObject(`${this.pkgName}`, `${this.resName}`).asCom; 40 | (!this.closeButton) && (this.closeButton = this.contentPane.getChild("closeButton")); 41 | this.center(true); 42 | this.modal = true; 43 | this.onCreate(this.contentPane); 44 | // console.log("showEnterAndLeaveAnim", this.showEnterAndLeaveAnim); 45 | } 46 | 47 | 48 | abstract onCreate(view: fgui.GComponent); 49 | 50 | 51 | protected doShowAnimation() { 52 | if (this.showEnterAndLeaveAnim) { 53 | this.contentPane.node.scale = 0.45; 54 | this.contentPane.node.runAction( 55 | cc.sequence([ 56 | cc.scaleTo(0.15, 1.05), 57 | cc.scaleTo(0.05, 1), 58 | ]) 59 | ); 60 | } 61 | const enterAnim = this.rootView.getTransition("enter_anim"); 62 | enterAnim && enterAnim.play(); 63 | this.onShown(); 64 | } 65 | 66 | 67 | protected doHideAnimation() { 68 | this.hideImmediately(); 69 | } 70 | 71 | 72 | protected onShown() { 73 | this.bringToFront(); 74 | // App.SDK.showBannerAd(null); 75 | } 76 | 77 | 78 | protected onHide() { 79 | // App.SDK.hideBannerAd(); 80 | } 81 | 82 | 83 | // --==============================分隔线================================-- 84 | 85 | 86 | /** 87 | * 调度一个自定义的回调函数。 88 | * 如果回调函数已调度,那么将不会重复调度它,只会更新时间间隔参数。 89 | * @param handler 回调 90 | * @param interval 间隔时间 91 | * @param repeat 重复次数(实际运行repeat + 1次) 92 | * @param delay 延迟多少时间后开始执行 93 | * @param pause 是否暂停 94 | */ 95 | schedule(handler: Function, interval: number, repeat: number, delay: number, pause: boolean) { 96 | this._timerManager.runTimer(handler, interval, repeat, delay, pause); 97 | } 98 | 99 | 100 | /** 101 | * 调度一个只运行一次的回调函数,可以指定 0 让回调函数在下一帧立即执行或者在一定的延时之后执行。 102 | * @param handler 回调 103 | * @param delay 延迟多少时间后开始执行 104 | */ 105 | scheduleOnce(handler: Function, delay: number = 0,) { 106 | this._timerManager.runDelayTimer(handler, delay); 107 | } 108 | 109 | 110 | /** 111 | * 注册事件 112 | * @param eventName 事件名 113 | * @param handler 事件回调 114 | * @param once 是否为单次消耗事件 115 | */ 116 | public bindEvent(type: string, callback?: Function, once: boolean = false) { 117 | let handler = callback ? callback.bind(this) : (this[type] ? this[type].bind(this) : null); 118 | if (once) { 119 | return this.Event.once(type, handler, this); 120 | } 121 | return this.Event.on(type, handler, this); 122 | } 123 | 124 | 125 | /** 126 | * 寻找fgui对象 127 | * @param sPath 路径 128 | * @param refrenceNode 相对组件 129 | */ 130 | public findGObj(sPath: string, refrenceNode: fgui.GComponent = this.rootView): fgui.GObject { 131 | let arr: Array = sPath.split("/"); 132 | let obj: fgui.GObject = null; 133 | for (let i = 0; i < arr.length; i++) { 134 | if (obj && obj.asCom && obj.asCom.getChild) { 135 | obj = obj.asCom.getChild(arr[i]); 136 | } else { 137 | obj = refrenceNode.getChild(arr[i]); 138 | } 139 | } 140 | return obj; 141 | } 142 | 143 | 144 | /** 145 | * 销毁window 146 | */ 147 | public destroy() { 148 | cc.log("销毁window", this.resName); 149 | this.dispose(); 150 | } 151 | 152 | 153 | /** 154 | * EventsManager 155 | */ 156 | get Event() { 157 | if (!this._eventsManager) { 158 | this._eventsManager = App.SingletonFactory.getInstance(EventsManager); 159 | let onDestroy = this.onDestroy.bind(this); 160 | this.onDestroy = () => { 161 | this.Event.offTarget(this); 162 | onDestroy && onDestroy(); 163 | }; 164 | } 165 | return this._eventsManager; 166 | } 167 | 168 | 169 | protected onDestroy() { 170 | this._timerManager.removeAllTimers(); 171 | } 172 | 173 | 174 | } -------------------------------------------------------------------------------- /assets/scripts/base/extensions/fgui/BaseWindow.ts.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.5", 3 | "uuid": "bcc83ff4-0653-43dd-9eee-acc576aca75c", 4 | "isPlugin": false, 5 | "loadPluginInWeb": true, 6 | "loadPluginInNative": true, 7 | "loadPluginInEditor": false, 8 | "subMetas": {} 9 | } -------------------------------------------------------------------------------- /assets/scripts/base/extensions/fgui/FGUIUtil.ts: -------------------------------------------------------------------------------- 1 | import { BaseWindow } from "./BaseWindow"; 2 | 3 | export class FGUIUtil { 4 | 5 | private static _uiList: Map<{ new() }, BaseWindow> = new Map<{ new() }, BaseWindow>(); 6 | 7 | /** 8 | * 获取ui 9 | * @param uiClass 10 | */ 11 | public static getUI(uiClass: { new(): T }): T { 12 | if (!this._uiList.has(uiClass)) { 13 | let obj = new uiClass(); 14 | this._uiList.set(uiClass, obj); 15 | return obj; 16 | } 17 | return this._uiList.get(uiClass); 18 | } 19 | 20 | /** 21 | * 清空并销毁所有ui 22 | */ 23 | public static clear() { 24 | this._uiList.forEach((dialog) => { 25 | if (dialog) { 26 | dialog.hide(); 27 | dialog.dispose(); 28 | } 29 | }); 30 | this._uiList.clear(); 31 | } 32 | 33 | /** 34 | * 隐藏所有ui 35 | */ 36 | public static hideAll() { 37 | this._uiList.forEach((dialog) => { 38 | dialog && dialog.hide(); 39 | }); 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /assets/scripts/base/extensions/fgui/FGUIUtil.ts.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.5", 3 | "uuid": "d99cd0b8-334e-4295-b47c-7f4f715ecb7a", 4 | "isPlugin": false, 5 | "loadPluginInWeb": true, 6 | "loadPluginInNative": true, 7 | "loadPluginInEditor": false, 8 | "subMetas": {} 9 | } -------------------------------------------------------------------------------- /assets/scripts/base/extensions/fgui/fairygui.d.ts.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "2.0.0", 3 | "uuid": "1410cab0-e2ba-48dc-9fbe-141cce69b33e", 4 | "subMetas": {} 5 | } -------------------------------------------------------------------------------- /assets/scripts/base/extensions/fgui/fairygui.js.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.5", 3 | "uuid": "87f3b0e6-4c8c-4ef7-b706-281bbe87cb27", 4 | "isPlugin": true, 5 | "loadPluginInWeb": true, 6 | "loadPluginInNative": true, 7 | "loadPluginInEditor": true, 8 | "subMetas": {} 9 | } -------------------------------------------------------------------------------- /assets/scripts/base/extensions/gzip.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.1", 3 | "uuid": "fac082ad-bd13-4222-81b2-23936d7738b0", 4 | "isSubpackage": false, 5 | "subpackageName": "", 6 | "subMetas": {} 7 | } -------------------------------------------------------------------------------- /assets/scripts/base/extensions/gzip/pako.d.ts: -------------------------------------------------------------------------------- 1 | declare module pako { 2 | 3 | 4 | export class Deflate { 5 | 6 | /** 7 | * @param options (Object) zlib deflate options. 8 | * Creates new deflator instance with specified params. Throws exception on bad params. Supported options: 9 | * >level 10 | * >windowBits 11 | * >memLevel 12 | * >strategy 13 | * >dictionary 14 | * http://zlib.net/manual.html#Advanced for more information on these. 15 | * 16 | * Additional options, for internal needs: 17 | * > chunkSize - size of generated data chunks (16K by default) 18 | * > raw (Boolean) - do raw deflate 19 | * > gzip (Boolean) - create gzip wrapper 20 | * > to (String) - if equal to 'string', then result will be "binary string" (each char code [0..255]) 21 | * > header (Object) - custom header for gzip 22 | * > text (Boolean) - true if compressed data believed to be text 23 | * > time (Number) - modification time, unix timestamp 24 | * > os (Number) - operation system code 25 | * > extra (Array) - array of bytes with extra data (max 65536) 26 | * > name (String) - file name (binary string) 27 | * > comment (String) - comment (binary string) 28 | * > hcrc (Boolean) - true if header crc should be added 29 | */ 30 | constructor(options?: Object); 31 | 32 | /** 33 | * Deflate.err -> Number 34 | * Error code after deflate finisnumberd 35 | * . 0 (Z_OK) on success. You will not need it in real life, because deflate errors are possible only on wrong options or bad onData / onEnd custom handlers. 36 | */var 37 | err: number; 38 | 39 | /** 40 | * Deflate.msg -> String 41 | * Error message, if Deflate.err != 0 42 | */ 43 | msg: string; 44 | 45 | /** 46 | * Deflate.result -> Uint8Array|Array 47 | * Compressed result, generated by default Deflate#onData and Deflate#onEnd handlers. Filled after you push last chunk (call Deflate#punumber 48 | * with Z_FINISH / true param) or if you push a chunk with explicit flush (call Deflate#punumber 49 | *export var with Z_SYNC_FLUSH param). 50 | */var 51 | result: Uint8Array | Array; 52 | 53 | /** 54 | * Deflate#onData(chunk)Void 55 | * @param chunk (Uint8Array|Array|String) output data. Type of array depends on js engine support. When string output requested, each chunk will be string. 56 | * By default, stores data blocks in chunks[] property and glue those in onEnd. Override this handler, if you need another behaviour. 57 | */ 58 | onData(chunk: Uint8Array | Array | String): void; 59 | 60 | /** 61 | * Deflate #onEnd(status)Void 62 | * @param status (number) deflate stanumbers 63 | * . 0 (Z_OK) on success, other if not. 64 | *export var Called once after you tell deflate that the input stream is conumberl 65 | * ete (Z_FINISH) or should be fnumbers 66 | *export var hed (Z_SYNC_FLUSH) or if an error happened. By default - join collected chunks, free memory and fill results / err properties. 67 | */var 68 | onEnd(status: number): void; 69 | 70 | /** 71 | * Deflate#push(data[, mode])Boolean 72 | * @param data (Uint8Array|Array|ArrayBuffer|String) input data. Strings will be converted to utf8 byte sequence. 73 | * @param mode (Number|Boolean) [0..6] for corresnumbern 74 | * ding Z_NOnumberL 75 | *export var USH..Z_TREE modes. See constants. Skipped or falsnumberm 76 | *export var eans Z_NO_FLUSH, trunumberm 77 | *export var eans Z_FINISH. 78 | *export var Sends input data to deflate pipe, generating Deflate#onData calls with new compressed chunks. Returns true on success. The last data block must hanumber 79 | * mode Z_FINISH (or true). That will flush internal pending buffers and call Deflate#onEnd. For interim explicit flushes (without ending the stream) you can unumber 80 | *export var mode Z_SYNC_FLUSH, keeping the compression context. 81 | */var 82 | push(data: Uint8Array | Array | ArrayBuffer | String, mode: Number | Boolean): boolean; 83 | 84 | } 85 | 86 | 87 | 88 | export class Inflate { 89 | 90 | /** 91 | * @param options (Object) zlib inflate options. 92 | * Creates new inflator instance with specified params. Throws exception on bad params. Supported options: 93 | * >windowBits 94 | * >dictionary 95 | * http://zlib.net/manual.html#Advanced for more information on these. 96 | * 97 | * Additional options, for internal needs: 98 | * >chunkSize - size of generated data chunks (16K by default) 99 | * >raw (Boolean) - do raw inflate 100 | * >to (String) - if equal to 'string', then result will be converted from utf8 to utf16 (javascript) string. When string output requested, chunk length can differ from chunkSize, depending on content. 101 | */ 102 | constructor(options?: Object); 103 | 104 | /** 105 | * Inflate.err -> Number 106 | * Error code after deflate finisnumberd 107 | * . 0 (Z_OK) on success. You will not need it in real life, because deflate errors are possible only on wrong options or bad onData / onEnd custom handlers. 108 | */var 109 | err: number; 110 | 111 | /** 112 | * Inflate.msg -> String 113 | * Error message, if Deflate.err != 0 114 | */ 115 | msg: string; 116 | 117 | /** 118 | * Inflate.result -> Uint8Array|Array 119 | * Compressed result, generated by default Deflate#onData and Deflate#onEnd handlers. Filled after you push last chunk (call Deflate#punumber 120 | * with Z_FINISH / true param) or if you push a chunk with explicit flush (call Deflate#punumber 121 | *export var with Z_SYNC_FLUSH param). 122 | */var 123 | result: Uint8Array | Array; 124 | 125 | /** 126 | * Inflate#onData(chunk)Void 127 | * @param chunk (Uint8Array|ArrayString) output data. Type of array depends on js engine support. When string output requested, each chunk will be string. 128 | * By default, stores data blocks in chunks[] property and glue those in onEnd. Override this handler, if you need another behaviour. 129 | */ 130 | onData(chunk); 131 | 132 | /** 133 | * Inflate#onEnd(status)Void 134 | * @param status (Number) inflate stanumbers 135 | * . 0 (Z_OK) on success, other if not. 136 | *export var Called either after you tell inflate that the input stream is conumberl 137 | * ete (Z_FINISH) or should be fnumbers 138 | *export var hed (Z_SYNC_FLUSH) or if an error happened. By default - join collected chunks, free memory and fill results / err properties. 139 | *export var @param status 140 | */ 141 | onEnd(status); 142 | 143 | /** 144 | * @param data (Uint8Array|Array|ArrayBuffer|String) input data 145 | * @param mode (Number|Boolean) [0..6] for corresnumbern 146 | * ding Z_NOnumberL 147 | *export var USH..Z_TREE modes. See constants. Skipped or falsnumberm 148 | *export var eans Z_NO_FLUSH, trunumberm 149 | *export var eans Z_FINISH. 150 | *export var 151 | * 152 | */ 153 | push(data, mode); 154 | 155 | } 156 | 157 | 158 | 159 | /** 160 | * deflate(data[, options])->Uint8Array|Array|String 161 | * @param data (Uint8Array|Array|String)input data to compress. 162 | * @param options (Object) zlib deflate options. 163 | * Compress data with deflate algorithm and options. 164 | * 165 | * Supported options are: 166 | * >level 167 | * >windowBits 168 | * >memLevel 169 | * >strategy 170 | * >dictionary 171 | * http://zlib.net/manual.html#Advanced for more information on these. 172 | * 173 | * Sugar (options): 174 | * >raw (Boolean) - say that we work with raw stream, if you don't wish to specify negative windowBits implicitly. 175 | * >to (String) - if equal to 'string', then result will be "binary string" (each char code [0..255]) 176 | * @param options 177 | */ 178 | export function deflate(data: Uint8Array | Array | String, options?: Object): Uint8Array | Array | String; 179 | 180 | 181 | /** 182 | * deflateRaw(data[, options])->Uint8Array|Array|String 183 | * @param data (Uint8Array|Array|String) input data to compress. 184 | * @param options (Object) zlib deflate options. 185 | * The same as deflate, but creates raw data, without wrapper (header and adler32 crc). 186 | */ 187 | export function deflateRaw(data: Uint8Array | Array | String, options?: Object): Uint8Array | Array | String; 188 | 189 | 190 | /** 191 | * gzip(data[, options])->Uint8Array|Array|String 192 | * @param data (Uint8Array|Array|String)input data to compress. 193 | * @param options (Object) zlib deflate options. 194 | * The same as deflate, but create gzip wrapper instead of deflate one. 195 | */ 196 | export function gzip(data: Uint8Array | Array | String, options?: Object): Uint8Array | Array | String; 197 | 198 | 199 | /** 200 | * inflate(data[, options])->Uint8Array|Array|String 201 | * @param data (Uint8Array|Array|String)input data to compress. 202 | * @param options (Object) zlib inflate options. 203 | * Decompress data with inflate/ungzip and options. Autodetect format via wrapper header by default. That's why we don't provide separate ungzip method. 204 | * 205 | * Supported options are: 206 | * >windowBits 207 | * http://zlib.net/manual.html#Advanced for more information. 208 | * 209 | * Sugar (options): 210 | * >raw (Boolean) - say that we work with raw stream, if you don't wish to specify negative windowBits implicitly. 211 | * >to (String) - if equal to 'string', then result will be converted from utf8 to utf16 (javascript) string. When string output requested, chunk length can differ from chunkSize, depending on content. 212 | */ 213 | export function inflate(data: Uint8Array | Array | String, options?: Object): Uint8Array | Array | String; 214 | 215 | 216 | /** 217 | * inflateRaw(data[, options])->Uint8Array|Array|String 218 | * @param data (Uint8Array|Array|String)input data to compress. 219 | * @param options (Object) zlib inflate options. 220 | * The same as inflate, but creates raw data, without wrapper (header and adler32 crc). 221 | */ 222 | export function inflateRaw(data: Uint8Array | Array | String, options?: Object): Uint8Array | Array | String; 223 | 224 | 225 | /** 226 | * ungzip(data[, options])->Uint8Array|Array|String 227 | * @param data (Uint8Array|Array|String)input data to compress. 228 | * @param options (Object) zlib inflate options. 229 | * Just shortcut to inflate, because it autodetects format by header.content. Done for convenience. 230 | */ 231 | export function ungzip(data: Uint8Array | Array | String, options?: Object): Uint8Array | Array | String; 232 | 233 | 234 | export var Z_BEST_COMPRESSION: number; 235 | 236 | export var Z_BEST_SPEED: number; 237 | 238 | export var Z_BINARY: number; 239 | 240 | export var Z_BLOCK: number; 241 | 242 | export var Z_BUF_ERROR: number; 243 | 244 | export var Z_DATA_ERROR: number; 245 | 246 | export var Z_DEFAULT_COMPRESSION: number; 247 | 248 | export var Z_DEFAULT_STRATEGY: number; 249 | 250 | export var Z_DEFLATED: number; 251 | 252 | export var Z_ERRNO: number; 253 | 254 | export var Z_FILTERED: number; 255 | 256 | export var Z_FINISH: number; 257 | 258 | export var Z_FIXED: number; 259 | 260 | export var Z_FULL_FLUSH: number; 261 | 262 | export var Z_HUFFMAN_ONLY: number; 263 | 264 | export var Z_NEED_DICT: number; 265 | 266 | export var Z_NO_COMPRESSION: number; 267 | 268 | export var Z_NO_FLUSH: number; 269 | 270 | export var Z_OK: number; 271 | 272 | export var Z_PARTIAL_FLUSH: number; 273 | 274 | export var Z_RLE: number; 275 | 276 | export var Z_STREAM_END: number; 277 | 278 | export var Z_STREAM_ERROR: number; 279 | 280 | export var Z_SYNC_FLUSH: number; 281 | 282 | export var Z_TEXT: number; 283 | 284 | export var Z_TREES: number; 285 | 286 | export var Z_UNKNOWN: number; 287 | 288 | } -------------------------------------------------------------------------------- /assets/scripts/base/extensions/gzip/pako.d.ts.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "2.0.0", 3 | "uuid": "6c37fbe5-5ddc-46bc-ad25-3bac96fefb20", 4 | "subMetas": {} 5 | } -------------------------------------------------------------------------------- /assets/scripts/base/extensions/gzip/pako.min.js.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.5", 3 | "uuid": "2685632d-adea-45d9-91b4-a2a7c380cf98", 4 | "isPlugin": true, 5 | "loadPluginInWeb": true, 6 | "loadPluginInNative": true, 7 | "loadPluginInEditor": true, 8 | "subMetas": {} 9 | } -------------------------------------------------------------------------------- /assets/scripts/base/extensions/protobuf.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.1", 3 | "uuid": "305c0a8b-dce4-404a-aad0-422e36b47092", 4 | "isSubpackage": false, 5 | "subpackageName": "", 6 | "subMetas": {} 7 | } -------------------------------------------------------------------------------- /assets/scripts/base/extensions/protobuf/protobuf.d.ts.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "2.0.0", 3 | "uuid": "221e3506-9a6a-4985-ad86-80fbac9ab315", 4 | "subMetas": {} 5 | } -------------------------------------------------------------------------------- /assets/scripts/base/extensions/protobuf/protobuf.min.js.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.5", 3 | "uuid": "a1deb465-9944-406f-80f8-68a29e376c95", 4 | "isPlugin": true, 5 | "loadPluginInWeb": true, 6 | "loadPluginInNative": true, 7 | "loadPluginInEditor": true, 8 | "subMetas": {} 9 | } -------------------------------------------------------------------------------- /assets/scripts/base/extensions/qrcode.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.1", 3 | "uuid": "1d5f470f-5a11-4e94-b3fc-7069b66019ea", 4 | "isSubpackage": false, 5 | "subpackageName": "", 6 | "subMetas": {} 7 | } -------------------------------------------------------------------------------- /assets/scripts/base/extensions/qrcode/components.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.1", 3 | "uuid": "c1906819-ea85-4d02-bee5-2826540e6f1a", 4 | "isSubpackage": false, 5 | "subpackageName": "", 6 | "subMetas": {} 7 | } -------------------------------------------------------------------------------- /assets/scripts/base/extensions/qrcode/components/QRCode.ts: -------------------------------------------------------------------------------- 1 | const { ccclass, property, requireComponent, executeInEditMode, menu } = cc._decorator; 2 | 3 | const ModeData = ["-1", "numeric", "alphanumeric", "octet"]; 4 | 5 | const EcclevelData = ["-1", "L", "M", "Q", "H"]; 6 | 7 | export enum ModeType { 8 | DEFAULT, 9 | MODE_NUMERIC, 10 | MODE_ALPHANUMERIC, 11 | MODE_OCTET 12 | } 13 | 14 | export enum EcclevelType { 15 | DEFAULT, 16 | ECCLEVEL_L, 17 | ECCLEVEL_M, 18 | ECCLEVEL_Q, 19 | ECCLEVEL_H, 20 | } 21 | 22 | @ccclass 23 | @menu("扩展组件/QRCode") 24 | @requireComponent(cc.Graphics) 25 | @executeInEditMode 26 | export default class QRCode extends cc.Component { 27 | 28 | @property({ visible: false }) 29 | _data: string = "二维码内容"; 30 | 31 | @property({ visible: false }) 32 | _padding: number = 10; 33 | 34 | @property({ visible: false }) 35 | _background: cc.Color = cc.Color.WHITE; 36 | 37 | @property({ visible: false }) 38 | _cell: cc.Color = cc.Color.BLACK; 39 | 40 | @property({ visible: false }) 41 | _cellSize: number = 5; 42 | 43 | @property({ visible: false }) 44 | _version: number = -1; 45 | 46 | @property({ min: -1, max: 8, step: 1 }) 47 | _mask = -1; 48 | 49 | @property({ type: cc.Enum(ModeType), visible: false }) 50 | _mode: ModeType = ModeType.DEFAULT; 51 | 52 | @property({ type: cc.Enum(EcclevelType), visible: false }) 53 | _ecclevel: EcclevelType = EcclevelType.DEFAULT; 54 | 55 | @property({ visible: false }) 56 | _preview: boolean = false; 57 | 58 | 59 | graphics: cc.Graphics; 60 | 61 | 62 | @property({ displayName: "内容" }) 63 | set data(data: string) { 64 | if (data != this.data) { 65 | this._data = data; 66 | this.applayChanged(); 67 | } 68 | } 69 | get data() { 70 | return this._data; 71 | } 72 | 73 | 74 | @property({ displayName: "预览" }) 75 | set preview(preview: boolean) { 76 | this._preview = preview; 77 | this._preview && this.applayChanged(); 78 | } 79 | get preview() { 80 | return this._preview; 81 | } 82 | 83 | 84 | @property({ displayName: "背景颜色" }) 85 | set background(background: cc.Color) { 86 | this._background = background; 87 | this.applayChanged(); 88 | } 89 | get background() { 90 | return this._background; 91 | } 92 | 93 | 94 | @property({ displayName: "块颜色" }) 95 | set cell(cell: cc.Color) { 96 | this._cell = cell; 97 | this.applayChanged(); 98 | } 99 | get cell() { 100 | return this._cell; 101 | } 102 | 103 | 104 | @property({ displayName: "块大小", step: 1 }) 105 | set cellSize(cellSize: number) { 106 | if (cellSize != this.cellSize) { 107 | this._cellSize = cellSize; 108 | this.applayChanged(); 109 | } 110 | } 111 | get cellSize() { 112 | return this._cellSize; 113 | } 114 | 115 | 116 | @property({ displayName: "边距", step: 1 }) 117 | set padding(padding: number) { 118 | if (padding != this.padding) { 119 | this._padding = padding; 120 | this.applayChanged(); 121 | } 122 | } 123 | get padding() { 124 | return this._padding; 125 | } 126 | 127 | 128 | @property({ step: 1 }) 129 | set version(version: number) { 130 | if (version != this.version) { 131 | this._version = version; 132 | this.applayChanged(); 133 | } 134 | } 135 | get version() { 136 | return this._version; 137 | } 138 | 139 | 140 | @property({ min: -1, max: 7, step: 1 }) 141 | set mask(mask: number) { 142 | if (mask != this.mask) { 143 | this._mask = mask; 144 | this.applayChanged(); 145 | } 146 | } 147 | get mask() { 148 | return this._mask; 149 | } 150 | 151 | 152 | @property({ type: cc.Enum(ModeType) }) 153 | set mode(mode: ModeType) { 154 | if (mode != this.mode) { 155 | this._mode = mode; 156 | this.applayChanged(); 157 | } 158 | } 159 | get mode() { 160 | return this._mode; 161 | } 162 | 163 | 164 | @property({ type: cc.Enum(EcclevelType) }) 165 | set ecclevel(ecclevel: EcclevelType) { 166 | if (ecclevel != this.ecclevel) { 167 | this._ecclevel = ecclevel; 168 | this.applayChanged(); 169 | } 170 | } 171 | get ecclevel() { 172 | return this._ecclevel; 173 | } 174 | 175 | 176 | onLoad() { 177 | this.graphics = this.node.getComponent(cc.Graphics); 178 | } 179 | 180 | 181 | start() { 182 | this.applayChanged(); 183 | } 184 | 185 | 186 | async applayChanged() { 187 | await 0; 188 | if (CC_EDITOR && !this.preview) { return; } 189 | let options = { 190 | version: this.version, 191 | mask: this.mask, 192 | mode: this.mode == 0 ? null : ModeData[this.mode], 193 | ecclevel: this.ecclevel == 0 ? null : EcclevelData[this.ecclevel], 194 | }; 195 | let dataArray = qrcode.generate(this.data, options); 196 | this.updateGraphics(dataArray); 197 | } 198 | 199 | 200 | async updateGraphics(dataArray: Array>) { 201 | // dataArray 202 | let size = dataArray.length * this.cellSize + this.padding * 2; 203 | this.graphics.clear(); 204 | this.graphics.fillColor = this.background; 205 | this.graphics.rect(- size * this.node.anchorX, - size * this.node.anchorY, size, size); 206 | this.graphics.fill(); 207 | this.graphics.fillColor = this.cell; 208 | for (let y = 0; y < dataArray.length; y++) { 209 | const dataLine = dataArray[y]; 210 | for (let x = 0; x < dataLine.length; x++) { 211 | const dataBlock = dataLine[x]; 212 | let y1 = dataArray.length - y - 1; 213 | dataBlock && this.graphics.rect(x * this.cellSize + this.padding - size * this.node.anchorX, y1 * this.cellSize + this.padding - size * this.node.anchorX, this.cellSize, this.cellSize); 214 | // dataBlock && this.graphics.stroke(); 215 | dataBlock && this.graphics.fill(); 216 | } 217 | } 218 | this.node.width = size; 219 | this.node.height = size; 220 | } 221 | 222 | // update (dt) {} 223 | } 224 | -------------------------------------------------------------------------------- /assets/scripts/base/extensions/qrcode/components/QRCode.ts.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.5", 3 | "uuid": "fe682acc-6a76-4798-9365-ce13e70888f3", 4 | "isPlugin": false, 5 | "loadPluginInWeb": true, 6 | "loadPluginInNative": true, 7 | "loadPluginInEditor": false, 8 | "subMetas": {} 9 | } -------------------------------------------------------------------------------- /assets/scripts/base/extensions/qrcode/qrcode.d.ts: -------------------------------------------------------------------------------- 1 | declare module qrcode { 2 | 3 | 4 | /** 5 | * 生成二维码 数组 6 | * @param data 内容 7 | * @param options 设置 8 | */ 9 | export function generate(data: string, options?: QROptions): Array>; 10 | 11 | 12 | /** 13 | * 生成二维码 html 14 | * @param data 内容 15 | * @param options 设置 16 | */ 17 | export function generateHTML(data: string, options?: QROptions): string; 18 | 19 | 20 | /** 21 | * 生成二维码 base64 22 | * @param data 内容 23 | * @param options 设置 24 | */ 25 | export function generatePNG(data: string, options?: QROptions): string; 26 | 27 | 28 | export interface QROptions { 29 | version?: number, 30 | mask?: number // [0-8] default -1 31 | mode: string, // [numeric、alphanumeric、octet],default numeric 32 | ecclevel: string, // [L、M、Q、H],default L 33 | } 34 | 35 | } -------------------------------------------------------------------------------- /assets/scripts/base/extensions/qrcode/qrcode.d.ts.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "2.0.0", 3 | "uuid": "95cb3a10-a5df-4a52-8502-2f207b153a8a", 4 | "subMetas": {} 5 | } -------------------------------------------------------------------------------- /assets/scripts/base/extensions/qrcode/qrcode.js.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.5", 3 | "uuid": "5063692f-f203-4b6f-9a09-6057d89160c1", 4 | "isPlugin": true, 5 | "loadPluginInWeb": true, 6 | "loadPluginInNative": true, 7 | "loadPluginInEditor": true, 8 | "subMetas": {} 9 | } -------------------------------------------------------------------------------- /assets/scripts/base/utils.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.1", 3 | "uuid": "7d8f6073-721a-46d6-91b1-6fce1fe07ba6", 4 | "isSubpackage": false, 5 | "subpackageName": "", 6 | "subMetas": {} 7 | } -------------------------------------------------------------------------------- /assets/scripts/base/utils/Base64.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Base64字符串处理,支持中文 3 | */ 4 | export class Base64 { 5 | 6 | /** 7 | * 使用Base64对input进行编码 8 | * @param input string或者ArrayBuffer 9 | */ 10 | public static encode(input: string): string { 11 | return this._utf8encode(input); 12 | } 13 | 14 | /** 15 | * 使用Base64对input进行解码 16 | * @param input 需要被解码的base64字符串 17 | * @param utf8 默认编码存在utf8字符进行解码,如果确认编码的字符里不存在utf8字符可以传false 18 | */ 19 | public static decode(input: string, utf8: boolean = true): any { 20 | return this._utf8decode(input, utf8); 21 | } 22 | 23 | private static _utf8encode(input: string): string { 24 | try { 25 | return window.btoa(input); 26 | } catch (e) { 27 | return window.btoa(unescape(encodeURIComponent(input))); 28 | } 29 | } 30 | 31 | private static _utf8decode(input: string, utf8: boolean): string { 32 | if (utf8) { 33 | try { 34 | return decodeURIComponent(escape(window.atob(input))); 35 | } catch (e) { 36 | return window.atob(unescape(input)); 37 | } 38 | } 39 | return window.atob(input); 40 | } 41 | 42 | } -------------------------------------------------------------------------------- /assets/scripts/base/utils/Base64.ts.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.5", 3 | "uuid": "e9b2e8ff-54c1-4309-9f42-61f45798f9ba", 4 | "isPlugin": false, 5 | "loadPluginInWeb": true, 6 | "loadPluginInNative": true, 7 | "loadPluginInEditor": false, 8 | "subMetas": {} 9 | } -------------------------------------------------------------------------------- /assets/scripts/base/utils/BezierMaker.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * BezierMaker 3 | * N阶贝塞尔曲线 4 | * git clone https://github.com/Aaaaaaaty/bezierMaker.js.git 5 | */ 6 | export default class BezierMaker { 7 | 8 | private _bezierArr: Array; 9 | 10 | private _bezierCtrlNodesArr: Array; 11 | 12 | 13 | /** 14 | * @param bezierCtrlNodesArr 控制点数组,包含x,y坐标 15 | */ 16 | constructor(bezierCtrlNodesArr?: Array) { 17 | this._bezierArr = []; 18 | this._bezierCtrlNodesArr = bezierCtrlNodesArr ? bezierCtrlNodesArr : []; 19 | } 20 | 21 | 22 | /** 23 | * 贝塞尔公式调用 24 | * @param t 尔函数涉及的占比比例,0<=t<=1 25 | */ 26 | public bezier(t) { 27 | let x = 0; 28 | let y = 0; 29 | let bezierCtrlNodesArr = this._bezierCtrlNodesArr; 30 | let n = bezierCtrlNodesArr.length - 1; 31 | bezierCtrlNodesArr.forEach((item, index) => { 32 | if (!index) { 33 | x += item.x * Math.pow((1 - t), n - index) * Math.pow(t, index); 34 | y += item.y * Math.pow((1 - t), n - index) * Math.pow(t, index); 35 | } else { 36 | x += this.factorial(n) / this.factorial(index) / this.factorial(n - index) * item.x * Math.pow((1 - t), n - index) * Math.pow(t, index); 37 | y += this.factorial(n) / this.factorial(index) / this.factorial(n - index) * item.y * Math.pow((1 - t), n - index) * Math.pow(t, index); 38 | } 39 | }); 40 | return { x: x, y: y }; 41 | } 42 | 43 | 44 | /** 45 | * 得到当前贝塞尔曲线上的点 46 | * @param count 需要获得的点个数 47 | */ 48 | public getBezierArr(count: number = 100) { 49 | let bezierArr = []; 50 | for (let i = 0; i < 1; i += 1 / count) { 51 | bezierArr.push(this.bezier(i)); 52 | } 53 | return bezierArr; 54 | } 55 | 56 | 57 | /** 58 | * 递归阶乘 59 | */ 60 | private factorial(num: number) { 61 | if (num <= 1) { 62 | return 1; 63 | } else { 64 | return num * this.factorial(num - 1); 65 | } 66 | } 67 | 68 | 69 | /** 70 | * 当前贝塞尔曲线上的点get(默认100个) 71 | */ 72 | get bezierArr() { 73 | if (!this._bezierArr.length) { 74 | this._bezierArr = this.getBezierArr(); 75 | } 76 | return this._bezierArr; 77 | } 78 | 79 | 80 | /** 81 | * 贝塞尔曲线控制点数组get 82 | */ 83 | get bezierCtrlNodesArr() { 84 | return this._bezierCtrlNodesArr; 85 | } 86 | 87 | 88 | /** 89 | * 贝塞尔曲线控制点数组set 90 | */ 91 | set bezierCtrlNodesArr(bezierCtrlNodesArr: Array) { 92 | bezierCtrlNodesArr.length < 2 && console.error("贝塞尔:至少传入两个点坐标"); 93 | this._bezierArr = []; 94 | this._bezierCtrlNodesArr = bezierCtrlNodesArr; 95 | } 96 | 97 | } 98 | 99 | /** 100 | * 坐标点 101 | */ 102 | export interface Point { 103 | x: number, 104 | y: number 105 | } -------------------------------------------------------------------------------- /assets/scripts/base/utils/BezierMaker.ts.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.5", 3 | "uuid": "17d039a1-370a-409f-b6cc-f4d48851b371", 4 | "isPlugin": false, 5 | "loadPluginInWeb": true, 6 | "loadPluginInNative": true, 7 | "loadPluginInEditor": false, 8 | "subMetas": {} 9 | } -------------------------------------------------------------------------------- /assets/scripts/base/utils/HttpUtil.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * HTTP工具类 3 | */ 4 | export class HttpUtil { 5 | 6 | // 请求标记,递增 7 | private static _seq: number = 1; 8 | 9 | // HTTP请求地址 10 | private static _host: string = "https://blog.liuwenkai.org"; 11 | 12 | 13 | /** 14 | * GET 15 | */ 16 | public static HttpGet(url: string, params: object, handler: Function, customData: object = null, extraHeaders: object = {}) { 17 | this.HttpRequest(url, "GET", params, handler, true, customData, extraHeaders); 18 | } 19 | 20 | 21 | /** 22 | * POST 23 | */ 24 | public static HttpPost(url: string, params: object, handler: Function, customData: object = null, extraHeaders: object = {}) { 25 | this.HttpRequest(url, "POST", params, handler, true, customData, extraHeaders); 26 | } 27 | 28 | 29 | /** 30 | * 同步的POST请求 31 | */ 32 | public static HttpPostSync(url: string, params: object, customData: object = null, extraHeaders: object = {}) { 33 | return this.HttpRequestSync(url, "GET", params, customData, extraHeaders); 34 | } 35 | 36 | 37 | /** 38 | * 同步的GET请求 39 | */ 40 | public static HttpGetPSync(url: string, params: object, customData: object = null, extraHeaders: object = {}) { 41 | return this.HttpRequestSync(url, "GET", params, customData, extraHeaders); 42 | } 43 | 44 | 45 | /** 46 | * HttpRequestSync 47 | * @param url 地址 48 | * @param mothed 方法 POST/GET 49 | * @param params 参数 50 | * @param customData 自定义数据 51 | * @param extraHeaders 临时headers 52 | */ 53 | public static HttpRequestSync(url: string, method: string, params: object, customData: object = null, extraHeaders: object = {}): Promise { 54 | return new Promise((resolve, reject) => { 55 | try { 56 | this.HttpRequest(url, method, params, (response) => { resolve(response); }, true, customData, extraHeaders); 57 | } catch (error) { 58 | reject(error); 59 | } 60 | }); 61 | } 62 | 63 | 64 | /** 65 | * HttpRequest 66 | * @param url 地址 67 | * @param mothed 方法 POST/GET 68 | * @param params 参数 69 | * @param handler 回调 70 | * @param async 是否异步请求 71 | * @param customData 自定义数据 72 | * @param extraHeaders 临时headers 73 | */ 74 | public static HttpRequest(url: string, mothed: string, params: object, handler: Function, async: boolean = false, customData: object = null, extraHeaders: object = {}) { 75 | let xhr = cc.loader.getXMLHttpRequest(); 76 | if (!/^http:\/\//.test(url) && !/^https:\/\//.test(url)) { 77 | url = this._host + url; 78 | } 79 | if (mothed == "GET") { 80 | url = url + this._encode(params); 81 | } 82 | xhr.open(mothed, url, async); 83 | xhr.timeout = 5000; 84 | this._extraHeaders(xhr, extraHeaders); 85 | mothed == "GET" && xhr.send(); 86 | mothed == "POST" && xhr.send(JSON.stringify(params)); 87 | this._registerScriptHandler(this._seq++, xhr, handler, url, mothed, params, customData); 88 | } 89 | 90 | 91 | /** 92 | * 下载文件 93 | * @param url 文件地址 94 | * @param fileName 文件保存路径 95 | * @param handler 文件下载结果回调 96 | * @param overwrite 是否覆盖同名文件 97 | */ 98 | public static HttpDownload(url: string, fileName: string, handler: Function, overwrite: boolean = false) { 99 | if (CC_JSB) { 100 | this.checkPathExist(fileName); 101 | const fullPath = jsb.fileUtils.getWritablePath() + fileName; // 文件保存路径 102 | if (jsb.fileUtils.isFileExist(fullPath) && (!overwrite)) { // 是否需要重复下载 103 | handler && handler(null, fullPath); 104 | return; 105 | } 106 | } 107 | const seq = this._seq++; 108 | const self = this; 109 | const xhr = new XMLHttpRequest(); 110 | xhr.open('GET', url, true); 111 | xhr.responseType = CC_JSB ? 'arraybuffer' : 'blob'; 112 | xhr.onload = () => { 113 | if (xhr.status == 200) { 114 | CC_JSB ? self.saveFileInNative(xhr.response, fileName, handler, overwrite) : self.saveFileInBrowser(xhr.response, fileName); 115 | cc.log(`[S->C] [Download.${seq}] -> ${url}%c success`, `color:#19A316;`); 116 | } else { 117 | cc.log(`%c[S->C] [Download.${seq}] -> ${url} failed`, `color:#f00;`); 118 | handler && handler("error", null); 119 | } 120 | }; 121 | xhr.send(); 122 | cc.log(`[C->S] [Download.${seq}] -> ${url}`); 123 | } 124 | 125 | 126 | /** 127 | * 检查文件路径是否存在,不存在则创建 128 | * @param path 相对于可写路径的路径 129 | * 例1:HttpUtil.checkPath("dir1/dir2/dir3/"); 130 | * 例2:HttpUtil.checkPath("dir1/dir2/dir3/file"); 131 | * 例1和例2等效 132 | */ 133 | public static checkPathExist(path: string) { 134 | let paths = path.split("/"); 135 | let dirPath = ""; 136 | for (let i = 0; i < paths.length - 1; i++) { 137 | const str = paths[i]; 138 | dirPath += str + "/"; 139 | if (!jsb.fileUtils.isDirectoryExist(dirPath)) { 140 | jsb.fileUtils.createDirectory(dirPath); 141 | } 142 | } 143 | return path; 144 | } 145 | 146 | 147 | /** 148 | * 保存文件 In Native 149 | * @param arrayBuffer 文件流 150 | * @param relativePath 相对路径 151 | * @param handler 保存结果回调 (error, result) => { } 152 | * @param overwrite 是否覆盖 153 | */ 154 | public static saveFileInNative(arrayBuffer: ArrayBuffer, relativePath: string, handler: Function, overwrite: boolean) { 155 | let fullPath = jsb.fileUtils.getWritablePath() + this.checkPathExist(relativePath); 156 | overwrite && jsb.fileUtils.isFileExist(fullPath) && jsb.fileUtils.removeFile(fullPath); 157 | let success = jsb.fileUtils.writeDataToFile(new Uint8Array(arrayBuffer), fullPath); 158 | if (success) { 159 | cc.log("save file data success!", fullPath); 160 | handler && handler(null, fullPath); 161 | } 162 | else { 163 | cc.log("save file data failed!", fullPath); 164 | handler && handler("error", null); 165 | } 166 | } 167 | 168 | 169 | /** 170 | * 下载文件 In Browser 171 | */ 172 | public static saveFileInBrowser(blob: Blob, fileName: string) { 173 | if (typeof window.navigator.msSaveBlob !== 'undefined') { 174 | window.navigator.msSaveBlob(blob, fileName); 175 | } else { 176 | let URL = window.URL || window[`webkitURL`] 177 | let objectUrl = URL.createObjectURL(blob); 178 | if (fileName) { 179 | var a = document.createElement('a'); 180 | if (typeof a.download === 'undefined') { 181 | (window as any).location = objectUrl; 182 | } else { 183 | a.href = objectUrl; 184 | a.download = fileName; 185 | document.body.appendChild(a); 186 | a.click(); 187 | a.remove(); 188 | } 189 | } else { 190 | (window as any).location = objectUrl; 191 | } 192 | URL.revokeObjectURL(objectUrl); 193 | } 194 | } 195 | 196 | 197 | /** 198 | * 注册网络请求事件回调 199 | * @param seq 请求sequence标记,递增 200 | * @param xhr xhr实例 201 | * @param handler 请求回调 202 | * @param url 网络请求地址 203 | * @param method 请求类型 GET POST 204 | * @param params 请求参数 205 | */ 206 | private static _registerScriptHandler(seq, xhr, handler, url, method, params, customData) { 207 | cc.log(`[C->S] [${method}.${seq}] -> ${url}`); 208 | // 失败和超时回调 209 | ['loadstart', 'abort', 'error', 'load', 'loadend', 'timeout'].forEach(function (eventname) { 210 | xhr["on" + eventname] = function () { 211 | if (eventname == "error" || eventname == "timeout") { 212 | let response: HttpResponse = { 213 | seq: seq, 214 | code: xhr.status, 215 | mothed: method, 216 | status: eventname, 217 | result: xhr.responseText, 218 | customData: customData 219 | }; 220 | CC_JSB ? 221 | cc.log(`[S->C] [${method}.${seq}] -> ${url} ${eventname} ${xhr.status}`) : 222 | cc.log(`%c[S->C] [${method}.${seq}] -> ${url} ${eventname} ${xhr.status}`, `color:#f00;`); 223 | handler && handler(response); 224 | } 225 | }; 226 | }); 227 | // 请求完成回调 228 | xhr.onreadystatechange = function () { 229 | if (xhr.readyState === 4) { 230 | // 请求成功 231 | if (((xhr.status >= 200 && xhr.status < 300) || xhr.status == 304)) { 232 | let response: HttpResponse = { 233 | seq: seq, 234 | code: xhr.status, 235 | mothed: method, 236 | status: "success", 237 | result: xhr.responseText, 238 | customData: customData 239 | }; 240 | CC_JSB ? 241 | cc.log(`[S->C] [${method}.${seq}] -> ${url} success ${xhr.status}\n${response.result}`) : 242 | cc.log(`[S->C] [${method}.${seq}] -> ${url}%c success ${xhr.status}\n%c${response.result}`, `color:#19A316;`, `color:#19A316;padding: 3px;border-radius:2px;border:1px solid #000a;`); 243 | handler && handler(response); 244 | } else { 245 | // 请求失败 246 | let response: HttpResponse = { 247 | seq: seq, 248 | code: xhr.status, 249 | mothed: method, 250 | status: "failed", 251 | errMsg: xhr.responseText, 252 | customData: customData 253 | }; 254 | CC_JSB ? 255 | cc.log(`[S->C] [${method}.${seq}] -> ${url} failed ${xhr.status} ${response.errMsg}`) : 256 | cc.log(`%c[S->C] [${method}.${seq}] -> ${url} failed ${xhr.status} ${response.errMsg}`, `color:#f00;`); 257 | handler && handler(response); 258 | } 259 | } 260 | } 261 | } 262 | 263 | 264 | /** 265 | * 将参数转为字符串GET 266 | * @param params 267 | */ 268 | private static _encode(params: object = {}): string { 269 | let str = "?"; 270 | if (params != null && params != undefined) { 271 | for (const key in params) { 272 | if (params.hasOwnProperty(key)) { 273 | str = str + key + "=" + params[key] + "&" 274 | } 275 | } 276 | } 277 | return str; 278 | } 279 | 280 | 281 | /** 282 | * 添加通用header 283 | * @param xhr XMLHttpRequest 284 | * @param extraHeaders 自定义Headers 285 | */ 286 | private static _extraHeaders(xhr: XMLHttpRequest, extraHeaders: object = {}) { 287 | // Default Headers 288 | xhr.setRequestHeader("Content-Type", "application/json"); 289 | xhr.setRequestHeader('Access-Control-Allow-Origin', '*'); 290 | // xhr.setRequestHeader('Authorization', 'Bearer ' + ""); 291 | // Extra Headers 292 | for (const key in extraHeaders) { 293 | if (extraHeaders.hasOwnProperty(key)) { 294 | const value = extraHeaders[key]; 295 | xhr.setRequestHeader(key, value); 296 | } 297 | } 298 | } 299 | 300 | } 301 | 302 | export interface HttpResponse { seq: number, code: string, mothed: string, status: string, errMsg?: string, result?: string, customData?: object } -------------------------------------------------------------------------------- /assets/scripts/base/utils/HttpUtil.ts.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.5", 3 | "uuid": "a9f8d824-6080-4b09-8cad-3a141064cbd7", 4 | "isPlugin": false, 5 | "loadPluginInWeb": true, 6 | "loadPluginInNative": true, 7 | "loadPluginInEditor": false, 8 | "subMetas": {} 9 | } -------------------------------------------------------------------------------- /assets/scripts/base/utils/polyfill.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.1", 3 | "uuid": "cd01d65d-fbd0-474c-b3ef-af1a5e5b26de", 4 | "isSubpackage": false, 5 | "subpackageName": "", 6 | "subMetas": {} 7 | } -------------------------------------------------------------------------------- /assets/scripts/base/utils/polyfill/atob&btoa.js: -------------------------------------------------------------------------------- 1 | (function (f) { 2 | 3 | 'use strict'; 4 | 5 | /* istanbul ignore else */ 6 | if (typeof exports === 'object' && exports != null && 7 | typeof exports.nodeType !== 'number') { 8 | module.exports = f(); 9 | } else if (typeof define === 'function' && define.amd != null) { 10 | define([], f); 11 | } else { 12 | var base64 = f(); 13 | // var global = typeof self !== 'undefined' ? self : $.global; 14 | var global = typeof self !== 'undefined' ? self : window; 15 | global.atob = null; 16 | global.btoa = null; 17 | if (typeof global.btoa !== 'function') { 18 | global.btoa = base64.btoa; 19 | console.log(`polyfill -> btoa`); 20 | } 21 | if (typeof global.atob !== 'function') { 22 | console.log(`polyfill -> atob`); 23 | global.atob = base64.atob; 24 | } 25 | } 26 | }(function () { 27 | 'use strict'; 28 | 29 | var chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/='; 30 | 31 | function InvalidCharacterError(message) { 32 | this.message = message; 33 | } 34 | InvalidCharacterError.prototype = new Error(); 35 | InvalidCharacterError.prototype.name = 'InvalidCharacterError'; 36 | 37 | // encoder 38 | // [https://gist.github.com/999166] by [https://github.com/nignag] 39 | function btoa(input) { 40 | var str = String(input); 41 | for ( 42 | // initialize result and counter 43 | var block, charCode, idx = 0, map = chars, output = ''; 44 | // if the next str index does not exist: 45 | // change the mapping table to "=" 46 | // check if d has no fractional digits 47 | str.charAt(idx | 0) || (map = '=', idx % 1); 48 | // "8 - idx % 1 * 8" generates the sequence 2, 4, 6, 8 49 | output += map.charAt(63 & block >> 8 - idx % 1 * 8) 50 | ) { 51 | charCode = str.charCodeAt(idx += 3 / 4); 52 | if (charCode > 0xFF) { 53 | throw new InvalidCharacterError("'btoa' failed: The string to be encoded contains characters outside of the Latin1 range."); 54 | } 55 | block = block << 8 | charCode; 56 | } 57 | return output; 58 | } 59 | 60 | // decoder 61 | // [https://gist.github.com/1020396] by [https://github.com/atk] 62 | function atob(input) { 63 | var str = (String(input)).replace(/[=]+$/, ''); // #31: ExtendScript bad parse of /= 64 | if (str.length % 4 === 1) { 65 | throw new InvalidCharacterError("'atob' failed: The string to be decoded is not correctly encoded."); 66 | } 67 | for ( 68 | // initialize result and counters 69 | var bc = 0, bs, buffer, idx = 0, output = ''; 70 | // get next character 71 | buffer = str.charAt(idx++); // eslint-disable-line no-cond-assign 72 | // character found in table? initialize bit storage and add its ascii value; 73 | ~buffer && (bs = bc % 4 ? bs * 64 + buffer : buffer, 74 | // and if not first of each 4 characters, 75 | // convert the first 8 bits to one ascii character 76 | bc++ % 4) ? output += String.fromCharCode(255 & bs >> (-2 * bc & 6)) : 0 77 | ) { 78 | // try to find character in table (0-63, not found => -1) 79 | buffer = chars.indexOf(buffer); 80 | } 81 | return output; 82 | } 83 | 84 | return { btoa: btoa, atob: atob }; 85 | 86 | })); -------------------------------------------------------------------------------- /assets/scripts/base/utils/polyfill/atob&btoa.js.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.5", 3 | "uuid": "7f2f3240-92e5-44c7-a8db-571d39355d15", 4 | "isPlugin": true, 5 | "loadPluginInWeb": true, 6 | "loadPluginInNative": true, 7 | "loadPluginInEditor": true, 8 | "subMetas": {} 9 | } -------------------------------------------------------------------------------- /assets/scripts/base/utils/polyfill/date.js: -------------------------------------------------------------------------------- 1 | Date.prototype['format'] = function (fmt) { 2 | var o = { 3 | "M+": this.getMonth() + 1, //月份 4 | "d+": this.getDate(), //日 5 | "h+": this.getHours(), //小时 6 | "m+": this.getMinutes(), //分 7 | "s+": this.getSeconds(), //秒 8 | "q+": Math.floor((this.getMonth() + 3) / 3), //季度 9 | "S": this.getMilliseconds() //毫秒 10 | }; 11 | if (/(y+)/.test(fmt)) { 12 | fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length)); 13 | } 14 | for (var k in o) { 15 | if (new RegExp("(" + k + ")").test(fmt)) { 16 | fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length))); 17 | } 18 | } 19 | return fmt; 20 | } -------------------------------------------------------------------------------- /assets/scripts/base/utils/polyfill/date.js.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.5", 3 | "uuid": "4f600b80-6112-441c-be2d-834188b9e9ff", 4 | "isPlugin": false, 5 | "loadPluginInWeb": true, 6 | "loadPluginInNative": true, 7 | "loadPluginInEditor": false, 8 | "subMetas": {} 9 | } -------------------------------------------------------------------------------- /assets/scripts/base/utils/polyfill/hotfix.js: -------------------------------------------------------------------------------- 1 | // 将版本【*.*.*】转换为数字 2 | const convertVersionNum = function (versionName) { 3 | const numArr = versionName.split(".") 4 | const baseNumArr = [10000, 100, 1]; 5 | const version = 0; 6 | numArr.forEach((num, index) => { 7 | version += num * baseNumArr[index]; 8 | }); 9 | return version; 10 | } 11 | 12 | // 比较 versionA - versionB 13 | const compareVersion = function (versionA, versionB) { 14 | return convertVersionNum(versionA) - convertVersionNum(versionB); 15 | } 16 | 17 | // --============================================================================================-- 18 | // --================================= STRAT 修复在【iOS 14】上的卡顿问题 ===========================-- 19 | 20 | const isIOS14Device = cc.sys.os === cc.sys.OS_IOS && cc.sys.isBrowser && cc.sys.isMobile && /iPhone OS 14/.test(window.navigator.userAgent); 21 | if (isIOS14Device) { 22 | // 针对大于【2.2.0】的版本 23 | if (compareVersion(cc.ENGINE_VERSION, "2.2.0") >= 0) { 24 | cc.MeshBuffer.prototype.checkAndSwitchBuffer = function (vertexCount) { 25 | if (this.vertexOffset + vertexCount > 65535) { 26 | this.uploadData(); 27 | this._batcher._flush(); 28 | } 29 | }; 30 | cc.MeshBuffer.prototype.forwardIndiceStartToOffset = function () { 31 | this.uploadData(); 32 | this.switchBuffer(); 33 | }; 34 | } 35 | // 针对【2.1.x】的版本 36 | else if (compareVersion(cc.ENGINE_VERSION, "2.0.0") >= 0) { 37 | if (compareVersion(cc.ENGINE_VERSION, "2.1.0") < 0) { 38 | cc.error("修复2.0.x在【iOS 14】上卡顿问题,无法直接hook解决,需要自定义引擎!!!"); 39 | } else { 40 | const _flush = function () { 41 | let material = this.material, 42 | buffer = this._buffer, 43 | indiceStart = buffer.indiceStart, 44 | indiceOffset = buffer.indiceOffset, 45 | indiceCount = indiceOffset - indiceStart; 46 | if (!this.walking || !material || indiceCount <= 0) { 47 | return; 48 | } 49 | 50 | let effect = material.effect; 51 | if (!effect) return; 52 | 53 | // Generate ia 54 | let ia = this._iaPool.add(); 55 | ia._vertexBuffer = buffer._vb; 56 | ia._indexBuffer = buffer._ib; 57 | ia._start = indiceStart; 58 | ia._count = indiceCount; 59 | 60 | // Generate model 61 | let model = this._modelPool.add(); 62 | this._batchedModels.push(model); 63 | model.sortKey = this._sortKey++; 64 | model._cullingMask = this.cullingMask; 65 | model.setNode(this.node); 66 | model.setEffect(effect, this.customProperties); 67 | model.setInputAssembler(ia); 68 | 69 | this._renderScene.addModel(model); 70 | 71 | if (isIOS14Device) { 72 | buffer.uploadData(); 73 | buffer.switchBuffer(); 74 | } 75 | else { 76 | buffer.byteStart = buffer.byteOffset; 77 | buffer.indiceStart = buffer.indiceOffset; 78 | buffer.vertexStart = buffer.vertexOffset; 79 | } 80 | } 81 | cc.MeshBuffer.prototype.checkAndSwitchBuffer = function (vertexCount) { 82 | if (this.vertexOffset + vertexCount > 65535) { 83 | this.uploadData(); 84 | if (!this._batcher['__fixedIOS14ANR']) { 85 | this._batcher._flush = _flush; 86 | this._batcher['__fixedIOS14ANR'] = true; 87 | } 88 | this._batcher._flush(); 89 | } 90 | }; 91 | } 92 | } 93 | } 94 | // --================================= END 修复在【iOS 14】上的卡顿问题 ===========================-- 95 | // --==========================================================================================-- 96 | -------------------------------------------------------------------------------- /assets/scripts/base/utils/polyfill/hotfix.js.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.5", 3 | "uuid": "4f600b80-6112-441c-be2d-834188b9eabs", 4 | "isPlugin": false, 5 | "loadPluginInWeb": true, 6 | "loadPluginInNative": true, 7 | "loadPluginInEditor": false, 8 | "subMetas": {} 9 | } -------------------------------------------------------------------------------- /assets/scripts/base/utils/polyfill/readme.md: -------------------------------------------------------------------------------- 1 | 所有的polyfill脚本都放在此文件夹,且以插件形式加载 -------------------------------------------------------------------------------- /assets/scripts/base/utils/polyfill/readme.md.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "2.0.0", 3 | "uuid": "167fec0c-0b66-4593-b069-2fefa922b36d", 4 | "subMetas": {} 5 | } -------------------------------------------------------------------------------- /assets/scripts/sdk.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.1", 3 | "uuid": "8c726c00-4e6b-490e-82d2-ea6f3e9bbd5c", 4 | "isSubpackage": false, 5 | "subpackageName": "", 6 | "subMetas": {} 7 | } -------------------------------------------------------------------------------- /assets/scripts/sdk/CallbackManager.ts: -------------------------------------------------------------------------------- 1 | import { CallbackHandle } from "./SdkAdapterBase"; 2 | 3 | export class CallbackManager { 4 | private _nextCallbackId = 100001; 5 | private _callbackMap: { [key: number]: CallbackHandle } = {}; 6 | private _tempCalbackMap: { [key: number]: CallbackHandle } = {}; 7 | 8 | // private static _instance: CallbackManager = null; 9 | // private constructor() { } 10 | // public static getInstance(): CallbackManager { 11 | // if (this._instance == null) { 12 | // this._instance = new CallbackManager() 13 | // } 14 | // return this._instance; 15 | // } 16 | 17 | public clearAll() { 18 | this._callbackMap = {}; 19 | this._tempCalbackMap = {}; 20 | } 21 | 22 | public doCallbackFunc(callbackId: number, result: { errCode: number, data?: any, msg?: string }) { 23 | if (callbackId == 0) { 24 | return; 25 | } 26 | const tempFunc = this._tempCalbackMap[callbackId]; 27 | if (tempFunc != null) { 28 | this._tempCalbackMap[callbackId] = null; 29 | tempFunc(result); 30 | return; 31 | } 32 | let pCallback = this._callbackMap[callbackId]; 33 | if (pCallback != null) { 34 | pCallback(result); 35 | return; 36 | } 37 | } 38 | 39 | public perm(callback: CallbackHandle): number { 40 | let callbackId = this._nextCallbackId += 1; 41 | this._callbackMap[callbackId] = callback; 42 | return callbackId; 43 | } 44 | 45 | public temp(callback: CallbackHandle): number { 46 | let callbackId = this._nextCallbackId += 1; 47 | this._tempCalbackMap[callbackId] = callback; 48 | return callbackId; 49 | } 50 | 51 | public removePerm(callbackId: number) { 52 | if (this._callbackMap[callbackId]) { 53 | this._callbackMap[callbackId] = null; 54 | } 55 | } 56 | }; -------------------------------------------------------------------------------- /assets/scripts/sdk/CallbackManager.ts.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.5", 3 | "uuid": "6a743082-703c-4b0f-9cfa-2b0d26f773be", 4 | "isPlugin": false, 5 | "loadPluginInWeb": true, 6 | "loadPluginInNative": true, 7 | "loadPluginInEditor": false, 8 | "subMetas": {} 9 | } -------------------------------------------------------------------------------- /assets/scripts/sdk/RecoderUtil.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * 分享参数 3 | */ 4 | export interface ShareParams { 5 | templateId?: string, 6 | title?: string, 7 | desc?: string, 8 | videoTopicList?: Array 9 | } 10 | 11 | /** 12 | * 录屏工具类 13 | * 支持 百度/头条 14 | */ 15 | export default class RecorderUtil { 16 | 17 | private static _instance: RecorderUtil; 18 | 19 | private _recorder = null; 20 | private _videoPath: string = null; 21 | 22 | private _shareParams: ShareParams = { 23 | title: "分享标题", 24 | desc: "分享描述", 25 | templateId: "分享模版ID", 26 | videoTopicList: ["话题1", "话题2", "话题3", "话题4"] 27 | }; 28 | 29 | get videoPath() { 30 | return this._videoPath; 31 | } 32 | 33 | get recording() { 34 | return this._recorder._recording; 35 | } 36 | 37 | get recorder() { 38 | return this._recorder; 39 | } 40 | 41 | get platform(): any { 42 | // 头条/百度 43 | return window[`tt`] || window[`swan`]; 44 | } 45 | 46 | static getInstance() { 47 | if (!this._instance) { 48 | this._instance = new RecorderUtil(); 49 | } 50 | return this._instance; 51 | } 52 | 53 | private constructor() { 54 | // 今日头条/百度 55 | if (this.platform) { 56 | // 初始化 recorder 57 | if (this.platform.getVideoRecorderManager) { 58 | this._recorder = this.platform.getVideoRecorderManager(); 59 | } else if (this.platform.getGameRecorderManager) { 60 | this._recorder = this.platform.getGameRecorderManager(); 61 | } 62 | if (!this._recorder) { 63 | return; 64 | } 65 | // 错误打印 66 | this._recorder.onError(errMsg => { 67 | console.error(errMsg); 68 | }); 69 | // 退到后台 70 | App.Utils.EventManager.on(cc.game.EVENT_HIDE, () => { 71 | this.recording && this.recorder.pause(); 72 | }, this); 73 | // 回到前台 74 | App.Utils.EventManager.on(cc.game.EVENT_HIDE, () => { 75 | this.recording && this.recorder.resume(); 76 | }, this); 77 | } 78 | } 79 | 80 | 81 | /** 82 | * 开始录屏 83 | * @param callback 开始录屏回调 84 | * @param stopCallback 自动结束录屏时回调 85 | */ 86 | startRecord(callback?: (res) => void, stopCallback?: (res) => void) { 87 | console.warn("调用开始录屏"); 88 | this.recorder && this.recorder.onStart(res => { 89 | console.warn("录屏开始", res); 90 | this.recorder._recording = true; 91 | this.recorder._st = new Date().getTime(); 92 | callback && callback(res); 93 | this.recorder.resume(); 94 | }); 95 | // 需要考虑录屏超时自动结束的问题 96 | this.recorder.onStop(res => { 97 | console.warn("录屏结束(自动)", res); 98 | this.recorder._recording = false; 99 | this.recorder._st = 0; 100 | this._videoPath = res.videoPath; 101 | // fix 头条上recoder._recording状态不对!! 102 | stopCallback && setTimeout(() => { 103 | stopCallback(res); 104 | }); 105 | }); 106 | // 默认使用最大支持时长 300s 107 | this.recorder && this.recorder.start({ duration: 300 }); 108 | } 109 | 110 | 111 | /** 112 | * 结束录屏 113 | * @param callback 结束录屏时回调 114 | */ 115 | stopRecord(callback?: (res) => void) { 116 | console.warn("调用结束录屏"); 117 | if (this.recorder) { 118 | this.recorder.resume(); 119 | if (!this.recorder._recording) { 120 | console.warn("当前录制器不处于录制中..."); 121 | callback && callback(null); 122 | return; 123 | } 124 | this.recorder.onStop(res => { 125 | console.warn("录屏结束", res); 126 | this._videoPath = res.videoPath; 127 | this.recorder._recording = false; 128 | this.recorder._st = 0; 129 | // fix 头条上recoder._recording状态不对!! 130 | callback && setTimeout(() => { 131 | callback(res); 132 | }); 133 | }); 134 | this.recorder.stop(); 135 | } else { 136 | callback && callback(null); 137 | } 138 | } 139 | 140 | 141 | /** 142 | * 分享录屏 143 | * @param isShowToast 是否展示toast 144 | * @param callback 分享结果回调 145 | * errCode 0成功 -1失败 146 | */ 147 | shareVideo(isShowToast: boolean, callback: (errCode: number) => void) { 148 | if (this.platform && this._videoPath && this._videoPath.length > 0) { 149 | this.platform.shareAppMessage({ 150 | channel: "video", 151 | templateId: this._shareParams.templateId, 152 | title: this._shareParams.title, 153 | desc: this._shareParams.desc, 154 | extra: { 155 | videoPath: this._videoPath, // 可替换成录屏得到的视频地址 156 | videoTopics: this._shareParams.videoTopicList 157 | }, 158 | success: () => { 159 | console.log("分享视频成功"); 160 | callback && callback(0); 161 | }, 162 | fail: (e) => { 163 | console.log("分享视频失败:'" + e.errMsg + "'", e); 164 | switch (e.errMsg) { 165 | case "shareAppMessage:fail video file is too short": 166 | isShowToast && this.showToast(`录制时间太短~`); 167 | break; 168 | case "shareAppMessage:cancel": 169 | case "shareAppMessage:fail publish fail": 170 | // isShowToast && this.showToast(`分享取消`); 171 | break; 172 | default: 173 | if (e.errMsg.match(`shareAppMessage:fail unknown error on method onFail`)) { 174 | // this.showToast(`录制时间太短~`); 175 | } else { 176 | isShowToast && this.showToast(`录制时间太短~`); 177 | } 178 | break; 179 | } 180 | callback && callback(-1); 181 | } 182 | }); 183 | } else { 184 | this.showToast("录制时间太短~"); 185 | } 186 | } 187 | 188 | 189 | showToast(title: string, duration: number = 2000) { 190 | this.platform && this.platform.showToast({ 191 | icon: 'none', 192 | title: title, 193 | duration: duration, 194 | success(res) { 195 | console.log(`${res}`); 196 | }, 197 | fail(res) { 198 | console.log(`showToast调用失败`); 199 | } 200 | }); 201 | } 202 | 203 | } 204 | 205 | window['RecorderUtil'] = RecorderUtil.getInstance(); -------------------------------------------------------------------------------- /assets/scripts/sdk/RecoderUtil.ts.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.5", 3 | "uuid": "3c4f0748-b99e-4208-9697-b77f7ff27feb", 4 | "isPlugin": false, 5 | "loadPluginInWeb": true, 6 | "loadPluginInNative": true, 7 | "loadPluginInEditor": false, 8 | "subMetas": {} 9 | } -------------------------------------------------------------------------------- /assets/scripts/sdk/SdkAdapterBase.ts: -------------------------------------------------------------------------------- 1 | 2 | export interface CallbackHandle { (result: { errCode: number, data?: any, msg?: string }): void; } 3 | 4 | export abstract class SdkAdapterBase { 5 | 6 | /** 7 | * 打开网页地址 8 | * @param url 9 | */ 10 | abstract openURL(url: string); 11 | 12 | /** 13 | * 打开外部应用 14 | * @param packageName 15 | */ 16 | abstract openApp(packageName: string); 17 | 18 | /** 19 | * 振动 20 | * @param type 0短振动 1长振动 21 | * @param duration 持续时间(仅在Android平台生效) 22 | */ 23 | abstract vibrate(type: number, duration?: number) 24 | 25 | /** 26 | * 复制文本到剪切板 27 | * @param text 28 | */ 29 | abstract copyToClipboard(text: string); 30 | 31 | /** 32 | * 展示插屏广告 33 | */ 34 | abstract showInsertAd(); 35 | 36 | /** 37 | * 展示横幅广告 38 | * @param isShow 39 | */ 40 | abstract showBannerAd(isShow: boolean); 41 | 42 | /** 43 | * 展示激励视频广告 44 | * @param videoId 45 | * @param callback 46 | */ 47 | abstract showVideoAd(videoId: string, callback: CallbackHandle); 48 | 49 | /** 50 | * 开始录屏 51 | * @param callback 开始录屏回调 52 | * @param stopCallback 结束录屏默认回调 53 | */ 54 | abstract startRecord(callback: Function, stopCallback: Function); 55 | 56 | /** 57 | * 结束录屏 58 | * @param callback 结束录屏回调 59 | */ 60 | abstract stopRecord(callback: Function); 61 | 62 | 63 | /** 64 | * 调用Java静态方法(Android) 65 | * @param className 类全名 66 | * @param methodNmae 方法名 67 | * @param paramType Java类型签名 68 | * int -> I 69 | * float -> F 70 | * boolean -> Z 71 | * string -> Ljava/lang/String; 72 | * @param params 参数 73 | */ 74 | public callJavaStaticFunc(className: string, methodNmae: string, paramTypeSignatures: string, ...params) { 75 | if (cc.sys.isNative && cc.sys.platform == cc.sys.ANDROID) { 76 | return jsb.reflection.callStaticMethod(className, methodNmae, paramTypeSignatures, ...params); 77 | } 78 | } 79 | 80 | 81 | /** 82 | * 调用OC静态方法(IOS) 83 | * @param className 类全名 84 | * @param methodNmae 方法名 85 | * @param params 参数 86 | */ 87 | public callOcStaticFunc(className: string, methodNmae: string, ...params) { 88 | if (cc.sys.isNative && (cc.sys.platform == cc.sys.IPHONE || cc.sys.platform == cc.sys.IPAD)) { 89 | return jsb.reflection.callStaticMethod(className, methodNmae, ...params); 90 | } 91 | } 92 | } -------------------------------------------------------------------------------- /assets/scripts/sdk/SdkAdapterBase.ts.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.5", 3 | "uuid": "c5056b55-1be4-4583-b60b-bbbc824b2635", 4 | "isPlugin": false, 5 | "loadPluginInWeb": true, 6 | "loadPluginInNative": true, 7 | "loadPluginInEditor": false, 8 | "subMetas": {} 9 | } -------------------------------------------------------------------------------- /assets/scripts/sdk/SdkManager.ts: -------------------------------------------------------------------------------- 1 | import { SdkAdapterBase } from "./SdkAdapterBase"; 2 | import { IOSAdapter } from "./platform/IOSAdapter"; 3 | import { AndroidAdapter } from "./platform/AndroidAdapter"; 4 | import { DefaultAdapter } from "./platform/DefaultAdapter"; 5 | 6 | 7 | export class SdkManager { 8 | 9 | private _adapter: SdkAdapterBase; 10 | 11 | // private static _instance: AdapterManager; 12 | 13 | constructor() { 14 | this.init(); 15 | } 16 | 17 | 18 | // 获取适配器 19 | get adapter() { 20 | return this._adapter; 21 | } 22 | 23 | 24 | // /** 25 | // * 获取单例 26 | // */ 27 | // static getInstance(): AdapterManager { 28 | // if (!AdapterManager._instance) { 29 | // AdapterManager._instance = new AdapterManager(); 30 | // } 31 | // return this._instance; 32 | // } 33 | 34 | 35 | /** 36 | * 初始化参数 37 | */ 38 | private init() { 39 | switch (cc.sys.platform) { 40 | // TODO 小游戏平台需要添加到 Android/iOS/iPad 之前 41 | case cc.sys.ANDROID: 42 | this._adapter = new AndroidAdapter(); 43 | break; 44 | 45 | case cc.sys.IPAD: 46 | case cc.sys.IPHONE: 47 | this._adapter = new IOSAdapter(); 48 | break; 49 | 50 | default: 51 | this._adapter = new DefaultAdapter(); 52 | break; 53 | } 54 | } 55 | 56 | } 57 | -------------------------------------------------------------------------------- /assets/scripts/sdk/SdkManager.ts.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.5", 3 | "uuid": "e4bb4b64-eca1-4f27-af50-d163309c493c", 4 | "isPlugin": false, 5 | "loadPluginInWeb": true, 6 | "loadPluginInNative": true, 7 | "loadPluginInEditor": false, 8 | "subMetas": {} 9 | } -------------------------------------------------------------------------------- /assets/scripts/sdk/platform.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.1", 3 | "uuid": "46a9d88d-5db8-4cd7-b5e2-585a32e31d31", 4 | "isSubpackage": false, 5 | "subpackageName": "", 6 | "subMetas": {} 7 | } -------------------------------------------------------------------------------- /assets/scripts/sdk/platform/AndroidAdapter.ts: -------------------------------------------------------------------------------- 1 | import { SdkAdapterBase, CallbackHandle } from "../SdkAdapterBase"; 2 | 3 | export class AndroidAdapter extends SdkAdapterBase { 4 | 5 | openURL(url: string) { 6 | } 7 | 8 | openApp(packageName: string) { 9 | } 10 | 11 | vibrate(type: number, duration?: number) { 12 | } 13 | 14 | copyToClipboard(text: string) { 15 | } 16 | 17 | showInsertAd() { 18 | } 19 | 20 | showBannerAd(isShow: boolean) { 21 | } 22 | 23 | showVideoAd(videoId: string, callback: CallbackHandle) { 24 | } 25 | 26 | startRecord(callback: Function, stopCallback: Function) { 27 | } 28 | 29 | stopRecord(callback: Function) { 30 | } 31 | 32 | } -------------------------------------------------------------------------------- /assets/scripts/sdk/platform/AndroidAdapter.ts.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.5", 3 | "uuid": "4417945e-6c18-4fe3-8ce9-e9a4fb17bfca", 4 | "isPlugin": false, 5 | "loadPluginInWeb": true, 6 | "loadPluginInNative": true, 7 | "loadPluginInEditor": false, 8 | "subMetas": {} 9 | } -------------------------------------------------------------------------------- /assets/scripts/sdk/platform/DefaultAdapter.ts: -------------------------------------------------------------------------------- 1 | import { SdkAdapterBase, CallbackHandle } from "../SdkAdapterBase"; 2 | 3 | export class DefaultAdapter extends SdkAdapterBase { 4 | 5 | openURL(url: string) { 6 | } 7 | 8 | openApp(packageName: string) { 9 | } 10 | 11 | vibrate(type: number, duration?: number) { 12 | } 13 | 14 | copyToClipboard(text: string) { 15 | } 16 | 17 | showInsertAd() { 18 | } 19 | 20 | showBannerAd(isShow: boolean) { 21 | } 22 | 23 | showVideoAd(videoId: string, callback: CallbackHandle) { 24 | } 25 | 26 | startRecord(callback: Function, stopCallback: Function) { 27 | } 28 | 29 | stopRecord(callback: Function) { 30 | } 31 | 32 | } -------------------------------------------------------------------------------- /assets/scripts/sdk/platform/DefaultAdapter.ts.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.5", 3 | "uuid": "3db79caa-990e-437d-b820-2ca28e292bec", 4 | "isPlugin": false, 5 | "loadPluginInWeb": true, 6 | "loadPluginInNative": true, 7 | "loadPluginInEditor": false, 8 | "subMetas": {} 9 | } -------------------------------------------------------------------------------- /assets/scripts/sdk/platform/IOSAdapter.ts: -------------------------------------------------------------------------------- 1 | import { SdkAdapterBase, CallbackHandle } from "../SdkAdapterBase"; 2 | 3 | export class IOSAdapter extends SdkAdapterBase { 4 | 5 | openURL(url: string) { 6 | } 7 | 8 | openApp(packageName: string) { 9 | } 10 | 11 | vibrate(type: number, duration?: number) { 12 | } 13 | 14 | copyToClipboard(text: string) { 15 | } 16 | 17 | showInsertAd() { 18 | } 19 | 20 | showBannerAd(isShow: boolean) { 21 | } 22 | 23 | showVideoAd(videoId: string, callback: CallbackHandle) { 24 | } 25 | 26 | startRecord(callback: Function, stopCallback: Function) { 27 | } 28 | 29 | stopRecord(callback: Function) { 30 | } 31 | 32 | } -------------------------------------------------------------------------------- /assets/scripts/sdk/platform/IOSAdapter.ts.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.5", 3 | "uuid": "564e2a1a-b833-46f4-96ee-fbc1d379db10", 4 | "isPlugin": false, 5 | "loadPluginInWeb": true, 6 | "loadPluginInNative": true, 7 | "loadPluginInEditor": false, 8 | "subMetas": {} 9 | } -------------------------------------------------------------------------------- /assets/scripts/sdk/platform/h5.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.1", 3 | "uuid": "41936732-7fd5-40b6-8bbb-e227a53f123a", 4 | "isSubpackage": false, 5 | "subpackageName": "", 6 | "subMetas": {} 7 | } -------------------------------------------------------------------------------- /assets/scripts/sdk/platform/h5/BaiduAdapter.ts: -------------------------------------------------------------------------------- 1 | import { SdkAdapterBase, CallbackHandle } from "../../SdkAdapterBase"; 2 | 3 | export class DefaultAdapter extends SdkAdapterBase { 4 | 5 | openURL(url: string) { 6 | } 7 | 8 | openApp(packageName: string) { 9 | } 10 | 11 | vibrate(type: number, duration?: number) { 12 | } 13 | 14 | copyToClipboard(text: string) { 15 | } 16 | 17 | showInsertAd() { 18 | } 19 | 20 | showBannerAd(isShow: boolean) { 21 | } 22 | 23 | showVideoAd(videoId: string, callback: CallbackHandle) { 24 | } 25 | 26 | startRecord(callback: Function, stopCallback: Function) { 27 | } 28 | 29 | stopRecord(callback: Function) { 30 | } 31 | 32 | } -------------------------------------------------------------------------------- /assets/scripts/sdk/platform/h5/BaiduAdapter.ts.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.5", 3 | "uuid": "40b56835-1cea-4884-af76-0ed03595876f", 4 | "isPlugin": false, 5 | "loadPluginInWeb": true, 6 | "loadPluginInNative": true, 7 | "loadPluginInEditor": false, 8 | "subMetas": {} 9 | } -------------------------------------------------------------------------------- /assets/scripts/sdk/platform/h5/OppoAdapter.ts: -------------------------------------------------------------------------------- 1 | import { SdkAdapterBase, CallbackHandle } from "../../SdkAdapterBase"; 2 | 3 | export class DefaultAdapter extends SdkAdapterBase { 4 | 5 | openURL(url: string) { 6 | } 7 | 8 | openApp(packageName: string) { 9 | } 10 | 11 | vibrate(type: number, duration?: number) { 12 | } 13 | 14 | copyToClipboard(text: string) { 15 | } 16 | 17 | showInsertAd() { 18 | } 19 | 20 | showBannerAd(isShow: boolean) { 21 | } 22 | 23 | showVideoAd(videoId: string, callback: CallbackHandle) { 24 | } 25 | 26 | startRecord(callback: Function, stopCallback: Function) { 27 | } 28 | 29 | stopRecord(callback: Function) { 30 | } 31 | 32 | } -------------------------------------------------------------------------------- /assets/scripts/sdk/platform/h5/OppoAdapter.ts.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.5", 3 | "uuid": "45cde38d-d614-4e4e-85c2-1a14dbc78928", 4 | "isPlugin": false, 5 | "loadPluginInWeb": true, 6 | "loadPluginInNative": true, 7 | "loadPluginInEditor": false, 8 | "subMetas": {} 9 | } -------------------------------------------------------------------------------- /assets/scripts/sdk/platform/h5/QQAdapter.ts: -------------------------------------------------------------------------------- 1 | import { SdkAdapterBase, CallbackHandle } from "../../SdkAdapterBase"; 2 | 3 | export class DefaultAdapter extends SdkAdapterBase { 4 | 5 | openURL(url: string) { 6 | } 7 | 8 | openApp(packageName: string) { 9 | } 10 | 11 | vibrate(type: number, duration?: number) { 12 | } 13 | 14 | copyToClipboard(text: string) { 15 | } 16 | 17 | showInsertAd() { 18 | } 19 | 20 | showBannerAd(isShow: boolean) { 21 | } 22 | 23 | showVideoAd(videoId: string, callback: CallbackHandle) { 24 | } 25 | 26 | startRecord(callback: Function, stopCallback: Function) { 27 | } 28 | 29 | stopRecord(callback: Function) { 30 | } 31 | 32 | } -------------------------------------------------------------------------------- /assets/scripts/sdk/platform/h5/QQAdapter.ts.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.5", 3 | "uuid": "9f92c7ac-733c-4599-bcf6-f267cee10451", 4 | "isPlugin": false, 5 | "loadPluginInWeb": true, 6 | "loadPluginInNative": true, 7 | "loadPluginInEditor": false, 8 | "subMetas": {} 9 | } -------------------------------------------------------------------------------- /assets/scripts/sdk/platform/h5/ToutiaoAdapter.ts: -------------------------------------------------------------------------------- 1 | import { SdkAdapterBase, CallbackHandle } from "../../SdkAdapterBase"; 2 | 3 | export class DefaultAdapter extends SdkAdapterBase { 4 | 5 | openURL(url: string) { 6 | } 7 | 8 | openApp(packageName: string) { 9 | } 10 | 11 | vibrate(type: number, duration?: number) { 12 | } 13 | 14 | copyToClipboard(text: string) { 15 | } 16 | 17 | showInsertAd() { 18 | } 19 | 20 | showBannerAd(isShow: boolean) { 21 | } 22 | 23 | showVideoAd(videoId: string, callback: CallbackHandle) { 24 | } 25 | 26 | startRecord(callback: Function, stopCallback: Function) { 27 | } 28 | 29 | stopRecord(callback: Function) { 30 | } 31 | 32 | } -------------------------------------------------------------------------------- /assets/scripts/sdk/platform/h5/ToutiaoAdapter.ts.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.5", 3 | "uuid": "a6d32ec0-d06c-4910-84a4-8b8e2db82362", 4 | "isPlugin": false, 5 | "loadPluginInWeb": true, 6 | "loadPluginInNative": true, 7 | "loadPluginInEditor": false, 8 | "subMetas": {} 9 | } -------------------------------------------------------------------------------- /assets/scripts/sdk/platform/h5/VivoAdapter.ts: -------------------------------------------------------------------------------- 1 | import { SdkAdapterBase, CallbackHandle } from "../../SdkAdapterBase"; 2 | 3 | export class DefaultAdapter extends SdkAdapterBase { 4 | 5 | openURL(url: string) { 6 | } 7 | 8 | openApp(packageName: string) { 9 | } 10 | 11 | vibrate(type: number, duration?: number) { 12 | } 13 | 14 | copyToClipboard(text: string) { 15 | } 16 | 17 | showInsertAd() { 18 | } 19 | 20 | showBannerAd(isShow: boolean) { 21 | } 22 | 23 | showVideoAd(videoId: string, callback: CallbackHandle) { 24 | } 25 | 26 | startRecord(callback: Function, stopCallback: Function) { 27 | } 28 | 29 | stopRecord(callback: Function) { 30 | } 31 | 32 | } -------------------------------------------------------------------------------- /assets/scripts/sdk/platform/h5/VivoAdapter.ts.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.5", 3 | "uuid": "d8d18419-4b5a-4937-9275-7a39e6e92d03", 4 | "isPlugin": false, 5 | "loadPluginInWeb": true, 6 | "loadPluginInNative": true, 7 | "loadPluginInEditor": false, 8 | "subMetas": {} 9 | } -------------------------------------------------------------------------------- /assets/scripts/sdk/platform/h5/WechatAdapter.ts: -------------------------------------------------------------------------------- 1 | import { SdkAdapterBase, CallbackHandle } from "../../SdkAdapterBase"; 2 | 3 | export class DefaultAdapter extends SdkAdapterBase { 4 | 5 | openURL(url: string) { 6 | } 7 | 8 | openApp(packageName: string) { 9 | } 10 | 11 | vibrate(type: number, duration?: number) { 12 | } 13 | 14 | copyToClipboard(text: string) { 15 | } 16 | 17 | showInsertAd() { 18 | } 19 | 20 | showBannerAd(isShow: boolean) { 21 | } 22 | 23 | showVideoAd(videoId: string, callback: CallbackHandle) { 24 | } 25 | 26 | startRecord(callback: Function, stopCallback: Function) { 27 | } 28 | 29 | stopRecord(callback: Function) { 30 | } 31 | 32 | } -------------------------------------------------------------------------------- /assets/scripts/sdk/platform/h5/WechatAdapter.ts.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.5", 3 | "uuid": "2c48ffc0-0946-41b3-9020-e6bb9d8198ae", 4 | "isPlugin": false, 5 | "loadPluginInWeb": true, 6 | "loadPluginInNative": true, 7 | "loadPluginInEditor": false, 8 | "subMetas": {} 9 | } -------------------------------------------------------------------------------- /assets/scripts/settings.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.1", 3 | "uuid": "949fa6c4-b81b-4792-9151-2f9b1e7c861e", 4 | "isSubpackage": false, 5 | "subpackageName": "", 6 | "subMetas": {} 7 | } -------------------------------------------------------------------------------- /assets/scripts/settings/settings.js: -------------------------------------------------------------------------------- 1 | cc.game.on(cc.game.EVENT_ENGINE_INITED, () => { 2 | // const physicsManager = cc.director.getPhysicsManager(); 3 | // physicsManager.enabled = true; 4 | // physicsManager.enabledAccumulator = true; 5 | // // cc.PhysicsManager.FIXED_TIME_STEP = 1 / 60; 6 | // physicsManager.debugDrawFlags = 7 | // // // 0; 8 | // // cc.PhysicsManager.DrawBits.e_aabbBit | 9 | // cc.PhysicsManager.DrawBits.e_jointBit | 10 | // cc.PhysicsManager.DrawBits.e_shapeBit 11 | // ; 12 | 13 | // const collisioManager = cc.director.getCollisionManager(); 14 | // collisioManager.enabled = true; 15 | // // collisioManager.enabledDebugDraw = true; 16 | }); -------------------------------------------------------------------------------- /assets/scripts/settings/settings.js.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.5", 3 | "uuid": "1b4b4b96-f5bf-4035-a2eb-b31eb69f8c60", 4 | "isPlugin": true, 5 | "loadPluginInWeb": true, 6 | "loadPluginInNative": true, 7 | "loadPluginInEditor": false, 8 | "subMetas": {} 9 | } -------------------------------------------------------------------------------- /assets/textures.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.1", 3 | "uuid": "66665aa7-b7d8-4dfe-9484-a315f58bd2a2", 4 | "isSubpackage": false, 5 | "subpackageName": "", 6 | "subMetas": {} 7 | } -------------------------------------------------------------------------------- /assets/textures/common.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.1", 3 | "uuid": "1177ffd2-0b3f-4b57-ba2b-8e14e1cb8969", 4 | "isSubpackage": false, 5 | "subpackageName": "", 6 | "subMetas": {} 7 | } -------------------------------------------------------------------------------- /assets/textures/common/default.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liuwenkai1023/ccc-frameworks/17851b2c22240e343fb7335c148aec8f75c0fb16/assets/textures/common/default.png -------------------------------------------------------------------------------- /assets/textures/common/default.png.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "2.3.3", 3 | "uuid": "0f8d7335-17ed-47da-9132-d457bfbd549e", 4 | "type": "sprite", 5 | "wrapMode": "clamp", 6 | "filterMode": "point", 7 | "premultiplyAlpha": false, 8 | "genMipmaps": false, 9 | "packable": true, 10 | "platformSettings": {}, 11 | "subMetas": { 12 | "default": { 13 | "ver": "1.0.4", 14 | "uuid": "adfd681c-6d64-4cbf-97e9-fd00b7c7ca9b", 15 | "rawTextureUuid": "0f8d7335-17ed-47da-9132-d457bfbd549e", 16 | "trimType": "auto", 17 | "trimThreshold": 1, 18 | "rotated": false, 19 | "offsetX": 0, 20 | "offsetY": 1, 21 | "trimX": 2, 22 | "trimY": 2, 23 | "width": 252, 24 | "height": 250, 25 | "rawWidth": 256, 26 | "rawHeight": 256, 27 | "borderTop": 0, 28 | "borderBottom": 0, 29 | "borderLeft": 0, 30 | "borderRight": 0, 31 | "subMetas": {} 32 | } 33 | } 34 | } -------------------------------------------------------------------------------- /assets/textures/common/singleColor.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liuwenkai1023/ccc-frameworks/17851b2c22240e343fb7335c148aec8f75c0fb16/assets/textures/common/singleColor.png -------------------------------------------------------------------------------- /assets/textures/common/singleColor.png.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "2.3.3", 3 | "uuid": "77db6770-de63-4e98-89df-375159ad9742", 4 | "type": "sprite", 5 | "wrapMode": "clamp", 6 | "filterMode": "bilinear", 7 | "premultiplyAlpha": false, 8 | "genMipmaps": false, 9 | "packable": true, 10 | "platformSettings": {}, 11 | "subMetas": { 12 | "singleColor": { 13 | "ver": "1.0.4", 14 | "uuid": "b559484e-3873-4afa-bec7-c70334465c27", 15 | "rawTextureUuid": "77db6770-de63-4e98-89df-375159ad9742", 16 | "trimType": "auto", 17 | "trimThreshold": 1, 18 | "rotated": false, 19 | "offsetX": 0, 20 | "offsetY": 0, 21 | "trimX": 0, 22 | "trimY": 0, 23 | "width": 2, 24 | "height": 2, 25 | "rawWidth": 2, 26 | "rawHeight": 2, 27 | "borderTop": 0, 28 | "borderBottom": 0, 29 | "borderLeft": 0, 30 | "borderRight": 0, 31 | "subMetas": {} 32 | } 33 | } 34 | } -------------------------------------------------------------------------------- /jsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es6", 4 | "module": "commonjs", 5 | "experimentalDecorators": true 6 | }, 7 | "exclude": [ 8 | "node_modules", 9 | ".vscode", 10 | "library", 11 | "local", 12 | "settings", 13 | "temp" 14 | ] 15 | } -------------------------------------------------------------------------------- /project.json: -------------------------------------------------------------------------------- 1 | { 2 | "engine": "cocos2d-html5", 3 | "packages": "packages", 4 | "version": "2.2.2", 5 | "id": "511cf5b8-1652-4193-98bc-3e21970a9f00" 6 | } -------------------------------------------------------------------------------- /readme.md: -------------------------------------------------------------------------------- 1 | # 基于Cocos Creater的游戏框架 2 | 3 | 4 | ### 框架介绍 5 | 6 | - 框架核心模块包含界面、事件、数据、音频、调度和存储管理器 7 | - 框架提供类似cocos2dx-lua中mvc模块,方便界面管理 8 | - 框架把常用操作和模块封装到基础组件,减少额外操作 9 | - 框架提供截图、界面适配、热更组件等常用组件 10 | - 框架提供网络请求、Base64加密、贝塞尔曲线运动计算等常用工具类 11 | - 框架支持不同平台sdk的快速适配(适配器模式) 12 | 13 | ### 框架目录 14 | ``` 15 | assets 16 | ├── resources #动态加载资源目录 17 | │   ├── configs #配置文件目录 18 | │   ├── prefabs #预制体目录 19 | │   ├── sounds #音频文件目录 20 | │   ├── textures #纹理资源目录 21 | │   ├── ... 22 | ├── scripts #脚本目录 23 | │   ├── app #游戏逻辑目录 24 | │   ├── base #框架主目录 25 | │   │   ├── components #框架自带的组件 26 | │   │   ├── core #框架的核心文件 27 | │   │   │   ├── audio #音频管理器 28 | │   │   │   ├── data #数据管理器 29 | │   │   │   ├── event #事件管理器 30 | │   │   │   ├── mvc #mvc(类似2dx-lua那一套) 31 | │   │   │   ├── storage #本地存储管理器 32 | │   │   │   ├── timer #调度管理器 33 | │   │   ├── extensions #扩展目录(按需添加或移除扩展即可) 34 | │   │   │   ├── expr-eval #表达式插件 35 | │   │   │   ├── fgui #fgui扩展 36 | │   │   │   ├── pako #gzip压缩插件 37 | │   │   │   ├── protobuf #protobuf插件 38 | │   │   │   ├── shader #shader扩展(暂时移除) 39 | │   │   │   ├── qrcode #二维码插件 40 | │   │   │   │   ├──components #对应二维码绘制组件目录(其它扩展同理) 41 | │   │   │   ├── ... 42 | │   │   ├── utils #工具类目录 43 | │   │   │   ├── polyfill #用作补丁,将某些平台不支持但又需要用到的功能以js插件形式引入 44 | │   ├── sdk #sdk-adapter,用于不同平台适配 45 | ├── settings #伴随引擎启动进行设置更改 46 | ├── textures #非动态加载资源目录 47 | ``` 48 | 49 | ### 框架附带组件 50 | - BaseComponent `基础组件` `建议继承` 51 | - ViewBase `mvc基础组件` 52 | - FitUI `ui适配组件` 53 | - ScreenCapture `截图组件` 54 | - ~~ShaderSprite~~ `扩展组件` 55 | - QRCode `扩展组件` 56 | 57 | ### 框架附带工具 58 | - excel 配置打表工具(配套框架中的数据管理器 DataManager) 59 | - protobuf-tools 用于生成*.proto对应的提示文件等 60 | - 热更新版本构建工具 61 | 62 | ### 附言 63 | 不要问有没有详细文档,没有,也不需要。打开AppStart场景即可运行,入口脚本同场景名,使用和示例相对简单。 64 | 看不懂请先移步[ Cocos Creator 用户手册](https://docs.cocos.com/creator/2.2/manual/zh/)。 65 | -------------------------------------------------------------------------------- /settings/builder.json: -------------------------------------------------------------------------------- 1 | { 2 | "encryptJs": false, 3 | "excludeScenes": [], 4 | "fb-instant-games": {}, 5 | "includeSDKBox": false, 6 | "inlineSpriteFrames": true, 7 | "inlineSpriteFrames_native": false, 8 | "md5Cache": true, 9 | "mergeStartScene": false, 10 | "optimizeHotUpdate": false, 11 | "orientation": { 12 | "landscapeLeft": false, 13 | "landscapeRight": false, 14 | "portrait": true, 15 | "upsideDown": false 16 | }, 17 | "packageName": "org.liuwenkai.project2", 18 | "qqplay": { 19 | "REMOTE_SERVER_ROOT": "", 20 | "orientation": "portrait" 21 | }, 22 | "startScene": "fd830f1b-8e80-4223-a2f0-53865788f5ce", 23 | "title": "project", 24 | "webOrientation": "auto", 25 | "wechatgame": { 26 | "REMOTE_SERVER_ROOT": "", 27 | "appid": "wx171b511bd9a4ace7", 28 | "isSubdomain": false, 29 | "orientation": "portrait", 30 | "subContext": "" 31 | }, 32 | "xxteaKey": "f12bde3d-3b11-4a", 33 | "zipCompressJs": true, 34 | "baidugame": { 35 | "appid": "testappid", 36 | "orientation": "portrait", 37 | "REMOTE_SERVER_ROOT": "", 38 | "subContext": "" 39 | }, 40 | "android-instant": { 41 | "REMOTE_SERVER_ROOT": "", 42 | "pathPattern": "", 43 | "scheme": "https", 44 | "host": "", 45 | "skipRecord": false, 46 | "recordPath": "" 47 | }, 48 | "appBundle": false 49 | } -------------------------------------------------------------------------------- /settings/builder.panel.json: -------------------------------------------------------------------------------- 1 | { 2 | "excludeScenes": [], 3 | "packageName": "org.liuwenkai.project", 4 | "platform": "web-mobile", 5 | "startScene": "2d2f792f-a40c-49bb-a189-ed176a246e49", 6 | "title": "project" 7 | } -------------------------------------------------------------------------------- /settings/project.json: -------------------------------------------------------------------------------- 1 | { 2 | "collision-matrix": [ 3 | [ 4 | true 5 | ] 6 | ], 7 | "design-resolution-height": 1280, 8 | "design-resolution-width": 720, 9 | "excluded-modules": [ 10 | "Geom Utils", 11 | "3D", 12 | "3D Primitive" 13 | ], 14 | "fit-height": true, 15 | "fit-width": true, 16 | "group-list": [ 17 | "default" 18 | ], 19 | "simulator-orientation": false, 20 | "simulator-resolution": { 21 | "height": 640, 22 | "width": 960 23 | }, 24 | "start-scene": "current", 25 | "use-customize-simulator": false, 26 | "use-project-simulator-setting": false, 27 | "last-module-event-record-time": 0, 28 | "assets-sort-type": "name", 29 | "facebook": { 30 | "enable": false, 31 | "appID": "", 32 | "live": { 33 | "enable": false 34 | }, 35 | "audience": { 36 | "enable": false 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /settings/services.json: -------------------------------------------------------------------------------- 1 | { 2 | "services": [ 3 | { 4 | "service_id": "235", 5 | "service_name": "Cocos Analytics", 6 | "service_icon": "https://account.cocos.com/client/3f8f31ccf66995e183044f167c092395.png", 7 | "service_desc": "提供最核心最基本的数据、标准化界面功能简洁易用、数据准确性最好", 8 | "service_title": "精准了解游戏的新增、活跃、留存、付费等数据", 9 | "service_guide_url": "https://n-analytics.cocos.com/docs/", 10 | "service_sample_url": "https://github.com/cocos-creator/tutorial-dark-slash/tree/analytics", 11 | "service_dev_url": "http://analytics.cocos.com/realtime/jump_to/", 12 | "service_type": "3", 13 | "service_type_zh": "公司和个人游戏", 14 | "support_platform": [ 15 | "Android", 16 | "iOS", 17 | "HTML5" 18 | ], 19 | "package_download_url": "https://download.cocos.com/CocosServices/plugins/service-analytics/1.2.5_2.1.1.zip", 20 | "package_version_desc": "

更新日期: 2020/03/05
\n更新说明:
\n1、修复小米快游戏的集成问题
\n2、新增趣头条、支付宝小游戏和 Cocos Play 的适配
\n3、添加参数自动保存,插件自动加载功能
\n", 21 | "service_component_name": "service-analytics", 22 | "package_versions": [ 23 | "1.2.5_2.1.1", 24 | "1.2.3_2.1.1", 25 | "1.2.0_2.1.0", 26 | "1.1.7_2.0.3", 27 | "1.1.6_2.0.1_2.0.2", 28 | "1.1.5_2.0.1", 29 | "1.1.4_2.0.1", 30 | "1.1.3_2.0.1", 31 | "1.1.2_2.0.0", 32 | "1.0.0_1.0.5" 33 | ], 34 | "build_platform": [], 35 | "require_verify": 0, 36 | "service_price": "", 37 | "service_protocol": "游戏首次开启该服务时,Cocos会后台通知服务方为游戏开通服务并初始化参数,服务方根据需要可能会获取您的Cocos账户信息,包括账户基本资料、游戏基本资料、账户余额等,点击确认开通按钮即视为您同意该服务访问您的账户信息,详见《Cocos用户服务协议》《Cocos隐私政策》" 38 | }, 39 | { 40 | "service_id": "241", 41 | "service_name": "Matchvs", 42 | "service_icon": "https://account.cocos.com/client/14406719a07eb3d714d36e5edc6e06fa.png", 43 | "service_desc": "通过SDK接入快速实现联网功能、帧同步、国内外多节点、服务器独立部署、gameServer自定义游戏服务端逻辑。", 44 | "service_title": "专业成熟的移动游戏联网与服务端解决方案", 45 | "service_guide_url": "http://doc.matchvs.com/QuickStart/QuickStart-CocosCreator", 46 | "service_sample_url": "http://www.matchvs.com/serviceCourse", 47 | "service_dev_url": "http://www.matchvs.com/cocosLogin", 48 | "service_type": "3", 49 | "service_type_zh": "公司和个人游戏", 50 | "support_platform": [ 51 | "Android", 52 | "iOS", 53 | "HTML5" 54 | ], 55 | "package_download_url": "https://download.cocos.com/CocosServices/plugins/service-matchvs/1.0.10_3.7.9.10.zip", 56 | "package_version_desc": "

更新日期: 2019/9/12\n更新内容:\n1.多语言支持\n2.SDK日常更新

", 57 | "service_component_name": "service-matchvs", 58 | "package_versions": [ 59 | "1.0.9_3.7.9.9", 60 | "1.0.7_3.7.9.6", 61 | "1.0.6_3.7.9.2", 62 | "1.0.5_3.7.7.3", 63 | "1.0.3_3.7.6.4", 64 | "1.0.10_3.7.9.10" 65 | ], 66 | "build_platform": [], 67 | "require_verify": 0, 68 | "service_price": "该服务按使用量计费,计费规则,所产生的费用将由第三方从您的 Cocos 账户余额 中扣除。", 69 | "service_protocol": "游戏首次开启该服务时,Cocos会后台通知服务方为游戏开通服务并初始化参数,服务方根据需要可能会获取您的Cocos账户信息,包括账户基本资料、游戏基本资料、账户余额等,点击确认开通按钮即视为您同意该服务访问您的账户信息,详见《Cocos用户服务协议》《Cocos隐私政策》" 70 | }, 71 | { 72 | "service_id": "242", 73 | "service_name": "Agora Voice", 74 | "service_icon": "https://account.cocos.com/uploads/client_icon/2019-07-16/273952d155b4cdb72d2b1bc61de91ade.png", 75 | "service_desc": "稳定、低耗、76ms超低延时、全球200+数据中心覆盖;变声器、超高音质、听声辩位等丰富玩法极速接入;全平台支持:Android、iOS、Web。", 76 | "service_title": "游戏内置实时语音", 77 | "service_guide_url": "https://docs.agora.io/cn/Interactive Gaming/game_c?platform=Cocos Creator", 78 | "service_sample_url": "https://github.com/AgoraIO/Voice-Call-for-Mobile-Gaming/tree/master/Basic-Voice-Call-for-Gaming/Hello-CocosCreator-Voice-Agora", 79 | "service_dev_url": "https://sso.agora.io/api/oauth/cocos/login", 80 | "service_type": "3", 81 | "service_type_zh": "公司和个人游戏", 82 | "support_platform": [ 83 | "Android", 84 | "iOS", 85 | "HTML5" 86 | ], 87 | "package_download_url": "https://download.cocos.com/CocosServices/plugins/service-agora/1.1.0_2.2.3.20_2.5.2.zip", 88 | "package_version_desc": "

更新日期: 2020/03/05
\n更新说明:
\n1、适配 Cocos Creator 2.3.x
\n", 89 | "service_component_name": "service-agora", 90 | "package_versions": [ 91 | "1.1.0_2.2.3.20_2.5.2", 92 | "1.0.2_2.2.3.20_2.5.2", 93 | "1.0.1_2.2.3.20_2.5.2" 94 | ], 95 | "build_platform": [], 96 | "require_verify": 1, 97 | "service_price": "该服务按使用量计费,计费规则,所产生的费用将由第三方从您的 Cocos 账户余额 中扣除。", 98 | "service_protocol": "游戏首次开启该服务时,Cocos会后台通知服务方为游戏开通服务并初始化参数,服务方根据需要可能会获取您的Cocos账户信息,包括账户基本资料、游戏基本资料、账户余额等,点击确认开通按钮即视为您同意该服务访问您的账户信息,详见《Cocos用户服务协议》《Cocos隐私政策》" 99 | } 100 | ], 101 | "game": { 102 | "name": "未知游戏", 103 | "appid": "UNKNOW" 104 | } 105 | } -------------------------------------------------------------------------------- /template-banner.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liuwenkai1023/ccc-frameworks/17851b2c22240e343fb7335c148aec8f75c0fb16/template-banner.png -------------------------------------------------------------------------------- /template.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "TEMPLATES.helloworld-ts.name", 3 | "desc": "TEMPLATES.helloworld-ts.desc", 4 | "banner": "template-banner.png" 5 | } -------------------------------------------------------------------------------- /tools/工具-excel配置导出工具.7z: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liuwenkai1023/ccc-frameworks/17851b2c22240e343fb7335c148aec8f75c0fb16/tools/工具-excel配置导出工具.7z -------------------------------------------------------------------------------- /tools/脚本-protobufjs转ts.7z: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liuwenkai1023/ccc-frameworks/17851b2c22240e343fb7335c148aec8f75c0fb16/tools/脚本-protobufjs转ts.7z -------------------------------------------------------------------------------- /tools/脚本-热更新版本构建.7z: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liuwenkai1023/ccc-frameworks/17851b2c22240e343fb7335c148aec8f75c0fb16/tools/脚本-热更新版本构建.7z -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "module": "commonjs", 4 | "lib": [ 5 | "dom", 6 | "es6", 7 | "es2016.array.include" 8 | ], 9 | "target": "es6", 10 | "allowJs": true, 11 | "experimentalDecorators": true, 12 | "skipLibCheck": true 13 | }, 14 | "exclude": [ 15 | "node_modules", 16 | "library", 17 | "local", 18 | "temp", 19 | "build", 20 | "settings" 21 | ] 22 | } --------------------------------------------------------------------------------