├── .gitignore ├── .laya ├── compile.js ├── launch.json └── publish.js ├── README.md ├── YKFrame.laya ├── bin ├── fileconfig.json ├── game.js ├── game.json ├── index.html ├── index.js ├── js │ ├── bundle.js │ └── ykLib.js ├── libs │ ├── bytebuffer.js │ ├── domparserinone.js │ ├── fairygui │ │ ├── fairygui.js │ │ └── fairygui.min.js │ ├── laya.ani.js │ ├── laya.bdmini.js │ ├── laya.core.js │ ├── laya.d3.js │ ├── laya.d3Plugin.js │ ├── laya.debugtool.js │ ├── laya.device.js │ ├── laya.effect.js │ ├── laya.filter.js │ ├── laya.html.js │ ├── laya.particle.js │ ├── laya.pathfinding.js │ ├── laya.physics.js │ ├── laya.physics3D.js │ ├── laya.physics3D.runtime.js │ ├── laya.physics3D.wasm.js │ ├── laya.physics3D.wasm.wasm │ ├── laya.tiledmap.js │ ├── laya.ui.js │ ├── laya.webgl.js │ ├── laya.wxmini.js │ ├── rawinflate │ │ └── rawinflate.min.js │ └── worker.js ├── project.config.json ├── project.swan.json ├── res │ ├── external │ │ ├── BasePack.bin │ │ ├── BasePack_atlas0.png │ │ ├── GamePack.bin │ │ ├── GamePack_atlas0.png │ │ ├── LoginPack.bin │ │ ├── MainPack.bin │ │ └── MainPack_atlas0.png │ ├── pb │ │ └── NetPack.proto │ └── source │ │ ├── Loading.bin │ │ ├── Loading_atlas0.png │ │ └── Loading_atlas_vckm32.jpg ├── swan-game-adapter.js ├── version.json └── weapp-adapter.js ├── laya ├── .laya ├── assets │ └── comp │ │ ├── blank.png │ │ ├── btn_close.png │ │ ├── button.png │ │ ├── checkbox.png │ │ ├── clip_num.png │ │ ├── clip_selectBox.png │ │ ├── clip_tree_arrow.png │ │ ├── clip_tree_folder.png │ │ ├── combobox.png │ │ ├── hscroll$bar.png │ │ ├── hscroll$down.png │ │ ├── hscroll$up.png │ │ ├── hscroll.png │ │ ├── hslider$bar.png │ │ ├── hslider.png │ │ ├── html.png │ │ ├── image.png │ │ ├── img_bg.png │ │ ├── label.png │ │ ├── linkbutton.png │ │ ├── progress$bar.png │ │ ├── progress.png │ │ ├── radio.png │ │ ├── radiogroup.png │ │ ├── tab.png │ │ ├── textarea.png │ │ ├── textinput.png │ │ ├── vscroll$bar.png │ │ ├── vscroll$down.png │ │ ├── vscroll$up.png │ │ ├── vscroll.png │ │ ├── vslider$bar.png │ │ └── vslider.png └── ignore.cfg ├── libs ├── LayaAir.d.ts ├── fairygui.d.ts └── wx.d.ts ├── protobuf ├── bundles │ ├── protobuf-bundles.d.ts │ ├── protobuf-bundles.js │ └── protobuf-bundles.min.js ├── library │ ├── protobuf-library.d.ts │ ├── protobuf-library.js │ └── protobuf-library.min.js ├── pbconfig.json └── protofile │ └── awesome.proto ├── src ├── Game │ ├── Defs │ │ ├── EventDef.ts │ │ └── ProtocolDef.ts │ ├── Modes │ │ ├── DDZLogic.ts │ │ └── RoleMode.ts │ ├── Scenes │ │ ├── LoadingScene.ts │ │ ├── LoginScene.ts │ │ └── MainScene.ts │ └── Winds │ │ ├── GamePlay │ │ ├── CardItem.ts │ │ └── CardMgr.ts │ │ ├── LoadingWind.ts │ │ ├── LoginWind.ts │ │ ├── MainWind.ts │ │ ├── MessageBox.ts │ │ └── WaitWind.ts ├── GameConfig.ts ├── Main.ts └── YKFarmework │ ├── EventMgr │ ├── DispatchEventNode.ts │ └── EventListenerMgr.ts │ ├── ModeMgr │ └── ModeMgr.ts │ ├── Net │ ├── NetMgr.ts │ ├── PackBase.ts │ ├── ProtoMap.ts │ └── ResponseMessageEvent.ts │ ├── ResMgr │ └── ResMgr.ts │ ├── SceneMgr │ ├── SceneBase.ts │ └── SceneMgr.ts │ ├── Task │ └── TaskBase.ts │ ├── UIMgr │ └── UIMgr.ts │ └── Util │ ├── GameFlag.ts │ ├── Log.ts │ └── TimeDelay.ts └── tsconfig.json /.gitignore: -------------------------------------------------------------------------------- 1 | 2 | \.laya/chrome/ 3 | -------------------------------------------------------------------------------- /.laya/compile.js: -------------------------------------------------------------------------------- 1 | // v1.0.0 2 | //是否使用IDE自带的node环境和插件,设置false后,则使用自己环境(使用命令行方式执行) 3 | let useIDENode = process.argv[0].indexOf("LayaAir") > -1 ? true : false; 4 | //获取Node插件和工作路径 5 | let ideModuleDir = useIDENode ? process.argv[1].replace("gulp\\bin\\gulp.js", "").replace("gulp/bin/gulp.js", "") : ""; 6 | let workSpaceDir = useIDENode ? process.argv[2].replace("--gulpfile=", "").replace("\\.laya\\compile.js", "").replace("/.laya/compile.js", "") : "./../"; 7 | 8 | //引用插件模块 9 | let gulp = require(ideModuleDir + "gulp"); 10 | let browserify = require(ideModuleDir + "browserify"); 11 | let source = require(ideModuleDir + "vinyl-source-stream"); 12 | let tsify = require(ideModuleDir + "tsify"); 13 | 14 | 15 | // 如果是发布时调用编译功能,增加prevTasks 16 | let prevTasks = ""; 17 | if (global.publish) { 18 | prevTasks = ["loadConfig"]; 19 | } 20 | 21 | //===== zys 22 | //自己全局安装的插件 23 | // let gutil = require(ideModuleDir + "gulp-util"); 24 | // // let babel = require("C:\\Users\\zys\\AppData\\Roaming\\npm\\node_modules\\"+ "gulp-babel"); 25 | // let ts = require("C:\\Users\\zys\\AppData\\Roaming\\npm\\node_modules\\"+ "gulp-typescript"); 26 | // let uglify = require( ideModuleDir + "gulp-uglify"); 27 | 28 | // // gutil.log(gutil.colors.red('[log]'), "ideModuleDir is " + ideModuleDir); 29 | 30 | // // gutil.log(gutil.colors.red('[log]'), "start yk " + workSpaceDir); 31 | // console.log("start yk complie"); 32 | // gulp.task("yk", prevTasks, function () { 33 | // // gutil.log(gutil.colors.red('[log]'), "start yk compile"); 34 | // return gulp.src([ 35 | // workSpaceDir + "/libs/*.d.ts", 36 | // workSpaceDir + "/protobuf/**/*.d.ts", 37 | // //如果需要加入 配置库 文件 38 | // workSpaceDir + "/src/YKFarmework/**/*.ts"]) 39 | // .pipe(ts({ 40 | // noImplicitAny: false, 41 | // outFile: "ykLib.js", 42 | // target: "es6", 43 | // lib: ["es6", "dom"], 44 | // removeComments: true, 45 | // })) 46 | // // .pipe(babel({ 47 | // // presets: ['es2015'] 48 | // // })) 49 | // // .pipe(uglify()) 50 | // .on('error', function (err) { 51 | // console.log(err.toString()); 52 | // // gutil.log(gutil.colors.red('[Error]'), err.toString()); 53 | // }) 54 | // .pipe(gulp.dest(workSpaceDir + "/bin/js")) 55 | // }); 56 | 57 | // let yktask = ["yk"]; 58 | //==== 59 | //使用browserify,转换ts到js,并输出到bin/js目录 60 | gulp.task("compile", prevTasks, function () { 61 | // 发布时调用编译功能,判断是否点击了编译选项 62 | if (global.publish && !global.config.compile) { 63 | return; 64 | } else if (global.publish && global.config.compile) { 65 | // 发布时调用编译,workSpaceDir使用publish.js里的变量 66 | workSpaceDir = global.workSpaceDir; 67 | } 68 | return browserify({ 69 | basedir: workSpaceDir, 70 | //是否开启调试,开启后会生成jsmap,方便调试ts源码,但会影响编译速度 71 | debug: true, 72 | entries: ['src/Main.ts'], 73 | cache: {}, 74 | packageCache: {} 75 | }) 76 | //使用tsify插件编译ts 77 | .plugin(tsify) 78 | .bundle() 79 | //使用source把输出文件命名为bundle.js 80 | .pipe(source('bundle.js')) 81 | //把bundle.js复制到bin/js目录 82 | .pipe(gulp.dest(workSpaceDir + "/bin/js")); 83 | }); -------------------------------------------------------------------------------- /.laya/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "0.2.0", 3 | "configurations": [ 4 | { 5 | "name": "layaAir", 6 | "type": "chrome", 7 | "request": "launch", 8 | "file": "${workspaceRoot}/bin/index.html", 9 | "runtimeExecutable": "${execPath}", 10 | "useBuildInServer": true, 11 | "sourceMaps": true, 12 | "webRoot": "${workspaceRoot}", 13 | "port": 9222, 14 | "fixedPort":false, 15 | "sourceMapPathOverrides": { 16 | "src/*": "${workspaceRoot}/src/*" 17 | } 18 | }, 19 | { 20 | "name": "chrome调试", 21 | "type": "chrome", 22 | "request": "launch", 23 | "file": "${workspaceRoot}/bin/index.html", 24 | // "换成自己的谷歌安装路径,": 比如 25 | //window 默认安装路径为: "C:/Program Files (x86)/Google/Chrome/Application/chrome.exe" 26 | //mac 系统上的默认安装路径为 "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome"; 27 | // "runtimeExecutable": "C:/Program Files (x86)/Google/Chrome/Application/chrome.exe", 28 | "runtimeArgs": [ 29 | "--allow-file-access-from-files", 30 | "--allow-file-access-frome-files", 31 | " --disable-web-security" 32 | ], 33 | "sourceMaps": true, 34 | "webRoot": "${workspaceRoot}", 35 | //假如谷歌调试报userDataDir不可用,请把谷歌安装路径取得管理员权限,或者更换${tmpdir}为其他可以读写的文件夹,也可以删除。 36 | "userDataDir": "${workspaceRoot}/.laya/chrome", 37 | "fixedPort":false, 38 | "sourceMapPathOverrides": { 39 | "src/*": "${workspaceRoot}/src/*" 40 | } 41 | } 42 | ] 43 | } -------------------------------------------------------------------------------- /.laya/publish.js: -------------------------------------------------------------------------------- 1 | // v1.0.1 2 | //是否使用IDE自带的node环境和插件,设置false后,则使用自己环境(使用命令行方式执行) 3 | const useIDENode = process.argv[0].indexOf("LayaAir") > -1 ? true : false; 4 | //获取Node插件和工作路径 5 | let ideModuleDir = useIDENode ? process.argv[1].replace("gulp\\bin\\gulp.js", "").replace("gulp/bin/gulp.js", "") : ""; 6 | let workSpaceDir = useIDENode ? process.argv[2].replace("--gulpfile=", "").replace("\\.laya\\publish.js", "").replace("/.laya/publish.js", "") + "/" : "./../"; 7 | 8 | //引用插件模块 9 | const gulp = require(ideModuleDir + "gulp"); 10 | const fs = require("fs"); 11 | const path = require("path"); 12 | const uglify = require(ideModuleDir + "gulp-uglify"); 13 | const jsonminify = require(ideModuleDir + "gulp-jsonminify"); 14 | const image = require(ideModuleDir + "gulp-image"); 15 | const rev = require(ideModuleDir + "gulp-rev"); 16 | const revdel = require(ideModuleDir + "gulp-rev-delete-original"); 17 | const revCollector = require(ideModuleDir + 'gulp-rev-collector'); 18 | const del = require(ideModuleDir + "del"); 19 | const requireDir = require(ideModuleDir + 'require-dir'); 20 | 21 | // 结合compile.js使用 22 | global.publish = true; 23 | requireDir('./', { 24 | filter: function (fullPath) { 25 | // 只用到了compile.js和publish.js 26 | if (path.basename(fullPath) === "compile.js") { 27 | return true; 28 | } else { 29 | return false; 30 | } 31 | } 32 | }); 33 | 34 | 35 | //清理临时文件夹,加载配置 36 | let config, 37 | releaseDir, 38 | platform; 39 | gulp.task("loadConfig", function () { 40 | platform = "web" 41 | if (!useIDENode && process.argv.length > 5 && process.argv[4] == "--config") { 42 | platform = process.argv[5].replace(".json", ""); 43 | } 44 | if (useIDENode && process.argv.length >= 4 && process.argv[3].startsWith("--config") && process.argv[3].endsWith(".json")) { 45 | platform = process.argv[3].match(/(\w+).json/)[1]; 46 | } 47 | let _path; 48 | if (!useIDENode) { 49 | _path = platform + ".json"; 50 | releaseDir = "../release/" + platform; 51 | } 52 | if (useIDENode) { 53 | _path = path.join(workSpaceDir, ".laya", `${platform}.json`); 54 | releaseDir = path.join(workSpaceDir, "release", platform).replace(/\\/g, "/"); 55 | } 56 | let file = fs.readFileSync(_path, "utf-8"); 57 | if (file) { 58 | file = file.replace(/\$basePath/g, releaseDir); 59 | config = JSON.parse(file); 60 | global.config = config; 61 | global.workSpaceDir = workSpaceDir; 62 | } 63 | }); 64 | 65 | //重新编译项目 66 | // gulp.task("compile", ["loadConfig"], function () { 67 | // if (config.compile) { 68 | // console.log("compile"); 69 | // } 70 | // }); 71 | 72 | //清理release文件夹 73 | gulp.task("clearReleaseDir", ["compile"], function (cb) { 74 | if (config.clearReleaseDir) { 75 | del([releaseDir, releaseDir + "_pack", config.packfileTargetValue], { force: true }).then(paths => { 76 | cb(); 77 | }); 78 | } else cb(); 79 | }); 80 | 81 | //copy bin文件到release文件夹 82 | gulp.task("copyFile", ["clearReleaseDir"], function () { 83 | let baseCopyFilter = `${workSpaceDir}/bin/**/*.*`; 84 | if (platform === "wxgame") { // 微信项目,不拷贝index.html,不拷贝百度bin目录中的文件 85 | config.copyFilesFilter = [baseCopyFilter, `!${workSpaceDir}/bin/index.html`, `!${workSpaceDir}/bin/{project.swan.json,swan-game-adapter.js}`]; 86 | } else if (platform === "bdgame") { // 百度项目,不拷贝index.html,不拷贝微信bin目录中的文件 87 | config.copyFilesFilter = [baseCopyFilter, `!${workSpaceDir}/bin/index.html`, `!${workSpaceDir}/bin/{project.config.json,weapp-adapter.js}`]; 88 | } else { // web|QQ项目,不拷贝微信、百度在bin目录中的文件 89 | config.copyFilesFilter = [baseCopyFilter, `!${workSpaceDir}/bin/{game.js,game.json,project.config.json,weapp-adapter.js,project.swan.json,swan-game-adapter.js}`]; 90 | } 91 | var stream = gulp.src(config.copyFilesFilter); 92 | return stream.pipe(gulp.dest(releaseDir)); 93 | }); 94 | 95 | // 根据不同的项目类型拷贝平台文件 96 | gulp.task("copyPlatformFile", ["copyFile"], function () { 97 | let fileLibsPath; 98 | if (useIDENode) { 99 | fileLibsPath = path.join(ideModuleDir, "../", "out", "layarepublic", "LayaAirProjectPack", "lib", "data"); 100 | } else if (process.argv.length >= 8 && process.argv[6] === "--libspath") { 101 | fileLibsPath = process.argv[7]; 102 | console.log("平台文件包是否存在: " + fs.existsSync(fileLibsPath)); 103 | } else { 104 | console.log("没有接收到可用文件包位置,不拷贝对应平台文件"); 105 | return; 106 | } 107 | // 微信项目 108 | if (platform === "wxgame") { 109 | // 如果新建项目时已经点击了"微信/百度小游戏bin目录快速调试",不再拷贝 110 | let isHadWXFiles = 111 | fs.existsSync(path.join(workSpaceDir, "bin", "game.js")) && 112 | fs.existsSync(path.join(workSpaceDir, "bin", "game.json")) && 113 | fs.existsSync(path.join(workSpaceDir, "bin", "project.config.json")) && 114 | fs.existsSync(path.join(workSpaceDir, "bin", "weapp-adapter.js")); 115 | if (isHadWXFiles) { 116 | return; 117 | } 118 | let platformDir = path.join(fileLibsPath, "wxfiles"); 119 | let stream = gulp.src(platformDir + "/*.*"); 120 | return stream.pipe(gulp.dest(releaseDir)); 121 | } 122 | // qq玩一玩项目,区分语言 123 | if (platform === "qqwanyiwan") { 124 | let projectLangDir = config.projectType; 125 | let platformDir = path.join(fileLibsPath, "qqfiles", projectLangDir); 126 | let stream = gulp.src(platformDir + "/**/*.*"); 127 | return stream.pipe(gulp.dest(releaseDir)); 128 | } 129 | // 百度项目 130 | if (platform === "bdgame") { 131 | // 如果新建项目时已经点击了"微信/百度小游戏bin目录快速调试",不再拷贝 132 | let isHadBdFiles = 133 | fs.existsSync(path.join(workSpaceDir, "bin", "game.js")) && 134 | fs.existsSync(path.join(workSpaceDir, "bin", "game.json")) && 135 | fs.existsSync(path.join(workSpaceDir, "bin", "project.swan.json")) && 136 | fs.existsSync(path.join(workSpaceDir, "bin", "swan-game-adapter.js")); 137 | if (isHadBdFiles) { 138 | return; 139 | } 140 | let platformDir = path.join(fileLibsPath, "bdfiles"); 141 | let stream = gulp.src(platformDir + "/*.*"); 142 | return stream.pipe(gulp.dest(releaseDir)); 143 | } 144 | }); 145 | 146 | // 拷贝文件后,针对特定平台修改文件内容 147 | gulp.task("modifyFile", ["copyPlatformFile"], function () { 148 | // QQ玩一玩 149 | if (platform === "qqwanyiwan") { 150 | // 修改bundle.js 151 | let bundleFilePath = path.join(releaseDir, "js", "bundle.js"); 152 | if (fs.existsSync(bundleFilePath)) { 153 | let fileContent = fs.readFileSync(bundleFilePath, "utf8"); 154 | var appendCode = 'if(window["BK"]&&window["BK"]["Sprite"]){BK.Script.loadlib("GameRes://layaforqq/laya.bkadpter.js");}'; 155 | if (fileContent.includes("/**LayaGameStart**/") && !fileContent.includes(appendCode)) { 156 | fileContent = fileContent.split("/**LayaGameStart**/").join(`/**LayaGameStart**/\n${appendCode}`); 157 | fs.writeFileSync(bundleFilePath, fileContent, "utf8"); 158 | } 159 | } 160 | 161 | // 修改index.js 162 | let indexFilePath = path.join(releaseDir, "index.js"); 163 | if (fs.existsSync(indexFilePath)) { 164 | let fileContent = fs.readFileSync(indexFilePath, "utf8"); 165 | fileContent = fileContent.replace(/loadLib\("/g, "BK.Script.loadlib(\"GameRes://"); 166 | // 非as语言,要添加类库 167 | if ("as" !== config.projectType) { 168 | if (fileContent.includes("//-----libs-end-------")) { 169 | fileContent = fileContent.split("//-----libs-end-------").join(`//-----libs-end-------\nBK.Script.loadlib("GameRes://layaforqq/laya.bkadpter.js");`); 170 | } 171 | } 172 | fs.writeFileSync(indexFilePath, fileContent, "utf8"); 173 | } 174 | 175 | // 修改main.js 176 | let mainFilePath = path.join(releaseDir, "main.js"); 177 | if (fs.existsSync(mainFilePath)) { 178 | let fileContent = fs.readFileSync(mainFilePath, "utf8"); 179 | fileContent = `BK.Script.loadlib("GameRes://layaforqq/qqPlayCore.js"); 180 | BK.Script.loadlib("GameRes://layaforqq/bkadptpre.js"); 181 | BK.Script.loadlib("GameRes://layaforqq/domparserinone.js"); 182 | BK.Script.loadlib("GameRes://index.js");`; 183 | fs.writeFileSync(mainFilePath, fileContent, "utf8"); 184 | } 185 | 186 | return; 187 | } 188 | 189 | // 百度项目,修改index.js 190 | if (platform === "bdgame") { 191 | let filePath = path.join(releaseDir, "index.js"); 192 | if (!fs.existsSync(filePath)) { 193 | return; 194 | } 195 | let fileContent = fs.readFileSync(filePath, "utf8"); 196 | fileContent = fileContent.replace(/loadLib\(/g, "require("); 197 | fs.writeFileSync(filePath, fileContent, "utf8"); 198 | return; 199 | } 200 | }); 201 | 202 | //压缩json 203 | gulp.task("compressJson", ["modifyFile"], function () { 204 | if (config.compressJson) { 205 | return gulp.src(config.compressJsonFilter) 206 | .pipe(jsonminify()) 207 | .pipe(gulp.dest(releaseDir)); 208 | } 209 | }); 210 | 211 | //压缩js 212 | gulp.task("compressJs", ["compressJson"], function () { 213 | if (config.compressJs) { 214 | return gulp.src(config.compressJsFilter) 215 | .pipe(uglify()) 216 | .on('error', function (err) { 217 | console.warn(err.toString()); 218 | }) 219 | .pipe(gulp.dest(releaseDir)); 220 | } 221 | }); 222 | 223 | //压缩png,jpg 224 | gulp.task("compressImage", ["compressJs"], function () { 225 | if (config.compressImage) { 226 | return gulp.src(config.compressImageFilter) 227 | .pipe(image({ 228 | pngquant: true, //PNG优化工具 229 | optipng: false, //PNG优化工具 230 | zopflipng: true, //PNG优化工具 231 | jpegRecompress: false, //jpg优化工具 232 | mozjpeg: true, //jpg优化工具 233 | guetzli: false, //jpg优化工具 234 | gifsicle: false, //gif优化工具 235 | svgo: false, //SVG优化工具 236 | concurrent: 10, //并发线程数 237 | quiet: true //是否是静默方式 238 | // optipng: ['-i 1', '-strip all', '-fix', '-o7', '-force'], 239 | // pngquant: ['--speed=1', '--force', 256], 240 | // zopflipng: ['-y', '--lossy_8bit', '--lossy_transparent'], 241 | // jpegRecompress: ['--strip', '--quality', 'medium', '--min', 40, '--max', 80], 242 | // mozjpeg: ['-optimize', '-progressive'], 243 | // guetzli: ['--quality', 85] 244 | })) 245 | .pipe(gulp.dest(releaseDir)); 246 | } 247 | }); 248 | 249 | 250 | //开放域的情况下,合并game.js和index.js 251 | gulp.task("openData", ["compressImage"], function () { 252 | if (config.openDataZone) { 253 | let indexPath = releaseDir + "/index.js"; 254 | let indexjs = readFile(indexPath); 255 | let gamejs = readFile(releaseDir + "/game.js"); 256 | if (gamejs && indexjs) { 257 | gamejs = gamejs.replace('require("index.js")', indexjs); 258 | fs.writeFileSync(indexPath, gamejs, 'utf-8'); 259 | } 260 | } 261 | }); 262 | 263 | function readFile(path) { 264 | if (fs.existsSync(path)) { 265 | return fs.readFileSync(path, "utf-8"); 266 | } 267 | return null; 268 | } 269 | 270 | //生成版本管理信息 271 | gulp.task("version1", ["openData"], function () { 272 | if (config.version) { 273 | return gulp.src(config.versionFilter) 274 | .pipe(rev()) 275 | .pipe(gulp.dest(releaseDir)) 276 | .pipe(revdel()) 277 | .pipe(rev.manifest("version.json")) 278 | .pipe(gulp.dest(releaseDir)); 279 | } 280 | }); 281 | 282 | //替换index.js里面的变化的文件名 283 | gulp.task("version2", ["version1"], function () { 284 | if (config.version) { 285 | //替换index.html和index.js里面的文件名称 286 | 287 | let htmlPath = releaseDir + "/index.html"; 288 | let versionPath = releaseDir + "/version.json"; 289 | let gameJSPath = releaseDir + "/game.js"; 290 | let mainJSPath = releaseDir + "/main.js"; 291 | let indexJSPath; 292 | let versionCon = fs.readFileSync(versionPath, "utf8"); 293 | versionCon = JSON.parse(versionCon); 294 | indexJSPath = releaseDir + "/" + versionCon["index.js"]; 295 | // 替换config.packfileFullValue中的路径 296 | let packfileStr = JSON.stringify(config.packfileFullValue).replace(/\\\\/g, "/"); 297 | let tempPackfile = `${workSpaceDir}/.laya/configTemp.json`; 298 | fs.writeFileSync(tempPackfile, packfileStr, "utf8"); 299 | 300 | let srcList = [versionPath, indexJSPath, tempPackfile]; 301 | if (fs.existsSync(htmlPath)) { 302 | srcList.push(htmlPath); 303 | } 304 | if (fs.existsSync(gameJSPath)) { 305 | srcList.push(gameJSPath); 306 | } 307 | if (fs.existsSync(mainJSPath)) { 308 | srcList.push(mainJSPath); 309 | } 310 | return gulp.src(srcList) 311 | .pipe(revCollector()) 312 | .pipe(gulp.dest(releaseDir)); 313 | } 314 | }); 315 | 316 | //起始任务,筛选4M包 317 | gulp.task("publish", ["version2"], function () { 318 | if (config.version) { 319 | // 从release目录取得带有版本号的目录 320 | let tempPackfile = `${workSpaceDir}/.laya/configTemp.json`; 321 | let releasePackfile = `${releaseDir}/configTemp.json`; 322 | let packfileStr = fs.readFileSync(releasePackfile, "utf8"); 323 | config.packfileFullValue = JSON.parse(packfileStr); 324 | // 删掉临时目录 325 | fs.unlinkSync(tempPackfile); 326 | fs.unlinkSync(releasePackfile); 327 | } 328 | if (config.packfile) { // 提取本地包(文件列表形式) 329 | return gulp.src(config.packfileFullValue, { base: releaseDir }) 330 | .pipe(gulp.dest(config.packfileTargetValue || releaseDir + "_pack")); 331 | } 332 | }); -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | laya1.0 的版本 https://github.com/YKPublicGame/LayaYKFamework.git 这是原作者 2 | 3 | laya2.0 的编译改了。把framework打成lib 文件加载 4 | -------------------------------------------------------------------------------- /YKFrame.laya: -------------------------------------------------------------------------------- 1 | {"proName":"YKFrame","engineType":0,"proType":1,"layaProType":0,"version":"2.0.0"} -------------------------------------------------------------------------------- /bin/fileconfig.json: -------------------------------------------------------------------------------- 1 | {"res/atlas/comp.atlas":["comp/",["blank.png","btn_close.png","button.png","checkbox.png","clip_num.png","clip_selectBox.png","clip_tree_arrow.png","clip_tree_folder.png","combobox.png","hscroll$bar.png","hscroll$down.png","hscroll$up.png","hscroll.png","hslider$bar.png","hslider.png","html.png","image.png","img_bg.png","label.png","linkbutton.png","progress$bar.png","progress.png","radio.png","radiogroup.png","tab.png","textarea.png","textinput.png","vscroll$bar.png","vscroll$down.png","vscroll$up.png","vscroll.png","vslider$bar.png","vslider.png"]]} -------------------------------------------------------------------------------- /bin/game.js: -------------------------------------------------------------------------------- 1 | if ((typeof swan !== 'undefined') && (typeof swanGlobal !== 'undefined')) { 2 | require("swan-game-adapter.js"); 3 | require("libs/laya.bdmini.js"); 4 | } else if (typeof wx!=="undefined") { 5 | require("weapp-adapter.js"); 6 | require("libs/laya.wxmini.js"); 7 | } 8 | window.loadLib = require; 9 | require("index.js"); -------------------------------------------------------------------------------- /bin/game.json: -------------------------------------------------------------------------------- 1 | { 2 | "deviceOrientation": "portrait", 3 | "showStatusBar": false, 4 | "networkTimeout": { 5 | "request": 10000, 6 | "connectSocket": 10000, 7 | "uploadFile": 10000, 8 | "downloadFile": 10000 9 | } 10 | } -------------------------------------------------------------------------------- /bin/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 |
4 |PathFinding
类用于创建寻路。
8 | */
9 | //class laya.d3.component.PathFind extends laya.components.Component
10 | var PathFind=(function(_super){
11 | function PathFind(){
12 | /**@private */
13 | this._meshTerrainSprite3D=null;
14 | /**@private */
15 | this._finder=null;
16 | /**@private */
17 | this._setting=null;
18 | /**寻路网格。*/
19 | this.grid=null;
20 | PathFind.__super.call(this);
21 | }
22 |
23 | __class(PathFind,'laya.d3.component.PathFind',_super);
24 | var __proto=PathFind.prototype;
25 | /**
26 | *@private
27 | *初始化载入蒙皮动画组件。
28 | *@param owner 所属精灵对象。
29 | */
30 | __proto._onAdded=function(){
31 | if (! (this.owner instanceof laya.d3.core.MeshTerrainSprite3D ))
32 | throw new Error("PathFinding: The owner must MeshTerrainSprite3D!");
33 | this._meshTerrainSprite3D=this.owner;
34 | }
35 |
36 | /**
37 | *寻找路径。
38 | *@param startX 开始X。
39 | *@param startZ 开始Z。
40 | *@param endX 结束X。
41 | *@param endZ 结束Z。
42 | *@return 路径。
43 | */
44 | __proto.findPath=function(startX,startZ,endX,endZ){
45 | var minX=this._meshTerrainSprite3D.minX;
46 | var minZ=this._meshTerrainSprite3D.minZ;
47 | var cellX=this._meshTerrainSprite3D.width / this.grid.width;
48 | var cellZ=this._meshTerrainSprite3D.depth / this.grid.height;
49 | var halfCellX=cellX / 2;
50 | var halfCellZ=cellZ / 2;
51 | var gridStartX=Math.floor((startX-minX)/ cellX);
52 | var gridStartZ=Math.floor((startZ-minZ)/ cellZ);
53 | var gridEndX=Math.floor((endX-minX)/ cellX);
54 | var gridEndZ=Math.floor((endZ-minZ)/ cellZ);
55 | var boundWidth=this.grid.width-1;
56 | var boundHeight=this.grid.height-1;
57 | (gridStartX > boundWidth)&& (gridStartX=boundWidth);
58 | (gridStartZ > boundHeight)&& (gridStartZ=boundHeight);
59 | (gridStartX < 0)&& (gridStartX=0);
60 | (gridStartZ < 0)&& (gridStartZ=0);
61 | (gridEndX > boundWidth)&& (gridEndX=boundWidth);
62 | (gridEndZ > boundHeight)&& (gridEndZ=boundHeight);
63 | (gridEndX < 0)&& (gridEndX=0);
64 | (gridEndZ < 0)&& (gridEndZ=0);
65 | var path=this._finder.findPath(gridStartX,gridStartZ,gridEndX,gridEndZ,this.grid);
66 | this.grid.reset();
67 | for (var i=1;i < path.length-1;i++){
68 | var gridPos=path[i];
69 | gridPos[0]=gridPos[0] *cellX+halfCellX+minX;
70 | gridPos[1]=gridPos[1] *cellZ+halfCellZ+minZ;
71 | }
72 | if (path.length==1){
73 | path[0][0]=endX;
74 | path[0][1]=endX;
75 | }else if (path.length > 1){
76 | path[0][0]=startX;
77 | path[0][1]=startZ;
78 | path[path.length-1][0]=endX;
79 | path[path.length-1][1]=endZ;
80 | }
81 | return path;
82 | }
83 |
84 | /**
85 | *设置寻路设置。
86 | *@param value 寻路设置。
87 | */
88 | /**
89 | *获取寻路设置。
90 | *@return 寻路设置。
91 | */
92 | __getset(0,__proto,'setting',function(){
93 | return this._setting;
94 | },function(value){
95 | (value)&& (this._finder=new PathFinding.finders.AStarFinder(value));
96 | this._setting=value;
97 | });
98 |
99 | return PathFind;
100 | })(Component)
101 |
102 |
103 |
104 | })(window,document,Laya);
105 |
--------------------------------------------------------------------------------
/bin/libs/laya.filter.js:
--------------------------------------------------------------------------------
1 |
2 | (function(window,document,Laya){
3 | var __un=Laya.un,__uns=Laya.uns,__static=Laya.static,__class=Laya.class,__getset=Laya.getset,__newvec=Laya.__newvec;
4 |
5 | var ColorUtils=laya.utils.ColorUtils,Filter=laya.filters.Filter,Matrix=laya.maths.Matrix,Render=laya.renders.Render;
6 | var RunDriver=laya.utils.RunDriver,ShaderDefines2D=laya.webgl.shader.d2.ShaderDefines2D,Sprite=laya.display.Sprite;
7 | var Value2D=laya.webgl.shader.d2.value.Value2D;
8 | /**
9 | *@private
10 | */
11 | //class laya.filters.GlowFilterGLRender
12 | var GlowFilterGLRender=(function(){
13 | function GlowFilterGLRender(){}
14 | __class(GlowFilterGLRender,'laya.filters.GlowFilterGLRender');
15 | var __proto=GlowFilterGLRender.prototype;
16 | __proto.setShaderInfo=function(shader,w,h,data){
17 | shader.defines.add(data.type);
18 | var sv=shader;
19 | sv.u_blurInfo1=data._sv_blurInfo1;
20 | var info2=data._sv_blurInfo2;
21 | info2[0]=w;info2[1]=h;
22 | sv.u_blurInfo2=info2;
23 | sv.u_color=data.getColor();
24 | }
25 |
26 | __proto.render=function(rt,ctx,width,height,filter){
27 | var w=width,h=height;
28 | var svBlur=Value2D.create(/*laya.webgl.shader.d2.ShaderDefines2D.TEXTURE2D*/0x01,0);
29 | this.setShaderInfo(svBlur,w,h,filter);
30 | var svCP=Value2D.create(/*laya.webgl.shader.d2.ShaderDefines2D.TEXTURE2D*/0x01,0);
31 | var matI=Matrix.TEMP.identity();
32 | ctx.drawTarget(rt,0,0,w,h,matI,svBlur);
33 | ctx.drawTarget(rt,0,0,w,h,matI,svCP);
34 | }
35 |
36 | return GlowFilterGLRender;
37 | })()
38 |
39 |
40 | /**
41 | *@private
42 | */
43 | //class laya.filters.BlurFilterGLRender
44 | var BlurFilterGLRender=(function(){
45 | function BlurFilterGLRender(){}
46 | __class(BlurFilterGLRender,'laya.filters.BlurFilterGLRender');
47 | var __proto=BlurFilterGLRender.prototype;
48 | __proto.render=function(rt,ctx,width,height,filter){
49 | var shaderValue=Value2D.create(/*laya.webgl.shader.d2.ShaderDefines2D.TEXTURE2D*/0x01,0);
50 | this.setShaderInfo(shaderValue,filter,rt.width,rt.height);
51 | ctx.drawTarget(rt,0,0,width,height,Matrix.EMPTY.identity(),shaderValue);
52 | }
53 |
54 | __proto.setShaderInfo=function(shader,filter,w,h){
55 | shader.defines.add(/*laya.filters.Filter.BLUR*/0x10);
56 | var sv=shader;
57 | BlurFilterGLRender.blurinfo[0]=w;BlurFilterGLRender.blurinfo[1]=h;
58 | sv.blurInfo=BlurFilterGLRender.blurinfo;
59 | var sigma=filter.strength/3.0;
60 | var sigma2=sigma*sigma;
61 | filter.strength_sig2_2sig2_gauss1[0]=filter.strength;
62 | filter.strength_sig2_2sig2_gauss1[1]=sigma2;
63 | filter.strength_sig2_2sig2_gauss1[2]=2.0*sigma2;
64 | filter.strength_sig2_2sig2_gauss1[3]=1.0/(2.0*Math.PI*sigma2);
65 | sv.strength_sig2_2sig2_gauss1=filter.strength_sig2_2sig2_gauss1;
66 | }
67 |
68 | __static(BlurFilterGLRender,
69 | ['blurinfo',function(){return this.blurinfo=new Array(2);}
70 | ]);
71 | return BlurFilterGLRender;
72 | })()
73 |
74 |
75 | /**
76 | *模糊滤镜
77 | */
78 | //class laya.filters.BlurFilter extends laya.filters.Filter
79 | var BlurFilter=(function(_super){
80 | function BlurFilter(strength){
81 | /**模糊滤镜的强度(值越大,越不清晰 */
82 | this.strength=NaN;
83 | this.strength_sig2_2sig2_gauss1=[];
84 | //给shader用的。避免创建对象
85 | this.strength_sig2_native=null;
86 | //给native用的
87 | this.renderFunc=null;
88 | BlurFilter.__super.call(this);
89 | (strength===void 0)&& (strength=4);
90 | this.strength=strength;
91 | this._action=null;
92 | this._glRender=new BlurFilterGLRender();
93 | }
94 |
95 | __class(BlurFilter,'laya.filters.BlurFilter',_super);
96 | var __proto=BlurFilter.prototype;
97 | __proto.getStrenth_sig2_2sig2_native=function(){
98 | if (!this.strength_sig2_native){
99 | this.strength_sig2_native=new Float32Array(4);
100 | };
101 | var sigma=this.strength/3.0;
102 | var sigma2=sigma *sigma;
103 | this.strength_sig2_native[0]=this.strength;
104 | this.strength_sig2_native[1]=sigma2;
105 | this.strength_sig2_native[2]=2.0*sigma2;
106 | this.strength_sig2_native[3]=1.0 / (2.0 *Math.PI *sigma2);
107 | return this.strength_sig2_native;
108 | }
109 |
110 | /**
111 | *@private
112 | *当前滤镜的类型
113 | */
114 | __getset(0,__proto,'type',function(){
115 | return 0x10;
116 | });
117 |
118 | return BlurFilter;
119 | })(Filter)
120 |
121 |
122 | /**
123 | *发光滤镜(也可以当成阴影滤使用)
124 | */
125 | //class laya.filters.GlowFilter extends laya.filters.Filter
126 | var GlowFilter=(function(_super){
127 | function GlowFilter(color,blur,offX,offY){
128 | //给shader用
129 | this._sv_blurInfo2=[0,0,1,0];
130 | /**滤镜的颜色*/
131 | this._color=null;
132 | this._color_native=null;
133 | this._blurInof1_native=null;
134 | this._blurInof2_native=null;
135 | GlowFilter.__super.call(this);
136 | this._elements=new Float32Array(9);
137 | this._sv_blurInfo1=new Array(4);
138 | (blur===void 0)&& (blur=4);
139 | (offX===void 0)&& (offX=6);
140 | (offY===void 0)&& (offY=6);
141 | this._color=new ColorUtils(color);
142 | this.blur=Math.min(blur,20);
143 | this.offX=offX;
144 | this.offY=offY;
145 | this._sv_blurInfo1[0]=this._sv_blurInfo1[1]=this.blur;this._sv_blurInfo1[2]=offX;this._sv_blurInfo1[3]=-offY;
146 | this._glRender=new GlowFilterGLRender();
147 | }
148 |
149 | __class(GlowFilter,'laya.filters.GlowFilter',_super);
150 | var __proto=GlowFilter.prototype;
151 | /**@private */
152 | __proto.getColor=function(){
153 | return this._color.arrColor;
154 | }
155 |
156 | __proto.getColorNative=function(){
157 | if (!this._color_native){
158 | this._color_native=new Float32Array(4);
159 | };
160 | var color=this.getColor();
161 | this._color_native[0]=color[0];
162 | this._color_native[1]=color[1];
163 | this._color_native[2]=color[2];
164 | this._color_native[3]=color[3];
165 | return this._color_native;
166 | }
167 |
168 | __proto.getBlurInfo1Native=function(){
169 | if (!this._blurInof1_native){
170 | this._blurInof1_native=new Float32Array(4);
171 | }
172 | this._blurInof1_native[0]=this._blurInof1_native[1]=this.blur;
173 | this._blurInof1_native[2]=this.offX;
174 | this._blurInof1_native[3]=this.offY;
175 | return this._blurInof1_native;
176 | }
177 |
178 | __proto.getBlurInfo2Native=function(){
179 | if (!this._blurInof2_native){
180 | this._blurInof2_native=new Float32Array(4);
181 | }
182 | this._blurInof2_native[2]=1;
183 | return this._blurInof2_native;
184 | }
185 |
186 | /**
187 | *@private
188 | *滤镜类型
189 | */
190 | __getset(0,__proto,'type',function(){
191 | return 0x08;
192 | });
193 |
194 | /**@private */
195 | /**@private */
196 | __getset(0,__proto,'offY',function(){
197 | return this._elements[6];
198 | },function(value){
199 | this._elements[6]=value;
200 | this._sv_blurInfo1[3]=-value;
201 | });
202 |
203 | /**@private */
204 | /**@private */
205 | __getset(0,__proto,'offX',function(){
206 | return this._elements[5];
207 | },function(value){
208 | this._elements[5]=value;
209 | this._sv_blurInfo1[2]=value;
210 | });
211 |
212 | /**@private */
213 | /**@private */
214 | __getset(0,__proto,'blur',function(){
215 | return this._elements[4];
216 | },function(value){
217 | this._elements[4]=value;
218 | this._sv_blurInfo1[0]=this._sv_blurInfo1[1]=value;
219 | });
220 |
221 | return GlowFilter;
222 | })(Filter)
223 |
224 |
225 |
226 | })(window,document,Laya);
227 |
--------------------------------------------------------------------------------
/bin/libs/laya.physics3D.wasm.wasm:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/superzys/YKFrame/5e53d6a95349ab9367197de22ae06206b0ac19c4/bin/libs/laya.physics3D.wasm.wasm
--------------------------------------------------------------------------------
/bin/libs/rawinflate/rawinflate.min.js:
--------------------------------------------------------------------------------
1 | /** @license zlib.js 2012 - imaya [ https://github.com/imaya/zlib.js ] The MIT License */(function() {'use strict';var l=this;function p(b,e){var a=b.split("."),c=l;!(a[0]in c)&&c.execScript&&c.execScript("var "+a[0]);for(var d;a.length&&(d=a.shift());)!a.length&&void 0!==e?c[d]=e:c=c[d]?c[d]:c[d]={}};var q="undefined"!==typeof Uint8Array&&"undefined"!==typeof Uint16Array&&"undefined"!==typeof Uint32Array&&"undefined"!==typeof DataView;function t(b){var e=b.length,a=0,c=Number.POSITIVE_INFINITY,d,f,g,h,k,m,r,n,s,J;for(n=0;n