├── .gitignore ├── LICENSE ├── README.md ├── assets ├── res.meta ├── res │ ├── animation.meta │ ├── animation │ │ ├── dialog.meta │ │ ├── dialog │ │ │ ├── close.anim │ │ │ ├── close.anim.meta │ │ │ ├── open.anim │ │ │ └── open.anim.meta │ │ ├── game.meta │ │ └── game │ │ │ ├── move.anim │ │ │ └── move.anim.meta │ ├── shader.meta │ └── shader │ │ ├── effects.meta │ │ ├── effects │ │ ├── multiTexture.effect │ │ ├── multiTexture.effect.meta │ │ ├── spriteFill.effect │ │ ├── spriteFill.effect.meta │ │ ├── spriteOutline.effect │ │ ├── spriteOutline.effect.meta │ │ ├── spriteShining.effect │ │ ├── spriteShining.effect.meta │ │ ├── spriteTile.effect │ │ └── spriteTile.effect.meta │ │ ├── materials.meta │ │ ├── materials │ │ ├── multiTexture.mtl │ │ ├── multiTexture.mtl.meta │ │ ├── spriteFill.mtl │ │ ├── spriteFill.mtl.meta │ │ ├── spriteOutline.mtl │ │ ├── spriteOutline.mtl.meta │ │ ├── spriteShining.mtl │ │ ├── spriteShining.mtl.meta │ │ ├── spriteTile.mtl │ │ └── spriteTile.mtl.meta │ │ ├── textures.meta │ │ └── textures │ │ ├── shaderCase.png │ │ ├── shaderCase.png.meta │ │ ├── weapon.png │ │ └── weapon.png.meta ├── resources.meta ├── resources │ ├── audio.meta │ ├── audio │ │ ├── bgm1.mp3 │ │ ├── bgm1.mp3.meta │ │ ├── bgm2.mp3 │ │ ├── bgm2.mp3.meta │ │ ├── sfx1.mp3 │ │ ├── sfx1.mp3.meta │ │ ├── sfx2.mp3 │ │ └── sfx2.mp3.meta │ ├── prefab.meta │ ├── prefab │ │ ├── dialog.meta │ │ ├── dialog │ │ │ ├── DlgAnimValue.prefab │ │ │ ├── DlgAnimValue.prefab.meta │ │ │ ├── DlgAudio.prefab │ │ │ ├── DlgAudio.prefab.meta │ │ │ ├── DlgButton.prefab │ │ │ ├── DlgButton.prefab.meta │ │ │ ├── DlgCircleList.prefab │ │ │ ├── DlgCircleList.prefab.meta │ │ │ ├── DlgEvents.prefab │ │ │ ├── DlgEvents.prefab.meta │ │ │ ├── DlgI18N.prefab │ │ │ ├── DlgI18N.prefab.meta │ │ │ ├── DlgLoopList.prefab │ │ │ ├── DlgLoopList.prefab.meta │ │ │ ├── DlgMultiTexture.prefab │ │ │ ├── DlgMultiTexture.prefab.meta │ │ │ ├── DlgShader.prefab │ │ │ ├── DlgShader.prefab.meta │ │ │ ├── DlgShake.prefab │ │ │ ├── DlgShake.prefab.meta │ │ │ ├── DlgTimer.prefab │ │ │ ├── DlgTimer.prefab.meta │ │ │ ├── DlgVirtualList.prefab │ │ │ ├── DlgVirtualList.prefab.meta │ │ │ ├── DlgVirtualList2.prefab │ │ │ ├── DlgVirtualList2.prefab.meta │ │ │ ├── layer.meta │ │ │ └── layer │ │ │ │ ├── DlgLayer.prefab │ │ │ │ ├── DlgLayer.prefab.meta │ │ │ │ ├── DlgLayer2.prefab │ │ │ │ ├── DlgLayer2.prefab.meta │ │ │ │ ├── DlgLayer3.prefab │ │ │ │ └── DlgLayer3.prefab.meta │ │ ├── game.meta │ │ ├── game │ │ │ ├── Game.prefab │ │ │ └── Game.prefab.meta │ │ ├── home.meta │ │ ├── home │ │ │ ├── Home.prefab │ │ │ └── Home.prefab.meta │ │ ├── tip.meta │ │ └── tip │ │ │ ├── Tip.prefab │ │ │ └── Tip.prefab.meta │ ├── textures.meta │ └── textures │ │ ├── localizedImage.meta │ │ ├── localizedImage │ │ ├── en.meta │ │ ├── en │ │ │ ├── AutoAtlas.pac │ │ │ ├── AutoAtlas.pac.meta │ │ │ ├── lang.png │ │ │ └── lang.png.meta │ │ ├── zh.meta │ │ └── zh │ │ │ ├── AutoAtlas.pac │ │ │ ├── AutoAtlas.pac.meta │ │ │ ├── lang.png │ │ │ └── lang.png.meta │ │ ├── showcase.meta │ │ └── showcase │ │ ├── circle.png │ │ └── circle.png.meta ├── scenes.meta ├── scenes │ ├── Main.fire │ └── Main.fire.meta ├── scripts.meta └── scripts │ ├── animator.meta │ ├── animator │ ├── AnimatorAnimation.ts │ ├── AnimatorAnimation.ts.meta │ ├── AnimatorCustomization.ts │ ├── AnimatorCustomization.ts.meta │ ├── AnimatorDragonBones.ts │ ├── AnimatorDragonBones.ts.meta │ ├── AnimatorSpine.ts │ ├── AnimatorSpine.ts.meta │ ├── AnimatorSpineSecondary.ts │ ├── AnimatorSpineSecondary.ts.meta │ ├── core.meta │ └── core │ │ ├── AnimatorBase.ts │ │ ├── AnimatorBase.ts.meta │ │ ├── AnimatorCondition.ts │ │ ├── AnimatorCondition.ts.meta │ │ ├── AnimatorController.ts │ │ ├── AnimatorController.ts.meta │ │ ├── AnimatorParams.ts │ │ ├── AnimatorParams.ts.meta │ │ ├── AnimatorState.ts │ │ ├── AnimatorState.ts.meta │ │ ├── AnimatorStateLogic.ts │ │ ├── AnimatorStateLogic.ts.meta │ │ ├── AnimatorTransition.ts │ │ └── AnimatorTransition.ts.meta │ ├── common.meta │ ├── common │ ├── cmpt.meta │ ├── cmpt │ │ ├── base.meta │ │ ├── base │ │ │ ├── DialogBase.ts │ │ │ ├── DialogBase.ts.meta │ │ │ ├── Layer.ts │ │ │ ├── Layer.ts.meta │ │ │ ├── Timer.ts │ │ │ ├── Timer.ts.meta │ │ │ ├── Tip.ts │ │ │ └── Tip.ts.meta │ │ ├── shader.meta │ │ ├── shader │ │ │ ├── ShaderFill.ts │ │ │ ├── ShaderFill.ts.meta │ │ │ ├── ShaderOutline.ts │ │ │ ├── ShaderOutline.ts.meta │ │ │ ├── ShaderShining.ts │ │ │ ├── ShaderShining.ts.meta │ │ │ ├── ShaderTile.ts │ │ │ └── ShaderTile.ts.meta │ │ ├── ui.meta │ │ └── ui │ │ │ ├── CountdownLabel.ts │ │ │ ├── CountdownLabel.ts.meta │ │ │ ├── ShakeNode.ts │ │ │ ├── ShakeNode.ts.meta │ │ │ ├── adapt.meta │ │ │ ├── adapt │ │ │ ├── AdaptCanvas.ts │ │ │ ├── AdaptCanvas.ts.meta │ │ │ ├── AdaptSize.ts │ │ │ └── AdaptSize.ts.meta │ │ │ ├── animValue.meta │ │ │ ├── animValue │ │ │ ├── AnimValue.ts │ │ │ ├── AnimValue.ts.meta │ │ │ ├── AnimValueLabel.ts │ │ │ ├── AnimValueLabel.ts.meta │ │ │ ├── AnimValueProgress.ts │ │ │ ├── AnimValueProgress.ts.meta │ │ │ ├── AnimValueProgressHP.ts │ │ │ └── AnimValueProgressHP.ts.meta │ │ │ ├── button.meta │ │ │ ├── button │ │ │ ├── ButtonChildGray.ts │ │ │ ├── ButtonChildGray.ts.meta │ │ │ ├── ButtonChildPos.ts │ │ │ ├── ButtonChildPos.ts.meta │ │ │ ├── ButtonSingle.ts │ │ │ └── ButtonSingle.ts.meta │ │ │ ├── i18n.meta │ │ │ ├── i18n │ │ │ ├── I18nLabel.ts │ │ │ ├── I18nLabel.ts.meta │ │ │ ├── I18nSprite.ts │ │ │ └── I18nSprite.ts.meta │ │ │ ├── multiTexture.meta │ │ │ ├── multiTexture │ │ │ ├── MultiSprite.ts │ │ │ ├── MultiSprite.ts.meta │ │ │ ├── MultiTextureManager.ts │ │ │ ├── MultiTextureManager.ts.meta │ │ │ ├── assembler.meta │ │ │ └── assembler │ │ │ │ ├── MultiAssembler.ts │ │ │ │ ├── MultiAssembler.ts.meta │ │ │ │ ├── MultiAssemblerBarFilled.ts │ │ │ │ ├── MultiAssemblerBarFilled.ts.meta │ │ │ │ ├── MultiAssemblerRadialFilled.ts │ │ │ │ ├── MultiAssemblerRadialFilled.ts.meta │ │ │ │ ├── MultiAssemblerSimple.ts │ │ │ │ ├── MultiAssemblerSimple.ts.meta │ │ │ │ ├── MultiAssemblerSliced.ts │ │ │ │ ├── MultiAssemblerSliced.ts.meta │ │ │ │ ├── MultiAssemblerTiled.ts │ │ │ │ └── MultiAssemblerTiled.ts.meta │ │ │ ├── res.meta │ │ │ ├── res │ │ │ ├── ResSpine.ts │ │ │ ├── ResSpine.ts.meta │ │ │ ├── ResSprite.ts │ │ │ └── ResSprite.ts.meta │ │ │ ├── scrollList.meta │ │ │ └── scrollList │ │ │ ├── CircleList.ts │ │ │ ├── CircleList.ts.meta │ │ │ ├── LoopList.ts │ │ │ ├── LoopList.ts.meta │ │ │ ├── VirtualItem.ts │ │ │ ├── VirtualItem.ts.meta │ │ │ ├── VirtualLayout.ts │ │ │ ├── VirtualLayout.ts.meta │ │ │ ├── VirtualList.ts │ │ │ └── VirtualList.ts.meta │ ├── config.meta │ ├── config │ │ ├── En.ts │ │ ├── En.ts.meta │ │ ├── Zh.ts │ │ └── Zh.ts.meta │ ├── const.meta │ ├── const │ │ ├── EventName.ts │ │ ├── EventName.ts.meta │ │ ├── Url.ts │ │ └── Url.ts.meta │ ├── hack.meta │ ├── hack │ │ ├── ButtonHack.ts │ │ ├── ButtonHack.ts.meta │ │ ├── EditorBoxHack.ts │ │ └── EditorBoxHack.ts.meta │ ├── util.meta │ └── util │ │ ├── AudioManager.ts │ │ ├── AudioManager.ts.meta │ │ ├── Behavior3.ts │ │ ├── Behavior3.ts.meta │ │ ├── Decorator.ts │ │ ├── Decorator.ts.meta │ │ ├── EditorTool.ts │ │ ├── EditorTool.ts.meta │ │ ├── Events.ts │ │ ├── Events.ts.meta │ │ ├── I18n.ts │ │ ├── I18n.ts.meta │ │ ├── Random.ts │ │ ├── Random.ts.meta │ │ ├── RecyclePool.ts │ │ ├── RecyclePool.ts.meta │ │ ├── Res.ts │ │ ├── Res.ts.meta │ │ ├── Tool.ts │ │ ├── Tool.ts.meta │ │ ├── Tween.ts │ │ └── Tween.ts.meta │ ├── showcase.meta │ └── showcase │ ├── dialog.meta │ ├── dialog │ ├── DlgAnimValue.ts │ ├── DlgAnimValue.ts.meta │ ├── DlgAudio.ts │ ├── DlgAudio.ts.meta │ ├── DlgCircleList.ts │ ├── DlgCircleList.ts.meta │ ├── DlgEvents.ts │ ├── DlgEvents.ts.meta │ ├── DlgI18N.ts │ ├── DlgI18N.ts.meta │ ├── DlgLayer.ts │ ├── DlgLayer.ts.meta │ ├── DlgLoopList.ts │ ├── DlgLoopList.ts.meta │ ├── DlgMultiTexture.ts │ ├── DlgMultiTexture.ts.meta │ ├── DlgShader.ts │ ├── DlgShader.ts.meta │ ├── DlgShake.ts │ ├── DlgShake.ts.meta │ ├── DlgTimer.ts │ ├── DlgTimer.ts.meta │ ├── DlgVirtualList.ts │ ├── DlgVirtualList.ts.meta │ ├── DlgVirtualList2.ts │ ├── DlgVirtualList2.ts.meta │ ├── ListItem.ts │ ├── ListItem.ts.meta │ ├── ListItem2.ts │ └── ListItem2.ts.meta │ ├── game.meta │ ├── game │ ├── Game.ts │ └── Game.ts.meta │ ├── home.meta │ ├── home │ ├── Home.ts │ └── Home.ts.meta │ ├── scenes.meta │ └── scenes │ ├── Main.ts │ └── Main.ts.meta ├── creator.d.ts ├── jsconfig.json ├── project.json ├── settings ├── builder.json ├── project.json └── services.json └── tsconfig.json /.gitignore: -------------------------------------------------------------------------------- 1 | #///////////////////////////////////////////////////////////////////////////// 2 | # Fireball Projects 3 | #///////////////////////////////////////////////////////////////////////////// 4 | 5 | /library/ 6 | /temp/ 7 | /local/ 8 | /build/ 9 | 10 | #///////////////////////////////////////////////////////////////////////////// 11 | # npm files 12 | #///////////////////////////////////////////////////////////////////////////// 13 | 14 | npm-debug.log 15 | node_modules/ 16 | 17 | #///////////////////////////////////////////////////////////////////////////// 18 | # Logs and databases 19 | #///////////////////////////////////////////////////////////////////////////// 20 | 21 | *.log 22 | *.sql 23 | *.sqlite 24 | 25 | #///////////////////////////////////////////////////////////////////////////// 26 | # files for debugger 27 | #///////////////////////////////////////////////////////////////////////////// 28 | 29 | *.sln 30 | *.csproj 31 | *.pidb 32 | *.unityproj 33 | *.suo 34 | 35 | #///////////////////////////////////////////////////////////////////////////// 36 | # OS generated files 37 | #///////////////////////////////////////////////////////////////////////////// 38 | 39 | .DS_Store 40 | ehthumbs.db 41 | Thumbs.db 42 | 43 | #///////////////////////////////////////////////////////////////////////////// 44 | # WebStorm files 45 | #///////////////////////////////////////////////////////////////////////////// 46 | 47 | .idea/ 48 | 49 | #////////////////////////// 50 | # VS Code files 51 | #////////////////////////// 52 | 53 | .vscode/ 54 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2021-2023 LeeYip 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /assets/res.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.1.3", 3 | "uuid": "056ddada-80fd-47dd-9dcd-cf8edbc78aff", 4 | "importer": "folder", 5 | "isBundle": false, 6 | "bundleName": "", 7 | "priority": 1, 8 | "compressionType": {}, 9 | "optimizeHotUpdate": {}, 10 | "inlineSpriteFrames": {}, 11 | "isRemoteBundle": {}, 12 | "subMetas": {} 13 | } -------------------------------------------------------------------------------- /assets/res/animation.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.1.3", 3 | "uuid": "14f9eb15-e099-4ede-b0d6-5395dbc71354", 4 | "importer": "folder", 5 | "isBundle": false, 6 | "bundleName": "", 7 | "priority": 1, 8 | "compressionType": {}, 9 | "optimizeHotUpdate": {}, 10 | "inlineSpriteFrames": {}, 11 | "isRemoteBundle": {}, 12 | "subMetas": {} 13 | } -------------------------------------------------------------------------------- /assets/res/animation/dialog.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.1.3", 3 | "uuid": "178c5adc-45d1-46e4-a351-6c64f0eb7b50", 4 | "importer": "folder", 5 | "isBundle": false, 6 | "bundleName": "", 7 | "priority": 1, 8 | "compressionType": {}, 9 | "optimizeHotUpdate": {}, 10 | "inlineSpriteFrames": {}, 11 | "isRemoteBundle": {}, 12 | "subMetas": {} 13 | } -------------------------------------------------------------------------------- /assets/res/animation/dialog/close.anim: -------------------------------------------------------------------------------- 1 | { 2 | "__type__": "cc.AnimationClip", 3 | "_name": "close", 4 | "_objFlags": 0, 5 | "_native": "", 6 | "_duration": 0.16666666666666666, 7 | "sample": 60, 8 | "speed": 1, 9 | "wrapMode": 1, 10 | "curveData": { 11 | "props": { 12 | "scale": [ 13 | { 14 | "frame": 0, 15 | "value": { 16 | "__type__": "cc.Vec2", 17 | "x": 1, 18 | "y": 1 19 | } 20 | }, 21 | { 22 | "frame": 0.16666666666666666, 23 | "value": { 24 | "__type__": "cc.Vec2", 25 | "x": 0, 26 | "y": 0 27 | } 28 | } 29 | ] 30 | } 31 | }, 32 | "events": [] 33 | } -------------------------------------------------------------------------------- /assets/res/animation/dialog/close.anim.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "2.1.2", 3 | "uuid": "85fcefc8-972b-4176-9d53-8f21017425a5", 4 | "importer": "animation-clip", 5 | "subMetas": {} 6 | } -------------------------------------------------------------------------------- /assets/res/animation/dialog/open.anim: -------------------------------------------------------------------------------- 1 | { 2 | "__type__": "cc.AnimationClip", 3 | "_name": "open", 4 | "_objFlags": 0, 5 | "_native": "", 6 | "_duration": 0.2, 7 | "sample": 60, 8 | "speed": 1, 9 | "wrapMode": 1, 10 | "curveData": { 11 | "props": { 12 | "scale": [ 13 | { 14 | "frame": 0, 15 | "value": { 16 | "__type__": "cc.Vec2", 17 | "x": 0, 18 | "y": 0 19 | } 20 | }, 21 | { 22 | "frame": 0.16666666666666666, 23 | "value": { 24 | "__type__": "cc.Vec2", 25 | "x": 1.1, 26 | "y": 1.1 27 | } 28 | }, 29 | { 30 | "frame": 0.2, 31 | "value": { 32 | "__type__": "cc.Vec2", 33 | "x": 1, 34 | "y": 1 35 | } 36 | } 37 | ] 38 | } 39 | }, 40 | "events": [] 41 | } -------------------------------------------------------------------------------- /assets/res/animation/dialog/open.anim.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "2.1.2", 3 | "uuid": "cf157bac-dfd6-4a5d-a483-5d2eecf8ff34", 4 | "importer": "animation-clip", 5 | "subMetas": {} 6 | } -------------------------------------------------------------------------------- /assets/res/animation/game.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.1.3", 3 | "uuid": "a1183658-4c6f-4484-adbb-b7346116aed3", 4 | "importer": "folder", 5 | "isBundle": false, 6 | "bundleName": "", 7 | "priority": 1, 8 | "compressionType": {}, 9 | "optimizeHotUpdate": {}, 10 | "inlineSpriteFrames": {}, 11 | "isRemoteBundle": {}, 12 | "subMetas": {} 13 | } -------------------------------------------------------------------------------- /assets/res/animation/game/move.anim: -------------------------------------------------------------------------------- 1 | { 2 | "__type__": "cc.AnimationClip", 3 | "_name": "move", 4 | "_objFlags": 0, 5 | "_native": "", 6 | "_duration": 2.5, 7 | "sample": 60, 8 | "speed": 1, 9 | "wrapMode": 2, 10 | "curveData": { 11 | "props": { 12 | "position": [ 13 | { 14 | "frame": 0, 15 | "value": [ 16 | -800, 17 | -430, 18 | 0 19 | ] 20 | }, 21 | { 22 | "frame": 0.5, 23 | "value": [ 24 | 765.404, 25 | 59.797, 26 | 0 27 | ] 28 | }, 29 | { 30 | "frame": 1, 31 | "value": [ 32 | -547.742, 33 | 440.107, 34 | 0 35 | ] 36 | }, 37 | { 38 | "frame": 1.5, 39 | "value": [ 40 | 181.056, 41 | -415.808, 42 | 0 43 | ] 44 | }, 45 | { 46 | "frame": 2, 47 | "value": [ 48 | 404.215, 49 | 459.88, 50 | 0 51 | ] 52 | }, 53 | { 54 | "frame": 2.5, 55 | "value": [ 56 | -800, 57 | -430, 58 | 0 59 | ] 60 | } 61 | ] 62 | } 63 | }, 64 | "events": [] 65 | } -------------------------------------------------------------------------------- /assets/res/animation/game/move.anim.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "2.1.2", 3 | "uuid": "34ac7c44-419b-48bd-a269-bd3bb80048f4", 4 | "importer": "animation-clip", 5 | "subMetas": {} 6 | } -------------------------------------------------------------------------------- /assets/res/shader.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.1.3", 3 | "uuid": "2b5e86be-3def-4621-b44b-5f6301a6af92", 4 | "importer": "folder", 5 | "isBundle": false, 6 | "bundleName": "", 7 | "priority": 1, 8 | "compressionType": {}, 9 | "optimizeHotUpdate": {}, 10 | "inlineSpriteFrames": {}, 11 | "isRemoteBundle": {}, 12 | "subMetas": {} 13 | } -------------------------------------------------------------------------------- /assets/res/shader/effects.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.1.3", 3 | "uuid": "c442e8dd-38fe-4cea-88c7-665e9684134c", 4 | "importer": "folder", 5 | "isBundle": false, 6 | "bundleName": "", 7 | "priority": 1, 8 | "compressionType": {}, 9 | "optimizeHotUpdate": {}, 10 | "inlineSpriteFrames": {}, 11 | "isRemoteBundle": {}, 12 | "subMetas": {} 13 | } -------------------------------------------------------------------------------- /assets/res/shader/effects/multiTexture.effect: -------------------------------------------------------------------------------- 1 | CCEffect %{ 2 | techniques: 3 | - passes: 4 | - vert: vs 5 | frag: fs 6 | blendState: 7 | targets: 8 | - blend: true 9 | rasterizerState: 10 | cullMode: none 11 | properties: 12 | texture0: { value: white } 13 | texture1: { value: white } 14 | texture2: { value: white } 15 | texture3: { value: white } 16 | texture4: { value: white } 17 | texture5: { value: white } 18 | texture6: { value: white } 19 | texture7: { value: white } 20 | 21 | alphaThreshold: { value: 0.5 } 22 | }% 23 | 24 | 25 | CCProgram vs %{ 26 | precision highp float; 27 | 28 | #include 29 | #include 30 | 31 | in vec3 a_position; 32 | in vec4 a_color; 33 | out vec4 v_color; 34 | 35 | in vec2 a_uv0; 36 | out vec2 v_uv0; 37 | 38 | in float a_texture_idx; 39 | out float texture_idx; 40 | 41 | void main () { 42 | vec4 pos = vec4(a_position, 1); 43 | 44 | #if CC_USE_MODEL 45 | pos = cc_matViewProj * cc_matWorld * pos; 46 | #else 47 | pos = cc_matViewProj * pos; 48 | #endif 49 | 50 | v_uv0 = a_uv0; 51 | texture_idx = a_texture_idx; 52 | 53 | v_color = a_color; 54 | 55 | gl_Position = pos; 56 | } 57 | }% 58 | 59 | 60 | CCProgram fs %{ 61 | precision highp float; 62 | 63 | #include 64 | #include 65 | 66 | in vec4 v_color; 67 | 68 | in vec2 v_uv0; 69 | in float texture_idx; 70 | uniform sampler2D texture0; 71 | uniform sampler2D texture1; 72 | uniform sampler2D texture2; 73 | uniform sampler2D texture3; 74 | uniform sampler2D texture4; 75 | uniform sampler2D texture5; 76 | uniform sampler2D texture6; 77 | uniform sampler2D texture7; 78 | 79 | void main () { 80 | vec4 o = vec4(1, 1, 1, 1); 81 | 82 | if (texture_idx <= 0.0) { 83 | CCTexture(texture0, v_uv0, o); 84 | } else if (texture_idx <= 1.0) { 85 | CCTexture(texture1, v_uv0, o); 86 | } else if (texture_idx <= 2.0) { 87 | CCTexture(texture2, v_uv0, o); 88 | } else if (texture_idx <= 3.0) { 89 | CCTexture(texture3, v_uv0, o); 90 | } else if (texture_idx <= 4.0) { 91 | CCTexture(texture4, v_uv0, o); 92 | } else if (texture_idx <= 5.0) { 93 | CCTexture(texture5, v_uv0, o); 94 | } else if (texture_idx <= 6.0) { 95 | CCTexture(texture6, v_uv0, o); 96 | } else if (texture_idx <= 7.0) { 97 | CCTexture(texture7, v_uv0, o); 98 | } 99 | 100 | o *= v_color; 101 | 102 | ALPHA_TEST(o); 103 | 104 | #if USE_BGRA 105 | gl_FragColor = o.bgra; 106 | #else 107 | gl_FragColor = o.rgba; 108 | #endif 109 | } 110 | }% 111 | -------------------------------------------------------------------------------- /assets/res/shader/effects/spriteFill.effect: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd. 2 | 3 | CCEffect %{ 4 | techniques: 5 | - passes: 6 | - vert: vs 7 | frag: fs 8 | blendState: 9 | targets: 10 | - blend: true 11 | rasterizerState: 12 | cullMode: none 13 | properties: 14 | texture: { value: white } 15 | alphaThreshold: { value: 0.5 } 16 | 17 | fillColor: { value: [1, 1, 1, 1], editor: { type: color} } 18 | fillPhase: { value: 0, editor: { range: [0, 1, 0.1] } } 19 | }% 20 | 21 | 22 | CCProgram vs %{ 23 | precision highp float; 24 | 25 | #include 26 | #include 27 | 28 | in vec3 a_position; 29 | in vec4 a_color; 30 | out vec4 v_color; 31 | 32 | #if USE_TEXTURE 33 | in vec2 a_uv0; 34 | out vec2 v_uv0; 35 | #endif 36 | 37 | void main () { 38 | vec4 pos = vec4(a_position, 1); 39 | 40 | #if CC_USE_MODEL 41 | pos = cc_matViewProj * cc_matWorld * pos; 42 | #else 43 | pos = cc_matViewProj * pos; 44 | #endif 45 | 46 | #if USE_TEXTURE 47 | v_uv0 = a_uv0; 48 | #endif 49 | 50 | v_color = a_color; 51 | 52 | gl_Position = pos; 53 | } 54 | }% 55 | 56 | 57 | CCProgram fs %{ 58 | precision highp float; 59 | 60 | #include 61 | #include 62 | 63 | in vec4 v_color; 64 | 65 | #if USE_TEXTURE 66 | in vec2 v_uv0; 67 | uniform sampler2D texture; 68 | #endif 69 | 70 | uniform Constant { 71 | vec4 fillColor; 72 | // 颜色混合率 73 | float fillPhase; 74 | }; 75 | 76 | void main () { 77 | vec4 o = vec4(1, 1, 1, 1); 78 | 79 | #if USE_TEXTURE 80 | CCTexture(texture, v_uv0, o); 81 | #endif 82 | 83 | o *= v_color; 84 | // 混合 85 | o.rgb = mix(o.rgb, fillColor.rgb * o.a, fillPhase); 86 | 87 | ALPHA_TEST(o); 88 | 89 | gl_FragColor = o; 90 | } 91 | }% 92 | -------------------------------------------------------------------------------- /assets/res/shader/effects/spriteFill.effect.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.27", 3 | "uuid": "a554cf17-f460-48b9-b951-82e33fc4d5f4", 4 | "importer": "effect", 5 | "compiledShaders": [ 6 | { 7 | "glsl1": { 8 | "vert": "\nprecision highp float;\nuniform mat4 cc_matViewProj;\nuniform mat4 cc_matWorld;\nattribute vec3 a_position;\nattribute vec4 a_color;\nvarying vec4 v_color;\n#if USE_TEXTURE\nattribute vec2 a_uv0;\nvarying vec2 v_uv0;\n#endif\nvoid main () {\n vec4 pos = vec4(a_position, 1);\n #if CC_USE_MODEL\n pos = cc_matViewProj * cc_matWorld * pos;\n #else\n pos = cc_matViewProj * pos;\n #endif\n #if USE_TEXTURE\n v_uv0 = a_uv0;\n #endif\n v_color = a_color;\n gl_Position = pos;\n}", 9 | "frag": "\nprecision highp float;\n#if USE_ALPHA_TEST\n uniform float alphaThreshold;\n#endif\nvoid ALPHA_TEST (in vec4 color) {\n #if USE_ALPHA_TEST\n if (color.a < alphaThreshold) discard;\n #endif\n}\nvoid ALPHA_TEST (in float alpha) {\n #if USE_ALPHA_TEST\n if (alpha < alphaThreshold) discard;\n #endif\n}\nvarying vec4 v_color;\n#if USE_TEXTURE\nvarying vec2 v_uv0;\nuniform sampler2D texture;\n#endif\nuniform vec4 fillColor;\nuniform float fillPhase;\nvoid main () {\n vec4 o = vec4(1, 1, 1, 1);\n #if USE_TEXTURE\n vec4 texture_tmp = texture2D(texture, v_uv0);\n #if CC_USE_ALPHA_ATLAS_texture\n texture_tmp.a *= texture2D(texture, v_uv0 + vec2(0, 0.5)).r;\n #endif\n #if INPUT_IS_GAMMA\n o.rgb *= (texture_tmp.rgb * texture_tmp.rgb);\n o.a *= texture_tmp.a;\n #else\n o *= texture_tmp;\n #endif\n #endif\n o *= v_color;\n o.rgb = mix(o.rgb, fillColor.rgb * o.a, fillPhase);\n ALPHA_TEST(o);\n gl_FragColor = o;\n}" 10 | }, 11 | "glsl3": { 12 | "vert": "\nprecision highp float;\nuniform CCGlobal {\n mat4 cc_matView;\n mat4 cc_matViewInv;\n mat4 cc_matProj;\n mat4 cc_matProjInv;\n mat4 cc_matViewProj;\n mat4 cc_matViewProjInv;\n vec4 cc_cameraPos;\n vec4 cc_time;\n mediump vec4 cc_screenSize;\n mediump vec4 cc_screenScale;\n};\nuniform CCLocal {\n mat4 cc_matWorld;\n mat4 cc_matWorldIT;\n};\nin vec3 a_position;\nin vec4 a_color;\nout vec4 v_color;\n#if USE_TEXTURE\nin vec2 a_uv0;\nout vec2 v_uv0;\n#endif\nvoid main () {\n vec4 pos = vec4(a_position, 1);\n #if CC_USE_MODEL\n pos = cc_matViewProj * cc_matWorld * pos;\n #else\n pos = cc_matViewProj * pos;\n #endif\n #if USE_TEXTURE\n v_uv0 = a_uv0;\n #endif\n v_color = a_color;\n gl_Position = pos;\n}", 13 | "frag": "\nprecision highp float;\n#if USE_ALPHA_TEST\n uniform ALPHA_TEST {\n float alphaThreshold;\n };\n#endif\nvoid ALPHA_TEST (in vec4 color) {\n #if USE_ALPHA_TEST\n if (color.a < alphaThreshold) discard;\n #endif\n}\nvoid ALPHA_TEST (in float alpha) {\n #if USE_ALPHA_TEST\n if (alpha < alphaThreshold) discard;\n #endif\n}\nin vec4 v_color;\n#if USE_TEXTURE\nin vec2 v_uv0;\nuniform sampler2D texture;\n#endif\nuniform Constant {\n vec4 fillColor;\n float fillPhase;\n};\nvoid main () {\n vec4 o = vec4(1, 1, 1, 1);\n #if USE_TEXTURE\n vec4 texture_tmp = texture(texture, v_uv0);\n #if CC_USE_ALPHA_ATLAS_texture\n texture_tmp.a *= texture(texture, v_uv0 + vec2(0, 0.5)).r;\n #endif\n #if INPUT_IS_GAMMA\n o.rgb *= (texture_tmp.rgb * texture_tmp.rgb);\n o.a *= texture_tmp.a;\n #else\n o *= texture_tmp;\n #endif\n #endif\n o *= v_color;\n o.rgb = mix(o.rgb, fillColor.rgb * o.a, fillPhase);\n ALPHA_TEST(o);\n gl_FragColor = o;\n}" 14 | } 15 | } 16 | ], 17 | "subMetas": {} 18 | } -------------------------------------------------------------------------------- /assets/res/shader/effects/spriteOutline.effect: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd. 2 | 3 | CCEffect %{ 4 | techniques: 5 | - passes: 6 | - vert: vs 7 | frag: fs 8 | blendState: 9 | targets: 10 | - blend: true 11 | rasterizerState: 12 | cullMode: none 13 | properties: 14 | texture: { value: white } 15 | alphaThreshold: { value: 0.5 } 16 | 17 | outlineColor: { value: [1, 1, 1, 1], editor: { type: color} } 18 | outlineInfo: { value: [1, 1, 1, 0] } 19 | }% 20 | 21 | 22 | CCProgram vs %{ 23 | precision highp float; 24 | 25 | #include 26 | #include 27 | 28 | in vec3 a_position; 29 | in vec4 a_color; 30 | out vec4 v_color; 31 | 32 | #if USE_TEXTURE 33 | in vec2 a_uv0; 34 | out vec2 v_uv0; 35 | #endif 36 | 37 | void main () { 38 | vec4 pos = vec4(a_position, 1); 39 | 40 | #if CC_USE_MODEL 41 | pos = cc_matViewProj * cc_matWorld * pos; 42 | #else 43 | pos = cc_matViewProj * pos; 44 | #endif 45 | 46 | #if USE_TEXTURE 47 | v_uv0 = a_uv0; 48 | #endif 49 | 50 | v_color = a_color; 51 | 52 | gl_Position = pos; 53 | } 54 | }% 55 | 56 | 57 | CCProgram fs %{ 58 | precision highp float; 59 | 60 | #include 61 | #include 62 | 63 | in vec4 v_color; 64 | 65 | #if USE_TEXTURE 66 | in vec2 v_uv0; 67 | uniform sampler2D texture; 68 | #endif 69 | 70 | uniform Constant { 71 | vec4 outlineColor; 72 | // 描边数据 单位为pixel x:图片width y:图片height z:描边宽度 w:1表示内描边 2表示外描边 73 | vec4 outlineInfo; 74 | }; 75 | 76 | // value在[minVal, maxVal]区间内返回1,否则返回0 77 | float checkEdge(float minVal, float maxVal, float value) { 78 | return step(minVal, value) * (1.0 - step(-value, -maxVal)); 79 | } 80 | 81 | // 外描边 返回上下左右叠加的alpha 82 | float getOutAlpha(sampler2D texture, vec2 uv) { 83 | float right = texture2D(texture, uv + vec2(outlineInfo.z / outlineInfo.x, 0.0)).a; 84 | float left = texture2D(texture, uv - vec2(outlineInfo.z / outlineInfo.x, 0.0)).a; 85 | float top = texture2D(texture, uv + vec2(0.0, outlineInfo.z / outlineInfo.y)).a; 86 | float bottom = texture2D(texture, uv - vec2(0.0, outlineInfo.z / outlineInfo.y)).a; 87 | 88 | return left + right + top + bottom; 89 | } 90 | 91 | // 内描边 上下左右alpha全不为0时返回1,否则返回0 92 | float getInnerAlpha(sampler2D texture, vec2 uv) { 93 | float right = texture2D(texture, uv + vec2(outlineInfo.z / outlineInfo.x, 0.0)).a * checkEdge(0.0, 1.0, uv.x + outlineInfo.z / outlineInfo.x); 94 | float left = texture2D(texture, uv - vec2(outlineInfo.z / outlineInfo.x, 0.0)).a * checkEdge(0.0, 1.0, uv.x - outlineInfo.z / outlineInfo.x); 95 | float top = texture2D(texture, uv + vec2(0.0, outlineInfo.z / outlineInfo.y)).a * checkEdge(0.0, 1.0, uv.y + outlineInfo.z / outlineInfo.y); 96 | float bottom = texture2D(texture, uv - vec2(0.0, outlineInfo.z / outlineInfo.y)).a * checkEdge(0.0, 1.0, uv.y - outlineInfo.z / outlineInfo.y); 97 | return step(1.0, 1.0 - left * right * top * bottom); 98 | } 99 | 100 | void main () { 101 | vec4 o = vec4(1, 1, 1, 1); 102 | 103 | #if USE_TEXTURE 104 | CCTexture(texture, v_uv0, o); 105 | #endif 106 | 107 | o *= v_color; 108 | 109 | // 描边 110 | if (outlineInfo.w == 1.0) { 111 | float a = getOutAlpha(texture, v_uv0); 112 | o = o * o.a + vec4(outlineColor.rgb, a) * (1.0 - o.a); 113 | } else if (outlineInfo.w == 2.0) { 114 | float a = getInnerAlpha(texture, v_uv0); 115 | o = o * (1.0 - a) + vec4(outlineColor.rgb, o.a) * a; 116 | } 117 | 118 | ALPHA_TEST(o); 119 | 120 | gl_FragColor = o; 121 | } 122 | }% 123 | -------------------------------------------------------------------------------- /assets/res/shader/effects/spriteShining.effect: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd. 2 | 3 | CCEffect %{ 4 | techniques: 5 | - passes: 6 | - vert: vs 7 | frag: fs 8 | blendState: 9 | targets: 10 | - blend: true 11 | rasterizerState: 12 | cullMode: none 13 | properties: 14 | texture: { value: white } 15 | alphaThreshold: { value: 0.5 } 16 | 17 | shiningData: { value: [1, 1, 1, 1] } 18 | extra: { value: [1, 1, 1, 1] } 19 | }% 20 | 21 | 22 | CCProgram vs %{ 23 | precision highp float; 24 | 25 | #include 26 | #include 27 | 28 | in vec3 a_position; 29 | in vec4 a_color; 30 | out vec4 v_color; 31 | 32 | #if USE_TEXTURE 33 | in vec2 a_uv0; 34 | out vec2 v_uv0; 35 | #endif 36 | 37 | void main () { 38 | vec4 pos = vec4(a_position, 1); 39 | 40 | #if CC_USE_MODEL 41 | pos = cc_matViewProj * cc_matWorld * pos; 42 | #else 43 | pos = cc_matViewProj * pos; 44 | #endif 45 | 46 | #if USE_TEXTURE 47 | v_uv0 = a_uv0; 48 | #endif 49 | 50 | v_color = a_color; 51 | 52 | gl_Position = pos; 53 | } 54 | }% 55 | 56 | 57 | CCProgram fs %{ 58 | precision highp float; 59 | 60 | #include 61 | #include 62 | 63 | in vec4 v_color; 64 | 65 | #if USE_TEXTURE 66 | in vec2 v_uv0; 67 | uniform sampler2D texture; 68 | #endif 69 | 70 | uniform Constant { 71 | // 流光数据 x:流光速度 y:流光斜率 z:流光宽度 w:两次流光动画之间的间隔时间 72 | // 可以通过改变速度和斜率的正负号来改变流光方向 73 | vec4 shiningData; 74 | // x:当前时间 y:流光强度 75 | vec4 extra; 76 | }; 77 | 78 | vec4 shining(vec4 color, vec2 uv) { 79 | float speed = shiningData.x; 80 | float slope = shiningData.y; 81 | float width = shiningData.z; 82 | float interval = shiningData.w; 83 | float time = extra.x; 84 | float strength = extra.y; 85 | 86 | float len = 2.0 + width + abs(speed) * interval; 87 | float delta = mod(speed * time, len); 88 | if (delta < 0.0) { 89 | delta += len; 90 | } 91 | float dir = step(0.0, slope); 92 | // 左下-右上 93 | float result1 = step(slope * uv.x + slope * (1.0 - delta), uv.y) - step(slope * uv.x + slope * (1.0 - (delta - width)), uv.y); 94 | // 左上-右下 95 | float result2 = step(slope * uv.x - slope * (delta - width), uv.y) - step(slope * uv.x - slope * delta, uv.y); 96 | float result = result1 * dir + result2 * (1.0 - dir); 97 | color += color * result * strength * step(1.0, color.a); 98 | return color; 99 | } 100 | 101 | void main () { 102 | vec4 o = vec4(1, 1, 1, 1); 103 | 104 | #if USE_TEXTURE 105 | CCTexture(texture, v_uv0, o); 106 | #endif 107 | 108 | o *= v_color; 109 | o = shining(o, v_uv0); 110 | 111 | ALPHA_TEST(o); 112 | 113 | #if USE_BGRA 114 | gl_FragColor = o.bgra; 115 | #else 116 | gl_FragColor = o.rgba; 117 | #endif 118 | } 119 | }% 120 | -------------------------------------------------------------------------------- /assets/res/shader/effects/spriteTile.effect: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd. 2 | 3 | CCEffect %{ 4 | techniques: 5 | - passes: 6 | - vert: vs 7 | frag: fs 8 | blendState: 9 | targets: 10 | - blend: true 11 | rasterizerState: 12 | cullMode: none 13 | properties: 14 | texture: { value: white } 15 | alphaThreshold: { value: 0.5 } 16 | 17 | tile: { value: [1, 1, 0, 0] } 18 | }% 19 | 20 | 21 | CCProgram vs %{ 22 | precision highp float; 23 | 24 | #include 25 | #include 26 | 27 | in vec3 a_position; 28 | in vec4 a_color; 29 | out vec4 v_color; 30 | 31 | #if USE_TEXTURE 32 | in vec2 a_uv0; 33 | out vec2 v_uv0; 34 | #endif 35 | 36 | void main () { 37 | vec4 pos = vec4(a_position, 1); 38 | 39 | #if CC_USE_MODEL 40 | pos = cc_matViewProj * cc_matWorld * pos; 41 | #else 42 | pos = cc_matViewProj * pos; 43 | #endif 44 | 45 | #if USE_TEXTURE 46 | v_uv0 = a_uv0; 47 | #endif 48 | 49 | v_color = a_color; 50 | 51 | gl_Position = pos; 52 | } 53 | }% 54 | 55 | 56 | CCProgram fs %{ 57 | precision highp float; 58 | 59 | #include 60 | #include 61 | 62 | in vec4 v_color; 63 | 64 | #if USE_TEXTURE 65 | in vec2 v_uv0; 66 | uniform sampler2D texture; 67 | #endif 68 | 69 | uniform Constant { 70 | // xy表示uv坐标缩放倍数 zw表示uv坐标偏移值 71 | vec4 tile; 72 | }; 73 | 74 | void main () { 75 | vec4 o = vec4(1, 1, 1, 1); 76 | 77 | // 缩放和偏移 78 | vec2 uv = fract(v_uv0 * tile.xy + tile.zw); 79 | 80 | #if USE_TEXTURE 81 | CCTexture(texture, uv, o); 82 | #endif 83 | 84 | o *= v_color; 85 | 86 | ALPHA_TEST(o); 87 | 88 | gl_FragColor = o; 89 | } 90 | }% 91 | -------------------------------------------------------------------------------- /assets/res/shader/effects/spriteTile.effect.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.27", 3 | "uuid": "ca172662-d789-401b-b14e-44ef45582eb8", 4 | "importer": "effect", 5 | "compiledShaders": [ 6 | { 7 | "glsl1": { 8 | "vert": "\nprecision highp float;\nuniform mat4 cc_matViewProj;\nuniform mat4 cc_matWorld;\nattribute vec3 a_position;\nattribute vec4 a_color;\nvarying vec4 v_color;\n#if USE_TEXTURE\nattribute vec2 a_uv0;\nvarying vec2 v_uv0;\n#endif\nvoid main () {\n vec4 pos = vec4(a_position, 1);\n #if CC_USE_MODEL\n pos = cc_matViewProj * cc_matWorld * pos;\n #else\n pos = cc_matViewProj * pos;\n #endif\n #if USE_TEXTURE\n v_uv0 = a_uv0;\n #endif\n v_color = a_color;\n gl_Position = pos;\n}", 9 | "frag": "\nprecision highp float;\n#if USE_ALPHA_TEST\n uniform float alphaThreshold;\n#endif\nvoid ALPHA_TEST (in vec4 color) {\n #if USE_ALPHA_TEST\n if (color.a < alphaThreshold) discard;\n #endif\n}\nvoid ALPHA_TEST (in float alpha) {\n #if USE_ALPHA_TEST\n if (alpha < alphaThreshold) discard;\n #endif\n}\nvarying vec4 v_color;\n#if USE_TEXTURE\nvarying vec2 v_uv0;\nuniform sampler2D texture;\n#endif\nuniform vec4 tile;\nvoid main () {\n vec4 o = vec4(1, 1, 1, 1);\n vec2 uv = fract(v_uv0 * tile.xy + tile.zw);\n #if USE_TEXTURE\n vec4 texture_tmp = texture2D(texture, uv);\n #if CC_USE_ALPHA_ATLAS_texture\n texture_tmp.a *= texture2D(texture, uv + vec2(0, 0.5)).r;\n #endif\n #if INPUT_IS_GAMMA\n o.rgb *= (texture_tmp.rgb * texture_tmp.rgb);\n o.a *= texture_tmp.a;\n #else\n o *= texture_tmp;\n #endif\n #endif\n o *= v_color;\n ALPHA_TEST(o);\n gl_FragColor = o;\n}" 10 | }, 11 | "glsl3": { 12 | "vert": "\nprecision highp float;\nuniform CCGlobal {\n mat4 cc_matView;\n mat4 cc_matViewInv;\n mat4 cc_matProj;\n mat4 cc_matProjInv;\n mat4 cc_matViewProj;\n mat4 cc_matViewProjInv;\n vec4 cc_cameraPos;\n vec4 cc_time;\n mediump vec4 cc_screenSize;\n mediump vec4 cc_screenScale;\n};\nuniform CCLocal {\n mat4 cc_matWorld;\n mat4 cc_matWorldIT;\n};\nin vec3 a_position;\nin vec4 a_color;\nout vec4 v_color;\n#if USE_TEXTURE\nin vec2 a_uv0;\nout vec2 v_uv0;\n#endif\nvoid main () {\n vec4 pos = vec4(a_position, 1);\n #if CC_USE_MODEL\n pos = cc_matViewProj * cc_matWorld * pos;\n #else\n pos = cc_matViewProj * pos;\n #endif\n #if USE_TEXTURE\n v_uv0 = a_uv0;\n #endif\n v_color = a_color;\n gl_Position = pos;\n}", 13 | "frag": "\nprecision highp float;\n#if USE_ALPHA_TEST\n uniform ALPHA_TEST {\n float alphaThreshold;\n };\n#endif\nvoid ALPHA_TEST (in vec4 color) {\n #if USE_ALPHA_TEST\n if (color.a < alphaThreshold) discard;\n #endif\n}\nvoid ALPHA_TEST (in float alpha) {\n #if USE_ALPHA_TEST\n if (alpha < alphaThreshold) discard;\n #endif\n}\nin vec4 v_color;\n#if USE_TEXTURE\nin vec2 v_uv0;\nuniform sampler2D texture;\n#endif\nuniform Constant {\n vec4 tile;\n};\nvoid main () {\n vec4 o = vec4(1, 1, 1, 1);\n vec2 uv = fract(v_uv0 * tile.xy + tile.zw);\n #if USE_TEXTURE\n vec4 texture_tmp = texture(texture, uv);\n #if CC_USE_ALPHA_ATLAS_texture\n texture_tmp.a *= texture(texture, uv + vec2(0, 0.5)).r;\n #endif\n #if INPUT_IS_GAMMA\n o.rgb *= (texture_tmp.rgb * texture_tmp.rgb);\n o.a *= texture_tmp.a;\n #else\n o *= texture_tmp;\n #endif\n #endif\n o *= v_color;\n ALPHA_TEST(o);\n gl_FragColor = o;\n}" 14 | } 15 | } 16 | ], 17 | "subMetas": {} 18 | } -------------------------------------------------------------------------------- /assets/res/shader/materials.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.1.3", 3 | "uuid": "10c763b2-0c57-405e-9d96-f2bb54da37a7", 4 | "importer": "folder", 5 | "isBundle": false, 6 | "bundleName": "", 7 | "priority": 1, 8 | "compressionType": {}, 9 | "optimizeHotUpdate": {}, 10 | "inlineSpriteFrames": {}, 11 | "isRemoteBundle": {}, 12 | "subMetas": {} 13 | } -------------------------------------------------------------------------------- /assets/res/shader/materials/multiTexture.mtl: -------------------------------------------------------------------------------- 1 | { 2 | "__type__": "cc.Material", 3 | "_name": "multiTexture", 4 | "_objFlags": 0, 5 | "_native": "", 6 | "_effectAsset": { 7 | "__uuid__": "ce2027f7-553d-45b4-8d4f-d396ff8e12eb" 8 | }, 9 | "_techniqueIndex": 0, 10 | "_techniqueData": { 11 | "0": { 12 | "defines": {}, 13 | "props": { 14 | "texture0": { 15 | "__uuid__": "532b9ab1-c7b6-49fb-afe4-189332d154ac" 16 | }, 17 | "texture1": { 18 | "__uuid__": "0a20c584-0173-46e4-b37b-83f696bf6b0b" 19 | } 20 | } 21 | } 22 | } 23 | } -------------------------------------------------------------------------------- /assets/res/shader/materials/multiTexture.mtl.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.5", 3 | "uuid": "f0d586d0-242a-46a1-a0ad-14a356015f90", 4 | "importer": "material", 5 | "dataAsSubAsset": null, 6 | "subMetas": {} 7 | } -------------------------------------------------------------------------------- /assets/res/shader/materials/spriteFill.mtl: -------------------------------------------------------------------------------- 1 | { 2 | "__type__": "cc.Material", 3 | "_name": "spriteFill", 4 | "_objFlags": 0, 5 | "_native": "", 6 | "_effectAsset": { 7 | "__uuid__": "a554cf17-f460-48b9-b951-82e33fc4d5f4" 8 | }, 9 | "_techniqueIndex": 0, 10 | "_techniqueData": { 11 | "0": { 12 | "defines": { 13 | "USE_TEXTURE": true 14 | } 15 | } 16 | } 17 | } -------------------------------------------------------------------------------- /assets/res/shader/materials/spriteFill.mtl.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.5", 3 | "uuid": "b0202e29-cde7-4bbb-a25f-5fd7004f1985", 4 | "importer": "material", 5 | "dataAsSubAsset": null, 6 | "subMetas": {} 7 | } -------------------------------------------------------------------------------- /assets/res/shader/materials/spriteOutline.mtl: -------------------------------------------------------------------------------- 1 | { 2 | "__type__": "cc.Material", 3 | "_name": "spriteOutline", 4 | "_objFlags": 0, 5 | "_native": "", 6 | "_effectAsset": { 7 | "__uuid__": "c2f342df-7997-455a-bece-98c648e51e50" 8 | }, 9 | "_techniqueIndex": 0, 10 | "_techniqueData": { 11 | "0": { 12 | "defines": { 13 | "USE_TEXTURE": true 14 | } 15 | } 16 | } 17 | } -------------------------------------------------------------------------------- /assets/res/shader/materials/spriteOutline.mtl.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.5", 3 | "uuid": "f6c75306-7c3c-4e05-b599-4965a12f0103", 4 | "importer": "material", 5 | "dataAsSubAsset": null, 6 | "subMetas": {} 7 | } -------------------------------------------------------------------------------- /assets/res/shader/materials/spriteShining.mtl: -------------------------------------------------------------------------------- 1 | { 2 | "__type__": "cc.Material", 3 | "_name": "spriteShining", 4 | "_objFlags": 0, 5 | "_native": "", 6 | "_effectAsset": { 7 | "__uuid__": "cb57e17e-6053-4b86-8c83-dec1e0b821bc" 8 | }, 9 | "_techniqueIndex": 0, 10 | "_techniqueData": { 11 | "0": { 12 | "defines": { 13 | "USE_TEXTURE": true 14 | }, 15 | "props": { 16 | "shiningData": { 17 | "__type__": "cc.Vec4", 18 | "x": 1, 19 | "y": -1, 20 | "z": 0.3, 21 | "w": 1 22 | }, 23 | "extra": { 24 | "__type__": "cc.Vec4", 25 | "x": 0, 26 | "y": 1, 27 | "z": 1, 28 | "w": 1 29 | } 30 | } 31 | } 32 | } 33 | } -------------------------------------------------------------------------------- /assets/res/shader/materials/spriteShining.mtl.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.5", 3 | "uuid": "099cd1c2-082f-449c-b955-9ac2dd86b3ae", 4 | "importer": "material", 5 | "dataAsSubAsset": null, 6 | "subMetas": {} 7 | } -------------------------------------------------------------------------------- /assets/res/shader/materials/spriteTile.mtl: -------------------------------------------------------------------------------- 1 | { 2 | "__type__": "cc.Material", 3 | "_name": "spriteTile", 4 | "_objFlags": 0, 5 | "_native": "", 6 | "_effectAsset": { 7 | "__uuid__": "ca172662-d789-401b-b14e-44ef45582eb8" 8 | }, 9 | "_techniqueIndex": 0, 10 | "_techniqueData": { 11 | "0": { 12 | "defines": { 13 | "USE_TEXTURE": true 14 | } 15 | } 16 | } 17 | } -------------------------------------------------------------------------------- /assets/res/shader/materials/spriteTile.mtl.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.0.5", 3 | "uuid": "f36651e3-25d3-4e98-a2b9-e3a6c06e8f5c", 4 | "importer": "material", 5 | "dataAsSubAsset": null, 6 | "subMetas": {} 7 | } -------------------------------------------------------------------------------- /assets/res/shader/textures.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.1.3", 3 | "uuid": "c67c7a8a-64b1-4a6f-bd3d-4fb945ce01c8", 4 | "importer": "folder", 5 | "isBundle": false, 6 | "bundleName": "", 7 | "priority": 1, 8 | "compressionType": {}, 9 | "optimizeHotUpdate": {}, 10 | "inlineSpriteFrames": {}, 11 | "isRemoteBundle": {}, 12 | "subMetas": {} 13 | } -------------------------------------------------------------------------------- /assets/res/shader/textures/shaderCase.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LeeYip/cocos-framework/d17e4454cb2cedc6ee3149405ec699eb8d75be5b/assets/res/shader/textures/shaderCase.png -------------------------------------------------------------------------------- /assets/res/shader/textures/shaderCase.png.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "2.3.7", 3 | "uuid": "cbcb3588-4fda-4798-8f17-ed8caae5007b", 4 | "importer": "texture", 5 | "type": "sprite", 6 | "wrapMode": "clamp", 7 | "filterMode": "bilinear", 8 | "premultiplyAlpha": false, 9 | "genMipmaps": false, 10 | "packable": false, 11 | "width": 300, 12 | "height": 300, 13 | "platformSettings": {}, 14 | "subMetas": { 15 | "shaderCase": { 16 | "ver": "1.0.6", 17 | "uuid": "e043afb0-2180-4d72-bb23-cb5e14704a26", 18 | "importer": "sprite-frame", 19 | "rawTextureUuid": "cbcb3588-4fda-4798-8f17-ed8caae5007b", 20 | "trimType": "none", 21 | "trimThreshold": 1, 22 | "rotated": false, 23 | "offsetX": 0, 24 | "offsetY": 0, 25 | "trimX": 0, 26 | "trimY": 0, 27 | "width": 300, 28 | "height": 300, 29 | "rawWidth": 300, 30 | "rawHeight": 300, 31 | "borderTop": 0, 32 | "borderBottom": 0, 33 | "borderLeft": 0, 34 | "borderRight": 0, 35 | "subMetas": {} 36 | } 37 | } 38 | } -------------------------------------------------------------------------------- /assets/res/shader/textures/weapon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LeeYip/cocos-framework/d17e4454cb2cedc6ee3149405ec699eb8d75be5b/assets/res/shader/textures/weapon.png -------------------------------------------------------------------------------- /assets/res/shader/textures/weapon.png.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "2.3.7", 3 | "uuid": "aa56b316-b8d1-475e-96b6-4f0fa4837312", 4 | "importer": "texture", 5 | "type": "sprite", 6 | "wrapMode": "clamp", 7 | "filterMode": "point", 8 | "premultiplyAlpha": false, 9 | "genMipmaps": false, 10 | "packable": false, 11 | "width": 192, 12 | "height": 160, 13 | "platformSettings": {}, 14 | "subMetas": { 15 | "weapon": { 16 | "ver": "1.0.6", 17 | "uuid": "a43ad13e-fc98-4b79-9aa7-6d6b23b07b68", 18 | "importer": "sprite-frame", 19 | "rawTextureUuid": "aa56b316-b8d1-475e-96b6-4f0fa4837312", 20 | "trimType": "auto", 21 | "trimThreshold": 1, 22 | "rotated": false, 23 | "offsetX": 0, 24 | "offsetY": 0, 25 | "trimX": 0, 26 | "trimY": 0, 27 | "width": 192, 28 | "height": 160, 29 | "rawWidth": 192, 30 | "rawHeight": 160, 31 | "borderTop": 0, 32 | "borderBottom": 0, 33 | "borderLeft": 0, 34 | "borderRight": 0, 35 | "subMetas": {} 36 | } 37 | } 38 | } -------------------------------------------------------------------------------- /assets/resources.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.1.3", 3 | "uuid": "664344e9-a61f-4532-9250-f89632fde27c", 4 | "importer": "folder", 5 | "isBundle": true, 6 | "bundleName": "resources", 7 | "priority": 8, 8 | "compressionType": {}, 9 | "optimizeHotUpdate": {}, 10 | "inlineSpriteFrames": {}, 11 | "isRemoteBundle": {}, 12 | "subMetas": {} 13 | } -------------------------------------------------------------------------------- /assets/resources/audio.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.1.3", 3 | "uuid": "fc7f8764-7109-410b-98c8-796aae615e32", 4 | "importer": "folder", 5 | "isBundle": false, 6 | "bundleName": "", 7 | "priority": 1, 8 | "compressionType": {}, 9 | "optimizeHotUpdate": {}, 10 | "inlineSpriteFrames": {}, 11 | "isRemoteBundle": {}, 12 | "subMetas": {} 13 | } -------------------------------------------------------------------------------- /assets/resources/audio/bgm1.mp3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LeeYip/cocos-framework/d17e4454cb2cedc6ee3149405ec699eb8d75be5b/assets/resources/audio/bgm1.mp3 -------------------------------------------------------------------------------- /assets/resources/audio/bgm1.mp3.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "2.0.3", 3 | "uuid": "91b2427e-5a33-4349-ad45-e0f0aeb417f1", 4 | "importer": "audio-clip", 5 | "downloadMode": 0, 6 | "duration": 191.582041, 7 | "subMetas": {} 8 | } -------------------------------------------------------------------------------- /assets/resources/audio/bgm2.mp3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LeeYip/cocos-framework/d17e4454cb2cedc6ee3149405ec699eb8d75be5b/assets/resources/audio/bgm2.mp3 -------------------------------------------------------------------------------- /assets/resources/audio/bgm2.mp3.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "2.0.3", 3 | "uuid": "24a05c96-3f5c-43d9-9a97-28149cb555c7", 4 | "importer": "audio-clip", 5 | "downloadMode": 0, 6 | "duration": 223.3992, 7 | "subMetas": {} 8 | } -------------------------------------------------------------------------------- /assets/resources/audio/sfx1.mp3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LeeYip/cocos-framework/d17e4454cb2cedc6ee3149405ec699eb8d75be5b/assets/resources/audio/sfx1.mp3 -------------------------------------------------------------------------------- /assets/resources/audio/sfx1.mp3.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "2.0.3", 3 | "uuid": "6d55a28a-5b55-4a9a-9522-af70a33b9fe0", 4 | "importer": "audio-clip", 5 | "downloadMode": 0, 6 | "duration": 0.7712, 7 | "subMetas": {} 8 | } -------------------------------------------------------------------------------- /assets/resources/audio/sfx2.mp3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LeeYip/cocos-framework/d17e4454cb2cedc6ee3149405ec699eb8d75be5b/assets/resources/audio/sfx2.mp3 -------------------------------------------------------------------------------- /assets/resources/audio/sfx2.mp3.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "2.0.3", 3 | "uuid": "98b6b5f6-aa8b-4852-a2d9-72d3dd98393f", 4 | "importer": "audio-clip", 5 | "downloadMode": 0, 6 | "duration": 0.866083, 7 | "subMetas": {} 8 | } -------------------------------------------------------------------------------- /assets/resources/prefab.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.1.3", 3 | "uuid": "a9387296-b8c9-4fd3-9a04-00396d3df2b2", 4 | "importer": "folder", 5 | "isBundle": false, 6 | "bundleName": "", 7 | "priority": 1, 8 | "compressionType": {}, 9 | "optimizeHotUpdate": {}, 10 | "inlineSpriteFrames": {}, 11 | "isRemoteBundle": {}, 12 | "subMetas": {} 13 | } -------------------------------------------------------------------------------- /assets/resources/prefab/dialog.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.1.3", 3 | "uuid": "089f34b2-e4b2-4f58-8a8e-0f1452d71bc0", 4 | "importer": "folder", 5 | "isBundle": false, 6 | "bundleName": "", 7 | "priority": 1, 8 | "compressionType": {}, 9 | "optimizeHotUpdate": {}, 10 | "inlineSpriteFrames": {}, 11 | "isRemoteBundle": {}, 12 | "subMetas": {} 13 | } -------------------------------------------------------------------------------- /assets/resources/prefab/dialog/DlgAnimValue.prefab.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.3.2", 3 | "uuid": "eb6d5018-3d55-4e20-9625-29af0808e40c", 4 | "importer": "prefab", 5 | "optimizationPolicy": "AUTO", 6 | "asyncLoadAssets": false, 7 | "readonly": false, 8 | "subMetas": {} 9 | } -------------------------------------------------------------------------------- /assets/resources/prefab/dialog/DlgAudio.prefab.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.3.2", 3 | "uuid": "5528a12a-f6bd-446f-89bf-7169feed193e", 4 | "importer": "prefab", 5 | "optimizationPolicy": "AUTO", 6 | "asyncLoadAssets": false, 7 | "readonly": false, 8 | "subMetas": {} 9 | } -------------------------------------------------------------------------------- /assets/resources/prefab/dialog/DlgButton.prefab.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.3.2", 3 | "uuid": "e75c176c-520b-4a83-a942-13f9e0031acf", 4 | "importer": "prefab", 5 | "optimizationPolicy": "AUTO", 6 | "asyncLoadAssets": false, 7 | "readonly": false, 8 | "subMetas": {} 9 | } -------------------------------------------------------------------------------- /assets/resources/prefab/dialog/DlgCircleList.prefab.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.3.2", 3 | "uuid": "96450dbc-5e7d-4e91-a983-8b530d3c1c4f", 4 | "importer": "prefab", 5 | "optimizationPolicy": "AUTO", 6 | "asyncLoadAssets": false, 7 | "readonly": false, 8 | "subMetas": {} 9 | } -------------------------------------------------------------------------------- /assets/resources/prefab/dialog/DlgEvents.prefab.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.3.2", 3 | "uuid": "eac3453b-febd-4423-b500-afed388e8285", 4 | "importer": "prefab", 5 | "optimizationPolicy": "AUTO", 6 | "asyncLoadAssets": false, 7 | "readonly": false, 8 | "subMetas": {} 9 | } -------------------------------------------------------------------------------- /assets/resources/prefab/dialog/DlgI18N.prefab.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.3.2", 3 | "uuid": "4517dbc4-a6e0-4e1d-8753-07a2a02f0e64", 4 | "importer": "prefab", 5 | "optimizationPolicy": "AUTO", 6 | "asyncLoadAssets": false, 7 | "readonly": false, 8 | "subMetas": {} 9 | } -------------------------------------------------------------------------------- /assets/resources/prefab/dialog/DlgLoopList.prefab.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.3.2", 3 | "uuid": "d7056117-c3be-4828-baf1-bf311d705f98", 4 | "importer": "prefab", 5 | "optimizationPolicy": "AUTO", 6 | "asyncLoadAssets": false, 7 | "readonly": false, 8 | "subMetas": {} 9 | } -------------------------------------------------------------------------------- /assets/resources/prefab/dialog/DlgMultiTexture.prefab.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.3.2", 3 | "uuid": "d66a9e91-5fbf-4e65-855c-f85f1af61003", 4 | "importer": "prefab", 5 | "optimizationPolicy": "AUTO", 6 | "asyncLoadAssets": false, 7 | "readonly": false, 8 | "subMetas": {} 9 | } -------------------------------------------------------------------------------- /assets/resources/prefab/dialog/DlgShader.prefab.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.3.2", 3 | "uuid": "ad67ef95-35bf-4a55-ba45-b7a7d770fa42", 4 | "importer": "prefab", 5 | "optimizationPolicy": "AUTO", 6 | "asyncLoadAssets": false, 7 | "readonly": false, 8 | "subMetas": {} 9 | } -------------------------------------------------------------------------------- /assets/resources/prefab/dialog/DlgShake.prefab.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.3.2", 3 | "uuid": "3a17d732-eef8-466c-801b-89a592e02c2e", 4 | "importer": "prefab", 5 | "optimizationPolicy": "AUTO", 6 | "asyncLoadAssets": false, 7 | "readonly": false, 8 | "subMetas": {} 9 | } -------------------------------------------------------------------------------- /assets/resources/prefab/dialog/DlgTimer.prefab.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.3.2", 3 | "uuid": "ab3387fa-4818-4fe1-af42-36456c066f44", 4 | "importer": "prefab", 5 | "optimizationPolicy": "AUTO", 6 | "asyncLoadAssets": false, 7 | "readonly": false, 8 | "subMetas": {} 9 | } -------------------------------------------------------------------------------- /assets/resources/prefab/dialog/DlgVirtualList.prefab.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.3.2", 3 | "uuid": "af6cbfbc-bae1-4de7-b425-2be6a4791e79", 4 | "importer": "prefab", 5 | "optimizationPolicy": "AUTO", 6 | "asyncLoadAssets": false, 7 | "readonly": false, 8 | "subMetas": {} 9 | } -------------------------------------------------------------------------------- /assets/resources/prefab/dialog/DlgVirtualList2.prefab.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.3.2", 3 | "uuid": "2322ebd0-1ac5-4150-bd50-2f170b230f60", 4 | "importer": "prefab", 5 | "optimizationPolicy": "AUTO", 6 | "asyncLoadAssets": false, 7 | "readonly": false, 8 | "subMetas": {} 9 | } -------------------------------------------------------------------------------- /assets/resources/prefab/dialog/layer.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.1.3", 3 | "uuid": "cdecf088-dc2e-4b1d-85dc-852c81b437ea", 4 | "importer": "folder", 5 | "isBundle": false, 6 | "bundleName": "", 7 | "priority": 1, 8 | "compressionType": {}, 9 | "optimizeHotUpdate": {}, 10 | "inlineSpriteFrames": {}, 11 | "isRemoteBundle": {}, 12 | "subMetas": {} 13 | } -------------------------------------------------------------------------------- /assets/resources/prefab/dialog/layer/DlgLayer.prefab.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.3.2", 3 | "uuid": "5ee5220c-826e-4cce-9879-ddc0da2d6c25", 4 | "importer": "prefab", 5 | "optimizationPolicy": "AUTO", 6 | "asyncLoadAssets": false, 7 | "readonly": false, 8 | "subMetas": {} 9 | } -------------------------------------------------------------------------------- /assets/resources/prefab/dialog/layer/DlgLayer2.prefab.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.3.2", 3 | "uuid": "d1960493-c334-4d25-8d29-a77ad213f668", 4 | "importer": "prefab", 5 | "optimizationPolicy": "AUTO", 6 | "asyncLoadAssets": false, 7 | "readonly": false, 8 | "subMetas": {} 9 | } -------------------------------------------------------------------------------- /assets/resources/prefab/dialog/layer/DlgLayer3.prefab.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.3.2", 3 | "uuid": "f5b75b4a-4d01-466d-92fb-cc3b0fc2b76d", 4 | "importer": "prefab", 5 | "optimizationPolicy": "AUTO", 6 | "asyncLoadAssets": false, 7 | "readonly": false, 8 | "subMetas": {} 9 | } -------------------------------------------------------------------------------- /assets/resources/prefab/game.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.1.3", 3 | "uuid": "8bd07425-5704-434d-ab39-3c1180504da9", 4 | "importer": "folder", 5 | "isBundle": false, 6 | "bundleName": "", 7 | "priority": 1, 8 | "compressionType": {}, 9 | "optimizeHotUpdate": {}, 10 | "inlineSpriteFrames": {}, 11 | "isRemoteBundle": {}, 12 | "subMetas": {} 13 | } -------------------------------------------------------------------------------- /assets/resources/prefab/game/Game.prefab.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.3.2", 3 | "uuid": "b3482a35-153b-4846-9cfe-fd248ab4bebe", 4 | "importer": "prefab", 5 | "optimizationPolicy": "AUTO", 6 | "asyncLoadAssets": false, 7 | "readonly": false, 8 | "subMetas": {} 9 | } -------------------------------------------------------------------------------- /assets/resources/prefab/home.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.1.3", 3 | "uuid": "51f19643-0c7b-4231-b412-b4f543e6430f", 4 | "importer": "folder", 5 | "isBundle": false, 6 | "bundleName": "", 7 | "priority": 1, 8 | "compressionType": {}, 9 | "optimizeHotUpdate": {}, 10 | "inlineSpriteFrames": {}, 11 | "isRemoteBundle": {}, 12 | "subMetas": {} 13 | } -------------------------------------------------------------------------------- /assets/resources/prefab/home/Home.prefab.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.3.2", 3 | "uuid": "e6a124fc-3100-4005-82ef-288774182675", 4 | "importer": "prefab", 5 | "optimizationPolicy": "AUTO", 6 | "asyncLoadAssets": false, 7 | "readonly": false, 8 | "subMetas": {} 9 | } -------------------------------------------------------------------------------- /assets/resources/prefab/tip.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.1.3", 3 | "uuid": "b61126b1-5a42-4e63-938d-0529de825a67", 4 | "importer": "folder", 5 | "isBundle": false, 6 | "bundleName": "", 7 | "priority": 1, 8 | "compressionType": {}, 9 | "optimizeHotUpdate": {}, 10 | "inlineSpriteFrames": {}, 11 | "isRemoteBundle": {}, 12 | "subMetas": {} 13 | } -------------------------------------------------------------------------------- /assets/resources/prefab/tip/Tip.prefab.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.3.2", 3 | "uuid": "75d3f38d-19e7-4091-ad3b-9f507048ce15", 4 | "importer": "prefab", 5 | "optimizationPolicy": "AUTO", 6 | "asyncLoadAssets": false, 7 | "readonly": false, 8 | "subMetas": {} 9 | } -------------------------------------------------------------------------------- /assets/resources/textures.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.1.3", 3 | "uuid": "44b4ab3a-6129-42b5-9ef9-f0d2d9bf5c9d", 4 | "importer": "folder", 5 | "isBundle": false, 6 | "bundleName": "", 7 | "priority": 1, 8 | "compressionType": {}, 9 | "optimizeHotUpdate": {}, 10 | "inlineSpriteFrames": {}, 11 | "isRemoteBundle": {}, 12 | "subMetas": {} 13 | } -------------------------------------------------------------------------------- /assets/resources/textures/localizedImage.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.1.3", 3 | "uuid": "e1f3446e-3f48-43de-9f67-851fe5f83e33", 4 | "importer": "folder", 5 | "isBundle": false, 6 | "bundleName": "", 7 | "priority": 1, 8 | "compressionType": {}, 9 | "optimizeHotUpdate": {}, 10 | "inlineSpriteFrames": {}, 11 | "isRemoteBundle": {}, 12 | "subMetas": {} 13 | } -------------------------------------------------------------------------------- /assets/resources/textures/localizedImage/en.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.1.3", 3 | "uuid": "4909162c-4c82-4741-9980-2473248ecb46", 4 | "importer": "folder", 5 | "isBundle": false, 6 | "bundleName": "", 7 | "priority": 1, 8 | "compressionType": {}, 9 | "optimizeHotUpdate": {}, 10 | "inlineSpriteFrames": {}, 11 | "isRemoteBundle": {}, 12 | "subMetas": {} 13 | } -------------------------------------------------------------------------------- /assets/resources/textures/localizedImage/en/AutoAtlas.pac: -------------------------------------------------------------------------------- 1 | { 2 | "__type__": "cc.SpriteAtlas" 3 | } -------------------------------------------------------------------------------- /assets/resources/textures/localizedImage/en/AutoAtlas.pac.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.2.5", 3 | "uuid": "24dac77a-35ec-4824-8bd7-5fa8fec73a62", 4 | "importer": "auto-atlas", 5 | "maxWidth": 1024, 6 | "maxHeight": 1024, 7 | "padding": 2, 8 | "compressionLevel": 6, 9 | "allowRotation": true, 10 | "forceSquared": false, 11 | "powerOfTwo": false, 12 | "algorithm": "MaxRects", 13 | "format": "png", 14 | "quality": 80, 15 | "contourBleed": true, 16 | "paddingBleed": true, 17 | "filterUnused": false, 18 | "packable": false, 19 | "premultiplyAlpha": false, 20 | "filterMode": "bilinear", 21 | "platformSettings": {}, 22 | "subMetas": {} 23 | } -------------------------------------------------------------------------------- /assets/resources/textures/localizedImage/en/lang.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LeeYip/cocos-framework/d17e4454cb2cedc6ee3149405ec699eb8d75be5b/assets/resources/textures/localizedImage/en/lang.png -------------------------------------------------------------------------------- /assets/resources/textures/localizedImage/en/lang.png.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "2.3.7", 3 | "uuid": "532b9ab1-c7b6-49fb-afe4-189332d154ac", 4 | "importer": "texture", 5 | "type": "sprite", 6 | "wrapMode": "clamp", 7 | "filterMode": "bilinear", 8 | "premultiplyAlpha": false, 9 | "genMipmaps": false, 10 | "packable": false, 11 | "width": 300, 12 | "height": 300, 13 | "platformSettings": {}, 14 | "subMetas": { 15 | "lang": { 16 | "ver": "1.0.6", 17 | "uuid": "889375ef-6d50-47d0-9231-2b1021f85798", 18 | "importer": "sprite-frame", 19 | "rawTextureUuid": "532b9ab1-c7b6-49fb-afe4-189332d154ac", 20 | "trimType": "auto", 21 | "trimThreshold": 1, 22 | "rotated": false, 23 | "offsetX": 0, 24 | "offsetY": 19.5, 25 | "trimX": 0, 26 | "trimY": 41, 27 | "width": 300, 28 | "height": 179, 29 | "rawWidth": 300, 30 | "rawHeight": 300, 31 | "borderTop": 0, 32 | "borderBottom": 0, 33 | "borderLeft": 0, 34 | "borderRight": 0, 35 | "subMetas": {} 36 | } 37 | } 38 | } -------------------------------------------------------------------------------- /assets/resources/textures/localizedImage/zh.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.1.3", 3 | "uuid": "6bc3d8e7-719c-46f3-9233-7549118d1533", 4 | "importer": "folder", 5 | "isBundle": false, 6 | "bundleName": "", 7 | "priority": 1, 8 | "compressionType": {}, 9 | "optimizeHotUpdate": {}, 10 | "inlineSpriteFrames": {}, 11 | "isRemoteBundle": {}, 12 | "subMetas": {} 13 | } -------------------------------------------------------------------------------- /assets/resources/textures/localizedImage/zh/AutoAtlas.pac: -------------------------------------------------------------------------------- 1 | { 2 | "__type__": "cc.SpriteAtlas" 3 | } -------------------------------------------------------------------------------- /assets/resources/textures/localizedImage/zh/AutoAtlas.pac.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.2.5", 3 | "uuid": "8d115240-4a9f-4c1d-a49e-4547259e533e", 4 | "importer": "auto-atlas", 5 | "maxWidth": 1024, 6 | "maxHeight": 1024, 7 | "padding": 2, 8 | "compressionLevel": 6, 9 | "allowRotation": true, 10 | "forceSquared": false, 11 | "powerOfTwo": false, 12 | "algorithm": "MaxRects", 13 | "format": "png", 14 | "quality": 80, 15 | "contourBleed": true, 16 | "paddingBleed": true, 17 | "filterUnused": false, 18 | "packable": false, 19 | "premultiplyAlpha": false, 20 | "filterMode": "bilinear", 21 | "platformSettings": {}, 22 | "subMetas": {} 23 | } -------------------------------------------------------------------------------- /assets/resources/textures/localizedImage/zh/lang.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LeeYip/cocos-framework/d17e4454cb2cedc6ee3149405ec699eb8d75be5b/assets/resources/textures/localizedImage/zh/lang.png -------------------------------------------------------------------------------- /assets/resources/textures/localizedImage/zh/lang.png.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "2.3.7", 3 | "uuid": "0a20c584-0173-46e4-b37b-83f696bf6b0b", 4 | "importer": "texture", 5 | "type": "sprite", 6 | "wrapMode": "clamp", 7 | "filterMode": "bilinear", 8 | "premultiplyAlpha": false, 9 | "genMipmaps": false, 10 | "packable": false, 11 | "width": 300, 12 | "height": 300, 13 | "platformSettings": {}, 14 | "subMetas": { 15 | "lang": { 16 | "ver": "1.0.6", 17 | "uuid": "a113662e-6624-4164-b66c-a6cda5e294d6", 18 | "importer": "sprite-frame", 19 | "rawTextureUuid": "0a20c584-0173-46e4-b37b-83f696bf6b0b", 20 | "trimType": "auto", 21 | "trimThreshold": 1, 22 | "rotated": false, 23 | "offsetX": 0, 24 | "offsetY": 8.5, 25 | "trimX": 0, 26 | "trimY": 22, 27 | "width": 300, 28 | "height": 239, 29 | "rawWidth": 300, 30 | "rawHeight": 300, 31 | "borderTop": 0, 32 | "borderBottom": 0, 33 | "borderLeft": 0, 34 | "borderRight": 0, 35 | "subMetas": {} 36 | } 37 | } 38 | } -------------------------------------------------------------------------------- /assets/resources/textures/showcase.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.1.3", 3 | "uuid": "5bc0bd2a-8a06-474a-ad69-6ebf9a20c2cd", 4 | "importer": "folder", 5 | "isBundle": false, 6 | "bundleName": "", 7 | "priority": 1, 8 | "compressionType": {}, 9 | "optimizeHotUpdate": {}, 10 | "inlineSpriteFrames": {}, 11 | "isRemoteBundle": {}, 12 | "subMetas": {} 13 | } -------------------------------------------------------------------------------- /assets/resources/textures/showcase/circle.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LeeYip/cocos-framework/d17e4454cb2cedc6ee3149405ec699eb8d75be5b/assets/resources/textures/showcase/circle.png -------------------------------------------------------------------------------- /assets/resources/textures/showcase/circle.png.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "2.3.7", 3 | "uuid": "0fea5d4f-b82a-4cc5-a826-5c49c9f98b20", 4 | "importer": "texture", 5 | "type": "sprite", 6 | "wrapMode": "clamp", 7 | "filterMode": "bilinear", 8 | "premultiplyAlpha": false, 9 | "genMipmaps": false, 10 | "packable": true, 11 | "width": 150, 12 | "height": 150, 13 | "platformSettings": {}, 14 | "subMetas": { 15 | "circle": { 16 | "ver": "1.0.6", 17 | "uuid": "40d5d2c5-5bd9-49ce-be62-8e3b813bad40", 18 | "importer": "sprite-frame", 19 | "rawTextureUuid": "0fea5d4f-b82a-4cc5-a826-5c49c9f98b20", 20 | "trimType": "auto", 21 | "trimThreshold": 1, 22 | "rotated": false, 23 | "offsetX": 0, 24 | "offsetY": 0, 25 | "trimX": 0, 26 | "trimY": 0, 27 | "width": 150, 28 | "height": 150, 29 | "rawWidth": 150, 30 | "rawHeight": 150, 31 | "borderTop": 0, 32 | "borderBottom": 0, 33 | "borderLeft": 0, 34 | "borderRight": 0, 35 | "subMetas": {} 36 | } 37 | } 38 | } -------------------------------------------------------------------------------- /assets/scenes.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.1.3", 3 | "uuid": "6f63145c-1c28-4115-84ff-74718b4004c4", 4 | "importer": "folder", 5 | "isBundle": false, 6 | "bundleName": "", 7 | "priority": 1, 8 | "compressionType": {}, 9 | "optimizeHotUpdate": {}, 10 | "inlineSpriteFrames": {}, 11 | "isRemoteBundle": {}, 12 | "subMetas": {} 13 | } -------------------------------------------------------------------------------- /assets/scenes/Main.fire.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.3.2", 3 | "uuid": "fafab544-3253-4695-b807-f3616f90183b", 4 | "importer": "scene", 5 | "asyncLoadAssets": false, 6 | "autoReleaseAssets": false, 7 | "subMetas": {} 8 | } -------------------------------------------------------------------------------- /assets/scripts.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.1.3", 3 | "uuid": "66f9cd20-ad33-4744-906a-8ff310715aef", 4 | "importer": "folder", 5 | "isBundle": false, 6 | "bundleName": "", 7 | "priority": 1, 8 | "compressionType": {}, 9 | "optimizeHotUpdate": {}, 10 | "inlineSpriteFrames": {}, 11 | "isRemoteBundle": {}, 12 | "subMetas": {} 13 | } -------------------------------------------------------------------------------- /assets/scripts/animator.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.1.3", 3 | "uuid": "a7cfde2a-3474-4653-bbbf-328521025c18", 4 | "importer": "folder", 5 | "isBundle": false, 6 | "bundleName": "", 7 | "priority": 1, 8 | "compressionType": {}, 9 | "optimizeHotUpdate": {}, 10 | "inlineSpriteFrames": {}, 11 | "isRemoteBundle": {}, 12 | "subMetas": {} 13 | } -------------------------------------------------------------------------------- /assets/scripts/animator/AnimatorAnimation.ts: -------------------------------------------------------------------------------- 1 | import AnimatorBase, { AnimationPlayer } from "./core/AnimatorBase"; 2 | import AnimatorStateLogic from "./core/AnimatorStateLogic"; 3 | 4 | const { ccclass, property, requireComponent, disallowMultiple, menu } = cc._decorator; 5 | 6 | /** 7 | * Cocos Animation状态机组件 8 | */ 9 | @ccclass 10 | @disallowMultiple 11 | @requireComponent(cc.Animation) 12 | @menu('Framework/Animator/AnimatorAnimation') 13 | export default class AnimatorAnimation extends AnimatorBase { 14 | /** Animation组件 */ 15 | private _animation: cc.Animation = null; 16 | /** 当前的动画实例 */ 17 | private _animState: cc.AnimationState = null; 18 | /** 记录初始的wrapmode */ 19 | private _wrapModeMap: Map = new Map(); 20 | 21 | protected start() { 22 | if (!this.playOnStart || this._hasInit) { 23 | return; 24 | } 25 | this._hasInit = true; 26 | 27 | this._animation = this.getComponent(cc.Animation); 28 | this._animation.on(cc.Animation.EventType.FINISHED, this.onAnimFinished, this); 29 | this._animation.on(cc.Animation.EventType.LASTFRAME, this.onAnimFinished, this); 30 | 31 | if (this.assetRawUrl !== null) { 32 | this.initJson(this.assetRawUrl.json); 33 | } 34 | } 35 | 36 | /** 37 | * 手动初始化状态机,可传入0-3个参数,类型如下 38 | * - onStateChangeCall 状态切换时的回调 39 | * - stateLogicMap 各个状态逻辑控制 40 | * - animationPlayer 自定义动画控制 41 | * @override 42 | */ 43 | public onInit(...args: Array | ((fromState: string, toState: string) => void) | AnimationPlayer>) { 44 | if (this.playOnStart || this._hasInit) { 45 | return; 46 | } 47 | this._hasInit = true; 48 | 49 | this.initArgs(...args); 50 | 51 | this._animation = this.getComponent(cc.Animation); 52 | this._animation.on(cc.Animation.EventType.FINISHED, this.onAnimFinished, this); 53 | this._animation.on(cc.Animation.EventType.LASTFRAME, this.onAnimFinished, this); 54 | 55 | if (this.assetRawUrl !== null) { 56 | this.initJson(this.assetRawUrl.json); 57 | } 58 | } 59 | 60 | /** 61 | * 播放动画 62 | * @override 63 | * @param animName 动画名 64 | * @param loop 是否循环播放 65 | */ 66 | protected playAnimation(animName: string, loop: boolean) { 67 | if (!animName) { 68 | return; 69 | } 70 | 71 | this._animState = this._animation.play(animName); 72 | if (!this._animState) { 73 | return; 74 | } 75 | if (!this._wrapModeMap.has(this._animState)) { 76 | this._wrapModeMap.set(this._animState, this._animState.wrapMode); 77 | } 78 | this._animState.wrapMode = loop ? cc.WrapMode.Loop : this._wrapModeMap.get(this._animState); 79 | } 80 | 81 | /** 82 | * 缩放动画播放速率 83 | * @override 84 | * @param scale 缩放倍率 85 | */ 86 | protected scaleTime(scale: number) { 87 | if (this._animState) { 88 | this._animState.speed = scale; 89 | } 90 | } 91 | } 92 | -------------------------------------------------------------------------------- /assets/scripts/animator/AnimatorAnimation.ts.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.1.0", 3 | "uuid": "ddcbc1d0-74f1-4e7d-8fa6-031b92449ec4", 4 | "importer": "typescript", 5 | "isPlugin": false, 6 | "loadPluginInWeb": true, 7 | "loadPluginInNative": true, 8 | "loadPluginInEditor": false, 9 | "subMetas": {} 10 | } -------------------------------------------------------------------------------- /assets/scripts/animator/AnimatorCustomization.ts: -------------------------------------------------------------------------------- 1 | import AnimatorBase, { AnimationPlayer } from "./core/AnimatorBase"; 2 | import AnimatorStateLogic from "./core/AnimatorStateLogic"; 3 | 4 | const { ccclass, property, requireComponent, disallowMultiple, menu } = cc._decorator; 5 | 6 | /** 7 | * 自定义动画控制的状态机组件 8 | */ 9 | @ccclass 10 | @disallowMultiple 11 | @menu('Framework/Animator/AnimatorCustomization') 12 | export default class AnimatorCustomization extends AnimatorBase { 13 | /** 此组件必须主动调用onInit初始化 */ 14 | @property({ override: true, visible: false }) 15 | protected playOnStart: boolean = false; 16 | 17 | /** 18 | * 手动初始化状态机,可传入0-3个参数,类型如下 19 | * - onStateChangeCall 状态切换时的回调 20 | * - stateLogicMap 各个状态逻辑控制 21 | * - animationPlayer 自定义动画控制 22 | * @override 23 | */ 24 | public onInit(...args: Array | ((fromState: string, toState: string) => void) | AnimationPlayer>) { 25 | if (this._hasInit) { 26 | return; 27 | } 28 | this._hasInit = true; 29 | 30 | this.initArgs(...args); 31 | 32 | if (this.assetRawUrl !== null) { 33 | this.initJson(this.assetRawUrl.json); 34 | } 35 | } 36 | 37 | /** 38 | * 播放动画 39 | * @override 40 | * @param animName 动画名 41 | * @param loop 是否循环播放 42 | */ 43 | protected playAnimation(animName: string, loop: boolean) { 44 | if (this._animationPlayer && animName) { 45 | this._animationPlayer.playAnimation(animName, loop); 46 | } 47 | } 48 | 49 | /** 50 | * 缩放动画播放速率 51 | * @override 52 | * @param scale 缩放倍率 53 | */ 54 | protected scaleTime(scale: number) { 55 | if (this._animationPlayer) { 56 | this._animationPlayer.scaleTime(scale); 57 | } 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /assets/scripts/animator/AnimatorCustomization.ts.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.1.0", 3 | "uuid": "32e01408-af0b-4fe1-bb8a-3120314c99ab", 4 | "importer": "typescript", 5 | "isPlugin": false, 6 | "loadPluginInWeb": true, 7 | "loadPluginInNative": true, 8 | "loadPluginInEditor": false, 9 | "subMetas": {} 10 | } -------------------------------------------------------------------------------- /assets/scripts/animator/AnimatorDragonBones.ts: -------------------------------------------------------------------------------- 1 | import AnimatorBase, { AnimationPlayer } from "./core/AnimatorBase"; 2 | import AnimatorStateLogic from "./core/AnimatorStateLogic"; 3 | 4 | const { ccclass, property, requireComponent, disallowMultiple, menu } = cc._decorator; 5 | 6 | /** 7 | * DragonBones状态机组件 8 | */ 9 | @ccclass 10 | @disallowMultiple 11 | @requireComponent(dragonBones.ArmatureDisplay) 12 | @menu('Framework/Animator/AnimatorDragonBones') 13 | export default class AnimatorDragonBones extends AnimatorBase { 14 | /** DragonBones组件 */ 15 | private _dragonBones: dragonBones.ArmatureDisplay = null; 16 | 17 | protected start() { 18 | if (!this.playOnStart || this._hasInit) { 19 | return; 20 | } 21 | this._hasInit = true; 22 | 23 | this._dragonBones = this.getComponent(dragonBones.ArmatureDisplay); 24 | this._dragonBones.addEventListener(dragonBones.EventObject.COMPLETE, this.onAnimFinished, this); 25 | 26 | if (this.assetRawUrl !== null) { 27 | this.initJson(this.assetRawUrl.json); 28 | } 29 | } 30 | 31 | /** 32 | * 手动初始化状态机,可传入0-3个参数,类型如下 33 | * - onStateChangeCall 状态切换时的回调 34 | * - stateLogicMap 各个状态逻辑控制 35 | * - animationPlayer 自定义动画控制 36 | * @override 37 | */ 38 | public onInit(...args: Array | ((fromState: string, toState: string) => void) | AnimationPlayer>) { 39 | if (this.playOnStart || this._hasInit) { 40 | return; 41 | } 42 | this._hasInit = true; 43 | 44 | this.initArgs(...args); 45 | 46 | this._dragonBones = this.getComponent(dragonBones.ArmatureDisplay); 47 | this._dragonBones.addEventListener(dragonBones.EventObject.COMPLETE, this.onAnimFinished, this); 48 | 49 | if (this.assetRawUrl !== null) { 50 | this.initJson(this.assetRawUrl.json); 51 | } 52 | } 53 | 54 | /** 55 | * 播放动画 56 | * @override 57 | * @param animName 动画名 58 | * @param loop 是否循环播放 59 | */ 60 | protected playAnimation(animName: string, loop: boolean) { 61 | animName && this._dragonBones.playAnimation(animName, loop ? 0 : -1); 62 | } 63 | 64 | /** 65 | * 缩放动画播放速率 66 | * @override 67 | * @param scale 缩放倍率 68 | */ 69 | protected scaleTime(scale: number) { 70 | this._dragonBones.timeScale = scale; 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /assets/scripts/animator/AnimatorDragonBones.ts.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.1.0", 3 | "uuid": "0592fdb2-d689-40d1-b2b5-0dd9d80daa04", 4 | "importer": "typescript", 5 | "isPlugin": false, 6 | "loadPluginInWeb": true, 7 | "loadPluginInNative": true, 8 | "loadPluginInEditor": false, 9 | "subMetas": {} 10 | } -------------------------------------------------------------------------------- /assets/scripts/animator/AnimatorSpine.ts.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.1.0", 3 | "uuid": "8f2247a2-0287-4cf1-821c-8eb67407dccd", 4 | "importer": "typescript", 5 | "isPlugin": false, 6 | "loadPluginInWeb": true, 7 | "loadPluginInNative": true, 8 | "loadPluginInEditor": false, 9 | "subMetas": {} 10 | } -------------------------------------------------------------------------------- /assets/scripts/animator/AnimatorSpineSecondary.ts: -------------------------------------------------------------------------------- 1 | import AnimatorSpine from "./AnimatorSpine"; 2 | import AnimatorBase, { AnimationPlayer } from "./core/AnimatorBase"; 3 | import AnimatorStateLogic from "./core/AnimatorStateLogic"; 4 | 5 | const { ccclass, property, requireComponent, menu } = cc._decorator; 6 | 7 | /** 8 | * Spine状态机组件(次状态机),同一节点可添加多个,用于在不同track中播放动画,trackIndex必须大于0 9 | */ 10 | @ccclass 11 | @requireComponent(sp.Skeleton) 12 | @menu('Framework/Animator/AnimatorSpineSecondary') 13 | export default class AnimatorSpineSecondary extends AnimatorBase { 14 | @property({ tooltip: CC_DEV && '动画播放的trackIndex,必须大于0' }) trackIndex: number = 1; 15 | 16 | /** 主状态机 */ 17 | private _main: AnimatorSpine = null; 18 | /** spine组件 */ 19 | private _spine: sp.Skeleton = null; 20 | 21 | protected start() { 22 | if (!this.playOnStart || this._hasInit) { 23 | return; 24 | } 25 | this._hasInit = true; 26 | 27 | this._spine = this.getComponent(sp.Skeleton); 28 | this._main = this.getComponent(AnimatorSpine); 29 | this._main.addSecondaryListener(this.onAnimFinished, this); 30 | 31 | if (this.assetRawUrl !== null) { 32 | this.initJson(this.assetRawUrl.json); 33 | } 34 | } 35 | 36 | /** 37 | * 手动初始化状态机,可传入0-3个参数,类型如下 38 | * - onStateChangeCall 状态切换时的回调 39 | * - stateLogicMap 各个状态逻辑控制 40 | * - animationPlayer 自定义动画控制 41 | * @override 42 | */ 43 | public onInit(...args: Array | ((fromState: string, toState: string) => void) | AnimationPlayer>) { 44 | if (this.playOnStart || this._hasInit) { 45 | return; 46 | } 47 | this._hasInit = true; 48 | 49 | this.initArgs(...args); 50 | 51 | this._spine = this.getComponent(sp.Skeleton); 52 | this._main = this.getComponent(AnimatorSpine); 53 | this._main.addSecondaryListener(this.onAnimFinished, this); 54 | 55 | if (this.assetRawUrl !== null) { 56 | this.initJson(this.assetRawUrl.json); 57 | } 58 | } 59 | 60 | /** 61 | * 播放动画 62 | * @override 63 | * @param animName 动画名 64 | * @param loop 是否循环播放 65 | */ 66 | protected playAnimation(animName: string, loop: boolean) { 67 | if (animName) { 68 | this._spine.setAnimation(this.trackIndex, animName, loop); 69 | } else { 70 | this._spine.clearTrack(this.trackIndex); 71 | } 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /assets/scripts/animator/AnimatorSpineSecondary.ts.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.1.0", 3 | "uuid": "24889df8-fd29-413d-8f67-82cbbc52a5a8", 4 | "importer": "typescript", 5 | "isPlugin": false, 6 | "loadPluginInWeb": true, 7 | "loadPluginInNative": true, 8 | "loadPluginInEditor": false, 9 | "subMetas": {} 10 | } -------------------------------------------------------------------------------- /assets/scripts/animator/core.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.1.3", 3 | "uuid": "bf6e640e-b5fe-460f-8f43-422638ec65da", 4 | "importer": "folder", 5 | "isBundle": false, 6 | "bundleName": "", 7 | "priority": 1, 8 | "compressionType": {}, 9 | "optimizeHotUpdate": {}, 10 | "inlineSpriteFrames": {}, 11 | "isRemoteBundle": {}, 12 | "subMetas": {} 13 | } -------------------------------------------------------------------------------- /assets/scripts/animator/core/AnimatorBase.ts.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.1.0", 3 | "uuid": "33dab704-593e-4896-a60b-4c3fe8cef8e5", 4 | "importer": "typescript", 5 | "isPlugin": false, 6 | "loadPluginInWeb": true, 7 | "loadPluginInNative": true, 8 | "loadPluginInEditor": false, 9 | "subMetas": {} 10 | } -------------------------------------------------------------------------------- /assets/scripts/animator/core/AnimatorCondition.ts: -------------------------------------------------------------------------------- 1 | import AnimatorController from "./AnimatorController"; 2 | 3 | /** 参数类型 */ 4 | export enum ParamType { 5 | COMPLETE = 0, 6 | BOOLEAN = 1, 7 | NUMBER = 2, 8 | TRIGGER = 3, 9 | AUTO_TRIGGER = 4 10 | } 11 | 12 | /** 逻辑类型 */ 13 | export enum LogicType { 14 | EQUAL = 0, 15 | NOTEQUAL = 1, 16 | GREATER = 2, 17 | LESS = 3, 18 | GREATER_EQUAL = 4, 19 | LESS_EQUAL = 5 20 | } 21 | 22 | /** 23 | * 单项条件 24 | */ 25 | export default class AnimatorCondition { 26 | private _ac: AnimatorController = null; 27 | /** 此条件对应的参数名 */ 28 | private _param: string = ""; 29 | /** 此条件对应的值 */ 30 | private _value: number = 0; 31 | /** 此条件与值比较的逻辑 */ 32 | private _logic: LogicType = LogicType.EQUAL; 33 | 34 | constructor(data: any, ac: AnimatorController) { 35 | this._ac = ac; 36 | this._param = data.param; 37 | this._value = data.value; 38 | this._logic = data.logic; 39 | } 40 | 41 | public getParamName() { 42 | return this._param; 43 | } 44 | 45 | public getParamType(): ParamType { 46 | return this._ac.params.getParamType(this._param); 47 | } 48 | 49 | /** 判断此条件是否满足 */ 50 | public check(): boolean { 51 | let type: ParamType = this.getParamType(); 52 | if (type === ParamType.BOOLEAN) { 53 | return this._ac.params.getBool(this._param) === this._value; 54 | } else if (type === ParamType.NUMBER) { 55 | let value: number = this._ac.params.getNumber(this._param); 56 | switch (this._logic) { 57 | case LogicType.EQUAL: 58 | return value === this._value; 59 | case LogicType.NOTEQUAL: 60 | return value !== this._value; 61 | case LogicType.GREATER: 62 | return value > this._value; 63 | case LogicType.LESS: 64 | return value < this._value; 65 | case LogicType.GREATER_EQUAL: 66 | return value >= this._value; 67 | case LogicType.LESS_EQUAL: 68 | return value <= this._value; 69 | default: 70 | return false; 71 | } 72 | } else if (type === ParamType.AUTO_TRIGGER) { 73 | return this._ac.params.getAutoTrigger(this._param) !== 0; 74 | } else if (type === ParamType.TRIGGER) { 75 | return this._ac.params.getTrigger(this._param) !== 0; 76 | } else { 77 | cc.error(`[AnimatorCondition.check] 错误的type: ${type}`); 78 | return false; 79 | } 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /assets/scripts/animator/core/AnimatorCondition.ts.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.1.0", 3 | "uuid": "dee7bfc7-373b-47ca-a159-b9c1448d6f12", 4 | "importer": "typescript", 5 | "isPlugin": false, 6 | "loadPluginInWeb": true, 7 | "loadPluginInNative": true, 8 | "loadPluginInEditor": false, 9 | "subMetas": {} 10 | } -------------------------------------------------------------------------------- /assets/scripts/animator/core/AnimatorController.ts.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.1.0", 3 | "uuid": "de78501a-e25a-451f-9f42-30257511bef8", 4 | "importer": "typescript", 5 | "isPlugin": false, 6 | "loadPluginInWeb": true, 7 | "loadPluginInNative": true, 8 | "loadPluginInEditor": false, 9 | "subMetas": {} 10 | } -------------------------------------------------------------------------------- /assets/scripts/animator/core/AnimatorParams.ts: -------------------------------------------------------------------------------- 1 | import { ParamType } from "./AnimatorCondition"; 2 | 3 | /** 4 | * 参数结构 5 | */ 6 | interface Param { 7 | type: ParamType; 8 | value: number; 9 | } 10 | 11 | /** 12 | * 状态机参数 13 | */ 14 | export default class AnimatorParams { 15 | private _paramMap: Map = new Map(); 16 | 17 | constructor(dataArr: any[]) { 18 | dataArr.forEach((data: any) => { 19 | let param: Param = { 20 | type: data.type, 21 | value: data.init 22 | }; 23 | this._paramMap.set(data.param, param); 24 | }); 25 | } 26 | 27 | public getParamType(key: string): ParamType { 28 | let param: Param = this._paramMap.get(key); 29 | if (param) { 30 | return param.type; 31 | } else { 32 | return null; 33 | } 34 | } 35 | 36 | public setNumber(key: string, value: number) { 37 | let param: Param = this._paramMap.get(key); 38 | if (param && param.type === ParamType.NUMBER) { 39 | param.value = value; 40 | } 41 | } 42 | 43 | public setBool(key: string, value: boolean) { 44 | let param: Param = this._paramMap.get(key); 45 | if (param && param.type === ParamType.BOOLEAN) { 46 | param.value = value ? 1 : 0; 47 | } 48 | } 49 | 50 | public setTrigger(key: string) { 51 | let param: Param = this._paramMap.get(key); 52 | if (param && param.type === ParamType.TRIGGER) { 53 | param.value = 1; 54 | } 55 | } 56 | 57 | public resetTrigger(key: string) { 58 | let param: Param = this._paramMap.get(key); 59 | if (param && param.type === ParamType.TRIGGER) { 60 | param.value = 0; 61 | } 62 | } 63 | 64 | public autoTrigger(key: string) { 65 | let param: Param = this._paramMap.get(key); 66 | if (param && param.type === ParamType.AUTO_TRIGGER) { 67 | param.value = 1; 68 | } 69 | } 70 | 71 | public resetAutoTrigger(key: string) { 72 | let param: Param = this._paramMap.get(key); 73 | if (param && param.type === ParamType.AUTO_TRIGGER) { 74 | param.value = 0; 75 | } 76 | } 77 | 78 | public resetAllAutoTrigger() { 79 | this._paramMap.forEach((param: Param, key: string) => { 80 | if (param.type === ParamType.AUTO_TRIGGER) { 81 | param.value = 0; 82 | } 83 | }); 84 | } 85 | 86 | public getNumber(key: string): number { 87 | let param: Param = this._paramMap.get(key); 88 | if (param && param.type === ParamType.NUMBER) { 89 | return param.value; 90 | } else { 91 | return 0; 92 | } 93 | } 94 | 95 | public getBool(key: string): number { 96 | let param: Param = this._paramMap.get(key); 97 | if (param && param.type === ParamType.BOOLEAN) { 98 | return param.value; 99 | } else { 100 | return 0; 101 | } 102 | } 103 | 104 | public getTrigger(key: string): number { 105 | let param: Param = this._paramMap.get(key); 106 | if (param && param.type === ParamType.TRIGGER) { 107 | return param.value; 108 | } else { 109 | return 0; 110 | } 111 | } 112 | 113 | public getAutoTrigger(key: string): number { 114 | let param: Param = this._paramMap.get(key); 115 | if (param && param.type === ParamType.AUTO_TRIGGER) { 116 | return param.value; 117 | } else { 118 | return 0; 119 | } 120 | } 121 | } 122 | -------------------------------------------------------------------------------- /assets/scripts/animator/core/AnimatorParams.ts.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.1.0", 3 | "uuid": "472508a2-13cb-4a51-917a-b6315495f328", 4 | "importer": "typescript", 5 | "isPlugin": false, 6 | "loadPluginInWeb": true, 7 | "loadPluginInNative": true, 8 | "loadPluginInEditor": false, 9 | "subMetas": {} 10 | } -------------------------------------------------------------------------------- /assets/scripts/animator/core/AnimatorState.ts: -------------------------------------------------------------------------------- 1 | import AnimatorController from "./AnimatorController"; 2 | import AnimatorTransition from "./AnimatorTransition"; 3 | 4 | /** 5 | * 状态管理类 6 | */ 7 | export default class AnimatorState { 8 | private _name: string = ""; 9 | private _motion: string = ""; 10 | private _loop: boolean = false; 11 | private _speed: number = 1; 12 | private _multi: string = ""; 13 | 14 | private _transitions: AnimatorTransition[] = []; 15 | private _ac: AnimatorController = null; 16 | 17 | /** 状态名 */ 18 | public get name() { return this._name; } 19 | /** 动画名 */ 20 | public get motion() { return this._motion; } 21 | /** 动画是否循环播放 */ 22 | public get loop() { return this._loop; } 23 | /** 动画播放速度 */ 24 | public get speed() { return this._speed; } 25 | /** 动画播放速度的混合参数 */ 26 | public get multi() { return this._multi; } 27 | 28 | constructor(data: any, ac: AnimatorController) { 29 | this._name = data.state; 30 | this._motion = data.motion || ''; 31 | this._loop = data.loop || false; 32 | this._speed = data.speed || 1; 33 | this._multi = data.multiplier || ''; 34 | 35 | this._ac = ac; 36 | 37 | for (let i = 0; i < data.transitions.length; i++) { 38 | let transition: AnimatorTransition = new AnimatorTransition(data.transitions[i], ac); 39 | transition.isValid() && this._transitions.push(transition); 40 | } 41 | } 42 | 43 | /** 44 | * 判断各个分支是否满足条件,满足则转换状态 45 | */ 46 | public checkAndTrans() { 47 | for (let i = 0; i < this._transitions.length; i++) { 48 | let transition: AnimatorTransition = this._transitions[i]; 49 | if (transition && transition.check()) { 50 | transition.doTrans(); 51 | return; 52 | } 53 | } 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /assets/scripts/animator/core/AnimatorState.ts.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.1.0", 3 | "uuid": "c1d25c48-827e-4cdd-96b1-5885759f98a2", 4 | "importer": "typescript", 5 | "isPlugin": false, 6 | "loadPluginInWeb": true, 7 | "loadPluginInNative": true, 8 | "loadPluginInEditor": false, 9 | "subMetas": {} 10 | } -------------------------------------------------------------------------------- /assets/scripts/animator/core/AnimatorStateLogic.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * 状态逻辑基类 3 | */ 4 | export default class AnimatorStateLogic { 5 | /** 6 | * 进入状态时调用 7 | * @virtual 8 | */ 9 | public onEntry() { 10 | } 11 | 12 | /** 13 | * 每次状态机逻辑更新时调用 14 | * @virtual 15 | */ 16 | public onUpdate() { 17 | } 18 | 19 | /** 20 | * 离开状态时调用 21 | * @virtual 22 | */ 23 | public onExit() { 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /assets/scripts/animator/core/AnimatorStateLogic.ts.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.1.0", 3 | "uuid": "67f8046d-a5c8-4f6d-b66b-e8e60153c348", 4 | "importer": "typescript", 5 | "isPlugin": false, 6 | "loadPluginInWeb": true, 7 | "loadPluginInNative": true, 8 | "loadPluginInEditor": false, 9 | "subMetas": {} 10 | } -------------------------------------------------------------------------------- /assets/scripts/animator/core/AnimatorTransition.ts: -------------------------------------------------------------------------------- 1 | import AnimatorCondition, { ParamType } from "./AnimatorCondition"; 2 | import AnimatorController from "./AnimatorController"; 3 | 4 | /** 5 | * 状态过渡类 6 | */ 7 | export default class AnimatorTransition { 8 | private _toStateName: string = ''; 9 | private _hasExitTime: boolean = false; 10 | private _conditions: AnimatorCondition[] = []; 11 | private _ac: AnimatorController = null; 12 | 13 | constructor(data: any, ac: AnimatorController) { 14 | this._toStateName = data.toState; 15 | this._hasExitTime = data.hasExitTime; 16 | this._ac = ac; 17 | for (let i = 0; i < data.conditions.length; i++) { 18 | let condition: AnimatorCondition = new AnimatorCondition(data.conditions[i], ac); 19 | this._conditions.push(condition); 20 | } 21 | } 22 | 23 | /** 24 | * 返回该transition是否有效,当未勾选hasExitTime以及没有添加任何condition时此transition无效并忽略 25 | */ 26 | public isValid(): boolean { 27 | return this._hasExitTime || this._conditions.length > 0; 28 | } 29 | 30 | /** 31 | * 判断是否满足所有转换条件 32 | */ 33 | public check(): boolean { 34 | if (this._toStateName === this._ac.curState.name) { 35 | return false; 36 | } 37 | 38 | if (this._hasExitTime && (this._ac.curState !== this._ac.animCompleteState || !this._ac.animComplete)) { 39 | return false; 40 | } 41 | 42 | for (let i = 0; i < this._conditions.length; i++) { 43 | if (!this._conditions[i].check()) { 44 | return false; 45 | } 46 | } 47 | return true; 48 | } 49 | 50 | /** 51 | * 转换状态 52 | */ 53 | public doTrans() { 54 | // 满足条件时重置动画播完标记 55 | if (this._hasExitTime) { 56 | this._ac.animComplete = false; 57 | } 58 | // 满足状态转换条件时重置trigger和autoTrigger 59 | for (let i = 0; i < this._conditions.length; i++) { 60 | let type = this._conditions[i].getParamType(); 61 | let name = this._conditions[i].getParamName(); 62 | if (type === ParamType.TRIGGER) { 63 | this._ac.params.resetTrigger(name); 64 | } else if (type === ParamType.AUTO_TRIGGER) { 65 | this._ac.params.resetAutoTrigger(name); 66 | } 67 | } 68 | 69 | this._ac.changeState(this._toStateName); 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /assets/scripts/animator/core/AnimatorTransition.ts.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.1.0", 3 | "uuid": "34b08043-b646-4388-b96c-a831d087b5d3", 4 | "importer": "typescript", 5 | "isPlugin": false, 6 | "loadPluginInWeb": true, 7 | "loadPluginInNative": true, 8 | "loadPluginInEditor": false, 9 | "subMetas": {} 10 | } -------------------------------------------------------------------------------- /assets/scripts/common.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.1.3", 3 | "uuid": "71dfb46a-3b64-40d7-9406-9b7f33c64b5f", 4 | "importer": "folder", 5 | "isBundle": false, 6 | "bundleName": "", 7 | "priority": 1, 8 | "compressionType": {}, 9 | "optimizeHotUpdate": {}, 10 | "inlineSpriteFrames": {}, 11 | "isRemoteBundle": {}, 12 | "subMetas": {} 13 | } -------------------------------------------------------------------------------- /assets/scripts/common/cmpt.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.1.3", 3 | "uuid": "98a71b0f-e1e1-4f93-b6be-eea78468fd74", 4 | "importer": "folder", 5 | "isBundle": false, 6 | "bundleName": "", 7 | "priority": 1, 8 | "compressionType": {}, 9 | "optimizeHotUpdate": {}, 10 | "inlineSpriteFrames": {}, 11 | "isRemoteBundle": {}, 12 | "subMetas": {} 13 | } -------------------------------------------------------------------------------- /assets/scripts/common/cmpt/base.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.1.3", 3 | "uuid": "e4e92c79-6fc4-454e-bd66-f5fe5912972b", 4 | "importer": "folder", 5 | "isBundle": false, 6 | "bundleName": "", 7 | "priority": 1, 8 | "compressionType": {}, 9 | "optimizeHotUpdate": {}, 10 | "inlineSpriteFrames": {}, 11 | "isRemoteBundle": {}, 12 | "subMetas": {} 13 | } -------------------------------------------------------------------------------- /assets/scripts/common/cmpt/base/DialogBase.ts.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.1.0", 3 | "uuid": "9b83ed8a-668a-4a4d-bf93-2d064d4eca73", 4 | "importer": "typescript", 5 | "isPlugin": false, 6 | "loadPluginInWeb": true, 7 | "loadPluginInNative": true, 8 | "loadPluginInEditor": false, 9 | "subMetas": {} 10 | } -------------------------------------------------------------------------------- /assets/scripts/common/cmpt/base/Layer.ts.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.1.0", 3 | "uuid": "a6e4802f-3e5b-4542-ac22-238cc0b0cab1", 4 | "importer": "typescript", 5 | "isPlugin": false, 6 | "loadPluginInWeb": true, 7 | "loadPluginInNative": true, 8 | "loadPluginInEditor": false, 9 | "subMetas": {} 10 | } -------------------------------------------------------------------------------- /assets/scripts/common/cmpt/base/Timer.ts.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.1.0", 3 | "uuid": "43594e30-8500-4de2-8f75-46f989169b80", 4 | "importer": "typescript", 5 | "isPlugin": false, 6 | "loadPluginInWeb": true, 7 | "loadPluginInNative": true, 8 | "loadPluginInEditor": false, 9 | "subMetas": {} 10 | } -------------------------------------------------------------------------------- /assets/scripts/common/cmpt/base/Tip.ts: -------------------------------------------------------------------------------- 1 | const { ccclass, property, disallowMultiple, menu } = cc._decorator; 2 | 3 | @ccclass 4 | @disallowMultiple 5 | @menu("Framework/基础组件/Tip") 6 | export default class Tip extends cc.Component { 7 | 8 | @property(cc.Layout) private layout: cc.Layout = null; 9 | @property(cc.Label) private textLab: cc.Label = null; 10 | 11 | public init(text: string): void { 12 | this.textLab.string = text; 13 | this.textLab["_forceUpdateRenderData"](); 14 | this.layout.updateLayout(); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /assets/scripts/common/cmpt/base/Tip.ts.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.1.0", 3 | "uuid": "86d61c1c-22c6-4f4a-b6f6-f45be614944b", 4 | "importer": "typescript", 5 | "isPlugin": false, 6 | "loadPluginInWeb": true, 7 | "loadPluginInNative": true, 8 | "loadPluginInEditor": false, 9 | "subMetas": {} 10 | } -------------------------------------------------------------------------------- /assets/scripts/common/cmpt/shader.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.1.3", 3 | "uuid": "7d7f8d07-7749-4c3a-b00a-7f4299038ac4", 4 | "importer": "folder", 5 | "isBundle": false, 6 | "bundleName": "", 7 | "priority": 1, 8 | "compressionType": {}, 9 | "optimizeHotUpdate": {}, 10 | "inlineSpriteFrames": {}, 11 | "isRemoteBundle": {}, 12 | "subMetas": {} 13 | } -------------------------------------------------------------------------------- /assets/scripts/common/cmpt/shader/ShaderFill.ts: -------------------------------------------------------------------------------- 1 | const { ccclass, property, menu, disallowMultiple, executeInEditMode } = cc._decorator; 2 | 3 | @ccclass 4 | @disallowMultiple 5 | @executeInEditMode 6 | @menu("Framework/Shader/ShaderFill") 7 | export default class ShaderFill extends cc.Component { 8 | @property({ tooltip: CC_DEV && "填充颜色" }) 9 | public fillColor: cc.Color = new cc.Color(); 10 | @property({ tooltip: CC_DEV && "填充率", range: [0, 1] }) 11 | public fillPhase: number = 0; 12 | 13 | private _mat: cc.Material = null; 14 | public get mat(): cc.Material { 15 | if (!this._mat) { 16 | this._mat = this.getComponent(cc.RenderComponent).getMaterial(0); 17 | } 18 | return this._mat; 19 | } 20 | 21 | protected start(): void { 22 | this.updateShader(); 23 | } 24 | 25 | protected update(): void { 26 | if (CC_EDITOR) { 27 | this.updateShader(); 28 | } 29 | } 30 | 31 | public updateShader(): void { 32 | this.mat.setProperty("fillColor", this.fillColor); 33 | this.mat.setProperty("fillPhase", this.fillPhase); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /assets/scripts/common/cmpt/shader/ShaderFill.ts.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.1.0", 3 | "uuid": "63dfa071-562a-43ed-b12f-f7d2bef7ed2e", 4 | "importer": "typescript", 5 | "isPlugin": false, 6 | "loadPluginInWeb": true, 7 | "loadPluginInNative": true, 8 | "loadPluginInEditor": false, 9 | "subMetas": {} 10 | } -------------------------------------------------------------------------------- /assets/scripts/common/cmpt/shader/ShaderOutline.ts: -------------------------------------------------------------------------------- 1 | const { ccclass, property, menu, disallowMultiple, executeInEditMode } = cc._decorator; 2 | 3 | enum OutlineType { 4 | NONE = 0, 5 | /** 外描边 */ 6 | OUT = 1, 7 | /** 内描边 */ 8 | INNER = 2, 9 | } 10 | 11 | @ccclass 12 | @disallowMultiple 13 | @executeInEditMode 14 | @menu("Framework/Shader/ShaderOutline") 15 | export default class ShaderOutline extends cc.Component { 16 | @property({ tooltip: CC_DEV && "描边颜色" }) 17 | public outlineColor: cc.Color = new cc.Color(); 18 | @property({ tooltip: CC_DEV && "描边宽度" }) 19 | public outLineWidth: number = 0; 20 | @property({ type: cc.Enum(OutlineType), tooltip: CC_DEV && "描边类型" }) 21 | public outlineType: OutlineType = OutlineType.NONE; 22 | @property({ tooltip: CC_DEV && "纹理大小" }) 23 | public textureSize: cc.Size = new cc.Size(1, 1); 24 | 25 | private _mat: cc.Material = null; 26 | public get mat(): cc.Material { 27 | if (!this._mat) { 28 | this._mat = this.getComponent(cc.RenderComponent).getMaterial(0); 29 | } 30 | return this._mat; 31 | } 32 | 33 | protected start(): void { 34 | this.updateShader(); 35 | } 36 | 37 | protected update(): void { 38 | if (CC_EDITOR) { 39 | this.updateShader(); 40 | } 41 | } 42 | 43 | public updateShader(): void { 44 | this.mat.setProperty("outlineColor", this.outlineColor); 45 | this.mat.setProperty("outlineInfo", new cc.Vec4(this.textureSize.width, this.textureSize.height, this.outLineWidth, this.outlineType)); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /assets/scripts/common/cmpt/shader/ShaderOutline.ts.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.1.0", 3 | "uuid": "d2a0b2c8-95d2-47a2-a1e1-2714d506ce47", 4 | "importer": "typescript", 5 | "isPlugin": false, 6 | "loadPluginInWeb": true, 7 | "loadPluginInNative": true, 8 | "loadPluginInEditor": false, 9 | "subMetas": {} 10 | } -------------------------------------------------------------------------------- /assets/scripts/common/cmpt/shader/ShaderShining.ts: -------------------------------------------------------------------------------- 1 | import Timer from "../base/Timer"; 2 | 3 | const { ccclass, property, menu, disallowMultiple, executeInEditMode } = cc._decorator; 4 | 5 | @ccclass 6 | @disallowMultiple 7 | @executeInEditMode 8 | @menu("Framework/Shader/ShaderShining") 9 | export default class ShaderShining extends cc.Component { 10 | @property({ tooltip: CC_DEV && "流光速度" }) 11 | public speed: number = 1; 12 | @property({ tooltip: CC_DEV && "流光斜率" }) 13 | public slope: number = 1; 14 | @property({ tooltip: CC_DEV && "流光宽度", range: [0, Number.MAX_SAFE_INTEGER] }) 15 | public len: number = 0.25; 16 | @property({ tooltip: CC_DEV && "流光强度", range: [0, Number.MAX_SAFE_INTEGER] }) 17 | public strength: number = 2; 18 | @property({ tooltip: CC_DEV && "两次流光动画之间的间隔时间", range: [0, Number.MAX_SAFE_INTEGER] }) 19 | public interval: number = 1; 20 | @property({ tooltip: CC_DEV && "流光速度是否受到timeScale的影响" }) 21 | public timeScale: boolean = false; 22 | 23 | private _mat: cc.Material = null; 24 | public get mat(): cc.Material { 25 | if (!this._mat) { 26 | this._mat = this.getComponent(cc.RenderComponent).getMaterial(0); 27 | } 28 | return this._mat; 29 | } 30 | 31 | protected start(): void { 32 | this.updateShader(); 33 | } 34 | 35 | protected update(): void { 36 | this.updateShader(); 37 | } 38 | 39 | public updateShader(): void { 40 | this.mat.setProperty("shiningData", new cc.Vec4(this.speed, this.slope, this.len, this.interval)); 41 | this.mat.setProperty("extra", new cc.Vec4(this.timeScale ? Timer.scaleGameSec : Timer.gameSec, this.strength)); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /assets/scripts/common/cmpt/shader/ShaderShining.ts.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.1.0", 3 | "uuid": "10bd95ac-d414-46fd-93c8-08380b34bbca", 4 | "importer": "typescript", 5 | "isPlugin": false, 6 | "loadPluginInWeb": true, 7 | "loadPluginInNative": true, 8 | "loadPluginInEditor": false, 9 | "subMetas": {} 10 | } -------------------------------------------------------------------------------- /assets/scripts/common/cmpt/shader/ShaderTile.ts: -------------------------------------------------------------------------------- 1 | const { ccclass, property, menu, disallowMultiple, executeInEditMode } = cc._decorator; 2 | 3 | @ccclass 4 | @disallowMultiple 5 | @executeInEditMode 6 | @menu("Framework/Shader/ShaderTile") 7 | export default class ShaderTile extends cc.Component { 8 | @property({ tooltip: CC_DEV && "uv坐标缩放倍数" }) 9 | public scale: cc.Vec2 = new cc.Vec2(1, 1); 10 | @property({ tooltip: CC_DEV && "uv坐标偏移值" }) 11 | public offset: cc.Vec2 = new cc.Vec2(0, 0); 12 | 13 | private _mat: cc.Material = null; 14 | public get mat(): cc.Material { 15 | if (!this._mat) { 16 | this._mat = this.getComponent(cc.RenderComponent).getMaterial(0); 17 | } 18 | return this._mat; 19 | } 20 | 21 | protected start(): void { 22 | this.updateShader(); 23 | } 24 | 25 | protected update(): void { 26 | if (CC_EDITOR) { 27 | this.updateShader(); 28 | } 29 | } 30 | 31 | public updateShader(): void { 32 | this.mat.setProperty("tile", new cc.Vec4(this.scale.x, this.scale.y, this.offset.x, this.offset.y)); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /assets/scripts/common/cmpt/shader/ShaderTile.ts.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.1.0", 3 | "uuid": "e6e3a81d-3a72-45fe-8eeb-8043a0e08abe", 4 | "importer": "typescript", 5 | "isPlugin": false, 6 | "loadPluginInWeb": true, 7 | "loadPluginInNative": true, 8 | "loadPluginInEditor": false, 9 | "subMetas": {} 10 | } -------------------------------------------------------------------------------- /assets/scripts/common/cmpt/ui.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.1.3", 3 | "uuid": "9d35c746-a4b8-4ef9-8244-dd5fb9d1ef63", 4 | "importer": "folder", 5 | "isBundle": false, 6 | "bundleName": "", 7 | "priority": 1, 8 | "compressionType": {}, 9 | "optimizeHotUpdate": {}, 10 | "inlineSpriteFrames": {}, 11 | "isRemoteBundle": {}, 12 | "subMetas": {} 13 | } -------------------------------------------------------------------------------- /assets/scripts/common/cmpt/ui/CountdownLabel.ts: -------------------------------------------------------------------------------- 1 | import Tool from "../../util/Tool"; 2 | import { SCALE_TWEEN, Tween } from "../../util/Tween"; 3 | 4 | const { ccclass, property, menu } = cc._decorator; 5 | 6 | type CountdownFormat = string | { "S": string; "M": string; "H": string; "D": string }; 7 | 8 | /** 9 | * 倒计时显示组件 10 | */ 11 | @ccclass 12 | @menu("Framework/UI组件/CountdownLabel") 13 | export default class CountdownLabel extends cc.Component { 14 | @property({ 15 | tooltip: CC_DEV && "倒计时是否受到timeScale的影响" 16 | }) 17 | public timeScale: boolean = false; 18 | 19 | private _tween: Tween = null; 20 | private _updateCall: () => void = null; 21 | private _completeCall: () => void = null; 22 | 23 | /** 格式化参数,详见`Tool.formatTimeString` */ 24 | private _format: CountdownFormat = "%{hh}:%{mm}:%{ss}"; 25 | /** 剩余秒数 */ 26 | private _leftSec: number = 0; 27 | public get leftSec(): number { return this._leftSec; } 28 | private _leftFloorSec: number = 0; 29 | 30 | private _label: cc.Label | cc.RichText = null; 31 | public get label(): cc.Label | cc.RichText { 32 | if (!this._label) { 33 | this._label = this.getComponent(cc.Label) ?? this.getComponent(cc.RichText); 34 | } 35 | return this._label; 36 | } 37 | 38 | public startCountdown(sec: number, format: CountdownFormat = "%{hh}:%{mm}:%{ss}", updateCall: () => void = null, completeCall: () => void = null): void { 39 | this._leftSec = sec; 40 | this._leftFloorSec = Math.floor(sec); 41 | this._format = format; 42 | this._updateCall = updateCall; 43 | this._completeCall = completeCall; 44 | this._tween?.stop(); 45 | this._tween = this.timeScale ? new Tween(this, SCALE_TWEEN) : new Tween(this); 46 | this._tween.to({ _leftSec: 0 }, sec * 1000) 47 | .onUpdate(() => { 48 | this.onUpdate(); 49 | }) 50 | .onComplete(() => { 51 | this.onComplete(); 52 | }) 53 | .start(); 54 | } 55 | 56 | private onUpdate(): void { 57 | // 每隔1s更新一次 58 | let floorSec = Math.floor(this._leftSec); 59 | if (floorSec === this._leftFloorSec) { 60 | return; 61 | } 62 | 63 | // 更新文本显示 64 | this._leftFloorSec = floorSec; 65 | if (this.label) { 66 | this.label.string = Tool.formatTimeString(this._leftFloorSec, this._format); 67 | } 68 | 69 | // 更新回调 70 | this._updateCall?.(); 71 | } 72 | 73 | private onComplete(): void { 74 | this._completeCall?.(); 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /assets/scripts/common/cmpt/ui/CountdownLabel.ts.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.1.0", 3 | "uuid": "a125e68b-64b5-4ef8-b42e-77604b8d671d", 4 | "importer": "typescript", 5 | "isPlugin": false, 6 | "loadPluginInWeb": true, 7 | "loadPluginInNative": true, 8 | "loadPluginInEditor": false, 9 | "subMetas": {} 10 | } -------------------------------------------------------------------------------- /assets/scripts/common/cmpt/ui/ShakeNode.ts: -------------------------------------------------------------------------------- 1 | import { SCALE_TWEEN, Tween } from "../../util/Tween"; 2 | 3 | const { ccclass, property, menu, disallowMultiple } = cc._decorator; 4 | 5 | /** 6 | * 节点振动 7 | */ 8 | @ccclass 9 | @disallowMultiple 10 | @menu("Framework/UI组件/ShakeNode") 11 | export default class ShakeNode extends cc.Component { 12 | @property({ tooltip: CC_DEV && "振动幅度" }) 13 | public shakePower: number = 5; 14 | 15 | @property({ tooltip: CC_DEV && "振动周期,单位:秒" }) 16 | public shakeTime: number = 0.16; 17 | 18 | @property({ 19 | tooltip: CC_DEV && "变化速度是否受到timeScale的影响" 20 | }) 21 | public timeScale: boolean = false; 22 | 23 | private _tween: Tween = null; 24 | 25 | /** 26 | * 振动 27 | * @param times 振动几个周期 28 | */ 29 | public shake(times: number = 5) { 30 | if ((this._tween && this._tween.isPlaying()) || times <= 0 || this.shakePower <= 0 || this.shakeTime <= 0) { 31 | return; 32 | } 33 | 34 | let sv = cc.v2(0, this.shakePower); 35 | this.node.setPosition(sv); 36 | let xArr: number[] = []; 37 | let yArr: number[] = []; 38 | for (let i = 1; i <= 8; i++) { 39 | let v = sv.rotate(Math.PI / 4 * (i * 3)); 40 | xArr.push(v.x); 41 | yArr.push(v.y); 42 | } 43 | 44 | this._tween = this.timeScale ? new Tween(this.node, SCALE_TWEEN) : new Tween(this.node); 45 | this._tween.to({ x: xArr, y: yArr }, this.shakeTime * 1000) 46 | .repeat(times) 47 | .start(); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /assets/scripts/common/cmpt/ui/ShakeNode.ts.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.1.0", 3 | "uuid": "936e87e5-02af-4bdb-8f13-94b8791f3774", 4 | "importer": "typescript", 5 | "isPlugin": false, 6 | "loadPluginInWeb": true, 7 | "loadPluginInNative": true, 8 | "loadPluginInEditor": false, 9 | "subMetas": {} 10 | } -------------------------------------------------------------------------------- /assets/scripts/common/cmpt/ui/adapt.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.1.3", 3 | "uuid": "080bd438-6e03-43aa-954c-1357f3e4cb6a", 4 | "importer": "folder", 5 | "isBundle": false, 6 | "bundleName": "", 7 | "priority": 1, 8 | "compressionType": {}, 9 | "optimizeHotUpdate": {}, 10 | "inlineSpriteFrames": {}, 11 | "isRemoteBundle": {}, 12 | "subMetas": {} 13 | } -------------------------------------------------------------------------------- /assets/scripts/common/cmpt/ui/adapt/AdaptCanvas.ts: -------------------------------------------------------------------------------- 1 | import { EventName } from "../../../const/EventName"; 2 | import Events, { eventsOnLoad, preloadEvent } from "../../../util/Events"; 3 | 4 | const { ccclass, property, menu, disallowMultiple } = cc._decorator; 5 | 6 | // 仅web有效 7 | cc.view.setResizeCallback(() => { 8 | Events.emit(EventName.RESIZE); 9 | }); 10 | 11 | /** 12 | * 分辨率适配组件,保证设计分辨率区域全部都能显示 13 | */ 14 | @ccclass 15 | @eventsOnLoad() 16 | @disallowMultiple 17 | @menu("Framework/UI组件/AdaptCanvas") 18 | export default class AdaptCanvas extends cc.Component { 19 | protected onLoad(): void { 20 | this.adapt(); 21 | } 22 | 23 | @preloadEvent(EventName.RESIZE) 24 | private adapt(): void { 25 | let resolutionRatio = cc.Canvas.instance.designResolution.width / cc.Canvas.instance.designResolution.height; 26 | let ratio = cc.winSize.width / cc.winSize.height; 27 | if (ratio > resolutionRatio) { 28 | cc.Canvas.instance.fitHeight = true; 29 | cc.Canvas.instance.fitWidth = false; 30 | } else { 31 | cc.Canvas.instance.fitHeight = false; 32 | cc.Canvas.instance.fitWidth = true; 33 | } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /assets/scripts/common/cmpt/ui/adapt/AdaptCanvas.ts.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.1.0", 3 | "uuid": "2174ff8f-2869-461f-b72c-be6d24a1656c", 4 | "importer": "typescript", 5 | "isPlugin": false, 6 | "loadPluginInWeb": true, 7 | "loadPluginInNative": true, 8 | "loadPluginInEditor": false, 9 | "subMetas": {} 10 | } -------------------------------------------------------------------------------- /assets/scripts/common/cmpt/ui/adapt/AdaptSize.ts: -------------------------------------------------------------------------------- 1 | import { EventName } from "../../../const/EventName"; 2 | import { eventsOnLoad, preloadEvent } from "../../../util/Events"; 3 | 4 | const { ccclass, property, menu, executeInEditMode } = cc._decorator; 5 | 6 | /** 7 | * - 适配组件,使节点与设计分辨率size保持一致,不影响节点位置 8 | * - 不使用cc.Widget是因为某些需要改变节点position的情况下会产生冲突 9 | */ 10 | @ccclass 11 | @eventsOnLoad() 12 | @executeInEditMode 13 | @menu("Framework/UI组件/AdaptSize") 14 | export default class AdaptSize extends cc.Component { 15 | protected onLoad(): void { 16 | this.adapt(); 17 | } 18 | 19 | @preloadEvent(EventName.RESIZE) 20 | private adapt(): void { 21 | if (CC_EDITOR) { 22 | this.node.width = cc["engine"].getDesignResolutionSize().width; 23 | this.node.height = cc["engine"].getDesignResolutionSize().height; 24 | } else { 25 | this.node.width = cc.winSize.width; 26 | this.node.height = cc.winSize.height; 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /assets/scripts/common/cmpt/ui/adapt/AdaptSize.ts.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.1.0", 3 | "uuid": "6c39175f-acd0-43f7-9abe-523f48d5e8c0", 4 | "importer": "typescript", 5 | "isPlugin": false, 6 | "loadPluginInWeb": true, 7 | "loadPluginInNative": true, 8 | "loadPluginInEditor": false, 9 | "subMetas": {} 10 | } -------------------------------------------------------------------------------- /assets/scripts/common/cmpt/ui/animValue.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.1.3", 3 | "uuid": "cdb796aa-a305-43cb-8c90-a70d0a4ef927", 4 | "importer": "folder", 5 | "isBundle": false, 6 | "bundleName": "", 7 | "priority": 1, 8 | "compressionType": {}, 9 | "optimizeHotUpdate": {}, 10 | "inlineSpriteFrames": {}, 11 | "isRemoteBundle": {}, 12 | "subMetas": {} 13 | } -------------------------------------------------------------------------------- /assets/scripts/common/cmpt/ui/animValue/AnimValue.ts.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.1.0", 3 | "uuid": "cfe49275-47b2-47c4-8a95-81ef76ed8aa3", 4 | "importer": "typescript", 5 | "isPlugin": false, 6 | "loadPluginInWeb": true, 7 | "loadPluginInNative": true, 8 | "loadPluginInEditor": false, 9 | "subMetas": {} 10 | } -------------------------------------------------------------------------------- /assets/scripts/common/cmpt/ui/animValue/AnimValueLabel.ts: -------------------------------------------------------------------------------- 1 | import AnimValue from "./AnimValue"; 2 | 3 | const { ccclass, property, menu, requireComponent, executeInEditMode } = cc._decorator; 4 | 5 | /** 6 | * 数值渐变的数字 7 | */ 8 | @ccclass 9 | @executeInEditMode 10 | @requireComponent(cc.Label) 11 | @menu("Framework/UI组件/AnimValueLabel") 12 | export default class AnimValueLabel extends AnimValue { 13 | 14 | private _label: cc.Label = null; 15 | public get label(): cc.Label { 16 | if (!this._label) this._label = this.getComponent(cc.Label); 17 | return this._label; 18 | } 19 | 20 | /** 21 | * @override 22 | */ 23 | protected onAnimUpdate(): void { 24 | this.label.string = `${Math.round(this.curValue)}`; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /assets/scripts/common/cmpt/ui/animValue/AnimValueLabel.ts.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.1.0", 3 | "uuid": "93188466-2a1d-461c-9849-60cc4db2efae", 4 | "importer": "typescript", 5 | "isPlugin": false, 6 | "loadPluginInWeb": true, 7 | "loadPluginInNative": true, 8 | "loadPluginInEditor": false, 9 | "subMetas": {} 10 | } -------------------------------------------------------------------------------- /assets/scripts/common/cmpt/ui/animValue/AnimValueProgress.ts: -------------------------------------------------------------------------------- 1 | import AnimValue from "./AnimValue"; 2 | 3 | const { ccclass, property, menu, requireComponent, executeInEditMode } = cc._decorator; 4 | 5 | /** 6 | * 数值渐变的进度条 7 | */ 8 | @ccclass 9 | @executeInEditMode 10 | @requireComponent(cc.ProgressBar) 11 | @menu("Framework/UI组件/AnimValueProgress") 12 | export default class AnimValueProgress extends AnimValue { 13 | 14 | private _progressBar: cc.ProgressBar = null; 15 | public get progressBar(): cc.ProgressBar { 16 | if (!this._progressBar) this._progressBar = this.getComponent(cc.ProgressBar); 17 | return this._progressBar; 18 | } 19 | 20 | /** 21 | * @override 22 | */ 23 | protected onAnimUpdate(): void { 24 | this.progressBar.progress = this.curValue; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /assets/scripts/common/cmpt/ui/animValue/AnimValueProgress.ts.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.1.0", 3 | "uuid": "7f95c5f1-24f8-4025-a41a-a91059907682", 4 | "importer": "typescript", 5 | "isPlugin": false, 6 | "loadPluginInWeb": true, 7 | "loadPluginInNative": true, 8 | "loadPluginInEditor": false, 9 | "subMetas": {} 10 | } -------------------------------------------------------------------------------- /assets/scripts/common/cmpt/ui/animValue/AnimValueProgressHP.ts: -------------------------------------------------------------------------------- 1 | import AnimValueProgress from "./AnimValueProgress"; 2 | 3 | const { ccclass, property, menu, requireComponent, executeInEditMode } = cc._decorator; 4 | 5 | /** 6 | * 血条组件 7 | */ 8 | @ccclass 9 | @executeInEditMode 10 | @requireComponent(cc.ProgressBar) 11 | @menu("Framework/UI组件/AnimValueProgressHP") 12 | export default class AnimValueProgressHP extends AnimValueProgress { 13 | @property({ 14 | type: cc.Sprite, 15 | tooltip: CC_DEV && "血条阴影,如果barSprite渲染模式为filled模式,此sprite也要对应修改,保持一致" 16 | }) 17 | public barShadow: cc.Sprite = null; 18 | 19 | private setBarShadow(progress: number): void { 20 | switch (this.progressBar.mode) { 21 | case cc.ProgressBar.Mode.HORIZONTAL: 22 | this.barShadow.node.width = this.progressBar.totalLength * progress; 23 | break; 24 | case cc.ProgressBar.Mode.VERTICAL: 25 | this.barShadow.node.height = this.progressBar.totalLength * progress; 26 | break; 27 | case cc.ProgressBar.Mode.FILLED: 28 | this.barShadow.fillRange = progress; 29 | default: 30 | break; 31 | } 32 | } 33 | 34 | /** 35 | * @override 36 | */ 37 | protected onAnimStart(): void { 38 | if (this.isAdd) { 39 | 40 | } else { 41 | this.progressBar.progress = this.endValue; 42 | } 43 | } 44 | 45 | /** 46 | * @override 47 | */ 48 | protected onAnimUpdate(): void { 49 | if (this.isAdd) { 50 | this.setBarShadow(this.curValue); 51 | this.progressBar.progress = this.curValue; 52 | } else { 53 | this.setBarShadow(this.curValue); 54 | } 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /assets/scripts/common/cmpt/ui/animValue/AnimValueProgressHP.ts.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.1.0", 3 | "uuid": "c3afe49d-6f30-490c-965e-8e9a571fdf2e", 4 | "importer": "typescript", 5 | "isPlugin": false, 6 | "loadPluginInWeb": true, 7 | "loadPluginInNative": true, 8 | "loadPluginInEditor": false, 9 | "subMetas": {} 10 | } -------------------------------------------------------------------------------- /assets/scripts/common/cmpt/ui/button.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.1.3", 3 | "uuid": "4426e314-7d83-44bb-b1de-f752ae34ed7d", 4 | "importer": "folder", 5 | "isBundle": false, 6 | "bundleName": "", 7 | "priority": 1, 8 | "compressionType": {}, 9 | "optimizeHotUpdate": {}, 10 | "inlineSpriteFrames": {}, 11 | "isRemoteBundle": {}, 12 | "subMetas": {} 13 | } -------------------------------------------------------------------------------- /assets/scripts/common/cmpt/ui/button/ButtonChildGray.ts: -------------------------------------------------------------------------------- 1 | import { ButtonHackEvent, ButtonState } from "../../../hack/ButtonHack"; 2 | import Tool from "../../../util/Tool"; 3 | 4 | const { ccclass, property, menu, requireComponent, executeInEditMode } = cc._decorator; 5 | 6 | /** 7 | * 根据button组件过渡状态,置灰子节点 8 | */ 9 | @ccclass 10 | @executeInEditMode 11 | @requireComponent(cc.Button) 12 | @menu("Framework/UI组件/ButtonChildGray") 13 | export default class ButtonChildGray extends cc.Component { 14 | 15 | @property({ type: cc.Node, tooltip: CC_DEV && "需要同步置灰的关联节点" }) public relatedNodes: cc.Node[] = []; 16 | @property(cc.Material) public normalMaterial: cc.Material = null; 17 | @property(cc.Material) public grayMaterial: cc.Material = null; 18 | 19 | protected onLoad(): void { 20 | this.node.on(ButtonHackEvent.STATE_CHANGE, this.onStateChange, this); 21 | } 22 | 23 | private onStateChange(state: ButtonState): void { 24 | if (state === ButtonState.DISABLED) { 25 | if (!this.grayMaterial) { 26 | this.grayMaterial = cc.Material.getBuiltinMaterial("2d-gray-sprite"); 27 | } 28 | let cb = (n: cc.Node): void => { 29 | let rc = n.getComponent(cc.RenderComponent); 30 | if (rc && (rc instanceof cc.Sprite || rc instanceof cc.Label)) { 31 | rc.setMaterial(0, this.grayMaterial); 32 | } 33 | }; 34 | Tool.nodeRecursive(this.node.children, cb); 35 | Tool.nodeRecursive(this.relatedNodes, cb); 36 | } else { 37 | if (!this.normalMaterial) { 38 | this.normalMaterial = cc.Material.getBuiltinMaterial("2d-sprite"); 39 | } 40 | let cb = (n: cc.Node): void => { 41 | let rc = n.getComponent(cc.RenderComponent); 42 | if (rc && (rc instanceof cc.Sprite || rc instanceof cc.Label)) { 43 | rc.setMaterial(0, this.normalMaterial); 44 | } 45 | }; 46 | Tool.nodeRecursive(this.node.children, cb); 47 | Tool.nodeRecursive(this.relatedNodes, cb); 48 | } 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /assets/scripts/common/cmpt/ui/button/ButtonChildGray.ts.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.1.0", 3 | "uuid": "19687030-1d18-408e-82dc-b06653af5607", 4 | "importer": "typescript", 5 | "isPlugin": false, 6 | "loadPluginInWeb": true, 7 | "loadPluginInNative": true, 8 | "loadPluginInEditor": false, 9 | "subMetas": {} 10 | } -------------------------------------------------------------------------------- /assets/scripts/common/cmpt/ui/button/ButtonChildPos.ts: -------------------------------------------------------------------------------- 1 | import { ButtonHackEvent, ButtonState } from "../../../hack/ButtonHack"; 2 | 3 | const { ccclass, property, menu, requireComponent } = cc._decorator; 4 | 5 | /** 6 | * 根据button组件过渡状态,移动子节点坐标 7 | */ 8 | @ccclass 9 | @requireComponent(cc.Button) 10 | @menu("Framework/UI组件/ButtonChildPos") 11 | export default class ButtonChildPos extends cc.Component { 12 | @property({ tooltip: CC_DEV && "普通状态下按钮子节点坐标" }) public normal: cc.Vec2 = cc.v2(0, 0); 13 | @property({ tooltip: CC_DEV && "按下状态下按钮子节点坐标" }) public pressed: cc.Vec2 = cc.v2(0, 0); 14 | @property({ tooltip: CC_DEV && "悬停状态下按钮子节点坐标" }) public hover: cc.Vec2 = cc.v2(0, 0); 15 | @property({ tooltip: CC_DEV && "禁用状态下按钮子节点坐标" }) public disabled: cc.Vec2 = cc.v2(0, 0); 16 | 17 | protected onLoad(): void { 18 | this.node.on(ButtonHackEvent.STATE_CHANGE, this.onStateChange, this); 19 | } 20 | 21 | private onStateChange(state: ButtonState): void { 22 | let pos = cc.v2(0, 0); 23 | switch (state) { 24 | case ButtonState.NORMAL: 25 | pos = this.normal; 26 | break; 27 | case ButtonState.PRESSED: 28 | pos = this.pressed; 29 | break; 30 | case ButtonState.HOVER: 31 | pos = this.hover; 32 | break; 33 | case ButtonState.DISABLED: 34 | pos = this.disabled; 35 | break; 36 | default: 37 | break; 38 | } 39 | this.node.children.forEach((e) => { 40 | e.setPosition(pos); 41 | }); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /assets/scripts/common/cmpt/ui/button/ButtonChildPos.ts.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.1.0", 3 | "uuid": "1c34d645-7ecc-4195-928f-a44954a2cdf0", 4 | "importer": "typescript", 5 | "isPlugin": false, 6 | "loadPluginInWeb": true, 7 | "loadPluginInNative": true, 8 | "loadPluginInEditor": false, 9 | "subMetas": {} 10 | } -------------------------------------------------------------------------------- /assets/scripts/common/cmpt/ui/button/ButtonSingle.ts: -------------------------------------------------------------------------------- 1 | const { ccclass, property, menu, requireComponent } = cc._decorator; 2 | 3 | /** 4 | * 按钮组数据 5 | */ 6 | interface GroupData { 7 | /** 该组是否锁定,同组按钮被触摸时进入锁定状态 */ 8 | lock: boolean; 9 | /** 同组按钮 */ 10 | buttonSet: Set; 11 | } 12 | 13 | /** 14 | * 按钮分组 15 | */ 16 | enum ButtonGroup { 17 | DEFAULT, 18 | GROUP1, 19 | GROUP2, 20 | } 21 | 22 | /** 23 | * 防多点触摸的按钮,同组按钮同一时刻只会有一个生效 24 | */ 25 | @ccclass 26 | @requireComponent(cc.Button) 27 | @menu("Framework/UI组件/ButtonSingle") 28 | export default class ButtonSingle extends cc.Component { 29 | @property({ type: cc.Enum(ButtonGroup), tooltip: CC_DEV && "按钮分组,同组按钮同一时刻只会有一个生效" }) 30 | public buttonGroup: ButtonGroup = ButtonGroup.DEFAULT; 31 | 32 | /** 记录所有绑定该组件的按钮数据 */ 33 | private static _groupMap: Map = null; 34 | private static get groupMap(): Map { 35 | if (this._groupMap === null) { 36 | this._groupMap = new Map(); 37 | } 38 | return this._groupMap; 39 | } 40 | 41 | private _button: cc.Button = null; 42 | 43 | protected onLoad(): void { 44 | this._button = this.getComponent(cc.Button); 45 | let groupData: GroupData = ButtonSingle.groupMap.get(this.buttonGroup); 46 | if (groupData === undefined) { 47 | groupData = { 48 | lock: false, 49 | buttonSet: new Set() 50 | }; 51 | ButtonSingle.groupMap.set(this.buttonGroup, groupData); 52 | } 53 | groupData.buttonSet.add(this._button); 54 | 55 | // 监听触摸事件 56 | this.node.on(cc.Node.EventType.TOUCH_START, this.onTouchStart, this); 57 | this.node.on(cc.Node.EventType.TOUCH_END, this.onTouchEnd, this); 58 | this.node.on(cc.Node.EventType.TOUCH_CANCEL, this.onTouchEnd, this); 59 | } 60 | 61 | protected onDestroy(): void { 62 | let groupData: GroupData = ButtonSingle.groupMap.get(this.buttonGroup); 63 | if (groupData === undefined) { 64 | cc.error(`[ButtonSingle.onDestroy] 数据异常 ButtonGroup: ${this.buttonGroup}`); 65 | return; 66 | } 67 | groupData.buttonSet.delete(this._button); 68 | this.unlock(groupData); 69 | } 70 | 71 | private onTouchStart(event: cc.Event.EventTouch): void { 72 | let groupData: GroupData = ButtonSingle.groupMap.get(this.buttonGroup); 73 | if (groupData === undefined) { 74 | cc.error(`[ButtonSingle.onTouchStart] 数据异常 ButtonGroup: ${this.buttonGroup}`); 75 | return; 76 | } 77 | 78 | if (groupData.lock) { 79 | return; 80 | } 81 | groupData.lock = true; 82 | groupData.buttonSet.forEach((e) => { 83 | e.enabled = (e === this._button); 84 | }); 85 | } 86 | 87 | private onTouchEnd(event: cc.Event.EventTouch): void { 88 | let groupData: GroupData = ButtonSingle.groupMap.get(this.buttonGroup); 89 | if (groupData === undefined) { 90 | cc.error(`[ButtonSingle.onTouchEnd] 数据异常 ButtonGroup: ${this.buttonGroup}`); 91 | return; 92 | } 93 | 94 | this.unlock(groupData); 95 | } 96 | 97 | /** 98 | * 当前按钮松开或销毁时解除同组按钮锁定状态 99 | */ 100 | private unlock(groupData: GroupData): void { 101 | if (groupData.lock && this._button.enabled) { 102 | groupData.lock = false; 103 | groupData.buttonSet.forEach((e) => { 104 | e.enabled = true; 105 | }); 106 | } 107 | } 108 | } 109 | -------------------------------------------------------------------------------- /assets/scripts/common/cmpt/ui/button/ButtonSingle.ts.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.1.0", 3 | "uuid": "0dd4f204-b2ee-47f1-81eb-2e2c44c3136e", 4 | "importer": "typescript", 5 | "isPlugin": false, 6 | "loadPluginInWeb": true, 7 | "loadPluginInNative": true, 8 | "loadPluginInEditor": false, 9 | "subMetas": {} 10 | } -------------------------------------------------------------------------------- /assets/scripts/common/cmpt/ui/i18n.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.1.3", 3 | "uuid": "f2f758d3-ca3c-4b5c-b2f7-1cd1ba57d2f9", 4 | "importer": "folder", 5 | "isBundle": false, 6 | "bundleName": "", 7 | "priority": 1, 8 | "compressionType": {}, 9 | "optimizeHotUpdate": {}, 10 | "inlineSpriteFrames": {}, 11 | "isRemoteBundle": {}, 12 | "subMetas": {} 13 | } -------------------------------------------------------------------------------- /assets/scripts/common/cmpt/ui/i18n/I18nLabel.ts: -------------------------------------------------------------------------------- 1 | import { EventName } from "../../../const/EventName"; 2 | import { eventsOnLoad, preloadEvent } from "../../../util/Events"; 3 | import I18n from "../../../util/I18n"; 4 | 5 | const { ccclass, property, executeInEditMode, menu } = cc._decorator; 6 | 7 | @ccclass 8 | @eventsOnLoad() 9 | @executeInEditMode 10 | @menu("Framework/I18N/I18nLabel") 11 | export default class I18nLabel extends cc.Component { 12 | @property(cc.String) private _textKey: string = ""; 13 | 14 | @property({ type: cc.String, tooltip: "i18n key" }) 15 | public get textKey(): string { return this._textKey; } 16 | public set textKey(key: string) { 17 | this._textKey = key; 18 | this.updateLabel(); 19 | } 20 | 21 | /** 22 | * 用于正则替换的配置 23 | */ 24 | private _option: { [k: string]: string | number } | Array = []; 25 | 26 | private _label: cc.Label | cc.RichText = null; 27 | public get label(): cc.Label | cc.RichText { 28 | if (!this._label) { 29 | this._label = this.node.getComponent(cc.Label) || this.node.getComponent(cc.RichText); 30 | if (!this._label) { 31 | cc.error("Failed to update localized label, label component is invalid!"); 32 | return null; 33 | } 34 | } 35 | return this._label; 36 | } 37 | 38 | protected onLoad(): void { 39 | try { 40 | I18n.init(); 41 | this.updateLabel(); 42 | } catch (err) { 43 | cc.error(err); 44 | } 45 | } 46 | 47 | protected update(): void { 48 | if (CC_EDITOR) { 49 | if (this.label.string) { 50 | let key = I18n.getKeyByValue(this.label.string); 51 | if (key) { 52 | this.textKey = key; 53 | } 54 | } 55 | } 56 | } 57 | 58 | /** 59 | * 更新语言 60 | */ 61 | @preloadEvent(EventName.UPDATE_LOCALIZED_CMPT) 62 | public updateLabel(): void { 63 | let localizedString = this._option instanceof Array ? I18n.getText(this._textKey, ...this._option) : I18n.getText(this._textKey, this._option); 64 | if (localizedString) { 65 | this.label.string = localizedString; 66 | } 67 | } 68 | 69 | /** 70 | * 设置语言与配置 71 | * @param key 72 | * @param option 73 | */ 74 | public setTextKeyAndOption(key: string, ...option: [{ [k: string]: string | number }] | Array): void { 75 | this._textKey = key; 76 | this.setOption(...option); 77 | } 78 | 79 | /** 80 | * 仅设置配置 81 | * @param option 82 | */ 83 | public setOption(...option: [{ [k: string]: string | number }] | Array): void { 84 | if (option.length === 1 && Object.prototype.toString.call(option[0]) === "[object Object]") { 85 | this._option = option[0] as { [k: string]: string | number }; 86 | } else { 87 | this._option = option as Array; 88 | } 89 | this.updateLabel(); 90 | } 91 | 92 | /** 93 | * 清除key 94 | */ 95 | public clear(): void { 96 | this.label.string = ""; 97 | this.textKey = ""; 98 | } 99 | } 100 | -------------------------------------------------------------------------------- /assets/scripts/common/cmpt/ui/i18n/I18nLabel.ts.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.1.0", 3 | "uuid": "102e7cd1-8e80-4821-a477-4ae9fd5c5549", 4 | "importer": "typescript", 5 | "isPlugin": false, 6 | "loadPluginInWeb": true, 7 | "loadPluginInNative": true, 8 | "loadPluginInEditor": false, 9 | "subMetas": {} 10 | } -------------------------------------------------------------------------------- /assets/scripts/common/cmpt/ui/i18n/I18nSprite.ts: -------------------------------------------------------------------------------- 1 | import { EventName } from "../../../const/EventName"; 2 | import { eventsOnLoad, preloadEvent } from "../../../util/Events"; 3 | import I18n, { LangType } from "../../../util/I18n"; 4 | import ResSprite from "../res/ResSprite"; 5 | 6 | const { ccclass, menu, requireComponent } = cc._decorator; 7 | 8 | @ccclass 9 | @eventsOnLoad() 10 | @requireComponent(ResSprite) 11 | @menu("Framework/I18N/I18nSprite") 12 | export default class I18nSprite extends cc.Component { 13 | private _sprite: ResSprite = null; 14 | private _imageKey: string = ""; 15 | /** 图片名 */ 16 | public get imageKey(): string { return this._imageKey; } 17 | public set imageKey(v: string) { 18 | if (this._imageKey === v) { 19 | return; 20 | } 21 | this._imageKey = v; 22 | this.updateSprite(); 23 | } 24 | 25 | protected onLoad(): void { 26 | try { 27 | I18n.init(); 28 | 29 | this._sprite = this.getComponent(ResSprite); 30 | if (this._sprite.spriteFrame) { 31 | this.imageKey = this._sprite.spriteFrame.name; 32 | } 33 | } catch (err) { 34 | cc.error(err); 35 | } 36 | } 37 | 38 | @preloadEvent(EventName.UPDATE_LOCALIZED_CMPT) 39 | public updateSprite(): void { 40 | if (!this.imageKey) { 41 | return; 42 | } 43 | 44 | let url = ""; 45 | switch (I18n.curLang) { 46 | case LangType.ZH: 47 | url = "textures/localizedImage/zh/"; 48 | break; 49 | case LangType.EN: 50 | url = "textures/localizedImage/en/"; 51 | break; 52 | default: 53 | return; 54 | } 55 | url += this.imageKey; 56 | this._sprite.setSpriteFrame(url); 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /assets/scripts/common/cmpt/ui/i18n/I18nSprite.ts.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.1.0", 3 | "uuid": "80273984-9ba1-4a23-a975-248da8936ac7", 4 | "importer": "typescript", 5 | "isPlugin": false, 6 | "loadPluginInWeb": true, 7 | "loadPluginInNative": true, 8 | "loadPluginInEditor": false, 9 | "subMetas": {} 10 | } -------------------------------------------------------------------------------- /assets/scripts/common/cmpt/ui/multiTexture.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.1.3", 3 | "uuid": "7357add2-8497-415d-968d-5bd965e217b3", 4 | "importer": "folder", 5 | "isBundle": false, 6 | "bundleName": "", 7 | "priority": 1, 8 | "compressionType": {}, 9 | "optimizeHotUpdate": {}, 10 | "inlineSpriteFrames": {}, 11 | "isRemoteBundle": {}, 12 | "subMetas": {} 13 | } -------------------------------------------------------------------------------- /assets/scripts/common/cmpt/ui/multiTexture/MultiSprite.ts.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.1.0", 3 | "uuid": "c922bc26-130e-4e57-8555-08172c37f706", 4 | "importer": "typescript", 5 | "isPlugin": false, 6 | "loadPluginInWeb": true, 7 | "loadPluginInNative": true, 8 | "loadPluginInEditor": false, 9 | "subMetas": {} 10 | } -------------------------------------------------------------------------------- /assets/scripts/common/cmpt/ui/multiTexture/MultiTextureManager.ts: -------------------------------------------------------------------------------- 1 | import MultiSprite from "./MultiSprite"; 2 | 3 | /** 4 | * Multi-Texture 管理器 5 | */ 6 | export class MultiTextureManager { 7 | /** 纹理最大数量 */ 8 | public static readonly MAX_TEXTURE_NUM = 8; 9 | 10 | private static _init: boolean = false; 11 | /** 共享材质 */ 12 | private static _mat: cc.Material = null; 13 | private static _texMap: Map = new Map(); 14 | private static _sprites: Set = new Set(); 15 | 16 | /** 17 | * 初始化纹理管理器 18 | */ 19 | public static init(mat: cc.Material): void { 20 | if (this._init || !(mat instanceof cc.Material) || mat instanceof cc.MaterialVariant) { 21 | return; 22 | } 23 | this._init = true; 24 | this._mat = mat; 25 | // 处理引用计数 26 | this._mat.addRef(); 27 | } 28 | 29 | public static addSprite(sp: MultiSprite): void { 30 | this._sprites.add(sp); 31 | } 32 | 33 | public static removeSprite(sp: MultiSprite): void { 34 | this._sprites.delete(sp); 35 | } 36 | 37 | /** 38 | * 设置合批纹理 39 | * @param idx 纹理id 40 | * @param tex 纹理对象 41 | * @returns 42 | */ 43 | public static setTexture(idx: number, tex: cc.Texture2D): void { 44 | if (!this._init) { 45 | cc.error("[MultiSpriteManager.setTexture] 未初始化MultiSpriteManager"); 46 | return; 47 | } 48 | 49 | if (!(tex instanceof cc.Texture2D)) { 50 | cc.error("[MultiSpriteManager.setTexture] 参数类型错误"); 51 | return; 52 | } 53 | 54 | idx = cc.misc.clampf(idx, 0, MultiTextureManager.MAX_TEXTURE_NUM - 1); 55 | let oldTex = this._texMap.get(idx); 56 | if (oldTex === tex) { 57 | return; 58 | } 59 | 60 | // 处理引用计数 61 | if (oldTex) { 62 | oldTex.decRef(); 63 | } 64 | tex.addRef(); 65 | 66 | this._texMap.set(idx, tex); 67 | // 修改共享材质属性 68 | this._mat.setProperty(`texture${idx}`, tex); 69 | // 修改已存在的渲染组件上材质变体的属性,同时更新渲染组件textureIdx 70 | this._sprites.forEach((v) => { 71 | /** 72 | * @bug 73 | * 2.4.5之前材质hash计算在utils.js中serializeUniforms有bug, 里面for-in遍历材质属性顺序受k-v对插入顺序影响(即setProperty顺序), 即使属性完全一致, hash却不一定一致 74 | * 因此在此直接创建新的材质 75 | */ 76 | // v.setMaterial(0, this._mat); 77 | 78 | // 材质变体中的属性必须完全一致, 材质的hash值计算才会一致 79 | let material = v.getMaterial(0); 80 | for (let i = 0; i < MultiTextureManager.MAX_TEXTURE_NUM; i++) { 81 | let texture = this._texMap.get(i); 82 | if (!texture) { 83 | continue; 84 | } 85 | let textureImpl = texture.getImpl(); 86 | if (material.getProperty(`texture${i}`, 0) !== textureImpl) { 87 | material.setProperty(`texture${i}`, texture); 88 | } 89 | } 90 | // 修改共享材质属性后,必须手动设置材质变体的_effect._dirty,不然不会重新计算材质变体的hash值 91 | material["_effect"]._dirty = true; 92 | 93 | // 更新textureIdx与材质属性 94 | v._updateMaterial(); 95 | }); 96 | } 97 | 98 | /** 99 | * 根据纹理获取对应的textureIdx 100 | * @param tex 101 | * @returns 102 | */ 103 | public static getIdx(tex: cc.Texture2D): number { 104 | if (!this._init) { 105 | cc.error("[MultiSpriteManager.getIdx] 未初始化MultiSpriteManager"); 106 | return; 107 | } 108 | 109 | for (let i = 0; i < MultiTextureManager.MAX_TEXTURE_NUM; i++) { 110 | if (this._texMap.get(i) === tex || this._mat.getProperty(`texture${i}`, 0) === tex.getImpl()) { 111 | return i; 112 | } 113 | } 114 | return -1; 115 | } 116 | } 117 | -------------------------------------------------------------------------------- /assets/scripts/common/cmpt/ui/multiTexture/MultiTextureManager.ts.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.1.0", 3 | "uuid": "4fc9c804-bd6c-4a64-ad21-605da38d0abb", 4 | "importer": "typescript", 5 | "isPlugin": false, 6 | "loadPluginInWeb": true, 7 | "loadPluginInNative": true, 8 | "loadPluginInEditor": false, 9 | "subMetas": {} 10 | } -------------------------------------------------------------------------------- /assets/scripts/common/cmpt/ui/multiTexture/assembler.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.1.3", 3 | "uuid": "64a9524b-1b61-49f4-b2b3-456f8ecb6aea", 4 | "importer": "folder", 5 | "isBundle": false, 6 | "bundleName": "", 7 | "priority": 1, 8 | "compressionType": {}, 9 | "optimizeHotUpdate": {}, 10 | "inlineSpriteFrames": {}, 11 | "isRemoteBundle": {}, 12 | "subMetas": {} 13 | } -------------------------------------------------------------------------------- /assets/scripts/common/cmpt/ui/multiTexture/assembler/MultiAssembler.ts.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.1.0", 3 | "uuid": "ac3d4a67-e39a-4f6c-8214-4d64c95aa9f8", 4 | "importer": "typescript", 5 | "isPlugin": false, 6 | "loadPluginInWeb": true, 7 | "loadPluginInNative": true, 8 | "loadPluginInEditor": false, 9 | "subMetas": {} 10 | } -------------------------------------------------------------------------------- /assets/scripts/common/cmpt/ui/multiTexture/assembler/MultiAssemblerBarFilled.ts.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.1.0", 3 | "uuid": "0d306faa-7659-4e26-8f93-efaa5e557548", 4 | "importer": "typescript", 5 | "isPlugin": false, 6 | "loadPluginInWeb": true, 7 | "loadPluginInNative": true, 8 | "loadPluginInEditor": false, 9 | "subMetas": {} 10 | } -------------------------------------------------------------------------------- /assets/scripts/common/cmpt/ui/multiTexture/assembler/MultiAssemblerRadialFilled.ts.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.1.0", 3 | "uuid": "37463720-1110-4b84-8f0a-eeb096cf3d66", 4 | "importer": "typescript", 5 | "isPlugin": false, 6 | "loadPluginInWeb": true, 7 | "loadPluginInNative": true, 8 | "loadPluginInEditor": false, 9 | "subMetas": {} 10 | } -------------------------------------------------------------------------------- /assets/scripts/common/cmpt/ui/multiTexture/assembler/MultiAssemblerSimple.ts: -------------------------------------------------------------------------------- 1 | import MultiAssembler from "./MultiAssembler"; 2 | 3 | export default class MultiAssemblerSimple extends MultiAssembler { 4 | public updateRenderData(sprite) { 5 | this.packToDynamicAtlas(sprite, sprite._spriteFrame); 6 | 7 | if (sprite._vertsDirty) { 8 | this.updateUVs(sprite); 9 | this.updateVerts(sprite); 10 | this.updateTextureIdx(sprite); 11 | sprite._vertsDirty = false; 12 | } 13 | } 14 | 15 | public updateUVs(sprite) { 16 | let uv = sprite._spriteFrame.uv; 17 | let uvOffset = this.uvOffset; 18 | let floatsPerVert = this.floatsPerVert; 19 | let verts = this._renderData.vDatas[0]; 20 | for (let i = 0; i < 4; i++) { 21 | let srcOffset = i * 2; 22 | let dstOffset = floatsPerVert * i + uvOffset; 23 | verts[dstOffset] = uv[srcOffset]; 24 | verts[dstOffset + 1] = uv[srcOffset + 1]; 25 | } 26 | } 27 | 28 | public updateVerts(sprite) { 29 | let node = sprite.node, 30 | cw = node.width, ch = node.height, 31 | appx = node.anchorX * cw, appy = node.anchorY * ch, 32 | l, b, r, t; 33 | if (sprite.trim) { 34 | l = -appx; 35 | b = -appy; 36 | r = cw - appx; 37 | t = ch - appy; 38 | } 39 | else { 40 | let frame = sprite.spriteFrame, 41 | ow = frame._originalSize.width, oh = frame._originalSize.height, 42 | rw = frame._rect.width, rh = frame._rect.height, 43 | offset = frame._offset, 44 | scaleX = cw / ow, scaleY = ch / oh; 45 | let trimLeft = offset.x + (ow - rw) / 2; 46 | let trimRight = offset.x - (ow - rw) / 2; 47 | let trimBottom = offset.y + (oh - rh) / 2; 48 | let trimTop = offset.y - (oh - rh) / 2; 49 | l = trimLeft * scaleX - appx; 50 | b = trimBottom * scaleY - appy; 51 | r = cw + trimRight * scaleX - appx; 52 | t = ch + trimTop * scaleY - appy; 53 | } 54 | 55 | let local = this._local; 56 | local[0] = l; 57 | local[1] = b; 58 | local[2] = r; 59 | local[3] = t; 60 | this.updateWorldVerts(sprite); 61 | } 62 | } 63 | 64 | if (CC_NATIVERENDERER) { 65 | let proto = MultiAssemblerSimple.prototype; 66 | //@ts-ignore 67 | let nativeProto = renderer.SimpleSprite2D.prototype; 68 | 69 | proto.updateWorldVerts = function (comp) { 70 | //@ts-ignore 71 | this._dirtyPtr[0] |= cc.Assembler.FLAG_VERTICES_DIRTY; 72 | }; 73 | 74 | //@ts-ignore 75 | proto._extendNative = function () { 76 | nativeProto.ctor.call(this); 77 | }; 78 | 79 | proto.initLocal = function () { 80 | this._local = new Float32Array(8); 81 | nativeProto.setLocalData.call(this, this._local); 82 | }; 83 | } 84 | -------------------------------------------------------------------------------- /assets/scripts/common/cmpt/ui/multiTexture/assembler/MultiAssemblerSimple.ts.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.1.0", 3 | "uuid": "aa9e0955-bc12-4ff4-8e04-16586d60225c", 4 | "importer": "typescript", 5 | "isPlugin": false, 6 | "loadPluginInWeb": true, 7 | "loadPluginInNative": true, 8 | "loadPluginInEditor": false, 9 | "subMetas": {} 10 | } -------------------------------------------------------------------------------- /assets/scripts/common/cmpt/ui/multiTexture/assembler/MultiAssemblerSliced.ts.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.1.0", 3 | "uuid": "0f3a2707-b3cb-4a7e-ace6-06e5fd2849d5", 4 | "importer": "typescript", 5 | "isPlugin": false, 6 | "loadPluginInWeb": true, 7 | "loadPluginInNative": true, 8 | "loadPluginInEditor": false, 9 | "subMetas": {} 10 | } -------------------------------------------------------------------------------- /assets/scripts/common/cmpt/ui/multiTexture/assembler/MultiAssemblerTiled.ts.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.1.0", 3 | "uuid": "825c0094-8508-4b1c-83a3-e6e95ab46519", 4 | "importer": "typescript", 5 | "isPlugin": false, 6 | "loadPluginInWeb": true, 7 | "loadPluginInNative": true, 8 | "loadPluginInEditor": false, 9 | "subMetas": {} 10 | } -------------------------------------------------------------------------------- /assets/scripts/common/cmpt/ui/res.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.1.3", 3 | "uuid": "9be993c7-28cb-47af-90ba-ad3e98d4aaff", 4 | "importer": "folder", 5 | "isBundle": false, 6 | "bundleName": "", 7 | "priority": 1, 8 | "compressionType": {}, 9 | "optimizeHotUpdate": {}, 10 | "inlineSpriteFrames": {}, 11 | "isRemoteBundle": {}, 12 | "subMetas": {} 13 | } -------------------------------------------------------------------------------- /assets/scripts/common/cmpt/ui/res/ResSpine.ts: -------------------------------------------------------------------------------- 1 | import Res from "../../../util/Res"; 2 | 3 | const { ccclass, menu, disallowMultiple, requireComponent } = cc._decorator; 4 | 5 | /** 6 | * spine组件,自动管理资源的引用计数 7 | */ 8 | @ccclass 9 | @disallowMultiple 10 | @requireComponent(sp.Skeleton) 11 | @menu("Framework/UI组件/ResSpine") 12 | export default class ResSpine extends cc.Component { 13 | // 动态加载的资源 14 | private _asset: sp.SkeletonData = null; 15 | 16 | private _url: string = ""; 17 | 18 | private _spine: sp.Skeleton = null; 19 | private get spine(): sp.Skeleton { 20 | if (!this._spine) { 21 | this._spine = this.getComponent(sp.Skeleton); 22 | } 23 | return this._spine; 24 | } 25 | 26 | public get skeletonData(): sp.SkeletonData { 27 | return this.spine.skeletonData; 28 | } 29 | public set skeletonData(v: sp.SkeletonData) { 30 | if (!this.isValid || this.spine.skeletonData === v) { 31 | return; 32 | } 33 | v?.addRef(); 34 | this._asset?.decRef(); 35 | this._asset = v; 36 | this.spine.skeletonData = v; 37 | } 38 | 39 | protected onDestroy(): void { 40 | this._asset?.decRef(); 41 | } 42 | 43 | /** 44 | * 设置skeletonData 45 | * @param url 骨骼资源路径,规则同Res加载路径 46 | */ 47 | public async setSkeletonData(url: string): Promise { 48 | this._url = url; 49 | let result = Res.get(url, sp.SkeletonData) || await Res.load(url, sp.SkeletonData); 50 | // 如短时间内多次调用,需保证使用最后一次加载的资源 51 | if (result instanceof sp.SkeletonData && this._url === url) { 52 | this.skeletonData = result; 53 | } 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /assets/scripts/common/cmpt/ui/res/ResSpine.ts.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.1.0", 3 | "uuid": "14fad96d-e200-4727-8ee6-65b4a5d624a6", 4 | "importer": "typescript", 5 | "isPlugin": false, 6 | "loadPluginInWeb": true, 7 | "loadPluginInNative": true, 8 | "loadPluginInEditor": false, 9 | "subMetas": {} 10 | } -------------------------------------------------------------------------------- /assets/scripts/common/cmpt/ui/res/ResSprite.ts: -------------------------------------------------------------------------------- 1 | import Res from "../../../util/Res"; 2 | 3 | const { ccclass, menu, disallowMultiple, requireComponent } = cc._decorator; 4 | 5 | /** 6 | * 精灵组件,自动管理资源的引用计数 7 | */ 8 | @ccclass 9 | @disallowMultiple 10 | @requireComponent(cc.Sprite) 11 | @menu("Framework/UI组件/ResSprite") 12 | export default class ResSprite extends cc.Component { 13 | // 动态加载的资源 14 | private _asset: cc.SpriteFrame | cc.SpriteAtlas = null; 15 | 16 | private _url: string = ""; 17 | private _atlasKey: string = ""; 18 | 19 | private _sprite: cc.Sprite = null; 20 | private get sprite(): cc.Sprite { 21 | if (!this._sprite) { 22 | this._sprite = this.getComponent(cc.Sprite); 23 | } 24 | return this._sprite; 25 | } 26 | 27 | public get spriteFrame(): cc.SpriteFrame { 28 | return this.sprite.spriteFrame; 29 | } 30 | public set spriteFrame(v: cc.SpriteFrame) { 31 | if (!this.isValid || this.sprite.spriteFrame === v) { 32 | return; 33 | } 34 | v?.addRef(); 35 | this._asset?.decRef(); 36 | this._asset = v; 37 | this.sprite.spriteFrame = v; 38 | } 39 | 40 | protected onDestroy(): void { 41 | this._asset?.decRef(); 42 | } 43 | 44 | /** 45 | * 加载并设置spriteFrame 46 | * @param url 图片或图集路径,规则同Res加载路径 47 | * @param key 如果需要加载的url为图集时,需传入图集的key 48 | */ 49 | public async setSpriteFrame(url: string, key: string = ""): Promise { 50 | this._url = url; 51 | this._atlasKey = key; 52 | let type = key ? cc.SpriteAtlas : cc.SpriteFrame; 53 | let result = Res.get(url, type) || await Res.load(url, type); 54 | // 如短时间内多次调用,需保证使用最后一次加载的资源 55 | if (result instanceof type && this._url === url && this._atlasKey === key) { 56 | this.spriteFrame = result instanceof cc.SpriteAtlas ? result.getSpriteFrame(key) : result; 57 | } 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /assets/scripts/common/cmpt/ui/res/ResSprite.ts.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.1.0", 3 | "uuid": "1e60891c-7c73-4397-ab31-179ef030d144", 4 | "importer": "typescript", 5 | "isPlugin": false, 6 | "loadPluginInWeb": true, 7 | "loadPluginInNative": true, 8 | "loadPluginInEditor": false, 9 | "subMetas": {} 10 | } -------------------------------------------------------------------------------- /assets/scripts/common/cmpt/ui/scrollList.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.1.3", 3 | "uuid": "689421fd-c2cb-4738-9245-334b70d4b453", 4 | "importer": "folder", 5 | "isBundle": false, 6 | "bundleName": "", 7 | "priority": 1, 8 | "compressionType": {}, 9 | "optimizeHotUpdate": {}, 10 | "inlineSpriteFrames": {}, 11 | "isRemoteBundle": {}, 12 | "subMetas": {} 13 | } -------------------------------------------------------------------------------- /assets/scripts/common/cmpt/ui/scrollList/CircleList.ts.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.1.0", 3 | "uuid": "b16a301a-cb8b-4eb2-b6a3-959924fba235", 4 | "importer": "typescript", 5 | "isPlugin": false, 6 | "loadPluginInWeb": true, 7 | "loadPluginInNative": true, 8 | "loadPluginInEditor": false, 9 | "subMetas": {} 10 | } -------------------------------------------------------------------------------- /assets/scripts/common/cmpt/ui/scrollList/LoopList.ts.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.1.0", 3 | "uuid": "4795735c-84af-4cde-99d7-af90dd507fc1", 4 | "importer": "typescript", 5 | "isPlugin": false, 6 | "loadPluginInWeb": true, 7 | "loadPluginInNative": true, 8 | "loadPluginInEditor": false, 9 | "subMetas": {} 10 | } -------------------------------------------------------------------------------- /assets/scripts/common/cmpt/ui/scrollList/VirtualItem.ts: -------------------------------------------------------------------------------- 1 | import { VirtualArgs } from "./VirtualList"; 2 | 3 | const { ccclass, disallowMultiple } = cc._decorator; 4 | 5 | /** 6 | * 虚拟列表的元素组件 7 | */ 8 | @ccclass 9 | @disallowMultiple 10 | export default class VirtualItem extends cc.Component { 11 | /** 列表数据索引 */ 12 | public dataIdx: number = 0; 13 | /** 列表数据 */ 14 | public args: T = null; 15 | /** 分层的其余节点,顺序为Others数组的顺序 */ 16 | public others: cc.Node[] = []; 17 | 18 | /** 19 | * 根据数据刷新item显示 20 | * @virtual 21 | */ 22 | public onRefresh(args: T): void { 23 | } 24 | 25 | /** 26 | * 在onRefresh之后调用,参数为分层显示的节点,参数顺序为Others数组的顺序 27 | * @virtual 28 | */ 29 | public onRefreshOthers(...nodes: cc.Node[]): void { 30 | } 31 | 32 | /** 33 | * 回收item时重置内部状态 34 | * @virtual 35 | */ 36 | public onReset(): void { 37 | } 38 | 39 | /** 40 | * 获取item显示当前数据所需的真实大小(若节点size会根据数据改变,请在此函数内返回准确的size) 41 | * @virtual 42 | */ 43 | public getRealSize(): cc.Size { 44 | return this.node.getContentSize(); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /assets/scripts/common/cmpt/ui/scrollList/VirtualItem.ts.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.1.0", 3 | "uuid": "37390c8b-da0f-46c7-9e88-08ba3730ad4a", 4 | "importer": "typescript", 5 | "isPlugin": false, 6 | "loadPluginInWeb": true, 7 | "loadPluginInNative": true, 8 | "loadPluginInEditor": false, 9 | "subMetas": {} 10 | } -------------------------------------------------------------------------------- /assets/scripts/common/cmpt/ui/scrollList/VirtualLayout.ts.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.1.0", 3 | "uuid": "23c510fe-30bd-4923-b373-e7c59d04e99f", 4 | "importer": "typescript", 5 | "isPlugin": false, 6 | "loadPluginInWeb": true, 7 | "loadPluginInNative": true, 8 | "loadPluginInEditor": false, 9 | "subMetas": {} 10 | } -------------------------------------------------------------------------------- /assets/scripts/common/cmpt/ui/scrollList/VirtualList.ts.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.1.0", 3 | "uuid": "8815f83f-dc52-448e-8863-fcfac2f67db5", 4 | "importer": "typescript", 5 | "isPlugin": false, 6 | "loadPluginInWeb": true, 7 | "loadPluginInNative": true, 8 | "loadPluginInEditor": false, 9 | "subMetas": {} 10 | } -------------------------------------------------------------------------------- /assets/scripts/common/config.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.1.3", 3 | "uuid": "80770054-9ff6-46e7-9201-dae3285fe8df", 4 | "importer": "folder", 5 | "isBundle": false, 6 | "bundleName": "", 7 | "priority": 1, 8 | "compressionType": {}, 9 | "optimizeHotUpdate": {}, 10 | "inlineSpriteFrames": {}, 11 | "isRemoteBundle": {}, 12 | "subMetas": {} 13 | } -------------------------------------------------------------------------------- /assets/scripts/common/config/En.ts: -------------------------------------------------------------------------------- 1 | export default { 2 | lang: "English", 3 | text1: "number: %{num}", 4 | text2: "param1: %{arg1}, param2: %{arg2}" 5 | }; 6 | -------------------------------------------------------------------------------- /assets/scripts/common/config/En.ts.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.1.0", 3 | "uuid": "e1a79c91-8e96-4589-9f12-842e5821172e", 4 | "importer": "typescript", 5 | "isPlugin": false, 6 | "loadPluginInWeb": true, 7 | "loadPluginInNative": true, 8 | "loadPluginInEditor": false, 9 | "subMetas": {} 10 | } -------------------------------------------------------------------------------- /assets/scripts/common/config/Zh.ts: -------------------------------------------------------------------------------- 1 | export default { 2 | lang: "中文", 3 | text1: "数字:%{num}", 4 | text2: "参数1: %{arg1}, 参数2: %{arg2}" 5 | }; 6 | -------------------------------------------------------------------------------- /assets/scripts/common/config/Zh.ts.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.1.0", 3 | "uuid": "5cb62683-689b-40e2-91e5-ad200a8d3636", 4 | "importer": "typescript", 5 | "isPlugin": false, 6 | "loadPluginInWeb": true, 7 | "loadPluginInNative": true, 8 | "loadPluginInEditor": false, 9 | "subMetas": {} 10 | } -------------------------------------------------------------------------------- /assets/scripts/common/const.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.1.3", 3 | "uuid": "f2f375fe-d559-4b99-beb6-0d7bf81e73c9", 4 | "importer": "folder", 5 | "isBundle": false, 6 | "bundleName": "", 7 | "priority": 1, 8 | "compressionType": {}, 9 | "optimizeHotUpdate": {}, 10 | "inlineSpriteFrames": {}, 11 | "isRemoteBundle": {}, 12 | "subMetas": {} 13 | } -------------------------------------------------------------------------------- /assets/scripts/common/const/EventName.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * 事件名 3 | */ 4 | export enum EventName { 5 | /** cc.view 调整视窗尺寸的事件,仅在 Web 平台下有效 */ 6 | RESIZE, 7 | /** 更新多语言组件 */ 8 | UPDATE_LOCALIZED_CMPT, 9 | 10 | /** 游戏暂停 */ 11 | GAME_PAUSE, 12 | /** 游戏恢复 */ 13 | GAME_RESUME, 14 | /** 游戏时间缩放值修改 */ 15 | TIME_SCALE, 16 | 17 | /** 相机移动 */ 18 | CAMERA_MOVE, 19 | 20 | EVENT_TEST1, 21 | EVENT_TEST2, 22 | }; 23 | -------------------------------------------------------------------------------- /assets/scripts/common/const/EventName.ts.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.1.0", 3 | "uuid": "52bf6e63-376c-4c63-a220-d9aae82a4430", 4 | "importer": "typescript", 5 | "isPlugin": false, 6 | "loadPluginInWeb": true, 7 | "loadPluginInNative": true, 8 | "loadPluginInEditor": false, 9 | "subMetas": {} 10 | } -------------------------------------------------------------------------------- /assets/scripts/common/const/Url.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * 单个资源路径 3 | */ 4 | export const ResUrl = { 5 | PREFAB: { 6 | TIP: "prefab/tip/Tip", 7 | HOME: "prefab/home/Home", 8 | GAME: "prefab/game/Game", 9 | }, 10 | 11 | ATLAS: { 12 | EN: "textures/localizedImage/en/AutoAtlas", 13 | ZH: "textures/localizedImage/zh/AutoAtlas" 14 | }, 15 | 16 | AUDIO: { 17 | BGM1: "audio/bgm1", 18 | BGM2: "audio/bgm2", 19 | 20 | SFX1: "audio/sfx1", 21 | SFX2: "audio/sfx2", 22 | SFX_UI: "audio/sfxUi", 23 | } 24 | } 25 | 26 | /** 27 | * 文件夹路径 28 | */ 29 | export const DirUrl = { 30 | PREFAB: "prefab/", 31 | PREFAB_DIALOG: "prefab/dialog/", 32 | 33 | ATLAS: "atlas/", 34 | 35 | TEXTURE: "textures/", 36 | 37 | AUDIO: "audio/", 38 | } 39 | -------------------------------------------------------------------------------- /assets/scripts/common/const/Url.ts.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.1.0", 3 | "uuid": "a8f3341b-7163-4c4d-9d0f-7ce432e54be1", 4 | "importer": "typescript", 5 | "isPlugin": false, 6 | "loadPluginInWeb": true, 7 | "loadPluginInNative": true, 8 | "loadPluginInEditor": false, 9 | "subMetas": {} 10 | } -------------------------------------------------------------------------------- /assets/scripts/common/hack.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.1.3", 3 | "uuid": "68f92e87-4738-427b-853f-8ec6d69e793b", 4 | "importer": "folder", 5 | "isBundle": false, 6 | "bundleName": "", 7 | "priority": 1, 8 | "compressionType": {}, 9 | "optimizeHotUpdate": {}, 10 | "inlineSpriteFrames": {}, 11 | "isRemoteBundle": {}, 12 | "subMetas": {} 13 | } -------------------------------------------------------------------------------- /assets/scripts/common/hack/ButtonHack.ts: -------------------------------------------------------------------------------- 1 | // 基于CocosCreator2.x 按钮组件hack代码 2 | 3 | export enum ButtonHackEvent { 4 | /** 按钮状态变更 */ 5 | STATE_CHANGE = "ButtonHackEvent-STATE_CHANGE", 6 | } 7 | 8 | export enum ButtonState { 9 | NORMAL = 0, 10 | HOVER = 1, 11 | PRESSED = 2, 12 | DISABLED = 3, 13 | } 14 | 15 | // @ts-ignore 16 | cc.Button.prototype._applyTransition = function (state: any) { 17 | let transition = this.transition; 18 | if (transition === cc.Button.Transition.COLOR) { 19 | this._updateColorTransition(state); 20 | } else if (transition === cc.Button.Transition.SPRITE) { 21 | this._updateSpriteTransition(state); 22 | } else if (transition === cc.Button.Transition.SCALE) { 23 | this._updateScaleTransition(state); 24 | } 25 | 26 | // 状态变更通知 27 | this.node.emit(ButtonHackEvent.STATE_CHANGE, state); 28 | }; 29 | -------------------------------------------------------------------------------- /assets/scripts/common/hack/ButtonHack.ts.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.1.0", 3 | "uuid": "2aaa3e89-9235-4b58-8b5b-cc822bea42a4", 4 | "importer": "typescript", 5 | "isPlugin": false, 6 | "loadPluginInWeb": true, 7 | "loadPluginInNative": true, 8 | "loadPluginInEditor": false, 9 | "subMetas": {} 10 | } -------------------------------------------------------------------------------- /assets/scripts/common/hack/EditorBoxHack.ts: -------------------------------------------------------------------------------- 1 | // 基于CocosCreator2.x EditBox组件hack代码 2 | // 移动端web环境下,当EditBox会被弹出的软键盘遮挡时,视图向上滚动至EditBox在软键盘上方可见的位置。反之视图位置不变 3 | if (!CC_PREVIEW && cc.sys.platform === cc.sys.MOBILE_BROWSER) { 4 | cc.EditBox["_ImplClass"].prototype._adjustWindowScroll = function () { 5 | let self = this; 6 | setTimeout(function () { 7 | if (window.scrollY < 100) { 8 | let editBox: cc.EditBox = self._delegate; 9 | if (editBox && editBox.node) { 10 | let worldBox = editBox.node.getBoundingBoxToWorld(); 11 | let scrollHeight = document.documentElement.scrollHeight || document.body.scrollHeight; 12 | let clientHeight = document.documentElement.clientHeight || document.body.clientHeight; 13 | let ratio = cc.winSize.height / scrollHeight; 14 | let keyboardDomHeight = scrollHeight - clientHeight; 15 | let keyboardCocosHeight = keyboardDomHeight * ratio; 16 | console.error(`scrollHeight: ${scrollHeight}, clientHeight: ${clientHeight}, ratio: ${ratio}`); 17 | console.error(`keyboardDomHeight: ${keyboardDomHeight}, keyboardCocosHeight: ${keyboardCocosHeight}`); 18 | if (worldBox.yMin >= keyboardCocosHeight) { 19 | console.error("return"); 20 | return; 21 | } 22 | 23 | // DOM坐标系下,EditBox底部与软键盘顶部的距离 24 | let domDelta = (keyboardCocosHeight - worldBox.yMin) / ratio; 25 | window.scroll({ top: domDelta, behavior: 'smooth' }); 26 | console.error(`domDelta: ${domDelta}`); 27 | } else { 28 | self._elem.scrollIntoView({ block: "start", inline: "nearest", behavior: "smooth" }); 29 | console.error(`scrollIntoView`); 30 | } 31 | } 32 | }, 500); 33 | } 34 | } -------------------------------------------------------------------------------- /assets/scripts/common/hack/EditorBoxHack.ts.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.1.0", 3 | "uuid": "4a973c63-af9d-4934-85d4-158dd0d97b02", 4 | "importer": "typescript", 5 | "isPlugin": false, 6 | "loadPluginInWeb": true, 7 | "loadPluginInNative": true, 8 | "loadPluginInEditor": false, 9 | "subMetas": {} 10 | } -------------------------------------------------------------------------------- /assets/scripts/common/util.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.1.3", 3 | "uuid": "104f562d-6f7d-486e-bd18-5e1150677761", 4 | "importer": "folder", 5 | "isBundle": false, 6 | "bundleName": "", 7 | "priority": 1, 8 | "compressionType": {}, 9 | "optimizeHotUpdate": {}, 10 | "inlineSpriteFrames": {}, 11 | "isRemoteBundle": {}, 12 | "subMetas": {} 13 | } -------------------------------------------------------------------------------- /assets/scripts/common/util/AudioManager.ts.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.1.0", 3 | "uuid": "ed9cb10e-1835-4648-824e-2a1ce54f0122", 4 | "importer": "typescript", 5 | "isPlugin": false, 6 | "loadPluginInWeb": true, 7 | "loadPluginInNative": true, 8 | "loadPluginInEditor": false, 9 | "subMetas": {} 10 | } -------------------------------------------------------------------------------- /assets/scripts/common/util/Behavior3.ts.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.1.0", 3 | "uuid": "de9bb28a-68c6-42d6-a6e3-63a7850e5fe6", 4 | "importer": "typescript", 5 | "isPlugin": false, 6 | "loadPluginInWeb": true, 7 | "loadPluginInNative": true, 8 | "loadPluginInEditor": false, 9 | "subMetas": {} 10 | } -------------------------------------------------------------------------------- /assets/scripts/common/util/Decorator.ts.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.1.0", 3 | "uuid": "194e1435-1d64-4d9b-8b8c-ac25484229d6", 4 | "importer": "typescript", 5 | "isPlugin": false, 6 | "loadPluginInWeb": true, 7 | "loadPluginInNative": true, 8 | "loadPluginInEditor": false, 9 | "subMetas": {} 10 | } -------------------------------------------------------------------------------- /assets/scripts/common/util/EditorTool.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * 编辑器工具类 3 | */ 4 | export default class EditorTool { 5 | /** 6 | * 编辑器模式下加载资源 7 | * @param url db://assets/ 8 | */ 9 | public static load(url: string): Promise { 10 | return new Promise((resolve, reject) => { 11 | if (!CC_EDITOR) { 12 | resolve(null); 13 | return; 14 | } 15 | Editor.assetdb.queryUuidByUrl(`db://assets/${url}`, (error: any, uuid: string) => { 16 | if (error || !uuid) { 17 | resolve(null); 18 | cc.warn(`[EditorTool.load] uuid查询失败 url: ${url}`); 19 | return; 20 | } 21 | //@ts-ignore 22 | cc.resources.load({ type: "uuid", uuid: uuid }, (error: any, result: T) => { 23 | if (error || !result) { 24 | resolve(null); 25 | cc.warn(`[EditorTool.load] 资源加载失败 url: ${url}`); 26 | return; 27 | } 28 | resolve(result); 29 | }); 30 | }); 31 | }); 32 | } 33 | 34 | /** 35 | * 编辑器模式下设置ccclass的属性装饰器中的枚举值 36 | */ 37 | public static setClassAttrPropEnum(ctor: unknown, propName: string, value: unknown): void { 38 | if (!CC_EDITOR) { 39 | return; 40 | } 41 | cc.Class["Attr"].setClassAttr(ctor, propName, "enumList", value); 42 | } 43 | 44 | /** 45 | * 编辑器模式下刷新选中节点的属性检查器窗口 46 | * @param node 选中的节点 47 | */ 48 | public static refreshSelectedInspector(node: cc.Node): void { 49 | if (!CC_EDITOR) { 50 | return; 51 | } 52 | Editor.Utils.refreshSelectedInspector("node", node.uuid); 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /assets/scripts/common/util/EditorTool.ts.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.1.0", 3 | "uuid": "50fe9ab2-651e-4b81-8bb1-5cdde82bbf31", 4 | "importer": "typescript", 5 | "isPlugin": false, 6 | "loadPluginInWeb": true, 7 | "loadPluginInNative": true, 8 | "loadPluginInEditor": false, 9 | "subMetas": {} 10 | } -------------------------------------------------------------------------------- /assets/scripts/common/util/Events.ts.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.1.0", 3 | "uuid": "aae4c427-6ab9-4513-89be-cde53bbddee6", 4 | "importer": "typescript", 5 | "isPlugin": false, 6 | "loadPluginInWeb": true, 7 | "loadPluginInNative": true, 8 | "loadPluginInEditor": false, 9 | "subMetas": {} 10 | } -------------------------------------------------------------------------------- /assets/scripts/common/util/I18n.ts: -------------------------------------------------------------------------------- 1 | import En from "../config/En"; 2 | import Zh from "../config/Zh"; 3 | import { EventName } from "../const/EventName"; 4 | import Events from "./Events"; 5 | import Tool from "./Tool"; 6 | 7 | /** 8 | * 语言类型 9 | */ 10 | export enum LangType { 11 | NONE = "", 12 | ZH = "zh", 13 | EN = "en" 14 | } 15 | 16 | /** 17 | * 多语言控制类 18 | */ 19 | export default class I18n { 20 | private static _init: boolean = false; 21 | 22 | /** 语言表 */ 23 | private static _phrases: any = null; 24 | 25 | private static _curLang: LangType = LangType.NONE; 26 | /* 当前语言类型 */ 27 | public static get curLang(): LangType { return this._curLang; } 28 | 29 | /** 30 | * 初始化语言 31 | * @param language 32 | */ 33 | public static init(language: LangType = LangType.NONE): void { 34 | if (this._init) { 35 | return; 36 | } 37 | this._init = true; 38 | let lang = language || cc.sys.language; 39 | this.switch(lang as LangType); 40 | } 41 | 42 | /** 43 | * 切换语言 44 | * @param language 45 | */ 46 | public static switch(language: LangType): void { 47 | if (this._curLang === language) { 48 | return; 49 | } 50 | 51 | this._curLang = language; 52 | switch (language) { 53 | case LangType.ZH: 54 | this._phrases = Zh; 55 | break; 56 | case LangType.EN: 57 | this._phrases = En; 58 | break; 59 | default: 60 | this._curLang = LangType.EN; 61 | this._phrases = En; 62 | break; 63 | } 64 | this.updateLocalizedCmpt(); 65 | } 66 | 67 | /** 68 | * 更新所有多语言组件 69 | */ 70 | public static updateLocalizedCmpt(): void { 71 | Events.emit(EventName.UPDATE_LOCALIZED_CMPT); 72 | } 73 | 74 | 75 | /** 76 | * 通过语言表value获取对应的key 77 | * @param value 语言表的value 78 | */ 79 | public static getKeyByValue(value: string): string { 80 | if (!this._phrases) { 81 | cc.error(`[I18n.getKeyByValue] 未正确初始化`); 82 | return ""; 83 | } 84 | for (let key in this._phrases) { 85 | if (this._phrases[key] === value) { 86 | return key; 87 | } 88 | } 89 | return ""; 90 | } 91 | 92 | /** 93 | * 通过key获取语言表中的字符串 94 | * @param key 语言表中的key 95 | * @param option 用于替换的数据,可以传键值对,也可以按顺序传参 96 | * @example 97 | * // 语言表 {"test": "test %{arg1} %{arg2} !!!"} 98 | * I18n.getText("test", {arg1: "somthing", arg2: 2}); // "test somthing 2 !!!" 99 | * I18n.getText("test", "somthing", 2); // "test somthing 2 !!!" 100 | */ 101 | public static getText(key: string, ...option: [Record] | Array): string { 102 | if (!this._phrases) { 103 | cc.error(`[I18n.getText] 未正确初始化`); 104 | return ""; 105 | } 106 | if (!key) { 107 | return ""; 108 | } 109 | 110 | let text: string = this._phrases.hasOwnProperty(key) ? this._phrases[key] : key; 111 | text = Tool.formatString(text, ...option); 112 | return text; 113 | } 114 | } 115 | -------------------------------------------------------------------------------- /assets/scripts/common/util/I18n.ts.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.1.0", 3 | "uuid": "a2438ddd-d63d-4545-b5da-06470f72d7e7", 4 | "importer": "typescript", 5 | "isPlugin": false, 6 | "loadPluginInWeb": true, 7 | "loadPluginInNative": true, 8 | "loadPluginInEditor": false, 9 | "subMetas": {} 10 | } -------------------------------------------------------------------------------- /assets/scripts/common/util/Random.ts: -------------------------------------------------------------------------------- 1 | import Tool from "./Tool"; 2 | 3 | const CHARS: string[] = [ 4 | "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", 5 | "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", 6 | "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z" 7 | ]; 8 | 9 | const BASE = 131; 10 | const MOD = 19260817; 11 | 12 | /** 13 | * 可设置随机种子的随机数生成器 14 | */ 15 | export default class Random { 16 | 17 | /** 18 | * 计算字符串的hash值 返回值>=0 19 | * @param str 20 | * @param initHash 计算的初始值 21 | */ 22 | public static hashCode(str: string, initHash: number = 0): number { 23 | let hash = initHash; 24 | if (!str) { 25 | return hash; 26 | } 27 | 28 | for (let i = 0; i < str.length; i++) { 29 | hash = (BASE * hash + str.charCodeAt(i)) % MOD; 30 | } 31 | return hash; 32 | } 33 | 34 | /** 35 | * 随机生成一个种子编码 36 | * @param length 编码字节长度 37 | */ 38 | public static getSeed(length: number = 8): string { 39 | let seed = ""; 40 | for (let i = 0; i < length; i++) { 41 | seed += Tool.arrayRand(CHARS); 42 | } 43 | return seed; 44 | } 45 | 46 | /** 47 | * 获取区间[0, 1)的浮点数 48 | */ 49 | public static random(seed: string | number): number { 50 | let seedCode: number = typeof seed === "string" ? this.hashCode(seed) : seed; 51 | return (seedCode * 9301 + 49297) % 233280 / 233280; 52 | } 53 | 54 | /** 55 | * 获取区间[min, max)的整数,传入1个参数则区间为[0, min) 56 | */ 57 | public static int(seed: string | number, min: number, max: number = undefined): number { 58 | if (max === undefined) { 59 | max = min; 60 | min = 0; 61 | } 62 | min = Math.ceil(min); 63 | max = Math.floor(max); 64 | return Math.floor(this.random(seed) * (max - min)) + min; 65 | } 66 | 67 | /** 68 | * 获取区间[min, max)的浮点数,传入1个参数则区间为[0, min) 69 | */ 70 | public static float(seed: string | number, min: number, max: number = undefined): number { 71 | if (max === undefined) { 72 | max = min; 73 | min = 0; 74 | } 75 | return this.random(seed) * (max - min) + min; 76 | } 77 | 78 | /** 79 | * 根据权重数组进行随机,返回结果下标 80 | * @param weightArr 权重数组 81 | * @returns 随机到的权重数组下标 82 | */ 83 | public static randWeightIdx(seed: string | number, weightArr: number[]) { 84 | let sum = 0; 85 | for (let i = 0; i < weightArr.length; i++) { 86 | sum += weightArr[i]; 87 | } 88 | let randNum = this.float(seed, 0, sum); 89 | let curValue = 0 90 | for (let i = 0; i < weightArr.length; i++) { 91 | curValue += weightArr[i]; 92 | if (randNum < curValue) { 93 | return i; 94 | } 95 | } 96 | return weightArr.length - 1; 97 | } 98 | 99 | /** 100 | * Fisher–Yates shuffle 数组随机乱序 101 | */ 102 | public static shuffle(seed: string | number, arr: Array): Array { 103 | for (let i = arr.length - 1; i >= 0; i--) { 104 | let randomIndex = Math.floor(this.random(seed) * (i + 1)); 105 | [arr[randomIndex], arr[i]] = [arr[i], arr[randomIndex]]; 106 | } 107 | return arr; 108 | } 109 | 110 | /** 111 | * 随机返回数组中的一个元素 112 | */ 113 | public static arrayRand(seed: string | number, arr: Array): T { 114 | if (arr.length <= 0) { 115 | return null; 116 | } 117 | return arr[this.int(seed, 0, arr.length)]; 118 | } 119 | } 120 | -------------------------------------------------------------------------------- /assets/scripts/common/util/Random.ts.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.1.0", 3 | "uuid": "67025620-4907-4643-abec-b7dc85add771", 4 | "importer": "typescript", 5 | "isPlugin": false, 6 | "loadPluginInWeb": true, 7 | "loadPluginInNative": true, 8 | "loadPluginInEditor": false, 9 | "subMetas": {} 10 | } -------------------------------------------------------------------------------- /assets/scripts/common/util/RecyclePool.ts.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.1.0", 3 | "uuid": "a6546ed4-ca54-4e76-8e80-e49d87aa52db", 4 | "importer": "typescript", 5 | "isPlugin": false, 6 | "loadPluginInWeb": true, 7 | "loadPluginInNative": true, 8 | "loadPluginInEditor": false, 9 | "subMetas": {} 10 | } -------------------------------------------------------------------------------- /assets/scripts/common/util/Res.ts.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.1.0", 3 | "uuid": "e6bb4ba0-d3e0-4823-be91-2de6dc6615ed", 4 | "importer": "typescript", 5 | "isPlugin": false, 6 | "loadPluginInWeb": true, 7 | "loadPluginInNative": true, 8 | "loadPluginInEditor": false, 9 | "subMetas": {} 10 | } -------------------------------------------------------------------------------- /assets/scripts/common/util/Tool.ts.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.1.0", 3 | "uuid": "8f0aa0d9-73ac-4176-bb0e-72f6c6645542", 4 | "importer": "typescript", 5 | "isPlugin": false, 6 | "loadPluginInWeb": true, 7 | "loadPluginInNative": true, 8 | "loadPluginInEditor": false, 9 | "subMetas": {} 10 | } -------------------------------------------------------------------------------- /assets/scripts/common/util/Tween.ts.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.1.0", 3 | "uuid": "c18124d6-803c-4bf6-b450-44173e4df4ca", 4 | "importer": "typescript", 5 | "isPlugin": false, 6 | "loadPluginInWeb": true, 7 | "loadPluginInNative": true, 8 | "loadPluginInEditor": false, 9 | "subMetas": {} 10 | } -------------------------------------------------------------------------------- /assets/scripts/showcase.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.1.3", 3 | "uuid": "2b4caf66-0172-49cc-88a0-b8d4cb820009", 4 | "importer": "folder", 5 | "isBundle": false, 6 | "bundleName": "", 7 | "priority": 1, 8 | "compressionType": {}, 9 | "optimizeHotUpdate": {}, 10 | "inlineSpriteFrames": {}, 11 | "isRemoteBundle": {}, 12 | "subMetas": {} 13 | } -------------------------------------------------------------------------------- /assets/scripts/showcase/dialog.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.1.3", 3 | "uuid": "a57de330-83e2-4408-bfa5-8674b90a125b", 4 | "importer": "folder", 5 | "isBundle": false, 6 | "bundleName": "", 7 | "priority": 1, 8 | "compressionType": {}, 9 | "optimizeHotUpdate": {}, 10 | "inlineSpriteFrames": {}, 11 | "isRemoteBundle": {}, 12 | "subMetas": {} 13 | } -------------------------------------------------------------------------------- /assets/scripts/showcase/dialog/DlgAnimValue.ts: -------------------------------------------------------------------------------- 1 | import DialogBase from "../../common/cmpt/base/DialogBase"; 2 | import AnimValueLabel from "../../common/cmpt/ui/animValue/AnimValueLabel"; 3 | import AnimValueProgress from "../../common/cmpt/ui/animValue/AnimValueProgress"; 4 | import AnimValueProgressHP from "../../common/cmpt/ui/animValue/AnimValueProgressHP"; 5 | import { DirUrl } from "../../common/const/Url"; 6 | 7 | const { ccclass, property } = cc._decorator; 8 | 9 | @ccclass 10 | export default class DlgAnimValue extends DialogBase { 11 | public static pUrl: string = DirUrl.PREFAB_DIALOG + "DlgAnimValue"; 12 | 13 | @property(AnimValueLabel) public animLab: AnimValueLabel = null; 14 | @property(AnimValueProgress) public animProgress: AnimValueProgress = null; 15 | @property(AnimValueProgressHP) public animHP: AnimValueProgressHP = null; 16 | 17 | private onClickLabAdd() { 18 | this.animLab.setValue(this.animLab.endValue + 10); 19 | } 20 | 21 | private onClickLabSub() { 22 | this.animLab.setValue(this.animLab.endValue - 10); 23 | } 24 | 25 | private onClickProgressAdd() { 26 | this.animProgress.setValue(Math.min(1, this.animProgress.endValue + 0.2)); 27 | } 28 | 29 | private onClickProgressSub() { 30 | this.animProgress.setValue(Math.max(0, this.animProgress.endValue - 0.2)); 31 | } 32 | 33 | private onClickHPAdd() { 34 | this.animHP.setValue(Math.min(1, this.animHP.endValue + 0.2)); 35 | } 36 | 37 | private onClickHPSub() { 38 | this.animHP.setValue(Math.max(0, this.animHP.endValue - 0.2)); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /assets/scripts/showcase/dialog/DlgAnimValue.ts.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.1.0", 3 | "uuid": "f8bbddb4-0af0-4cf9-8555-96b6c222e817", 4 | "importer": "typescript", 5 | "isPlugin": false, 6 | "loadPluginInWeb": true, 7 | "loadPluginInNative": true, 8 | "loadPluginInEditor": false, 9 | "subMetas": {} 10 | } -------------------------------------------------------------------------------- /assets/scripts/showcase/dialog/DlgAudio.ts: -------------------------------------------------------------------------------- 1 | import DialogBase from "../../common/cmpt/base/DialogBase"; 2 | import { DirUrl, ResUrl } from "../../common/const/Url"; 3 | import AudioManager, { SfxType } from "../../common/util/AudioManager"; 4 | import Res from "../../common/util/Res"; 5 | 6 | const { ccclass, property } = cc._decorator; 7 | 8 | @ccclass 9 | export default class DlgAudio extends DialogBase { 10 | public static pUrl: string = DirUrl.PREFAB_DIALOG + "DlgAudio"; 11 | 12 | @property(cc.Slider) public volumeSlider: cc.Slider = null; 13 | 14 | protected onDestroy() { 15 | AudioManager.stopAll(); 16 | } 17 | 18 | /** 19 | * @override 20 | */ 21 | public onOpen() { 22 | this.onSlide(); 23 | } 24 | 25 | private onSlide() { 26 | AudioManager.bgmVolume = this.volumeSlider.progress; 27 | AudioManager.sfxVolume = this.volumeSlider.progress; 28 | } 29 | 30 | private onClickBgm1FadeIn() { 31 | AudioManager.playBgm({ clip: Res.get(ResUrl.AUDIO.BGM1, cc.AudioClip), fadeDuration: 5 }); 32 | } 33 | 34 | private onClickBgm1OutBgm2In() { 35 | AudioManager.stopBgm(Res.get(ResUrl.AUDIO.BGM1, cc.AudioClip), 5); 36 | AudioManager.playBgm({ clip: Res.get(ResUrl.AUDIO.BGM2, cc.AudioClip), fadeDuration: 5 }); 37 | } 38 | 39 | private onClickBgmFadeOut() { 40 | AudioManager.stopBgm(Res.get(ResUrl.AUDIO.BGM1, cc.AudioClip), 5); 41 | AudioManager.stopBgm(Res.get(ResUrl.AUDIO.BGM2, cc.AudioClip), 5); 42 | } 43 | 44 | // 即使多次点击按钮,此音效也始终只会同时播放一个 45 | private onClickSfx1() { 46 | AudioManager.setSfxData(Res.get(ResUrl.AUDIO.SFX1, cc.AudioClip), SfxType.NORMAL, 1, false); 47 | AudioManager.playSfx(Res.get(ResUrl.AUDIO.SFX1, cc.AudioClip), SfxType.NORMAL); 48 | } 49 | 50 | // 此音效最多同时播放五个 51 | private onClickSfx2() { 52 | AudioManager.setSfxData(Res.get(ResUrl.AUDIO.SFX2, cc.AudioClip), SfxType.NORMAL, 5, false); 53 | AudioManager.playSfx(Res.get(ResUrl.AUDIO.SFX2, cc.AudioClip), SfxType.NORMAL); 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /assets/scripts/showcase/dialog/DlgAudio.ts.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.1.0", 3 | "uuid": "58e95a9c-d0ad-4c4b-9faa-eb02c4579c41", 4 | "importer": "typescript", 5 | "isPlugin": false, 6 | "loadPluginInWeb": true, 7 | "loadPluginInNative": true, 8 | "loadPluginInEditor": false, 9 | "subMetas": {} 10 | } -------------------------------------------------------------------------------- /assets/scripts/showcase/dialog/DlgCircleList.ts: -------------------------------------------------------------------------------- 1 | import DialogBase from "../../common/cmpt/base/DialogBase"; 2 | import CircleList from "../../common/cmpt/ui/scrollList/CircleList"; 3 | import { DirUrl } from "../../common/const/Url"; 4 | 5 | const { ccclass, property } = cc._decorator; 6 | 7 | @ccclass 8 | export default class DlgCircleList extends DialogBase { 9 | public static pUrl: string = DirUrl.PREFAB_DIALOG + "DlgCircleList"; 10 | 11 | @property(CircleList) list: CircleList = null; 12 | 13 | /** 14 | * @override 15 | */ 16 | public onOpen() { 17 | this.list.init(); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /assets/scripts/showcase/dialog/DlgCircleList.ts.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.1.0", 3 | "uuid": "33471100-49c2-465d-9393-0f4915cd520c", 4 | "importer": "typescript", 5 | "isPlugin": false, 6 | "loadPluginInWeb": true, 7 | "loadPluginInNative": true, 8 | "loadPluginInEditor": false, 9 | "subMetas": {} 10 | } -------------------------------------------------------------------------------- /assets/scripts/showcase/dialog/DlgEvents.ts: -------------------------------------------------------------------------------- 1 | import DialogBase from "../../common/cmpt/base/DialogBase"; 2 | import { EventName } from "../../common/const/EventName"; 3 | import { DirUrl } from "../../common/const/Url"; 4 | import Events, { eventsOnEnable, preloadEvent } from "../../common/util/Events"; 5 | import Tool from "../../common/util/Tool"; 6 | 7 | const { ccclass, property } = cc._decorator; 8 | 9 | @ccclass 10 | @eventsOnEnable() 11 | export default class DlgEvents extends DialogBase { 12 | public static pUrl: string = DirUrl.PREFAB_DIALOG + "DlgEvents"; 13 | 14 | @property(cc.Label) lab1: cc.Label = null; 15 | 16 | private async onClickEmit() { 17 | await Events.emitAsync(EventName.EVENT_TEST1, "触发了事件1,请等待事件2"); 18 | Events.emit(EventName.EVENT_TEST2, "触发了事件2"); 19 | } 20 | 21 | @preloadEvent(EventName.EVENT_TEST1) 22 | private async eventTest1(str: string) { 23 | this.lab1.string = str; 24 | await Tool.waitCmpt(this, 1); 25 | } 26 | 27 | @preloadEvent(EventName.EVENT_TEST2) 28 | private eventTest2(str: string) { 29 | this.lab1.string = str; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /assets/scripts/showcase/dialog/DlgEvents.ts.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.1.0", 3 | "uuid": "e89a27eb-bf51-459c-862a-c563cf43868a", 4 | "importer": "typescript", 5 | "isPlugin": false, 6 | "loadPluginInWeb": true, 7 | "loadPluginInNative": true, 8 | "loadPluginInEditor": false, 9 | "subMetas": {} 10 | } -------------------------------------------------------------------------------- /assets/scripts/showcase/dialog/DlgI18N.ts: -------------------------------------------------------------------------------- 1 | import DialogBase from "../../common/cmpt/base/DialogBase"; 2 | import I18nLabel from "../../common/cmpt/ui/i18n/I18nLabel"; 3 | import { DirUrl } from "../../common/const/Url"; 4 | import I18n, { LangType } from "../../common/util/I18n"; 5 | 6 | const { ccclass, property } = cc._decorator; 7 | 8 | @ccclass 9 | export default class DlgI18N extends DialogBase { 10 | public static pUrl: string = DirUrl.PREFAB_DIALOG + "DlgI18N"; 11 | 12 | @property(I18nLabel) text1: I18nLabel = null; 13 | @property(I18nLabel) text2: I18nLabel = null; 14 | 15 | /** 16 | * @override 17 | */ 18 | public onOpen() { 19 | this.text1.setOption({ num: 10 }); 20 | this.text2.setOption(10, "---"); 21 | } 22 | 23 | private onClickZh() { 24 | I18n.switch(LangType.ZH); 25 | } 26 | 27 | private onClickEn() { 28 | I18n.switch(LangType.EN); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /assets/scripts/showcase/dialog/DlgI18N.ts.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.1.0", 3 | "uuid": "a9171468-b92b-4cb6-95f6-8dddfa1cfc5f", 4 | "importer": "typescript", 5 | "isPlugin": false, 6 | "loadPluginInWeb": true, 7 | "loadPluginInNative": true, 8 | "loadPluginInEditor": false, 9 | "subMetas": {} 10 | } -------------------------------------------------------------------------------- /assets/scripts/showcase/dialog/DlgLayer.ts: -------------------------------------------------------------------------------- 1 | import DialogBase from "../../common/cmpt/base/DialogBase"; 2 | import Layer from "../../common/cmpt/base/Layer"; 3 | import { DirUrl } from "../../common/const/Url"; 4 | 5 | const { ccclass, property } = cc._decorator; 6 | 7 | @ccclass 8 | export default class DlgLayer extends DialogBase { 9 | public static pUrl: string = DirUrl.PREFAB_DIALOG + "layer/DlgLayer"; 10 | 11 | /** 12 | * @override 13 | */ 14 | public onOpen() { 15 | 16 | } 17 | 18 | private async onClockAwait() { 19 | await Layer.inst.openUniDialogAsync(DirUrl.PREFAB_DIALOG + "layer/DlgLayer2"); 20 | await Layer.inst.waitCloseDialog(DirUrl.PREFAB_DIALOG + "layer/DlgLayer2"); 21 | await Layer.inst.openUniDialogAsync(DirUrl.PREFAB_DIALOG + "layer/DlgLayer3"); 22 | } 23 | 24 | private onClickTipUnique() { 25 | Layer.inst.showTip({ text: "这是一条唯一提示", unique: true, end: cc.v2(0, 100) }); 26 | } 27 | 28 | private onClickTip() { 29 | Layer.inst.showTip({ text: "这是一条普通提示", end: cc.v2(0, 100), duration: 0 }); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /assets/scripts/showcase/dialog/DlgLayer.ts.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.1.0", 3 | "uuid": "4ec76c8a-6e29-4b70-9c83-7579f3930007", 4 | "importer": "typescript", 5 | "isPlugin": false, 6 | "loadPluginInWeb": true, 7 | "loadPluginInNative": true, 8 | "loadPluginInEditor": false, 9 | "subMetas": {} 10 | } -------------------------------------------------------------------------------- /assets/scripts/showcase/dialog/DlgLoopList.ts: -------------------------------------------------------------------------------- 1 | import DialogBase from "../../common/cmpt/base/DialogBase"; 2 | import LoopList from "../../common/cmpt/ui/scrollList/LoopList"; 3 | import { DirUrl } from "../../common/const/Url"; 4 | 5 | const { ccclass, property } = cc._decorator; 6 | 7 | @ccclass 8 | export default class DlgLoopList extends DialogBase { 9 | public static pUrl: string = DirUrl.PREFAB_DIALOG + "DlgLoopList"; 10 | 11 | @property(LoopList) list: LoopList = null; 12 | 13 | /** 14 | * @override 15 | */ 16 | public onOpen() { 17 | this.list.onInit(10, 5, this.refreshItem, this); 18 | } 19 | 20 | private refreshItem(item: cc.Node, idx: number, isCur: boolean) { 21 | let color = { 22 | 0: cc.color(255, 200, 200), 23 | 1: cc.color(200, 255, 200), 24 | 2: cc.color(200, 200, 255), 25 | 3: cc.color(100, 200, 255), 26 | 4: cc.color(200, 100, 255), 27 | 5: cc.color(200, 100, 155), 28 | 6: cc.color(100, 150, 105), 29 | 7: cc.color(100, 250, 255), 30 | 8: cc.color(200, 150, 255), 31 | 9: cc.color(105, 100, 100) 32 | } 33 | item.color = color[idx]; 34 | item.getChildByName("lab").getComponent(cc.Label).string = `${idx}${isCur ? "-cur" : ""}`; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /assets/scripts/showcase/dialog/DlgLoopList.ts.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.1.0", 3 | "uuid": "298dd197-a1ac-493c-9577-f7f0c26fecfe", 4 | "importer": "typescript", 5 | "isPlugin": false, 6 | "loadPluginInWeb": true, 7 | "loadPluginInNative": true, 8 | "loadPluginInEditor": false, 9 | "subMetas": {} 10 | } -------------------------------------------------------------------------------- /assets/scripts/showcase/dialog/DlgMultiTexture.ts: -------------------------------------------------------------------------------- 1 | import DialogBase from "../../common/cmpt/base/DialogBase"; 2 | import MultiSprite from "../../common/cmpt/ui/multiTexture/MultiSprite"; 3 | import { MultiTextureManager } from "../../common/cmpt/ui/multiTexture/MultiTextureManager"; 4 | import { DirUrl, ResUrl } from "../../common/const/Url"; 5 | import Res from "../../common/util/Res"; 6 | 7 | const { ccclass, property } = cc._decorator; 8 | 9 | // 原生平台默认关闭动态合图,在此为了测试强制开启 10 | if (CC_NATIVERENDERER) { 11 | cc.game.once(cc.game.EVENT_ENGINE_INITED, () => { 12 | cc.macro.CLEANUP_IMAGE_CACHE = false; 13 | cc.dynamicAtlasManager.enabled = true; 14 | }); 15 | } 16 | 17 | @ccclass 18 | export default class DlgMultiTexture extends DialogBase { 19 | public static pUrl: string = DirUrl.PREFAB_DIALOG + "DlgMultiTexture"; 20 | 21 | @property(cc.Node) 22 | item1: cc.Node = null; 23 | @property(cc.Node) 24 | item2: cc.Node = null; 25 | @property(cc.Node) 26 | item3: cc.Node = null; 27 | 28 | /** 29 | * @override 30 | */ 31 | public async onOpen() { 32 | let arr = [ResUrl.ATLAS.EN, ResUrl.ATLAS.ZH]; 33 | 34 | // idx为0的纹理:Cocos自动图集纹理 35 | let atlas = await Res.load(arr[0], cc.SpriteAtlas); 36 | MultiTextureManager.setTexture(0, atlas.getTexture()); 37 | 38 | this.createNodes(); 39 | 40 | // idx为1的纹理:Cocos自动图集纹理 41 | atlas = await Res.load(arr[1], cc.SpriteAtlas); 42 | MultiTextureManager.setTexture(1, atlas.getTexture()); 43 | 44 | this.createNodes(); 45 | 46 | // idx为2的纹理:动态合图纹理 47 | let lastNode = this.node.getChildByName("bg").children[this.node.getChildByName("bg").childrenCount - 1]; 48 | let sf = lastNode.getComponent(MultiSprite).spriteFrame; 49 | if (sf["_original"]) { 50 | // 此纹理已进行动态合图 51 | MultiTextureManager.setTexture(2, sf.getTexture()); 52 | } 53 | 54 | this.createNodes(); 55 | } 56 | 57 | /** 58 | * 生成3个使用不同图集纹理的节点 59 | */ 60 | private createNodes() { 61 | let node1 = Res.instantiate(this.item1); 62 | this.node.getChildByName("bg").addChild(node1); 63 | node1.setPosition(0, 0); 64 | let node2 = Res.instantiate(this.item2); 65 | this.node.getChildByName("bg").addChild(node2); 66 | node2.setPosition(0, 0); 67 | let node3 = Res.instantiate(this.item3); 68 | this.node.getChildByName("bg").addChild(node3); 69 | node3.setPosition(0, 0); 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /assets/scripts/showcase/dialog/DlgMultiTexture.ts.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.1.0", 3 | "uuid": "195937a1-30fb-4bb2-8784-76376e2dc359", 4 | "importer": "typescript", 5 | "isPlugin": false, 6 | "loadPluginInWeb": true, 7 | "loadPluginInNative": true, 8 | "loadPluginInEditor": false, 9 | "subMetas": {} 10 | } -------------------------------------------------------------------------------- /assets/scripts/showcase/dialog/DlgShader.ts: -------------------------------------------------------------------------------- 1 | import DialogBase from "../../common/cmpt/base/DialogBase"; 2 | import Timer from "../../common/cmpt/base/Timer"; 3 | import ShaderFill from "../../common/cmpt/shader/ShaderFill"; 4 | import ShaderTile from "../../common/cmpt/shader/ShaderTile"; 5 | import { DirUrl } from "../../common/const/Url"; 6 | import { Easing, SCALE_TWEEN, Tween } from "../../common/util/Tween"; 7 | 8 | const { ccclass, property } = cc._decorator; 9 | 10 | @ccclass 11 | export default class DlgShader extends DialogBase { 12 | public static pUrl: string = DirUrl.PREFAB_DIALOG + "DlgShader"; 13 | 14 | @property(ShaderTile) tile: ShaderTile = null; 15 | @property(ShaderFill) fill: ShaderFill = null; 16 | 17 | private _tween: Tween = null; 18 | private _sx: number = 2; 19 | 20 | /** 21 | * @override 22 | */ 23 | public onOpen() { 24 | this._tween = new Tween(this.fill, SCALE_TWEEN) 25 | .to({ fillPhase: [1, 0] }, 1000) 26 | .repeat(1000) 27 | .easing(Easing.Quadratic.In) 28 | .onUpdate(() => { 29 | this.fill.updateShader(); 30 | }) 31 | .start(); 32 | } 33 | 34 | protected update() { 35 | this.tile.scale.x += Timer.scaleDt * this._sx; 36 | if (this.tile.scale.x >= 10) { 37 | this._sx = -2; 38 | } else if (this.tile.scale.x <= 1) { 39 | this._sx = 2; 40 | } 41 | this.tile.offset.x -= Timer.scaleDt * 5; 42 | this.tile.updateShader(); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /assets/scripts/showcase/dialog/DlgShader.ts.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.1.0", 3 | "uuid": "21c0d459-59a0-4295-ae54-9c1caf1411c3", 4 | "importer": "typescript", 5 | "isPlugin": false, 6 | "loadPluginInWeb": true, 7 | "loadPluginInNative": true, 8 | "loadPluginInEditor": false, 9 | "subMetas": {} 10 | } -------------------------------------------------------------------------------- /assets/scripts/showcase/dialog/DlgShake.ts: -------------------------------------------------------------------------------- 1 | import DialogBase from "../../common/cmpt/base/DialogBase"; 2 | import ShakeNode from "../../common/cmpt/ui/ShakeNode"; 3 | import { DirUrl } from "../../common/const/Url"; 4 | 5 | const { ccclass, property } = cc._decorator; 6 | 7 | @ccclass 8 | export default class DlgShake extends DialogBase { 9 | public static pUrl: string = DirUrl.PREFAB_DIALOG + "DlgShake"; 10 | 11 | @property(ShakeNode) shake: ShakeNode = null; 12 | 13 | private onClickShake() { 14 | this.shake.shake(1); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /assets/scripts/showcase/dialog/DlgShake.ts.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.1.0", 3 | "uuid": "bd6c422a-f2a4-4324-abae-bf55957c4079", 4 | "importer": "typescript", 5 | "isPlugin": false, 6 | "loadPluginInWeb": true, 7 | "loadPluginInNative": true, 8 | "loadPluginInEditor": false, 9 | "subMetas": {} 10 | } -------------------------------------------------------------------------------- /assets/scripts/showcase/dialog/DlgTimer.ts: -------------------------------------------------------------------------------- 1 | import DialogBase from "../../common/cmpt/base/DialogBase"; 2 | import Timer from "../../common/cmpt/base/Timer"; 3 | import { EventName } from "../../common/const/EventName"; 4 | import { DirUrl } from "../../common/const/Url"; 5 | import Events, { preloadEvent } from "../../common/util/Events"; 6 | import { SCALE_TWEEN, Tween } from "../../common/util/Tween"; 7 | 8 | const { ccclass, property } = cc._decorator; 9 | 10 | @ccclass 11 | export default class DlgTimer extends DialogBase { 12 | public static pUrl: string = DirUrl.PREFAB_DIALOG + "DlgTimer"; 13 | 14 | @property(cc.Slider) public slider: cc.Slider = null; 15 | @property(cc.Node) move1: cc.Node = null; 16 | @property(cc.Node) move2: cc.Node = null; 17 | @property(cc.Node) move3: cc.Node = null; 18 | 19 | private _dir = 1; 20 | private _tween: Tween = null; 21 | 22 | protected onLoad() { 23 | super.onLoad(); 24 | Events.targetOn(this); 25 | } 26 | 27 | protected onDestroy() { 28 | this._tween?.stop(); 29 | Events.targetOff(this); 30 | } 31 | 32 | protected update() { 33 | this.move2.x += Timer.scaleDt * 300 * this._dir; 34 | if (this._dir > 0 && this.move2.x > 500) { 35 | this._dir = -1; 36 | } else if (this._dir < 0 && this.move2.x < -500) { 37 | this._dir = 1; 38 | } 39 | } 40 | 41 | /** 42 | * @override 43 | */ 44 | public onOpen() { 45 | this.slider.progress = Timer.timeScale; 46 | this.slider.node.getChildByName("lab").getComponent(cc.Label).string = `timescale: ${Math.floor(this.slider.progress * 100) / 100}`; 47 | this.eventTimeScale(); 48 | 49 | this._tween = new Tween(this.move3, SCALE_TWEEN) 50 | .to({ x: [300, -300], y: [300, -300] }, 2000) 51 | .repeat(1000) 52 | .start(); 53 | } 54 | 55 | private onSlide() { 56 | this.slider.node.getChildByName("lab").getComponent(cc.Label).string = `timescale: ${Math.floor(this.slider.progress * 100) / 100}`; 57 | Timer.timeScale = this.slider.progress; 58 | } 59 | 60 | @preloadEvent(EventName.TIME_SCALE) 61 | private eventTimeScale() { 62 | this.move1.getComponent(cc.Animation).getAnimationState("move").speed = Timer.timeScale; 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /assets/scripts/showcase/dialog/DlgTimer.ts.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.1.0", 3 | "uuid": "9b54329e-c75d-408a-a02b-7c5aefdbe46e", 4 | "importer": "typescript", 5 | "isPlugin": false, 6 | "loadPluginInWeb": true, 7 | "loadPluginInNative": true, 8 | "loadPluginInEditor": false, 9 | "subMetas": {} 10 | } -------------------------------------------------------------------------------- /assets/scripts/showcase/dialog/DlgVirtualList.ts: -------------------------------------------------------------------------------- 1 | import DialogBase from "../../common/cmpt/base/DialogBase"; 2 | import VirtualList from "../../common/cmpt/ui/scrollList/VirtualList"; 3 | import { DirUrl } from "../../common/const/Url"; 4 | import Tool from "../../common/util/Tool"; 5 | import { ItemArgs } from "./ListItem"; 6 | 7 | const { ccclass, property } = cc._decorator; 8 | 9 | @ccclass 10 | export default class DlgVirtualList extends DialogBase { 11 | public static pUrl: string = DirUrl.PREFAB_DIALOG + "DlgVirtualList"; 12 | 13 | @property(VirtualList) list: VirtualList = null; 14 | @property(cc.Label) rndLab: cc.Label = null; 15 | 16 | private _rnd: number = 0; 17 | 18 | /** 19 | * @override 20 | */ 21 | public onOpen() { 22 | for (let i = 0; i < 50; i++) { 23 | this.list.push({ num: Tool.randInt(0, 1000) }); 24 | } 25 | 26 | this._rnd = Tool.randInt(0, this.list.argsArr.length); 27 | this.rndLab.string = `-> 下一次滚动到的下标为:${this._rnd}`; 28 | } 29 | 30 | private onClickAdd() { 31 | this.list.push({ num: Tool.randInt(0, 1000) }); 32 | } 33 | 34 | private onClickDelete() { 35 | this.list.splice(0, 1); 36 | } 37 | 38 | private onClickScroll() { 39 | // 滚动到对应下标的item的左上角对齐view的左上角 40 | this.list.scrollItemToView(this._rnd, cc.v2(0, 1), cc.v2(0, 1), 0.5, true); 41 | this._rnd = Tool.randInt(0, this.list.argsArr.length); 42 | this.rndLab.string = `-> 下一次滚动到的下标为:${this._rnd}`; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /assets/scripts/showcase/dialog/DlgVirtualList.ts.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.1.0", 3 | "uuid": "eb01c4d1-6fbc-4d4e-8375-4bd0acfea96b", 4 | "importer": "typescript", 5 | "isPlugin": false, 6 | "loadPluginInWeb": true, 7 | "loadPluginInNative": true, 8 | "loadPluginInEditor": false, 9 | "subMetas": {} 10 | } -------------------------------------------------------------------------------- /assets/scripts/showcase/dialog/DlgVirtualList2.ts: -------------------------------------------------------------------------------- 1 | import DialogBase from "../../common/cmpt/base/DialogBase"; 2 | import VirtualList from "../../common/cmpt/ui/scrollList/VirtualList"; 3 | import { DirUrl } from "../../common/const/Url"; 4 | import Tool from "../../common/util/Tool"; 5 | import { ItemArgs } from "./ListItem"; 6 | 7 | const { ccclass, property } = cc._decorator; 8 | 9 | function calcItemSize(args: ItemArgs): cc.Size { 10 | return cc.size(0, args.num); 11 | } 12 | 13 | @ccclass 14 | export default class DlgVirtualList2 extends DialogBase { 15 | public static pUrl: string = DirUrl.PREFAB_DIALOG + "DlgVirtualList2"; 16 | 17 | @property(VirtualList) list: VirtualList = null; 18 | @property(cc.Label) rndLab: cc.Label = null; 19 | 20 | private _rnd: number = 0; 21 | private _heights: number[] = [80, 100, 180]; 22 | 23 | /** 24 | * @override 25 | */ 26 | public onOpen() { 27 | // 元素大小不一致时提供计算元素大小的接口 28 | this.list.setCalcItemSize(calcItemSize); 29 | 30 | for (let i = 0; i < 50; i++) { 31 | this.list.push({ num: Tool.arrayRand(this._heights) }); 32 | } 33 | 34 | this._rnd = Tool.randInt(0, this.list.argsArr.length); 35 | this.rndLab.string = `-> 下一次滚动到的下标为:${this._rnd}`; 36 | } 37 | 38 | private onClickAdd() { 39 | this.list.push({ num: Tool.arrayRand(this._heights) }); 40 | } 41 | 42 | private onClickDelete() { 43 | this.list.splice(0, 1); 44 | } 45 | 46 | private onClickScroll() { 47 | // 滚动到对应下标的item的左上角对齐view的左上角 48 | this.list.scrollItemToView(this._rnd, cc.v2(0, 1), cc.v2(0, 1), 0.5, true); 49 | this._rnd = Tool.randInt(0, this.list.argsArr.length); 50 | this.rndLab.string = `-> 下一次滚动到的下标为:${this._rnd}`; 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /assets/scripts/showcase/dialog/DlgVirtualList2.ts.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.1.0", 3 | "uuid": "a1368129-7d48-4e19-bf0f-6310e35d8d31", 4 | "importer": "typescript", 5 | "isPlugin": false, 6 | "loadPluginInWeb": true, 7 | "loadPluginInNative": true, 8 | "loadPluginInEditor": false, 9 | "subMetas": {} 10 | } -------------------------------------------------------------------------------- /assets/scripts/showcase/dialog/ListItem.ts: -------------------------------------------------------------------------------- 1 | import VirtualItem from "../../common/cmpt/ui/scrollList/VirtualItem"; 2 | import { VirtualArgs } from "../../common/cmpt/ui/scrollList/VirtualList"; 3 | 4 | const { ccclass, property } = cc._decorator; 5 | 6 | export interface ItemArgs extends VirtualArgs { 7 | num: number; 8 | } 9 | 10 | @ccclass 11 | export default class ListItem extends VirtualItem { 12 | @property(cc.Label) lab: cc.Label = null; 13 | 14 | /** 15 | * @override 16 | */ 17 | public onRefresh(args: ItemArgs) { 18 | this.lab.string = `idx: ${this.dataIdx}`; 19 | cc.log(`[ListItem.onRefresh] idx: ${this.dataIdx}, args.num: ${args.num}`); 20 | } 21 | 22 | /** 23 | * @override 24 | */ 25 | public onRefreshOthers(labNode: cc.Node) { 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /assets/scripts/showcase/dialog/ListItem.ts.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.1.0", 3 | "uuid": "ca68fe6b-8f90-4251-b9bb-6cd14222d528", 4 | "importer": "typescript", 5 | "isPlugin": false, 6 | "loadPluginInWeb": true, 7 | "loadPluginInNative": true, 8 | "loadPluginInEditor": false, 9 | "subMetas": {} 10 | } -------------------------------------------------------------------------------- /assets/scripts/showcase/dialog/ListItem2.ts: -------------------------------------------------------------------------------- 1 | import VirtualItem from "../../common/cmpt/ui/scrollList/VirtualItem"; 2 | import { ItemArgs } from "./ListItem"; 3 | 4 | const {ccclass, property} = cc._decorator; 5 | 6 | @ccclass 7 | export default class ListItem2 extends VirtualItem { 8 | 9 | @property(cc.Node) bg: cc.Node = null; 10 | @property(cc.Label) lab: cc.Label = null; 11 | 12 | /** 13 | * @override 14 | */ 15 | public onRefresh(args: ItemArgs) { 16 | this.lab.string = `idx: ${this.dataIdx}`; 17 | this.node.height = args.num; 18 | this.bg.height = this.node.height - 20; 19 | cc.log(`[ListItem2.onRefresh] idx: ${this.dataIdx}, args.num: ${args.num}`); 20 | } 21 | 22 | /** 23 | * @override 24 | */ 25 | public onRefreshOthers(labNode: cc.Node) { 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /assets/scripts/showcase/dialog/ListItem2.ts.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.1.0", 3 | "uuid": "2ca3a288-e48a-4965-9363-d9f124cb7478", 4 | "importer": "typescript", 5 | "isPlugin": false, 6 | "loadPluginInWeb": true, 7 | "loadPluginInNative": true, 8 | "loadPluginInEditor": false, 9 | "subMetas": {} 10 | } -------------------------------------------------------------------------------- /assets/scripts/showcase/game.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.1.3", 3 | "uuid": "c9a91e6d-feb5-4a5a-aa33-dde3cd9ae5d3", 4 | "importer": "folder", 5 | "isBundle": false, 6 | "bundleName": "", 7 | "priority": 1, 8 | "compressionType": {}, 9 | "optimizeHotUpdate": {}, 10 | "inlineSpriteFrames": {}, 11 | "isRemoteBundle": {}, 12 | "subMetas": {} 13 | } -------------------------------------------------------------------------------- /assets/scripts/showcase/game/Game.ts: -------------------------------------------------------------------------------- 1 | import Layer from "../../common/cmpt/base/Layer"; 2 | import { DirUrl, ResUrl } from "../../common/const/Url"; 3 | import { eventsOnLoad } from "../../common/util/Events"; 4 | import Res from "../../common/util/Res"; 5 | import DlgAnimValue from "../dialog/DlgAnimValue"; 6 | import DlgAudio from "../dialog/DlgAudio"; 7 | import DlgCircleList from "../dialog/DlgCircleList"; 8 | import DlgEvents from "../dialog/DlgEvents"; 9 | import DlgI18N from "../dialog/DlgI18N"; 10 | import DlgLayer from "../dialog/DlgLayer"; 11 | import DlgLoopList from "../dialog/DlgLoopList"; 12 | import DlgMultiTexture from "../dialog/DlgMultiTexture"; 13 | import DlgShader from "../dialog/DlgShader"; 14 | import DlgShake from "../dialog/DlgShake"; 15 | import DlgTimer from "../dialog/DlgTimer"; 16 | import DlgVirtualList from "../dialog/DlgVirtualList"; 17 | import DlgVirtualList2 from "../dialog/DlgVirtualList2"; 18 | 19 | const { ccclass, property } = cc._decorator; 20 | 21 | @ccclass 22 | @eventsOnLoad() 23 | export default class Game extends cc.Component { 24 | 25 | private onClickHome() { 26 | Layer.inst.enterMain(ResUrl.PREFAB.HOME); 27 | } 28 | 29 | private onClickTimer() { 30 | Layer.inst.openUniDialogAsync(DlgTimer.pUrl); 31 | } 32 | 33 | private onClickLayer() { 34 | Layer.inst.openUniDialogAsync(DlgLayer.pUrl); 35 | } 36 | 37 | private onClickShader() { 38 | Layer.inst.openUniDialogAsync(DlgShader.pUrl); 39 | } 40 | 41 | private onClickAnimValue() { 42 | Layer.inst.openUniDialogAsync(DlgAnimValue.pUrl); 43 | } 44 | 45 | private onClickButton() { 46 | Layer.inst.openUniDialogAsync(DirUrl.PREFAB_DIALOG + "DlgButton"); 47 | } 48 | 49 | private onClickShake() { 50 | Layer.inst.openUniDialogAsync(DlgShake.pUrl); 51 | } 52 | 53 | private onClickVirtualList() { 54 | Layer.inst.openUniDialogAsync(DlgVirtualList.pUrl); 55 | } 56 | 57 | private onClickVirtualList2() { 58 | Layer.inst.openUniDialogAsync(DlgVirtualList2.pUrl); 59 | } 60 | 61 | private onClickLoopList() { 62 | Layer.inst.openUniDialogAsync(DlgLoopList.pUrl); 63 | } 64 | 65 | private onClickCircleList() { 66 | Layer.inst.openUniDialogAsync(DlgCircleList.pUrl); 67 | } 68 | 69 | private async onClickAudio() { 70 | Layer.inst.openUniDialogAsync(DlgAudio.pUrl); 71 | Layer.inst.showLoading(); 72 | await Res.loadDir(DirUrl.AUDIO, cc.AudioClip, false); 73 | Layer.inst.hideLoading(); 74 | } 75 | 76 | private onClickI18N() { 77 | Layer.inst.openUniDialogAsync(DlgI18N.pUrl); 78 | } 79 | 80 | private onClickEvent() { 81 | Layer.inst.openUniDialogAsync(DlgEvents.pUrl); 82 | } 83 | 84 | private onClickMultiTexture() { 85 | Layer.inst.openUniDialogAsync(DlgMultiTexture.pUrl); 86 | } 87 | } 88 | -------------------------------------------------------------------------------- /assets/scripts/showcase/game/Game.ts.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.1.0", 3 | "uuid": "1ee18300-2a04-4fcf-8220-ffcf4df200d7", 4 | "importer": "typescript", 5 | "isPlugin": false, 6 | "loadPluginInWeb": true, 7 | "loadPluginInNative": true, 8 | "loadPluginInEditor": false, 9 | "subMetas": {} 10 | } -------------------------------------------------------------------------------- /assets/scripts/showcase/home.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.1.3", 3 | "uuid": "9f39a0bd-0464-486c-9019-18688b5ce536", 4 | "importer": "folder", 5 | "isBundle": false, 6 | "bundleName": "", 7 | "priority": 1, 8 | "compressionType": {}, 9 | "optimizeHotUpdate": {}, 10 | "inlineSpriteFrames": {}, 11 | "isRemoteBundle": {}, 12 | "subMetas": {} 13 | } -------------------------------------------------------------------------------- /assets/scripts/showcase/home/Home.ts: -------------------------------------------------------------------------------- 1 | import Layer from "../../common/cmpt/base/Layer"; 2 | import { ResUrl } from "../../common/const/Url"; 3 | 4 | const { ccclass, property } = cc._decorator; 5 | 6 | @ccclass 7 | export default class Home extends cc.Component { 8 | 9 | private onClickGame() { 10 | Layer.inst.enterMain(ResUrl.PREFAB.GAME); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /assets/scripts/showcase/home/Home.ts.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.1.0", 3 | "uuid": "1d227706-09f9-4809-91a3-05090b0bbbd2", 4 | "importer": "typescript", 5 | "isPlugin": false, 6 | "loadPluginInWeb": true, 7 | "loadPluginInNative": true, 8 | "loadPluginInEditor": false, 9 | "subMetas": {} 10 | } -------------------------------------------------------------------------------- /assets/scripts/showcase/scenes.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.1.3", 3 | "uuid": "1c63a166-5b10-428c-9d41-33b26c072589", 4 | "importer": "folder", 5 | "isBundle": false, 6 | "bundleName": "", 7 | "priority": 1, 8 | "compressionType": {}, 9 | "optimizeHotUpdate": {}, 10 | "inlineSpriteFrames": {}, 11 | "isRemoteBundle": {}, 12 | "subMetas": {} 13 | } -------------------------------------------------------------------------------- /assets/scripts/showcase/scenes/Main.ts: -------------------------------------------------------------------------------- 1 | import Layer from "../../common/cmpt/base/Layer"; 2 | import { ResUrl } from "../../common/const/Url"; 3 | import Res from "../../common/util/Res"; 4 | 5 | const { ccclass, property } = cc._decorator; 6 | 7 | @ccclass 8 | export default class Main extends cc.Component { 9 | 10 | @property(cc.Label) public dcLab: cc.Label = null; 11 | 12 | protected start() { 13 | Layer.inst.enterMain(ResUrl.PREFAB.HOME); 14 | // 60s清理一次缓存 15 | this.schedule(() => { 16 | Res.releaseAll(); 17 | }, 60); 18 | } 19 | 20 | protected lateUpdate() { 21 | this.dcLab.string = `DrawCall: ${cc.renderer.drawCalls}`; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /assets/scripts/showcase/scenes/Main.ts.meta: -------------------------------------------------------------------------------- 1 | { 2 | "ver": "1.1.0", 3 | "uuid": "eef8ce6a-26c9-4e43-bd62-b308bf16ec58", 4 | "importer": "typescript", 5 | "isPlugin": false, 6 | "loadPluginInWeb": true, 7 | "loadPluginInNative": true, 8 | "loadPluginInEditor": false, 9 | "subMetas": {} 10 | } -------------------------------------------------------------------------------- /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": "cocos-creator-js", 3 | "packages": "packages", 4 | "name": "cocos-framework", 5 | "id": "209981c2-3c09-4e28-aa24-cdd7028ec2ad", 6 | "version": "2.4.11", 7 | "isNew": false 8 | } -------------------------------------------------------------------------------- /settings/builder.json: -------------------------------------------------------------------------------- 1 | { 2 | "title": "cocos-framework", 3 | "packageName": "org.cocos2d.demo", 4 | "startScene": "fafab544-3253-4695-b807-f3616f90183b", 5 | "excludeScenes": [], 6 | "orientation": { 7 | "landscapeRight": true, 8 | "landscapeLeft": true, 9 | "portrait": false, 10 | "upsideDown": false 11 | }, 12 | "webOrientation": "auto", 13 | "inlineSpriteFrames": true, 14 | "inlineSpriteFrames_native": true, 15 | "mainCompressionType": "default", 16 | "mainIsRemote": false, 17 | "optimizeHotUpdate": false, 18 | "md5Cache": true, 19 | "nativeMd5Cache": true, 20 | "encryptJs": true, 21 | "xxteaKey": "2d94a998-41bf-49", 22 | "zipCompressJs": true, 23 | "fb-instant-games": {}, 24 | "android": { 25 | "packageName": "org.cocos2d.demo", 26 | "REMOTE_SERVER_ROOT": "" 27 | }, 28 | "ios": { 29 | "packageName": "org.cocos2d.demo", 30 | "REMOTE_SERVER_ROOT": "", 31 | "ios_enable_jit": true 32 | }, 33 | "mac": { 34 | "packageName": "org.cocos2d.demo", 35 | "REMOTE_SERVER_ROOT": "", 36 | "width": 1280, 37 | "height": 720 38 | }, 39 | "win32": { 40 | "REMOTE_SERVER_ROOT": "", 41 | "width": 1280, 42 | "height": 720 43 | }, 44 | "android-instant": { 45 | "packageName": "org.cocos2d.demo", 46 | "REMOTE_SERVER_ROOT": "", 47 | "pathPattern": "", 48 | "scheme": "https", 49 | "host": "", 50 | "skipRecord": false, 51 | "recordPath": "" 52 | }, 53 | "appBundle": false, 54 | "agreements": {} 55 | } 56 | -------------------------------------------------------------------------------- /settings/project.json: -------------------------------------------------------------------------------- 1 | { 2 | "last-module-event-record-time": 1657374797531, 3 | "group-list": [ 4 | "default" 5 | ], 6 | "collision-matrix": [ 7 | [ 8 | true 9 | ] 10 | ], 11 | "excluded-modules": [ 12 | "3D", 13 | "3D Primitive", 14 | "3D Physics/cannon.js", 15 | "3D Physics/Builtin", 16 | "3D Particle" 17 | ], 18 | "preview-port": 7456, 19 | "design-resolution-width": 960, 20 | "design-resolution-height": 640, 21 | "fit-width": false, 22 | "fit-height": true, 23 | "use-project-simulator-setting": false, 24 | "simulator-orientation": false, 25 | "use-customize-simulator": true, 26 | "simulator-resolution": { 27 | "width": 960, 28 | "height": 640 29 | }, 30 | "clear-simulator-cache": true, 31 | "facebook": { 32 | "enable": false, 33 | "appID": "", 34 | "live": { 35 | "enable": false 36 | }, 37 | "audience": { 38 | "enable": false 39 | } 40 | }, 41 | "migrate-history": [ 42 | "cloud-function" 43 | ], 44 | "start-scene": "fafab544-3253-4695-b807-f3616f90183b" 45 | } 46 | -------------------------------------------------------------------------------- /settings/services.json: -------------------------------------------------------------------------------- 1 | { 2 | "game": { 3 | "name": "未知游戏", 4 | "appid": "UNKNOW" 5 | } 6 | } -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "module": "commonjs", 4 | "lib": [ "es2015", "es2017", "dom" ], 5 | "target": "es5", 6 | "experimentalDecorators": true, 7 | "skipLibCheck": true, 8 | "outDir": "temp/vscode-dist", 9 | "forceConsistentCasingInFileNames": true 10 | }, 11 | "exclude": [ 12 | "node_modules", 13 | "library", 14 | "local", 15 | "temp", 16 | "build", 17 | "settings" 18 | ] 19 | } --------------------------------------------------------------------------------