Commit 247d9195 authored by zjz1994's avatar zjz1994

Merge branch 'dev' of http://gitlab2.dui88.com/laoqifeng/zeroing-libs into zjz

parents 99081c32 564408cc
No preview for this file type
{
"liveServer.settings.port": 5501
}
\ No newline at end of file
No preview for this file type
{
"name": "赛龙舟",
"desc": "赛龙舟模块",
"props": {
"playerPositionY": {
"alias": "玩家Y轴位置",
"type": "number",
"default": 900
},
"playerPositionX": {
"alias": "玩家Y轴位置",
"type": "number",
"default": 300
},
"runScore": {
"alias": "每前进1米加分(不能小于1)",
"type": "number",
"default": 1
},
"rainScore": {
"alias": "接金币获得分数",
"type": "number",
"default": 5
},
"rain2Score": {
"alias": "接粽子获得分数",
"type": "number",
"default": 10
},
"speed": {
"alias": "道具掉落初始速度",
"type": "number",
"default": 10
},
"maxSpeed": {
"alias": "道具掉落速度上限",
"type": "number",
"default": 3
},
"playerHeight": {
"alias": "玩家高度",
"type": "number",
"default": 100
},
"playerWidth": {
"alias": "玩家宽度",
"type": "number",
"default": 100
},
"maxStageBound": {
"alias": "最大移动边距",
"type": "number",
"default": -20
},
"maxNpcBound": {
"alias": "道具随机出现的边距",
"type": "number",
"default": 100
},
"gameOverCondition": {
"alias": "游戏结束条件(1:接到炸弹死亡,2:分数负数或接到炸弹死亡)",
"type": "number",
"default": 1
},
"boomPosition1Offset": {
"alias": "奖励爆炸svga位置偏移[x,y]",
"type": "array<number>",
"default": "-80,-200"
},
"boomPosition2Offset": {
"alias": "奖励爆炸svga位置偏移[x,y]",
"type": "array<number>",
"default": "-80,-200"
},
"boomPosition3Offset": {
"alias": "障碍爆炸svga位置偏移[x,y]",
"type": "array<number>",
"default": "0,-100"
},
"playerRunPosition3Offset": {
"alias": "玩家滑动位置偏移",
"type": "array<number>",
"default": "-120,-125"
},
"playerOverPosition3Offset": {
"alias": "玩家翻船位置偏移",
"type": "array<number>",
"default": "-120,-125"
}
},
"assets": [
{
"name": "循环背景1",
"url": "//yun.duiba.com.cn/aurora/assets/a57af3e2092f421ebbb47ee7a3d30f4326b5b7cd.jpg",
"uuid": "d95a5911-1c7c-4b60-9ff1-5cb179738e91",
"ext": ".jpg"
},
{
"name": "循环背景2",
"url": "//yun.duiba.com.cn/aurora/assets/489de78a248456d9dee74d8106da3dae40c0268b.jpg",
"uuid": "2222b6d9-17cb-42a6-a0f2-54c390522ca5",
"ext": ".jpg"
},
{
"name": "金币",
"url": "//yun.duiba.com.cn/aurora/assets/6d2719418a59a95fc0db0c0b761d00b4b4519b81.png",
"uuid": "d3ce99da-89e1-447d-8c52-b3f391925c3c",
"ext": ".png"
},
{
"name": "粽子",
"url": "//yun.duiba.com.cn/aurora/assets/89ec786e36cd306225502b384ddb7550d79166c2.png",
"uuid": "02f17008-1d8d-4108-a0fc-03fbc71fd118",
"ext": ".png"
},
{
"name": "石块",
"url": "//yun.duiba.com.cn/aurora/assets/13efce5d31f114e2db9c9b0baac057bc1baf89d2.png",
"uuid": "eb88b42d-e151-4c1b-94b9-7c16f7bfac29",
"ext": ".png"
},
{
"name": "木头",
"url": "//yun.duiba.com.cn/aurora/assets/3071bf51a8cc4e1733fe7ab6549206d27be15e7c.png",
"uuid": "ab1bdabc-21ba-46bf-9299-6c638f766c88",
"ext": ".png"
},
{
"name": "碰到金币svga",
"url": "//yun.duiba.com.cn/aurora/assets/ebd0dc01e7154970bc2b1e65a6a3641aec0e319c.svga",
"uuid": "cdd2268f-ad65-4b5e-a965-ee61b730da21",
"ext": ".svga"
},
{
"name": "碰到粽子svga",
"url": "//yun.duiba.com.cn/aurora/assets/b9d21ca9758a8503dc5271949924f7cb08adcdf2.svga",
"uuid": "ce252ae3-9cc5-490b-9c18-a4111317c473",
"ext": ".svga"
},
{
"name": "碰到石头svga",
"url": "//yun.duiba.com.cn/aurora/assets/862802a8173acc1bde28dd603c7ffd2ccc426700.svga",
"uuid": "d7a3947b-7fcb-48f2-9ddf-2f075d37a619",
"ext": ".svga"
},
{
"name": "玩家翻船",
"url": "//yun.duiba.com.cn/aurora/assets/4dd3f3d80c8560d534abfd4c55f4ed758fd9c6f1.svga",
"uuid": "6338498f-78ba-4d4b-a172-85755646baf7",
"ext": ".svga"
},
{
"name": "玩家滑动",
"url": "//yun.duiba.com.cn/aurora/assets/83c888fcce01d2202a9b4ab73090b3f9e2bc11cd.svga",
"uuid": "59920d79-e5bf-46e0-a753-f4e7a1315a97",
"ext": ".svga"
},
{
"name": "玩家静止",
"url": "//yun.duiba.com.cn/aurora/assets/9e1d76f3ce486edd17c81e97782ed8afe3f66c0b.png",
"uuid": "4931d296-4421-4a2f-8299-7bab87407c72",
"ext": ".png"
}
],
"events": {
"in": {
"dragon-boat-race-reset": {
"alias": "重置",
"data": {
"goodsProbability": "[0.2,0.2,0.3,0.3]道具概率(金币、粽子、木头、石块),所有概率相加为1",
"countDown": "倒计时(s)",
"acceleratedSpeed": "道具掉落加速度(单位:每秒)"
}
},
"dragon-boat-race-start": {
"alias": "开始"
},
"dragon-boat-race-revive": {
"alias": "复活"
},
"dragon-boat-race-pause": {
"alias": "暂停"
},
"dragon-boat-race-resume": {
"alias": "恢复"
},
"dragon-boat-race-clear": {
"alias": "清空,通过reset事件恢复"
}
},
"out": {
"dragon-boat-race-score-update": {
"alias": "分数更新",
"data": {
"score": "分数"
}
},
"dragon-boat-race-time-update": {
"alias": "倒计时更新",
"data": {
"time": "剩余时间"
}
},
"dragon-boat-race-game-over": {
"alias": "游戏结束",
"data": {
"score": "分数",
"reason": "结束原因(1:时间到了,2:玩家死亡)"
}
}
}
},
"id": "dragon-boat-race",
"code": "(function (global, factory) {\n\ttypeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('tslib')) :\n\ttypeof define === 'function' && define.amd ? define(['tslib'], factory) :\n\t(global = global || self, global['dragon-boat-race'] = factory(global.tslib));\n}(this, (function (tslib) { 'use strict';\n\n\tvar props = {};\n\tfunction prepareProps() {\n\t var metaProps = getProps();\n\t engine.injectProp(props, metaProps);\n\t}\n\tfunction injectProps(p) {\n\t engine.injectProp(props, p);\n\t}\n\t//# sourceMappingURL=props.js.map\n\n\tfunction getTexture(uuid) {\n\t return engine.Texture.from(getAssetByUUID(uuid).uuid);\n\t}\n\tfunction getTextureByName(name) {\n\t return getTexture(getAssetByName(name).uuid);\n\t}\n\tfunction createSvga(name, anchorName) {\n\t var inst = new svga.Svga();\n\t inst.source = 'asset://' + getAssetByName(name).uuid;\n\t return inst;\n\t}\n\t//# sourceMappingURL=utils.js.map\n\n\tvar Goods = (function (_super) {\n\t tslib.__extends(Goods, _super);\n\t function Goods() {\n\t var _this = _super.call(this) || this;\n\t var body;\n\t body = _this._body = new engine.Rect();\n\t var rain = new engine.Sprite(getTextureByName('金币'));\n\t var rain1 = new engine.Sprite(getTextureByName('粽子'));\n\t rain[\"npcType\"] = \"rain0\";\n\t rain1[\"npcType\"] = \"rain1\";\n\t var stone = new engine.Sprite(getTextureByName('木头'));\n\t stone[\"npcType\"] = \"stone\";\n\t var boom = new engine.Sprite(getTextureByName('石块'));\n\t boom[\"npcType\"] = \"boom\";\n\t rain.visible = false;\n\t rain1.visible = false;\n\t stone.visible = false;\n\t boom.visible = false;\n\t rain.anchorX = rain.width / 2;\n\t rain1.anchorX = rain1.width / 2;\n\t stone.anchorX = stone.width / 2;\n\t boom.anchorX = boom.width / 2;\n\t rain.anchorY = rain.height / 2;\n\t rain1.anchorY = rain1.height / 2;\n\t stone.anchorY = stone.height / 2;\n\t boom.anchorY = boom.height / 2;\n\t body.addChild(rain);\n\t body.addChild(rain1);\n\t body.addChild(stone);\n\t body.addChild(boom);\n\t _this.addChild(body);\n\t body.width = .0001;\n\t body.height = .0001;\n\t body.mouseEnabled = false;\n\t return _this;\n\t }\n\t Goods.prototype.getRandomNumberByRange = function (start, end) {\n\t return Math.floor(Math.random() * (end - start) + start);\n\t };\n\t Goods.prototype.reset = function () {\n\t this[\"lifeState\"] = true;\n\t this.visible = true;\n\t this.rotation = 0;\n\t this.anchorOffsetY = 0;\n\t if (this.width <= 0) {\n\t this.anchorX = 50;\n\t }\n\t else {\n\t this.anchorX = this.width / 2;\n\t }\n\t this.anchorY = this.height / 2;\n\t this.scaleX = this.scaleY = 1;\n\t this.y = 0;\n\t this.x = ((750 - props.maxNpcBound) - 120) * Math.random() + 30 + props.maxNpcBound;\n\t this.rotation = 0;\n\t var random = Math.random();\n\t if (typeof (props.goodsProbability) == 'string') {\n\t props.goodsProbability = props.goodsProbability.split(',').map(function (i) { return +i; });\n\t console.log(props.goodsProbability);\n\t }\n\t if (random < props.goodsProbability[0]) {\n\t this.showNpc(\"rain0\");\n\t }\n\t else if (random >= props.goodsProbability[0] && random <= (props.goodsProbability[0] + props.goodsProbability[1])) {\n\t this.showNpc(\"rain1\");\n\t }\n\t else if (random >= (props.goodsProbability[0] + props.goodsProbability[1]) && random <= (props.goodsProbability[0] + props.goodsProbability[1] + props.goodsProbability[2])) {\n\t this.showNpc(\"stone\");\n\t }\n\t else if (random > (props.goodsProbability[0] + props.goodsProbability[1] + props.goodsProbability[2])) {\n\t this.showNpc(\"boom\");\n\t }\n\t };\n\t Goods.prototype.showNpc = function (type) {\n\t for (var i = 0; i < this._body.children.length; i++) {\n\t this._body.children[i].visible = false;\n\t this._body.children[i].mouseEnabled = false;\n\t }\n\t for (var i = 0; i < this._body.children.length; i++) {\n\t if (this._body.children[i][\"npcType\"] == type) {\n\t this[\"npcType\"] = type;\n\t this._body.children[i].visible = true;\n\t this._body.children[i].mouseEnabled = false;\n\t }\n\t }\n\t };\n\t Object.defineProperty(Goods.prototype, \"anchorOffsetY\", {\n\t set: function (v) {\n\t this._body.y = v;\n\t },\n\t enumerable: true,\n\t configurable: true\n\t });\n\t return Goods;\n\t}(engine.Container));\n\t//# sourceMappingURL=Goods.js.map\n\n\tvar ObjectPool = engine.ObjectPool;\n\tvar PoolName = 'goods';\n\tObjectPool.registerPool(PoolName, function () {\n\t return new Goods();\n\t}, function (item, data) {\n\t item.reset();\n\t});\n\t//# sourceMappingURL=object-pool-init.js.map\n\n\tvar ObjectPool$1 = engine.ObjectPool;\n\tvar GameView = (function (_super) {\n\t tslib.__extends(GameView, _super);\n\t function GameView() {\n\t var _this = _super.call(this) || this;\n\t _this.goodsItems = [];\n\t _this.moveCatchX = 0;\n\t _this.playerCatchX = 0;\n\t _this.onDownStage = function (e) {\n\t _this.moveCatchX = e.localX;\n\t _this.playerCatchX = _this.player.x;\n\t };\n\t _this.onMoveStage = function (e) {\n\t var maxStageBound = props.maxStageBound;\n\t if (_this.gameIng) {\n\t var playerX = _this.playerCatchX + (e.localX - _this.moveCatchX);\n\t if (playerX < maxStageBound) {\n\t _this.player.x = maxStageBound;\n\t }\n\t else if (playerX + _this.player.width + maxStageBound > 750) {\n\t _this.player.x = 750 - maxStageBound - _this.player.width;\n\t }\n\t else {\n\t _this.player.x = playerX;\n\t }\n\t }\n\t };\n\t _this.onOutStage = function (e) {\n\t _this.moveCatchX = 0;\n\t };\n\t _this.once(engine.Event.ADDED_TO_STAGE, _this.setup, _this);\n\t return _this;\n\t }\n\t GameView.prototype.setup = function () {\n\t var _this = this;\n\t if (this._hasSetup) {\n\t return;\n\t }\n\t this._hasSetup = true;\n\t this.bg = new engine.Container();\n\t this.bg.mouseEnabled = false;\n\t this.addChild(this.bg);\n\t this.NpcBg = new engine.Container();\n\t this.NpcBg.alpha = 1;\n\t this.NpcBg.width = 0;\n\t this.NpcBg.height = 0;\n\t this.addChild(this.NpcBg);\n\t this.player = new engine.Container();\n\t this.player.mouseEnabled = false;\n\t this.player.mouseChildren = false;\n\t this.labelScore = new engine.BitmapText();\n\t this.labelScore.font = props.fontName;\n\t this.labelScore.scaleX = this.labelScore.scaleY = 1;\n\t this.addChild(this.labelScore);\n\t this.waterSvga = createSvga(\"碰到金币svga\");\n\t this.water2Svga = createSvga(\"碰到粽子svga\");\n\t this.boomSvga = createSvga(\"碰到石头svga\");\n\t this.playerSvgaReset = new engine.Sprite(getTextureByName('玩家静止'));\n\t this.playerSvgaRun = createSvga(\"玩家滑动\");\n\t this.playerSvgaOver = createSvga(\"玩家翻船\");\n\t this.bg1 = new engine.Sprite(getTextureByName('循环背景1'));\n\t this.bg2 = new engine.Sprite(getTextureByName('循环背景2'));\n\t this.bg3 = new engine.Sprite(getTextureByName('循环背景1'));\n\t this.bg4 = new engine.Sprite(getTextureByName('循环背景2'));\n\t this.player.addChild(this.playerSvgaReset);\n\t this.player.addChild(this.playerSvgaRun);\n\t this.player.addChild(this.playerSvgaOver);\n\t this.addChild(this.waterSvga);\n\t this.addChild(this.water2Svga);\n\t this.addChild(this.boomSvga);\n\t this.addChild(this.player);\n\t this.bg.addChild(this.bg1);\n\t this.bg.addChild(this.bg2);\n\t this.bg.addChild(this.bg3);\n\t this.bg.addChild(this.bg4);\n\t this.waterSvga.visible = false;\n\t this.water2Svga.visible = false;\n\t this.boomSvga.visible = false;\n\t this.setPlayState(this.playerSvgaReset);\n\t this.visible = false;\n\t setTimeout(function () {\n\t _this.visible = true;\n\t _this.player.x = props.playerPositionX;\n\t _this.player.y = props.playerPositionY;\n\t _this.playerSvgaRun.x = props.playerRunPosition3Offset[0];\n\t _this.playerSvgaRun.y = props.playerRunPosition3Offset[1];\n\t _this.playerSvgaOver.x = props.playerOverPosition3Offset[0];\n\t _this.playerSvgaOver.y = props.playerOverPosition3Offset[1];\n\t _this.bg1.y = 0;\n\t _this.bg2.y = _this.bg1.height;\n\t _this.bg3.y = _this.bg1.height + _this.bg2.height;\n\t _this.bg4.y = _this.bg1.height + _this.bg2.height + _this.bg3.height;\n\t engine.Tween.get(_this.playerSvgaReset, { loop: true })\n\t .to({ y: 10 }, 500)\n\t .to({ y: 0 }, 500)\n\t .to({ y: 10 }, 500)\n\t .call(function () { });\n\t }, 300);\n\t this.rectBg = new engine.Container();\n\t this.rectBg.alpha = 0;\n\t this.rectBg.width = 750;\n\t this.rectBg.height = 1624;\n\t this.addChild(this.rectBg);\n\t this.rectBg.addEventListener(engine.MouseEvent.MOUSE_DOWN, this.onDownStage, this);\n\t this.rectBg.addEventListener(engine.MouseEvent.MOUSE_MOVE, this.onMoveStage, this);\n\t this.rectBg.addEventListener(engine.MouseEvent.MOUSE_OUT, this.onOutStage, this);\n\t this.rectBg.addEventListener(engine.Event.ENTER_FRAME, this.enterFrame, this);\n\t };\n\t GameView.prototype.setBoomPosition = function (svga, callback) {\n\t svga.x = this.player.x;\n\t svga.y = this.player.y;\n\t if (svga == this.waterSvga) {\n\t svga.x += props.boomPosition1Offset[0];\n\t svga.y += props.boomPosition1Offset[1];\n\t }\n\t else if (svga == this.water2Svga) {\n\t svga.x += props.boomPosition2Offset[0];\n\t svga.y += props.boomPosition2Offset[1];\n\t }\n\t else if (svga == this.boomSvga) {\n\t svga.x += props.boomPosition3Offset[0];\n\t svga.y += props.boomPosition3Offset[1];\n\t }\n\t svga.visible = true;\n\t svga.play(true, false);\n\t svga.once(engine.Event.END_FRAME, function () {\n\t svga.visible = false;\n\t if (callback) {\n\t callback();\n\t }\n\t }, this);\n\t };\n\t GameView.prototype.enterFrame = function () {\n\t if (this.bg.y >= 0) {\n\t this.bg.y = -this.bg3.y;\n\t }\n\t if (this.gameIng) {\n\t this.bg.y += (4 * this.speed);\n\t }\n\t };\n\t GameView.prototype.reset = function () {\n\t this.recycleGoods();\n\t this.score = 0;\n\t this.speed = props.speed;\n\t this.bg.y = -this.bg3.y;\n\t this.player.anchorY = this.player.height / 2;\n\t this.player.anchorX = this.player.width / 2;\n\t this.player.x = props.playerPositionX;\n\t this.player.y = props.playerPositionY;\n\t this.setPlayState(this.playerSvgaReset);\n\t };\n\t GameView.prototype.setPlayState = function (svga) {\n\t this.playerSvgaReset.visible = false;\n\t this.playerSvgaRun.visible = false;\n\t this.playerSvgaOver.visible = false;\n\t console.log(svga);\n\t svga.visible = true;\n\t if (svga == this.playerSvgaOver) {\n\t svga.play(false, false);\n\t svga.once(engine.Event.END_FRAME, function () {\n\t }, this);\n\t }\n\t else if (svga == this.playerSvgaRun) {\n\t svga.play();\n\t }\n\t };\n\t GameView.prototype.start = function () {\n\t var _this = this;\n\t this.gameIng = true;\n\t this.creatNpc();\n\t this.beginNpc();\n\t this.countdown = props.countDown;\n\t this.setPlayState(this.playerSvgaRun);\n\t this.countdownTimer = setInterval(function () {\n\t if (_this.gameIng) {\n\t if (_this.countdown > 0) {\n\t engine.globalEvent.dispatchEvent('dragon-boat-race-time-update', {\n\t time: _this.countdown,\n\t });\n\t _this.countdown -= 1;\n\t }\n\t else {\n\t engine.globalEvent.dispatchEvent('dragon-boat-race-game-over', {\n\t score: _this.score,\n\t reason: 1\n\t });\n\t _this.died();\n\t }\n\t _this.score += Math.round(_this.speed * props.runScore);\n\t engine.globalEvent.dispatchEvent('dragon-boat-race-score-update', {\n\t score: _this.score,\n\t });\n\t }\n\t }, 1000);\n\t };\n\t GameView.prototype.beginNpc = function () {\n\t var _this = this;\n\t this.timer = setTimeout(function () {\n\t if (_this.gameIng) {\n\t _this.speed += props.acceleratedSpeed;\n\t _this.speed += props.acceleratedSpeed;\n\t if (_this.speed > props.maxSpeed) {\n\t _this.speed = props.maxSpeed;\n\t }\n\t _this.creatNpc();\n\t }\n\t _this.beginNpc();\n\t }, 2000 / this.speed);\n\t };\n\t GameView.prototype.pause = function () {\n\t this.gameIng = false;\n\t };\n\t GameView.prototype.revive = function () {\n\t this.gameIng = true;\n\t };\n\t GameView.prototype.resume = function () {\n\t this.reset();\n\t this.start();\n\t };\n\t GameView.prototype.creatNpc = function () {\n\t var _this = this;\n\t var goods = this._goods = ObjectPool$1.getObject(PoolName);\n\t this.goodsItems.push(goods);\n\t this.NpcBg.addChild(goods);\n\t goods.addEventListener(engine.Event.ENTER_FRAME, goods[\"onGoodsEnter\"] = function () {\n\t if (goods.y > 1624) {\n\t _this.removeNpc(goods);\n\t }\n\t else {\n\t if (_this.gameIng) {\n\t goods.y += (4 * _this.speed);\n\t if (goods[\"lifeState\"] && _this.hasHit(_this.player, goods)) {\n\t goods[\"lifeState\"] = false;\n\t if (goods[\"npcType\"] == \"rain0\") {\n\t console.log(\"碰到雨滴\");\n\t _this.score += props.rainScore;\n\t if (_this.score < 0) {\n\t _this.score = 0;\n\t }\n\t _this.setBoomPosition(_this.waterSvga);\n\t engine.Tween.get(goods, null, null, true)\n\t .to({ scaleX: 0, scaleY: 0 }, 200)\n\t .call(function () { _this.removeNpc(goods); });\n\t }\n\t else if (goods[\"npcType\"] == \"rain1\") {\n\t console.log(\"碰到雨滴\");\n\t _this.score += props.rain2Score;\n\t if (_this.score < 0) {\n\t _this.score = 0;\n\t }\n\t _this.setBoomPosition(_this.water2Svga);\n\t engine.Tween.get(goods, null, null, true)\n\t .to({ scaleX: 0, scaleY: 0 }, 200)\n\t .call(function () { _this.removeNpc(goods); });\n\t }\n\t else if (goods[\"npcType\"] == \"boom\" || goods[\"npcType\"] == \"stone\") {\n\t console.log(\"碰到炸弹\");\n\t _this.setBoomPosition(_this.boomSvga, function () {\n\t engine.globalEvent.dispatchEvent('dragon-boat-race-game-over', {\n\t score: _this.score,\n\t reason: 2\n\t });\n\t _this.died();\n\t });\n\t _this.setPlayState(_this.playerSvgaOver);\n\t _this.pause();\n\t }\n\t engine.globalEvent.dispatchEvent('dragon-boat-race-score-update', {\n\t score: _this.score,\n\t });\n\t }\n\t }\n\t }\n\t }, this);\n\t };\n\t GameView.prototype.died = function () {\n\t this.score = 0;\n\t this.pause();\n\t };\n\t GameView.prototype.removeNpc = function (goods) {\n\t this.NpcBg.removeChild(goods);\n\t ObjectPool$1.recycleObject(PoolName, goods);\n\t goods.removeEventListener(engine.Event.ENTER_FRAME, goods[\"onGoodsEnter\"], this);\n\t var index = this.goodsItems.indexOf(goods);\n\t if (index > -1) {\n\t this.goodsItems.splice(index, 1);\n\t }\n\t };\n\t GameView.prototype.recycleGoods = function () {\n\t clearTimeout(this.timer);\n\t clearInterval(this.countdownTimer);\n\t for (var _i = 0, _a = this.goodsItems; _i < _a.length; _i++) {\n\t var goods = _a[_i];\n\t if (goods) {\n\t this.NpcBg.removeChild(goods);\n\t ObjectPool$1.recycleObject(PoolName, goods);\n\t goods.removeEventListener(engine.Event.ENTER_FRAME, goods[\"onGoodsEnter\"], this);\n\t }\n\t }\n\t this.goodsItems = [];\n\t };\n\t GameView.prototype.hasHit = function (a, b) {\n\t var playerH = a.height;\n\t var playerW = a.width;\n\t var playerX = a.x;\n\t if (props.playerHeight) {\n\t playerH = props.playerHeight;\n\t }\n\t if (props.playerWidth) {\n\t playerW = props.playerWidth;\n\t playerX = a.x + (a.width - props.playerWidth) / 2;\n\t }\n\t if (Math.abs((playerX + playerW / 2) - (b.x + b.width / 2)) < playerW / 2 + b.width / 2\n\t &&\n\t Math.abs((a.y + playerH / 1.3) - (b.y + b.height / 2)) < playerH / 2 + b.height / 2) {\n\t return true;\n\t }\n\t else {\n\t return false;\n\t }\n\t };\n\t return GameView;\n\t}(engine.Container));\n\n\tvar GameWrapper = (function (_super) {\n\t tslib.__extends(GameWrapper, _super);\n\t function GameWrapper() {\n\t var _this = _super.call(this) || this;\n\t engine.globalEvent.addEventListener('dragon-boat-race-reset', _this.reset, _this);\n\t engine.globalEvent.addEventListener('dragon-boat-race-start', _this.start, _this);\n\t engine.globalEvent.addEventListener('dragon-boat-race-pause', _this.pause, _this);\n\t engine.globalEvent.addEventListener('dragon-boat-race-resume', _this.resume, _this);\n\t engine.globalEvent.addEventListener('dragon-boat-race-revive', _this.revive, _this);\n\t engine.globalEvent.addEventListener('dragon-boat-race-clear', _this.clear, _this);\n\t _this.addEventListener(engine.MouseEvent.CLICK, _this.onTap, _this);\n\t var gameView = _this._gameView = new GameView();\n\t _this.addChild(gameView);\n\t return _this;\n\t }\n\t GameWrapper.prototype.reset = function (event) {\n\t injectProps(event.data);\n\t this._gameView.visible = true;\n\t this._gameView.reset();\n\t };\n\t GameWrapper.prototype.start = function (event) {\n\t injectProps(event.data);\n\t this._status = 1;\n\t this._gameView.start();\n\t };\n\t GameWrapper.prototype.pause = function () {\n\t this._gameView.pause();\n\t };\n\t GameWrapper.prototype.resume = function () {\n\t this._gameView.resume();\n\t };\n\t GameWrapper.prototype.revive = function () {\n\t this._gameView.revive();\n\t };\n\t GameWrapper.prototype.clear = function () {\n\t this._gameView.visible = false;\n\t };\n\t GameWrapper.prototype.onTap = function (event) {\n\t };\n\t return GameWrapper;\n\t}(engine.Container));\n\t//# sourceMappingURL=GameWrapper.js.map\n\n\tfunction index (props) {\n\t prepareProps();\n\t injectProps(props);\n\t var instance = new GameWrapper();\n\t return instance;\n\t}\n\t//# sourceMappingURL=index.js.map\n\n\treturn index;\n\n})));\n"
}
{
"name": "接粽子",
"desc": "接粽子模块",
"props": {
"playerPositionY": {
"alias": "玩家Y轴位置",
"type": "number",
"default": 900
},
"rainScore": {
"alias": "接中雨滴获得分数",
"type": "number",
"default": 1
},
"stoneScore": {
"alias": "接中石块获得分数",
"type": "number",
"default": -1
},
"speed": {
"alias": "道具掉落初始速度",
"type": "number",
"default": 1
},
"maxSpeed": {
"alias": "道具掉落速度上限",
"type": "number",
"default": 3
},
"playerHeight": {
"alias": "玩家高度",
"type": "number",
"default": 100
},
"playerWidth": {
"alias": "玩家宽度",
"type": "number",
"default": 100
},
"maxStageBound": {
"alias": "最大移动边距",
"type": "number",
"default": -20
},
"gameOverCondition": {
"alias": "游戏结束条件(1:接到炸弹死亡,2:分数负数或接到炸弹死亡)",
"type": "number",
"default": 1
},
"boomPosition1Offset": {
"alias": "爆炸svga位置偏移[x,y]",
"type": "array<number>",
"default": "0,0"
},
"boomPosition2Offset": {
"alias": "爆炸svga位置偏移[x,y]",
"type": "array<number>",
"default": "0,0"
},
"boomPosition3Offset": {
"alias": "爆炸svga位置偏移[x,y]",
"type": "array<number>",
"default": "-100,-100"
}
},
"assets": [
{
"name": "雨滴0",
"url": "//yun.duiba.com.cn/aurora/assets/badb3627bbcc75276a3eed53daa8b0a454ced6eb.png",
"uuid": "d3ce99da-89e1-447d-8c52-b3f391925c3c",
"ext": ".png"
},
{
"name": "雨滴1",
"url": "//yun.duiba.com.cn/aurora/assets/5cc0092913c571eeb52317b8e1e0dc715793049c.png",
"uuid": "02f17008-1d8d-4108-a0fc-03fbc71fd118",
"ext": ".png"
},
{
"name": "雨滴2",
"url": "//yun.duiba.com.cn/aurora/assets/4b938949b85d50b36ef0f66450643495efbf7580.png",
"uuid": "46aa4f8a-9a6c-4210-8ffd-92da0dd3bc75",
"ext": ".png"
},
{
"name": "炸弹",
"url": "//yun.duiba.com.cn/aurora/assets/171e92283cd13c013ee1b76d28d252ff08815d47.png",
"uuid": "eb88b42d-e151-4c1b-94b9-7c16f7bfac29",
"ext": ".png"
},
{
"name": "石块",
"url": "//yun.duiba.com.cn/aurora/assets/99b0af0c59fe79a415a3f032149cfacc27e3ac2c.png",
"uuid": "ab1bdabc-21ba-46bf-9299-6c638f766c88",
"ext": ".png"
},
{
"name": "水花",
"url": "//yun.duiba.com.cn/aurora/assets/11b1f49fa3afa3a48f1dd3e3c1eb294e3fa9d886.svga",
"uuid": "cdd2268f-ad65-4b5e-a965-ee61b730da21",
"ext": ".svga"
},
{
"name": "石头svga",
"url": "//yun.duiba.com.cn/aurora/assets/01aa6fcb33aa8231f075257026eab2f0aeb3c27a.svga",
"uuid": "846a139d-0990-4db4-a323-f22379932ee4",
"ext": ".svga"
},
{
"name": "炸弹svga",
"url": "//yun.duiba.com.cn/aurora/assets/3b58e7ace031b09c651cf8e7202f9c86e86852c9.svga",
"uuid": "d7a3947b-7fcb-48f2-9ddf-2f075d37a619",
"ext": ".svga"
},
{
"name": "玩家",
"url": "//yun.duiba.com.cn/aurora/assets/db0130d36ef79865be9c753ea0627027f16341d8.png",
"uuid": "4931d296-4421-4a2f-8299-7bab87407c72",
"ext": ".png"
}
],
"events": {
"in": {
"food-fell-reset": {
"alias": "重置",
"data": {
"goodsProbability": "[0.2,0.5,0.3]道具概率(雨滴、石头、炸弹),所有概率相加为1",
"countDown": "倒计时(s)",
"acceleratedSpeed": "道具掉落加速度(单位:每秒)"
}
},
"food-fell-start": {
"alias": "开始"
},
"food-fell-revive": {
"alias": "复活"
},
"food-fell-pause": {
"alias": "暂停"
},
"food-fell-resume": {
"alias": "恢复"
},
"food-fell-clear": {
"alias": "清空,通过reset事件恢复"
}
},
"out": {
"food-fell-score-update": {
"alias": "分数更新",
"data": {
"score": "分数"
}
},
"food-fell-time-update": {
"alias": "倒计时更新",
"data": {
"time": "剩余时间"
}
},
"food-fell-game-over": {
"alias": "游戏结束",
"data": {
"score": "分数",
"reason": "结束原因(1:时间到了,2:玩家死亡)"
}
}
}
},
"id": "food-fell2",
"code": "(function (global, factory) {\n\ttypeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('tslib')) :\n\ttypeof define === 'function' && define.amd ? define(['tslib'], factory) :\n\t(global = global || self, global['food-fell2'] = factory(global.tslib));\n}(this, (function (tslib) { 'use strict';\n\n\tvar props = {};\n\tfunction prepareProps() {\n\t var metaProps = getProps();\n\t engine.injectProp(props, metaProps);\n\t}\n\tfunction injectProps(p) {\n\t engine.injectProp(props, p);\n\t}\n\n\tfunction getTextureByName(name) {\n\t return engine.Texture.from(getAssetByName(name).uuid);\n\t}\n\tfunction createSvga(name, anchorName) {\n\t var inst = new svga.Svga();\n\t inst.source = 'asset://' + getAssetByName(name).uuid;\n\t return inst;\n\t}\n\n\tvar Goods = (function (_super) {\n\t tslib.__extends(Goods, _super);\n\t function Goods() {\n\t var _this = _super.call(this) || this;\n\t var body;\n\t body = _this._body = new engine.Rect();\n\t var rain = new engine.Sprite(getTextureByName('雨滴0'));\n\t var rain1 = new engine.Sprite(getTextureByName('雨滴1'));\n\t var rain2 = new engine.Sprite(getTextureByName('雨滴2'));\n\t rain[\"npcType\"] = \"rain0\";\n\t rain1[\"npcType\"] = \"rain1\";\n\t rain2[\"npcType\"] = \"rain2\";\n\t var stone = new engine.Sprite(getTextureByName('石块'));\n\t stone[\"npcType\"] = \"stone\";\n\t var boom = new engine.Sprite(getTextureByName('炸弹'));\n\t boom[\"npcType\"] = \"boom\";\n\t rain.visible = false;\n\t rain1.visible = false;\n\t rain2.visible = false;\n\t stone.visible = false;\n\t boom.visible = false;\n\t body.addChild(rain);\n\t body.addChild(rain1);\n\t body.addChild(rain2);\n\t body.addChild(stone);\n\t body.addChild(boom);\n\t _this.addChild(body);\n\t body.width = .0001;\n\t body.height = .0001;\n\t body.mouseEnabled = false;\n\t return _this;\n\t }\n\t Goods.prototype.getRandomNumberByRange = function (start, end) {\n\t return Math.floor(Math.random() * (end - start) + start);\n\t };\n\t Goods.prototype.reset = function () {\n\t this.visible = true;\n\t this.rotation = 0;\n\t this.anchorOffsetY = 0;\n\t this.y = 0;\n\t this.x = (750 - 120) * Math.random() + 30;\n\t this.rotation = 0;\n\t var random = Math.random();\n\t if (typeof (props.goodsProbability) == 'string') {\n\t props.goodsProbability = props.goodsProbability.split(',').map(function (i) { return +i; });\n\t }\n\t if (random < props.goodsProbability[0]) {\n\t var randomNum = Math.floor(Math.random() * 3);\n\t this.showNpc(\"rain\" + randomNum);\n\t }\n\t else if (random >= props.goodsProbability[0] && random <= (props.goodsProbability[0] + props.goodsProbability[1])) {\n\t this.showNpc(\"stone\");\n\t }\n\t else if (random > (props.goodsProbability[0] + props.goodsProbability[1])) {\n\t this.showNpc(\"boom\");\n\t }\n\t };\n\t Goods.prototype.showNpc = function (type) {\n\t for (var i = 0; i < this._body.children.length; i++) {\n\t this._body.children[i].visible = false;\n\t this._body.children[i].mouseEnabled = false;\n\t }\n\t for (var i = 0; i < this._body.children.length; i++) {\n\t if (this._body.children[i][\"npcType\"] == type) {\n\t this[\"npcType\"] = type;\n\t this._body.children[i].visible = true;\n\t this._body.children[i].mouseEnabled = false;\n\t }\n\t }\n\t };\n\t Object.defineProperty(Goods.prototype, \"anchorOffsetY\", {\n\t set: function (v) {\n\t this._body.y = v;\n\t },\n\t enumerable: true,\n\t configurable: true\n\t });\n\t return Goods;\n\t}(engine.Container));\n\n\tvar ObjectPool = engine.ObjectPool;\n\tvar PoolName = 'goods';\n\tObjectPool.registerPool(PoolName, function () {\n\t return new Goods();\n\t}, function (item, data) {\n\t item.reset();\n\t});\n\n\tvar ObjectPool$1 = engine.ObjectPool;\n\tvar GameView = (function (_super) {\n\t tslib.__extends(GameView, _super);\n\t function GameView() {\n\t var _this = _super.call(this) || this;\n\t _this.goodsItems = [];\n\t _this.viewVisible = true;\n\t _this.cacheTime = 0;\n\t _this.cacheTime2 = 0;\n\t _this.moveCatchX = 0;\n\t _this.playerCatchX = 0;\n\t _this.onDownStage = function (e) {\n\t _this.moveCatchX = e.localX;\n\t _this.playerCatchX = _this.player.x;\n\t };\n\t _this.onMoveStage = function (e) {\n\t var maxStageBound = props.maxStageBound;\n\t if (_this.gameIng) {\n\t var playerX = _this.playerCatchX + (e.localX - _this.moveCatchX);\n\t if (playerX < maxStageBound) {\n\t _this.player.x = maxStageBound;\n\t }\n\t else if (playerX + _this.player.width + maxStageBound > 750) {\n\t _this.player.x = 750 - maxStageBound - _this.player.width;\n\t }\n\t else {\n\t _this.player.x = playerX;\n\t }\n\t }\n\t };\n\t _this.onOutStage = function (e) {\n\t _this.moveCatchX = 0;\n\t };\n\t _this.once(engine.Event.ADDED_TO_STAGE, _this.setup, _this);\n\t return _this;\n\t }\n\t GameView.prototype.setup = function () {\n\t var _this = this;\n\t if (this._hasSetup) {\n\t return;\n\t }\n\t this._hasSetup = true;\n\t this.NpcBg = new engine.Container();\n\t this.NpcBg.alpha = 1;\n\t this.NpcBg.width = 0;\n\t this.NpcBg.height = 0;\n\t this.addChild(this.NpcBg);\n\t this.player = new engine.Container();\n\t this.player.mouseEnabled = false;\n\t this.addChild(this.player);\n\t this.waterSvga = createSvga(\"水花\");\n\t this.stoneSvga = createSvga(\"石头svga\");\n\t this.playerSvga = new engine.Sprite(getTextureByName('玩家'));\n\t this.boomSvga = createSvga(\"炸弹svga\");\n\t this.player.addChild(this.playerSvga);\n\t this.player.addChild(this.stoneSvga);\n\t this.player.addChild(this.waterSvga);\n\t this.player.addChild(this.boomSvga);\n\t this.waterSvga.visible = false;\n\t this.stoneSvga.visible = false;\n\t this.boomSvga.visible = false;\n\t this.visible = false;\n\t setTimeout(function () {\n\t _this.visible = true;\n\t _this.player.anchorY = _this.player.height / 2;\n\t _this.player.anchorX = _this.player.width / 2;\n\t _this.player.x = 375 - _this.player.width / 2;\n\t _this.player.y = props.playerPositionY;\n\t _this.stoneSvga.x = _this.player.width / 2 - _this.stoneSvga.width / 2 + props.boomPosition1Offset[0];\n\t _this.stoneSvga.y = _this.player.height / 2 - _this.stoneSvga.height / 2 + props.boomPosition1Offset[1];\n\t _this.waterSvga.x = _this.player.width / 2 - _this.waterSvga.width / 2 + props.boomPosition2Offset[0];\n\t _this.waterSvga.y = _this.player.height / 2 - _this.waterSvga.height / 2 + props.boomPosition2Offset[1];\n\t _this.boomSvga.x = _this.player.width / 2 - _this.boomSvga.width / 2 + props.boomPosition3Offset[0];\n\t _this.boomSvga.y = _this.player.height / 2 - _this.boomSvga.height / 2 + props.boomPosition3Offset[1];\n\t }, 300);\n\t this.rectBg = new engine.Container();\n\t this.rectBg.alpha = 0;\n\t this.rectBg.width = 750;\n\t this.rectBg.height = 1624;\n\t this.addChild(this.rectBg);\n\t this.rectBg.addEventListener(engine.MouseEvent.MOUSE_DOWN, this.onDownStage, this);\n\t this.rectBg.addEventListener(engine.MouseEvent.MOUSE_MOVE, this.onMoveStage, this);\n\t this.rectBg.addEventListener(engine.MouseEvent.MOUSE_OUT, this.onOutStage, this);\n\t document.addEventListener(\"visibilitychange\", function () {\n\t if (document.visibilityState == \"visible\") {\n\t _this.viewVisible = true;\n\t }\n\t if (document.visibilityState == \"hidden\") {\n\t _this.viewVisible = false;\n\t }\n\t });\n\t this.addEventListener(engine.Event.ENTER_FRAME, this.enterFrame, this);\n\t };\n\t GameView.prototype.enterFrame = function () {\n\t this.updateTime();\n\t this.updateTimeBeginNpc();\n\t };\n\t GameView.prototype.reset = function () {\n\t this.score = props.speed;\n\t this.recycleGoods();\n\t this.player.x = 375 - this.player.width / 2;\n\t };\n\t GameView.prototype.start = function () {\n\t this.score = 0;\n\t this.speed = 1;\n\t this.gameIng = true;\n\t this.beginNpc();\n\t this.countdown = props.countDown;\n\t };\n\t GameView.prototype.updateTime = function () {\n\t if (Date.now() - this.cacheTime > 1000) {\n\t this.cacheTime = Date.now();\n\t }\n\t else {\n\t return;\n\t }\n\t if (this.gameIng) {\n\t if (this.countdown > 0) {\n\t engine.globalEvent.dispatchEvent('food-fell-time-update', {\n\t time: this.countdown,\n\t });\n\t this.countdown -= 1;\n\t }\n\t else {\n\t engine.globalEvent.dispatchEvent('food-fell-game-over', {\n\t score: this.score,\n\t reason: 1\n\t });\n\t this.died();\n\t }\n\t }\n\t };\n\t GameView.prototype.beginNpc = function () {\n\t };\n\t GameView.prototype.updateTimeBeginNpc = function () {\n\t if (Date.now() - this.cacheTime2 > (2000 / this.speed)) {\n\t this.cacheTime2 = Date.now();\n\t }\n\t else {\n\t return;\n\t }\n\t if (this.gameIng) {\n\t this.speed += props.acceleratedSpeed;\n\t if (this.speed >= props.maxSpeed) {\n\t this.speed = props.maxSpeed;\n\t }\n\t this.creatNpc();\n\t }\n\t };\n\t GameView.prototype.pause = function () {\n\t this.gameIng = false;\n\t };\n\t GameView.prototype.revive = function () {\n\t this.gameIng = true;\n\t };\n\t GameView.prototype.resume = function () {\n\t this.reset();\n\t this.start();\n\t };\n\t GameView.prototype.creatNpc = function () {\n\t var _this = this;\n\t var goods = this._goods = ObjectPool$1.getObject(PoolName);\n\t this.goodsItems.push(goods);\n\t this.NpcBg.addChild(goods);\n\t goods.addEventListener(engine.Event.ENTER_FRAME, goods[\"onGoodsEnter\"] = function () {\n\t if (goods.y > 1624) {\n\t _this.removeNpc(goods);\n\t }\n\t else {\n\t if (_this.gameIng) {\n\t goods.y += (4 * _this.speed);\n\t if (_this.hasHit(_this.player, goods)) {\n\t if (goods[\"npcType\"].indexOf(\"rain\") > -1) {\n\t _this.score += props.rainScore;\n\t _this.waterSvga.visible = true;\n\t _this.waterSvga.play(false, false);\n\t _this.waterSvga.once(engine.Event.END_FRAME, function () {\n\t _this.waterSvga.visible = false;\n\t }, _this);\n\t if (_this.score < 0) {\n\t _this.score = 0;\n\t }\n\t }\n\t else if (goods[\"npcType\"] == \"stone\") {\n\t _this.score += props.stoneScore;\n\t if (_this.score < 0) {\n\t _this.score = 0;\n\t }\n\t _this.stoneSvga.visible = true;\n\t _this.stoneSvga.play(false, false);\n\t _this.stoneSvga.once(engine.Event.END_FRAME, function () {\n\t _this.stoneSvga.visible = false;\n\t }, _this);\n\t }\n\t else if (goods[\"npcType\"] == \"boom\") {\n\t _this.boomSvga.visible = true;\n\t _this.boomSvga.play(false, false);\n\t _this.died();\n\t _this.boomSvga.once(engine.Event.END_FRAME, function () {\n\t _this.boomSvga.visible = false;\n\t engine.globalEvent.dispatchEvent('food-fell-game-over', {\n\t score: _this.score,\n\t reason: 2\n\t });\n\t }, _this);\n\t }\n\t engine.globalEvent.dispatchEvent('food-fell-score-update', {\n\t score: _this.score,\n\t });\n\t _this.removeNpc(goods);\n\t }\n\t }\n\t }\n\t }, this);\n\t };\n\t GameView.prototype.died = function () {\n\t this.pause();\n\t };\n\t GameView.prototype.removeNpc = function (goods) {\n\t this.NpcBg.removeChild(goods);\n\t ObjectPool$1.recycleObject(PoolName, goods);\n\t goods.removeEventListener(engine.Event.ENTER_FRAME, goods[\"onGoodsEnter\"], this);\n\t var index = this.goodsItems.indexOf(goods);\n\t if (index > -1) {\n\t this.goodsItems.splice(index, 1);\n\t }\n\t };\n\t GameView.prototype.recycleGoods = function () {\n\t clearTimeout(this.timer);\n\t clearInterval(this.countdownTimer);\n\t for (var _i = 0, _a = this.goodsItems; _i < _a.length; _i++) {\n\t var goods = _a[_i];\n\t if (goods) {\n\t this.NpcBg.removeChild(goods);\n\t ObjectPool$1.recycleObject(PoolName, goods);\n\t goods.removeEventListener(engine.Event.ENTER_FRAME, goods[\"onGoodsEnter\"], this);\n\t }\n\t }\n\t this.goodsItems = [];\n\t };\n\t GameView.prototype.hasHit = function (a, b) {\n\t var playerH = a.height;\n\t var playerW = a.width;\n\t var playerX = a.x;\n\t if (props.playerHeight) {\n\t playerH = props.playerHeight;\n\t }\n\t if (props.playerWidth) {\n\t playerW = props.playerWidth;\n\t playerX = a.x + (a.width - props.playerWidth) / 2;\n\t }\n\t if (Math.abs((playerX + playerW / 2) - (b.x + b.width / 2)) < playerW / 2 + b.width / 2\n\t &&\n\t Math.abs((a.y + playerH / 1.3) - (b.y + b.height / 2)) < playerH / 2 + b.height / 2) {\n\t return true;\n\t }\n\t else {\n\t return false;\n\t }\n\t };\n\t return GameView;\n\t}(engine.Container));\n\n\tvar GameWrapper = (function (_super) {\n\t tslib.__extends(GameWrapper, _super);\n\t function GameWrapper() {\n\t var _this = _super.call(this) || this;\n\t engine.globalEvent.addEventListener('food-fell-reset', _this.reset, _this);\n\t engine.globalEvent.addEventListener('food-fell-start', _this.start, _this);\n\t engine.globalEvent.addEventListener('food-fell-pause', _this.pause, _this);\n\t engine.globalEvent.addEventListener('food-fell-resume', _this.resume, _this);\n\t engine.globalEvent.addEventListener('food-fell-revive', _this.revive, _this);\n\t engine.globalEvent.addEventListener('food-fell-clear', _this.clear, _this);\n\t _this.addEventListener(engine.MouseEvent.CLICK, _this.onTap, _this);\n\t var gameView = _this._gameView = new GameView();\n\t _this.addChild(gameView);\n\t return _this;\n\t }\n\t GameWrapper.prototype.reset = function (event) {\n\t injectProps(event.data);\n\t this._gameView.visible = true;\n\t this._gameView.reset();\n\t };\n\t GameWrapper.prototype.start = function (event) {\n\t injectProps(event.data);\n\t this._status = 1;\n\t this._gameView.start();\n\t };\n\t GameWrapper.prototype.pause = function () {\n\t this._gameView.pause();\n\t };\n\t GameWrapper.prototype.resume = function () {\n\t this._gameView.resume();\n\t };\n\t GameWrapper.prototype.revive = function () {\n\t this._gameView.revive();\n\t };\n\t GameWrapper.prototype.clear = function () {\n\t this._gameView.visible = false;\n\t };\n\t GameWrapper.prototype.onTap = function (event) {\n\t };\n\t return GameWrapper;\n\t}(engine.Container));\n\n\tfunction index (props) {\n\t prepareProps();\n\t injectProps(props);\n\t var instance = new GameWrapper();\n\t return instance;\n\t}\n\n\treturn index;\n\n})));\n"
}
......@@ -398,5 +398,5 @@
}
},
"id": "jump-high",
"code": "(function (global, factory) {\n\ttypeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('tslib')) :\n\ttypeof define === 'function' && define.amd ? define(['tslib'], factory) :\n\t(global = global || self, global['jump-high'] = factory(global.tslib));\n}(this, (function (tslib) { 'use strict';\n\n\tvar props = {};\n\tfunction prepareProps() {\n\t var metaProps = getProps();\n\t engine.injectProp(props, metaProps);\n\t}\n\tfunction injectProps(p) {\n\t engine.injectProp(props, p);\n\t}\n\n\tfunction getTexture(uuid) {\n\t return engine.Texture.from(getAssetByUUID(uuid).uuid);\n\t}\n\tfunction getTextureByName(name) {\n\t return getTexture(engine.getAssetByName(name).uuid);\n\t}\n\tfunction getBlockAsset(type) {\n\t return engine.getAssetByName(props.blockAssets[type]);\n\t}\n\tfunction createSvga(name, anchorName) {\n\t var inst = new svga.Svga();\n\t inst.source = 'asset://' + engine.getAssetByName(name).uuid;\n\t var anchor = props[(anchorName)];\n\t if (anchor) {\n\t inst.x = -anchor.x;\n\t inst.y = -anchor.y;\n\t inst.anchorX = anchor.x;\n\t inst.anchorY = anchor.y;\n\t }\n\t return inst;\n\t}\n\tfunction playSound(name) {\n\t engine.playSound(engine.getAssetByName(name).uuid, { keep: true });\n\t}\n\n\tvar Block = (function (_super) {\n\t tslib.__extends(Block, _super);\n\t function Block() {\n\t var _this = _super.call(this) || this;\n\t var body = _this.body = new svga.Svga();\n\t body.x = -props.blockWidth / 2;\n\t body.y = -props.blockHitHeight - props.blockPaddingTop;\n\t _this.addChild(body);\n\t return _this;\n\t }\n\t Block.prototype.reset = function (_a) {\n\t var type = _a.type;\n\t this.dir = Math.random() > 0.5 ? 1 : -1;\n\t if (this.type != type) {\n\t this.type = type;\n\t var asset = getBlockAsset(type);\n\t this.body.source = 'asset://' + asset.uuid;\n\t }\n\t this.scaleX = this.dir;\n\t this.body.gotoAndStop(1);\n\t };\n\t Block.prototype.playEnter = function (index, animation) {\n\t var _this = this;\n\t this.visible = true;\n\t this.x = this.dir * this.stage.width;\n\t var _a = props.blockDurationRange, min = _a[0], max = _a[1];\n\t var duration = Math.max(max - index * props.blockDurationStep, min);\n\t duration = duration + max * Math.random() * props.blockDurationRandom * (Math.random() > 0.5 ? 1 : -1);\n\t return new Promise(function (resolve) {\n\t if (animation) {\n\t engine.Tween.get(_this, null, null, true)\n\t .to({ x: 0, }, duration)\n\t .call(resolve);\n\t }\n\t else {\n\t _this.x = 0;\n\t setTimeout(function () {\n\t console.log(_this.body);\n\t }, 200);\n\t resolve();\n\t }\n\t });\n\t };\n\t Block.prototype.playLeave = function () {\n\t this.visible = false;\n\t };\n\t Block.prototype.playEffect = function () {\n\t var body = this.body;\n\t body.play(true, false);\n\t body.once(engine.Event.END_FRAME, function () {\n\t body.gotoAndStop(1);\n\t }, this);\n\t };\n\t Block.prototype.stop = function () {\n\t engine.Tween.removeTweens(this);\n\t };\n\t return Block;\n\t}(engine.Container));\n\n\tvar Background = (function (_super) {\n\t tslib.__extends(Background, _super);\n\t function Background() {\n\t return _super.call(this) || this;\n\t }\n\t Background.prototype.setup = function () {\n\t var _a = this.stage, width = _a.width, height = _a.height;\n\t var bg = this._bg = new engine.Image(getTextureByName('背景图'));\n\t bg.anchorX = bg.width / 2;\n\t bg.anchorY = bg.height / 2;\n\t bg.x = -(bg.width - width) / 2;\n\t bg.y = -(bg.height - height) / 2;\n\t this.addChild(bg);\n\t this._minScale = width / bg.width;\n\t };\n\t Background.prototype.playZoom = function (type, duration) {\n\t var _this = this;\n\t if (duration === void 0) { duration = 700; }\n\t return new Promise(function (resolve) {\n\t var scale = type === 'in' ? 1 : _this._minScale;\n\t engine.Tween.get(_this._bg, null, null, true)\n\t .to({ scaleX: scale, scaleY: scale }, duration, engine.Ease.cubicInOut)\n\t .call(resolve);\n\t });\n\t };\n\t return Background;\n\t}(engine.Container));\n\n\tvar svgaAssets = {\n\t aniReady: { name: '准备立正', dir: 1 },\n\t aniJump: { name: '跳上升', dir: 1 },\n\t aniFall: { name: '跳下落', dir: 1 },\n\t aniLandNormal: { name: '普通着地', dir: 1 },\n\t aniLandSide: { name: '边缘着地', dir: -1 },\n\t aniHit: { name: '被撞开', dir: -1 },\n\t aniParachute: { name: '降落', dir: -1 },\n\t};\n\tvar Player = (function (_super) {\n\t tslib.__extends(Player, _super);\n\t function Player() {\n\t var _this = _super.call(this) || this;\n\t _this.g = props.gravity;\n\t _this.addEventListener(engine.Event.ENTER_FRAME, _this.onEnterFrame, _this);\n\t return _this;\n\t }\n\t Player.prototype.switchAni = function (name, dir, play, loop) {\n\t var _this = this;\n\t if (dir === void 0) { dir = 1; }\n\t if (play === void 0) { play = true; }\n\t if (loop === void 0) { loop = false; }\n\t return new Promise(function (resolve) {\n\t _this.scaleX = dir;\n\t if (_this._aniName !== name) {\n\t _this._aniName = name;\n\t var oldAni = _this.removeChild(_this.getChildByName('body'));\n\t if (oldAni) {\n\t oldAni.stop();\n\t }\n\t var ani = _this._currentAni = _this['ani' + name];\n\t _this.addChild(ani);\n\t if (play) {\n\t ani.play(false, loop);\n\t if (loop) {\n\t resolve();\n\t }\n\t else {\n\t ani.once(engine.Event.END_FRAME, resolve);\n\t }\n\t }\n\t else {\n\t ani.gotoAndStop(1);\n\t resolve();\n\t }\n\t }\n\t });\n\t };\n\t Player.prototype.setup = function () {\n\t this.prefectEffect = createSvga('完美着地特效', 'playerLandPrefectAnchor');\n\t this.landEffect = createSvga('着地特效', 'playerLandEffectAnchor');\n\t for (var key in svgaAssets) {\n\t var _a = svgaAssets[key], name = _a.name, dir = _a.dir;\n\t var body = this[key] = createSvga(name, key.replace('ani', 'player') + 'Anchor');\n\t body.name = 'body';\n\t body.scaleX = dir;\n\t }\n\t };\n\t Player.prototype.reset = function (revive) {\n\t this.x = 0;\n\t this.rotation = 0;\n\t this.scaleX = this.scaleY = 1;\n\t this._prefectLandCounting = 0;\n\t engine.Tween.removeTweens(this);\n\t if (revive) {\n\t this.switchAni('Jump', 1, false);\n\t }\n\t };\n\t Player.prototype.playReady = function () {\n\t var _this = this;\n\t return new Promise(function (resolve) {\n\t _this.switchAni('Ready', 1);\n\t _this._currentAni.once(engine.Event.END_FRAME, function () {\n\t this.switchAni('Jump', 1, false);\n\t resolve();\n\t }, _this);\n\t });\n\t };\n\t Player.prototype.onEnterFrame = function (event) {\n\t if (!this.playing) {\n\t return;\n\t }\n\t this.vy += this.g;\n\t this.y += this.vy;\n\t if (this.vy > 0 && this._aniName !== 'Fall') {\n\t this.dispatchEvent('jump-on-top');\n\t this.switchAni('Fall');\n\t }\n\t if (this.y > this.baseY) {\n\t this.y = this.baseY;\n\t this.playing = false;\n\t this.jumpPromise && this.jumpPromise({\n\t aboveBlock: this.aboveBlock,\n\t });\n\t this.jumpPromise = null;\n\t }\n\t };\n\t Player.prototype.changeBaseY = function (v) {\n\t if (this.baseY == v) {\n\t return;\n\t }\n\t this.aboveBlock = true;\n\t this.baseY = v;\n\t };\n\t Player.prototype.jump = function () {\n\t var _this = this;\n\t playSound('跳起音效');\n\t this.switchAni('Jump', 1, false);\n\t this._currentAni.play(false, false);\n\t this.aboveBlock = false;\n\t this.playing = true;\n\t this.baseY = this.y;\n\t this.vy = -props.jumpSpeed;\n\t return new Promise(function (resolve) {\n\t _this.jumpPromise = resolve;\n\t });\n\t };\n\t Player.prototype.playLand = function (type, dir) {\n\t return tslib.__awaiter(this, void 0, void 0, function () {\n\t var _a, prefectEffect_1, landEffect_1;\n\t return tslib.__generator(this, function (_b) {\n\t switch (_b.label) {\n\t case 0:\n\t _a = type;\n\t switch (_a) {\n\t case 0: return [3, 1];\n\t case 1: return [3, 3];\n\t case 2: return [3, 3];\n\t case 3: return [3, 4];\n\t }\n\t return [3, 5];\n\t case 1:\n\t this._prefectLandCounting++;\n\t playSound('完美落地音效' + Math.min(4, this._prefectLandCounting));\n\t prefectEffect_1 = this.prefectEffect;\n\t this.addChildAt(prefectEffect_1, 0);\n\t prefectEffect_1.gotoAndPlay(1);\n\t prefectEffect_1.once(engine.Event.END_FRAME, function () {\n\t this.removeChild(prefectEffect_1);\n\t }, this);\n\t landEffect_1 = this.landEffect;\n\t this.addChildAt(landEffect_1, 0);\n\t landEffect_1.gotoAndPlay(1);\n\t landEffect_1.once(engine.Event.END_FRAME, function () {\n\t this.removeChild(landEffect_1);\n\t }, this);\n\t return [4, this.switchAni('LandNormal')];\n\t case 2:\n\t _b.sent();\n\t return [3, 5];\n\t case 3:\n\t this._prefectLandCounting = 0;\n\t playSound('普通落地音效');\n\t this.switchAni('LandNormal');\n\t return [3, 5];\n\t case 4:\n\t this._prefectLandCounting = 0;\n\t playSound('边缘落地音效');\n\t this.switchAni('LandSide', dir);\n\t return [3, 5];\n\t case 5: return [2];\n\t }\n\t });\n\t });\n\t };\n\t Player.prototype.hitAway = function (dir) {\n\t return tslib.__awaiter(this, void 0, void 0, function () {\n\t var _this = this;\n\t return tslib.__generator(this, function (_a) {\n\t switch (_a.label) {\n\t case 0:\n\t this.jumpPromise && this.jumpPromise();\n\t this.jumpPromise = null;\n\t playSound('被撞开音效');\n\t this.switchAni('Hit', dir);\n\t this.vy = 0;\n\t return [4, new Promise(function (resolve) {\n\t engine.Tween.get(_this)\n\t .to({\n\t x: -dir * props.hitAwayDistance.x,\n\t }, props.hitAwayDuration, engine.Ease.quartOut);\n\t engine.Tween.get(_this)\n\t .to({\n\t y: _this.y + props.hitAwayDistance.y,\n\t }, props.hitAwayDuration, engine.Ease.cubicOut)\n\t .call(resolve);\n\t })];\n\t case 1:\n\t _a.sent();\n\t return [2];\n\t }\n\t });\n\t });\n\t };\n\t Player.prototype.parachute = function (dir) {\n\t var _this = this;\n\t this.switchAni('Parachute', dir);\n\t return new Promise(function (resolve) {\n\t engine.Tween.get(_this)\n\t .wait(200)\n\t .call(function () {\n\t playSound('降落伞下落音效');\n\t })\n\t .wait(300)\n\t .to({ y: _this.y + props.parachuteDistance }, props.parachuteDuration)\n\t .set({ anchorOffsetY: 0 })\n\t .call(resolve);\n\t });\n\t };\n\t return Player;\n\t}(engine.Container));\n\n\tvar Base = (function (_super) {\n\t tslib.__extends(Base, _super);\n\t function Base() {\n\t return _super.call(this, getTextureByName('底座')) || this;\n\t }\n\t Base.prototype.setup = function () {\n\t this.x = -(this.width) / 2;\n\t };\n\t Base.prototype.reset = function () {\n\t this.y = -props.baseOffset;\n\t };\n\t return Base;\n\t}(engine.Image));\n\n\tvar GuideLayer = (function (_super) {\n\t tslib.__extends(GuideLayer, _super);\n\t function GuideLayer() {\n\t var _this = _super.call(this) || this;\n\t _this.setup();\n\t return _this;\n\t }\n\t GuideLayer.prototype.setup = function () {\n\t };\n\t GuideLayer.prototype.show = function (id, options) {\n\t var _this = this;\n\t return new Promise(function (resolve) {\n\t _this.visible = true;\n\t if (!_this.guideMask) {\n\t var _a = _this.stage, width = _a.width, height = _a.height;\n\t var guideMask = _this.guideMask = new engine.Container();\n\t var guideHole = new engine.Image(getTextureByName('引导遮罩'));\n\t guideHole.x = (width - guideHole.width) / 2;\n\t guideHole.y = options.y;\n\t guideMask.addChild(guideHole);\n\t _this.createRect(guideMask, 0, 0, width, guideHole.y);\n\t _this.createRect(guideMask, 0, guideHole.y, guideHole.x, guideHole.height);\n\t _this.createRect(guideMask, guideHole.x + guideHole.width, guideHole.y, width - guideHole.x - guideHole.width, guideHole.height);\n\t _this.createRect(guideMask, 0, guideHole.y + guideHole.height, width, height - guideHole.y - guideHole.height);\n\t var label = _this.label = new engine.Label();\n\t label.fillColor = 'white';\n\t label.size = 25;\n\t label.text = props.guideText;\n\t label.x = (width - label.width) / 2;\n\t label.y = guideHole.y + guideHole.height + 50;\n\t guideMask.addChild(label);\n\t _this.addChild(guideMask);\n\t }\n\t _this.once(engine.MouseEvent.CLICK, function () {\n\t this.visible = false;\n\t resolve();\n\t }, _this);\n\t });\n\t };\n\t GuideLayer.prototype.createRect = function (container, x, y, width, height) {\n\t var rect = new engine.Rect();\n\t rect.x = x;\n\t rect.y = y;\n\t rect.width = width;\n\t rect.height = height;\n\t rect.fillColor = 'black';\n\t rect.alpha = 0.7;\n\t container.addChild(rect);\n\t };\n\t return GuideLayer;\n\t}(engine.Container));\n\n\tvar GoldBag = (function (_super) {\n\t tslib.__extends(GoldBag, _super);\n\t function GoldBag() {\n\t var _this = _super.call(this) || this;\n\t _this.setup();\n\t return _this;\n\t }\n\t GoldBag.prototype.setup = function () {\n\t var avatar = this.avatar = new engine.Sprite(getTextureByName('钱袋-静态'));\n\t avatar.x = -props.goldPackAvatarAnchor.x;\n\t avatar.y = -props.goldPackAvatarAnchor.y;\n\t this.addChild(avatar);\n\t var svga = this.svga = createSvga('钱袋', 'goldPackAnchor');\n\t svga.visible = false;\n\t this.addChild(svga);\n\t };\n\t GoldBag.prototype.reset = function (data) {\n\t this.y = data.y;\n\t this.avatar.visible = true;\n\t this.svga.visible = false;\n\t this.svga.gotoAndStop(1);\n\t this.remain = data.remain;\n\t };\n\t GoldBag.prototype.playOpen = function () {\n\t var _this = this;\n\t this.avatar.visible = false;\n\t this.svga.visible = true;\n\t return new Promise(function (resolve) {\n\t _this.svga.play(true, false);\n\t _this.svga.once(engine.Event.END_FRAME, function () {\n\t this.svga.visible = false;\n\t resolve();\n\t }, _this);\n\t });\n\t };\n\t return GoldBag;\n\t}(engine.Container));\n\n\tvar ObjectPool = engine.ObjectPool;\n\tvar PoolName = 'gold-bag';\n\tObjectPool.registerPool(PoolName, function () {\n\t return new GoldBag();\n\t}, function (item, data) {\n\t item.reset(data);\n\t});\n\tvar GameView = (function (_super) {\n\t tslib.__extends(GameView, _super);\n\t function GameView() {\n\t var _this = _super.call(this) || this;\n\t _this.index = -1;\n\t _this.goldBags = [];\n\t _this.baseOffset = -props.baseOffset + props.playerOffset;\n\t _this.once(engine.Event.ADDED_TO_STAGE, _this.setup, _this);\n\t return _this;\n\t }\n\t GameView.prototype.setup = function () {\n\t if (this._hasSetup) {\n\t return;\n\t }\n\t this._hasSetup = true;\n\t var _a = this.stage, width = _a.width, height = _a.height;\n\t var background = this.background = new Background();\n\t this.addChild(background);\n\t background.setup();\n\t var frontContainer = this.frontContainer = new engine.Container();\n\t frontContainer.x = width / 2;\n\t this.addChild(frontContainer);\n\t var guideLayer = this.guideLayer = new GuideLayer();\n\t this.addChild(guideLayer);\n\t var base = this.base = new Base();\n\t frontContainer.addChild(base);\n\t base.setup();\n\t var blockContainer = this.blockContainer = new engine.Container();\n\t frontContainer.addChild(blockContainer);\n\t var player = this.player = new Player();\n\t frontContainer.addChild(player);\n\t player.setup();\n\t player.addEventListener('jump-on-top', this.onPlayerJumpOnTop, this);\n\t ObjectPool.recycleObject(PoolName, ObjectPool.getObject(PoolName, {\n\t y: 0,\n\t remain: 0,\n\t }));\n\t this.hitEffect = createSvga('被撞烟雾', 'hitEffectAnchor');\n\t this.pos = 0;\n\t this.background.setup();\n\t this.addEventListener(engine.Event.ENTER_FRAME, this.onEnterFrame, this);\n\t this.reset();\n\t };\n\t GameView.prototype.reset = function (revive) {\n\t if (revive === void 0) { revive = false; }\n\t return tslib.__awaiter(this, void 0, void 0, function () {\n\t var blockContainer, i, li, block, i, i, li, goldBag;\n\t return tslib.__generator(this, function (_a) {\n\t switch (_a.label) {\n\t case 0:\n\t this.base.reset();\n\t this.index = -1;\n\t this._score = 0;\n\t if (revive) ;\n\t else {\n\t this.pos = 0;\n\t blockContainer = this.blockContainer;\n\t for (i = 0, li = blockContainer.children.length; i < li; i++) {\n\t block = blockContainer.getChildAt(i);\n\t block.playLeave();\n\t }\n\t }\n\t for (i = 0; i < props.initBlockCount; i++) {\n\t this.addBlock(false);\n\t }\n\t for (i = 0, li = this.goldBags.length; i < li; i++) {\n\t goldBag = this.goldBags[i];\n\t this.frontContainer.removeChild(goldBag);\n\t ObjectPool.recycleObject(PoolName, goldBag);\n\t }\n\t this.goldBags.splice(0);\n\t this.playZoom('in');\n\t return [4, this.resetPlayer(revive)];\n\t case 1:\n\t _a.sent();\n\t return [2];\n\t }\n\t });\n\t });\n\t };\n\t GameView.prototype.resetPlayer = function (revive) {\n\t if (revive === void 0) { revive = false; }\n\t return tslib.__awaiter(this, void 0, void 0, function () {\n\t return tslib.__generator(this, function (_a) {\n\t this.player.reset(revive);\n\t this.player.y = this.baseOffset - (this.index + 1) * props.blockHitHeight;\n\t return [2];\n\t });\n\t });\n\t };\n\t GameView.prototype.start = function (revive) {\n\t if (revive === void 0) { revive = false; }\n\t return tslib.__awaiter(this, void 0, void 0, function () {\n\t var guideFlagKey, guideFlag;\n\t var _this = this;\n\t return tslib.__generator(this, function (_a) {\n\t switch (_a.label) {\n\t case 0:\n\t if (!!revive) return [3, 2];\n\t return [4, this.player.playReady()];\n\t case 1:\n\t _a.sent();\n\t _a.label = 2;\n\t case 2:\n\t guideFlagKey = 'jump-high-guide_' + props.guideFlagKey;\n\t guideFlag = localStorage.getItem(guideFlagKey);\n\t if (!!guideFlag) return [3, 4];\n\t localStorage.setItem(guideFlagKey, '1');\n\t return [4, this.guideLayer.show('', { y: this.stage.height + this.player.y - 280 })];\n\t case 3:\n\t _a.sent();\n\t _a.label = 4;\n\t case 4:\n\t this.lastLandType = 0;\n\t this._remainToShowGoldBag = props.goldBagScoreMultiple - props.goldBagScoreSubtraction;\n\t this._touchEnabled = true;\n\t setTimeout(function () {\n\t _this.addBlock();\n\t }, 100);\n\t engine.globalEvent.dispatchEvent('jump-high-game-start');\n\t return [2];\n\t }\n\t });\n\t });\n\t };\n\t GameView.prototype.pause = function () {\n\t if (this.currentBlock) {\n\t engine.Tween.pauseTweens(this.currentBlock);\n\t }\n\t engine.Tween.pauseTweens(this.player);\n\t };\n\t GameView.prototype.resume = function () {\n\t if (this.currentBlock) {\n\t engine.Tween.resumeTweens(this.currentBlock);\n\t }\n\t engine.Tween.resumeTweens(this.player);\n\t };\n\t GameView.prototype.revive = function () {\n\t return tslib.__awaiter(this, void 0, void 0, function () {\n\t return tslib.__generator(this, function (_a) {\n\t switch (_a.label) {\n\t case 0:\n\t this.blockContainer.getChildAt(this.index).visible = false;\n\t this.index--;\n\t return [4, this.resetPlayer(true)];\n\t case 1:\n\t _a.sent();\n\t return [4, this.playZoom('in')];\n\t case 2:\n\t _a.sent();\n\t this.start(true);\n\t return [2];\n\t }\n\t });\n\t });\n\t };\n\t GameView.prototype.addBlock = function (animation) {\n\t var _this = this;\n\t if (animation === void 0) { animation = true; }\n\t this.index++;\n\t var blockContainer = this.blockContainer;\n\t var block;\n\t if (blockContainer.children.length > this.index) {\n\t block = blockContainer.getChildAt(this.index);\n\t block.visible = true;\n\t }\n\t else {\n\t block = new Block();\n\t blockContainer.addChild(block);\n\t }\n\t block.reset({\n\t type: Math.floor(Math.random() * props.blockAssets.length),\n\t });\n\t block.y = this.baseOffset - this.index * props.blockHitHeight;\n\t this.blockComplete = false;\n\t block.playEnter(this.index, animation).then(function (data) {\n\t _this.blockComplete = true;\n\t });\n\t if (animation) {\n\t this.needHitTest = true;\n\t }\n\t this.currentBlock = block;\n\t };\n\t GameView.prototype.addGoldBag = function () {\n\t var goldBag = ObjectPool.getObject(PoolName, {\n\t y: this.baseOffset - (this.blockCount + props.goldBagDistance + props.goldBagJumpSubtraction) * props.blockHitHeight,\n\t remain: props.goldBagDistance,\n\t });\n\t this.frontContainer.addChild(goldBag);\n\t this.goldBags.push(goldBag);\n\t };\n\t GameView.prototype.playOpenGoldBag = function () {\n\t return tslib.__awaiter(this, void 0, void 0, function () {\n\t var i, li, goldBag;\n\t return tslib.__generator(this, function (_a) {\n\t switch (_a.label) {\n\t case 0:\n\t i = 0, li = this.goldBags.length;\n\t _a.label = 1;\n\t case 1:\n\t if (!(i < li)) return [3, 4];\n\t goldBag = this.goldBags[i];\n\t goldBag.remain--;\n\t if (!(goldBag.remain <= 0)) return [3, 3];\n\t this.goldBags.splice(i, 1);\n\t i--;\n\t li--;\n\t this.nextToUpdateScore = true;\n\t return [4, goldBag.playOpen()];\n\t case 2:\n\t _a.sent();\n\t this.frontContainer.removeChild(goldBag);\n\t ObjectPool.recycleObject(PoolName, goldBag);\n\t _a.label = 3;\n\t case 3:\n\t i++;\n\t return [3, 1];\n\t case 4: return [2];\n\t }\n\t });\n\t });\n\t };\n\t GameView.prototype.onPlayerJumpOnTop = function () {\n\t if (this.nextToUpdateScore) {\n\t this.nextToUpdateScore = false;\n\t this.scoreChange(4);\n\t playSound('撞击钱袋音效');\n\t }\n\t };\n\t Object.defineProperty(GameView.prototype, \"blockCount\", {\n\t get: function () {\n\t return this.index - props.initBlockCount + 1;\n\t },\n\t enumerable: true,\n\t configurable: true\n\t });\n\t Object.defineProperty(GameView.prototype, \"pos\", {\n\t get: function () {\n\t return this._pos;\n\t },\n\t set: function (v) {\n\t this._pos = v;\n\t this.updatePos();\n\t },\n\t enumerable: true,\n\t configurable: true\n\t });\n\t GameView.prototype.updatePos = function () {\n\t this.frontContainer.y = this.stage.height + this._pos;\n\t };\n\t GameView.prototype.onEnterFrame = function (event) {\n\t if (this.needHitTest) {\n\t if (this.currentBlock) {\n\t var _a = this.currentBlock, bx = _a.x, by = _a.y, dir = _a.dir;\n\t var _b = this.player, px = _b.x, py = _b.y;\n\t var blockHitWidth = props.blockHitWidth, blockHitHeight = props.blockHitHeight, playerWidth = props.playerWidth;\n\t var hitOn = false;\n\t if (Math.abs(px - bx) < (blockHitWidth + playerWidth) / 2) {\n\t this.player.changeBaseY(by - blockHitHeight);\n\t if (py > by - blockHitHeight) {\n\t hitOn = true;\n\t }\n\t }\n\t if (hitOn) {\n\t this.onHitOn(dir);\n\t }\n\t }\n\t }\n\t };\n\t GameView.prototype.onHitOn = function (dir) {\n\t return tslib.__awaiter(this, void 0, void 0, function () {\n\t return tslib.__generator(this, function (_a) {\n\t switch (_a.label) {\n\t case 0:\n\t this._touchEnabled = false;\n\t this.needHitTest = false;\n\t clearInterval(this.timer);\n\t this.currentBlock.stop();\n\t this.playHitEffect(dir);\n\t return [4, this.player.hitAway(dir)];\n\t case 1:\n\t _a.sent();\n\t this.playZoom('out');\n\t return [4, this.player.parachute(dir)];\n\t case 2:\n\t _a.sent();\n\t engine.globalEvent.dispatchEvent('jump-high-game-end');\n\t return [2];\n\t }\n\t });\n\t });\n\t };\n\t GameView.prototype.jump = function () {\n\t return tslib.__awaiter(this, void 0, void 0, function () {\n\t var result, pos, type, lastLandType;\n\t var _this = this;\n\t return tslib.__generator(this, function (_a) {\n\t switch (_a.label) {\n\t case 0:\n\t if (!this._touchEnabled) {\n\t return [2];\n\t }\n\t this._touchEnabled = false;\n\t this.playOpenGoldBag();\n\t return [4, this.player.jump()];\n\t case 1:\n\t result = _a.sent();\n\t if (!result) return [3, 5];\n\t if (!result.aboveBlock) return [3, 4];\n\t pos = Math.abs(this.currentBlock.x);\n\t type = 0;\n\t if (pos > 0) {\n\t type = pos > 0 && pos < props.scoreThreshold ? 2 : 3;\n\t }\n\t lastLandType = this.lastLandType;\n\t this.lastLandType = type;\n\t if (type === 0) {\n\t if (lastLandType !== type) {\n\t type = 1;\n\t }\n\t }\n\t if (type < 3) {\n\t this.currentBlock.playEffect();\n\t }\n\t this.player.playLand(type, this.currentBlock.dir);\n\t this.currentBlock.stop();\n\t this.scoreChange(type);\n\t return [4, this.playShake()];\n\t case 2:\n\t _a.sent();\n\t return [4, new Promise(function (resolve) {\n\t engine.Tween.get(_this, null, null, true)\n\t .to({ pos: props.blockHitHeight * _this.index }, 300, engine.Ease.cubicOut)\n\t .call(resolve);\n\t })];\n\t case 3:\n\t _a.sent();\n\t this.addBlock();\n\t _a.label = 4;\n\t case 4:\n\t this._touchEnabled = true;\n\t _a.label = 5;\n\t case 5: return [2];\n\t }\n\t });\n\t });\n\t };\n\t GameView.prototype.scoreChange = function (type) {\n\t var scoreAdd = props.scoreWeights[type];\n\t this._score += scoreAdd;\n\t this._remainToShowGoldBag -= scoreAdd;\n\t var score = this._score;\n\t engine.globalEvent.dispatchEvent('jump-high-score', {\n\t type: type,\n\t score: score,\n\t scoreAdd: scoreAdd,\n\t });\n\t console.log(score, this._remainToShowGoldBag);\n\t if (this._remainToShowGoldBag <= 0) {\n\t this._remainToShowGoldBag += props.goldBagScoreMultiple;\n\t this.addGoldBag();\n\t console.log('addGoldBag');\n\t }\n\t };\n\t GameView.prototype.playHitEffect = function (dir) {\n\t var hitEffect = this.hitEffect;\n\t hitEffect.scaleX = dir;\n\t hitEffect.y = this.player.y - props.hitEffectAnchor.y;\n\t hitEffect.play(true, false);\n\t hitEffect.once(engine.Event.END_FRAME, function () {\n\t this.frontContainer.removeChild(hitEffect);\n\t }, this);\n\t this.frontContainer.addChild(hitEffect);\n\t };\n\t GameView.prototype.playZoom = function (type, duration) {\n\t var _this = this;\n\t if (duration === void 0) { duration = 700; }\n\t this.background.playZoom(type, duration);\n\t var count = this.stage.height / props.blockHitHeight;\n\t return new Promise(function (resolve) {\n\t _this.frontContainer.anchorY = -props.blockHitHeight * (_this.index + count * 1.3) + props.baseOffset;\n\t var scale = type === 'in' ? 1 : Math.min((_this.stage.height / props.blockHitHeight / (_this.index + count)), props.maxScale);\n\t console.log(scale);\n\t engine.Tween.get(_this.frontContainer, null, null, true)\n\t .to({ scaleX: scale, scaleY: scale }, duration, engine.Ease.cubicInOut)\n\t .call(resolve);\n\t });\n\t };\n\t GameView.prototype.playShake = function () {\n\t var _this = this;\n\t var _a = this.frontContainer, x = _a.x, y = _a.y;\n\t return new Promise(function (resolve) {\n\t var shakeOffset = 7;\n\t var duration = 30;\n\t engine.Tween.get(_this.frontContainer, null, null, true)\n\t .to({ x: x, y: y - shakeOffset }, duration)\n\t .to({ x: x, y: y + shakeOffset }, duration)\n\t .to({ x: x + shakeOffset, y: y }, duration)\n\t .to({ x: x - shakeOffset, y: y }, duration)\n\t .to({ x: x, y: y }, duration)\n\t .call(resolve);\n\t });\n\t };\n\t return GameView;\n\t}(engine.Container));\n\n\tvar JumpHigh = (function (_super) {\n\t tslib.__extends(JumpHigh, _super);\n\t function JumpHigh() {\n\t var _this = _super.call(this) || this;\n\t engine.globalEvent.addEventListener('jump-high-reset', _this.reset, _this);\n\t engine.globalEvent.addEventListener('jump-high-start', _this.start, _this);\n\t engine.globalEvent.addEventListener('jump-high-pause', _this.pause, _this);\n\t engine.globalEvent.addEventListener('jump-high-resume', _this.resume, _this);\n\t engine.globalEvent.addEventListener('jump-high-revive', _this.revive, _this);\n\t _this.addEventListener(engine.MouseEvent.MOUSE_DOWN, _this.onTap, _this);\n\t var gameView = _this._gameView = new GameView();\n\t _this.addChild(gameView);\n\t return _this;\n\t }\n\t JumpHigh.prototype.reset = function () {\n\t this._gameView.reset();\n\t };\n\t JumpHigh.prototype.start = function (event) {\n\t {\n\t injectProps(event.data);\n\t }\n\t this._status = 1;\n\t this._gameView.start();\n\t };\n\t JumpHigh.prototype.pause = function () {\n\t this._gameView.pause();\n\t };\n\t JumpHigh.prototype.resume = function () {\n\t this._gameView.resume();\n\t };\n\t JumpHigh.prototype.revive = function () {\n\t this._gameView.revive();\n\t };\n\t JumpHigh.prototype.onTap = function (event) {\n\t this._gameView.jump();\n\t };\n\t return JumpHigh;\n\t}(engine.Container));\n\n\tfunction index (props) {\n\t prepareProps();\n\t injectProps(props);\n\t var instance = new JumpHigh();\n\t return instance;\n\t}\n\n\treturn index;\n\n})));\n"
"code": "(function (global, factory) {\n\ttypeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('tslib')) :\n\ttypeof define === 'function' && define.amd ? define(['tslib'], factory) :\n\t(global = global || self, global['jump-high'] = factory(global.tslib));\n}(this, (function (tslib) { 'use strict';\n\n\tvar props = {};\n\tfunction prepareProps() {\n\t var metaProps = getProps();\n\t engine.injectProp(props, metaProps);\n\t}\n\tfunction injectProps(p) {\n\t engine.injectProp(props, p);\n\t}\n\n\tfunction getTextureByName(name) {\n\t return engine.Texture.from(getAssetByName(name).uuid);\n\t}\n\tfunction getBlockAsset(type) {\n\t return engine.getAssetByName(props.blockAssets[type]);\n\t}\n\tfunction createSvga(name, anchorName) {\n\t var inst = new svga.Svga();\n\t inst.source = 'asset://' + getAssetByName(name).uuid;\n\t var anchor = props[anchorName];\n\t if (anchor) {\n\t inst.x = -anchor.x;\n\t inst.y = -anchor.y;\n\t inst.anchorX = anchor.x;\n\t inst.anchorY = anchor.y;\n\t }\n\t return inst;\n\t}\n\tfunction playSound(name) {\n\t engine.playSound(getAssetByName(name).uuid, { keep: true });\n\t}\n\n\tvar Block = (function (_super) {\n\t tslib.__extends(Block, _super);\n\t function Block() {\n\t var _this = _super.call(this) || this;\n\t var body = _this.body = new svga.Svga();\n\t body.x = -props.blockWidth / 2;\n\t body.y = -props.blockHitHeight - props.blockPaddingTop;\n\t _this.addChild(body);\n\t return _this;\n\t }\n\t Block.prototype.reset = function (_a) {\n\t var type = _a.type;\n\t this.dir = Math.random() > 0.5 ? 1 : -1;\n\t if (this.type != type) {\n\t this.type = type;\n\t var asset = getBlockAsset(type);\n\t this.body.source = 'asset://' + asset.uuid;\n\t }\n\t this.scaleX = this.dir;\n\t this.body.gotoAndStop(1);\n\t };\n\t Block.prototype.playEnter = function (index, animation) {\n\t var _this = this;\n\t this.visible = true;\n\t this.x = this.dir * this.stage.width;\n\t var _a = props.blockDurationRange, min = _a[0], max = _a[1];\n\t var duration = Math.max(max - index * props.blockDurationStep, min);\n\t duration = duration + max * Math.random() * props.blockDurationRandom * (Math.random() > 0.5 ? 1 : -1);\n\t return new Promise(function (resolve) {\n\t if (animation) {\n\t engine.Tween.get(_this, null, null, true)\n\t .to({ x: 0, }, duration)\n\t .call(resolve);\n\t }\n\t else {\n\t _this.x = 0;\n\t setTimeout(function () {\n\t console.log(_this.body);\n\t }, 200);\n\t resolve();\n\t }\n\t });\n\t };\n\t Block.prototype.playLeave = function () {\n\t this.visible = false;\n\t };\n\t Block.prototype.playEffect = function () {\n\t var body = this.body;\n\t body.play(true, false);\n\t body.once(engine.Event.END_FRAME, function () {\n\t body.gotoAndStop(1);\n\t }, this);\n\t };\n\t Block.prototype.stop = function () {\n\t engine.Tween.removeTweens(this);\n\t };\n\t return Block;\n\t}(engine.Container));\n\n\tvar Background = (function (_super) {\n\t tslib.__extends(Background, _super);\n\t function Background() {\n\t return _super.call(this) || this;\n\t }\n\t Background.prototype.setup = function () {\n\t var _a = this.stage, width = _a.width, height = _a.height;\n\t var bg = this._bg = new engine.Image(getTextureByName('背景图'));\n\t bg.anchorX = bg.width / 2;\n\t bg.anchorY = bg.height / 2;\n\t bg.x = -(bg.width - width) / 2;\n\t bg.y = -(bg.height - height) / 2;\n\t this.addChild(bg);\n\t this._minScale = width / bg.width;\n\t };\n\t Background.prototype.playZoom = function (type, duration) {\n\t var _this = this;\n\t if (duration === void 0) { duration = 700; }\n\t return new Promise(function (resolve) {\n\t var scale = type === 'in' ? 1 : _this._minScale;\n\t engine.Tween.get(_this._bg, null, null, true)\n\t .to({ scaleX: scale, scaleY: scale }, duration, engine.Ease.cubicInOut)\n\t .call(resolve);\n\t });\n\t };\n\t return Background;\n\t}(engine.Container));\n\n\tvar svgaAssets = {\n\t aniReady: { name: '准备立正', dir: 1 },\n\t aniJump: { name: '跳上升', dir: 1 },\n\t aniFall: { name: '跳下落', dir: 1 },\n\t aniLandNormal: { name: '普通着地', dir: 1 },\n\t aniLandSide: { name: '边缘着地', dir: -1 },\n\t aniHit: { name: '被撞开', dir: -1 },\n\t aniParachute: { name: '降落', dir: -1 },\n\t};\n\tvar Player = (function (_super) {\n\t tslib.__extends(Player, _super);\n\t function Player() {\n\t var _this = _super.call(this) || this;\n\t _this.g = props.gravity;\n\t _this.addEventListener(engine.Event.ENTER_FRAME, _this.onEnterFrame, _this);\n\t return _this;\n\t }\n\t Player.prototype.switchAni = function (name, dir, play, loop) {\n\t var _this = this;\n\t if (dir === void 0) { dir = 1; }\n\t if (play === void 0) { play = true; }\n\t if (loop === void 0) { loop = false; }\n\t return new Promise(function (resolve) {\n\t _this.scaleX = dir;\n\t if (_this._aniName !== name) {\n\t _this._aniName = name;\n\t var oldAni = _this.removeChild(_this.getChildByName('body'));\n\t if (oldAni) {\n\t oldAni.stop();\n\t }\n\t var ani = _this._currentAni = _this['ani' + name];\n\t _this.addChild(ani);\n\t if (play) {\n\t ani.play(false, loop);\n\t if (loop) {\n\t resolve();\n\t }\n\t else {\n\t ani.once(engine.Event.END_FRAME, resolve);\n\t }\n\t }\n\t else {\n\t ani.gotoAndStop(1);\n\t resolve();\n\t }\n\t }\n\t });\n\t };\n\t Player.prototype.setup = function () {\n\t this.prefectEffect = createSvga('完美着地特效', 'playerLandPrefectAnchor');\n\t this.landEffect = createSvga('着地特效', 'playerLandEffectAnchor');\n\t for (var key in svgaAssets) {\n\t var _a = svgaAssets[key], name = _a.name, dir = _a.dir;\n\t var body = this[key] = createSvga(name, key.replace('ani', 'player') + 'Anchor');\n\t body.name = 'body';\n\t body.scaleX = dir;\n\t }\n\t };\n\t Player.prototype.reset = function (revive) {\n\t this.x = 0;\n\t this.rotation = 0;\n\t this.scaleX = this.scaleY = 1;\n\t this._prefectLandCounting = 0;\n\t engine.Tween.removeTweens(this);\n\t if (revive) {\n\t this.switchAni('Jump', 1, false);\n\t }\n\t };\n\t Player.prototype.playReady = function () {\n\t var _this = this;\n\t return new Promise(function (resolve) {\n\t _this.switchAni('Ready', 1);\n\t _this._currentAni.once(engine.Event.END_FRAME, function () {\n\t this.switchAni('Jump', 1, false);\n\t resolve();\n\t }, _this);\n\t });\n\t };\n\t Player.prototype.onEnterFrame = function (event) {\n\t if (!this.playing) {\n\t return;\n\t }\n\t this.vy += this.g;\n\t this.y += this.vy;\n\t if (this.vy > 0 && this._aniName !== 'Fall') {\n\t this.dispatchEvent('jump-on-top');\n\t this.switchAni('Fall');\n\t }\n\t if (this.y > this.baseY) {\n\t this.y = this.baseY;\n\t this.playing = false;\n\t this.jumpPromise && this.jumpPromise({\n\t aboveBlock: this.aboveBlock,\n\t });\n\t this.jumpPromise = null;\n\t }\n\t };\n\t Player.prototype.changeBaseY = function (v) {\n\t if (this.baseY == v) {\n\t return;\n\t }\n\t this.aboveBlock = true;\n\t this.baseY = v;\n\t };\n\t Player.prototype.jump = function () {\n\t var _this = this;\n\t playSound('跳起音效');\n\t this.switchAni('Jump', 1, false);\n\t this._currentAni.play(false, false);\n\t this.aboveBlock = false;\n\t this.playing = true;\n\t this.baseY = this.y;\n\t this.vy = -props.jumpSpeed;\n\t return new Promise(function (resolve) {\n\t _this.jumpPromise = resolve;\n\t });\n\t };\n\t Player.prototype.playLand = function (type, dir) {\n\t return tslib.__awaiter(this, void 0, void 0, function () {\n\t var _a, prefectEffect_1, landEffect_1;\n\t return tslib.__generator(this, function (_b) {\n\t switch (_b.label) {\n\t case 0:\n\t _a = type;\n\t switch (_a) {\n\t case 0: return [3, 1];\n\t case 1: return [3, 3];\n\t case 2: return [3, 3];\n\t case 3: return [3, 4];\n\t }\n\t return [3, 5];\n\t case 1:\n\t this._prefectLandCounting++;\n\t playSound('完美落地音效' + Math.min(4, this._prefectLandCounting));\n\t prefectEffect_1 = this.prefectEffect;\n\t this.addChildAt(prefectEffect_1, 0);\n\t prefectEffect_1.gotoAndPlay(1);\n\t prefectEffect_1.once(engine.Event.END_FRAME, function () {\n\t this.removeChild(prefectEffect_1);\n\t }, this);\n\t landEffect_1 = this.landEffect;\n\t this.addChildAt(landEffect_1, 0);\n\t landEffect_1.gotoAndPlay(1);\n\t landEffect_1.once(engine.Event.END_FRAME, function () {\n\t this.removeChild(landEffect_1);\n\t }, this);\n\t return [4, this.switchAni('LandNormal')];\n\t case 2:\n\t _b.sent();\n\t return [3, 5];\n\t case 3:\n\t this._prefectLandCounting = 0;\n\t playSound('普通落地音效');\n\t this.switchAni('LandNormal');\n\t return [3, 5];\n\t case 4:\n\t this._prefectLandCounting = 0;\n\t playSound('边缘落地音效');\n\t this.switchAni('LandSide', dir);\n\t return [3, 5];\n\t case 5: return [2];\n\t }\n\t });\n\t });\n\t };\n\t Player.prototype.hitAway = function (dir) {\n\t return tslib.__awaiter(this, void 0, void 0, function () {\n\t var _this = this;\n\t return tslib.__generator(this, function (_a) {\n\t switch (_a.label) {\n\t case 0:\n\t this.jumpPromise && this.jumpPromise();\n\t this.jumpPromise = null;\n\t playSound('被撞开音效');\n\t this.switchAni('Hit', dir);\n\t this.vy = 0;\n\t return [4, new Promise(function (resolve) {\n\t engine.Tween.get(_this)\n\t .to({\n\t x: -dir * props.hitAwayDistance.x,\n\t }, props.hitAwayDuration, engine.Ease.quartOut);\n\t engine.Tween.get(_this)\n\t .to({\n\t y: _this.y + props.hitAwayDistance.y,\n\t }, props.hitAwayDuration, engine.Ease.cubicOut)\n\t .call(resolve);\n\t })];\n\t case 1:\n\t _a.sent();\n\t return [2];\n\t }\n\t });\n\t });\n\t };\n\t Player.prototype.parachute = function (dir) {\n\t var _this = this;\n\t this.switchAni('Parachute', dir);\n\t return new Promise(function (resolve) {\n\t engine.Tween.get(_this)\n\t .wait(200)\n\t .call(function () {\n\t playSound('降落伞下落音效');\n\t })\n\t .wait(300)\n\t .to({ y: _this.y + props.parachuteDistance }, props.parachuteDuration)\n\t .set({ anchorOffsetY: 0 })\n\t .call(resolve);\n\t });\n\t };\n\t return Player;\n\t}(engine.Container));\n\n\tvar Base = (function (_super) {\n\t tslib.__extends(Base, _super);\n\t function Base() {\n\t return _super.call(this, getTextureByName('底座')) || this;\n\t }\n\t Base.prototype.setup = function () {\n\t this.x = -(this.width) / 2;\n\t };\n\t Base.prototype.reset = function () {\n\t this.y = -props.baseOffset;\n\t };\n\t return Base;\n\t}(engine.Image));\n\n\tvar GuideLayer = (function (_super) {\n\t tslib.__extends(GuideLayer, _super);\n\t function GuideLayer() {\n\t var _this = _super.call(this) || this;\n\t _this.setup();\n\t return _this;\n\t }\n\t GuideLayer.prototype.setup = function () {\n\t };\n\t GuideLayer.prototype.show = function (id, options) {\n\t var _this = this;\n\t return new Promise(function (resolve) {\n\t _this.visible = true;\n\t if (!_this.guideMask) {\n\t var _a = _this.stage, width = _a.width, height = _a.height;\n\t var guideMask = _this.guideMask = new engine.Container();\n\t var guideHole = new engine.Image(getTextureByName('引导遮罩'));\n\t guideHole.x = (width - guideHole.width) / 2;\n\t guideHole.y = options.y;\n\t guideMask.addChild(guideHole);\n\t _this.createRect(guideMask, 0, 0, width, guideHole.y);\n\t _this.createRect(guideMask, 0, guideHole.y, guideHole.x, guideHole.height);\n\t _this.createRect(guideMask, guideHole.x + guideHole.width, guideHole.y, width - guideHole.x - guideHole.width, guideHole.height);\n\t _this.createRect(guideMask, 0, guideHole.y + guideHole.height, width, height - guideHole.y - guideHole.height);\n\t var label = _this.label = new engine.Label();\n\t label.fillColor = 'white';\n\t label.size = 25;\n\t label.text = props.guideText;\n\t label.x = (width - label.width) / 2;\n\t label.y = guideHole.y + guideHole.height + 50;\n\t guideMask.addChild(label);\n\t _this.addChild(guideMask);\n\t }\n\t _this.once(engine.MouseEvent.CLICK, function () {\n\t this.visible = false;\n\t resolve();\n\t }, _this);\n\t });\n\t };\n\t GuideLayer.prototype.createRect = function (container, x, y, width, height) {\n\t var rect = new engine.Rect();\n\t rect.x = x;\n\t rect.y = y;\n\t rect.width = width;\n\t rect.height = height;\n\t rect.fillColor = 'black';\n\t rect.alpha = 0.7;\n\t container.addChild(rect);\n\t };\n\t return GuideLayer;\n\t}(engine.Container));\n\n\tvar GoldBag = (function (_super) {\n\t tslib.__extends(GoldBag, _super);\n\t function GoldBag() {\n\t var _this = _super.call(this) || this;\n\t _this.setup();\n\t return _this;\n\t }\n\t GoldBag.prototype.setup = function () {\n\t var avatar = this.avatar = new engine.Sprite(getTextureByName('钱袋-静态'));\n\t avatar.x = -props.goldPackAvatarAnchor.x;\n\t avatar.y = -props.goldPackAvatarAnchor.y;\n\t this.addChild(avatar);\n\t var svga = this.svga = createSvga('钱袋', 'goldPackAnchor');\n\t svga.visible = false;\n\t this.addChild(svga);\n\t };\n\t GoldBag.prototype.reset = function (data) {\n\t this.y = data.y;\n\t this.avatar.visible = true;\n\t this.svga.visible = false;\n\t this.svga.gotoAndStop(1);\n\t this.remain = data.remain;\n\t };\n\t GoldBag.prototype.playOpen = function () {\n\t var _this = this;\n\t this.avatar.visible = false;\n\t this.svga.visible = true;\n\t return new Promise(function (resolve) {\n\t _this.svga.play(true, false);\n\t _this.svga.once(engine.Event.END_FRAME, function () {\n\t this.svga.visible = false;\n\t resolve();\n\t }, _this);\n\t });\n\t };\n\t return GoldBag;\n\t}(engine.Container));\n\n\tvar ObjectPool = engine.ObjectPool;\n\tvar PoolName = 'gold-bag';\n\tObjectPool.registerPool(PoolName, function () {\n\t return new GoldBag();\n\t}, function (item, data) {\n\t item.reset(data);\n\t});\n\tvar GameView = (function (_super) {\n\t tslib.__extends(GameView, _super);\n\t function GameView() {\n\t var _this = _super.call(this) || this;\n\t _this.index = -1;\n\t _this.goldBags = [];\n\t _this.baseOffset = -props.baseOffset + props.playerOffset;\n\t _this.once(engine.Event.ADDED_TO_STAGE, _this.setup, _this);\n\t return _this;\n\t }\n\t GameView.prototype.setup = function () {\n\t if (this._hasSetup) {\n\t return;\n\t }\n\t this._hasSetup = true;\n\t var _a = this.stage, width = _a.width, height = _a.height;\n\t var background = this.background = new Background();\n\t this.addChild(background);\n\t background.setup();\n\t var frontContainer = this.frontContainer = new engine.Container();\n\t frontContainer.x = width / 2;\n\t this.addChild(frontContainer);\n\t var guideLayer = this.guideLayer = new GuideLayer();\n\t this.addChild(guideLayer);\n\t var base = this.base = new Base();\n\t frontContainer.addChild(base);\n\t base.setup();\n\t var blockContainer = this.blockContainer = new engine.Container();\n\t frontContainer.addChild(blockContainer);\n\t var player = this.player = new Player();\n\t frontContainer.addChild(player);\n\t player.setup();\n\t player.addEventListener('jump-on-top', this.onPlayerJumpOnTop, this);\n\t ObjectPool.recycleObject(PoolName, ObjectPool.getObject(PoolName, {\n\t y: 0,\n\t remain: 0,\n\t }));\n\t this.hitEffect = createSvga('被撞烟雾', 'hitEffectAnchor');\n\t this.pos = 0;\n\t this.background.setup();\n\t this.addEventListener(engine.Event.ENTER_FRAME, this.onEnterFrame, this);\n\t this.reset();\n\t };\n\t GameView.prototype.reset = function (revive) {\n\t if (revive === void 0) { revive = false; }\n\t return tslib.__awaiter(this, void 0, void 0, function () {\n\t var blockContainer, i, li, block, i, i, li, goldBag;\n\t return tslib.__generator(this, function (_a) {\n\t switch (_a.label) {\n\t case 0:\n\t this.base.reset();\n\t this.index = -1;\n\t this._score = 0;\n\t if (revive) ;\n\t else {\n\t this.pos = 0;\n\t blockContainer = this.blockContainer;\n\t for (i = 0, li = blockContainer.children.length; i < li; i++) {\n\t block = blockContainer.getChildAt(i);\n\t block.playLeave();\n\t }\n\t }\n\t for (i = 0; i < props.initBlockCount; i++) {\n\t this.addBlock(false);\n\t }\n\t for (i = 0, li = this.goldBags.length; i < li; i++) {\n\t goldBag = this.goldBags[i];\n\t this.frontContainer.removeChild(goldBag);\n\t ObjectPool.recycleObject(PoolName, goldBag);\n\t }\n\t this.goldBags.splice(0);\n\t this.playZoom('in');\n\t return [4, this.resetPlayer(revive)];\n\t case 1:\n\t _a.sent();\n\t return [2];\n\t }\n\t });\n\t });\n\t };\n\t GameView.prototype.resetPlayer = function (revive) {\n\t if (revive === void 0) { revive = false; }\n\t return tslib.__awaiter(this, void 0, void 0, function () {\n\t return tslib.__generator(this, function (_a) {\n\t this.player.reset(revive);\n\t this.player.y = this.baseOffset - (this.index + 1) * props.blockHitHeight;\n\t return [2];\n\t });\n\t });\n\t };\n\t GameView.prototype.start = function (revive) {\n\t if (revive === void 0) { revive = false; }\n\t return tslib.__awaiter(this, void 0, void 0, function () {\n\t var guideFlagKey, guideFlag;\n\t var _this = this;\n\t return tslib.__generator(this, function (_a) {\n\t switch (_a.label) {\n\t case 0:\n\t if (!!revive) return [3, 2];\n\t return [4, this.player.playReady()];\n\t case 1:\n\t _a.sent();\n\t _a.label = 2;\n\t case 2:\n\t guideFlagKey = 'jump-high-guide_' + props.guideFlagKey;\n\t guideFlag = localStorage.getItem(guideFlagKey);\n\t if (!!guideFlag) return [3, 4];\n\t localStorage.setItem(guideFlagKey, '1');\n\t return [4, this.guideLayer.show('', { y: this.stage.height + this.player.y - 280 })];\n\t case 3:\n\t _a.sent();\n\t _a.label = 4;\n\t case 4:\n\t this.lastLandType = 0;\n\t this._remainToShowGoldBag = props.goldBagScoreMultiple - props.goldBagScoreSubtraction;\n\t this._touchEnabled = true;\n\t setTimeout(function () {\n\t _this.addBlock();\n\t }, 100);\n\t engine.globalEvent.dispatchEvent('jump-high-game-start');\n\t return [2];\n\t }\n\t });\n\t });\n\t };\n\t GameView.prototype.pause = function () {\n\t if (this.currentBlock) {\n\t engine.Tween.pauseTweens(this.currentBlock);\n\t }\n\t engine.Tween.pauseTweens(this.player);\n\t };\n\t GameView.prototype.resume = function () {\n\t if (this.currentBlock) {\n\t engine.Tween.resumeTweens(this.currentBlock);\n\t }\n\t engine.Tween.resumeTweens(this.player);\n\t };\n\t GameView.prototype.revive = function () {\n\t return tslib.__awaiter(this, void 0, void 0, function () {\n\t return tslib.__generator(this, function (_a) {\n\t switch (_a.label) {\n\t case 0:\n\t this.blockContainer.getChildAt(this.index).visible = false;\n\t this.index--;\n\t return [4, this.resetPlayer(true)];\n\t case 1:\n\t _a.sent();\n\t return [4, this.playZoom('in')];\n\t case 2:\n\t _a.sent();\n\t this.start(true);\n\t return [2];\n\t }\n\t });\n\t });\n\t };\n\t GameView.prototype.addBlock = function (animation) {\n\t var _this = this;\n\t if (animation === void 0) { animation = true; }\n\t this.index++;\n\t var blockContainer = this.blockContainer;\n\t var block;\n\t if (blockContainer.children.length > this.index) {\n\t block = blockContainer.getChildAt(this.index);\n\t block.visible = true;\n\t }\n\t else {\n\t block = new Block();\n\t blockContainer.addChild(block);\n\t }\n\t block.reset({\n\t type: Math.floor(Math.random() * props.blockAssets.length),\n\t });\n\t block.y = this.baseOffset - this.index * props.blockHitHeight;\n\t this.blockComplete = false;\n\t block.playEnter(this.index, animation).then(function (data) {\n\t _this.blockComplete = true;\n\t });\n\t if (animation) {\n\t this.needHitTest = true;\n\t }\n\t this.currentBlock = block;\n\t };\n\t GameView.prototype.addGoldBag = function () {\n\t var goldBag = ObjectPool.getObject(PoolName, {\n\t y: this.baseOffset - (this.blockCount + props.goldBagDistance + props.goldBagJumpSubtraction) * props.blockHitHeight,\n\t remain: props.goldBagDistance,\n\t });\n\t this.frontContainer.addChild(goldBag);\n\t this.goldBags.push(goldBag);\n\t };\n\t GameView.prototype.playOpenGoldBag = function () {\n\t return tslib.__awaiter(this, void 0, void 0, function () {\n\t var i, li, goldBag;\n\t return tslib.__generator(this, function (_a) {\n\t switch (_a.label) {\n\t case 0:\n\t i = 0, li = this.goldBags.length;\n\t _a.label = 1;\n\t case 1:\n\t if (!(i < li)) return [3, 4];\n\t goldBag = this.goldBags[i];\n\t goldBag.remain--;\n\t if (!(goldBag.remain <= 0)) return [3, 3];\n\t this.goldBags.splice(i, 1);\n\t i--;\n\t li--;\n\t this.nextToUpdateScore = true;\n\t return [4, goldBag.playOpen()];\n\t case 2:\n\t _a.sent();\n\t this.frontContainer.removeChild(goldBag);\n\t ObjectPool.recycleObject(PoolName, goldBag);\n\t _a.label = 3;\n\t case 3:\n\t i++;\n\t return [3, 1];\n\t case 4: return [2];\n\t }\n\t });\n\t });\n\t };\n\t GameView.prototype.onPlayerJumpOnTop = function () {\n\t if (this.nextToUpdateScore) {\n\t this.nextToUpdateScore = false;\n\t this.scoreChange(4);\n\t playSound('撞击钱袋音效');\n\t }\n\t };\n\t Object.defineProperty(GameView.prototype, \"blockCount\", {\n\t get: function () {\n\t return this.index - props.initBlockCount + 1;\n\t },\n\t enumerable: true,\n\t configurable: true\n\t });\n\t Object.defineProperty(GameView.prototype, \"pos\", {\n\t get: function () {\n\t return this._pos;\n\t },\n\t set: function (v) {\n\t this._pos = v;\n\t this.updatePos();\n\t },\n\t enumerable: true,\n\t configurable: true\n\t });\n\t GameView.prototype.updatePos = function () {\n\t this.frontContainer.y = this.stage.height + this._pos;\n\t };\n\t GameView.prototype.onEnterFrame = function (event) {\n\t if (this.needHitTest) {\n\t if (this.currentBlock) {\n\t var _a = this.currentBlock, bx = _a.x, by = _a.y, dir = _a.dir;\n\t var _b = this.player, px = _b.x, py = _b.y;\n\t var blockHitWidth = props.blockHitWidth, blockHitHeight = props.blockHitHeight, playerWidth = props.playerWidth;\n\t var hitOn = false;\n\t if (Math.abs(px - bx) < (blockHitWidth + playerWidth) / 2) {\n\t this.player.changeBaseY(by - blockHitHeight);\n\t if (py > by - blockHitHeight) {\n\t hitOn = true;\n\t }\n\t }\n\t if (hitOn) {\n\t this.onHitOn(dir);\n\t }\n\t }\n\t }\n\t };\n\t GameView.prototype.onHitOn = function (dir) {\n\t return tslib.__awaiter(this, void 0, void 0, function () {\n\t return tslib.__generator(this, function (_a) {\n\t switch (_a.label) {\n\t case 0:\n\t this._touchEnabled = false;\n\t this.needHitTest = false;\n\t clearInterval(this.timer);\n\t this.currentBlock.stop();\n\t this.playHitEffect(dir);\n\t return [4, this.player.hitAway(dir)];\n\t case 1:\n\t _a.sent();\n\t this.playZoom('out');\n\t return [4, this.player.parachute(dir)];\n\t case 2:\n\t _a.sent();\n\t engine.globalEvent.dispatchEvent('jump-high-game-end');\n\t return [2];\n\t }\n\t });\n\t });\n\t };\n\t GameView.prototype.jump = function () {\n\t return tslib.__awaiter(this, void 0, void 0, function () {\n\t var result, pos, type, lastLandType;\n\t var _this = this;\n\t return tslib.__generator(this, function (_a) {\n\t switch (_a.label) {\n\t case 0:\n\t if (!this._touchEnabled) {\n\t return [2];\n\t }\n\t this._touchEnabled = false;\n\t this.playOpenGoldBag();\n\t return [4, this.player.jump()];\n\t case 1:\n\t result = _a.sent();\n\t if (!result) return [3, 5];\n\t if (!result.aboveBlock) return [3, 4];\n\t pos = Math.abs(this.currentBlock.x);\n\t type = 0;\n\t if (pos > 0) {\n\t type = pos > 0 && pos < props.scoreThreshold ? 2 : 3;\n\t }\n\t lastLandType = this.lastLandType;\n\t this.lastLandType = type;\n\t if (type === 0) {\n\t if (lastLandType !== type) {\n\t type = 1;\n\t }\n\t }\n\t if (type < 3) {\n\t this.currentBlock.playEffect();\n\t }\n\t this.player.playLand(type, this.currentBlock.dir);\n\t this.currentBlock.stop();\n\t this.scoreChange(type);\n\t return [4, this.playShake()];\n\t case 2:\n\t _a.sent();\n\t return [4, new Promise(function (resolve) {\n\t engine.Tween.get(_this, null, null, true)\n\t .to({ pos: props.blockHitHeight * _this.index }, 300, engine.Ease.cubicOut)\n\t .call(resolve);\n\t })];\n\t case 3:\n\t _a.sent();\n\t this.addBlock();\n\t _a.label = 4;\n\t case 4:\n\t this._touchEnabled = true;\n\t _a.label = 5;\n\t case 5: return [2];\n\t }\n\t });\n\t });\n\t };\n\t GameView.prototype.scoreChange = function (type) {\n\t var scoreAdd = props.scoreWeights[type];\n\t this._score += scoreAdd;\n\t this._remainToShowGoldBag -= scoreAdd;\n\t var score = this._score;\n\t engine.globalEvent.dispatchEvent('jump-high-score', {\n\t type: type,\n\t score: score,\n\t scoreAdd: scoreAdd,\n\t });\n\t console.log(score, this._remainToShowGoldBag);\n\t if (this._remainToShowGoldBag <= 0) {\n\t this._remainToShowGoldBag += props.goldBagScoreMultiple;\n\t this.addGoldBag();\n\t console.log('addGoldBag');\n\t }\n\t };\n\t GameView.prototype.playHitEffect = function (dir) {\n\t var hitEffect = this.hitEffect;\n\t hitEffect.scaleX = dir;\n\t hitEffect.y = this.player.y - props.hitEffectAnchor.y;\n\t hitEffect.play(true, false);\n\t hitEffect.once(engine.Event.END_FRAME, function () {\n\t this.frontContainer.removeChild(hitEffect);\n\t }, this);\n\t this.frontContainer.addChild(hitEffect);\n\t };\n\t GameView.prototype.playZoom = function (type, duration) {\n\t var _this = this;\n\t if (duration === void 0) { duration = 700; }\n\t this.background.playZoom(type, duration);\n\t var count = this.stage.height / props.blockHitHeight;\n\t return new Promise(function (resolve) {\n\t _this.frontContainer.anchorY = -props.blockHitHeight * (_this.index + count * 1.3) + props.baseOffset;\n\t var scale = type === 'in' ? 1 : Math.min((_this.stage.height / props.blockHitHeight / (_this.index + count)), props.maxScale);\n\t console.log(scale);\n\t engine.Tween.get(_this.frontContainer, null, null, true)\n\t .to({ scaleX: scale, scaleY: scale }, duration, engine.Ease.cubicInOut)\n\t .call(resolve);\n\t });\n\t };\n\t GameView.prototype.playShake = function () {\n\t var _this = this;\n\t var _a = this.frontContainer, x = _a.x, y = _a.y;\n\t return new Promise(function (resolve) {\n\t var shakeOffset = 7;\n\t var duration = 30;\n\t engine.Tween.get(_this.frontContainer, null, null, true)\n\t .to({ x: x, y: y - shakeOffset }, duration)\n\t .to({ x: x, y: y + shakeOffset }, duration)\n\t .to({ x: x + shakeOffset, y: y }, duration)\n\t .to({ x: x - shakeOffset, y: y }, duration)\n\t .to({ x: x, y: y }, duration)\n\t .call(resolve);\n\t });\n\t };\n\t return GameView;\n\t}(engine.Container));\n\n\tvar JumpHigh = (function (_super) {\n\t tslib.__extends(JumpHigh, _super);\n\t function JumpHigh() {\n\t var _this = _super.call(this) || this;\n\t engine.globalEvent.addEventListener('jump-high-reset', _this.reset, _this);\n\t engine.globalEvent.addEventListener('jump-high-start', _this.start, _this);\n\t engine.globalEvent.addEventListener('jump-high-pause', _this.pause, _this);\n\t engine.globalEvent.addEventListener('jump-high-resume', _this.resume, _this);\n\t engine.globalEvent.addEventListener('jump-high-revive', _this.revive, _this);\n\t _this.addEventListener(engine.MouseEvent.MOUSE_DOWN, _this.onTap, _this);\n\t var gameView = _this._gameView = new GameView();\n\t _this.addChild(gameView);\n\t return _this;\n\t }\n\t JumpHigh.prototype.reset = function () {\n\t this._gameView.reset();\n\t };\n\t JumpHigh.prototype.start = function (event) {\n\t {\n\t injectProps(event.data);\n\t }\n\t this._status = 1;\n\t this._gameView.start();\n\t };\n\t JumpHigh.prototype.pause = function () {\n\t this._gameView.pause();\n\t };\n\t JumpHigh.prototype.resume = function () {\n\t this._gameView.resume();\n\t };\n\t JumpHigh.prototype.revive = function () {\n\t this._gameView.revive();\n\t };\n\t JumpHigh.prototype.onTap = function (event) {\n\t this._gameView.jump();\n\t };\n\t return JumpHigh;\n\t}(engine.Container));\n\n\tfunction index (props) {\n\t prepareProps();\n\t injectProps(props);\n\t var instance = new JumpHigh();\n\t return instance;\n\t}\n\n\treturn index;\n\n})));\n"
}
{
"name": "跳一跳",
"desc": "跳一跳模块",
"props": {
"prizeScore": {
"alias": "接中奖品获得分数",
"type": "number",
"default": 3
},
"prizeOdds": {
"alias": "奖品出现概率",
"type": "number",
"default": 0.3
},
"ghostOdds": {
"alias": "怪物出现概率",
"type": "number",
"default": 0.3
}
},
"assets": [
{
"name": "玩家abc",
"url": "//yun.duiba.com.cn/aurora/assets/41aab15126a106fb7b4083fbc50f9bcea5b3a090.svga",
"uuid": "613125b7-f199-4aa1-860a-9243fc16c4eb",
"ext": ".svga"
},
{
"name": "玩家右",
"url": "//yun.duiba.com.cn/aurora/assets/85af8997aa6dd1aa47011ea843302a4a072f2efd.png",
"uuid": "09e76db2-db0f-46e0-803a-998b1895a027",
"ext": ".png"
},
{
"name": "台阶",
"url": "//yun.duiba.com.cn/aurora/assets/e37ef0563103ffd582d787d36032d7262a3dce47.png",
"uuid": "db411686-ad6b-4bed-81b5-b844715e2882",
"ext": ".png"
},
{
"name": "青团",
"url": "//yun.duiba.com.cn/aurora/assets/14bfed9ab0c2f995b1ca34a5ca0116e8d155012d.png",
"uuid": "84b0849b-7417-4322-b4a3-f7d1a38b15c3",
"ext": ".png"
},
{
"name": "大灰狼",
"url": "//yun.duiba.com.cn/aurora/assets/25a1b525af1daeab062565c2c2c9737957ce4be3.svga",
"uuid": "eae1241a-d133-4816-9496-a2850e7e2d8f",
"ext": ".svga"
},
{
"name": "得分",
"url": "//yun.duiba.com.cn/aurora/assets/88e5d349a8829ddd2b0f608da4d2d537db4bad54.png",
"uuid": "8d9cfa4e-18f9-43a4-8f8e-6996577482b6",
"ext": ".png"
},
{
"name": "加分",
"url": "//yun.duiba.com.cn/aurora/assets/b534a5f50ccc7eeca9ea4f0d4dea78430b8dec9b.png",
"uuid": "6dcb1e61-95e2-4841-8b71-7152f8d6cb37",
"ext": ".png"
},
{
"name": "游戏背景音乐",
"url": "//yun.duiba.com.cn/aurora/assets/7c955f550176b8ea2797b5555c30f1dfc9a770c1.mp3",
"uuid": "da826400-c835-4b75-8991-a29b64c5ac0b",
"ext": ".mp3"
},
{
"name": "吃道具音效",
"url": "//yun.duiba.com.cn/aurora/assets/a9e40a494d33b2c2a5c70ad93090efb4b36cb55d.mp3",
"uuid": "6b809f4e-1712-4201-beed-a683294ded02",
"ext": ".mp3"
},
{
"name": "碰到怪物掉落死亡音效",
"url": "//yun.duiba.com.cn/aurora/assets/e7f28dbc188c24613dccd11690a6f2e66bd00caa.mp3",
"uuid": "dc4426e3-cfe0-492e-bf74-002e0eb605cf",
"ext": ".mp3"
},
{
"name": "跳起死亡音效",
"url": "//yun.duiba.com.cn/aurora/assets/5603f0353a3eeea305c7398bd17f993be7474641.mp3",
"uuid": "f3f66910-8af2-4ceb-b7b3-27329a8ca93b",
"ext": ".mp3"
}
],
"events": {
"in": {
"jump-more-reset": {
"alias": "重置",
"data": {
"goodsProbability": "[0.2,0.5,0.3]道具概率(雨滴、石头、炸弹),所有概率相加为1",
"countDown": "倒计时(s)",
"acceleratedSpeed": "道具掉落加速度(单位:每秒)"
}
},
"jump-more-start": {
"alias": "开始"
},
"jump-more-revive": {
"alias": "复活"
},
"jump-more-pause": {
"alias": "暂停"
},
"jump-more-resume": {
"alias": "恢复"
}
},
"out": {
"jump-more-score-update": {
"alias": "分数更新",
"data": {
"score": "分数"
}
},
"jump-more-game-over": {
"alias": "游戏结束",
"data": {
"score": "分数",
"reason": "结束原因(1:时间到了,2:玩家死亡)"
}
}
}
},
"id": "jump-more",
"code": "(function (global, factory) {\n\ttypeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('tslib')) :\n\ttypeof define === 'function' && define.amd ? define(['tslib'], factory) :\n\t(global = global || self, global['jump-more'] = factory(global.tslib));\n}(this, (function (tslib) { 'use strict';\n\n\tvar props = {};\n\tfunction prepareProps() {\n\t var metaProps = getProps();\n\t engine.injectProp(props, metaProps);\n\t}\n\tfunction injectProps(p) {\n\t engine.injectProp(props, p);\n\t}\n\n\tfunction getTexture(uuid) {\n\t return engine.Texture.from(getAssetByUUID(uuid).uuid);\n\t}\n\tfunction getTextureByName(name) {\n\t return getTexture(engine.getAssetByName(name).uuid);\n\t}\n\tfunction createSvga(name, anchorName) {\n\t var inst = new svga.Svga();\n\t inst.source = 'asset://' + engine.getAssetByName(name).uuid;\n\t return inst;\n\t}\n\n\tvar Platform = (function (_super) {\n\t tslib.__extends(Platform, _super);\n\t function Platform() {\n\t var _this = _super.call(this) || this;\n\t _this.x = 0;\n\t _this.y = 0;\n\t _this.prizeOdds = props.prizeOdds;\n\t _this.ghostOdds = props.ghostOdds;\n\t _this.width = 224;\n\t _this.height = 56;\n\t _this.flag = 0;\n\t _this.state = 0;\n\t _this.moved = 0;\n\t _this.vx = 1;\n\t _this.type = 1;\n\t _this._body = new engine.Rect();\n\t _this.isNew = true;\n\t _this.addStatus = false;\n\t _this.addChild(new engine.Sprite(getTextureByName('台阶')));\n\t _this.prizeIcon = new engine.Sprite(getTextureByName('青团'));\n\t _this.prizeIcon.x = _this.x + _this.width / 2 - _this.prizeIcon.width / 2;\n\t _this.prizeIcon.y = _this.y - _this.height + 10;\n\t _this.ghostIcon = createSvga('大灰狼');\n\t _this.ghostIcon.gotoAndPlay(1);\n\t setTimeout(function () {\n\t _this.ghostIcon.y = -_this.height * 2 - 10;\n\t _this.ghostIcon.x = _this.width / 2 - _this.ghostIcon.width / 2;\n\t }, 10);\n\t _this.prizeIcon.visible = false;\n\t _this.ghostIcon.visible = false;\n\t _this.addChild(_this.ghostIcon);\n\t _this.addChild(_this.prizeIcon);\n\t _this.prizeFlag = Math.random() < _this.prizeOdds ? true : false;\n\t if (_this.prizeFlag) {\n\t _this.ghostFlag = false;\n\t _this.prizeIcon.visible = true;\n\t }\n\t return _this;\n\t }\n\t Platform.prototype.getStatus = function () {\n\t this.prizeIcon.visible = false;\n\t this.ghostIcon.visible = false;\n\t this.prizeFlag = Math.random() < this.prizeOdds ? true : false;\n\t if (this.prizeFlag) {\n\t this.ghostFlag = false;\n\t this.prizeIcon.visible = true;\n\t }\n\t else {\n\t this.ghostFlag = Math.random() < this.ghostOdds ? true : false;\n\t if (this.ghostFlag)\n\t this.ghostIcon.visible = true;\n\t }\n\t };\n\t return Platform;\n\t}(engine.Container));\n\n\tvar Goods = (function (_super) {\n\t tslib.__extends(Goods, _super);\n\t function Goods() {\n\t var _this = _super.call(this) || this;\n\t var body;\n\t body = _this._body = new engine.Rect();\n\t var rain = new engine.Sprite(getTextureByName('雨滴'));\n\t rain[\"npcType\"] = \"rain\";\n\t var stone = new engine.Sprite(getTextureByName('石块'));\n\t stone[\"npcType\"] = \"stone\";\n\t var boom = new engine.Sprite(getTextureByName('炸弹'));\n\t boom[\"npcType\"] = \"boom\";\n\t rain.visible = false;\n\t stone.visible = false;\n\t boom.visible = false;\n\t body.addChild(rain);\n\t body.addChild(stone);\n\t body.addChild(boom);\n\t _this.addChild(body);\n\t body.width = .0001;\n\t body.height = .0001;\n\t body.mouseEnabled = false;\n\t return _this;\n\t }\n\t Goods.prototype.getRandomNumberByRange = function (start, end) {\n\t return Math.floor(Math.random() * (end - start) + start);\n\t };\n\t Goods.prototype.reset = function () {\n\t this.visible = true;\n\t this.rotation = 0;\n\t this.anchorOffsetY = 0;\n\t this.y = 0;\n\t this.x = (750 - 120) * Math.random() + 30;\n\t this.rotation = 0;\n\t var random = Math.random();\n\t if (random < props.goodsProbability[0]) {\n\t this.showNpc(\"rain\");\n\t }\n\t else if (random >= props.goodsProbability[0] && random <= (props.goodsProbability[0] + props.goodsProbability[1])) {\n\t this.showNpc(\"stone\");\n\t }\n\t else if (random > (props.goodsProbability[0] + props.goodsProbability[1])) {\n\t this.showNpc(\"boom\");\n\t }\n\t };\n\t Goods.prototype.showNpc = function (type) {\n\t for (var i = 0; i < this._body.children.length; i++) {\n\t this._body.children[i].visible = false;\n\t this._body.children[i].mouseEnabled = false;\n\t }\n\t for (var i = 0; i < this._body.children.length; i++) {\n\t if (this._body.children[i][\"npcType\"] == type) {\n\t this[\"npcType\"] = type;\n\t this._body.children[i].visible = true;\n\t this._body.children[i].mouseEnabled = false;\n\t }\n\t }\n\t };\n\t Object.defineProperty(Goods.prototype, \"anchorOffsetY\", {\n\t set: function (v) {\n\t this._body.y = v;\n\t },\n\t enumerable: true,\n\t configurable: true\n\t });\n\t return Goods;\n\t}(engine.Container));\n\n\tvar ObjectPool = engine.ObjectPool;\n\tvar PoolName = 'goods';\n\tObjectPool.registerPool(PoolName, function () {\n\t return new Goods();\n\t}, function (item, data) {\n\t item.reset();\n\t});\n\n\tvar SoundMgr = (function () {\n\t function SoundMgr() {\n\t }\n\t Object.defineProperty(SoundMgr, \"instance\", {\n\t get: function () {\n\t if (!this._instance) {\n\t this._instance = new SoundMgr();\n\t }\n\t return this._instance;\n\t },\n\t enumerable: true,\n\t configurable: true\n\t });\n\t Object.defineProperty(SoundMgr.prototype, \"enabled\", {\n\t get: function () {\n\t return engine.env.soundEnabled;\n\t },\n\t enumerable: true,\n\t configurable: true\n\t });\n\t SoundMgr.prototype.playEffect = function (name, loop) {\n\t if (loop === void 0) { loop = false; }\n\t engine.playSound(getAssetByUUID(nameToUuid[name]).uuid, {\n\t loop: loop,\n\t keep: true\n\t }, name);\n\t };\n\t SoundMgr.prototype.stopEffect = function (name) {\n\t engine.stopSound(name);\n\t engine.destroySound(name);\n\t };\n\t SoundMgr._instance = null;\n\t return SoundMgr;\n\t}());\n\tvar nameToUuid = {\n\t bgm: \"da826400-c835-4b75-8991-a29b64c5ac0b\",\n\t prize: \"6b809f4e-1712-4201-beed-a683294ded02\",\n\t ghost: \"dc4426e3-cfe0-492e-bf74-002e0eb605cf\",\n\t jumpdied: \"f3f66910-8af2-4ceb-b7b3-27329a8ca93b\",\n\t};\n\n\tvar ObjectPool$1 = engine.ObjectPool;\n\tvar GameView = (function (_super) {\n\t tslib.__extends(GameView, _super);\n\t function GameView() {\n\t var _this = _super.call(this) || this;\n\t _this.gravity = 0.2;\n\t _this.bottomY = 5;\n\t _this.jumpCount = 0;\n\t _this.flag = 0;\n\t _this.iconX = 0;\n\t _this.goodsItems = [];\n\t _this.platformCount = 12;\n\t _this.platformGap = 0;\n\t _this.platPosition = 0;\n\t _this.platforms = [];\n\t _this.newPlatforms = [];\n\t _this.cashNum = 0;\n\t _this.moveCatchX = 0;\n\t _this.playerCatchX = 0;\n\t _this.onDownStage = function (e) {\n\t if (e.stageX < _this.width / 2) {\n\t _this.player.dir = 'left';\n\t _this.player.isMovingLeft = true;\n\t _this.playerSvga.scaleX = -1;\n\t setTimeout(function () {\n\t _this.player.isMovingLeft = false;\n\t }, 500);\n\t }\n\t else {\n\t _this.player.dir = 'right';\n\t _this.player.isMovingRight = true;\n\t _this.playerSvga.scaleX = 1;\n\t setTimeout(function () {\n\t _this.player.isMovingRight = false;\n\t }, 500);\n\t }\n\t };\n\t _this.onMoveStage = function (e) {\n\t if (_this.gameIng) {\n\t _this.player.x = _this.playerCatchX + (e.localX - _this.moveCatchX);\n\t }\n\t };\n\t _this.onOutStage = function (e) {\n\t if (e.stageX < _this.width / 2) {\n\t _this.player.dir = 'left';\n\t _this.player.isMovingLeft = false;\n\t }\n\t else {\n\t _this.player.dir = 'right';\n\t _this.player.isMovingRight = false;\n\t }\n\t };\n\t _this.once(engine.Event.ADDED_TO_STAGE, _this.setup, _this);\n\t return _this;\n\t }\n\t GameView.prototype.setup = function () {\n\t var _this = this;\n\t if (this._hasSetup) {\n\t return;\n\t }\n\t this._hasSetup = true;\n\t this.NpcBg = new engine.Container();\n\t this.NpcBg.alpha = 1;\n\t this.NpcBg.width = 0;\n\t this.NpcBg.height = 0;\n\t this.addChild(this.NpcBg);\n\t this.player = new engine.Container();\n\t this.player.vx = 0;\n\t this.player.vy = 11;\n\t this.player.isMovingLeft = false;\n\t this.player.isMovingRight = false;\n\t this.player.isDead = false;\n\t this.player.jump = function () {\n\t _this.player.vy = -10;\n\t _this.playerSvga.play(false, false);\n\t };\n\t this.playerSvga = createSvga('玩家abc');\n\t this.player.addChild(this.playerSvga);\n\t this.visible = false;\n\t this.addScoreIcon = new engine.Sprite(getTextureByName('加分'));\n\t this.addScoreIcon.visible = false;\n\t this.player.addChild(this.addScoreIcon);\n\t setTimeout(function () {\n\t _this.visible = true;\n\t _this.playerSvga.anchorY = _this.playerSvga.height / 2;\n\t _this.playerSvga.anchorX = _this.playerSvga.width / 2;\n\t _this.player.anchorY = _this.player.height / 2;\n\t _this.player.anchorX = _this.player.width / 2;\n\t _this.player.x = 375 - _this.player.width / 2;\n\t _this.iconX = _this.player.width + 20;\n\t _this.addScoreIcon.y =\n\t _this.player.height / 2 - _this.addScoreIcon.height / 2 + 20;\n\t }, 300);\n\t this.score = 0;\n\t this.rectBg = new engine.Container();\n\t this.rectBg.width = 750;\n\t this.rectBg.height = 1624;\n\t this.rectHeight = this.stage.height - this.rectBg.height;\n\t this.rectBg.y = this.rectHeight;\n\t this.addChild(this.rectBg);\n\t this.player.y = this.rectBg.height;\n\t this.baseY = this.rectBg.height - this.bottomY;\n\t this.rectBg.addEventListener(engine.MouseEvent.CLICK, this.onDownStage, this);\n\t };\n\t GameView.prototype.base = function () { };\n\t GameView.prototype.createPlatform = function (needGhost) {\n\t if (needGhost === void 0) { needGhost = false; }\n\t var platform = new Platform();\n\t platform.x = Math.random() * (this.width - platform.width);\n\t this.platPosition += this.rectBg.height / this.platformCount;\n\t var platform2 = new Platform();\n\t var left = platform.x;\n\t if (left > this.width / 2) {\n\t platform2.x =\n\t Math.random() * (platform.x - platform.width) - platform.width / 2;\n\t }\n\t else {\n\t platform2.x =\n\t platform.x +\n\t platform.width +\n\t Math.random() * (this.width - platform.x - platform.width * 1.5);\n\t }\n\t platform2.y = platform.y = this.platPosition;\n\t if (needGhost && !platform.prizeFlag) {\n\t platform.ghostFlag = Math.random() < platform.ghostOdds ? true : false;\n\t if (platform.ghostFlag)\n\t platform.ghostIcon.visible = true;\n\t }\n\t return [platform, platform2];\n\t };\n\t GameView.prototype.changePlatformGap = function (to) {\n\t var _this = this;\n\t if (this.platformCount == to)\n\t return;\n\t this.platformCount = to;\n\t var min = this.rectBg.height;\n\t for (var i = 0; i < this.platforms.length; i++) {\n\t if (min > this.platforms[i].y) {\n\t min = this.platforms[i].y;\n\t }\n\t }\n\t this.platPosition =\n\t min - this.rectBg.height / this.platformCount + this.rectBg.height;\n\t var newList = [];\n\t for (var i = 0; i < this.platformCount; i++) {\n\t newList.push.apply(newList, this.createPlatform(true));\n\t }\n\t this.newPlatforms = newList;\n\t this.newPlatforms.forEach(function (p) {\n\t if (p.isNew && !p.addStatus) {\n\t _this.rectBg.addChild(p);\n\t p.addStatus = true;\n\t }\n\t });\n\t this.platforms.forEach(function (p) {\n\t p.isNew = false;\n\t _this.rectBg.addChild(p);\n\t });\n\t this.platforms = this.platforms.concat(this.newPlatforms);\n\t };\n\t GameView.prototype.platformInit = function () {\n\t var _a;\n\t var _this = this;\n\t for (var i = 0; i < this.platformCount; i++) {\n\t (_a = this.platforms).push.apply(_a, this.createPlatform());\n\t }\n\t this.platforms.forEach(function (p, i) {\n\t _this.rectBg.addChild(p);\n\t });\n\t };\n\t GameView.prototype.playerJump = function () {\n\t var _this = this;\n\t this.player.y += this.player.vy;\n\t this.player.vy += this.gravity;\n\t if (this.player.vy > 0 &&\n\t this.player.x + 15 < 260 &&\n\t this.player.x + this.player.width - 15 > 155 &&\n\t this.player.y + this.player.height > 475 &&\n\t this.player.y + this.player.height < 500) {\n\t return this.player.jump();\n\t }\n\t if (this.player.isMovingLeft === true) {\n\t this.player.x += this.player.vx;\n\t this.player.vx -= 0.1;\n\t }\n\t else {\n\t this.player.x += this.player.vx;\n\t if (this.player.vx < 0)\n\t this.player.vx += 0.07;\n\t }\n\t if (this.player.isMovingRight === true) {\n\t this.player.x += this.player.vx;\n\t this.player.vx += 0.1;\n\t }\n\t else {\n\t this.player.x += this.player.vx;\n\t if (this.player.vx > 0)\n\t this.player.vx -= 0.07;\n\t }\n\t if (this.player.vx > 4)\n\t this.player.vx = 4;\n\t else if (this.player.vx < -4)\n\t this.player.vx = -4;\n\t if (this.player.y + this.player.height > this.baseY &&\n\t this.baseY < this.rectBg.height) {\n\t this.player.jump();\n\t }\n\t if (this.baseY > this.rectBg.height &&\n\t this.player.y + this.player.height > this.rectBg.height &&\n\t this.player.isDead != 'lol') {\n\t this.player.isDead = true;\n\t SoundMgr.instance.playEffect('jumpdied');\n\t }\n\t if (this.player.x > this.width)\n\t this.player.x = 0 - this.player.width;\n\t else if (this.player.x < 0 - this.player.width)\n\t this.player.x = this.width - this.player.width;\n\t if (this.player.y >= this.rectBg.height / 2 - this.player.height / 2) {\n\t this.player.y += this.player.vy;\n\t this.player.vy += this.gravity;\n\t }\n\t else {\n\t if (this.player.y < this.height / 2) {\n\t this.player.y -= this.player.vy;\n\t }\n\t if (this.newPlatforms.length > 0) {\n\t this.platforms.forEach(function (p, i) {\n\t if (_this.player.vy < 0) {\n\t p.y -= _this.player.vy;\n\t }\n\t if (_this.player.y < _this.height / 2) {\n\t p.y -= _this.player.vy;\n\t }\n\t if (p.y > _this.height) {\n\t if (p.isNew == false) {\n\t _this.cashNum++;\n\t if (_this.cashNum ==\n\t _this.platforms.length - _this.newPlatforms.length) {\n\t var list = _this.platforms.splice(0, _this.cashNum);\n\t _this.newPlatforms = [];\n\t for (var i_1 = 0; i_1 < list.length; i_1++) {\n\t _this.rectBg.removeChild(list[i_1]);\n\t }\n\t _this.cashNum = 0;\n\t }\n\t }\n\t p.y = p.y - _this.rectBg.height * 2;\n\t }\n\t });\n\t }\n\t else {\n\t this.platforms.forEach(function (p, i) {\n\t if (_this.player.vy < 0) {\n\t p.y -= _this.player.vy;\n\t }\n\t if (_this.player.y < _this.height / 2) {\n\t p.y -= _this.player.vy;\n\t }\n\t if (p.y > _this.height) {\n\t if (i % 2 == 0) {\n\t _this.platforms[i].x =\n\t Math.random() * (_this.width - _this.platforms[i].width);\n\t if (i != 0) {\n\t p.getStatus();\n\t }\n\t }\n\t else {\n\t var last = _this.platforms[i - 1], left = last.x;\n\t if (left > _this.width / 2) {\n\t p.x = Math.random() * (last.x - p.width) - p.width / 2;\n\t }\n\t else {\n\t p.x =\n\t last.x +\n\t p.width +\n\t Math.random() * (_this.width - last.x - p.width * 1.5);\n\t }\n\t }\n\t p.y = p.y - _this.rectBg.height;\n\t }\n\t });\n\t }\n\t this.baseY -= this.player.vy;\n\t this.player.vy += this.gravity;\n\t if (this.player.vy >= 0) {\n\t this.player.y += this.player.vy;\n\t this.player.vy += this.gravity;\n\t }\n\t if (this.score > 30 && this.score < 60) {\n\t this.changePlatformGap(11);\n\t }\n\t else if (this.score > 60 && this.score < 120) {\n\t this.changePlatformGap(10);\n\t }\n\t else if (this.score > 120) {\n\t this.changePlatformGap(8);\n\t }\n\t }\n\t if (this.player.isDead === false)\n\t this.collides();\n\t if (this.player.isDead == true) {\n\t this.gameOver();\n\t }\n\t };\n\t GameView.prototype.playMusic = function () {\n\t SoundMgr.instance.playEffect('bgm', true);\n\t };\n\t GameView.prototype.collides = function () {\n\t var _this = this;\n\t this.platforms.forEach(function (p, i) {\n\t if (_this.player.vy > 0 &&\n\t p.state === 0 &&\n\t _this.player.x + 55 < p.x + p.width &&\n\t _this.player.x + _this.player.width - 30 > p.x &&\n\t _this.player.y + _this.player.height + 15 > p.y &&\n\t _this.player.y + _this.player.height + 15 < p.y + p.height) {\n\t if (p.prizeFlag) {\n\t SoundMgr.instance.playEffect('prize');\n\t _this.score += props.prizeScore;\n\t engine.globalEvent.dispatchEvent('jump-more-score-update', {\n\t score: _this.score\n\t });\n\t p.prizeFlag = false;\n\t p.prizeIcon.visible = false;\n\t if (p.x > _this.rectBg.width - p.width * 1.5) {\n\t _this.addScoreIcon.x = -20 - _this.addScoreIcon.width;\n\t }\n\t else {\n\t _this.addScoreIcon.x = _this.iconX;\n\t }\n\t _this.addScoreIcon.visible = true;\n\t if (_this.addTimer) {\n\t clearTimeout(_this.addTimer);\n\t }\n\t _this.addTimer = setTimeout(function () {\n\t _this.addScoreIcon.visible = false;\n\t }, 1000);\n\t }\n\t else if (p.ghostFlag) {\n\t SoundMgr.instance.playEffect('ghost');\n\t _this.diedIndex = i;\n\t _this.gameOver();\n\t }\n\t else {\n\t _this.player.jump();\n\t }\n\t }\n\t });\n\t };\n\t GameView.prototype.gameOver = function () {\n\t this.platforms.forEach(function (p, i) {\n\t p.y -= 12;\n\t });\n\t if (this.player.y > this.rectBg.height / 2 && this.flag === 0) {\n\t this.player.y -= 8;\n\t this.player.vy = 0;\n\t }\n\t else if (this.player.y + this.player.height > this.rectBg.height) ;\n\t engine.globalEvent.dispatchEvent('jump-more-game-over', {\n\t score: this.score\n\t });\n\t this.player.isDead = 'lol';\n\t };\n\t GameView.prototype.rectBgCalc = function () {\n\t };\n\t GameView.prototype.gameRevive = function () {\n\t this.player.isDead = false;\n\t var random = Math.floor(Math.random() * 3) * 2;\n\t this.player.x = this.platforms[random].x;\n\t this.player.y = this.platforms[random].y;\n\t this.player.vx = 0;\n\t this.player.vy = 11;\n\t this.platforms.forEach(function (p, i) {\n\t p.ghostFlag = false;\n\t p.ghostIcon.visible = false;\n\t });\n\t };\n\t GameView.prototype.update_my = function () {\n\t this.playerJump();\n\t this.rectBg.addChild(this.player);\n\t };\n\t GameView.prototype.reset = function () {\n\t this.removeEventListener(engine.Event.ENTER_FRAME, this.test, this);\n\t SoundMgr.instance.stopEffect('bgm');\n\t this.recycleGoods();\n\t this.player.vx = 0;\n\t this.player.vy = 11;\n\t this.player.isMovingLeft = false;\n\t this.player.isMovingRight = false;\n\t this.player.x = 375 - this.player.width / 2;\n\t this.player.y = this.rectBg.height - 200;\n\t this.rectBg.y = this.rectHeight;\n\t this.platPosition = 0;\n\t this.score = 0;\n\t this.platformCount = 12;\n\t this.platformGap = 0;\n\t this.baseY = this.rectBg.height - this.bottomY;\n\t this.player.isDead = false;\n\t this.platformInit();\n\t this.playerJump();\n\t };\n\t GameView.prototype.start = function () {\n\t this.aniLoop();\n\t this.playMusic();\n\t };\n\t GameView.prototype.pause = function () {\n\t this.gameIng = false;\n\t };\n\t GameView.prototype.revive = function () {\n\t this.gameIng = true;\n\t };\n\t GameView.prototype.resume = function () {\n\t return tslib.__awaiter(this, void 0, void 0, function () {\n\t return tslib.__generator(this, function (_a) {\n\t this.reset();\n\t this.start();\n\t return [2];\n\t });\n\t });\n\t };\n\t GameView.prototype.aniLoop = function () {\n\t var _this = this;\n\t this.addEventListener(engine.Event.ENTER_FRAME, (this.test = function () {\n\t _this.update_my();\n\t }), this);\n\t };\n\t GameView.prototype.died = function () {\n\t this.score = 0;\n\t this.pause();\n\t };\n\t GameView.prototype.removeNpc = function (goods) {\n\t var _this = this;\n\t this.NpcBg.removeChild(goods);\n\t ObjectPool$1.recycleObject(PoolName, goods);\n\t this.removeEventListener(engine.Event.ENTER_FRAME, function () {\n\t _this.update_my();\n\t }, this);\n\t var index = this.goodsItems.indexOf(goods);\n\t if (index > -1) {\n\t this.goodsItems.splice(index, 1);\n\t }\n\t };\n\t GameView.prototype.recycleGoods = function () {\n\t for (var _i = 0, _a = this.platforms; _i < _a.length; _i++) {\n\t var p = _a[_i];\n\t this.rectBg.removeChild(p);\n\t }\n\t this.newPlatforms = [];\n\t this.platforms = [];\n\t };\n\t GameView.prototype.hasHit = function (a, b) {\n\t if (Math.abs(a.x + a.width / 2 - (b.x + b.width / 2)) <\n\t a.width / 2 + b.width / 2 &&\n\t Math.abs(a.y + a.height / 2 - (b.y + b.height / 2)) <\n\t a.height / 2 + b.height / 2) {\n\t return true;\n\t }\n\t else {\n\t return false;\n\t }\n\t };\n\t return GameView;\n\t}(engine.Container));\n\n\tvar GameWrapper = (function (_super) {\n\t tslib.__extends(GameWrapper, _super);\n\t function GameWrapper() {\n\t var _this = _super.call(this) || this;\n\t engine.globalEvent.addEventListener('jump-more-reset', _this.reset, _this);\n\t engine.globalEvent.addEventListener('jump-more-start', _this.start, _this);\n\t engine.globalEvent.addEventListener('jump-more-resume', _this.resume, _this);\n\t engine.globalEvent.addEventListener('jump-more-revive', _this.revive, _this);\n\t _this.addEventListener(engine.MouseEvent.CLICK, _this.onTap, _this);\n\t var gameView = _this._gameView = new GameView();\n\t _this.addChild(gameView);\n\t return _this;\n\t }\n\t GameWrapper.prototype.reset = function (event) {\n\t injectProps(event.data);\n\t this._gameView.visible = true;\n\t this._gameView.reset();\n\t };\n\t GameWrapper.prototype.start = function (event) {\n\t injectProps(event.data);\n\t this._gameView.start();\n\t };\n\t GameWrapper.prototype.pause = function () {\n\t this._gameView.pause();\n\t };\n\t GameWrapper.prototype.resume = function () {\n\t this._gameView.resume();\n\t };\n\t GameWrapper.prototype.revive = function () {\n\t this._gameView.gameRevive();\n\t };\n\t GameWrapper.prototype.onTap = function (event) {\n\t };\n\t return GameWrapper;\n\t}(engine.Container));\n\n\tfunction index (props) {\n\t prepareProps();\n\t injectProps(props);\n\t var instance = new GameWrapper();\n\t return instance;\n\t}\n\n\treturn index;\n\n})));\n"
}
......@@ -12,7 +12,7 @@
"complete"
],
"id": "wait",
"script": "var duration = engine.findVariable('duration', args, props);\nsetTimeout(function () {\n next('complete');\n}, duration);\n",
"script": "var duration = engine.findVariable('duration', args, props);\nsetTimeout(function () {\n next('complete', args);\n}, duration);\n",
"group": "base",
"type": "builtin"
}
{
"name": "选择图片",
"desc": "选择一个图片文件",
"props": {},
"output": [
"success"
],
"id": "pick-image",
"script": "pick(function (imgData) {\n next('success', imgData);\n});\nfunction getExif(img, callback) {\n EXIF.getData(img, function () {\n var allMetaData = EXIF.getAllTags(this);\n callback(allMetaData);\n });\n}\nfunction pick(callback) {\n var fileInput = document.createElement(\"input\");\n fileInput.type = \"file\";\n fileInput.accept = \"image/*\";\n fileInput.style.display = \"none\";\n document.body.insertBefore(fileInput, document.body.firstChild);\n fileInput.addEventListener(\"change\", function (evt) {\n var mime = { \"png\": \"image/png\", \"jpg\": \"image/jpeg\", \"jpeg\": \"image/jpeg\", \"bmp\": \"image/bmp\" };\n var file = evt.target.files[0];\n var type = file.type;\n if (!type) {\n type = mime[file.name.match(/\\.([^\\.]+)$/i)[1]];\n }\n var fileReader = new FileReader();\n fileReader.onload = function () {\n getExif(file, function (exif) {\n var orientation = -1;\n if (exif) {\n orientation = exif[\"Orientation\"];\n }\n var image = new Image();\n image.onload = function () {\n var canvas = document.createElement(\"canvas\");\n var ctx = canvas.getContext(\"2d\");\n canvas.width = image.width;\n canvas.height = image.height;\n if (orientation > 4) {\n canvas.width = image.height;\n canvas.height = image.width;\n }\n ctx.clearRect(0, 0, canvas.width, canvas.height);\n switch (orientation) {\n case 2:\n ctx.translate(canvas.width, 0);\n ctx.scale(-1, 1);\n break;\n case 3:\n ctx.translate(canvas.width, canvas.height);\n ctx.rotate(Math.PI);\n break;\n case 4:\n ctx.translate(0, canvas.height);\n ctx.scale(1, -1);\n break;\n case 5:\n ctx.rotate(0.5 * Math.PI);\n ctx.scale(1, -1);\n break;\n case 6:\n ctx.rotate(0.5 * Math.PI);\n ctx.translate(0, -image.height);\n break;\n case 7:\n ctx.rotate(0.5 * Math.PI);\n ctx.translate(canvas.width, -canvas.height);\n ctx.scale(-1, 1);\n break;\n case 8:\n ctx.rotate(-0.5 * Math.PI);\n ctx.translate(-canvas.height, 0);\n break;\n default:\n ctx.transform(1, 0, 0, 1, 0, 0);\n }\n ctx.drawImage(image, 0, 0);\n var imagetype = \"png\";\n if (orientation !== -1) {\n imagetype = \"jpeg\";\n }\n var resultURL = \"\";\n if (imagetype === \"jpg\" || imagetype === \"jpeg\") {\n resultURL = canvas.toDataURL(\"image/\" + imagetype);\n }\n else {\n resultURL = canvas.toDataURL(\"image/\" + imagetype);\n }\n callback(resultURL);\n image.parentNode.removeChild(image);\n fileInput.parentNode.removeChild(fileInput);\n };\n image.src = fileReader.result;\n image.style.display = \"none\";\n document.body.appendChild(image);\n fileInput.value = \"\";\n });\n };\n fileReader.readAsDataURL(file);\n }, false);\n fileInput.click();\n}\n",
"group": "other",
"type": "builtin"
}
{
"name": "缩放图片",
"desc": "缩放图片",
"props": {
"width": {
"type": "number",
"alias": "目标宽度"
},
"height": {
"type": "number",
"alias": "目标高度"
},
"cutType": {
"type": "enum",
"enum": [
"inner",
"outer"
],
"alias": "裁剪类型",
"default": "inner"
},
"type": {
"type": "enum",
"enum": [
"png",
"jpeg"
],
"alias": "输出类型",
"default": "png"
},
"quality": {
"type": "number",
"alias": "图片质量",
"default": 0.7
}
},
"output": [
"success"
],
"id": "resize-image",
"script": "var width = engine.findVariable('width', args, props);\nvar height = engine.findVariable('height', args, props);\nvar cutType = engine.findVariable('cutType', args, props);\nvar type = engine.findVariable('type', args, props);\nvar quality = engine.findVariable('quality', args, props);\nvar img = args;\nif (typeof args === 'string') {\n img = new Image();\n img.onload = function () {\n deal();\n };\n img.onerror = function (e) {\n console.log(e);\n };\n img.src = args;\n}\nelse {\n deal();\n}\nfunction deal() {\n var m = cutType === 'inner' ? Math.min : Math.max;\n var r = m(width / img.width, height / img.height);\n var imgWidth = img.width * r;\n var imgHeight = img.height * r;\n var x = (width - imgWidth) / 2;\n var y = (height - imgHeight) / 2;\n var canvas = document.createElement('canvas');\n canvas.width = width;\n canvas.height = height;\n var ctx = canvas.getContext('2d');\n ctx.translate(x, y);\n ctx.scale(r, r);\n ctx.drawImage(img, 0, 0);\n var dataUrl = canvas.toDataURL('image/' + type, quality);\n next('success', dataUrl);\n}\n",
"group": "other",
"type": "builtin"
}
......@@ -6,13 +6,42 @@
},
"text": {
"type": "string",
"alias": "内容"
"alias": "文本内容"
},
"labelAlign": {
"alias": "文本对齐",
"type": "enum",
"enum": [
{
"label": "左对齐",
"value": "left"
},
{
"label": "居中对齐",
"value": "center"
},
{
"label": "右对齐",
"value": "right"
}
],
"default": "center"
},
"labSize": {
"alias": "文本大小",
"type": "number",
"default": 30
},
"padding": {
"type": "number",
"default": 10,
"alias": "边距"
},
"bgAlpha": {
"type": "number",
"default": 0.7,
"alias": "背景透明度"
},
"paddingH": {
"type": "number",
"alias": "横向边距"
......
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var ObjectPool = engine.ObjectPool;
var utils_1 = require("./utils");
var object_pool_init_1 = require("./object-pool-init");
var frontBox_1 = require("./frontBox");
var backBox_1 = require("./backBox");
var Zhuazi_1 = require("./Zhuazi");
var GameView = (function (_super) {
__extends(GameView, _super);
function GameView() {
var _this = _super.call(this) || this;
_this.startstatus = false;
_this.ifPrize = false;
_this.goodsItems = [];
_this.once(engine.Event.ADDED_TO_STAGE, _this.setup, _this);
return _this;
}
GameView.prototype.setup = function () {
if (this._hasSetup) {
return;
}
this._hasSetup = true;
var frontBoxs = (this._frontBoxs = new frontBox_1.FrontBoxs());
this._frontBoxs.GameView = this;
var backBoxs = (this._backBoxs = new backBox_1.BackBoxs());
this._Zhuazi = new Zhuazi_1.Zhuazi();
this._Zhuazi.GameView = this;
this.frontTransfer = new engine.Container();
this.backTransfer = new engine.Container();
this.frontTransfer.width = 0;
this.frontTransfer.height = 0;
this.frontTransfer.alpha = 1;
this.backTransfer.width = 0;
this.backTransfer.height = 0;
this.backTransfer.alpha = 1;
this.rect = new engine.Rect();
this.rect.width = 611;
this.rect.height = 704;
this.rect.x = 65;
this.rect.y = 263;
this.NpcBg = new engine.Container();
this.addChild(this.NpcBg);
this.addChild(this.rect);
var gameBg = new engine.Sprite(utils_1.getTextureByName("游戏背景"));
gameBg.x = 65;
gameBg.y = 263;
this.NpcBg.addChild(gameBg);
this.frontDesk = new engine.Sprite(utils_1.getTextureByName("前传输带"));
this.frontDesk.x = 60;
this.frontDesk.y = 781;
this.backDesk = new engine.Sprite(utils_1.getTextureByName("后传输带"));
this.backDesk.x = 60;
this.backDesk.y = 712;
this.NpcBg.addChild(this.backDesk);
this.NpcBg.addChild(this.frontDesk);
this.NpcBg.addChild(this.backTransfer);
this.NpcBg.addChild(this.frontTransfer);
this.NpcBg.addChild(this._Zhuazi);
this.NpcBg.mask = this.rect;
this._Zhuazi.setup();
this.backTransfer.addChild(this._backBoxs);
this._backBoxs.setup();
this.frontTransfer.addChild(this._frontBoxs);
this._frontBoxs.setup();
};
GameView.prototype.stopMove = function () {
this._frontBoxs.stop();
};
GameView.prototype.setMoveX = function (x, item) {
this.moveTime = x;
this.prizeBox = item;
this._Zhuazi.move();
};
GameView.prototype.setVisible = function (isshow) {
this._frontBoxs.showHidePrizeBox(isshow);
};
GameView.prototype.getMoveX = function () {
return this.moveTime;
};
GameView.prototype.resetMoveX = function () {
this.moveTime = null;
};
GameView.prototype.getBox = function () {
return this.prizeBox;
};
GameView.prototype.reset = function () {
this.startstatus = false;
this.ifPrize = false;
this._Zhuazi.getReset();
};
GameView.prototype.start = function (type) {
if (type === void 0) { type = null; }
this.speed = 1;
this.gameIng = true;
console.log('执行', type);
this.startstatus = true;
this.ifPrize = type && type.prize || false;
};
GameView.prototype.beginNpc = function () {
var _this = this;
this.timer = setTimeout(function () {
if (_this.gameIng) {
}
}, 2000 / this.speed);
};
GameView.prototype.pause = function () {
this.gameIng = false;
};
GameView.prototype.revive = function () {
this.gameIng = true;
};
GameView.prototype.resume = function () {
this.reset();
this.start();
};
GameView.prototype.initNpc = function () {
this.box1 = new engine.Sprite(utils_1.getTextureByName("草泥马盒"));
this.box2 = new engine.Sprite(utils_1.getTextureByName("狗盒"));
this.box3 = new engine.Sprite(utils_1.getTextureByName("猫盒"));
this.box4 = new engine.Sprite(utils_1.getTextureByName("草泥马盒"));
this.box5 = new engine.Sprite(utils_1.getTextureByName("猫盒"));
this.box1.x = 120;
this.box1.y = 434;
this.box2.x = 306;
this.box2.y = 434;
this.box3.x = 487;
this.box3.y = 434;
this.box4.x = 240;
this.box4.scaleX = 0.5;
this.box4.scaleY = 0.5;
this.box4.y = 390;
this.box5.x = 434;
this.box5.y = 390;
this.box5.scaleX = 0.5;
this.box5.scaleY = 0.5;
this.backTransfer.addChild(this.box4);
this.backTransfer.addChild(this.box5);
this.frontTransfer.addChild(this.box1);
this.frontTransfer.addChild(this.box2);
this.frontTransfer.addChild(this.box3);
};
GameView.prototype.died = function () {
this.score = 0;
this.pause();
};
GameView.prototype.removeNpc = function (goods) {
this.NpcBg.removeChild(goods);
ObjectPool.recycleObject(object_pool_init_1.PoolName, goods);
goods.removeEventListener(engine.Event.ENTER_FRAME, goods["onGoodsEnter"], this);
var index = this.goodsItems.indexOf(goods);
if (index > -1) {
this.goodsItems.splice(index, 1);
}
};
GameView.prototype.recycleGoods = function () {
clearTimeout(this.timer);
clearInterval(this.countdownTimer);
for (var _i = 0, _a = this.goodsItems; _i < _a.length; _i++) {
var goods = _a[_i];
if (goods) {
this.removeChild(goods);
ObjectPool.recycleObject(object_pool_init_1.PoolName, goods);
goods.removeEventListener(engine.Event.ENTER_FRAME, goods["onGoodsEnter"], this);
}
}
this.goodsItems = [];
};
GameView.prototype.hasHit = function (a, b) {
if (Math.abs(a.x + a.width / 2 - (b.x + b.width / 2)) <
a.width / 2 + b.width / 2 &&
Math.abs(a.y + a.height / 2 - (b.y + b.height / 2)) <
a.height / 2 + b.height / 2) {
return true;
}
else {
return false;
}
};
return GameView;
}(engine.Container));
exports.default = GameView;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var GameView_1 = require("./GameView");
var props_1 = require("../props");
var GameWrapper = (function (_super) {
__extends(GameWrapper, _super);
function GameWrapper() {
var _this = _super.call(this) || this;
engine.globalEvent.addEventListener('doll-machine-reset', _this.reset, _this);
engine.globalEvent.addEventListener('doll-machine-prize', _this.start, _this);
var gameView = _this._gameView = new GameView_1.default();
_this.addChild(gameView);
return _this;
}
GameWrapper.prototype.reset = function (event) {
props_1.injectProps(event.data);
this._gameView.visible = true;
this._gameView.reset();
};
GameWrapper.prototype.start = function (event) {
console.log('监听开始');
props_1.injectProps(event.data);
this._gameView.start(event.data);
};
GameWrapper.prototype.pause = function () {
this._gameView.pause();
};
GameWrapper.prototype.resume = function () {
this._gameView.resume();
};
GameWrapper.prototype.revive = function () {
this._gameView.revive();
};
GameWrapper.prototype.clear = function () {
this._gameView.visible = false;
};
GameWrapper.prototype.onTap = function (event) {
};
return GameWrapper;
}(engine.Container));
exports.GameWrapper = GameWrapper;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var utils_1 = require("./utils");
var Goods = (function (_super) {
__extends(Goods, _super);
function Goods() {
var _this = _super.call(this) || this;
var body;
body = _this._body = new engine.Rect();
var box1 = new engine.Sprite(utils_1.getTextureByName("草泥马盒"));
box1["npcType"] = "box1";
var box2 = new engine.Sprite(utils_1.getTextureByName("狗盒"));
box2["npcType"] = "box2";
var box3 = new engine.Sprite(utils_1.getTextureByName("猫盒"));
box3["npcType"] = "box3";
box1.visible = false;
box2.visible = false;
box3.visible = false;
body.addChild(box1);
body.addChild(box2);
body.addChild(box3);
_this.addChild(body);
body.width = 0.0001;
body.height = 0.0001;
body.mouseEnabled = false;
return _this;
}
Goods.prototype.getRandomNumberByRange = function (start, end) {
return Math.floor(Math.random() * (end - start) + start);
};
Goods.prototype.reset = function () {
this.visible = true;
this.y = 200;
this.x = 0;
this.rotation = 0;
var random = Math.random();
if (random < 0.3) {
this.showNpc("box1");
}
else if (random < 0.6) {
this.showNpc("box2");
}
else {
this.showNpc("box3");
}
};
Goods.prototype.showNpc = function (type) {
for (var i = 0; i < this._body.children.length; i++) {
this._body.children[i].visible = false;
this._body.children[i].mouseEnabled = false;
}
for (var i = 0; i < this._body.children.length; i++) {
if (this._body.children[i]["npcType"] == type) {
this["npcType"] = type;
console.log(type);
this._body.children[i].visible = true;
this._body.children[i].mouseEnabled = false;
}
}
};
Object.defineProperty(Goods.prototype, "anchorOffsetY", {
set: function (v) {
this._body.y = v;
},
enumerable: true,
configurable: true
});
return Goods;
}(engine.Container));
exports.Goods = Goods;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var utils_1 = require("./utils");
var props_1 = require("../props");
var Zhuazi = (function (_super) {
__extends(Zhuazi, _super);
function Zhuazi() {
var _this = _super.call(this) || this;
_this.moveArr = [];
_this.prizeBoxs = [];
return _this;
}
Zhuazi.prototype.setup = function () {
this.ganNode = new engine.Container();
this.moveNode = new engine.Container();
this.ganNode.x = 280;
this.ganNode.y = 350;
this.bashouGan = new engine.Sprite(utils_1.getTextureByName("把手杆子"));
this.bashouGan.x = 60;
this.bashouGan.y = 275;
this.bashou = new engine.Sprite(utils_1.getTextureByName("把手"));
this.bashou.x = 0;
this.bashou.y = 263;
this.ganzi = new engine.Sprite(utils_1.getTextureByName("伸缩杆"));
this.ganzi.x = 97;
this.ganzi.y = 290;
this.connect = new engine.Sprite(utils_1.getTextureByName("连接点"));
this.connect.x = 18;
this.connect.y = -5;
this.left_zhuazi = new engine.Sprite(utils_1.getTextureByName("左爪"));
this.left_zhuazi.x = -15;
this.left_zhuazi.y = 60;
this.left_zhuazi.anchorX = this.left_zhuazi.width;
this.left_zhuazi.anchorY = 0;
this.right_zhuazi = new engine.Sprite(utils_1.getTextureByName("右爪"));
this.right_zhuazi.x = 98;
this.right_zhuazi.y = 60;
this.ganNode.addChild(this.left_zhuazi);
this.ganNode.addChild(this.right_zhuazi);
this.ganNode.addChild(this.connect);
this.ganNode.x = 30;
this.zhuaziY = this.ganNode.y;
this.moveNode.addChild(this.ganzi);
this.moveNode.addChild(this.ganNode);
this.moveNode.addChild(this.bashou);
this.moveNode.x = 262;
this.addChild(this.bashouGan);
this.addChild(this.moveNode);
this.createPrizeBox();
};
Zhuazi.prototype.createPrizeBox = function () {
var _this = this;
this.box1 = new engine.Sprite(utils_1.getTextureByName("中奖狗盒"));
this.box1["npcType"] = "box1";
this.box2 = new engine.Sprite(utils_1.getTextureByName("中奖猫盒"));
this.box2["npcType"] = "box2";
this.box3 = new engine.Sprite(utils_1.getTextureByName("中奖草泥马盒"));
this.box3["npcType"] = "box3";
this.box4 = new engine.Sprite(utils_1.getTextureByName("中奖狗盒"));
this.box4["npcType"] = "box4";
this.box5 = new engine.Sprite(utils_1.getTextureByName("中奖猫盒"));
this.box5["npcType"] = "box5";
this.prizeBoxs = [this.box1, this.box2, this.box3, this.box4, this.box5];
this.prizeBoxs.forEach(function (item) {
_this.ganNode.addChild(item);
item.visible = false;
item.x = 15;
item.y = 48;
});
};
Zhuazi.prototype.showPrizeBox = function () {
var _this = this;
this.prizeBoxs.forEach(function (item) {
console.log(_this.GameView.getBox()['npcType']);
if (item['npcType'] === _this.GameView.getBox()['npcType']) {
item.visible = true;
_this.itemShow = item;
}
else {
item.visible = false;
}
});
};
Zhuazi.prototype.move = function () {
var _this = this;
var rndist = Math.random();
var halfWidth = this.bashou.width / 2;
var randomX = rndist * (rndist > 0.5 ? 1 : -1) * props_1.props.bashouMoveDist;
console.log(randomX);
engine.Tween.get(this.moveNode).to({ x: 370 + halfWidth - 71 }, 1000).call(function () {
_this.zhangkai();
});
};
Zhuazi.prototype.zhangkai = function () {
var _this = this;
this.left_zhuazi.anchorX = this.left_zhuazi.width;
this.left_zhuazi.anchorY = 0;
engine.Tween.get(this.left_zhuazi, { loop: false }).to({ rotation: props_1.props.leftRotation }, 1000);
engine.Tween.get(this.right_zhuazi, { loop: false }).to({ rotation: props_1.props.rightRotation }, 1000);
setTimeout(function () {
_this.getLong();
}, 500);
};
Zhuazi.prototype.getLong = function () {
var _this = this;
var droptime = Number((this.GameView.getMoveX() / 60 - 1).toFixed(2)) * 1000;
console.log('dr', droptime);
var times = (props_1.props.ganMoveEndY - this.ganzi.y) / this.ganzi.height;
console.log(Number(times.toFixed(2)));
engine.Tween.get(this.ganzi).to({ scaleY: Number(times.toFixed(2)) }, droptime).to({ scaleY: 1 }, droptime);
console.log('node', this.zhuaziY);
engine.Tween.get(this.ganNode).to({ y: props_1.props.ganMoveEndY }, droptime).call(function () {
_this.GameView.stopMove();
if (_this.GameView.ifPrize) {
_this.showPrizeBox();
_this.GameView.setVisible(false);
}
}).to({ y: this.zhuaziY }, droptime).call(function () {
if (_this.GameView.ifPrize) {
_this.itemShow.visible = false;
}
engine.globalEvent.dispatchEvent('doll-machine-gameover');
});
};
Zhuazi.prototype.getReset = function () {
this.left_zhuazi.anchorX = this.left_zhuazi.width;
this.left_zhuazi.anchorY = 0;
engine.Tween.get(this.moveNode, { loop: false }).to({ x: 262 }, 1000);
engine.Tween.get(this.left_zhuazi, { loop: false }).to({ rotation: 0 }, 1000);
engine.Tween.get(this.right_zhuazi, { loop: false }).to({ rotation: 0 }, 1000);
this.GameView.resetMoveX();
};
return Zhuazi;
}(engine.Container));
exports.Zhuazi = Zhuazi;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var utils_1 = require("./utils");
var props_1 = require("../props");
var BackBoxs = (function (_super) {
__extends(BackBoxs, _super);
function BackBoxs() {
var _this = _super.call(this) || this;
_this.backBoxs = [];
return _this;
}
BackBoxs.prototype.setup = function () {
var initX, initY = 0;
this.box1 = new engine.Sprite(utils_1.getTextureByName("后狗盒"));
initX = this.box1.x = 188;
initY = this.box1.y = 616;
this.box2 = new engine.Sprite(utils_1.getTextureByName("后猫盒"));
this.box3 = new engine.Sprite(utils_1.getTextureByName("后草泥马盒"));
this.box4 = new engine.Sprite(utils_1.getTextureByName("后狗盒"));
this.box5 = new engine.Sprite(utils_1.getTextureByName("后猫盒"));
this.backBoxs = [this.box1, this.box2, this.box3, this.box4, this.box5];
for (var i = 0; i < this.backBoxs.length; i++) {
if (i == 0) {
this.backBoxs[i].x = initX;
}
else {
this.backBoxs[i].x = this.backBoxs[i - 1].x + this.backBoxs[i].width + props_1.props.backmargin;
}
this.backBoxs[i].y = initY;
this.addChild(this.backBoxs[i]);
}
this.addEventListener(engine.Event.ENTER_FRAME, this.frameMove, this);
};
BackBoxs.prototype.frameMove = function () {
var _this = this;
this.backBoxs.forEach(function (item) {
item.x -= props_1.props.moveSpeed;
if (item.x <= 0) {
var lastitem = _this.backBoxs.shift();
lastitem.x = _this.backBoxs[_this.backBoxs.length - 1].x + item.width + props_1.props.backmargin;
_this.backBoxs.push(lastitem);
}
});
};
return BackBoxs;
}(engine.Container));
exports.BackBoxs = BackBoxs;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var utils_1 = require("./utils");
var props_1 = require("../props");
var FrontBoxs = (function (_super) {
__extends(FrontBoxs, _super);
function FrontBoxs() {
var _this = _super.call(this) || this;
_this.frontBoxs = [];
return _this;
}
FrontBoxs.prototype.setup = function () {
var initX, initY = 0;
this.box1 = new engine.Sprite(utils_1.getTextureByName("狗盒"));
this.box1["npcType"] = "box1";
initX = this.box1.x = 435;
initY = this.box1.y = 614;
this.box2 = new engine.Sprite(utils_1.getTextureByName("猫盒"));
this.box2["npcType"] = "box2";
this.box3 = new engine.Sprite(utils_1.getTextureByName("草泥马盒"));
this.box3["npcType"] = "box3";
this.box4 = new engine.Sprite(utils_1.getTextureByName("狗盒"));
this.box4["npcType"] = "box4";
this.box5 = new engine.Sprite(utils_1.getTextureByName("猫盒"));
this.box5["npcType"] = "box5";
this.frontBoxs = [this.box1, this.box2, this.box3, this.box4];
for (var i = 0; i < this.frontBoxs.length; i++) {
if (i == 0) {
this.frontBoxs[i].x = initX;
}
else {
this.frontBoxs[i].x = this.frontBoxs[i - 1].x - this.box1.width - props_1.props.frontmargin;
}
this.frontBoxs[i].y = initY;
this.addChild(this.frontBoxs[i]);
}
this.addEventListener(engine.Event.ENTER_FRAME, this.frameMove, this);
};
FrontBoxs.prototype.frameMove = function () {
var _this = this;
this.frontBoxs.forEach(function (item, index) {
item.x += props_1.props.moveSpeed;
if (item.x <= 0 && !item.visible) {
item.visible = true;
}
if (item.x >= 750) {
var lastitem = _this.frontBoxs.shift();
lastitem.x = _this.frontBoxs[_this.frontBoxs.length - 1].x - _this.box1.width - props_1.props.frontmargin;
if (!_this.GameView.getMoveX() && item.x <= 0 && _this.GameView.startstatus) {
_this.GameView.setMoveX((370 - item.x - 13) / props_1.props.moveSpeed, item);
_this.hideBox = item;
}
_this.frontBoxs.push(lastitem);
}
});
};
FrontBoxs.prototype.stop = function () {
};
FrontBoxs.prototype.showHidePrizeBox = function (isshow) {
this.hideBox.visible = isshow;
};
return FrontBoxs;
}(engine.Container));
exports.FrontBoxs = FrontBoxs;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var Goods_1 = require("./Goods");
var ObjectPool = engine.ObjectPool;
exports.PoolName = 'goods';
ObjectPool.registerPool(exports.PoolName, function () {
return new Goods_1.Goods();
}, function (item, data) {
item.reset();
});
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
function getTexture(uuid) {
return engine.Texture.from(getAssetByUUID(uuid).uuid);
}
exports.getTexture = getTexture;
function getTextureByName(name) {
return getTexture(engine.getAssetByName(name).uuid);
}
exports.getTextureByName = getTextureByName;
function playSound(name) {
engine.playSound(engine.getAssetByName(name).uuid, { keep: true });
}
exports.playSound = playSound;
function createSvga(name, anchorName) {
var inst = new svga.Svga();
inst.source = 'asset://' + engine.getAssetByName(name).uuid;
return inst;
}
exports.createSvga = createSvga;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var GameWrapper_1 = require("./game/GameWrapper");
var props_1 = require("./props");
function default_1(props) {
props_1.prepareProps();
props_1.injectProps(props);
var instance = new GameWrapper_1.GameWrapper();
return instance;
}
exports.default = default_1;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.props = {};
function prepareProps() {
var metaProps = getProps();
engine.injectProp(exports.props, metaProps);
}
exports.prepareProps = prepareProps;
function injectProps(p) {
engine.injectProp(exports.props, p);
}
exports.injectProps = injectProps;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var props_1 = require("../props");
var utils_1 = require("./utils");
var frontBox_1 = require("./frontBox");
var backBox_1 = require("./backBox");
var Zhuazi_1 = require("./Zhuazi");
var GameView = (function (_super) {
__extends(GameView, _super);
function GameView() {
var _this = _super.call(this) || this;
_this.startstatus = false;
_this.ifPrize = false;
_this.goodsItems = [];
_this.once(engine.Event.ADDED_TO_STAGE, _this.setup, _this);
return _this;
}
GameView.prototype.setup = function () {
var _this = this;
if (this._hasSetup) {
return;
}
this._hasSetup = true;
var frontBoxs = (this._frontBoxs = new frontBox_1.FrontBoxs());
this._frontBoxs.GameView = this;
var backBoxs = (this._backBoxs = new backBox_1.BackBoxs());
this._Zhuazi = new Zhuazi_1.Zhuazi();
this._Zhuazi.GameView = this;
this.frontTransfer = new engine.Container();
this.backTransfer = new engine.Container();
this.frontTransfer.width = 0;
this.frontTransfer.height = 0;
this.frontTransfer.alpha = 1;
this.backTransfer.width = 0;
this.backTransfer.height = 0;
this.backTransfer.alpha = 1;
this.rect = new engine.Rect();
this.rect.width = props_1.props.gameStageWidth;
this.rect.height = props_1.props.gameStageHeight;
this.rect.x = 65;
this.rect.y = 0;
this.NpcBg = new engine.Container();
this.NpcBg.x = 0;
this.NpcBg.y = 0;
this.addChild(this.NpcBg);
this.addChild(this.rect);
this.frontDesk = new engine.Sprite(utils_1.getTextureByName("前传输带"));
this.frontDesk.x = props_1.props.initOffsetLeft;
this.frontDesk.y = props_1.props.frontDeskY - props_1.props.initOffsetTop;
this.backDesk = new engine.Sprite(utils_1.getTextureByName("后传输带"));
this.backDesk.x = props_1.props.initOffsetLeft;
this.backDesk.y = props_1.props.backDeskY - props_1.props.initOffsetTop;
if (props_1.props.single) {
this.backDesk.visible = false;
}
var pcarr = [this.backDesk, this.frontDesk, this.backTransfer, this.frontTransfer, this._Zhuazi];
pcarr.forEach(function (item) {
_this.NpcBg.addChild(item);
});
this.NpcBg.mask = this.rect;
this._Zhuazi.setup();
this.backTransfer.addChild(this._backBoxs);
this._backBoxs.setup();
if (props_1.props.single) {
this.backTransfer.visible = false;
}
this.frontTransfer.addChild(this._frontBoxs);
this._frontBoxs.setup();
};
GameView.prototype.stopMove = function () {
this._frontBoxs.stop();
};
GameView.prototype.setMoveX = function (x, item) {
this.moveTime = x;
this.prizeBox = item;
this._Zhuazi.move();
};
GameView.prototype.setVisible = function (isshow) {
this._frontBoxs.showHidePrizeBox(isshow);
};
GameView.prototype.getMoveX = function () {
return this.moveTime;
};
GameView.prototype.resetMoveX = function () {
this.moveTime = null;
};
GameView.prototype.getBox = function () {
return this.prizeBox;
};
GameView.prototype.reset = function () {
this.startstatus = false;
this.ifPrize = false;
this._Zhuazi.getReset();
};
GameView.prototype.start = function (type) {
if (type === void 0) { type = null; }
this.speed = 1;
this.gameIng = true;
console.log('执行', type);
this.startstatus = true;
this.ifPrize = type && type.prize || false;
};
GameView.prototype.beginNpc = function () {
var _this = this;
this.timer = setTimeout(function () {
if (_this.gameIng) {
}
}, 2000 / this.speed);
};
GameView.prototype.pause = function () {
this.gameIng = false;
};
GameView.prototype.revive = function () {
this.gameIng = true;
};
GameView.prototype.resume = function () {
this.reset();
this.start();
};
return GameView;
}(engine.Container));
exports.default = GameView;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var GameView_1 = require("./GameView");
var props_1 = require("../props");
var GameWrapper = (function (_super) {
__extends(GameWrapper, _super);
function GameWrapper() {
var _this = _super.call(this) || this;
engine.globalEvent.addEventListener('doll-machine2-game-init', _this.reset, _this);
engine.globalEvent.addEventListener('doll-machine2-game-start', _this.start, _this);
var gameView = _this._gameView = new GameView_1.default();
_this.addChild(gameView);
return _this;
}
GameWrapper.prototype.reset = function (event) {
props_1.injectProps(event.data);
this._gameView.visible = true;
this._gameView.reset();
};
GameWrapper.prototype.start = function (event) {
console.log('监听开始');
props_1.injectProps(event.data);
this._gameView.start(event.data);
};
GameWrapper.prototype.pause = function () {
this._gameView.pause();
};
GameWrapper.prototype.resume = function () {
this._gameView.resume();
};
GameWrapper.prototype.revive = function () {
this._gameView.revive();
};
GameWrapper.prototype.clear = function () {
this._gameView.visible = false;
};
GameWrapper.prototype.onTap = function (event) {
};
return GameWrapper;
}(engine.Container));
exports.GameWrapper = GameWrapper;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var utils_1 = require("./utils");
var Goods = (function (_super) {
__extends(Goods, _super);
function Goods() {
var _this = _super.call(this) || this;
var body;
body = _this._body = new engine.Rect();
var box1 = new engine.Sprite(utils_1.getTextureByName("草泥马盒"));
box1["npcType"] = "box1";
var box2 = new engine.Sprite(utils_1.getTextureByName("狗盒"));
box2["npcType"] = "box2";
var box3 = new engine.Sprite(utils_1.getTextureByName("猫盒"));
box3["npcType"] = "box3";
box1.visible = false;
box2.visible = false;
box3.visible = false;
body.addChild(box1);
body.addChild(box2);
body.addChild(box3);
_this.addChild(body);
body.width = 0.0001;
body.height = 0.0001;
body.mouseEnabled = false;
return _this;
}
Goods.prototype.getRandomNumberByRange = function (start, end) {
return Math.floor(Math.random() * (end - start) + start);
};
Goods.prototype.reset = function () {
this.visible = true;
this.y = 200;
this.x = 0;
this.rotation = 0;
var random = Math.random();
if (random < 0.3) {
this.showNpc("box1");
}
else if (random < 0.6) {
this.showNpc("box2");
}
else {
this.showNpc("box3");
}
};
Goods.prototype.showNpc = function (type) {
for (var i = 0; i < this._body.children.length; i++) {
this._body.children[i].visible = false;
this._body.children[i].mouseEnabled = false;
}
for (var i = 0; i < this._body.children.length; i++) {
if (this._body.children[i]["npcType"] == type) {
this["npcType"] = type;
console.log(type);
this._body.children[i].visible = true;
this._body.children[i].mouseEnabled = false;
}
}
};
Object.defineProperty(Goods.prototype, "anchorOffsetY", {
set: function (v) {
this._body.y = v;
},
enumerable: true,
configurable: true
});
return Goods;
}(engine.Container));
exports.Goods = Goods;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var utils_1 = require("./utils");
var props_1 = require("../props");
var Zhuazi = (function (_super) {
__extends(Zhuazi, _super);
function Zhuazi() {
var _this = _super.call(this) || this;
_this.moveArr = [];
_this.prizeBoxs = [];
return _this;
}
Zhuazi.prototype.setup = function () {
this.ganNode = new engine.Container();
this.moveNode = new engine.Container();
this.ganNode.x = 280;
this.ganNode.y = 350;
this.bashouGan = new engine.Sprite(utils_1.getTextureByName("把手杆子"));
this.bashouGan.x = 60;
this.bashouGan.y = 12;
this.bashou = new engine.Sprite(utils_1.getTextureByName("把手"));
this.bashou.x = 0;
this.bashou.y = 0;
this.ganzi = new engine.Sprite(utils_1.getTextureByName("伸缩杆"));
this.ganzi.x = 97;
this.ganzi.y = 27;
this.connect = new engine.Sprite(utils_1.getTextureByName("连接点"));
this.connect.x = 18;
this.connect.y = -5;
this.left_zhuazi = new engine.Sprite(utils_1.getTextureByName("左爪"));
this.left_zhuazi.x = props_1.props.leftLocX;
this.left_zhuazi.y = props_1.props.leftLocY;
this.left_zhuazi.anchorX = this.left_zhuazi.width;
this.left_zhuazi.anchorY = 0;
this.right_zhuazi = new engine.Sprite(utils_1.getTextureByName("右爪"));
this.right_zhuazi.x = props_1.props.rightLocX;
this.right_zhuazi.y = props_1.props.rightLocY;
this.ganNode.addChild(this.left_zhuazi);
this.ganNode.addChild(this.right_zhuazi);
this.ganNode.addChild(this.connect);
this.ganNode.x = 30;
this.ganNode.y = this.ganNode.y - 263;
this.zhuaziY = this.ganNode.y;
this.moveNode.addChild(this.ganzi);
this.moveNode.addChild(this.ganNode);
this.moveNode.addChild(this.bashou);
this.moveNode.x = 262;
this.bashouGan.y = this.bashouGan.y;
this.moveNode.y = this.moveNode.y;
this.addChild(this.bashouGan);
this.addChild(this.moveNode);
if (!props_1.props.ganziShow) {
this.bashouGan.visible = false;
}
if (!props_1.props.bashouShow) {
this.bashou.visible = false;
}
this.createPrizeBox();
};
Zhuazi.prototype.createPrizeBox = function () {
var _this = this;
for (var i = 0; i < props_1.props.dollNum; i++) {
if (!new engine.Sprite(utils_1.getTextureByName('prizebox_' + i))) {
return;
}
this.prizeBoxs[i] = new engine.Sprite(utils_1.getTextureByName('prizebox_' + i));
this.prizeBoxs[i]['npcType'] = 'box' + i;
}
this.prizeBoxs[props_1.props.dollNum] = new engine.Sprite(utils_1.getTextureByName('prizebox_0'));
this.prizeBoxs[props_1.props.dollNum]['npcType'] = 'box' + props_1.props.dollNum;
this.prizeBoxs.forEach(function (item) {
_this.ganNode.addChild(item);
item.visible = false;
item.x = props_1.props.prizeBoxInitX;
item.y = props_1.props.prizeBoxInitY;
});
};
Zhuazi.prototype.showPrizeBox = function () {
var _this = this;
this.prizeBoxs.forEach(function (item) {
console.log(_this.GameView.getBox()['npcType']);
if (item['npcType'] === _this.GameView.getBox()['npcType']) {
item.visible = true;
_this.itemShow = item;
}
else {
item.visible = false;
}
});
};
Zhuazi.prototype.move = function () {
var _this = this;
var rndist = Math.random();
var halfWidth = this.bashou.width / 2;
var randomX = rndist * (rndist > 0.5 ? 1 : -1) * props_1.props.bashouMoveDist;
console.log(randomX);
engine.Tween.get(this.moveNode).to({ x: 370 + halfWidth - 71 }, 1000).call(function () {
_this.zhangkai();
});
};
Zhuazi.prototype.zhangkai = function () {
var _this = this;
this.left_zhuazi.anchorX = this.left_zhuazi.width;
this.left_zhuazi.anchorY = 0;
engine.Tween.get(this.left_zhuazi, { loop: false }).to({ rotation: props_1.props.leftRotation }, 1000);
engine.Tween.get(this.right_zhuazi, { loop: false }).to({ rotation: props_1.props.rightRotation }, 1000);
setTimeout(function () {
_this.getLong();
}, 500);
};
Zhuazi.prototype.getLong = function () {
var _this = this;
var droptime = Number((this.GameView.getMoveX() / 60 - 1).toFixed(2)) * 1000 - 130;
console.log('dr', droptime);
var times = (props_1.props.ganMoveEndY - this.ganzi.y) / this.ganzi.height;
console.log(Number(times.toFixed(2)));
engine.Tween.get(this.ganzi).to({ scaleY: Number(times.toFixed(2)) }, droptime).to({ scaleY: 1 }, droptime);
console.log('node', this.zhuaziY);
engine.Tween.get(this.ganNode).to({ y: props_1.props.ganMoveEndY }, droptime).call(function () {
_this.GameView.stopMove();
if (_this.GameView.ifPrize) {
_this.showPrizeBox();
_this.GameView.setVisible(false);
}
}).to({ y: this.zhuaziY }, droptime).call(function () {
if (_this.GameView.ifPrize) {
_this.itemShow.visible = false;
}
engine.globalEvent.dispatchEvent('doll-machine2-game-end');
});
};
Zhuazi.prototype.getReset = function () {
this.left_zhuazi.anchorX = this.left_zhuazi.width;
this.left_zhuazi.anchorY = 0;
engine.Tween.get(this.moveNode, { loop: false }).to({ x: 262 }, 1000);
engine.Tween.get(this.left_zhuazi, { loop: false }).to({ rotation: 0 }, 1000);
engine.Tween.get(this.right_zhuazi, { loop: false }).to({ rotation: 0 }, 1000);
this.GameView.resetMoveX();
};
return Zhuazi;
}(engine.Container));
exports.Zhuazi = Zhuazi;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var utils_1 = require("./utils");
var props_1 = require("../props");
var BackBoxs = (function (_super) {
__extends(BackBoxs, _super);
function BackBoxs() {
var _this = _super.call(this) || this;
_this.backBoxs = [];
return _this;
}
BackBoxs.prototype.setup = function () {
var initX, initY = 0;
for (var i = 0; i < props_1.props.dollNum; i++) {
this.backBoxs[i] = new engine.Sprite(utils_1.getTextureByName('backbox_' + i));
initX = this.backBoxs[0].x = props_1.props.backInitX;
initY = this.backBoxs[0].y = props_1.props.backInitY - props_1.props.initOffsetTop;
this.backBoxs[i]['npcType'] = 'box' + i;
}
this.backBoxs[props_1.props.dollNum] = new engine.Sprite(utils_1.getTextureByName('backbox_0'));
this.backBoxs[props_1.props.dollNum]['npcType'] = 'box' + props_1.props.dollNum;
for (var i = 0; i < this.backBoxs.length; i++) {
if (i == 0) {
this.backBoxs[i].x = initX;
}
else {
this.backBoxs[i].x = this.backBoxs[i - 1].x + this.backBoxs[i].width + props_1.props.backmargin;
}
this.backBoxs[i].y = initY;
this.addChild(this.backBoxs[i]);
}
this.addEventListener(engine.Event.ENTER_FRAME, this.frameMove, this);
};
BackBoxs.prototype.frameMove = function () {
var _this = this;
this.backBoxs.forEach(function (item) {
item.x -= props_1.props.moveSpeed;
if (item.x <= 0) {
var lastitem = _this.backBoxs.shift();
lastitem.x = _this.backBoxs[_this.backBoxs.length - 1].x + item.width + props_1.props.backmargin;
_this.backBoxs.push(lastitem);
}
});
};
return BackBoxs;
}(engine.Container));
exports.BackBoxs = BackBoxs;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var utils_1 = require("./utils");
var props_1 = require("../props");
var FrontBoxs = (function (_super) {
__extends(FrontBoxs, _super);
function FrontBoxs() {
var _this = _super.call(this) || this;
_this.frontBoxs = [];
return _this;
}
FrontBoxs.prototype.setup = function () {
var initX, initY = 0;
for (var i = 0; i < props_1.props.dollNum; i++) {
if (!new engine.Sprite(utils_1.getTextureByName('frontbox_' + i))) {
return;
}
this.frontBoxs[i] = new engine.Sprite(utils_1.getTextureByName('frontbox_' + i));
initX = this.frontBoxs[0].x = props_1.props.frontInitX;
initY = this.frontBoxs[0].y = props_1.props.frontInitY;
this.frontBoxs[i]['npcType'] = 'box' + i;
}
this.frontBoxs[props_1.props.dollNum] = new engine.Sprite(utils_1.getTextureByName('frontbox_0'));
this.frontBoxs[props_1.props.dollNum]['npcType'] = 'box' + props_1.props.dollNum;
console.log(this.frontBoxs);
for (var i = 0; i < this.frontBoxs.length; i++) {
if (i == 0) {
this.frontBoxs[i].x = initX;
}
else {
this.frontBoxs[i].x = this.frontBoxs[i - 1].x - this.frontBoxs[0].width - props_1.props.frontmargin;
}
console.log(this.frontBoxs[i].x);
this.frontBoxs[i].y = initY;
this.addChild(this.frontBoxs[i]);
console.log('aaa', this.frontBoxs[i].x);
}
this.addEventListener(engine.Event.ENTER_FRAME, this.frameMove, this);
};
FrontBoxs.prototype.frameMove = function () {
var _this = this;
this.frontBoxs.forEach(function (item, index) {
item.x += props_1.props.moveSpeed;
if (item.x <= 0 && !item.visible) {
item.visible = true;
}
if (item.x >= 750) {
var tmpIndex = 0;
if (index <= 0) {
tmpIndex = _this.frontBoxs.length - 1;
}
else {
tmpIndex = index - 1;
}
item.x = _this.frontBoxs[tmpIndex].x - _this.frontBoxs[0].width - props_1.props.frontmargin;
if (!_this.GameView.getMoveX() && item.x <= 0 && _this.GameView.startstatus) {
_this.GameView.setMoveX((370 - item.x - 13) / props_1.props.moveSpeed, item);
_this.hideBox = item;
}
}
});
};
FrontBoxs.prototype.stop = function () {
};
FrontBoxs.prototype.showHidePrizeBox = function (isshow) {
this.hideBox.visible = isshow;
};
return FrontBoxs;
}(engine.Container));
exports.FrontBoxs = FrontBoxs;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var Goods_1 = require("./Goods");
var ObjectPool = engine.ObjectPool;
exports.PoolName = 'goods';
ObjectPool.registerPool(exports.PoolName, function () {
return new Goods_1.Goods();
}, function (item, data) {
item.reset();
});
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
function getTexture(uuid) {
return engine.Texture.from(getAssetByUUID(uuid).uuid);
}
exports.getTexture = getTexture;
function getTextureByName(name) {
return getTexture(engine.getAssetByName(name).uuid);
}
exports.getTextureByName = getTextureByName;
function playSound(name) {
engine.playSound(engine.getAssetByName(name).uuid, { keep: true });
}
exports.playSound = playSound;
function createSvga(name, anchorName) {
var inst = new svga.Svga();
inst.source = 'asset://' + engine.getAssetByName(name).uuid;
return inst;
}
exports.createSvga = createSvga;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var GameWrapper_1 = require("./game/GameWrapper");
var props_1 = require("./props");
function default_1(props) {
props_1.prepareProps();
props_1.injectProps(props);
var instance = new GameWrapper_1.GameWrapper();
return instance;
}
exports.default = default_1;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.props = {};
function prepareProps() {
var metaProps = getProps();
engine.injectProp(exports.props, metaProps);
}
exports.prepareProps = prepareProps;
function injectProps(p) {
engine.injectProp(exports.props, p);
}
exports.injectProps = injectProps;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var utils_1 = require("./utils");
var LoopComponent_1 = require("./LoopComponent");
var props_1 = require("./../props");
var Background = (function (_super) {
__extends(Background, _super);
function Background() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this.partResHHL = ['hhl_after', 'hhl_front'];
_this.partResHB = ['hb_after', 'hb_front'];
_this.partResWH = ['wh_after', 'wh_front'];
_this.speeds = [];
_this.resArray = [];
_this.frameMovePos = 0;
return _this;
}
Background.prototype.initBg = function () {
this.sumMovePos = 0;
this.speeds.push(props_1.props.afterBGMoveSpeed);
this.speeds.push(props_1.props.frontBGMoveSpeed);
var bottomBg = new engine.Rect();
bottomBg.x = 0;
bottomBg.y = 0;
bottomBg.width = utils_1.getStage().width;
bottomBg.height = 0;
bottomBg.fillColor = 0x75c9f5;
this.addChild(bottomBg);
this.resArray.push(this.partResHHL);
this.resArray.push(this.partResHB);
this.resArray.push(this.partResWH);
this._bgIndex = 0;
var parts = [];
for (var i = 0; i < 2; i++) {
var part = new LoopComponent_1.LoopComponent();
part.setupLoop([
this.resArray[0][i],
this.resArray[0][i],
]);
parts.push(part);
this.addChild(part);
}
parts[1].y = 200;
};
Background.prototype.setViewport = function (pos) {
this.needFrameSum = (props_1.props.pierMoveTime / 1000) * 60;
this.frameMovePos = pos / this.needFrameSum;
this.frameIndex = 0;
this.addEventListener(engine.Event.ENTER_FRAME, this.frameBack, this);
};
Background.prototype.frameBack = function () {
if (this.frameIndex < this.needFrameSum) {
for (var i = 0; i < 2; i++) {
var part = this.getChildAt(i + 1);
var speed = this.speeds[i];
var tmpPos = ((this.frameMovePos * this.frameIndex) + this.sumMovePos) * speed;
part.setViewport(tmpPos);
}
this.frameIndex++;
}
else {
this.sumMovePos += this.frameMovePos * this.needFrameSum;
this.frameIndex = 0;
this.removeEventListener(engine.Event.ENTER_FRAME, this.frameBack, this);
}
};
Background.prototype.changeBg = function (index) {
for (var i = 0; i < 2; i++) {
var part = this.getChildAt(i + 1);
part.changeBg(this.resArray[index][i]);
if (i == 1 && index == 1) {
part.y = 400;
}
if (i == 1 && index == 2) {
part.y = 250;
}
}
this._bgIndex = index;
};
Background.prototype.getBgIndex = function () {
return this._bgIndex;
};
return Background;
}(engine.Container));
exports.Background = Background;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var Road_1 = require("./Road");
var props_1 = require("../props");
var utils_1 = require("./utils");
var GuideLayer_1 = require("./GuideLayer");
var Background_1 = require("./Background");
var ObjectPool = engine.ObjectPool;
var Pier_1 = require("./Pier");
var Player_1 = require("./Player");
var Strut_1 = require("./Strut");
var ScoreLabel_1 = require("./ScoreLabel");
exports.PoolName = 'pier';
ObjectPool.registerPool(exports.PoolName, function () {
return new Pier_1.Pier();
}, function (item, data) {
item.init();
});
var GameView = (function (_super) {
__extends(GameView, _super);
function GameView() {
var _this = _super.call(this) || this;
_this.moveX = 0;
_this.once(engine.Event.ADDED_TO_STAGE, _this.setup, _this);
return _this;
}
GameView.prototype.setup = function () {
if (this._hasSetup) {
return;
}
this._hasSetup = true;
this._backgroud = new Background_1.Background();
this.addChild(this._backgroud);
this._backgroud.initBg();
var road = this._road = new Road_1.Road();
this.addChild(road);
road.setup();
var pierWidth = this._road.getFristPier();
var player = this._player = new Player_1.Player();
this.addChild(player);
player.initPlayer(pierWidth);
var strut = this._strut = new Strut_1.Strut();
this.addChild(strut);
strut.init();
this._scoreContainer = new engine.Container();
this.addChild(this._scoreContainer);
this.initLabScore();
};
GameView.prototype.start = function (guide) {
return __awaiter(this, void 0, void 0, function () {
var initScore;
return __generator(this, function (_a) {
this._isTouchLayer = true;
this._sumScore = 0;
this._isMouseDown = false;
this._guide = guide;
initScore = this._road.getStartGold(0) ? props_1.props.goldScore : 0;
this.updateScore(initScore);
if (this._guide == '1') {
this.setGuide();
}
else {
this.initTouch();
this.registerEvent();
}
return [2];
});
});
};
GameView.prototype.setGuide = function () {
var _this = this;
this._road.setGuide();
var guideLayer = this.guideLayer = new GuideLayer_1.GuideLayer();
this.addChild(guideLayer);
this.guideLayer.show(1, { x: 20, y: 650, guideText: props_1.props.guideText1 }, function () {
var posX = _this._road.getMovePos();
_this.guideLayer.show(2, { x: posX + 20, y: 620, guideText: props_1.props.guideText2 }, function () {
_this.initTouch();
_this.registerEvent();
});
});
};
GameView.prototype.initLabScore = function () {
var scoreBg = new engine.Sprite(utils_1.getTextureByName('scoreBg'));
scoreBg.x = utils_1.getStage().width / 2 - scoreBg.width / 2;
scoreBg.y = 80;
var scoreHint = new engine.Sprite(utils_1.getTextureByName('scoreHint'));
scoreHint.x = utils_1.getStage().width / 2 - scoreHint.width / 2;
scoreHint.y = 40;
this._scoreContainer.addChild(scoreHint);
this.labScore = new ScoreLabel_1.ScoreLabel();
this.labScore.fillColor = 0xff7646;
this.labScore.size = 70;
this.labScore.width = utils_1.getStage().width;
this.labScore.height = scoreBg.height;
this.labScore.textAlign = engine.TEXT_ALIGN.CENTER;
this.labScore.x = 0;
this.labScore.y = scoreBg.y + 10;
this._scoreContainer.addChild(this.labScore);
};
GameView.prototype.registerEvent = function () {
this._touchLayer.addEventListener(engine.MouseEvent.MOUSE_DOWN, this.onMouseDown, this);
this._touchLayer.addEventListener(engine.MouseEvent.MOUSE_UP, this.onMouseUp, this);
};
GameView.prototype.removeListener = function () {
this._touchLayer.removeEventListener(engine.MouseEvent.MOUSE_DOWN, this.onMouseDown, this);
this._touchLayer.removeEventListener(engine.MouseEvent.MOUSE_UP, this.onMouseUp, this);
};
GameView.prototype.initTouch = function () {
this._touchLayer = new engine.Rect();
this.addChild(this._touchLayer);
this._touchLayer.width = utils_1.getStage().width;
this._touchLayer.height = utils_1.getStage().height;
this._touchLayer.x = 0;
this._touchLayer.y = 0;
this._touchLayer.alpha = 0;
};
GameView.prototype.setScoreShow = function () {
};
GameView.prototype.onMouseDown = function () {
if (this._isTouchLayer) {
this._isMouseDown = true;
this._strut.onMouseDown(this._road.getFristPier(), this._road.getDistance(), this.goCallBcak.bind(this));
}
};
GameView.prototype.onMouseUp = function () {
if (this._isTouchLayer && this._isMouseDown) {
this._strut.onMouseUp();
this._isMouseDown = false;
this._isTouchLayer = false;
}
};
GameView.prototype.goCallBcak = function (isSuccess) {
var _this = this;
if (isSuccess) {
console.log('成功了');
var movePos = this._road.getMovePos();
if (this._road.getStartGold(1, false)) {
this.updateScore(props_1.props.singleScore + props_1.props.goldScore);
}
else {
this.updateScore(props_1.props.singleScore);
}
this._player.setViewport(movePos, this.complete.bind(this));
}
else {
console.log('失败了');
this._player.setViewport(this._strut.getStrutHeight(), function () {
console.log('掉下去了');
engine.globalEvent.dispatchEvent('dxbcyj-game-result', { score: _this._sumScore });
}, this._road.getFristPier());
}
};
GameView.prototype.complete = function () {
var _this = this;
this._road.getStartGold(1);
var movePos = this._road.getMovePos();
this._road.setViewport();
this._backgroud.setViewport(movePos);
this._player.setBackViewport(function () {
_this._isTouchLayer = true;
});
this.closeStrut();
};
GameView.prototype.closeStrut = function () {
this._strut.rest();
};
GameView.prototype.updateScore = function (score) {
this._sumScore += score;
if (0 <= this._sumScore && this._sumScore <= props_1.props.bgFristScore) {
this.changeBg(0);
}
else if (props_1.props.bgFristScore < this._sumScore && this._sumScore <= props_1.props.bgSecondScore) {
this.changeBg(1);
}
else {
this.changeBg(2);
}
this.labScore.updateScore(this._sumScore);
};
GameView.prototype.getScore = function () {
return this._sumScore;
};
GameView.prototype.changeBg = function (index) {
if (this._backgroud.getBgIndex() != index) {
this._backgroud.changeBg(index);
}
};
return GameView;
}(engine.Container));
exports.default = GameView;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var GameView_1 = require("./GameView");
var GameWrapper = (function (_super) {
__extends(GameWrapper, _super);
function GameWrapper() {
var _this = _super.call(this) || this;
engine.globalEvent.addEventListener('dxbcyj-game-start', _this.start, _this);
var gameView = _this._gameView = new GameView_1.default();
_this.addChild(gameView);
return _this;
}
GameWrapper.prototype.start = function (event) {
this._gameView.start(event.data.guide);
};
return GameWrapper;
}(engine.Container));
exports.GameWrapper = GameWrapper;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var props_1 = require("../props");
var utils_1 = require("./utils");
var GuideLayer = (function (_super) {
__extends(GuideLayer, _super);
function GuideLayer() {
var _this = _super.call(this) || this;
_this._canClear = [];
_this.setup();
return _this;
}
GuideLayer.prototype.setup = function () {
};
GuideLayer.prototype.show = function (id, options, callback) {
this.visible = true;
this._callBack = callback ? callback : null;
if (!this.guideMask) {
this._options = options;
var _a = this.stage, width = _a.width, height = _a.height;
var guideMask = this.guideMask = new engine.Container();
var guideHole = this._guideHole = new engine.Image(utils_1.getTextureByName('guide'));
guideHole.x = options.x;
guideHole.y = options.y;
guideHole.width = 250;
guideHole.height = 250;
guideHole.name = 'guideHole';
guideMask.addChild(guideHole);
this.createRect(guideMask, 0, 0, width, guideHole.y);
this.createRect(guideMask, 0, guideHole.y, guideHole.x, guideHole.height);
this.createRect(guideMask, guideHole.x + guideHole.width, guideHole.y, width - guideHole.x - guideHole.width, guideHole.height);
this.createRect(guideMask, 0, guideHole.y + guideHole.height, width, height - guideHole.y - guideHole.height);
this.guideStep(id);
var label = this.label = new engine.Label();
label.fillColor = 'white';
label.size = 30;
label.text = options.guideText;
label.x = (width - label.width) / 2;
label.y = guideHole.y + guideHole.height + 50;
label.textAlign = engine.TEXT_ALIGN.CENTER;
label.name = 'labHint';
guideMask.addChild(label);
this.addChild(guideMask);
}
this.once(engine.MouseEvent.CLICK, function () {
this.removeChild(this.guideMask);
this.guideMask = null;
if (this._callBack) {
this._callBack();
}
}, this);
};
GuideLayer.prototype.createRect = function (container, x, y, width, height) {
var rect = new engine.Rect();
rect.x = x;
rect.y = y;
rect.width = width;
rect.height = height;
rect.fillColor = 'black';
rect.alpha = 0.7;
container.addChild(rect);
};
GuideLayer.prototype.guideStep = function (id) {
if (id == 1) {
var guideHand = new engine.Image(utils_1.getTextureByName('guideHand'));
guideHand.x = this._options.x + 300;
guideHand.y = this._options.y + 100;
this.guideMask.addChild(guideHand);
var rect = new engine.Rect();
rect.x = this._options.x + 200;
rect.y = this._options.y - 15;
rect.width = props_1.props.strutWidth;
rect.height = 200;
rect.fillColor = props_1.props.strutColor;
this.guideMask.addChild(rect);
this._canClear.push(guideHand);
this._canClear.push(rect);
}
if (id == 2) {
var know = new engine.Image(utils_1.getTextureByName('know'));
know.x = (this.stage.width - know.width) / 2;
know.y = this._options.y + 400;
this.guideMask.addChild(know);
this._canClear.push(know);
}
};
return GuideLayer;
}(engine.Container));
exports.GuideLayer = GuideLayer;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var utils_1 = require("./utils");
var LoopComponent = (function (_super) {
__extends(LoopComponent, _super);
function LoopComponent() {
var _this = _super.call(this) || this;
_this.onceInfo = { width: 0, height: 0, count: 0 };
_this.loopInfo = { width: 0, height: 0, count: 0 };
_this.parts = [];
return _this;
}
LoopComponent.prototype.setup = function (parts, info) {
var _this = this;
parts.forEach(function (item, index) {
var part;
if (typeof item == 'string') {
part = new engine.Sprite(utils_1.getTextureByName(item));
}
else if (item instanceof engine.Texture) {
part = new engine.Sprite(item);
}
else {
part = item;
}
_this.addChild(part);
_this.parts.push(part);
if (index == 0) {
info.width = part.width;
info.height = part.height;
}
});
info.count = parts.length;
this.setViewport(0, 0);
};
LoopComponent.prototype.changeBg = function (changName) {
this.parts.forEach(function (item, index) {
item.texture = utils_1.getTextureByName(changName);
});
};
LoopComponent.prototype.setupLoop = function (resArr) {
this.setup(resArr, this.loopInfo);
};
LoopComponent.prototype.setViewport = function (x, y) {
if (y === void 0) { y = 0; }
var sizeField = y == 0 ? 'width' : 'height';
var posField = y == 0 ? 'x' : 'y';
var pos = y == 0 ? x : y;
var index;
var onceSize = this.onceInfo[sizeField];
var onceCount = this.onceInfo.count;
var loopCount = this.loopInfo.count;
var loopSize = this.loopInfo[sizeField];
index = onceSize == 0 ? -1 : Math.floor(pos / onceSize);
if (index < 0 || index >= onceCount) {
var loopIndex = Math.floor((pos - onceCount * onceSize) / this.loopInfo[sizeField]);
index = onceCount + loopIndex;
}
var formerIndex = index < onceCount ? index : (index) % loopCount + onceCount;
var latterIndex = index < onceCount ? index + 1 : (index - onceCount + 1) % loopCount + onceCount;
var former = this.parts[formerIndex];
var latter = this.parts[latterIndex];
if (!former || !latter) {
console.log(formerIndex, latterIndex);
}
former[posField] = -(pos - loopSize * (index < onceCount ? index : index - onceCount) - (index < onceCount ? 0 : onceCount * onceSize));
latter[posField] = former.x + (index < onceCount ? onceSize : loopSize);
};
return LoopComponent;
}(engine.Container));
exports.LoopComponent = LoopComponent;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var props_1 = require("./../props");
var utils_1 = require("./utils");
var Pier = (function (_super) {
__extends(Pier, _super);
function Pier() {
var _this = _super.call(this) || this;
_this.bmp = new engine.Sprite();
_this.addChild(_this.bmp);
return _this;
}
Pier.prototype.init = function () {
var bmp = this.bmp;
bmp.alpha = 1;
bmp.texture = utils_1.getTextureByName('pier');
bmp.x = 0;
bmp.y = bmp.height;
if (this.children.length < 2) {
var gold = new engine.Sprite();
gold.texture = utils_1.getTextureByName('gold');
gold.name = 'gold';
this.addChild(gold);
}
this.setGoldPosX(bmp);
this.setShowGold();
};
Pier.prototype.setShowGold = function () {
var nodeGold = this.getChildByName('gold');
var randomWard = Math.random();
nodeGold.alpha = 1;
var isShow = randomWard < props_1.props.reward ? true : false;
nodeGold.visible = isShow;
this.haveGold = isShow;
};
Pier.prototype.setGoldPosX = function (bmp) {
var nodeGold = this.getChildByName('gold');
var pos = bmp.width / 2 - nodeGold.width / 2;
nodeGold.x = pos;
nodeGold.y = bmp.height - nodeGold.height - 50;
nodeGold.visible = false;
};
Pier.prototype.closeGold = function () {
var _this = this;
this.children.forEach(function (item) {
if (item.name == 'gold') {
item.anchorX = item.width / 2;
item.anchorY = item.height / 2;
engine.Tween.get(item, { loop: false })
.to({ scaleX: 2.5, scaleY: 2.5 }, 200, engine.Ease.cubicOut)
.to({ scaleX: 1, scaleY: 1, alpha: 0 }, 200, engine.Ease.cubicIn)
.call(function () {
item.visible = false;
_this.haveGold = false;
});
}
});
};
return Pier;
}(engine.Container));
exports.Pier = Pier;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var props_1 = require("../props");
var utils_1 = require("./utils");
var Player = (function (_super) {
__extends(Player, _super);
function Player() {
return _super !== null && _super.apply(this, arguments) || this;
}
Player.prototype.initPlayer = function (pierWidth) {
this._container = new engine.Container();
this.addChild(this._container);
this.playerNode = utils_1.createSvga('walk');
this._container.addChild(this.playerNode);
this.playerNode.y = 675;
this.playerNode.x = pierWidth / 2 - 80;
this.playerNode.play();
};
Player.prototype.setViewport = function (pos, callBack, pierWidth) {
var tmpPos = 0;
var isSuccess = false;
if (!pierWidth) {
tmpPos = pos;
isSuccess = true;
}
else {
tmpPos = pierWidth - this.playerNode.x + pos - 60;
}
this.playGoTween(tmpPos, callBack, isSuccess);
};
Player.prototype.playGoTween = function (pos, callBack, isSuccess) {
var _this = this;
engine.Tween.get(this._container, { loop: false })
.to({ x: pos }, props_1.props.playerMoveSpeed)
.call(function () {
engine.Tween.removeTweens(_this._container);
if (isSuccess) {
if (callBack) {
callBack();
}
}
else {
_this.playDropTween(callBack);
}
});
};
Player.prototype.playDropTween = function (callBack) {
var _this = this;
engine.Tween.get(this._container, { loop: false })
.to({ y: 2000 }, 1000)
.call(function () {
engine.Tween.removeTweens(_this._container);
if (callBack) {
callBack();
}
});
};
Player.prototype.setBackViewport = function (callBack) {
var _this = this;
engine.Tween.get(this._container, { loop: false })
.to({ x: 0 }, props_1.props.pierMoveTime)
.call(function () {
engine.Tween.removeTweens(_this._container);
if (callBack) {
callBack();
}
});
};
return Player;
}(engine.Container));
exports.Player = Player;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var props_1 = require("./../props");
var ObjectPool = engine.ObjectPool;
var Road = (function (_super) {
__extends(Road, _super);
function Road() {
return _super !== null && _super.apply(this, arguments) || this;
}
Road.prototype.setup = function () {
this.lastPos = 0;
this.addPier();
};
Road.prototype.getFristPier = function () {
return this.getChildAt(0).width;
};
Road.prototype.getDistance = function () {
var distance = [];
var pier1 = this.getChildAt(0);
var pier2 = this.getChildAt(1);
distance.push(pier2.x - pier1.x);
distance.push(pier2.width);
return distance;
};
Road.prototype.addPier = function () {
while (this.children.length < props_1.props.pierCount + 1) {
var childrenNum = this.children.length;
var randomPos = this.makeRandomFloat(props_1.props.pierMaxDistance, props_1.props.pierMinDistance);
var pier = ObjectPool.getObject('pier');
this.addChild(pier);
if (childrenNum == 0) {
pier.x = 0;
}
else {
pier.x = this.lastPos + randomPos;
}
this.lastPos = pier.x;
}
};
Road.prototype.moveAddPier = function () {
var randomPos = this.makeRandomFloat(props_1.props.pierMaxDistance, props_1.props.pierMinDistance);
var pier = ObjectPool.getObject('pier');
var lastChild = this.getChildAt(this.children.length - 1);
pier.x = lastChild.x + randomPos;
this.addChild(pier);
};
Road.prototype.makeRandomFloat = function (max, min) {
if (min === void 0) { min = 0; }
return Math.random() * (max - min) + min;
};
Road.prototype.setViewport = function () {
var _this = this;
var tmpMovepos = this.getMovePos();
this.children.forEach(function (item, index) {
_this.playTween(item, index, tmpMovepos);
});
};
Road.prototype.getMovePos = function () {
var movePos = this.getChildAt(1);
return movePos.x;
};
Road.prototype.playTween = function (item, index, tmpMovepos) {
var _this = this;
engine.Tween.get(item, { loop: false })
.to({ x: item.x - tmpMovepos }, props_1.props.pierMoveTime)
.call(function () {
if (_this.getChildIndex(item) == 0) {
engine.Tween.removeTweens(item);
_this.removeChild(item);
ObjectPool.recycleObject('pier', item);
}
if (index == 0) {
_this.moveAddPier();
}
});
};
Road.prototype.getStartGold = function (index, isClose) {
if (isClose === void 0) { isClose = true; }
var tmpNode = this.getChildAt(index);
var haveGold = tmpNode.haveGold;
if (haveGold && isClose) {
tmpNode.closeGold();
}
return haveGold;
};
Road.prototype.setGuide = function () {
var tmpNode = this.getChildAt(1);
if (!tmpNode.haveGold) {
tmpNode.children.forEach(function (item) {
if (item.name == 'gold') {
item.visible = true;
}
});
tmpNode.haveGold = true;
}
};
return Road;
}(engine.Container));
exports.Road = Road;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var ScoreLabel = (function (_super) {
__extends(ScoreLabel, _super);
function ScoreLabel() {
return _super !== null && _super.apply(this, arguments) || this;
}
ScoreLabel.prototype.updateScore = function (score, animation) {
if (animation === void 0) { animation = true; }
this._value = score;
if (animation && this._tmp) {
this.animationUpdate();
}
else {
this.updateLocal(score);
}
};
ScoreLabel.prototype.animationUpdate = function () {
var _this = this;
var tmpInterval = setInterval(function () {
_this._tmp += 1;
if (_this._tmp <= _this._value) {
_this.text = _this._tmp;
}
else {
_this._tmp = _this._value;
clearInterval(tmpInterval);
}
}, 50);
};
ScoreLabel.prototype.updateLocal = function (v) {
this._tmp = v;
this.text = v;
};
return ScoreLabel;
}(engine.Label));
exports.ScoreLabel = ScoreLabel;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var props_1 = require("../props");
var Strut = (function (_super) {
__extends(Strut, _super);
function Strut() {
return _super !== null && _super.apply(this, arguments) || this;
}
Strut.prototype.init = function () {
this._strut = new engine.Rect();
this.addChild(this._strut);
this._strut.width = props_1.props.strutWidth;
this._strut.y = 833;
this._strut.fillColor = props_1.props.strutColor;
this._strut.rotation = 180;
};
Strut.prototype.onMouseDown = function (pierWidth, distance, callBack) {
this._strut.x = pierWidth - 60;
this._distance = distance;
this._callBack = callBack;
this._strut.visible = true;
this.addEventListener(engine.Event.ENTER_FRAME, this.frameStrut, this);
};
Strut.prototype.onMouseUp = function () {
var _this = this;
this.removeEventListener(engine.Event.ENTER_FRAME, this.frameStrut, this);
setTimeout(function () {
_this.strutRotation();
}, 200);
};
Strut.prototype.strutRotation = function () {
var _this = this;
engine.Tween.get(this._strut, { loop: false })
.to({ rotation: 270 }, props_1.props.strutRotationSpeed)
.call(function () {
_this.judgeResult();
engine.Tween.removeTweens(_this._strut);
});
};
Strut.prototype.judgeResult = function () {
var isSuccess = false;
if (this._distance[0] - this._distance[1] + 100 <= this._strut.height && this._strut.height <= this._distance[0] + 20) {
isSuccess = true;
}
if (this._callBack) {
this._callBack(isSuccess);
}
};
Strut.prototype.frameStrut = function () {
if (this._strut.height < 1000) {
this._strut.height += props_1.props.strutUpSpeed;
}
};
Strut.prototype.rest = function () {
this._strut.width = props_1.props.strutWidth;
this._strut.y = 833;
this._strut.fillColor = props_1.props.strutColor;
this._strut.rotation = 180;
this._strut.height = 0;
this._strut.visible = false;
};
Strut.prototype.getStrutHeight = function () {
var distance = this._strut.height > 1000 ? 1000 : this._strut.height;
return distance;
};
return Strut;
}(engine.Container));
exports.Strut = Strut;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var Pier_1 = require("./Pier");
var ObjectPool = engine.ObjectPool;
exports.PoolName = 'pier';
ObjectPool.registerPool(exports.PoolName, function () {
return new Pier_1.Pier();
}, function (item, data) {
item.init();
});
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
function getTexture(uuid) {
return engine.Texture.from(getAssetByUUID(uuid).uuid);
}
exports.getTexture = getTexture;
function getTextureByName(name) {
return getTexture(engine.getAssetByName(name).uuid);
}
exports.getTextureByName = getTextureByName;
function playSound(name) {
engine.playSound(engine.getAssetByName(name).uuid, { keep: true });
}
exports.playSound = playSound;
function getStage() {
return engine.gameStage.stage;
}
exports.getStage = getStage;
function createSvga(name) {
var inst = new svga.Svga();
inst.source = engine.getAssetByName(name).uuid;
return inst;
}
exports.createSvga = createSvga;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var GameWrapper_1 = require("./game/GameWrapper");
var props_1 = require("./props");
function default_1(props) {
props_1.prepareProps();
props_1.injectProps(props);
var instance = new GameWrapper_1.GameWrapper();
return instance;
}
exports.default = default_1;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.props = {};
function prepareProps() {
var metaProps = getProps();
engine.injectProp(exports.props, metaProps);
}
exports.prepareProps = prepareProps;
function injectProps(p) {
engine.injectProp(exports.props, p);
}
exports.injectProps = injectProps;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var props_1 = require("../props");
var utils_1 = require("./utils");
var GameView = (function (_super) {
__extends(GameView, _super);
function GameView() {
var _this = _super.call(this) || this;
_this.once(engine.Event.ADDED_TO_STAGE, _this.setup, _this);
return _this;
}
GameView.prototype.setup = function () {
if (this._hasSetup) {
return;
}
this._hasSetup = true;
this.NpcBg = new engine.Container();
this.NpcBg.x = props_1.props.initX;
this.NpcBg.y = props_1.props.initY;
this.addChild(this.NpcBg);
this.bottomCircle = new engine.Sprite(utils_1.getTextureByName('底座'));
this.bottomCircle.x = 17;
this.bottomCircle.y = 305;
this.loveDot = new engine.Sprite(utils_1.getTextureByName('点缀'));
this.loveDot.x = 0;
this.loveDot.y = 6;
this.giftboxSvga = utils_1.createSvga('初始礼盒');
this.giftboxSvga.x = 105;
this.giftboxSvga.y = 37;
this.giftAfterSvga = utils_1.createSvga("拆礼盒");
this.giftAfterSvga.x = 105;
this.giftAfterSvga.y = 0;
this.giftAfterSvga.visible = false;
this.NpcBg.addChild(this.bottomCircle);
this.NpcBg.addChild(this.giftboxSvga);
this.NpcBg.addChild(this.giftAfterSvga);
this.NpcBg.addChild(this.loveDot);
this.giftboxSvga.play(false, true);
};
GameView.prototype.reset = function () {
this.giftboxSvga.visible = true;
this.giftAfterSvga.visible = false;
};
GameView.prototype.start = function () {
this.giftAfterSvga.visible = true;
this.giftboxSvga.visible = false;
this.giftAfterSvga.play(false, false);
this.giftAfterSvga.once(engine.Event.END_FRAME, function () {
engine.globalEvent.dispatchEvent('open-gift-game-end');
}, this);
};
GameView.prototype.resume = function () {
this.reset();
this.start();
};
return GameView;
}(engine.Container));
exports.default = GameView;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var GameView_1 = require("./GameView");
var props_1 = require("../props");
var GameWrapper = (function (_super) {
__extends(GameWrapper, _super);
function GameWrapper() {
var _this = _super.call(this) || this;
engine.globalEvent.addEventListener('open-gift-game-init', _this.reset, _this);
engine.globalEvent.addEventListener('open-gift-game-start', _this.start, _this);
var gameView = _this._gameView = new GameView_1.default();
_this.addChild(gameView);
return _this;
}
GameWrapper.prototype.reset = function (event) {
props_1.injectProps(event.data);
this._gameView.visible = true;
this._gameView.reset();
};
GameWrapper.prototype.start = function (event) {
console.log('监听开始');
props_1.injectProps(event.data);
this._gameView.start();
};
GameWrapper.prototype.clear = function () {
this._gameView.visible = false;
};
return GameWrapper;
}(engine.Container));
exports.GameWrapper = GameWrapper;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
function getTexture(uuid) {
return engine.Texture.from(getAssetByUUID(uuid).uuid);
}
exports.getTexture = getTexture;
function getTextureByName(name) {
return getTexture(engine.getAssetByName(name).uuid);
}
exports.getTextureByName = getTextureByName;
function playSound(name) {
engine.playSound(engine.getAssetByName(name).uuid, { keep: true });
}
exports.playSound = playSound;
function createSvga(name, anchorName) {
var inst = new svga.Svga();
inst.source = 'asset://' + engine.getAssetByName(name).uuid;
return inst;
}
exports.createSvga = createSvga;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var GameWrapper_1 = require("./game/GameWrapper");
var props_1 = require("./props");
function default_1(props) {
props_1.prepareProps();
props_1.injectProps(props);
var instance = new GameWrapper_1.GameWrapper();
return instance;
}
exports.default = default_1;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.props = {};
function prepareProps() {
var metaProps = getProps();
engine.injectProp(exports.props, metaProps);
}
exports.prepareProps = prepareProps;
function injectProps(p) {
engine.injectProp(exports.props, p);
}
exports.injectProps = injectProps;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var utils_1 = require("./utils");
var LoopComponent_1 = require("./LoopComponent");
var utils_2 = require("./utils");
var Background = (function (_super) {
__extends(Background, _super);
function Background() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this.partRes = ['bg_far', 'bg_mid', 'bg_near'];
_this.speeds = [0.05, 0.5, 1];
return _this;
}
Background.prototype.setup = function () {
var bottomBg = new engine.Rect();
bottomBg.x = 0;
bottomBg.y = 0;
bottomBg.width = utils_2.getStage().width;
bottomBg.height = 0;
bottomBg.fillColor = 0x75c9f5;
this.addChild(bottomBg);
var parts = [];
for (var i = 0; i < 3; i++) {
var part = new LoopComponent_1.LoopComponent();
part.setupLoop([
this.partRes[i],
this.partRes[i],
]);
parts.push(part);
this.addChild(part);
}
var height = utils_2.getStage().height;
parts[0].y = (height - parts[0].height) / 2 - 400;
parts[1].y = (height - parts[1].height) / 2 - 120;
parts[2].y = (height - parts[2].height) / 2 + 300;
bottomBg.y = parts[2].y;
bottomBg.height = height - parts[2].y;
var moon = new engine.Sprite(utils_1.getTextureByName('moon'));
moon.x = 100;
moon.y = 100;
this.addChild(moon);
};
Background.prototype.setViewport = function (pos) {
for (var i = 0; i < 3; i++) {
var part = this.getChildAt(i + 1);
var speed = this.speeds[i];
part.setViewport(pos * speed);
}
};
Background.prototype.reset = function (revive) {
if (revive === void 0) { revive = false; }
};
return Background;
}(engine.Container));
exports.Background = Background;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var utils_1 = require("./utils");
var Block = (function (_super) {
__extends(Block, _super);
function Block() {
var _this = _super.call(this) || this;
_this.bmp = new engine.Sprite();
_this.addChild(_this.bmp = new engine.Sprite());
return _this;
}
Block.prototype.reset = function (_a) {
var type = _a.type;
this.type = type;
var bmp = this.bmp;
bmp.alpha = 1;
bmp.texture = this.getBlock();
var _b = Block.configs[type], width = _b.width, off = _b.off;
bmp.x = -(off + width / 2);
bmp.y = -(bmp.height / 2);
};
Block.prototype.getBlock = function () {
return utils_1.getTextureByName('block_' + this.type);
};
Block.prototype.playEffect = function () {
};
Block.prototype.playFadeOut = function () {
return this.getTweenPromise(engine.Tween.get(this.bmp)
.to({ alpha: 0 }, 100)
.to({ alpha: 1 }, 100)
.to({ alpha: 0 }, 100));
};
Block.prototype.onEffectComplete = function (event) {
this.effectResolve && this.effectResolve();
this.effectResolve = null;
};
Block.prototype.getTweenPromise = function (tween) {
return new Promise(function (resolve) {
tween.call(resolve);
});
};
Block.configs = [
{ ratio: 0.6, width: 15, off: 32, effect: '', effect_offset: { x: 0, y: 0 } },
{ ratio: 0.1, width: 10, off: 18, effect: '', effect_offset: { x: 0, y: 0 } },
{ ratio: 0.15, width: 30, off: 32, effect: '', effect_offset: { x: 0, y: 0 } },
{ ratio: 0.1, width: 86, off: 28, effect: '', effect_offset: { x: 0, y: 0 } },
{ ratio: 0.5, width: 70, off: 20, effect: '', effect_offset: { x: 0, y: -20 } },
{ ratio: 0, width: 0, off: 0, effect: '', effect_offset: { x: 0, y: 0 } },
{ ratio: 0, width: 0, off: 0, effect: '', effect_offset: { x: 0, y: 0 } },
{ ratio: 0, width: 0, off: 0, effect: '', effect_offset: { x: 0, y: 0 } },
{ ratio: 0, width: 0, off: 0, effect: '', effect_offset: { x: 0, y: 0 } },
{ ratio: 0, width: 0, off: 0, effect: '', effect_offset: { x: 0, y: 0 } },
{ ratio: 0, width: 123, off: 23, effect: '', effect_offset: { x: 0, y: 0 } },
];
return Block;
}(engine.Container));
exports.Block = Block;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var PlayGame_1 = require("./PlayGame");
var Background_1 = require("./Background");
var Road_1 = require("./Road");
var Player_1 = require("./player/Player");
var utils_1 = require("./utils");
var Block_1 = require("./Block");
var ObjectPool = engine.ObjectPool;
exports.PoolName = 'block';
ObjectPool.registerPool(exports.PoolName, function () {
return new Block_1.Block();
}, function (item, data) {
item.reset(data);
});
var GameView = (function (_super) {
__extends(GameView, _super);
function GameView() {
var _this = _super.call(this) || this;
_this.offset = { x: -100, y: 320 };
_this.worldFPS = 60;
_this._viewport = {
x: 0,
y: 0,
};
return _this;
}
Object.defineProperty(GameView, "instance", {
get: function () {
if (this._instance == undefined) {
this._instance = new GameView();
}
return this._instance;
},
enumerable: true,
configurable: true
});
GameView.prototype.eventStart = function () {
var _this = this;
if (this.hasPreSetup) {
return;
}
this.hasPreSetup = true;
var background = this.background = new Background_1.Background();
background.setup();
this.addChild(background);
var road = this.road = new Road_1.Road();
road.y = utils_1.getStage().height / 2 + 310;
this.addChild(road);
this.road.preSetup();
this.setupWorld();
this.player.fade(0, false);
this.viewport = 0;
this.startWorld();
this.reset();
this.setup();
var playHint = new engine.Label();
playHint.fillColor = 'block';
playHint.size = 30;
playHint.text = '注意不要踩到线和陷阱哦,后果很严重哦~';
playHint.x = (utils_1.getStage().width - playHint.width) / 2;
playHint.y = utils_1.getStage().height / 2 + 500;
this.addChild(playHint);
this.playGame = new PlayGame_1.PlayGame();
setTimeout(function () {
_this.playGame.GameView = _this;
_this.addChild(_this.playGame);
_this.start();
}, 500);
};
GameView.prototype.setup = function () {
if (this.hasSetup) {
return;
}
this.hasSetup = true;
this.road.setup();
};
GameView.prototype.setupWorld = function () {
var OTHER = Math.pow(2, 1), BODYPARTS = Math.pow(2, 2), GROUND = Math.pow(2, 3);
var world = this.world = new p2.World({});
world.sleepMode = p2.World.BODY_SLEEPING;
var planeShape = new p2.Plane();
var ground = new p2.Body({
position: [0, 0],
});
ground.addShape(planeShape);
planeShape.collisionGroup = GROUND;
planeShape.collisionMask = BODYPARTS | OTHER;
world.addBody(ground);
var player = this.player = new Player_1.Player();
player.setup({
collisionGroup: BODYPARTS,
collisionMask: GROUND | OTHER,
world: world,
ground: ground,
});
player.addEventListener('move', this.onMove, this);
player.addEventListener('foot_down', this.onFootDown, this);
};
GameView.prototype.onTicker = function (dt) {
var world = this.world;
this.world.step(this.worldFPS / 1000);
var l = world.bodies.length;
for (var i = 0; i < l; i++) {
var body = world.bodies[i];
var display = body.displays ? body.displays[0] : null;
if (display) {
if (!this.contains(display)) {
this.addChild(display);
}
display.localUpdate(body.position[0] * utils_1.getfactor() + utils_1.getStage().width / 2 + this.offset.x - this.viewport, utils_1.getStage().height / 2 - body.position[1] * utils_1.getfactor() + this.offset.y, 360 - (body.angle + body.shapes[0].angle) * 180 / Math.PI, body.sleepState == p2.Body.SLEEPING);
}
}
return false;
};
GameView.prototype.reset = function (revive) {
if (revive === void 0) { revive = false; }
this.background.reset(revive);
this.road.reset(revive);
this.player.reset(revive);
this.player.fade(0);
this.viewport = revive ? this.revivePos : 0;
};
GameView.prototype.start = function (revive) {
if (revive === void 0) { revive = false; }
this.road.start(revive);
this.player.fade(1);
this.playGame.start(revive);
};
GameView.prototype.startWorld = function () {
if (this.playing) {
return;
}
this.playing = true;
engine.gameStage.addEventListener(engine.Event.ENTER_FRAME, this.onTicker, this);
};
GameView.prototype.stopWorld = function () {
if (!this.playing) {
return;
}
this.playing = false;
engine.gameStage.removeEventListener(engine.Event.ENTER_FRAME, this.onTicker, this);
};
Object.defineProperty(GameView.prototype, "viewport", {
get: function () {
return this._viewport.x;
},
set: function (v) {
this._viewport.x = v;
this.updateViewport();
},
enumerable: true,
configurable: true
});
GameView.prototype.updateViewport = function () {
var _a = this._viewport, x = _a.x, y = _a.y;
var pos = Math.max(0, x);
this.background.setViewport(pos);
this.road.setViewport(pos);
};
GameView.prototype.onMove = function (event) {
var _a = event.data, pos = _a.pos, bodyPos = _a.bodyPos;
this.viewport = pos;
if (this.road.hitReward(bodyPos)) {
this.dispatchEvent('scoreChange', {
rewardScore: 100,
passType: 10,
}, true);
}
};
GameView.prototype.down = function () {
if (this.lock) {
return;
}
this.player.down();
};
GameView.prototype.up = function () {
if (this.lock) {
return;
}
this.player.up();
};
GameView.prototype.onFootDown = function (event) {
var _a = event.data, mileage = _a.mileage, pos = _a.pos;
this.revivePos = pos;
var _b = this.road.hitBlock(pos), target = _b.target, lastTarget = _b.lastTarget;
this.road.playDust(pos);
if (target) {
this.lock = true;
this.stopWorld();
this.dispatchEvent(engine.Event.COMPLETE, null, true);
target.playFadeOut();
target.playEffect();
if (target.type == 4) {
this.player.setSkin('gray');
}
this.road.removeBlock(target);
this.player.switchFace(target.type);
if (target.type == 0) {
this.player.fall();
}
this.lock = false;
this.startWorld();
}
else {
this.player.switchFace('normal');
var score = Math.floor(mileage / 50 * 5);
this.dispatchEvent('scoreChange', {
score: score,
passType: lastTarget ? lastTarget.type : -1,
}, true);
}
};
GameView.prototype.setWitchFace = function (type) {
this.player.switchFace(type);
};
return GameView;
}(engine.Container));
exports.default = GameView;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var GameView_1 = require("./GameView");
var props_1 = require("../props");
var GameWrapper = (function (_super) {
__extends(GameWrapper, _super);
function GameWrapper() {
var _this = _super.call(this) || this;
engine.globalEvent.addEventListener('walking-cat-start', _this.start, _this);
engine.globalEvent.addEventListener('walking-cat-revive', _this.revive, _this);
engine.globalEvent.addEventListener('walking-cat-showScore', _this.revive, _this);
var gameView = _this._gameView = new GameView_1.default();
_this.addChild(gameView);
return _this;
}
GameWrapper.prototype.start = function (event) {
props_1.injectProps(event.data);
this._gameView.eventStart();
};
GameWrapper.prototype.revive = function () {
console.log('复活');
this._gameView.reset(true);
this._gameView.start(true);
};
return GameWrapper;
}(engine.Container));
exports.GameWrapper = GameWrapper;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var utils_1 = require("./utils");
var LoopComponent = (function (_super) {
__extends(LoopComponent, _super);
function LoopComponent() {
var _this = _super.call(this) || this;
_this.onceInfo = { width: 0, height: 0, count: 0 };
_this.loopInfo = { width: 0, height: 0, count: 0 };
_this.parts = [];
return _this;
}
LoopComponent.prototype.setup = function (parts, info) {
var _this = this;
parts.forEach(function (item, index) {
var part;
if (typeof item == 'string') {
part = new engine.Sprite(utils_1.getTextureByName(item));
}
else if (item instanceof engine.Texture) {
part = new engine.Sprite(item);
}
else {
part = item;
}
_this.addChild(part);
_this.parts.push(part);
if (index == 0) {
info.width = part.width;
info.height = part.height;
}
});
info.count = parts.length;
this.setViewport(0, 0);
};
LoopComponent.prototype.setupOnce = function (resArr) {
this.setup(resArr, this.onceInfo);
};
LoopComponent.prototype.setupLoop = function (resArr) {
this.setup(resArr, this.loopInfo);
};
LoopComponent.prototype.setViewport = function (x, y) {
if (y === void 0) { y = 0; }
var sizeField = y == 0 ? 'width' : 'height';
var posField = y == 0 ? 'x' : 'y';
var pos = y == 0 ? x : y;
var index;
var onceSize = this.onceInfo[sizeField];
var onceCount = this.onceInfo.count;
var loopCount = this.loopInfo.count;
var loopSize = this.loopInfo[sizeField];
index = onceSize == 0 ? -1 : Math.floor(pos / onceSize);
if (index < 0 || index >= onceCount) {
var loopIndex = Math.floor((pos - onceCount * onceSize) / this.loopInfo[sizeField]);
index = onceCount + loopIndex;
}
var formerIndex = index < onceCount ? index : (index) % loopCount + onceCount;
var latterIndex = index < onceCount ? index + 1 : (index - onceCount + 1) % loopCount + onceCount;
var former = this.parts[formerIndex];
var latter = this.parts[latterIndex];
if (!former || !latter) {
console.log(formerIndex, latterIndex);
}
former[posField] = -(pos - loopSize * (index < onceCount ? index : index - onceCount) - (index < onceCount ? 0 : onceCount * onceSize));
latter[posField] = former.x + (index < onceCount ? onceSize : loopSize);
};
return LoopComponent;
}(engine.Container));
exports.LoopComponent = LoopComponent;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var utils_1 = require("./utils");
var props_1 = require("../props");
var ScoreLabel_1 = require("./ScoreLabel");
var PlayGame = (function (_super) {
__extends(PlayGame, _super);
function PlayGame() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this.addlabelScore = null;
_this.formatScore = function (s) {
var t = (Math.ceil(s * 10) / 10).toString();
t += t.indexOf('.') < 0 ? '.0' : '';
return t;
};
return _this;
}
Object.defineProperty(PlayGame, "instance", {
get: function () {
if (this._instance == undefined) {
this._instance = new PlayGame();
}
return this._instance;
},
enumerable: true,
configurable: true
});
PlayGame.prototype.start = function (revive) {
if (revive === void 0) { revive = false; }
if (!revive) {
this.normalScore = 0;
this.rewardScore = 0;
this.lastDialogTs = 0;
this.initTouch();
this.initLabScore();
this.initAddlabel();
this.initDialog();
}
this.registerEvent();
};
PlayGame.prototype.registerEvent = function () {
this.touchLayer.addEventListener(engine.MouseEvent.MOUSE_DOWN, this.onMouseDown, this);
this.touchLayer.addEventListener(engine.MouseEvent.MOUSE_UP, this.onMouseUp, this);
this.GameView.addEventListener(engine.Event.COMPLETE, this.onGameComplete, this);
this.GameView.addEventListener('scoreChange', this.onScoreChange, this);
};
PlayGame.prototype.initTouch = function () {
this.touchLayer = new engine.Rect();
this.addChild(this.touchLayer);
this.touchLayer.width = utils_1.getStage().width;
this.touchLayer.height = utils_1.getStage().height;
this.touchLayer.x = 0;
this.touchLayer.y = 0;
this.touchLayer.alpha = 0;
};
PlayGame.prototype.removeListener = function () {
this.touchLayer.removeEventListener(engine.MouseEvent.MOUSE_DOWN, this.onMouseDown, this);
this.touchLayer.removeEventListener(engine.MouseEvent.MOUSE_UP, this.onMouseUp, this);
this.GameView.removeEventListener(engine.Event.COMPLETE, this.onGameComplete, this);
this.GameView.removeEventListener('scoreChange', this.onScoreChange, this);
};
PlayGame.prototype.initLabScore = function () {
this.labScore = new ScoreLabel_1.ScoreLabel();
this.labScore.visible = props_1.props.showScore;
this.labScore.updateScore(0, this.formatScore, false);
this.labScore.fillColor = 'yellow';
this.labScore.size = 46;
this.labScore.x = 610;
engine.Tween.get(this.labScore, { loop: false })
.set({ y: -100 })
.wait(300)
.to({ y: 40 }, 200, engine.Ease.backOut);
this.addChild(this.labScore);
};
PlayGame.prototype.initAddlabel = function () {
this.addlabelScore = new engine.Label();
this.addlabelScore.fillColor = 'yellow';
this.addlabelScore.size = 40;
this.addlabelScore.text = '';
this.addlabelScore.x = 378;
this.addlabelScore.y = 582;
this.addlabelScore.visible = false;
this.addChild(this.addlabelScore);
};
PlayGame.prototype.initDialog = function () {
this.dialog = new engine.Image();
this.dialog.x = 390;
this.dialog.y = 323;
this.addChild(this.dialog);
};
PlayGame.prototype.onMouseDown = function () {
this.GameView.down();
};
PlayGame.prototype.onMouseUp = function () {
this.GameView.up();
};
PlayGame.prototype.onGameComplete = function () {
console.log('死亡');
this.removeListener();
var score = this.getScore();
engine.globalEvent.dispatchEvent('walking-cat-game-end', { score: score });
};
PlayGame.prototype.getScore = function (round) {
if (round === void 0) { round = false; }
var score = (this.normalScore + this.rewardScore) / 10;
score *= (props_1.props.scoreTimes || 1);
if (round) {
return Math.round(score);
}
return score;
};
PlayGame.prototype.onScoreChange = function (event) {
var _a = event.data, score = _a.score, passType = _a.passType, rewardScore = _a.rewardScore;
var scoreAdd;
if (rewardScore) {
this.rewardScore += rewardScore;
scoreAdd = rewardScore;
}
else {
scoreAdd = score - this.normalScore;
this.normalScore = score;
}
var curScore = this.getScore();
this.labScore.updateScore(curScore, this.formatScore);
if (passType > 0 && passType <= 4) {
var now = Date.now();
if (now - this.lastDialogTs > 15000) {
this.play(1);
this.lastDialogTs = now;
}
}
else if (passType == 10) {
this.play(0);
this.lastDialogTs = Date.now();
this.GameView.setWitchFace('happy');
}
if (scoreAdd > 0) {
var labScoreAdd_1 = this.addlabelScore;
labScoreAdd_1.visible = props_1.props.showScore;
labScoreAdd_1.alpha = 0;
labScoreAdd_1.verticalCenter = 0;
labScoreAdd_1.text = '+' + (scoreAdd / 10 * (props_1.props.scoreTimes || 1));
engine.Tween.get(labScoreAdd_1, null, null, true)
.to({ verticalCenter: -50, alpha: 1, }, 200, engine.Ease.cubicIn)
.wait(300)
.to({ verticalCenter: -100, alpha: 0, }, 100, engine.Ease.cubicOut)
.call(function () {
labScoreAdd_1.visible = false;
}, this);
}
engine.globalEvent.dispatchEvent('walking-cat-game-changScore', { score: curScore });
};
PlayGame.prototype.play = function (id) {
var img = this.dialog;
img.texture = utils_1.getTextureByName('dialog_' + id);
img.scaleX = img.scaleY = 0;
img.alpha = 1;
img.visible = true;
engine.Tween.get(img, null, null, true)
.to({
scaleX: 1, scaleY: 1
}, 500, engine.Ease.backOut)
.wait(500)
.to({
alpha: 0,
}, 300)
.call(function () {
img.visible = false;
});
};
PlayGame.prototype.revive = function () {
this.GameView.reset(true);
this.GameView.start(true);
};
return PlayGame;
}(engine.Container));
exports.PlayGame = PlayGame;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var localWave_1 = require("./../localWave");
var ObjectPool = engine.ObjectPool;
var utils_1 = require("./utils");
var utils_2 = require("./utils");
var props_1 = require("../props");
var Block_1 = require("./Block");
var Road = (function (_super) {
__extends(Road, _super);
function Road() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this.dustIndex = 0;
_this.index = 0;
_this.minDistance = parseInt(props_1.props.blockMinDistance) || 100;
_this.maxDistance = parseInt(props_1.props.blockMaxDistance) || 300;
_this.basePos = utils_1.getStage().width / 2 - 100;
_this.padding = 500;
return _this;
}
Road.prototype.preSetup = function () {
this.addChild(this.container = new engine.Container());
var flag = this.flag = new engine.Sprite(utils_2.getTextureByName('flag_record'));
this.anchorRate(flag, 0.5, 1);
flag.y = -230;
flag.x = this.transScoreToFlagPos();
flag.visible = flag.x > 0;
this.addChild(flag);
};
Road.prototype.setup = function () {
this.dustNode = new engine.Container();
this.dustSprite = new engine.Sprite();
this.dustSprite.visible = false;
this.dustNode.y = -1000;
this.dustNode.x = -450;
this.dustNode.addChild(this.dustSprite);
this.addChild(this.dustNode);
var reward = this.reward = new engine.Sprite();
reward.visible = false;
reward.y = -500;
this.addChild(reward);
this.aniReward = new localWave_1.localWave();
this.aniReward.init(reward, 2000, localWave_1.localWave.sin.bind(null, 10));
};
Road.prototype.start = function (revive) {
if (revive === void 0) { revive = false; }
if (revive) {
}
else {
this.rewardIndex = 0;
this.showReward();
}
};
Road.prototype.reset = function (revive) {
if (revive === void 0) { revive = false; }
if (!revive) {
this.index = 0;
this.lastPos = 0;
this.clear();
this.fill();
this.flag.x = this.transScoreToFlagPos();
this.flag.visible = this.flag.x > 0;
}
};
Road.prototype.anchorRate = function (target, rx, ry, width, height, resetPos) {
if (width === void 0) { width = 0; }
if (height === void 0) { height = 0; }
if (resetPos === void 0) { resetPos = true; }
if (width == 0) {
width = target.width;
}
if (height == 0) {
height = target.height;
}
if (resetPos) {
if (rx == 0) {
target.x -= target.anchorOffsetX;
}
if (ry == 0) {
target.y -= target.anchorOffsetY;
}
}
target.anchorOffsetX = width * rx;
target.anchorOffsetY = height * ry;
if (resetPos) {
if (rx > 0) {
target.x += target.anchorOffsetX;
}
if (ry > 0) {
target.y += target.anchorOffsetY;
}
}
};
Road.prototype.transScoreToFlagPos = function () {
return -1;
};
Road.prototype.clear = function () {
while (this.container.children.length > 0) {
this.removeBlockAt(0);
}
};
Road.prototype.addBlock = function () {
var type = 0, v;
if (this.index > 10) {
do {
var rv = Math.random();
v = 0;
for (var i = 0; i < 5; i++) {
v += Block_1.Block.configs[i].ratio;
if (rv < v) {
type = i;
break;
}
}
} while (this.lastBlockType == type);
this.lastBlockType = type;
}
var block = ObjectPool.getObject('block', { type: type });
var width = Block_1.Block.configs[type].width;
var distance = this.index == 0 ?
this.maxDistance :
this.makeRandomFloat(this.maxDistance, this.minDistance);
var pos = this.lastPos + distance;
block.x = pos;
this.container.addChild(block);
this.lastPos = pos + width;
this.index++;
};
Road.prototype.removeBlockAt = function (index) {
var block = this.container.removeChildAt(index);
ObjectPool.recycleObject('block', block);
};
Road.prototype.removeBlock = function (block) {
this.container.removeChild(block);
ObjectPool.recycleObject('block', block);
};
Road.prototype.fill = function () {
if (isNaN(this.lastPos)) {
return;
}
while (true) {
if (this.lastPos + this.x > utils_1.getStage().width + this.padding) {
break;
}
this.addBlock();
}
};
Road.prototype.makeRandomFloat = function (max, min) {
if (min === void 0) { min = 0; }
return Math.random() * (max - min) + min;
};
Road.prototype.setViewport = function (pos) {
this.x = this.basePos - pos;
while (this.container.children.length > 0) {
if (this.container.getChildAt(0).x >= pos - this.padding) {
break;
}
this.removeBlockAt(0);
}
this.fill();
};
Road.prototype.showReward = function (type) {
if (type === void 0) { type = 10; }
this.rewardIndex++;
var pos = this.rewardIndex * utils_1.getStage().width * 3;
var reward = this.reward;
reward.visible = true;
reward.alpha = 1;
reward.texture = utils_2.getTextureByName('menu_block_10');
reward.x = pos;
this.aniReward.updateRegisterPos();
};
Road.prototype.hideReward = function () {
var _this = this;
var reward = this.reward;
this.tweenReward = engine.Tween.get(reward)
.to({ alpha: 0 }, 200)
.call(function () {
_this.tweenReward = null;
_this.showReward();
});
};
Road.prototype.hitReward = function (pos) {
if (this.reward.visible && pos >= this.reward.x && !this.tweenReward) {
this.hideReward();
return true;
}
};
Road.prototype.playDust = function (pos) {
this.dustSprite.x = pos;
this.dustSprite.visible = true;
this.addEventListener(engine.Event.ENTER_FRAME, this.onEnterFrame, this);
};
Road.prototype.onEnterFrame = function () {
if (this.dustIndex < 12) {
this.dustSprite.texture = utils_2.getTextureByName('dust_' + this.dustIndex);
this.dustIndex++;
}
else {
this.dustIndex = 0;
this.dustSprite.visible = false;
this.removeEventListener(engine.Event.ENTER_FRAME, this.onEnterFrame, this);
}
};
Road.prototype.hitBlock = function (pos) {
var _this = this;
var target, lastTarget;
var foot = { a: pos - 84 / 2, b: pos + 84 / 2 };
this.container.children.some(function (block, i) {
var width = Block_1.Block.configs[block.type].width;
var line = { a: block.x - width / 2, b: block.x + width / 2 };
if (_this.lineHitTest(foot, line)) {
target = block;
return true;
}
});
if (!target) {
for (var i = this.container.children.length; i > 0; i--) {
var block = this.container.getChildAt(i - 1);
if (block.x < pos) {
lastTarget = block;
break;
}
}
}
return {
target: target,
lastTarget: lastTarget,
};
};
Road.prototype.lineHitTest = function (l0, l1) {
return l0.a < l1.b && l0.b > l1.a;
};
return Road;
}(engine.Container));
exports.Road = Road;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var ScoreLabel = (function (_super) {
__extends(ScoreLabel, _super);
function ScoreLabel() {
return _super !== null && _super.apply(this, arguments) || this;
}
ScoreLabel.prototype.updateScore = function (score, formatFun, animation) {
if (formatFun === void 0) { formatFun = null; }
if (animation === void 0) { animation = true; }
this.formatFun = formatFun;
this._value = score;
if (animation) {
engine.Tween.get(this, null, null, true)
.to({ temp: score }, 300);
}
else {
this.updateLocal(score);
}
};
Object.defineProperty(ScoreLabel.prototype, "score", {
get: function () {
return this._value;
},
enumerable: true,
configurable: true
});
Object.defineProperty(ScoreLabel.prototype, "temp", {
get: function () {
return this._temp;
},
set: function (v) {
this._temp = v;
this.updateLocal(v);
},
enumerable: true,
configurable: true
});
ScoreLabel.prototype.updateLocal = function (v) {
this.text = this.formatFun && this.formatFun(v) || v;
};
return ScoreLabel;
}(engine.Label));
exports.ScoreLabel = ScoreLabel;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var Block_1 = require("./Block");
var ObjectPool = engine.ObjectPool;
exports.PoolName = 'block';
ObjectPool.registerPool(exports.PoolName, function () {
return new Block_1.Block();
}, function (item, data) {
item.reset(data);
});
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var utils_1 = require("../utils");
var factor = 10;
var Head = (function (_super) {
__extends(Head, _super);
function Head() {
var _this = _super.call(this) || this;
_this.imgFace = new engine.Sprite(utils_1.getTextureByName('head_0'));
_this.addChild(_this.imgFace);
_this.imgFace.anchorTexture.set(107 / _this.imgFace.width, 155 / _this.imgFace.height);
_this.imgFace.y = 65;
_this._headType = '';
return _this;
}
Head.prototype.localUpdate = function (x, y, rotation, sleeping) {
this.x = x;
this.y = y;
this.rotation = rotation;
};
Object.defineProperty(Head.prototype, "fWidth", {
get: function () {
return this.width / factor;
},
enumerable: true,
configurable: true
});
Object.defineProperty(Head.prototype, "fHeight", {
get: function () {
return this.height / factor;
},
enumerable: true,
configurable: true
});
Head.prototype.switchFace = function (type, playAni) {
if (type == this._headType) {
return;
}
var headName = '';
if (type == 'normal') {
headName = 'head_0';
}
else if (type == 'happy') {
headName = 'head_1';
}
else if (type == 1 || type == 0 || type == 2) {
headName = 'head_2';
}
else if (type == 3) {
headName = 'head_3';
}
else if (type == 4) {
headName = 'head_4';
}
this._headType = type;
this.imgFace.texture = utils_1.getTextureByName(headName);
};
return Head;
}(engine.Container));
exports.Head = Head;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var Head_1 = require("./Head");
var PlayerPart_1 = require("./PlayerPart");
var utils_1 = require("../utils");
var PlayerStat;
(function (PlayerStat) {
PlayerStat[PlayerStat["RELEASE"] = 0] = "RELEASE";
PlayerStat[PlayerStat["RISING"] = 1] = "RISING";
PlayerStat[PlayerStat["FALL"] = 2] = "FALL";
})(PlayerStat || (PlayerStat = {}));
var debug = false;
var Player = (function (_super) {
__extends(Player, _super);
function Player() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this.partMass = 0.1;
_this.footMass = 0.1;
_this.shouldersDistance = 50 / utils_1.getfactor();
_this.speed = 30;
_this.skin = '';
_this.originPos = {};
_this.safePos = 0;
_this.onPostStep = function (e) {
if (e === void 0) { e = null; }
var side = _this.currentSide;
var footHang = _this.foots[_this.currentSide];
var footFall = _this.foots[_this.anotherSide];
switch (_this.state) {
case PlayerStat.FALL:
break;
case PlayerStat.RISING:
var footOffset = footHang.position[0] - footFall.position[0];
var speed = _this.speed;
_this.upperLegs[side].angularVelocity = 10;
_this.upperLegs[side].velocity = [
footOffset < 0 ? speed - 10 : speed,
0
];
_this.lowerLegs[side].velocity = [
footOffset < 0 ? speed - 10 : speed,
footOffset < 0 ? 3 : 2
];
_this.head.velocity = [speed * 0.5, 20];
_this.dispatchEvent('move', {
pos: (_this.leftFoot.position[0] + _this.rightFoot.position[0]) / 2 * utils_1.getfactor(),
bodyPos: _this.body.position[0] * utils_1.getfactor(),
}, true);
if (footOffset > 50) {
_this.up();
}
break;
case PlayerStat.RELEASE:
_this.head.velocity = [0, 30];
break;
}
};
_this.onFootDown = function () {
var pos = _this.foots[_this.currentSide].position[0] * utils_1.getfactor();
var mileage = Math.max(_this.foots[0].position[0], _this.foots[1].position[0]) * utils_1.getfactor();
_this.safePos = _this.foots[_this.currentSide].position[0];
_this.dispatchEvent('foot_down', {
mileage: mileage,
pos: pos,
}, true);
};
return _this;
}
Player.prototype.setup = function (options) {
var collisionGroup = options.collisionGroup, collisionMask = options.collisionMask, world = options.world, ground = options.ground;
this.world = world;
world.on('postStep', this.onPostStep);
var bodyPartShapes = [];
var leftFootDisplay = this.createDisplay('foot');
var lowerLeftLegDisplay = this.createDisplay('lower_left_leg');
var upperLeftLegDisplay = this.createDisplay('upper_left_leg');
var rightFootDisplay = this.createDisplay('foot');
var lowerRightLegDisplay = this.createDisplay('lower_right_leg');
var upperRightLegDisplay = this.createDisplay('upper_right_leg');
var bodyDisplay = this.createDisplay('body', { x: 50, y: 0 });
var headDisplay = new Head_1.Head();
var upperLeftArmDisplay = this.createDisplay('upper_left_arm');
var lowerLeftArmDisplay = this.createDisplay('lower_left_arm', { x: -20, y: 0 });
var upperRightArmDisplay = this.createDisplay('upper_right_arm');
var lowerRightArmDisplay = this.createDisplay('lower_right_arm', { x: -39, y: 0 });
var leftFootShape = new p2.Box(leftFootDisplay.fSize);
bodyPartShapes.push(leftFootShape);
this.originPos['leftFoot'] = [
-this.shouldersDistance / 2,
leftFootDisplay.fHeight / 2
];
var leftFoot = this.leftFoot = new p2.Body({
allowSleep: false,
mass: this.footMass,
position: this.originPos['leftFoot'],
});
if (!debug)
leftFoot.displays = [leftFootDisplay];
leftFoot.addShape(leftFootShape);
var lowerLeftLegShape = new p2.Box(lowerLeftLegDisplay.fSize);
bodyPartShapes.push(lowerLeftLegShape);
this.originPos['lowerLeftLeg'] = [
-this.shouldersDistance / 2,
leftFoot.position[1] + lowerLeftLegDisplay.fHeight / 2 + 5 / utils_1.getfactor()
];
var lowerLeftLeg = this.lowerLeftLeg = new p2.Body({
allowSleep: false,
mass: this.partMass,
position: this.originPos['lowerLeftLeg'],
});
if (!debug)
lowerLeftLeg.displays = [lowerLeftLegDisplay];
lowerLeftLeg.addShape(lowerLeftLegShape);
var leftAnkleJoint = new p2.RevoluteConstraint(lowerLeftLeg, leftFoot, {
localPivotA: [0, -lowerLeftLegDisplay.fHeight / 2 + 5 / utils_1.getfactor()],
localPivotB: [-leftFootDisplay.fWidth / 2 + 18 / utils_1.getfactor(), 0],
});
leftAnkleJoint.setLimits(-Math.PI / 3, Math.PI / 3);
var leftFootGroundCons = this.leftFootGroundCons = new p2.RevoluteConstraint(leftFoot, ground, {
localPivotA: [0, -leftFootDisplay.fHeight / 2],
localPivotB: [leftFoot.position[0], 0],
});
leftFootGroundCons.setLimits(0, 0);
var upperLeftLegShape = new p2.Box(upperLeftLegDisplay.fSize);
bodyPartShapes.push(upperLeftLegShape);
this.originPos['upperLeftLeg'] = [
-this.shouldersDistance / 2,
lowerLeftLeg.position[1] + lowerLeftLegDisplay.fHeight / 2 + upperLeftLegDisplay.fHeight / 2 - 40 / utils_1.getfactor()
];
var upperLeftLeg = this.upperLeftLeg = new p2.Body({
allowSleep: false,
mass: this.partMass,
position: this.originPos['upperLeftLeg'],
});
if (!debug)
upperLeftLeg.displays = [upperLeftLegDisplay];
upperLeftLeg.addShape(upperLeftLegShape);
var leftKneeJoint = new p2.RevoluteConstraint(upperLeftLeg, lowerLeftLeg, {
localPivotA: [0, -upperLeftLegDisplay.fHeight / 2 + 20 / utils_1.getfactor()],
localPivotB: [0, lowerLeftLegDisplay.fHeight / 2 - 20 / utils_1.getfactor()],
});
leftKneeJoint.setLimits(-Math.PI, 0);
var rightFootShape = new p2.Box(rightFootDisplay.fSize);
bodyPartShapes.push(rightFootShape);
this.originPos['rightFoot'] = [
this.shouldersDistance / 2,
rightFootDisplay.fHeight / 2
];
var rightFoot = this.rightFoot = new p2.Body({
allowSleep: false,
mass: this.footMass,
position: this.originPos['rightFoot'],
});
if (!debug)
rightFoot.displays = [rightFootDisplay];
rightFoot.addShape(rightFootShape);
var lowerRightLegShape = new p2.Box(lowerRightLegDisplay.fSize);
bodyPartShapes.push(lowerRightLegShape);
this.originPos['lowerRightLeg'] = [
this.shouldersDistance / 2,
rightFoot.position[1] + lowerRightLegDisplay.fHeight / 2 + 5 / utils_1.getfactor()
];
var lowerRightLeg = this.lowerRightLeg = new p2.Body({
allowSleep: false,
mass: this.partMass,
position: this.originPos['lowerRightLeg'],
});
if (!debug)
lowerRightLeg.displays = [lowerRightLegDisplay];
lowerRightLeg.addShape(lowerRightLegShape);
var rightAnkleJoint = new p2.RevoluteConstraint(lowerRightLeg, rightFoot, {
localPivotA: [0, -lowerRightLegDisplay.fHeight / 2 + 5 / utils_1.getfactor()],
localPivotB: [-rightFootDisplay.fWidth / 2 + 18 / utils_1.getfactor(), 0],
});
rightAnkleJoint.setLimits(-Math.PI / 3, Math.PI / 3);
var rightFootGroundCons = this.rightFootGroundCons = new p2.RevoluteConstraint(rightFoot, ground, {
localPivotA: [0, -rightFootDisplay.fHeight / 2],
localPivotB: [rightFoot.position[0], 0],
});
rightFootGroundCons.setLimits(0, 0);
var upperRightLegShape = new p2.Box(upperRightLegDisplay.fSize);
bodyPartShapes.push(upperRightLegShape);
this.originPos['upperRightLeg'] = [
this.shouldersDistance / 2,
lowerRightLeg.position[1] + lowerRightLegDisplay.fHeight / 2 + upperRightLegDisplay.fHeight / 2 - 40 / utils_1.getfactor()
];
var upperRightLeg = this.upperRightLeg = new p2.Body({
allowSleep: false,
mass: this.partMass,
position: this.originPos['upperRightLeg'],
});
if (!debug)
upperRightLeg.displays = [upperRightLegDisplay];
upperRightLeg.addShape(upperRightLegShape);
var rightKneeJoint = new p2.RevoluteConstraint(upperRightLeg, lowerRightLeg, {
localPivotA: [0, -upperRightLegDisplay.fHeight / 2 + 20 / utils_1.getfactor()],
localPivotB: [0, lowerRightLegDisplay.fHeight / 2 - 20 / utils_1.getfactor()],
});
rightKneeJoint.setLimits(-Math.PI, 0);
var bodyWidth = 120 / utils_1.getfactor();
var bodyHeight = 250 / utils_1.getfactor();
var bodyShape = new p2.Box({ width: bodyWidth, height: bodyHeight });
bodyPartShapes.push(bodyShape);
this.originPos['body'] = [
0,
upperRightLeg.position[1] + upperRightLegDisplay.fHeight / 2 + bodyHeight / 2 - 60 / utils_1.getfactor()
];
var body = this.body = new p2.Body({
allowSleep: false,
mass: this.partMass,
position: this.originPos['body'],
});
if (!debug)
body.displays = [bodyDisplay];
body.addShape(bodyShape);
var leftHipJoint = new p2.RevoluteConstraint(body, upperLeftLeg, {
localPivotA: [-20 / utils_1.getfactor(), -bodyHeight / 2 + 30 / utils_1.getfactor()],
localPivotB: [0, upperLeftLegDisplay.fHeight / 2 - 30 / utils_1.getfactor()],
});
leftHipJoint.setLimits(-Math.PI / 6 * 2, Math.PI / 6 * 2);
var rightHipJoint = new p2.RevoluteConstraint(body, upperRightLeg, {
localPivotA: [-20 / utils_1.getfactor(), -bodyHeight / 2 + 30 / utils_1.getfactor()],
localPivotB: [0, upperRightLegDisplay.fHeight / 2 - 30 / utils_1.getfactor()],
});
rightHipJoint.setLimits(-Math.PI / 6 * 2, Math.PI / 6 * 2);
var headShape = new p2.Circle({ radius: 85 / utils_1.getfactor() });
bodyPartShapes.push(headShape);
this.originPos['head'] = [
0,
body.position[1] + bodyHeight / 2 + 85 / utils_1.getfactor()
];
var head = this.head = new p2.Body({
allowSleep: false,
mass: this.partMass,
position: this.originPos['head'],
});
head.addShape(headShape);
if (!debug)
head.displays = [headDisplay];
var headJoint = new p2.RevoluteConstraint(body, head, {
localPivotA: [0, bodyHeight / 2 - 10 / utils_1.getfactor()],
localPivotB: [0, (-85 + 10) / utils_1.getfactor()],
});
headJoint.setLimits(-Math.PI / 6 * 2, Math.PI / 6 * 2);
var upperLeftArmShape = new p2.Box(upperLeftArmDisplay.fSize);
bodyPartShapes.push(upperLeftArmShape);
this.originPos['upperLeftArm'] = [
-this.shouldersDistance / 2 - 10 / utils_1.getfactor(),
body.position[1] + bodyHeight / 2 - upperLeftArmDisplay.fHeight / 2
];
var upperLeftArm = this.upperLeftArm = new p2.Body({
allowSleep: false,
mass: this.partMass,
position: this.originPos['upperLeftArm'],
});
if (!debug)
upperLeftArm.displays = [upperLeftArmDisplay];
upperLeftArm.addShape(upperLeftArmShape);
var leftShoulderJoint = new p2.RevoluteConstraint(body, upperLeftArm, {
localPivotA: [-this.shouldersDistance / 2 + 10 / utils_1.getfactor(), bodyHeight / 2],
localPivotB: [0, upperLeftArmDisplay.fHeight / 2],
});
leftShoulderJoint.setLimits(-Math.PI / 2, 0);
var width = 50 / utils_1.getfactor();
var lowerLeftArmShape = new p2.Box({ width: width, height: lowerLeftArmDisplay.fHeight });
bodyPartShapes.push(lowerLeftArmShape);
this.originPos['lowerLeftArm'] = [
-this.shouldersDistance / 2 - 10 / utils_1.getfactor() + 10 / utils_1.getfactor(),
upperLeftArm.position[1] - upperLeftArmDisplay.fHeight / 2 - lowerLeftArmDisplay.fHeight / 2 + 20 / utils_1.getfactor()
];
var lowerLeftArm = this.lowerLeftArm = new p2.Body({
allowSleep: false,
mass: this.partMass,
position: this.originPos['lowerLeftArm'],
});
if (!debug)
lowerLeftArm.displays = [lowerLeftArmDisplay];
lowerLeftArm.addShape(lowerLeftArmShape);
var leftElbowJoint = new p2.RevoluteConstraint(upperLeftArm, lowerLeftArm, {
localPivotA: [0, -upperLeftArmDisplay.fHeight / 2 + 10 / utils_1.getfactor()],
localPivotB: [-10 / utils_1.getfactor(), lowerLeftLegDisplay.fHeight / 2 - 10 / utils_1.getfactor()],
});
leftElbowJoint.setLimits(0, Math.PI * 2 / 3);
var upperRightArmShape = new p2.Box(upperRightArmDisplay.fSize);
bodyPartShapes.push(upperRightArmShape);
this.originPos['upperRightArm'] = [
this.shouldersDistance / 2,
body.position[1] + bodyHeight / 2 - upperRightArmDisplay.fHeight / 2
];
var upperRightArm = this.upperRightArm = new p2.Body({
allowSleep: false,
mass: this.partMass,
position: this.originPos['upperRightArm'],
});
if (!debug)
upperRightArm.displays = [upperRightArmDisplay];
upperRightArm.addShape(upperRightArmShape);
var rightShoulderJoint = new p2.RevoluteConstraint(body, upperRightArm, {
localPivotA: [this.shouldersDistance / 2 + 10 / utils_1.getfactor(), bodyHeight / 2],
localPivotB: [0, upperRightArmDisplay.fHeight / 2],
});
rightShoulderJoint.setLimits(-Math.PI / 2, 0);
var width = 30 / utils_1.getfactor();
var lowerRightArmShape = new p2.Box({ width: width, height: lowerRightArmDisplay.fHeight });
bodyPartShapes.push(lowerRightArmShape);
this.originPos['lowerRightArm'] = [
this.shouldersDistance / 2,
upperRightArm.position[1] - upperRightArmDisplay.fHeight / 2 - lowerRightArmDisplay.fHeight / 2 + 40 / utils_1.getfactor()
];
var lowerRightArm = this.lowerRightArm = new p2.Body({
allowSleep: false,
mass: this.partMass,
position: this.originPos['lowerRightArm'],
});
if (!debug)
lowerRightArm.displays = [lowerRightArmDisplay];
lowerRightArm.addShape(lowerRightArmShape);
var rightElbowJoint = new p2.RevoluteConstraint(upperRightArm, lowerRightArm, {
localPivotA: [0, -upperRightArmDisplay.fHeight / 2 + 20 / utils_1.getfactor()],
localPivotB: [0, lowerRightLegDisplay.fHeight / 2 - 20 / utils_1.getfactor()],
});
rightElbowJoint.setLimits(0, Math.PI * 2 / 3);
var bodies = [
lowerRightArm, upperRightArm,
lowerRightLeg, upperRightLeg, rightFoot,
body,
lowerLeftLeg, upperLeftLeg, leftFoot,
lowerLeftArm, upperLeftArm,
head,
];
bodies.forEach(function (body) {
world.addBody(body);
});
var joints = [
leftAnkleJoint,
leftKneeJoint,
rightAnkleJoint,
rightKneeJoint,
headJoint,
leftHipJoint,
rightHipJoint,
leftShoulderJoint,
leftElbowJoint,
rightShoulderJoint,
rightElbowJoint,
leftFootGroundCons,
rightFootGroundCons,
];
joints.forEach(function (joint) {
world.addConstraint(joint);
});
for (var i = 0; i < bodyPartShapes.length; i++) {
var s = bodyPartShapes[i];
s.collisionGroup = collisionGroup;
s.collisionMask = collisionMask;
}
this.foots = [leftFoot, rightFoot];
this.lowerLegs = [lowerLeftLeg, lowerRightLeg];
this.upperLegs = [upperLeftLeg, upperRightLeg];
this.footGroundCons = [leftFootGroundCons, rightFootGroundCons];
};
Player.prototype.reset = function (revive) {
var _this = this;
if (revive === void 0) { revive = false; }
if (revive) {
}
else {
this.step = -1;
this.safePos = 0;
[
'lowerLeftLeg',
'upperLeftLeg',
'lowerRightLeg',
'upperRightLeg',
'body',
'head',
'upperLeftArm',
'lowerLeftArm',
'upperRightArm',
'lowerRightArm',
].forEach(function (partName) {
var part = _this[partName];
part.position[0] = _this.safePos + _this.originPos[partName][0];
});
}
for (var i = 0; i < 2; i++) {
var cons = this.footGroundCons[i];
cons.pivotB[0] = this.foots[i].position[0] = this.safePos + (i == 0 ? -1 : 1) * this.shouldersDistance / 2;
if (this.state == PlayerStat.FALL) {
this.world.addConstraint(cons);
}
}
this.switchFace('normal', false);
this.setSkin('normal');
this.state = PlayerStat.RELEASE;
};
Player.prototype.createDisplay = function (resName, offset) {
if (offset === void 0) { offset = null; }
var bmp = new PlayerPart_1.PlayerPart(resName);
var anchorX = bmp.width / 2 + (offset ? offset.x : 0);
var anchorY = bmp.height / 2 + (offset ? offset.y : 0);
bmp.anchorTexture.set(anchorX / bmp.width, anchorY / bmp.height);
return bmp;
};
Object.defineProperty(Player.prototype, "currentSide", {
get: function () {
return this.step % 2;
},
enumerable: true,
configurable: true
});
Object.defineProperty(Player.prototype, "anotherSide", {
get: function () {
return (this.step + 1) % 2;
},
enumerable: true,
configurable: true
});
Player.prototype.down = function () {
if (this.state == PlayerStat.RISING) {
return;
}
this.step++;
var cons = this.footGroundCons[this.currentSide];
this.world.removeConstraint(cons);
this.state = PlayerStat.RISING;
};
Player.prototype.up = function () {
if (this.state == PlayerStat.RELEASE) {
return;
}
var side = this.currentSide;
this.foots[side].velocity = [0, 0];
this.body.velocity = [0, 0];
var currentFoot = this.foots[side];
var cons = this.footGroundCons[side];
cons.pivotB[0] = currentFoot.position[0];
this.world.addConstraint(cons);
this.state = PlayerStat.RELEASE;
setTimeout(this.onFootDown, 200);
};
Player.prototype.fall = function () {
this.body.velocity = [0, -30];
this.head.velocity = [-50, -50];
this.world.removeConstraint(this.footGroundCons[0]);
this.world.removeConstraint(this.footGroundCons[1]);
this.foots[this.currentSide].velocity[0] = 60;
this.foots[this.anotherSide].velocity[0] = 70;
this.state = PlayerStat.FALL;
};
Player.prototype.switchFace = function (type, playAni) {
if (playAni === void 0) { playAni = true; }
var headDisplay = this.head.displays[0];
headDisplay.switchFace(type, playAni);
};
Player.prototype.setSkin = function (name) {
var _this = this;
if (this.skin == name) {
return;
}
this.skin = name;
[
'leftFoot',
'lowerLeftLeg',
'upperLeftLeg',
'rightFoot',
'lowerRightLeg',
'upperRightLeg',
'body',
'upperLeftArm',
'lowerLeftArm',
'upperRightArm',
'lowerRightArm',
].forEach(function (partName) {
var part = _this[partName];
part.displays[0].setSkin(name);
});
};
Player.prototype.fade = function (alpha, animation) {
var _this = this;
if (animation === void 0) { animation = true; }
[
'leftFoot',
'lowerLeftLeg',
'upperLeftLeg',
'rightFoot',
'lowerRightLeg',
'upperRightLeg',
'body',
'head',
'upperLeftArm',
'lowerLeftArm',
'upperRightArm',
'lowerRightArm',
].forEach(function (partName) {
var display = _this[partName].displays[0];
if (animation) {
engine.Tween.get(display, null, null, true)
.to({ alpha: alpha }, 200);
}
else {
display.alpha = alpha;
}
});
};
return Player;
}(engine.EventDispatcher));
exports.Player = Player;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var utils_1 = require("../utils");
var PlayerPart = (function (_super) {
__extends(PlayerPart, _super);
function PlayerPart(name) {
var _this = _super.call(this) || this;
_this.changeRes(name);
return _this;
}
PlayerPart.prototype.changeRes = function (name) {
this.name = name;
this.texture = utils_1.getTextureByName('body_normal_' + name);
};
;
PlayerPart.prototype.setSkin = function (name) {
this.texture = utils_1.getTextureByName('body_' + name + '_' + this.name);
};
PlayerPart.prototype.localUpdate = function (x, y, rotation, sleeping) {
this.x = x;
this.y = y;
this.rotation = rotation;
};
Object.defineProperty(PlayerPart.prototype, "fSize", {
get: function () {
return { width: this.fWidth, height: this.fHeight };
},
enumerable: true,
configurable: true
});
Object.defineProperty(PlayerPart.prototype, "fWidth", {
get: function () {
return this.width / utils_1.getfactor();
},
enumerable: true,
configurable: true
});
Object.defineProperty(PlayerPart.prototype, "fHeight", {
get: function () {
return this.height / utils_1.getfactor();
},
enumerable: true,
configurable: true
});
PlayerPart.prototype.reset = function () {
};
return PlayerPart;
}(engine.Sprite));
exports.PlayerPart = PlayerPart;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
function getTexture(uuid) {
return engine.Texture.from(getAssetByUUID(uuid).uuid);
}
exports.getTexture = getTexture;
function getTextureByName(name) {
return getTexture(engine.getAssetByName(name).uuid);
}
exports.getTextureByName = getTextureByName;
function playSound(name) {
engine.playSound(engine.getAssetByName(name).uuid, { keep: true });
}
exports.playSound = playSound;
function getStage() {
return engine.gameStage.stage;
}
exports.getStage = getStage;
function getfactor() {
return 10;
}
exports.getfactor = getfactor;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var GameWrapper_1 = require("./game/GameWrapper");
var props_1 = require("./props");
function default_1(props) {
props_1.prepareProps();
props_1.injectProps(props);
var instance = new GameWrapper_1.GameWrapper();
return instance;
}
exports.default = default_1;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var localWave = (function () {
function localWave() {
this._oldProperties = {};
this._t = 0;
}
localWave.prototype.init = function (target, duration, calProps, loop, autoPlay, reverse, delay, offset) {
if (calProps === void 0) { calProps = null; }
if (loop === void 0) { loop = 0; }
if (autoPlay === void 0) { autoPlay = true; }
if (reverse === void 0) { reverse = false; }
if (delay === void 0) { delay = 0; }
if (offset === void 0) { offset = 0; }
this.target = target;
this._calProps = calProps ? calProps : localWave.round;
this.duration = duration;
this.loop = loop;
this.reverse = reverse;
this.delay = delay;
this.offset = offset;
this.updateRegisterPos();
if (autoPlay) {
this.play();
}
};
localWave.prototype.updateRegisterPos = function () {
this._oldProperties.x = this.target.x;
this._oldProperties.y = this.target.y;
this._oldProperties.scaleX = this.target.scaleX;
this._oldProperties.scaleY = this.target.scaleY;
this._oldProperties.skewX = this.target.skewX;
this._oldProperties.skewY = this.target.skewY;
this._oldProperties.rotation = this.target.rotation;
this._oldProperties.alpha = this.target.alpha;
};
localWave.prototype.play = function () {
if (this._tween) {
return this._tween;
}
this._count = 0;
return this._playStep();
};
localWave.prototype._playStep = function () {
if (this.loop > 0 && this._count >= this.loop) {
this.stop();
return;
}
this._count++;
this.t = this.reverse ? Math.PI * 2 : 0;
this._tween = engine.Tween.get(this);
this._tween.wait(this.delay).to({ t: this.reverse ? 0 : Math.PI * 2 }, this.duration).call(this._playStep, this);
return this._tween;
};
Object.defineProperty(localWave.prototype, "t", {
get: function () {
return this._t;
},
set: function (value) {
if (!this.target.stage) {
return;
}
this._t = value;
var props = this._calProps.call(this, this._t + this.offset);
if (props.hasOwnProperty('x')) {
this.target.x = (props.x || 0) + this._oldProperties.x;
}
if (props.hasOwnProperty('y')) {
this.target.y = (props.y || 0) + this._oldProperties.y;
}
if (props.hasOwnProperty('sx')) {
this.target.scaleX = props.sx;
}
if (props.hasOwnProperty('sy')) {
this.target.scaleY = props.sy;
}
if (props.hasOwnProperty('skewX')) {
this.target.skewX = props.skewX;
}
if (props.hasOwnProperty('skewY')) {
this.target.skewY = props.skewY;
}
if (props.hasOwnProperty('r')) {
this.target.rotation = props.r;
}
if (props.hasOwnProperty('alpha')) {
this.target.alpha = props.alpha;
}
},
enumerable: true,
configurable: true
});
localWave.prototype.stop = function (recovery, animation, duration) {
if (recovery === void 0) { recovery = false; }
if (animation === void 0) { animation = false; }
if (duration === void 0) { duration = 1000; }
if (!this._tween) {
return;
}
engine.Tween.removeTweens(this);
if (recovery) {
engine.Tween.get(this.target).to(this._oldProperties, duration);
}
this._tween = null;
};
Object.defineProperty(localWave.prototype, "playing", {
get: function () {
return this._tween != null;
},
enumerable: true,
configurable: true
});
localWave.round = function (h, t) {
return { x: Math.cos(t) * h, y: Math.sin(t) * h };
};
localWave.cos = function (h, t) {
return { x: Math.cos(t) * h, y: 0 };
};
localWave.sin = function (h, t) {
h = h || 1;
return { x: 0, y: Math.sin(t) * h };
};
localWave.rotate = function (t) {
return { r: 360 * t / Math.PI / 2 };
};
localWave.shake = function (angle, count, t) {
return { r: Math.sin(t * count) * angle };
};
localWave.breath = function (scale, t) {
return { sx: Math.sin(t) * scale + 1, sy: -Math.sin(t + Math.PI / 4) * scale + 1 };
};
localWave.zoom = function (scale, t) {
scale = scale || 0.1;
return { sx: Math.sin(t) * scale + 1, sy: Math.sin(t) * scale + 1 };
};
localWave.fade = function (base, t) {
return { alpha: (Math.sin(t) + 1) * 0.5 + base };
};
return localWave;
}());
exports.localWave = localWave;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.props = {};
function prepareProps() {
var metaProps = getProps();
engine.injectProp(exports.props, metaProps);
}
exports.prepareProps = prepareProps;
function injectProps(p) {
engine.injectProp(exports.props, p);
}
exports.injectProps = injectProps;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
function prop(key, meta) {
return function (target, propertyKey, descriptor) {
};
}
var default_1 = (function () {
function default_1() {
}
default_1.process = function () {
var leftValue = engine.findVariable('left', args, props);
var rightValue = engine.findVariable('right', args, props);
var operator = engine.findVariable('operator', args, props);
var result;
if (operator === 'exist') {
result = !!leftValue;
}
else {
switch (props.type) {
case 'string':
leftValue = '"' + leftValue + '"';
rightValue = '"' + rightValue + '"';
break;
case 'number':
leftValue = typeof leftValue === 'number' ? leftValue : parseFloat(leftValue);
rightValue = typeof rightValue === 'number' ? rightValue : parseFloat(rightValue);
break;
case 'boolean':
leftValue = typeof leftValue === 'boolean' ? leftValue :
(leftValue === 'true' ? true :
(leftValue === 'false' ? false : !!leftValue));
rightValue = typeof rightValue === 'boolean' ? rightValue :
(rightValue === 'true' ? true :
(rightValue === 'false' ? false : !!rightValue));
break;
}
var func = new Function('return ' + leftValue + operator + rightValue);
result = func();
}
next(result ? 'true' : 'false');
};
__decorate([
prop('left', { "alias": "左值", "type": "dynamic", "default": "" })
], default_1, "process", null);
return default_1;
}());
exports.default = default_1;
......@@ -10,7 +10,7 @@ declare type NodeClass =
declare const args: any;
declare const scope: any;
declare const props: ProcessProps;
declare const props: ProcessProps | any;
declare const target: NodeClass;
declare const global: {
gameStage: engine.GameStage,
......
/**
* Created by renjianfeng on 2020-03-13.
*/
const customId = 'dragon-boat-race';
(async function () {
let customModule = await fetch(`../meta.json`);
customModule = await customModule.json();
console.log(customModule);
await loadAssets(customModule.assets);
launchWithCustomModule(customModule);
})();
function launchWithCustomModule(customModule) {
//engine.registerCustomCodeModule(customModule);
engine.registerCustomModule(customId, window[customId]);
const {props: propsOption, assets} = customModule;
let props = engine.computeProps(customModuleProps, propsOption);
const customModuleIns = {
id: customId,
props,
assets,
};
engine.registerCustomModules([customModuleIns]);
engine.launchWithConfig({
options: {
entrySceneView: 'entry',
},
assets: [],
views: [{
name: 'entry',
type: 'node',
properties: {
x: 0,
y: 0,
}
}],
customs: []
}, null, function () {
setTimeout(() => {
engine.addCustomModule(customId, engine.gameStage.sceneContainer.getChildAt(0));
}, 100);
setTimeout(() => {
engine.globalEvent.dispatchEvent('dragon-boat-race-reset', {
"goodsProbability": "0.3,0.2,0.3,0.2",
"countDown": 30,
"acceleratedSpeed":0.1
});
engine.globalEvent.dispatchEvent('dragon-boat-race-start');
}, 1000);
});
engine.globalEvent.addEventListener('dragon-boat-race-time-update', (e) => {
console.log(e.type, e.data);
});
engine.globalEvent.addEventListener('dragon-boat-race-score-update', (e) => {
console.log(e.type, e.data);
});
engine.globalEvent.addEventListener('dragon-boat-race-game-over', (e) => {
console.log(e.type, e.data);
});
}
function getAssetByUUID(uuid) {
return engine.resolveCustomAsset(customId, uuid);
}
function getProps() {
return engine.getProps(customId);
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>美食从天而降</title>
<meta name="viewport"
content="width=device-width,initial-scale=1, minimum-scale=1, maximum-scale=1, user-scalable=no"/>
<meta name="apple-mobile-web-app-capable" content="yes"/>
<meta name="full-screen" content="true"/>
<meta name="screen-orientation" content="portrait"/>
<meta name="x5-fullscreen" content="true"/>
<meta name="360-fullscreen" content="true"/>
<style>
html,
body {
padding: 0;
margin: 0;
border: 0;
width: 100%;
height: 100%;
overflow: hidden;
position: absolute;
background-color: red;
}
.game-container{
width: 100%;
height: 100%;
line-height:0;
font-size:0;
}
</style>
</head>
<body>
<div id="game-container" class="game-container"></div>
<!-- <script crossorigin="anonymous" src="//yun.duiba.com.cn/editor/zeroing/libs/engine.50cdcef6ebe4e8c0fbc624f9d4fbf225102c5750.js"></script> -->
<script crossorigin="anonymous" src="//yun.duiba.com.cn/editor/zeroing/libs/engine.fbc60c6d3cb30e5ab97e82d392d9efeee91b8581.js"></script>
<script crossorigin="anonymous" src="//yun.duiba.com.cn/editor/zeroing/libs/svga.fd3923ae6e664251ca7981801a65809cc5f36bc3.js"></script>
<!-- <script src="//yun.duiba.com.cn/editor/zeroing/libs/engine.ebc906f6b50b8da0a669f77027981d5f3cb560ce.js"></script> -->
<!-- <script src="http://localhost:4002/debug/engine.js"></script>
<script src="http://localhost:4003/debug/engine-svga.js"></script> -->
<!--<script src="//yun.duiba.com.cn/editor/zeroing/libs/engine.9a9dbfda4cb2dd5508ecddfe3d95dfd88063f7b5.js"></script>-->
<script src="app.js"></script>
<script src="props.js"></script>
<script src="load-assets.js"></script>
<script src="main.js"></script>
<script>
</script>
</body>
\ No newline at end of file
/**
* Created by rockyl on 2020-01-21.
*/
const assets = [
// {
// "name": "循环背景1",
// "url": "//yun.duiba.com.cn/aurora/assets/a57af3e2092f421ebbb47ee7a3d30f4326b5b7cd.jpg",
// "uuid": "d95a5911-1c7c-4b60-9ff1-5cb179738e91",
// "ext": ".jpg"
// },
// {
// "name": "循环背景2",
// "url": "//yun.duiba.com.cn/aurora/assets/489de78a248456d9dee74d8106da3dae40c0268b.jpg",
// "uuid": "2222b6d9-17cb-42a6-a0f2-54c390522ca5",
// "ext": ".jpg"
// },
// {
// "name": "雨滴0",
// "url": "//yun.duiba.com.cn/aurora/assets/badb3627bbcc75276a3eed53daa8b0a454ced6eb.png",
// "uuid": "d3ce99da-89e1-447d-8c52-b3f391925c3c",
// "ext": ".png"
// },
// {
// "name": "雨滴1",
// "url": "//yun.duiba.com.cn/aurora/assets/5cc0092913c571eeb52317b8e1e0dc715793049c.png",
// "uuid": "02f17008-1d8d-4108-a0fc-03fbc71fd118",
// "ext": ".png"
// },
// {
// "name": "雨滴2",
// "url": "//yun.duiba.com.cn/aurora/assets/4b938949b85d50b36ef0f66450643495efbf7580.png",
// "uuid": "46aa4f8a-9a6c-4210-8ffd-92da0dd3bc75",
// "ext": ".png"
// },
// {
// "name": "炸弹",
// "url": "//yun.duiba.com.cn/aurora/assets/171e92283cd13c013ee1b76d28d252ff08815d47.png",
// "uuid": "eb88b42d-e151-4c1b-94b9-7c16f7bfac29",
// "ext": ".png"
// },
// {
// "name": "石块",
// "url": "//yun.duiba.com.cn/aurora/assets/99b0af0c59fe79a415a3f032149cfacc27e3ac2c.png",
// "uuid": "ab1bdabc-21ba-46bf-9299-6c638f766c88",
// "ext": ".png"
// },
// {
// "name": "水花",
// "url": "//yun.duiba.com.cn/aurora/assets/ac85f46bd6e47b729a4d16f91696e12d273cdc75.svga",
// "uuid": "cdd2268f-ad65-4b5e-a965-ee61b730da21",
// "ext": ".svga"
// },
// {
// "name": "石头svga",
// "url": "//yun.duiba.com.cn/aurora/assets/01aa6fcb33aa8231f075257026eab2f0aeb3c27a.svga",
// "uuid": "846a139d-0990-4db4-a323-f22379932ee4",
// "ext": ".svga"
// },
// {
// "name": "炸弹svga",
// "url": "//yun.duiba.com.cn/aurora/assets/862802a8173acc1bde28dd603c7ffd2ccc426700.svga",
// "uuid": "d7a3947b-7fcb-48f2-9ddf-2f075d37a619",
// "ext": ".svga"
// },
// {
// "name": "玩家翻船",
// "url": "//yun.duiba.com.cn/aurora/assets/1615916b51ec577afd09e2392ac8ee3fa32e6891.svga",
// "uuid": "6338498f-78ba-4d4b-a172-85755646baf7",
// "ext": ".svga"
// },
// {
// "name": "玩家滑动",
// "url": "//yun.duiba.com.cn/aurora/assets/790b67abcc05f1690dde2edae058d865ceb1fe6f.svga",
// "uuid": "59920d79-e5bf-46e0-a753-f4e7a1315a97",
// "ext": ".svga"
// },
// {
// "name": "玩家静止",
// "url": "//yun.duiba.com.cn/aurora/assets/db0130d36ef79865be9c753ea0627027f16341d8.png",
// "uuid": "4931d296-4421-4a2f-8299-7bab87407c72",
// "ext": ".png"
// }
];
function loadAssets(customModuleAssets, onProgress, onComplete){
return engine.loadAssets(assets.concat(...customModuleAssets), onProgress, onComplete);
}
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('tslib')) :
typeof define === 'function' && define.amd ? define(['tslib'], factory) :
(global = global || self, global['dragon-boat-race'] = factory(global.tslib));
}(this, (function (tslib) { 'use strict';
var props = {};
function prepareProps() {
var metaProps = getProps();
engine.injectProp(props, metaProps);
}
function injectProps(p) {
engine.injectProp(props, p);
}
//# sourceMappingURL=props.js.map
function getTexture(uuid) {
return engine.Texture.from(getAssetByUUID(uuid).uuid);
}
function getTextureByName(name) {
return getTexture(getAssetByName(name).uuid);
}
function createSvga(name, anchorName) {
var inst = new svga.Svga();
inst.source = 'asset://' + getAssetByName(name).uuid;
return inst;
}
//# sourceMappingURL=utils.js.map
var Goods = (function (_super) {
tslib.__extends(Goods, _super);
function Goods() {
var _this = _super.call(this) || this;
var body;
body = _this._body = new engine.Rect();
var rain = new engine.Sprite(getTextureByName('金币'));
var rain1 = new engine.Sprite(getTextureByName('粽子'));
rain["npcType"] = "rain0";
rain1["npcType"] = "rain1";
var stone = new engine.Sprite(getTextureByName('木头'));
stone["npcType"] = "stone";
var boom = new engine.Sprite(getTextureByName('石块'));
boom["npcType"] = "boom";
rain.visible = false;
rain1.visible = false;
stone.visible = false;
boom.visible = false;
rain.anchorX = rain.width / 2;
rain1.anchorX = rain1.width / 2;
stone.anchorX = stone.width / 2;
boom.anchorX = boom.width / 2;
rain.anchorY = rain.height / 2;
rain1.anchorY = rain1.height / 2;
stone.anchorY = stone.height / 2;
boom.anchorY = boom.height / 2;
body.addChild(rain);
body.addChild(rain1);
body.addChild(stone);
body.addChild(boom);
_this.addChild(body);
body.width = .0001;
body.height = .0001;
body.mouseEnabled = false;
return _this;
}
Goods.prototype.getRandomNumberByRange = function (start, end) {
return Math.floor(Math.random() * (end - start) + start);
};
Goods.prototype.reset = function () {
this["lifeState"] = true;
this.visible = true;
this.rotation = 0;
this.anchorOffsetY = 0;
if (this.width <= 0) {
this.anchorX = 50;
}
else {
this.anchorX = this.width / 2;
}
this.anchorY = this.height / 2;
this.scaleX = this.scaleY = 1;
this.y = 0;
this.x = ((750 - props.maxNpcBound) - 120) * Math.random() + 30 + props.maxNpcBound;
this.rotation = 0;
var random = Math.random();
if (typeof (props.goodsProbability) == 'string') {
props.goodsProbability = props.goodsProbability.split(',').map(function (i) { return +i; });
console.log(props.goodsProbability);
}
if (random < props.goodsProbability[0]) {
this.showNpc("rain0");
}
else if (random >= props.goodsProbability[0] && random <= (props.goodsProbability[0] + props.goodsProbability[1])) {
this.showNpc("rain1");
}
else if (random >= (props.goodsProbability[0] + props.goodsProbability[1]) && random <= (props.goodsProbability[0] + props.goodsProbability[1] + props.goodsProbability[2])) {
this.showNpc("stone");
}
else if (random > (props.goodsProbability[0] + props.goodsProbability[1] + props.goodsProbability[2])) {
this.showNpc("boom");
}
};
Goods.prototype.showNpc = function (type) {
for (var i = 0; i < this._body.children.length; i++) {
this._body.children[i].visible = false;
this._body.children[i].mouseEnabled = false;
}
for (var i = 0; i < this._body.children.length; i++) {
if (this._body.children[i]["npcType"] == type) {
this["npcType"] = type;
this._body.children[i].visible = true;
this._body.children[i].mouseEnabled = false;
}
}
};
Object.defineProperty(Goods.prototype, "anchorOffsetY", {
set: function (v) {
this._body.y = v;
},
enumerable: true,
configurable: true
});
return Goods;
}(engine.Container));
//# sourceMappingURL=Goods.js.map
var ObjectPool = engine.ObjectPool;
var PoolName = 'goods';
ObjectPool.registerPool(PoolName, function () {
return new Goods();
}, function (item, data) {
item.reset();
});
//# sourceMappingURL=object-pool-init.js.map
var ObjectPool$1 = engine.ObjectPool;
var GameView = (function (_super) {
tslib.__extends(GameView, _super);
function GameView() {
var _this = _super.call(this) || this;
_this.goodsItems = [];
_this.moveCatchX = 0;
_this.playerCatchX = 0;
_this.onDownStage = function (e) {
_this.moveCatchX = e.localX;
_this.playerCatchX = _this.player.x;
};
_this.onMoveStage = function (e) {
var maxStageBound = props.maxStageBound;
if (_this.gameIng) {
var playerX = _this.playerCatchX + (e.localX - _this.moveCatchX);
if (playerX < maxStageBound) {
_this.player.x = maxStageBound;
}
else if (playerX + _this.player.width + maxStageBound > 750) {
_this.player.x = 750 - maxStageBound - _this.player.width;
}
else {
_this.player.x = playerX;
}
}
};
_this.onOutStage = function (e) {
_this.moveCatchX = 0;
};
_this.once(engine.Event.ADDED_TO_STAGE, _this.setup, _this);
return _this;
}
GameView.prototype.setup = function () {
var _this = this;
if (this._hasSetup) {
return;
}
this._hasSetup = true;
this.bg = new engine.Container();
this.bg.mouseEnabled = false;
this.addChild(this.bg);
this.NpcBg = new engine.Container();
this.NpcBg.alpha = 1;
this.NpcBg.width = 0;
this.NpcBg.height = 0;
this.addChild(this.NpcBg);
this.player = new engine.Container();
this.player.mouseEnabled = false;
this.player.mouseChildren = false;
this.labelScore = new engine.BitmapText();
this.labelScore.font = props.fontName;
this.labelScore.scaleX = this.labelScore.scaleY = 1;
this.addChild(this.labelScore);
this.waterSvga = createSvga("碰到金币svga");
this.water2Svga = createSvga("碰到粽子svga");
this.boomSvga = createSvga("碰到石头svga");
this.playerSvgaReset = new engine.Sprite(getTextureByName('玩家静止'));
this.playerSvgaRun = createSvga("玩家滑动");
this.playerSvgaOver = createSvga("玩家翻船");
this.bg1 = new engine.Sprite(getTextureByName('循环背景1'));
this.bg2 = new engine.Sprite(getTextureByName('循环背景2'));
this.bg3 = new engine.Sprite(getTextureByName('循环背景1'));
this.bg4 = new engine.Sprite(getTextureByName('循环背景2'));
this.player.addChild(this.playerSvgaReset);
this.player.addChild(this.playerSvgaRun);
this.player.addChild(this.playerSvgaOver);
this.addChild(this.waterSvga);
this.addChild(this.water2Svga);
this.addChild(this.boomSvga);
this.addChild(this.player);
this.bg.addChild(this.bg1);
this.bg.addChild(this.bg2);
this.bg.addChild(this.bg3);
this.bg.addChild(this.bg4);
this.waterSvga.visible = false;
this.water2Svga.visible = false;
this.boomSvga.visible = false;
this.setPlayState(this.playerSvgaReset);
this.visible = false;
setTimeout(function () {
_this.visible = true;
_this.player.x = props.playerPositionX;
_this.player.y = props.playerPositionY;
_this.playerSvgaRun.x = props.playerRunPosition3Offset[0];
_this.playerSvgaRun.y = props.playerRunPosition3Offset[1];
_this.playerSvgaOver.x = props.playerOverPosition3Offset[0];
_this.playerSvgaOver.y = props.playerOverPosition3Offset[1];
_this.bg1.y = 0;
_this.bg2.y = _this.bg1.height;
_this.bg3.y = _this.bg1.height + _this.bg2.height;
_this.bg4.y = _this.bg1.height + _this.bg2.height + _this.bg3.height;
engine.Tween.get(_this.playerSvgaReset, { loop: true })
.to({ y: 10 }, 500)
.to({ y: 0 }, 500)
.to({ y: 10 }, 500)
.call(function () { });
}, 300);
this.rectBg = new engine.Container();
this.rectBg.alpha = 0;
this.rectBg.width = 750;
this.rectBg.height = 1624;
this.addChild(this.rectBg);
this.rectBg.addEventListener(engine.MouseEvent.MOUSE_DOWN, this.onDownStage, this);
this.rectBg.addEventListener(engine.MouseEvent.MOUSE_MOVE, this.onMoveStage, this);
this.rectBg.addEventListener(engine.MouseEvent.MOUSE_OUT, this.onOutStage, this);
this.rectBg.addEventListener(engine.Event.ENTER_FRAME, this.enterFrame, this);
};
GameView.prototype.setBoomPosition = function (svga, callback) {
svga.x = this.player.x;
svga.y = this.player.y;
if (svga == this.waterSvga) {
svga.x += props.boomPosition1Offset[0];
svga.y += props.boomPosition1Offset[1];
}
else if (svga == this.water2Svga) {
svga.x += props.boomPosition2Offset[0];
svga.y += props.boomPosition2Offset[1];
}
else if (svga == this.boomSvga) {
svga.x += props.boomPosition3Offset[0];
svga.y += props.boomPosition3Offset[1];
}
svga.visible = true;
svga.play(true, false);
svga.once(engine.Event.END_FRAME, function () {
svga.visible = false;
if (callback) {
callback();
}
}, this);
};
GameView.prototype.enterFrame = function () {
if (this.bg.y >= 0) {
this.bg.y = -this.bg3.y;
}
if (this.gameIng) {
this.bg.y += (4 * this.speed);
}
};
GameView.prototype.reset = function () {
this.recycleGoods();
this.score = 0;
this.speed = props.speed;
this.bg.y = -this.bg3.y;
this.player.anchorY = this.player.height / 2;
this.player.anchorX = this.player.width / 2;
this.player.x = props.playerPositionX;
this.player.y = props.playerPositionY;
this.setPlayState(this.playerSvgaReset);
};
GameView.prototype.setPlayState = function (svga) {
this.playerSvgaReset.visible = false;
this.playerSvgaRun.visible = false;
this.playerSvgaOver.visible = false;
console.log(svga);
svga.visible = true;
if (svga == this.playerSvgaOver) {
svga.play(false, false);
svga.once(engine.Event.END_FRAME, function () {
}, this);
}
else if (svga == this.playerSvgaRun) {
svga.play();
}
};
GameView.prototype.start = function () {
var _this = this;
this.gameIng = true;
this.creatNpc();
this.beginNpc();
this.countdown = props.countDown;
this.setPlayState(this.playerSvgaRun);
this.countdownTimer = setInterval(function () {
if (_this.gameIng) {
if (_this.countdown > 0) {
engine.globalEvent.dispatchEvent('dragon-boat-race-time-update', {
time: _this.countdown,
});
_this.countdown -= 1;
}
else {
engine.globalEvent.dispatchEvent('dragon-boat-race-game-over', {
score: _this.score,
reason: 1
});
_this.died();
}
_this.score += Math.round(_this.speed * props.runScore);
engine.globalEvent.dispatchEvent('dragon-boat-race-score-update', {
score: _this.score,
});
}
}, 1000);
};
GameView.prototype.beginNpc = function () {
var _this = this;
this.timer = setTimeout(function () {
if (_this.gameIng) {
_this.speed += props.acceleratedSpeed;
_this.speed += props.acceleratedSpeed;
if (_this.speed > props.maxSpeed) {
_this.speed = props.maxSpeed;
}
_this.creatNpc();
}
_this.beginNpc();
}, 2000 / this.speed);
};
GameView.prototype.pause = function () {
this.gameIng = false;
};
GameView.prototype.revive = function () {
this.gameIng = true;
};
GameView.prototype.resume = function () {
this.reset();
this.start();
};
GameView.prototype.creatNpc = function () {
var _this = this;
var goods = this._goods = ObjectPool$1.getObject(PoolName);
this.goodsItems.push(goods);
this.NpcBg.addChild(goods);
goods.addEventListener(engine.Event.ENTER_FRAME, goods["onGoodsEnter"] = function () {
if (goods.y > 1624) {
_this.removeNpc(goods);
}
else {
if (_this.gameIng) {
goods.y += (4 * _this.speed);
if (goods["lifeState"] && _this.hasHit(_this.player, goods)) {
goods["lifeState"] = false;
if (goods["npcType"] == "rain0") {
console.log("碰到雨滴");
_this.score += props.rainScore;
if (_this.score < 0) {
_this.score = 0;
}
_this.setBoomPosition(_this.waterSvga);
engine.Tween.get(goods, null, null, true)
.to({ scaleX: 0, scaleY: 0 }, 200)
.call(function () { _this.removeNpc(goods); });
}
else if (goods["npcType"] == "rain1") {
console.log("碰到雨滴");
_this.score += props.rain2Score;
if (_this.score < 0) {
_this.score = 0;
}
_this.setBoomPosition(_this.water2Svga);
engine.Tween.get(goods, null, null, true)
.to({ scaleX: 0, scaleY: 0 }, 200)
.call(function () { _this.removeNpc(goods); });
}
else if (goods["npcType"] == "boom" || goods["npcType"] == "stone") {
console.log("碰到炸弹");
_this.setBoomPosition(_this.boomSvga, function () {
engine.globalEvent.dispatchEvent('dragon-boat-race-game-over', {
score: _this.score,
reason: 2
});
_this.died();
});
_this.setPlayState(_this.playerSvgaOver);
_this.pause();
}
engine.globalEvent.dispatchEvent('dragon-boat-race-score-update', {
score: _this.score,
});
}
}
}
}, this);
};
GameView.prototype.died = function () {
this.score = 0;
this.pause();
};
GameView.prototype.removeNpc = function (goods) {
this.NpcBg.removeChild(goods);
ObjectPool$1.recycleObject(PoolName, goods);
goods.removeEventListener(engine.Event.ENTER_FRAME, goods["onGoodsEnter"], this);
var index = this.goodsItems.indexOf(goods);
if (index > -1) {
this.goodsItems.splice(index, 1);
}
};
GameView.prototype.recycleGoods = function () {
clearTimeout(this.timer);
clearInterval(this.countdownTimer);
for (var _i = 0, _a = this.goodsItems; _i < _a.length; _i++) {
var goods = _a[_i];
if (goods) {
this.NpcBg.removeChild(goods);
ObjectPool$1.recycleObject(PoolName, goods);
goods.removeEventListener(engine.Event.ENTER_FRAME, goods["onGoodsEnter"], this);
}
}
this.goodsItems = [];
};
GameView.prototype.hasHit = function (a, b) {
var playerH = a.height;
var playerW = a.width;
var playerX = a.x;
if (props.playerHeight) {
playerH = props.playerHeight;
}
if (props.playerWidth) {
playerW = props.playerWidth;
playerX = a.x + (a.width - props.playerWidth) / 2;
}
if (Math.abs((playerX + playerW / 2) - (b.x + b.width / 2)) < playerW / 2 + b.width / 2
&&
Math.abs((a.y + playerH / 1.3) - (b.y + b.height / 2)) < playerH / 2 + b.height / 2) {
return true;
}
else {
return false;
}
};
return GameView;
}(engine.Container));
var GameWrapper = (function (_super) {
tslib.__extends(GameWrapper, _super);
function GameWrapper() {
var _this = _super.call(this) || this;
engine.globalEvent.addEventListener('dragon-boat-race-reset', _this.reset, _this);
engine.globalEvent.addEventListener('dragon-boat-race-start', _this.start, _this);
engine.globalEvent.addEventListener('dragon-boat-race-pause', _this.pause, _this);
engine.globalEvent.addEventListener('dragon-boat-race-resume', _this.resume, _this);
engine.globalEvent.addEventListener('dragon-boat-race-revive', _this.revive, _this);
engine.globalEvent.addEventListener('dragon-boat-race-clear', _this.clear, _this);
_this.addEventListener(engine.MouseEvent.CLICK, _this.onTap, _this);
var gameView = _this._gameView = new GameView();
_this.addChild(gameView);
return _this;
}
GameWrapper.prototype.reset = function (event) {
injectProps(event.data);
this._gameView.visible = true;
this._gameView.reset();
};
GameWrapper.prototype.start = function (event) {
injectProps(event.data);
this._status = 1;
this._gameView.start();
};
GameWrapper.prototype.pause = function () {
this._gameView.pause();
};
GameWrapper.prototype.resume = function () {
this._gameView.resume();
};
GameWrapper.prototype.revive = function () {
this._gameView.revive();
};
GameWrapper.prototype.clear = function () {
this._gameView.visible = false;
};
GameWrapper.prototype.onTap = function (event) {
};
return GameWrapper;
}(engine.Container));
//# sourceMappingURL=GameWrapper.js.map
function index (props) {
prepareProps();
injectProps(props);
var instance = new GameWrapper();
return instance;
}
//# sourceMappingURL=index.js.map
return index;
})));
//# sourceMappingURL=main.js.map
\ No newline at end of file
{"version":3,"file":"index.js","sources":["src/custom/dragon-boat-race/src/props.ts","src/custom/dragon-boat-race/src/game/utils.ts","src/custom/dragon-boat-race/src/game/Goods.ts","src/custom/dragon-boat-race/src/game/object-pool-init.ts","src/custom/dragon-boat-race/src/game/GameView.ts","src/custom/dragon-boat-race/src/game/GameWrapper.ts","src/custom/dragon-boat-race/src/index.ts"],"sourcesContent":["/**\n * Created by rockyl on 2020-01-21.\n */\n\nexport let props: any = {};\n\nexport function prepareProps() {\n\tlet metaProps = getProps();\n\n\tengine.injectProp(props, metaProps);\n}\n\nexport function injectProps(p) {\n\tengine.injectProp(props, p);\n}\n","/**\n * Created by rockyl on 2020-01-21.\n */\n\nexport function getTexture(uuid) {\n\treturn engine.Texture.from(getAssetByUUID(uuid).uuid);\n}\n\nexport function getTextureByName(name) {\n\treturn getTexture(getAssetByName(name).uuid);\n}\n\nexport function playSound(name) {\n\tengine.playSound(getAssetByName(name).uuid, {keep: true});\n}\nexport function createSvga(name, anchorName?) {\n\tlet inst = new svga.Svga();\n\tinst.source = 'asset://' + getAssetByName(name).uuid;\n\treturn inst;\n}","/**\n * Created by rockyl on 2020-02-02.\n *\n * 掉落物品\n */\nimport {getTextureByName} from \"./utils\";\nimport {props} from \"../props\";\n\nexport class Goods extends engine.Container {\n\tprivate _body:engine.Rect\n\tprivate _toY;\n\n\tconstructor() {\n\t\tsuper();\n\n\t\tlet body\n\t\tbody = this._body =new engine.Rect()\n\t\t\n\t\t// let randomNum = Math.floor(Math.random() * 3)\t\t\n\t\t// console.log('雨滴' + randomNum);\n\t\t\n\t\tlet rain = new engine.Sprite(getTextureByName('金币'));\n\t\tlet rain1 = new engine.Sprite(getTextureByName('粽子'));\n\t\train[\"npcType\"]=\"rain0\"\n\t\train1[\"npcType\"]=\"rain1\"\n\t\tlet stone = new engine.Sprite(getTextureByName('木头'));\n\t\tstone[\"npcType\"]=\"stone\"\n\t\tlet boom = new engine.Sprite(getTextureByName('石块'));\n\t\tboom[\"npcType\"]=\"boom\"\n\n\t\train.visible=false;\n\t\train1.visible=false;\n\t\tstone.visible=false;\n\t\tboom.visible=false;\n\n\t\train.anchorX=rain.width/2\n\t\train1.anchorX=rain1.width/2\n\t\tstone.anchorX=stone.width/2\n\t\tboom.anchorX=boom.width/2\n\n\t\train.anchorY=rain.height/2\n\t\train1.anchorY=rain1.height/2\n\t\tstone.anchorY=stone.height/2\n\t\tboom.anchorY=boom.height/2\n\n\t\tbody.addChild(rain)\n\t\tbody.addChild(rain1)\n\t\tbody.addChild(stone)\n\t\tbody.addChild(boom)\n\t\t\n\t\tthis.addChild(body);\n\t\tbody.width=.0001;\n\t\tbody.height=.0001;\n\t\tbody.mouseEnabled=false;\n\t}\n\n\n\tgetRandomNumberByRange(start, end) {\n\t\treturn Math.floor(Math.random() * (end - start) + start)\n\t}\n\n\treset() {\n\t\tthis[\"lifeState\"]=true;\n\t\tthis.visible = true;\n\t\tthis.rotation = 0;\n\t\tthis.anchorOffsetY = 0;\n\t\tif(this.width<=0){\n\t\t\tthis.anchorX=50;\n\t\t}else{\n\t\t\tthis.anchorX=this.width/2;\n\t\t}\n\t\t\n\t\tthis.anchorY=this.height/2;\n\t\tthis.scaleX=this.scaleY=1;\n\t\tthis.y = 0;\n\t\tthis.x = ((750-props.maxNpcBound)-120)*Math.random()+30+props.maxNpcBound;\n\t\tthis.rotation = 0;\n\t\tlet random=Math.random()\n\t\tif(typeof (props.goodsProbability) == 'string'){\n\t\t\tprops.goodsProbability=props.goodsProbability.split(',').map((i: string) => +i)\n\t\t\tconsole.log(props.goodsProbability);\n\t\t}\n\t\tif(random<props.goodsProbability[0]){\n\t\t\tthis.showNpc(\"rain0\")\n\t\t}else if(random>=props.goodsProbability[0]&&random<=(props.goodsProbability[0]+props.goodsProbability[1])){\n\t\t\tthis.showNpc(\"rain1\")\n\t\t}else if(random>=(props.goodsProbability[0]+props.goodsProbability[1])&&random<=(props.goodsProbability[0]+props.goodsProbability[1]+props.goodsProbability[2])){\n\t\t\tthis.showNpc(\"stone\")\n\t\t}else if(random>(props.goodsProbability[0]+props.goodsProbability[1]+props.goodsProbability[2])){\n\t\t\tthis.showNpc(\"boom\")\n\t\t}\n\t}\n\n\n\tshowNpc(type){\n\t\tfor(let i=0;i<this._body.children.length;i++){\n\t\t\tthis._body.children[i].visible=false;\n\t\t\tthis._body.children[i].mouseEnabled=false;\n\t\t}\t\t\n\t\tfor(let i=0;i<this._body.children.length;i++){\n\t\t\tif(this._body.children[i][\"npcType\"]==type){\n\t\t\t\tthis[\"npcType\"]=type\n\t\t\t\tthis._body.children[i].visible=true;\n\t\t\t\tthis._body.children[i].mouseEnabled=false;\n\t\t\t}\n\t\t}\n\t\t\n\t}\n\n\tset anchorOffsetY(v) {\n\t\tthis._body.y = v;\n\t}\n}\n","/**\n * Created by rockyl on 2020-02-03.\n */\n\nimport {Goods} from \"./Goods\";\nimport ObjectPool = engine.ObjectPool;\n\nexport const PoolName: string = 'goods';\n\nObjectPool.registerPool(PoolName, function () {\n\treturn new Goods();\n}, function (item: Goods, data) {\n\titem.reset();\n});\n","/**\n * Created by rockyl on 2018/8/16.\n */\n\nimport { props } from \"../props\";\nimport { playSound, createSvga } from \"./utils\";\nimport ObjectPool = engine.ObjectPool;\nimport { getTextureByName } from \"./utils\";\nimport { Goods } from \"./Goods\";\nimport { PoolName } from \"./object-pool-init\";\n\n\n\nexport default class GameView extends engine.Container {\n\n\tprivate _hasSetup;\n\n\t//玩家\n\tprivate player: engine.Container;\n\t//触摸层\n\t// private rectBg: engine.Rect;\n\tprivate rectBg: engine.Container;\n\t//npc层\n\tprivate NpcBg: engine.Container;\n\n\t//当前分数\n\tprivate score\n\n\t//游戏状态\n\tprivate gameIng;\n\n\t//npc出身计时器\n\tprivate timer\n\t//倒计时计时器\n\tprivate countdownTimer: any\n\t//倒计时\n\tprivate countdown: number\n\n\t//当前速度\n\tprivate speed: number\n\n\t// 当前场景上面的物品\n\tprivate goodsItems = []\n\n\n\tprivate _goods: Goods;\n\n\tconstructor() {\n\t\tsuper();\n\t\tthis.once(engine.Event.ADDED_TO_STAGE, this.setup, this);\n\t}\n\n\tprivate waterSvga\n\tprivate water2Svga\n\tprivate boomSvga\n\tprivate playerSvgaReset\n\tprivate playerSvgaRun\n\tprivate playerSvgaOver\n\tprivate bg1\n\tprivate bg2\n\tprivate bg3\n\tprivate bg4\n\tprivate bg\n\tprivate labelScore\n\t\n\n\n\tsetup() {\n\t\tif (this._hasSetup) {\n\t\t\treturn;\n\t\t}\n\t\tthis._hasSetup = true;\n\n\t\tthis.bg = new engine.Container();\n\t\tthis.bg.mouseEnabled = false;\n\t\tthis.addChild(this.bg);\n\n\t\tthis.NpcBg = new engine.Container();\n\t\tthis.NpcBg.alpha = 1;\n\t\tthis.NpcBg.width = 0;\n\t\tthis.NpcBg.height = 0;\n\t\tthis.addChild(this.NpcBg);\n\n\t\tthis.player = new engine.Container();\n\t\tthis.player.mouseEnabled=false;\n\t\tthis.player.mouseChildren=false\n\t//\tthis.player.fillColor=\"rgba(0, 0, 0,1)\"\n\t\t//console.log(this.player.fillColor)\n\n\t\t//创建文字\n\t\tthis.labelScore = new engine.BitmapText();\n\t\tthis.labelScore.font = props.fontName;\n\t\tthis.labelScore.scaleX = this.labelScore.scaleY = 1;\n\t\tthis.addChild(this.labelScore);\n\t\n\t\n\n\t\tthis.waterSvga=createSvga(\"碰到金币svga\")\n\t\tthis.water2Svga=createSvga(\"碰到粽子svga\")\n\t\tthis.boomSvga=createSvga(\"碰到石头svga\")\n\t\t// this.playerSvga=createSvga(\"玩家\")\n\t\tthis.playerSvgaReset= new engine.Sprite(getTextureByName('玩家静止'))\n\t\tthis.playerSvgaRun= createSvga(\"玩家滑动\")\n\t\tthis.playerSvgaOver= createSvga(\"玩家翻船\")\n\t\tthis.bg1= new engine.Sprite(getTextureByName('循环背景1'))\n\t\tthis.bg2= new engine.Sprite(getTextureByName('循环背景2'))\n\t\tthis.bg3= new engine.Sprite(getTextureByName('循环背景1'))\n\t\tthis.bg4= new engine.Sprite(getTextureByName('循环背景2'))\n\t\tthis.player.addChild(this.playerSvgaReset);\n\t\tthis.player.addChild(this.playerSvgaRun);\n\t\tthis.player.addChild(this.playerSvgaOver);\n\t\t this.addChild(this.waterSvga);\n\t\t this.addChild(this.water2Svga);\n\t\t this.addChild(this.boomSvga);\n\t\t this.addChild(this.player);\n\t\tthis.bg.addChild(this.bg1);\n\t\tthis.bg.addChild(this.bg2);\n\t\tthis.bg.addChild(this.bg3);\n\t\tthis.bg.addChild(this.bg4);\n\t\t\n\t\t// this.playerSvga.gotoAndPlay(1);\n\n\t\tthis.waterSvga.visible = false\n\t\tthis.water2Svga.visible = false\n\t\tthis.boomSvga.visible = false\n\t\tthis.setPlayState(this.playerSvgaReset)\n\t\t\n\t\tthis.visible=false;\n\t\tsetTimeout(()=>{\n\t\t\tthis.visible=true;\n\t\t\t//this.player.anchorY = this.player.height / 2;\n\t\t//\tthis.player.anchorX = this.player.width / 2;\n\t\t\tthis.player.x = props.playerPositionX;\n\t\t\tthis.player.y = props.playerPositionY;\n\n\t\t\t// this.stoneSvga.x = this.player.width / 2 - \tthis.stoneSvga.width/2 + props.boomPosition1Offset[0];\n\t\t\t// this.stoneSvga.y = this.player.height / 2 - this.stoneSvga.height/2 + props.boomPosition1Offset[1];\n\n\t\t\t// this.waterSvga.x = this.player.width / 2 - \tthis.waterSvga.width/2+ props.boomPosition2Offset[0];\n\t\t\t// this.waterSvga.y = this.player.height / 2 - this.waterSvga.height/2 + props.boomPosition2Offset[1];\n\n\t\t\t// this.boomSvga.x = this.player.width / 2 - \tthis.boomSvga.width/2+ props.boomPosition3Offset[0];\n\t\t\t// this.boomSvga.y = this.player.height / 2 - this.boomSvga.height/2 + props.boomPosition3Offset[1];\n\n\n\t\t\tthis.playerSvgaRun.x=props.playerRunPosition3Offset[0]\n\t\t\tthis.playerSvgaRun.y=props.playerRunPosition3Offset[1]\n\n\t\t\tthis.playerSvgaOver.x=props.playerOverPosition3Offset[0]\n\t\t\tthis.playerSvgaOver.y=props.playerOverPosition3Offset[1]\n\n\t\t\tthis.bg1.y=0\n\t\t\tthis.bg2.y=this.bg1.height\n\t\t\tthis.bg3.y=this.bg1.height+this.bg2.height\n\t\t\tthis.bg4.y=this.bg1.height+this.bg2.height+this.bg3.height\n\n\t\t\tengine.Tween.get(this.playerSvgaReset, {loop:true})\n\t\t\t.to({y:10}, 500)\n\t\t\t.to({y:0}, 500)\n\t\t\t.to({y:10}, 500)\n\t\t\t.call(()=>{});\n\n\t\t\t// this.stoneSvga.x=props.boomPositionOffset[0]\n\t\t\t// this.stoneSvga.y=props.boomPositionOffset[1]\n\n\t\t\t// this.waterSvga.x=props.boomPositionOffset[0]\n\t\t\t// this.waterSvga.y=props.boomPositionOffset[1]\n\n\t\t\t// this.boomSvga.x=props.boomPositionOffset[0]\n\t\t\t// this.boomSvga.y=props.boomPositionOffset[1]\n\n\t\t\t\n\t\t},300)\n\n\t\t\n\t\tthis.rectBg = new engine.Container();\n\t\tthis.rectBg.alpha = 0;\n\t\tthis.rectBg.width = 750;\n\t\tthis.rectBg.height = 1624;\n\t\tthis.addChild(this.rectBg)\n\n\t\tthis.rectBg.addEventListener(engine.MouseEvent.MOUSE_DOWN, this.onDownStage, this);\n\t\tthis.rectBg.addEventListener(engine.MouseEvent.MOUSE_MOVE, this.onMoveStage, this);\n\t\tthis.rectBg.addEventListener(engine.MouseEvent.MOUSE_OUT, this.onOutStage, this);\n\t\tthis.rectBg.addEventListener(engine.Event.ENTER_FRAME, this.enterFrame, this);\n\t\n\t}\n\n\n\tsetBoomPosition(svga,callback?){\n\t\tsvga.x=this.player.x;\n\t\tsvga.y=this.player.y;\n\t\tif(svga==this.waterSvga){\n\t\t\tsvga.x+=props.boomPosition1Offset[0]\n\t\t\tsvga.y+=props.boomPosition1Offset[1]\n\t\t}else if(svga==this.water2Svga){\n\t\t\tsvga.x+=props.boomPosition2Offset[0]\n\t\t\tsvga.y+=props.boomPosition2Offset[1]\n\t\t}else if(svga==this.boomSvga){\n\t\t\tsvga.x+=props.boomPosition3Offset[0]\n\t\t\tsvga.y+=props.boomPosition3Offset[1]\n\t\t} \n\n\t\tsvga.visible=true;\n\t\tsvga.play(true,false)\n\t\tsvga.once(engine.Event.END_FRAME, ()=>{\n\t\t\tsvga.visible=false;\n\t\t\tif(callback){\n\t\t\t\tcallback()\n\t\t\t}\t\t\n\t\t}, this);\n\n\t}\n\n\tenterFrame(){\n\t\tif(this.bg.y>=0){\n\t\t\tthis.bg.y=-this.bg3.y\n\t\t}\n\t\tif(this.gameIng){\n\t\t\tthis.bg.y += (4 * this.speed)\n\t\t}\n\t}\n\n\n\t/**\n\t * 重置场景\n\t */\n\treset() {\n\t\tthis.recycleGoods()\n\t\tthis.score = 0;\n\t\tthis.speed = props.speed;\n\t\tthis.bg.y=-this.bg3.y\n\n\t\tthis.player.anchorY = this.player.height / 2;\n\t\tthis.player.anchorX = this.player.width / 2;\n\t\tthis.player.x = props.playerPositionX;\n\t\tthis.player.y = props.playerPositionY;\n\t\tthis.setPlayState(this.playerSvgaReset)\n\t}\n\n\n\tsetPlayState(svga){\n\t\tthis.playerSvgaReset.visible=false\n\t\tthis.playerSvgaRun.visible=false\n\t\tthis.playerSvgaOver.visible=false\n\t\tconsole.log(svga)\n\t\tsvga.visible=true;\n if(svga==this.playerSvgaOver){\n\t\t\tsvga.play(false, false)\n\t\t\tsvga.once(engine.Event.END_FRAME, ()=>{\n\t\t\t}, this);\n\t\t}else if(svga==this.playerSvgaRun){\n\t\t\tsvga.play()\n\t\t}\n\t}\n\n\t/**\n\t * 开始\n\t */\n\tstart() {\n\t\tthis.gameIng = true;\n\t\tthis.creatNpc()\n\t\tthis.beginNpc()\n\t\tthis.countdown = props.countDown;\n\t\tthis.setPlayState(this.playerSvgaRun)\n\t\n\t\tthis.countdownTimer = setInterval(() => {\n\t\t\tif (this.gameIng) {\n\t\t\t\tif (this.countdown > 0) {\n\t\t\t\t\tengine.globalEvent.dispatchEvent('dragon-boat-race-time-update', {\n\t\t\t\t\t\ttime: this.countdown,\n\t\t\t\t\t});\n\t\t\t\t\tthis.countdown -= 1\n\t\t\t\t} else {\n\t\t\t\t\tengine.globalEvent.dispatchEvent('dragon-boat-race-game-over', {\n\t\t\t\t\t\tscore: this.score,\n\t\t\t\t\t\treason: 1\n\t\t\t\t\t});\n\t\t\t\t\tthis.died()\n\t\t\t\t}\n\t\t\t\tthis.score += Math.round(this.speed*props.runScore);\n\t\t\t\tengine.globalEvent.dispatchEvent('dragon-boat-race-score-update', {\n\t\t\t\t\tscore: this.score,\n\t\t\t\t});\n\t\t\t}\n\t\t}, 1000)\n\t}\n\n\t/**\n\t * npc开始掉落\n\t */\n\tbeginNpc() {\n\t\tthis.timer = setTimeout(() => {\n\t\t\tif (this.gameIng) {\n\t\t\t\tthis.speed += props.acceleratedSpeed;\n\t\t\t\tthis.speed += props.acceleratedSpeed;\n\t\t\t\tif(this.speed>props.maxSpeed){\n\t\t\t\t\tthis.speed=props.maxSpeed\n\t\t\t\t}\n\t\t\t\tthis.creatNpc()\n\t\t\t}\n\t\t\t//递归执行\n\t\t\tthis.beginNpc()\n\t\t}, 2000 / this.speed)\n\t}\n\n\t/**\n\t * 暂停\n\t */\n\tpause() {\n\t\tthis.gameIng = false;\n\t}\n\n\t/**\n\t * 恢复\n\t */\n\trevive() {\n\t\tthis.gameIng = true;\n\t}\n\n\t/**\n\t * 重新开始\n\t */\n\tresume() {\n\t\tthis.reset()\n\t\tthis.start()\n\t}\n\n\t/**\n\t * 创建NPC\n\t */\n\tprivate creatNpc() {\n\t\tlet goods = this._goods = <Goods>ObjectPool.getObject(PoolName);\n\t\tthis.goodsItems.push(goods)\n\t\t//console.log(goods);\n\t\t\n\t\tthis.NpcBg.addChild(goods);\n\t\tgoods.addEventListener(engine.Event.ENTER_FRAME, goods[\"onGoodsEnter\"] = () => {\n\t\t\tif (goods.y > 1624) {\n\t\t\t\tthis.removeNpc(goods)\n\t\t\t} else {\n\t\t\t\tif (this.gameIng) {\n\t\t\t\t\t//速度叠加\n\t\t\t\t\tgoods.y += (4 * this.speed)\n\t\t\t\t\t//如果玩家和物品发生碰撞\n\t\t\t\t\tif (goods[\"lifeState\"]&&this.hasHit(this.player, goods)) {\n\t\t\t\t\t\tgoods[\"lifeState\"]=false;\n\t\t\t\t\t\tif (goods[\"npcType\"] == \"rain0\") {\n\t\t\t\t\t\t\tconsole.log(\"碰到雨滴\")\n\t\t\t\t\t\t\tthis.score += props.rainScore\n\t\t\t\t\t\t\tif(this.score<0){\n\t\t\t\t\t\t\t\tthis.score=0;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tthis.setBoomPosition(this.waterSvga)\n\t\t\t\t\t\t\t engine.Tween.get(goods, null, null, true)\n\t\t\t\t\t\t\t .to({scaleX: 0,scaleY:0}, 200)\n\t\t\t\t\t\t\t .call(()=>{this.removeNpc(goods)});\n\t\t\t\t\t\t\n\n\t\t\t\t\t\t}else if (goods[\"npcType\"] == \"rain1\") {\n\t\t\t\t\t\t\tconsole.log(\"碰到雨滴\")\n\t\t\t\t\t\t\tthis.score += props.rain2Score\n\t\t\t\t\t\t\tif(this.score<0){\n\t\t\t\t\t\t\t\tthis.score=0;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tthis.setBoomPosition(this.water2Svga)\n\t\t\t\t\t\t\t engine.Tween.get(goods, null, null, true)\n\t\t\t\t\t\t\t .to({scaleX: 0,scaleY:0}, 200)\n\t\t\t\t\t\t\t .call(()=>{this.removeNpc(goods)});\n\n\t\t\t\t\t\t} else if (goods[\"npcType\"] == \"boom\"||goods[\"npcType\"] == \"stone\") {\n\t\t\t\t\t\t\tconsole.log(\"碰到炸弹\")\n\t\t\t\t\t\t\tthis.setBoomPosition(this.boomSvga,()=>{\n\t\t\t\t\t\t\t\tengine.globalEvent.dispatchEvent('dragon-boat-race-game-over', {\n\t\t\t\t\t\t\t\t\tscore: this.score,\n\t\t\t\t\t\t\t\t\treason: 2\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\tthis.died()\n\t\t\t\t\t\t\t})\n\t\t\t\t\t\t\tthis.setPlayState(this.playerSvgaOver)\n\t\t\t\t\t\t\tthis.pause()\n\t\t\t\t\t\t\n\t\t\t\t\t\t}\n\t\t\t\t\t\tengine.globalEvent.dispatchEvent('dragon-boat-race-score-update', {\n\t\t\t\t\t\t\tscore: this.score,\n\t\t\t\t\t\t});\n\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t}, this);\n\t}\n\n\t/**\n\t * 玩家死亡\n\t */\n\tprivate died() {\n\t\tthis.score = 0\n\t\tthis.pause()\n\t}\n\n\t/**\n\t * 回收指定物品\n\t * @param goods 物品\n\t */\n\tprivate removeNpc(goods) {\n\t\tthis.NpcBg.removeChild(goods);\n\t\tObjectPool.recycleObject(PoolName, goods);\n\t\tgoods.removeEventListener(engine.Event.ENTER_FRAME, goods[\"onGoodsEnter\"], this);\n\t\tlet index = this.goodsItems.indexOf(goods);\n\t\tif (index > -1) {\n\t\t\tthis.goodsItems.splice(index, 1);\n\t\t}\n\t}\n\n\t/**\n\t * 回收对象\n\t */\n\tprivate recycleGoods() {\n\t\tclearTimeout(this.timer)\n\t\tclearInterval(this.countdownTimer)\n\t\tfor (let goods of this.goodsItems) {\n\t\t\tif (goods) {\n\t\t\t\tthis.NpcBg.removeChild(goods);\n\t\t\t\tObjectPool.recycleObject(PoolName, goods);\n\t\t\t\tgoods.removeEventListener(engine.Event.ENTER_FRAME, goods[\"onGoodsEnter\"], this);\n\t\t\t}\n\t\t}\n\t\tthis.goodsItems = []\n\t}\n\n\tprivate moveCatchX = 0\n\tprivate playerCatchX = 0\n\n\t/**\n\t * 碰撞检测\n\t * @param a a盒子\n\t * @param b b盒子\n\t */\n\tprivate hasHit(a, b) {\n\n\t\tlet playerH=a.height\n\t\tlet playerW=a.width\n\t\tlet playerX=a.x\n\t\tif(props.playerHeight){\n\t\t\tplayerH=props.playerHeight\n\t\t}\n\t\tif(props.playerWidth){\n\t\t\tplayerW=props.playerWidth\n\t\t\tplayerX=a.x+(a.width-props.playerWidth)/2\n\t\t}\n\n\t\tif (\n\t\t\tMath.abs((playerX + playerW / 2) - (b.x + b.width / 2)) < playerW / 2 + b.width / 2\n\t\t\t&&\n\t\t\t// Math.abs((a.y + a.height / 2 ) - (b.y + b.height / 2)) < a.height / 2 + b.height / 2\n\t\t\tMath.abs((a.y + playerH / 1.3 ) - (b.y + b.height / 2)) < playerH / 2 + b.height / 2\n\t\t) {\n\t\t\treturn true;\n\t\t} else {\n\t\t\treturn false;\n\t\t}\n\t}\n\n\tprivate onDownStage = (e) => {\n\t\tthis.moveCatchX = e.localX;\n\t\tthis.playerCatchX = this.player.x\n\t}\n\n\tprivate onMoveStage = (e) => {\n\t\tlet maxStageBound=props.maxStageBound;\n\t\tif (this.gameIng) {\n\t\t\tlet playerX=this.playerCatchX + (e.localX - this.moveCatchX)\n\t\t\tif(playerX<maxStageBound){\n\t\t\t\tthis.player.x=maxStageBound\n\t\t\t}else if(playerX+this.player.width+maxStageBound>750){\n\t\t\t\tthis.player.x=750-maxStageBound-this.player.width\n\t\t\t}else{\n\t\t\t\tthis.player.x=playerX\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate onOutStage = (e) => {\n\t\tthis.moveCatchX = 0\n\t}\n}\n","/**\n * Created by rockyl on 2020-01-09.\n */\n\nimport GameView from \"./GameView\";\nimport {injectProps} from \"../props\";\n\n\nexport class GameWrapper extends engine.Container {\n\tprivate _status;\n\tprivate _gameView: GameView;\n\n\tconstructor() {\n\t\tsuper();\n\t\tengine.globalEvent.addEventListener('dragon-boat-race-reset', this.reset, this);\n\t\tengine.globalEvent.addEventListener('dragon-boat-race-start', this.start, this);\n\t\tengine.globalEvent.addEventListener('dragon-boat-race-pause', this.pause, this);\n\t\tengine.globalEvent.addEventListener('dragon-boat-race-resume', this.resume, this);\n\t\tengine.globalEvent.addEventListener('dragon-boat-race-revive', this.revive, this);\n\t\tengine.globalEvent.addEventListener('dragon-boat-race-clear', this.clear, this);\n\n\t\tthis.addEventListener(engine.MouseEvent.CLICK, this.onTap, this);\n\n\t\tlet gameView = this._gameView = new GameView();\n\t\tthis.addChild(gameView);\n\t\t// gameView.reset()\n\t\t// gameView.start()\n\t}\n\n\treset(event: engine.Event) {\t\t\n\t\tinjectProps(event.data);\n\t\tthis._gameView.visible = true;\n\t\tthis._gameView.reset();\n\t}\n\n\tstart(event: engine.Event) {\n\t\tinjectProps(event.data);\n\t\tthis._status = 1;\n\t\tthis._gameView.start();\n\t}\n\n\tpause() {\n\t\tthis._gameView.pause();\n\t}\n\n\tresume() {\n\t\tthis._gameView.resume();\n\t}\n\n\trevive() {\n\t\tthis._gameView.revive();\n\t}\n\n\tclear() {\n\t\tthis._gameView.visible = false;\n\t}\n\n\tprivate onTap(event) {\n\t//\tthis._gameView.tap(event);\n\t}\n}\n","/**\n * Created by rockyl on 2019-11-20.\n */\n\nimport {GameWrapper} from \"./game/GameWrapper\";\nimport {injectProps, prepareProps} from \"./props\";\n\nexport default function (props) {\n\tpr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AAQ,CAAC,CAAC;;MAGxB;KAED,2BAAK,GAAL,UAAM,KAAmB;SACxB,WAAW,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;SACxB,IAAI,CAAC,SAAS,CAAC,OAAO,GAAG,IAAI,CAAC;SAC9B,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,CAAC;MACvB;KAED,2BAAK,GAAL,UAAM,KAAmB;SACxB,WAAW,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;SACxB,IAAI,CAAC,OAAO,GAAG,CAAC,CAAC;SACjB,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,CAAC;MACvB;KAED,2BAAK,GAAL;SACC,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,CAAC;MACvB;KAED,4BAAM,GAAN;SACC,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,CAAC;MACxB;KAED,4BAAM,GAAN;SACC,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,CAAC;MACxB;KAED,2BAAK,GAAL;SACC,IAAI,CAAC,SAAS,CAAC,OAAO,GAAG,KAAK,CAAC;MAC/B;KAEO,2BAAK,GAAb,UAAc,KAAK;MAElB;KACF,kBAAC;CAAD,CAAC,CApDgC,MAAM,CAAC,SAAS,GAoDhD;;;iBCrDwB,KAAK;KAC7B,YAAY,EAAE,CAAC;KACf,WAAW,CAAC,KAAK,CAAC,CAAC;KAEnB,IAAI,QAAQ,GAAG,IAAI,WAAW,EAAE,CAAC;KACjC,OAAO,QAAQ,CAAC;CACjB,CAAC;;;;;;;;;"}
\ No newline at end of file
/**
* Created by rockyl on 2020-01-21.
*/
let customModuleProps = {
};
{
"name": "赛龙舟",
"desc": "赛龙舟模块",
"props": {
"playerPositionY": {
"alias": "玩家Y轴位置",
"type": "number",
"default": 900
},
"playerPositionX": {
"alias": "玩家Y轴位置",
"type": "number",
"default": 300
},
"runScore": {
"alias": "每前进1米加分(不能小于1)",
"type": "number",
"default": 1
},
"rainScore": {
"alias": "接金币获得分数",
"type": "number",
"default": 5
},
"rain2Score": {
"alias": "接粽子获得分数",
"type": "number",
"default": 10
},
"speed": {
"alias": "道具掉落初始速度",
"type": "number",
"default": 10
},
"maxSpeed": {
"alias": "道具掉落速度上限",
"type": "number",
"default": 3
},
"playerHeight": {
"alias": "玩家高度",
"type": "number",
"default": 100
},
"playerWidth": {
"alias": "玩家宽度",
"type": "number",
"default": 100
},
"maxStageBound": {
"alias": "最大移动边距",
"type": "number",
"default": -20
},
"maxNpcBound": {
"alias": "道具随机出现的边距",
"type": "number",
"default": 100
},
"gameOverCondition": {
"alias": "游戏结束条件(1:接到炸弹死亡,2:分数负数或接到炸弹死亡)",
"type": "number",
"default": 1
},
"boomPosition1Offset": {
"alias": "奖励爆炸svga位置偏移[x,y]",
"type": "array<number>",
"default": "-80,-200"
},
"boomPosition2Offset": {
"alias": "奖励爆炸svga位置偏移[x,y]",
"type": "array<number>",
"default": "-80,-200"
},
"boomPosition3Offset": {
"alias": "障碍爆炸svga位置偏移[x,y]",
"type": "array<number>",
"default": "0,-100"
},
"playerRunPosition3Offset": {
"alias": "玩家滑动位置偏移",
"type": "array<number>",
"default": "-120,-125"
},
"playerOverPosition3Offset": {
"alias": "玩家翻船位置偏移",
"type": "array<number>",
"default": "-120,-125"
}
},
"assets": [
{
"name": "循环背景1",
"url": "//yun.duiba.com.cn/aurora/assets/a57af3e2092f421ebbb47ee7a3d30f4326b5b7cd.jpg",
"uuid": "d95a5911-1c7c-4b60-9ff1-5cb179738e91",
"ext": ".jpg"
},
{
"name": "循环背景2",
"url": "//yun.duiba.com.cn/aurora/assets/489de78a248456d9dee74d8106da3dae40c0268b.jpg",
"uuid": "2222b6d9-17cb-42a6-a0f2-54c390522ca5",
"ext": ".jpg"
},
{
"name": "金币",
"url": "//yun.duiba.com.cn/aurora/assets/6d2719418a59a95fc0db0c0b761d00b4b4519b81.png",
"uuid": "d3ce99da-89e1-447d-8c52-b3f391925c3c",
"ext": ".png"
},
{
"name": "粽子",
"url": "//yun.duiba.com.cn/aurora/assets/89ec786e36cd306225502b384ddb7550d79166c2.png",
"uuid": "02f17008-1d8d-4108-a0fc-03fbc71fd118",
"ext": ".png"
},
{
"name": "石块",
"url": "//yun.duiba.com.cn/aurora/assets/13efce5d31f114e2db9c9b0baac057bc1baf89d2.png",
"uuid": "eb88b42d-e151-4c1b-94b9-7c16f7bfac29",
"ext": ".png"
},
{
"name": "木头",
"url": "//yun.duiba.com.cn/aurora/assets/3071bf51a8cc4e1733fe7ab6549206d27be15e7c.png",
"uuid": "ab1bdabc-21ba-46bf-9299-6c638f766c88",
"ext": ".png"
},
{
"name": "碰到金币svga",
"url": "//yun.duiba.com.cn/aurora/assets/ebd0dc01e7154970bc2b1e65a6a3641aec0e319c.svga",
"uuid": "cdd2268f-ad65-4b5e-a965-ee61b730da21",
"ext": ".svga"
},
{
"name": "碰到粽子svga",
"url": "//yun.duiba.com.cn/aurora/assets/b9d21ca9758a8503dc5271949924f7cb08adcdf2.svga",
"uuid": "ce252ae3-9cc5-490b-9c18-a4111317c473",
"ext": ".svga"
},
{
"name": "碰到石头svga",
"url": "//yun.duiba.com.cn/aurora/assets/862802a8173acc1bde28dd603c7ffd2ccc426700.svga",
"uuid": "d7a3947b-7fcb-48f2-9ddf-2f075d37a619",
"ext": ".svga"
},
{
"name": "玩家翻船",
"url": "//yun.duiba.com.cn/aurora/assets/4dd3f3d80c8560d534abfd4c55f4ed758fd9c6f1.svga",
"uuid": "6338498f-78ba-4d4b-a172-85755646baf7",
"ext": ".svga"
},
{
"name": "玩家滑动",
"url": "//yun.duiba.com.cn/aurora/assets/83c888fcce01d2202a9b4ab73090b3f9e2bc11cd.svga",
"uuid": "59920d79-e5bf-46e0-a753-f4e7a1315a97",
"ext": ".svga"
},
{
"name": "玩家静止",
"url": "//yun.duiba.com.cn/aurora/assets/9e1d76f3ce486edd17c81e97782ed8afe3f66c0b.png",
"uuid": "4931d296-4421-4a2f-8299-7bab87407c72",
"ext": ".png"
}
],
"events": {
"in": {
"dragon-boat-race-reset": {
"alias": "重置",
"data": {
"goodsProbability": "[0.2,0.2,0.3,0.3]道具概率(金币、粽子、木头、石块),所有概率相加为1",
"countDown": "倒计时(s)",
"acceleratedSpeed":"道具掉落加速度(单位:每秒)"
}
},
"dragon-boat-race-start": {
"alias": "开始"
},
"dragon-boat-race-revive": {
"alias": "复活"
},
"dragon-boat-race-pause": {
"alias": "暂停"
},
"dragon-boat-race-resume": {
"alias": "恢复"
},
"dragon-boat-race-clear": {
"alias": "清空,通过reset事件恢复"
}
},
"out": {
"dragon-boat-race-score-update": {
"alias": "分数更新",
"data": {
"score":"分数"
}
},
"dragon-boat-race-time-update": {
"alias": "倒计时更新",
"data": {
"time":"剩余时间"
}
},
"dragon-boat-race-game-over": {
"alias": "游戏结束",
"data": {
"score":"分数",
"reason": "结束原因(1:时间到了,2:玩家死亡)"
}
}
}
}
}
\ No newline at end of file
/**
* Created by rockyl on 2018/8/16.
*/
import { props } from "../props";
import { playSound, createSvga } from "./utils";
import ObjectPool = engine.ObjectPool;
import { getTextureByName } from "./utils";
import { Goods } from "./Goods";
import { PoolName } from "./object-pool-init";
export default class GameView extends engine.Container {
private _hasSetup;
//玩家
private player: engine.Container;
//触摸层
// private rectBg: engine.Rect;
private rectBg: engine.Container;
//npc层
private NpcBg: engine.Container;
//当前分数
private score
//游戏状态
private gameIng;
//npc出身计时器
private timer
//倒计时计时器
private countdownTimer: any
//倒计时
private countdown: number
//当前速度
private speed: number
// 当前场景上面的物品
private goodsItems = []
private _goods: Goods;
constructor() {
super();
this.once(engine.Event.ADDED_TO_STAGE, this.setup, this);
}
private waterSvga
private water2Svga
private boomSvga
private playerSvgaReset
private playerSvgaRun
private playerSvgaOver
private bg1
private bg2
private bg3
private bg4
private bg
private labelScore
setup() {
if (this._hasSetup) {
return;
}
this._hasSetup = true;
this.bg = new engine.Container();
this.bg.mouseEnabled = false;
this.addChild(this.bg);
this.NpcBg = new engine.Container();
this.NpcBg.alpha = 1;
this.NpcBg.width = 0;
this.NpcBg.height = 0;
this.addChild(this.NpcBg);
this.player = new engine.Container();
this.player.mouseEnabled=false;
this.player.mouseChildren=false
// this.player.fillColor="rgba(0, 0, 0,1)"
//console.log(this.player.fillColor)
//创建文字
this.labelScore = new engine.BitmapText();
this.labelScore.font = props.fontName;
this.labelScore.scaleX = this.labelScore.scaleY = 1;
this.addChild(this.labelScore);
this.waterSvga=createSvga("碰到金币svga")
this.water2Svga=createSvga("碰到粽子svga")
this.boomSvga=createSvga("碰到石头svga")
// this.playerSvga=createSvga("玩家")
this.playerSvgaReset= new engine.Sprite(getTextureByName('玩家静止'))
this.playerSvgaRun= createSvga("玩家滑动")
this.playerSvgaOver= createSvga("玩家翻船")
this.bg1= new engine.Sprite(getTextureByName('循环背景1'))
this.bg2= new engine.Sprite(getTextureByName('循环背景2'))
this.bg3= new engine.Sprite(getTextureByName('循环背景1'))
this.bg4= new engine.Sprite(getTextureByName('循环背景2'))
this.player.addChild(this.playerSvgaReset);
this.player.addChild(this.playerSvgaRun);
this.player.addChild(this.playerSvgaOver);
this.addChild(this.waterSvga);
this.addChild(this.water2Svga);
this.addChild(this.boomSvga);
this.addChild(this.player);
this.bg.addChild(this.bg1);
this.bg.addChild(this.bg2);
this.bg.addChild(this.bg3);
this.bg.addChild(this.bg4);
// this.playerSvga.gotoAndPlay(1);
this.waterSvga.visible = false
this.water2Svga.visible = false
this.boomSvga.visible = false
this.setPlayState(this.playerSvgaReset)
this.visible=false;
setTimeout(()=>{
this.visible=true;
//this.player.anchorY = this.player.height / 2;
// this.player.anchorX = this.player.width / 2;
this.player.x = props.playerPositionX;
this.player.y = props.playerPositionY;
// this.stoneSvga.x = this.player.width / 2 - this.stoneSvga.width/2 + props.boomPosition1Offset[0];
// this.stoneSvga.y = this.player.height / 2 - this.stoneSvga.height/2 + props.boomPosition1Offset[1];
// this.waterSvga.x = this.player.width / 2 - this.waterSvga.width/2+ props.boomPosition2Offset[0];
// this.waterSvga.y = this.player.height / 2 - this.waterSvga.height/2 + props.boomPosition2Offset[1];
// this.boomSvga.x = this.player.width / 2 - this.boomSvga.width/2+ props.boomPosition3Offset[0];
// this.boomSvga.y = this.player.height / 2 - this.boomSvga.height/2 + props.boomPosition3Offset[1];
this.playerSvgaRun.x=props.playerRunPosition3Offset[0]
this.playerSvgaRun.y=props.playerRunPosition3Offset[1]
this.playerSvgaOver.x=props.playerOverPosition3Offset[0]
this.playerSvgaOver.y=props.playerOverPosition3Offset[1]
this.bg1.y=0
this.bg2.y=this.bg1.height
this.bg3.y=this.bg1.height+this.bg2.height
this.bg4.y=this.bg1.height+this.bg2.height+this.bg3.height
engine.Tween.get(this.playerSvgaReset, {loop:true})
.to({y:10}, 500)
.to({y:0}, 500)
.to({y:10}, 500)
.call(()=>{});
// this.stoneSvga.x=props.boomPositionOffset[0]
// this.stoneSvga.y=props.boomPositionOffset[1]
// this.waterSvga.x=props.boomPositionOffset[0]
// this.waterSvga.y=props.boomPositionOffset[1]
// this.boomSvga.x=props.boomPositionOffset[0]
// this.boomSvga.y=props.boomPositionOffset[1]
},300)
this.rectBg = new engine.Container();
this.rectBg.alpha = 0;
this.rectBg.width = 750;
this.rectBg.height = 1624;
this.addChild(this.rectBg)
this.rectBg.addEventListener(engine.MouseEvent.MOUSE_DOWN, this.onDownStage, this);
this.rectBg.addEventListener(engine.MouseEvent.MOUSE_MOVE, this.onMoveStage, this);
this.rectBg.addEventListener(engine.MouseEvent.MOUSE_OUT, this.onOutStage, this);
this.rectBg.addEventListener(engine.Event.ENTER_FRAME, this.enterFrame, this);
}
setBoomPosition(svga,callback?){
svga.x=this.player.x;
svga.y=this.player.y;
if(svga==this.waterSvga){
svga.x+=props.boomPosition1Offset[0]
svga.y+=props.boomPosition1Offset[1]
}else if(svga==this.water2Svga){
svga.x+=props.boomPosition2Offset[0]
svga.y+=props.boomPosition2Offset[1]
}else if(svga==this.boomSvga){
svga.x+=props.boomPosition3Offset[0]
svga.y+=props.boomPosition3Offset[1]
}
svga.visible=true;
svga.play(true,false)
svga.once(engine.Event.END_FRAME, ()=>{
svga.visible=false;
if(callback){
callback()
}
}, this);
}
enterFrame(){
if(this.bg.y>=0){
this.bg.y=-this.bg3.y
}
if(this.gameIng){
this.bg.y += (4 * this.speed)
}
}
/**
* 重置场景
*/
reset() {
this.recycleGoods()
this.score = 0;
this.speed = props.speed;
this.bg.y=-this.bg3.y
this.player.anchorY = this.player.height / 2;
this.player.anchorX = this.player.width / 2;
this.player.x = props.playerPositionX;
this.player.y = props.playerPositionY;
this.setPlayState(this.playerSvgaReset)
}
setPlayState(svga){
this.playerSvgaReset.visible=false
this.playerSvgaRun.visible=false
this.playerSvgaOver.visible=false
console.log(svga)
svga.visible=true;
if(svga==this.playerSvgaOver){
svga.play(false, false)
svga.once(engine.Event.END_FRAME, ()=>{
}, this);
}else if(svga==this.playerSvgaRun){
svga.play()
}
}
/**
* 开始
*/
start() {
this.gameIng = true;
this.creatNpc()
this.beginNpc()
this.countdown = props.countDown;
this.setPlayState(this.playerSvgaRun)
this.countdownTimer = setInterval(() => {
if (this.gameIng) {
if (this.countdown > 0) {
engine.globalEvent.dispatchEvent('dragon-boat-race-time-update', {
time: this.countdown,
});
this.countdown -= 1
} else {
engine.globalEvent.dispatchEvent('dragon-boat-race-game-over', {
score: this.score,
reason: 1
});
this.died()
}
this.score += Math.round(this.speed*props.runScore);
engine.globalEvent.dispatchEvent('dragon-boat-race-score-update', {
score: this.score,
});
}
}, 1000)
}
/**
* npc开始掉落
*/
beginNpc() {
this.timer = setTimeout(() => {
if (this.gameIng) {
this.speed += props.acceleratedSpeed;
this.speed += props.acceleratedSpeed;
if(this.speed>props.maxSpeed){
this.speed=props.maxSpeed
}
this.creatNpc()
}
//递归执行
this.beginNpc()
}, 2000 / this.speed)
}
/**
* 暂停
*/
pause() {
this.gameIng = false;
}
/**
* 恢复
*/
revive() {
this.gameIng = true;
}
/**
* 重新开始
*/
resume() {
this.reset()
this.start()
}
/**
* 创建NPC
*/
private creatNpc() {
let goods = this._goods = <Goods>ObjectPool.getObject(PoolName);
this.goodsItems.push(goods)
//console.log(goods);
this.NpcBg.addChild(goods);
goods.addEventListener(engine.Event.ENTER_FRAME, goods["onGoodsEnter"] = () => {
if (goods.y > 1624) {
this.removeNpc(goods)
} else {
if (this.gameIng) {
//速度叠加
goods.y += (4 * this.speed)
//如果玩家和物品发生碰撞
if (goods["lifeState"]&&this.hasHit(this.player, goods)) {
goods["lifeState"]=false;
if (goods["npcType"] == "rain0") {
console.log("碰到雨滴")
this.score += props.rainScore
if(this.score<0){
this.score=0;
}
this.setBoomPosition(this.waterSvga)
engine.Tween.get(goods, null, null, true)
.to({scaleX: 0,scaleY:0}, 200)
.call(()=>{this.removeNpc(goods)});
}else if (goods["npcType"] == "rain1") {
console.log("碰到雨滴")
this.score += props.rain2Score
if(this.score<0){
this.score=0;
}
this.setBoomPosition(this.water2Svga)
engine.Tween.get(goods, null, null, true)
.to({scaleX: 0,scaleY:0}, 200)
.call(()=>{this.removeNpc(goods)});
} else if (goods["npcType"] == "boom"||goods["npcType"] == "stone") {
console.log("碰到炸弹")
this.setBoomPosition(this.boomSvga,()=>{
engine.globalEvent.dispatchEvent('dragon-boat-race-game-over', {
score: this.score,
reason: 2
});
this.died()
})
this.setPlayState(this.playerSvgaOver)
this.pause()
}
engine.globalEvent.dispatchEvent('dragon-boat-race-score-update', {
score: this.score,
});
}
}
}
}, this);
}
/**
* 玩家死亡
*/
private died() {
this.score = 0
this.pause()
}
/**
* 回收指定物品
* @param goods 物品
*/
private removeNpc(goods) {
this.NpcBg.removeChild(goods);
ObjectPool.recycleObject(PoolName, goods);
goods.removeEventListener(engine.Event.ENTER_FRAME, goods["onGoodsEnter"], this);
let index = this.goodsItems.indexOf(goods);
if (index > -1) {
this.goodsItems.splice(index, 1);
}
}
/**
* 回收对象
*/
private recycleGoods() {
clearTimeout(this.timer)
clearInterval(this.countdownTimer)
for (let goods of this.goodsItems) {
if (goods) {
this.NpcBg.removeChild(goods);
ObjectPool.recycleObject(PoolName, goods);
goods.removeEventListener(engine.Event.ENTER_FRAME, goods["onGoodsEnter"], this);
}
}
this.goodsItems = []
}
private moveCatchX = 0
private playerCatchX = 0
/**
* 碰撞检测
* @param a a盒子
* @param b b盒子
*/
private hasHit(a, b) {
let playerH=a.height
let playerW=a.width
let playerX=a.x
if(props.playerHeight){
playerH=props.playerHeight
}
if(props.playerWidth){
playerW=props.playerWidth
playerX=a.x+(a.width-props.playerWidth)/2
}
if (
Math.abs((playerX + playerW / 2) - (b.x + b.width / 2)) < playerW / 2 + b.width / 2
&&
// Math.abs((a.y + a.height / 2 ) - (b.y + b.height / 2)) < a.height / 2 + b.height / 2
Math.abs((a.y + playerH / 1.3 ) - (b.y + b.height / 2)) < playerH / 2 + b.height / 2
) {
return true;
} else {
return false;
}
}
private onDownStage = (e) => {
this.moveCatchX = e.localX;
this.playerCatchX = this.player.x
}
private onMoveStage = (e) => {
let maxStageBound=props.maxStageBound;
if (this.gameIng) {
let playerX=this.playerCatchX + (e.localX - this.moveCatchX)
if(playerX<maxStageBound){
this.player.x=maxStageBound
}else if(playerX+this.player.width+maxStageBound>750){
this.player.x=750-maxStageBound-this.player.width
}else{
this.player.x=playerX
}
}
}
private onOutStage = (e) => {
this.moveCatchX = 0
}
}
/**
* Created by rockyl on 2020-01-09.
*/
import GameView from "./GameView";
import {injectProps} from "../props";
export class GameWrapper extends engine.Container {
private _status;
private _gameView: GameView;
constructor() {
super();
engine.globalEvent.addEventListener('dragon-boat-race-reset', this.reset, this);
engine.globalEvent.addEventListener('dragon-boat-race-start', this.start, this);
engine.globalEvent.addEventListener('dragon-boat-race-pause', this.pause, this);
engine.globalEvent.addEventListener('dragon-boat-race-resume', this.resume, this);
engine.globalEvent.addEventListener('dragon-boat-race-revive', this.revive, this);
engine.globalEvent.addEventListener('dragon-boat-race-clear', this.clear, this);
this.addEventListener(engine.MouseEvent.CLICK, this.onTap, this);
let gameView = this._gameView = new GameView();
this.addChild(gameView);
// gameView.reset()
// gameView.start()
}
reset(event: engine.Event) {
injectProps(event.data);
this._gameView.visible = true;
this._gameView.reset();
}
start(event: engine.Event) {
injectProps(event.data);
this._status = 1;
this._gameView.start();
}
pause() {
this._gameView.pause();
}
resume() {
this._gameView.resume();
}
revive() {
this._gameView.revive();
}
clear() {
this._gameView.visible = false;
}
private onTap(event) {
// this._gameView.tap(event);
}
}
/**
* Created by rockyl on 2020-02-02.
*
* 掉落物品
*/
import {getTextureByName} from "./utils";
import {props} from "../props";
export class Goods extends engine.Container {
private _body:engine.Rect
private _toY;
constructor() {
super();
let body
body = this._body =new engine.Rect()
// let randomNum = Math.floor(Math.random() * 3)
// console.log('雨滴' + randomNum);
let rain = new engine.Sprite(getTextureByName('金币'));
let rain1 = new engine.Sprite(getTextureByName('粽子'));
rain["npcType"]="rain0"
rain1["npcType"]="rain1"
let stone = new engine.Sprite(getTextureByName('木头'));
stone["npcType"]="stone"
let boom = new engine.Sprite(getTextureByName('石块'));
boom["npcType"]="boom"
rain.visible=false;
rain1.visible=false;
stone.visible=false;
boom.visible=false;
rain.anchorX=rain.width/2
rain1.anchorX=rain1.width/2
stone.anchorX=stone.width/2
boom.anchorX=boom.width/2
rain.anchorY=rain.height/2
rain1.anchorY=rain1.height/2
stone.anchorY=stone.height/2
boom.anchorY=boom.height/2
body.addChild(rain)
body.addChild(rain1)
body.addChild(stone)
body.addChild(boom)
this.addChild(body);
body.width=.0001;
body.height=.0001;
body.mouseEnabled=false;
}
getRandomNumberByRange(start, end) {
return Math.floor(Math.random() * (end - start) + start)
}
reset() {
this["lifeState"]=true;
this.visible = true;
this.rotation = 0;
this.anchorOffsetY = 0;
if(this.width<=0){
this.anchorX=50;
}else{
this.anchorX=this.width/2;
}
this.anchorY=this.height/2;
this.scaleX=this.scaleY=1;
this.y = 0;
this.x = ((750-props.maxNpcBound)-120)*Math.random()+30+props.maxNpcBound;
this.rotation = 0;
let random=Math.random()
if(typeof (props.goodsProbability) == 'string'){
props.goodsProbability=props.goodsProbability.split(',').map((i: string) => +i)
console.log(props.goodsProbability);
}
if(random<props.goodsProbability[0]){
this.showNpc("rain0")
}else if(random>=props.goodsProbability[0]&&random<=(props.goodsProbability[0]+props.goodsProbability[1])){
this.showNpc("rain1")
}else if(random>=(props.goodsProbability[0]+props.goodsProbability[1])&&random<=(props.goodsProbability[0]+props.goodsProbability[1]+props.goodsProbability[2])){
this.showNpc("stone")
}else if(random>(props.goodsProbability[0]+props.goodsProbability[1]+props.goodsProbability[2])){
this.showNpc("boom")
}
}
showNpc(type){
for(let i=0;i<this._body.children.length;i++){
this._body.children[i].visible=false;
this._body.children[i].mouseEnabled=false;
}
for(let i=0;i<this._body.children.length;i++){
if(this._body.children[i]["npcType"]==type){
this["npcType"]=type
this._body.children[i].visible=true;
this._body.children[i].mouseEnabled=false;
}
}
}
set anchorOffsetY(v) {
this._body.y = v;
}
}
/**
* Created by rockyl on 2020-02-03.
*/
import {Goods} from "./Goods";
import ObjectPool = engine.ObjectPool;
export const PoolName: string = 'goods';
ObjectPool.registerPool(PoolName, function () {
return new Goods();
}, function (item: Goods, data) {
item.reset();
});
/**
* Created by rockyl on 2020-01-21.
*/
export function getTexture(uuid) {
return engine.Texture.from(getAssetByUUID(uuid).uuid);
}
export function getTextureByName(name) {
return getTexture(getAssetByName(name).uuid);
}
export function playSound(name) {
engine.playSound(getAssetByName(name).uuid, {keep: true});
}
export function createSvga(name, anchorName?) {
let inst = new svga.Svga();
inst.source = 'asset://' + getAssetByName(name).uuid;
return inst;
}
\ No newline at end of file
/**
* Created by rockyl on 2019-11-20.
*/
import {GameWrapper} from "./game/GameWrapper";
import {injectProps, prepareProps} from "./props";
export default function (props) {
prepareProps();
injectProps(props);
let instance = new GameWrapper();
return instance;
}
/**
* Created by rockyl on 2020-01-21.
*/
export let props: any = {};
export function prepareProps() {
let metaProps = getProps();
engine.injectProp(props, metaProps);
}
export function injectProps(p) {
engine.injectProp(props, p);
}
/**
* Created by renjianfeng on 2020-03-13.
*/
const customId = 'food-fell2';
(async function () {
let customModule = await fetch(`../meta.json`);
customModule = await customModule.json();
console.log(customModule);
await loadAssets(customModule.assets);
launchWithCustomModule(customModule);
})();
function launchWithCustomModule(customModule) {
//engine.registerCustomCodeModule(customModule);
engine.registerCustomModule(customId, window[customId]);
const {props: propsOption, assets} = customModule;
let props = engine.computeProps(customModuleProps, propsOption);
const customModuleIns = {
id: customId,
props,
assets,
};
engine.registerCustomModules([customModuleIns]);
engine.launchWithConfig({
options: {
entrySceneView: 'entry',
},
assets: [],
views: [{
name: 'entry',
type: 'node',
properties: {
x: 0,
y: 0,
}
}],
customs: []
}, null, function () {
setTimeout(() => {
engine.addCustomModule(customId, engine.gameStage.sceneContainer.getChildAt(0));
}, 100);
setTimeout(() => {
engine.globalEvent.dispatchEvent('food-fell-reset', {
"goodsProbability": "0.8,0.1,0.1",
"countDown": 30,
"acceleratedSpeed":0.1
});
engine.globalEvent.dispatchEvent('food-fell-start');
}, 500);
});
engine.globalEvent.addEventListener('food-fell-time-update', (e) => {
console.log(e.type, e.data);
});
engine.globalEvent.addEventListener('food-fell-score-update', (e) => {
console.log(e.type, e.data);
});
engine.globalEvent.addEventListener('food-fell-game-over', (e) => {
console.log(e.type, e.data);
});
}
function getAssetByUUID(uuid) {
return engine.resolveCustomAsset(customId, uuid);
}
function getProps() {
return engine.getProps(customId);
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>美食从天而降</title>
<meta name="viewport"
content="width=device-width,initial-scale=1, minimum-scale=1, maximum-scale=1, user-scalable=no"/>
<meta name="apple-mobile-web-app-capable" content="yes"/>
<meta name="full-screen" content="true"/>
<meta name="screen-orientation" content="portrait"/>
<meta name="x5-fullscreen" content="true"/>
<meta name="360-fullscreen" content="true"/>
<style>
html,
body {
padding: 0;
margin: 0;
border: 0;
width: 100%;
height: 100%;
overflow: hidden;
position: absolute;
background-color: red;
}
.game-container{
width: 100%;
height: 100%;
line-height:0;
font-size:0;
}
</style>
</head>
<body>
<div id="game-container" class="game-container"></div>
<!-- <script crossorigin="anonymous" src="//yun.duiba.com.cn/editor/zeroing/libs/engine.50cdcef6ebe4e8c0fbc624f9d4fbf225102c5750.js"></script> -->
<script crossorigin="anonymous" src="//yun.duiba.com.cn/editor/zeroing/libs/engine.fbc60c6d3cb30e5ab97e82d392d9efeee91b8581.js"></script>
<script crossorigin="anonymous" src="//yun.duiba.com.cn/editor/zeroing/libs/svga.fd3923ae6e664251ca7981801a65809cc5f36bc3.js"></script>
<!-- <script src="//yun.duiba.com.cn/editor/zeroing/libs/engine.ebc906f6b50b8da0a669f77027981d5f3cb560ce.js"></script> -->
<!-- <script src="http://localhost:4002/debug/engine.js"></script>
<script src="http://localhost:4003/debug/engine-svga.js"></script> -->
<!--<script src="//yun.duiba.com.cn/editor/zeroing/libs/engine.9a9dbfda4cb2dd5508ecddfe3d95dfd88063f7b5.js"></script>-->
<script src="app.js"></script>
<script src="props.js"></script>
<script src="load-assets.js"></script>
<script src="main.js"></script>
<script>
</script>
</body>
\ No newline at end of file
/**
* Created by rockyl on 2020-01-21.
*/
const assets = [
{
"name": "雨滴0",
"url": "//yun.duiba.com.cn/aurora/assets/badb3627bbcc75276a3eed53daa8b0a454ced6eb.png",
"uuid": "d3ce99da-89e1-447d-8c52-b3f391925c3c",
"ext": ".png"
},
{
"name": "雨滴1",
"url": "//yun.duiba.com.cn/aurora/assets/5cc0092913c571eeb52317b8e1e0dc715793049c.png",
"uuid": "02f17008-1d8d-4108-a0fc-03fbc71fd118",
"ext": ".png"
},
{
"name": "雨滴2",
"url": "//yun.duiba.com.cn/aurora/assets/4b938949b85d50b36ef0f66450643495efbf7580.png",
"uuid": "46aa4f8a-9a6c-4210-8ffd-92da0dd3bc75",
"ext": ".png"
},
{
"name": "炸弹",
"url": "//yun.duiba.com.cn/aurora/assets/171e92283cd13c013ee1b76d28d252ff08815d47.png",
"uuid": "eb88b42d-e151-4c1b-94b9-7c16f7bfac29",
"ext": ".png"
},
{
"name": "石块",
"url": "//yun.duiba.com.cn/aurora/assets/99b0af0c59fe79a415a3f032149cfacc27e3ac2c.png",
"uuid": "ab1bdabc-21ba-46bf-9299-6c638f766c88",
"ext": ".png"
},
{
"name": "水花",
"url": "//yun.duiba.com.cn/aurora/assets/11b1f49fa3afa3a48f1dd3e3c1eb294e3fa9d886.svga",
"uuid": "cdd2268f-ad65-4b5e-a965-ee61b730da21",
"ext": ".svga"
},
{
"name": "石头svga",
"url": "//yun.duiba.com.cn/aurora/assets/01aa6fcb33aa8231f075257026eab2f0aeb3c27a.svga",
"uuid": "846a139d-0990-4db4-a323-f22379932ee4",
"ext": ".svga"
},
{
"name": "炸弹svga",
"url": "//yun.duiba.com.cn/aurora/assets/3b58e7ace031b09c651cf8e7202f9c86e86852c9.svga",
"uuid": "d7a3947b-7fcb-48f2-9ddf-2f075d37a619",
"ext": ".svga"
},
{
"name": "玩家",
"url": "//yun.duiba.com.cn/aurora/assets/db0130d36ef79865be9c753ea0627027f16341d8.png",
"uuid": "4931d296-4421-4a2f-8299-7bab87407c72",
"ext": ".png"
}
];
function loadAssets(customModuleAssets, onProgress, onComplete){
return engine.loadAssets(assets.concat(...customModuleAssets), onProgress, onComplete);
}
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('tslib')) :
typeof define === 'function' && define.amd ? define(['tslib'], factory) :
(global = global || self, global['food-fell2'] = factory(global.tslib));
}(this, (function (tslib) { 'use strict';
var props = {};
function prepareProps() {
var metaProps = getProps();
engine.injectProp(props, metaProps);
}
function injectProps(p) {
engine.injectProp(props, p);
}
function getTextureByName(name) {
return engine.Texture.from(getAssetByName(name).uuid);
}
function createSvga(name, anchorName) {
var inst = new svga.Svga();
inst.source = 'asset://' + getAssetByName(name).uuid;
return inst;
}
var Goods = (function (_super) {
tslib.__extends(Goods, _super);
function Goods() {
var _this = _super.call(this) || this;
var body;
body = _this._body = new engine.Rect();
var rain = new engine.Sprite(getTextureByName('雨滴0'));
var rain1 = new engine.Sprite(getTextureByName('雨滴1'));
var rain2 = new engine.Sprite(getTextureByName('雨滴2'));
rain["npcType"] = "rain0";
rain1["npcType"] = "rain1";
rain2["npcType"] = "rain2";
var stone = new engine.Sprite(getTextureByName('石块'));
stone["npcType"] = "stone";
var boom = new engine.Sprite(getTextureByName('炸弹'));
boom["npcType"] = "boom";
rain.visible = false;
rain1.visible = false;
rain2.visible = false;
stone.visible = false;
boom.visible = false;
body.addChild(rain);
body.addChild(rain1);
body.addChild(rain2);
body.addChild(stone);
body.addChild(boom);
_this.addChild(body);
body.width = .0001;
body.height = .0001;
body.mouseEnabled = false;
return _this;
}
Goods.prototype.getRandomNumberByRange = function (start, end) {
return Math.floor(Math.random() * (end - start) + start);
};
Goods.prototype.reset = function () {
this.visible = true;
this.rotation = 0;
this.anchorOffsetY = 0;
this.y = 0;
this.x = (750 - 120) * Math.random() + 30;
this.rotation = 0;
var random = Math.random();
if (typeof (props.goodsProbability) == 'string') {
props.goodsProbability = props.goodsProbability.split(',').map(function (i) { return +i; });
}
if (random < props.goodsProbability[0]) {
var randomNum = Math.floor(Math.random() * 3);
this.showNpc("rain" + randomNum);
}
else if (random >= props.goodsProbability[0] && random <= (props.goodsProbability[0] + props.goodsProbability[1])) {
this.showNpc("stone");
}
else if (random > (props.goodsProbability[0] + props.goodsProbability[1])) {
this.showNpc("boom");
}
};
Goods.prototype.showNpc = function (type) {
for (var i = 0; i < this._body.children.length; i++) {
this._body.children[i].visible = false;
this._body.children[i].mouseEnabled = false;
}
for (var i = 0; i < this._body.children.length; i++) {
if (this._body.children[i]["npcType"] == type) {
this["npcType"] = type;
this._body.children[i].visible = true;
this._body.children[i].mouseEnabled = false;
}
}
};
Object.defineProperty(Goods.prototype, "anchorOffsetY", {
set: function (v) {
this._body.y = v;
},
enumerable: true,
configurable: true
});
return Goods;
}(engine.Container));
var ObjectPool = engine.ObjectPool;
var PoolName = 'goods';
ObjectPool.registerPool(PoolName, function () {
return new Goods();
}, function (item, data) {
item.reset();
});
var ObjectPool$1 = engine.ObjectPool;
var GameView = (function (_super) {
tslib.__extends(GameView, _super);
function GameView() {
var _this = _super.call(this) || this;
_this.goodsItems = [];
_this.viewVisible = true;
_this.cacheTime = 0;
_this.cacheTime2 = 0;
_this.moveCatchX = 0;
_this.playerCatchX = 0;
_this.onDownStage = function (e) {
_this.moveCatchX = e.localX;
_this.playerCatchX = _this.player.x;
};
_this.onMoveStage = function (e) {
var maxStageBound = props.maxStageBound;
if (_this.gameIng) {
var playerX = _this.playerCatchX + (e.localX - _this.moveCatchX);
if (playerX < maxStageBound) {
_this.player.x = maxStageBound;
}
else if (playerX + _this.player.width + maxStageBound > 750) {
_this.player.x = 750 - maxStageBound - _this.player.width;
}
else {
_this.player.x = playerX;
}
}
};
_this.onOutStage = function (e) {
_this.moveCatchX = 0;
};
_this.once(engine.Event.ADDED_TO_STAGE, _this.setup, _this);
return _this;
}
GameView.prototype.setup = function () {
var _this = this;
if (this._hasSetup) {
return;
}
this._hasSetup = true;
this.NpcBg = new engine.Container();
this.NpcBg.alpha = 1;
this.NpcBg.width = 0;
this.NpcBg.height = 0;
this.addChild(this.NpcBg);
this.player = new engine.Container();
this.player.mouseEnabled = false;
this.addChild(this.player);
this.waterSvga = createSvga("水花");
this.stoneSvga = createSvga("石头svga");
this.playerSvga = new engine.Sprite(getTextureByName('玩家'));
this.boomSvga = createSvga("炸弹svga");
this.player.addChild(this.playerSvga);
this.player.addChild(this.stoneSvga);
this.player.addChild(this.waterSvga);
this.player.addChild(this.boomSvga);
this.waterSvga.visible = false;
this.stoneSvga.visible = false;
this.boomSvga.visible = false;
this.visible = false;
setTimeout(function () {
_this.visible = true;
_this.player.anchorY = _this.player.height / 2;
_this.player.anchorX = _this.player.width / 2;
_this.player.x = 375 - _this.player.width / 2;
_this.player.y = props.playerPositionY;
_this.stoneSvga.x = _this.player.width / 2 - _this.stoneSvga.width / 2 + props.boomPosition1Offset[0];
_this.stoneSvga.y = _this.player.height / 2 - _this.stoneSvga.height / 2 + props.boomPosition1Offset[1];
_this.waterSvga.x = _this.player.width / 2 - _this.waterSvga.width / 2 + props.boomPosition2Offset[0];
_this.waterSvga.y = _this.player.height / 2 - _this.waterSvga.height / 2 + props.boomPosition2Offset[1];
_this.boomSvga.x = _this.player.width / 2 - _this.boomSvga.width / 2 + props.boomPosition3Offset[0];
_this.boomSvga.y = _this.player.height / 2 - _this.boomSvga.height / 2 + props.boomPosition3Offset[1];
}, 300);
this.rectBg = new engine.Container();
this.rectBg.alpha = 0;
this.rectBg.width = 750;
this.rectBg.height = 1624;
this.addChild(this.rectBg);
this.rectBg.addEventListener(engine.MouseEvent.MOUSE_DOWN, this.onDownStage, this);
this.rectBg.addEventListener(engine.MouseEvent.MOUSE_MOVE, this.onMoveStage, this);
this.rectBg.addEventListener(engine.MouseEvent.MOUSE_OUT, this.onOutStage, this);
document.addEventListener("visibilitychange", function () {
if (document.visibilityState == "visible") {
_this.viewVisible = true;
}
if (document.visibilityState == "hidden") {
_this.viewVisible = false;
}
});
this.addEventListener(engine.Event.ENTER_FRAME, this.enterFrame, this);
};
GameView.prototype.enterFrame = function () {
this.updateTime();
this.updateTimeBeginNpc();
};
GameView.prototype.reset = function () {
this.score = props.speed;
this.recycleGoods();
this.player.x = 375 - this.player.width / 2;
};
GameView.prototype.start = function () {
this.score = 0;
this.speed = 1;
this.gameIng = true;
this.beginNpc();
this.countdown = props.countDown;
};
GameView.prototype.updateTime = function () {
if (Date.now() - this.cacheTime > 1000) {
this.cacheTime = Date.now();
}
else {
return;
}
if (this.gameIng) {
if (this.countdown > 0) {
engine.globalEvent.dispatchEvent('food-fell-time-update', {
time: this.countdown,
});
this.countdown -= 1;
}
else {
engine.globalEvent.dispatchEvent('food-fell-game-over', {
score: this.score,
reason: 1
});
this.died();
}
}
};
GameView.prototype.beginNpc = function () {
};
GameView.prototype.updateTimeBeginNpc = function () {
if (Date.now() - this.cacheTime2 > (2000 / this.speed)) {
this.cacheTime2 = Date.now();
}
else {
return;
}
if (this.gameIng) {
this.speed += props.acceleratedSpeed;
if (this.speed >= props.maxSpeed) {
this.speed = props.maxSpeed;
}
this.creatNpc();
}
};
GameView.prototype.pause = function () {
this.gameIng = false;
};
GameView.prototype.revive = function () {
this.gameIng = true;
};
GameView.prototype.resume = function () {
this.reset();
this.start();
};
GameView.prototype.creatNpc = function () {
var _this = this;
var goods = this._goods = ObjectPool$1.getObject(PoolName);
this.goodsItems.push(goods);
this.NpcBg.addChild(goods);
goods.addEventListener(engine.Event.ENTER_FRAME, goods["onGoodsEnter"] = function () {
if (goods.y > 1624) {
_this.removeNpc(goods);
}
else {
if (_this.gameIng) {
goods.y += (4 * _this.speed);
if (_this.hasHit(_this.player, goods)) {
if (goods["npcType"].indexOf("rain") > -1) {
_this.score += props.rainScore;
_this.waterSvga.visible = true;
_this.waterSvga.play(false, false);
_this.waterSvga.once(engine.Event.END_FRAME, function () {
_this.waterSvga.visible = false;
}, _this);
if (_this.score < 0) {
_this.score = 0;
}
}
else if (goods["npcType"] == "stone") {
_this.score += props.stoneScore;
if (_this.score < 0) {
_this.score = 0;
}
_this.stoneSvga.visible = true;
_this.stoneSvga.play(false, false);
_this.stoneSvga.once(engine.Event.END_FRAME, function () {
_this.stoneSvga.visible = false;
}, _this);
}
else if (goods["npcType"] == "boom") {
_this.boomSvga.visible = true;
_this.boomSvga.play(false, false);
_this.died();
_this.boomSvga.once(engine.Event.END_FRAME, function () {
_this.boomSvga.visible = false;
engine.globalEvent.dispatchEvent('food-fell-game-over', {
score: _this.score,
reason: 2
});
}, _this);
}
engine.globalEvent.dispatchEvent('food-fell-score-update', {
score: _this.score,
});
_this.removeNpc(goods);
}
}
}
}, this);
};
GameView.prototype.died = function () {
this.pause();
};
GameView.prototype.removeNpc = function (goods) {
this.NpcBg.removeChild(goods);
ObjectPool$1.recycleObject(PoolName, goods);
goods.removeEventListener(engine.Event.ENTER_FRAME, goods["onGoodsEnter"], this);
var index = this.goodsItems.indexOf(goods);
if (index > -1) {
this.goodsItems.splice(index, 1);
}
};
GameView.prototype.recycleGoods = function () {
clearTimeout(this.timer);
clearInterval(this.countdownTimer);
for (var _i = 0, _a = this.goodsItems; _i < _a.length; _i++) {
var goods = _a[_i];
if (goods) {
this.NpcBg.removeChild(goods);
ObjectPool$1.recycleObject(PoolName, goods);
goods.removeEventListener(engine.Event.ENTER_FRAME, goods["onGoodsEnter"], this);
}
}
this.goodsItems = [];
};
GameView.prototype.hasHit = function (a, b) {
var playerH = a.height;
var playerW = a.width;
var playerX = a.x;
if (props.playerHeight) {
playerH = props.playerHeight;
}
if (props.playerWidth) {
playerW = props.playerWidth;
playerX = a.x + (a.width - props.playerWidth) / 2;
}
if (Math.abs((playerX + playerW / 2) - (b.x + b.width / 2)) < playerW / 2 + b.width / 2
&&
Math.abs((a.y + playerH / 1.3) - (b.y + b.height / 2)) < playerH / 2 + b.height / 2) {
return true;
}
else {
return false;
}
};
return GameView;
}(engine.Container));
var GameWrapper = (function (_super) {
tslib.__extends(GameWrapper, _super);
function GameWrapper() {
var _this = _super.call(this) || this;
engine.globalEvent.addEventListener('food-fell-reset', _this.reset, _this);
engine.globalEvent.addEventListener('food-fell-start', _this.start, _this);
engine.globalEvent.addEventListener('food-fell-pause', _this.pause, _this);
engine.globalEvent.addEventListener('food-fell-resume', _this.resume, _this);
engine.globalEvent.addEventListener('food-fell-revive', _this.revive, _this);
engine.globalEvent.addEventListener('food-fell-clear', _this.clear, _this);
_this.addEventListener(engine.MouseEvent.CLICK, _this.onTap, _this);
var gameView = _this._gameView = new GameView();
_this.addChild(gameView);
return _this;
}
GameWrapper.prototype.reset = function (event) {
injectProps(event.data);
this._gameView.visible = true;
this._gameView.reset();
};
GameWrapper.prototype.start = function (event) {
injectProps(event.data);
this._status = 1;
this._gameView.start();
};
GameWrapper.prototype.pause = function () {
this._gameView.pause();
};
GameWrapper.prototype.resume = function () {
this._gameView.resume();
};
GameWrapper.prototype.revive = function () {
this._gameView.revive();
};
GameWrapper.prototype.clear = function () {
this._gameView.visible = false;
};
GameWrapper.prototype.onTap = function (event) {
};
return GameWrapper;
}(engine.Container));
function index (props) {
prepareProps();
injectProps(props);
var instance = new GameWrapper();
return instance;
}
return index;
})));
//# sourceMappingURL=main.js.map
\ No newline at end of file
{"version":3,"file":"index.js","sources":["src/custom/food-fell2/src/props.ts","src/custom/food-fell2/src/game/utils.ts","src/custom/food-fell2/src/game/Goods.ts","src/custom/food-fell2/src/game/object-pool-init.ts","src/custom/food-fell2/src/game/GameView.ts","src/custom/food-fell2/src/game/GameWrapper.ts","src/custom/food-fell2/src/index.ts"],"sourcesContent":["/**\n * Created by rockyl on 2020-01-21.\n */\n\nexport let props: any = {};\n\nexport function prepareProps() {\n\tlet metaProps = getProps();\n\n\tengine.injectProp(props, metaProps);\n}\n\nexport function injectProps(p) {\n\tengine.injectProp(props, p);\n}\n","/**\n * Created by rockyl on 2020-01-21.\n */\n\nexport function getTexture(uuid) {\n\treturn engine.Texture.from(getAssetByUUID(uuid).uuid);\n}\n\nexport function getTextureByName(name) {\n\treturn engine.Texture.from(getAssetByName(name).uuid);\n}\n\nexport function playSound(name) {\n\tengine.playSound(getAssetByName(name).uuid, {keep: true});\n}\nexport function createSvga(name, anchorName?) {\n\tlet inst = new svga.Svga();\n\tinst.source = 'asset://' + getAssetByName(name).uuid;\n\treturn inst;\n}","/**\n * Created by rockyl on 2020-02-02.\n *\n * 掉落物品\n */\nimport {getTextureByName} from \"./utils\";\nimport {props} from \"../props\";\n\nexport class Goods extends engine.Container {\n\tprivate _body:engine.Rect\n\tprivate _toY;\n\n\tconstructor() {\n\t\tsuper();\n\n\t\tlet body\n\t\tbody = this._body =new engine.Rect()\n\t\t\n\t\t// let randomNum = Math.floor(Math.random() * 3)\t\t\n\t\t// console.log('雨滴' + randomNum);\n\t\t\n\t\tlet rain = new engine.Sprite(getTextureByName('雨滴0'));\n\t\tlet rain1 = new engine.Sprite(getTextureByName('雨滴1'));\n\t\tlet rain2 = new engine.Sprite(getTextureByName('雨滴2'));\n\t\train[\"npcType\"]=\"rain0\"\n\t\train1[\"npcType\"]=\"rain1\"\n\t\train2[\"npcType\"]=\"rain2\"\n\t\tlet stone = new engine.Sprite(getTextureByName('石块'));\n\t\tstone[\"npcType\"]=\"stone\"\n\t\tlet boom = new engine.Sprite(getTextureByName('炸弹'));\n\t\tboom[\"npcType\"]=\"boom\"\n\n\t\train.visible=false;\n\t\train1.visible=false;\n\t\train2.visible=false;\n\t\tstone.visible=false;\n\t\tboom.visible=false;\n\t\tbody.addChild(rain)\n\t\tbody.addChild(rain1)\n\t\tbody.addChild(rain2)\n\t\tbody.addChild(stone)\n\t\tbody.addChild(boom)\n\t\t\n\t\tthis.addChild(body);\n\t\tbody.width=.0001;\n\t\tbody.height=.0001;\n\t\tbody.mouseEnabled=false;\n\t}\n\n\n\tgetRandomNumberByRange(start, end) {\n\t\treturn Math.floor(Math.random() * (end - start) + start)\n\t}\n\n\treset() {\n\t\tthis.visible = true;\n\t\tthis.rotation = 0;\n\t\tthis.anchorOffsetY = 0;\n\t\tthis.y = 0;\n\t\tthis.x = (750-120)*Math.random()+30;\n\t\tthis.rotation = 0;\n\t\tlet random=Math.random()\n\t\tif(typeof (props.goodsProbability) == 'string'){\n\t\t\tprops.goodsProbability=props.goodsProbability.split(',').map((i: string) => +i)\n\t\t\t//console.log(props.goodsProbability);\n\t\t\t\n\t\t}\n\t\tif(random<props.goodsProbability[0]){\n\t\t\tlet randomNum = Math.floor(Math.random() * 3)\t\t\n\t\t\tthis.showNpc(\"rain\" + randomNum)\n\t\t}else if(random>=props.goodsProbability[0]&&random<=(props.goodsProbability[0]+props.goodsProbability[1])){\n\t\t\tthis.showNpc(\"stone\")\n\t\t}else if(random>(props.goodsProbability[0]+props.goodsProbability[1])){\n\t\t\tthis.showNpc(\"boom\")\n\t\t}\n\t}\n\n\n\tshowNpc(type){\n\t\tfor(let i=0;i<this._body.children.length;i++){\n\t\t\tthis._body.children[i].visible=false;\n\t\t\tthis._body.children[i].mouseEnabled=false;\n\t\t}\t\t\n\t\tfor(let i=0;i<this._body.children.length;i++){\n\t\t\tif(this._body.children[i][\"npcType\"]==type){\n\t\t\t\tthis[\"npcType\"]=type\n\t\t\t\tthis._body.children[i].visible=true;\n\t\t\t\tthis._body.children[i].mouseEnabled=false;\n\t\t\t}\n\t\t}\n\t\t\n\t}\n\n\tset anchorOffsetY(v) {\n\t\tthis._body.y = v;\n\t}\n}\n","/**\n * Created by rockyl on 2020-02-03.\n */\n\nimport {Goods} from \"./Goods\";\nimport ObjectPool = engine.ObjectPool;\n\nexport const PoolName: string = 'goods';\n\nObjectPool.registerPool(PoolName, function () {\n\treturn new Goods();\n}, function (item: Goods, data) {\n\titem.reset();\n});\n","/**\n * Created by rockyl on 2018/8/16.\n */\n\nimport { props } from \"../props\";\nimport { playSound, createSvga } from \"./utils\";\nimport ObjectPool = engine.ObjectPool;\nimport { getTextureByName } from \"./utils\";\nimport { Goods } from \"./Goods\";\nimport { PoolName } from \"./object-pool-init\";\n\n\n\nexport default class GameView extends engine.Container {\n\n\tprivate _hasSetup;\n\n\t//玩家\n\tprivate player: engine.Container;\n\t//触摸层\n\t// private rectBg: engine.Rect;\n\tprivate rectBg: engine.Container;\n\t//npc层\n\tprivate NpcBg: engine.Container;\n\n\t//当前分数\n\tprivate score\n\n\t//游戏状态\n\tprivate gameIng;\n\n\t//npc出身计时器\n\tprivate timer\n\t//倒计时计时器\n\tprivate countdownTimer: any\n\t//倒计时\n\tprivate countdown: number\n\n\t//当前速度\n\tprivate speed: number\n\n\t// 当前场景上面的物品\n\tprivate goodsItems = []\n\n\tprivate viewVisible=true;\n\n\n\tprivate _goods: Goods;\n\n\tconstructor() {\n\t\tsuper();\n\t\tthis.once(engine.Event.ADDED_TO_STAGE, this.setup, this);\n\t}\n\n\tprivate waterSvga\n\tprivate stoneSvga\n\tprivate boomSvga\n\tprivate playerSvga\n\n\tsetup() {\n\t\tif (this._hasSetup) {\n\t\t\treturn;\n\t\t}\n\t\tthis._hasSetup = true;\n\t\tthis.NpcBg = new engine.Container();\n\t\tthis.NpcBg.alpha = 1;\n\t\tthis.NpcBg.width = 0;\n\t\tthis.NpcBg.height = 0;\n\t\tthis.addChild(this.NpcBg);\n\n\t\n\n\t\tthis.player = new engine.Container();\n\t\tthis.player.mouseEnabled = false;\n\t//\tthis.player.fillColor=\"rgba(0, 0, 0,1)\"\n\t\t//console.log(this.player.fillColor)\n\t\n\t\tthis.addChild(this.player);\n\n\t\tthis.waterSvga=createSvga(\"水花\")\n\t\tthis.stoneSvga=createSvga(\"石头svga\")\n\t\t// this.playerSvga=createSvga(\"玩家\")\n\t\tthis.playerSvga= new engine.Sprite(getTextureByName('玩家'))\n\t\tthis.boomSvga=createSvga(\"炸弹svga\")\n\t\tthis.player.addChild(this.playerSvga);\n\t\tthis.player.addChild(this.stoneSvga);\n\t\tthis.player.addChild(this.waterSvga);\n\t\tthis.player.addChild(this.boomSvga);\n\t\t// this.playerSvga.gotoAndPlay(1);\n\n\t\t\n\n\t\tthis.waterSvga.visible = false\n\t\tthis.stoneSvga.visible = false\n\t\tthis.boomSvga.visible = false\n\t\t\n\t\tthis.visible=false;\n\t\tsetTimeout(()=>{\n\t\t\tthis.visible=true;\n\t\t\tthis.player.anchorY = this.player.height / 2;\n\t\t\tthis.player.anchorX = this.player.width / 2;\n\t\t\tthis.player.x = 375 - this.player.width / 2;\n\t\t\tthis.player.y = props.playerPositionY;\n\n\t\t\tthis.stoneSvga.x = this.player.width / 2 - \tthis.stoneSvga.width/2 + props.boomPosition1Offset[0];\n\t\t\tthis.stoneSvga.y = this.player.height / 2 - this.stoneSvga.height/2 + props.boomPosition1Offset[1];\n\n\t\t\tthis.waterSvga.x = this.player.width / 2 - \tthis.waterSvga.width/2+ props.boomPosition2Offset[0];\n\t\t\tthis.waterSvga.y = this.player.height / 2 - this.waterSvga.height/2 + props.boomPosition2Offset[1];\n\n\t\t\tthis.boomSvga.x = this.player.width / 2 - \tthis.boomSvga.width/2+ props.boomPosition3Offset[0];\n\t\t\tthis.boomSvga.y = this.player.height / 2 - this.boomSvga.height/2 + props.boomPosition3Offset[1];\n\n\t\t\t// this.stoneSvga.x=props.boomPositionOffset[0]\n\t\t\t// this.stoneSvga.y=props.boomPositionOffset[1]\n\n\t\t\t// this.waterSvga.x=props.boomPositionOffset[0]\n\t\t\t// this.waterSvga.y=props.boomPositionOffset[1]\n\n\t\t\t// this.boomSvga.x=props.boomPositionOffset[0]\n\t\t\t// this.boomSvga.y=props.boomPositionOffset[1]\n\n\t\t\t\n\t\t},300)\n\n\t\t\n\t\tthis.rectBg = new engine.Container();\n\t\tthis.rectBg.alpha = 0;\n\t\tthis.rectBg.width = 750;\n\t\tthis.rectBg.height = 1624;\n\t\tthis.addChild(this.rectBg)\n\n\t\tthis.rectBg.addEventListener(engine.MouseEvent.MOUSE_DOWN, this.onDownStage, this);\n\t\tthis.rectBg.addEventListener(engine.MouseEvent.MOUSE_MOVE, this.onMoveStage, this);\n\t\tthis.rectBg.addEventListener(engine.MouseEvent.MOUSE_OUT, this.onOutStage, this);\n\n\n\t\tdocument.addEventListener(\"visibilitychange\",()=>{\n\t\t\tif(document.visibilityState==\"visible\"){\n\t\t\t\tthis.viewVisible=true;\n\t\t\t}\n\t\t\tif(document.visibilityState==\"hidden\"){\n\t\t\t\tthis.viewVisible=false;\n\t\t\t}\n\t\t})\n\n\t\tthis.addEventListener(engine.Event.ENTER_FRAME, this.enterFrame,this)\n\t\n\t}\n\n\tenterFrame(){\n\t\tthis.updateTime()\n\t\tthis.updateTimeBeginNpc()\n\t}\n\n\n\t/**\n\t * 重置场景\n\t */\n\treset() {\n\t\tthis.score = props.speed\n\t\tthis.recycleGoods()\n\t\tthis.player.x = 375 - this.player.width / 2;\n\t}\n\n\t/**\n\t * 开始\n\t */\n\tstart() {\n\t\tthis.score = 0;\n\t\tthis.speed = 1\n\t\tthis.gameIng = true;\n\t\t//this.creatNpc()\n\t\tthis.beginNpc()\n\t\tthis.countdown = props.countDown;\n\t}\n\n\tcacheTime=0\n\tupdateTime(){\n\t\tif(Date.now()-this.cacheTime>1000){\n\t\t\tthis.cacheTime=Date.now()\n\t\t}else{\n\t\t\treturn;\n\t\t}\n\t\tif (this.gameIng) {\n\t\t\tif (this.countdown > 0) {\n\t\t\t\tengine.globalEvent.dispatchEvent('food-fell-time-update', {\n\t\t\t\t\ttime: this.countdown,\n\t\t\t\t});\n\t\t\t\tthis.countdown -= 1\n\t\t\t} else {\n\t\t\t\tengine.globalEvent.dispatchEvent('food-fell-game-over', {\n\t\t\t\t\tscore: this.score,\n\t\t\t\t\treason: 1\n\t\t\t\t});\n\t\t\t\tthis.died()\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * npc开始掉落\n\t */\n\tbeginNpc() {\n\t\t// this.timer = setTimeout(() => {\n\t\t\t\n\t\t// \t//递归执行\n\t\t// \tthis.beginNpc()\n\t\t// }, 2000 / this.speed)\n\t}\n\n\tcacheTime2=0\n\tupdateTimeBeginNpc(){\n\t\tif(Date.now()-this.cacheTime2>(2000 / this.speed)){\n\t\t\tthis.cacheTime2=Date.now()\n\t\t}else{\n\t\t\treturn;\n\t\t}\n\t\tif (this.gameIng) {\n\t\t\tthis.speed += props.acceleratedSpeed;\n\t\t\tif(this.speed >= props.maxSpeed){\n\t\t\t\tthis.speed = props.maxSpeed\n\t\t\t}\n\t\t\tthis.creatNpc()\n\t\t}\n\t}\n\n\t/**\n\t * 暂停\n\t */\n\tpause() {\n\t\tthis.gameIng = false;\n\t}\n\n\t/**\n\t * 恢复\n\t */\n\trevive() {\n\t\tthis.gameIng = true;\n\t}\n\n\t/**\n\t * 重新开始\n\t */\n\tresume() {\n\t\tthis.reset()\n\t\tthis.start()\n\t}\n\n\t/**\n\t * 创建NPC\n\t */\n\tprivate creatNpc() {\n\t\tlet goods = this._goods = <Goods>ObjectPool.getObject(PoolName);\n\t\tthis.goodsItems.push(goods)\n\t\t//console.log(goods);\n\t\t\n\t\tthis.NpcBg.addChild(goods);\n\t\tgoods.addEventListener(engine.Event.ENTER_FRAME, goods[\"onGoodsEnter\"] = () => {\n\t\t\tif (goods.y > 1624) {\n\t\t\t\tthis.removeNpc(goods)\n\t\t\t} else {\n\t\t\t\tif (this.gameIng) {\n\t\t\t\t\t//速度叠加\n\t\t\t\t\tgoods.y += (4 * this.speed)\n\t\t\t\t\t//如果玩家和物品发生碰撞\n\t\t\t\t\tif (this.hasHit(this.player, goods)) {\n\t\t\t\t\t\tif (goods[\"npcType\"].indexOf(\"rain\") > -1) {\n\t\t\t\t\t\t\t//console.log(\"碰到雨滴\")\n\t\t\t\t\t\t\tthis.score += props.rainScore;\n\t\t\t\t\t\t\tthis.waterSvga.visible=true;\n\t\t\t\t\t\t//\tthis.waterSvga.x= goods.x - this.player.x;\n\t\t\t\t\t\t\tthis.waterSvga.play(false, false)\n\t\t\t\t\t\t\tthis.waterSvga.once(engine.Event.END_FRAME, ()=>{\n\t\t\t\t\t\t\t\tthis.waterSvga.visible=false;\n\t\t\t\t\t\t\t}, this);\n\n\t\t\t\t\t\t\tif(this.score<0){\n\t\t\t\t\t\t\t\tthis.score=0;\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t} else if (goods[\"npcType\"] == \"stone\") {\n\t\t\t\t\t\t\t//console.log(\"碰到石头\")\n\t\t\t\t\t\t\tthis.score += props.stoneScore\n\t\t\t\t\t\t\tif(this.score<0){\n\t\t\t\t\t\t\t\tthis.score=0;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tthis.stoneSvga.visible=true;\n\t\t\t\t\t\t\tthis.stoneSvga.play(false, false)\n\t\t\t\t\t\t\tthis.stoneSvga.once(engine.Event.END_FRAME, ()=>{\n\t\t\t\t\t\t\t\tthis.stoneSvga.visible=false;\n\t\t\t\t\t\t\t}, this);\n\t\t\t\t\t\t} else if (goods[\"npcType\"] == \"boom\") {\n\t\t\t\t\t\t\t//console.log(\"碰到炸弹\")\n\t\t\t\t\t\t\tthis.boomSvga.visible=true;\n\t\t\t\t\t\t\tthis.boomSvga.play(false, false)\n\t\t\t\t\t\t\tthis.died()\n\t\t\t\t\t\t\tthis.boomSvga.once(engine.Event.END_FRAME, ()=>{\n\t\t\t\t\t\t\t\tthis.boomSvga.visible=false;\n\t\t\t\t\t\t\t\tengine.globalEvent.dispatchEvent('food-fell-game-over', {\n\t\t\t\t\t\t\t\t\tscore: this.score,\n\t\t\t\t\t\t\t\t\treason: 2\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t}, this);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tengine.globalEvent.dispatchEvent('food-fell-score-update', {\n\t\t\t\t\t\t\tscore: this.score,\n\t\t\t\t\t\t});\n\t\t\t\t\t\tthis.removeNpc(goods)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t}, this);\n\t}\n\n\t/**\n\t * 玩家死亡\n\t */\n\tprivate died() {\n\t\tthis.pause();\n\t}\n\n\t/**\n\t * 回收指定物品\n\t * @param goods 物品\n\t */\n\tprivate removeNpc(goods) {\n\t\tthis.NpcBg.removeChild(goods);\n\t\tObjectPool.recycleObject(PoolName, goods);\n\t\tgoods.removeEventListener(engine.Event.ENTER_FRAME, goods[\"onGoodsEnter\"], this);\n\t\tlet index = this.goodsItems.indexOf(goods);\n\t\tif (index > -1) {\n\t\t\tthis.goodsItems.splice(index, 1);\n\t\t}\n\t}\n\n\t/**\n\t * 回收对象\n\t */\n\tprivate recycleGoods() {\n\t\tclearTimeout(this.timer)\n\t\tclearInterval(this.countdownTimer)\n\t\tfor (let goods of this.goodsItems) {\n\t\t\tif (goods) {\n\t\t\t\tthis.NpcBg.removeChild(goods);\n\t\t\t\tObjectPool.recycleObject(PoolName, goods);\n\t\t\t\tgoods.removeEventListener(engine.Event.ENTER_FRAME, goods[\"onGoodsEnter\"], this);\n\t\t\t}\n\t\t}\n\t\tthis.goodsItems = []\n\t}\n\n\tprivate moveCatchX = 0\n\tprivate playerCatchX = 0\n\n\t/**\n\t * 碰撞检测\n\t * @param a a盒子\n\t * @param b b盒子\n\t */\n\tprivate hasHit(a, b) {\n\n\t\tlet playerH=a.height\n\t\tlet playerW=a.width\n\t\tlet playerX=a.x\n\t\tif(props.playerHeight){\n\t\t\tplayerH=props.playerHeight\n\t\t}\n\t\tif(props.playerWidth){\n\t\t\tplayerW=props.playerWidth\n\t\t\tplayerX=a.x+(a.width-props.playerWidth)/2\n\t\t}\n\n\t\tif (\n\t\t\tMath.abs((playerX + playerW / 2) - (b.x + b.width / 2)) < playerW / 2 + b.width / 2\n\t\t\t&&\n\t\t\t// Math.abs((a.y + a.height / 2 ) - (b.y + b.height / 2)) < a.height / 2 + b.height / 2\n\t\t\tMath.abs((a.y + playerH / 1.3 ) - (b.y + b.height / 2)) < playerH / 2 + b.height / 2\n\t\t) {\n\t\t\treturn true;\n\t\t} else {\n\t\t\treturn false;\n\t\t}\n\t}\n\n\tprivate onDownStage = (e) => {\n\t\tthis.moveCatchX = e.localX;\n\t\tthis.playerCatchX = this.player.x\n\t}\n\n\tprivate onMoveStage = (e) => {\n\t\tlet maxStageBound=props.maxStageBound;\n\t\tif (this.gameIng) {\n\t\t\tlet playerX=this.playerCatchX + (e.localX - this.moveCatchX)\n\t\t\tif(playerX<maxStageBound){\n\t\t\t\tthis.player.x=maxStageBound\n\t\t\t}else if(playerX+this.player.width+maxStageBound>750){\n\t\t\t\tthis.player.x=750-maxStageBound-this.player.width\n\t\t\t}else{\n\t\t\t\tthis.player.x=playerX\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate onOutStage = (e) => {\n\t\tthis.moveCatchX = 0\n\t}\n}\n","/**\n * Created by rockyl on 2020-01-09.\n */\n\nimport GameView from \"./GameView\";\nimport {injectProps} from \"../props\";\n\n\nexport class GameWrapper extends engine.Container {\n\tprivate _status;\n\tprivate _gameView: GameView;\n\n\n\n\n\n\tconstructor() {\n\t\tsuper();\n\t\tengine.globalEvent.addEventListener('food-fell-reset', this.reset, this);\n\t\tengine.globalEvent.addEventListener('food-fell-start', this.start, this);\n\t\tengine.globalEvent.addEventListener('food-fell-pause', this.pause, this);\n\t\tengine.globalEvent.addEventListener('food-fell-resume', this.resume, this);\n\t\tengine.globalEvent.addEventListener('food-fell-revive', this.revive, this);\n\t\tengine.globalEvent.addEventListener('food-fell-clear', this.clear, this);\n\n\t\tthis.addEventListener(engine.MouseEvent.CLICK, this.onTap, this);\n\n\t\tlet gameView = this._gameView = new GameView();\n\t\tthis.addChild(gameView);\n\t\t// gameView.reset()\n\t\t// gameView.start()\n\t}\n\n\treset(event: engine.Event) {\t\t\n\t\tinjectProps(event.data);\n\t\tthis._gameView.visible = true;\n\t\tthis._gameView.reset();\n\t}\n\n\tstart(event: engine.Event) {\n\t\tinjectProps(event.data);\n\t\tthis._status = 1;\n\t\tthis._gameView.start();\n\t}\n\n\tpause() {\n\t\tthis._gameView.pause();\n\t}\n\n\tresume() {\n\t\tthis._gameView.resume();\n\t}\n\n\trevive() {\n\t\tthis._gameView.revive();\n\t}\n\n\tclear() {\n\t\tthis._gameView.visible = false;\n\t}\n\n\tprivate onTap(event) {\n\t//\tthis._gameView.tap(event);\n\t}\n}\n","/**\n * Created by rockyl on 2019-11-20.\n */\n\nimport {GameWrapper} from \"./game/GameWrapper\";\nimport {injectProps, prepareProps} from \"./props\";\n\nexport default function (props) {\n\tprepareProps();\n\tinjectProps(props);\n\n\tlet instance = new GameWrapper();\n\treturn instance;\n}\n"],"names":["__extends","ObjectPool"],"mappings":";;;;;;CAIO,IAAI,KAAK,GAAQ,EAAE,CAAC;AAE3B,UAAgB,YAAY;KAC3B,IAAI,SAAS,GAAG,QAAQ,EAAE,CAAC;KAE3B,MAAM,CAAC,UAAU,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC;CACrC,CAAC;AAED,UAAgB,WAAW,CAAC,CAAC;KAC5B,MAAM,CAAC,UAAU,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;CAC7B,CAAC;;UCNe,gBAAgB,CAAC,IAAI;KACpC,OAAO,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,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EAAE,CAAC;MACvB;KAED,2BAAK,GAAL,UAAM,KAAmB;SACxB,WAAW,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;SACxB,IAAI,CAAC,OAAO,GAAG,CAAC,CAAC;SACjB,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,CAAC;MACvB;KAED,2BAAK,GAAL;SACC,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,CAAC;MACvB;KAED,4BAAM,GAAN;SACC,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,CAAC;MACxB;KAED,4BAAM,GAAN;SACC,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,CAAC;MACxB;KAED,2BAAK,GAAL;SACC,IAAI,CAAC,SAAS,CAAC,OAAO,GAAG,KAAK,CAAC;MAC/B;KAEO,2BAAK,GAAb,UAAc,KAAK;MAElB;KACF,kBAAC;CAAD,CAAC,CAxDgC,MAAM,CAAC,SAAS,GAwDhD;;iBCzDwB,KAAK;KAC7B,YAAY,EAAE,CAAC;KACf,WAAW,CAAC,KAAK,CAAC,CAAC;KAEnB,IAAI,QAAQ,GAAG,IAAI,WAAW,EAAE,CAAC;KACjC,OAAO,QAAQ,CAAC;CACjB,CAAC;;;;;;;;"}
\ No newline at end of file
/**
* Created by rockyl on 2020-01-21.
*/
let customModuleProps = {
};
{
"name": "接粽子",
"desc": "接粽子模块",
"props": {
"playerPositionY": {
"alias": "玩家Y轴位置",
"type": "number",
"default": 900
},
"rainScore": {
"alias": "接中雨滴获得分数",
"type": "number",
"default": 1
},
"stoneScore": {
"alias": "接中石块获得分数",
"type": "number",
"default": -1
},
"speed": {
"alias": "道具掉落初始速度",
"type": "number",
"default": 1
},
"maxSpeed": {
"alias": "道具掉落速度上限",
"type": "number",
"default": 3
},
"playerHeight": {
"alias": "玩家高度",
"type": "number",
"default": 100
},
"playerWidth": {
"alias": "玩家宽度",
"type": "number",
"default": 100
},
"maxStageBound": {
"alias": "最大移动边距",
"type": "number",
"default": -20
},
"gameOverCondition": {
"alias": "游戏结束条件(1:接到炸弹死亡,2:分数负数或接到炸弹死亡)",
"type": "number",
"default": 1
},
"boomPosition1Offset": {
"alias": "爆炸svga位置偏移[x,y]",
"type": "array<number>",
"default": "0,0"
}
,
"boomPosition2Offset": {
"alias": "爆炸svga位置偏移[x,y]",
"type": "array<number>",
"default": "0,0"
}
,
"boomPosition3Offset": {
"alias": "爆炸svga位置偏移[x,y]",
"type": "array<number>",
"default": "-100,-100"
}
},
"assets": [
{
"name": "雨滴0",
"url": "//yun.duiba.com.cn/aurora/assets/badb3627bbcc75276a3eed53daa8b0a454ced6eb.png",
"uuid": "d3ce99da-89e1-447d-8c52-b3f391925c3c",
"ext": ".png"
},
{
"name": "雨滴1",
"url": "//yun.duiba.com.cn/aurora/assets/5cc0092913c571eeb52317b8e1e0dc715793049c.png",
"uuid": "02f17008-1d8d-4108-a0fc-03fbc71fd118",
"ext": ".png"
},
{
"name": "雨滴2",
"url": "//yun.duiba.com.cn/aurora/assets/4b938949b85d50b36ef0f66450643495efbf7580.png",
"uuid": "46aa4f8a-9a6c-4210-8ffd-92da0dd3bc75",
"ext": ".png"
},
{
"name": "炸弹",
"url": "//yun.duiba.com.cn/aurora/assets/171e92283cd13c013ee1b76d28d252ff08815d47.png",
"uuid": "eb88b42d-e151-4c1b-94b9-7c16f7bfac29",
"ext": ".png"
},
{
"name": "石块",
"url": "//yun.duiba.com.cn/aurora/assets/99b0af0c59fe79a415a3f032149cfacc27e3ac2c.png",
"uuid": "ab1bdabc-21ba-46bf-9299-6c638f766c88",
"ext": ".png"
},
{
"name": "水花",
"url": "//yun.duiba.com.cn/aurora/assets/11b1f49fa3afa3a48f1dd3e3c1eb294e3fa9d886.svga",
"uuid": "cdd2268f-ad65-4b5e-a965-ee61b730da21",
"ext": ".svga"
},
{
"name": "石头svga",
"url": "//yun.duiba.com.cn/aurora/assets/01aa6fcb33aa8231f075257026eab2f0aeb3c27a.svga",
"uuid": "846a139d-0990-4db4-a323-f22379932ee4",
"ext": ".svga"
},
{
"name": "炸弹svga",
"url": "//yun.duiba.com.cn/aurora/assets/3b58e7ace031b09c651cf8e7202f9c86e86852c9.svga",
"uuid": "d7a3947b-7fcb-48f2-9ddf-2f075d37a619",
"ext": ".svga"
},
{
"name": "玩家",
"url": "//yun.duiba.com.cn/aurora/assets/db0130d36ef79865be9c753ea0627027f16341d8.png",
"uuid": "4931d296-4421-4a2f-8299-7bab87407c72",
"ext": ".png"
}
],
"events": {
"in": {
"food-fell-reset": {
"alias": "重置",
"data": {
"goodsProbability": "[0.2,0.5,0.3]道具概率(雨滴、石头、炸弹),所有概率相加为1",
"countDown": "倒计时(s)",
"acceleratedSpeed":"道具掉落加速度(单位:每秒)"
}
},
"food-fell-start": {
"alias": "开始"
},
"food-fell-revive": {
"alias": "复活"
},
"food-fell-pause": {
"alias": "暂停"
},
"food-fell-resume": {
"alias": "恢复"
},
"food-fell-clear": {
"alias": "清空,通过reset事件恢复"
}
},
"out": {
"food-fell-score-update": {
"alias": "分数更新",
"data": {
"score":"分数"
}
},
"food-fell-time-update": {
"alias": "倒计时更新",
"data": {
"time":"剩余时间"
}
},
"food-fell-game-over": {
"alias": "游戏结束",
"data": {
"score":"分数",
"reason": "结束原因(1:时间到了,2:玩家死亡)"
}
}
}
}
}
\ No newline at end of file
/**
* Created by rockyl on 2018/8/16.
*/
import { props } from "../props";
import { playSound, createSvga } from "./utils";
import ObjectPool = engine.ObjectPool;
import { getTextureByName } from "./utils";
import { Goods } from "./Goods";
import { PoolName } from "./object-pool-init";
export default class GameView extends engine.Container {
private _hasSetup;
//玩家
private player: engine.Container;
//触摸层
// private rectBg: engine.Rect;
private rectBg: engine.Container;
//npc层
private NpcBg: engine.Container;
//当前分数
private score
//游戏状态
private gameIng;
//npc出身计时器
private timer
//倒计时计时器
private countdownTimer: any
//倒计时
private countdown: number
//当前速度
private speed: number
// 当前场景上面的物品
private goodsItems = []
private viewVisible=true;
private _goods: Goods;
constructor() {
super();
this.once(engine.Event.ADDED_TO_STAGE, this.setup, this);
}
private waterSvga
private stoneSvga
private boomSvga
private playerSvga
setup() {
if (this._hasSetup) {
return;
}
this._hasSetup = true;
this.NpcBg = new engine.Container();
this.NpcBg.alpha = 1;
this.NpcBg.width = 0;
this.NpcBg.height = 0;
this.addChild(this.NpcBg);
this.player = new engine.Container();
this.player.mouseEnabled = false;
// this.player.fillColor="rgba(0, 0, 0,1)"
//console.log(this.player.fillColor)
this.addChild(this.player);
this.waterSvga=createSvga("水花")
this.stoneSvga=createSvga("石头svga")
// this.playerSvga=createSvga("玩家")
this.playerSvga= new engine.Sprite(getTextureByName('玩家'))
this.boomSvga=createSvga("炸弹svga")
this.player.addChild(this.playerSvga);
this.player.addChild(this.stoneSvga);
this.player.addChild(this.waterSvga);
this.player.addChild(this.boomSvga);
// this.playerSvga.gotoAndPlay(1);
this.waterSvga.visible = false
this.stoneSvga.visible = false
this.boomSvga.visible = false
this.visible=false;
setTimeout(()=>{
this.visible=true;
this.player.anchorY = this.player.height / 2;
this.player.anchorX = this.player.width / 2;
this.player.x = 375 - this.player.width / 2;
this.player.y = props.playerPositionY;
this.stoneSvga.x = this.player.width / 2 - this.stoneSvga.width/2 + props.boomPosition1Offset[0];
this.stoneSvga.y = this.player.height / 2 - this.stoneSvga.height/2 + props.boomPosition1Offset[1];
this.waterSvga.x = this.player.width / 2 - this.waterSvga.width/2+ props.boomPosition2Offset[0];
this.waterSvga.y = this.player.height / 2 - this.waterSvga.height/2 + props.boomPosition2Offset[1];
this.boomSvga.x = this.player.width / 2 - this.boomSvga.width/2+ props.boomPosition3Offset[0];
this.boomSvga.y = this.player.height / 2 - this.boomSvga.height/2 + props.boomPosition3Offset[1];
// this.stoneSvga.x=props.boomPositionOffset[0]
// this.stoneSvga.y=props.boomPositionOffset[1]
// this.waterSvga.x=props.boomPositionOffset[0]
// this.waterSvga.y=props.boomPositionOffset[1]
// this.boomSvga.x=props.boomPositionOffset[0]
// this.boomSvga.y=props.boomPositionOffset[1]
},300)
this.rectBg = new engine.Container();
this.rectBg.alpha = 0;
this.rectBg.width = 750;
this.rectBg.height = 1624;
this.addChild(this.rectBg)
this.rectBg.addEventListener(engine.MouseEvent.MOUSE_DOWN, this.onDownStage, this);
this.rectBg.addEventListener(engine.MouseEvent.MOUSE_MOVE, this.onMoveStage, this);
this.rectBg.addEventListener(engine.MouseEvent.MOUSE_OUT, this.onOutStage, this);
document.addEventListener("visibilitychange",()=>{
if(document.visibilityState=="visible"){
this.viewVisible=true;
}
if(document.visibilityState=="hidden"){
this.viewVisible=false;
}
})
this.addEventListener(engine.Event.ENTER_FRAME, this.enterFrame,this)
}
enterFrame(){
this.updateTime()
this.updateTimeBeginNpc()
}
/**
* 重置场景
*/
reset() {
this.score = props.speed
this.recycleGoods()
this.player.x = 375 - this.player.width / 2;
}
/**
* 开始
*/
start() {
this.score = 0;
this.speed = 1
this.gameIng = true;
//this.creatNpc()
this.beginNpc()
this.countdown = props.countDown;
}
cacheTime=0
updateTime(){
if(Date.now()-this.cacheTime>1000){
this.cacheTime=Date.now()
}else{
return;
}
if (this.gameIng) {
if (this.countdown > 0) {
engine.globalEvent.dispatchEvent('food-fell-time-update', {
time: this.countdown,
});
this.countdown -= 1
} else {
engine.globalEvent.dispatchEvent('food-fell-game-over', {
score: this.score,
reason: 1
});
this.died()
}
}
}
/**
* npc开始掉落
*/
beginNpc() {
// this.timer = setTimeout(() => {
// //递归执行
// this.beginNpc()
// }, 2000 / this.speed)
}
cacheTime2=0
updateTimeBeginNpc(){
if(Date.now()-this.cacheTime2>(2000 / this.speed)){
this.cacheTime2=Date.now()
}else{
return;
}
if (this.gameIng) {
this.speed += props.acceleratedSpeed;
if(this.speed >= props.maxSpeed){
this.speed = props.maxSpeed
}
this.creatNpc()
}
}
/**
* 暂停
*/
pause() {
this.gameIng = false;
}
/**
* 恢复
*/
revive() {
this.gameIng = true;
}
/**
* 重新开始
*/
resume() {
this.reset()
this.start()
}
/**
* 创建NPC
*/
private creatNpc() {
let goods = this._goods = <Goods>ObjectPool.getObject(PoolName);
this.goodsItems.push(goods)
//console.log(goods);
this.NpcBg.addChild(goods);
goods.addEventListener(engine.Event.ENTER_FRAME, goods["onGoodsEnter"] = () => {
if (goods.y > 1624) {
this.removeNpc(goods)
} else {
if (this.gameIng) {
//速度叠加
goods.y += (4 * this.speed)
//如果玩家和物品发生碰撞
if (this.hasHit(this.player, goods)) {
if (goods["npcType"].indexOf("rain") > -1) {
//console.log("碰到雨滴")
this.score += props.rainScore;
this.waterSvga.visible=true;
// this.waterSvga.x= goods.x - this.player.x;
this.waterSvga.play(false, false)
this.waterSvga.once(engine.Event.END_FRAME, ()=>{
this.waterSvga.visible=false;
}, this);
if(this.score<0){
this.score=0;
}
} else if (goods["npcType"] == "stone") {
//console.log("碰到石头")
this.score += props.stoneScore
if(this.score<0){
this.score=0;
}
this.stoneSvga.visible=true;
this.stoneSvga.play(false, false)
this.stoneSvga.once(engine.Event.END_FRAME, ()=>{
this.stoneSvga.visible=false;
}, this);
} else if (goods["npcType"] == "boom") {
//console.log("碰到炸弹")
this.boomSvga.visible=true;
this.boomSvga.play(false, false)
this.died()
this.boomSvga.once(engine.Event.END_FRAME, ()=>{
this.boomSvga.visible=false;
engine.globalEvent.dispatchEvent('food-fell-game-over', {
score: this.score,
reason: 2
});
}, this);
}
engine.globalEvent.dispatchEvent('food-fell-score-update', {
score: this.score,
});
this.removeNpc(goods)
}
}
}
}, this);
}
/**
* 玩家死亡
*/
private died() {
this.pause();
}
/**
* 回收指定物品
* @param goods 物品
*/
private removeNpc(goods) {
this.NpcBg.removeChild(goods);
ObjectPool.recycleObject(PoolName, goods);
goods.removeEventListener(engine.Event.ENTER_FRAME, goods["onGoodsEnter"], this);
let index = this.goodsItems.indexOf(goods);
if (index > -1) {
this.goodsItems.splice(index, 1);
}
}
/**
* 回收对象
*/
private recycleGoods() {
clearTimeout(this.timer)
clearInterval(this.countdownTimer)
for (let goods of this.goodsItems) {
if (goods) {
this.NpcBg.removeChild(goods);
ObjectPool.recycleObject(PoolName, goods);
goods.removeEventListener(engine.Event.ENTER_FRAME, goods["onGoodsEnter"], this);
}
}
this.goodsItems = []
}
private moveCatchX = 0
private playerCatchX = 0
/**
* 碰撞检测
* @param a a盒子
* @param b b盒子
*/
private hasHit(a, b) {
let playerH=a.height
let playerW=a.width
let playerX=a.x
if(props.playerHeight){
playerH=props.playerHeight
}
if(props.playerWidth){
playerW=props.playerWidth
playerX=a.x+(a.width-props.playerWidth)/2
}
if (
Math.abs((playerX + playerW / 2) - (b.x + b.width / 2)) < playerW / 2 + b.width / 2
&&
// Math.abs((a.y + a.height / 2 ) - (b.y + b.height / 2)) < a.height / 2 + b.height / 2
Math.abs((a.y + playerH / 1.3 ) - (b.y + b.height / 2)) < playerH / 2 + b.height / 2
) {
return true;
} else {
return false;
}
}
private onDownStage = (e) => {
this.moveCatchX = e.localX;
this.playerCatchX = this.player.x
}
private onMoveStage = (e) => {
let maxStageBound=props.maxStageBound;
if (this.gameIng) {
let playerX=this.playerCatchX + (e.localX - this.moveCatchX)
if(playerX<maxStageBound){
this.player.x=maxStageBound
}else if(playerX+this.player.width+maxStageBound>750){
this.player.x=750-maxStageBound-this.player.width
}else{
this.player.x=playerX
}
}
}
private onOutStage = (e) => {
this.moveCatchX = 0
}
}
/**
* Created by rockyl on 2020-01-09.
*/
import GameView from "./GameView";
import {injectProps} from "../props";
export class GameWrapper extends engine.Container {
private _status;
private _gameView: GameView;
constructor() {
super();
engine.globalEvent.addEventListener('food-fell-reset', this.reset, this);
engine.globalEvent.addEventListener('food-fell-start', this.start, this);
engine.globalEvent.addEventListener('food-fell-pause', this.pause, this);
engine.globalEvent.addEventListener('food-fell-resume', this.resume, this);
engine.globalEvent.addEventListener('food-fell-revive', this.revive, this);
engine.globalEvent.addEventListener('food-fell-clear', this.clear, this);
this.addEventListener(engine.MouseEvent.CLICK, this.onTap, this);
let gameView = this._gameView = new GameView();
this.addChild(gameView);
// gameView.reset()
// gameView.start()
}
reset(event: engine.Event) {
injectProps(event.data);
this._gameView.visible = true;
this._gameView.reset();
}
start(event: engine.Event) {
injectProps(event.data);
this._status = 1;
this._gameView.start();
}
pause() {
this._gameView.pause();
}
resume() {
this._gameView.resume();
}
revive() {
this._gameView.revive();
}
clear() {
this._gameView.visible = false;
}
private onTap(event) {
// this._gameView.tap(event);
}
}
/**
* Created by rockyl on 2020-02-02.
*
* 掉落物品
*/
import {getTextureByName} from "./utils";
import {props} from "../props";
export class Goods extends engine.Container {
private _body:engine.Rect
private _toY;
constructor() {
super();
let body
body = this._body =new engine.Rect()
// let randomNum = Math.floor(Math.random() * 3)
// console.log('雨滴' + randomNum);
let rain = new engine.Sprite(getTextureByName('雨滴0'));
let rain1 = new engine.Sprite(getTextureByName('雨滴1'));
let rain2 = new engine.Sprite(getTextureByName('雨滴2'));
rain["npcType"]="rain0"
rain1["npcType"]="rain1"
rain2["npcType"]="rain2"
let stone = new engine.Sprite(getTextureByName('石块'));
stone["npcType"]="stone"
let boom = new engine.Sprite(getTextureByName('炸弹'));
boom["npcType"]="boom"
rain.visible=false;
rain1.visible=false;
rain2.visible=false;
stone.visible=false;
boom.visible=false;
body.addChild(rain)
body.addChild(rain1)
body.addChild(rain2)
body.addChild(stone)
body.addChild(boom)
this.addChild(body);
body.width=.0001;
body.height=.0001;
body.mouseEnabled=false;
}
getRandomNumberByRange(start, end) {
return Math.floor(Math.random() * (end - start) + start)
}
reset() {
this.visible = true;
this.rotation = 0;
this.anchorOffsetY = 0;
this.y = 0;
this.x = (750-120)*Math.random()+30;
this.rotation = 0;
let random=Math.random()
if(typeof (props.goodsProbability) == 'string'){
props.goodsProbability=props.goodsProbability.split(',').map((i: string) => +i)
//console.log(props.goodsProbability);
}
if(random<props.goodsProbability[0]){
let randomNum = Math.floor(Math.random() * 3)
this.showNpc("rain" + randomNum)
}else if(random>=props.goodsProbability[0]&&random<=(props.goodsProbability[0]+props.goodsProbability[1])){
this.showNpc("stone")
}else if(random>(props.goodsProbability[0]+props.goodsProbability[1])){
this.showNpc("boom")
}
}
showNpc(type){
for(let i=0;i<this._body.children.length;i++){
this._body.children[i].visible=false;
this._body.children[i].mouseEnabled=false;
}
for(let i=0;i<this._body.children.length;i++){
if(this._body.children[i]["npcType"]==type){
this["npcType"]=type
this._body.children[i].visible=true;
this._body.children[i].mouseEnabled=false;
}
}
}
set anchorOffsetY(v) {
this._body.y = v;
}
}
/**
* Created by rockyl on 2020-02-03.
*/
import {Goods} from "./Goods";
import ObjectPool = engine.ObjectPool;
export const PoolName: string = 'goods';
ObjectPool.registerPool(PoolName, function () {
return new Goods();
}, function (item: Goods, data) {
item.reset();
});
/**
* Created by rockyl on 2020-01-21.
*/
export function getTexture(uuid) {
return engine.Texture.from(getAssetByUUID(uuid).uuid);
}
export function getTextureByName(name) {
return engine.Texture.from(getAssetByName(name).uuid);
}
export function playSound(name) {
engine.playSound(getAssetByName(name).uuid, {keep: true});
}
export function createSvga(name, anchorName?) {
let inst = new svga.Svga();
inst.source = 'asset://' + getAssetByName(name).uuid;
return inst;
}
\ No newline at end of file
/**
* Created by rockyl on 2019-11-20.
*/
import {GameWrapper} from "./game/GameWrapper";
import {injectProps, prepareProps} from "./props";
export default function (props) {
prepareProps();
injectProps(props);
let instance = new GameWrapper();
return instance;
}
/**
* Created by rockyl on 2020-01-21.
*/
export let props: any = {};
export function prepareProps() {
let metaProps = getProps();
engine.injectProp(props, metaProps);
}
export function injectProps(p) {
engine.injectProp(props, p);
}
......@@ -13,11 +13,8 @@
engine.injectProp(props, p);
}
function getTexture(uuid) {
return engine.Texture.from(uuid);
}
function getTextureByName(name) {
return getTexture(getAssetByName(name).uuid);
return engine.Texture.from(getAssetByName(name).uuid);
}
function getBlockAsset(type) {
return engine.getAssetByName(props.blockAssets[type]);
......@@ -853,7 +850,6 @@
};
return GameView;
}(engine.Container));
//# sourceMappingURL=GameView.js.map
var JumpHigh = (function (_super) {
tslib.__extends(JumpHigh, _super);
......
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -8,7 +8,7 @@ export function getTexture(uuid) {
}
export function getTextureByName(name) {
return getTexture(getAssetByName(name).uuid);
return engine.Texture.from(getAssetByName(name).uuid);
}
export function getBlockAsset(type) {
......
/**
* Created by renjianfeng on 2020-03-13.
*/
//这里需要修改
const customId = 'jump-more';
(async function () {
let customModule = await fetch(`../meta.json`);
customModule = await customModule.json();
console.log(customModule);
await loadAssets(customModule.assets);
launchWithCustomModule(customModule);
})();
function launchWithCustomModule(customModule) {
//engine.registerCustomCodeModule(customModule);
engine.registerCustomModule(customId, window[customId]);
const {props: propsOption, assets} = customModule;
let props = engine.computeProps(customModuleProps, propsOption);
const customModuleIns = {
id: customId,
props,
assets,
};
engine.registerCustomModules([customModuleIns]);
engine.launchWithConfig({
options: {
entrySceneView: 'entry',
},
assets: [],
views: [{
name: 'entry',
type: 'node',
properties: {
x: 0,
y: 0,
}
}],
}, null, function () {
setTimeout(() => {
engine.addCustomModule(customId, engine.gameStage.sceneContainer.getChildAt(0));
}, 100);
setTimeout(() => {
engine.globalEvent.dispatchEvent('jump-more-reset', {
"goodsProbability": [0.8,0.1,0.1],
"countDown": 30,
"acceleratedSpeed":0.1
});
engine.globalEvent.dispatchEvent('jump-more-start');
// engine.globalEvent.dispatchEvent('jump-more-play-music');
}, 500);
});
engine.globalEvent.addEventListener('jump-more-time-update', (e) => {
// console.log(e.type, e.data);
});
engine.globalEvent.addEventListener('jump-more-score-update', (e) => {
// console.log(e.type, e.data);
});
engine.globalEvent.addEventListener('jump-more-game-over', (e) => {
// console.log(e.type, e.data);
});
engine.globalEvent.addEventListener('jump-more-score-update', (e) => {
});
}
function getAssetByUUID(uuid) {
return engine.resolveCustomAsset(customId, uuid);
}
function getProps() {
return engine.getProps(customId);
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>美食从天而降</title>
<meta name="viewport"
content="width=device-width,initial-scale=1, minimum-scale=1, maximum-scale=1, user-scalable=no"/>
<meta name="apple-mobile-web-app-capable" content="yes"/>
<meta name="full-screen" content="true"/>
<meta name="screen-orientation" content="portrait"/>
<meta name="x5-fullscreen" content="true"/>
<meta name="360-fullscreen" content="true"/>
<style>
html,
body {
padding: 0;
margin: 0;
border: 0;
width: 100%;
height: 100%;
overflow: hidden;
position: absolute;
/* background-color: red; */
}
</style>
</head>
<body>
<div id="game-container" style="line-height:0;font-size:0"></div>
<script crossorigin="anonymous" src="//yun.duiba.com.cn/editor/zeroing/libs/engine.50cdcef6ebe4e8c0fbc624f9d4fbf225102c5750.js"></script>
<script crossorigin="anonymous" src="//yun.duiba.com.cn/editor/zeroing/libs/svga.fd3923ae6e664251ca7981801a65809cc5f36bc3.js"></script>
<!-- <script src="//yun.duiba.com.cn/editor/zeroing/libs/engine.ebc906f6b50b8da0a669f77027981d5f3cb560ce.js"></script> -->
<!-- <script src="http://localhost:4002/debug/engine.js"></script>
<script src="http://localhost:4003/debug/engine-svga.js"></script> -->
<!--<script src="//yun.duiba.com.cn/editor/zeroing/libs/engine.9a9dbfda4cb2dd5508ecddfe3d95dfd88063f7b5.js"></script>-->
<script>
window.requestAnimFrame = (function() {
return (
window.requestAnimationFrame ||
window.webkitRequestAnimationFrame ||
window.mozRequestAnimationFrame ||
window.oRequestAnimationFrame ||
window.msRequestAnimationFrame ||
function(callback) {
window.setTimeout(callback, 1000 / 60);
}
);
})();
</script>
<script src="app.js"></script>
<script src="props.js"></script>
<script src="load-assets.js"></script>
<script src="main.js"></script>
</body>
\ No newline at end of file
/**
* Created by rockyl on 2020-01-21.
*/
const assets = [
{
"name": "玩家icon",
"url": "//yun.duiba.com.cn/aurora/assets/50a7212a113175fa18c866b005d98f07c558dc77.png",
"uuid": "66f23d13-82a5-4cec-9496-301ec240d087",
"ext": ".png"
},
{
"name": "雨滴",
"url": "//yun.duiba.com.cn/aurora/assets/8564c8c9be3aead71b05a0bab8d7d07ac3f778a1.png",
"uuid": "264a6192-d7bf-45e8-8f15-6ba2c439a532",
"ext": ".png"
},
{
"name": "炸弹",
"url": "//yun.duiba.com.cn/aurora/assets/171e92283cd13c013ee1b76d28d252ff08815d47.png",
"uuid": "eb88b42d-e151-4c1b-94b9-7c16f7bfac29",
"ext": ".png"
},
{
"name": "石块",
"url": "//yun.duiba.com.cn/aurora/assets/99b0af0c59fe79a415a3f032149cfacc27e3ac2c.png",
"uuid": "ab1bdabc-21ba-46bf-9299-6c638f766c88",
"ext": ".png"
},
{
"name": "水花",
"url": "//yun.duiba.com.cn/aurora/assets/93d37b4a0e367e80e375308a6b4414d72d7666fc.svga",
"uuid": "b521bf94-20e1-44dd-8eca-d24996cbaeae",
"ext": ".svga"
},
{
"name": "炸弹",
"url": "//yun.duiba.com.cn/aurora/assets/4dd18f0689c663bbcf710a7afc4d929084d97d36.svga",
"uuid": "322edf39-805b-4e84-9d07-5573dfeebc0e",
"ext": ".svga"
},
{
"name": "玩家abc",
"url": "//yun.duiba.com.cn/aurora/assets/41aab15126a106fb7b4083fbc50f9bcea5b3a090.svga",
"uuid": "613125b7-f199-4aa1-860a-9243fc16c4eb",
"ext": ".svga"
},
{
"name": "玩家右",
"url": "//yun.duiba.com.cn/aurora/assets/85af8997aa6dd1aa47011ea843302a4a072f2efd.png",
"uuid": "09e76db2-db0f-46e0-803a-998b1895a027",
"ext": ".png"
},
{
"name": "台阶",
"url": "//yun.duiba.com.cn/aurora/assets/e37ef0563103ffd582d787d36032d7262a3dce47.png",
"uuid": "db411686-ad6b-4bed-81b5-b844715e2882",
"ext": ".png"
},
{
"name": "青团",
"url": "//yun.duiba.com.cn/aurora/assets/14bfed9ab0c2f995b1ca34a5ca0116e8d155012d.png",
"uuid": "84b0849b-7417-4322-b4a3-f7d1a38b15c3",
"ext": ".png"
},
{
"name": "大灰狼",
"url": "//yun.duiba.com.cn/aurora/assets/25a1b525af1daeab062565c2c2c9737957ce4be3.svga",
"uuid": "eae1241a-d133-4816-9496-a2850e7e2d8f",
"ext": ".svga"
}, {
"name": "得分",
"url": "//yun.duiba.com.cn/aurora/assets/88e5d349a8829ddd2b0f608da4d2d537db4bad54.png",
"uuid": "8d9cfa4e-18f9-43a4-8f8e-6996577482b6",
"ext": ".png"
}, {
"name": "加分",
"url": "//yun.duiba.com.cn/aurora/assets/b534a5f50ccc7eeca9ea4f0d4dea78430b8dec9b.png",
"uuid": "6dcb1e61-95e2-4841-8b71-7152f8d6cb37",
"ext": ".png"
},
{
"name": "游戏背景音乐",
"url": "//yun.duiba.com.cn/aurora/assets/7c955f550176b8ea2797b5555c30f1dfc9a770c1.mp3",
"uuid": "da826400-c835-4b75-8991-a29b64c5ac0b",
"ext": ".mp3"
},
{
"name": "吃道具音效",
"url": "//yun.duiba.com.cn/aurora/assets/a9e40a494d33b2c2a5c70ad93090efb4b36cb55d.mp3",
"uuid": "6b809f4e-1712-4201-beed-a683294ded02",
"ext": ".mp3"
},
{
"name": "碰到怪物掉落死亡音效",
"url": "//yun.duiba.com.cn/aurora/assets/e7f28dbc188c24613dccd11690a6f2e66bd00caa.mp3",
"uuid": "dc4426e3-cfe0-492e-bf74-002e0eb605cf",
"ext": ".mp3"
},
{
"name": "跳起死亡音效",
"url": "//yun.duiba.com.cn/aurora/assets/5603f0353a3eeea305c7398bd17f993be7474641.mp3",
"uuid": "f3f66910-8af2-4ceb-b7b3-27329a8ca93b",
"ext": ".mp3"
}
];
function loadAssets(customModuleAssets, onProgress, onComplete){
return engine.loadAssets(assets.concat(...customModuleAssets), onProgress, onComplete);
}
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('tslib')) :
typeof define === 'function' && define.amd ? define(['tslib'], factory) :
(global = global || self, global['jump-more'] = factory(global.tslib));
}(this, (function (tslib) { 'use strict';
var props = {};
function prepareProps() {
var metaProps = getProps();
engine.injectProp(props, metaProps);
}
function injectProps(p) {
engine.injectProp(props, p);
}
function getTexture(uuid) {
return engine.Texture.from(getAssetByUUID(uuid).uuid);
}
function getTextureByName(name) {
return getTexture(engine.getAssetByName(name).uuid);
}
function createSvga(name, anchorName) {
var inst = new svga.Svga();
inst.source = 'asset://' + engine.getAssetByName(name).uuid;
return inst;
}
var Platform = (function (_super) {
tslib.__extends(Platform, _super);
function Platform() {
var _this = _super.call(this) || this;
_this.x = 0;
_this.y = 0;
_this.prizeOdds = props.prizeOdds;
_this.ghostOdds = props.ghostOdds;
_this.width = 224;
_this.height = 56;
_this.flag = 0;
_this.state = 0;
_this.moved = 0;
_this.vx = 1;
_this.type = 1;
_this._body = new engine.Rect();
_this.isNew = true;
_this.addStatus = false;
_this.addChild(new engine.Sprite(getTextureByName('台阶')));
_this.prizeIcon = new engine.Sprite(getTextureByName('青团'));
_this.prizeIcon.x = _this.x + _this.width / 2 - _this.prizeIcon.width / 2;
_this.prizeIcon.y = _this.y - _this.height + 10;
_this.ghostIcon = createSvga('大灰狼');
_this.ghostIcon.gotoAndPlay(1);
setTimeout(function () {
_this.ghostIcon.y = -_this.height * 2 - 10;
_this.ghostIcon.x = _this.width / 2 - _this.ghostIcon.width / 2;
}, 10);
_this.prizeIcon.visible = false;
_this.ghostIcon.visible = false;
_this.addChild(_this.ghostIcon);
_this.addChild(_this.prizeIcon);
_this.prizeFlag = Math.random() < _this.prizeOdds ? true : false;
if (_this.prizeFlag) {
_this.ghostFlag = false;
_this.prizeIcon.visible = true;
}
return _this;
}
Platform.prototype.getStatus = function () {
this.prizeIcon.visible = false;
this.ghostIcon.visible = false;
this.prizeFlag = Math.random() < this.prizeOdds ? true : false;
if (this.prizeFlag) {
this.ghostFlag = false;
this.prizeIcon.visible = true;
}
else {
this.ghostFlag = Math.random() < this.ghostOdds ? true : false;
if (this.ghostFlag)
this.ghostIcon.visible = true;
}
};
return Platform;
}(engine.Container));
var Goods = (function (_super) {
tslib.__extends(Goods, _super);
function Goods() {
var _this = _super.call(this) || this;
var body;
body = _this._body = new engine.Rect();
var rain = new engine.Sprite(getTextureByName('雨滴'));
rain["npcType"] = "rain";
var stone = new engine.Sprite(getTextureByName('石块'));
stone["npcType"] = "stone";
var boom = new engine.Sprite(getTextureByName('炸弹'));
boom["npcType"] = "boom";
rain.visible = false;
stone.visible = false;
boom.visible = false;
body.addChild(rain);
body.addChild(stone);
body.addChild(boom);
_this.addChild(body);
body.width = .0001;
body.height = .0001;
body.mouseEnabled = false;
return _this;
}
Goods.prototype.getRandomNumberByRange = function (start, end) {
return Math.floor(Math.random() * (end - start) + start);
};
Goods.prototype.reset = function () {
this.visible = true;
this.rotation = 0;
this.anchorOffsetY = 0;
this.y = 0;
this.x = (750 - 120) * Math.random() + 30;
this.rotation = 0;
var random = Math.random();
if (random < props.goodsProbability[0]) {
this.showNpc("rain");
}
else if (random >= props.goodsProbability[0] && random <= (props.goodsProbability[0] + props.goodsProbability[1])) {
this.showNpc("stone");
}
else if (random > (props.goodsProbability[0] + props.goodsProbability[1])) {
this.showNpc("boom");
}
};
Goods.prototype.showNpc = function (type) {
for (var i = 0; i < this._body.children.length; i++) {
this._body.children[i].visible = false;
this._body.children[i].mouseEnabled = false;
}
for (var i = 0; i < this._body.children.length; i++) {
if (this._body.children[i]["npcType"] == type) {
this["npcType"] = type;
this._body.children[i].visible = true;
this._body.children[i].mouseEnabled = false;
}
}
};
Object.defineProperty(Goods.prototype, "anchorOffsetY", {
set: function (v) {
this._body.y = v;
},
enumerable: true,
configurable: true
});
return Goods;
}(engine.Container));
var ObjectPool = engine.ObjectPool;
var PoolName = 'goods';
ObjectPool.registerPool(PoolName, function () {
return new Goods();
}, function (item, data) {
item.reset();
});
var SoundMgr = (function () {
function SoundMgr() {
}
Object.defineProperty(SoundMgr, "instance", {
get: function () {
if (!this._instance) {
this._instance = new SoundMgr();
}
return this._instance;
},
enumerable: true,
configurable: true
});
Object.defineProperty(SoundMgr.prototype, "enabled", {
get: function () {
return engine.env.soundEnabled;
},
enumerable: true,
configurable: true
});
SoundMgr.prototype.playEffect = function (name, loop) {
if (loop === void 0) { loop = false; }
engine.playSound(getAssetByUUID(nameToUuid[name]).uuid, {
loop: loop,
keep: true
}, name);
};
SoundMgr.prototype.stopEffect = function (name) {
engine.stopSound(name);
engine.destroySound(name);
};
SoundMgr._instance = null;
return SoundMgr;
}());
var nameToUuid = {
bgm: "da826400-c835-4b75-8991-a29b64c5ac0b",
prize: "6b809f4e-1712-4201-beed-a683294ded02",
ghost: "dc4426e3-cfe0-492e-bf74-002e0eb605cf",
jumpdied: "f3f66910-8af2-4ceb-b7b3-27329a8ca93b",
};
var ObjectPool$1 = engine.ObjectPool;
var GameView = (function (_super) {
tslib.__extends(GameView, _super);
function GameView() {
var _this = _super.call(this) || this;
_this.gravity = 0.2;
_this.bottomY = 5;
_this.jumpCount = 0;
_this.flag = 0;
_this.iconX = 0;
_this.goodsItems = [];
_this.platformCount = 12;
_this.platformGap = 0;
_this.platPosition = 0;
_this.platforms = [];
_this.newPlatforms = [];
_this.cashNum = 0;
_this.moveCatchX = 0;
_this.playerCatchX = 0;
_this.onDownStage = function (e) {
if (e.stageX < _this.width / 2) {
_this.player.dir = 'left';
_this.player.isMovingLeft = true;
_this.playerSvga.scaleX = -1;
setTimeout(function () {
_this.player.isMovingLeft = false;
}, 500);
}
else {
_this.player.dir = 'right';
_this.player.isMovingRight = true;
_this.playerSvga.scaleX = 1;
setTimeout(function () {
_this.player.isMovingRight = false;
}, 500);
}
};
_this.onMoveStage = function (e) {
if (_this.gameIng) {
_this.player.x = _this.playerCatchX + (e.localX - _this.moveCatchX);
}
};
_this.onOutStage = function (e) {
if (e.stageX < _this.width / 2) {
_this.player.dir = 'left';
_this.player.isMovingLeft = false;
}
else {
_this.player.dir = 'right';
_this.player.isMovingRight = false;
}
};
_this.once(engine.Event.ADDED_TO_STAGE, _this.setup, _this);
return _this;
}
GameView.prototype.setup = function () {
var _this = this;
if (this._hasSetup) {
return;
}
this._hasSetup = true;
this.NpcBg = new engine.Container();
this.NpcBg.alpha = 1;
this.NpcBg.width = 0;
this.NpcBg.height = 0;
this.addChild(this.NpcBg);
this.player = new engine.Container();
this.player.vx = 0;
this.player.vy = 11;
this.player.isMovingLeft = false;
this.player.isMovingRight = false;
this.player.isDead = false;
this.player.jump = function () {
_this.player.vy = -10;
_this.playerSvga.play(false, false);
};
this.playerSvga = createSvga('玩家abc');
this.player.addChild(this.playerSvga);
this.visible = false;
this.addScoreIcon = new engine.Sprite(getTextureByName('加分'));
this.addScoreIcon.visible = false;
this.player.addChild(this.addScoreIcon);
setTimeout(function () {
_this.visible = true;
_this.playerSvga.anchorY = _this.playerSvga.height / 2;
_this.playerSvga.anchorX = _this.playerSvga.width / 2;
_this.player.anchorY = _this.player.height / 2;
_this.player.anchorX = _this.player.width / 2;
_this.player.x = 375 - _this.player.width / 2;
_this.iconX = _this.player.width + 20;
_this.addScoreIcon.y =
_this.player.height / 2 - _this.addScoreIcon.height / 2 + 20;
}, 300);
this.score = 0;
this.rectBg = new engine.Container();
this.rectBg.width = 750;
this.rectBg.height = 1624;
this.rectHeight = this.stage.height - this.rectBg.height;
this.rectBg.y = this.rectHeight;
this.addChild(this.rectBg);
this.player.y = this.rectBg.height;
this.baseY = this.rectBg.height - this.bottomY;
this.rectBg.addEventListener(engine.MouseEvent.CLICK, this.onDownStage, this);
};
GameView.prototype.base = function () { };
GameView.prototype.createPlatform = function (needGhost) {
if (needGhost === void 0) { needGhost = false; }
var platform = new Platform();
platform.x = Math.random() * (this.width - platform.width);
this.platPosition += this.rectBg.height / this.platformCount;
var platform2 = new Platform();
var left = platform.x;
if (left > this.width / 2) {
platform2.x =
Math.random() * (platform.x - platform.width) - platform.width / 2;
}
else {
platform2.x =
platform.x +
platform.width +
Math.random() * (this.width - platform.x - platform.width * 1.5);
}
platform2.y = platform.y = this.platPosition;
if (needGhost && !platform.prizeFlag) {
platform.ghostFlag = Math.random() < platform.ghostOdds ? true : false;
if (platform.ghostFlag)
platform.ghostIcon.visible = true;
}
return [platform, platform2];
};
GameView.prototype.changePlatformGap = function (to) {
var _this = this;
if (this.platformCount == to)
return;
this.platformCount = to;
var min = this.rectBg.height;
for (var i = 0; i < this.platforms.length; i++) {
if (min > this.platforms[i].y) {
min = this.platforms[i].y;
}
}
this.platPosition =
min - this.rectBg.height / this.platformCount + this.rectBg.height;
var newList = [];
for (var i = 0; i < this.platformCount; i++) {
newList.push.apply(newList, this.createPlatform(true));
}
this.newPlatforms = newList;
this.newPlatforms.forEach(function (p) {
if (p.isNew && !p.addStatus) {
_this.rectBg.addChild(p);
p.addStatus = true;
}
});
this.platforms.forEach(function (p) {
p.isNew = false;
_this.rectBg.addChild(p);
});
this.platforms = this.platforms.concat(this.newPlatforms);
};
GameView.prototype.platformInit = function () {
var _a;
var _this = this;
for (var i = 0; i < this.platformCount; i++) {
(_a = this.platforms).push.apply(_a, this.createPlatform());
}
this.platforms.forEach(function (p, i) {
_this.rectBg.addChild(p);
});
};
GameView.prototype.playerJump = function () {
var _this = this;
this.player.y += this.player.vy;
this.player.vy += this.gravity;
if (this.player.vy > 0 &&
this.player.x + 15 < 260 &&
this.player.x + this.player.width - 15 > 155 &&
this.player.y + this.player.height > 475 &&
this.player.y + this.player.height < 500) {
return this.player.jump();
}
if (this.player.isMovingLeft === true) {
this.player.x += this.player.vx;
this.player.vx -= 0.1;
}
else {
this.player.x += this.player.vx;
if (this.player.vx < 0)
this.player.vx += 0.07;
}
if (this.player.isMovingRight === true) {
this.player.x += this.player.vx;
this.player.vx += 0.1;
}
else {
this.player.x += this.player.vx;
if (this.player.vx > 0)
this.player.vx -= 0.07;
}
if (this.player.vx > 4)
this.player.vx = 4;
else if (this.player.vx < -4)
this.player.vx = -4;
if (this.player.y + this.player.height > this.baseY &&
this.baseY < this.rectBg.height) {
this.player.jump();
}
if (this.baseY > this.rectBg.height &&
this.player.y + this.player.height > this.rectBg.height &&
this.player.isDead != 'lol') {
this.player.isDead = true;
SoundMgr.instance.playEffect('jumpdied');
}
if (this.player.x > this.width)
this.player.x = 0 - this.player.width;
else if (this.player.x < 0 - this.player.width)
this.player.x = this.width - this.player.width;
if (this.player.y >= this.rectBg.height / 2 - this.player.height / 2) {
this.player.y += this.player.vy;
this.player.vy += this.gravity;
}
else {
if (this.player.y < this.height / 2) {
this.player.y -= this.player.vy;
}
if (this.newPlatforms.length > 0) {
this.platforms.forEach(function (p, i) {
if (_this.player.vy < 0) {
p.y -= _this.player.vy;
}
if (_this.player.y < _this.height / 2) {
p.y -= _this.player.vy;
}
if (p.y > _this.height) {
if (p.isNew == false) {
_this.cashNum++;
if (_this.cashNum ==
_this.platforms.length - _this.newPlatforms.length) {
var list = _this.platforms.splice(0, _this.cashNum);
_this.newPlatforms = [];
for (var i_1 = 0; i_1 < list.length; i_1++) {
_this.rectBg.removeChild(list[i_1]);
}
_this.cashNum = 0;
}
}
p.y = p.y - _this.rectBg.height * 2;
}
});
}
else {
this.platforms.forEach(function (p, i) {
if (_this.player.vy < 0) {
p.y -= _this.player.vy;
}
if (_this.player.y < _this.height / 2) {
p.y -= _this.player.vy;
}
if (p.y > _this.height) {
if (i % 2 == 0) {
_this.platforms[i].x =
Math.random() * (_this.width - _this.platforms[i].width);
if (i != 0) {
p.getStatus();
}
}
else {
var last = _this.platforms[i - 1], left = last.x;
if (left > _this.width / 2) {
p.x = Math.random() * (last.x - p.width) - p.width / 2;
}
else {
p.x =
last.x +
p.width +
Math.random() * (_this.width - last.x - p.width * 1.5);
}
}
p.y = p.y - _this.rectBg.height;
}
});
}
this.baseY -= this.player.vy;
this.player.vy += this.gravity;
if (this.player.vy >= 0) {
this.player.y += this.player.vy;
this.player.vy += this.gravity;
}
if (this.score > 30 && this.score < 60) {
this.changePlatformGap(11);
}
else if (this.score > 60 && this.score < 120) {
this.changePlatformGap(10);
}
else if (this.score > 120) {
this.changePlatformGap(8);
}
}
if (this.player.isDead === false)
this.collides();
if (this.player.isDead == true) {
this.gameOver();
}
};
GameView.prototype.playMusic = function () {
SoundMgr.instance.playEffect('bgm', true);
};
GameView.prototype.collides = function () {
var _this = this;
this.platforms.forEach(function (p, i) {
if (_this.player.vy > 0 &&
p.state === 0 &&
_this.player.x + 55 < p.x + p.width &&
_this.player.x + _this.player.width - 30 > p.x &&
_this.player.y + _this.player.height + 15 > p.y &&
_this.player.y + _this.player.height + 15 < p.y + p.height) {
if (p.prizeFlag) {
SoundMgr.instance.playEffect('prize');
_this.score += props.prizeScore;
engine.globalEvent.dispatchEvent('jump-more-score-update', {
score: _this.score
});
p.prizeFlag = false;
p.prizeIcon.visible = false;
if (p.x > _this.rectBg.width - p.width * 1.5) {
_this.addScoreIcon.x = -20 - _this.addScoreIcon.width;
}
else {
_this.addScoreIcon.x = _this.iconX;
}
_this.addScoreIcon.visible = true;
if (_this.addTimer) {
clearTimeout(_this.addTimer);
}
_this.addTimer = setTimeout(function () {
_this.addScoreIcon.visible = false;
}, 1000);
}
else if (p.ghostFlag) {
SoundMgr.instance.playEffect('ghost');
_this.diedIndex = i;
_this.gameOver();
}
else {
_this.player.jump();
}
}
});
};
GameView.prototype.gameOver = function () {
this.platforms.forEach(function (p, i) {
p.y -= 12;
});
if (this.player.y > this.rectBg.height / 2 && this.flag === 0) {
this.player.y -= 8;
this.player.vy = 0;
}
else if (this.player.y + this.player.height > this.rectBg.height) ;
engine.globalEvent.dispatchEvent('jump-more-game-over', {
score: this.score
});
this.player.isDead = 'lol';
};
GameView.prototype.rectBgCalc = function () {
};
GameView.prototype.gameRevive = function () {
this.player.isDead = false;
var random = Math.floor(Math.random() * 3) * 2;
this.player.x = this.platforms[random].x;
this.player.y = this.platforms[random].y;
this.player.vx = 0;
this.player.vy = 11;
this.platforms.forEach(function (p, i) {
p.ghostFlag = false;
p.ghostIcon.visible = false;
});
};
GameView.prototype.update_my = function () {
this.playerJump();
this.rectBg.addChild(this.player);
};
GameView.prototype.reset = function () {
this.removeEventListener(engine.Event.ENTER_FRAME, this.test, this);
SoundMgr.instance.stopEffect('bgm');
this.recycleGoods();
this.player.vx = 0;
this.player.vy = 11;
this.player.isMovingLeft = false;
this.player.isMovingRight = false;
this.player.x = 375 - this.player.width / 2;
this.player.y = this.rectBg.height - 200;
this.rectBg.y = this.rectHeight;
this.platPosition = 0;
this.score = 0;
this.platformCount = 12;
this.platformGap = 0;
this.baseY = this.rectBg.height - this.bottomY;
this.player.isDead = false;
this.platformInit();
this.playerJump();
};
GameView.prototype.start = function () {
this.aniLoop();
this.playMusic();
};
GameView.prototype.pause = function () {
this.gameIng = false;
};
GameView.prototype.revive = function () {
this.gameIng = true;
};
GameView.prototype.resume = function () {
return tslib.__awaiter(this, void 0, void 0, function () {
return tslib.__generator(this, function (_a) {
this.reset();
this.start();
return [2];
});
});
};
GameView.prototype.aniLoop = function () {
var _this = this;
this.addEventListener(engine.Event.ENTER_FRAME, (this.test = function () {
_this.update_my();
}), this);
};
GameView.prototype.died = function () {
this.score = 0;
this.pause();
};
GameView.prototype.removeNpc = function (goods) {
var _this = this;
this.NpcBg.removeChild(goods);
ObjectPool$1.recycleObject(PoolName, goods);
this.removeEventListener(engine.Event.ENTER_FRAME, function () {
_this.update_my();
}, this);
var index = this.goodsItems.indexOf(goods);
if (index > -1) {
this.goodsItems.splice(index, 1);
}
};
GameView.prototype.recycleGoods = function () {
for (var _i = 0, _a = this.platforms; _i < _a.length; _i++) {
var p = _a[_i];
this.rectBg.removeChild(p);
}
this.newPlatforms = [];
this.platforms = [];
};
GameView.prototype.hasHit = function (a, b) {
if (Math.abs(a.x + a.width / 2 - (b.x + b.width / 2)) <
a.width / 2 + b.width / 2 &&
Math.abs(a.y + a.height / 2 - (b.y + b.height / 2)) <
a.height / 2 + b.height / 2) {
return true;
}
else {
return false;
}
};
return GameView;
}(engine.Container));
var GameWrapper = (function (_super) {
tslib.__extends(GameWrapper, _super);
function GameWrapper() {
var _this = _super.call(this) || this;
engine.globalEvent.addEventListener('jump-more-reset', _this.reset, _this);
engine.globalEvent.addEventListener('jump-more-start', _this.start, _this);
engine.globalEvent.addEventListener('jump-more-resume', _this.resume, _this);
engine.globalEvent.addEventListener('jump-more-revive', _this.revive, _this);
_this.addEventListener(engine.MouseEvent.CLICK, _this.onTap, _this);
var gameView = _this._gameView = new GameView();
_this.addChild(gameView);
return _this;
}
GameWrapper.prototype.reset = function (event) {
injectProps(event.data);
this._gameView.visible = true;
this._gameView.reset();
};
GameWrapper.prototype.start = function (event) {
injectProps(event.data);
this._gameView.start();
};
GameWrapper.prototype.pause = function () {
this._gameView.pause();
};
GameWrapper.prototype.resume = function () {
this._gameView.resume();
};
GameWrapper.prototype.revive = function () {
this._gameView.gameRevive();
};
GameWrapper.prototype.onTap = function (event) {
};
return GameWrapper;
}(engine.Container));
function index (props) {
prepareProps();
injectProps(props);
var instance = new GameWrapper();
return instance;
}
return index;
})));
//# sourceMappingURL=main.js.map
\ No newline at end of file
{"version":3,"file":"index.js","sources":["src/custom/jump-more/src/props.ts","src/custom/jump-more/src/game/utils.ts","src/custom/jump-more/src/game/Platform.ts","src/custom/jump-more/src/game/Goods.ts","src/custom/jump-more/src/game/object-pool-init.ts","src/custom/jump-more/src/game/SoundMgr.ts","src/custom/jump-more/src/game/GameView.ts","src/custom/jump-more/src/game/GameWrapper.ts","src/custom/jump-more/src/index.ts"],"sourcesContent":["/**\n * Created by rockyl on 2020-01-21.\n */\n\nexport let props: any = {};\n\nexport function prepareProps() {\n\tlet metaProps = getProps();\n\n\tengine.injectProp(props, metaProps);\n}\n\nexport function injectProps(p) {\n\tengine.injectProp(props, p);\n}\n","/**\n * Created by rockyl on 2020-01-21.\n */\n\nexport function getTexture(uuid) {\n\treturn engine.Texture.from(getAssetByUUID(uuid).uuid);\n}\n\nexport function getTextureByName(name) {\n\treturn getTexture(engine.getAssetByName(name).uuid);\n}\n\nexport function playSound(name) {\n\tengine.playSound(engine.getAssetByName(name).uuid, {keep: true});\n}\nexport function createSvga(name, anchorName?) {\n\tlet inst = new svga.Svga();\n\tinst.source = 'asset://' + engine.getAssetByName(name).uuid;\n\treturn inst;\n}","import { getTextureByName } from './utils';\nimport { props } from '../props';\nimport { createSvga } from './utils';\ninterface PlatformProps {\n width: number;\n height: number;\n x: number;\n y: number;\n count: number;\n}\n\nexport class Platform extends engine.Container {\n private _body: engine.Rect;\n // private _toY;\n flag;\n state;\n moved;\n vx;\n type;\n x = 0;\n y = 0;\n prizeOdds = props.prizeOdds;\n ghostOdds = props.ghostOdds;\n prizeFlag: boolean;\n ghostFlag: boolean;\n isNew: boolean;\n addStatus: boolean;\n prizeIcon: engine.Sprite;\n ghostIcon;\n constructor() {\n super();\n this.width = 224;\n this.height = 56;\n\n this.flag = 0;\n this.state = 0;\n this.moved = 0;\n this.vx = 1;\n this.type = 1;\n this._body = new engine.Rect();\n this.isNew = true\n this.addStatus = false\n this.addChild(new engine.Sprite(getTextureByName('台阶')));\n this.prizeIcon = new engine.Sprite(getTextureByName('青团'));\n this.prizeIcon.x = this.x + this.width / 2 - this.prizeIcon.width / 2;\n this.prizeIcon.y = this.y - this.height + 10;\n this.ghostIcon = createSvga('大灰狼');\n this.ghostIcon.gotoAndPlay(1);\n setTimeout(() => {\n this.ghostIcon.y = -this.height * 2 - 10;\n this.ghostIcon.x = this.width / 2 - this.ghostIcon.width / 2;\n }, 10);\n this.prizeIcon.visible = false;\n this.ghostIcon.visible = false;\n this.addChild(this.ghostIcon);\n this.addChild(this.prizeIcon);\n\n this.prizeFlag = Math.random() < this.prizeOdds ? true : false;\n if (this.prizeFlag) {\n this.ghostFlag = false;\n this.prizeIcon.visible = true;\n } else {\n // this.ghostFlag = Math.random() < this.ghostOdds ? true : false;\n\n // if (this.ghostFlag) this.ghostIcon.visible = true;\n }\n // let platform = new engine.Sprite(getTextureByName('台阶'));\n }\n getStatus() {\n this.prizeIcon.visible = false;\n this.ghostIcon.visible = false;\n this.prizeFlag = Math.random() < this.prizeOdds ? true : false;\n if (this.prizeFlag) {\n this.ghostFlag = false;\n this.prizeIcon.visible = true;\n } else {\n this.ghostFlag = Math.random() < this.ghostOdds ? true : false;\n if (this.ghostFlag) this.ghostIcon.visible = true;\n }\n }\n}\n","/**\n * Created by rockyl on 2020-02-02.\n *\n * 掉落物品\n */\nimport {getTextureByName} from \"./utils\";\nimport {props} from \"../props\";\n\nexport class Goods extends engine.Container {\n\tprivate _body:engine.Rect\n\tprivate _toY;\n\n\tconstructor() {\n\t\tsuper();\n\n\t\tlet body\n\t\tbody = this._body =new engine.Rect()\n\t\t\n\t\t\n\t\tlet rain = new engine.Sprite(getTextureByName('雨滴'));\n\t\train[\"npcType\"]=\"rain\"\n\t\tlet stone = new engine.Sprite(getTextureByName('石块'));\n\t\tstone[\"npcType\"]=\"stone\"\n\t\tlet boom = new engine.Sprite(getTextureByName('炸弹'));\n\t\tboom[\"npcType\"]=\"boom\"\n\n\t\train.visible=false;\n\t\tstone.visible=false;\n\t\tboom.visible=false;\n\t\tbody.addChild(rain)\n\t\tbody.addChild(stone)\n\t\tbody.addChild(boom)\n\t\t\n\t\tthis.addChild(body);\n\t\tbody.width=.0001;\n\t\tbody.height=.0001;\n\t\tbody.mouseEnabled=false;\n\t}\n\n\n\tgetRandomNumberByRange(start, end) {\n\t\treturn Math.floor(Math.random() * (end - start) + start)\n\t}\n\n\treset() {\n\t\tthis.visible = true;\n\t\tthis.rotation = 0;\n\t\tthis.anchorOffsetY = 0;\n\t\tthis.y = 0;\n\t\tthis.x = (750-120)*Math.random()+30;\n\t\tthis.rotation = 0;\n\t\tlet random=Math.random()\n\n\t\tif(random<props.goodsProbability[0]){\n\t\t\tthis.showNpc(\"rain\")\n\t\t}else if(random>=props.goodsProbability[0]&&random<=(props.goodsProbability[0]+props.goodsProbability[1])){\n\t\t\tthis.showNpc(\"stone\")\n\t\t}else if(random>(props.goodsProbability[0]+props.goodsProbability[1])){\n\t\t\tthis.showNpc(\"boom\")\n\t\t}\n\t}\n\n\n\tshowNpc(type){\n\t\tfor(let i=0;i<this._body.children.length;i++){\n\t\t\tthis._body.children[i].visible=false;\n\t\t\tthis._body.children[i].mouseEnabled=false;\n\t\t}\n\n\t\tfor(let i=0;i<this._body.children.length;i++){\n\t\t\tif(this._body.children[i][\"npcType\"]==type){\n\t\t\t\tthis[\"npcType\"]=type\n\t\t\t\tthis._body.children[i].visible=true;\n\t\t\t\tthis._body.children[i].mouseEnabled=false;\n\t\t\t}\n\t\t}\n\t\t\n\t}\n\n\tset anchorOffsetY(v) {\n\t\tthis._body.y = v;\n\t}\n}\n","/**\n * Created by rockyl on 2020-02-03.\n */\n\nimport {Goods} from \"./Goods\";\nimport {Platform} from \"./Platform\";\nimport ObjectPool = engine.ObjectPool;\n\nexport const PoolName: string = 'goods';\n\nObjectPool.registerPool(PoolName, function () {\n\treturn new Goods();\n}, function (item: Goods, data) {\n\titem.reset();\n});\n","\nexport default class SoundMgr {\n\tprivate static _instance: SoundMgr = null;\n\tpublic static get instance(): SoundMgr {\n\t\tif (!this._instance) {\n\t\t\tthis._instance = new SoundMgr();\n\t\t}\n\n\t\treturn this._instance;\n\t}\n\n\tpublic get enabled() {\n\t\treturn engine.env.soundEnabled;\n\t}\n\n\tpublic playEffect(name: string, loop: boolean = false) {\n\t\t//if (!this.enabled) return;\n\n\t\tengine.playSound(getAssetByUUID(nameToUuid[name]).uuid, {\n\t\t\tloop,\n\t\t\tkeep: true\n\t\t}, name);\n\t}\n\tpublic stopEffect(name: string){\n\t\tengine.stopSound(name);\n\t\tengine.destroySound(name);\n\t}\n\n\n}\n\nconst nameToUuid = {\n\tbgm: \"da826400-c835-4b75-8991-a29b64c5ac0b\",\n\tprize: \"6b809f4e-1712-4201-beed-a683294ded02\",\n\tghost: \"dc4426e3-cfe0-492e-bf74-002e0eb605cf\",\n\tjumpdied: \"f3f66910-8af2-4ceb-b7b3-27329a8ca93b\",\n}","/**\n * Created by rockyl on 2018/8/16.\n */\n\nimport { props } from '../props';\nimport { playSound, createSvga } from './utils';\nimport ObjectPool = engine.ObjectPool;\nimport { Platform } from './Platform';\nimport { PrizeGood } from './PrizeGood';\nimport { getTextureByName } from './utils';\nimport { Goods } from './Goods';\nimport { PoolName } from './object-pool-init';\nimport SoundMgr from './SoundMgr';\ninterface playerProp extends engine.Container {\n // x速度\n vx?: number;\n // y速度\n vy?: number;\n isMovingLeft?: boolean;\n isMovingRight?: boolean;\n isDead?: boolean | string;\n dir?: string;\n // deadInfo:object;\n draw?(): void;\n jump?(): void;\n jumpHigh?(): void;\n}\n\nexport default class GameView extends engine.Container {\n private _hasSetup;\n gravity: number = 0.2;\n bottomY: number = 5;\n jumpCount: number = 0;\n baseY: number;\n flag = 0;\n loopFrame: any;\n prizeGoodList: { number: PrizeGood };\n diedIndex: number;\n rectHeight: number;\n addTimer: NodeJS.Timer | null;\n iconX = 0;\n //玩家\n private player: playerProp;\n\n //触摸层\n private rectBg: engine.Container;\n //npc层\n private NpcBg: engine.Container;\n\n //当前分数\n private score;\n\n //游戏状态\n private gameIng;\n\n //npc出身计时器\n private timer;\n //倒计时计时器\n private countdownTimer: any;\n //倒计时\n private countdown: number;\n\n //当前速度\n private speed: number;\n\n // 当前场景上面的物品\n private goodsItems = [];\n\n private _goods: Goods;\n\n constructor() {\n super();\n // this.platformCount = 10\n this.once(engine.Event.ADDED_TO_STAGE, this.setup, this);\n // engine.globalEvent.addEventListener('jump-more-score', , this);\n }\n platformCount = 12;\n platformGap = 0;\n platPosition = 0;\n platforms = [];\n newPlatforms = [];\n cashNum = 0;\n\n private waterSvga;\n private boomSvga;\n private playerSvga;\n private addScoreIcon;\n\n setup() {\n if (this._hasSetup) {\n return;\n }\n this._hasSetup = true;\n this.NpcBg = new engine.Container();\n this.NpcBg.alpha = 1;\n this.NpcBg.width = 0;\n this.NpcBg.height = 0;\n this.addChild(this.NpcBg);\n\n this.player = new engine.Container();\n\n this.player.vx = 0;\n this.player.vy = 11;\n this.player.isMovingLeft = false;\n this.player.isMovingRight = false;\n this.player.isDead = false;\n this.player.jump = () => {\n this.player.vy = -10;\n this.playerSvga.play(false, false);\n };\n\n this.playerSvga = createSvga('玩家abc');\n this.player.addChild(this.playerSvga);\n // this.playerSvga.gotoAndPlay(1);\n this.visible = false;\n this.addScoreIcon = new engine.Sprite(getTextureByName('加分'));\n this.addScoreIcon.visible = false;\n this.player.addChild(this.addScoreIcon);\n\n setTimeout(() => {\n this.visible = true;\n this.playerSvga.anchorY = this.playerSvga.height / 2;\n this.playerSvga.anchorX = this.playerSvga.width / 2;\n this.player.anchorY = this.player.height / 2;\n this.player.anchorX = this.player.width / 2;\n this.player.x = 375 - this.player.width / 2;\n // this.addScoreIcon.x = this.player.width + 20;\n this.iconX = this.player.width + 20;\n this.addScoreIcon.y =\n this.player.height / 2 - this.addScoreIcon.height / 2 + 20;\n\n // this.player.y = props.playerPositionY;\n }, 300);\n this.score = 0;\n this.rectBg = new engine.Container();\n // this.rectBg.alpha = 0;\n this.rectBg.width = 750;\n this.rectBg.height = 1624;\n this.rectHeight = this.stage.height - this.rectBg.height;\n this.rectBg.y = this.rectHeight;\n\n // this.bottom = 1624\n this.addChild(this.rectBg);\n this.player.y = this.rectBg.height;\n this.baseY = this.rectBg.height - this.bottomY;\n\n this.rectBg.addEventListener(\n engine.MouseEvent.CLICK,\n this.onDownStage,\n this\n );\n }\n\n base() {}\n // 创建台阶\n createPlatform(needGhost: boolean = false) {\n let platform = new Platform();\n platform.x = Math.random() * (this.width - platform.width);\n\n this.platPosition += this.rectBg.height / this.platformCount;\n let platform2 = new Platform();\n\n //左边出现的位置\n let left = platform.x;\n if (left > this.width / 2) {\n platform2.x =\n Math.random() * (platform.x - platform.width) - platform.width / 2;\n } else {\n platform2.x =\n platform.x +\n platform.width +\n Math.random() * (this.width - platform.x - platform.width * 1.5);\n }\n platform2.y = platform.y = this.platPosition;\n if (needGhost && !platform.prizeFlag) {\n platform.ghostFlag = Math.random() < platform.ghostOdds ? true : false;\n if (platform.ghostFlag) platform.ghostIcon.visible = true;\n }\n return [platform, platform2];\n }\n changePlatformGap(to: number) {\n if (this.platformCount == to) return;\n this.platformCount = to;\n let min = this.rectBg.height;\n for (let i = 0; i < this.platforms.length; i++) {\n if (min > this.platforms[i].y) {\n min = this.platforms[i].y;\n }\n }\n this.platPosition =\n min - this.rectBg.height / this.platformCount + this.rectBg.height;\n let newList = [];\n for (let i = 0; i < this.platformCount; i++) {\n newList.push(...this.createPlatform(true));\n }\n\n this.newPlatforms = newList;\n\n this.newPlatforms.forEach(p => {\n if (p.isNew && !p.addStatus) {\n this.rectBg.addChild(p);\n p.addStatus = true;\n }\n });\n this.platforms.forEach(p => {\n p.isNew = false;\n // // 如果有狼层级变高\n this.rectBg.addChild(p);\n // if (p.ghostFlag) {\n // this.rectBg.addChild(p);\n // }\n });\n this.platforms = this.platforms.concat(this.newPlatforms);\n // console.log(this.platforms);\n }\n // 台阶展示\n platformInit() {\n for (let i = 0; i < this.platformCount; i++) {\n this.platforms.push(...this.createPlatform());\n }\n this.platforms.forEach((p, i) => {\n this.rectBg.addChild(p);\n });\n }\n // getNewPlatform(){\n\n // }\n // 兔子跳起\n playerJump() {\n this.player.y += this.player.vy;\n this.player.vy += this.gravity;\n\n if (\n this.player.vy > 0 &&\n this.player.x + 15 < 260 &&\n this.player.x + this.player.width - 15 > 155 &&\n this.player.y + this.player.height > 475 &&\n this.player.y + this.player.height < 500\n ) {\n return this.player.jump();\n }\n\n if (this.player.isMovingLeft === true) {\n this.player.x += this.player.vx;\n this.player.vx -= 0.1;\n } else {\n this.player.x += this.player.vx;\n if (this.player.vx < 0) this.player.vx += 0.07;\n }\n\n if (this.player.isMovingRight === true) {\n this.player.x += this.player.vx;\n this.player.vx += 0.1;\n } else {\n this.player.x += this.player.vx;\n if (this.player.vx > 0) this.player.vx -= 0.07;\n }\n\n if (this.player.vx > 4) this.player.vx = 4;\n else if (this.player.vx < -4) this.player.vx = -4;\n\n if (\n this.player.y + this.player.height > this.baseY &&\n this.baseY < this.rectBg.height\n ) {\n this.player.jump();\n }\n\n if (\n this.baseY > this.rectBg.height &&\n this.player.y + this.player.height > this.rectBg.height &&\n this.player.isDead != 'lol'\n ) {\n this.player.isDead = true;\n SoundMgr.instance.playEffect('jumpdied');\n }\n\n if (this.player.x > this.width) this.player.x = 0 - this.player.width;\n else if (this.player.x < 0 - this.player.width)\n this.player.x = this.width - this.player.width;\n\n if (this.player.y >= this.rectBg.height / 2 - this.player.height / 2) {\n this.player.y += this.player.vy;\n this.player.vy += this.gravity;\n }\n\n //高度过半 重新创建台阶 滚动效果\n else {\n if (this.player.y < this.height / 2) {\n this.player.y -= this.player.vy;\n }\n if (this.newPlatforms.length > 0) {\n this.platforms.forEach((p, i) => {\n if (this.player.vy < 0) {\n p.y -= this.player.vy;\n }\n if (this.player.y < this.height / 2) {\n p.y -= this.player.vy;\n }\n // if (p.isNew && !p.addStatus) {\n // this.rectBg.addChild(p);\n // p.addStatus = true;\n // // this.newPlatforms.length--;\n // }\n // // 如果有狼层级变高\n // if (!p.isNew && p.ghostFlag) {\n // this.rectBg.addChild(p);\n // }\n if (p.y > this.height) {\n if (p.isNew == false) {\n this.cashNum++;\n if (\n this.cashNum ==\n this.platforms.length - this.newPlatforms.length\n ) {\n let list = this.platforms.splice(0, this.cashNum);\n // console.log(this.platforms);\n this.newPlatforms = [];\n // for (let p of list) {\n // this.rectBg.removeChild(p);\n // }\n for (let i = 0; i < list.length; i++) {\n this.rectBg.removeChild(list[i]);\n }\n this.cashNum = 0;\n }\n }\n\n p.y = p.y - this.rectBg.height * 2;\n }\n });\n } else {\n this.platforms.forEach((p, i) => {\n if (this.player.vy < 0) {\n p.y -= this.player.vy;\n }\n if (this.player.y < this.height / 2) {\n p.y -= this.player.vy;\n }\n if (p.y > this.height) {\n if (i % 2 == 0) {\n this.platforms[i].x =\n Math.random() * (this.width - this.platforms[i].width);\n if (i != 0) {\n p.getStatus();\n }\n } else {\n let last = this.platforms[i - 1],\n left = last.x;\n // p.y = last.y\n if (left > this.width / 2) {\n p.x = Math.random() * (last.x - p.width) - p.width / 2;\n } else {\n p.x =\n last.x +\n p.width +\n Math.random() * (this.width - last.x - p.width * 1.5);\n }\n }\n p.y = p.y - this.rectBg.height;\n }\n });\n }\n\n this.baseY -= this.player.vy;\n\n this.player.vy += this.gravity;\n if (this.player.vy >= 0) {\n this.player.y += this.player.vy;\n this.player.vy += this.gravity;\n }\n\n // 向上跳加分\n // this.score++;\n\n // engine.globalEvent.dispatchEvent('jump-more-score-update', {\n // score: this.score\n // });\n\n if (this.score > 30 && this.score < 60) {\n this.changePlatformGap(11);\n } else if (this.score > 60 && this.score < 120) {\n this.changePlatformGap(10);\n } else if (this.score > 120) {\n this.changePlatformGap(8);\n }\n }\n if (this.player.isDead === false) this.collides();\n if (this.player.isDead == true) {\n this.gameOver();\n }\n }\n playMusic() {\n SoundMgr.instance.playEffect('bgm', true);\n }\n // 跳上台阶检测\n collides() {\n this.platforms.forEach((p, i) => {\n if (\n this.player.vy > 0 &&\n p.state === 0 &&\n this.player.x + 55 < p.x + p.width &&\n this.player.x + this.player.width - 30 > p.x &&\n this.player.y + this.player.height + 15 > p.y &&\n this.player.y + this.player.height + 15 < p.y + p.height\n ) {\n // console.log(\"左边:\" , this.player.x + this.player.width - 30 > p.x);\n // console.log(\"右边:\" , this.player.x + 30< p.x + p.width);\n // console.log(this.player.x + 40, p.x + p.width);\n\n if (p.prizeFlag) {\n SoundMgr.instance.playEffect('prize');\n this.score += props.prizeScore;\n\n engine.globalEvent.dispatchEvent('jump-more-score-update', {\n score: this.score\n });\n p.prizeFlag = false;\n p.prizeIcon.visible = false;\n if (p.x > this.rectBg.width - p.width * 1.5) {\n this.addScoreIcon.x = -20 - this.addScoreIcon.width;\n // console.log(this.addScoreIcon.x);\n } else {\n this.addScoreIcon.x = this.iconX;\n }\n this.addScoreIcon.visible = true;\n if (this.addTimer) {\n clearTimeout(this.addTimer);\n }\n this.addTimer = setTimeout(() => {\n this.addScoreIcon.visible = false;\n }, 1000);\n } else if (p.ghostFlag) {\n SoundMgr.instance.playEffect('ghost');\n this.diedIndex = i;\n this.gameOver();\n } else {\n this.player.jump();\n }\n }\n });\n }\n\n gameOver() {\n this.platforms.forEach((p, i) => {\n p.y -= 12;\n });\n\n if (this.player.y > this.rectBg.height / 2 && this.flag === 0) {\n this.player.y -= 8;\n this.player.vy = 0;\n } else if (this.player.y + this.player.height > this.rectBg.height) {\n // console.log('showGoMenu');\n // this.player.isDead = 'lol';\n }\n engine.globalEvent.dispatchEvent('jump-more-game-over', {\n score: this.score\n });\n // console.log('showGoMenu');\n this.player.isDead = 'lol';\n // setTimeout(() => {\n // this.resume();\n // }, 3000);\n }\n rectBgCalc() {\n // if(this.player.y < this.height/2){\n // \tthis.rectBg.y-=this.player.vy;\n // }\n }\n gameRevive() {\n this.player.isDead = false;\n let random = Math.floor(Math.random() * 3) * 2;\n\n this.player.x = this.platforms[random].x;\n this.player.y = this.platforms[random].y;\n this.player.vx = 0;\n this.player.vy = 11;\n this.platforms.forEach((p, i) => {\n p.ghostFlag = false;\n p.ghostIcon.visible = false;\n });\n }\n update_my() {\n this.playerJump();\n // if (this.platforms[0].ghostFlag || this.platforms[1].ghostFlag) {\n // console.log(this.platforms[0]);\n // }\n\n this.rectBg.addChild(this.player);\n }\n\n /**\n * 重置场景\n */\n reset() {\n this.removeEventListener(engine.Event.ENTER_FRAME, this.test, this);\n SoundMgr.instance.stopEffect('bgm');\n this.recycleGoods();\n this.player.vx = 0;\n this.player.vy = 11;\n this.player.isMovingLeft = false;\n this.player.isMovingRight = false;\n this.player.x = 375 - this.player.width / 2;\n this.player.y = this.rectBg.height - 200;\n this.rectBg.y = this.rectHeight;\n this.platPosition = 0;\n this.score = 0;\n // this.cashNum = 0\n this.platformCount = 12;\n this.platformGap = 0;\n this.baseY = this.rectBg.height - this.bottomY;\n this.player.isDead = false;\n this.platformInit();\n this.playerJump();\n }\n\n /**\n * 开始\n */\n start() {\n // this.platformInit();\n this.aniLoop();\n this.playMusic();\n }\n\n /**\n * 暂停\n */\n pause() {\n this.gameIng = false;\n }\n\n /**\n * 恢复\n */\n revive() {\n this.gameIng = true;\n }\n\n /**\n * 重新开始\n */\n async resume() {\n this.reset();\n this.start();\n }\n\n test;\n\n aniLoop() {\n this.addEventListener(\n engine.Event.ENTER_FRAME,\n (this.test = () => {\n this.update_my();\n }),\n this\n );\n }\n\n /**\n * 玩家死亡\n */\n private died() {\n this.score = 0;\n this.pause();\n }\n\n /**\n * 回收指定物品\n * @param goods 物品\n */\n private removeNpc(goods) {\n this.NpcBg.removeChild(goods);\n ObjectPool.recycleObject(PoolName, goods);\n this.removeEventListener(\n engine.Event.ENTER_FRAME,\n () => {\n this.update_my();\n },\n this\n );\n let index = this.goodsItems.indexOf(goods);\n if (index > -1) {\n this.goodsItems.splice(index, 1);\n }\n }\n\n /**\n * 回收对象\n */\n private recycleGoods() {\n for (let p of this.platforms) {\n this.rectBg.removeChild(p);\n }\n this.newPlatforms = [];\n this.platforms = [];\n }\n\n private moveCatchX = 0;\n private playerCatchX = 0;\n\n /**\n * 碰撞检测\n * @param a a盒子\n * @param b b盒子\n */\n private hasHit(a, b) {\n if (\n Math.abs(a.x + a.width / 2 - (b.x + b.width / 2)) <\n a.width / 2 + b.width / 2 &&\n Math.abs(a.y + a.height / 2 - (b.y + b.height / 2)) <\n a.height / 2 + b.height / 2\n ) {\n return true;\n } else {\n return false;\n }\n }\n\n private onDownStage = e => {\n if (e.stageX < this.width / 2) {\n this.player.dir = 'left';\n this.player.isMovingLeft = true;\n this.playerSvga.scaleX = -1;\n setTimeout(() => {\n this.player.isMovingLeft = false;\n }, 500);\n } else {\n this.player.dir = 'right';\n this.player.isMovingRight = true;\n this.playerSvga.scaleX = 1;\n setTimeout(() => {\n this.player.isMovingRight = false;\n }, 500);\n }\n };\n private onMoveStage = e => {\n if (this.gameIng) {\n this.player.x = this.playerCatchX + (e.localX - this.moveCatchX);\n }\n };\n\n private onOutStage = e => {\n // this.moveCatchX = 0;\n // console.log(e);\n\n if (e.stageX < this.width / 2) {\n this.player.dir = 'left';\n this.player.isMovingLeft = false;\n } else {\n this.player.dir = 'right';\n this.player.isMovingRight = false;\n }\n };\n}\n","/**\n * Created by rockyl on 2020-01-09.\n */\n\nimport GameView from \"./GameView\";\nimport {injectProps} from \"../props\";\n\n\nexport class GameWrapper extends engine.Container {\n\tprivate _status;\n\tprivate _gameView: GameView;\n\n\n\n\n\n\tconstructor() {\n\t\tsuper();\n\t\tengine.globalEvent.addEventListener('jump-more-reset', this.reset, this);\n\t\tengine.globalEvent.addEventListener('jump-more-start', this.start, this);\n\t\t// engine.globalEvent.addEventListener('jump-more-pause', this.pause, this);\n\t\tengine.globalEvent.addEventListener('jump-more-resume', this.resume, this);\n\t\tengine.globalEvent.addEventListener('jump-more-revive', this.revive, this);\n\t\t// engine.globalEvent.addEventListener('jump-more-play-music', this.playMusic, this);\n\t\t// engine.globalEvent.addEventListener('food-fell-clear', this.clear, this);\n\t\t// engine.globalEvent.addEventListener('jump-more-score', ()=>{\n\t\t\n\t\t// } , this);\n\t\tthis.addEventListener(engine.MouseEvent.CLICK, this.onTap, this);\n\n\t\tlet gameView = this._gameView = new GameView();\n\t\tthis.addChild(gameView);\n\t\t// gameView.reset()\n\t\t// gameView.start()\n\t}\n\n\treset(event: engine.Event) {\t\t\n\t\tinjectProps(event.data);\n\t\tthis._gameView.visible = true;\n\t\tthis._gameView.reset();\n\t}\n\n\tstart(event: engine.Event) {\n\t\tinjectProps(event.data);\n\t\t// this._status = 1;\n\t\tthis._gameView.start();\n\t}\n\n\tpause() {\n\t\tthis._gameView.pause();\n\t}\n\n\tresume() {\n\t\tthis._gameView.resume();\n\t}\n\n\trevive() {\n\t\tthis._gameView.gameRevive();\n\t}\n\t// playMusic(){\n\t// \tthis._gameView.playMusic()\n\t// }\n\n\t// clear() {\n\t// \tthis._gameView.visible = false;\n\t// }\n\n\tprivate onTap(event) {\n\t//\tthis._gameView.tap(event);\n\t}\n}\n","/**\n * Created by rockyl on 2019-11-20.\n */\n\nimport {GameWrapper} from \"./game/GameWrapper\";\nimport {injectProps, prepareProps} from \"./props\";\n\nexport default function (props) {\n\tprepareProps();\n\tinjectProps(props);\n\n\tlet instance = new GameWrapper();\n\treturn instance;\n}\n"],"names":["__extends","ObjectPool"],"mappings":";;;;;;CAIO,IAAI,KAAK,GAAQ,EAAE,CAAC;AAE3B,UAAgB,YAAY;KAC3B,IAAI,SAAS,GAAG,QAAQ,EAAE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AAE,CAAC;MACvB;KAED,2BAAK,GAAL,UAAM,KAAmB;SACxB,WAAW,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;SAExB,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,CAAC;MACvB;KAED,2BAAK,GAAL;SACC,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,CAAC;MACvB;KAED,4BAAM,GAAN;SACC,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,CAAC;MACxB;KAED,4BAAM,GAAN;SACC,IAAI,CAAC,SAAS,CAAC,UAAU,EAAE,CAAC;MAC5B;KASO,2BAAK,GAAb,UAAc,KAAK;MAElB;KACF,kBAAC;CAAD,CAAC,CA9DgC,MAAM,CAAC,SAAS,GA8DhD;;iBC/DwB,KAAK;KAC7B,YAAY,EAAE,CAAC;KACf,WAAW,CAAC,KAAK,CAAC,CAAC;KAEnB,IAAI,QAAQ,GAAG,IAAI,WAAW,EAAE,CAAC;KACjC,OAAO,QAAQ,CAAC;CACjB,CAAC;;;;;;;;"}
\ No newline at end of file
/**
* Created by rockyl on 2020-01-21.
*/
let customModuleProps = {
};
{
"name": "跳一跳",
"desc": "跳一跳模块",
"props": {
"prizeScore": {
"alias": "接中奖品获得分数",
"type": "number",
"default": 3
},
"prizeOdds": {
"alias": "奖品出现概率",
"type": "number",
"default": 0.3
},
"ghostOdds": {
"alias": "怪物出现概率",
"type": "number",
"default": 0.3
}
},
"assets": [
{
"name": "玩家abc",
"url": "//yun.duiba.com.cn/aurora/assets/41aab15126a106fb7b4083fbc50f9bcea5b3a090.svga",
"uuid": "613125b7-f199-4aa1-860a-9243fc16c4eb",
"ext": ".svga"
},
{
"name": "玩家右",
"url": "//yun.duiba.com.cn/aurora/assets/85af8997aa6dd1aa47011ea843302a4a072f2efd.png",
"uuid": "09e76db2-db0f-46e0-803a-998b1895a027",
"ext": ".png"
},
{
"name": "台阶",
"url": "//yun.duiba.com.cn/aurora/assets/e37ef0563103ffd582d787d36032d7262a3dce47.png",
"uuid": "db411686-ad6b-4bed-81b5-b844715e2882",
"ext": ".png"
},
{
"name": "青团",
"url": "//yun.duiba.com.cn/aurora/assets/14bfed9ab0c2f995b1ca34a5ca0116e8d155012d.png",
"uuid": "84b0849b-7417-4322-b4a3-f7d1a38b15c3",
"ext": ".png"
}, {
"name": "大灰狼",
"url": "//yun.duiba.com.cn/aurora/assets/25a1b525af1daeab062565c2c2c9737957ce4be3.svga",
"uuid": "eae1241a-d133-4816-9496-a2850e7e2d8f",
"ext": ".svga"
}, {
"name": "得分",
"url": "//yun.duiba.com.cn/aurora/assets/88e5d349a8829ddd2b0f608da4d2d537db4bad54.png",
"uuid": "8d9cfa4e-18f9-43a4-8f8e-6996577482b6",
"ext": ".png"
},{
"name": "加分",
"url": "//yun.duiba.com.cn/aurora/assets/b534a5f50ccc7eeca9ea4f0d4dea78430b8dec9b.png",
"uuid": "6dcb1e61-95e2-4841-8b71-7152f8d6cb37",
"ext": ".png"
},
{
"name": "游戏背景音乐",
"url": "//yun.duiba.com.cn/aurora/assets/7c955f550176b8ea2797b5555c30f1dfc9a770c1.mp3",
"uuid": "da826400-c835-4b75-8991-a29b64c5ac0b",
"ext": ".mp3"
},
{
"name": "吃道具音效",
"url": "//yun.duiba.com.cn/aurora/assets/a9e40a494d33b2c2a5c70ad93090efb4b36cb55d.mp3",
"uuid": "6b809f4e-1712-4201-beed-a683294ded02",
"ext": ".mp3"
},
{
"name": "碰到怪物掉落死亡音效",
"url": "//yun.duiba.com.cn/aurora/assets/e7f28dbc188c24613dccd11690a6f2e66bd00caa.mp3",
"uuid": "dc4426e3-cfe0-492e-bf74-002e0eb605cf",
"ext": ".mp3"
},
{
"name": "跳起死亡音效",
"url": "//yun.duiba.com.cn/aurora/assets/5603f0353a3eeea305c7398bd17f993be7474641.mp3",
"uuid": "f3f66910-8af2-4ceb-b7b3-27329a8ca93b",
"ext": ".mp3"
}
],
"events": {
"in": {
"jump-more-reset": {
"alias": "重置",
"data": {
"goodsProbability": "[0.2,0.5,0.3]道具概率(雨滴、石头、炸弹),所有概率相加为1",
"countDown": "倒计时(s)",
"acceleratedSpeed": "道具掉落加速度(单位:每秒)"
}
},
"jump-more-start": {
"alias": "开始"
},
"jump-more-revive": {
"alias": "复活"
},
"jump-more-pause": {
"alias": "暂停"
},
"jump-more-resume": {
"alias": "恢复"
}
},
"out": {
"jump-more-score-update": {
"alias": "分数更新",
"data": {
"score": "分数"
}
},
"jump-more-game-over": {
"alias": "游戏结束",
"data": {
"score": "分数",
"reason": "结束原因(1:时间到了,2:玩家死亡)"
}
}
}
}
}
/**
* Created by rockyl on 2018/8/16.
*/
import { props } from '../props';
import { playSound, createSvga } from './utils';
import ObjectPool = engine.ObjectPool;
import { Platform } from './Platform';
import { PrizeGood } from './PrizeGood';
import { getTextureByName } from './utils';
import { Goods } from './Goods';
import { PoolName } from './object-pool-init';
import SoundMgr from './SoundMgr';
interface playerProp extends engine.Container {
// x速度
vx?: number;
// y速度
vy?: number;
isMovingLeft?: boolean;
isMovingRight?: boolean;
isDead?: boolean | string;
dir?: string;
// deadInfo:object;
draw?(): void;
jump?(): void;
jumpHigh?(): void;
}
export default class GameView extends engine.Container {
private _hasSetup;
gravity: number = 0.2;
bottomY: number = 5;
jumpCount: number = 0;
baseY: number;
flag = 0;
loopFrame: any;
prizeGoodList: { number: PrizeGood };
diedIndex: number;
rectHeight: number;
addTimer: NodeJS.Timer | null;
iconX = 0;
//玩家
private player: playerProp;
//触摸层
private rectBg: engine.Container;
//npc层
private NpcBg: engine.Container;
//当前分数
private score;
//游戏状态
private gameIng;
//npc出身计时器
private timer;
//倒计时计时器
private countdownTimer: any;
//倒计时
private countdown: number;
//当前速度
private speed: number;
// 当前场景上面的物品
private goodsItems = [];
private _goods: Goods;
constructor() {
super();
// this.platformCount = 10
this.once(engine.Event.ADDED_TO_STAGE, this.setup, this);
// engine.globalEvent.addEventListener('jump-more-score', , this);
}
platformCount = 12;
platformGap = 0;
platPosition = 0;
platforms = [];
newPlatforms = [];
cashNum = 0;
private waterSvga;
private boomSvga;
private playerSvga;
private addScoreIcon;
setup() {
if (this._hasSetup) {
return;
}
this._hasSetup = true;
this.NpcBg = new engine.Container();
this.NpcBg.alpha = 1;
this.NpcBg.width = 0;
this.NpcBg.height = 0;
this.addChild(this.NpcBg);
this.player = new engine.Container();
this.player.vx = 0;
this.player.vy = 11;
this.player.isMovingLeft = false;
this.player.isMovingRight = false;
this.player.isDead = false;
this.player.jump = () => {
this.player.vy = -10;
this.playerSvga.play(false, false);
};
this.playerSvga = createSvga('玩家abc');
this.player.addChild(this.playerSvga);
// this.playerSvga.gotoAndPlay(1);
this.visible = false;
this.addScoreIcon = new engine.Sprite(getTextureByName('加分'));
this.addScoreIcon.visible = false;
this.player.addChild(this.addScoreIcon);
setTimeout(() => {
this.visible = true;
this.playerSvga.anchorY = this.playerSvga.height / 2;
this.playerSvga.anchorX = this.playerSvga.width / 2;
this.player.anchorY = this.player.height / 2;
this.player.anchorX = this.player.width / 2;
this.player.x = 375 - this.player.width / 2;
// this.addScoreIcon.x = this.player.width + 20;
this.iconX = this.player.width + 20;
this.addScoreIcon.y =
this.player.height / 2 - this.addScoreIcon.height / 2 + 20;
// this.player.y = props.playerPositionY;
}, 300);
this.score = 0;
this.rectBg = new engine.Container();
// this.rectBg.alpha = 0;
this.rectBg.width = 750;
this.rectBg.height = 1624;
this.rectHeight = this.stage.height - this.rectBg.height;
this.rectBg.y = this.rectHeight;
// this.bottom = 1624
this.addChild(this.rectBg);
this.player.y = this.rectBg.height;
this.baseY = this.rectBg.height - this.bottomY;
this.rectBg.addEventListener(
engine.MouseEvent.CLICK,
this.onDownStage,
this
);
}
base() {}
// 创建台阶
createPlatform(needGhost: boolean = false) {
let platform = new Platform();
platform.x = Math.random() * (this.width - platform.width);
this.platPosition += this.rectBg.height / this.platformCount;
let platform2 = new Platform();
//左边出现的位置
let left = platform.x;
if (left > this.width / 2) {
platform2.x =
Math.random() * (platform.x - platform.width) - platform.width / 2;
} else {
platform2.x =
platform.x +
platform.width +
Math.random() * (this.width - platform.x - platform.width * 1.5);
}
platform2.y = platform.y = this.platPosition;
if (needGhost && !platform.prizeFlag) {
platform.ghostFlag = Math.random() < platform.ghostOdds ? true : false;
if (platform.ghostFlag) platform.ghostIcon.visible = true;
}
return [platform, platform2];
}
changePlatformGap(to: number) {
if (this.platformCount == to) return;
this.platformCount = to;
let min = this.rectBg.height;
for (let i = 0; i < this.platforms.length; i++) {
if (min > this.platforms[i].y) {
min = this.platforms[i].y;
}
}
this.platPosition =
min - this.rectBg.height / this.platformCount + this.rectBg.height;
let newList = [];
for (let i = 0; i < this.platformCount; i++) {
newList.push(...this.createPlatform(true));
}
this.newPlatforms = newList;
this.newPlatforms.forEach(p => {
if (p.isNew && !p.addStatus) {
this.rectBg.addChild(p);
p.addStatus = true;
}
});
this.platforms.forEach(p => {
p.isNew = false;
// // 如果有狼层级变高
this.rectBg.addChild(p);
// if (p.ghostFlag) {
// this.rectBg.addChild(p);
// }
});
this.platforms = this.platforms.concat(this.newPlatforms);
// console.log(this.platforms);
}
// 台阶展示
platformInit() {
for (let i = 0; i < this.platformCount; i++) {
this.platforms.push(...this.createPlatform());
}
this.platforms.forEach((p, i) => {
this.rectBg.addChild(p);
});
}
// getNewPlatform(){
// }
// 兔子跳起
playerJump() {
this.player.y += this.player.vy;
this.player.vy += this.gravity;
if (
this.player.vy > 0 &&
this.player.x + 15 < 260 &&
this.player.x + this.player.width - 15 > 155 &&
this.player.y + this.player.height > 475 &&
this.player.y + this.player.height < 500
) {
return this.player.jump();
}
if (this.player.isMovingLeft === true) {
this.player.x += this.player.vx;
this.player.vx -= 0.1;
} else {
this.player.x += this.player.vx;
if (this.player.vx < 0) this.player.vx += 0.07;
}
if (this.player.isMovingRight === true) {
this.player.x += this.player.vx;
this.player.vx += 0.1;
} else {
this.player.x += this.player.vx;
if (this.player.vx > 0) this.player.vx -= 0.07;
}
if (this.player.vx > 4) this.player.vx = 4;
else if (this.player.vx < -4) this.player.vx = -4;
if (
this.player.y + this.player.height > this.baseY &&
this.baseY < this.rectBg.height
) {
this.player.jump();
}
if (
this.baseY > this.rectBg.height &&
this.player.y + this.player.height > this.rectBg.height &&
this.player.isDead != 'lol'
) {
this.player.isDead = true;
SoundMgr.instance.playEffect('jumpdied');
}
if (this.player.x > this.width) this.player.x = 0 - this.player.width;
else if (this.player.x < 0 - this.player.width)
this.player.x = this.width - this.player.width;
if (this.player.y >= this.rectBg.height / 2 - this.player.height / 2) {
this.player.y += this.player.vy;
this.player.vy += this.gravity;
}
//高度过半 重新创建台阶 滚动效果
else {
if (this.player.y < this.height / 2) {
this.player.y -= this.player.vy;
}
if (this.newPlatforms.length > 0) {
this.platforms.forEach((p, i) => {
if (this.player.vy < 0) {
p.y -= this.player.vy;
}
if (this.player.y < this.height / 2) {
p.y -= this.player.vy;
}
// if (p.isNew && !p.addStatus) {
// this.rectBg.addChild(p);
// p.addStatus = true;
// // this.newPlatforms.length--;
// }
// // 如果有狼层级变高
// if (!p.isNew && p.ghostFlag) {
// this.rectBg.addChild(p);
// }
if (p.y > this.height) {
if (p.isNew == false) {
this.cashNum++;
if (
this.cashNum ==
this.platforms.length - this.newPlatforms.length
) {
let list = this.platforms.splice(0, this.cashNum);
// console.log(this.platforms);
this.newPlatforms = [];
// for (let p of list) {
// this.rectBg.removeChild(p);
// }
for (let i = 0; i < list.length; i++) {
this.rectBg.removeChild(list[i]);
}
this.cashNum = 0;
}
}
p.y = p.y - this.rectBg.height * 2;
}
});
} else {
this.platforms.forEach((p, i) => {
if (this.player.vy < 0) {
p.y -= this.player.vy;
}
if (this.player.y < this.height / 2) {
p.y -= this.player.vy;
}
if (p.y > this.height) {
if (i % 2 == 0) {
this.platforms[i].x =
Math.random() * (this.width - this.platforms[i].width);
if (i != 0) {
p.getStatus();
}
} else {
let last = this.platforms[i - 1],
left = last.x;
// p.y = last.y
if (left > this.width / 2) {
p.x = Math.random() * (last.x - p.width) - p.width / 2;
} else {
p.x =
last.x +
p.width +
Math.random() * (this.width - last.x - p.width * 1.5);
}
}
p.y = p.y - this.rectBg.height;
}
});
}
this.baseY -= this.player.vy;
this.player.vy += this.gravity;
if (this.player.vy >= 0) {
this.player.y += this.player.vy;
this.player.vy += this.gravity;
}
// 向上跳加分
// this.score++;
// engine.globalEvent.dispatchEvent('jump-more-score-update', {
// score: this.score
// });
if (this.score > 30 && this.score < 60) {
this.changePlatformGap(11);
} else if (this.score > 60 && this.score < 120) {
this.changePlatformGap(10);
} else if (this.score > 120) {
this.changePlatformGap(8);
}
}
if (this.player.isDead === false) this.collides();
if (this.player.isDead == true) {
this.gameOver();
}
}
playMusic() {
SoundMgr.instance.playEffect('bgm', true);
}
// 跳上台阶检测
collides() {
this.platforms.forEach((p, i) => {
if (
this.player.vy > 0 &&
p.state === 0 &&
this.player.x + 55 < p.x + p.width &&
this.player.x + this.player.width - 30 > p.x &&
this.player.y + this.player.height + 15 > p.y &&
this.player.y + this.player.height + 15 < p.y + p.height
) {
// console.log("左边:" , this.player.x + this.player.width - 30 > p.x);
// console.log("右边:" , this.player.x + 30< p.x + p.width);
// console.log(this.player.x + 40, p.x + p.width);
if (p.prizeFlag) {
SoundMgr.instance.playEffect('prize');
this.score += props.prizeScore;
engine.globalEvent.dispatchEvent('jump-more-score-update', {
score: this.score
});
p.prizeFlag = false;
p.prizeIcon.visible = false;
if (p.x > this.rectBg.width - p.width * 1.5) {
this.addScoreIcon.x = -20 - this.addScoreIcon.width;
// console.log(this.addScoreIcon.x);
} else {
this.addScoreIcon.x = this.iconX;
}
this.addScoreIcon.visible = true;
if (this.addTimer) {
clearTimeout(this.addTimer);
}
this.addTimer = setTimeout(() => {
this.addScoreIcon.visible = false;
}, 1000);
} else if (p.ghostFlag) {
SoundMgr.instance.playEffect('ghost');
this.diedIndex = i;
this.gameOver();
} else {
this.player.jump();
}
}
});
}
gameOver() {
this.platforms.forEach((p, i) => {
p.y -= 12;
});
if (this.player.y > this.rectBg.height / 2 && this.flag === 0) {
this.player.y -= 8;
this.player.vy = 0;
} else if (this.player.y + this.player.height > this.rectBg.height) {
// console.log('showGoMenu');
// this.player.isDead = 'lol';
}
engine.globalEvent.dispatchEvent('jump-more-game-over', {
score: this.score
});
// console.log('showGoMenu');
this.player.isDead = 'lol';
// setTimeout(() => {
// this.resume();
// }, 3000);
}
rectBgCalc() {
// if(this.player.y < this.height/2){
// this.rectBg.y-=this.player.vy;
// }
}
gameRevive() {
this.player.isDead = false;
let random = Math.floor(Math.random() * 3) * 2;
this.player.x = this.platforms[random].x;
this.player.y = this.platforms[random].y;
this.player.vx = 0;
this.player.vy = 11;
this.platforms.forEach((p, i) => {
p.ghostFlag = false;
p.ghostIcon.visible = false;
});
}
update_my() {
this.playerJump();
// if (this.platforms[0].ghostFlag || this.platforms[1].ghostFlag) {
// console.log(this.platforms[0]);
// }
this.rectBg.addChild(this.player);
}
/**
* 重置场景
*/
reset() {
this.removeEventListener(engine.Event.ENTER_FRAME, this.test, this);
SoundMgr.instance.stopEffect('bgm');
this.recycleGoods();
this.player.vx = 0;
this.player.vy = 11;
this.player.isMovingLeft = false;
this.player.isMovingRight = false;
this.player.x = 375 - this.player.width / 2;
this.player.y = this.rectBg.height - 200;
this.rectBg.y = this.rectHeight;
this.platPosition = 0;
this.score = 0;
// this.cashNum = 0
this.platformCount = 12;
this.platformGap = 0;
this.baseY = this.rectBg.height - this.bottomY;
this.player.isDead = false;
this.platformInit();
this.playerJump();
}
/**
* 开始
*/
start() {
// this.platformInit();
this.aniLoop();
this.playMusic();
}
/**
* 暂停
*/
pause() {
this.gameIng = false;
}
/**
* 恢复
*/
revive() {
this.gameIng = true;
}
/**
* 重新开始
*/
async resume() {
this.reset();
this.start();
}
test;
aniLoop() {
this.addEventListener(
engine.Event.ENTER_FRAME,
(this.test = () => {
this.update_my();
}),
this
);
}
/**
* 玩家死亡
*/
private died() {
this.score = 0;
this.pause();
}
/**
* 回收指定物品
* @param goods 物品
*/
private removeNpc(goods) {
this.NpcBg.removeChild(goods);
ObjectPool.recycleObject(PoolName, goods);
this.removeEventListener(
engine.Event.ENTER_FRAME,
() => {
this.update_my();
},
this
);
let index = this.goodsItems.indexOf(goods);
if (index > -1) {
this.goodsItems.splice(index, 1);
}
}
/**
* 回收对象
*/
private recycleGoods() {
for (let p of this.platforms) {
this.rectBg.removeChild(p);
}
this.newPlatforms = [];
this.platforms = [];
}
private moveCatchX = 0;
private playerCatchX = 0;
/**
* 碰撞检测
* @param a a盒子
* @param b b盒子
*/
private hasHit(a, b) {
if (
Math.abs(a.x + a.width / 2 - (b.x + b.width / 2)) <
a.width / 2 + b.width / 2 &&
Math.abs(a.y + a.height / 2 - (b.y + b.height / 2)) <
a.height / 2 + b.height / 2
) {
return true;
} else {
return false;
}
}
private onDownStage = e => {
if (e.stageX < this.width / 2) {
this.player.dir = 'left';
this.player.isMovingLeft = true;
this.playerSvga.scaleX = -1;
setTimeout(() => {
this.player.isMovingLeft = false;
}, 500);
} else {
this.player.dir = 'right';
this.player.isMovingRight = true;
this.playerSvga.scaleX = 1;
setTimeout(() => {
this.player.isMovingRight = false;
}, 500);
}
};
private onMoveStage = e => {
if (this.gameIng) {
this.player.x = this.playerCatchX + (e.localX - this.moveCatchX);
}
};
private onOutStage = e => {
// this.moveCatchX = 0;
// console.log(e);
if (e.stageX < this.width / 2) {
this.player.dir = 'left';
this.player.isMovingLeft = false;
} else {
this.player.dir = 'right';
this.player.isMovingRight = false;
}
};
}
/**
* Created by rockyl on 2020-01-09.
*/
import GameView from "./GameView";
import {injectProps} from "../props";
export class GameWrapper extends engine.Container {
private _status;
private _gameView: GameView;
constructor() {
super();
engine.globalEvent.addEventListener('jump-more-reset', this.reset, this);
engine.globalEvent.addEventListener('jump-more-start', this.start, this);
// engine.globalEvent.addEventListener('jump-more-pause', this.pause, this);
engine.globalEvent.addEventListener('jump-more-resume', this.resume, this);
engine.globalEvent.addEventListener('jump-more-revive', this.revive, this);
// engine.globalEvent.addEventListener('jump-more-play-music', this.playMusic, this);
// engine.globalEvent.addEventListener('food-fell-clear', this.clear, this);
// engine.globalEvent.addEventListener('jump-more-score', ()=>{
// } , this);
this.addEventListener(engine.MouseEvent.CLICK, this.onTap, this);
let gameView = this._gameView = new GameView();
this.addChild(gameView);
// gameView.reset()
// gameView.start()
}
reset(event: engine.Event) {
injectProps(event.data);
this._gameView.visible = true;
this._gameView.reset();
}
start(event: engine.Event) {
injectProps(event.data);
// this._status = 1;
this._gameView.start();
}
pause() {
this._gameView.pause();
}
resume() {
this._gameView.resume();
}
revive() {
this._gameView.gameRevive();
}
// playMusic(){
// this._gameView.playMusic()
// }
// clear() {
// this._gameView.visible = false;
// }
private onTap(event) {
// this._gameView.tap(event);
}
}
/**
* Created by rockyl on 2020-02-02.
*
* 掉落物品
*/
import {getTextureByName} from "./utils";
import {props} from "../props";
export class Goods extends engine.Container {
private _body:engine.Rect
private _toY;
constructor() {
super();
let body
body = this._body =new engine.Rect()
let rain = new engine.Sprite(getTextureByName('雨滴'));
rain["npcType"]="rain"
let stone = new engine.Sprite(getTextureByName('石块'));
stone["npcType"]="stone"
let boom = new engine.Sprite(getTextureByName('炸弹'));
boom["npcType"]="boom"
rain.visible=false;
stone.visible=false;
boom.visible=false;
body.addChild(rain)
body.addChild(stone)
body.addChild(boom)
this.addChild(body);
body.width=.0001;
body.height=.0001;
body.mouseEnabled=false;
}
getRandomNumberByRange(start, end) {
return Math.floor(Math.random() * (end - start) + start)
}
reset() {
this.visible = true;
this.rotation = 0;
this.anchorOffsetY = 0;
this.y = 0;
this.x = (750-120)*Math.random()+30;
this.rotation = 0;
let random=Math.random()
if(random<props.goodsProbability[0]){
this.showNpc("rain")
}else if(random>=props.goodsProbability[0]&&random<=(props.goodsProbability[0]+props.goodsProbability[1])){
this.showNpc("stone")
}else if(random>(props.goodsProbability[0]+props.goodsProbability[1])){
this.showNpc("boom")
}
}
showNpc(type){
for(let i=0;i<this._body.children.length;i++){
this._body.children[i].visible=false;
this._body.children[i].mouseEnabled=false;
}
for(let i=0;i<this._body.children.length;i++){
if(this._body.children[i]["npcType"]==type){
this["npcType"]=type
this._body.children[i].visible=true;
this._body.children[i].mouseEnabled=false;
}
}
}
set anchorOffsetY(v) {
this._body.y = v;
}
}
import { getTextureByName } from './utils';
import { props } from '../props';
import { createSvga } from './utils';
interface PlatformProps {
width: number;
height: number;
x: number;
y: number;
count: number;
}
export class Platform extends engine.Container {
private _body: engine.Rect;
// private _toY;
flag;
state;
moved;
vx;
type;
x = 0;
y = 0;
prizeOdds = props.prizeOdds;
ghostOdds = props.ghostOdds;
prizeFlag: boolean;
ghostFlag: boolean;
isNew: boolean;
addStatus: boolean;
prizeIcon: engine.Sprite;
ghostIcon;
constructor() {
super();
this.width = 224;
this.height = 56;
this.flag = 0;
this.state = 0;
this.moved = 0;
this.vx = 1;
this.type = 1;
this._body = new engine.Rect();
this.isNew = true
this.addStatus = false
this.addChild(new engine.Sprite(getTextureByName('台阶')));
this.prizeIcon = new engine.Sprite(getTextureByName('青团'));
this.prizeIcon.x = this.x + this.width / 2 - this.prizeIcon.width / 2;
this.prizeIcon.y = this.y - this.height + 10;
this.ghostIcon = createSvga('大灰狼');
this.ghostIcon.gotoAndPlay(1);
setTimeout(() => {
this.ghostIcon.y = -this.height * 2 - 10;
this.ghostIcon.x = this.width / 2 - this.ghostIcon.width / 2;
}, 10);
this.prizeIcon.visible = false;
this.ghostIcon.visible = false;
this.addChild(this.ghostIcon);
this.addChild(this.prizeIcon);
this.prizeFlag = Math.random() < this.prizeOdds ? true : false;
if (this.prizeFlag) {
this.ghostFlag = false;
this.prizeIcon.visible = true;
} else {
// this.ghostFlag = Math.random() < this.ghostOdds ? true : false;
// if (this.ghostFlag) this.ghostIcon.visible = true;
}
// let platform = new engine.Sprite(getTextureByName('台阶'));
}
getStatus() {
this.prizeIcon.visible = false;
this.ghostIcon.visible = false;
this.prizeFlag = Math.random() < this.prizeOdds ? true : false;
if (this.prizeFlag) {
this.ghostFlag = false;
this.prizeIcon.visible = true;
} else {
this.ghostFlag = Math.random() < this.ghostOdds ? true : false;
if (this.ghostFlag) this.ghostIcon.visible = true;
}
}
}
import {getTextureByName} from "./utils";
import {props} from "../props";
export class PrizeGood extends engine.Container {
private _body:engine.Rect
// private _toY;
x = 0;
y = 0;
id = 0;
state: number
constructor() {
super();
this.width = 146
this.height = 52
this.state = 0
this.addChild(new engine.Sprite(getTextureByName('青团')));
}
}
\ No newline at end of file
export default class SoundMgr {
private static _instance: SoundMgr = null;
public static get instance(): SoundMgr {
if (!this._instance) {
this._instance = new SoundMgr();
}
return this._instance;
}
public get enabled() {
return engine.env.soundEnabled;
}
public playEffect(name: string, loop: boolean = false) {
//if (!this.enabled) return;
engine.playSound(getAssetByUUID(nameToUuid[name]).uuid, {
loop,
keep: true
}, name);
}
public stopEffect(name: string){
engine.stopSound(name);
engine.destroySound(name);
}
}
const nameToUuid = {
bgm: "da826400-c835-4b75-8991-a29b64c5ac0b",
prize: "6b809f4e-1712-4201-beed-a683294ded02",
ghost: "dc4426e3-cfe0-492e-bf74-002e0eb605cf",
jumpdied: "f3f66910-8af2-4ceb-b7b3-27329a8ca93b",
}
\ No newline at end of file
/**
* Created by rockyl on 2020-02-03.
*/
import {Goods} from "./Goods";
import {Platform} from "./Platform";
import ObjectPool = engine.ObjectPool;
export const PoolName: string = 'goods';
ObjectPool.registerPool(PoolName, function () {
return new Goods();
}, function (item: Goods, data) {
item.reset();
});
/**
* Created by rockyl on 2020-01-21.
*/
export function getTexture(uuid) {
return engine.Texture.from(getAssetByUUID(uuid).uuid);
}
export function getTextureByName(name) {
return getTexture(engine.getAssetByName(name).uuid);
}
export function playSound(name) {
engine.playSound(engine.getAssetByName(name).uuid, {keep: true});
}
export function createSvga(name, anchorName?) {
let inst = new svga.Svga();
inst.source = 'asset://' + engine.getAssetByName(name).uuid;
return inst;
}
\ No newline at end of file
/**
* Created by rockyl on 2019-11-20.
*/
import {GameWrapper} from "./game/GameWrapper";
import {injectProps, prepareProps} from "./props";
export default function (props) {
prepareProps();
injectProps(props);
let instance = new GameWrapper();
return instance;
}
/**
* Created by rockyl on 2020-01-21.
*/
export let props: any = {};
export function prepareProps() {
let metaProps = getProps();
engine.injectProp(props, metaProps);
}
export function injectProps(p) {
engine.injectProp(props, p);
}
......@@ -17,7 +17,6 @@
padding: 0;
margin: 0;
border: 0;
width: 100%;
height: 100%;
overflow: hidden;
......
......@@ -14,4 +14,5 @@
"output": [
"true", "false"
]
}
\ No newline at end of file
}
/**
* Created by rockyl on 2019-11-16.
*/
*/
engine.gameStage.dataCenter.mutate(props.name, args, props.path);
next('success', args);
......@@ -5,5 +5,5 @@
const duration = engine.findVariable('duration', args, props);
setTimeout(function(){
next('complete')
next('complete', args)
}, duration);
/**
* Created by rockyl on 2019-11-16.
*/
pick(function (imgData) {
next('success', imgData);
});
function getExif(img, callback) {
EXIF.getData(img, function () {
let allMetaData = EXIF.getAllTags(this);
callback(allMetaData)
});
}
function pick(callback) {
let fileInput = document.createElement("input");
fileInput.type = "file";
fileInput.accept = "image/*";
fileInput.style.display = "none";
document.body.insertBefore(fileInput, document.body.firstChild);
fileInput.addEventListener("change", function (evt) {
let mime = {"png": "image/png", "jpg": "image/jpeg", "jpeg": "image/jpeg", "bmp": "image/bmp"};
let file = evt.target.files[0];
let type = file.type;
if (!type) {
type = mime[file.name.match(/\.([^\.]+)$/i)[1]];
}
let fileReader = new FileReader();
fileReader.onload = function () {
getExif(file, (exif) => {
//let exif = EXIF.readFromBinaryFile(arrayBuffer);
let orientation = -1;
if (exif) {
orientation = exif["Orientation"];
}
let image = new Image();
image.onload = function () {
let canvas = document.createElement("canvas");
let ctx = canvas.getContext("2d");
canvas.width = image.width;
canvas.height = image.height;
if (orientation > 4) {
canvas.width = image.height;
canvas.height = image.width;
}
ctx.clearRect(0, 0, canvas.width, canvas.height);
switch (orientation) {
case 2:
// horizontal flip
ctx.translate(canvas.width, 0);
ctx.scale(-1, 1);
break;
case 3:
// 180° rotate left
ctx.translate(canvas.width, canvas.height);
ctx.rotate(Math.PI);
break;
case 4:
ctx.translate(0, canvas.height);
ctx.scale(1, -1);
break;
case 5:
ctx.rotate(0.5 * Math.PI);
ctx.scale(1, -1);
break;
case 6:
ctx.rotate(0.5 * Math.PI);
ctx.translate(0, -image.height);
break;
case 7:
ctx.rotate(0.5 * Math.PI);
ctx.translate(canvas.width, -canvas.height);
ctx.scale(-1, 1);
break;
case 8:
ctx.rotate(-0.5 * Math.PI);
ctx.translate(-canvas.height, 0);
break;
default:
ctx.transform(1, 0, 0, 1, 0, 0);
}
ctx.drawImage(image, 0, 0);
let imagetype = "png";
if (orientation !== -1) {
imagetype = "jpeg";
}
let resultURL = "";
if (imagetype === "jpg" || imagetype === "jpeg") {
resultURL = canvas.toDataURL("image/" + imagetype);
} else {
resultURL = canvas.toDataURL("image/" + imagetype);
}
callback(resultURL);
image.parentNode.removeChild(image);
fileInput.parentNode.removeChild(fileInput);
};
image.src = fileReader.result;
image.style.display = "none";
document.body.appendChild(image);
fileInput.value = "";
});
};
fileReader.readAsDataURL(file);
}, false);
fileInput.click();
}
{
"name": "选择图片",
"desc": "选择一个图片文件",
"props": {
},
"output": [
"success"
]
}
/**
* Created by rockyl on 2019-11-16.
*/
const width = engine.findVariable('width', args, props);
const height = engine.findVariable('height', args, props);
const cutType = engine.findVariable('cutType', args, props);
const type = engine.findVariable('type', args, props);
const quality = engine.findVariable('quality', args, props);
let img = args;
if (typeof args === 'string') {
img = new Image();
img.onload = function () {
deal();
};
img.onerror = function (e) {
console.log(e);
};
img.src = args;
}
else {
deal();
}
function deal() {
let m = cutType === 'inner' ? Math.min : Math.max;
let r = m(width / img.width, height / img.height);
let imgWidth = img.width * r;
let imgHeight = img.height * r;
let x = (width - imgWidth) / 2;
let y = (height - imgHeight) / 2;
let canvas = document.createElement('canvas');
canvas.width = width;
canvas.height = height;
let ctx = canvas.getContext('2d');
ctx.translate(x, y);
ctx.scale(r, r);
ctx.drawImage(img, 0, 0);
let dataUrl = canvas.toDataURL('image/' + type, quality);
next('success', dataUrl);
}
{
"name": "缩放图片",
"desc": "缩放图片",
"props": {
"width": {"type": "number", "alias": "目标宽度"},
"height": {"type": "number", "alias": "目标高度"},
"cutType": {"type": "enum", "enum": ["inner", "outer"], "alias": "裁剪类型", "default": "inner"},
"type": {"type": "enum", "enum": ["png", "jpeg"], "alias": "输出类型", "default": "png"},
"quality": {"type": "number", "alias": "图片质量", "default": 0.7}
},
"output": [
"success"
]
}
......@@ -6,13 +6,33 @@
},
"text": {
"type": "string",
"alias": "内容"
"alias": "文本内容"
},
"labelAlign": {
"alias": "文本对齐",
"type": "enum",
"enum": [
{"label":"左对齐", "value":"left"},
{"label":"居中对齐", "value":"center"},
{"label":"右对齐", "value":"right"}
],
"default": "center"
},
"labSize": {
"alias": "文本大小",
"type": "number",
"default": 30
},
"padding": {
"type": "number",
"default": 10,
"alias": "边距"
},
"bgAlpha": {
"type": "number",
"default": 0.7,
"alias": "背景透明度"
},
"paddingH": {
"type": "number",
"alias": "横向边距"
......@@ -46,4 +66,4 @@
"output": [
"success"
]
}
\ No newline at end of file
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment