Commit 1c89e887 authored by wildfirecode's avatar wildfirecode

1

parent 86132dab
......@@ -412,5 +412,5 @@
}
},
"id": "recycling",
"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.recycling = factory(global.tslib));\n}(this, (function (tslib) { 'use strict';\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\t//# sourceMappingURL=utils.js.map\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\tvar Conveyor = (function (_super) {\n\t tslib.__extends(Conveyor, _super);\n\t function Conveyor() {\n\t var _this = _super.call(this) || this;\n\t _this.y = 904.21;\n\t var sp = new engine.Sprite(getTextureByName('conveyor'));\n\t _this.addChild(sp);\n\t _this.idx0 = _this.createItem(75, 50);\n\t _this.idx1 = _this.createItem(225, 50);\n\t _this.idx2 = _this.createItem(375, 50);\n\t _this.idx3 = _this.createItem(525, 50);\n\t _this.idx4 = _this.createItem(675, 50);\n\t return _this;\n\t }\n\t Conveyor.prototype.clear = function () {\n\t this.clearItem(this.idx0);\n\t this.clearItem(this.idx1);\n\t this.clearItem(this.idx2);\n\t this.clearItem(this.idx3);\n\t this.clearItem(this.idx4);\n\t };\n\t Conveyor.prototype.clearItem = function (idx) {\n\t if (idx.children.length > 0)\n\t idx.removeChildAt(0);\n\t };\n\t Conveyor.prototype.createItem = function (x, y) {\n\t var sp = new engine.Sprite();\n\t this.addChild(sp);\n\t sp.x = x;\n\t sp.y = y;\n\t return sp;\n\t };\n\t return Conveyor;\n\t}(engine.Sprite));\n\t//# sourceMappingURL=Conveyor.js.map\n\n\tvar GarbageTypes;\n\t(function (GarbageTypes) {\n\t GarbageTypes[\"recoverableWaste\"] = \"recoverableWaste\";\n\t GarbageTypes[\"harmfulWaste\"] = \"harmfulWaste\";\n\t GarbageTypes[\"wetWaste\"] = \"wetWaste\";\n\t GarbageTypes[\"dryWaste\"] = \"dryWaste\";\n\t})(GarbageTypes || (GarbageTypes = {}));\n\t//# sourceMappingURL=GarbageTypes.js.map\n\n\tvar GarbageConfig = (function () {\n\t function GarbageConfig() {\n\t }\n\t GarbageConfig.config = [\n\t { name: \"电池\", source: \"g00\", type: GarbageTypes.harmfulWaste, width: 51, height: 123 },\n\t { name: \"温度计\", source: \"g01\", type: GarbageTypes.harmfulWaste, width: 65, height: 130 },\n\t { name: \"鱼刺\", source: \"g02\", type: GarbageTypes.wetWaste, width: 104, height: 82 },\n\t { name: \"龙虾\", source: \"g03\", type: GarbageTypes.wetWaste, width: 129, height: 122 },\n\t { name: \"西瓜\", source: \"g04\", type: GarbageTypes.wetWaste, width: 134, height: 111 },\n\t { name: \"旧玩具\", source: \"g05\", type: GarbageTypes.recoverableWaste, width: 72, height: 135 },\n\t { name: \"口红\", source: \"g06\", type: GarbageTypes.dryWaste, width: 49, height: 134 },\n\t { name: \"面包\", source: \"g07\", type: GarbageTypes.wetWaste, width: 96, height: 128 },\n\t { name: \"绿植\", source: \"g08\", type: GarbageTypes.wetWaste, width: 81, height: 131 },\n\t { name: \"保温瓶\", source: \"g09\", type: GarbageTypes.recoverableWaste, width: 66, height: 137 },\n\t { name: \"破衣服\", source: \"g10\", type: GarbageTypes.recoverableWaste, width: 91, height: 121 },\n\t { name: \"茶叶渣\", source: \"g11\", type: GarbageTypes.wetWaste, width: 108, height: 125 },\n\t { name: \"湿巾\", source: \"g12\", type: GarbageTypes.dryWaste, width: 106, height: 109 },\n\t { name: \"过期药膏\", source: \"g13\", type: GarbageTypes.harmfulWaste, width: 107, height: 130 },\n\t { name: \"用完的洗发水瓶\", source: \"g14\", type: GarbageTypes.recoverableWaste, width: 153, height: 148 },\n\t { name: \"婴儿纸尿裤\", source: \"g15\", type: GarbageTypes.dryWaste, width: 108, height: 123 },\n\t { name: \"香水瓶\", source: \"g16\", type: GarbageTypes.recoverableWaste, width: 65, height: 127 },\n\t { name: \"花甲壳\", source: \"g17\", type: GarbageTypes.wetWaste, width: 99, height: 115 },\n\t { name: \"过期调味料\", source: \"g18\", type: GarbageTypes.wetWaste, width: 109, height: 130 },\n\t { name: \"地毯\", source: \"g19\", type: GarbageTypes.recoverableWaste, width: 145, height: 119 },\n\t { name: \"甘蔗渣\", source: \"g20\", type: GarbageTypes.wetWaste, width: 100, height: 116 },\n\t { name: \"玻璃渣\", source: \"g21\", type: GarbageTypes.recoverableWaste, width: 95, height: 122 },\n\t { name: \"番茄酱\", source: \"g22\", type: GarbageTypes.wetWaste, width: 82, height: 125 },\n\t { name: \"酒精棉\", source: \"g23\", type: GarbageTypes.dryWaste, width: 64, height: 124 },\n\t { name: \"指甲油瓶子\", source: \"g24\", type: GarbageTypes.harmfulWaste, width: 109, height: 125 },\n\t { name: \"肉骨头\", source: \"g25\", type: GarbageTypes.dryWaste, width: 67, height: 123 },\n\t { name: \"嚼过的口香糖\", source: \"g26\", type: GarbageTypes.dryWaste, width: 135, height: 116 },\n\t { name: \"充电插头\", source: \"g27\", type: GarbageTypes.recoverableWaste, width: 86, height: 128 },\n\t { name: \"旧报纸\", source: \"g28\", type: GarbageTypes.recoverableWaste, width: 68, height: 124 },\n\t { name: \"烟头\", source: \"g29\", type: GarbageTypes.dryWaste, width: 108, height: 145 },\n\t { name: \"奶茶塑料杯\", source: \"g30\", type: GarbageTypes.dryWaste, width: 109, height: 143 },\n\t { name: \"瓜子壳\", source: \"g31\", type: GarbageTypes.wetWaste, width: 87, height: 121 },\n\t { name: \"橘子皮\", source: \"g32\", type: GarbageTypes.wetWaste, width: 78, height: 120 },\n\t { name: \"气球\", source: \"g33\", type: GarbageTypes.dryWaste, width: 78, height: 121 },\n\t { name: \"树叶\", source: \"g34\", type: GarbageTypes.wetWaste, width: 75, height: 117 },\n\t { name: \"感冒药\", source: \"g35\", type: GarbageTypes.harmfulWaste, width: 92, height: 121 },\n\t { name: \"电话机\", source: \"g36\", type: GarbageTypes.recoverableWaste, width: 63, height: 121 },\n\t { name: \"奶酪\", source: \"g37\", type: GarbageTypes.wetWaste, width: 90, height: 116 },\n\t { name: \"啤酒瓶\", source: \"g38\", type: GarbageTypes.recoverableWaste, width: 64, height: 123 },\n\t { name: \"薯片包装\", source: \"g39\", type: GarbageTypes.dryWaste, width: 134, height: 123 },\n\t { name: \"过期保健品\", source: \"g40\", type: GarbageTypes.harmfulWaste, width: 108, height: 125 },\n\t { name: \"雪糕包装袋\", source: \"g41\", type: GarbageTypes.dryWaste, width: 109, height: 128 },\n\t { name: \"废油漆\", source: \"g42\", type: GarbageTypes.harmfulWaste, width: 98, height: 122 },\n\t { name: \"食品罐头\", source: \"g43\", type: GarbageTypes.recoverableWaste, width: 94, height: 117 },\n\t { name: \"陶瓷碗\", source: \"g44\", type: GarbageTypes.dryWaste, width: 105, height: 122 },\n\t { name: \"蚊香\", source: \"g45\", type: GarbageTypes.dryWaste, width: 69, height: 146 },\n\t { name: \"电脑机箱\", source: \"g46\", type: GarbageTypes.recoverableWaste, width: 84, height: 124 },\n\t { name: \"鲜花\", source: \"g47\", type: GarbageTypes.wetWaste, width: 62, height: 122 },\n\t { name: \"宠物粮食\", source: \"g48\", type: GarbageTypes.wetWaste, width: 87, height: 121 },\n\t { name: \"银行卡\", source: \"g49\", type: GarbageTypes.recoverableWaste, width: 115, height: 123 },\n\t ];\n\t return GarbageConfig;\n\t}());\n\t//# sourceMappingURL=GarbageConfig.js.map\n\n\tvar transStores = (function (list) {\n\t var tmp = [];\n\t var contains = function (val) {\n\t for (var _i = 0, tmp_1 = tmp; _i < tmp_1.length; _i++) {\n\t var i = tmp_1[_i];\n\t if (val.targetType == i.targetType && val.itemType == i.itemType && val.itemName == i.itemName)\n\t return true;\n\t }\n\t return false;\n\t };\n\t list.forEach(function (i) {\n\t if (!contains(i))\n\t tmp.push(i);\n\t });\n\t list = tmp;\n\t tmp = [];\n\t var nameList = [];\n\t var contains2 = function (val) {\n\t for (var _i = 0, tmp_2 = tmp; _i < tmp_2.length; _i++) {\n\t var i = tmp_2[_i];\n\t if (val.itemName == i.itemName) {\n\t nameList.push(i.itemName);\n\t return true;\n\t }\n\t }\n\t return false;\n\t };\n\t list.forEach(function (i) {\n\t if (!contains2(i))\n\t tmp.push(i);\n\t });\n\t list = tmp;\n\t list.forEach(function (i) {\n\t if (nameList.indexOf(i.itemName) != -1) {\n\t i.targetType = i.itemType;\n\t }\n\t });\n\t return list.map(function (i) {\n\t return {\n\t 'targetName': getTargetName(i.targetType),\n\t 'isCorrect': i.targetType == i.itemType,\n\t 'itemName': i.itemName\n\t };\n\t });\n\t});\n\tvar getTargetName = function (type) {\n\t switch (type) {\n\t case GarbageTypes.recoverableWaste:\n\t return '可回收物';\n\t case GarbageTypes.harmfulWaste:\n\t return '有害垃圾';\n\t case GarbageTypes.wetWaste:\n\t return '湿垃圾';\n\t case GarbageTypes.dryWaste:\n\t return '干垃圾';\n\t }\n\t};\n\t//# sourceMappingURL=transStores.js.map\n\n\tvar checkHit = (function (view, rect) {\n\t var x = view.x, y = view.y;\n\t var _a = view.texture, width = _a.width, height = _a.height;\n\t if (x > rect.x && y > rect.y && (x + width) < (rect.x + rect.width) && (y + height) < (rect.y + rect.height)) {\n\t return true;\n\t }\n\t return false;\n\t});\n\t//# sourceMappingURL=checkHit.js.map\n\n\tvar removeChild = (function (d) {\n\t if (d && d.parent) {\n\t d.parent.removeChild(d);\n\t }\n\t});\n\t//# sourceMappingURL=removeChild.js.map\n\n\tvar removeEle = (function (e, arr) {\n\t var index = arr.indexOf(e);\n\t if (index >= 0) {\n\t arr.splice(index, 1);\n\t }\n\t});\n\t//# sourceMappingURL=removeEle.js.map\n\n\tvar shuffle = (function (arr) {\n\t var _a;\n\t var i = arr.length;\n\t while (i) {\n\t var j = Math.floor(Math.random() * i--);\n\t _a = [arr[i], arr[j]], arr[j] = _a[0], arr[i] = _a[1];\n\t }\n\t return arr;\n\t});\n\t//# sourceMappingURL=shuffle.js.map\n\n\tvar Conveyors = (function (_super) {\n\t tslib.__extends(Conveyors, _super);\n\t function Conveyors(p) {\n\t var _this = _super.call(this) || this;\n\t _this.conveyorsPool = [];\n\t _this.GarbageConfig = GarbageConfig.config;\n\t _this.datas = [];\n\t _this.wrapper = p;\n\t return _this;\n\t }\n\t Conveyors.prototype.initData = function (conveyor0, conveyor1) {\n\t this.conveyor0 = conveyor0;\n\t this.conveyor1 = conveyor1;\n\t };\n\t Conveyors.prototype.setDefault = function () {\n\t this.clear();\n\t this.score = 0;\n\t this.conveyorsPool.push(this.conveyor0);\n\t this.conveyorsPool.push(this.conveyor1);\n\t var allConfigs = shuffle(this.GarbageConfig);\n\t for (var i = 0; i < GarbageConfig.config.length; i++) {\n\t allConfigs[i].idx = i;\n\t allConfigs[i].isRight = false;\n\t allConfigs[i].isMistake = false;\n\t allConfigs[i].isOnStage = false;\n\t this.datas.push(allConfigs[i]);\n\t }\n\t for (var i = 0; i < 5; i++) {\n\t var data = this.datas[i];\n\t var view = new engine.Sprite(getTextureByName(data.source));\n\t view.isWrong = false;\n\t view.isRight = false;\n\t data.isOnStage = true;\n\t view.type = data.type;\n\t view.name = data.name;\n\t view.anchorX = data.width / 2;\n\t view.anchorY = data.height;\n\t view.x = -data.width / 2;\n\t view.y = -data.height + 40;\n\t this.conveyor1[\"idx\" + i].addChild(view);\n\t view.addEventListener(engine.MouseEvent.MOUSE_DOWN, this.onDown_garbage, this);\n\t }\n\t };\n\t Conveyors.prototype.startConveyors = function () {\n\t this.setDefault();\n\t engine.gameStage.addEventListener(engine.Event.ENTER_FRAME, this.onEnterFrame, this);\n\t };\n\t Conveyors.prototype.onEnterFrame = function (ENTER_FRAME, onEnterFrame, arg2) {\n\t if (this.score == (props.maxScore || 100)) {\n\t this.gameOver();\n\t this.wrapper.stop();\n\t }\n\t this.conveyorsPool.forEach(function (conveyor) {\n\t conveyor.x -= props.speed || 3;\n\t });\n\t if (this.conveyorsPool[this.conveyorsPool.length - 1].x <= 764) {\n\t var conveyor = new Conveyor();\n\t conveyor.x = this.conveyorsPool[this.conveyorsPool.length - 1].x + 764;\n\t this.wrapper.addChild(conveyor);\n\t this.conveyorsPool.push(conveyor);\n\t }\n\t else {\n\t var dataList = [];\n\t for (var n = 0; n < this.datas.length; n++) {\n\t var dataItem = this.datas[n];\n\t if (!dataItem.isRight && !dataItem.isOnStage) {\n\t dataList.push(dataItem);\n\t }\n\t }\n\t var lastConveyor = this.conveyorsPool[this.conveyorsPool.length - 1];\n\t for (var m = 0; m < 5; m++) {\n\t if (!lastConveyor[\"idx\" + m].children[0]) {\n\t var data = dataList.shift();\n\t if (data) {\n\t data.isOnStage = true;\n\t var view = new engine.Sprite(getTextureByName(data.source));\n\t view.isWrong = false;\n\t view.isRight = false;\n\t view.type = data.type;\n\t view.name = data.name;\n\t view.anchorX = data.width / 2;\n\t view.anchorY = data.height;\n\t view.x = -data.width / 2;\n\t view.y = -data.height + 40;\n\t lastConveyor[\"idx\" + m].addChild(view);\n\t view.addEventListener(engine.MouseEvent.MOUSE_DOWN, this.onDown_garbage, this);\n\t }\n\t else {\n\t break;\n\t }\n\t }\n\t }\n\t }\n\t if (this.conveyorsPool[0].x < -750) {\n\t for (var k = 0; k < this.datas.length; k++) {\n\t var dataItem = this.datas[k];\n\t var idx4 = this.conveyorsPool[0][\"idx\" + 4];\n\t if (idx4.children[0]) {\n\t if (dataItem.name == idx4.children[0].name) {\n\t dataItem.isOnStage = false;\n\t removeEle(dataItem, this.datas);\n\t this.datas.push(dataItem);\n\t idx4.removeChild(idx4.children[0]);\n\t break;\n\t }\n\t }\n\t }\n\t this.conveyorsPool.shift();\n\t }\n\t else if (this.conveyorsPool[0].x < -600) {\n\t for (var k = 0; k < this.datas.length; k++) {\n\t var dataItem = this.datas[k];\n\t var idx3 = this.conveyorsPool[0][\"idx\" + 3];\n\t if (idx3.children[0]) {\n\t if (dataItem.name == idx3.children[0].name) {\n\t dataItem.isOnStage = false;\n\t removeEle(dataItem, this.datas);\n\t this.datas.push(dataItem);\n\t idx3.removeChild(idx3.children[0]);\n\t break;\n\t }\n\t }\n\t }\n\t }\n\t else if (this.conveyorsPool[0].x < -450) {\n\t for (var k = 0; k < this.datas.length; k++) {\n\t var dataItem = this.datas[k];\n\t var idx2 = this.conveyorsPool[0][\"idx\" + 2];\n\t if (idx2.children[0]) {\n\t if (dataItem.name == idx2.children[0].name) {\n\t dataItem.isOnStage = false;\n\t removeEle(dataItem, this.datas);\n\t this.datas.push(dataItem);\n\t idx2.removeChild(idx2.children[0]);\n\t break;\n\t }\n\t }\n\t }\n\t }\n\t else if (this.conveyorsPool[0].x < -300) {\n\t for (var k = 0; k < this.datas.length; k++) {\n\t var dataItem = this.datas[k];\n\t var idx1 = this.conveyorsPool[0][\"idx\" + 1];\n\t if (idx1.children[0]) {\n\t if (dataItem.name == idx1.children[0].name) {\n\t dataItem.isOnStage = false;\n\t removeEle(dataItem, this.datas);\n\t this.datas.push(dataItem);\n\t idx1.removeChild(idx1.children[0]);\n\t break;\n\t }\n\t }\n\t }\n\t }\n\t else if (this.conveyorsPool[0].x < -150) {\n\t for (var k = 0; k < this.datas.length; k++) {\n\t var dataItem = this.datas[k];\n\t var idx0 = this.conveyorsPool[0][\"idx\" + 0];\n\t if (idx0.children[0]) {\n\t if (dataItem.name == idx0.children[0].name) {\n\t dataItem.isOnStage = false;\n\t removeEle(dataItem, this.datas);\n\t this.datas.push(dataItem);\n\t idx0.removeChild(idx0.children[0]);\n\t break;\n\t }\n\t }\n\t }\n\t }\n\t };\n\t Conveyors.prototype.addscore = function () {\n\t this.score += (props.onceScore || 2);\n\t engine.globalEvent.dispatchEvent('recycling-score-update', {\n\t score: this.score\n\t });\n\t };\n\t Conveyors.prototype.gameOver = function () {\n\t engine.gameStage.removeEventListener(engine.Event.ENTER_FRAME, this.onEnterFrame, this);\n\t engine.globalEvent.dispatchEvent('recycling-game-end', transStores(this.stores));\n\t };\n\t Conveyors.prototype.onDown_garbage = function (e) {\n\t if (this._currentDragView) {\n\t removeChild(this._currentDragView);\n\t }\n\t var target = e.target;\n\t var view = new engine.Sprite(target.texture);\n\t this._currentDragView = view;\n\t this._currentTarget = target;\n\t target.scaleX = target.scaleY = 0;\n\t this.wrapper.addChild(view);\n\t view.x = e.stageX - target.texture.width / 2;\n\t view.y = e.stageY - target.texture.height / 2;\n\t view.type = target['type'];\n\t view.name = target['name'];\n\t this.wrapper.once(engine.MouseEvent.MOUSE_UP, this.onStageMouseUp, this);\n\t this.wrapper.addEventListener(engine.MouseEvent.MOUSE_MOVE, this.onStageMouseMove, this);\n\t };\n\t Conveyors.prototype.onStageMouseMove = function (e) {\n\t var view = this._currentDragView;\n\t view.x = e.stageX - view.texture.width / 2;\n\t view.y = e.stageY - view.texture.height / 2;\n\t };\n\t Conveyors.prototype.onStageMouseUp = function (e) {\n\t var _this = this;\n\t this.wrapper.removeEventListener(engine.MouseEvent.MOUSE_MOVE, this.onStageMouseMove, this);\n\t if (!this._currentDragView)\n\t return;\n\t var result = this.checkHitRect();\n\t if (result) {\n\t if (result == this._currentDragView['type']) {\n\t this.addscore();\n\t }\n\t else {\n\t engine.Tween.get(this._currentTarget).to({ scaleX: 1, scaleY: 1 }, 300).call(function () { });\n\t }\n\t this.stores.push({ targetType: result, itemType: this._currentDragView['type'], itemName: this._currentDragView['name'] });\n\t }\n\t else {\n\t engine.Tween.get(this._currentTarget).to({ scaleX: 1, scaleY: 1 }, 300).call(function () { });\n\t }\n\t this._currentDragView.anchorX = this._currentDragView.texture.width / 2;\n\t this._currentDragView.anchorY = this._currentDragView.texture.height / 2;\n\t engine.Tween.get(this._currentDragView).to({ scaleX: 0, scaleY: 0 }, 300).call(function () {\n\t removeChild(_this._currentDragView);\n\t });\n\t };\n\t Conveyors.prototype.clear = function () {\n\t this.conveyorsPool.forEach(function (i) {\n\t i.clear();\n\t });\n\t this.conveyorsPool = [];\n\t this.datas = [];\n\t this.stores = [];\n\t };\n\t Conveyors.prototype.timeout = function () {\n\t this.gameOver();\n\t };\n\t Conveyors.prototype.checkHitRect = function () {\n\t if (checkHit(this._currentDragView, this.wrapper.wetWaste)) {\n\t return GarbageTypes.wetWaste;\n\t }\n\t if (checkHit(this._currentDragView, this.wrapper.harmfulWaste)) {\n\t return GarbageTypes.harmfulWaste;\n\t }\n\t if (checkHit(this._currentDragView, this.wrapper.dryWaste)) {\n\t return GarbageTypes.dryWaste;\n\t }\n\t if (checkHit(this._currentDragView, this.wrapper.recoverableWaste)) {\n\t return GarbageTypes.recoverableWaste;\n\t }\n\t return null;\n\t };\n\t return Conveyors;\n\t}(engine.Sprite));\n\n\tvar uiConfig = (function () {\n\t return [\n\t {\n\t id: 'playBg',\n\t texture: 'playBg'\n\t },\n\t {\n\t id: 'idler0',\n\t texture: 'idlerWheel',\n\t pos: [75, 1038],\n\t anchor: [20, 21.5]\n\t },\n\t {\n\t id: 'idler1',\n\t texture: 'idlerWheel',\n\t pos: [175, 1038],\n\t anchor: [20, 21.5]\n\t },\n\t {\n\t id: 'idler2',\n\t texture: 'idlerWheel',\n\t pos: [275, 1038],\n\t anchor: [20, 21.5]\n\t },\n\t {\n\t id: 'idler3',\n\t texture: 'idlerWheel',\n\t pos: [375, 1038],\n\t anchor: [20, 21.5]\n\t },\n\t {\n\t id: 'idler4',\n\t texture: 'idlerWheel',\n\t pos: [475, 1038],\n\t anchor: [20, 21.5]\n\t },\n\t {\n\t id: 'idler5',\n\t texture: 'idlerWheel',\n\t pos: [575, 1038],\n\t anchor: [20, 21.5]\n\t },\n\t {\n\t id: 'idler6',\n\t texture: 'idlerWheel',\n\t pos: [675, 1038],\n\t anchor: [20, 21.5]\n\t },\n\t ];\n\t});\n\t//# sourceMappingURL=uiConfig.js.map\n\n\tvar getGuideInfo = (function () {\n\t if (!window.localStorage) {\n\t return 0;\n\t }\n\t return localStorage.getItem('recyclingGuide');\n\t});\n\tvar setGuide = function () {\n\t if (window.localStorage)\n\t localStorage.setItem('recyclingGuide', '1');\n\t};\n\t//# sourceMappingURL=getGuideInfo.js.map\n\n\tvar createBg = (function (a) {\n\t if (a === void 0) { a = 1; }\n\t var rect = new engine.Graphics();\n\t rect.beginFill(0);\n\t rect.drawRect(0, 0, 750, 1624);\n\t rect.endFill();\n\t rect.alpha = a;\n\t return rect;\n\t});\n\t//# sourceMappingURL=createBg.js.map\n\n\tvar createImg = (function (texture) {\n\t return new engine.Sprite(getTextureByName(texture));\n\t});\n\t//# sourceMappingURL=createImg.js.map\n\n\tvar CountDownGroup = (function (_super) {\n\t tslib.__extends(CountDownGroup, _super);\n\t function CountDownGroup() {\n\t var _this = _super.call(this) || this;\n\t _this.addChild(createBg(.6));\n\t _this.num1 = createImg('num1');\n\t _this.num2 = createImg('num2');\n\t _this.num3 = createImg('num3');\n\t _this.go = createImg('go');\n\t _this.go.anchorX = 240;\n\t _this.go.anchorY = 171.5;\n\t _this.num1.anchorX = 125.5;\n\t _this.num1.anchorY = 189;\n\t _this.num2.anchorX = 149.5;\n\t _this.num2.anchorY = 191.5;\n\t _this.num3.anchorX = 148.5;\n\t _this.num3.anchorY = 191.5;\n\t _this.go.x = 750 / 2 - 240;\n\t _this.go.y = 525 - 171.5;\n\t _this.num1.x = 750 / 2 - 125.5;\n\t _this.num1.y = 529 - 189;\n\t _this.num2.x = 750 / 2 - 149.5;\n\t _this.num2.y = 526 - 191.5;\n\t _this.num3.x = 750 / 2 - 148.5;\n\t _this.num3.y = 525 - 191.5;\n\t _this.addChild(_this.num1);\n\t _this.addChild(_this.num2);\n\t _this.addChild(_this.num3);\n\t _this.addChild(_this.go);\n\t _this.visible = false;\n\t _this.reset();\n\t return _this;\n\t }\n\t CountDownGroup.prototype.reset = function () {\n\t this.go.alpha = this.num1.alpha = this.num2.alpha = this.num3.alpha = 0;\n\t this.go.scaleX = this.num1.scaleX = this.num2.scaleX = this.num3.scaleX = 3;\n\t this.go.scaleY = this.num1.scaleY = this.num2.scaleY = this.num3.scaleY = 3;\n\t };\n\t CountDownGroup.prototype.startCountDown = function () {\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 return [2, new Promise(function (r) {\n\t _this.reset();\n\t _this.visible = true;\n\t _this.num3.alpha = 1;\n\t var n3 = engine.Tween.get(_this.num3);\n\t n3.to({ scaleX: 0.8, scaleY: 0.8 }, 200).to({ scaleX: 1, scaleY: 1 }, 100).wait(500).to({ scaleX: 0, scaleY: 0 }, 200).call(function () {\n\t _this.num2.alpha = 1;\n\t var n2 = engine.Tween.get(_this.num2);\n\t n2.to({ scaleX: 0.8, scaleY: 0.8 }, 200).to({ scaleX: 1, scaleY: 1 }, 100).wait(500).to({ scaleX: 0, scaleY: 0 }, 200).call(function () {\n\t _this.num1.alpha = 1;\n\t var n1 = engine.Tween.get(_this.num1);\n\t n1.to({ scaleX: 0.8, scaleY: 0.8 }, 200).to({ scaleX: 1, scaleY: 1 }, 100).wait(500).to({ scaleX: 0, scaleY: 0 }, 200).call(function () {\n\t _this.go.alpha = 1;\n\t var go = engine.Tween.get(_this.go);\n\t go.to({ scaleX: 0.8, scaleY: 0.8 }, 200).to({ scaleX: 1, scaleY: 1 }, 100).wait(500).call(function () {\n\t _this.visible = false;\n\t r();\n\t });\n\t });\n\t });\n\t });\n\t })];\n\t });\n\t });\n\t };\n\t return CountDownGroup;\n\t}(engine.Sprite));\n\t//# sourceMappingURL=CountDownGroup.js.map\n\n\tvar GuideView = (function (_super) {\n\t tslib.__extends(GuideView, _super);\n\t function GuideView() {\n\t var _this = _super.call(this) || this;\n\t _this.initUI();\n\t _this.visible = false;\n\t return _this;\n\t }\n\t GuideView.prototype.initUI = function () {\n\t this.addChild(createBg(.6));\n\t this.guideBg = createImg('guideBg');\n\t this.addChild(this.guideBg);\n\t this.guideEle = createImg('guideEle');\n\t this.addChild(this.guideEle);\n\t this.guideBg.x = 393;\n\t this.guideBg.y = 552;\n\t this.guideEle.x = 361;\n\t this.guideEle.y = 877;\n\t this.guideEle.mouseEnabled = this.guideEle.mouseChildren = true;\n\t var svga = createSvga(\"guideTips\");\n\t this.svga = svga;\n\t this.addChild(svga);\n\t svga.gotoAndStop(1);\n\t svga.mouseEnabled = svga.mouseChildren = false;\n\t };\n\t GuideView.prototype.checkHit = function (x, y, w, h) {\n\t var rect = new engine.Rectangle(393, 552, 281, 320);\n\t if (x > rect.x && y > rect.y && (x + w) < (rect.x + rect.width) && (y + h) < (rect.y + rect.height)) {\n\t return true;\n\t }\n\t return false;\n\t };\n\t GuideView.prototype.startGuide = function () {\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 return [2, new Promise(function (r) {\n\t _this.visible = true;\n\t _this.svga.gotoAndStop(1);\n\t _this.svga.play(false, true);\n\t _this.guideEle.scaleX = 1;\n\t _this.guideEle.scaleY = 1;\n\t var offset = [0, 0];\n\t var guideOver = function () {\n\t _this.guideEle.removeEventListener(engine.MouseEvent.MOUSE_DOWN, ondown, _this);\n\t engine.Tween.get(_this.guideEle).to({ scaleX: 0, scaleY: 0 }, 300).call(function () {\n\t _this.visible = false;\n\t r();\n\t });\n\t };\n\t var onUp = function (e) {\n\t _this.stage.removeEventListener(engine.MouseEvent.MOUSE_MOVE, onMove, _this);\n\t if (_this.checkHit(_this.guideEle.x, _this.guideEle.y, _this.guideEle.width, _this.guideEle.height)) {\n\t guideOver();\n\t }\n\t else {\n\t _this.svga.visible = true;\n\t _this.guideEle.x = 361;\n\t _this.guideEle.y = 877;\n\t }\n\t };\n\t var onMove = function (e) {\n\t _this.guideEle.x = e.stageX - offset[0];\n\t _this.guideEle.y = e.stageY - offset[1];\n\t };\n\t var ondown = function (e) {\n\t offset = [e.localX, e.localY];\n\t _this.svga.visible = false;\n\t _this.stage.once(engine.MouseEvent.MOUSE_UP, onUp, _this);\n\t _this.stage.addEventListener(engine.MouseEvent.MOUSE_MOVE, onMove, _this);\n\t };\n\t _this.guideEle.addEventListener(engine.MouseEvent.MOUSE_DOWN, ondown, _this);\n\t })];\n\t });\n\t });\n\t };\n\t return GuideView;\n\t}(engine.Sprite));\n\t//# sourceMappingURL=guideView.js.map\n\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._timeCounter = 0;\n\t _this.once(engine.Event.ADDED_TO_STAGE, _this.setup, _this);\n\t return _this;\n\t }\n\t GameView.prototype.configUI = function () {\n\t var uiMap = {};\n\t this.uiMap = uiMap;\n\t var config = uiConfig();\n\t for (var _i = 0, config_1 = config; _i < config_1.length; _i++) {\n\t var item = config_1[_i];\n\t var id = item.id, texture = item.texture, pos = item.pos, anchor = item.anchor;\n\t var sp = new engine.Sprite(getTextureByName(texture));\n\t this.addChild(sp);\n\t uiMap[id] = sp;\n\t if (anchor) {\n\t sp.anchorX = anchor[0];\n\t sp.anchorY = anchor[1];\n\t }\n\t if (pos) {\n\t sp.x = pos[0];\n\t sp.y = pos[1];\n\t if (anchor) {\n\t sp.x = pos[0] - sp.anchorX;\n\t sp.y = pos[1] - sp.anchorY;\n\t }\n\t }\n\t }\n\t this.configConveyors();\n\t this.createRects();\n\t this.countdown = new CountDownGroup();\n\t this.addChild(this.countdown);\n\t this.guide = new GuideView();\n\t this.addChild(this.guide);\n\t };\n\t GameView.prototype.createRects = function () {\n\t this.wetWaste = this.createRect(74, 552, 301, 293, 0xffffff);\n\t this.harmfulWaste = this.createRect(75, 247, 300, 293, 0xff0000);\n\t this.dryWaste = this.createRect(389, 249, 286, 291, 0x000000);\n\t this.recoverableWaste = this.createRect(389, 551, 287, 292, 0x0000ff);\n\t };\n\t GameView.prototype.createRect = function (x, y, w, h, c) {\n\t var rect = new engine.Rectangle(x, y, w, h);\n\t var sp = new engine.Sprite();\n\t this.addChild(sp);\n\t sp.x = x;\n\t sp.y = y;\n\t var g = new engine.Graphics;\n\t g.alpha = 0.0;\n\t g.beginFill(c);\n\t g.drawRect(0, 0, w, h);\n\t g.endFill();\n\t sp.addChild(g);\n\t return rect;\n\t };\n\t GameView.prototype.configConveyors = function () {\n\t var conveyor0 = new Conveyor();\n\t conveyor0.x = 0;\n\t var conveyor1 = new Conveyor();\n\t this.addChild(conveyor0);\n\t this.addChild(conveyor1);\n\t conveyor1.x = 764;\n\t this.conveyors = new Conveyors(this);\n\t this.conveyors.initData(conveyor0, conveyor1);\n\t };\n\t GameView.prototype.playAni = function () {\n\t var _this = this;\n\t var idlerWheels = ['idler0', 'idler1', 'idler2', 'idler3', 'idler4', 'idler5', 'idler6'];\n\t idlerWheels = idlerWheels.map(function (i) { return _this.uiMap[i]; });\n\t idlerWheels.forEach(function (i) {\n\t engine.Tween.get(i, { loop: true }).to({ rotation: -360 }, 1000);\n\t });\n\t };\n\t GameView.prototype.stopAni = function () {\n\t var _this = this;\n\t var idlerWheels = ['idler0', 'idler1', 'idler2', 'idler3', 'idler4', 'idler5', 'idler6'];\n\t idlerWheels = idlerWheels.map(function (i) { return _this.uiMap[i]; });\n\t idlerWheels.forEach(function (i) {\n\t engine.Tween.removeTweens(i);\n\t });\n\t };\n\t GameView.prototype.start = function () {\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 console.log('on start');\n\t this._timeCounter = 0;\n\t if (!!getGuideInfo()) return [3, 2];\n\t return [4, this.guide.startGuide()];\n\t case 1:\n\t _a.sent();\n\t setGuide();\n\t _a.label = 2;\n\t case 2:\n\t this.startGame();\n\t engine.globalEvent.dispatchEvent('recycling-time-update', {\n\t second: this.getSecond(),\n\t });\n\t this._timer = setInterval(function () {\n\t _this.onTimer();\n\t }, 1000);\n\t return [2];\n\t }\n\t });\n\t });\n\t };\n\t GameView.prototype.startGame = function () {\n\t this.playAni();\n\t this.conveyors.startConveyors();\n\t };\n\t GameView.prototype.stopGame = function () {\n\t this.stopAni();\n\t };\n\t GameView.prototype.getSecond = function () {\n\t return props.time - this._timeCounter;\n\t };\n\t GameView.prototype.onTimer = function () {\n\t this._timeCounter++;\n\t engine.globalEvent.dispatchEvent('recycling-time-update', {\n\t second: this.getSecond(),\n\t });\n\t if (this.getSecond() == 0) {\n\t this.stop();\n\t this.conveyors.timeout();\n\t }\n\t };\n\t GameView.prototype.stop = function () {\n\t clearInterval(this._timer);\n\t this.stopGame();\n\t };\n\t GameView.prototype.setup = function () {\n\t console.log('onSteup', props);\n\t this.configUI();\n\t };\n\t GameView.prototype.onDown = function (e) {\n\t };\n\t GameView.prototype.stageOnUp = function (e) {\n\t };\n\t GameView.prototype.onSuccess = function () {\n\t };\n\t GameView.prototype.onMove = function (e) {\n\t };\n\t return GameView;\n\t}(engine.Container));\n\t//# sourceMappingURL=GameView.js.map\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('recycling-start', _this.start, _this);\n\t engine.globalEvent.addEventListener('recycling-stop', _this.stop, _this);\n\t var gameView = _this._gameView = new GameView();\n\t _this.addChild(gameView);\n\t return _this;\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.stop = function (event) {\n\t this._gameView.stop();\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"
"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.recycling = factory(global.tslib));\n}(this, (function (tslib) { 'use strict';\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\t//# sourceMappingURL=utils.js.map\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\tvar Conveyor = (function (_super) {\n\t tslib.__extends(Conveyor, _super);\n\t function Conveyor() {\n\t var _this = _super.call(this) || this;\n\t _this.y = 904.21;\n\t var sp = new engine.Sprite(getTextureByName('conveyor'));\n\t _this.addChild(sp);\n\t _this.idx0 = _this.createItem(75, 50);\n\t _this.idx1 = _this.createItem(225, 50);\n\t _this.idx2 = _this.createItem(375, 50);\n\t _this.idx3 = _this.createItem(525, 50);\n\t _this.idx4 = _this.createItem(675, 50);\n\t return _this;\n\t }\n\t Conveyor.prototype.clear = function () {\n\t this.clearItem(this.idx0);\n\t this.clearItem(this.idx1);\n\t this.clearItem(this.idx2);\n\t this.clearItem(this.idx3);\n\t this.clearItem(this.idx4);\n\t };\n\t Conveyor.prototype.clearItem = function (idx) {\n\t if (idx.children.length > 0)\n\t idx.removeChildAt(0);\n\t };\n\t Conveyor.prototype.createItem = function (x, y) {\n\t var sp = new engine.Sprite();\n\t this.addChild(sp);\n\t sp.x = x;\n\t sp.y = y;\n\t return sp;\n\t };\n\t return Conveyor;\n\t}(engine.Sprite));\n\t//# sourceMappingURL=Conveyor.js.map\n\n\tvar GarbageTypes;\n\t(function (GarbageTypes) {\n\t GarbageTypes[\"recoverableWaste\"] = \"recoverableWaste\";\n\t GarbageTypes[\"harmfulWaste\"] = \"harmfulWaste\";\n\t GarbageTypes[\"wetWaste\"] = \"wetWaste\";\n\t GarbageTypes[\"dryWaste\"] = \"dryWaste\";\n\t})(GarbageTypes || (GarbageTypes = {}));\n\t//# sourceMappingURL=GarbageTypes.js.map\n\n\tvar GarbageConfig = (function () {\n\t function GarbageConfig() {\n\t }\n\t GarbageConfig.config = [\n\t { name: \"电池\", source: \"g00\", type: GarbageTypes.harmfulWaste, width: 51, height: 123 },\n\t { name: \"温度计\", source: \"g01\", type: GarbageTypes.harmfulWaste, width: 65, height: 130 },\n\t { name: \"鱼刺\", source: \"g02\", type: GarbageTypes.wetWaste, width: 104, height: 82 },\n\t { name: \"龙虾\", source: \"g03\", type: GarbageTypes.wetWaste, width: 129, height: 122 },\n\t { name: \"西瓜\", source: \"g04\", type: GarbageTypes.wetWaste, width: 134, height: 111 },\n\t { name: \"旧玩具\", source: \"g05\", type: GarbageTypes.recoverableWaste, width: 72, height: 135 },\n\t { name: \"口红\", source: \"g06\", type: GarbageTypes.dryWaste, width: 49, height: 134 },\n\t { name: \"面包\", source: \"g07\", type: GarbageTypes.wetWaste, width: 96, height: 128 },\n\t { name: \"绿植\", source: \"g08\", type: GarbageTypes.wetWaste, width: 81, height: 131 },\n\t { name: \"保温瓶\", source: \"g09\", type: GarbageTypes.recoverableWaste, width: 66, height: 137 },\n\t { name: \"破衣服\", source: \"g10\", type: GarbageTypes.recoverableWaste, width: 91, height: 121 },\n\t { name: \"茶叶渣\", source: \"g11\", type: GarbageTypes.wetWaste, width: 108, height: 125 },\n\t { name: \"湿巾\", source: \"g12\", type: GarbageTypes.dryWaste, width: 106, height: 109 },\n\t { name: \"过期药膏\", source: \"g13\", type: GarbageTypes.harmfulWaste, width: 107, height: 130 },\n\t { name: \"用完的洗发水瓶\", source: \"g14\", type: GarbageTypes.recoverableWaste, width: 153, height: 148 },\n\t { name: \"婴儿纸尿裤\", source: \"g15\", type: GarbageTypes.dryWaste, width: 108, height: 123 },\n\t { name: \"香水瓶\", source: \"g16\", type: GarbageTypes.recoverableWaste, width: 65, height: 127 },\n\t { name: \"花甲壳\", source: \"g17\", type: GarbageTypes.wetWaste, width: 99, height: 115 },\n\t { name: \"过期调味料\", source: \"g18\", type: GarbageTypes.wetWaste, width: 109, height: 130 },\n\t { name: \"地毯\", source: \"g19\", type: GarbageTypes.recoverableWaste, width: 145, height: 119 },\n\t { name: \"甘蔗渣\", source: \"g20\", type: GarbageTypes.wetWaste, width: 100, height: 116 },\n\t { name: \"玻璃渣\", source: \"g21\", type: GarbageTypes.recoverableWaste, width: 95, height: 122 },\n\t { name: \"番茄酱\", source: \"g22\", type: GarbageTypes.wetWaste, width: 82, height: 125 },\n\t { name: \"酒精棉\", source: \"g23\", type: GarbageTypes.dryWaste, width: 64, height: 124 },\n\t { name: \"指甲油瓶子\", source: \"g24\", type: GarbageTypes.harmfulWaste, width: 109, height: 125 },\n\t { name: \"肉骨头\", source: \"g25\", type: GarbageTypes.dryWaste, width: 67, height: 123 },\n\t { name: \"嚼过的口香糖\", source: \"g26\", type: GarbageTypes.dryWaste, width: 135, height: 116 },\n\t { name: \"充电插头\", source: \"g27\", type: GarbageTypes.recoverableWaste, width: 86, height: 128 },\n\t { name: \"旧报纸\", source: \"g28\", type: GarbageTypes.recoverableWaste, width: 68, height: 124 },\n\t { name: \"烟头\", source: \"g29\", type: GarbageTypes.dryWaste, width: 108, height: 145 },\n\t { name: \"奶茶塑料杯\", source: \"g30\", type: GarbageTypes.dryWaste, width: 109, height: 143 },\n\t { name: \"瓜子壳\", source: \"g31\", type: GarbageTypes.wetWaste, width: 87, height: 121 },\n\t { name: \"橘子皮\", source: \"g32\", type: GarbageTypes.wetWaste, width: 78, height: 120 },\n\t { name: \"气球\", source: \"g33\", type: GarbageTypes.dryWaste, width: 78, height: 121 },\n\t { name: \"树叶\", source: \"g34\", type: GarbageTypes.wetWaste, width: 75, height: 117 },\n\t { name: \"感冒药\", source: \"g35\", type: GarbageTypes.harmfulWaste, width: 92, height: 121 },\n\t { name: \"电话机\", source: \"g36\", type: GarbageTypes.recoverableWaste, width: 63, height: 121 },\n\t { name: \"奶酪\", source: \"g37\", type: GarbageTypes.wetWaste, width: 90, height: 116 },\n\t { name: \"啤酒瓶\", source: \"g38\", type: GarbageTypes.recoverableWaste, width: 64, height: 123 },\n\t { name: \"薯片包装\", source: \"g39\", type: GarbageTypes.dryWaste, width: 134, height: 123 },\n\t { name: \"过期保健品\", source: \"g40\", type: GarbageTypes.harmfulWaste, width: 108, height: 125 },\n\t { name: \"雪糕包装袋\", source: \"g41\", type: GarbageTypes.dryWaste, width: 109, height: 128 },\n\t { name: \"废油漆\", source: \"g42\", type: GarbageTypes.harmfulWaste, width: 98, height: 122 },\n\t { name: \"食品罐头\", source: \"g43\", type: GarbageTypes.recoverableWaste, width: 94, height: 117 },\n\t { name: \"陶瓷碗\", source: \"g44\", type: GarbageTypes.dryWaste, width: 105, height: 122 },\n\t { name: \"蚊香\", source: \"g45\", type: GarbageTypes.dryWaste, width: 69, height: 146 },\n\t { name: \"电脑机箱\", source: \"g46\", type: GarbageTypes.recoverableWaste, width: 84, height: 124 },\n\t { name: \"鲜花\", source: \"g47\", type: GarbageTypes.wetWaste, width: 62, height: 122 },\n\t { name: \"宠物粮食\", source: \"g48\", type: GarbageTypes.wetWaste, width: 87, height: 121 },\n\t { name: \"银行卡\", source: \"g49\", type: GarbageTypes.recoverableWaste, width: 115, height: 123 },\n\t ];\n\t return GarbageConfig;\n\t}());\n\t//# sourceMappingURL=GarbageConfig.js.map\n\n\tvar transStores = (function (list) {\n\t var tmp = [];\n\t var contains = function (val) {\n\t for (var _i = 0, tmp_1 = tmp; _i < tmp_1.length; _i++) {\n\t var i = tmp_1[_i];\n\t if (val.targetType == i.targetType && val.itemType == i.itemType && val.itemName == i.itemName)\n\t return true;\n\t }\n\t return false;\n\t };\n\t list.forEach(function (i) {\n\t if (!contains(i))\n\t tmp.push(i);\n\t });\n\t list = tmp;\n\t tmp = [];\n\t var nameList = [];\n\t var contains2 = function (val) {\n\t for (var _i = 0, tmp_2 = tmp; _i < tmp_2.length; _i++) {\n\t var i = tmp_2[_i];\n\t if (val.itemName == i.itemName) {\n\t nameList.push(i.itemName);\n\t return true;\n\t }\n\t }\n\t return false;\n\t };\n\t list.forEach(function (i) {\n\t if (!contains2(i))\n\t tmp.push(i);\n\t });\n\t list = tmp;\n\t list.forEach(function (i) {\n\t if (nameList.indexOf(i.itemName) != -1) {\n\t i.targetType = i.itemType;\n\t }\n\t });\n\t return list.map(function (i) {\n\t return {\n\t 'targetName': getTargetName(i.targetType),\n\t 'isCorrect': i.targetType == i.itemType,\n\t 'itemName': i.itemName\n\t };\n\t });\n\t});\n\tvar getTargetName = function (type) {\n\t switch (type) {\n\t case GarbageTypes.recoverableWaste:\n\t return '可回收物';\n\t case GarbageTypes.harmfulWaste:\n\t return '有害垃圾';\n\t case GarbageTypes.wetWaste:\n\t return '湿垃圾';\n\t case GarbageTypes.dryWaste:\n\t return '干垃圾';\n\t }\n\t};\n\t//# sourceMappingURL=transStores.js.map\n\n\tvar checkHit = (function (view, rect) {\n\t var x = view.x, y = view.y;\n\t var _a = view.texture, width = _a.width, height = _a.height;\n\t if (x > rect.x && y > rect.y && (x + width) < (rect.x + rect.width) && (y + height) < (rect.y + rect.height)) {\n\t return true;\n\t }\n\t return false;\n\t});\n\t//# sourceMappingURL=checkHit.js.map\n\n\tvar removeChild = (function (d) {\n\t if (d && d.parent) {\n\t d.parent.removeChild(d);\n\t }\n\t});\n\t//# sourceMappingURL=removeChild.js.map\n\n\tvar removeEle = (function (e, arr) {\n\t var index = arr.indexOf(e);\n\t if (index >= 0) {\n\t arr.splice(index, 1);\n\t }\n\t});\n\t//# sourceMappingURL=removeEle.js.map\n\n\tvar shuffle = (function (arr) {\n\t var _a;\n\t var i = arr.length;\n\t while (i) {\n\t var j = Math.floor(Math.random() * i--);\n\t _a = [arr[i], arr[j]], arr[j] = _a[0], arr[i] = _a[1];\n\t }\n\t return arr;\n\t});\n\t//# sourceMappingURL=shuffle.js.map\n\n\tvar Conveyors = (function (_super) {\n\t tslib.__extends(Conveyors, _super);\n\t function Conveyors(p) {\n\t var _this = _super.call(this) || this;\n\t _this.conveyorsPool = [];\n\t _this.GarbageConfig = GarbageConfig.config;\n\t _this.datas = [];\n\t _this.wrapper = p;\n\t return _this;\n\t }\n\t Conveyors.prototype.initData = function (conveyor0, conveyor1) {\n\t this.conveyor0 = conveyor0;\n\t this.conveyor1 = conveyor1;\n\t };\n\t Conveyors.prototype.setDefault = function () {\n\t this.score = 0;\n\t this.conveyorsPool.push(this.conveyor0);\n\t this.conveyorsPool.push(this.conveyor1);\n\t var allConfigs = shuffle(this.GarbageConfig.concat([]));\n\t for (var i = 0; i < GarbageConfig.config.length; i++) {\n\t allConfigs[i].idx = i;\n\t allConfigs[i].isRight = false;\n\t allConfigs[i].isMistake = false;\n\t allConfigs[i].isOnStage = false;\n\t this.datas.push(allConfigs[i]);\n\t }\n\t for (var i = 0; i < 5; i++) {\n\t var data = this.datas[i];\n\t var view = new engine.Sprite(getTextureByName(data.source));\n\t view.isWrong = false;\n\t view.isRight = false;\n\t data.isOnStage = true;\n\t view.type = data.type;\n\t view.name = data.name;\n\t view.anchorX = data.width / 2;\n\t view.anchorY = data.height;\n\t view.x = -data.width / 2;\n\t view.y = -data.height + 40;\n\t this.conveyor1[\"idx\" + i].addChild(view);\n\t view.addEventListener(engine.MouseEvent.MOUSE_DOWN, this.onDown_garbage, this);\n\t }\n\t };\n\t Conveyors.prototype.startConveyors = function () {\n\t this.setDefault();\n\t engine.gameStage.addEventListener(engine.Event.ENTER_FRAME, this.onEnterFrame, this);\n\t };\n\t Conveyors.prototype.onEnterFrame = function (ENTER_FRAME, onEnterFrame, arg2) {\n\t if (this.score == (props.maxScore || 100)) {\n\t this.gameOver();\n\t this.wrapper.stop();\n\t }\n\t this.conveyorsPool.forEach(function (conveyor) {\n\t conveyor.x -= props.speed || 3;\n\t });\n\t if (this.conveyorsPool[this.conveyorsPool.length - 1].x <= 764) {\n\t var conveyor = new Conveyor();\n\t conveyor.x = this.conveyorsPool[this.conveyorsPool.length - 1].x + 764;\n\t this.wrapper.addChild(conveyor);\n\t this.conveyorsPool.push(conveyor);\n\t }\n\t else {\n\t var dataList = [];\n\t for (var n = 0; n < this.datas.length; n++) {\n\t var dataItem = this.datas[n];\n\t if (!dataItem.isRight && !dataItem.isOnStage) {\n\t dataList.push(dataItem);\n\t }\n\t }\n\t var lastConveyor = this.conveyorsPool[this.conveyorsPool.length - 1];\n\t for (var m = 0; m < 5; m++) {\n\t if (!lastConveyor[\"idx\" + m].children[0]) {\n\t var data = dataList.shift();\n\t if (data) {\n\t data.isOnStage = true;\n\t var view = new engine.Sprite(getTextureByName(data.source));\n\t view.isWrong = false;\n\t view.isRight = false;\n\t view.type = data.type;\n\t view.name = data.name;\n\t view.anchorX = data.width / 2;\n\t view.anchorY = data.height;\n\t view.x = -data.width / 2;\n\t view.y = -data.height + 40;\n\t lastConveyor[\"idx\" + m].addChild(view);\n\t view.addEventListener(engine.MouseEvent.MOUSE_DOWN, this.onDown_garbage, this);\n\t }\n\t else {\n\t break;\n\t }\n\t }\n\t }\n\t }\n\t if (this.conveyorsPool[0].x < -750) {\n\t for (var k = 0; k < this.datas.length; k++) {\n\t var dataItem = this.datas[k];\n\t var idx4 = this.conveyorsPool[0][\"idx\" + 4];\n\t if (idx4.children[0]) {\n\t if (dataItem.name == idx4.children[0].name) {\n\t dataItem.isOnStage = false;\n\t removeEle(dataItem, this.datas);\n\t this.datas.push(dataItem);\n\t idx4.removeChild(idx4.children[0]);\n\t break;\n\t }\n\t }\n\t }\n\t this.conveyorsPool.shift();\n\t }\n\t else if (this.conveyorsPool[0].x < -600) {\n\t for (var k = 0; k < this.datas.length; k++) {\n\t var dataItem = this.datas[k];\n\t var idx3 = this.conveyorsPool[0][\"idx\" + 3];\n\t if (idx3.children[0]) {\n\t if (dataItem.name == idx3.children[0].name) {\n\t dataItem.isOnStage = false;\n\t removeEle(dataItem, this.datas);\n\t this.datas.push(dataItem);\n\t idx3.removeChild(idx3.children[0]);\n\t break;\n\t }\n\t }\n\t }\n\t }\n\t else if (this.conveyorsPool[0].x < -450) {\n\t for (var k = 0; k < this.datas.length; k++) {\n\t var dataItem = this.datas[k];\n\t var idx2 = this.conveyorsPool[0][\"idx\" + 2];\n\t if (idx2.children[0]) {\n\t if (dataItem.name == idx2.children[0].name) {\n\t dataItem.isOnStage = false;\n\t removeEle(dataItem, this.datas);\n\t this.datas.push(dataItem);\n\t idx2.removeChild(idx2.children[0]);\n\t break;\n\t }\n\t }\n\t }\n\t }\n\t else if (this.conveyorsPool[0].x < -300) {\n\t for (var k = 0; k < this.datas.length; k++) {\n\t var dataItem = this.datas[k];\n\t var idx1 = this.conveyorsPool[0][\"idx\" + 1];\n\t if (idx1.children[0]) {\n\t if (dataItem.name == idx1.children[0].name) {\n\t dataItem.isOnStage = false;\n\t removeEle(dataItem, this.datas);\n\t this.datas.push(dataItem);\n\t idx1.removeChild(idx1.children[0]);\n\t break;\n\t }\n\t }\n\t }\n\t }\n\t else if (this.conveyorsPool[0].x < -150) {\n\t for (var k = 0; k < this.datas.length; k++) {\n\t var dataItem = this.datas[k];\n\t var idx0 = this.conveyorsPool[0][\"idx\" + 0];\n\t if (idx0.children[0]) {\n\t if (dataItem.name == idx0.children[0].name) {\n\t dataItem.isOnStage = false;\n\t removeEle(dataItem, this.datas);\n\t this.datas.push(dataItem);\n\t idx0.removeChild(idx0.children[0]);\n\t break;\n\t }\n\t }\n\t }\n\t }\n\t };\n\t Conveyors.prototype.addscore = function () {\n\t this.score += (props.onceScore || 2);\n\t engine.globalEvent.dispatchEvent('recycling-score-update', {\n\t score: this.score\n\t });\n\t };\n\t Conveyors.prototype.gameOver = function () {\n\t engine.gameStage.removeEventListener(engine.Event.ENTER_FRAME, this.onEnterFrame, this);\n\t engine.globalEvent.dispatchEvent('recycling-game-end', transStores(this.stores));\n\t };\n\t Conveyors.prototype.onDown_garbage = function (e) {\n\t if (this._currentDragView) {\n\t removeChild(this._currentDragView);\n\t }\n\t var target = e.target;\n\t var view = new engine.Sprite(target.texture);\n\t this._currentDragView = view;\n\t this._currentTarget = target;\n\t target.scaleX = target.scaleY = 0;\n\t this.wrapper.addChild(view);\n\t view.x = e.stageX - target.texture.width / 2;\n\t view.y = e.stageY - target.texture.height / 2;\n\t view.type = target['type'];\n\t view.name = target['name'];\n\t this.wrapper.addEventListener(engine.MouseEvent.MOUSE_UP, this.onStageMouseUp, this);\n\t this.wrapper.addEventListener(engine.MouseEvent.MOUSE_MOVE, this.onStageMouseMove, this);\n\t };\n\t Conveyors.prototype.onStageMouseMove = function (e) {\n\t console.log('onStageMouseMove');\n\t var view = this._currentDragView;\n\t view.x = e.stageX - view.texture.width / 2;\n\t view.y = e.stageY - view.texture.height / 2;\n\t };\n\t Conveyors.prototype.onStageMouseUp = function (e) {\n\t var _this = this;\n\t console.log('onStageMouseUp');\n\t this.wrapper.removeEventListener(engine.MouseEvent.MOUSE_UP, this.onStageMouseUp, this);\n\t this.wrapper.removeEventListener(engine.MouseEvent.MOUSE_MOVE, this.onStageMouseMove, this);\n\t if (!this._currentDragView)\n\t return;\n\t var result = this.checkHitRect();\n\t if (result) {\n\t if (result == this._currentDragView['type']) {\n\t this.addscore();\n\t }\n\t else {\n\t engine.Tween.get(this._currentTarget).to({ scaleX: 1, scaleY: 1 }, 300).call(function () { });\n\t }\n\t this.stores.push({ targetType: result, itemType: this._currentDragView['type'], itemName: this._currentDragView['name'] });\n\t }\n\t else {\n\t engine.Tween.get(this._currentTarget).to({ scaleX: 1, scaleY: 1 }, 300).call(function () { });\n\t }\n\t this._currentDragView.anchorX = this._currentDragView.texture.width / 2;\n\t this._currentDragView.anchorY = this._currentDragView.texture.height / 2;\n\t engine.Tween.get(this._currentDragView).to({ scaleX: 0, scaleY: 0 }, 300).call(function () {\n\t removeChild(_this._currentDragView);\n\t });\n\t };\n\t Conveyors.prototype.clear = function () {\n\t this.conveyor0.x = 0;\n\t this.conveyor1.x = 764;\n\t this.conveyorsPool.forEach(function (i) {\n\t i.clear();\n\t });\n\t this.conveyorsPool = [];\n\t this.datas = [];\n\t this.stores = [];\n\t };\n\t Conveyors.prototype.timeout = function () {\n\t if (this._currentDragView) {\n\t removeChild(this._currentDragView);\n\t }\n\t this.wrapper.removeEventListener(engine.MouseEvent.MOUSE_UP, this.onStageMouseUp, this);\n\t this.wrapper.removeEventListener(engine.MouseEvent.MOUSE_MOVE, this.onStageMouseMove, this);\n\t this.gameOver();\n\t };\n\t Conveyors.prototype.checkHitRect = function () {\n\t if (checkHit(this._currentDragView, this.wrapper.wetWaste)) {\n\t return GarbageTypes.wetWaste;\n\t }\n\t if (checkHit(this._currentDragView, this.wrapper.harmfulWaste)) {\n\t return GarbageTypes.harmfulWaste;\n\t }\n\t if (checkHit(this._currentDragView, this.wrapper.dryWaste)) {\n\t return GarbageTypes.dryWaste;\n\t }\n\t if (checkHit(this._currentDragView, this.wrapper.recoverableWaste)) {\n\t return GarbageTypes.recoverableWaste;\n\t }\n\t return null;\n\t };\n\t return Conveyors;\n\t}(engine.Sprite));\n\n\tvar uiConfig = (function () {\n\t return [\n\t {\n\t id: 'playBg',\n\t texture: 'playBg'\n\t },\n\t {\n\t id: 'idler0',\n\t texture: 'idlerWheel',\n\t pos: [75, 1038],\n\t anchor: [20, 21.5]\n\t },\n\t {\n\t id: 'idler1',\n\t texture: 'idlerWheel',\n\t pos: [175, 1038],\n\t anchor: [20, 21.5]\n\t },\n\t {\n\t id: 'idler2',\n\t texture: 'idlerWheel',\n\t pos: [275, 1038],\n\t anchor: [20, 21.5]\n\t },\n\t {\n\t id: 'idler3',\n\t texture: 'idlerWheel',\n\t pos: [375, 1038],\n\t anchor: [20, 21.5]\n\t },\n\t {\n\t id: 'idler4',\n\t texture: 'idlerWheel',\n\t pos: [475, 1038],\n\t anchor: [20, 21.5]\n\t },\n\t {\n\t id: 'idler5',\n\t texture: 'idlerWheel',\n\t pos: [575, 1038],\n\t anchor: [20, 21.5]\n\t },\n\t {\n\t id: 'idler6',\n\t texture: 'idlerWheel',\n\t pos: [675, 1038],\n\t anchor: [20, 21.5]\n\t },\n\t ];\n\t});\n\t//# sourceMappingURL=uiConfig.js.map\n\n\tvar getGuideInfo = (function () {\n\t if (!window.localStorage) {\n\t return 0;\n\t }\n\t return localStorage.getItem('recyclingGuide');\n\t});\n\tvar setGuide = function () {\n\t if (window.localStorage)\n\t localStorage.setItem('recyclingGuide', '1');\n\t};\n\t//# sourceMappingURL=getGuideInfo.js.map\n\n\tvar createBg = (function (a) {\n\t if (a === void 0) { a = 1; }\n\t var rect = new engine.Graphics();\n\t rect.beginFill(0);\n\t rect.drawRect(0, 0, 750, 1624);\n\t rect.endFill();\n\t rect.alpha = a;\n\t return rect;\n\t});\n\t//# sourceMappingURL=createBg.js.map\n\n\tvar createImg = (function (texture) {\n\t return new engine.Sprite(getTextureByName(texture));\n\t});\n\t//# sourceMappingURL=createImg.js.map\n\n\tvar CountDownGroup = (function (_super) {\n\t tslib.__extends(CountDownGroup, _super);\n\t function CountDownGroup() {\n\t var _this = _super.call(this) || this;\n\t _this.addChild(createBg(.6));\n\t _this.num1 = createImg('num1');\n\t _this.num2 = createImg('num2');\n\t _this.num3 = createImg('num3');\n\t _this.go = createImg('go');\n\t _this.go.anchorX = 240;\n\t _this.go.anchorY = 171.5;\n\t _this.num1.anchorX = 125.5;\n\t _this.num1.anchorY = 189;\n\t _this.num2.anchorX = 149.5;\n\t _this.num2.anchorY = 191.5;\n\t _this.num3.anchorX = 148.5;\n\t _this.num3.anchorY = 191.5;\n\t _this.go.x = 750 / 2 - 240;\n\t _this.go.y = 525 - 171.5;\n\t _this.num1.x = 750 / 2 - 125.5;\n\t _this.num1.y = 529 - 189;\n\t _this.num2.x = 750 / 2 - 149.5;\n\t _this.num2.y = 526 - 191.5;\n\t _this.num3.x = 750 / 2 - 148.5;\n\t _this.num3.y = 525 - 191.5;\n\t _this.addChild(_this.num1);\n\t _this.addChild(_this.num2);\n\t _this.addChild(_this.num3);\n\t _this.addChild(_this.go);\n\t _this.visible = false;\n\t _this.reset();\n\t return _this;\n\t }\n\t CountDownGroup.prototype.reset = function () {\n\t this.go.alpha = this.num1.alpha = this.num2.alpha = this.num3.alpha = 0;\n\t this.go.scaleX = this.num1.scaleX = this.num2.scaleX = this.num3.scaleX = 3;\n\t this.go.scaleY = this.num1.scaleY = this.num2.scaleY = this.num3.scaleY = 3;\n\t };\n\t CountDownGroup.prototype.startCountDown = function () {\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 return [2, new Promise(function (r) {\n\t _this.reset();\n\t _this.visible = true;\n\t _this.num3.alpha = 1;\n\t var n3 = engine.Tween.get(_this.num3);\n\t n3.to({ scaleX: 0.8, scaleY: 0.8 }, 200).to({ scaleX: 1, scaleY: 1 }, 100).wait(500).to({ scaleX: 0, scaleY: 0 }, 200).call(function () {\n\t _this.num2.alpha = 1;\n\t var n2 = engine.Tween.get(_this.num2);\n\t n2.to({ scaleX: 0.8, scaleY: 0.8 }, 200).to({ scaleX: 1, scaleY: 1 }, 100).wait(500).to({ scaleX: 0, scaleY: 0 }, 200).call(function () {\n\t _this.num1.alpha = 1;\n\t var n1 = engine.Tween.get(_this.num1);\n\t n1.to({ scaleX: 0.8, scaleY: 0.8 }, 200).to({ scaleX: 1, scaleY: 1 }, 100).wait(500).to({ scaleX: 0, scaleY: 0 }, 200).call(function () {\n\t _this.go.alpha = 1;\n\t var go = engine.Tween.get(_this.go);\n\t go.to({ scaleX: 0.8, scaleY: 0.8 }, 200).to({ scaleX: 1, scaleY: 1 }, 100).wait(500).call(function () {\n\t _this.visible = false;\n\t r();\n\t });\n\t });\n\t });\n\t });\n\t })];\n\t });\n\t });\n\t };\n\t return CountDownGroup;\n\t}(engine.Sprite));\n\t//# sourceMappingURL=CountDownGroup.js.map\n\n\tvar GuideView = (function (_super) {\n\t tslib.__extends(GuideView, _super);\n\t function GuideView() {\n\t var _this = _super.call(this) || this;\n\t _this.initUI();\n\t _this.visible = false;\n\t return _this;\n\t }\n\t GuideView.prototype.initUI = function () {\n\t this.addChild(createBg(.6));\n\t this.guideBg = createImg('guideBg');\n\t this.addChild(this.guideBg);\n\t this.guideEle = createImg('guideEle');\n\t this.addChild(this.guideEle);\n\t this.guideBg.x = 393;\n\t this.guideBg.y = 552;\n\t this.guideEle.x = 361;\n\t this.guideEle.y = 877;\n\t this.guideEle.mouseEnabled = this.guideEle.mouseChildren = true;\n\t var svga = createSvga(\"guideTips\");\n\t this.svga = svga;\n\t this.addChild(svga);\n\t svga.gotoAndStop(1);\n\t svga.mouseEnabled = svga.mouseChildren = false;\n\t };\n\t GuideView.prototype.checkHit = function (x, y, w, h) {\n\t var rect = new engine.Rectangle(393, 552, 281, 320);\n\t if (x > rect.x && y > rect.y && (x + w) < (rect.x + rect.width) && (y + h) < (rect.y + rect.height)) {\n\t return true;\n\t }\n\t return false;\n\t };\n\t GuideView.prototype.startGuide = function () {\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 return [2, new Promise(function (r) {\n\t _this.visible = true;\n\t _this.svga.gotoAndStop(1);\n\t _this.svga.play(false, true);\n\t _this.guideEle.scaleX = 1;\n\t _this.guideEle.scaleY = 1;\n\t var offset = [0, 0];\n\t var guideOver = function () {\n\t _this.guideEle.removeEventListener(engine.MouseEvent.MOUSE_DOWN, ondown, _this);\n\t engine.Tween.get(_this.guideEle).to({ scaleX: 0, scaleY: 0 }, 300).call(function () {\n\t _this.visible = false;\n\t r();\n\t });\n\t };\n\t var onUp = function (e) {\n\t _this.stage.removeEventListener(engine.MouseEvent.MOUSE_MOVE, onMove, _this);\n\t if (_this.checkHit(_this.guideEle.x, _this.guideEle.y, _this.guideEle.width, _this.guideEle.height)) {\n\t guideOver();\n\t }\n\t else {\n\t _this.svga.visible = true;\n\t _this.guideEle.x = 361;\n\t _this.guideEle.y = 877;\n\t }\n\t };\n\t var onMove = function (e) {\n\t _this.guideEle.x = e.stageX - offset[0];\n\t _this.guideEle.y = e.stageY - offset[1];\n\t };\n\t var ondown = function (e) {\n\t offset = [e.localX, e.localY];\n\t _this.svga.visible = false;\n\t _this.stage.once(engine.MouseEvent.MOUSE_UP, onUp, _this);\n\t _this.stage.addEventListener(engine.MouseEvent.MOUSE_MOVE, onMove, _this);\n\t };\n\t _this.guideEle.addEventListener(engine.MouseEvent.MOUSE_DOWN, ondown, _this);\n\t })];\n\t });\n\t });\n\t };\n\t return GuideView;\n\t}(engine.Sprite));\n\t//# sourceMappingURL=guideView.js.map\n\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._timeCounter = 0;\n\t _this.once(engine.Event.ADDED_TO_STAGE, _this.setup, _this);\n\t return _this;\n\t }\n\t GameView.prototype.configUI = function () {\n\t var uiMap = {};\n\t this.uiMap = uiMap;\n\t var config = uiConfig();\n\t for (var _i = 0, config_1 = config; _i < config_1.length; _i++) {\n\t var item = config_1[_i];\n\t var id = item.id, texture = item.texture, pos = item.pos, anchor = item.anchor;\n\t var sp = new engine.Sprite(getTextureByName(texture));\n\t this.addChild(sp);\n\t uiMap[id] = sp;\n\t if (anchor) {\n\t sp.anchorX = anchor[0];\n\t sp.anchorY = anchor[1];\n\t }\n\t if (pos) {\n\t sp.x = pos[0];\n\t sp.y = pos[1];\n\t if (anchor) {\n\t sp.x = pos[0] - sp.anchorX;\n\t sp.y = pos[1] - sp.anchorY;\n\t }\n\t }\n\t }\n\t this.configConveyors();\n\t this.createRects();\n\t this.countdown = new CountDownGroup();\n\t this.addChild(this.countdown);\n\t this.guide = new GuideView();\n\t this.addChild(this.guide);\n\t };\n\t GameView.prototype.createRects = function () {\n\t this.wetWaste = this.createRect(74, 552, 301, 293, 0xffffff);\n\t this.harmfulWaste = this.createRect(75, 247, 300, 293, 0xff0000);\n\t this.dryWaste = this.createRect(389, 249, 286, 291, 0x000000);\n\t this.recoverableWaste = this.createRect(389, 551, 287, 292, 0x0000ff);\n\t };\n\t GameView.prototype.createRect = function (x, y, w, h, c) {\n\t var rect = new engine.Rectangle(x, y, w, h);\n\t var sp = new engine.Sprite();\n\t this.addChild(sp);\n\t sp.x = x;\n\t sp.y = y;\n\t var g = new engine.Graphics;\n\t g.alpha = 0.0;\n\t g.beginFill(c);\n\t g.drawRect(0, 0, w, h);\n\t g.endFill();\n\t sp.addChild(g);\n\t return rect;\n\t };\n\t GameView.prototype.configConveyors = function () {\n\t var conveyor0 = new Conveyor();\n\t var conveyor1 = new Conveyor();\n\t this.addChild(conveyor0);\n\t this.addChild(conveyor1);\n\t conveyor0.x = 0;\n\t conveyor1.x = 764;\n\t this.conveyors = new Conveyors(this);\n\t this.conveyors.initData(conveyor0, conveyor1);\n\t };\n\t GameView.prototype.playAni = function () {\n\t var _this = this;\n\t var idlerWheels = ['idler0', 'idler1', 'idler2', 'idler3', 'idler4', 'idler5', 'idler6'];\n\t idlerWheels = idlerWheels.map(function (i) { return _this.uiMap[i]; });\n\t idlerWheels.forEach(function (i) {\n\t engine.Tween.get(i, { loop: true }).to({ rotation: -360 }, 1000);\n\t });\n\t };\n\t GameView.prototype.stopAni = function () {\n\t var _this = this;\n\t var idlerWheels = ['idler0', 'idler1', 'idler2', 'idler3', 'idler4', 'idler5', 'idler6'];\n\t idlerWheels = idlerWheels.map(function (i) { return _this.uiMap[i]; });\n\t idlerWheels.forEach(function (i) {\n\t engine.Tween.removeTweens(i);\n\t });\n\t };\n\t GameView.prototype.start = function () {\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 console.log('on start');\n\t this._timeCounter = 0;\n\t if (!!getGuideInfo()) return [3, 2];\n\t return [4, this.guide.startGuide()];\n\t case 1:\n\t _a.sent();\n\t setGuide();\n\t _a.label = 2;\n\t case 2:\n\t this.conveyors.clear();\n\t return [4, this.countdown.startCountDown()];\n\t case 3:\n\t _a.sent();\n\t this.startGame();\n\t engine.globalEvent.dispatchEvent('recycling-time-update', {\n\t second: this.getSecond(),\n\t });\n\t this._timer = setInterval(function () {\n\t _this.onTimer();\n\t }, 1000);\n\t return [2];\n\t }\n\t });\n\t });\n\t };\n\t GameView.prototype.startGame = function () {\n\t this.playAni();\n\t this.conveyors.startConveyors();\n\t };\n\t GameView.prototype.stopGame = function () {\n\t this.stopAni();\n\t };\n\t GameView.prototype.getSecond = function () {\n\t return props.time - this._timeCounter;\n\t };\n\t GameView.prototype.onTimer = function () {\n\t this._timeCounter++;\n\t engine.globalEvent.dispatchEvent('recycling-time-update', {\n\t second: this.getSecond(),\n\t });\n\t if (this.getSecond() == 0) {\n\t this.stop();\n\t this.conveyors.timeout();\n\t }\n\t };\n\t GameView.prototype.stop = function () {\n\t clearInterval(this._timer);\n\t this.stopGame();\n\t };\n\t GameView.prototype.setup = function () {\n\t console.log('onSteup', props);\n\t this.configUI();\n\t };\n\t GameView.prototype.onDown = function (e) {\n\t };\n\t GameView.prototype.stageOnUp = function (e) {\n\t };\n\t GameView.prototype.onSuccess = function () {\n\t };\n\t GameView.prototype.onMove = function (e) {\n\t };\n\t return GameView;\n\t}(engine.Container));\n\t//# sourceMappingURL=GameView.js.map\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('recycling-start', _this.start, _this);\n\t engine.globalEvent.addEventListener('recycling-stop', _this.stop, _this);\n\t var gameView = _this._gameView = new GameView();\n\t _this.addChild(gameView);\n\t return _this;\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.stop = function (event) {\n\t this._gameView.stop();\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"
}
......@@ -46,19 +46,19 @@ function launchWithCustomModule(customModule) {
}, 100);
setTimeout(() => {
engine.globalEvent.dispatchEvent('recycling-start', { time: 1000, maxScore: 200 });
engine.globalEvent.dispatchEvent('recycling-start', { time: 2, maxScore: 2 });
const d = engine.gameStage.sceneContainer.getChildAt(0);
}, 200);
// setTimeout(() => {
// engine.globalEvent.dispatchEvent('recycling-start', { time: 2 });
setTimeout(() => {
engine.globalEvent.dispatchEvent('recycling-start', { time: 8, maxScore: 2 });
// const d = engine.gameStage.sceneContainer.getChildAt(0);
// }, 1000 * 10);
const d = engine.gameStage.sceneContainer.getChildAt(0);
}, 1000 * 10);
});
engine.globalEvent.addEventListener('recycling-time-update', (e) => {
// console.log(e.type, e.data);
console.log(e.type, e.data);
});
engine.globalEvent.addEventListener('recycling-score-update', (e) => {
console.log(e.type, e.data);
......
......@@ -241,11 +241,10 @@
this.conveyor1 = conveyor1;
};
Conveyors.prototype.setDefault = function () {
this.clear();
this.score = 0;
this.conveyorsPool.push(this.conveyor0);
this.conveyorsPool.push(this.conveyor1);
var allConfigs = shuffle(this.GarbageConfig);
var allConfigs = shuffle(this.GarbageConfig.concat([]));
for (var i = 0; i < GarbageConfig.config.length; i++) {
allConfigs[i].idx = i;
allConfigs[i].isRight = false;
......@@ -420,16 +419,19 @@
view.y = e.stageY - target.texture.height / 2;
view.type = target['type'];
view.name = target['name'];
this.wrapper.once(engine.MouseEvent.MOUSE_UP, this.onStageMouseUp, this);
this.wrapper.addEventListener(engine.MouseEvent.MOUSE_UP, this.onStageMouseUp, this);
this.wrapper.addEventListener(engine.MouseEvent.MOUSE_MOVE, this.onStageMouseMove, this);
};
Conveyors.prototype.onStageMouseMove = function (e) {
console.log('onStageMouseMove');
var view = this._currentDragView;
view.x = e.stageX - view.texture.width / 2;
view.y = e.stageY - view.texture.height / 2;
};
Conveyors.prototype.onStageMouseUp = function (e) {
var _this = this;
console.log('onStageMouseUp');
this.wrapper.removeEventListener(engine.MouseEvent.MOUSE_UP, this.onStageMouseUp, this);
this.wrapper.removeEventListener(engine.MouseEvent.MOUSE_MOVE, this.onStageMouseMove, this);
if (!this._currentDragView)
return;
......@@ -453,6 +455,8 @@
});
};
Conveyors.prototype.clear = function () {
this.conveyor0.x = 0;
this.conveyor1.x = 764;
this.conveyorsPool.forEach(function (i) {
i.clear();
});
......@@ -461,6 +465,11 @@
this.stores = [];
};
Conveyors.prototype.timeout = function () {
if (this._currentDragView) {
removeChild(this._currentDragView);
}
this.wrapper.removeEventListener(engine.MouseEvent.MOUSE_UP, this.onStageMouseUp, this);
this.wrapper.removeEventListener(engine.MouseEvent.MOUSE_MOVE, this.onStageMouseMove, this);
this.gameOver();
};
Conveyors.prototype.checkHitRect = function () {
......@@ -772,10 +781,10 @@
};
GameView.prototype.configConveyors = function () {
var conveyor0 = new Conveyor();
conveyor0.x = 0;
var conveyor1 = new Conveyor();
this.addChild(conveyor0);
this.addChild(conveyor1);
conveyor0.x = 0;
conveyor1.x = 764;
this.conveyors = new Conveyors(this);
this.conveyors.initData(conveyor0, conveyor1);
......@@ -811,6 +820,10 @@
setGuide();
_a.label = 2;
case 2:
this.conveyors.clear();
return [4, this.countdown.startCountDown()];
case 3:
_a.sent();
this.startGame();
engine.globalEvent.dispatchEvent('recycling-time-update', {
second: this.getSecond(),
......
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -36,7 +36,6 @@ export default class Conveyors extends engine.Sprite {
}
private setDefault() {
this.clear();
this.score = 0;
......@@ -44,7 +43,7 @@ export default class Conveyors extends engine.Sprite {
this.conveyorsPool.push(this.conveyor1);
// 本局游戏的20种垃圾
const allConfigs = shuffle(this.GarbageConfig);
const allConfigs = shuffle(this.GarbageConfig.concat([]));
for (let i = 0; i < GarbageConfig.config.length; i++) {
allConfigs[i].idx = i;
......@@ -233,7 +232,7 @@ export default class Conveyors extends engine.Sprite {
private _currentDragView: engine.Sprite;
private _currentTarget: engine.Sprite;
onDown_garbage(e: engine.MouseEvent) {
if(this._currentDragView){
if (this._currentDragView) {
removeChild(this._currentDragView)
}
const target: engine.Sprite = e.target;
......@@ -246,17 +245,20 @@ export default class Conveyors extends engine.Sprite {
view.y = e.stageY - target.texture.height / 2;
view.type = target['type'];
view.name = target['name'];
this.wrapper.once(engine.MouseEvent.MOUSE_UP, this.onStageMouseUp, this)
this.wrapper.addEventListener(engine.MouseEvent.MOUSE_UP, this.onStageMouseUp, this)
this.wrapper.addEventListener(engine.MouseEvent.MOUSE_MOVE, this.onStageMouseMove, this)
}
onStageMouseMove(e: engine.MouseEvent) {
console.log('onStageMouseMove')
const view = this._currentDragView;
view.x = e.stageX - view.texture.width / 2;
view.y = e.stageY - view.texture.height / 2;
}
onStageMouseUp(e: engine.MouseEvent) {
console.log('onStageMouseUp')
this.wrapper.removeEventListener(engine.MouseEvent.MOUSE_UP, this.onStageMouseUp, this)
this.wrapper.removeEventListener(engine.MouseEvent.MOUSE_MOVE, this.onStageMouseMove, this)
if (!this._currentDragView) return;
const result: GarbageTypes = this.checkHitRect();
......@@ -281,7 +283,9 @@ export default class Conveyors extends engine.Sprite {
});
}
private clear() {
clear() {
this.conveyor0.x = 0;
this.conveyor1.x = 764;
this.conveyorsPool.forEach(i => {
i.clear();
});
......@@ -291,6 +295,11 @@ export default class Conveyors extends engine.Sprite {
}
timeout() {
if (this._currentDragView) {
removeChild(this._currentDragView)
}
this.wrapper.removeEventListener(engine.MouseEvent.MOUSE_UP, this.onStageMouseUp, this)
this.wrapper.removeEventListener(engine.MouseEvent.MOUSE_MOVE, this.onStageMouseMove, this)
this.gameOver();
}
......
......@@ -91,11 +91,10 @@ export default class GameView extends engine.Container {
private configConveyors() {
const conveyor0 = new Conveyor();
conveyor0.x = 0;
const conveyor1 = new Conveyor();
this.addChild(conveyor0);
this.addChild(conveyor1);
conveyor0.x = 0;
conveyor1.x = 764;
this.conveyors = new Conveyors(this);
this.conveyors.initData(conveyor0, conveyor1)
......@@ -126,7 +125,9 @@ export default class GameView extends engine.Container {
setGuide();
}
// await this.countdown.startCountDown();
this.conveyors.clear()
await this.countdown.startCountDown();
this.startGame();
......
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