├── AirWar ├── .laya │ ├── launch.json │ └── tasks.json ├── AirWar.laya ├── bin │ ├── index.html │ ├── js │ │ ├── BackGround.js │ │ ├── BackGround.js.map │ │ ├── Game.js │ │ ├── Game.js.map │ │ ├── Role.js │ │ └── Role.js.map │ ├── libs │ │ ├── LayaRender.js │ │ ├── bytebuffer.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 │ │ ├── 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 │ │ ├── protobuf.js │ │ └── worker.js │ ├── res │ │ └── atlas │ │ │ ├── .rec │ │ │ ├── war.json │ │ │ └── war.png │ ├── unpack.json │ └── war │ │ └── background.png ├── laya │ ├── .laya │ └── assets │ │ └── war │ │ ├── background.png │ │ ├── enemy1_down1.png │ │ ├── enemy1_down2.png │ │ ├── enemy1_down3.png │ │ ├── enemy1_down4.png │ │ ├── enemy1_fly1.png │ │ ├── enemy2_down1.png │ │ ├── enemy2_down2.png │ │ ├── enemy2_down3.png │ │ ├── enemy2_down4.png │ │ ├── enemy2_fly1.png │ │ ├── enemy2_hit.png │ │ ├── enemy3_down1.png │ │ ├── enemy3_down2.png │ │ ├── enemy3_down3.png │ │ ├── enemy3_down4.png │ │ ├── enemy3_down5.png │ │ ├── enemy3_down6.png │ │ ├── enemy3_fly1.png │ │ ├── enemy3_fly2.png │ │ ├── enemy3_hit.png │ │ ├── hero_down1.png │ │ ├── hero_down2.png │ │ ├── hero_down3.png │ │ ├── hero_down4.png │ │ ├── hero_fly1.png │ │ └── hero_fly2.png ├── libs │ └── LayaAir.d.ts ├── src │ ├── BackGround.ts │ ├── Game.ts │ └── Role.ts └── tsconfig.json ├── LICENSE └── README.md /AirWar/.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 | "url": "${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": "${tmpdir}", 34 | "port":9222, 35 | "fixedPort":false 36 | } 37 | ] 38 | } -------------------------------------------------------------------------------- /AirWar/.laya/tasks.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "0.1.0", 3 | "command": "tsc", 4 | "isShellCommand": true, 5 | "args": [ 6 | "-p", 7 | ".", 8 | "--outDir", 9 | "bin/js" 10 | ], 11 | "showOutput": "silent", 12 | "problemMatcher": "$tsc" 13 | } -------------------------------------------------------------------------------- /AirWar/AirWar.laya: -------------------------------------------------------------------------------- 1 | {"proName":"AirWar","version":"1.7.10beta","proType":1} -------------------------------------------------------------------------------- /AirWar/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 | -------------------------------------------------------------------------------- /AirWar/bin/js/BackGround.js: -------------------------------------------------------------------------------- 1 | var __extends = (this && this.__extends) || (function () { 2 | var extendStatics = Object.setPrototypeOf || 3 | ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || 4 | function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; 5 | return function (d, b) { 6 | extendStatics(d, b); 7 | function __() { this.constructor = d; } 8 | d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); 9 | }; 10 | })(); 11 | /** 12 | * 循环滚动游戏背景 13 | */ 14 | var BackGround = /** @class */ (function (_super) { 15 | __extends(BackGround, _super); 16 | function BackGround() { 17 | var _this = _super.call(this) || this; 18 | _this.init(); 19 | return _this; 20 | } 21 | BackGround.prototype.init = function () { 22 | // 创建背景1 23 | this.bg1 = new Laya.Sprite(); 24 | // 加载资源路径 25 | this.bg1.loadImage("war/background.png"); 26 | // 背景图显示在容器内 27 | this.addChild(this.bg1); 28 | // 创建背景2 29 | this.bg2 = new Laya.Sprite(); 30 | this.bg2.loadImage("war/background.png"); 31 | // 更改背景2的位置 让它放在背景1的上面 32 | this.bg2.pos(0, -852); 33 | this.addChild(this.bg2); 34 | // 创建一个帧循环,更新容器的位置 35 | Laya.timer.frameLoop(1, this, this.animate); 36 | }; 37 | BackGround.prototype.animate = function () { 38 | // 背景容器每帧往下移动一像素 39 | this.y += 1; 40 | if (this.bg1.y + this.y >= 852) { 41 | this.bg1.y -= 852 * 2; 42 | } 43 | if (this.bg2.y + this.y >= 852) { 44 | this.bg2.y -= 852 * 2; 45 | } 46 | }; 47 | return BackGround; 48 | }(Laya.Sprite)); 49 | //# sourceMappingURL=BackGround.js.map -------------------------------------------------------------------------------- /AirWar/bin/js/BackGround.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"BackGround.js","sourceRoot":"","sources":["../../src/BackGround.ts"],"names":[],"mappings":";;;;;;;;;;AAAI;;GAEG;AACP;IAAyB,8BAAW;IAIhC;QAAA,YACI,iBAAO,SAEV;QADG,KAAI,CAAC,IAAI,EAAE,CAAC;;IAChB,CAAC;IACD,yBAAI,GAAJ;QACI,QAAQ;QACR,IAAI,CAAC,GAAG,GAAG,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC;QAC7B,SAAS;QACT,IAAI,CAAC,GAAG,CAAC,SAAS,CAAC,oBAAoB,CAAC,CAAC;QACzC,YAAY;QACZ,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QACxB,QAAQ;QACR,IAAI,CAAC,GAAG,GAAG,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC;QAC7B,IAAI,CAAC,GAAG,CAAC,SAAS,CAAC,oBAAoB,CAAC,CAAC;QACzC,sBAAsB;QACtB,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,EAAC,CAAC,GAAG,CAAC,CAAA;QACpB,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QACxB,kBAAkB;QAClB,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,EAAC,IAAI,EAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAC9C,CAAC;IACD,4BAAO,GAAP;QACI,gBAAgB;QAChB,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC;QACZ,EAAE,CAAA,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,IAAI,GAAG,CAAC,CAAA,CAAC;YAC3B,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,GAAG,GAAC,CAAC,CAAC;QACxB,CAAC;QACD,EAAE,CAAA,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,IAAI,GAAG,CAAC,CAAA,CAAC;YAC3B,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,GAAG,GAAC,CAAC,CAAC;QACxB,CAAC;IACL,CAAC;IAEL,iBAAC;AAAD,CAAC,AAnCD,CAAyB,IAAI,CAAC,MAAM,GAmCnC"} -------------------------------------------------------------------------------- /AirWar/bin/js/Game.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Game 程序入口类 3 | */ 4 | var Game = /** @class */ (function () { 5 | function Game() { 6 | // 敌机血量 敌机速度 敌机被击半径 7 | this.hps = [1, 2, 10]; 8 | this.speeds = [3, 2, 1]; 9 | this.radius = [15, 30, 70]; 10 | // 初始化引擎,这是游戏的宽高 11 | Laya.init(400, 852, Laya.WebGL); 12 | var bg = new BackGround(); 13 | Laya.stage.addChild(bg); 14 | Laya.loader.load("res/atlas/war.json", Laya.Handler.create(this, this.onLoaded), null, Laya.Loader.ATLAS); 15 | } 16 | Game.prototype.onLoaded = function () { 17 | this.hero = new Role(); 18 | this.hero.init("hero", 0, 1, 0, 30); 19 | this.hero.pos(200, 500); 20 | Laya.stage.addChild(this.hero); 21 | Laya.stage.on(Laya.Event.MOUSE_MOVE, this, this.onMouseMove); 22 | // 创建敌人 23 | //this.createEnemy(10); 24 | // 创建一个主循环 25 | Laya.timer.frameLoop(1, this, this.onLoop); 26 | }; 27 | Game.prototype.onLoop = function () { 28 | // 遍历舞台上所有的飞机,更改飞机的状态 29 | for (var i = Laya.stage.numChildren - 1; i > 0; i--) { 30 | var role = Laya.stage.getChildAt(i); 31 | if (role && role.speed) { 32 | // 根据飞机速度改变位置 33 | role.y += role.speed; 34 | // 敌机移动到显示区域外的话则移除掉 35 | if (role.y > 1000) { 36 | role.removeSelf(); 37 | Laya.Pool.recover("role", role); 38 | } 39 | } 40 | } 41 | // 每隔30帧创建新的敌机 42 | if (Laya.timer.currFrame % 60 === 0) { 43 | this.createEnemy(2); 44 | } 45 | }; 46 | Game.prototype.onMouseMove = function () { 47 | // 让飞机根据鼠标的位置来改变 48 | this.hero.pos(Laya.stage.mouseX, Laya.stage.mouseY); 49 | }; 50 | Game.prototype.createEnemy = function (num) { 51 | for (var i = 0; i < num; i++) { 52 | // 随机出现敌人的随机数 53 | var r = Math.random(); 54 | //根据随机数,随机敌人 55 | var type = r < 0.7 ? 0 : r < 0.95 ? 1 : 2; 56 | // 创建敌人 57 | var enemy = Laya.Pool.getItemByClass("role", Role); 58 | // 初始化敌人 59 | enemy.init('enemy' + (type + 1), 1, this.hps[type], this.speeds[type], this.radius[type]); 60 | // 随机位置 61 | enemy.pos(Math.random() * 400 + 40, Math.random() * 200); 62 | // 添加到舞台上 63 | Laya.stage.addChild(enemy); 64 | } 65 | }; 66 | return Game; 67 | }()); 68 | // 启动游戏 69 | new Game(); 70 | //# sourceMappingURL=Game.js.map -------------------------------------------------------------------------------- /AirWar/bin/js/Game.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"Game.js","sourceRoot":"","sources":["../../src/Game.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;IAEI;QA2CA,mBAAmB;QACX,QAAG,GAAkB,CAAC,CAAC,EAAC,CAAC,EAAC,EAAE,CAAC,CAAC;QAC9B,WAAM,GAAkB,CAAC,CAAC,EAAC,CAAC,EAAC,CAAC,CAAC,CAAC;QAChC,WAAM,GAAkB,CAAC,EAAE,EAAC,EAAE,EAAC,EAAE,CAAC,CAAC;QA7CvC,gBAAgB;QAChB,IAAI,CAAC,IAAI,CAAC,GAAG,EAAC,GAAG,EAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QAC9B,IAAI,EAAE,GAAc,IAAI,UAAU,EAAE,CAAC;QACrC,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;QACxB,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,oBAAoB,EAAC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,EAAC,IAAI,CAAC,QAAQ,CAAC,EAAC,IAAI,EAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IAC1G,CAAC;IACD,uBAAQ,GAAR;QACI,IAAI,CAAC,IAAI,GAAG,IAAI,IAAI,EAAE,CAAC;QACvB,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,EAAC,CAAC,EAAC,CAAC,EAAC,CAAC,EAAC,EAAE,CAAC,CAAC;QAChC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;QACxB,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC/B,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,UAAU,EAAC,IAAI,EAAC,IAAI,CAAC,WAAW,CAAC,CAAC;QAG3D,OAAO;QACP,uBAAuB;QACvB,UAAU;QACV,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,EAAC,IAAI,EAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IAC7C,CAAC;IACD,qBAAM,GAAN;QACI,qBAAqB;QACrB,GAAG,CAAA,CAAC,IAAI,CAAC,GAAU,IAAI,CAAC,KAAK,CAAC,WAAW,GAAC,CAAC,EAAE,CAAC,GAAC,CAAC,EAAE,CAAC,EAAE,EAAC,CAAC;YACnD,IAAI,IAAI,GAAQ,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,CAAS,CAAC;YACjD,EAAE,CAAA,CAAC,IAAI,IAAI,IAAI,CAAC,KAAK,CAAC,CAAA,CAAC;gBACnB,aAAa;gBACb,IAAI,CAAC,CAAC,IAAI,IAAI,CAAC,KAAK,CAAC;gBACrB,mBAAmB;gBACnB,EAAE,CAAA,CAAC,IAAI,CAAC,CAAC,GAAG,IAAI,CAAC,CAAA,CAAC;oBACd,IAAI,CAAC,UAAU,EAAE,CAAC;oBAClB,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,EAAC,IAAI,CAAC,CAAC;gBACnC,CAAC;YACL,CAAC;QACL,CAAC;QACD,cAAc;QACd,EAAE,CAAA,CAAC,IAAI,CAAC,KAAK,CAAC,SAAS,GAAC,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC;YAC/B,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC;QACxB,CAAC;IACL,CAAC;IACD,0BAAW,GAAX;QACI,gBAAgB;QAChB,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;IACxD,CAAC;IAKD,0BAAW,GAAX,UAAY,GAAU;QAClB,GAAG,CAAA,CAAC,IAAI,CAAC,GAAU,CAAC,EAAE,CAAC,GAAG,GAAG,EAAE,CAAC,EAAE,EAAC,CAAC;YAChC,aAAa;YACb,IAAI,CAAC,GAAU,IAAI,CAAC,MAAM,EAAE,CAAC;YAC7B,YAAY;YACZ,IAAI,IAAI,GAAW,CAAC,GAAG,GAAG,GAAC,CAAC,GAAC,CAAC,GAAC,IAAI,GAAC,CAAC,GAAC,CAAC,CAAC;YACxC,OAAO;YACP,IAAI,KAAK,GAAQ,IAAI,CAAC,IAAI,CAAC,cAAc,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;YACxD,QAAQ;YACR,KAAK,CAAC,IAAI,CAAC,OAAO,GAAC,CAAC,IAAI,GAAC,CAAC,CAAC,EAAC,CAAC,EAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,EAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,EAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC;YAClF,OAAO;YACP,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,MAAM,EAAE,GAAC,GAAG,GAAG,EAAE,EAAE,IAAI,CAAC,MAAM,EAAE,GAAC,GAAG,CAAC,CAAC;YACrD,SAAS;YACT,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;QAC/B,CAAC;IACL,CAAC;IACL,WAAC;AAAD,CAAC,AAjED,IAiEC;AAED,OAAO;AACP,IAAI,IAAI,EAAE,CAAC"} -------------------------------------------------------------------------------- /AirWar/bin/js/Role.js: -------------------------------------------------------------------------------- 1 | var __extends = (this && this.__extends) || (function () { 2 | var extendStatics = Object.setPrototypeOf || 3 | ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || 4 | function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; 5 | return function (d, b) { 6 | extendStatics(d, b); 7 | function __() { this.constructor = d; } 8 | d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); 9 | }; 10 | })(); 11 | /** 12 | * 角色类 13 | */ 14 | var Role = /** @class */ (function (_super) { 15 | __extends(Role, _super); 16 | function Role() { 17 | return _super.call(this) || this; 18 | // 初始化 19 | //this.init(); 20 | } 21 | Role.prototype.init = function (_type, _camp, _hp, _speed, _hitRadius) { 22 | this.type = _type; 23 | this.camp = _camp; 24 | this.hp = _hp; 25 | this.speed = _speed; 26 | this.hitRadius = _hitRadius; 27 | if (!Role.cached) { 28 | // 缓存飞行动画 29 | Laya.Animation.createFrames(["war/hero_fly1.png", "war/hero_fly2.png"], "hero_fly"); 30 | // 缓存击中爆炸动画 31 | Laya.Animation.createFrames(["war/hero_down1.png", "war/hero_down2.png", "war/hero_down3.png", "war/hero_down4.png"], "hero_down"); 32 | // 缓存敌机1飞行动画 33 | Laya.Animation.createFrames(["war/enemy1_fly1.png"], "enemy1_fly"); 34 | // 缓存敌机1爆炸动画 35 | Laya.Animation.createFrames(["war/enemy1_down1.png", "war/enemy1_down2.png", "war/enemy1_down3.png", "war/enemy1_down4.png"], "enemy1_down"); 36 | // 缓存敌机2飞行动画 37 | Laya.Animation.createFrames(["war/enemy2_fly1.png"], "enemy2_fly"); 38 | // 缓存敌机2爆炸动画 39 | Laya.Animation.createFrames(["war/enemy2_down1.png", "war/enemy2_down2.png", "war/enemy2_down3.png", "war/enemy2_down4.png"], "enemy2_down"); 40 | // 缓存敌机2碰撞动画 41 | Laya.Animation.createFrames(["war/enemy2_hit.png"], "enemy2_hit"); 42 | // 缓存敌机3飞行动画 43 | Laya.Animation.createFrames(["war/enemy3_fly1.png", "war/enemy3_fly2.png"], "enemy3_fly"); 44 | // 缓存敌机3爆炸动画 45 | Laya.Animation.createFrames(["war/enemy3_down1.png", "war/enemy3_down2.png", "war/enemy3_down3.png", "war/enemy3_down4.png", "war/enemy3_down5.png", "war/enemy3_down6.png"], "enemy3_down"); 46 | // 缓存敌机3碰撞动画 47 | Laya.Animation.createFrames(["war/enemy3_hit.png"], "enemy3_hit"); 48 | } 49 | if (!this.body) { 50 | // 创建飞机机身动画 51 | this.body = new Laya.Animation(); 52 | this.addChild(this.body); 53 | } 54 | // 播放飞机动画 55 | this.palyAction("fly"); 56 | }; 57 | Role.prototype.palyAction = function (action) { 58 | // 根据不同的动画类型类播放 59 | this.body.play(0, true, this.type + "_" + action); 60 | var bounds = this.body.getBounds(); 61 | // 设置机身居中 62 | this.body.pos(-bounds.width / 2, -bounds.height / 2); 63 | }; 64 | // 判断是否缓存了动画,只让动画缓存一次 65 | Role.cached = false; 66 | return Role; 67 | }(Laya.Sprite)); 68 | //# sourceMappingURL=Role.js.map -------------------------------------------------------------------------------- /AirWar/bin/js/Role.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"Role.js","sourceRoot":"","sources":["../../src/Role.ts"],"names":[],"mappings":";;;;;;;;;;AAAA;;GAEG;AACH;IAAmB,wBAAW;IAe1B;eACI,iBAAO;QACP,MAAM;QACN,cAAc;IAClB,CAAC;IACM,mBAAI,GAAX,UAAY,KAAa,EAAC,KAAY,EAAC,GAAU,EAAC,MAAa,EAAC,UAAiB;QAC7E,IAAI,CAAC,IAAI,GAAG,KAAK,CAAC;QAClB,IAAI,CAAC,IAAI,GAAG,KAAK,CAAC;QAClB,IAAI,CAAC,EAAE,GAAG,GAAG,CAAC;QACd,IAAI,CAAC,KAAK,GAAG,MAAM,CAAC;QACpB,IAAI,CAAC,SAAS,GAAG,UAAU,CAAC;QAC5B,EAAE,CAAA,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA,CAAC;YACb,SAAS;YACT,IAAI,CAAC,SAAS,CAAC,YAAY,CAAC,CAAC,mBAAmB,EAAC,mBAAmB,CAAC,EAAC,UAAU,CAAC,CAAC;YAClF,WAAW;YACX,IAAI,CAAC,SAAS,CAAC,YAAY,CAAC,CAAC,oBAAoB,EAAC,oBAAoB,EAAC,oBAAoB,EAAC,oBAAoB,CAAC,EAAC,WAAW,CAAC,CAAC;YAC/H,YAAY;YACZ,IAAI,CAAC,SAAS,CAAC,YAAY,CAAC,CAAC,qBAAqB,CAAC,EAAC,YAAY,CAAC,CAAC;YAClE,YAAY;YACZ,IAAI,CAAC,SAAS,CAAC,YAAY,CAAC,CAAC,sBAAsB,EAAC,sBAAsB,EAAC,sBAAsB,EAAC,sBAAsB,CAAC,EAAC,aAAa,CAAC,CAAC;YACzI,YAAY;YACZ,IAAI,CAAC,SAAS,CAAC,YAAY,CAAC,CAAC,qBAAqB,CAAC,EAAC,YAAY,CAAC,CAAC;YAClE,YAAY;YACZ,IAAI,CAAC,SAAS,CAAC,YAAY,CAAC,CAAC,sBAAsB,EAAC,sBAAsB,EAAC,sBAAsB,EAAC,sBAAsB,CAAC,EAAC,aAAa,CAAC,CAAC;YACzI,YAAY;YACZ,IAAI,CAAC,SAAS,CAAC,YAAY,CAAC,CAAC,oBAAoB,CAAC,EAAC,YAAY,CAAC,CAAC;YACjE,YAAY;YACZ,IAAI,CAAC,SAAS,CAAC,YAAY,CAAC,CAAC,qBAAqB,EAAC,qBAAqB,CAAC,EAAC,YAAY,CAAC,CAAC;YACxF,YAAY;YACZ,IAAI,CAAC,SAAS,CAAC,YAAY,CAAC,CAAC,sBAAsB,EAAC,sBAAsB,EAAC,sBAAsB,EAAC,sBAAsB,EAAC,sBAAsB,EAAC,sBAAsB,CAAC,EAAC,aAAa,CAAC,CAAC;YACvL,YAAY;YACZ,IAAI,CAAC,SAAS,CAAC,YAAY,CAAC,CAAC,oBAAoB,CAAC,EAAC,YAAY,CAAC,CAAC;QACrE,CAAC;QACD,EAAE,CAAA,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA,CAAC;YACX,WAAW;YACX,IAAI,CAAC,IAAI,GAAG,IAAI,IAAI,CAAC,SAAS,EAAE,CAAC;YACjC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC7B,CAAC;QACD,SAAS;QACT,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;IAC3B,CAAC;IACD,yBAAU,GAAV,UAAW,MAAa;QACpB,eAAe;QACf,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,GAAG,GAAG,GAAG,MAAM,CAAC,CAAC;QAClD,IAAI,MAAM,GAAmB,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,CAAC;QACnD,SAAS;QACT,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,KAAK,GAAG,CAAC,EAAG,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;IAC1D,CAAC;IA5DD,qBAAqB;IACN,WAAM,GAAY,KAAK,CAAC;IA4D3C,WAAC;CAAA,AA/DD,CAAmB,IAAI,CAAC,MAAM,GA+D7B"} -------------------------------------------------------------------------------- /AirWar/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 | })(); -------------------------------------------------------------------------------- /AirWar/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,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 | this._meshTerrainSprite3D=null; 14 | this._finder=null; 15 | this._setting=null; 16 | this.grid=null; 17 | PathFind.__super.call(this); 18 | } 19 | 20 | __class(PathFind,'laya.d3.component.PathFind',_super); 21 | var __proto=PathFind.prototype; 22 | /** 23 | *@private 24 | *初始化载入蒙皮动画组件。 25 | *@param owner 所属精灵对象。 26 | */ 27 | __proto._load=function(owner){ 28 | if (! (owner instanceof laya.d3.core.MeshTerrainSprite3D )) 29 | throw new Error("PathFinding: The owner must MeshTerrainSprite3D!"); 30 | _super.prototype._load.call(this,owner); 31 | this._meshTerrainSprite3D=owner; 32 | } 33 | 34 | /** 35 | *寻找路径。 36 | *@param startX 开始X。 37 | *@param startZ 开始Z。 38 | *@param endX 结束X。 39 | *@param endZ 结束Z。 40 | *@return 路径。 41 | */ 42 | __proto.findPath=function(startX,startZ,endX,endZ){ 43 | var minX=this._meshTerrainSprite3D.minX; 44 | var minZ=this._meshTerrainSprite3D.minZ; 45 | var cellX=this._meshTerrainSprite3D.width / this.grid.width; 46 | var cellZ=this._meshTerrainSprite3D.depth / this.grid.height; 47 | var halfCellX=cellX / 2; 48 | var halfCellZ=cellZ / 2; 49 | var gridStartX=Math.floor((startX-minX)/ cellX); 50 | var gridStartZ=Math.floor((startZ-minZ)/ cellZ); 51 | var gridEndX=Math.floor((endX-minX)/ cellX); 52 | var gridEndZ=Math.floor((endZ-minZ)/ cellZ); 53 | var boundWidth=this.grid.width-1; 54 | var boundHeight=this.grid.height-1; 55 | (gridStartX > boundWidth)&& (gridStartX=boundWidth); 56 | (gridStartZ > boundHeight)&& (gridStartZ=boundHeight); 57 | (gridStartX < 0)&& (gridStartX=0); 58 | (gridStartZ < 0)&& (gridStartZ=0); 59 | (gridEndX > boundWidth)&& (gridEndX=boundWidth); 60 | (gridEndZ > boundHeight)&& (gridEndZ=boundHeight); 61 | (gridEndX < 0)&& (gridEndX=0); 62 | (gridEndZ < 0)&& (gridEndZ=0); 63 | var path=this._finder.findPath(gridStartX,gridStartZ,gridEndX,gridEndZ,this.grid); 64 | this.grid.reset(); 65 | for (var i=1;i < path.length-1;i++){ 66 | var gridPos=path[i]; 67 | gridPos[0]=gridPos[0] *cellX+halfCellX+minX; 68 | gridPos[1]=gridPos[1] *cellZ+halfCellZ+minZ; 69 | } 70 | if (path.length==1){ 71 | path[0][0]=endX; 72 | path[0][1]=endX; 73 | }else if (path.length > 1){ 74 | path[0][0]=startX; 75 | path[0][1]=startZ; 76 | path[path.length-1][0]=endX; 77 | path[path.length-1][1]=endZ; 78 | } 79 | return path; 80 | } 81 | 82 | /** 83 | *设置寻路设置。 84 | *@param value 寻路设置。 85 | */ 86 | /** 87 | *获取寻路设置。 88 | *@return 寻路设置。 89 | */ 90 | __getset(0,__proto,'setting',function(){ 91 | return this._setting; 92 | },function(value){ 93 | (value)&& (this._finder=new PathFinding.finders.AStarFinder(value)); 94 | this._setting=value; 95 | }); 96 | 97 | return PathFind; 98 | })(Component3D) 99 | 100 | 101 | 102 | })(window,document,Laya); 103 | -------------------------------------------------------------------------------- /AirWar/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 | this.strength=NaN; 95 | this.strength_sig2_2sig2_gauss1=[]; 96 | BlurFilter.__super.call(this); 97 | (strength===void 0)&& (strength=4); 98 | if (Render.isWebGL)WebGLFilter.enable(); 99 | this.strength=strength; 100 | this._action=RunDriver.createFilterAction(0x10); 101 | this._action.data=this; 102 | } 103 | 104 | __class(BlurFilter,'laya.filters.BlurFilter',_super); 105 | var __proto=BlurFilter.prototype; 106 | /** 107 | *@private 通知微端 108 | */ 109 | __proto.callNative=function(sp){ 110 | sp.conchModel &&sp.conchModel.blurFilter&&sp.conchModel.blurFilter(this.strength); 111 | } 112 | 113 | /** 114 | *@private 115 | *当前滤镜对应的操作器 116 | */ 117 | __getset(0,__proto,'action',function(){ 118 | return this._action; 119 | }); 120 | 121 | /** 122 | *@private 123 | *当前滤镜的类型 124 | */ 125 | __getset(0,__proto,'type',function(){ 126 | return 0x10; 127 | }); 128 | 129 | return BlurFilter; 130 | })(Filter) 131 | 132 | 133 | /** 134 | *发光滤镜(也可以当成阴影滤使用) 135 | */ 136 | //class laya.filters.GlowFilter extends laya.filters.Filter 137 | var GlowFilter=(function(_super){ 138 | function GlowFilter(color,blur,offX,offY){ 139 | this._color=null; 140 | GlowFilter.__super.call(this); 141 | this._elements=new Float32Array(9); 142 | (blur===void 0)&& (blur=4); 143 | (offX===void 0)&& (offX=6); 144 | (offY===void 0)&& (offY=6); 145 | if (Render.isWebGL){ 146 | WebGLFilter.enable(); 147 | } 148 | this._color=new Color(color); 149 | this.blur=Math.min(blur,20); 150 | this.offX=offX; 151 | this.offY=offY; 152 | this._action=RunDriver.createFilterAction(0x08); 153 | this._action.data=this; 154 | } 155 | 156 | __class(GlowFilter,'laya.filters.GlowFilter',_super); 157 | var __proto=GlowFilter.prototype; 158 | /**@private */ 159 | __proto.getColor=function(){ 160 | return this._color._color; 161 | } 162 | 163 | /** 164 | *@private 通知微端 165 | */ 166 | __proto.callNative=function(sp){ 167 | sp.conchModel &&sp.conchModel.glowFilter&&sp.conchModel.glowFilter(this._color.strColor,this._elements[4],this._elements[5],this._elements[6]); 168 | } 169 | 170 | /** 171 | *@private 172 | *滤镜类型 173 | */ 174 | __getset(0,__proto,'type',function(){ 175 | return 0x08; 176 | }); 177 | 178 | /**@private */ 179 | __getset(0,__proto,'action',function(){ 180 | return this._action; 181 | }); 182 | 183 | /**@private */ 184 | /**@private */ 185 | __getset(0,__proto,'offY',function(){ 186 | return this._elements[6]; 187 | },function(value){ 188 | this._elements[6]=value; 189 | }); 190 | 191 | /**@private */ 192 | /**@private */ 193 | __getset(0,__proto,'offX',function(){ 194 | return this._elements[5]; 195 | },function(value){ 196 | this._elements[5]=value; 197 | }); 198 | 199 | /**@private */ 200 | /**@private */ 201 | __getset(0,__proto,'blur',function(){ 202 | return this._elements[4]; 203 | },function(value){ 204 | this._elements[4]=value; 205 | }); 206 | 207 | return GlowFilter; 208 | })(Filter) 209 | 210 | 211 | /** 212 | *@private 213 | */ 214 | //class laya.filters.webgl.BlurFilterActionGL extends laya.filters.webgl.FilterActionGL 215 | var BlurFilterActionGL=(function(_super){ 216 | function BlurFilterActionGL(){ 217 | this.data=null; 218 | BlurFilterActionGL.__super.call(this); 219 | } 220 | 221 | __class(BlurFilterActionGL,'laya.filters.webgl.BlurFilterActionGL',_super); 222 | var __proto=BlurFilterActionGL.prototype; 223 | __proto.setValueMix=function(shader){ 224 | shader.defines.add(this.data.type); 225 | var o=shader; 226 | } 227 | 228 | __proto.apply3d=function(scope,sprite,context,x,y){ 229 | var b=scope.getValue("bounds"); 230 | var shaderValue=Value2D.create(/*laya.webgl.shader.d2.ShaderDefines2D.TEXTURE2D*/0x01,0); 231 | shaderValue.setFilters([this.data]); 232 | var tMatrix=Matrix.EMPTY; 233 | tMatrix.identity(); 234 | context.ctx.drawTarget(scope,0,0,b.width,b.height,Matrix.EMPTY,"src",shaderValue); 235 | shaderValue.setFilters(null); 236 | } 237 | 238 | __proto.setValue=function(shader){ 239 | shader.strength=this.data.strength; 240 | var sigma=this.data.strength/3.0; 241 | var sigma2=sigma*sigma; 242 | this.data.strength_sig2_2sig2_gauss1[0]=this.data.strength; 243 | this.data.strength_sig2_2sig2_gauss1[1]=sigma2; 244 | this.data.strength_sig2_2sig2_gauss1[2]=2.0*sigma2; 245 | this.data.strength_sig2_2sig2_gauss1[3]=1.0/(2.0*Math.PI*sigma2); 246 | shader.strength_sig2_2sig2_gauss1=this.data.strength_sig2_2sig2_gauss1; 247 | } 248 | 249 | __getset(0,__proto,'typeMix',function(){return /*laya.filters.Filter.BLUR*/0x10;}); 250 | return BlurFilterActionGL; 251 | })(FilterActionGL) 252 | 253 | 254 | /** 255 | *@private 256 | */ 257 | //class laya.filters.webgl.GlowFilterActionGL extends laya.filters.webgl.FilterActionGL 258 | var GlowFilterActionGL=(function(_super){ 259 | function GlowFilterActionGL(){ 260 | this.data=null; 261 | this._initKey=false; 262 | this._textureWidth=0; 263 | this._textureHeight=0; 264 | GlowFilterActionGL.__super.call(this); 265 | } 266 | 267 | __class(GlowFilterActionGL,'laya.filters.webgl.GlowFilterActionGL',_super); 268 | var __proto=GlowFilterActionGL.prototype; 269 | Laya.imps(__proto,{"laya.filters.IFilterActionGL":true}) 270 | __proto.setValueMix=function(shader){} 271 | __proto.apply3d=function(scope,sprite,context,x,y){ 272 | var b=scope.getValue("bounds"); 273 | scope.addValue("color",this.data.getColor()); 274 | var w=b.width,h=b.height; 275 | this._textureWidth=w; 276 | this._textureHeight=h; 277 | var shaderValue; 278 | var mat=Matrix.TEMP; 279 | mat.identity(); 280 | shaderValue=Value2D.create(/*laya.webgl.shader.d2.ShaderDefines2D.TEXTURE2D*/0x01,0); 281 | shaderValue.setFilters([this.data]); 282 | context.ctx.drawTarget(scope,0,0,this._textureWidth,this._textureHeight,mat,"src",shaderValue,null); 283 | shaderValue=Value2D.create(/*laya.webgl.shader.d2.ShaderDefines2D.TEXTURE2D*/0x01,0); 284 | context.ctx.drawTarget(scope,0,0,this._textureWidth,this._textureHeight,mat,"src",shaderValue); 285 | return null; 286 | } 287 | 288 | __proto.setSpriteWH=function(sprite){ 289 | this._textureWidth=sprite.width; 290 | this._textureHeight=sprite.height; 291 | } 292 | 293 | __proto.setValue=function(shader){ 294 | shader.u_offsetX=this.data.offX; 295 | shader.u_offsetY=-this.data.offY; 296 | shader.u_strength=1.0; 297 | shader.u_blurX=this.data.blur; 298 | shader.u_blurY=this.data.blur; 299 | shader.u_textW=this._textureWidth; 300 | shader.u_textH=this._textureHeight; 301 | shader.u_color=this.data.getColor(); 302 | } 303 | 304 | __getset(0,__proto,'typeMix',function(){return /*laya.filters.Filter.GLOW*/0x08;}); 305 | GlowFilterActionGL.tmpTarget=function(scope,sprite,context,x,y){ 306 | var b=scope.getValue("bounds"); 307 | var out=scope.getValue("out"); 308 | out.end(); 309 | var tmpTarget=RenderTarget2D.create(b.width,b.height); 310 | tmpTarget.start(); 311 | var color=scope.getValue("color"); 312 | if (color){ 313 | tmpTarget.clear(color[0],color[1],color[2],0); 314 | } 315 | scope.addValue("tmpTarget",tmpTarget); 316 | } 317 | 318 | GlowFilterActionGL.startOut=function(scope,sprite,context,x,y){ 319 | var tmpTarget=scope.getValue("tmpTarget"); 320 | tmpTarget.end(); 321 | var out=scope.getValue("out"); 322 | out.start(); 323 | var color=scope.getValue("color"); 324 | if (color){ 325 | out.clear(color[0],color[1],color[2],0); 326 | } 327 | } 328 | 329 | GlowFilterActionGL.recycleTarget=function(scope,sprite,context,x,y){ 330 | var src=scope.getValue("src"); 331 | var tmpTarget=scope.getValue("tmpTarget"); 332 | tmpTarget.recycle(); 333 | } 334 | 335 | return GlowFilterActionGL; 336 | })(FilterActionGL) 337 | 338 | 339 | Laya.__init([WebGLFilter]); 340 | })(window,document,Laya); 341 | -------------------------------------------------------------------------------- /AirWar/bin/libs/laya.html.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,CSSStyle=laya.display.css.CSSStyle,ClassUtils=laya.utils.ClassUtils; 6 | var Event=laya.events.Event,HTMLChar=laya.utils.HTMLChar,Loader=laya.net.Loader,Node=laya.display.Node,Rectangle=laya.maths.Rectangle; 7 | var Render=laya.renders.Render,RenderContext=laya.renders.RenderContext,RenderSprite=laya.renders.RenderSprite; 8 | var Sprite=laya.display.Sprite,Stat=laya.utils.Stat,Texture=laya.resource.Texture,URL=laya.net.URL,Utils=laya.utils.Utils; 9 | /** 10 | *@private 11 | */ 12 | //class laya.html.utils.HTMLParse 13 | var HTMLParse=(function(){ 14 | function HTMLParse(){}; 15 | __class(HTMLParse,'laya.html.utils.HTMLParse'); 16 | HTMLParse.parse=function(ower,xmlString,url){ 17 | xmlString=xmlString.replace(/
/g,"
"); 18 | xmlString=""+xmlString+""; 19 | xmlString=xmlString.replace(HTMLParse.spacePattern,HTMLParse.char255); 20 | var xml=Utils.parseXMLFromString(xmlString); 21 | HTMLParse._parseXML(ower,xml.childNodes[0].childNodes,url); 22 | } 23 | 24 | HTMLParse._parseXML=function(parent,xml,url,href){ 25 | var i=0,n=0; 26 | if (xml.join || xml.item){ 27 | for (i=0,n=xml.length;i < n;++i){ 28 | HTMLParse._parseXML(parent,xml[i],url,href); 29 | } 30 | }else { 31 | var node; 32 | var nodeName; 33 | if (xml.nodeType==3){ 34 | var txt; 35 | if ((parent instanceof laya.html.dom.HTMLDivElement )){ 36 | if (xml.nodeName==null){ 37 | xml.nodeName="#text"; 38 | } 39 | nodeName=xml.nodeName.toLowerCase(); 40 | txt=xml.textContent.replace(/^\s+|\s+$/g,''); 41 | if (txt.length > 0){ 42 | node=ClassUtils.getInstance(nodeName); 43 | if (node){ 44 | parent.addChild(node); 45 | ((node).innerTEXT=txt.replace(HTMLParse.char255AndOneSpacePattern," ")); 46 | } 47 | } 48 | }else { 49 | txt=xml.textContent.replace(/^\s+|\s+$/g,''); 50 | if (txt.length > 0){ 51 | ((parent).innerTEXT=txt.replace(HTMLParse.char255AndOneSpacePattern," ")); 52 | } 53 | } 54 | return; 55 | }else { 56 | nodeName=xml.nodeName.toLowerCase(); 57 | if (nodeName=="#comment")return; 58 | node=ClassUtils.getInstance(nodeName); 59 | if (node){ 60 | node=parent.addChild(node); 61 | (node).URI=url; 62 | (node).href=href; 63 | var attributes=xml.attributes; 64 | if (attributes && attributes.length > 0){ 65 | for (i=0,n=attributes.length;i < n;++i){ 66 | var attribute=attributes[i]; 67 | var attrName=attribute.nodeName; 68 | var value=attribute.value; 69 | node._setAttributes(attrName,value); 70 | } 71 | } 72 | HTMLParse._parseXML(node,xml.childNodes,url,(node).href); 73 | }else { 74 | HTMLParse._parseXML(parent,xml.childNodes,url,href); 75 | } 76 | } 77 | } 78 | } 79 | 80 | HTMLParse.char255=String.fromCharCode(255); 81 | HTMLParse.spacePattern=/ | /g; 82 | HTMLParse.char255AndOneSpacePattern=new RegExp(String.fromCharCode(255)+"|(\\s+)","g"); 83 | return HTMLParse; 84 | })() 85 | 86 | 87 | /** 88 | *@private 89 | *HTML的布局类 90 | *对HTML的显示对象进行排版 91 | */ 92 | //class laya.html.utils.Layout 93 | var Layout=(function(){ 94 | function Layout(){}; 95 | __class(Layout,'laya.html.utils.Layout'); 96 | Layout.later=function(element){ 97 | if (Layout._will==null){ 98 | Layout._will=[]; 99 | Laya.stage.frameLoop(1,null,function(){ 100 | if (Layout._will.length < 1) 101 | return; 102 | for (var i=0;i < Layout._will.length;i++){ 103 | laya.html.utils.Layout.layout(Layout._will[i]); 104 | } 105 | Layout._will.length=0; 106 | }); 107 | } 108 | Layout._will.push(element); 109 | } 110 | 111 | Layout.layout=function(element){ 112 | if (!element || !element._style)return null; 113 | if ((element._style._type & /*laya.display.css.CSSStyle.ADDLAYOUTED*/0x200)===0) 114 | return null; 115 | element.getStyle()._type &=~ /*laya.display.css.CSSStyle.ADDLAYOUTED*/0x200; 116 | var arr=Layout._multiLineLayout(element); 117 | if (Render.isConchApp&&element["layaoutCallNative"]){ 118 | (element).layaoutCallNative(); 119 | } 120 | return arr; 121 | } 122 | 123 | Layout._multiLineLayout=function(element){ 124 | var elements=new Array; 125 | element._addChildsToLayout(elements); 126 | var i=0,n=elements.length,j=0; 127 | var style=element._getCSSStyle(); 128 | var letterSpacing=style.letterSpacing; 129 | var leading=style.leading; 130 | var lineHeight=style.lineHeight; 131 | var widthAuto=style._widthAuto()|| !style.wordWrap; 132 | var width=widthAuto ? 999999 :element.width; 133 | var height=element.height; 134 | var maxWidth=0; 135 | var exWidth=style.italic ? style.fontSize / 3 :0; 136 | var align=style._getAlign(); 137 | var valign=style._getValign(); 138 | var endAdjust=valign!==0 || align!==0 || lineHeight !=0; 139 | var oneLayout; 140 | var x=0; 141 | var y=0; 142 | var w=0; 143 | var h=0; 144 | var tBottom=0; 145 | var lines=new Array; 146 | var curStyle; 147 | var curPadding; 148 | var curLine=lines[0]=new LayoutLine(); 149 | var newLine=false,nextNewline=false; 150 | var htmlWord; 151 | var sprite; 152 | curLine.h=0; 153 | if (style.italic) 154 | width-=style.fontSize / 3; 155 | var tWordWidth=0; 156 | var tLineFirstKey=true; 157 | function addLine (){ 158 | curLine.y=y; 159 | y+=curLine.h+leading; 160 | if (curLine.h==0)y+=lineHeight; 161 | curLine.mWidth=tWordWidth; 162 | tWordWidth=0; 163 | curLine=new LayoutLine(); 164 | lines.push(curLine); 165 | curLine.h=0; 166 | x=0; 167 | tLineFirstKey=true; 168 | newLine=false; 169 | } 170 | for (i=0;i < n;i++){ 171 | oneLayout=elements[i]; 172 | if (oneLayout==null){ 173 | if (!tLineFirstKey){ 174 | x+=Layout.DIV_ELEMENT_PADDING; 175 | } 176 | curLine.wordStartIndex=curLine.elements.length; 177 | continue ; 178 | } 179 | tLineFirstKey=false; 180 | if ((oneLayout instanceof laya.html.dom.HTMLBrElement )){ 181 | addLine(); 182 | curLine.y=y; 183 | continue ; 184 | }else if (oneLayout._isChar()){ 185 | htmlWord=oneLayout; 186 | if (!htmlWord.isWord){ 187 | if (lines.length > 0 && (x+w)> width && curLine.wordStartIndex > 0){ 188 | var tLineWord=0; 189 | tLineWord=curLine.elements.length-curLine.wordStartIndex+1; 190 | curLine.elements.length=curLine.wordStartIndex; 191 | i-=tLineWord; 192 | addLine(); 193 | continue ; 194 | } 195 | newLine=false; 196 | tWordWidth+=htmlWord.width; 197 | }else { 198 | newLine=nextNewline || (htmlWord.char==='\n'); 199 | curLine.wordStartIndex=curLine.elements.length; 200 | } 201 | w=htmlWord.width+letterSpacing; 202 | h=htmlWord.height; 203 | nextNewline=false; 204 | newLine=newLine || ((x+w)> width); 205 | newLine && addLine(); 206 | curLine.minTextHeight=Math.min(curLine.minTextHeight,oneLayout.height); 207 | }else { 208 | curStyle=oneLayout._getCSSStyle(); 209 | sprite=oneLayout; 210 | curPadding=curStyle.padding; 211 | curStyle._getCssFloat()===0 || (endAdjust=true); 212 | newLine=nextNewline || curStyle.lineElement; 213 | w=sprite.width *sprite._style._tf.scaleX+curPadding[1]+curPadding[3]+letterSpacing; 214 | h=sprite.height *sprite._style._tf.scaleY+curPadding[0]+curPadding[2]; 215 | nextNewline=curStyle.lineElement; 216 | newLine=newLine || ((x+w)> width && curStyle.wordWrap); 217 | newLine && addLine(); 218 | } 219 | curLine.elements.push(oneLayout); 220 | curLine.h=Math.max(curLine.h,h); 221 | oneLayout.x=x; 222 | oneLayout.y=y; 223 | x+=w; 224 | curLine.w=x-letterSpacing; 225 | curLine.y=y; 226 | maxWidth=Math.max(x+exWidth,maxWidth); 227 | } 228 | y=curLine.y+curLine.h; 229 | if (endAdjust){ 230 | var tY=0; 231 | var tWidth=width; 232 | if (widthAuto && element.width > 0){ 233 | tWidth=element.width; 234 | } 235 | for (i=0,n=lines.length;i < n;i++){ 236 | lines[i].updatePos(0,tWidth,i,tY,align,valign,lineHeight); 237 | tY+=Math.max(lineHeight,lines[i].h+leading); 238 | } 239 | y=tY; 240 | } 241 | widthAuto && (element.width=maxWidth); 242 | (y > element.height)&& (element.height=y); 243 | return [maxWidth,y]; 244 | } 245 | 246 | Layout._will=null 247 | Layout.DIV_ELEMENT_PADDING=0; 248 | return Layout; 249 | })() 250 | 251 | 252 | /** 253 | *@private 254 | */ 255 | //class laya.html.utils.LayoutLine 256 | var LayoutLine=(function(){ 257 | function LayoutLine(){ 258 | this.x=0; 259 | this.y=0; 260 | this.w=0; 261 | this.h=0; 262 | this.wordStartIndex=0; 263 | this.minTextHeight=99999; 264 | this.mWidth=0; 265 | this.elements=new Array; 266 | } 267 | 268 | __class(LayoutLine,'laya.html.utils.LayoutLine'); 269 | var __proto=LayoutLine.prototype; 270 | /** 271 | *底对齐(默认) 272 | *@param left 273 | *@param width 274 | *@param dy 275 | *@param align 水平 276 | *@param valign 垂直 277 | *@param lineHeight 行高 278 | */ 279 | __proto.updatePos=function(left,width,lineNum,dy,align,valign,lineHeight){ 280 | var w=0; 281 | var one 282 | if (this.elements.length > 0){ 283 | one=this.elements[this.elements.length-1]; 284 | w=one.x+one.width-this.elements[0].x; 285 | }; 286 | var dx=0,ddy=NaN; 287 | align===/*laya.display.css.CSSStyle.ALIGN_CENTER*/1 && (dx=(width-w)/ 2); 288 | align===/*laya.display.css.CSSStyle.ALIGN_RIGHT*/2 && (dx=(width-w)); 289 | lineHeight===0 || valign !=0 || (valign=1); 290 | for (var i=0,n=this.elements.length;i < n;i++){ 291 | one=this.elements[i]; 292 | var tCSSStyle=one._getCSSStyle(); 293 | dx!==0 && (one.x+=dx); 294 | switch (tCSSStyle._getValign()){ 295 | case 0: 296 | one.y=dy; 297 | break ; 298 | case /*laya.display.css.CSSStyle.VALIGN_MIDDLE*/1:; 299 | var tMinTextHeight=0; 300 | if (this.minTextHeight !=99999){ 301 | tMinTextHeight=this.minTextHeight; 302 | }; 303 | var tBottomLineY=(tMinTextHeight+lineHeight)/ 2; 304 | tBottomLineY=Math.max(tBottomLineY,this.h); 305 | if ((one instanceof laya.html.dom.HTMLImageElement )){ 306 | ddy=dy+tBottomLineY-one.height; 307 | }else { 308 | ddy=dy+tBottomLineY-one.height; 309 | } 310 | one.y=ddy; 311 | break ; 312 | case /*laya.display.css.CSSStyle.VALIGN_BOTTOM*/2: 313 | one.y=dy+(lineHeight-one.height); 314 | break ; 315 | } 316 | } 317 | } 318 | 319 | return LayoutLine; 320 | })() 321 | 322 | 323 | /** 324 | *@private 325 | */ 326 | //class laya.html.dom.HTMLElement extends laya.display.Sprite 327 | var HTMLElement=(function(_super){ 328 | function HTMLElement(){ 329 | this.URI=null; 330 | this._href=null; 331 | HTMLElement.__super.call(this); 332 | this._text=HTMLElement._EMPTYTEXT; 333 | this.setStyle(new CSSStyle(this)); 334 | this._getCSSStyle().valign="middle"; 335 | this.mouseEnabled=true; 336 | } 337 | 338 | __class(HTMLElement,'laya.html.dom.HTMLElement',_super); 339 | var __proto=HTMLElement.prototype; 340 | /** 341 | *@private 342 | */ 343 | __proto.layaoutCallNative=function(){ 344 | var n=0; 345 | if (this._childs &&(n=this._childs.length)> 0){ 346 | for (var i=0;i < n;i++){ 347 | this._childs[i].layaoutCallNative && this._childs[i].layaoutCallNative(); 348 | } 349 | }; 350 | var word=this._getWords(); 351 | word&&HTMLElement.fillWords(this,word,0,0,this.style.font,this.style.color,this.style.underLine); 352 | } 353 | 354 | __proto.appendChild=function(c){ 355 | return this.addChild(c); 356 | } 357 | 358 | __proto._getWords=function(){ 359 | var txt=this._text.text; 360 | if (!txt || txt.length===0) 361 | return null; 362 | var words=this._text.words; 363 | if (words && words.length===txt.length) 364 | return words; 365 | words===null && (this._text.words=words=[]); 366 | words.length=txt.length; 367 | var size; 368 | var style=this.style; 369 | var fontStr=style.font; 370 | var startX=0; 371 | for (var i=0,n=txt.length;i < n;i++){ 372 | size=Utils.measureText(txt.charAt(i),fontStr); 373 | var tHTMLChar=words[i]=new HTMLChar(txt.charAt(i),size.width,size.height||style.fontSize,style); 374 | if (this.href){ 375 | var tSprite=new Sprite(); 376 | this.addChild(tSprite); 377 | tHTMLChar.setSprite(tSprite); 378 | } 379 | } 380 | return words; 381 | } 382 | 383 | __proto.showLinkSprite=function(){ 384 | var words=this._text.words; 385 | if (words){ 386 | var tLinkSpriteList=[]; 387 | var tSprite; 388 | var tHtmlChar; 389 | for (var i=0;i < words.length;i++){ 390 | tHtmlChar=words[i]; 391 | tSprite=new Sprite(); 392 | tSprite.graphics.drawRect(0,0,tHtmlChar.width,tHtmlChar.height,"#ff0000"); 393 | tSprite.width=tHtmlChar.width; 394 | tSprite.height=tHtmlChar.height; 395 | this.addChild(tSprite); 396 | tLinkSpriteList.push(tSprite); 397 | } 398 | } 399 | } 400 | 401 | __proto._layoutLater=function(){ 402 | var style=this.style; 403 | if ((style._type & /*laya.display.css.CSSStyle.ADDLAYOUTED*/0x200))return; 404 | if (style.widthed(this)&& (this._childs.length>0 || this._getWords()!=null)&& style.block){ 405 | Layout.later(this); 406 | style._type |=/*laya.display.css.CSSStyle.ADDLAYOUTED*/0x200; 407 | } 408 | else{ 409 | this.parent && (this.parent)._layoutLater(); 410 | } 411 | } 412 | 413 | __proto._setAttributes=function(name,value){ 414 | switch (name){ 415 | case 'style': 416 | this.style.cssText(value); 417 | return; 418 | case 'class': 419 | this.className=value; 420 | return; 421 | } 422 | _super.prototype._setAttributes.call(this,name,value); 423 | } 424 | 425 | __proto.updateHref=function(){ 426 | if (this._href !=null){ 427 | var words=this._getWords(); 428 | if (words){ 429 | var tHTMLChar; 430 | var tSprite; 431 | for (var i=0;i < words.length;i++){ 432 | tHTMLChar=words[i]; 433 | tSprite=tHTMLChar.getSprite(); 434 | if (tSprite){ 435 | tSprite.size(tHTMLChar.width,tHTMLChar.height); 436 | tSprite.on(/*laya.events.Event.CLICK*/"click",this,this.onLinkHandler); 437 | } 438 | } 439 | } 440 | } 441 | } 442 | 443 | __proto.onLinkHandler=function(e){ 444 | switch(e.type){ 445 | case /*laya.events.Event.CLICK*/"click":; 446 | var target=this; 447 | while (target){ 448 | target.event(/*laya.events.Event.LINK*/"link",[this.href]); 449 | target=target.parent; 450 | } 451 | break ; 452 | } 453 | } 454 | 455 | __proto.formatURL=function(url){ 456 | if (!this.URI)return url; 457 | return URL.formatURL(url,this.URI ? this.URI.path :null); 458 | } 459 | 460 | __getset(0,__proto,'href',function(){ 461 | return this._href; 462 | },function(url){ 463 | this._href=url; 464 | if (url !=null){ 465 | this._getCSSStyle().underLine=1; 466 | this.updateHref(); 467 | } 468 | }); 469 | 470 | __getset(0,__proto,'color',null,function(value){ 471 | this.style.color=value; 472 | }); 473 | 474 | __getset(0,__proto,'onClick',null,function(value){ 475 | var fn; 476 | /*__JS__ */eval("fn=function(event){"+value+";}"); 477 | this.on(/*laya.events.Event.CLICK*/"click",this,fn); 478 | }); 479 | 480 | __getset(0,__proto,'id',null,function(value){ 481 | HTMLDocument.document.setElementById(value,this); 482 | }); 483 | 484 | __getset(0,__proto,'innerTEXT',function(){ 485 | return this._text.text; 486 | },function(value){ 487 | this.text=value; 488 | }); 489 | 490 | __getset(0,__proto,'style',function(){ 491 | return this._style; 492 | }); 493 | 494 | __getset(0,__proto,'text',function(){ 495 | return this._text.text; 496 | },function(value){ 497 | if (this._text==HTMLElement._EMPTYTEXT){ 498 | this._text={text:value,words:null}; 499 | } 500 | else{ 501 | this._text.text=value; 502 | this._text.words && (this._text.words.length=0); 503 | } 504 | this._renderType |=/*laya.renders.RenderSprite.CHILDS*/0x800; 505 | this.repaint(); 506 | this.updateHref(); 507 | }); 508 | 509 | __getset(0,__proto,'parent',_super.prototype._$get_parent,function(value){ 510 | if ((value instanceof laya.html.dom.HTMLElement )){ 511 | var p=value; 512 | this.URI || (this.URI=p.URI); 513 | this.style.inherit(p.style); 514 | } 515 | _super.prototype._$set_parent.call(this,value); 516 | }); 517 | 518 | __getset(0,__proto,'className',null,function(value){ 519 | this.style.attrs(HTMLDocument.document.styleSheets['.'+value]); 520 | }); 521 | 522 | HTMLElement.fillWords=function(ele,words,x,y,font,color,underLine){ 523 | ele.graphics.clear(); 524 | for (var i=0,n=words.length;i < n;i++){ 525 | var a=words[i]; 526 | ele.graphics.fillText(a.char,a.x+x,a.y+y,font,color,'left',underLine); 527 | } 528 | } 529 | 530 | HTMLElement._EMPTYTEXT={text:null,words:null}; 531 | return HTMLElement; 532 | })(Sprite) 533 | 534 | 535 | /** 536 | *@private 537 | */ 538 | //class laya.html.dom.HTMLBrElement extends laya.html.dom.HTMLElement 539 | var HTMLBrElement=(function(_super){ 540 | function HTMLBrElement(){ 541 | HTMLBrElement.__super.call(this); 542 | this.style.lineElement=true; 543 | this.style.block=true; 544 | } 545 | 546 | __class(HTMLBrElement,'laya.html.dom.HTMLBrElement',_super); 547 | return HTMLBrElement; 548 | })(HTMLElement) 549 | 550 | 551 | /** 552 | *DIV标签 553 | */ 554 | //class laya.html.dom.HTMLDivElement extends laya.html.dom.HTMLElement 555 | var HTMLDivElement=(function(_super){ 556 | function HTMLDivElement(){ 557 | this.contextHeight=NaN; 558 | this.contextWidth=NaN; 559 | HTMLDivElement.__super.call(this); 560 | this.style.block=true; 561 | this.style.lineElement=true; 562 | this.style.width=200; 563 | this.style.height=200; 564 | HTMLStyleElement; 565 | } 566 | 567 | __class(HTMLDivElement,'laya.html.dom.HTMLDivElement',_super); 568 | var __proto=HTMLDivElement.prototype; 569 | /** 570 | *追加内容,解析并对显示对象排版 571 | *@param text 572 | */ 573 | __proto.appendHTML=function(text){ 574 | HTMLParse.parse(this,text,this.URI); 575 | this.layout(); 576 | } 577 | 578 | /** 579 | *@private 580 | *@param out 581 | *@return 582 | */ 583 | __proto._addChildsToLayout=function(out){ 584 | var words=this._getWords(); 585 | if (words==null && this._childs.length==0)return false; 586 | words && words.forEach(function(o){ 587 | out.push(o); 588 | }); 589 | var tFirstKey=true; 590 | for (var i=0,len=this._childs.length;i < len;i++){ 591 | var o=this._childs[i]; 592 | if (tFirstKey){ 593 | tFirstKey=false; 594 | }else { 595 | out.push(null); 596 | } 597 | o._addToLayout(out) 598 | } 599 | return true; 600 | } 601 | 602 | /** 603 | *@private 604 | *@param out 605 | */ 606 | __proto._addToLayout=function(out){ 607 | this.layout(); 608 | } 609 | 610 | /** 611 | *@private 612 | *对显示内容进行排版 613 | */ 614 | __proto.layout=function(){ 615 | this.style._type |=/*laya.display.css.CSSStyle.ADDLAYOUTED*/0x200; 616 | var tArray=Layout.layout(this); 617 | if (tArray){ 618 | if (!this._$P.mHtmlBounds)this._set$P("mHtmlBounds",new Rectangle()); 619 | var tRectangle=this._$P.mHtmlBounds; 620 | tRectangle.x=tRectangle.y=0; 621 | tRectangle.width=this.contextWidth=tArray[0]; 622 | tRectangle.height=this.contextHeight=tArray[1]; 623 | this.setBounds(tRectangle); 624 | } 625 | } 626 | 627 | /** 628 | *获取对象的高 629 | */ 630 | __getset(0,__proto,'height',function(){ 631 | if (this._height)return this._height; 632 | return this.contextHeight; 633 | },_super.prototype._$set_height); 634 | 635 | /** 636 | *设置标签内容 637 | */ 638 | __getset(0,__proto,'innerHTML',null,function(text){ 639 | this.destroyChildren(); 640 | this.appendHTML(text); 641 | }); 642 | 643 | /** 644 | *获取对象的宽 645 | */ 646 | __getset(0,__proto,'width',function(){ 647 | if (this._width)return this._width; 648 | return this.contextWidth; 649 | },function(value){ 650 | var changed=false; 651 | if (value===0){ 652 | changed=value !=this._width; 653 | }else{ 654 | changed=value !=this.width; 655 | } 656 | _super.prototype._$set_width.call(this,value); 657 | if(changed) 658 | this.layout(); 659 | }); 660 | 661 | return HTMLDivElement; 662 | })(HTMLElement) 663 | 664 | 665 | /** 666 | *@private 667 | */ 668 | //class laya.html.dom.HTMLDocument extends laya.html.dom.HTMLElement 669 | var HTMLDocument=(function(_super){ 670 | function HTMLDocument(){ 671 | this.all=new Array; 672 | this.styleSheets=CSSStyle.styleSheets; 673 | HTMLDocument.__super.call(this); 674 | } 675 | 676 | __class(HTMLDocument,'laya.html.dom.HTMLDocument',_super); 677 | var __proto=HTMLDocument.prototype; 678 | __proto.getElementById=function(id){ 679 | return this.all[id]; 680 | } 681 | 682 | __proto.setElementById=function(id,e){ 683 | this.all[id]=e; 684 | } 685 | 686 | __static(HTMLDocument, 687 | ['document',function(){return this.document=new HTMLDocument();} 688 | ]); 689 | return HTMLDocument; 690 | })(HTMLElement) 691 | 692 | 693 | /** 694 | *@private 695 | */ 696 | //class laya.html.dom.HTMLImageElement extends laya.html.dom.HTMLElement 697 | var HTMLImageElement=(function(_super){ 698 | function HTMLImageElement(){ 699 | this._tex=null; 700 | this._url=null; 701 | this._renderArgs=[]; 702 | HTMLImageElement.__super.call(this); 703 | this.style.block=true; 704 | } 705 | 706 | __class(HTMLImageElement,'laya.html.dom.HTMLImageElement',_super); 707 | var __proto=HTMLImageElement.prototype; 708 | __proto._addToLayout=function(out){ 709 | !this._style.absolute && out.push(this); 710 | } 711 | 712 | __proto.render=function(context,x,y){ 713 | if (!this._tex || !this._tex.loaded || !this._tex.loaded || this._width < 1 || this._height < 1)return; 714 | Stat.spriteCount++; 715 | this._renderArgs[0]=this._tex; 716 | this._renderArgs[1]=this.x; 717 | this._renderArgs[2]=this.y; 718 | this._renderArgs[3]=this.width || this._tex.width; 719 | this._renderArgs[4]=this.height || this._tex.height; 720 | context.ctx.drawTexture2(x,y,this.style.translateX,this.style.translateY,this.transform,this.style.alpha,this.style.blendMode,this._renderArgs); 721 | } 722 | 723 | __getset(0,__proto,'src',null,function(url){ 724 | var _$this=this; 725 | url=this.formatURL(url); 726 | if (this._url==url)return; 727 | this._url=url; 728 | var tex=this._tex=Loader.getRes(url); 729 | if (!tex){ 730 | this._tex=tex=new Texture(); 731 | tex.load(url); 732 | Loader.cacheRes(url,tex); 733 | } 734 | function onloaded (){ 735 | var style=_$this._style; 736 | var w=style.widthed(_$this)?-1:_$this._tex.width; 737 | var h=style.heighted(_$this)?-1:_$this._tex.height; 738 | if (!style.widthed(_$this)&& _$this._width !=_$this._tex.width){ 739 | _$this.width=_$this._tex.width; 740 | _$this.parent && (_$this.parent)._layoutLater(); 741 | } 742 | if (!style.heighted(_$this)&& _$this._height !=_$this._tex.height){ 743 | _$this.height=_$this._tex.height; 744 | _$this.parent && (_$this.parent)._layoutLater(); 745 | } 746 | if (Render.isConchApp){ 747 | _$this._renderArgs[0]=_$this._tex; 748 | _$this._renderArgs[1]=_$this.x; 749 | _$this._renderArgs[2]=_$this.y; 750 | _$this._renderArgs[3]=_$this.width || _$this._tex.width; 751 | _$this._renderArgs[4]=_$this.height || _$this._tex.height; 752 | _$this.graphics.drawTexture(_$this._tex,0,0,_$this._renderArgs[3],_$this._renderArgs[4]); 753 | } 754 | _$this.repaint(); 755 | _$this.parentRepaint(); 756 | } 757 | tex.loaded?onloaded():tex.on(/*laya.events.Event.LOADED*/"loaded",null,onloaded); 758 | }); 759 | 760 | return HTMLImageElement; 761 | })(HTMLElement) 762 | 763 | 764 | /** 765 | *@private 766 | */ 767 | //class laya.html.dom.HTMLLinkElement extends laya.html.dom.HTMLElement 768 | var HTMLLinkElement=(function(_super){ 769 | function HTMLLinkElement(){ 770 | this.type=null; 771 | HTMLLinkElement.__super.call(this); 772 | this.visible=false; 773 | } 774 | 775 | __class(HTMLLinkElement,'laya.html.dom.HTMLLinkElement',_super); 776 | var __proto=HTMLLinkElement.prototype; 777 | __proto._onload=function(data){ 778 | switch(this.type){ 779 | case 'text/css': 780 | CSSStyle.parseCSS(data,this.URI); 781 | break ; 782 | } 783 | } 784 | 785 | __getset(0,__proto,'href',_super.prototype._$get_href,function(url){ 786 | var _$this=this; 787 | url=this.formatURL(url); 788 | this.URI=new URL(url); 789 | var l=new Loader(); 790 | l.once(/*laya.events.Event.COMPLETE*/"complete",null,function(data){ 791 | _$this._onload(data); 792 | }); 793 | l.load(url,/*laya.net.Loader.TEXT*/"text"); 794 | }); 795 | 796 | HTMLLinkElement._cuttingStyle=new RegExp("((@keyframes[\\s\\t]+|)(.+))[\\t\\n\\r\\\s]*{","g"); 797 | return HTMLLinkElement; 798 | })(HTMLElement) 799 | 800 | 801 | /** 802 | *@private 803 | */ 804 | //class laya.html.dom.HTMLStyleElement extends laya.html.dom.HTMLElement 805 | var HTMLStyleElement=(function(_super){ 806 | function HTMLStyleElement(){ 807 | HTMLStyleElement.__super.call(this); 808 | this.visible=false; 809 | } 810 | 811 | __class(HTMLStyleElement,'laya.html.dom.HTMLStyleElement',_super); 812 | var __proto=HTMLStyleElement.prototype; 813 | /** 814 | *解析样式 815 | */ 816 | __getset(0,__proto,'text',_super.prototype._$get_text,function(value){ 817 | CSSStyle.parseCSS(value,null); 818 | }); 819 | 820 | return HTMLStyleElement; 821 | })(HTMLElement) 822 | 823 | 824 | /** 825 | *iframe标签类,目前用于加载外并解析数据 826 | */ 827 | //class laya.html.dom.HTMLIframeElement extends laya.html.dom.HTMLDivElement 828 | var HTMLIframeElement=(function(_super){ 829 | function HTMLIframeElement(){ 830 | HTMLIframeElement.__super.call(this); 831 | this._getCSSStyle().valign="middle"; 832 | } 833 | 834 | __class(HTMLIframeElement,'laya.html.dom.HTMLIframeElement',_super); 835 | var __proto=HTMLIframeElement.prototype; 836 | /** 837 | *加载html文件,并解析数据 838 | *@param url 839 | */ 840 | __getset(0,__proto,'href',_super.prototype._$get_href,function(url){ 841 | var _$this=this; 842 | url=this.formatURL(url); 843 | var l=new Loader(); 844 | l.once(/*laya.events.Event.COMPLETE*/"complete",null,function(data){ 845 | var pre=_$this.URI; 846 | _$this.URI=new URL(url); 847 | _$this.innerHTML=data; 848 | !pre || (_$this.URI=pre); 849 | }); 850 | l.load(url,/*laya.net.Loader.TEXT*/"text"); 851 | }); 852 | 853 | return HTMLIframeElement; 854 | })(HTMLDivElement) 855 | 856 | 857 | 858 | })(window,document,Laya); 859 | -------------------------------------------------------------------------------- /AirWar/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 | })(); -------------------------------------------------------------------------------- /AirWar/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,h=(e.__newvec,laya.d3.component.Component3D);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,h=this._meshTerrainSprite3D.minZ,a=this._meshTerrainSprite3D.width/this.grid.width,s=this._meshTerrainSprite3D.depth/this.grid.height,o=a/2,d=s/2,l=Math.floor((t-r)/a),g=Math.floor((i-h)/s),f=Math.floor((e-r)/a),c=Math.floor((n-h)/s),p=this.grid.width-1,u=this.grid.height-1;l>p&&(l=p),g>u&&(g=u),l<0&&(l=0),g<0&&(g=0),f>p&&(f=p),c>u&&(c=u),f<0&&(f=0),c<0&&(c=0);var _=this._finder.findPath(l,g,f,c,this.grid);this.grid.reset();for(var m=1;m<_.length-1;m++){var D=_[m];D[0]=D[0]*a+o+r,D[1]=D[1]*s+d+h}return 1==_.length?(_[0][0]=e,_[0][1]=e):_.length>1&&(_[0][0]=t,_[0][1]=i,_[_.length-1][0]=e,_[_.length-1][1]=n),_},r(0,e,"setting",function(){return this._setting},function(t){t&&(this._finder=new PathFinding.finders.AStarFinder(t)),this._setting=t})}(h)}(window,document,Laya); -------------------------------------------------------------------------------- /AirWar/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),t._instance},laya.events.EventDispatcher._$SET_instance),t.getTransformedAcceleration=function(e){t.transformedAcceleration=t.transformedAcceleration||new p,t.transformedAcceleration.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),t._instance},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);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,t._instance},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 T: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(t){e.prototype._$set_height.call(this,t),this.paused&&this.renderCanvas()}),o(0,i,"width",e.prototype._$get_width,function(t){this.videoElement.width=this.width/s.pixelRatio,e.prototype._$set_width.call(this,t),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}(),T=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))}return a(t,"laya.device.media.WebGLVideo",w),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); -------------------------------------------------------------------------------- /AirWar/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),g=(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),f=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 f;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=g.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); -------------------------------------------------------------------------------- /AirWar/bin/libs/min/laya.html.min.js: -------------------------------------------------------------------------------- 1 | !function(window,document,Laya){var __un=Laya.un,__uns=Laya.uns,__static=Laya.static,__class=Laya.class,__getset=Laya.getset,__newvec=Laya.__newvec,Browser=laya.utils.Browser,CSSStyle=laya.display.css.CSSStyle,ClassUtils=laya.utils.ClassUtils,Event=laya.events.Event,HTMLChar=laya.utils.HTMLChar,Loader=laya.net.Loader,Node=laya.display.Node,Rectangle=laya.maths.Rectangle,Render=laya.renders.Render,RenderContext=laya.renders.RenderContext,RenderSprite=laya.renders.RenderSprite,Sprite=laya.display.Sprite,Stat=laya.utils.Stat,Texture=laya.resource.Texture,URL=laya.net.URL,Utils=laya.utils.Utils,HTMLParse=function(){function t(){}return __class(t,"laya.html.utils.HTMLParse"),t.parse=function(e,i,n){i=(i=""+(i=i.replace(/
/g,"
"))+"
").replace(t.spacePattern,t.char255);var s=Utils.parseXMLFromString(i);t._parseXML(e,s.childNodes[0].childNodes,n)},t._parseXML=function(e,i,n,s){var l=0,r=0;if(i.join||i.item)for(l=0,r=i.length;l0&&(a=ClassUtils.getInstance(h))&&(e.addChild(a),a.innerTEXT=o.replace(t.char255AndOneSpacePattern," "))):(o=i.textContent.replace(/^\s+|\s+$/g,"")).length>0&&(e.innerTEXT=o.replace(t.char255AndOneSpacePattern," ")))}if("#comment"==(h=i.nodeName.toLowerCase()))return;if(a=ClassUtils.getInstance(h)){(a=e.addChild(a)).URI=n,a.href=s;var _=i.attributes;if(_&&_.length>0)for(l=0,r=_.length;l0&&v+S>p&&E.wordStartIndex>0){var U=0;U=E.elements.length-E.wordStartIndex+1,E.elements.length=E.wordStartIndex,o-=U,i();continue}C=!1,I+=a.width}S=a.width+d,H=a.height,R=!1,(C=C||v+S>p)&&i(),E.minTextHeight=Math.min(E.minTextHeight,s.height)}else h=s,r=(l=s._getCSSStyle()).padding,0===l._getCssFloat()||(x=!0),C=R||l.lineElement,S=h.width*h._style._tf.scaleX+r[1]+r[3]+d,H=h.height*h._style._tf.scaleY+r[0]+r[2],R=l.lineElement,(C=C||v+S>p&&l.wordWrap)&&i();E.elements.push(s),E.h=Math.max(E.h,H),s.x=v,s.y=T,v+=S,E.w=v-d,E.y=T,g=Math.max(v+m,g)}else A||(v+=t.DIV_ELEMENT_PADDING),E.wordStartIndex=E.elements.length;if(T=E.y+E.h,x){var N=0,b=p;for(f&&e.width>0&&(b=e.width),o=0,_=M.length;o<_;o++)M[o].updatePos(0,b,o,N,L,w,y),N+=Math.max(y,M[o].h+c);T=N}return f&&(e.width=g),T>e.height&&(e.height=T),[g,T]},t._will=null,t.DIV_ELEMENT_PADDING=0,t}(),LayoutLine=function(){function t(){this.x=0,this.y=0,this.w=0,this.h=0,this.wordStartIndex=0,this.minTextHeight=99999,this.mWidth=0,this.elements=new Array}return __class(t,"laya.html.utils.LayoutLine"),t.prototype.updatePos=function(t,e,i,n,s,l,r){var a,h=0;this.elements.length>0&&(h=(a=this.elements[this.elements.length-1]).x+a.width-this.elements[0].x);var o=0,_=NaN;1===s&&(o=(e-h)/2),2===s&&(o=e-h),0===r||0!=l||(l=1);for(var u=0,d=this.elements.length;u0)for(var e=0;e0||null!=this._getWords())&&t.block?(Layout.later(this),t._type|=512):this.parent&&this.parent._layoutLater())},__proto._setAttributes=function(t,e){switch(t){case"style":return void this.style.cssText(e);case"class":return void(this.className=e)}_super.prototype._setAttributes.call(this,t,e)},__proto.updateHref=function(){if(null!=this._href){var t=this._getWords();if(t)for(var e,i,n=0;nthis.minEmissionTime;)this._frameTime-=this.minEmissionTime,this.emit()},n(0,e,"particleTemplate",null,function(t){this._particleTemplate=t}),n(0,e,"emissionRate",function(){return this._emissionRate},function(t){t<=0||(this._emissionRate=t,t>0&&(this.minEmissionTime=1/t))}),t}()),g=function(){function t(){this.position=null,this.velocity=null,this.startColor=null,this.endColor=null,this.sizeRotation=null,this.radius=null,this.radian=null,this.durationAddScale=NaN,this.time=NaN}return r(t,"laya.particle.ParticleData"),t.Create=function(e,i,a,r){var n=new t;n.position=i,c.scaleVector3(a,e.emitterVelocitySensitivity,t._tempVelocity);var s=c.lerp(e.minHorizontalVelocity,e.maxHorizontalVelocity,Math.random()),o=Math.random()*Math.PI*2;t._tempVelocity[0]+=s*Math.cos(o),t._tempVelocity[2]+=s*Math.sin(o),t._tempVelocity[1]+=c.lerp(e.minVerticalVelocity,e.maxVerticalVelocity,Math.random()),n.velocity=t._tempVelocity,n.startColor=t._tempStartColor,n.endColor=t._tempEndColor;var l=0;if(e.disableColor)for(l=0;l<4;l++)n.startColor[l]=1,n.endColor[l]=1;else if(e.colorComponentInter)for(l=0;l<4;l++)n.startColor[l]=c.lerp(e.minStartColor[l],e.maxStartColor[l],Math.random()),n.endColor[l]=c.lerp(e.minEndColor[l],e.maxEndColor[l],Math.random());else c.lerpVector4(e.minStartColor,e.maxStartColor,Math.random(),n.startColor),c.lerpVector4(e.minEndColor,e.maxEndColor,Math.random(),n.endColor);n.sizeRotation=t._tempSizeRotation;var h=Math.random();n.sizeRotation[0]=c.lerp(e.minStartSize,e.maxStartSize,h),n.sizeRotation[1]=c.lerp(e.minEndSize,e.maxEndSize,h),n.sizeRotation[2]=c.lerp(e.minRotateSpeed,e.maxRotateSpeed,Math.random()),n.radius=t._tempRadius;var u=Math.random();n.radius[0]=c.lerp(e.minStartRadius,e.maxStartRadius,u),n.radius[1]=c.lerp(e.minEndRadius,e.maxEndRadius,u),n.radian=t._tempRadian,n.radian[0]=c.lerp(e.minHorizontalStartRadian,e.maxHorizontalStartRadian,Math.random()),n.radian[1]=c.lerp(e.minVerticalStartRadian,e.maxVerticalStartRadian,Math.random());var d=e.useEndRadian;return n.radian[2]=d?c.lerp(e.minHorizontalEndRadian,e.maxHorizontalEndRadian,Math.random()):n.radian[0],n.radian[3]=d?c.lerp(e.minVerticalEndRadian,e.maxVerticalEndRadian,Math.random()):n.radian[1],n.durationAddScale=e.ageAddScale*Math.random(),n.time=r,n},a(t,["_tempVelocity",function(){return this._tempVelocity=new Float32Array(3)},"_tempStartColor",function(){return this._tempStartColor=new Float32Array(4)},"_tempEndColor",function(){return this._tempEndColor=new Float32Array(4)},"_tempSizeRotation",function(){return this._tempSizeRotation=new Float32Array(3)},"_tempRadius",function(){return this._tempRadius=new Float32Array(2)},"_tempRadian",function(){return this._tempRadian=new Float32Array(4)}]),t}(),R=(function(){function t(t,e,i){this._templet=null,this._timeBetweenParticles=NaN,this._previousPosition=null,this._timeLeftOver=0,this._tempVelocity=new Float32Array([0,0,0]),this._tempPosition=new Float32Array([0,0,0]),this._templet=t,this._timeBetweenParticles=1/e,this._previousPosition=i}r(t,"laya.particle.ParticleEmitter"),t.prototype.update=function(t,e){if((t/=1e3)>0){c.subtractVector3(e,this._previousPosition,this._tempVelocity),c.scaleVector3(this._tempVelocity,1/t,this._tempVelocity);for(var i=this._timeLeftOver+t,a=-this._timeLeftOver;i>this._timeBetweenParticles;)a+=this._timeBetweenParticles,i-=this._timeBetweenParticles,c.lerpVector3(this._previousPosition,e,a/t,this._tempPosition),this._templet.addParticleArray(this._tempPosition,this._tempVelocity);this._timeLeftOver=i}this._previousPosition[0]=e[0],this._previousPosition[1]=e[1],this._previousPosition[2]=e[2]}}(),function(){function t(){this.textureName=null,this.textureCount=1,this.maxPartices=100,this.duration=1,this.ageAddScale=0,this.emitterVelocitySensitivity=1,this.minStartSize=100,this.maxStartSize=100,this.minEndSize=100,this.maxEndSize=100,this.minHorizontalVelocity=0,this.maxHorizontalVelocity=0,this.minVerticalVelocity=0,this.maxVerticalVelocity=0,this.endVelocity=1,this.minRotateSpeed=0,this.maxRotateSpeed=0,this.minStartRadius=0,this.maxStartRadius=0,this.minEndRadius=0,this.maxEndRadius=0,this.minHorizontalStartRadian=0,this.maxHorizontalStartRadian=0,this.minVerticalStartRadian=0,this.maxVerticalStartRadian=0,this.useEndRadian=!0,this.minHorizontalEndRadian=0,this.maxHorizontalEndRadian=0,this.minVerticalEndRadian=0,this.maxVerticalEndRadian=0,this.colorComponentInter=!1,this.disableColor=!1,this.blendState=0,this.emitterType="null",this.emissionRate=0,this.sphereEmitterRadius=1,this.sphereEmitterVelocity=0,this.sphereEmitterVelocityAddVariance=0,this.ringEmitterRadius=30,this.ringEmitterVelocity=0,this.ringEmitterVelocityAddVariance=0,this.ringEmitterUp=2,this.gravity=new Float32Array([0,0,0]),this.minStartColor=new Float32Array([1,1,1,1]),this.maxStartColor=new Float32Array([1,1,1,1]),this.minEndColor=new Float32Array([1,1,1,1]),this.maxEndColor=new Float32Array([1,1,1,1]),this.pointEmitterPosition=new Float32Array([0,0,0]),this.pointEmitterPositionVariance=new Float32Array([0,0,0]),this.pointEmitterVelocity=new Float32Array([0,0,0]),this.pointEmitterVelocityAddVariance=new Float32Array([0,0,0]),this.boxEmitterCenterPosition=new Float32Array([0,0,0]),this.boxEmitterSize=new Float32Array([0,0,0]),this.boxEmitterVelocity=new Float32Array([0,0,0]),this.boxEmitterVelocityAddVariance=new Float32Array([0,0,0]),this.sphereEmitterCenterPosition=new Float32Array([0,0,0]),this.ringEmitterCenterPosition=new Float32Array([0,0,0]),this.positionVariance=new Float32Array([0,0,0])}return r(t,"laya.particle.ParticleSetting"),t.checkSetting=function(e){var i;for(i in t._defaultSetting)e.hasOwnProperty(i)||(e[i]=t._defaultSetting[i])},a(t,["_defaultSetting",function(){return this._defaultSetting=new t}]),t}()),S=function(){function t(){this.settings=null,this.texture=null}return r(t,"laya.particle.ParticleTemplateBase"),t.prototype.addParticleArray=function(t,e){},t}(),V=function(){function t(){this.u_Duration=NaN,this.u_EndVelocity=NaN,this.u_Gravity=null,this.a_Position=null,this.a_Velocity=null,this.a_StartColor=null,this.a_EndColor=null,this.a_SizeRotation=null,this.a_Radius=null,this.a_Radian=null,this.a_AgeAddScale=NaN,this.gl_Position=null,this.v_Color=null,this.oSize=NaN,this._color=new Float32Array(4),this._position=new Float32Array(3)}r(t,"laya.particle.particleUtils.CanvasShader");var e=t.prototype;return e.getLen=function(t){return Math.sqrt(t[0]*t[0]+t[1]*t[1]+t[2]*t[2])},e.ComputeParticlePosition=function(t,e,i,a){this._position[0]=t[0],this._position[1]=t[1],this._position[2]=t[2];var r=this.getLen(e),n=r*a+(r*this.u_EndVelocity-r)*a*a/2,s=NaN;s=this.getLen(e);var o=0;for(3,o=0;o<3;o++)this._position[o]=this._position[o]+e[o]/s*n*this.u_Duration,this._position[o]+=this.u_Gravity[o]*i*a;var l=c.lerp(this.a_Radius[0],this.a_Radius[1],a),h=c.lerp(this.a_Radian[0],this.a_Radian[2],a),u=c.lerp(this.a_Radian[1],this.a_Radian[3],a),d=Math.cos(u)*l;return this._position[1]+=Math.sin(u)*l,this._position[0]+=Math.cos(h)*d,this._position[2]+=Math.sin(h)*d,new Float32Array([this._position[0],this._position[1],0,1])},e.ComputeParticleSize=function(t,e,i){return c.lerp(t,e,i)},e.ComputeParticleRotation=function(t,e){return t*e},e.ComputeParticleColor=function(t,e,i){var a=this._color;return c.lerpVector4(t,e,i,a),a[3]=a[3]*i*(1-i)*(1-i)*6.7,a},e.clamp=function(t,e,i){return ti?i:t},e.getData=function(t){t*=1+this.a_AgeAddScale;var e=this.clamp(t/this.u_Duration,0,1);this.gl_Position=this.ComputeParticlePosition(this.a_Position,this.a_Velocity,t,e);var i=this.ComputeParticleSize(this.a_SizeRotation[0],this.a_SizeRotation[1],e),a=this.ComputeParticleRotation(this.a_SizeRotation[2],t);this.v_Color=this.ComputeParticleColor(this.a_StartColor,this.a_EndColor,e);var r=new u,n=NaN;n=i/this.oSize*2,r.scale(n,n),r.rotate(a),r.setTranslate(this.gl_Position[0],-this.gl_Position[1]);var s=NaN;return s=this.v_Color[3],[this.v_Color,s,r,this.v_Color[0]*s,this.v_Color[1]*s,this.v_Color[2]*s]},t}(),E=function(){function t(){this.maxIndex=0,this.cmds=null,this.id=0}return r(t,"laya.particle.particleUtils.CMDParticle"),t.prototype.setCmds=function(t){this.cmds=t,this.maxIndex=t.length-1},t}(),A=function(){function t(){}return r(t,"laya.particle.particleUtils.PicTool"),t.getCanvasPic=function(t,e){t=t.bitmap;var i=new o("2D"),a=i.getContext("2d");i.size(t.width,t.height);var r=e>>16&255,n=e>>8&255,s=255&e;if(d.isConchApp&&a.setFilter(r/255,n/255,s/255,0),a.drawImage(t.source,0,0),!d.isConchApp){for(var l=a.getImageData(0,0,i.width,i.height),h=l.data,c=0,u=h.length;c=this.settings.maxPartices&&(this._firstActiveElement=0)}},i.freeRetiredParticles=function(){for(;this._firstRetiredElement!=this._firstActiveElement&&!(this._drawCounter-this._vertices[this._firstRetiredElement*this._floatCountPerVertex*4+28]<3);)++this._firstRetiredElement>=this.settings.maxPartices&&(this._firstRetiredElement=0)},i.addNewParticlesToVertexBuffer=function(){},i.addParticleArray=function(t,e){var i=this._firstFreeElement+1;if(i>=this.settings.maxPartices&&(i=0),i!==this._firstRetiredElement){for(var a=g.Create(this.settings,t,e,this._currentTime),r=this._firstFreeElement*this._floatCountPerVertex*4,n=0;n<4;n++){var s=0,o=0;for(s=0,o=4;s<3;s++)this._vertices[r+n*this._floatCountPerVertex+o+s]=a.position[s];for(s=0,o=7;s<3;s++)this._vertices[r+n*this._floatCountPerVertex+o+s]=a.velocity[s];for(s=0,o=10;s<4;s++)this._vertices[r+n*this._floatCountPerVertex+o+s]=a.startColor[s];for(s=0,o=14;s<4;s++)this._vertices[r+n*this._floatCountPerVertex+o+s]=a.endColor[s];for(s=0,o=18;s<3;s++)this._vertices[r+n*this._floatCountPerVertex+o+s]=a.sizeRotation[s];for(s=0,o=21;s<2;s++)this._vertices[r+n*this._floatCountPerVertex+o+s]=a.radius[s];for(s=0,o=23;s<4;s++)this._vertices[r+n*this._floatCountPerVertex+o+s]=a.radian[s];this._vertices[r+n*this._floatCountPerVertex+27]=a.durationAddScale,this._vertices[r+n*this._floatCountPerVertex+28]=a.time}this._firstFreeElement=i}},e}(),z=function(t){function e(t){this._ready=!1,this.textureList=[],this.particleList=[],this.pX=0,this.pY=0,this.activeParticles=[],this.deadParticles=[],this.iList=[],this._maxNumParticles=0,this.textureWidth=NaN,this.dTextureWidth=NaN,this.colorChange=!0,this.step=1/60,this.canvasShader=new V,e.__super.call(this),this.settings=t,this._maxNumParticles=t.maxPartices,this.texture=new f,this.texture.on("loaded",this,this._textureLoaded),this.texture.load(t.textureName)}r(e,"laya.particle.ParticleTemplateCanvas",S);var i=e.prototype;return i._textureLoaded=function(t){this.setTexture(this.texture),this._ready=!0},i.clear=function(t){void 0===t&&(t=!0),this.deadParticles.length=0,this.activeParticles.length=0,this.textureList.length=0},i.setTexture=function(t){this.texture=t,this.textureWidth=t.width,this.dTextureWidth=1/this.textureWidth,this.pX=.5*-t.width,this.pY=.5*-t.height,this.textureList=e.changeTexture(t,this.textureList),this.particleList.length=0,this.deadParticles.length=0,this.activeParticles.length=0},i._createAParticleData=function(t,e){this.canvasShader.u_EndVelocity=this.settings.endVelocity,this.canvasShader.u_Gravity=this.settings.gravity,this.canvasShader.u_Duration=this.settings.duration;var i;i=g.Create(this.settings,t,e,0),this.canvasShader.a_Position=i.position,this.canvasShader.a_Velocity=i.velocity,this.canvasShader.a_StartColor=i.startColor,this.canvasShader.a_EndColor=i.endColor,this.canvasShader.a_SizeRotation=i.sizeRotation,this.canvasShader.a_Radius=i.radius,this.canvasShader.a_Radian=i.radian,this.canvasShader.a_AgeAddScale=i.durationAddScale,this.canvasShader.oSize=this.textureWidth;var a=new E,r=0,n=this.settings.duration/(1+i.durationAddScale),s=[];for(r=0;r0&&(i=this.deadParticles.pop(),this.iList[i.id]=0,this.activeParticles.push(i))}},i.advanceTime=function(t){if(void 0===t&&(t=1),this._ready){var e,i=this.activeParticles,a=this.deadParticles,r=0,n=i.length,s=0,o=this.iList;for(r=n-1;r>-1;r--)(s=o[(e=i[r]).id])>=e.maxIndex?(s=0,i.splice(r,1),a.push(e)):s+=1,o[e.id]=s}},i.render=function(t,e,i){this._ready&&(this.activeParticles.length<1||this.textureList.length<2||(this.settings.disableColor?this.noColorRender(t,e,i):this.canvasRender(t,e,i)))},i.noColorRender=function(t,e,i){var a,r,n=this.activeParticles,s=0,o=n.length,l=NaN,h=this.pX,c=this.pY,u=2*-h,d=2*-c,m=0,_=(this.textureList,this.iList),p=NaN;for(t.translate(e,i),p=t.ctx.globalAlpha,s=0;s.01&&(t.setAlpha(f*r[3]),t.drawTexture(_[0],h,c,u,d)),r[4]>.01&&(t.setAlpha(f*r[4]),t.drawTexture(_[1],h,c,u,d)),r[5]>.01&&(t.setAlpha(f*r[5]),t.drawTexture(_[2],h,c,u,d)),t.restore()));t.setAlpha(f),t.translate(-e,-i),t.blendMode(n)},e.changeTexture=function(t,e,i){return e||(e=[]),e.length=0,i&&i.disableColor?e.push(t,t,t):v.copyArray(e,A.getRGBPic(t)),e},e}(),b=function(t){function e(t){this._vertexBuffer2D=null,this._indexBuffer2D=null,this.x=0,this.y=0,this._blendFn=null,this._startTime=0,this.sv=new F,e.__super.call(this,t);var a=this;i.loader.load(this.settings.textureName,l.create(null,function(t){t.bitmap.enableMerageInAtlas=!1,a.texture=t})),this.sv.u_Duration=this.settings.duration,this.sv.u_Gravity=this.settings.gravity,this.sv.u_EndVelocity=this.settings.endVelocity,this._blendFn=s.fns[t.blendState],this.initialize(),this._vertexBuffer=this._vertexBuffer2D=y.create(-1,35048),this._indexBuffer=this._indexBuffer2D=h.create(35044),this.loadContent()}r(e,"laya.particle.ParticleTemplate2D",t);var a=e.prototype;return i.imps(a,{"laya.webgl.submit.ISubmit":!0}),a.getRenderType=function(){return-111},a.releaseRender=function(){},a.addParticleArray=function(e,i){e[0]+=this.x,e[1]+=this.y,t.prototype.addParticleArray.call(this,e,i)},a.loadContent=function(){for(var t=new Uint16Array(6*this.settings.maxPartices),e=0;e0&&(this._vertexBuffer2D.setNeedUpload(),this._vertexBuffer2D.subUpload(0,0,4*this._firstFreeElement*this._floatCountPerVertex*4))),this._firstNewElement=this._firstFreeElement},a.renderSubmit=function(){if(this.texture&&this.texture.loaded){if(this.update(i.timer.delta),this.sv.u_CurrentTime=this._currentTime,this._firstNewElement!=this._firstFreeElement&&this.addNewParticlesToVertexBuffer(),this.blend(),this._firstActiveElement!=this._firstFreeElement){C.mainContext;this._vertexBuffer2D.bind(this._indexBuffer2D),this.sv.u_texture=this.texture.source,this.sv.upload(),this._firstActiveElement0&&C.mainContext.drawElements(4,6*this._firstFreeElement,5123,0)),p.drawCall++}this._drawCounter++}return 1},a.blend=function(){if(s.activeBlendFunction!==this._blendFn){var t=C.mainContext;t.enable(3042),this._blendFn(t),s.activeBlendFunction=this._blendFn}},a.dispose=function(){this._indexBuffer2D.dispose()},e.activeBlendType=-1,e}(w),F=function(t){function e(){this.a_CornerTextureCoordinate=[4,5126,!1,116,0],this.a_Position=[3,5126,!1,116,16],this.a_Velocity=[3,5126,!1,116,28],this.a_StartColor=[4,5126,!1,116,40],this.a_EndColor=[4,5126,!1,116,56],this.a_SizeRotation=[3,5126,!1,116,72],this.a_Radius=[2,5126,!1,116,84],this.a_Radian=[4,5126,!1,116,92],this.a_AgeAddScale=[1,5126,!1,116,108],this.a_Time=[1,5126,!1,116,112],this.u_CurrentTime=NaN,this.u_Duration=NaN,this.u_Gravity=null,this.u_EndVelocity=NaN,this.u_texture=null,e.__super.call(this,0,0)}return r(e,"laya.particle.shader.value.ParticleShaderValue",x),e.prototype.upload=function(){this.refresh(),e.pShader.upload(this)},a(e,["pShader",function(){return this.pShader=new N}]),e}(),N=(function(e){function a(t){this._matrix4=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],this._particleTemplate=null,this._canvasTemplate=null,this._emitter=null,this.autoPlay=!0,a.__super.call(this),t&&this.setParticleSetting(t)}r(a,"laya.particle.Particle2D",e);var s=a.prototype;s.load=function(t){i.loader.load(t,l.create(this,this.setParticleSetting),null,"json")},s.setParticleSetting=function(e){var a=this;if(!e)return this.stop();if(R.checkSetting(e),t.ConchParticleTemplate2D&&!d.isWebGL||(this.customRenderEnable=!0),d.isWebGL)this._particleTemplate=new b(e),this.graphics._saveToCmd(d.context._drawParticle,[this._particleTemplate]);else{if(d.isConchApp&&t.ConchParticleTemplate2D){this._particleTemplate=new ConchParticleTemplate2D;var r=this;return i.loader.load(e.textureName,l.create(null,function(t){r._particleTemplate.texture=t,r._particleTemplate.settings=e,d.isConchNode?r.graphics.drawParticle(r._particleTemplate):r.graphics._saveToCmd(d.context._drawParticle,[a._particleTemplate])})),this._emitter={start:function(){}},this.play=this._particleTemplate.play.bind(this._particleTemplate),this.stop=this._particleTemplate.stop.bind(this._particleTemplate),void(this.autoPlay&&this.play())}this._particleTemplate=this._canvasTemplate=new z(e)}this._emitter?this._emitter.template=this._particleTemplate:this._emitter=new T(this._particleTemplate),this.autoPlay&&(this.emitter.start(),this.play())},s.play=function(){i.timer.frameLoop(1,this,this._loop)},s.stop=function(){i.timer.clear(this,this._loop)},s._loop=function(){this.advanceTime(1/60)},s.advanceTime=function(t){void 0===t&&(t=1),this._canvasTemplate&&this._canvasTemplate.advanceTime(t),this._emitter&&this._emitter.advanceTime(t)},s.customRender=function(t,e,i){d.isWebGL&&(this._matrix4[0]=t.ctx._curMat.a,this._matrix4[1]=t.ctx._curMat.b,this._matrix4[4]=t.ctx._curMat.c,this._matrix4[5]=t.ctx._curMat.d,this._matrix4[12]=t.ctx._curMat.tx,this._matrix4[13]=t.ctx._curMat.ty,this._particleTemplate.sv.u_mmat=this._matrix4),this._canvasTemplate&&this._canvasTemplate.render(t,e,i)},s.destroy=function(t){void 0===t&&(t=!0),this._particleTemplate instanceof laya.particle.ParticleTemplate2D&&this._particleTemplate.dispose(),e.prototype.destroy.call(this,t)},n(0,s,"url",null,function(t){this.load(t)}),n(0,s,"emitter",function(){return this._emitter})}(_),function(t){function e(){e.__super.call(this,e.vs,e.ps,"ParticleShader")}return r(e,"laya.particle.shader.ParticleShader",m),a(e,["vs",function(){return this.vs="attribute vec4 a_CornerTextureCoordinate;\nattribute vec3 a_Position;\nattribute vec3 a_Velocity;\nattribute vec4 a_StartColor;\nattribute vec4 a_EndColor;\nattribute vec3 a_SizeRotation;\nattribute vec2 a_Radius;\nattribute vec4 a_Radian;\nattribute float a_AgeAddScale;\nattribute float a_Time;\n\nvarying vec4 v_Color;\nvarying vec2 v_TextureCoordinate;\n\nuniform float u_CurrentTime;\nuniform float u_Duration;\nuniform float u_EndVelocity;\nuniform vec3 u_Gravity;\n\n#ifdef PARTICLE3D\n uniform mat4 u_WorldMat;\n uniform mat4 u_View;\n uniform mat4 u_Projection;\n uniform vec2 u_ViewportScale;\n#else\n uniform vec2 size;\n uniform mat4 mmat;\n uniform mat4 u_mmat;\n#endif\n\nvec4 ComputeParticlePosition(in vec3 position, in vec3 velocity,in float age,in float normalizedAge)\n{\n\n float startVelocity = length(velocity);//起始标量速度\n float endVelocity = startVelocity * u_EndVelocity;//结束标量速度\n\n float velocityIntegral = startVelocity * normalizedAge +(endVelocity - startVelocity) * normalizedAge *normalizedAge/2.0;//计算当前速度的标量(单位空间),vt=v0*t+(1/2)*a*(t^2)\n \n vec3 addPosition = normalize(velocity) * velocityIntegral * u_Duration;//计算受自身速度影响的位置,转换标量到矢量 \n addPosition += u_Gravity * age * normalizedAge;//计算受重力影响的位置\n \n float radius=mix(a_Radius.x, a_Radius.y, normalizedAge); //计算粒子受半径和角度影响(无需计算角度和半径时,可用宏定义优化屏蔽此计算)\n float radianHorizontal =mix(a_Radian.x,a_Radian.z,normalizedAge);\n float radianVertical =mix(a_Radian.y,a_Radian.w,normalizedAge);\n \n float r =cos(radianVertical)* radius;\n addPosition.y += sin(radianVertical) * radius;\n\t\n addPosition.x += cos(radianHorizontal) *r;\n addPosition.z += sin(radianHorizontal) *r;\n \n #ifdef PARTICLE3D\n position+=addPosition;\n return u_Projection*u_View*u_WorldMat*(vec4(position, 1.0));\n #else\n addPosition.y=-addPosition.y;//2D粒子位置更新需要取负,2D粒子坐标系Y轴正向朝上\n position+=addPosition;\n return vec4(position,1.0);\n #endif\n}\n\nfloat ComputeParticleSize(in float startSize,in float endSize, in float normalizedAge)\n{ \n float size = mix(startSize, endSize, normalizedAge);\n \n\t#ifdef PARTICLE3D\n //Project the size into screen coordinates.\n return size * u_Projection[1][1];\n\t#else\n\t return size;\n\t#endif\n}\n\nmat2 ComputeParticleRotation(in float rot,in float age)\n{ \n float rotation =rot * age;\n //计算2x2旋转矩阵.\n float c = cos(rotation);\n float s = sin(rotation);\n return mat2(c, -s, s, c);\n}\n\nvec4 ComputeParticleColor(in vec4 startColor,in vec4 endColor,in float normalizedAge)\n{\n\tvec4 color=mix(startColor,endColor,normalizedAge);\n //硬编码设置,使粒子淡入很快,淡出很慢,6.7的缩放因子把置归一在0到1之间,可以谷歌x*(1-x)*(1-x)*6.7的制图表\n color.a *= normalizedAge * (1.0-normalizedAge) * (1.0-normalizedAge) * 6.7;\n \n return color;\n}\n\nvoid main()\n{\n float age = u_CurrentTime - a_Time;\n age *= 1.0 + a_AgeAddScale;\n float normalizedAge = clamp(age / u_Duration,0.0,1.0);\n gl_Position = ComputeParticlePosition(a_Position, a_Velocity, age, normalizedAge);//计算粒子位置\n float pSize = ComputeParticleSize(a_SizeRotation.x,a_SizeRotation.y, normalizedAge);\n mat2 rotation = ComputeParticleRotation(a_SizeRotation.z, age);\n\t\n #ifdef PARTICLE3D\n\tgl_Position.xy += (rotation*a_CornerTextureCoordinate.xy) * pSize * u_ViewportScale;\n #else\n mat4 mat=u_mmat*mmat;\n gl_Position=vec4((mat*gl_Position).xy,0.0,1.0);\n\tgl_Position.xy += (rotation*a_CornerTextureCoordinate.xy) * pSize*vec2(mat[0][0],mat[1][1]);\n gl_Position=vec4((gl_Position.x/size.x-0.5)*2.0,(0.5-gl_Position.y/size.y)*2.0,0.0,1.0);\n #endif\n \n v_Color = ComputeParticleColor(a_StartColor,a_EndColor, normalizedAge);\n v_TextureCoordinate =a_CornerTextureCoordinate.zw;\n}\n\n"},"ps",function(){return this.ps="#ifdef FSHIGHPRECISION\nprecision highp float;\n#else\nprecision mediump float;\n#endif\n\nvarying vec4 v_Color;\nvarying vec2 v_TextureCoordinate;\nuniform sampler2D u_texture;\n\nvoid main()\n{\t\n\tgl_FragColor=texture2D(u_texture,v_TextureCoordinate)*v_Color;\n\tgl_FragColor.xyz *= v_Color.w;\n}"}]),e}())}(window,document,Laya); -------------------------------------------------------------------------------- /AirWar/bin/libs/min/laya.pathfinding.min.js: -------------------------------------------------------------------------------- 1 | !function(t,e,i){var n=(i.un,i.uns,i.static,i.class),s=(i.getset,i.__newvec,function(){function t(){}return n(t,"PathFinding.core.DiagonalMovement"),t.Always=1,t.Never=2,t.IfAtMostOneObstacle=3,t.OnlyWhenNoObstacles=4,t}()),a=function(){function t(t,e,i){this.width=0,this.height=0,this.nodes=null;var n=0;"number"==typeof t?n=t:(e=t.length,n=t[0].length,i=t),this.width=n,this.height=e,this.nodes=this._buildNodes(n,e,i)}n(t,"PathFinding.core.Grid");var e=t.prototype;return e._buildNodes=function(t,e,i){var n=0,s=0,a=[];for(n=0;n=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;st)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(); -------------------------------------------------------------------------------- /AirWar/bin/res/atlas/.rec: -------------------------------------------------------------------------------- 1 | D . 2 | D war 3 | R 4F008F46 background.png 4 | P 2BF0B93D enemy1_down1.png 5 | P B390F16A enemy1_down2.png 6 | P 31482119 enemy1_down3.png 7 | P 86E83C52 enemy1_down4.png 8 | P 31B0F330 enemy1_fly1.png 9 | P 95084A5B enemy2_down1.png 10 | P 93C8D1DC enemy2_down2.png 11 | P B468547B enemy2_down3.png 12 | P 72B4D4DD enemy2_down4.png 13 | P F17FEAE2 enemy2_fly1.png 14 | P 2EF80128 enemy2_hit.png 15 | P D7E26D83 enemy3_down1.png 16 | P 549C2429 enemy3_down2.png 17 | P 2E373DFB enemy3_down3.png 18 | P 2CDB0724 enemy3_down4.png 19 | P 612AD565 enemy3_down5.png 20 | P 3E137DEE enemy3_down6.png 21 | P 05AB04E5 enemy3_fly1.png 22 | P 857787A9 enemy3_fly2.png 23 | P A8782C5B enemy3_hit.png 24 | P A1876A5F hero_down1.png 25 | P 50922602 hero_down2.png 26 | P E0E80CA1 hero_down3.png 27 | P 9AC69A4E hero_down4.png 28 | P 75C8D8F4 hero_fly1.png 29 | P 44A2D9AC hero_fly2.png 30 | -------------------------------------------------------------------------------- /AirWar/bin/res/atlas/war.json: -------------------------------------------------------------------------------- 1 | {"frames":{"enemy1_down1.png":{"frame":{"h":51,"idx":0,"w":57,"x":440,"y":52},"rotated":false,"sourceSize":{"h":51,"w":57},"spriteSourceSize":{"h":51,"w":57,"x":0,"y":0},"trimmed":false},"enemy1_down2.png":{"frame":{"h":51,"idx":0,"w":57,"x":440,"y":0},"rotated":false,"sourceSize":{"h":51,"w":57},"spriteSourceSize":{"h":51,"w":57,"x":0,"y":0},"trimmed":false},"enemy1_down3.png":{"frame":{"h":51,"idx":0,"w":57,"x":976,"y":346},"rotated":false,"sourceSize":{"h":51,"w":57},"spriteSourceSize":{"h":51,"w":57,"x":0,"y":0},"trimmed":false},"enemy1_down4.png":{"frame":{"h":51,"idx":0,"w":57,"x":964,"y":442},"rotated":false,"sourceSize":{"h":51,"w":57},"spriteSourceSize":{"h":51,"w":57,"x":0,"y":0},"trimmed":false},"enemy1_fly1.png":{"frame":{"h":51,"idx":0,"w":57,"x":906,"y":442},"rotated":false,"sourceSize":{"h":51,"w":57},"spriteSourceSize":{"h":51,"w":57,"x":0,"y":0},"trimmed":false},"enemy2_down1.png":{"frame":{"h":95,"idx":0,"w":69,"x":906,"y":346},"rotated":false,"sourceSize":{"h":95,"w":69},"spriteSourceSize":{"h":95,"w":69,"x":0,"y":0},"trimmed":false},"enemy2_down2.png":{"frame":{"h":95,"idx":0,"w":69,"x":976,"y":250},"rotated":false,"sourceSize":{"h":95,"w":69},"spriteSourceSize":{"h":95,"w":69,"x":0,"y":0},"trimmed":false},"enemy2_down3.png":{"frame":{"h":95,"idx":0,"w":69,"x":906,"y":250},"rotated":false,"sourceSize":{"h":95,"w":69},"spriteSourceSize":{"h":95,"w":69,"x":0,"y":0},"trimmed":false},"enemy2_down4.png":{"frame":{"h":95,"idx":0,"w":69,"x":836,"y":446},"rotated":false,"sourceSize":{"h":95,"w":69},"spriteSourceSize":{"h":95,"w":69,"x":0,"y":0},"trimmed":false},"enemy2_fly1.png":{"frame":{"h":95,"idx":0,"w":69,"x":836,"y":350},"rotated":false,"sourceSize":{"h":95,"w":69},"spriteSourceSize":{"h":95,"w":69,"x":0,"y":0},"trimmed":false},"enemy2_hit.png":{"frame":{"h":99,"idx":0,"w":69,"x":836,"y":250},"rotated":false,"sourceSize":{"h":99,"w":69},"spriteSourceSize":{"h":99,"w":69,"x":0,"y":0},"trimmed":false},"enemy3_down1.png":{"frame":{"h":261,"idx":0,"w":165,"x":504,"y":0},"rotated":false,"sourceSize":{"h":261,"w":165},"spriteSourceSize":{"h":261,"w":165,"x":0,"y":0},"trimmed":false},"enemy3_down2.png":{"frame":{"h":261,"idx":0,"w":165,"x":504,"y":262},"rotated":false,"sourceSize":{"h":261,"w":165},"spriteSourceSize":{"h":261,"w":165,"x":0,"y":0},"trimmed":false},"enemy3_down3.png":{"frame":{"h":260,"idx":0,"w":165,"x":670,"y":262},"rotated":false,"sourceSize":{"h":260,"w":165},"spriteSourceSize":{"h":260,"w":165,"x":0,"y":0},"trimmed":false},"enemy3_down4.png":{"frame":{"h":261,"idx":0,"w":165,"x":670,"y":0},"rotated":false,"sourceSize":{"h":261,"w":165},"spriteSourceSize":{"h":261,"w":165,"x":0,"y":0},"trimmed":false},"enemy3_down5.png":{"frame":{"h":260,"idx":0,"w":166,"x":337,"y":259},"rotated":false,"sourceSize":{"h":260,"w":166},"spriteSourceSize":{"h":260,"w":166,"x":0,"y":0},"trimmed":false},"enemy3_down6.png":{"frame":{"h":261,"idx":0,"w":166,"x":170,"y":259},"rotated":false,"sourceSize":{"h":261,"w":166},"spriteSourceSize":{"h":261,"w":166,"x":0,"y":0},"trimmed":false},"enemy3_fly1.png":{"frame":{"h":258,"idx":0,"w":169,"x":170,"y":0},"rotated":false,"sourceSize":{"h":258,"w":169},"spriteSourceSize":{"h":258,"w":169,"x":0,"y":0},"trimmed":false},"enemy3_fly2.png":{"frame":{"h":258,"idx":0,"w":169,"x":0,"y":259},"rotated":false,"sourceSize":{"h":258,"w":169},"spriteSourceSize":{"h":258,"w":169,"x":0,"y":0},"trimmed":false},"enemy3_hit.png":{"frame":{"h":258,"idx":0,"w":169,"x":0,"y":0},"rotated":false,"sourceSize":{"h":258,"w":169},"spriteSourceSize":{"h":258,"w":169,"x":0,"y":0},"trimmed":false},"hero_down1.png":{"frame":{"h":124,"idx":0,"w":99,"x":936,"y":125},"rotated":false,"sourceSize":{"h":124,"w":99},"spriteSourceSize":{"h":124,"w":99,"x":0,"y":0},"trimmed":false},"hero_down2.png":{"frame":{"h":124,"idx":0,"w":99,"x":836,"y":125},"rotated":false,"sourceSize":{"h":124,"w":99},"spriteSourceSize":{"h":124,"w":99,"x":0,"y":0},"trimmed":false},"hero_down3.png":{"frame":{"h":124,"idx":0,"w":99,"x":936,"y":0},"rotated":false,"sourceSize":{"h":124,"w":99},"spriteSourceSize":{"h":124,"w":99,"x":0,"y":0},"trimmed":false},"hero_down4.png":{"frame":{"h":124,"idx":0,"w":99,"x":836,"y":0},"rotated":false,"sourceSize":{"h":124,"w":99},"spriteSourceSize":{"h":124,"w":99,"x":0,"y":0},"trimmed":false},"hero_fly1.png":{"frame":{"h":124,"idx":0,"w":99,"x":340,"y":125},"rotated":false,"sourceSize":{"h":124,"w":99},"spriteSourceSize":{"h":124,"w":99,"x":0,"y":0},"trimmed":false},"hero_fly2.png":{"frame":{"h":124,"idx":0,"w":99,"x":340,"y":0},"rotated":false,"sourceSize":{"h":124,"w":99},"spriteSourceSize":{"h":124,"w":99,"x":0,"y":0},"trimmed":false}},"meta":{"image":"war.png","prefix":"war/"}} -------------------------------------------------------------------------------- /AirWar/bin/res/atlas/war.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhangxinghua0337/layaair-AirWar/8fa735334477c1f620f490851753ed8d3bdefa46/AirWar/bin/res/atlas/war.png -------------------------------------------------------------------------------- /AirWar/bin/unpack.json: -------------------------------------------------------------------------------- 1 | ["war/background.png"] -------------------------------------------------------------------------------- /AirWar/bin/war/background.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhangxinghua0337/layaair-AirWar/8fa735334477c1f620f490851753ed8d3bdefa46/AirWar/bin/war/background.png -------------------------------------------------------------------------------- /AirWar/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 | -------------------------------------------------------------------------------- /AirWar/laya/assets/war/background.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhangxinghua0337/layaair-AirWar/8fa735334477c1f620f490851753ed8d3bdefa46/AirWar/laya/assets/war/background.png -------------------------------------------------------------------------------- /AirWar/laya/assets/war/enemy1_down1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhangxinghua0337/layaair-AirWar/8fa735334477c1f620f490851753ed8d3bdefa46/AirWar/laya/assets/war/enemy1_down1.png -------------------------------------------------------------------------------- /AirWar/laya/assets/war/enemy1_down2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhangxinghua0337/layaair-AirWar/8fa735334477c1f620f490851753ed8d3bdefa46/AirWar/laya/assets/war/enemy1_down2.png -------------------------------------------------------------------------------- /AirWar/laya/assets/war/enemy1_down3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhangxinghua0337/layaair-AirWar/8fa735334477c1f620f490851753ed8d3bdefa46/AirWar/laya/assets/war/enemy1_down3.png -------------------------------------------------------------------------------- /AirWar/laya/assets/war/enemy1_down4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhangxinghua0337/layaair-AirWar/8fa735334477c1f620f490851753ed8d3bdefa46/AirWar/laya/assets/war/enemy1_down4.png -------------------------------------------------------------------------------- /AirWar/laya/assets/war/enemy1_fly1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhangxinghua0337/layaair-AirWar/8fa735334477c1f620f490851753ed8d3bdefa46/AirWar/laya/assets/war/enemy1_fly1.png -------------------------------------------------------------------------------- /AirWar/laya/assets/war/enemy2_down1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhangxinghua0337/layaair-AirWar/8fa735334477c1f620f490851753ed8d3bdefa46/AirWar/laya/assets/war/enemy2_down1.png -------------------------------------------------------------------------------- /AirWar/laya/assets/war/enemy2_down2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhangxinghua0337/layaair-AirWar/8fa735334477c1f620f490851753ed8d3bdefa46/AirWar/laya/assets/war/enemy2_down2.png -------------------------------------------------------------------------------- /AirWar/laya/assets/war/enemy2_down3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhangxinghua0337/layaair-AirWar/8fa735334477c1f620f490851753ed8d3bdefa46/AirWar/laya/assets/war/enemy2_down3.png -------------------------------------------------------------------------------- /AirWar/laya/assets/war/enemy2_down4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhangxinghua0337/layaair-AirWar/8fa735334477c1f620f490851753ed8d3bdefa46/AirWar/laya/assets/war/enemy2_down4.png -------------------------------------------------------------------------------- /AirWar/laya/assets/war/enemy2_fly1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhangxinghua0337/layaair-AirWar/8fa735334477c1f620f490851753ed8d3bdefa46/AirWar/laya/assets/war/enemy2_fly1.png -------------------------------------------------------------------------------- /AirWar/laya/assets/war/enemy2_hit.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhangxinghua0337/layaair-AirWar/8fa735334477c1f620f490851753ed8d3bdefa46/AirWar/laya/assets/war/enemy2_hit.png -------------------------------------------------------------------------------- /AirWar/laya/assets/war/enemy3_down1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhangxinghua0337/layaair-AirWar/8fa735334477c1f620f490851753ed8d3bdefa46/AirWar/laya/assets/war/enemy3_down1.png -------------------------------------------------------------------------------- /AirWar/laya/assets/war/enemy3_down2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhangxinghua0337/layaair-AirWar/8fa735334477c1f620f490851753ed8d3bdefa46/AirWar/laya/assets/war/enemy3_down2.png -------------------------------------------------------------------------------- /AirWar/laya/assets/war/enemy3_down3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhangxinghua0337/layaair-AirWar/8fa735334477c1f620f490851753ed8d3bdefa46/AirWar/laya/assets/war/enemy3_down3.png -------------------------------------------------------------------------------- /AirWar/laya/assets/war/enemy3_down4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhangxinghua0337/layaair-AirWar/8fa735334477c1f620f490851753ed8d3bdefa46/AirWar/laya/assets/war/enemy3_down4.png -------------------------------------------------------------------------------- /AirWar/laya/assets/war/enemy3_down5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhangxinghua0337/layaair-AirWar/8fa735334477c1f620f490851753ed8d3bdefa46/AirWar/laya/assets/war/enemy3_down5.png -------------------------------------------------------------------------------- /AirWar/laya/assets/war/enemy3_down6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhangxinghua0337/layaair-AirWar/8fa735334477c1f620f490851753ed8d3bdefa46/AirWar/laya/assets/war/enemy3_down6.png -------------------------------------------------------------------------------- /AirWar/laya/assets/war/enemy3_fly1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhangxinghua0337/layaair-AirWar/8fa735334477c1f620f490851753ed8d3bdefa46/AirWar/laya/assets/war/enemy3_fly1.png -------------------------------------------------------------------------------- /AirWar/laya/assets/war/enemy3_fly2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhangxinghua0337/layaair-AirWar/8fa735334477c1f620f490851753ed8d3bdefa46/AirWar/laya/assets/war/enemy3_fly2.png -------------------------------------------------------------------------------- /AirWar/laya/assets/war/enemy3_hit.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhangxinghua0337/layaair-AirWar/8fa735334477c1f620f490851753ed8d3bdefa46/AirWar/laya/assets/war/enemy3_hit.png -------------------------------------------------------------------------------- /AirWar/laya/assets/war/hero_down1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhangxinghua0337/layaair-AirWar/8fa735334477c1f620f490851753ed8d3bdefa46/AirWar/laya/assets/war/hero_down1.png -------------------------------------------------------------------------------- /AirWar/laya/assets/war/hero_down2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhangxinghua0337/layaair-AirWar/8fa735334477c1f620f490851753ed8d3bdefa46/AirWar/laya/assets/war/hero_down2.png -------------------------------------------------------------------------------- /AirWar/laya/assets/war/hero_down3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhangxinghua0337/layaair-AirWar/8fa735334477c1f620f490851753ed8d3bdefa46/AirWar/laya/assets/war/hero_down3.png -------------------------------------------------------------------------------- /AirWar/laya/assets/war/hero_down4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhangxinghua0337/layaair-AirWar/8fa735334477c1f620f490851753ed8d3bdefa46/AirWar/laya/assets/war/hero_down4.png -------------------------------------------------------------------------------- /AirWar/laya/assets/war/hero_fly1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhangxinghua0337/layaair-AirWar/8fa735334477c1f620f490851753ed8d3bdefa46/AirWar/laya/assets/war/hero_fly1.png -------------------------------------------------------------------------------- /AirWar/laya/assets/war/hero_fly2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhangxinghua0337/layaair-AirWar/8fa735334477c1f620f490851753ed8d3bdefa46/AirWar/laya/assets/war/hero_fly2.png -------------------------------------------------------------------------------- /AirWar/src/BackGround.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * 循环滚动游戏背景 3 | */ 4 | class BackGround extends Laya.Sprite { 5 | // 定义背景1 6 | private bg1:Laya.Sprite; 7 | private bg2:Laya.Sprite; 8 | constructor(){ 9 | super(); 10 | this.init(); 11 | } 12 | init():void{ 13 | // 创建背景1 14 | this.bg1 = new Laya.Sprite(); 15 | // 加载资源路径 16 | this.bg1.loadImage("war/background.png"); 17 | // 背景图显示在容器内 18 | this.addChild(this.bg1); 19 | // 创建背景2 20 | this.bg2 = new Laya.Sprite(); 21 | this.bg2.loadImage("war/background.png"); 22 | // 更改背景2的位置 让它放在背景1的上面 23 | this.bg2.pos(0,-852) 24 | this.addChild(this.bg2); 25 | // 创建一个帧循环,更新容器的位置 26 | Laya.timer.frameLoop(1,this,this.animate); 27 | } 28 | animate():void{ 29 | // 背景容器每帧往下移动一像素 30 | this.y += 1; 31 | if(this.bg1.y + this.y >= 852){ 32 | this.bg1.y -= 852*2; 33 | } 34 | if(this.bg2.y + this.y >= 852){ 35 | this.bg2.y -= 852*2; 36 | } 37 | } 38 | 39 | } -------------------------------------------------------------------------------- /AirWar/src/Game.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Game 程序入口类 3 | */ 4 | class Game { 5 | private hero: Role; 6 | constructor(){ 7 | // 初始化引擎,这是游戏的宽高 8 | Laya.init(400,852,Laya.WebGL); 9 | let bg:BackGround = new BackGround(); 10 | Laya.stage.addChild(bg); 11 | Laya.loader.load("res/atlas/war.json",Laya.Handler.create(this,this.onLoaded),null,Laya.Loader.ATLAS); 12 | } 13 | onLoaded():void { 14 | this.hero = new Role(); 15 | this.hero.init("hero",0,1,0,30); 16 | this.hero.pos(200, 500); 17 | Laya.stage.addChild(this.hero); 18 | Laya.stage.on(Laya.Event.MOUSE_MOVE,this,this.onMouseMove); 19 | 20 | 21 | // 创建敌人 22 | //this.createEnemy(10); 23 | // 创建一个主循环 24 | Laya.timer.frameLoop(1,this,this.onLoop); 25 | } 26 | onLoop():void { 27 | // 遍历舞台上所有的飞机,更改飞机的状态 28 | for(let i:number = Laya.stage.numChildren-1; i>0; i--){ 29 | let role:Role = Laya.stage.getChildAt(i) as Role; 30 | if(role && role.speed){ 31 | // 根据飞机速度改变位置 32 | role.y += role.speed; 33 | // 敌机移动到显示区域外的话则移除掉 34 | if(role.y > 1000){ 35 | role.removeSelf(); 36 | Laya.Pool.recover("role",role); 37 | } 38 | } 39 | } 40 | // 每隔30帧创建新的敌机 41 | if(Laya.timer.currFrame%60 === 0) { 42 | this.createEnemy(2); 43 | } 44 | } 45 | onMouseMove(): void { 46 | // 让飞机根据鼠标的位置来改变 47 | this.hero.pos(Laya.stage.mouseX, Laya.stage.mouseY); 48 | } 49 | // 敌机血量 敌机速度 敌机被击半径 50 | private hps: Array = [1,2,10]; 51 | private speeds: Array = [3,2,1]; 52 | private radius: Array = [15,30,70]; 53 | createEnemy(num:number):void { 54 | for(let i:number = 0; i < num; i++){ 55 | // 随机出现敌人的随机数 56 | let r:number = Math.random(); 57 | //根据随机数,随机敌人 58 | let type: number = r < 0.7?0:r<0.95?1:2; 59 | // 创建敌人 60 | let enemy:Role = Laya.Pool.getItemByClass("role", Role); 61 | // 初始化敌人 62 | enemy.init('enemy'+(type+1),1,this.hps[type],this.speeds[type],this.radius[type]); 63 | // 随机位置 64 | enemy.pos(Math.random()*400 + 40, Math.random()*200); 65 | // 添加到舞台上 66 | Laya.stage.addChild(enemy); 67 | } 68 | } 69 | } 70 | 71 | // 启动游戏 72 | new Game(); -------------------------------------------------------------------------------- /AirWar/src/Role.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * 角色类 3 | */ 4 | class Role extends Laya.Sprite { 5 | private body: Laya.Animation; 6 | // 判断是否缓存了动画,只让动画缓存一次 7 | private static cached: boolean = false; 8 | // 飞机的类型 9 | public type: string; 10 | // 阵营 11 | public camp: number; 12 | // 飞机的血量 13 | public hp: number; 14 | // 敌机的速度 飞机越小速度越快 15 | public speed: number; 16 | // 被敌机击中的半径 17 | public hitRadius: number; 18 | 19 | constructor() { 20 | super(); 21 | // 初始化 22 | //this.init(); 23 | } 24 | public init(_type: string,_camp:number,_hp:number,_speed:number,_hitRadius:number): void { 25 | this.type = _type; 26 | this.camp = _camp; 27 | this.hp = _hp; 28 | this.speed = _speed; 29 | this.hitRadius = _hitRadius; 30 | if(!Role.cached){ 31 | // 缓存飞行动画 32 | Laya.Animation.createFrames(["war/hero_fly1.png","war/hero_fly2.png"],"hero_fly"); 33 | // 缓存击中爆炸动画 34 | Laya.Animation.createFrames(["war/hero_down1.png","war/hero_down2.png","war/hero_down3.png","war/hero_down4.png"],"hero_down"); 35 | // 缓存敌机1飞行动画 36 | Laya.Animation.createFrames(["war/enemy1_fly1.png"],"enemy1_fly"); 37 | // 缓存敌机1爆炸动画 38 | Laya.Animation.createFrames(["war/enemy1_down1.png","war/enemy1_down2.png","war/enemy1_down3.png","war/enemy1_down4.png"],"enemy1_down"); 39 | // 缓存敌机2飞行动画 40 | Laya.Animation.createFrames(["war/enemy2_fly1.png"],"enemy2_fly"); 41 | // 缓存敌机2爆炸动画 42 | Laya.Animation.createFrames(["war/enemy2_down1.png","war/enemy2_down2.png","war/enemy2_down3.png","war/enemy2_down4.png"],"enemy2_down"); 43 | // 缓存敌机2碰撞动画 44 | Laya.Animation.createFrames(["war/enemy2_hit.png"],"enemy2_hit"); 45 | // 缓存敌机3飞行动画 46 | Laya.Animation.createFrames(["war/enemy3_fly1.png","war/enemy3_fly2.png"],"enemy3_fly"); 47 | // 缓存敌机3爆炸动画 48 | Laya.Animation.createFrames(["war/enemy3_down1.png","war/enemy3_down2.png","war/enemy3_down3.png","war/enemy3_down4.png","war/enemy3_down5.png","war/enemy3_down6.png"],"enemy3_down"); 49 | // 缓存敌机3碰撞动画 50 | Laya.Animation.createFrames(["war/enemy3_hit.png"],"enemy3_hit"); 51 | } 52 | if(!this.body){ 53 | // 创建飞机机身动画 54 | this.body = new Laya.Animation(); 55 | this.addChild(this.body); 56 | } 57 | // 播放飞机动画 58 | this.palyAction("fly"); 59 | } 60 | palyAction(action:string): void { 61 | // 根据不同的动画类型类播放 62 | this.body.play(0, true, this.type + "_" + action); 63 | let bounds: Laya.Rectangle = this.body.getBounds(); 64 | // 设置机身居中 65 | this.body.pos(-bounds.width / 2 , -bounds.height / 2); 66 | } 67 | } -------------------------------------------------------------------------------- /AirWar/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "module": "commonjs", 4 | "target": "es5", 5 | "sourceMap": true 6 | }, 7 | "exclude": [ 8 | "node_modules" 9 | ] 10 | } -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 章星华 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # layaair-AirWar 2 | h5,微信小游戏,飞机大战 3 | --------------------------------------------------------------------------------