├── .laya ├── launch.json ├── pubset.json └── tasks.json ├── FatDouDiZhu.laya ├── README.md ├── bin ├── code.js ├── index.html ├── js │ └── .gitkeep ├── libs │ ├── LayaRender.js │ ├── bytebuffer.js │ ├── domparserinone.js │ ├── laya.ani.js │ ├── laya.core.js │ ├── laya.d3.js │ ├── laya.d3Plugin.js │ ├── laya.debugtool.js │ ├── laya.device.js │ ├── laya.filter.js │ ├── laya.html.js │ ├── laya.particle.js │ ├── laya.pathfinding.js │ ├── laya.tiledmap.js │ ├── laya.ui.js │ ├── laya.webgl.js │ ├── laya.wxmini.js │ ├── matter-RenderLaya.js │ ├── matter.js │ ├── min │ │ ├── laya.ani.min.js │ │ ├── laya.core.min.js │ │ ├── laya.d3.min.js │ │ ├── laya.d3Plugin.min.js │ │ ├── laya.debugtool.min.js │ │ ├── laya.device.min.js │ │ ├── laya.filter.min.js │ │ ├── laya.html.min.js │ │ ├── laya.particle.min.js │ │ ├── laya.pathfinding.min.js │ │ ├── laya.tiledmap.min.js │ │ ├── laya.ui.min.js │ │ ├── laya.webgl.min.js │ │ └── laya.wxmini.min.js │ ├── protobuf.js │ └── worker.js ├── res │ └── .gitkeep └── unpack.json ├── laya ├── .laya ├── assets │ ├── comp │ │ ├── bg.png │ │ ├── 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 │ │ ├── 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 │ ├── doudizhu │ │ ├── bg_poker.png │ │ ├── dizhu.png │ │ └── nongmin.png │ └── poker │ │ ├── 1.jpg │ │ ├── 10.jpg │ │ ├── 11.jpg │ │ ├── 12.jpg │ │ ├── 13.jpg │ │ ├── 14.jpg │ │ ├── 15.jpg │ │ ├── 16.jpg │ │ ├── 17.jpg │ │ ├── 18.jpg │ │ ├── 19.jpg │ │ ├── 2.jpg │ │ ├── 20.jpg │ │ ├── 21.jpg │ │ ├── 22.jpg │ │ ├── 23.jpg │ │ ├── 24.jpg │ │ ├── 25.jpg │ │ ├── 26.jpg │ │ ├── 27.jpg │ │ ├── 28.jpg │ │ ├── 29.jpg │ │ ├── 3.jpg │ │ ├── 30.jpg │ │ ├── 31.jpg │ │ ├── 32.jpg │ │ ├── 33.jpg │ │ ├── 34.jpg │ │ ├── 35.jpg │ │ ├── 36.jpg │ │ ├── 37.jpg │ │ ├── 38.jpg │ │ ├── 39.jpg │ │ ├── 4.jpg │ │ ├── 40.jpg │ │ ├── 41.jpg │ │ ├── 42.jpg │ │ ├── 43.jpg │ │ ├── 44.jpg │ │ ├── 45.jpg │ │ ├── 46.jpg │ │ ├── 47.jpg │ │ ├── 48.jpg │ │ ├── 49.jpg │ │ ├── 5.jpg │ │ ├── 50.jpg │ │ ├── 51.jpg │ │ ├── 52.jpg │ │ ├── 53.jpg │ │ ├── 54.jpg │ │ ├── 6.jpg │ │ ├── 7.jpg │ │ ├── 8.jpg │ │ └── 9.jpg └── pages │ ├── back.ui │ └── enter.ui ├── libs └── LayaAir.d.ts ├── src ├── Config │ ├── Common.ts │ └── Local.ts ├── Constants │ ├── MsgCode.ts │ └── PokerType.ts ├── Game │ ├── CardSet.ts │ ├── Game.ts │ ├── MessageHandler.ts │ ├── Poker.ts │ ├── PokerLogic.ts │ ├── PoolManage.ts │ └── Room.ts ├── GameMain.ts ├── GameView │ ├── EnterView.ts │ └── RoomView.ts ├── Net │ ├── Message.ts │ └── SocketManage.ts └── ui │ └── layaUI.max.all.ts └── tsconfig.json /.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 | }, 16 | { 17 | "name": "chrome调试", 18 | "type": "chrome", 19 | "request": "launch", 20 | "file": "${workspaceRoot}/bin/index.html", 21 | // "换成自己的谷歌安装路径,": 比如 22 | //window 默认安装路径为: "C:/Program Files (x86)/Google/Chrome/Application/chrome.exe" 23 | //mac 系统上的默认安装路径为 "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome"; 24 | // "runtimeExecutable": "C:/Program Files (x86)/Google/Chrome/Application/chrome.exe", 25 | "runtimeArgs": [ 26 | "--allow-file-access-from-files", 27 | "--allow-file-access-frome-files", 28 | " --disable-web-security" 29 | ], 30 | "sourceMaps": true, 31 | "webRoot": "${workspaceRoot}", 32 | //假如谷歌调试报userDataDir不可用,请把谷歌安装路径取得管理员权限,或者更换${tmpdir}为其他可以读写的文件夹,也可以删除。 33 | "userDataDir": "${workspaceRoot}/.laya/chrome", 34 | "fixedPort":false 35 | } 36 | ] 37 | } -------------------------------------------------------------------------------- /.laya/pubset.json: -------------------------------------------------------------------------------- 1 | {"0":{"sourcePath":"E:\\laya_workspace\\fatdoudizhu\\bin","outPath":"E:\\laya_workspace\\fatdoudizhu\\release\\web","pngQualityLow":"65","pngQualityHigh":"80","jpgQuality":"85","mergeJs":false,"compressPng":false,"compressJpg":false,"compressJson":false,"jsontypes":"json,atlas,ls,lh,lmat,lav","compressJs":false,"enableVersion":false,"excludeFiles":"","publishType":0,"projectType":"ts","copyOutFiles":"","copyOutPath":"","userCmd":""},"1":{"sourcePath":"E:\\laya_workspace\\fatdoudizhu\\bin","outPath":"E:\\laya_workspace\\fatdoudizhu\\release\\wxgame","pngQualityLow":"65","pngQualityHigh":"80","jpgQuality":"85","mergeJs":true,"compressPng":false,"compressJpg":false,"compressJson":false,"jsontypes":"json,atlas,ls,lh,lmat,lav","compressJs":false,"enableVersion":false,"excludeFiles":"","publishType":1,"projectType":"ts","copyOutFiles":"","copyOutPath":"","userCmd":""},"pf":1} -------------------------------------------------------------------------------- /.laya/tasks.json: -------------------------------------------------------------------------------- 1 | {"version":"0.1.0","command":"tsc","isShellCommand":true,"args":["-p",".","--outDir","bin/js"],"showOutput":"silent","problemMatcher":"$tsc"} -------------------------------------------------------------------------------- /FatDouDiZhu.laya: -------------------------------------------------------------------------------- 1 | {"proName":"FatDouDiZhu","engineType":0,"proType":1,"layaProType":0} -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # 斗地主客户端 layabox - typescript(ts) 2 | 3 | 此客户端源自 [WangQingye](https://github.com/WangQingye) 的[白鹭客户端](https://github.com/WangQingye/Doudizhu-client),用Layabox重写的,并修复了其中一些牌型判断的问题。 4 | 5 | # 使用 6 | 1. 安装nodejs和layabox环境,这个自行百度吧。我安装的node版本是8.9.3,layabox是1.7.18。 7 | 2. 下载斗地主服务端,原版的在[这里](https://github.com/WangQingye/Doudizhu-sever)。 8 | 我对原版进行了fork,见[这里](https://github.com/tianhe1986/Doudizhu-sever)。我做了一些修复,之后还会有其他的调整,所有的这些都会提pull request,但是也可能不会被merge。 9 | 10 | 3. 在服务端目录,运行 node app.js,开启服务端。 11 | 4. 下载此源码,导入layabox,编译运行即可。 12 | 13 | 如需更改端口。服务端在 `socket/websocket.js`中修改,客户端在`src/Config/Local.ts`中修改。 14 | 15 | 可发布成H5和微信小游戏。 16 | 17 | # TODO 18 | 1. 增加服务端对牌型的判断。已在服务端分支实现,见[这里](https://github.com/tianhe1986/Doudizhu-sever/tree/develop_server) 19 | 2. 游戏中掉线超时处理。 20 | 3. 房间内一局结束后,继续进行下一局。 21 | 22 | # go服务端 23 | 随着技术的进步,用go语言重写了个简单服务端,目前还没有处理牌型判断,正在完善。相比nodejs的服务端,见[这里](https://github.com/tianhe1986/Doudizhu-server-go)调整如下: 24 | 1. 暂不考虑重连,游戏中掉线,直接解散房间。 25 | 2. 一局游戏结束后,解散房间,需重新进行匹配。 26 | 3. TODO 增加服务端对牌型的判断。 -------------------------------------------------------------------------------- /bin/index.html: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | www.layabox.com 7 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | -------------------------------------------------------------------------------- /bin/js/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tianhe1986/Fat-Doudizhu/8c8b82362011ee54c350f4c64c58e06472e687a1/bin/js/.gitkeep -------------------------------------------------------------------------------- /bin/libs/LayaRender.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Matter.js 渲染器在 LayaAir 的实现。 3 | */ 4 | (function() 5 | { 6 | var LayaRender = {}; 7 | 8 | var Common = Matter.Common; 9 | var Composite = Matter.Composite; 10 | var Bounds = Matter.Bounds; 11 | var Events = Matter.Events; 12 | var Grid = Matter.Grid; 13 | var Vector = Matter.Vector; 14 | 15 | /** 16 | * 创建新的渲染器。 17 | * @param {object} options 所有属性都有默认值,options中的属性会覆盖默认属性。 18 | * @return {render} 返回创建的旋绕器 19 | */ 20 | LayaRender.create = function(options) 21 | { 22 | var defaults = { 23 | controller: LayaRender, 24 | engine: null, 25 | element: null, 26 | canvas: null, 27 | mouse: null, 28 | frameRequestId: null, 29 | options: 30 | { 31 | width: 800, 32 | height: 600, 33 | pixelRatio: 1, 34 | background: '#fafafa', 35 | wireframeBackground: '#222222', 36 | hasBounds: !!options.bounds, 37 | enabled: true, 38 | wireframes: true, 39 | showSleeping: true, 40 | showDebug: false, 41 | showBroadphase: false, 42 | showBounds: false, 43 | showVelocity: false, 44 | showCollisions: false, 45 | showSeparations: false, 46 | showAxes: false, 47 | showPositions: false, 48 | showAngleIndicator: false, 49 | showIds: false, 50 | showShadows: false, 51 | showVertexNumbers: false, 52 | showConvexHulls: false, 53 | showInternalEdges: false, 54 | showMousePosition: false 55 | } 56 | }; 57 | var render = Common.extend(defaults, options); 58 | render.mouse = options.mouse; 59 | render.engine = options.engine; 60 | // 如果用户没有指定contaienr,默认使用stage 61 | render.container = render.container || Laya.stage; 62 | render.bounds = render.bounds || 63 | { 64 | min: 65 | { 66 | x: 0, 67 | y: 0 68 | }, 69 | max: 70 | { 71 | x: render.width, 72 | y: render.height 73 | } 74 | }; 75 | 76 | return render; 77 | } 78 | 79 | /** 80 | * 运行渲染器。 81 | * @param {render} render 渲染的目标是LayaRender.create()返回的对象 82 | * @return {void} 83 | */ 84 | LayaRender.run = function(render) 85 | { 86 | Laya.timer.frameLoop(1, this, LayaRender.world, [render]); 87 | Events.on(render.engine.world, 'afterRemove', LayaRender.onRemoveSprite); 88 | }; 89 | 90 | /** 91 | * 停止渲染器。 92 | * @param {render} LayaRender.create()返回的对象 93 | * @return {void} 94 | */ 95 | LayaRender.stop = function(render) 96 | { 97 | Laya.timer.clear(this, LayaRender.world); 98 | Events.off(render.engine.world, 'afterRemove', LayaRender.onRemoveSprite); 99 | } 100 | 101 | LayaRender.onRemoveSprite = function(args) 102 | { 103 | var sprite = args.object.layaSprite; 104 | if (sprite && sprite.parent) 105 | sprite.parent.removeChild(sprite); 106 | } 107 | 108 | /** 109 | * 渲染给定的 engine 的 Matter.World 对象。 110 | * 这是渲染的入口,每次场景改变时都应该被调用。 111 | * @param {render} render 112 | * @return {void} 113 | */ 114 | LayaRender.world = function(render) 115 | { 116 | var engine = render.engine, 117 | world = engine.world, 118 | renderer = render.renderer, 119 | container = render.container, 120 | options = render.options, 121 | bodies = Composite.allBodies(world), 122 | allConstraints = Composite.allConstraints(world), 123 | constraints = [], 124 | i; 125 | 126 | if (options.wireframes) 127 | { 128 | LayaRender.setBackground(render, options.wireframeBackground); 129 | } 130 | else 131 | { 132 | LayaRender.setBackground(render, options.background); 133 | } 134 | 135 | // 处理 bounds 136 | var boundsWidth = render.bounds.max.x - render.bounds.min.x, 137 | boundsHeight = render.bounds.max.y - render.bounds.min.y, 138 | boundsScaleX = boundsWidth / render.options.width, 139 | boundsScaleY = boundsHeight / render.options.height; 140 | 141 | if (options.hasBounds) 142 | { 143 | // 隐藏不在视口内的bodies 144 | for (i = 0; i < bodies.length; i++) 145 | { 146 | var body = bodies[i]; 147 | body.render.sprite.visible = Bounds.overlaps(body.bounds, render.bounds); 148 | } 149 | 150 | // 过滤掉不在视口内的 constraints 151 | for (i = 0; i < allConstraints.length; i++) 152 | { 153 | var constraint = allConstraints[i], 154 | bodyA = constraint.bodyA, 155 | bodyB = constraint.bodyB, 156 | pointAWorld = constraint.pointA, 157 | pointBWorld = constraint.pointB; 158 | 159 | if (bodyA) pointAWorld = Vector.add(bodyA.position, constraint.pointA); 160 | if (bodyB) pointBWorld = Vector.add(bodyB.position, constraint.pointB); 161 | 162 | if (!pointAWorld || !pointBWorld) 163 | continue; 164 | 165 | if (Bounds.contains(render.bounds, pointAWorld) || Bounds.contains(render.bounds, pointBWorld)) 166 | constraints.push(constraint); 167 | } 168 | 169 | // 改变视口 170 | container.scale(1 / boundsScaleX, 1 / boundsScaleY); 171 | container.pos(-render.bounds.min.x * (1 / boundsScaleX), -render.bounds.min.y * (1 / boundsScaleY)); 172 | } 173 | else 174 | { 175 | constraints = allConstraints; 176 | } 177 | 178 | for (i = 0; i < bodies.length; i++) 179 | LayaRender.body(render, bodies[i]); 180 | 181 | for (i = 0; i < constraints.length; i++) 182 | LayaRender.constraint(render, constraints[i]); 183 | }; 184 | 185 | /** 186 | * 设置背景色或者背景图片。 187 | * @param {render} render 188 | * @param {string} background 16进制颜色字符串或者图片路径 189 | */ 190 | LayaRender.setBackground = function(render, background) 191 | { 192 | if (render.currentBackground !== background) 193 | { 194 | var isColor = background.indexOf && background.indexOf('#') !== -1; 195 | 196 | render.container.graphics.clear(); 197 | 198 | if (isColor) 199 | { 200 | // 使用纯色背景 201 | render.container.bgColor = background; 202 | } 203 | else 204 | { 205 | render.container.loadImage(background); 206 | // 使用背景图片时把背景色设置为白色 207 | render.container.bgColor = "#FFFFFF"; 208 | } 209 | 210 | render.currentBackground = background; 211 | } 212 | } 213 | 214 | /** 215 | * 渲染 body 216 | * @param {render} render 217 | * @param {body} body 218 | * @return {void} 219 | */ 220 | LayaRender.body = function(render, body) 221 | { 222 | var engine = render.engine, 223 | bodyRender = body.render; 224 | 225 | if (!bodyRender.visible) 226 | return; 227 | 228 | // 有纹理的body 229 | if (bodyRender.sprite && bodyRender.sprite.texture) 230 | { 231 | var spriteId = 'b-' + body.id, 232 | sprite = body.layaSprite, 233 | container = render.container; 234 | 235 | // 如果sprite不存在,则初始化一个 236 | if (!sprite) 237 | sprite = body.layaSprite = _createBodySprite(render, body); 238 | 239 | // 如果sprite未在显示列表,则添加至显示列表 240 | if (!container.contains(sprite)) 241 | container.addChild(sprite); 242 | 243 | // 更新sprite位置 244 | sprite.x = body.position.x; 245 | sprite.y = body.position.y; 246 | sprite.rotation = body.angle * 180 / Math.PI; 247 | sprite.scaleX = bodyRender.sprite.xScale || 1; 248 | sprite.scaleY = bodyRender.sprite.yScale || 1; 249 | } 250 | else // 没有纹理的body 251 | { 252 | var primitiveId = 'b-' + body.id, 253 | sprite = body.layaSprite, 254 | container = render.container; 255 | 256 | // 如果sprite不存在,则初始化一个 257 | if (!sprite) 258 | { 259 | sprite = body.layaSprite = _createBodyPrimitive(render, body); 260 | sprite.initialAngle = body.angle; 261 | } 262 | 263 | // 如果sprite未在显示列表,则添加至显示列表 264 | if (!container.contains(sprite)) 265 | container.addChild(sprite); 266 | // 更新sprite位置 267 | sprite.x = body.position.x; 268 | sprite.y = body.position.y; 269 | sprite.rotation = (body.angle - sprite.initialAngle) * 180 / Math.PI; 270 | } 271 | }; 272 | 273 | /** 274 | * 创建使用纹理的Sprite对象。 275 | * @param {render} render 276 | * @param {body} body 277 | * @return {void} 278 | */ 279 | var _createBodySprite = function(render, body) 280 | { 281 | var bodyRender = body.render, 282 | texturePath = bodyRender.sprite.texture, 283 | sprite = new Laya.Sprite(); 284 | 285 | sprite.loadImage(texturePath); 286 | sprite.pivotX = body.render.sprite.xOffset; 287 | sprite.pivotY = body.render.sprite.yOffset; 288 | 289 | return sprite; 290 | }; 291 | 292 | /** 293 | * 创建使用矢量绘图的Sprite对象。 294 | * @param {render} render 295 | * @param {body} body 296 | * @return {void} 297 | */ 298 | var _createBodyPrimitive = function(render, body) 299 | { 300 | var bodyRender = body.render, 301 | options = render.options, 302 | sprite = new Laya.Sprite(), 303 | fillStyle, strokeStyle, lineWidth, 304 | part, points = []; 305 | 306 | var primitive = sprite.graphics; 307 | primitive.clear(); 308 | 309 | // 处理 compound parts 310 | for (var k = body.parts.length > 1 ? 1 : 0; k < body.parts.length; k++) 311 | { 312 | part = body.parts[k]; 313 | 314 | if (!options.wireframes) 315 | { 316 | fillStyle = bodyRender.fillStyle; 317 | strokeStyle = bodyRender.strokeStyle; 318 | lineWidth = bodyRender.lineWidth; 319 | } 320 | else 321 | { 322 | fillStyle = null; 323 | strokeStyle = '#bbbbbb'; 324 | lineWidth = 1; 325 | } 326 | 327 | points.push(part.vertices[0].x - body.position.x, part.vertices[0].y - body.position.y); 328 | 329 | for (var j = 1; j < part.vertices.length; j++) 330 | { 331 | points.push(part.vertices[j].x - body.position.x, part.vertices[j].y - body.position.y); 332 | } 333 | 334 | points.push(part.vertices[0].x - body.position.x, part.vertices[0].y - body.position.y); 335 | 336 | primitive.drawPoly(0, 0, points, fillStyle, strokeStyle, lineWidth); 337 | 338 | // 角度指示器 339 | if (options.showAngleIndicator || options.showAxes) 340 | { 341 | lineWidth = 1; 342 | if (options.wireframes) 343 | { 344 | strokeStyle = '#CD5C5C'; 345 | } 346 | else 347 | { 348 | strokeStyle = bodyRender.strokeStyle; 349 | } 350 | 351 | primitive.drawLine(part.position.x - body.position.x, part.position.y - body.position.y, 352 | ((part.vertices[0].x + part.vertices[part.vertices.length - 1].x) / 2 - body.position.x), 353 | ((part.vertices[0].y + part.vertices[part.vertices.length - 1].y) / 2 - body.position.y)); 354 | } 355 | } 356 | 357 | return sprite; 358 | }; 359 | 360 | /** 361 | * 绘制 constraint。 362 | * @param {render} render 363 | * @param {constraint} constraint 364 | * @return {void} 365 | */ 366 | LayaRender.constraint = function(render, constraint) 367 | { 368 | var engine = render.engine, 369 | bodyA = constraint.bodyA, 370 | bodyB = constraint.bodyB, 371 | pointA = constraint.pointA, 372 | pointB = constraint.pointB, 373 | container = render.container, 374 | constraintRender = constraint.render, 375 | primitiveId = 'c-' + constraint.id, 376 | sprite = constraint.layaSprite; 377 | 378 | // 如果sprite不存在,则初始化一个 379 | if (!sprite) 380 | sprite = constraint.layaSprite = new Laya.Sprite(); 381 | 382 | var primitive = sprite.graphics; 383 | 384 | // constraint 没有两个终点时不渲染 385 | if (!constraintRender.visible || !constraint.pointA || !constraint.pointB) 386 | { 387 | primitive.clear(); 388 | return; 389 | } 390 | 391 | // 如果sprite未在显示列表,则添加至显示列表 392 | if (!container.contains(sprite)) 393 | container.addChild(sprite); 394 | 395 | // 渲染 constraint 396 | primitive.clear(); 397 | 398 | var fromX, fromY, toX, toY; 399 | if (bodyA) 400 | { 401 | fromX = bodyA.position.x + pointA.x; 402 | fromY = bodyA.position.y + pointA.y; 403 | } 404 | else 405 | { 406 | fromX = pointA.x; 407 | fromY = pointA.y; 408 | } 409 | 410 | if (bodyB) 411 | { 412 | toX = bodyB.position.x + pointB.x; 413 | toY = bodyB.position.y + pointB.y; 414 | } 415 | else 416 | { 417 | toX = pointB.x; 418 | toY = pointB.y; 419 | } 420 | 421 | primitive.drawLine(fromX, fromY, toX, toY, constraintRender.strokeStyle, constraintRender.lineWidth); 422 | }; 423 | 424 | window.LayaRender = LayaRender; 425 | })(); -------------------------------------------------------------------------------- /bin/libs/laya.d3Plugin.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 Component3D=laya.d3.component.Component3D,ComponentNode=laya.d3.core.ComponentNode,MeshTerrainSprite3D=laya.d3.core.MeshTerrainSprite3D; 6 | var Sprite3D=laya.d3.core.Sprite3D; 7 | /** 8 | *PathFinding 类用于创建寻路。 9 | */ 10 | //class laya.d3.component.PathFind extends laya.d3.component.Component3D 11 | var PathFind=(function(_super){ 12 | function PathFind(){ 13 | /**@private */ 14 | this._meshTerrainSprite3D=null; 15 | /**@private */ 16 | this._finder=null; 17 | /**@private */ 18 | this._setting=null; 19 | /**寻路网格。*/ 20 | this.grid=null; 21 | PathFind.__super.call(this); 22 | } 23 | 24 | __class(PathFind,'laya.d3.component.PathFind',_super); 25 | var __proto=PathFind.prototype; 26 | /** 27 | *@private 28 | *初始化载入蒙皮动画组件。 29 | *@param owner 所属精灵对象。 30 | */ 31 | __proto._load=function(owner){ 32 | if (! (owner instanceof laya.d3.core.MeshTerrainSprite3D )) 33 | throw new Error("PathFinding: The owner must MeshTerrainSprite3D!"); 34 | _super.prototype._load.call(this,owner); 35 | this._meshTerrainSprite3D=owner; 36 | } 37 | 38 | /** 39 | *寻找路径。 40 | *@param startX 开始X。 41 | *@param startZ 开始Z。 42 | *@param endX 结束X。 43 | *@param endZ 结束Z。 44 | *@return 路径。 45 | */ 46 | __proto.findPath=function(startX,startZ,endX,endZ){ 47 | var minX=this._meshTerrainSprite3D.minX; 48 | var minZ=this._meshTerrainSprite3D.minZ; 49 | var cellX=this._meshTerrainSprite3D.width / this.grid.width; 50 | var cellZ=this._meshTerrainSprite3D.depth / this.grid.height; 51 | var halfCellX=cellX / 2; 52 | var halfCellZ=cellZ / 2; 53 | var gridStartX=Math.floor((startX-minX)/ cellX); 54 | var gridStartZ=Math.floor((startZ-minZ)/ cellZ); 55 | var gridEndX=Math.floor((endX-minX)/ cellX); 56 | var gridEndZ=Math.floor((endZ-minZ)/ cellZ); 57 | var boundWidth=this.grid.width-1; 58 | var boundHeight=this.grid.height-1; 59 | (gridStartX > boundWidth)&& (gridStartX=boundWidth); 60 | (gridStartZ > boundHeight)&& (gridStartZ=boundHeight); 61 | (gridStartX < 0)&& (gridStartX=0); 62 | (gridStartZ < 0)&& (gridStartZ=0); 63 | (gridEndX > boundWidth)&& (gridEndX=boundWidth); 64 | (gridEndZ > boundHeight)&& (gridEndZ=boundHeight); 65 | (gridEndX < 0)&& (gridEndX=0); 66 | (gridEndZ < 0)&& (gridEndZ=0); 67 | var path=this._finder.findPath(gridStartX,gridStartZ,gridEndX,gridEndZ,this.grid); 68 | this.grid.reset(); 69 | for (var i=1;i < path.length-1;i++){ 70 | var gridPos=path[i]; 71 | gridPos[0]=gridPos[0] *cellX+halfCellX+minX; 72 | gridPos[1]=gridPos[1] *cellZ+halfCellZ+minZ; 73 | } 74 | if (path.length==1){ 75 | path[0][0]=endX; 76 | path[0][1]=endX; 77 | }else if (path.length > 1){ 78 | path[0][0]=startX; 79 | path[0][1]=startZ; 80 | path[path.length-1][0]=endX; 81 | path[path.length-1][1]=endZ; 82 | } 83 | return path; 84 | } 85 | 86 | /** 87 | *设置寻路设置。 88 | *@param value 寻路设置。 89 | */ 90 | /** 91 | *获取寻路设置。 92 | *@return 寻路设置。 93 | */ 94 | __getset(0,__proto,'setting',function(){ 95 | return this._setting; 96 | },function(value){ 97 | (value)&& (this._finder=new PathFinding.finders.AStarFinder(value)); 98 | this._setting=value; 99 | }); 100 | 101 | return PathFind; 102 | })(Component3D) 103 | 104 | 105 | 106 | })(window,document,Laya); 107 | 108 | if (typeof define === 'function' && define.amd){ 109 | define('laya.core', ['require', "exports"], function(require, exports) { 110 | 'use strict'; 111 | Object.defineProperty(exports, '__esModule', { value: true }); 112 | for (var i in Laya) { 113 | var o = Laya[i]; 114 | o && o.__isclass && (exports[i] = o); 115 | } 116 | }); 117 | } -------------------------------------------------------------------------------- /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 Browser=laya.utils.Browser,Color=laya.utils.Color,ColorFilterAction=laya.filters.ColorFilterAction; 6 | var ColorFilterActionGL=laya.filters.webgl.ColorFilterActionGL,Filter=laya.filters.Filter,FilterActionGL=laya.filters.webgl.FilterActionGL; 7 | var Matrix=laya.maths.Matrix,Rectangle=laya.maths.Rectangle,Render=laya.renders.Render,RenderContext=laya.renders.RenderContext; 8 | var RenderTarget2D=laya.webgl.resource.RenderTarget2D,RunDriver=laya.utils.RunDriver,ShaderDefines2D=laya.webgl.shader.d2.ShaderDefines2D; 9 | var Sprite=laya.display.Sprite,Texture=laya.resource.Texture,Value2D=laya.webgl.shader.d2.value.Value2D; 10 | /** 11 | *默认的FILTER,什么都不做 12 | *@private 13 | */ 14 | //class laya.filters.FilterAction 15 | var FilterAction=(function(){ 16 | function FilterAction(){ 17 | this.data=null; 18 | } 19 | 20 | __class(FilterAction,'laya.filters.FilterAction'); 21 | var __proto=FilterAction.prototype; 22 | Laya.imps(__proto,{"laya.filters.IFilterAction":true}) 23 | __proto.apply=function(data){ 24 | return null; 25 | } 26 | 27 | return FilterAction; 28 | })() 29 | 30 | 31 | /** 32 | *@private 33 | */ 34 | //class laya.filters.WebGLFilter 35 | var WebGLFilter=(function(){ 36 | function WebGLFilter(){} 37 | __class(WebGLFilter,'laya.filters.WebGLFilter'); 38 | WebGLFilter.enable=function(){ 39 | if (WebGLFilter.isInit)return; 40 | WebGLFilter.isInit=true; 41 | if (!Render.isWebGL)return; 42 | RunDriver.createFilterAction=function (type){ 43 | var action; 44 | switch (type){ 45 | case /*laya.filters.Filter.COLOR*/0x20: 46 | action=new ColorFilterActionGL(); 47 | break ; 48 | case /*laya.filters.Filter.BLUR*/0x10: 49 | action=new BlurFilterActionGL(); 50 | break ; 51 | case /*laya.filters.Filter.GLOW*/0x08: 52 | action=new GlowFilterActionGL(); 53 | break ; 54 | } 55 | return action; 56 | } 57 | } 58 | 59 | WebGLFilter.isInit=false; 60 | WebGLFilter.__init$=function(){ 61 | BlurFilterActionGL; 62 | ColorFilterActionGL; 63 | GlowFilterActionGL; 64 | Render; 65 | RunDriver;{ 66 | RunDriver.createFilterAction=function (type){ 67 | var action; 68 | switch (type){ 69 | case /*laya.filters.Filter.BLUR*/0x10: 70 | action=new FilterAction(); 71 | break ; 72 | case /*laya.filters.Filter.GLOW*/0x08: 73 | action=new FilterAction(); 74 | break ; 75 | case /*laya.filters.Filter.COLOR*/0x20: 76 | action=new ColorFilterAction(); 77 | break ; 78 | } 79 | return action; 80 | } 81 | } 82 | } 83 | 84 | return WebGLFilter; 85 | })() 86 | 87 | 88 | /** 89 | *模糊滤镜 90 | */ 91 | //class laya.filters.BlurFilter extends laya.filters.Filter 92 | var BlurFilter=(function(_super){ 93 | function BlurFilter(strength){ 94 | /**模糊滤镜的强度(值越大,越不清晰 */ 95 | this.strength=NaN; 96 | this.strength_sig2_2sig2_gauss1=[]; 97 | BlurFilter.__super.call(this); 98 | (strength===void 0)&& (strength=4); 99 | if (Render.isWebGL)WebGLFilter.enable(); 100 | this.strength=strength; 101 | this._action=RunDriver.createFilterAction(0x10); 102 | this._action.data=this; 103 | } 104 | 105 | __class(BlurFilter,'laya.filters.BlurFilter',_super); 106 | var __proto=BlurFilter.prototype; 107 | /** 108 | *@private 通知微端 109 | */ 110 | __proto.callNative=function(sp){ 111 | sp.conchModel &&sp.conchModel.blurFilter&&sp.conchModel.blurFilter(this.strength); 112 | } 113 | 114 | /** 115 | *@private 116 | *当前滤镜对应的操作器 117 | */ 118 | __getset(0,__proto,'action',function(){ 119 | return this._action; 120 | }); 121 | 122 | /** 123 | *@private 124 | *当前滤镜的类型 125 | */ 126 | __getset(0,__proto,'type',function(){ 127 | return 0x10; 128 | }); 129 | 130 | return BlurFilter; 131 | })(Filter) 132 | 133 | 134 | /** 135 | *发光滤镜(也可以当成阴影滤使用) 136 | */ 137 | //class laya.filters.GlowFilter extends laya.filters.Filter 138 | var GlowFilter=(function(_super){ 139 | function GlowFilter(color,blur,offX,offY){ 140 | /**滤镜的颜色*/ 141 | this._color=null; 142 | GlowFilter.__super.call(this); 143 | this._elements=new Float32Array(9); 144 | (blur===void 0)&& (blur=4); 145 | (offX===void 0)&& (offX=6); 146 | (offY===void 0)&& (offY=6); 147 | if (Render.isWebGL){ 148 | WebGLFilter.enable(); 149 | } 150 | this._color=new Color(color); 151 | this.blur=Math.min(blur,20); 152 | this.offX=offX; 153 | this.offY=offY; 154 | this._action=RunDriver.createFilterAction(0x08); 155 | this._action.data=this; 156 | } 157 | 158 | __class(GlowFilter,'laya.filters.GlowFilter',_super); 159 | var __proto=GlowFilter.prototype; 160 | /**@private */ 161 | __proto.getColor=function(){ 162 | return this._color._color; 163 | } 164 | 165 | /** 166 | *@private 通知微端 167 | */ 168 | __proto.callNative=function(sp){ 169 | sp.conchModel &&sp.conchModel.glowFilter&&sp.conchModel.glowFilter(this._color.strColor,this._elements[4],this._elements[5],this._elements[6]); 170 | } 171 | 172 | /** 173 | *@private 174 | *滤镜类型 175 | */ 176 | __getset(0,__proto,'type',function(){ 177 | return 0x08; 178 | }); 179 | 180 | /**@private */ 181 | __getset(0,__proto,'action',function(){ 182 | return this._action; 183 | }); 184 | 185 | /**@private */ 186 | /**@private */ 187 | __getset(0,__proto,'offY',function(){ 188 | return this._elements[6]; 189 | },function(value){ 190 | this._elements[6]=value; 191 | }); 192 | 193 | /**@private */ 194 | /**@private */ 195 | __getset(0,__proto,'offX',function(){ 196 | return this._elements[5]; 197 | },function(value){ 198 | this._elements[5]=value; 199 | }); 200 | 201 | /**@private */ 202 | /**@private */ 203 | __getset(0,__proto,'blur',function(){ 204 | return this._elements[4]; 205 | },function(value){ 206 | this._elements[4]=value; 207 | }); 208 | 209 | return GlowFilter; 210 | })(Filter) 211 | 212 | 213 | /** 214 | *@private 215 | */ 216 | //class laya.filters.webgl.BlurFilterActionGL extends laya.filters.webgl.FilterActionGL 217 | var BlurFilterActionGL=(function(_super){ 218 | function BlurFilterActionGL(){ 219 | this.data=null; 220 | BlurFilterActionGL.__super.call(this); 221 | } 222 | 223 | __class(BlurFilterActionGL,'laya.filters.webgl.BlurFilterActionGL',_super); 224 | var __proto=BlurFilterActionGL.prototype; 225 | __proto.setValueMix=function(shader){ 226 | shader.defines.add(this.data.type); 227 | var o=shader; 228 | } 229 | 230 | __proto.apply3d=function(scope,sprite,context,x,y){ 231 | var b=scope.getValue("bounds"); 232 | var shaderValue=Value2D.create(/*laya.webgl.shader.d2.ShaderDefines2D.TEXTURE2D*/0x01,0); 233 | shaderValue.setFilters([this.data]); 234 | var tMatrix=Matrix.EMPTY; 235 | tMatrix.identity(); 236 | context.ctx.drawTarget(scope,0,0,b.width,b.height,Matrix.EMPTY,"src",shaderValue); 237 | shaderValue.setFilters(null); 238 | } 239 | 240 | __proto.setValue=function(shader){ 241 | shader.strength=this.data.strength; 242 | var sigma=this.data.strength/3.0; 243 | var sigma2=sigma*sigma; 244 | this.data.strength_sig2_2sig2_gauss1[0]=this.data.strength; 245 | this.data.strength_sig2_2sig2_gauss1[1]=sigma2; 246 | this.data.strength_sig2_2sig2_gauss1[2]=2.0*sigma2; 247 | this.data.strength_sig2_2sig2_gauss1[3]=1.0/(2.0*Math.PI*sigma2); 248 | shader.strength_sig2_2sig2_gauss1=this.data.strength_sig2_2sig2_gauss1; 249 | } 250 | 251 | __getset(0,__proto,'typeMix',function(){return /*laya.filters.Filter.BLUR*/0x10;}); 252 | return BlurFilterActionGL; 253 | })(FilterActionGL) 254 | 255 | 256 | /** 257 | *@private 258 | */ 259 | //class laya.filters.webgl.GlowFilterActionGL extends laya.filters.webgl.FilterActionGL 260 | var GlowFilterActionGL=(function(_super){ 261 | function GlowFilterActionGL(){ 262 | this.data=null; 263 | this._initKey=false; 264 | this._textureWidth=0; 265 | this._textureHeight=0; 266 | GlowFilterActionGL.__super.call(this); 267 | } 268 | 269 | __class(GlowFilterActionGL,'laya.filters.webgl.GlowFilterActionGL',_super); 270 | var __proto=GlowFilterActionGL.prototype; 271 | Laya.imps(__proto,{"laya.filters.IFilterActionGL":true}) 272 | __proto.setValueMix=function(shader){} 273 | __proto.apply3d=function(scope,sprite,context,x,y){ 274 | var b=scope.getValue("bounds"); 275 | scope.addValue("color",this.data.getColor()); 276 | var w=b.width,h=b.height; 277 | this._textureWidth=w; 278 | this._textureHeight=h; 279 | var shaderValue; 280 | var mat=Matrix.TEMP; 281 | mat.identity(); 282 | shaderValue=Value2D.create(/*laya.webgl.shader.d2.ShaderDefines2D.TEXTURE2D*/0x01,0); 283 | shaderValue.setFilters([this.data]); 284 | context.ctx.drawTarget(scope,0,0,this._textureWidth,this._textureHeight,mat,"src",shaderValue,null); 285 | shaderValue=Value2D.create(/*laya.webgl.shader.d2.ShaderDefines2D.TEXTURE2D*/0x01,0); 286 | context.ctx.drawTarget(scope,0,0,this._textureWidth,this._textureHeight,mat,"src",shaderValue); 287 | return null; 288 | } 289 | 290 | __proto.setSpriteWH=function(sprite){ 291 | this._textureWidth=sprite.width; 292 | this._textureHeight=sprite.height; 293 | } 294 | 295 | __proto.setValue=function(shader){ 296 | shader.u_offsetX=this.data.offX; 297 | shader.u_offsetY=-this.data.offY; 298 | shader.u_strength=1.0; 299 | shader.u_blurX=this.data.blur; 300 | shader.u_blurY=this.data.blur; 301 | shader.u_textW=this._textureWidth; 302 | shader.u_textH=this._textureHeight; 303 | shader.u_color=this.data.getColor(); 304 | } 305 | 306 | __getset(0,__proto,'typeMix',function(){return /*laya.filters.Filter.GLOW*/0x08;}); 307 | GlowFilterActionGL.tmpTarget=function(scope,sprite,context,x,y){ 308 | var b=scope.getValue("bounds"); 309 | var out=scope.getValue("out"); 310 | out.end(); 311 | var tmpTarget=RenderTarget2D.create(b.width,b.height); 312 | tmpTarget.start(); 313 | var color=scope.getValue("color"); 314 | if (color){ 315 | tmpTarget.clear(color[0],color[1],color[2],0); 316 | } 317 | scope.addValue("tmpTarget",tmpTarget); 318 | } 319 | 320 | GlowFilterActionGL.startOut=function(scope,sprite,context,x,y){ 321 | var tmpTarget=scope.getValue("tmpTarget"); 322 | tmpTarget.end(); 323 | var out=scope.getValue("out"); 324 | out.start(); 325 | var color=scope.getValue("color"); 326 | if (color){ 327 | out.clear(color[0],color[1],color[2],0); 328 | } 329 | } 330 | 331 | GlowFilterActionGL.recycleTarget=function(scope,sprite,context,x,y){ 332 | var src=scope.getValue("src"); 333 | var tmpTarget=scope.getValue("tmpTarget"); 334 | tmpTarget.recycle(); 335 | } 336 | 337 | return GlowFilterActionGL; 338 | })(FilterActionGL) 339 | 340 | 341 | Laya.__init([WebGLFilter]); 342 | })(window,document,Laya); 343 | 344 | if (typeof define === 'function' && define.amd){ 345 | define('laya.core', ['require', "exports"], function(require, exports) { 346 | 'use strict'; 347 | Object.defineProperty(exports, '__esModule', { value: true }); 348 | for (var i in Laya) { 349 | var o = Laya[i]; 350 | o && o.__isclass && (exports[i] = o); 351 | } 352 | }); 353 | } -------------------------------------------------------------------------------- /bin/libs/matter-RenderLaya.js: -------------------------------------------------------------------------------- 1 | var Browser = laya.utils.Browser; 2 | 3 | var Composite = Matter.Composite; 4 | var Events = Matter.Events; 5 | var Bounds = Matter.Bounds; 6 | var Common = Matter.Common; 7 | var Vertices = Matter.Vertices; 8 | var Vector = Matter.Vector; 9 | var Sleeping = Matter.Sleeping; 10 | var Axes = Matter.Axes; 11 | var Body = Matter.Body; 12 | var SAT = Matter.SAT; 13 | var Contact = Matter.Contact; 14 | var Pair = Matter.Pair; 15 | var Detector = Matter.Detector; 16 | var Grid = Matter.Grid; 17 | 18 | var LayaRender = {}; 19 | 20 | (function() 21 | { 22 | var graphics, 23 | spriteCon, 24 | graphicsCon; 25 | 26 | LayaRender.create = function(options) 27 | { 28 | var defaults = { 29 | controller: LayaRender, 30 | element: null, 31 | canvas: null, 32 | mouse: null, 33 | options: 34 | { 35 | width: 800, 36 | height: 600, 37 | pixelRatio: 1, 38 | background: '#fafafa', 39 | wireframeBackground: '#222', 40 | hasBounds: !!options.bounds, 41 | enabled: true, 42 | wireframes: true, 43 | showSleeping: true, 44 | showDebug: false, 45 | showBroadphase: false, 46 | showBounds: false, 47 | showVelocity: false, 48 | showCollisions: false, 49 | showSeparations: false, 50 | showAxes: false, 51 | showPositions: false, 52 | showAngleIndicator: false, 53 | showIds: false, 54 | showShadows: false, 55 | showVertexNumbers: false, 56 | showConvexHulls: false, 57 | showInternalEdges: false, 58 | showMousePosition: false 59 | } 60 | }; 61 | 62 | var render = Common.extend(defaults, options); 63 | 64 | render.canvas = laya.renders.Render.canvas; 65 | render.context = laya.renders.Render.context.ctx; 66 | 67 | render.textures = {}; 68 | 69 | render.bounds = render.bounds || 70 | { 71 | min: 72 | { 73 | x: 0, 74 | y: 0 75 | }, 76 | max: 77 | { 78 | x: Laya.stage.width, 79 | y: Laya.stage.height 80 | } 81 | }; 82 | 83 | createContainer(render); 84 | setBackground(render); 85 | setPixelRatio(); 86 | 87 | return render; 88 | }; 89 | 90 | function createContainer(render) 91 | { 92 | var con = render.container; 93 | 94 | spriteCon = new Laya.Sprite(); 95 | graphicsCon = new Laya.Sprite(); 96 | 97 | render.spriteContainer = spriteCon; 98 | render.graphicsContainer = graphicsCon; 99 | 100 | con.addChild(spriteCon); 101 | con.addChild(graphicsCon); 102 | 103 | graphics = graphicsCon.graphics; 104 | } 105 | 106 | // 设置背景 107 | function setBackground(render) 108 | { 109 | var bg = render.options.background; 110 | // 纯色背景 111 | if (bg.length == 7 && bg[0] == '#') 112 | { 113 | spriteCon.graphics.drawRect( 114 | 0, 0, 115 | render.options.width, render.options.height, 116 | bg); 117 | } 118 | // 图片背景 119 | else 120 | { 121 | spriteCon.loadImage(bg); 122 | } 123 | } 124 | 125 | function setPixelRatio() 126 | { 127 | var pixelRatio; 128 | pixelRatio = 1; 129 | Laya.Render.canvas.setAttribute('data-pixel-ratio', pixelRatio); 130 | } 131 | 132 | /** 133 | * Renders the given `engine`'s `Matter.World` object. 134 | * This is the entry point for all rendering and should be called every time the scene changes. 135 | * @method world 136 | * @param {engine} engine 137 | */ 138 | LayaRender.world = function(engine) 139 | { 140 | var render = engine.render, 141 | world = engine.world, 142 | options = render.options, 143 | allConstraints = Composite.allConstraints(world), 144 | bodies = Composite.allBodies(world), 145 | constraints = [], 146 | i; 147 | 148 | // handle bounds 149 | if (options.hasBounds) 150 | { 151 | var boundsWidth = render.bounds.max.x - render.bounds.min.x, 152 | boundsHeight = render.bounds.max.y - render.bounds.min.y, 153 | boundsScaleX = boundsWidth / options.width, 154 | boundsScaleY = boundsHeight / options.height; 155 | 156 | // filter out bodies that are not in view 157 | for (i = 0; i < bodies.length; i++) 158 | { 159 | var body = bodies[i]; 160 | body.render.sprite.visible = Bounds.overlaps(body.bounds, render.bounds); 161 | } 162 | 163 | // filter out constraints that are not in view 164 | for (i = 0; i < allConstraints.length; i++) 165 | { 166 | var constraint = allConstraints[i], 167 | bodyA = constraint.bodyA, 168 | bodyB = constraint.bodyB, 169 | pointAWorld = constraint.pointA, 170 | pointBWorld = constraint.pointB; 171 | 172 | if (bodyA) pointAWorld = Vector.add(bodyA.position, constraint.pointA); 173 | if (bodyB) pointBWorld = Vector.add(bodyB.position, constraint.pointB); 174 | 175 | if (!pointAWorld || !pointBWorld) 176 | continue; 177 | 178 | if (Bounds.contains(render.bounds, pointAWorld) || Bounds.contains(render.bounds, pointBWorld)) 179 | constraints.push(constraint); 180 | } 181 | 182 | // transform the view 183 | // context.scale(1 / boundsScaleX, 1 / boundsScaleY); 184 | // context.translate(-render.bounds.min.x, -render.bounds.min.y); 185 | } 186 | else 187 | { 188 | constraints = allConstraints; 189 | } 190 | 191 | graphics.clear(); 192 | for (i = 0; i < bodies.length; i++) 193 | LayaRender.body(engine, bodies[i]); 194 | 195 | for (i = 0; i < constraints.length; i++) 196 | LayaRender.constraint(engine, constraints[i]); 197 | }; 198 | LayaRender.body = function(engine, body) 199 | { 200 | var render = engine.render, 201 | bodyRender = body.render; 202 | 203 | if (!bodyRender.visible) 204 | { 205 | return; 206 | } 207 | 208 | var spInfo = bodyRender.sprite; 209 | var sp = body.sprite; 210 | if (bodyRender.sprite && bodyRender.sprite.texture) 211 | { 212 | // initialize body sprite if not existing 213 | if (!sp) 214 | { 215 | sp = body.sprite = createBodySprite(spInfo.xOffset, spInfo.yOffset); 216 | sp.loadImage(spInfo.texture); 217 | } 218 | 219 | sp.scale(spInfo.xScale, spInfo.yScale); 220 | sp.pos(body.position.x, body.position.y); 221 | sp.rotation = body.angle * 180 / Math.PI; 222 | } 223 | else 224 | { 225 | var options = render.options; 226 | // handle compound parts 227 | for (k = body.parts.length > 1 ? 1 : 0; k < body.parts.length; k++) 228 | { 229 | part = body.parts[k]; 230 | 231 | if (!part.render.visible) 232 | continue; 233 | 234 | var fillStyle = options.wireframes ? null : part.render.fillStyle; 235 | var lineWidth = part.render.lineWidth; 236 | var strokeStyle = part.render.strokeStyle; 237 | // part polygon 238 | if (part.circleRadius) 239 | { 240 | graphics.drawCircle(part.position.x, part.position.y, part.circleRadius, fillStyle, strokeStyle, lineWidth); 241 | } 242 | else 243 | { 244 | var path = []; 245 | path.push(part.vertices[0].x, part.vertices[0].y); 246 | 247 | for (var j = 1; j < part.vertices.length; j++) 248 | { 249 | if (!part.vertices[j - 1].isInternal || showInternalEdges) 250 | { 251 | path.push(part.vertices[j].x, part.vertices[j].y); 252 | } 253 | else 254 | { 255 | path.push(part.vertices[j].x, part.vertices[j].y); 256 | } 257 | 258 | if (part.vertices[j].isInternal && !showInternalEdges) 259 | { 260 | path.push(part.vertices[(j + 1) % part.vertices.length].x, part.vertices[(j + 1) % part.vertices.length].y); 261 | } 262 | } 263 | 264 | graphics.drawPoly(0, 0, path, fillStyle, strokeStyle, lineWidth); 265 | } 266 | } 267 | } 268 | }; 269 | 270 | LayaRender.constraint = function(engine, constraint) 271 | { 272 | var sx, sy, ex, ey; 273 | if (!constraint.render.visible || !constraint.pointA || !constraint.pointB) 274 | { 275 | return; 276 | } 277 | 278 | var bodyA = constraint.bodyA, 279 | bodyB = constraint.bodyB; 280 | 281 | if (bodyA) 282 | { 283 | sx = bodyA.position.x + constraint.pointA.x; 284 | sy = bodyA.position.y + constraint.pointA.y; 285 | } 286 | else 287 | { 288 | sx = constraint.pointA.x; 289 | sy = constraint.pointA.y; 290 | } 291 | 292 | if (bodyB) 293 | { 294 | ex = bodyB.position.x + constraint.pointB.x; 295 | ey = bodyB.position.y + constraint.pointB.y; 296 | } 297 | else 298 | { 299 | ex = constraint.pointB.x; 300 | ey = constraint.pointB.y; 301 | } 302 | 303 | graphics.drawLine( 304 | sx, sy, ex, ey, 305 | constraint.render.strokeStyle, 306 | constraint.render.lineWidth); 307 | }; 308 | 309 | function createBodySprite(xOffset, yOffset) 310 | { 311 | var sp = new Laya.Sprite(); 312 | 313 | sp.pivot(xOffset, yOffset); 314 | sp.pos(-9999, -9999); 315 | spriteCon.addChild(sp); 316 | 317 | return sp; 318 | } 319 | })(); -------------------------------------------------------------------------------- /bin/libs/min/laya.d3Plugin.min.js: -------------------------------------------------------------------------------- 1 | !function(t,i,e){e.un,e.uns,e.static;var n=e.class,r=e.getset,a=(e.__newvec,laya.d3.component.Component3D);laya.d3.core.ComponentNode,laya.d3.core.MeshTerrainSprite3D,laya.d3.core.Sprite3D,function(t){function i(){this._meshTerrainSprite3D=null,this._finder=null,this._setting=null,this.grid=null,i.__super.call(this)}n(i,"laya.d3.component.PathFind",t);var e=i.prototype;e._load=function(i){if(!(i instanceof laya.d3.core.MeshTerrainSprite3D))throw new Error("PathFinding: The owner must MeshTerrainSprite3D!");t.prototype._load.call(this,i),this._meshTerrainSprite3D=i},e.findPath=function(t,i,e,n){var r=this._meshTerrainSprite3D.minX,a=this._meshTerrainSprite3D.minZ,h=this._meshTerrainSprite3D.width/this.grid.width,s=this._meshTerrainSprite3D.depth/this.grid.height,o=h/2,d=s/2,l=Math.floor((t-r)/h),f=Math.floor((i-a)/s),c=Math.floor((e-r)/h),u=Math.floor((n-a)/s),p=this.grid.width-1,_=this.grid.height-1;l>p&&(l=p),f>_&&(f=_),l<0&&(l=0),f<0&&(f=0),c>p&&(c=p),u>_&&(u=_),c<0&&(c=0),u<0&&(u=0);var g=this._finder.findPath(l,f,c,u,this.grid);this.grid.reset();for(var m=1;m1&&(g[0][0]=t,g[0][1]=i,g[g.length-1][0]=e,g[g.length-1][1]=n),g},r(0,e,"setting",function(){return this._setting},function(t){t&&(this._finder=new PathFinding.finders.AStarFinder(t)),this._setting=t})}(a)}(window,document,Laya),"function"==typeof define&&define.amd&&define("laya.core",["require","exports"],function(t,i){"use strict";Object.defineProperty(i,"__esModule",{value:!0});for(var e in Laya){var n=Laya[e];n&&n.__isclass&&(i[e]=n)}}); -------------------------------------------------------------------------------- /bin/libs/min/laya.device.min.js: -------------------------------------------------------------------------------- 1 | !function(e,t,n){n.un,n.uns;var i=n.static,a=n.class,o=n.getset,r=(n.__newvec,laya.resource.Bitmap),s=laya.utils.Browser,c=(laya.events.Event,laya.events.EventDispatcher),l=(laya.utils.Handler,laya.maths.Rectangle,laya.renders.Render),d=laya.display.Sprite,h=(laya.display.Stage,laya.resource.Texture),u=laya.utils.Utils,v=laya.webgl.WebGL,m=laya.webgl.WebGLContext,g=(function(){function e(){}a(e,"laya.device.geolocation.Geolocation"),e.getCurrentPosition=function(t,n){e.navigator.geolocation.getCurrentPosition(function(n){e.position.setPosition(n),t.runWith(e.position)},function(e){n.runWith(e)},{enableHighAccuracy:laya.device.geolocation.Geolocation.enableHighAccuracy,timeout:laya.device.geolocation.Geolocation.timeout,maximumAge:laya.device.geolocation.Geolocation.maximumAge})},e.watchPosition=function(t,n){return e.navigator.geolocation.watchPosition(function(n){e.position.setPosition(n),t.runWith(e.position)},function(e){n.runWith(e)},{enableHighAccuracy:e.enableHighAccuracy,timeout:e.timeout,maximumAge:e.maximumAge})},e.clearWatch=function(t){e.navigator.geolocation.clearWatch(t)},e.PERMISSION_DENIED=1,e.POSITION_UNAVAILABLE=2,e.TIMEOUT=3,e.enableHighAccuracy=!1,e.maximumAge=0,i(e,["navigator",function(){return this.navigator=s.window.navigator},"position",function(){return this.position=new g},"supported",function(){return this.supported=!!e.navigator.geolocation},"timeout",function(){return this.timeout=1e10}])}(),function(){function e(){this.pos=null,this.coords=null}a(e,"laya.device.geolocation.GeolocationInfo");var t=e.prototype;return t.setPosition=function(e){this.pos=e,this.coords=e.coords},o(0,t,"heading",function(){return this.coords.heading}),o(0,t,"latitude",function(){return this.coords.latitude}),o(0,t,"altitudeAccuracy",function(){return this.coords.altitudeAccuracy}),o(0,t,"longitude",function(){return this.coords.longitude}),o(0,t,"altitude",function(){return this.coords.altitude}),o(0,t,"accuracy",function(){return this.coords.accuracy}),o(0,t,"speed",function(){return this.coords.speed}),o(0,t,"timestamp",function(){return this.pos.timestamp}),e}()),f=function(){function e(){}return a(e,"laya.device.media.Media"),e.supported=function(){return!!s.window.navigator.getUserMedia},e.getMedia=function(e,t,n){s.window.navigator.getUserMedia&&s.window.navigator.getUserMedia(e,function(e){t.runWith(s.window.URL.createObjectURL(e))},function(e){n.runWith(e)})},e.__init$=function(){navigator.getUserMedia=navigator.getUserMedia||navigator.webkitGetUserMedia||navigator.mozGetUserMedia},e}(),p=function(){function e(){this.x=NaN,this.y=NaN,this.z=NaN}return a(e,"laya.device.motion.AccelerationInfo"),e}(),y=function(){function e(){this.absolute=!1,this.alpha=NaN,this.beta=NaN,this.gamma=NaN,this.compassAccuracy=NaN}return a(e,"laya.device.motion.RotationInfo"),e}(),E=function(e){function t(e){t.__super.call(this),this.onDeviceOrientationChange=this.onDeviceOrientationChange.bind(this)}a(t,"laya.device.motion.Accelerator",e);var r=t.prototype;return r.on=function(t,n,i,a){return e.prototype.on.call(this,t,n,i,a),s.window.addEventListener("devicemotion",this.onDeviceOrientationChange),this},r.off=function(t,n,i,a){return void 0===a&&(a=!1),this.hasListener(t)||s.window.removeEventListener("devicemotion",this.onDeviceOrientationChange),e.prototype.off.call(this,t,n,i,a)},r.onDeviceOrientationChange=function(e){var n=e.interval;t.acceleration.x=e.acceleration.x,t.acceleration.y=e.acceleration.y,t.acceleration.z=e.acceleration.z,t.accelerationIncludingGravity.x=e.accelerationIncludingGravity.x,t.accelerationIncludingGravity.y=e.accelerationIncludingGravity.y,t.accelerationIncludingGravity.z=e.accelerationIncludingGravity.z,t.rotationRate.alpha=-1*e.rotationRate.gamma,t.rotationRate.beta=-1*e.rotationRate.alpha,t.rotationRate.gamma=e.rotationRate.beta,s.onAndriod?(t.onChrome&&(t.rotationRate.alpha*=180/Math.PI,t.rotationRate.beta*=180/Math.PI,t.rotationRate.gamma*=180/Math.PI),t.acceleration.x*=-1,t.accelerationIncludingGravity.x*=-1):s.onIOS&&(t.acceleration.y*=-1,t.acceleration.z*=-1,t.accelerationIncludingGravity.y*=-1,t.accelerationIncludingGravity.z*=-1,n*=1e3),this.event("change",[t.acceleration,t.accelerationIncludingGravity,t.rotationRate,n])},o(1,t,"instance",function(){return t._instance=t._instance||new t(0)},laya.events.EventDispatcher._$SET_instance),t.getTransformedAcceleration=function(e){(t.transformedAcceleration=t.transformedAcceleration||new p).z=e.z,90==s.window.orientation?(t.transformedAcceleration.x=e.y,t.transformedAcceleration.y=-e.x):-90==s.window.orientation?(t.transformedAcceleration.x=-e.y,t.transformedAcceleration.y=e.x):s.window.orientation?180==s.window.orientation&&(t.transformedAcceleration.x=-e.x,t.transformedAcceleration.y=-e.y):(t.transformedAcceleration.x=e.x,t.transformedAcceleration.y=e.y);var i=NaN;return-90==n.stage.canvasDegree?(i=t.transformedAcceleration.x,t.transformedAcceleration.x=-t.transformedAcceleration.y,t.transformedAcceleration.y=i):90==n.stage.canvasDegree&&(i=t.transformedAcceleration.x,t.transformedAcceleration.x=t.transformedAcceleration.y,t.transformedAcceleration.y=-i),t.transformedAcceleration},t._instance=null,t.transformedAcceleration=null,i(t,["acceleration",function(){return this.acceleration=new p},"accelerationIncludingGravity",function(){return this.accelerationIncludingGravity=new p},"rotationRate",function(){return this.rotationRate=new y},"onChrome",function(){return this.onChrome=s.userAgent.indexOf("Chrome")>-1}]),t}(c),L=(function(e){function t(e){t.__super.call(this),this.onDeviceOrientationChange=this.onDeviceOrientationChange.bind(this)}a(t,"laya.device.motion.Gyroscope",e);var n=t.prototype;n.on=function(t,n,i,a){return e.prototype.on.call(this,t,n,i,a),s.window.addEventListener("deviceorientation",this.onDeviceOrientationChange),this},n.off=function(t,n,i,a){return void 0===a&&(a=!1),this.hasListener(t)||s.window.removeEventListener("deviceorientation",this.onDeviceOrientationChange),e.prototype.off.call(this,t,n,i,a)},n.onDeviceOrientationChange=function(e){t.info.alpha=e.alpha,t.info.beta=e.beta,t.info.gamma=e.gamma,e.webkitCompassHeading&&(t.info.alpha=-1*e.webkitCompassHeading,t.info.compassAccuracy=e.webkitCompassAccuracy),this.event("change",[e.absolute,t.info])},o(1,t,"instance",function(){return t._instance=t._instance||new t(0)},laya.events.EventDispatcher._$SET_instance),t._instance=null,i(t,["info",function(){return this.info=new y}])}(c),function(e){function t(){this.throushold=0,this.shakeInterval=0,this.callback=null,this.lastX=NaN,this.lastY=NaN,this.lastZ=NaN,this.lastMillSecond=NaN,t.__super.call(this)}a(t,"laya.device.Shake",c);var n=t.prototype;n.start=function(e,t){this.throushold=e,this.shakeInterval=t,this.lastX=this.lastY=this.lastZ=NaN,E.instance.on("change",this,this.onShake)},n.stop=function(){E.instance.off("change",this,this.onShake)},n.onShake=function(e,t,n,i){if(isNaN(this.lastX))return this.lastX=t.x,this.lastY=t.y,this.lastZ=t.z,void(this.lastMillSecond=s.now());var a=Math.abs(this.lastX-t.x),o=Math.abs(this.lastY-t.y),r=Math.abs(this.lastZ-t.z);if(this.isShaked(a,o,r)){s.now()-this.lastMillSecond>this.shakeInterval&&(this.event("change"),this.lastMillSecond=s.now())}this.lastX=t.x,this.lastY=t.y,this.lastZ=t.z},n.isShaked=function(e,t,n){return e>this.throushold&&t>this.throushold||e>this.throushold&&n>this.throushold||t>this.throushold&&n>this.throushold},o(1,t,"instance",function(){return t._instance=t._instance||new t},laya.events.EventDispatcher._$SET_instance),t._instance=null}(),function(e){function t(e,n){this.htmlVideo=null,this.videoElement=null,this.internalTexture=null,void 0===e&&(e=320),void 0===n&&(n=240),t.__super.call(this),l.isWebGL?this.htmlVideo=new x:this.htmlVideo=new w,this.videoElement=this.htmlVideo.getVideo(),this.videoElement.layaTarget=this,this.internalTexture=new h(this.htmlVideo),this.videoElement.addEventListener("abort",t.onAbort),this.videoElement.addEventListener("canplay",t.onCanplay),this.videoElement.addEventListener("canplaythrough",t.onCanplaythrough),this.videoElement.addEventListener("durationchange",t.onDurationchange),this.videoElement.addEventListener("emptied",t.onEmptied),this.videoElement.addEventListener("error",t.onError),this.videoElement.addEventListener("loadeddata",t.onLoadeddata),this.videoElement.addEventListener("loadedmetadata",t.onLoadedmetadata),this.videoElement.addEventListener("loadstart",t.onLoadstart),this.videoElement.addEventListener("pause",t.onPause),this.videoElement.addEventListener("play",t.onPlay),this.videoElement.addEventListener("playing",t.onPlaying),this.videoElement.addEventListener("progress",t.onProgress),this.videoElement.addEventListener("ratechange",t.onRatechange),this.videoElement.addEventListener("seeked",t.onSeeked),this.videoElement.addEventListener("seeking",t.onSeeking),this.videoElement.addEventListener("stalled",t.onStalled),this.videoElement.addEventListener("suspend",t.onSuspend),this.videoElement.addEventListener("timeupdate",t.onTimeupdate),this.videoElement.addEventListener("volumechange",t.onVolumechange),this.videoElement.addEventListener("waiting",t.onWaiting),this.videoElement.addEventListener("ended",this.onPlayComplete.bind(this)),this.size(e,n),s.onMobile&&(this.onDocumentClick=this.onDocumentClick.bind(this),s.document.addEventListener("touchend",this.onDocumentClick))}a(t,"laya.device.media.Video",e);var i=t.prototype;return i.onPlayComplete=function(e){n.timer.clear(this,this.renderCanvas),this.event("ended")},i.load=function(e){0==e.indexOf("blob:")?this.videoElement.src=e:this.htmlVideo.setSource(e,laya.device.media.Video.MP4)},i.play=function(){this.videoElement.play(),n.timer.frameLoop(1,this,this.renderCanvas)},i.pause=function(){this.videoElement.pause(),n.timer.clear(this,this.renderCanvas)},i.reload=function(){this.videoElement.load()},i.canPlayType=function(e){var t;switch(e){case laya.device.media.Video.MP4:t="video/mp4";break;case laya.device.media.Video.OGG:t="video/ogg";break;case laya.device.media.Video.WEBM:t="video/webm"}return this.videoElement.canPlayType(t)},i.renderCanvas=function(){0!==this.readyState&&(l.isWebGL&&this.htmlVideo.updateTexture(),this.graphics.clear(),this.graphics.drawTexture(this.internalTexture,0,0,this.width,this.height))},i.onDocumentClick=function(){this.videoElement.play(),this.videoElement.pause(),s.document.removeEventListener("touchend",this.onDocumentClick)},i.size=function(t,n){return e.prototype.size.call(this,t,n),this.videoElement.width=t/s.pixelRatio,this.paused&&this.renderCanvas(),this},i.destroy=function(n){void 0===n&&(n=!0),e.prototype.destroy.call(this,n),this.videoElement.removeEventListener("abort",t.onAbort),this.videoElement.removeEventListener("canplay",t.onCanplay),this.videoElement.removeEventListener("canplaythrough",t.onCanplaythrough),this.videoElement.removeEventListener("durationchange",t.onDurationchange),this.videoElement.removeEventListener("emptied",t.onEmptied),this.videoElement.removeEventListener("error",t.onError),this.videoElement.removeEventListener("loadeddata",t.onLoadeddata),this.videoElement.removeEventListener("loadedmetadata",t.onLoadedmetadata),this.videoElement.removeEventListener("loadstart",t.onLoadstart),this.videoElement.removeEventListener("pause",t.onPause),this.videoElement.removeEventListener("play",t.onPlay),this.videoElement.removeEventListener("playing",t.onPlaying),this.videoElement.removeEventListener("progress",t.onProgress),this.videoElement.removeEventListener("ratechange",t.onRatechange),this.videoElement.removeEventListener("seeked",t.onSeeked),this.videoElement.removeEventListener("seeking",t.onSeeking),this.videoElement.removeEventListener("stalled",t.onStalled),this.videoElement.removeEventListener("suspend",t.onSuspend),this.videoElement.removeEventListener("timeupdate",t.onTimeupdate),this.videoElement.removeEventListener("volumechange",t.onVolumechange),this.videoElement.removeEventListener("waiting",t.onWaiting),this.videoElement.removeEventListener("ended",this.onPlayComplete),this.pause(),this.videoElement=null},i.syncVideoPosition=function(){var e,t=n.stage;e=u.getGlobalPosAndScale(this);var i=t._canvasTransform.a,a=t._canvasTransform.d,o=e.x*t.clientScaleX*i+t.offset.x,r=e.y*t.clientScaleY*a+t.offset.y;this.videoElement.style.left=o+"px",this.videoElement.style.top=r+"px",this.videoElement.width=this.width/s.pixelRatio,this.videoElement.height=this.height/s.pixelRatio},o(0,i,"buffered",function(){return this.videoElement.buffered}),o(0,i,"videoWidth",function(){return this.videoElement.videoWidth}),o(0,i,"currentSrc",function(){return this.videoElement.currentSrc}),o(0,i,"currentTime",function(){return this.videoElement.currentTime},function(e){this.videoElement.currentTime=e,this.renderCanvas()}),o(0,i,"ended",function(){return this.videoElement.ended}),o(0,i,"volume",function(){return this.videoElement.volume},function(e){this.videoElement.volume=e}),o(0,i,"videoHeight",function(){return this.videoElement.videoHeight}),o(0,i,"readyState",function(){return this.videoElement.readyState}),o(0,i,"duration",function(){return this.videoElement.duration}),o(0,i,"error",function(){return this.videoElement.error}),o(0,i,"loop",function(){return this.videoElement.loop},function(e){this.videoElement.loop=e}),o(0,i,"playbackRate",function(){return this.videoElement.playbackRate},function(e){this.videoElement.playbackRate=e}),o(0,i,"muted",function(){return this.videoElement.muted},function(e){this.videoElement.muted=e}),o(0,i,"paused",function(){return this.videoElement.paused}),o(0,i,"preload",function(){return this.videoElement.preload},function(e){this.videoElement.preload=e}),o(0,i,"seekable",function(){return this.videoElement.seekable}),o(0,i,"seeking",function(){return this.videoElement.seeking}),o(0,i,"height",e.prototype._$get_height,function(e){n.superSet(d,this,"height",e),this.paused&&this.renderCanvas()}),o(0,i,"width",e.prototype._$get_width,function(e){this.videoElement.width=this.width/s.pixelRatio,n.superSet(d,this,"width",e),this.paused&&this.renderCanvas()}),t.onAbort=function(e){e.target.layaTarget.event("abort")},t.onCanplay=function(e){e.target.layaTarget.event("canplay")},t.onCanplaythrough=function(e){e.target.layaTarget.event("canplaythrough")},t.onDurationchange=function(e){e.target.layaTarget.event("durationchange")},t.onEmptied=function(e){e.target.layaTarget.event("emptied")},t.onError=function(e){e.target.layaTarget.event("error")},t.onLoadeddata=function(e){e.target.layaTarget.event("loadeddata")},t.onLoadedmetadata=function(e){e.target.layaTarget.event("loadedmetadata")},t.onLoadstart=function(e){e.target.layaTarget.event("loadstart")},t.onPause=function(e){e.target.layaTarget.event("pause")},t.onPlay=function(e){e.target.layaTarget.event("play")},t.onPlaying=function(e){e.target.layaTarget.event("playing")},t.onProgress=function(e){e.target.layaTarget.event("progress")},t.onRatechange=function(e){e.target.layaTarget.event("ratechange")},t.onSeeked=function(e){e.target.layaTarget.event("seeked")},t.onSeeking=function(e){e.target.layaTarget.event("seeking")},t.onStalled=function(e){e.target.layaTarget.event("stalled")},t.onSuspend=function(e){e.target.layaTarget.event("suspend")},t.onTimeupdate=function(e){e.target.layaTarget.event("timeupdate")},t.onVolumechange=function(e){e.target.layaTarget.event("volumechange")},t.onWaiting=function(e){e.target.layaTarget.event("waiting")},t.MP4=1,t.OGG=2,t.CAMERA=4,t.WEBM=8,t.SUPPORT_PROBABLY="probably",t.SUPPORT_MAYBY="maybe",t.SUPPORT_NO="",t}(d)),w=function(e){function t(){this.video=null,t.__super.call(this),this._w=1,this._h=1,this.createDomElement()}a(t,"laya.device.media.HtmlVideo",r);var n=t.prototype;return n.createDomElement=function(){var e=this;this._source=this.video=s.createElement("video");var t=this.video.style;t.position="absolute",t.top="0px",t.left="0px",this.video.addEventListener("loadedmetadata",function(){this._w=e.video.videoWidth,this._h=e.video.videoHeight}.bind(this))},n.setSource=function(e,t){for(;this.video.childElementCount;)this.video.firstChild.remove();t&L.MP4&&this.appendSource(e,"video/mp4"),t&L.OGG&&this.appendSource(e+".ogg","video/ogg")},n.appendSource=function(e,t){var n=s.createElement("source");n.src=e,n.type=t,this.video.appendChild(n)},n.getVideo=function(){return this.video},t.create=function(){return new t},t}(),x=function(e){function t(){this.gl=null,this.preTarget=null,this.preTexture=null,t.__super.call(this),s.onIPhone||(this.gl=v.mainContext,this._source=this.gl.createTexture(),this.preTarget=m.curBindTexTarget,this.preTexture=m.curBindTexValue,m.bindTexture(this.gl,3553,this._source),this.gl.texParameteri(3553,10242,33071),this.gl.texParameteri(3553,10243,33071),this.gl.texParameteri(3553,10240,9729),this.gl.texParameteri(3553,10241,9729),this.preTarget&&this.preTexture&&m.bindTexture(this.gl,this.preTarget,this.preTexture))}a(t,"laya.device.media.WebGLVideo",w);return t.prototype.updateTexture=function(){s.onIPhone||(m.bindTexture(this.gl,3553,this._source),this.gl.texImage2D(3553,0,6407,6407,5121,this.video))},t}();n.__init([f])}(window,document,Laya),"function"==typeof define&&define.amd&&define("laya.core",["require","exports"],function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0});for(var n in Laya){var i=Laya[n];i&&i.__isclass&&(t[n]=i)}}); -------------------------------------------------------------------------------- /bin/libs/min/laya.filter.min.js: -------------------------------------------------------------------------------- 1 | !function(t,e,i){i.un,i.uns,i.static;var a=i.class,r=i.getset,n=(i.__newvec,laya.utils.Browser,laya.utils.Color),s=laya.filters.ColorFilterAction,l=laya.filters.webgl.ColorFilterActionGL,o=laya.filters.Filter,u=laya.filters.webgl.FilterActionGL,c=laya.maths.Matrix,h=(laya.maths.Rectangle,laya.renders.Render),f=(laya.renders.RenderContext,laya.webgl.resource.RenderTarget2D),_=laya.utils.RunDriver,d=(laya.webgl.shader.d2.ShaderDefines2D,laya.display.Sprite,laya.resource.Texture,laya.webgl.shader.d2.value.Value2D),g=function(){function t(){this.data=null}a(t,"laya.filters.FilterAction");var e=t.prototype;return i.imps(e,{"laya.filters.IFilterAction":!0}),e.apply=function(t){return null},t}(),y=function(){function t(){}return a(t,"laya.filters.WebGLFilter"),t.enable=function(){t.isInit||(t.isInit=!0,h.isWebGL&&(_.createFilterAction=function(t){var e;switch(t){case 32:e=new l;break;case 16:e=new p;break;case 8:e=new w}return e}))},t.isInit=!1,t.__init$=function(){_.createFilterAction=function(t){var e;switch(t){case 16:case 8:e=new g;break;case 32:e=new s}return e}},t}(),p=(function(t){function e(t){this.strength=NaN,this.strength_sig2_2sig2_gauss1=[],e.__super.call(this),void 0===t&&(t=4),h.isWebGL&&y.enable(),this.strength=t,this._action=_.createFilterAction(16),this._action.data=this}a(e,"laya.filters.BlurFilter",o);var i=e.prototype;i.callNative=function(t){t.conchModel&&t.conchModel.blurFilter&&t.conchModel.blurFilter(this.strength)},r(0,i,"action",function(){return this._action}),r(0,i,"type",function(){return 16})}(),function(t){function e(t,i,a,r){this._color=null,e.__super.call(this),this._elements=new Float32Array(9),void 0===i&&(i=4),void 0===a&&(a=6),void 0===r&&(r=6),h.isWebGL&&y.enable(),this._color=new n(t),this.blur=Math.min(i,20),this.offX=a,this.offY=r,this._action=_.createFilterAction(8),this._action.data=this}a(e,"laya.filters.GlowFilter",o);var i=e.prototype;i.getColor=function(){return this._color._color},i.callNative=function(t){t.conchModel&&t.conchModel.glowFilter&&t.conchModel.glowFilter(this._color.strColor,this._elements[4],this._elements[5],this._elements[6])},r(0,i,"type",function(){return 8}),r(0,i,"action",function(){return this._action}),r(0,i,"offY",function(){return this._elements[6]},function(t){this._elements[6]=t}),r(0,i,"offX",function(){return this._elements[5]},function(t){this._elements[5]=t}),r(0,i,"blur",function(){return this._elements[4]},function(t){this._elements[4]=t})}(),function(t){function e(){this.data=null,e.__super.call(this)}a(e,"laya.filters.webgl.BlurFilterActionGL",u);var i=e.prototype;return i.setValueMix=function(t){t.defines.add(this.data.type)},i.apply3d=function(t,e,i,a,r){var n=t.getValue("bounds"),s=d.create(1,0);s.setFilters([this.data]);c.EMPTY.identity(),i.ctx.drawTarget(t,0,0,n.width,n.height,c.EMPTY,"src",s),s.setFilters(null)},i.setValue=function(t){t.strength=this.data.strength;var e=this.data.strength/3,i=e*e;this.data.strength_sig2_2sig2_gauss1[0]=this.data.strength,this.data.strength_sig2_2sig2_gauss1[1]=i,this.data.strength_sig2_2sig2_gauss1[2]=2*i,this.data.strength_sig2_2sig2_gauss1[3]=1/(2*Math.PI*i),t.strength_sig2_2sig2_gauss1=this.data.strength_sig2_2sig2_gauss1},r(0,i,"typeMix",function(){return 16}),e}()),w=function(t){function e(){this.data=null,this._initKey=!1,this._textureWidth=0,this._textureHeight=0,e.__super.call(this)}a(e,"laya.filters.webgl.GlowFilterActionGL",u);var n=e.prototype;return i.imps(n,{"laya.filters.IFilterActionGL":!0}),n.setValueMix=function(t){},n.apply3d=function(t,e,i,a,r){var n=t.getValue("bounds");t.addValue("color",this.data.getColor());var s=n.width,l=n.height;this._textureWidth=s,this._textureHeight=l;var o,u=c.TEMP;return u.identity(),(o=d.create(1,0)).setFilters([this.data]),i.ctx.drawTarget(t,0,0,this._textureWidth,this._textureHeight,u,"src",o,null),o=d.create(1,0),i.ctx.drawTarget(t,0,0,this._textureWidth,this._textureHeight,u,"src",o),null},n.setSpriteWH=function(t){this._textureWidth=t.width,this._textureHeight=t.height},n.setValue=function(t){t.u_offsetX=this.data.offX,t.u_offsetY=-this.data.offY,t.u_strength=1,t.u_blurX=this.data.blur,t.u_blurY=this.data.blur,t.u_textW=this._textureWidth,t.u_textH=this._textureHeight,t.u_color=this.data.getColor()},r(0,n,"typeMix",function(){return 8}),e.tmpTarget=function(t,e,i,a,r){var n=t.getValue("bounds");t.getValue("out").end();var s=f.create(n.width,n.height);s.start();var l=t.getValue("color");l&&s.clear(l[0],l[1],l[2],0),t.addValue("tmpTarget",s)},e.startOut=function(t,e,i,a,r){t.getValue("tmpTarget").end();var n=t.getValue("out");n.start();var s=t.getValue("color");s&&n.clear(s[0],s[1],s[2],0)},e.recycleTarget=function(t,e,i,a,r){t.getValue("src");t.getValue("tmpTarget").recycle()},e}();i.__init([y])}(window,document,Laya),"function"==typeof define&&define.amd&&define("laya.core",["require","exports"],function(t,e){"use strict";Object.defineProperty(e,"__esModule",{value:!0});for(var i in Laya){var a=Laya[i];a&&a.__isclass&&(e[i]=a)}}); -------------------------------------------------------------------------------- /bin/libs/min/laya.html.min.js: -------------------------------------------------------------------------------- 1 | !function(t,e,i){i.un,i.uns;var n=i.static,h=i.class,l=i.getset,s=(i.__newvec,laya.utils.Browser,laya.display.css.CSSStyle),r=laya.utils.ClassUtils,a=(laya.events.Event,laya.utils.HTMLChar),o=laya.net.Loader,d=(laya.display.Node,laya.maths.Rectangle),u=laya.renders.Render,c=(laya.renders.RenderContext,laya.renders.RenderSprite,laya.display.Sprite),f=laya.utils.Stat,_=laya.display.Text,g=laya.resource.Texture,y=laya.net.URL,p=laya.utils.Utils,m=function(){function t(){}return h(t,"laya.html.utils.HTMLParse"),t.parse=function(e,i,n){i=(i=""+(i=i.replace(/
/g,"
"))+"
").replace(t.spacePattern,t.char255);var h=p.parseXMLFromString(i);t._parseXML(e,h.childNodes[0].childNodes,n)},t._parseXML=function(e,i,n,h){var l=0,s=0;if(i.join||i.item)for(l=0,s=i.length;l0&&(a=r.getInstance(o))&&(e.addChild(a),a.innerTEXT=d.replace(t.char255AndOneSpacePattern," "))):(d=i.textContent.replace(/^\s+|\s+$/g,"")).length>0&&(e.innerTEXT=d.replace(t.char255AndOneSpacePattern," ")))}if("#comment"==(o=i.nodeName.toLowerCase()))return;if(a=r.getInstance(o)){(a=e.addChild(a)).URI=n,a.href=h;var u=i.attributes;if(u&&u.length>0)for(l=0,s=u.length;l0&&T+E>p&&I.wordStartIndex>0){var U=0;U=I.elements.length-I.wordStartIndex+1,I.elements.length=I.wordStartIndex,o-=U,i();continue}A=!1,R+=r.width}E=r.width+c,M=r.height,N=!1,(A=A||T+E>p)&&i(),I.minTextHeight=Math.min(I.minTextHeight,h.height)}else a=h,s=(l=h._getCSSStyle()).padding,0===l._getCssFloat()||(L=!0),A=N||l.lineElement,E=a.width*a._style._tf.scaleX+s[1]+s[3]+c,M=a.height*a._style._tf.scaleY+s[0]+s[2],N=l.lineElement,(A=A||T+E>p&&l.wordWrap)&&i();I.elements.push(h),I.h=Math.max(I.h,M),h.x=T,h.y=C,T+=E,I.w=T-c,I.y=C,m=Math.max(T+w,m)}else W||(T+=t.DIV_ELEMENT_PADDING),I.wordStartIndex=I.elements.length;if(C=I.y+I.h,L){var b=0,P=p;for(y&&e.width>0&&(P=e.width),o=0,d=H.length;oe.height&&(e.height=C),[m,C]},t._multiLineLayout2=function(e){function i(){H.y=T,T+=H.h+f,0==H.h&&(T+=_),H.mWidth=N,N=0,H=new x,M.push(H),H.h=0,L=0,R=!0,I=!1}var n=new Array;e._addChildsToLayout(n);var h,l,s,r,a,o=0,d=n.length,u=e._getCSSStyle(),c=u.letterSpacing,f=u.leading,_=u.lineHeight,g=u._widthAuto()||!u.wordWrap,y=g?999999:e.width,p=(e.height,0),m=u.italic?u.fontSize/3:0,w=2-u._getAlign(),v=u._getValign(),S=0!==v||0!==w||0!=_,L=0,T=0,C=0,E=0,M=new Array,H=M[0]=new x,I=!1,A=!1;H.h=0,u.italic&&(y-=u.fontSize/3);var N=0,R=!0;for(o=0;o0&&L+C>y&&H.wordStartIndex>0){var W=0;W=H.elements.length-H.wordStartIndex+1,H.elements.length=H.wordStartIndex,o-=W,i();continue}I=!1,N+=r.width}C=r.width+c,E=r.height,A=!1,(I=I||L+C>y)&&i(),H.minTextHeight=Math.min(H.minTextHeight,h.height)}else a=h,s=(l=h._getCSSStyle()).padding,0===l._getCssFloat()||(S=!0),I=A||l.lineElement,C=a.width*a._style._tf.scaleX+s[1]+s[3]+c,E=a.height*a._style._tf.scaleY+s[0]+s[2],A=l.lineElement,(I=I||L+C>y&&l.wordWrap)&&i();H.elements.push(h),H.h=Math.max(H.h,E),h.x=L,h.y=T,L+=C,H.w=L-c,H.y=T,p=Math.max(L+m,p)}else R||(L+=t.DIV_ELEMENT_PADDING),H.wordStartIndex=H.elements.length;if(T=H.y+H.h,S){var U=0,b=y;for(o=0,d=M.length;oe.height&&(e.height=T),o=0,d=M.length;o0&&(a=(r=this.elements[this.elements.length-1]).x+r.width-this.elements[0].x);var o=0,d=NaN;1===h&&(o=(e-a)/2),2===h&&(o=e-a),0===s||0!=l||(l=1);for(var u=0,c=this.elements.length;u0){var i=0,n=0;for(n=this.elements.length,i=0;i0)for(var e=0;e=0&&i.push(e[h]),this._text.drawWords=i}var l=this._text.words;if(l&&l.length===i.length)return l;null===l&&(this._text.words=l=[]),l.length=i.length;var s,r=this.style,o=r.font;for(n=0,h=i.length;n1&&(d.charNum=d.char),this.href){var u=new c;this.addChild(u),d.setSprite(u)}}return l},n._getWords=function(){if(!_.CharacterCache)return this._getWords2();var t=this._text.text;if(!t||0===t.length)return null;var e=this._text.words;if(e&&e.length===t.length)return e;null===e&&(this._text.words=e=[]),e.length=t.length;for(var i,n=this.style,h=n.font,l=0,s=t.length;l0||null!=this._getWords())&&t.block?(w.later(this),t._type|=512):this.parent&&this.parent._layoutLater())},n._setAttributes=function(e,i){switch(e){case"style":return void this.style.cssText(i);case"class":return void(this.className=i)}t.prototype._setAttributes.call(this,e,i)},n.updateHref=function(){if(null!=this._href){var t=this._getWords();if(t)for(var e,i,n=0;n0)for(var e=0;e=0&&t=0&&e-l&&(u-=l,t+=o),d0&&(new Date).getTime()-h>1e3*o.timeLimit)return 1/0;var f=e+l(t,c)*o.weight;if(f>i)return f;if(t==c)return n[a]=[t.x,t.y],t;var p,g=0,b=0,m=0,v=s.getNeighbors(t,o.diagonalMovement);for(m=0,g=1/0;p=v[m];++m){if(o.trackRecursion&&(p.retainCount=p.retainCount+1||1,1!=p.tested&&(p.tested=!0)),(b=d(p,e+u(t,p),i,n,a+1))instanceof PathFinding.core.Node)return n[a]=[t.x,t.y],b;o.trackRecursion&&0==--p.retainCount&&(p.tested=!1),be?1:0}}n(t,"PathFinding.libs.HeapFunction");var e=t.prototype;return e.insort=function(t,e,i,n,s){var a=NaN;if(null==i&&(i=0),null==s&&(s=this.defaultCmp),i<0)throw new Error("lo must be non-negative");for(null==n&&(n=t.length);ii;0<=i?h++:h--)a.push(h);return a}.apply(this).reverse(),s=[],r=0,l=n.length;rh;0<=h?++d:--d)l.push(this.heappop(t,i));return l},e._siftdown=function(t,e,i,n){var s,a,o=0;for(null==n&&(n=this.defaultCmp),s=t[i];i>e&&(o=i-1>>1,a=t[o],n(s,a)<0);)t[i]=a,i=o;return t[i]=s},e._siftup=function(t,e,i){var n,s=0,a=0,o=0,r=0;for(null==i&&(i=this.defaultCmp),a=t.length,r=e,n=t[e],s=2*e+1;s\s+<");try{n=(new i.Parser.DOMParser).parseFromString(e,"text/xml")}catch(i){throw"需要引入xml解析库文件"}return n},e.idx=1,t(e,["nativefiles",function(){return this.nativefiles=["layaNativeDir","wxlocal"]}]),e}(),w=function(){function i(){}return o(i,"laya.wx.mini.MiniFileMgr"),i.isLocalNativeFile=function(i){for(var e=0,n=y.nativefiles.length;e=52428800&&(e.size>y.minClearSize&&(y.minClearSize=e.size),i.onClearCacheRes()),i.deleteFile(r,n,t,o,e.size)},fail:function(i){null!=t&&t.runWith([1,i])}}):null!=t&&t.runWith([0]):i.fs.getFileInfo({filePath:e,success:function(a){u+4194304+a.size>=52428800&&(a.size>y.minClearSize&&(y.minClearSize=a.size),i.onClearCacheRes()),i.fs.copyFile({srcPath:e,destPath:s,success:function(e){i.onSaveFile(n,r,!0,o,t,a.size)},fail:function(i){null!=t&&t.runWith([1,i])}})},fail:function(i){null!=t&&t.runWith([1,i])}})},i.onClearCacheRes=function(){var e=y.minClearSize,n=[];for(var t in i.filesListObj)n.push(i.filesListObj[t]);i.sortOn(n,"time",16);for(var o=0,a=1,r=n.length;a=e)break;o+=l.size,i.deleteFile("",l.readyUrl)}},i.sortOn=function(i,e,n){return void 0===n&&(n=0),16==n?i.sort(function(i,n){return i[e]-n[e]}):18==n?i.sort(function(i,n){return n[e]-i[e]}):i.sort(function(i,n){return i[e]-n[e]})},i.getFileNativePath=function(i){return laya.wx.mini.MiniFileMgr.fileNativeDir+"/"+i},i.deleteFile=function(e,n,t,o,a){void 0===n&&(n=""),void 0===o&&(o=""),void 0===a&&(a=0);var r=i.getFileInfo(n),l=i.getFileNativePath(r.md5);i.fs.unlink({filePath:l,success:function(r){var l=""!=e;if(""!=e){var s=i.getFileNativePath(e);i.fs.copyFile({srcPath:e,destPath:s,success:function(a){i.onSaveFile(n,e,l,o,t,a.size)},fail:function(i){null!=t&&t.runWith([1,i])}})}else i.onSaveFile(n,e,l,o,t,a)},fail:function(i){}})},i.deleteAll=function(){var e=[];for(var n in i.filesListObj)e.push(i.filesListObj[n]);for(var t=1,o=e.length;t0&&this.loops--,this.startTime=0,this.play()},t.play=function(){this.isStopped=!1,m.addChannel(this),this._audio.play()},t.stop=function(){this.isStopped=!0,m.removeChannel(this),this.completeHandler=null,this._audio&&(this._audio.pause(),this._audio.offEnded(null),this._audio=null,this._miniSound=null,this._onEnd=null)},t.pause=function(){this.isStopped=!0,this._audio.pause()},t.resume=function(){this._audio&&(this.isStopped=!1,m.addChannel(this),this._audio.play())},a(0,t,"autoplay",function(){return this._audio.autoplay},function(i){this._audio.autoplay=i}),a(0,t,"position",function(){return this._audio?this._audio.currentTime:0}),a(0,t,"duration",function(){return this._audio?this._audio.duration:0}),a(0,t,"loop",function(){return this._audio.loop},function(i){this._audio.loop=i}),a(0,t,"volume",function(){return this._audio?this._audio.volume:1},function(i){this._audio&&(this._audio.volume=i)}),e.bindToThis=function(i,e){return i.bind(e)},e}()}(window,document,Laya),"function"==typeof define&&define.amd&&define("laya.core",["require","exports"],function(i,e){"use strict";Object.defineProperty(e,"__esModule",{value:!0});for(var n in Laya){var t=Laya[n];t&&t.__isclass&&(e[n]=t)}}); -------------------------------------------------------------------------------- /bin/libs/worker.js: -------------------------------------------------------------------------------- 1 | function testCanImageData(){try{cc=new ImageData(20,20),canUseImageData=!0}catch(t){}}function loadImage(t){PNG.load(t.url,pngLoaded)}function loadImage2(t){var e,a=t.url;e=new XMLHttpRequest,e.open("GET",a,!0),e.responseType="arraybuffer",e.onload=function(){var t,i,r=e.response||e.mozResponseArrayBuffer;if(t=new Uint8Array(r),self.createImageBitmap)return void doCreateImageBitmap(t,a);try{startTime=getTimeNow(),i=new PNG(t),i.url=a,i.startTime=startTime,i.decodeEndTime=getTimeNow(),i.decodeTime=i.decodeEndTime-startTime,pngLoaded(i)}catch(s){pngFail(a,"parse fail"+s.toString()+":ya")}},e.onerror=function(t){pngFail(a,"loadFail")},e.send(null)}function doCreateImageBitmap(t,e){try{var a=getTimeNow();t=new self.Blob([t],{type:"image/png"}),self.createImageBitmap(t).then(function(t){var i={};i.url=e,i.imageBitmap=t,i.dataType="imageBitmap",i.startTime=a,i.decodeTime=getTimeNow()-a,i.sendTime=getTimeNow(),console.log("Decode By createImageBitmap,"+i.decodeTime,e),i.type="Image",postMessage(i,[i.imageBitmap])})["catch"](function(t){showMsgToMain("cache:"+t),pngFail(e,"parse fail"+t+":ya")})}catch(i){pngFail(e,"parse fail"+i.toString()+":ya")}}function getTimeNow(){return(new Date).getTime()}function pngFail(t,e){var a={};a.url=t,a.imagedata=null,a.type="Image",a.msg=e,console.log(e),postMessage(a)}function showMsgToMain(t){var e={};e.type="Msg",e.msg=t,postMessage(e)}function pngLoaded(t){var e={};e.url=t.url,canUseImageData?(e.imagedata=t.getImageData(),e.dataType="imagedata"):(e.buffer=t.getImageDataBuffer(),e.dataType="buffer"),e.width=t.width,e.height=t.height,e.decodeTime=getTimeNow()-t.startTime,console.log("Decode By PNG.js,"+(getTimeNow()-t.startTime),t.url),e.type="Image",canUseImageData?postMessage(e,[e.imagedata.data.buffer]):postMessage(e,[e.buffer.buffer])}var DecodeStream=function(){function t(){this.pos=0,this.bufferLength=0,this.eof=!1,this.buffer=null}return t.prototype={ensureBuffer:function(t){var e=this.buffer,a=e?e.byteLength:0;if(a>t)return e;for(var i=512;t>i;)i<<=1;for(var r=new Uint8Array(i),s=0;a>s;++s)r[s]=e[s];return this.buffer=r},getByte:function(){for(var t=this.pos;this.bufferLength<=t;){if(this.eof)return null;this.readBlock()}return this.buffer[this.pos++]},getBytes:function(t){var e=this.pos;if(t){this.ensureBuffer(e+t);for(var a=e+t;!this.eof&&this.bufferLengthi&&(a=i)}else{for(;!this.eof;)this.readBlock();var a=this.bufferLength}return this.pos=a,this.buffer.subarray(e,a)},lookChar:function(){for(var t=this.pos;this.bufferLength<=t;){if(this.eof)return null;this.readBlock()}return String.fromCharCode(this.buffer[this.pos])},getChar:function(){for(var t=this.pos;this.bufferLength<=t;){if(this.eof)return null;this.readBlock()}return String.fromCharCode(this.buffer[this.pos++])},makeSubStream:function(t,e,a){for(var i=t+e;this.bufferLength<=i&&!this.eof;)this.readBlock();return new Stream(this.buffer,t,e,a)},skip:function(t){t||(t=1),this.pos+=t},reset:function(){this.pos=0}},t}(),FlateStream=function(){function t(t){throw new Error(t)}function e(e){var a=0,i=e[a++],r=e[a++];-1!=i&&-1!=r||t("Invalid header in flate stream"),8!=(15&i)&&t("Unknown compression method in flate stream"),((i<<8)+r)%31!=0&&t("Bad FCHECK in flate stream"),32&r&&t("FDICT bit set in flate stream"),this.bytes=e,this.bytesPos=a,this.codeSize=0,this.codeBuf=0,DecodeStream.call(this)}var a=new Uint32Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),i=new Uint32Array([3,4,5,6,7,8,9,10,65547,65549,65551,65553,131091,131095,131099,131103,196643,196651,196659,196667,262211,262227,262243,262259,327811,327843,327875,327907,258,258,258]),r=new Uint32Array([1,2,3,4,65541,65543,131081,131085,196625,196633,262177,262193,327745,327777,393345,393409,459009,459137,524801,525057,590849,591361,657409,658433,724993,727041,794625,798721,868353,876545]),s=[new Uint32Array([459008,524368,524304,524568,459024,524400,524336,590016,459016,524384,524320,589984,524288,524416,524352,590048,459012,524376,524312,589968,459028,524408,524344,590032,459020,524392,524328,59e4,524296,524424,524360,590064,459010,524372,524308,524572,459026,524404,524340,590024,459018,524388,524324,589992,524292,524420,524356,590056,459014,524380,524316,589976,459030,524412,524348,590040,459022,524396,524332,590008,524300,524428,524364,590072,459009,524370,524306,524570,459025,524402,524338,590020,459017,524386,524322,589988,524290,524418,524354,590052,459013,524378,524314,589972,459029,524410,524346,590036,459021,524394,524330,590004,524298,524426,524362,590068,459011,524374,524310,524574,459027,524406,524342,590028,459019,524390,524326,589996,524294,524422,524358,590060,459015,524382,524318,589980,459031,524414,524350,590044,459023,524398,524334,590012,524302,524430,524366,590076,459008,524369,524305,524569,459024,524401,524337,590018,459016,524385,524321,589986,524289,524417,524353,590050,459012,524377,524313,589970,459028,524409,524345,590034,459020,524393,524329,590002,524297,524425,524361,590066,459010,524373,524309,524573,459026,524405,524341,590026,459018,524389,524325,589994,524293,524421,524357,590058,459014,524381,524317,589978,459030,524413,524349,590042,459022,524397,524333,590010,524301,524429,524365,590074,459009,524371,524307,524571,459025,524403,524339,590022,459017,524387,524323,589990,524291,524419,524355,590054,459013,524379,524315,589974,459029,524411,524347,590038,459021,524395,524331,590006,524299,524427,524363,590070,459011,524375,524311,524575,459027,524407,524343,590030,459019,524391,524327,589998,524295,524423,524359,590062,459015,524383,524319,589982,459031,524415,524351,590046,459023,524399,524335,590014,524303,524431,524367,590078,459008,524368,524304,524568,459024,524400,524336,590017,459016,524384,524320,589985,524288,524416,524352,590049,459012,524376,524312,589969,459028,524408,524344,590033,459020,524392,524328,590001,524296,524424,524360,590065,459010,524372,524308,524572,459026,524404,524340,590025,459018,524388,524324,589993,524292,524420,524356,590057,459014,524380,524316,589977,459030,524412,524348,590041,459022,524396,524332,590009,524300,524428,524364,590073,459009,524370,524306,524570,459025,524402,524338,590021,459017,524386,524322,589989,524290,524418,524354,590053,459013,524378,524314,589973,459029,524410,524346,590037,459021,524394,524330,590005,524298,524426,524362,590069,459011,524374,524310,524574,459027,524406,524342,590029,459019,524390,524326,589997,524294,524422,524358,590061,459015,524382,524318,589981,459031,524414,524350,590045,459023,524398,524334,590013,524302,524430,524366,590077,459008,524369,524305,524569,459024,524401,524337,590019,459016,524385,524321,589987,524289,524417,524353,590051,459012,524377,524313,589971,459028,524409,524345,590035,459020,524393,524329,590003,524297,524425,524361,590067,459010,524373,524309,524573,459026,524405,524341,590027,459018,524389,524325,589995,524293,524421,524357,590059,459014,524381,524317,589979,459030,524413,524349,590043,459022,524397,524333,590011,524301,524429,524365,590075,459009,524371,524307,524571,459025,524403,524339,590023,459017,524387,524323,589991,524291,524419,524355,590055,459013,524379,524315,589975,459029,524411,524347,590039,459021,524395,524331,590007,524299,524427,524363,590071,459011,524375,524311,524575,459027,524407,524343,590031,459019,524391,524327,589999,524295,524423,524359,590063,459015,524383,524319,589983,459031,524415,524351,590047,459023,524399,524335,590015,524303,524431,524367,590079]),9],n=[new Uint32Array([327680,327696,327688,327704,327684,327700,327692,327708,327682,327698,327690,327706,327686,327702,327694,0,327681,327697,327689,327705,327685,327701,327693,327709,327683,327699,327691,327707,327687,327703,327695,0]),5];return e.prototype=Object.create(DecodeStream.prototype),e.prototype.getBits=function(e){for(var a,i=this.codeSize,r=this.codeBuf,s=this.bytes,n=this.bytesPos;e>i;)"undefined"==typeof(a=s[n++])&&t("Bad encoding in flate stream"),r|=a<>e,this.codeSize=i-=e,this.bytesPos=n,a},e.prototype.getCode=function(e){for(var a=e[0],i=e[1],r=this.codeSize,s=this.codeBuf,n=this.bytes,o=this.bytesPos;i>r;){var h;"undefined"==typeof(h=n[o++])&&t("Bad encoding in flate stream"),s|=h<>16,c=65535&f;return(0==r||d>r||0==d)&&t("Bad encoding in flate stream"),this.codeBuf=s>>d,this.codeSize=r-d,this.bytesPos=o,c},e.prototype.generateHuffmanTable=function(t){for(var e=t.length,a=0,i=0;e>i;++i)t[i]>a&&(a=t[i]);for(var r=1<=n;++n,o<<=1,h<<=1)for(var f=0;e>f;++f)if(t[f]==n){for(var d=0,c=o,i=0;n>i;++i)d=d<<1|1&c,c>>=1;for(var i=d;r>i;i+=h)s[i]=n<<16|f;++o}return[s,a]},e.prototype.readBlock=function(){function e(t,e,a,i,r){for(var s=t.getBits(a)+i;s-- >0;)e[I++]=r}var o=this.getBits(3);if(1&o&&(this.eof=!0),o>>=1,0==o){var h,f=this.bytes,d=this.bytesPos;"undefined"==typeof(h=f[d++])&&t("Bad block header in flate stream");var c=h;"undefined"==typeof(h=f[d++])&&t("Bad block header in flate stream"),c|=h<<8,"undefined"==typeof(h=f[d++])&&t("Bad block header in flate stream");var l=h;"undefined"==typeof(h=f[d++])&&t("Bad block header in flate stream"),l|=h<<8,l!=(65535&~c)&&t("Bad uncompressed block length in flate stream"),this.codeBuf=0,this.codeSize=0;var u=this.bufferLength,p=this.ensureBuffer(u+c),g=u+c;this.bufferLength=g;for(var m=u;g>m;++m){if("undefined"==typeof(h=f[d++])){this.eof=!0;break}p[m]=h}return void(this.bytesPos=d)}var y,v;if(1==o)y=s,v=n;else if(2==o){for(var b=this.getBits(5)+257,w=this.getBits(5)+1,B=this.getBits(4)+4,T=Array(a.length),I=0;B>I;)T[a[I++]]=this.getBits(3);for(var U=this.generateHuffmanTable(T),D=0,I=0,k=b+w,A=new Array(k);k>I;){var C=this.getCode(U);16==C?e(this,A,2,3,D):17==C?e(this,A,3,3,D=0):18==C?e(this,A,7,11,D=0):A[I++]=D=C}y=this.generateHuffmanTable(A.slice(0,b)),v=this.generateHuffmanTable(A.slice(b,k))}else t("Unknown block type in flate stream");for(var p=this.buffer,S=p?p.length:0,P=this.bufferLength;;){var M=this.getCode(y);if(256>M)P+1>=S&&(p=this.ensureBuffer(P+1),S=p.length),p[P++]=M;else{if(256==M)return void(this.bufferLength=P);M-=257,M=i[M];var L=M>>16;L>0&&(L=this.getBits(L));var D=(65535&M)+L;M=this.getCode(v),M=r[M],L=M>>16,L>0&&(L=this.getBits(L));var x=(65535&M)+L;P+D>=S&&(p=this.ensureBuffer(P+D),S=p.length);for(var N=0;D>N;++N,++P)p[P]=p[P-x]}}},e}();(function(){var t;t=function(){function t(t){var e,a,i,r,s,n,o,h,f,d,c,l,u,p;for(this.data=t,this.pos=8,this.palette=[],this.imgData=[],this.transparency={},this.animation=null,this.text={},s=null;;){switch(e=this.readUInt32(),f=function(){var t,e;for(e=[],n=t=0;4>t;n=++t)e.push(String.fromCharCode(this.data[this.pos++]));return e}.call(this).join("")){case"IHDR":if(this.width=this.readUInt32(),this.height=this.readUInt32(),this.bits=this.data[this.pos++],this.colorType=this.data[this.pos++],this.compressionMethod=this.data[this.pos++],this.filterMethod=this.data[this.pos++],this.interlaceMethod=this.data[this.pos++],0!=this.interlaceMethod)throw new Error("Invalid interlaceMethod: "+this.interlaceMethod);break;case"acTL":this.animation={numFrames:this.readUInt32(),numPlays:this.readUInt32()||1/0,frames:[]};break;case"PLTE":this.palette=this.read(e);break;case"fcTL":s&&this.animation.frames.push(s),this.pos+=4,s={width:this.readUInt32(),height:this.readUInt32(),xOffset:this.readUInt32(),yOffset:this.readUInt32()},r=this.readUInt16(),i=this.readUInt16()||100,s.delay=1e3*r/i,s.disposeOp=this.data[this.pos++],s.blendOp=this.data[this.pos++],s.data=[];break;case"IDAT":case"fdAT":for("fdAT"===f&&(this.pos+=4,e-=4),t=(null!=s?s.data:void 0)||this.imgData,n=l=0;e>=0?e>l:l>e;n=e>=0?++l:--l)t.push(this.data[this.pos++]);break;case"tRNS":switch(this.transparency={},this.colorType){case 3:if(this.transparency.indexed=this.read(e),d=255-this.transparency.indexed.length,d>0)for(n=u=0;d>=0?d>u:u>d;n=d>=0?++u:--u)this.transparency.indexed.push(255);break;case 0:this.transparency.grayscale=this.read(e)[0];break;case 2:this.transparency.rgb=this.read(e)}break;case"tEXt":c=this.read(e),o=c.indexOf(0),h=String.fromCharCode.apply(String,c.slice(0,o)),this.text[h]=String.fromCharCode.apply(String,c.slice(o+1));break;case"IEND":return s&&this.animation.frames.push(s),this.colors=function(){switch(this.colorType){case 0:case 3:case 4:return 1;case 2:case 6:return 3}}.call(this),this.hasAlphaChannel=4===(p=this.colorType)||6===p,a=this.colors+(this.hasAlphaChannel?1:0),this.pixelBitlength=this.bits*a,this.colorSpace=function(){switch(this.colors){case 1:return"DeviceGray";case 3:return"DeviceRGB"}}.call(this),void(this.imgData=new Uint8Array(this.imgData));default:this.pos+=e}if(this.pos+=4,this.pos>this.data.length)throw new Error("Incomplete or corrupt PNG file")}}var e,a,i,r,s,n;return t.load=function(e,a){var i;return"function"==typeof canvas&&(a=canvas),i=new XMLHttpRequest,i.open("GET",e,!0),i.responseType="arraybuffer",i.onload=function(){var r,s;return r=new Uint8Array(i.response||i.mozResponseArrayBuffer),s=new t(r),s.url=e,"function"==typeof a?a(s):void 0},i.send(null)},r=0,i=1,s=2,a=0,e=1,t.prototype.read=function(t){var e,a,i;for(i=[],e=a=0;t>=0?t>a:a>t;e=t>=0?++a:--a)i.push(this.data[this.pos++]);return i},t.prototype.readUInt32=function(){var t,e,a,i;return t=this.data[this.pos++]<<24,e=this.data[this.pos++]<<16,a=this.data[this.pos++]<<8,i=this.data[this.pos++],t|e|a|i},t.prototype.readUInt16=function(){var t,e;return t=this.data[this.pos++]<<8,e=this.data[this.pos++],t|e},t.prototype.decodePixels=function(t){var e,a,i,r,s,n,o,h,f,d,c,l,u,p,g,m,y,v,b,w,B,T,I;if(null==t&&(t=this.imgData),0===t.length)return new Uint8Array(0);for(t=new FlateStream(t),t=t.getBytes(),l=this.pixelBitlength/8,m=l*this.width,u=new Uint8Array(m*this.height),n=t.length,g=0,p=0,a=0;n>p;){switch(t[p++]){case 0:for(r=b=0;m>b;r=b+=1)u[a++]=t[p++];break;case 1:for(r=w=0;m>w;r=w+=1)e=t[p++],s=l>r?0:u[a-l],u[a++]=(e+s)%256;break;case 2:for(r=B=0;m>B;r=B+=1)e=t[p++],i=(r-r%l)/l,y=g&&u[(g-1)*m+i*l+r%l],u[a++]=(y+e)%256;break;case 3:for(r=T=0;m>T;r=T+=1)e=t[p++],i=(r-r%l)/l,s=l>r?0:u[a-l],y=g&&u[(g-1)*m+i*l+r%l],u[a++]=(e+Math.floor((s+y)/2))%256;break;case 4:for(r=I=0;m>I;r=I+=1)e=t[p++],i=(r-r%l)/l,s=l>r?0:u[a-l],0===g?y=v=0:(y=u[(g-1)*m+i*l+r%l],v=i&&u[(g-1)*m+(i-1)*l+r%l]),o=s+y-v,h=Math.abs(o-s),d=Math.abs(o-y),c=Math.abs(o-v),f=d>=h&&c>=h?s:c>=d?y:v,u[a++]=(e+f)%256;break;default:throw new Error("Invalid filter algorithm: "+t[p-1])}g++}return u},t.prototype.decodePalette=function(){var t,e,a,i,r,s,n,o,h,f;i=this.palette,n=this.transparency.indexed||[];var d;for(d=4*i.length/3,s=new Uint8Array(d),r=0,a=i.length,t=0,e=o=0,h=i.length;h>o;e=o+=3)s[r++]=i[e],s[r++]=i[e+1],s[r++]=i[e+2],s[r++]=null!=(f=n[t++])?f:255;return s},t.prototype.getImageData=function(){var t=new self.ImageData(this.width,this.height);return this.copyToImageData(t,this.decodePixels()),t},t.prototype.getImageDataBuffer=function(){var t;return t=self.Uint8ClampedArray?new self.Uint8ClampedArray(this.width*this.height*4):new self.Uint8Array(this.width*this.height*4),this.copyToImageData(t,this.decodePixels()),t},t.prototype.copyToImageData=function(t,e){var a,i,r,s,n,o,h,f,d,c,l;if(i=this.colors,d=null,a=this.hasAlphaChannel,this.palette.length&&(d=null!=(l=this._decodedPalette)?l:this._decodedPalette=this.decodePalette(),i=4,a=!0),r=t.data||t,f=r.length,n=d||e,s=o=0,1===i)for(;f>s;)h=d?4*e[s/4]:o,c=n[h++],r[s++]=c,r[s++]=c,r[s++]=c,r[s++]=a?n[h++]:255,o=h;else for(;f>s;)h=d?4*e[s/4]:o,r[s++]=n[h++],r[s++]=n[h++],r[s++]=n[h++],r[s++]=a?n[h++]:255,o=h},t.prototype.decode=function(){var t;return t=new Uint8Array(this.width*this.height*4),this.copyToImageData(t,this.decodePixels()),t},t.prototype.decodeFrames=function(t){var e,a,i,r,s,o,h,f;if(this.animation){for(h=this.animation.frames,f=[],a=s=0,o=h.length;o>s;a=++s)e=h[a],i=t.createImageData(e.width,e.height),r=this.decodePixels(new Uint8Array(e.data)),this.copyToImageData(i,r),e.imageData=i,f.push(e.image=n(i));return f}},t}(),this.PNG=t}).call(this),onmessage=function(t){var e=t.data;switch(e.type){case"load":loadImage2(e)}};var canUseImageData=!1;testCanImageData(); -------------------------------------------------------------------------------- /bin/res/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tianhe1986/Fat-Doudizhu/8c8b82362011ee54c350f4c64c58e06472e687a1/bin/res/.gitkeep -------------------------------------------------------------------------------- /bin/unpack.json: -------------------------------------------------------------------------------- 1 | [] -------------------------------------------------------------------------------- /laya/.laya: -------------------------------------------------------------------------------- 1 | 2 | img,temp,sound 3 | embed 4 | png,jpg 5 | bin/res/atlas 6 | bin 7 | src/ui 8 | 9 | 11 | 0 12 | bin/ui.json 13 | Box,List,Tab,RadioGroup,ViewStack,Panel,HBox,VBox,Tree,Sprite 14 | View,Dialog 15 | 16 | 1 17 | 18 | 80 19 | 20 | 21 | 23 | 2048 24 | 2048 25 | 512 26 | 512 27 | false 28 | false 29 | -------------------------------------------------------------------------------- /laya/assets/comp/bg.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tianhe1986/Fat-Doudizhu/8c8b82362011ee54c350f4c64c58e06472e687a1/laya/assets/comp/bg.png -------------------------------------------------------------------------------- /laya/assets/comp/blank.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tianhe1986/Fat-Doudizhu/8c8b82362011ee54c350f4c64c58e06472e687a1/laya/assets/comp/blank.png -------------------------------------------------------------------------------- /laya/assets/comp/btn_close.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tianhe1986/Fat-Doudizhu/8c8b82362011ee54c350f4c64c58e06472e687a1/laya/assets/comp/btn_close.png -------------------------------------------------------------------------------- /laya/assets/comp/button.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tianhe1986/Fat-Doudizhu/8c8b82362011ee54c350f4c64c58e06472e687a1/laya/assets/comp/button.png -------------------------------------------------------------------------------- /laya/assets/comp/checkbox.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tianhe1986/Fat-Doudizhu/8c8b82362011ee54c350f4c64c58e06472e687a1/laya/assets/comp/checkbox.png -------------------------------------------------------------------------------- /laya/assets/comp/clip_num.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tianhe1986/Fat-Doudizhu/8c8b82362011ee54c350f4c64c58e06472e687a1/laya/assets/comp/clip_num.png -------------------------------------------------------------------------------- /laya/assets/comp/clip_selectBox.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tianhe1986/Fat-Doudizhu/8c8b82362011ee54c350f4c64c58e06472e687a1/laya/assets/comp/clip_selectBox.png -------------------------------------------------------------------------------- /laya/assets/comp/clip_tree_arrow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tianhe1986/Fat-Doudizhu/8c8b82362011ee54c350f4c64c58e06472e687a1/laya/assets/comp/clip_tree_arrow.png -------------------------------------------------------------------------------- /laya/assets/comp/clip_tree_folder.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tianhe1986/Fat-Doudizhu/8c8b82362011ee54c350f4c64c58e06472e687a1/laya/assets/comp/clip_tree_folder.png -------------------------------------------------------------------------------- /laya/assets/comp/combobox.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tianhe1986/Fat-Doudizhu/8c8b82362011ee54c350f4c64c58e06472e687a1/laya/assets/comp/combobox.png -------------------------------------------------------------------------------- /laya/assets/comp/hscroll$bar.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tianhe1986/Fat-Doudizhu/8c8b82362011ee54c350f4c64c58e06472e687a1/laya/assets/comp/hscroll$bar.png -------------------------------------------------------------------------------- /laya/assets/comp/hscroll$down.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tianhe1986/Fat-Doudizhu/8c8b82362011ee54c350f4c64c58e06472e687a1/laya/assets/comp/hscroll$down.png -------------------------------------------------------------------------------- /laya/assets/comp/hscroll$up.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tianhe1986/Fat-Doudizhu/8c8b82362011ee54c350f4c64c58e06472e687a1/laya/assets/comp/hscroll$up.png -------------------------------------------------------------------------------- /laya/assets/comp/hscroll.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tianhe1986/Fat-Doudizhu/8c8b82362011ee54c350f4c64c58e06472e687a1/laya/assets/comp/hscroll.png -------------------------------------------------------------------------------- /laya/assets/comp/hslider$bar.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tianhe1986/Fat-Doudizhu/8c8b82362011ee54c350f4c64c58e06472e687a1/laya/assets/comp/hslider$bar.png -------------------------------------------------------------------------------- /laya/assets/comp/hslider.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tianhe1986/Fat-Doudizhu/8c8b82362011ee54c350f4c64c58e06472e687a1/laya/assets/comp/hslider.png -------------------------------------------------------------------------------- /laya/assets/comp/html.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tianhe1986/Fat-Doudizhu/8c8b82362011ee54c350f4c64c58e06472e687a1/laya/assets/comp/html.png -------------------------------------------------------------------------------- /laya/assets/comp/image.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tianhe1986/Fat-Doudizhu/8c8b82362011ee54c350f4c64c58e06472e687a1/laya/assets/comp/image.png -------------------------------------------------------------------------------- /laya/assets/comp/label.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tianhe1986/Fat-Doudizhu/8c8b82362011ee54c350f4c64c58e06472e687a1/laya/assets/comp/label.png -------------------------------------------------------------------------------- /laya/assets/comp/linkbutton.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tianhe1986/Fat-Doudizhu/8c8b82362011ee54c350f4c64c58e06472e687a1/laya/assets/comp/linkbutton.png -------------------------------------------------------------------------------- /laya/assets/comp/progress$bar.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tianhe1986/Fat-Doudizhu/8c8b82362011ee54c350f4c64c58e06472e687a1/laya/assets/comp/progress$bar.png -------------------------------------------------------------------------------- /laya/assets/comp/progress.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tianhe1986/Fat-Doudizhu/8c8b82362011ee54c350f4c64c58e06472e687a1/laya/assets/comp/progress.png -------------------------------------------------------------------------------- /laya/assets/comp/radio.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tianhe1986/Fat-Doudizhu/8c8b82362011ee54c350f4c64c58e06472e687a1/laya/assets/comp/radio.png -------------------------------------------------------------------------------- /laya/assets/comp/radiogroup.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tianhe1986/Fat-Doudizhu/8c8b82362011ee54c350f4c64c58e06472e687a1/laya/assets/comp/radiogroup.png -------------------------------------------------------------------------------- /laya/assets/comp/tab.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tianhe1986/Fat-Doudizhu/8c8b82362011ee54c350f4c64c58e06472e687a1/laya/assets/comp/tab.png -------------------------------------------------------------------------------- /laya/assets/comp/textarea.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tianhe1986/Fat-Doudizhu/8c8b82362011ee54c350f4c64c58e06472e687a1/laya/assets/comp/textarea.png -------------------------------------------------------------------------------- /laya/assets/comp/textinput.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tianhe1986/Fat-Doudizhu/8c8b82362011ee54c350f4c64c58e06472e687a1/laya/assets/comp/textinput.png -------------------------------------------------------------------------------- /laya/assets/comp/vscroll$bar.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tianhe1986/Fat-Doudizhu/8c8b82362011ee54c350f4c64c58e06472e687a1/laya/assets/comp/vscroll$bar.png -------------------------------------------------------------------------------- /laya/assets/comp/vscroll$down.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tianhe1986/Fat-Doudizhu/8c8b82362011ee54c350f4c64c58e06472e687a1/laya/assets/comp/vscroll$down.png -------------------------------------------------------------------------------- /laya/assets/comp/vscroll$up.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tianhe1986/Fat-Doudizhu/8c8b82362011ee54c350f4c64c58e06472e687a1/laya/assets/comp/vscroll$up.png -------------------------------------------------------------------------------- /laya/assets/comp/vscroll.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tianhe1986/Fat-Doudizhu/8c8b82362011ee54c350f4c64c58e06472e687a1/laya/assets/comp/vscroll.png -------------------------------------------------------------------------------- /laya/assets/comp/vslider$bar.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tianhe1986/Fat-Doudizhu/8c8b82362011ee54c350f4c64c58e06472e687a1/laya/assets/comp/vslider$bar.png -------------------------------------------------------------------------------- /laya/assets/comp/vslider.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tianhe1986/Fat-Doudizhu/8c8b82362011ee54c350f4c64c58e06472e687a1/laya/assets/comp/vslider.png -------------------------------------------------------------------------------- /laya/assets/doudizhu/bg_poker.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tianhe1986/Fat-Doudizhu/8c8b82362011ee54c350f4c64c58e06472e687a1/laya/assets/doudizhu/bg_poker.png -------------------------------------------------------------------------------- /laya/assets/doudizhu/dizhu.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tianhe1986/Fat-Doudizhu/8c8b82362011ee54c350f4c64c58e06472e687a1/laya/assets/doudizhu/dizhu.png -------------------------------------------------------------------------------- /laya/assets/doudizhu/nongmin.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tianhe1986/Fat-Doudizhu/8c8b82362011ee54c350f4c64c58e06472e687a1/laya/assets/doudizhu/nongmin.png -------------------------------------------------------------------------------- /laya/assets/poker/1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tianhe1986/Fat-Doudizhu/8c8b82362011ee54c350f4c64c58e06472e687a1/laya/assets/poker/1.jpg -------------------------------------------------------------------------------- /laya/assets/poker/10.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tianhe1986/Fat-Doudizhu/8c8b82362011ee54c350f4c64c58e06472e687a1/laya/assets/poker/10.jpg -------------------------------------------------------------------------------- /laya/assets/poker/11.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tianhe1986/Fat-Doudizhu/8c8b82362011ee54c350f4c64c58e06472e687a1/laya/assets/poker/11.jpg -------------------------------------------------------------------------------- /laya/assets/poker/12.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tianhe1986/Fat-Doudizhu/8c8b82362011ee54c350f4c64c58e06472e687a1/laya/assets/poker/12.jpg -------------------------------------------------------------------------------- /laya/assets/poker/13.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tianhe1986/Fat-Doudizhu/8c8b82362011ee54c350f4c64c58e06472e687a1/laya/assets/poker/13.jpg -------------------------------------------------------------------------------- /laya/assets/poker/14.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tianhe1986/Fat-Doudizhu/8c8b82362011ee54c350f4c64c58e06472e687a1/laya/assets/poker/14.jpg -------------------------------------------------------------------------------- /laya/assets/poker/15.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tianhe1986/Fat-Doudizhu/8c8b82362011ee54c350f4c64c58e06472e687a1/laya/assets/poker/15.jpg -------------------------------------------------------------------------------- /laya/assets/poker/16.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tianhe1986/Fat-Doudizhu/8c8b82362011ee54c350f4c64c58e06472e687a1/laya/assets/poker/16.jpg -------------------------------------------------------------------------------- /laya/assets/poker/17.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tianhe1986/Fat-Doudizhu/8c8b82362011ee54c350f4c64c58e06472e687a1/laya/assets/poker/17.jpg -------------------------------------------------------------------------------- /laya/assets/poker/18.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tianhe1986/Fat-Doudizhu/8c8b82362011ee54c350f4c64c58e06472e687a1/laya/assets/poker/18.jpg -------------------------------------------------------------------------------- /laya/assets/poker/19.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tianhe1986/Fat-Doudizhu/8c8b82362011ee54c350f4c64c58e06472e687a1/laya/assets/poker/19.jpg -------------------------------------------------------------------------------- /laya/assets/poker/2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tianhe1986/Fat-Doudizhu/8c8b82362011ee54c350f4c64c58e06472e687a1/laya/assets/poker/2.jpg -------------------------------------------------------------------------------- /laya/assets/poker/20.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tianhe1986/Fat-Doudizhu/8c8b82362011ee54c350f4c64c58e06472e687a1/laya/assets/poker/20.jpg -------------------------------------------------------------------------------- /laya/assets/poker/21.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tianhe1986/Fat-Doudizhu/8c8b82362011ee54c350f4c64c58e06472e687a1/laya/assets/poker/21.jpg -------------------------------------------------------------------------------- /laya/assets/poker/22.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tianhe1986/Fat-Doudizhu/8c8b82362011ee54c350f4c64c58e06472e687a1/laya/assets/poker/22.jpg -------------------------------------------------------------------------------- /laya/assets/poker/23.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tianhe1986/Fat-Doudizhu/8c8b82362011ee54c350f4c64c58e06472e687a1/laya/assets/poker/23.jpg -------------------------------------------------------------------------------- /laya/assets/poker/24.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tianhe1986/Fat-Doudizhu/8c8b82362011ee54c350f4c64c58e06472e687a1/laya/assets/poker/24.jpg -------------------------------------------------------------------------------- /laya/assets/poker/25.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tianhe1986/Fat-Doudizhu/8c8b82362011ee54c350f4c64c58e06472e687a1/laya/assets/poker/25.jpg -------------------------------------------------------------------------------- /laya/assets/poker/26.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tianhe1986/Fat-Doudizhu/8c8b82362011ee54c350f4c64c58e06472e687a1/laya/assets/poker/26.jpg -------------------------------------------------------------------------------- /laya/assets/poker/27.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tianhe1986/Fat-Doudizhu/8c8b82362011ee54c350f4c64c58e06472e687a1/laya/assets/poker/27.jpg -------------------------------------------------------------------------------- /laya/assets/poker/28.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tianhe1986/Fat-Doudizhu/8c8b82362011ee54c350f4c64c58e06472e687a1/laya/assets/poker/28.jpg -------------------------------------------------------------------------------- /laya/assets/poker/29.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tianhe1986/Fat-Doudizhu/8c8b82362011ee54c350f4c64c58e06472e687a1/laya/assets/poker/29.jpg -------------------------------------------------------------------------------- /laya/assets/poker/3.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tianhe1986/Fat-Doudizhu/8c8b82362011ee54c350f4c64c58e06472e687a1/laya/assets/poker/3.jpg -------------------------------------------------------------------------------- /laya/assets/poker/30.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tianhe1986/Fat-Doudizhu/8c8b82362011ee54c350f4c64c58e06472e687a1/laya/assets/poker/30.jpg -------------------------------------------------------------------------------- /laya/assets/poker/31.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tianhe1986/Fat-Doudizhu/8c8b82362011ee54c350f4c64c58e06472e687a1/laya/assets/poker/31.jpg -------------------------------------------------------------------------------- /laya/assets/poker/32.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tianhe1986/Fat-Doudizhu/8c8b82362011ee54c350f4c64c58e06472e687a1/laya/assets/poker/32.jpg -------------------------------------------------------------------------------- /laya/assets/poker/33.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tianhe1986/Fat-Doudizhu/8c8b82362011ee54c350f4c64c58e06472e687a1/laya/assets/poker/33.jpg -------------------------------------------------------------------------------- /laya/assets/poker/34.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tianhe1986/Fat-Doudizhu/8c8b82362011ee54c350f4c64c58e06472e687a1/laya/assets/poker/34.jpg -------------------------------------------------------------------------------- /laya/assets/poker/35.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tianhe1986/Fat-Doudizhu/8c8b82362011ee54c350f4c64c58e06472e687a1/laya/assets/poker/35.jpg -------------------------------------------------------------------------------- /laya/assets/poker/36.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tianhe1986/Fat-Doudizhu/8c8b82362011ee54c350f4c64c58e06472e687a1/laya/assets/poker/36.jpg -------------------------------------------------------------------------------- /laya/assets/poker/37.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tianhe1986/Fat-Doudizhu/8c8b82362011ee54c350f4c64c58e06472e687a1/laya/assets/poker/37.jpg -------------------------------------------------------------------------------- /laya/assets/poker/38.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tianhe1986/Fat-Doudizhu/8c8b82362011ee54c350f4c64c58e06472e687a1/laya/assets/poker/38.jpg -------------------------------------------------------------------------------- /laya/assets/poker/39.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tianhe1986/Fat-Doudizhu/8c8b82362011ee54c350f4c64c58e06472e687a1/laya/assets/poker/39.jpg -------------------------------------------------------------------------------- /laya/assets/poker/4.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tianhe1986/Fat-Doudizhu/8c8b82362011ee54c350f4c64c58e06472e687a1/laya/assets/poker/4.jpg -------------------------------------------------------------------------------- /laya/assets/poker/40.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tianhe1986/Fat-Doudizhu/8c8b82362011ee54c350f4c64c58e06472e687a1/laya/assets/poker/40.jpg -------------------------------------------------------------------------------- /laya/assets/poker/41.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tianhe1986/Fat-Doudizhu/8c8b82362011ee54c350f4c64c58e06472e687a1/laya/assets/poker/41.jpg -------------------------------------------------------------------------------- /laya/assets/poker/42.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tianhe1986/Fat-Doudizhu/8c8b82362011ee54c350f4c64c58e06472e687a1/laya/assets/poker/42.jpg -------------------------------------------------------------------------------- /laya/assets/poker/43.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tianhe1986/Fat-Doudizhu/8c8b82362011ee54c350f4c64c58e06472e687a1/laya/assets/poker/43.jpg -------------------------------------------------------------------------------- /laya/assets/poker/44.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tianhe1986/Fat-Doudizhu/8c8b82362011ee54c350f4c64c58e06472e687a1/laya/assets/poker/44.jpg -------------------------------------------------------------------------------- /laya/assets/poker/45.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tianhe1986/Fat-Doudizhu/8c8b82362011ee54c350f4c64c58e06472e687a1/laya/assets/poker/45.jpg -------------------------------------------------------------------------------- /laya/assets/poker/46.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tianhe1986/Fat-Doudizhu/8c8b82362011ee54c350f4c64c58e06472e687a1/laya/assets/poker/46.jpg -------------------------------------------------------------------------------- /laya/assets/poker/47.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tianhe1986/Fat-Doudizhu/8c8b82362011ee54c350f4c64c58e06472e687a1/laya/assets/poker/47.jpg -------------------------------------------------------------------------------- /laya/assets/poker/48.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tianhe1986/Fat-Doudizhu/8c8b82362011ee54c350f4c64c58e06472e687a1/laya/assets/poker/48.jpg -------------------------------------------------------------------------------- /laya/assets/poker/49.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tianhe1986/Fat-Doudizhu/8c8b82362011ee54c350f4c64c58e06472e687a1/laya/assets/poker/49.jpg -------------------------------------------------------------------------------- /laya/assets/poker/5.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tianhe1986/Fat-Doudizhu/8c8b82362011ee54c350f4c64c58e06472e687a1/laya/assets/poker/5.jpg -------------------------------------------------------------------------------- /laya/assets/poker/50.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tianhe1986/Fat-Doudizhu/8c8b82362011ee54c350f4c64c58e06472e687a1/laya/assets/poker/50.jpg -------------------------------------------------------------------------------- /laya/assets/poker/51.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tianhe1986/Fat-Doudizhu/8c8b82362011ee54c350f4c64c58e06472e687a1/laya/assets/poker/51.jpg -------------------------------------------------------------------------------- /laya/assets/poker/52.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tianhe1986/Fat-Doudizhu/8c8b82362011ee54c350f4c64c58e06472e687a1/laya/assets/poker/52.jpg -------------------------------------------------------------------------------- /laya/assets/poker/53.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tianhe1986/Fat-Doudizhu/8c8b82362011ee54c350f4c64c58e06472e687a1/laya/assets/poker/53.jpg -------------------------------------------------------------------------------- /laya/assets/poker/54.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tianhe1986/Fat-Doudizhu/8c8b82362011ee54c350f4c64c58e06472e687a1/laya/assets/poker/54.jpg -------------------------------------------------------------------------------- /laya/assets/poker/6.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tianhe1986/Fat-Doudizhu/8c8b82362011ee54c350f4c64c58e06472e687a1/laya/assets/poker/6.jpg -------------------------------------------------------------------------------- /laya/assets/poker/7.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tianhe1986/Fat-Doudizhu/8c8b82362011ee54c350f4c64c58e06472e687a1/laya/assets/poker/7.jpg -------------------------------------------------------------------------------- /laya/assets/poker/8.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tianhe1986/Fat-Doudizhu/8c8b82362011ee54c350f4c64c58e06472e687a1/laya/assets/poker/8.jpg -------------------------------------------------------------------------------- /laya/assets/poker/9.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tianhe1986/Fat-Doudizhu/8c8b82362011ee54c350f4c64c58e06472e687a1/laya/assets/poker/9.jpg -------------------------------------------------------------------------------- /laya/pages/enter.ui: -------------------------------------------------------------------------------- 1 | { 2 | "x":0, 3 | "type":"View", 4 | "selectedBox":1, 5 | "selecteID":7, 6 | "props":{"width":800,"sceneColor":"#6699cc","rotation":0,"height":600}, 7 | "nodeParent":-1, 8 | "label":"View", 9 | "isOpen":true, 10 | "isDirectory":true, 11 | "isAniNode":true, 12 | "hasChild":true, 13 | "compId":1, 14 | "child":[ 15 | { 16 | "x":15, 17 | "type":"Button", 18 | "props":{"y":234,"x":291,"width":191,"var":"enter","skin":"comp/button.png","scaleY":1,"scaleX":1,"pivotY":-1,"pivotX":3,"labelSize":28,"label":"开始匹配","height":75}, 19 | "nodeParent":1, 20 | "label":"Button(enter)", 21 | "isDirectory":false, 22 | "isAniNode":true, 23 | "hasChild":false, 24 | "compId":4, 25 | "child":[ 26 | ] 27 | }, 28 | { 29 | "x":15, 30 | "type":"Text", 31 | "props":{"y":255,"x":309,"width":164,"var":"isMatching","text":"正在匹配","height":63,"fontSize":36}, 32 | "nodeParent":1, 33 | "label":"Text(isMatching)", 34 | "isDirectory":false, 35 | "isAniNode":true, 36 | "hasChild":false, 37 | "compId":6, 38 | "child":[ 39 | ], 40 | "$HIDDEN":true 41 | }, 42 | { 43 | "x":15, 44 | "type":"Rect", 45 | "props":{"y":0,"x":0,"width":1200,"lineWidth":1,"height":805,"fillColor":"#56b8e7"}, 46 | "nodeParent":1, 47 | "label":"Rect", 48 | "isDirectory":false, 49 | "isAniNode":true, 50 | "hasChild":false, 51 | "compId":7, 52 | "child":[ 53 | ] 54 | }], 55 | "animations":[ 56 | { 57 | "nodes":[ 58 | ], 59 | "name":"ani1", 60 | "id":1, 61 | "frameRate":24, 62 | "action":0 63 | }] 64 | } -------------------------------------------------------------------------------- /src/Config/Common.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * name 3 | */ 4 | module Config{ 5 | export class Common{ 6 | static env = 'local'; 7 | } 8 | } -------------------------------------------------------------------------------- /src/Config/Local.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * name 3 | */ 4 | module Config{ 5 | export class Local{ 6 | static url = 'ws://localhost:8181'; 7 | } 8 | } -------------------------------------------------------------------------------- /src/Constants/MsgCode.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * name 3 | */ 4 | module Constants{ 5 | export class MsgCode{ 6 | public static SYSTEM_MSG = 1; 7 | public static REGISTER = 2; 8 | public static LOGIN = 3; 9 | public static MATCH_PLAYER = 4; 10 | public static PLAY_GAME = 5; 11 | public static ROOM_NOTIFY = 6; 12 | public static PLAYER_PLAYCARD = 7; 13 | public static PLAYER_WANTDIZHU = 8; 14 | public static ROOM_EXIT = 9; 15 | } 16 | } -------------------------------------------------------------------------------- /src/Constants/PokerType.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * name 3 | */ 4 | module Constants{ 5 | //牌型 6 | export class PokerType{ 7 | public static PASS_CARDS = -2; //过 8 | public static NO_CARDS = -1; //前面还没有牌(首家) 9 | public static ERROR_CARDS = 0; //错误牌型 10 | public static SINGLE_CARD = 1; //单牌 11 | public static DOUBLE_CARD = 2; //对子 12 | public static THREE_CARD = 3;//3不带 13 | public static THREE_ONE_CARD = 4;//3带1 14 | public static THREE_TWO_CARD = 5; //3带2 15 | public static BOMB_TWO_CARD = 6; //4带2 16 | public static STRAIGHT = 7; //连牌 17 | public static CONNECT_CARD = 8; //连对 18 | public static AIRCRAFT = 9; //飞机不带 19 | public static AIRCRAFT_CARD = 10; //飞机带单牌 20 | public static AIRCRAFT_WING = 11; //飞机带对子 21 | public static BOMB_CARD = 12; //炸弹 22 | public static KINGBOMB_CARD = 13;//王炸 23 | public static BOMB_FOUR_CARD = 14; // 4带2对 24 | public static BOMB_TWO_STRAIGHT_CARD = 15; // 连续4带2 25 | public static BOMB_FOUR_STRAIGHT_CARD = 16; // 连续4带2对 26 | } 27 | } -------------------------------------------------------------------------------- /src/Game/CardSet.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * name 3 | */ 4 | module Game{ 5 | export class CardSet{ 6 | /**牌型*/ 7 | public type:number = Constants.PokerType.NO_CARDS; 8 | /**头子(头子中最小的那张)*/ 9 | public header:number = 0; 10 | /**具体是哪些牌,用于展示在桌面上(index)*/ 11 | public cards:Array = []; 12 | } 13 | } -------------------------------------------------------------------------------- /src/Game/Game.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * name 3 | */ 4 | module Game{ 5 | export class Game{ 6 | public gameId:number; 7 | //环境变更 8 | public env:string; 9 | 10 | //进入视图 11 | public enterView: GameView.EnterView = null; 12 | 13 | //房间视图 14 | public roomView: GameView.RoomView = null; 15 | 16 | //游戏管理 17 | public room: Room = null; 18 | 19 | //对象管理 20 | public poolManage: PoolManage; 21 | 22 | //扑克逻辑处理 23 | public pokerLogic: PokerLogic = null; 24 | 25 | //socket管理 26 | public socketManager: Net.SocketManage; 27 | 28 | //消息处理 29 | public msgHandler: MessageHandler; 30 | 31 | constructor() 32 | { 33 | this.gameId = Math.round(Math.random() * 1000000); 34 | this.env = Config.Common.env; 35 | } 36 | 37 | public begin() 38 | { 39 | this.poolManage = new PoolManage(); 40 | this.msgHandler = new MessageHandler(); 41 | 42 | let config:any; 43 | switch (this.env) { 44 | case 'local': 45 | config = Config.Local; 46 | break; 47 | default: 48 | break; 49 | } 50 | this.socketManager = new Net.SocketManage(config.url); 51 | 52 | this.refreshToMatch(); 53 | } 54 | 55 | // 重新回到匹配页 56 | public refreshToMatch() 57 | { 58 | // 简单粗暴的把原来的全清了,重新来过 59 | if (this.enterView) { 60 | this.enterView.removeSelf(); 61 | this.enterView.destroy(); 62 | this.enterView = null; 63 | } 64 | 65 | if (this.roomView) { 66 | this.roomView.removeSelf(); 67 | this.roomView.destroy(); 68 | this.roomView = null; 69 | } 70 | 71 | if (this.room) { 72 | delete this.room; 73 | this.room = null; 74 | } 75 | 76 | if (this.pokerLogic) { 77 | delete this.pokerLogic; 78 | this.pokerLogic = null; 79 | } 80 | 81 | this.room = new Room(); 82 | this.pokerLogic = new PokerLogic(); 83 | 84 | this.enterView = new GameView.EnterView(); 85 | this.roomView = new GameView.RoomView(); 86 | Laya.stage.addChild(this.enterView); 87 | } 88 | 89 | //开始匹配 90 | public beginMatch() 91 | { 92 | let message = new Net.Message(); 93 | message.command = Constants.MsgCode.MATCH_PLAYER; 94 | message.content = { "name": this.gameId }; 95 | this.socketManager.sendData(message, this.msgHandler.matchCallback, this.msgHandler); 96 | this.enterView.isMatching.visible = true; 97 | this.enterView.enter.visible = false; 98 | } 99 | 100 | // 重新匹配 101 | public reMatch() 102 | { 103 | this.refreshToMatch(); 104 | this.beginMatch(); 105 | } 106 | } 107 | } 108 | let game:Game.Game; -------------------------------------------------------------------------------- /src/Game/MessageHandler.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * name 3 | */ 4 | module Game{ 5 | export class MessageHandler{ 6 | constructor(){ 7 | 8 | } 9 | 10 | public handle(data: any) 11 | { 12 | if (data.code == undefined || data.code == 0) { 13 | //根据不同的command进行处理 14 | switch (data.command) { 15 | case Constants.MsgCode.PLAY_GAME: //游戏中消息 16 | game.room.onPlayGame(data.content); 17 | break; 18 | case Constants.MsgCode.PLAYER_WANTDIZHU: //抢地主消息 19 | game.room.onWantDiZhu(data.content); 20 | break; 21 | case Constants.MsgCode.ROOM_EXIT: // 房间解散了 22 | game.room.onRoomExit(); 23 | break; 24 | default: 25 | break; 26 | } 27 | 28 | } else { //错误处理 29 | 30 | } 31 | } 32 | 33 | public matchCallback(message: Net.Message) 34 | { 35 | //console.log(message); 36 | //处理座位信息 37 | game.room.processSeat(message.content); 38 | //展示房间 39 | game.enterView.removeSelf(); 40 | Laya.stage.addChild(game.roomView); 41 | } 42 | } 43 | } -------------------------------------------------------------------------------- /src/Game/Poker.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * name 3 | */ 4 | module Game{ 5 | export class Poker extends Laya.Image{ 6 | //index序号 7 | protected _index:number; 8 | 9 | //点数 10 | public point:number; 11 | 12 | public isSelected:boolean = false; 13 | 14 | //图片 15 | public img:string = "doudizhu/bg_poker.png"; 16 | 17 | constructor(){ 18 | super(); 19 | this.width = 105; 20 | this.height = 150; 21 | } 22 | 23 | public recover() 24 | { 25 | this.off(Laya.Event.CLICK, this, this.switchStatus); 26 | this.img = "doudizhu/bg_poker.png"; 27 | } 28 | 29 | public switchStatus() 30 | { 31 | if (game.room.canSelect) { 32 | this.isSelected = ! this.isSelected; 33 | if (this.isSelected) { 34 | this.y = -20; 35 | } else { 36 | this.y = 0; 37 | } 38 | game.room.checkOutPokers(); 39 | } 40 | } 41 | 42 | public set index(value:number) 43 | { 44 | this._index = value; 45 | this.img = "poker/" + value + ".jpg"; 46 | if (value < 53) { 47 | if (value % 4 == 0) { 48 | this.point = value/4 + 2; 49 | } else { 50 | this.point = Math.floor(value/4) + 3; 51 | } 52 | } else { 53 | this.point = Math.floor(value/4) + 2 + value % 4; 54 | } 55 | } 56 | 57 | public get index() 58 | { 59 | return this._index; 60 | } 61 | } 62 | } -------------------------------------------------------------------------------- /src/Game/PokerLogic.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * name 3 | */ 4 | module Game{ 5 | export class PokerLogic{ 6 | constructor(){ 7 | 8 | } 9 | 10 | //是否可出 11 | public canOut(nowPokers:CardSet, myReadyPokers:CardSet) 12 | { 13 | //如果当前没有牌,只要牌型正确,就可以出 14 | if (nowPokers.type == Constants.PokerType.NO_CARDS && myReadyPokers.type != Constants.PokerType.ERROR_CARDS) { 15 | return true; 16 | } 17 | 18 | //炸弹 19 | if (myReadyPokers.type == Constants.PokerType.KINGBOMB_CARD) { //王炸,天下无敌 20 | return true; 21 | } else if (myReadyPokers.type == Constants.PokerType.BOMB_CARD) { 22 | if (nowPokers.type == Constants.PokerType.BOMB_CARD) { //前面也是炸弹,需要比较大小 23 | if (myReadyPokers.header > nowPokers.header) { 24 | return true; 25 | } 26 | } else { //炸了 27 | return true; 28 | } 29 | } else { 30 | if (myReadyPokers.cards.length == nowPokers.cards.length && myReadyPokers.type == nowPokers.type && myReadyPokers.header > nowPokers.header) { //同类型,张数相同,值更大 31 | return true; 32 | } 33 | } 34 | 35 | return false; 36 | } 37 | 38 | //计算牌型 39 | public calcuPokerType(cards: Array): number 40 | { 41 | //转换为点数 42 | let points = this.cardsToPoints(cards); 43 | 44 | return this.calcuPointsType(points); 45 | } 46 | 47 | 48 | public calcuPointsType(points):number 49 | { 50 | let len = points.length; 51 | 52 | if (len == 1) { //单牌 53 | return Constants.PokerType.SINGLE_CARD; 54 | } else if (len == 2) { 55 | if (points[0] == 16 && points[1] == 17) { //王炸 56 | return Constants.PokerType.KINGBOMB_CARD; 57 | } 58 | if (points[0] == points[1]) { //对子 59 | return Constants.PokerType.DOUBLE_CARD; 60 | } 61 | } else if (len == 3 && points[0] == points[1] && points[1] == points[2]) { //三不带 62 | return Constants.PokerType.THREE_CARD; 63 | } else if (len == 4) { 64 | if (points[0] == points[1] && points[1] == points[2] && points[2] == points[3]) { //炸弹 65 | return Constants.PokerType.BOMB_CARD; 66 | } else if (this.calcMaxSameNum(points) == 3) {//最多有三张相等的,说明是三带一 67 | return Constants.PokerType.THREE_ONE_CARD; 68 | } 69 | } else if (len >= 5 && this.isStraight(points) && points[len - 1] < 15) { //这里直接判断所有顺子,免得后面大于5的时候都去判断是否是顺子 70 | return Constants.PokerType.STRAIGHT; 71 | } else if (len == 5 && this.calcMaxSameNum(points) == 3 && this.calcDiffNum(points) == 2) {//最大相同数为3,有两种点数,说明是三带二 72 | return Constants.PokerType.THREE_TWO_CARD; 73 | } else if ( len >= 6) {//大于6的情况比较多,比如连对(n对),飞机(n飞,带或不带,3张飞还是4张飞 74 | let maxSameNum = this.calcMaxSameNum(points); 75 | let diffNum = this.calcDiffNum(points); 76 | if (len%3 == 0 && maxSameNum == 3 && diffNum == len/3 && (points[len - 1] - points[0] == len/3 - 1) && points[len - 1] < 15) { //三张牌飞机不带 77 | return Constants.PokerType.AIRCRAFT; 78 | } else if (len%2 == 0 && maxSameNum == 2 && diffNum == len/2 && (points[len - 1] - points[0] == len/2 - 1) && points[len - 1] < 15) { //连对 79 | return Constants.PokerType.CONNECT_CARD; 80 | } else if (len%4 == 0) { 81 | let threeCards = this.calcSameNumMaxStraightCards(points, 3); 82 | if (threeCards.length >= len/4 && threeCards[len/4 - 1] < 15) { //飞机三带一 83 | return Constants.PokerType.AIRCRAFT_CARD; 84 | } 85 | } 86 | if (len%5 == 0) { 87 | let threeCards = this.calcSameNumCards(points, 3); 88 | // 除了3张的之外,其他的都必须是成对,因此检查是否没有单张的出现即可 89 | let oneCards = this.calcSameNumCards(points, 1); 90 | 91 | if (threeCards.length == len/5 && this.isStraight(threeCards) && threeCards[threeCards.length - 1] < 15 && oneCards.length == 0) { //飞机三带二 92 | return Constants.PokerType.AIRCRAFT_WING; 93 | } 94 | } 95 | 96 | if (len == 6 && maxSameNum == 4 ) { //四带二 97 | return Constants.PokerType.BOMB_TWO_CARD; 98 | } else if (len == 8 && maxSameNum == 4) { // 四带两对 99 | let oneCards = this.calcSameNumCards(points, 1); 100 | let threeCards = this.calcSameNumCards(points, 3); 101 | 102 | // TODO: 33334444 这样的到底算连续三带一还是四带两对? 103 | if (oneCards.length == 0 && threeCards.length == 0) { 104 | return Constants.PokerType.BOMB_FOUR_CARD; 105 | } 106 | } 107 | 108 | if (len % 6 == 0) { 109 | let fourCards = this.calcSameNumMaxStraightCards(points, 4); 110 | if (fourCards.length >= len/6 && fourCards[len/6 - 1] < 15) { // 连续四带二 111 | return Constants.PokerType.BOMB_TWO_STRAIGHT_CARD; 112 | } 113 | } 114 | 115 | if (len % 8 == 0) { 116 | let fourCards = this.calcSameNumMaxStraightCards(points, 4); 117 | 118 | // 其他的都必须是成对,因此检查是否没有单张和三张的出现即可 119 | let oneCards = this.calcSameNumCards(points, 1); 120 | let threeCards = this.calcSameNumCards(points, 3); 121 | 122 | if (fourCards.length >= len/8 && oneCards.length == 0 && threeCards.length == 0 && fourCards[len/8 - 1] < 15) { // 连续四带两对 123 | return Constants.PokerType.BOMB_FOUR_STRAIGHT_CARD; 124 | } 125 | } 126 | } 127 | return Constants.PokerType.ERROR_CARDS; //错误牌型 128 | } 129 | 130 | //计算最大的牌 131 | public calcPokerHeader(cards: Array, type: number): number 132 | { 133 | let points = this.cardsToPoints(cards); 134 | return this.calcPointsHeader(points, type); 135 | } 136 | 137 | public calcPointsHeader(points: Array, type: number): number 138 | { 139 | let threeCards, fourCards; 140 | switch (type) { 141 | case Constants.PokerType.SINGLE_CARD: //单牌 142 | case Constants.PokerType.DOUBLE_CARD: //对子 143 | case Constants.PokerType.THREE_CARD: //三张 144 | case Constants.PokerType.STRAIGHT: //连牌 145 | case Constants.PokerType.CONNECT_CARD: //连对 146 | case Constants.PokerType.AIRCRAFT: //飞机不带 147 | case Constants.PokerType.BOMB_CARD: //炸弹 148 | return points[0]; 149 | case Constants.PokerType.THREE_ONE_CARD: //3带1 150 | case Constants.PokerType.THREE_TWO_CARD: //3带2 151 | case Constants.PokerType.BOMB_TWO_CARD: //4带2 152 | return points[2]; 153 | case Constants.PokerType.AIRCRAFT_CARD: //飞机带单牌 154 | threeCards = this.calcSameNumMaxStraightCards(points, 3); 155 | return threeCards[0]; 156 | case Constants.PokerType.AIRCRAFT_WING: //飞机带对子 157 | return this.calcFirstPoint(points, 3); 158 | case Constants.PokerType.BOMB_FOUR_CARD: //4带2对 159 | fourCards = this.calcSameNumCards(points, 4); 160 | return fourCards[fourCards.length - 1]; 161 | case Constants.PokerType.BOMB_TWO_STRAIGHT_CARD: // 连续4带2 162 | case Constants.PokerType.BOMB_FOUR_STRAIGHT_CARD: // 连续4带2对 163 | fourCards = this.calcSameNumMaxStraightCards(points, 4); 164 | return fourCards[0]; 165 | default: 166 | return 0; 167 | } 168 | } 169 | 170 | //最多有多少张点数相同的牌 171 | public calcMaxSameNum(points: Array): number 172 | { 173 | let maxNum = 1; 174 | let nowNum = 1; 175 | for (let i = 0; i < points.length - 1; i++) { 176 | if (points[i] == points[i+1]) { //与下一张相同,数量加1 177 | nowNum++; 178 | if (nowNum > maxNum) { 179 | maxNum = nowNum; 180 | } 181 | } else { //重新开始计算 182 | nowNum = 1; 183 | } 184 | } 185 | 186 | return maxNum; 187 | } 188 | 189 | //第一个出现N次的点数 190 | public calcFirstPoint(points: Array, num:number): number 191 | { 192 | let nowNum = 1; 193 | for (let i = 0; i < points.length - 1; i++) { 194 | if (points[i] == points[i+1]) { //与下一张相同,数量加1 195 | nowNum++; 196 | } else { //重新开始计算 197 | if (nowNum == num) { 198 | return points[i]; 199 | } 200 | nowNum = 1; 201 | } 202 | } 203 | 204 | if (nowNum == num) { 205 | return points[points.length - 1]; 206 | } 207 | 208 | return 0; 209 | } 210 | 211 | //取出所有满足条件的点数:该点数的数量等于N 212 | public calcSameNumCards(points: Array, num:number): Array 213 | { 214 | let cards = new Array(); 215 | 216 | let nowNum = 1; 217 | for (let i = 0; i < points.length - 1; i++) { 218 | if (points[i] == points[i+1]) { //与下一张相同,数量加1 219 | nowNum++; 220 | } else { //重新开始计算 221 | if (nowNum == num) { 222 | cards.push(points[i]); 223 | } 224 | nowNum = 1; 225 | } 226 | } 227 | 228 | if (nowNum == num) { 229 | cards.push(points[points.length - 1]); 230 | } 231 | 232 | return cards; 233 | } 234 | 235 | // 取出所有满足条件的点数:该点数的数量大于等于N 236 | // TODO: 与上面的calcSameNumCards合并 237 | public calcGeNumCards(points: Array, num:number): Array 238 | { 239 | let cards = new Array(); 240 | 241 | let nowNum = 1; 242 | for (let i = 0; i < points.length - 1; i++) { 243 | if (points[i] == points[i+1]) { //与下一张相同,数量加1 244 | nowNum++; 245 | } else { //重新开始计算 246 | if (nowNum >= num) { 247 | cards.push(points[i]); 248 | } 249 | nowNum = 1; 250 | } 251 | } 252 | 253 | if (nowNum >= num) { 254 | cards.push(points[points.length - 1]); 255 | } 256 | 257 | return cards; 258 | } 259 | 260 | // 取出所有满足条件的点数: 261 | // 从所有点数的数量等于N的列表中,取出最长连续递增子区间 262 | public calcSameNumMaxStraightCards(points: Array, num:number): Array 263 | { 264 | let geNumCards = this.calcGeNumCards(points, num); 265 | if (geNumCards.length == 0) { 266 | return []; 267 | } 268 | 269 | // 遍历找最长连续递增子区间 270 | let maxStartPoint:number = geNumCards[0]; 271 | let maxNum: number = 1; 272 | 273 | let nowStartPoint:number = geNumCards[0]; 274 | let nowNum: number = 1; 275 | 276 | for (let i = 1, len = geNumCards.length; i < len; i++) { 277 | if (geNumCards[i] == geNumCards[i-1] + 1) { // 比上一张多1 278 | nowNum++; 279 | } else { // 重新开始计算 280 | if (nowNum > maxNum) { 281 | maxNum = nowNum; 282 | maxStartPoint = nowStartPoint; 283 | } 284 | nowNum = 1; 285 | nowStartPoint = geNumCards[i]; 286 | } 287 | } 288 | 289 | if (nowNum > maxNum) { 290 | maxNum = nowNum; 291 | maxStartPoint = nowStartPoint; 292 | } 293 | 294 | let cards = new Array(); 295 | for (let i = 0; i < maxNum; i++) { 296 | cards.push(maxStartPoint + i); 297 | } 298 | 299 | return cards; 300 | } 301 | 302 | //有多少不同的点数 303 | public calcDiffNum(points: Array): number 304 | { 305 | let diffNum = 1; 306 | for (let i = 0; i < points.length - 1; i++) { 307 | if (points[i] != points[i+1]) { //与下一张不同,数量加1 308 | diffNum++; 309 | } 310 | } 311 | 312 | return diffNum; 313 | } 314 | 315 | //是否是顺子 316 | public isStraight(points: Array): boolean 317 | { 318 | for (let i = 0; i < points.length - 1; i++) { 319 | if (points[i+1] - points[i] != 1) { 320 | return false; 321 | } 322 | } 323 | return true; 324 | } 325 | 326 | //牌转点数 327 | public cardsToPoints(cards: Array): Array 328 | { 329 | let points = new Array(); 330 | let point = 0; 331 | cards.forEach((value, index, array) => { 332 | if (value < 53) { 333 | if (value % 4 == 0) { 334 | point = value/4 + 2; 335 | } else { 336 | point = Math.floor(value/4) + 3; 337 | } 338 | } else { 339 | point = Math.floor(value/4) + 2 + value % 4; 340 | } 341 | points.push(point); 342 | }); 343 | 344 | //从小到大,再排一下序 345 | points.sort(function(a, b){return a - b;}); 346 | 347 | return points; 348 | } 349 | } 350 | } -------------------------------------------------------------------------------- /src/Game/PoolManage.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * name 3 | */ 4 | module Game{ 5 | export class PoolManage{ 6 | constructor(){ 7 | 8 | } 9 | 10 | //获得到一个Poker对象 11 | public getPoker(): Poker 12 | { 13 | let poker = Laya.Pool.getItemByClass('poker', Poker); 14 | poker.recover(); 15 | 16 | return poker; 17 | } 18 | } 19 | } -------------------------------------------------------------------------------- /src/Game/Room.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * name 3 | */ 4 | module Game{ 5 | export class Room{ 6 | //房间号 7 | public roomId:number; 8 | 9 | //自己牌 10 | public myPokers: Array = []; 11 | 12 | //左边牌 13 | public leftPokers: Array = []; 14 | 15 | //右边牌 16 | public rightPokers: Array = []; 17 | 18 | //地主牌 19 | public dizhuPokers: Array = []; 20 | 21 | //当前打出展示的牌,自己,左,右 22 | public myOutPokers: Array = []; 23 | public leftOutPokers: Array = []; 24 | public rightOutPokers: Array = []; 25 | 26 | 27 | //自己信息 28 | public myInfo = {"seat":0, "name": "", "pass":0}; //座位,昵称,是否跳过 29 | 30 | //左右座位信息 31 | public leftInfo = {"seat":0, name: ""}; 32 | public rightInfo = {"seat":0, name: ""}; 33 | 34 | //当前出牌座位 35 | public nowSeat:number; 36 | 37 | //地主 38 | public dizhu:number; 39 | 40 | //当前桌面上牌,若重新一轮则为空 41 | public nowPokers:CardSet; 42 | 43 | //当前我选中的牌 44 | public myReadyPokers:CardSet; 45 | 46 | //是否可出 47 | public canSelect:boolean = false; 48 | 49 | public scoreList:Array = []; 50 | 51 | constructor() 52 | { 53 | this.myReadyPokers = new CardSet(); 54 | this.nowPokers = new CardSet(); 55 | for (let i = 0; i < 17; i++) { 56 | this.leftPokers.push(game.poolManage.getPoker()); 57 | this.rightPokers.push(game.poolManage.getPoker()); 58 | } 59 | } 60 | 61 | //收到游戏中消息 62 | public onPlayGame(content:any) 63 | { 64 | let state = content.state; 65 | switch (state) { 66 | case 0: //发牌了 67 | let tempCards = content.cards.sort(function(a,b){return b-a}); 68 | this.refreshMyPokers(tempCards); 69 | this.showAllPokers(); 70 | break; 71 | case 1: //游戏中,出牌信息 72 | this.nextOutProcess(content); 73 | break; 74 | case 2: //游戏结束,结算 75 | this.gameOver(content); 76 | break; 77 | default: 78 | break; 79 | } 80 | } 81 | 82 | //游戏结束处理 83 | public gameOver(content) 84 | { 85 | //设置数据 86 | let scores = content.scores; 87 | console.log(scores); 88 | let groups = [this.myInfo, this.leftInfo, this.rightInfo]; 89 | let txt = ''; 90 | this.scoreList = []; 91 | groups.forEach((info, index, array) => { 92 | //console.log(info.seat, scores[info.seat]); 93 | txt = (info.seat == this.dizhu ? '(地主) ' : '(农民) ' ) + info.seat + '号位 : ' + scores[info.seat]; 94 | this.scoreList.push(txt); 95 | }); 96 | 97 | game.roomView.scoreList.array = this.scoreList; 98 | game.roomView.scorePanel.visible = true; 99 | } 100 | 101 | public onRoomExit() 102 | { 103 | // 正常结束,房间内直接展示匹配按钮 104 | if (game.roomView.scorePanel.visible) { 105 | game.roomView.outOption.visible = false; 106 | game.roomView.enter.visible = true; 107 | } else { // 由于有人退出而结束,直接回到匹配页 108 | game.refreshToMatch(); 109 | } 110 | } 111 | 112 | //出牌信息处理 113 | public nextOutProcess(content:any): void 114 | { 115 | //当前出牌的座位 116 | let seat = content.curPlayerIndex; 117 | this.nowSeat = seat; 118 | 119 | this.showCouldAction(seat); 120 | //console.log(content.curCard); 121 | //上一轮出牌座位 122 | let lastSeat = seat - 1;; 123 | if (lastSeat == 0) { 124 | lastSeat = 3; 125 | } 126 | 127 | //当前出牌类型 128 | let cardType = content.curCard.type; 129 | switch (cardType) { 130 | case Constants.PokerType.NO_CARDS: //新一轮开始 131 | //清空当前牌 132 | this.removeAllOutPokers(); 133 | break; 134 | case Constants.PokerType.PASS_CARDS: //不要 135 | //清空当前出牌者的牌 136 | this.removeOutPokers(seat); 137 | //上轮出牌座位展示不要 138 | this.showPass(lastSeat); 139 | break; 140 | default: 141 | //清空当前出牌者的牌 142 | this.removeOutPokers(seat); 143 | //展示新牌 144 | this.showOutPokers(lastSeat, content.curCard); 145 | break; 146 | } 147 | 148 | //如果是我,展示出牌与不出牌框 149 | if (seat == this.myInfo.seat) { 150 | this.canSelect = true; 151 | game.roomView.outYes.visible = false; 152 | game.roomView.outNo.visible = (cardType != Constants.PokerType.NO_CARDS); 153 | } else { 154 | this.canSelect = false; 155 | game.roomView.outYes.visible = false; 156 | game.roomView.outNo.visible = false; 157 | } 158 | //TODO: 如果新一轮,只要选了牌,就可出,不允许不出 159 | //如果有其他的牌,选的牌类型相同,且值更大,则可出。允许不出 160 | } 161 | 162 | //出牌 163 | public giveOutAction() 164 | { 165 | if (game.pokerLogic.canOut(this.nowPokers, this.myReadyPokers)) { 166 | let data = new Net.Message(); 167 | data.command = Constants.MsgCode.PLAYER_PLAYCARD; 168 | data.content = { roomId:this.roomId, index:this.myInfo.seat, curCards:{type: this.myReadyPokers.type, header:this.myReadyPokers.header, cards:this.myReadyPokers.cards}}; 169 | game.socketManager.sendData(data, this.giveOutBack, this); 170 | } 171 | } 172 | 173 | public giveOutBack(data: Net.Message) 174 | { 175 | if(data.code == 0) { 176 | //已选择的牌从手牌中移除 177 | let newPokers = new Array(); 178 | this.myPokers.forEach((poker, index, array) => { 179 | if (poker.isSelected) { 180 | poker.removeSelf(); 181 | } else { 182 | newPokers.push(poker); 183 | } 184 | }); 185 | this.myPokers = newPokers; 186 | 187 | let i = 0; 188 | this.myPokers.forEach((poker, index, array) => { 189 | poker.x = (i++)*30; 190 | poker.y = 0; 191 | }); 192 | this.canSelect = false; 193 | 194 | //清除当前准备好的牌 195 | this.myReadyPokers.cards = []; 196 | this.myReadyPokers.type = Constants.PokerType.ERROR_CARDS; 197 | 198 | game.roomView.outYes.visible = false; 199 | game.roomView.outNo.visible = false; 200 | 201 | game.roomView.myPokerNum.text = '' + this.myPokers.length; 202 | } 203 | } 204 | 205 | //检查要出的牌 206 | public checkOutPokers() 207 | { 208 | //将选中的牌放入准备牌中 209 | this.myReadyPokers.cards = []; 210 | this.myPokers.forEach((poker, index, array) => { 211 | if (poker.isSelected) { 212 | this.myReadyPokers.cards.push(poker.index); 213 | } 214 | }); 215 | //计算牌型 216 | this.myReadyPokers.type = game.pokerLogic.calcuPokerType(this.myReadyPokers.cards); 217 | 218 | //计算牌头 219 | this.myReadyPokers.header = game.pokerLogic.calcPokerHeader(this.myReadyPokers.cards, this.myReadyPokers.type); 220 | 221 | //是否可出 222 | if (game.pokerLogic.canOut(this.nowPokers, this.myReadyPokers)) { 223 | game.roomView.outYes.visible = true; 224 | } else { 225 | game.roomView.outYes.visible = false; 226 | } 227 | } 228 | 229 | public passAction() 230 | { 231 | let data = new Net.Message(); 232 | data.command = Constants.MsgCode.PLAYER_PLAYCARD; 233 | data.content = { roomId:this.roomId, index:this.myInfo.seat, curCards:{ type:Constants.PokerType.PASS_CARDS, cards:[]}}; 234 | game.socketManager.sendData(data, this.passActionBack, this); 235 | } 236 | 237 | public passActionBack(data: Net.Message) 238 | { 239 | if(data.code == 0) { 240 | //还原已选择的牌 241 | this.myPokers.forEach((poker, index, array) => { 242 | poker.isSelected = false; 243 | poker.y = 0; 244 | }); 245 | this.canSelect = false; 246 | game.roomView.outYes.visible = false; 247 | game.roomView.outNo.visible = false; 248 | } 249 | } 250 | 251 | public showOutPokers(seat:number, cards:any) 252 | { 253 | /*this.nowPokers.cards = cards.cards; 254 | this.nowPokers.type = cards.type; 255 | this.nowPokers.header = cards.header;*/ 256 | this.nowPokers = cards; 257 | if (seat == this.myInfo.seat) { 258 | for (let i = 0; i < cards.cards.length; i++) { 259 | let poker = game.poolManage.getPoker(); 260 | poker.index = cards.cards[i]; 261 | this.myOutPokers.push(poker); 262 | poker.x = i*30; 263 | poker.y = 0; 264 | poker.skin = poker.img; 265 | game.roomView.myOutCard.addChild(poker); 266 | } 267 | //这里不用移除手牌,在出牌成功的时候自然会移除 268 | } else if (seat == this.leftInfo.seat) { 269 | for (let i = 0; i < cards.cards.length; i++) { 270 | let poker = game.poolManage.getPoker(); 271 | poker.index = cards.cards[i]; 272 | this.leftOutPokers.push(poker); 273 | poker.x = 0; 274 | poker.y = i*30; 275 | poker.skin = poker.img; 276 | game.roomView.leftOutCard.addChild(poker); 277 | } 278 | //将最后的几张手牌移除即可 279 | let len = this.leftPokers.length - 1; 280 | for (let i = 0; i < cards.cards.length; i++) { 281 | this.leftPokers[len - i].removeSelf(); 282 | } 283 | this.leftPokers.splice(this.leftPokers.length - cards.cards.length); 284 | game.roomView.leftPokerNum.text = '' + this.leftPokers.length; 285 | } else { 286 | for (let i = 0; i < cards.cards.length; i++) { 287 | let poker = game.poolManage.getPoker(); 288 | poker.index = cards.cards[i]; 289 | this.rightOutPokers.push(poker); 290 | poker.x = 0; 291 | poker.y = i * 30; 292 | poker.skin = poker.img; 293 | game.roomView.rightOutCard.addChild(poker); 294 | } 295 | let len = this.rightPokers.length - 1; 296 | for (let i = 0; i < cards.cards.length; i++) { 297 | this.rightPokers[len - i].removeSelf(); 298 | } 299 | this.rightPokers.splice(this.rightPokers.length - cards.cards.length); 300 | game.roomView.rightPokerNum.text = '' + this.rightPokers.length; 301 | } 302 | } 303 | 304 | public removeOutPokers(seat: number): void 305 | { 306 | let group = this.myOutPokers; 307 | if (seat == this.leftInfo.seat) { 308 | group = this.leftOutPokers; 309 | game.roomView.leftPass.visible = false; 310 | } else if (seat == this.rightInfo.seat) { 311 | group = this.rightOutPokers; 312 | game.roomView.rightPass.visible = false; 313 | } else { 314 | game.roomView.myPass.visible = false; 315 | } 316 | 317 | group.forEach((poker, index, array) => { 318 | poker.removeSelf(); 319 | }); 320 | group = []; 321 | } 322 | 323 | //清空当前牌 324 | public removeAllOutPokers() 325 | { 326 | this.nowPokers.cards = []; 327 | this.nowPokers.header = 0; 328 | this.nowPokers.type = Constants.PokerType.NO_CARDS; 329 | let groups = [this.myOutPokers, this.leftOutPokers, this.rightOutPokers]; 330 | groups.forEach((groupItem, groupIndex, groupArray) => { 331 | groupItem.forEach((poker, index, array) => { 332 | poker.removeSelf(); 333 | }); 334 | groupItem = []; 335 | }); 336 | game.roomView.myPass.visible = false; 337 | game.roomView.leftPass.visible = false; 338 | game.roomView.rightPass.visible = false; 339 | } 340 | 341 | //展示不要框 342 | public showPass(seat:number) 343 | { 344 | if (seat == this.myInfo.seat) { 345 | game.roomView.myPass.visible = true; 346 | } else if (seat == this.leftInfo.seat) { 347 | game.roomView.leftPass.visible = true; 348 | } else { 349 | game.roomView.rightPass.visible = true; 350 | } 351 | } 352 | 353 | //刷新牌 354 | protected refreshMyPokers(tempCards:Array) 355 | { 356 | this.myPokers = []; 357 | tempCards.forEach((value, index, array) => { 358 | let poker = game.poolManage.getPoker(); 359 | poker.index = value; 360 | this.myPokers.push(poker); 361 | }); 362 | } 363 | 364 | //展示所有的牌 365 | protected showAllPokers() 366 | { 367 | //一开始默认都是17张 368 | game.roomView.leftPokerNum.text = '17'; 369 | game.roomView.leftPokerNum.visible = true; 370 | game.roomView.rightPokerNum.text = '17'; 371 | game.roomView.rightPokerNum.visible = true; 372 | game.roomView.myPokerNum.text = '17'; 373 | game.roomView.myPokerNum.visible = true; 374 | 375 | let i = 0; 376 | this.myPokers.forEach((poker, index, array) => { 377 | poker.x = (i++)*30; 378 | poker.y = 0; 379 | poker.skin = poker.img; 380 | poker.on(Laya.Event.CLICK, poker, poker.switchStatus); 381 | game.roomView.myCard.addChild(poker); 382 | }); 383 | 384 | i = 0; 385 | this.leftPokers.forEach((poker, index, array) => { 386 | poker.x = 0; 387 | poker.y = (i++)*15; 388 | poker.skin = poker.img; 389 | game.roomView.leftCard.addChild(poker); 390 | }); 391 | 392 | i = 0; 393 | this.rightPokers.forEach((poker, index, array) => { 394 | poker.x = 0; 395 | poker.y = (i++)*15; 396 | poker.skin = poker.img; 397 | game.roomView.rightCard.addChild(poker); 398 | }); 399 | } 400 | 401 | //收到抢地主消息 402 | public onWantDiZhu(content:any):void 403 | { 404 | //有地主了,展示地主信息 405 | if (content.dizhu != undefined) { 406 | this.showDizhu(content.dizhu, content.dizhuCards); 407 | } else { 408 | //如果轮到自己,展示抢地主选项 409 | let seat = content.curPlayerIndex; 410 | let nowScore = content.nowScore; 411 | this.showCouldAction(seat); 412 | if (seat == this.myInfo.seat) { 413 | game.roomView.qiangdizhu.visible = true; 414 | //不抢始终显示 415 | game.roomView.giveup.visible = true; 416 | //显示比当前分大的按钮 417 | for (let i = 1; i <= 3; i++) { 418 | if (i <= nowScore) { 419 | game.roomView['score'+i].visible = false; 420 | } else { 421 | game.roomView['score'+i].visible = true; 422 | } 423 | } 424 | } else { 425 | game.roomView.qiangdizhu.visible = false; 426 | } 427 | } 428 | } 429 | 430 | //抢地主 431 | public wantDiZhu(score:number): void 432 | { 433 | let data = new Net.Message(); 434 | data.command = Constants.MsgCode.PLAYER_WANTDIZHU; 435 | data.content = { roomId:this.roomId, index:this.myInfo.seat, score:score}; 436 | game.socketManager.sendData(data, this.wantDizhuBack, this); 437 | } 438 | 439 | //抢地主回调 440 | public wantDizhuBack(data: Net.Message): void 441 | { 442 | if (data.code == 0) { 443 | game.roomView.qiangdizhu.visible = false; 444 | } 445 | } 446 | 447 | //不抢地主 448 | public passDiZhu(): void 449 | { 450 | let data = new Net.Message(); 451 | data.command = Constants.MsgCode.PLAYER_WANTDIZHU; 452 | data.content = { roomId:this.roomId, index:this.myInfo.seat, score:0}; 453 | game.socketManager.sendData(data, this.wantDizhuBack, this); 454 | } 455 | 456 | //展示行动信息 457 | public showCouldAction(seat:number):void 458 | { 459 | if (seat == this.myInfo.seat) { 460 | game.roomView.myAction.visible = true; 461 | game.roomView.leftAction.visible = false; 462 | game.roomView.rightAction.visible = false; 463 | } else if (seat == this.leftInfo.seat) { 464 | game.roomView.myAction.visible = false; 465 | game.roomView.leftAction.visible = true; 466 | game.roomView.rightAction.visible = false; 467 | } else { 468 | game.roomView.myAction.visible = false; 469 | game.roomView.leftAction.visible = false; 470 | game.roomView.rightAction.visible = true; 471 | } 472 | } 473 | 474 | //展示地主信息 475 | public showDizhu(dizhu:number, dizhuCards:Array):void 476 | { 477 | this.dizhu = dizhu; 478 | 479 | //地主牌 480 | let i = 0; 481 | dizhuCards.forEach((value, index, array) => { 482 | let poker = game.poolManage.getPoker(); 483 | poker.index = value; 484 | this.dizhuPokers.push(poker); 485 | poker.x = (i++)*105; 486 | poker.y = 0; 487 | poker.skin = poker.img; 488 | game.roomView.dizhuCards.addChild(poker); 489 | }); 490 | 491 | //地主图标 492 | game.roomView.dizhuhead.visible = true; 493 | if (dizhu == this.myInfo.seat) { 494 | game.roomView.dizhuhead.pos(478, 718); 495 | //加入手牌,并重新排序 496 | dizhuCards.forEach((value, index, array) => { 497 | let poker = game.poolManage.getPoker(); 498 | poker.index = value; 499 | this.myPokers.push(poker); 500 | poker.skin = poker.img; 501 | poker.on(Laya.Event.CLICK, poker, poker.switchStatus); 502 | game.roomView.myCard.addChild(poker); 503 | }); 504 | this.myPokers.sort(function(a,b){return b.index-a.index}); 505 | let i = 0; 506 | this.myPokers.forEach((poker, index, array) => { 507 | poker.x = (i++)*30; 508 | poker.y = 0; 509 | poker.zOrder = i; 510 | }); 511 | game.roomView.myPokerNum.text = '20'; 512 | } else if (dizhu == this.leftInfo.seat) { 513 | game.roomView.dizhuhead.pos(5, 300); 514 | //加入手牌展示即可 515 | let i = 17; 516 | dizhuCards.forEach((value, index, array) => { 517 | let poker = game.poolManage.getPoker(); 518 | this.leftPokers.push(poker); 519 | poker.x = 0; 520 | poker.y = (i++)*15; 521 | poker.skin = poker.img; 522 | game.roomView.leftCard.addChild(poker); 523 | }); 524 | game.roomView.leftPokerNum.text = '20'; 525 | } else { 526 | let i = 17; 527 | dizhuCards.forEach((value, index, array) => { 528 | let poker = game.poolManage.getPoker(); 529 | this.rightPokers.push(poker); 530 | poker.x = 0; 531 | poker.y = (i++)*15; 532 | poker.skin = poker.img; 533 | game.roomView.rightCard.addChild(poker); 534 | }); 535 | game.roomView.dizhuhead.pos(1130, 300); 536 | game.roomView.rightPokerNum.text = '20'; 537 | } 538 | } 539 | 540 | //处理座位 541 | public processSeat(content:any) 542 | { 543 | let players = content.players; 544 | this.roomId = content.roomId; 545 | for( let i = 0; i < players.length; i++) 546 | { 547 | if(game.gameId == players[i]) 548 | { 549 | this.myInfo.name = (i+1) + '号位:' + players[i]; 550 | this.myInfo.seat = i + 1; 551 | if(i == 2) 552 | { 553 | this.rightInfo.name = '1号位:' + players[0]; 554 | this.rightInfo.seat = 1; 555 | this.leftInfo.name = '2号位:' + players[1]; 556 | this.leftInfo.seat = 2; 557 | }else if(i == 0) 558 | { 559 | this.rightInfo.name = '2号位:' + players[1]; 560 | this.rightInfo.seat = 2; 561 | this.leftInfo.name = '3号位:' + players[2]; 562 | this.leftInfo.seat = 3; 563 | 564 | }else 565 | { 566 | this.rightInfo.name = '3号位:' + players[2]; 567 | this.rightInfo.seat = 3; 568 | this.leftInfo.name = '1号位:' + players[0]; 569 | this.leftInfo.seat = 1; 570 | } 571 | } 572 | } 573 | game.roomView.myName.text = this.myInfo.name; 574 | game.roomView.myName.visible = true; 575 | game.roomView.leftName.text = this.leftInfo.name; 576 | game.roomView.leftName.visible = true; 577 | game.roomView.rightName.text = this.rightInfo.name; 578 | game.roomView.rightName.visible = true; 579 | } 580 | } 581 | } -------------------------------------------------------------------------------- /src/GameMain.ts: -------------------------------------------------------------------------------- 1 | // 程序入口 2 | class GameMain{ 3 | constructor() 4 | { 5 | Laya.MiniAdpter.init(); 6 | Laya.init(1200, 800); 7 | this.initStage(); 8 | this.loadResource(); 9 | } 10 | 11 | //初始化stage 12 | private initStage(): void 13 | { 14 | Laya.stage.scaleMode = Laya.Stage.SCALE_SHOWALL; 15 | Laya.stage.screenMode = Laya.Stage.SCREEN_HORIZONTAL; 16 | Laya.stage.alignV = Laya.Stage.ALIGN_CENTER; 17 | Laya.stage.alignH = Laya.Stage.ALIGN_CENTER; 18 | Laya.stage.bgColor = "#6699cc"; 19 | } 20 | 21 | //加载资源 22 | private loadResource(): void 23 | { 24 | let uiResArry:Array = [ 25 | { url: "res/atlas/comp.atlas", type:Laya.Loader.ATLAS}, 26 | { url: "res/atlas/doudizhu.atlas", type: Laya.Loader.ATLAS }, 27 | { url: "res/atlas/poker.atlas", type: Laya.Loader.ATLAS } 28 | ]; 29 | Laya.loader.load(uiResArry, Laya.Handler.create(this, () => { 30 | game = new Game.Game(); 31 | game.begin(); 32 | })); 33 | } 34 | } 35 | new GameMain(); -------------------------------------------------------------------------------- /src/GameView/EnterView.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * name 3 | */ 4 | module GameView{ 5 | export class EnterView extends ui.enterUI{ 6 | constructor(){ 7 | super(); 8 | this.enter.on(Laya.Event.CLICK, game, game.beginMatch); 9 | this.isMatching.visible = false; 10 | this.enter.visible = true; 11 | } 12 | } 13 | } -------------------------------------------------------------------------------- /src/GameView/RoomView.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * name 3 | */ 4 | module GameView{ 5 | export class RoomView extends ui.backUI{ 6 | constructor(){ 7 | super(); 8 | this.score3.on(Laya.Event.CLICK, game.room, game.room.wantDiZhu, [3]); 9 | this.score2.on(Laya.Event.CLICK, game.room, game.room.wantDiZhu, [2]); 10 | this.score1.on(Laya.Event.CLICK, game.room, game.room.wantDiZhu, [1]); 11 | this.giveup.on(Laya.Event.CLICK, game.room, game.room.passDiZhu); 12 | this.outYes.on(Laya.Event.CLICK, game.room, game.room.giveOutAction); 13 | this.outNo.on(Laya.Event.CLICK, game.room, game.room.passAction); 14 | this.enter.on(Laya.Event.CLICK, game, game.reMatch); 15 | 16 | this.scoreList.renderHandler = new Laya.Handler(this,this.scoreRender); 17 | } 18 | 19 | public scoreRender(cell:Laya.Box,index:number):void 20 | { 21 | //如果索引不再可索引范围,则终止该函数 22 | if (index >= game.room.scoreList.length) { 23 | return; 24 | } 25 | 26 | let txt = game.room.scoreList[index]; 27 | let scoreItem:any = cell.getChildByName("scoreText"); 28 | scoreItem.text = txt; 29 | } 30 | } 31 | } -------------------------------------------------------------------------------- /src/Net/Message.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * name 3 | */ 4 | module Net{ 5 | export class Message{ 6 | public seq:number; //用于处理ack 7 | public code:number; //状态码 8 | public command:number; //消息码 9 | public content:any; //消息内容 10 | } 11 | } -------------------------------------------------------------------------------- /src/Net/SocketManage.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * name 3 | */ 4 | module Net{ 5 | import Socket = Laya.Socket; 6 | import Byte = Laya.Byte; 7 | export class SocketManage{ 8 | private socket: Socket; 9 | private output: Byte; 10 | private url: string; 11 | private sequence:number = 1; 12 | private callbackPool: Object = {}; 13 | 14 | constructor(url) { 15 | this.url = url; 16 | this.connect(); 17 | } 18 | 19 | private connect(): void { 20 | this.socket = new Socket(); 21 | 22 | this.socket.connectByUrl(this.url); 23 | 24 | this.socket.on(Laya.Event.OPEN, this, this.onSocketOpen); 25 | this.socket.on(Laya.Event.CLOSE, this, this.onSocketClose); 26 | this.socket.on(Laya.Event.MESSAGE, this, this.onMessageReveived); 27 | this.socket.on(Laya.Event.ERROR, this, this.onConnectError); 28 | } 29 | 30 | private onSocketOpen(): void { 31 | 32 | // 发送字符串 33 | this.socket.send(JSON.stringify({'opcode': 10001})); 34 | this.socket.flush(); 35 | } 36 | 37 | private onSocketClose(): void { 38 | //console.log("Socket closed"); 39 | } 40 | 41 | private onMessageReveived(message: any): void { 42 | //console.log("Message from server:"); 43 | if (typeof message == "string") { 44 | let data = JSON.parse(message); 45 | if (data.seq && this.callbackPool[data.seq]) { 46 | this.callbackPool[data.seq][0].call(this.callbackPool[data.seq][1], data); 47 | delete(this.callbackPool[data.seq]); 48 | } else { 49 | game.msgHandler.handle(data); 50 | } 51 | } 52 | 53 | this.socket.input.clear(); 54 | } 55 | 56 | private onConnectError(e: Event): void { 57 | //console.log("error"); 58 | } 59 | 60 | public sendData(data: Message, callback:Function|null, obj:any|null) 61 | { 62 | data.seq = this.sequence++; 63 | this.socket.send(JSON.stringify(data)); 64 | 65 | if (callback && obj) { 66 | this.callbackPool[data.seq] = [callback, obj]; 67 | } 68 | } 69 | } 70 | } -------------------------------------------------------------------------------- /src/ui/layaUI.max.all.ts: -------------------------------------------------------------------------------- 1 | 2 | import View=laya.ui.View; 3 | import Dialog=laya.ui.Dialog; 4 | module ui { 5 | export class backUI extends View { 6 | public leftCard:Laya.Box; 7 | public rightCard:Laya.Box; 8 | public myCard:Laya.Box; 9 | public leftOutCard:Laya.Box; 10 | public rightOutCard:Laya.Box; 11 | public myOutCard:Laya.Box; 12 | public outOption:Laya.Box; 13 | public outYes:Laya.Button; 14 | public outNo:Laya.Button; 15 | public leftAction:Laya.Box; 16 | public rightAction:Laya.Box; 17 | public myAction:Laya.Box; 18 | public leftName:laya.display.Text; 19 | public rightName:laya.display.Text; 20 | public myName:laya.display.Text; 21 | public dizhuhead:Laya.Image; 22 | public dizhuCards:Laya.Box; 23 | public qiangdizhu:Laya.Box; 24 | public score1:Laya.Button; 25 | public score2:Laya.Button; 26 | public score3:Laya.Button; 27 | public giveup:Laya.Button; 28 | public leftPass:laya.display.Text; 29 | public myPass:laya.display.Text; 30 | public rightPass:laya.display.Text; 31 | public scorePanel:Laya.Box; 32 | public scoreList:Laya.List; 33 | public leftPokerNum:laya.display.Text; 34 | public rightPokerNum:laya.display.Text; 35 | public myPokerNum:laya.display.Text; 36 | public enter:Laya.Button; 37 | 38 | public static uiView:any ={"type":"View","props":{"y":3,"width":1200,"left":-6,"height":800},"child":[{"type":"Box","props":{"y":100,"width":105,"visible":true,"var":"leftCard","left":77,"height":417},"child":[{"type":"Image","props":{"y":0,"x":0,"width":105,"visible":false,"skin":"doudizhu/bg_poker.png","height":150}}]},{"type":"Box","props":{"y":100,"width":105,"visible":true,"var":"rightCard","left":1014,"height":271},"child":[{"type":"Image","props":{"y":0,"x":0,"width":105,"visible":false,"skin":"doudizhu/bg_poker.png","height":150}}]},{"type":"Box","props":{"y":551,"width":688,"visible":true,"var":"myCard","left":315,"height":150},"child":[{"type":"Image","props":{"y":0,"x":0,"width":105,"visible":false,"skin":"doudizhu/bg_poker.png","height":150}}]},{"type":"Box","props":{"y":75,"x":251,"width":105,"visible":true,"var":"leftOutCard","height":387},"child":[{"type":"Image","props":{"width":105,"visible":false,"skin":"doudizhu/bg_poker.png","height":150}}]},{"type":"Box","props":{"y":75,"x":847,"width":105,"visible":true,"var":"rightOutCard","height":391},"child":[{"type":"Image","props":{"width":105,"visible":false,"skin":"doudizhu/bg_poker.png","height":150}}]},{"type":"Box","props":{"y":346,"width":465,"visible":true,"var":"myOutCard","left":383,"height":150},"child":[{"type":"Image","props":{"y":0,"x":0,"width":105,"visible":false,"skin":"doudizhu/bg_poker.png","height":150}}]},{"type":"Box","props":{"y":484,"x":482,"width":205,"visible":true,"var":"outOption","height":45},"child":[{"type":"Button","props":{"y":0,"x":0,"width":90,"visible":false,"var":"outYes","skin":"comp/button.png","labelSize":22,"label":"出牌","height":45}},{"type":"Button","props":{"y":0,"x":114,"width":90,"visible":false,"var":"outNo","skin":"comp/button.png","labelSize":22,"label":"不出","height":45}}]},{"type":"Box","props":{"y":20,"x":117,"width":18,"visible":false,"var":"leftAction","height":30},"child":[{"type":"Line","props":{"y":2.5,"x":9.5,"toY":25,"toX":0,"lineWidth":1,"lineColor":"#ff0000"}},{"type":"Lines","props":{"y":-21.5,"x":-32.5,"points":"36,41,42,51,47,41","lineWidth":1,"lineColor":"#ff0000"}}]},{"type":"Box","props":{"y":21,"x":1055,"width":18,"visible":false,"var":"rightAction","height":30},"child":[{"type":"Line","props":{"y":2.5,"x":9.5,"toY":25,"toX":0,"lineWidth":1,"lineColor":"#ff0000"}},{"type":"Lines","props":{"y":-21.5,"x":-32.5,"points":"36,41,42,51,47,41","lineWidth":1,"lineColor":"#ff0000"}}]},{"type":"Box","props":{"y":429,"x":578,"width":18,"visible":false,"var":"myAction","height":30},"child":[{"type":"Line","props":{"y":2.5,"x":9.5,"toY":25,"toX":0,"lineWidth":1,"lineColor":"#ff0000"}},{"type":"Lines","props":{"y":-21.5,"x":-32.5,"points":"36,41,42,51,47,41","lineWidth":1,"lineColor":"#ff0000"}}]},{"type":"Text","props":{"y":60,"x":79,"width":42,"var":"leftName","text":"text","height":34,"fontSize":24}},{"type":"Text","props":{"y":61,"x":1016,"width":42,"var":"rightName","text":"text","height":34,"fontSize":24}},{"type":"Text","props":{"y":714,"x":560,"width":42,"var":"myName","text":"text","height":34,"fontSize":24}},{"type":"Image","props":{"y":718,"x":478,"width":60,"visible":false,"var":"dizhuhead","skin":"doudizhu/dizhu.png","height":70}},{"type":"Box","props":{"y":19,"x":445,"width":315,"visible":true,"var":"dizhuCards","height":150},"child":[{"type":"Image","props":{"visible":false,"skin":"doudizhu/bg_poker.png"}}]},{"type":"Box","props":{"y":487,"x":380,"width":427,"visible":false,"var":"qiangdizhu","height":37},"child":[{"type":"Button","props":{"y":0,"x":0,"width":81,"var":"score1","skin":"comp/button.png","labelSize":20,"label":"一分","height":37}},{"type":"Button","props":{"y":0,"x":105,"width":81,"var":"score2","skin":"comp/button.png","labelSize":20,"label":"两分","height":37}},{"type":"Button","props":{"y":0,"x":210,"width":81,"var":"score3","skin":"comp/button.png","labelSize":20,"label":"三分","height":37}},{"type":"Button","props":{"y":0,"x":315,"width":81,"var":"giveup","skin":"comp/button.png","labelSize":20,"label":"不要","height":37}}]},{"type":"Text","props":{"y":290,"x":234,"width":54,"visible":false,"var":"leftPass","text":"打得","height":34,"fontSize":26,"color":"#1b1717","bold":true}},{"type":"Text","props":{"y":488,"x":557,"width":54,"visible":false,"var":"myPass","text":"打得","height":34,"fontSize":26,"color":"#060606","bold":true}},{"type":"Text","props":{"y":290,"x":926,"width":54,"visible":false,"var":"rightPass","text":"打得","height":34,"fontSize":26,"color":"#060606","bold":true}},{"type":"Box","props":{"y":79,"x":379,"visible":false,"var":"scorePanel","renderType":"render"},"child":[{"type":"Rect","props":{"width":427,"lineWidth":1,"height":283,"fillColor":"#d1e3d5"}},{"type":"List","props":{"y":58,"x":29,"width":379,"var":"scoreList","renderType":"render","height":190},"child":[{"type":"Box","props":{"y":-1,"x":9,"width":377,"renderType":"render","height":36},"child":[{"type":"Text","props":{"y":2,"x":9,"width":372,"text":"text","name":"scoreText","height":28,"fontSize":20,"color":"#000000"}}]}]},{"type":"Text","props":{"y":14,"x":157,"width":95,"text":"计分板","height":43,"fontSize":30,"color":"#342828","bold":true}}]},{"type":"Rect","props":{"y":-4,"x":0,"width":1200,"lineWidth":0,"height":804,"fillColor":"#78a4f1"}},{"type":"Text","props":{"y":120,"x":19,"width":43,"visible":false,"var":"leftPokerNum","text":"text","height":27,"fontSize":24,"color":"#000000"}},{"type":"Text","props":{"y":120,"x":1137,"visible":false,"var":"rightPokerNum","text":"text","height":27,"fontSize":24,"color":"#000000"}},{"type":"Text","props":{"y":714,"x":348,"width":43,"visible":false,"var":"myPokerNum","text":"text","height":27,"fontSize":24,"color":"#000000"}},{"type":"Button","props":{"y":398,"x":518,"width":191,"visible":false,"var":"enter","skin":"comp/button.png","scaleY":1,"scaleX":1,"pivotY":-1,"pivotX":3,"labelSize":28,"label":"重新匹配","height":75}}]}; 39 | constructor(){ super()} 40 | createChildren():void { 41 | View.regComponent("Text",laya.display.Text); 42 | 43 | super.createChildren(); 44 | this.createView(ui.backUI.uiView); 45 | 46 | } 47 | 48 | } 49 | } 50 | 51 | module ui { 52 | export class enterUI extends View { 53 | public enter:Laya.Button; 54 | public isMatching:laya.display.Text; 55 | 56 | public static uiView:any ={"type":"View","props":{"width":800,"rotation":0,"height":600},"child":[{"type":"Button","props":{"y":234,"x":291,"width":191,"var":"enter","skin":"comp/button.png","scaleY":1,"scaleX":1,"pivotY":-1,"pivotX":3,"labelSize":28,"label":"开始匹配","height":75}},{"type":"Text","props":{"y":255,"x":309,"width":164,"var":"isMatching","text":"正在匹配","height":63,"fontSize":36}},{"type":"Rect","props":{"y":0,"x":0,"width":1200,"lineWidth":1,"height":805,"fillColor":"#56b8e7"}}]}; 57 | constructor(){ super()} 58 | createChildren():void { 59 | View.regComponent("Text",laya.display.Text); 60 | 61 | super.createChildren(); 62 | this.createView(ui.enterUI.uiView); 63 | 64 | } 65 | 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "module": "commonjs", 4 | "target": "es5", 5 | "sourceMap": true 6 | }, 7 | "exclude": [ 8 | "node_modules" 9 | ] 10 | } --------------------------------------------------------------------------------