Commit cbcb78af authored by lujinlei's avatar lujinlei

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

parents 7dc16f58 55a77ca7
No preview for this file type
No preview for this file type
{
"name": "北京现代出游季",
"desc": "北京现代出游记模块",
"props": {
"guideText1": {
"alias": "引导1的文本",
"type": "string",
"default": "长按屏幕\n杆子变长即可通过"
},
"guideText2": {
"alias": "引导2的文本",
"type": "string",
"default": "当度小宝获得金币时积分+5"
},
"pierMinDistance": {
"alias": "障碍物最小间距",
"type": "number",
"default": 350
},
"pierMaxDistance": {
"alias": "障碍物最大间距",
"type": "number",
"default": 500
},
"frontBGMoveSpeed": {
"alias": "前背影移动速度",
"type": "number",
"default": 0.5
},
"afterBGMoveSpeed": {
"alias": "后背影移动速度",
"type": "number",
"default": 0.2
},
"reward": {
"alias": "出现金币的概率(0-1区间 1为必出现 0为必不出现)",
"type": "number",
"default": 0
},
"pierCount": {
"alias": "一屏中最多出现的桥墩数量(最好默认为2)",
"type": "number",
"default": 2
},
"pierMoveTime": {
"alias": "一个周期内桥墩移动的总时长(毫秒)",
"type": "number",
"default": 1000
},
"strutUpSpeed": {
"alias": "撑杆上升速度(每帧上升增量,一秒60帧)",
"type": "number",
"default": 30
},
"strutWidth": {
"alias": "撑杆宽度",
"type": "number",
"default": 5
},
"strutColor": {
"alias": "撑杆颜色",
"type": "string",
"default": "#ffffff"
},
"strutRotationSpeed": {
"alias": "撑杆旋转总时长(毫秒)",
"type": "number",
"default": 300
},
"playerMoveSpeed": {
"alias": "人物移动总时长(毫秒)",
"type": "number",
"default": 1200
},
"singleScore": {
"alias": "每个桥墩分数",
"type": "number",
"default": 5
},
"goldScore": {
"alias": "每个金币分数",
"type": "number",
"default": 5
},
"bgFristScore": {
"alias": "第一张图的分数区间最大值(超过此值就更换第二张背景图)",
"type": "number",
"default": 30
},
"bgSecondScore": {
"alias": "第二张图的分数区间最大值(超过此值就更换第三张背景图)",
"type": "number",
"default": 80
}
},
"assets": [
{
"name": "bg1",
"url": "//yun.duiba.com.cn/aurora/assets/f3fda198741657d9cab9418bd5d47248af065487.jpg",
"uuid": "bg1",
"ext": ".jpg"
},
{
"name": "bg2",
"url": "//yun.duiba.com.cn/aurora/assets/8fa1de1570023f21b676a8602ec9315cee83a99b.jpg",
"uuid": "bg2",
"ext": ".jpg"
},
{
"name": "bg3",
"url": "//yun.duiba.com.cn/aurora/assets/517fc529c79b18ff4881d206c942c8f2888ad6fd.jpg",
"uuid": "bg3",
"ext": ".jpg"
},
{
"name": "car1",
"url": "//yun.duiba.com.cn/aurora/assets/c1e80aee4eee3665e0f0bce08233b05be4b4ee9c.png",
"uuid": "car1",
"ext": ".png"
},
{
"name": "yindao1",
"url": "//yun.duiba.com.cn/aurora/assets/4449285320882460ae0dd0b59b3c73e0bb92def6.png",
"uuid": "yindao1",
"ext": ".png"
},
{
"name": "yindao2",
"url": "//yun.duiba.com.cn/aurora/assets/1c914031834736b93e9b2a94a4e8a643871795f7.png",
"uuid": "yindao2",
"ext": ".png"
},
{
"name": "shouzhi",
"url": "//yun.duiba.com.cn/aurora/assets/fd62b438bfd67345fe441f5e68e4394d650fac8d.png",
"uuid": "shouzhi",
"ext": ".png"
},
{
"name": "zhuzi1",
"url": "//yun.duiba.com.cn/aurora/assets/cb779c9ebf4bfbd5bec1d817a6ef824d4ae5d751.png",
"uuid": "zhuzi1",
"ext": ".png"
},
{
"name": "zhuzi2",
"url": "//yun.duiba.com.cn/aurora/assets/c5187595bec08c211c8e45bf5f163ff02fd659ab.png",
"uuid": "zhuzi2",
"ext": ".png"
},
{
"name": "zhuzi3",
"url": "//yun.duiba.com.cn/aurora/assets/08dc255864c2af52dac7a993a4c62b1970dd6db4.png",
"uuid": "zhuzi3",
"ext": ".png"
},
{
"name": "person",
"url": "//yun.duiba.com.cn/aurora/assets/094526243496c8ebf1002f73f3cbbf3c9e12892a.png",
"uuid": "person",
"ext": ".png"
},
{
"name": "gold",
"url": "//yun.duiba.com.cn/aurora/assets/ae210ad26cee13f8fb6e69be62f7f5498be50a5b.png",
"uuid": "7f4e19f2-c80f-4a65-bec2-1f3c3dc6d210",
"ext": ".png"
},
{
"name": "walk",
"url": "//yun.duiba.com.cn/aurora/assets/5b31481f8d5669213da518b156aac7cadf5d9374",
"uuid": "10cd1fdd-4fd8-43cf-a1c7-6ff5846d8a91",
"ext": ".svga"
},
{
"name": "xiache",
"url": "//yun.duiba.com.cn/aurora/assets/57ad75aa036c04e13abcf32c464ff5ae37419495",
"uuid": "xiache",
"ext": ".svga"
},
{
"name": "ganzi",
"url": "//yun.duiba.com.cn/aurora/assets/501972d5960c29b7db1e476422e6fd3cb3a92c8f.png",
"uuid": "ganzi",
"ext": ".png"
}
],
"events": {
"in": {
"bjxd-game-start": {
"alias": "开始",
"data": {}
},
"bjxd-game-revive": {
"alias": "复活",
"data": {}
},
"bjxd-game-reset": {
"alias": "重置",
"data": {}
},
"bjxd-game-change": {
"alias": "替换显示",
"data": {
"index": 1
}
},
"bjxd-game-speed": {
"alias": "修改速度",
"data": {
"speed": 10
}
}
},
"out": {
"bjxd-game-over": {
"alias": "游戏结束",
"data": {
"score": 0
}
},
"bjxd-game-score": {
"alias": "分数",
"data": {
"score": 0
}
},
"bjxd-game-inmove": {
"alias": "游戏进行状态",
"data": {
"canstop": false
}
}
}
},
"id": "bjxd-game",
"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['bjxd-game'] = factory(global.tslib));\n}(this, (function (tslib) { 'use strict';\n\n\tvar props = {};\r\n\tfunction prepareProps() {\r\n\t var metaProps = getProps();\r\n\t engine.injectProp(props, metaProps);\r\n\t}\r\n\tfunction injectProps(p) {\r\n\t engine.injectProp(props, p);\r\n\t}\r\n\t//# sourceMappingURL=props.js.map\n\n\tvar ObjectPool = engine.ObjectPool;\r\n\tvar Road = (function (_super) {\r\n\t tslib.__extends(Road, _super);\r\n\t function Road() {\r\n\t return _super !== null && _super.apply(this, arguments) || this;\r\n\t }\r\n\t Road.prototype.setup = function () {\r\n\t this.lastPos = 0;\r\n\t this.addPier();\r\n\t };\r\n\t Road.prototype.getFristPier = function () {\r\n\t return this.getChildAt(0).width;\r\n\t };\r\n\t Road.prototype.getDistance = function () {\r\n\t var distance = [];\r\n\t var pier1 = this.getChildAt(0);\r\n\t var pier2 = this.getChildAt(1);\r\n\t distance.push(pier2.x - pier1.x);\r\n\t distance.push(pier2.width);\r\n\t return distance;\r\n\t };\r\n\t Road.prototype.addPier = function () {\r\n\t while (this.children.length < props.pierCount + 1) {\r\n\t var childrenNum = this.children.length;\r\n\t var randomPos = this.makeRandomFloat(props.pierMaxDistance, props.pierMinDistance);\r\n\t var pier = ObjectPool.getObject('pier');\r\n\t this.addChild(pier);\r\n\t pier.changeBg();\r\n\t if (childrenNum == 0) {\r\n\t pier.x = 0;\r\n\t }\r\n\t else {\r\n\t pier.x = this.lastPos + randomPos;\r\n\t }\r\n\t this.lastPos = pier.x;\r\n\t }\r\n\t };\r\n\t Road.prototype.changeBg = function () {\r\n\t var nume = this.children.length;\r\n\t for (var i = 0; i < nume; i++) {\r\n\t var ipier = this.getChildAt(i);\r\n\t ipier.changeBg();\r\n\t }\r\n\t };\r\n\t Road.prototype.moveAddPier = function () {\r\n\t var randomPos = this.makeRandomFloat(props.pierMaxDistance, props.pierMinDistance);\r\n\t var pier = ObjectPool.getObject('pier');\r\n\t var lastChild = this.getChildAt(this.children.length - 1);\r\n\t pier.x = lastChild.x + randomPos;\r\n\t this.addChild(pier);\r\n\t pier.changeBg();\r\n\t };\r\n\t Road.prototype.makeRandomFloat = function (max, min) {\r\n\t if (min === void 0) { min = 0; }\r\n\t return Math.random() * (max - min) + min;\r\n\t };\r\n\t Road.prototype.setViewport = function () {\r\n\t var _this = this;\r\n\t var tmpMovepos = this.getMovePos();\r\n\t this.children.forEach(function (item, index) {\r\n\t _this.playTween(item, index, tmpMovepos);\r\n\t });\r\n\t };\r\n\t Road.prototype.getMovePos = function () {\r\n\t var movePos = this.getChildAt(1);\r\n\t return movePos.x;\r\n\t };\r\n\t Road.prototype.playTween = function (item, index, tmpMovepos) {\r\n\t var _this = this;\r\n\t engine.Tween.get(item, { loop: false })\r\n\t .to({ x: item.x - tmpMovepos }, props.pierMoveTime)\r\n\t .call(function () {\r\n\t if (_this.getChildIndex(item) == 0) {\r\n\t engine.Tween.removeTweens(item);\r\n\t _this.removeChild(item);\r\n\t ObjectPool.recycleObject('pier', item);\r\n\t }\r\n\t if (index == 0) {\r\n\t _this.moveAddPier();\r\n\t }\r\n\t });\r\n\t };\r\n\t Road.prototype.getStartGold = function (index, isClose) {\r\n\t if (isClose === void 0) { isClose = true; }\r\n\t var tmpNode = this.getChildAt(index);\r\n\t var haveGold = tmpNode.haveGold;\r\n\t if (haveGold && isClose) {\r\n\t tmpNode.closeGold();\r\n\t }\r\n\t return haveGold;\r\n\t };\r\n\t Road.prototype.setGuide = function () {\r\n\t var tmpNode = this.getChildAt(1);\r\n\t if (!tmpNode.haveGold) {\r\n\t tmpNode.children.forEach(function (item) {\r\n\t if (item.name == 'gold') {\r\n\t item.visible = true;\r\n\t }\r\n\t });\r\n\t tmpNode.haveGold = true;\r\n\t }\r\n\t };\r\n\t return Road;\r\n\t}(engine.Container));\r\n\t//# sourceMappingURL=Road.js.map\n\n\tfunction getTexture(uuid) {\r\n\t return engine.Texture.from(getAssetByUUID(uuid).uuid);\r\n\t}\r\n\tfunction getTextureByName(name) {\r\n\t return getTexture(engine.getAssetByName(name).uuid);\r\n\t}\r\n\tfunction getStage() {\r\n\t return engine.gameStage.stage;\r\n\t}\r\n\tfunction createSvga(name) {\r\n\t var inst = new svga.Svga();\r\n\t inst.source = engine.getAssetByName(name).uuid;\r\n\t return inst;\r\n\t}\r\n\t//# sourceMappingURL=utils.js.map\n\n\tvar GuideLayer = (function (_super) {\r\n\t tslib.__extends(GuideLayer, _super);\r\n\t function GuideLayer() {\r\n\t var _this = _super.call(this) || this;\r\n\t _this.setup();\r\n\t return _this;\r\n\t }\r\n\t GuideLayer.prototype.setup = function () {\r\n\t };\r\n\t GuideLayer.prototype.show = function (id, options, callback) {\r\n\t this.visible = true;\r\n\t this._callBack = callback ? callback : null;\r\n\t if (!this.guideMask) {\r\n\t var _a = this.stage, width = _a.width, height = _a.height;\r\n\t this.guideMask = new engine.Container();\r\n\t this.addChild(this.guideMask);\r\n\t this.guideImg = new engine.Image();\r\n\t this.guideMask.addChild(this.guideImg);\r\n\t this.shouzhi = new engine.Image(getTextureByName(\"shouzhi\"));\r\n\t this.guideMask.addChild(this.shouzhi);\r\n\t }\r\n\t this.guideImg.texture = getTextureByName(\"yindao\" + id);\r\n\t this.guideStep(id);\r\n\t this.once(engine.MouseEvent.CLICK, function () {\r\n\t this.visible = false;\r\n\t if (this._callBack) {\r\n\t this._callBack();\r\n\t }\r\n\t }, this);\r\n\t };\r\n\t GuideLayer.prototype.guideStep = function (id) {\r\n\t if (id == 1) {\r\n\t this.shouzhi.x = 244;\r\n\t this.shouzhi.y = 812;\r\n\t }\r\n\t if (id == 2) {\r\n\t this.shouzhi.x = 346;\r\n\t this.shouzhi.y = 1108;\r\n\t }\r\n\t };\r\n\t return GuideLayer;\r\n\t}(engine.Container));\r\n\t//# sourceMappingURL=GuideLayer.js.map\n\n\tvar LoopComponent = (function (_super) {\r\n\t tslib.__extends(LoopComponent, _super);\r\n\t function LoopComponent() {\r\n\t var _this = _super.call(this) || this;\r\n\t _this.onceInfo = { width: 0, height: 0, count: 0 };\r\n\t _this.loopInfo = { width: 0, height: 0, count: 0 };\r\n\t _this.parts = [];\r\n\t return _this;\r\n\t }\r\n\t LoopComponent.prototype.setup = function (parts, info) {\r\n\t var _this = this;\r\n\t parts.forEach(function (item, index) {\r\n\t var part;\r\n\t if (typeof item == 'string') {\r\n\t if (item.length > 0) {\r\n\t part = new engine.Sprite(getTextureByName(item));\r\n\t }\r\n\t else {\r\n\t part = new engine.Sprite();\r\n\t }\r\n\t }\r\n\t else if (item instanceof engine.Texture) {\r\n\t part = new engine.Sprite(item);\r\n\t }\r\n\t else {\r\n\t part = item;\r\n\t }\r\n\t _this.addChild(part);\r\n\t _this.parts.push(part);\r\n\t if (index == 0) {\r\n\t info.width = part.width;\r\n\t info.height = part.height;\r\n\t }\r\n\t });\r\n\t info.count = parts.length;\r\n\t this.setViewport(0, 0);\r\n\t };\r\n\t LoopComponent.prototype.changeBg = function (changName) {\r\n\t this.parts.forEach(function (item, index) {\r\n\t if (changName && changName.length > 0) {\r\n\t item.texture = getTextureByName(changName);\r\n\t }\r\n\t });\r\n\t };\r\n\t LoopComponent.prototype.setupLoop = function (resArr) {\r\n\t this.setup(resArr, this.loopInfo);\r\n\t };\r\n\t LoopComponent.prototype.setViewport = function (x, y) {\r\n\t if (y === void 0) { y = 0; }\r\n\t var sizeField = y == 0 ? 'width' : 'height';\r\n\t var posField = y == 0 ? 'x' : 'y';\r\n\t var pos = y == 0 ? x : y;\r\n\t var index;\r\n\t var onceSize = this.onceInfo[sizeField];\r\n\t var onceCount = this.onceInfo.count;\r\n\t var loopCount = this.loopInfo.count;\r\n\t var loopSize = this.loopInfo[sizeField];\r\n\t index = onceSize == 0 ? -1 : Math.floor(pos / onceSize);\r\n\t if (index < 0 || index >= onceCount) {\r\n\t var loopIndex = Math.floor((pos - onceCount * onceSize) / this.loopInfo[sizeField]);\r\n\t index = onceCount + loopIndex;\r\n\t }\r\n\t var formerIndex = index < onceCount ? index : (index) % loopCount + onceCount;\r\n\t var latterIndex = index < onceCount ? index + 1 : (index - onceCount + 1) % loopCount + onceCount;\r\n\t var former = this.parts[formerIndex];\r\n\t var latter = this.parts[latterIndex];\r\n\t if (!former || !latter) {\r\n\t console.log(formerIndex, latterIndex);\r\n\t }\r\n\t former[posField] = -(pos - loopSize * (index < onceCount ? index : index - onceCount) - (index < onceCount ? 0 : onceCount * onceSize));\r\n\t latter[posField] = former.x + (index < onceCount ? onceSize : loopSize);\r\n\t };\r\n\t return LoopComponent;\r\n\t}(engine.Container));\r\n\t//# sourceMappingURL=LoopComponent.js.map\n\n\tvar Background = (function (_super) {\r\n\t tslib.__extends(Background, _super);\r\n\t function Background() {\r\n\t var _this = _super !== null && _super.apply(this, arguments) || this;\r\n\t _this.partResHHL = ['bg1', ''];\r\n\t _this.partResHB = ['bg2', ''];\r\n\t _this.partResWH = ['bg3', ''];\r\n\t _this.speeds = [];\r\n\t _this.resArray = [];\r\n\t _this.frameMovePos = 0;\r\n\t return _this;\r\n\t }\r\n\t Background.prototype.initBg = function () {\r\n\t this.sumMovePos = 0;\r\n\t this.speeds.push(props.afterBGMoveSpeed);\r\n\t this.speeds.push(props.frontBGMoveSpeed);\r\n\t var bottomBg = new engine.Rect();\r\n\t bottomBg.x = 0;\r\n\t bottomBg.y = 0;\r\n\t bottomBg.width = getStage().width;\r\n\t bottomBg.height = 0;\r\n\t bottomBg.fillColor = 0x75c9f5;\r\n\t this.addChild(bottomBg);\r\n\t this.resArray.push(this.partResHHL);\r\n\t this.resArray.push(this.partResHB);\r\n\t this.resArray.push(this.partResWH);\r\n\t var parts = [];\r\n\t for (var i = 0; i < 2; i++) {\r\n\t var part = new LoopComponent();\r\n\t part.setupLoop([\r\n\t this.resArray[0][i],\r\n\t this.resArray[0][i],\r\n\t ]);\r\n\t parts.push(part);\r\n\t this.addChild(part);\r\n\t }\r\n\t parts[1].y = 200;\r\n\t };\r\n\t Background.prototype.setViewport = function (pos) {\r\n\t this.needFrameSum = (props.pierMoveTime / 1000) * 60;\r\n\t this.frameMovePos = pos / this.needFrameSum;\r\n\t this.frameIndex = 0;\r\n\t this.addEventListener(engine.Event.ENTER_FRAME, this.frameBack, this);\r\n\t };\r\n\t Background.prototype.frameBack = function () {\r\n\t if (this.frameIndex < this.needFrameSum) {\r\n\t for (var i = 0; i < 2; i++) {\r\n\t var part = this.getChildAt(i + 1);\r\n\t var speed = this.speeds[i];\r\n\t var tmpPos = ((this.frameMovePos * this.frameIndex) + this.sumMovePos) * speed;\r\n\t part.setViewport(tmpPos);\r\n\t }\r\n\t this.frameIndex++;\r\n\t }\r\n\t else {\r\n\t this.sumMovePos += this.frameMovePos * this.needFrameSum;\r\n\t this.frameIndex = 0;\r\n\t this.removeEventListener(engine.Event.ENTER_FRAME, this.frameBack, this);\r\n\t }\r\n\t };\r\n\t Background.prototype.changeBg = function (index) {\r\n\t for (var i = 0; i < 2; i++) {\r\n\t var part = this.getChildAt(i + 1);\r\n\t part.changeBg(this.resArray[index][i]);\r\n\t if (i == 1 && index == 1) {\r\n\t part.y = 400;\r\n\t }\r\n\t if (i == 1 && index == 2) {\r\n\t part.y = 250;\r\n\t }\r\n\t }\r\n\t };\r\n\t return Background;\r\n\t}(engine.Container));\r\n\t//# sourceMappingURL=Background.js.map\n\n\tvar Pier = (function (_super) {\r\n\t tslib.__extends(Pier, _super);\r\n\t function Pier() {\r\n\t var _this = _super.call(this) || this;\r\n\t _this.part1tex = \"zhuzi1\";\r\n\t _this.part2tex = \"zhuzi2\";\r\n\t _this.part3tex = \"zhuzi3\";\r\n\t _this.texname = \"\";\r\n\t _this.zhuy = 1006;\r\n\t _this.bmp = new engine.Sprite();\r\n\t _this.addChild(_this.bmp);\r\n\t return _this;\r\n\t }\r\n\t Pier.prototype.init = function () {\r\n\t var bmp = this.bmp;\r\n\t bmp.alpha = 1;\r\n\t this.changeBg();\r\n\t bmp.x = 0;\r\n\t bmp.y = this.zhuy;\r\n\t };\r\n\t Pier.prototype.changeBg = function () {\r\n\t var texstr;\r\n\t if (GameView.bgIndex == 0) {\r\n\t texstr = this.part1tex;\r\n\t }\r\n\t else if (GameView.bgIndex == 1) {\r\n\t texstr = this.part2tex;\r\n\t }\r\n\t else {\r\n\t texstr = this.part3tex;\r\n\t }\r\n\t if (this.texname != texstr) {\r\n\t this.texname = texstr;\r\n\t this.bmp.texture = getTextureByName(texstr);\r\n\t }\r\n\t };\r\n\t Pier.prototype.setShowGold = function () {\r\n\t var nodeGold = this.getChildByName('gold');\r\n\t var randomWard = Math.random();\r\n\t nodeGold.alpha = 1;\r\n\t var isShow = randomWard < props.reward ? true : false;\r\n\t nodeGold.visible = isShow;\r\n\t this.haveGold = isShow;\r\n\t };\r\n\t Pier.prototype.setGoldPosX = function (bmp) {\r\n\t var nodeGold = this.getChildByName('gold');\r\n\t var pos = bmp.width / 2 - nodeGold.width / 2;\r\n\t nodeGold.x = pos;\r\n\t nodeGold.y = this.zhuy - nodeGold.height - 50;\r\n\t nodeGold.visible = false;\r\n\t };\r\n\t Pier.prototype.closeGold = function () {\r\n\t var _this = this;\r\n\t this.children.forEach(function (item) {\r\n\t if (item.name == 'gold') {\r\n\t item.anchorX = item.width / 2;\r\n\t item.anchorY = item.height / 2;\r\n\t engine.Tween.get(item, { loop: false })\r\n\t .to({ scaleX: 2.5, scaleY: 2.5 }, 200, engine.Ease.cubicOut)\r\n\t .to({ scaleX: 1, scaleY: 1, alpha: 0 }, 200, engine.Ease.cubicIn)\r\n\t .call(function () {\r\n\t item.visible = false;\r\n\t _this.haveGold = false;\r\n\t });\r\n\t }\r\n\t });\r\n\t };\r\n\t return Pier;\r\n\t}(engine.Container));\r\n\t//# sourceMappingURL=Pier.js.map\n\n\tvar Player = (function (_super) {\r\n\t tslib.__extends(Player, _super);\r\n\t function Player() {\r\n\t var _this = _super !== null && _super.apply(this, arguments) || this;\r\n\t _this.playery = 878;\r\n\t return _this;\r\n\t }\r\n\t Player.prototype.initPlayer = function (pierWidth) {\r\n\t this.pierWidth = pierWidth;\r\n\t this._container = new engine.Container();\r\n\t this.addChild(this._container);\r\n\t this.playerNode = createSvga('walk');\r\n\t this._container.addChild(this.playerNode);\r\n\t this.playerNode.y = this.playery;\r\n\t this.playerNode.x = pierWidth / 2 - 50;\r\n\t this.playerNode.play();\r\n\t this._container.visible = false;\r\n\t };\r\n\t Player.prototype.revive = function () {\r\n\t this._container.x = 0;\r\n\t this._container.y = 0;\r\n\t this.playerNode.x = this.pierWidth / 2 - 50;\r\n\t this.playerNode.y = this.playery;\r\n\t };\r\n\t Player.prototype.setViewport = function (pos, callBack, pierWidth) {\r\n\t var tmpPos = 0;\r\n\t var isSuccess = false;\r\n\t if (!pierWidth) {\r\n\t tmpPos = pos;\r\n\t isSuccess = true;\r\n\t }\r\n\t else {\r\n\t tmpPos = pierWidth - this.playerNode.x + pos - 60;\r\n\t }\r\n\t this.playGoTween(tmpPos, callBack, isSuccess);\r\n\t };\r\n\t Player.prototype.playGoTween = function (pos, callBack, isSuccess) {\r\n\t var _this = this;\r\n\t engine.Tween.get(this._container, { loop: false })\r\n\t .to({ x: pos }, props.playerMoveSpeed)\r\n\t .call(function () {\r\n\t engine.Tween.removeTweens(_this._container);\r\n\t if (isSuccess) {\r\n\t if (callBack) {\r\n\t callBack();\r\n\t }\r\n\t }\r\n\t else {\r\n\t _this.playDropTween(callBack);\r\n\t }\r\n\t });\r\n\t };\r\n\t Player.prototype.playDropTween = function (callBack) {\r\n\t var _this = this;\r\n\t engine.Tween.get(this._container, { loop: false })\r\n\t .to({ y: 2000 }, 1000)\r\n\t .call(function () {\r\n\t engine.Tween.removeTweens(_this._container);\r\n\t if (callBack) {\r\n\t callBack();\r\n\t }\r\n\t });\r\n\t };\r\n\t Player.prototype.setBackViewport = function (callBack) {\r\n\t var _this = this;\r\n\t engine.Tween.get(this._container, { loop: false })\r\n\t .to({ x: 0 }, props.pierMoveTime)\r\n\t .call(function () {\r\n\t engine.Tween.removeTweens(_this._container);\r\n\t if (callBack) {\r\n\t callBack();\r\n\t }\r\n\t });\r\n\t };\r\n\t return Player;\r\n\t}(engine.Container));\r\n\t//# sourceMappingURL=Player.js.map\n\n\tvar Strut = (function (_super) {\r\n\t tslib.__extends(Strut, _super);\r\n\t function Strut() {\r\n\t var _this = _super !== null && _super.apply(this, arguments) || this;\r\n\t _this.gany = 1005;\r\n\t return _this;\r\n\t }\r\n\t Strut.prototype.init = function () {\r\n\t this._strut = new engine.Image(getTextureByName(\"ganzi\"));\r\n\t this.addChild(this._strut);\r\n\t this._strut.y = this.gany;\r\n\t this._strut.rotation = 180;\r\n\t };\r\n\t Strut.prototype.onMouseDown = function (pierWidth, distance, callBack) {\r\n\t var paddingx = 20;\r\n\t if (GameView.bgIndex == 0) {\r\n\t paddingx = 20;\r\n\t }\r\n\t else if (GameView.bgIndex == 1) {\r\n\t paddingx = 30;\r\n\t }\r\n\t else if (GameView.bgIndex == 2) {\r\n\t paddingx = 20;\r\n\t }\r\n\t this._strut.x = pierWidth - paddingx;\r\n\t this._distance = distance;\r\n\t this._callBack = callBack;\r\n\t this._strut.visible = true;\r\n\t this.addEventListener(engine.Event.ENTER_FRAME, this.frameStrut, this);\r\n\t };\r\n\t Strut.prototype.onMouseUp = function () {\r\n\t var _this = this;\r\n\t this.removeEventListener(engine.Event.ENTER_FRAME, this.frameStrut, this);\r\n\t setTimeout(function () {\r\n\t _this.strutRotation();\r\n\t }, 200);\r\n\t };\r\n\t Strut.prototype.strutRotation = function () {\r\n\t var _this = this;\r\n\t engine.Tween.get(this._strut, { loop: false })\r\n\t .to({ rotation: 270 }, props.strutRotationSpeed)\r\n\t .call(function () {\r\n\t _this.judgeResult();\r\n\t engine.Tween.removeTweens(_this._strut);\r\n\t });\r\n\t };\r\n\t Strut.prototype.judgeResult = function () {\r\n\t var isSuccess = false;\r\n\t var paddingx = 20;\r\n\t var chax = 20;\r\n\t if (GameView.bgIndex == 0) {\r\n\t paddingx = 20;\r\n\t chax = 20;\r\n\t }\r\n\t else if (GameView.bgIndex == 1) {\r\n\t paddingx = 3;\r\n\t chax = 39;\r\n\t }\r\n\t else if (GameView.bgIndex == 2) {\r\n\t paddingx = 20;\r\n\t chax = 20;\r\n\t }\r\n\t var mindis = this._distance[0] - this._distance[1] + chax;\r\n\t var maxdis = this._distance[0] + paddingx;\r\n\t if (mindis <= this._strut.height && this._strut.height <= maxdis) {\r\n\t isSuccess = true;\r\n\t }\r\n\t if (this._callBack) {\r\n\t this._callBack(isSuccess);\r\n\t }\r\n\t };\r\n\t Strut.prototype.frameStrut = function () {\r\n\t var maxdis = 700;\r\n\t if (this._strut.height < maxdis) {\r\n\t if (this._strut.height + GameView.speed > maxdis) {\r\n\t this._strut.height = maxdis;\r\n\t }\r\n\t else {\r\n\t this._strut.height += GameView.speed;\r\n\t }\r\n\t }\r\n\t };\r\n\t Strut.prototype.rest = function () {\r\n\t this._strut.y = this.gany;\r\n\t this._strut.rotation = 180;\r\n\t this._strut.height = 0;\r\n\t this._strut.visible = false;\r\n\t };\r\n\t Strut.prototype.getStrutHeight = function () {\r\n\t var distance = this._strut.height > 1000 ? 1000 : this._strut.height;\r\n\t return distance;\r\n\t };\r\n\t return Strut;\r\n\t}(engine.Container));\r\n\t//# sourceMappingURL=Strut.js.map\n\n\tvar ObjectPool$1 = engine.ObjectPool;\r\n\tvar PoolName = 'pier';\r\n\tObjectPool$1.registerPool(PoolName, function () {\r\n\t return new Pier();\r\n\t}, function (item, data) {\r\n\t item.init();\r\n\t});\r\n\tvar GameView = (function (_super) {\r\n\t tslib.__extends(GameView, _super);\r\n\t function GameView() {\r\n\t var _this = _super.call(this) || this;\r\n\t _this.moveX = 0;\r\n\t _this.playery = 878;\r\n\t _this.inani = true;\r\n\t _this.once(engine.Event.ADDED_TO_STAGE, _this.setup, _this);\r\n\t return _this;\r\n\t }\r\n\t GameView.prototype.setup = function () {\r\n\t if (this._hasSetup) {\r\n\t return;\r\n\t }\r\n\t this._hasSetup = true;\r\n\t this._backgroud = new Background();\r\n\t this.addChild(this._backgroud);\r\n\t this._backgroud.initBg();\r\n\t var road = this._road = new Road();\r\n\t this.addChild(road);\r\n\t road.setup();\r\n\t var pierWidth = this._road.getFristPier();\r\n\t var player = this._player = new Player();\r\n\t this.addChild(player);\r\n\t player.initPlayer(pierWidth);\r\n\t this.pierWidth = pierWidth;\r\n\t this.xiacheNode = createSvga(\"xiache\");\r\n\t this.addChild(this.xiacheNode);\r\n\t this.xiacheNode.y = this.playery - 35;\r\n\t this.xiacheNode.x = this.pierWidth / 2 - 100;\r\n\t this.xiacheNode.stop();\r\n\t this.xiacheNode.name = \"xiacheanm\";\r\n\t console.log(\"下车动画帧数\", this.xiacheNode.totalFrames, this.xiacheNode);\r\n\t this.xiacheNode.visible = false;\r\n\t var strut = this._strut = new Strut();\r\n\t this.addChild(strut);\r\n\t strut.init();\r\n\t };\r\n\t GameView.prototype.playComp = function () {\r\n\t var curframe = this.xiacheNode.currentFrame;\r\n\t if (curframe == this.xiacheNode.totalFrames) {\r\n\t this.inani = false;\r\n\t this.xiacheNode.stop();\r\n\t this.xiacheNode.removeEventListener(engine.Event.ENTER_FRAME, this.playComp, this);\r\n\t for (var i = 0; i < 15; i++) {\r\n\t if (i < 12) {\r\n\t this.xiacheNode.getChildAt(i).visible = false;\r\n\t }\r\n\t }\r\n\t this._player._container.visible = true;\r\n\t }\r\n\t };\r\n\t GameView.prototype.start = function (guide) {\r\n\t return tslib.__awaiter(this, void 0, void 0, function () {\r\n\t var initScore;\r\n\t return tslib.__generator(this, function (_a) {\r\n\t this._isTouchLayer = true;\r\n\t this._sumScore = 0;\r\n\t this._isMouseDown = false;\r\n\t this._guide = guide;\r\n\t this._player.revive();\r\n\t this.closeStrut();\r\n\t initScore = 0;\r\n\t this.updateScore(initScore);\r\n\t if (this.xiacheNode.x < this.pierWidth / 2 - 105) {\r\n\t this.startAnm();\r\n\t }\r\n\t if (this._guide == '1') {\r\n\t this.setGuide();\r\n\t }\r\n\t else {\r\n\t this.initTouch();\r\n\t this.registerEvent();\r\n\t }\r\n\t engine.globalEvent.dispatchEvent(\"bjxd-game-inmove\", {\r\n\t \"canstop\": true\r\n\t });\r\n\t return [2];\r\n\t });\r\n\t });\r\n\t };\r\n\t GameView.prototype.startAnm = function () {\r\n\t this.inani = true;\r\n\t this.xiacheNode.visible = true;\r\n\t for (var i = 0; i < 15; i++) {\r\n\t if (i < 12) {\r\n\t this.xiacheNode.getChildAt(i).visible = true;\r\n\t }\r\n\t }\r\n\t this.xiacheNode.x = this.pierWidth / 2 - 100;\r\n\t this._player._container.visible = false;\r\n\t this.xiacheNode.gotoAndPlay(1);\r\n\t this.xiacheNode.addEventListener(engine.Event.ENTER_FRAME, this.playComp, this);\r\n\t };\r\n\t GameView.prototype.reset = function () {\r\n\t this._sumScore = 0;\r\n\t engine.globalEvent.dispatchEvent('bjxd-game-score', { score: this._sumScore });\r\n\t this._player.revive();\r\n\t this.closeStrut();\r\n\t this.changeBg(GameView.bgIndex);\r\n\t this.startAnm();\r\n\t engine.globalEvent.dispatchEvent(\"bjxd-game-inmove\", {\r\n\t \"canstop\": true\r\n\t });\r\n\t };\r\n\t GameView.prototype.revive = function () {\r\n\t this._player.revive();\r\n\t this.startAnm();\r\n\t this._isTouchLayer = true;\r\n\t this.closeStrut();\r\n\t engine.globalEvent.dispatchEvent(\"bjxd-game-inmove\", {\r\n\t \"canstop\": true\r\n\t });\r\n\t };\r\n\t GameView.prototype.setGuide = function () {\r\n\t var _this = this;\r\n\t this._road.setGuide();\r\n\t var guideLayer = this.guideLayer = new GuideLayer();\r\n\t this.addChild(guideLayer);\r\n\t this.guideLayer.show(1, { x: 20, y: 650, guideText: props.guideText1 }, function () {\r\n\t var posX = _this._road.getMovePos();\r\n\t _this.guideLayer.show(2, { x: posX + 20, y: 620, guideText: props.guideText2 }, function () {\r\n\t _this.initTouch();\r\n\t _this.registerEvent();\r\n\t });\r\n\t });\r\n\t };\r\n\t GameView.prototype.initLabScore = function () {\r\n\t };\r\n\t GameView.prototype.registerEvent = function () {\r\n\t this.removeListener();\r\n\t this.addEventListener(engine.MouseEvent.MOUSE_DOWN, this.onMouseDown, this);\r\n\t this.addEventListener(engine.MouseEvent.MOUSE_UP, this.onMouseUp, this);\r\n\t };\r\n\t GameView.prototype.removeListener = function () {\r\n\t this.removeEventListener(engine.MouseEvent.MOUSE_DOWN, this.onMouseDown, this);\r\n\t this.removeEventListener(engine.MouseEvent.MOUSE_UP, this.onMouseUp, this);\r\n\t };\r\n\t GameView.prototype.initTouch = function () {\r\n\t };\r\n\t GameView.prototype.setScoreShow = function () {\r\n\t };\r\n\t GameView.prototype.onMouseDown = function () {\r\n\t if (this._isTouchLayer && !this.inani) {\r\n\t engine.globalEvent.dispatchEvent(\"bjxd-game-inmove\", {\r\n\t \"canstop\": false\r\n\t });\r\n\t this._isMouseDown = true;\r\n\t this._strut.onMouseDown(this._road.getFristPier(), this._road.getDistance(), this.goCallBcak.bind(this));\r\n\t }\r\n\t };\r\n\t GameView.prototype.onMouseUp = function () {\r\n\t if (this._isTouchLayer && this._isMouseDown) {\r\n\t this._strut.onMouseUp();\r\n\t this._isMouseDown = false;\r\n\t this._isTouchLayer = false;\r\n\t }\r\n\t };\r\n\t GameView.prototype.goCallBcak = function (isSuccess) {\r\n\t var _this = this;\r\n\t if (isSuccess) {\r\n\t var movePos = this._road.getMovePos();\r\n\t if (this._road.getStartGold(1, false)) {\r\n\t this.updateScore(props.singleScore + props.goldScore);\r\n\t }\r\n\t else {\r\n\t this.updateScore(props.singleScore);\r\n\t }\r\n\t this._player.setViewport(movePos, this.complete.bind(this));\r\n\t }\r\n\t else {\r\n\t this._player.setViewport(this._strut.getStrutHeight(), function () {\r\n\t engine.globalEvent.dispatchEvent('bjxd-game-over', { score: _this._sumScore });\r\n\t }, this._road.getFristPier());\r\n\t }\r\n\t };\r\n\t GameView.prototype.complete = function () {\r\n\t var _this = this;\r\n\t this._road.getStartGold(1);\r\n\t var movePos = this._road.getMovePos();\r\n\t this._road.setViewport();\r\n\t this._backgroud.setViewport(movePos);\r\n\t this._player.setBackViewport(function () {\r\n\t _this._isTouchLayer = true;\r\n\t });\r\n\t var carx = this.xiacheNode.x;\r\n\t if (carx > -200) {\r\n\t carx -= movePos;\r\n\t engine.Tween.get(this.xiacheNode, { loop: false })\r\n\t .to({\r\n\t x: carx\r\n\t }, props.pierMoveTime);\r\n\t }\r\n\t engine.globalEvent.dispatchEvent(\"bjxd-game-inmove\", {\r\n\t \"canstop\": true\r\n\t });\r\n\t this.closeStrut();\r\n\t };\r\n\t GameView.prototype.closeStrut = function () {\r\n\t this._strut.rest();\r\n\t };\r\n\t GameView.prototype.updateScore = function (score) {\r\n\t this._sumScore += score;\r\n\t engine.globalEvent.dispatchEvent('bjxd-game-score', { score: this._sumScore });\r\n\t };\r\n\t GameView.prototype.getScore = function () {\r\n\t return this._sumScore;\r\n\t };\r\n\t GameView.prototype.changeBg = function (index) {\r\n\t if (GameView.bgIndex != index) {\r\n\t GameView.bgIndex = index;\r\n\t this._backgroud.changeBg(index);\r\n\t this._road.changeBg();\r\n\t }\r\n\t };\r\n\t GameView.prototype.changeSpeed = function (speed) {\r\n\t if (GameView.speed != speed) {\r\n\t GameView.speed = speed;\r\n\t }\r\n\t };\r\n\t GameView.bgIndex = 0;\r\n\t GameView.speed = 20;\r\n\t return GameView;\r\n\t}(engine.Container));\r\n\t//# sourceMappingURL=GameView.js.map\n\n\tvar GameWrapper = (function (_super) {\r\n\t tslib.__extends(GameWrapper, _super);\r\n\t function GameWrapper() {\r\n\t var _this = _super.call(this) || this;\r\n\t engine.globalEvent.addEventListener('bjxd-game-start', _this.start, _this);\r\n\t engine.globalEvent.addEventListener('bjxd-game-reset', _this.reset, _this);\r\n\t engine.globalEvent.addEventListener('bjxd-game-revive', _this.revive, _this);\r\n\t engine.globalEvent.addEventListener('bjxd-game-change', _this.change, _this);\r\n\t engine.globalEvent.addEventListener('bjxd-game-speed', _this.speed, _this);\r\n\t var gameView = _this._gameView = new GameView();\r\n\t _this.addChild(gameView);\r\n\t return _this;\r\n\t }\r\n\t GameWrapper.prototype.start = function (event) {\r\n\t this._gameView.start(event.data.guide);\r\n\t };\r\n\t GameWrapper.prototype.reset = function () {\r\n\t this._gameView.reset();\r\n\t };\r\n\t GameWrapper.prototype.revive = function () {\r\n\t this._gameView.revive();\r\n\t };\r\n\t GameWrapper.prototype.change = function (event) {\r\n\t this._gameView.changeBg(event.data.index);\r\n\t };\r\n\t GameWrapper.prototype.speed = function (event) {\r\n\t this._gameView.changeSpeed(event.data.speed);\r\n\t };\r\n\t return GameWrapper;\r\n\t}(engine.Container));\r\n\t//# sourceMappingURL=GameWrapper.js.map\n\n\tfunction index (props) {\r\n\t prepareProps();\r\n\t injectProps(props);\r\n\t var instance = new GameWrapper();\r\n\t return instance;\r\n\t}\r\n\t//# sourceMappingURL=index.js.map\n\n\treturn index;\n\n})));\n"
}
...@@ -194,5 +194,5 @@ ...@@ -194,5 +194,5 @@
} }
}, },
"id": "dxbcyj-game", "id": "dxbcyj-game",
"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['dxbcyj-game'] = factory(global.tslib));\n}(this, (function (tslib) { 'use strict';\n\n\tvar props = {};\r\n\tfunction prepareProps() {\r\n\t var metaProps = getProps();\r\n\t engine.injectProp(props, metaProps);\r\n\t}\r\n\tfunction injectProps(p) {\r\n\t engine.injectProp(props, p);\r\n\t}\n\n\tvar ObjectPool = engine.ObjectPool;\r\n\tvar Road = (function (_super) {\r\n\t tslib.__extends(Road, _super);\r\n\t function Road() {\r\n\t return _super !== null && _super.apply(this, arguments) || this;\r\n\t }\r\n\t Road.prototype.setup = function () {\r\n\t this.lastPos = 0;\r\n\t this.addPier();\r\n\t };\r\n\t Road.prototype.getFristPier = function () {\r\n\t return this.getChildAt(0).width;\r\n\t };\r\n\t Road.prototype.getDistance = function () {\r\n\t var distance = [];\r\n\t var pier1 = this.getChildAt(0);\r\n\t var pier2 = this.getChildAt(1);\r\n\t distance.push(pier2.x - pier1.x);\r\n\t distance.push(pier2.width);\r\n\t return distance;\r\n\t };\r\n\t Road.prototype.addPier = function () {\r\n\t while (this.children.length < props.pierCount + 1) {\r\n\t var childrenNum = this.children.length;\r\n\t var randomPos = this.makeRandomFloat(props.pierMaxDistance, props.pierMinDistance);\r\n\t var pier = ObjectPool.getObject('pier');\r\n\t this.addChild(pier);\r\n\t if (childrenNum == 0) {\r\n\t pier.x = 0;\r\n\t }\r\n\t else {\r\n\t pier.x = this.lastPos + randomPos;\r\n\t }\r\n\t this.lastPos = pier.x;\r\n\t }\r\n\t };\r\n\t Road.prototype.moveAddPier = function () {\r\n\t var randomPos = this.makeRandomFloat(props.pierMaxDistance, props.pierMinDistance);\r\n\t var pier = ObjectPool.getObject('pier');\r\n\t var lastChild = this.getChildAt(this.children.length - 1);\r\n\t pier.x = lastChild.x + randomPos;\r\n\t this.addChild(pier);\r\n\t };\r\n\t Road.prototype.makeRandomFloat = function (max, min) {\r\n\t if (min === void 0) { min = 0; }\r\n\t return Math.random() * (max - min) + min;\r\n\t };\r\n\t Road.prototype.setViewport = function () {\r\n\t var _this = this;\r\n\t var tmpMovepos = this.getMovePos();\r\n\t this.children.forEach(function (item, index) {\r\n\t _this.playTween(item, index, tmpMovepos);\r\n\t });\r\n\t };\r\n\t Road.prototype.getMovePos = function () {\r\n\t var movePos = this.getChildAt(1);\r\n\t return movePos.x;\r\n\t };\r\n\t Road.prototype.playTween = function (item, index, tmpMovepos) {\r\n\t var _this = this;\r\n\t engine.Tween.get(item, { loop: false })\r\n\t .to({ x: item.x - tmpMovepos }, props.pierMoveTime)\r\n\t .call(function () {\r\n\t if (_this.getChildIndex(item) == 0) {\r\n\t engine.Tween.removeTweens(item);\r\n\t _this.removeChild(item);\r\n\t ObjectPool.recycleObject('pier', item);\r\n\t }\r\n\t if (index == 0) {\r\n\t _this.moveAddPier();\r\n\t }\r\n\t });\r\n\t };\r\n\t Road.prototype.getStartGold = function (index, isClose) {\r\n\t if (isClose === void 0) { isClose = true; }\r\n\t var tmpNode = this.getChildAt(index);\r\n\t var haveGold = tmpNode.haveGold;\r\n\t if (haveGold && isClose) {\r\n\t tmpNode.closeGold();\r\n\t }\r\n\t return haveGold;\r\n\t };\r\n\t Road.prototype.setGuide = function () {\r\n\t var tmpNode = this.getChildAt(1);\r\n\t if (!tmpNode.haveGold) {\r\n\t tmpNode.children.forEach(function (item) {\r\n\t if (item.name == 'gold') {\r\n\t item.visible = true;\r\n\t }\r\n\t });\r\n\t tmpNode.haveGold = true;\r\n\t }\r\n\t };\r\n\t return Road;\r\n\t}(engine.Container));\n\n\tfunction getTexture(uuid) {\r\n\t return engine.Texture.from(getAssetByUUID(uuid).uuid);\r\n\t}\r\n\tfunction getTextureByName(name) {\r\n\t return getTexture(engine.getAssetByName(name).uuid);\r\n\t}\r\n\tfunction getStage() {\r\n\t return engine.gameStage.stage;\r\n\t}\r\n\tfunction createSvga(name) {\r\n\t var inst = new svga.Svga();\r\n\t inst.source = engine.getAssetByName(name).uuid;\r\n\t return inst;\r\n\t}\n\n\tvar GuideLayer = (function (_super) {\r\n\t tslib.__extends(GuideLayer, _super);\r\n\t function GuideLayer() {\r\n\t var _this = _super.call(this) || this;\r\n\t _this._canClear = [];\r\n\t _this.setup();\r\n\t return _this;\r\n\t }\r\n\t GuideLayer.prototype.setup = function () {\r\n\t };\r\n\t GuideLayer.prototype.show = function (id, options, callback) {\r\n\t this.visible = true;\r\n\t this._callBack = callback ? callback : null;\r\n\t if (!this.guideMask) {\r\n\t this._options = options;\r\n\t var _a = this.stage, width = _a.width, height = _a.height;\r\n\t var guideMask = this.guideMask = new engine.Container();\r\n\t var guideHole = this._guideHole = new engine.Image(getTextureByName('guide'));\r\n\t guideHole.x = options.x;\r\n\t guideHole.y = options.y;\r\n\t guideHole.width = 250;\r\n\t guideHole.height = 250;\r\n\t guideHole.name = 'guideHole';\r\n\t guideMask.addChild(guideHole);\r\n\t this.createRect(guideMask, 0, 0, width, guideHole.y);\r\n\t this.createRect(guideMask, 0, guideHole.y, guideHole.x, guideHole.height);\r\n\t this.createRect(guideMask, guideHole.x + guideHole.width, guideHole.y, width - guideHole.x - guideHole.width, guideHole.height);\r\n\t this.createRect(guideMask, 0, guideHole.y + guideHole.height, width, height - guideHole.y - guideHole.height);\r\n\t this.guideStep(id);\r\n\t var label = this.label = new engine.Label();\r\n\t label.fillColor = 'white';\r\n\t label.size = 30;\r\n\t label.text = options.guideText;\r\n\t label.x = (width - label.width) / 2;\r\n\t label.y = guideHole.y + guideHole.height + 50;\r\n\t label.textAlign = engine.TEXT_ALIGN.CENTER;\r\n\t label.name = 'labHint';\r\n\t guideMask.addChild(label);\r\n\t this.addChild(guideMask);\r\n\t }\r\n\t this.once(engine.MouseEvent.CLICK, function () {\r\n\t this.removeChild(this.guideMask);\r\n\t this.guideMask = null;\r\n\t if (this._callBack) {\r\n\t this._callBack();\r\n\t }\r\n\t }, this);\r\n\t };\r\n\t GuideLayer.prototype.createRect = function (container, x, y, width, height) {\r\n\t var rect = new engine.Rect();\r\n\t rect.x = x;\r\n\t rect.y = y;\r\n\t rect.width = width;\r\n\t rect.height = height;\r\n\t rect.fillColor = 'black';\r\n\t rect.alpha = 0.7;\r\n\t container.addChild(rect);\r\n\t };\r\n\t GuideLayer.prototype.guideStep = function (id) {\r\n\t if (id == 1) {\r\n\t var guideHand = new engine.Image(getTextureByName('guideHand'));\r\n\t guideHand.x = this._options.x + 300;\r\n\t guideHand.y = this._options.y + 100;\r\n\t this.guideMask.addChild(guideHand);\r\n\t var rect = new engine.Rect();\r\n\t rect.x = this._options.x + 200;\r\n\t rect.y = this._options.y - 15;\r\n\t rect.width = props.strutWidth;\r\n\t rect.height = 200;\r\n\t rect.fillColor = props.strutColor;\r\n\t this.guideMask.addChild(rect);\r\n\t this._canClear.push(guideHand);\r\n\t this._canClear.push(rect);\r\n\t }\r\n\t if (id == 2) {\r\n\t var know = new engine.Image(getTextureByName('know'));\r\n\t know.x = (this.stage.width - know.width) / 2;\r\n\t know.y = this._options.y + 400;\r\n\t this.guideMask.addChild(know);\r\n\t this._canClear.push(know);\r\n\t }\r\n\t };\r\n\t return GuideLayer;\r\n\t}(engine.Container));\n\n\tvar LoopComponent = (function (_super) {\r\n\t tslib.__extends(LoopComponent, _super);\r\n\t function LoopComponent() {\r\n\t var _this = _super.call(this) || this;\r\n\t _this.onceInfo = { width: 0, height: 0, count: 0 };\r\n\t _this.loopInfo = { width: 0, height: 0, count: 0 };\r\n\t _this.parts = [];\r\n\t return _this;\r\n\t }\r\n\t LoopComponent.prototype.setup = function (parts, info) {\r\n\t var _this = this;\r\n\t parts.forEach(function (item, index) {\r\n\t var part;\r\n\t if (typeof item == 'string') {\r\n\t part = new engine.Sprite(getTextureByName(item));\r\n\t }\r\n\t else if (item instanceof engine.Texture) {\r\n\t part = new engine.Sprite(item);\r\n\t }\r\n\t else {\r\n\t part = item;\r\n\t }\r\n\t _this.addChild(part);\r\n\t _this.parts.push(part);\r\n\t if (index == 0) {\r\n\t info.width = part.width;\r\n\t info.height = part.height;\r\n\t }\r\n\t });\r\n\t info.count = parts.length;\r\n\t this.setViewport(0, 0);\r\n\t };\r\n\t LoopComponent.prototype.changeBg = function (changName) {\r\n\t this.parts.forEach(function (item, index) {\r\n\t item.texture = getTextureByName(changName);\r\n\t });\r\n\t };\r\n\t LoopComponent.prototype.setupLoop = function (resArr) {\r\n\t this.setup(resArr, this.loopInfo);\r\n\t };\r\n\t LoopComponent.prototype.setViewport = function (x, y) {\r\n\t if (y === void 0) { y = 0; }\r\n\t var sizeField = y == 0 ? 'width' : 'height';\r\n\t var posField = y == 0 ? 'x' : 'y';\r\n\t var pos = y == 0 ? x : y;\r\n\t var index;\r\n\t var onceSize = this.onceInfo[sizeField];\r\n\t var onceCount = this.onceInfo.count;\r\n\t var loopCount = this.loopInfo.count;\r\n\t var loopSize = this.loopInfo[sizeField];\r\n\t index = onceSize == 0 ? -1 : Math.floor(pos / onceSize);\r\n\t if (index < 0 || index >= onceCount) {\r\n\t var loopIndex = Math.floor((pos - onceCount * onceSize) / this.loopInfo[sizeField]);\r\n\t index = onceCount + loopIndex;\r\n\t }\r\n\t var formerIndex = index < onceCount ? index : (index) % loopCount + onceCount;\r\n\t var latterIndex = index < onceCount ? index + 1 : (index - onceCount + 1) % loopCount + onceCount;\r\n\t var former = this.parts[formerIndex];\r\n\t var latter = this.parts[latterIndex];\r\n\t if (!former || !latter) {\r\n\t console.log(formerIndex, latterIndex);\r\n\t }\r\n\t former[posField] = -(pos - loopSize * (index < onceCount ? index : index - onceCount) - (index < onceCount ? 0 : onceCount * onceSize));\r\n\t latter[posField] = former.x + (index < onceCount ? onceSize : loopSize);\r\n\t };\r\n\t return LoopComponent;\r\n\t}(engine.Container));\n\n\tvar Background = (function (_super) {\r\n\t tslib.__extends(Background, _super);\r\n\t function Background() {\r\n\t var _this = _super !== null && _super.apply(this, arguments) || this;\r\n\t _this.partResHHL = ['hhl_after', 'hhl_front'];\r\n\t _this.partResHB = ['hb_after', 'hb_front'];\r\n\t _this.partResWH = ['wh_after', 'wh_front'];\r\n\t _this.speeds = [];\r\n\t _this.resArray = [];\r\n\t _this.frameMovePos = 0;\r\n\t return _this;\r\n\t }\r\n\t Background.prototype.initBg = function () {\r\n\t this.sumMovePos = 0;\r\n\t this.speeds.push(props.afterBGMoveSpeed);\r\n\t this.speeds.push(props.frontBGMoveSpeed);\r\n\t var bottomBg = new engine.Rect();\r\n\t bottomBg.x = 0;\r\n\t bottomBg.y = 0;\r\n\t bottomBg.width = getStage().width;\r\n\t bottomBg.height = 0;\r\n\t bottomBg.fillColor = 0x75c9f5;\r\n\t this.addChild(bottomBg);\r\n\t this.resArray.push(this.partResHHL);\r\n\t this.resArray.push(this.partResHB);\r\n\t this.resArray.push(this.partResWH);\r\n\t this._bgIndex = 0;\r\n\t var parts = [];\r\n\t for (var i = 0; i < 2; i++) {\r\n\t var part = new LoopComponent();\r\n\t part.setupLoop([\r\n\t this.resArray[0][i],\r\n\t this.resArray[0][i],\r\n\t ]);\r\n\t parts.push(part);\r\n\t this.addChild(part);\r\n\t }\r\n\t parts[1].y = 200;\r\n\t };\r\n\t Background.prototype.setViewport = function (pos) {\r\n\t this.needFrameSum = (props.pierMoveTime / 1000) * 60;\r\n\t this.frameMovePos = pos / this.needFrameSum;\r\n\t this.frameIndex = 0;\r\n\t this.addEventListener(engine.Event.ENTER_FRAME, this.frameBack, this);\r\n\t };\r\n\t Background.prototype.frameBack = function () {\r\n\t if (this.frameIndex < this.needFrameSum) {\r\n\t for (var i = 0; i < 2; i++) {\r\n\t var part = this.getChildAt(i + 1);\r\n\t var speed = this.speeds[i];\r\n\t var tmpPos = ((this.frameMovePos * this.frameIndex) + this.sumMovePos) * speed;\r\n\t part.setViewport(tmpPos);\r\n\t }\r\n\t this.frameIndex++;\r\n\t }\r\n\t else {\r\n\t this.sumMovePos += this.frameMovePos * this.needFrameSum;\r\n\t this.frameIndex = 0;\r\n\t this.removeEventListener(engine.Event.ENTER_FRAME, this.frameBack, this);\r\n\t }\r\n\t };\r\n\t Background.prototype.changeBg = function (index) {\r\n\t for (var i = 0; i < 2; i++) {\r\n\t var part = this.getChildAt(i + 1);\r\n\t part.changeBg(this.resArray[index][i]);\r\n\t if (i == 1 && index == 1) {\r\n\t part.y = 400;\r\n\t }\r\n\t if (i == 1 && index == 2) {\r\n\t part.y = 250;\r\n\t }\r\n\t }\r\n\t this._bgIndex = index;\r\n\t };\r\n\t Background.prototype.getBgIndex = function () {\r\n\t return this._bgIndex;\r\n\t };\r\n\t return Background;\r\n\t}(engine.Container));\n\n\tvar Pier = (function (_super) {\r\n\t tslib.__extends(Pier, _super);\r\n\t function Pier() {\r\n\t var _this = _super.call(this) || this;\r\n\t _this.bmp = new engine.Sprite();\r\n\t _this.addChild(_this.bmp);\r\n\t return _this;\r\n\t }\r\n\t Pier.prototype.init = function () {\r\n\t var bmp = this.bmp;\r\n\t bmp.alpha = 1;\r\n\t bmp.texture = getTextureByName('pier');\r\n\t bmp.x = 0;\r\n\t bmp.y = bmp.height;\r\n\t if (this.children.length < 2) {\r\n\t var gold = new engine.Sprite();\r\n\t gold.texture = getTextureByName('gold');\r\n\t gold.name = 'gold';\r\n\t this.addChild(gold);\r\n\t }\r\n\t this.setGoldPosX(bmp);\r\n\t this.setShowGold();\r\n\t };\r\n\t Pier.prototype.setShowGold = function () {\r\n\t var nodeGold = this.getChildByName('gold');\r\n\t var randomWard = Math.random();\r\n\t nodeGold.alpha = 1;\r\n\t var isShow = randomWard < props.reward ? true : false;\r\n\t nodeGold.visible = isShow;\r\n\t this.haveGold = isShow;\r\n\t };\r\n\t Pier.prototype.setGoldPosX = function (bmp) {\r\n\t var nodeGold = this.getChildByName('gold');\r\n\t var pos = bmp.width / 2 - nodeGold.width / 2;\r\n\t nodeGold.x = pos;\r\n\t nodeGold.y = bmp.height - nodeGold.height - 50;\r\n\t nodeGold.visible = false;\r\n\t };\r\n\t Pier.prototype.closeGold = function () {\r\n\t var _this = this;\r\n\t this.children.forEach(function (item) {\r\n\t if (item.name == 'gold') {\r\n\t item.anchorX = item.width / 2;\r\n\t item.anchorY = item.height / 2;\r\n\t engine.Tween.get(item, { loop: false })\r\n\t .to({ scaleX: 2.5, scaleY: 2.5 }, 200, engine.Ease.cubicOut)\r\n\t .to({ scaleX: 1, scaleY: 1, alpha: 0 }, 200, engine.Ease.cubicIn)\r\n\t .call(function () {\r\n\t item.visible = false;\r\n\t _this.haveGold = false;\r\n\t });\r\n\t }\r\n\t });\r\n\t };\r\n\t return Pier;\r\n\t}(engine.Container));\n\n\tvar Player = (function (_super) {\r\n\t tslib.__extends(Player, _super);\r\n\t function Player() {\r\n\t return _super !== null && _super.apply(this, arguments) || this;\r\n\t }\r\n\t Player.prototype.initPlayer = function (pierWidth) {\r\n\t this._container = new engine.Container();\r\n\t this.addChild(this._container);\r\n\t this.playerNode = createSvga('walk');\r\n\t this._container.addChild(this.playerNode);\r\n\t this.playerNode.y = 675;\r\n\t this.playerNode.x = pierWidth / 2 - 80;\r\n\t this.playerNode.play();\r\n\t };\r\n\t Player.prototype.setViewport = function (pos, callBack, pierWidth) {\r\n\t var tmpPos = 0;\r\n\t var isSuccess = false;\r\n\t if (!pierWidth) {\r\n\t tmpPos = pos;\r\n\t isSuccess = true;\r\n\t }\r\n\t else {\r\n\t tmpPos = pierWidth - this.playerNode.x + pos - 60;\r\n\t }\r\n\t this.playGoTween(tmpPos, callBack, isSuccess);\r\n\t };\r\n\t Player.prototype.playGoTween = function (pos, callBack, isSuccess) {\r\n\t var _this = this;\r\n\t engine.Tween.get(this._container, { loop: false })\r\n\t .to({ x: pos }, props.playerMoveSpeed)\r\n\t .call(function () {\r\n\t engine.Tween.removeTweens(_this._container);\r\n\t if (isSuccess) {\r\n\t if (callBack) {\r\n\t callBack();\r\n\t }\r\n\t }\r\n\t else {\r\n\t _this.playDropTween(callBack);\r\n\t }\r\n\t });\r\n\t };\r\n\t Player.prototype.playDropTween = function (callBack) {\r\n\t var _this = this;\r\n\t engine.Tween.get(this._container, { loop: false })\r\n\t .to({ y: 2000 }, 1000)\r\n\t .call(function () {\r\n\t engine.Tween.removeTweens(_this._container);\r\n\t if (callBack) {\r\n\t callBack();\r\n\t }\r\n\t });\r\n\t };\r\n\t Player.prototype.setBackViewport = function (callBack) {\r\n\t var _this = this;\r\n\t engine.Tween.get(this._container, { loop: false })\r\n\t .to({ x: 0 }, props.pierMoveTime)\r\n\t .call(function () {\r\n\t engine.Tween.removeTweens(_this._container);\r\n\t if (callBack) {\r\n\t callBack();\r\n\t }\r\n\t });\r\n\t };\r\n\t return Player;\r\n\t}(engine.Container));\n\n\tvar Strut = (function (_super) {\r\n\t tslib.__extends(Strut, _super);\r\n\t function Strut() {\r\n\t return _super !== null && _super.apply(this, arguments) || this;\r\n\t }\r\n\t Strut.prototype.init = function () {\r\n\t this._strut = new engine.Rect();\r\n\t this.addChild(this._strut);\r\n\t this._strut.width = props.strutWidth;\r\n\t this._strut.y = 833;\r\n\t this._strut.fillColor = props.strutColor;\r\n\t this._strut.rotation = 180;\r\n\t };\r\n\t Strut.prototype.onMouseDown = function (pierWidth, distance, callBack) {\r\n\t this._strut.x = pierWidth - 60;\r\n\t this._distance = distance;\r\n\t this._callBack = callBack;\r\n\t this._strut.visible = true;\r\n\t this.addEventListener(engine.Event.ENTER_FRAME, this.frameStrut, this);\r\n\t };\r\n\t Strut.prototype.onMouseUp = function () {\r\n\t var _this = this;\r\n\t this.removeEventListener(engine.Event.ENTER_FRAME, this.frameStrut, this);\r\n\t setTimeout(function () {\r\n\t _this.strutRotation();\r\n\t }, 200);\r\n\t };\r\n\t Strut.prototype.strutRotation = function () {\r\n\t var _this = this;\r\n\t engine.Tween.get(this._strut, { loop: false })\r\n\t .to({ rotation: 270 }, props.strutRotationSpeed)\r\n\t .call(function () {\r\n\t _this.judgeResult();\r\n\t engine.Tween.removeTweens(_this._strut);\r\n\t });\r\n\t };\r\n\t Strut.prototype.judgeResult = function () {\r\n\t var isSuccess = false;\r\n\t if (this._distance[0] - this._distance[1] + 100 <= this._strut.height && this._strut.height <= this._distance[0] + 20) {\r\n\t isSuccess = true;\r\n\t }\r\n\t if (this._callBack) {\r\n\t this._callBack(isSuccess);\r\n\t }\r\n\t };\r\n\t Strut.prototype.frameStrut = function () {\r\n\t if (this._strut.height < 1000) {\r\n\t this._strut.height += props.strutUpSpeed;\r\n\t }\r\n\t };\r\n\t Strut.prototype.rest = function () {\r\n\t this._strut.width = props.strutWidth;\r\n\t this._strut.y = 833;\r\n\t this._strut.fillColor = props.strutColor;\r\n\t this._strut.rotation = 180;\r\n\t this._strut.height = 0;\r\n\t this._strut.visible = false;\r\n\t };\r\n\t Strut.prototype.getStrutHeight = function () {\r\n\t var distance = this._strut.height > 1000 ? 1000 : this._strut.height;\r\n\t return distance;\r\n\t };\r\n\t return Strut;\r\n\t}(engine.Container));\n\n\tvar ScoreLabel = (function (_super) {\r\n\t tslib.__extends(ScoreLabel, _super);\r\n\t function ScoreLabel() {\r\n\t return _super !== null && _super.apply(this, arguments) || this;\r\n\t }\r\n\t ScoreLabel.prototype.updateScore = function (score, animation) {\r\n\t if (animation === void 0) { animation = true; }\r\n\t this._value = score;\r\n\t if (animation && this._tmp) {\r\n\t this.animationUpdate();\r\n\t }\r\n\t else {\r\n\t this.updateLocal(score);\r\n\t }\r\n\t };\r\n\t ScoreLabel.prototype.animationUpdate = function () {\r\n\t var _this = this;\r\n\t var tmpInterval = setInterval(function () {\r\n\t _this._tmp += 1;\r\n\t if (_this._tmp <= _this._value) {\r\n\t _this.text = _this._tmp;\r\n\t }\r\n\t else {\r\n\t _this._tmp = _this._value;\r\n\t clearInterval(tmpInterval);\r\n\t }\r\n\t }, 50);\r\n\t };\r\n\t ScoreLabel.prototype.updateLocal = function (v) {\r\n\t this._tmp = v;\r\n\t this.text = v;\r\n\t };\r\n\t return ScoreLabel;\r\n\t}(engine.Label));\n\n\tvar ObjectPool$1 = engine.ObjectPool;\r\n\tvar PoolName = 'pier';\r\n\tObjectPool$1.registerPool(PoolName, function () {\r\n\t return new Pier();\r\n\t}, function (item, data) {\r\n\t item.init();\r\n\t});\r\n\tvar GameView = (function (_super) {\r\n\t tslib.__extends(GameView, _super);\r\n\t function GameView() {\r\n\t var _this = _super.call(this) || this;\r\n\t _this.moveX = 0;\r\n\t _this.once(engine.Event.ADDED_TO_STAGE, _this.setup, _this);\r\n\t return _this;\r\n\t }\r\n\t GameView.prototype.setup = function () {\r\n\t if (this._hasSetup) {\r\n\t return;\r\n\t }\r\n\t this._hasSetup = true;\r\n\t this._backgroud = new Background();\r\n\t this.addChild(this._backgroud);\r\n\t this._backgroud.initBg();\r\n\t var road = this._road = new Road();\r\n\t this.addChild(road);\r\n\t road.setup();\r\n\t var pierWidth = this._road.getFristPier();\r\n\t var player = this._player = new Player();\r\n\t this.addChild(player);\r\n\t player.initPlayer(pierWidth);\r\n\t var strut = this._strut = new Strut();\r\n\t this.addChild(strut);\r\n\t strut.init();\r\n\t this._scoreContainer = new engine.Container();\r\n\t this.addChild(this._scoreContainer);\r\n\t this.initLabScore();\r\n\t };\r\n\t GameView.prototype.start = function (guide) {\r\n\t return tslib.__awaiter(this, void 0, void 0, function () {\r\n\t var initScore;\r\n\t return tslib.__generator(this, function (_a) {\r\n\t this._isTouchLayer = true;\r\n\t this._sumScore = 0;\r\n\t this._isMouseDown = false;\r\n\t this._guide = guide;\r\n\t initScore = this._road.getStartGold(0) ? props.goldScore : 0;\r\n\t this.updateScore(initScore);\r\n\t if (this._guide == '1') {\r\n\t this.setGuide();\r\n\t }\r\n\t else {\r\n\t this.initTouch();\r\n\t this.registerEvent();\r\n\t }\r\n\t return [2];\r\n\t });\r\n\t });\r\n\t };\r\n\t GameView.prototype.setGuide = function () {\r\n\t var _this = this;\r\n\t this._road.setGuide();\r\n\t var guideLayer = this.guideLayer = new GuideLayer();\r\n\t this.addChild(guideLayer);\r\n\t this.guideLayer.show(1, { x: 20, y: 650, guideText: props.guideText1 }, function () {\r\n\t var posX = _this._road.getMovePos();\r\n\t _this.guideLayer.show(2, { x: posX + 20, y: 620, guideText: props.guideText2 }, function () {\r\n\t _this.initTouch();\r\n\t _this.registerEvent();\r\n\t });\r\n\t });\r\n\t };\r\n\t GameView.prototype.initLabScore = function () {\r\n\t var scoreBg = new engine.Sprite(getTextureByName('scoreBg'));\r\n\t scoreBg.x = getStage().width / 2 - scoreBg.width / 2;\r\n\t scoreBg.y = 80;\r\n\t var scoreHint = new engine.Sprite(getTextureByName('scoreHint'));\r\n\t scoreHint.x = getStage().width / 2 - scoreHint.width / 2;\r\n\t scoreHint.y = 40;\r\n\t this._scoreContainer.addChild(scoreHint);\r\n\t this.labScore = new ScoreLabel();\r\n\t this.labScore.fillColor = 0xff7646;\r\n\t this.labScore.size = 70;\r\n\t this.labScore.width = getStage().width;\r\n\t this.labScore.height = scoreBg.height;\r\n\t this.labScore.textAlign = engine.TEXT_ALIGN.CENTER;\r\n\t this.labScore.x = 0;\r\n\t this.labScore.y = scoreBg.y + 10;\r\n\t this._scoreContainer.addChild(this.labScore);\r\n\t };\r\n\t GameView.prototype.registerEvent = function () {\r\n\t this._touchLayer.addEventListener(engine.MouseEvent.MOUSE_DOWN, this.onMouseDown, this);\r\n\t this._touchLayer.addEventListener(engine.MouseEvent.MOUSE_UP, this.onMouseUp, this);\r\n\t };\r\n\t GameView.prototype.removeListener = function () {\r\n\t this._touchLayer.removeEventListener(engine.MouseEvent.MOUSE_DOWN, this.onMouseDown, this);\r\n\t this._touchLayer.removeEventListener(engine.MouseEvent.MOUSE_UP, this.onMouseUp, this);\r\n\t };\r\n\t GameView.prototype.initTouch = function () {\r\n\t this._touchLayer = new engine.Rect();\r\n\t this.addChild(this._touchLayer);\r\n\t this._touchLayer.width = getStage().width;\r\n\t this._touchLayer.height = getStage().height;\r\n\t this._touchLayer.x = 0;\r\n\t this._touchLayer.y = 0;\r\n\t this._touchLayer.alpha = 0;\r\n\t };\r\n\t GameView.prototype.setScoreShow = function () {\r\n\t };\r\n\t GameView.prototype.onMouseDown = function () {\r\n\t if (this._isTouchLayer) {\r\n\t this._isMouseDown = true;\r\n\t this._strut.onMouseDown(this._road.getFristPier(), this._road.getDistance(), this.goCallBcak.bind(this));\r\n\t }\r\n\t };\r\n\t GameView.prototype.onMouseUp = function () {\r\n\t if (this._isTouchLayer && this._isMouseDown) {\r\n\t this._strut.onMouseUp();\r\n\t this._isMouseDown = false;\r\n\t this._isTouchLayer = false;\r\n\t }\r\n\t };\r\n\t GameView.prototype.goCallBcak = function (isSuccess) {\r\n\t var _this = this;\r\n\t if (isSuccess) {\r\n\t console.log('成功了');\r\n\t var movePos = this._road.getMovePos();\r\n\t if (this._road.getStartGold(1, false)) {\r\n\t this.updateScore(props.singleScore + props.goldScore);\r\n\t }\r\n\t else {\r\n\t this.updateScore(props.singleScore);\r\n\t }\r\n\t this._player.setViewport(movePos, this.complete.bind(this));\r\n\t }\r\n\t else {\r\n\t console.log('失败了');\r\n\t this._player.setViewport(this._strut.getStrutHeight(), function () {\r\n\t console.log('掉下去了');\r\n\t engine.globalEvent.dispatchEvent('dxbcyj-game-result', { score: _this._sumScore });\r\n\t }, this._road.getFristPier());\r\n\t }\r\n\t };\r\n\t GameView.prototype.complete = function () {\r\n\t var _this = this;\r\n\t this._road.getStartGold(1);\r\n\t var movePos = this._road.getMovePos();\r\n\t this._road.setViewport();\r\n\t this._backgroud.setViewport(movePos);\r\n\t this._player.setBackViewport(function () {\r\n\t _this._isTouchLayer = true;\r\n\t });\r\n\t this.closeStrut();\r\n\t };\r\n\t GameView.prototype.closeStrut = function () {\r\n\t this._strut.rest();\r\n\t };\r\n\t GameView.prototype.updateScore = function (score) {\r\n\t this._sumScore += score;\r\n\t if (0 <= this._sumScore && this._sumScore <= props.bgFristScore) {\r\n\t this.changeBg(0);\r\n\t }\r\n\t else if (props.bgFristScore < this._sumScore && this._sumScore <= props.bgSecondScore) {\r\n\t this.changeBg(1);\r\n\t }\r\n\t else {\r\n\t this.changeBg(2);\r\n\t }\r\n\t this.labScore.updateScore(this._sumScore);\r\n\t };\r\n\t GameView.prototype.getScore = function () {\r\n\t return this._sumScore;\r\n\t };\r\n\t GameView.prototype.changeBg = function (index) {\r\n\t if (this._backgroud.getBgIndex() != index) {\r\n\t this._backgroud.changeBg(index);\r\n\t }\r\n\t };\r\n\t return GameView;\r\n\t}(engine.Container));\n\n\tvar GameWrapper = (function (_super) {\r\n\t tslib.__extends(GameWrapper, _super);\r\n\t function GameWrapper() {\r\n\t var _this = _super.call(this) || this;\r\n\t engine.globalEvent.addEventListener('dxbcyj-game-start', _this.start, _this);\r\n\t var gameView = _this._gameView = new GameView();\r\n\t _this.addChild(gameView);\r\n\t return _this;\r\n\t }\r\n\t GameWrapper.prototype.start = function (event) {\r\n\t this._gameView.start(event.data.guide);\r\n\t };\r\n\t return GameWrapper;\r\n\t}(engine.Container));\n\n\tfunction index (props) {\r\n\t prepareProps();\r\n\t injectProps(props);\r\n\t var instance = new GameWrapper();\r\n\t return instance;\r\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['dxbcyj-game'] = factory(global.tslib));\n}(this, (function (tslib) { 'use strict';\n\n\tvar props = {};\r\n\tfunction prepareProps() {\r\n\t var metaProps = getProps();\r\n\t engine.injectProp(props, metaProps);\r\n\t}\r\n\tfunction injectProps(p) {\r\n\t engine.injectProp(props, p);\r\n\t}\n\n\tvar ObjectPool = engine.ObjectPool;\r\n\tvar Road = (function (_super) {\r\n\t tslib.__extends(Road, _super);\r\n\t function Road() {\r\n\t return _super !== null && _super.apply(this, arguments) || this;\r\n\t }\r\n\t Road.prototype.setup = function () {\r\n\t this.lastPos = 0;\r\n\t this.addPier();\r\n\t };\r\n\t Road.prototype.getFristPier = function () {\r\n\t return this.getChildAt(0).width;\r\n\t };\r\n\t Road.prototype.getDistance = function () {\r\n\t var distance = [];\r\n\t var pier1 = this.getChildAt(0);\r\n\t var pier2 = this.getChildAt(1);\r\n\t distance.push(pier2.x - pier1.x);\r\n\t distance.push(pier2.width);\r\n\t return distance;\r\n\t };\r\n\t Road.prototype.addPier = function () {\r\n\t while (this.children.length < props.pierCount + 1) {\r\n\t var childrenNum = this.children.length;\r\n\t var randomPos = this.makeRandomFloat(props.pierMaxDistance, props.pierMinDistance);\r\n\t var pier = ObjectPool.getObject('pier');\r\n\t this.addChild(pier);\r\n\t if (childrenNum == 0) {\r\n\t pier.x = 0;\r\n\t }\r\n\t else {\r\n\t pier.x = this.lastPos + randomPos;\r\n\t }\r\n\t this.lastPos = pier.x;\r\n\t }\r\n\t };\r\n\t Road.prototype.moveAddPier = function () {\r\n\t var randomPos = this.makeRandomFloat(props.pierMaxDistance, props.pierMinDistance);\r\n\t var pier = ObjectPool.getObject('pier');\r\n\t var lastChild = this.getChildAt(this.children.length - 1);\r\n\t pier.x = lastChild.x + randomPos;\r\n\t this.addChild(pier);\r\n\t };\r\n\t Road.prototype.makeRandomFloat = function (max, min) {\r\n\t if (min === void 0) { min = 0; }\r\n\t return Math.random() * (max - min) + min;\r\n\t };\r\n\t Road.prototype.setViewport = function () {\r\n\t var _this = this;\r\n\t var tmpMovepos = this.getMovePos();\r\n\t this.children.forEach(function (item, index) {\r\n\t _this.playTween(item, index, tmpMovepos);\r\n\t });\r\n\t };\r\n\t Road.prototype.getMovePos = function () {\r\n\t var movePos = this.getChildAt(1);\r\n\t return movePos.x;\r\n\t };\r\n\t Road.prototype.playTween = function (item, index, tmpMovepos) {\r\n\t var _this = this;\r\n\t engine.Tween.get(item, { loop: false })\r\n\t .to({ x: item.x - tmpMovepos }, props.pierMoveTime)\r\n\t .call(function () {\r\n\t if (_this.getChildIndex(item) == 0) {\r\n\t engine.Tween.removeTweens(item);\r\n\t _this.removeChild(item);\r\n\t ObjectPool.recycleObject('pier', item);\r\n\t }\r\n\t if (index == 0) {\r\n\t _this.moveAddPier();\r\n\t }\r\n\t });\r\n\t };\r\n\t Road.prototype.getStartGold = function (index, isClose) {\r\n\t if (isClose === void 0) { isClose = true; }\r\n\t var tmpNode = this.getChildAt(index);\r\n\t var haveGold = tmpNode.haveGold;\r\n\t if (haveGold && isClose) {\r\n\t tmpNode.closeGold();\r\n\t }\r\n\t return haveGold;\r\n\t };\r\n\t Road.prototype.setGuide = function () {\r\n\t var tmpNode = this.getChildAt(1);\r\n\t if (!tmpNode.haveGold) {\r\n\t tmpNode.children.forEach(function (item) {\r\n\t if (item.name == 'gold') {\r\n\t item.visible = true;\r\n\t }\r\n\t });\r\n\t tmpNode.haveGold = true;\r\n\t }\r\n\t };\r\n\t return Road;\r\n\t}(engine.Container));\n\n\tfunction getTexture(uuid) {\r\n\t return engine.Texture.from(getAssetByUUID(uuid).uuid);\r\n\t}\r\n\tfunction getTextureByName(name) {\r\n\t return getTexture(engine.getAssetByName(name).uuid);\r\n\t}\r\n\tfunction getStage() {\r\n\t return engine.gameStage.stage;\r\n\t}\r\n\tfunction createSvga(name) {\r\n\t var inst = new svga.Svga();\r\n\t inst.source = engine.getAssetByName(name).uuid;\r\n\t return inst;\r\n\t}\n\n\tvar GuideLayer = (function (_super) {\r\n\t tslib.__extends(GuideLayer, _super);\r\n\t function GuideLayer() {\r\n\t var _this = _super.call(this) || this;\r\n\t _this._canClear = [];\r\n\t _this.setup();\r\n\t return _this;\r\n\t }\r\n\t GuideLayer.prototype.setup = function () {\r\n\t };\r\n\t GuideLayer.prototype.show = function (id, options, callback) {\r\n\t this.visible = true;\r\n\t this._callBack = callback ? callback : null;\r\n\t if (!this.guideMask) {\r\n\t this._options = options;\r\n\t var _a = this.stage, width = _a.width, height = _a.height;\r\n\t var guideMask = this.guideMask = new engine.Container();\r\n\t var guideHole = this._guideHole = new engine.Image(getTextureByName('guide'));\r\n\t guideHole.x = options.x;\r\n\t guideHole.y = options.y;\r\n\t guideHole.width = 250;\r\n\t guideHole.height = 250;\r\n\t guideHole.name = 'guideHole';\r\n\t guideMask.addChild(guideHole);\r\n\t this.createRect(guideMask, 0, 0, width, guideHole.y);\r\n\t this.createRect(guideMask, 0, guideHole.y, guideHole.x, guideHole.height);\r\n\t this.createRect(guideMask, guideHole.x + guideHole.width, guideHole.y, width - guideHole.x - guideHole.width, guideHole.height);\r\n\t this.createRect(guideMask, 0, guideHole.y + guideHole.height, width, height - guideHole.y - guideHole.height);\r\n\t this.guideStep(id);\r\n\t var label = this.label = new engine.Label();\r\n\t label.fillColor = 'white';\r\n\t label.size = 30;\r\n\t label.text = options.guideText;\r\n\t label.x = (width - label.width) / 2;\r\n\t label.y = guideHole.y + guideHole.height + 50;\r\n\t label.textAlign = engine.TEXT_ALIGN.CENTER;\r\n\t label.name = 'labHint';\r\n\t guideMask.addChild(label);\r\n\t this.addChild(guideMask);\r\n\t }\r\n\t this.once(engine.MouseEvent.CLICK, function () {\r\n\t this.removeChild(this.guideMask);\r\n\t this.guideMask = null;\r\n\t if (this._callBack) {\r\n\t this._callBack();\r\n\t }\r\n\t }, this);\r\n\t };\r\n\t GuideLayer.prototype.createRect = function (container, x, y, width, height) {\r\n\t var rect = new engine.Rect();\r\n\t rect.x = x;\r\n\t rect.y = y;\r\n\t rect.width = width;\r\n\t rect.height = height;\r\n\t rect.fillColor = 'black';\r\n\t rect.alpha = 0.7;\r\n\t container.addChild(rect);\r\n\t };\r\n\t GuideLayer.prototype.guideStep = function (id) {\r\n\t if (id == 1) {\r\n\t var guideHand = new engine.Image(getTextureByName('guideHand'));\r\n\t guideHand.x = this._options.x + 300;\r\n\t guideHand.y = this._options.y + 100;\r\n\t this.guideMask.addChild(guideHand);\r\n\t var rect = new engine.Rect();\r\n\t rect.x = this._options.x + 200;\r\n\t rect.y = this._options.y - 15;\r\n\t rect.width = props.strutWidth;\r\n\t rect.height = 200;\r\n\t rect.fillColor = props.strutColor;\r\n\t this.guideMask.addChild(rect);\r\n\t this._canClear.push(guideHand);\r\n\t this._canClear.push(rect);\r\n\t }\r\n\t if (id == 2) {\r\n\t var know = new engine.Image(getTextureByName('know'));\r\n\t know.x = (this.stage.width - know.width) / 2;\r\n\t know.y = this._options.y + 400;\r\n\t this.guideMask.addChild(know);\r\n\t this._canClear.push(know);\r\n\t }\r\n\t };\r\n\t return GuideLayer;\r\n\t}(engine.Container));\n\n\tvar LoopComponent = (function (_super) {\r\n\t tslib.__extends(LoopComponent, _super);\r\n\t function LoopComponent() {\r\n\t var _this = _super.call(this) || this;\r\n\t _this.onceInfo = { width: 0, height: 0, count: 0 };\r\n\t _this.loopInfo = { width: 0, height: 0, count: 0 };\r\n\t _this.parts = [];\r\n\t return _this;\r\n\t }\r\n\t LoopComponent.prototype.setup = function (parts, info) {\r\n\t var _this = this;\r\n\t parts.forEach(function (item, index) {\r\n\t var part;\r\n\t if (typeof item == 'string') {\r\n\t part = new engine.Sprite(getTextureByName(item));\r\n\t }\r\n\t else if (item instanceof engine.Texture) {\r\n\t part = new engine.Sprite(item);\r\n\t }\r\n\t else {\r\n\t part = item;\r\n\t }\r\n\t _this.addChild(part);\r\n\t _this.parts.push(part);\r\n\t if (index == 0) {\r\n\t info.width = part.width;\r\n\t info.height = part.height;\r\n\t }\r\n\t });\r\n\t info.count = parts.length;\r\n\t this.setViewport(0, 0);\r\n\t };\r\n\t LoopComponent.prototype.changeBg = function (changName) {\r\n\t this.parts.forEach(function (item, index) {\r\n\t item.texture = getTextureByName(changName);\r\n\t });\r\n\t };\r\n\t LoopComponent.prototype.setupLoop = function (resArr) {\r\n\t this.setup(resArr, this.loopInfo);\r\n\t };\r\n\t LoopComponent.prototype.setViewport = function (x, y) {\r\n\t if (y === void 0) { y = 0; }\r\n\t var sizeField = y == 0 ? 'width' : 'height';\r\n\t var posField = y == 0 ? 'x' : 'y';\r\n\t var pos = y == 0 ? x : y;\r\n\t var index;\r\n\t var onceSize = this.onceInfo[sizeField];\r\n\t var onceCount = this.onceInfo.count;\r\n\t var loopCount = this.loopInfo.count;\r\n\t var loopSize = this.loopInfo[sizeField];\r\n\t index = onceSize == 0 ? -1 : Math.floor(pos / onceSize);\r\n\t if (index < 0 || index >= onceCount) {\r\n\t var loopIndex = Math.floor((pos - onceCount * onceSize) / this.loopInfo[sizeField]);\r\n\t index = onceCount + loopIndex;\r\n\t }\r\n\t var formerIndex = index < onceCount ? index : (index) % loopCount + onceCount;\r\n\t var latterIndex = index < onceCount ? index + 1 : (index - onceCount + 1) % loopCount + onceCount;\r\n\t var former = this.parts[formerIndex];\r\n\t var latter = this.parts[latterIndex];\r\n\t if (!former || !latter) {\r\n\t console.log(formerIndex, latterIndex);\r\n\t }\r\n\t former[posField] = -(pos - loopSize * (index < onceCount ? index : index - onceCount) - (index < onceCount ? 0 : onceCount * onceSize));\r\n\t latter[posField] = former.x + (index < onceCount ? onceSize : loopSize);\r\n\t };\r\n\t return LoopComponent;\r\n\t}(engine.Container));\n\n\tvar Background = (function (_super) {\r\n\t tslib.__extends(Background, _super);\r\n\t function Background() {\r\n\t var _this = _super !== null && _super.apply(this, arguments) || this;\r\n\t _this.partResHHL = ['hhl_after', 'hhl_front'];\r\n\t _this.partResHB = ['hb_after', 'hb_front'];\r\n\t _this.partResWH = ['wh_after', 'wh_front'];\r\n\t _this.speeds = [];\r\n\t _this.resArray = [];\r\n\t _this.frameMovePos = 0;\r\n\t return _this;\r\n\t }\r\n\t Background.prototype.initBg = function () {\r\n\t this.sumMovePos = 0;\r\n\t this.speeds.push(props.afterBGMoveSpeed);\r\n\t this.speeds.push(props.frontBGMoveSpeed);\r\n\t var bottomBg = new engine.Rect();\r\n\t bottomBg.x = 0;\r\n\t bottomBg.y = 0;\r\n\t bottomBg.width = getStage().width;\r\n\t bottomBg.height = 0;\r\n\t bottomBg.fillColor = 0x75c9f5;\r\n\t this.addChild(bottomBg);\r\n\t this.resArray.push(this.partResHHL);\r\n\t this.resArray.push(this.partResHB);\r\n\t this.resArray.push(this.partResWH);\r\n\t this._bgIndex = 0;\r\n\t var parts = [];\r\n\t for (var i = 0; i < 2; i++) {\r\n\t var part = new LoopComponent();\r\n\t part.setupLoop([\r\n\t this.resArray[0][i],\r\n\t this.resArray[0][i],\r\n\t ]);\r\n\t parts.push(part);\r\n\t this.addChild(part);\r\n\t }\r\n\t parts[1].y = 200;\r\n\t };\r\n\t Background.prototype.setViewport = function (pos) {\r\n\t this.needFrameSum = (props.pierMoveTime / 1000) * 60;\r\n\t this.frameMovePos = pos / this.needFrameSum;\r\n\t this.frameIndex = 0;\r\n\t this.addEventListener(engine.Event.ENTER_FRAME, this.frameBack, this);\r\n\t };\r\n\t Background.prototype.frameBack = function () {\r\n\t if (this.frameIndex < this.needFrameSum) {\r\n\t for (var i = 0; i < 2; i++) {\r\n\t var part = this.getChildAt(i + 1);\r\n\t var speed = this.speeds[i];\r\n\t var tmpPos = ((this.frameMovePos * this.frameIndex) + this.sumMovePos) * speed;\r\n\t part.setViewport(tmpPos);\r\n\t }\r\n\t this.frameIndex++;\r\n\t }\r\n\t else {\r\n\t this.sumMovePos += this.frameMovePos * this.needFrameSum;\r\n\t this.frameIndex = 0;\r\n\t this.removeEventListener(engine.Event.ENTER_FRAME, this.frameBack, this);\r\n\t }\r\n\t };\r\n\t Background.prototype.changeBg = function (index) {\r\n\t for (var i = 0; i < 2; i++) {\r\n\t var part = this.getChildAt(i + 1);\r\n\t part.changeBg(this.resArray[index][i]);\r\n\t if (i == 1 && index == 1) {\r\n\t part.y = 400;\r\n\t }\r\n\t if (i == 1 && index == 2) {\r\n\t part.y = 250;\r\n\t }\r\n\t }\r\n\t this._bgIndex = index;\r\n\t };\r\n\t Background.prototype.getBgIndex = function () {\r\n\t return this._bgIndex;\r\n\t };\r\n\t return Background;\r\n\t}(engine.Container));\n\n\tvar Pier = (function (_super) {\r\n\t tslib.__extends(Pier, _super);\r\n\t function Pier() {\r\n\t var _this = _super.call(this) || this;\r\n\t _this.bmp = new engine.Sprite();\r\n\t _this.addChild(_this.bmp);\r\n\t return _this;\r\n\t }\r\n\t Pier.prototype.init = function () {\r\n\t var bmp = this.bmp;\r\n\t bmp.alpha = 1;\r\n\t bmp.texture = getTextureByName('pier');\r\n\t bmp.x = 0;\r\n\t bmp.y = bmp.height;\r\n\t if (this.children.length < 2) {\r\n\t var gold = new engine.Sprite();\r\n\t gold.texture = getTextureByName('gold');\r\n\t gold.name = 'gold';\r\n\t this.addChild(gold);\r\n\t }\r\n\t this.setGoldPosX(bmp);\r\n\t this.setShowGold();\r\n\t };\r\n\t Pier.prototype.setShowGold = function () {\r\n\t var nodeGold = this.getChildByName('gold');\r\n\t var randomWard = Math.random();\r\n\t nodeGold.alpha = 1;\r\n\t var isShow = randomWard < props.reward ? true : false;\r\n\t nodeGold.visible = isShow;\r\n\t this.haveGold = isShow;\r\n\t };\r\n\t Pier.prototype.setGoldPosX = function (bmp) {\r\n\t var nodeGold = this.getChildByName('gold');\r\n\t var pos = bmp.width / 2 - nodeGold.width / 2;\r\n\t nodeGold.x = pos;\r\n\t nodeGold.y = bmp.height - nodeGold.height - 50;\r\n\t nodeGold.visible = false;\r\n\t };\r\n\t Pier.prototype.closeGold = function () {\r\n\t var _this = this;\r\n\t this.children.forEach(function (item) {\r\n\t if (item.name == 'gold') {\r\n\t item.anchorX = item.width / 2;\r\n\t item.anchorY = item.height / 2;\r\n\t engine.Tween.get(item, { loop: false })\r\n\t .to({ scaleX: 2.5, scaleY: 2.5 }, 200, engine.Ease.cubicOut)\r\n\t .to({ scaleX: 1, scaleY: 1, alpha: 0 }, 200, engine.Ease.cubicIn)\r\n\t .call(function () {\r\n\t item.visible = false;\r\n\t _this.haveGold = false;\r\n\t });\r\n\t }\r\n\t });\r\n\t };\r\n\t return Pier;\r\n\t}(engine.Container));\n\n\tvar Player = (function (_super) {\r\n\t tslib.__extends(Player, _super);\r\n\t function Player() {\r\n\t return _super !== null && _super.apply(this, arguments) || this;\r\n\t }\r\n\t Player.prototype.initPlayer = function (pierWidth) {\r\n\t this.pierWidth = pierWidth;\r\n\t this._container = new engine.Container();\r\n\t this.addChild(this._container);\r\n\t this.playerNode = createSvga('walk');\r\n\t this._container.addChild(this.playerNode);\r\n\t this.playerNode.y = 675;\r\n\t this.playerNode.x = pierWidth / 2 - 80;\r\n\t this.playerNode.play();\r\n\t };\r\n\t Player.prototype.revive = function () {\r\n\t this._container.x = 0;\r\n\t this._container.y = 0;\r\n\t this.playerNode.x = this.pierWidth / 2 - 80;\r\n\t this.playerNode.y = 675;\r\n\t };\r\n\t Player.prototype.setViewport = function (pos, callBack, pierWidth) {\r\n\t var tmpPos = 0;\r\n\t var isSuccess = false;\r\n\t if (!pierWidth) {\r\n\t tmpPos = pos;\r\n\t isSuccess = true;\r\n\t }\r\n\t else {\r\n\t tmpPos = pierWidth - this.playerNode.x + pos - 60;\r\n\t }\r\n\t this.playGoTween(tmpPos, callBack, isSuccess);\r\n\t };\r\n\t Player.prototype.playGoTween = function (pos, callBack, isSuccess) {\r\n\t var _this = this;\r\n\t engine.Tween.get(this._container, { loop: false })\r\n\t .to({ x: pos }, props.playerMoveSpeed)\r\n\t .call(function () {\r\n\t engine.Tween.removeTweens(_this._container);\r\n\t if (isSuccess) {\r\n\t if (callBack) {\r\n\t callBack();\r\n\t }\r\n\t }\r\n\t else {\r\n\t _this.playDropTween(callBack);\r\n\t }\r\n\t });\r\n\t };\r\n\t Player.prototype.playDropTween = function (callBack) {\r\n\t var _this = this;\r\n\t engine.Tween.get(this._container, { loop: false })\r\n\t .to({ y: 2000 }, 1000)\r\n\t .call(function () {\r\n\t engine.Tween.removeTweens(_this._container);\r\n\t if (callBack) {\r\n\t callBack();\r\n\t }\r\n\t });\r\n\t };\r\n\t Player.prototype.setBackViewport = function (callBack) {\r\n\t var _this = this;\r\n\t engine.Tween.get(this._container, { loop: false })\r\n\t .to({ x: 0 }, props.pierMoveTime)\r\n\t .call(function () {\r\n\t engine.Tween.removeTweens(_this._container);\r\n\t if (callBack) {\r\n\t callBack();\r\n\t }\r\n\t });\r\n\t };\r\n\t return Player;\r\n\t}(engine.Container));\n\n\tvar Strut = (function (_super) {\r\n\t tslib.__extends(Strut, _super);\r\n\t function Strut() {\r\n\t return _super !== null && _super.apply(this, arguments) || this;\r\n\t }\r\n\t Strut.prototype.init = function () {\r\n\t this._strut = new engine.Rect();\r\n\t this.addChild(this._strut);\r\n\t this._strut.width = props.strutWidth;\r\n\t this._strut.y = 833;\r\n\t this._strut.fillColor = props.strutColor;\r\n\t this._strut.rotation = 180;\r\n\t };\r\n\t Strut.prototype.onMouseDown = function (pierWidth, distance, callBack) {\r\n\t this._strut.x = pierWidth - 60;\r\n\t this._distance = distance;\r\n\t this._callBack = callBack;\r\n\t this._strut.visible = true;\r\n\t this.addEventListener(engine.Event.ENTER_FRAME, this.frameStrut, this);\r\n\t };\r\n\t Strut.prototype.onMouseUp = function () {\r\n\t var _this = this;\r\n\t this.removeEventListener(engine.Event.ENTER_FRAME, this.frameStrut, this);\r\n\t setTimeout(function () {\r\n\t _this.strutRotation();\r\n\t }, 200);\r\n\t };\r\n\t Strut.prototype.strutRotation = function () {\r\n\t var _this = this;\r\n\t engine.Tween.get(this._strut, { loop: false })\r\n\t .to({ rotation: 270 }, props.strutRotationSpeed)\r\n\t .call(function () {\r\n\t _this.judgeResult();\r\n\t engine.Tween.removeTweens(_this._strut);\r\n\t });\r\n\t };\r\n\t Strut.prototype.judgeResult = function () {\r\n\t var isSuccess = false;\r\n\t if (this._distance[0] - this._distance[1] + 100 <= this._strut.height && this._strut.height <= this._distance[0] + 20) {\r\n\t isSuccess = true;\r\n\t }\r\n\t if (this._callBack) {\r\n\t this._callBack(isSuccess);\r\n\t }\r\n\t };\r\n\t Strut.prototype.frameStrut = function () {\r\n\t if (this._strut.height < 1000) {\r\n\t this._strut.height += props.strutUpSpeed;\r\n\t }\r\n\t };\r\n\t Strut.prototype.rest = function () {\r\n\t this._strut.width = props.strutWidth;\r\n\t this._strut.y = 833;\r\n\t this._strut.fillColor = props.strutColor;\r\n\t this._strut.rotation = 180;\r\n\t this._strut.height = 0;\r\n\t this._strut.visible = false;\r\n\t };\r\n\t Strut.prototype.getStrutHeight = function () {\r\n\t var distance = this._strut.height > 1000 ? 1000 : this._strut.height;\r\n\t return distance;\r\n\t };\r\n\t return Strut;\r\n\t}(engine.Container));\n\n\tvar ScoreLabel = (function (_super) {\r\n\t tslib.__extends(ScoreLabel, _super);\r\n\t function ScoreLabel() {\r\n\t return _super !== null && _super.apply(this, arguments) || this;\r\n\t }\r\n\t ScoreLabel.prototype.updateScore = function (score, animation) {\r\n\t if (animation === void 0) { animation = true; }\r\n\t this._value = score;\r\n\t if (animation && this._tmp) {\r\n\t this.animationUpdate();\r\n\t }\r\n\t else {\r\n\t this.updateLocal(score);\r\n\t }\r\n\t };\r\n\t ScoreLabel.prototype.animationUpdate = function () {\r\n\t var _this = this;\r\n\t var tmpInterval = setInterval(function () {\r\n\t _this._tmp += 1;\r\n\t if (_this._tmp <= _this._value) {\r\n\t _this.text = _this._tmp;\r\n\t }\r\n\t else {\r\n\t _this._tmp = _this._value;\r\n\t clearInterval(tmpInterval);\r\n\t }\r\n\t }, 50);\r\n\t };\r\n\t ScoreLabel.prototype.updateLocal = function (v) {\r\n\t this._tmp = v;\r\n\t this.text = v;\r\n\t };\r\n\t return ScoreLabel;\r\n\t}(engine.Label));\n\n\tvar ObjectPool$1 = engine.ObjectPool;\r\n\tvar PoolName = 'pier';\r\n\tObjectPool$1.registerPool(PoolName, function () {\r\n\t return new Pier();\r\n\t}, function (item, data) {\r\n\t item.init();\r\n\t});\r\n\tvar GameView = (function (_super) {\r\n\t tslib.__extends(GameView, _super);\r\n\t function GameView() {\r\n\t var _this = _super.call(this) || this;\r\n\t _this.moveX = 0;\r\n\t _this.once(engine.Event.ADDED_TO_STAGE, _this.setup, _this);\r\n\t return _this;\r\n\t }\r\n\t GameView.prototype.setup = function () {\r\n\t if (this._hasSetup) {\r\n\t return;\r\n\t }\r\n\t this._hasSetup = true;\r\n\t this._backgroud = new Background();\r\n\t this.addChild(this._backgroud);\r\n\t this._backgroud.initBg();\r\n\t var road = this._road = new Road();\r\n\t this.addChild(road);\r\n\t road.setup();\r\n\t var pierWidth = this._road.getFristPier();\r\n\t var player = this._player = new Player();\r\n\t this.addChild(player);\r\n\t player.initPlayer(pierWidth);\r\n\t var strut = this._strut = new Strut();\r\n\t this.addChild(strut);\r\n\t strut.init();\r\n\t this._scoreContainer = new engine.Container();\r\n\t this.addChild(this._scoreContainer);\r\n\t this.initLabScore();\r\n\t };\r\n\t GameView.prototype.start = function (guide) {\r\n\t return tslib.__awaiter(this, void 0, void 0, function () {\r\n\t var initScore;\r\n\t return tslib.__generator(this, function (_a) {\r\n\t this._isTouchLayer = true;\r\n\t this._sumScore = 0;\r\n\t this._isMouseDown = false;\r\n\t this._guide = guide;\r\n\t initScore = this._road.getStartGold(0) ? props.goldScore : 0;\r\n\t this.updateScore(initScore);\r\n\t if (this._guide == '1') {\r\n\t this.setGuide();\r\n\t }\r\n\t else {\r\n\t this.initTouch();\r\n\t this.registerEvent();\r\n\t }\r\n\t return [2];\r\n\t });\r\n\t });\r\n\t };\r\n\t GameView.prototype.revive = function () {\r\n\t console.log(\"复活---------\");\r\n\t this._player.revive();\r\n\t this._isTouchLayer = true;\r\n\t this.closeStrut();\r\n\t };\r\n\t GameView.prototype.setGuide = function () {\r\n\t var _this = this;\r\n\t this._road.setGuide();\r\n\t var guideLayer = this.guideLayer = new GuideLayer();\r\n\t this.addChild(guideLayer);\r\n\t this.guideLayer.show(1, { x: 20, y: 650, guideText: props.guideText1 }, function () {\r\n\t var posX = _this._road.getMovePos();\r\n\t _this.guideLayer.show(2, { x: posX + 20, y: 620, guideText: props.guideText2 }, function () {\r\n\t _this.initTouch();\r\n\t _this.registerEvent();\r\n\t });\r\n\t });\r\n\t };\r\n\t GameView.prototype.initLabScore = function () {\r\n\t var scoreBg = new engine.Sprite(getTextureByName('scoreBg'));\r\n\t scoreBg.x = getStage().width / 2 - scoreBg.width / 2;\r\n\t scoreBg.y = 80;\r\n\t var scoreHint = new engine.Sprite(getTextureByName('scoreHint'));\r\n\t scoreHint.x = getStage().width / 2 - scoreHint.width / 2;\r\n\t scoreHint.y = 40;\r\n\t this._scoreContainer.addChild(scoreHint);\r\n\t this.labScore = new ScoreLabel();\r\n\t this.labScore.fillColor = 0xff7646;\r\n\t this.labScore.size = 70;\r\n\t this.labScore.width = getStage().width;\r\n\t this.labScore.height = scoreBg.height;\r\n\t this.labScore.textAlign = engine.TEXT_ALIGN.CENTER;\r\n\t this.labScore.x = 0;\r\n\t this.labScore.y = scoreBg.y + 10;\r\n\t this._scoreContainer.addChild(this.labScore);\r\n\t };\r\n\t GameView.prototype.registerEvent = function () {\r\n\t this._touchLayer.addEventListener(engine.MouseEvent.MOUSE_DOWN, this.onMouseDown, this);\r\n\t this._touchLayer.addEventListener(engine.MouseEvent.MOUSE_UP, this.onMouseUp, this);\r\n\t };\r\n\t GameView.prototype.removeListener = function () {\r\n\t this._touchLayer.removeEventListener(engine.MouseEvent.MOUSE_DOWN, this.onMouseDown, this);\r\n\t this._touchLayer.removeEventListener(engine.MouseEvent.MOUSE_UP, this.onMouseUp, this);\r\n\t };\r\n\t GameView.prototype.initTouch = function () {\r\n\t this._touchLayer = new engine.Rect();\r\n\t this.addChild(this._touchLayer);\r\n\t this._touchLayer.width = getStage().width;\r\n\t this._touchLayer.height = getStage().height;\r\n\t this._touchLayer.x = 0;\r\n\t this._touchLayer.y = 0;\r\n\t this._touchLayer.alpha = 0;\r\n\t this.testrevive = new engine.Label();\r\n\t this.addChild(this.testrevive);\r\n\t this.testrevive.size = 55;\r\n\t this.testrevive.text = \"复活\";\r\n\t this.testrevive.width = 500;\r\n\t this.testrevive.height = 200;\r\n\t this.testrevive.mouseEnabled = true;\r\n\t this.testrevive.addEventListener(engine.MouseEvent.CLICK, this.revive, this);\r\n\t };\r\n\t GameView.prototype.setScoreShow = function () {\r\n\t };\r\n\t GameView.prototype.onMouseDown = function () {\r\n\t if (this._isTouchLayer) {\r\n\t this._isMouseDown = true;\r\n\t this._strut.onMouseDown(this._road.getFristPier(), this._road.getDistance(), this.goCallBcak.bind(this));\r\n\t }\r\n\t };\r\n\t GameView.prototype.onMouseUp = function () {\r\n\t if (this._isTouchLayer && this._isMouseDown) {\r\n\t this._strut.onMouseUp();\r\n\t this._isMouseDown = false;\r\n\t this._isTouchLayer = false;\r\n\t }\r\n\t };\r\n\t GameView.prototype.goCallBcak = function (isSuccess) {\r\n\t var _this = this;\r\n\t if (isSuccess) {\r\n\t console.log('成功了');\r\n\t var movePos = this._road.getMovePos();\r\n\t if (this._road.getStartGold(1, false)) {\r\n\t this.updateScore(props.singleScore + props.goldScore);\r\n\t }\r\n\t else {\r\n\t this.updateScore(props.singleScore);\r\n\t }\r\n\t this._player.setViewport(movePos, this.complete.bind(this));\r\n\t }\r\n\t else {\r\n\t console.log('失败了');\r\n\t this._player.setViewport(this._strut.getStrutHeight(), function () {\r\n\t console.log('掉下去了');\r\n\t engine.globalEvent.dispatchEvent('dxbcyj-game-result', { score: _this._sumScore });\r\n\t }, this._road.getFristPier());\r\n\t }\r\n\t };\r\n\t GameView.prototype.complete = function () {\r\n\t var _this = this;\r\n\t this._road.getStartGold(1);\r\n\t var movePos = this._road.getMovePos();\r\n\t this._road.setViewport();\r\n\t this._backgroud.setViewport(movePos);\r\n\t this._player.setBackViewport(function () {\r\n\t _this._isTouchLayer = true;\r\n\t });\r\n\t this.closeStrut();\r\n\t };\r\n\t GameView.prototype.closeStrut = function () {\r\n\t this._strut.rest();\r\n\t };\r\n\t GameView.prototype.updateScore = function (score) {\r\n\t this._sumScore += score;\r\n\t if (0 <= this._sumScore && this._sumScore <= props.bgFristScore) {\r\n\t this.changeBg(0);\r\n\t }\r\n\t else if (props.bgFristScore < this._sumScore && this._sumScore <= props.bgSecondScore) {\r\n\t this.changeBg(1);\r\n\t }\r\n\t else {\r\n\t this.changeBg(2);\r\n\t }\r\n\t this.labScore.updateScore(this._sumScore);\r\n\t };\r\n\t GameView.prototype.getScore = function () {\r\n\t return this._sumScore;\r\n\t };\r\n\t GameView.prototype.changeBg = function (index) {\r\n\t if (this._backgroud.getBgIndex() != index) {\r\n\t this._backgroud.changeBg(index);\r\n\t }\r\n\t };\r\n\t return GameView;\r\n\t}(engine.Container));\n\n\tvar GameWrapper = (function (_super) {\r\n\t tslib.__extends(GameWrapper, _super);\r\n\t function GameWrapper() {\r\n\t var _this = _super.call(this) || this;\r\n\t engine.globalEvent.addEventListener('dxbcyj-game-start', _this.start, _this);\r\n\t engine.globalEvent.addEventListener('dxbcyj-game-revive', _this.revive);\r\n\t var gameView = _this._gameView = new GameView();\r\n\t _this.addChild(gameView);\r\n\t return _this;\r\n\t }\r\n\t GameWrapper.prototype.start = function (event) {\r\n\t this._gameView.start(event.data.guide);\r\n\t };\r\n\t GameWrapper.prototype.revive = function () {\r\n\t this._gameView.revive();\r\n\t };\r\n\t return GameWrapper;\r\n\t}(engine.Container));\n\n\tfunction index (props) {\r\n\t prepareProps();\r\n\t injectProps(props);\r\n\t var instance = new GameWrapper();\r\n\t return instance;\r\n\t}\n\n\treturn index;\n\n})));\n"
} }
{
"name": "拼图",
"desc": "拼图模块1.0",
"props": {
"MAX_COL": {
"alias": "图片分成几列",
"type": "number",
"default": 3
},
"MAX_ROW": {
"alias": "图片分成几行",
"type": "number",
"default": 4
},
"W": {
"alias": "图片的宽度",
"type": "number",
"default": 620
},
"H": {
"alias": "图片的高度",
"type": "number",
"default": 620
},
"OFFSET_X": {
"alias": "OFFSET_X",
"type": "number",
"default": 0
},
"OFFSET_Y": {
"alias": "OFFSET_Y",
"type": "number",
"default": 0
},
"GAP": {
"alias": "图片间隙",
"type": "number",
"default": 0
},
"GAME_TIME": {
"alias": "游戏时间",
"type": "number",
"default": 30
}
},
"assets": [
{
"name": "遮罩",
"url": "//yun.duiba.com.cn/aurora/assets/5b3e30496b2d9fdafb0cf3835fd6704ce10e45b4.png",
"uuid": "888",
"ext": ".png"
},
{
"name": "框3",
"url": "//yun.duiba.com.cn/aurora/assets/521e08c574bd76c7dcf708cd6f8c4906e3707f06.png",
"uuid": "kuang3",
"ext": ".png"
},
{
"name": "框4",
"url": "//yun.duiba.com.cn/aurora/assets/1c384d986504d5aabfffeb5125dc67e73ce1b539.png",
"uuid": "kuang4",
"ext": ".png"
},
{
"name": "testimg",
"url": "//yun.duiba.com.cn/aurora/assets/2628186c60c3b80013ae3178ff21a73ffbe71d43.jpg",
"uuid": "morentu",
"ext": ".jpg"
}
],
"events": {
"in": {
"pictures-initgame": {
"alias": "初始化",
"data": {
"gameUrls": [
"https://yun.duiba.com.cn/aurora/assets/1456b2a9d72e56f075abb29df99052d87a0f1e48.jpg",
"https://yun.duiba.com.cn/aurora/assets/61fd0754d7924305fd2851be86a480d71d2c2981.jpg",
"https://yun.duiba.com.cn/aurora/assets/6b70d7ec626f35f21347bf5bc3e61bedc44167be.jpg"
]
}
},
"pictures-start": {
"alias": "开始",
"data": {
"actidx": 1,
"rows": 3,
"cols": 3,
"gametime": 30
}
},
"pictures-luanxu": {
"alias": "乱序"
},
"pictures-pause": {
"alias": "停止"
},
"pictures-resume": {
"alias": "继续"
}
},
"out": {
"pictures-time-update": {
"alias": "倒计时更新",
"data": {
"time": "剩余时间"
}
},
"pictures-game-over": {
"alias": "游戏结束",
"data": {
"reason": "结束(1:成功,2失败)"
}
},
"pictures-load-complete": {
"alias": "图片加载完毕",
"data": {
"reason": "结束(1:成功,2失败)"
}
},
"pictures-time-passtime": {
"alias": "倒计时进度条",
"data": {
"passtime": 0
}
},
"pictures-time-initcomp": {
"alias": "倒计时进度条",
"data": {
"passtime": 0
}
}
}
},
"id": "pintu",
"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.pintu = factory(global.tslib));\n}(this, (function (tslib) { 'use strict';\n\n\tvar props = {};\r\n\tfunction prepareProps() {\r\n\t var metaProps = getProps();\r\n\t engine.injectProp(props, metaProps);\r\n\t}\r\n\tfunction injectProps(p) {\r\n\t engine.injectProp(props, p);\r\n\t}\r\n\t//# sourceMappingURL=props.js.map\n\n\tfunction getTexture(uuid) {\r\n\t return engine.Texture.from(getAssetByUUID(uuid).uuid);\r\n\t}\r\n\tfunction getTextureByName(name) {\r\n\t return getTexture(engine.getAssetByName(name).uuid);\r\n\t}\r\n\tfunction loadImageByUrl(url) {\r\n\t return tslib.__awaiter(this, void 0, void 0, function () {\r\n\t return tslib.__generator(this, function (_a) {\r\n\t try {\r\n\t return [2, new Promise(function (resolve) {\r\n\t var t1 = setTimeout(function () {\r\n\t return resolve(null);\r\n\t }, 2000);\r\n\t if (engine.TextureCache[url]) {\r\n\t clearTimeout(t1);\r\n\t resolve(engine.TextureCache[url]);\r\n\t }\r\n\t else {\r\n\t var t = engine.Texture.from(url);\r\n\t t.addEventListener(\"loaded\", function () { clearTimeout(t1); resolve(t); });\r\n\t }\r\n\t })];\r\n\t }\r\n\t catch (e) {\r\n\t return [2, null];\r\n\t }\r\n\t return [2];\r\n\t });\r\n\t });\r\n\t}\r\n\t//# sourceMappingURL=utils.js.map\n\n\tvar Tool = (function () {\r\n\t function Tool() {\r\n\t }\r\n\t Tool.getOnePic = function () {\r\n\t if (this.picPool.length > 0) {\r\n\t return this.picPool.shift();\r\n\t }\r\n\t else {\r\n\t var ipic = new engine.Container();\r\n\t var isprite = new engine.ScrollView();\r\n\t isprite.name = \"iscrollv\";\r\n\t var nsp = new engine.Sprite();\r\n\t nsp.name = \"isprite\";\r\n\t nsp.texture;\r\n\t isprite.addChild(nsp);\r\n\t ipic.addChild(isprite);\r\n\t isprite.mouseEnabled = false;\r\n\t nsp.mouseEnabled = false;\r\n\t return ipic;\r\n\t }\r\n\t };\r\n\t Tool.repushToPool = function (icont) {\r\n\t this.picPool.push(icont);\r\n\t };\r\n\t Tool.picPool = new Array();\r\n\t return Tool;\r\n\t}());\r\n\t//# sourceMappingURL=Tool.js.map\n\n\tvar qietu = (function (url, type1, rows, cols, parent) { return tslib.__awaiter(void 0, void 0, void 0, function () {\r\n\t var t, t1, setimgwid, mwid1, mhei1, picarr, picnames, startlix, addlix, startliy, addliy, twid1, thei1, r, startx, c, starty, nsprite, isprite, nsp, ispritename, e_1;\r\n\t return tslib.__generator(this, function (_a) {\r\n\t switch (_a.label) {\r\n\t case 0:\r\n\t _a.trys.push([0, 6, , 8]);\r\n\t t = void 0;\r\n\t if (!(type1 == 1)) return [3, 1];\r\n\t t = url;\r\n\t return [3, 5];\r\n\t case 1:\r\n\t if (!(type1 == 2)) return [3, 3];\r\n\t return [4, loadImageByUrl(url)];\r\n\t case 2:\r\n\t t1 = _a.sent();\r\n\t if (t1) {\r\n\t t = t1;\r\n\t }\r\n\t return [3, 5];\r\n\t case 3:\r\n\t if (!(type1 == 3)) return [3, 5];\r\n\t return [4, getTextureByName(\"testimg\")];\r\n\t case 4:\r\n\t t = (_a.sent());\r\n\t _a.label = 5;\r\n\t case 5:\r\n\t if (!t) {\r\n\t return [2, qietu(\"testimg\", 3, rows, cols)];\r\n\t }\r\n\t setimgwid = 612;\r\n\t mwid1 = setimgwid / rows;\r\n\t mhei1 = setimgwid / cols;\r\n\t picarr = {};\r\n\t picnames = [];\r\n\t startlix = 0;\r\n\t addlix = 1 / rows;\r\n\t startliy = 0;\r\n\t addliy = 1 / cols;\r\n\t twid1 = setimgwid;\r\n\t thei1 = setimgwid;\r\n\t for (r = 0; r < rows; r++) {\r\n\t startx = startlix + addlix * r;\r\n\t for (c = 0; c < cols; c++) {\r\n\t starty = startliy + addliy * c;\r\n\t nsprite = Tool.getOnePic();\r\n\t isprite = nsprite.getChildByName(\"iscrollv\");\r\n\t nsp = isprite.getChildByName(\"isprite\");\r\n\t nsp.texture = t;\r\n\t nsp.width = twid1;\r\n\t nsp.height = thei1;\r\n\t nsp.x = -starty * twid1;\r\n\t nsp.y = -startx * thei1;\r\n\t isprite.width = mwid1;\r\n\t isprite.height = mhei1;\r\n\t nsprite.width = mwid1;\r\n\t nsprite.height = mhei1;\r\n\t ispritename = \"pic_\" + c + \"_\" + r;\r\n\t nsprite.name = ispritename;\r\n\t picarr[ispritename] = nsprite;\r\n\t picnames.push(ispritename);\r\n\t }\r\n\t }\r\n\t return [2, {\r\n\t res: true,\r\n\t picarr: picarr,\r\n\t mwid: mwid1,\r\n\t mhei: mhei1,\r\n\t picnames: picnames\r\n\t }];\r\n\t case 6:\r\n\t e_1 = _a.sent();\r\n\t return [4, new Promise(function (res) {\r\n\t setTimeout(function () {\r\n\t res();\r\n\t }, 200);\r\n\t })];\r\n\t case 7:\r\n\t _a.sent();\r\n\t return [2, qietu(\"testimg\", 3, rows, cols)];\r\n\t case 8: return [2];\r\n\t }\r\n\t });\r\n\t}); });\r\n\t//# sourceMappingURL=qietu.js.map\n\n\tvar GameView = (function (_super) {\r\n\t tslib.__extends(GameView, _super);\r\n\t function GameView() {\r\n\t var _this = _super.call(this) || this;\r\n\t _this.ingame = false;\r\n\t _this.selectImgArr = [];\r\n\t _this.sucposData = {};\r\n\t _this.gameUrls = [];\r\n\t _this.gameTimes = [];\r\n\t _this.onegamePics = [];\r\n\t _this.movesteps = 0;\r\n\t _this.startime = 0;\r\n\t _this.once(engine.Event.ADDED_TO_STAGE, _this.initScene, _this);\r\n\t return _this;\r\n\t }\r\n\t GameView.prototype.initScene = function () {\r\n\t this.lineShape = new engine.Shape();\r\n\t this.selectimg3 = new engine.Image(getTextureByName(\"框3\"));\r\n\t this.selectimg4 = new engine.Image(getTextureByName(\"框4\"));\r\n\t this.selectimg3.mouseEnabled = false;\r\n\t this.selectimg4.mouseEnabled = false;\r\n\t this.dicont = new engine.Container();\r\n\t this.linecont = new engine.Container();\r\n\t this.blockcont = new engine.Container();\r\n\t this.addChild(this.dicont);\r\n\t this.addChild(this.linecont);\r\n\t this.addChild(this.blockcont);\r\n\t this.linecont.addChild(this.lineShape);\r\n\t engine.globalEvent.dispatchEvent(\"pictures-time-initcomp\", {});\r\n\t this.removeEventListener(engine.Event.ADDED_TO_STAGE, this.initScene, this);\r\n\t };\r\n\t GameView.prototype.initgame = function () {\r\n\t return tslib.__awaiter(this, void 0, void 0, function () {\r\n\t var l, lurl, lt;\r\n\t return tslib.__generator(this, function (_a) {\r\n\t switch (_a.label) {\r\n\t case 0:\r\n\t this.gameUrls = props.gameUrls || [\"https://yun.duiba.com.cn/db_games/activity/game/1596074071/resource/assets/ptimgs/28.jpg\", \"https://yun.duiba.com.cn/db_games/activity/game/1596074071/resource/assets/ptimgs/29.jpg\", \"https://yun.duiba.com.cn/db_games/activity/game/1596074071/resource/assets/ptimgs/30.jpg\"];\r\n\t this.gameTimes = props.gameTimes || [30, 60, 60];\r\n\t this.onegamePics = new Array();\r\n\t l = 0;\r\n\t _a.label = 1;\r\n\t case 1:\r\n\t if (!(l < this.gameUrls.length)) return [3, 4];\r\n\t lurl = this.gameUrls[l];\r\n\t return [4, loadImageByUrl(lurl)];\r\n\t case 2:\r\n\t lt = _a.sent();\r\n\t if (lt) {\r\n\t lt = lt;\r\n\t }\r\n\t else {\r\n\t lt = null;\r\n\t }\r\n\t this.onegamePics.push(lt);\r\n\t if (this.onegamePics.length == 1) {\r\n\t this.startfirst();\r\n\t }\r\n\t _a.label = 3;\r\n\t case 3:\r\n\t l++;\r\n\t return [3, 1];\r\n\t case 4:\r\n\t this.removeSelectImg();\r\n\t return [2];\r\n\t }\r\n\t });\r\n\t });\r\n\t };\r\n\t GameView.prototype.removeSelectImg = function () {\r\n\t if (this.selectimg3) {\r\n\t this.blockcont.removeChild(this.selectimg3);\r\n\t }\r\n\t if (this.selectimg4) {\r\n\t this.blockcont.removeChild(this.selectimg4);\r\n\t }\r\n\t };\r\n\t GameView.prototype.removeDiPics = function () {\r\n\t var nume = this.dicont.children.length;\r\n\t for (var i = nume - 1; i >= 0; i--) {\r\n\t var ichild = this.dicont.getChildAt(i);\r\n\t if (ichild) {\r\n\t ichild.removeEventListener(engine.MouseEvent.MOUSE_DOWN, this.touchPic, this);\r\n\t this.dicont.removeChild(ichild);\r\n\t Tool.repushToPool(ichild);\r\n\t }\r\n\t }\r\n\t };\r\n\t GameView.prototype.startfirst = function () {\r\n\t return tslib.__awaiter(this, void 0, void 0, function () {\r\n\t var actidx, tex, type1, result, res, picarr, mwid, mhei, picnames, gap, r, c, ipicx, ipicy, npicname, ipic, rl, cl;\r\n\t return tslib.__generator(this, function (_a) {\r\n\t switch (_a.label) {\r\n\t case 0:\r\n\t this.removeDiPics();\r\n\t this.movesteps = 0;\r\n\t this.startime = Date.now();\r\n\t this.removeSelectImg();\r\n\t actidx = 0;\r\n\t this.gametime = this.gameTimes[actidx];\r\n\t this.showtime = this.gameTimes[actidx];\r\n\t this.passtime = 0;\r\n\t engine.globalEvent.dispatchEvent(\"pictures-time-update\", {\r\n\t time: this.showtime,\r\n\t });\r\n\t engine.globalEvent.dispatchEvent(\"pictures-time-passtime\", {\r\n\t passtime: this.passtime\r\n\t });\r\n\t this.rows = 3;\r\n\t this.cols = 3;\r\n\t this.nselectimg = null;\r\n\t if (this.rows == 3) {\r\n\t this.nselectimg = this.selectimg3;\r\n\t }\r\n\t if (this.rows == 4) {\r\n\t this.nselectimg = this.selectimg4;\r\n\t }\r\n\t this.selectImgArr = new Array();\r\n\t this.sucposData = {};\r\n\t tex = this.onegamePics[actidx];\r\n\t type1 = 1;\r\n\t if (!tex) {\r\n\t tex = this.gameUrls[actidx];\r\n\t type1 = 3;\r\n\t }\r\n\t return [4, qietu(tex, type1, this.rows, this.cols, this.dicont)];\r\n\t case 1:\r\n\t result = _a.sent();\r\n\t res = result.res;\r\n\t if (res) {\r\n\t picarr = result.picarr;\r\n\t mwid = result.mwid;\r\n\t mhei = result.mhei;\r\n\t picnames = result.picnames;\r\n\t this.mwid = mwid;\r\n\t this.mhei = mhei;\r\n\t this.picarr = picarr;\r\n\t this.picnames = picnames;\r\n\t gap = 2;\r\n\t for (r = 0; r < this.rows; r++) {\r\n\t for (c = 0; c < this.cols; c++) {\r\n\t ipicx = mwid * c + gap;\r\n\t ipicy = mhei * r + gap;\r\n\t npicname = \"pic_\" + c + \"_\" + r;\r\n\t ipic = picarr[npicname];\r\n\t this.dicont.addChild(ipic);\r\n\t ipic.x = ipicx;\r\n\t ipic.y = ipicy;\r\n\t }\r\n\t }\r\n\t this.lineShape.clear();\r\n\t this.lineShape.beginStroke(0x0069df, 4, engine.LINE_CAP.BUTT, engine.LINE_JOIN.BEVEL, 100);\r\n\t this.lineShape.moveTo(0 + gap, 0 + gap);\r\n\t this.lineShape.lineTo(mhei * this.cols + gap, 0 + gap);\r\n\t this.lineShape.lineTo(mhei * this.cols + gap, mwid * this.rows + gap);\r\n\t this.lineShape.lineTo(0 + gap, mwid * this.rows + gap);\r\n\t this.lineShape.lineTo(0 + gap, 0 + gap);\r\n\t for (rl = 1; rl < this.rows; rl++) {\r\n\t this.lineShape.moveTo(0 + gap, rl * mhei + gap);\r\n\t this.lineShape.lineTo(mwid * this.cols + gap, rl * mhei + gap);\r\n\t }\r\n\t for (cl = 1; cl < this.cols; cl++) {\r\n\t this.lineShape.moveTo(cl * mwid + gap, 0 + gap);\r\n\t this.lineShape.lineTo(cl * mwid + gap, this.rows * mhei + gap);\r\n\t }\r\n\t this.lineShape.endStroke();\r\n\t engine.globalEvent.dispatchEvent(\"pictures-load-complete\");\r\n\t this.ticker && clearInterval(this.ticker);\r\n\t this.ticker = setInterval(this.update, 10);\r\n\t }\r\n\t else {\r\n\t console.error(\"图片处理失败\");\r\n\t }\r\n\t return [2];\r\n\t }\r\n\t });\r\n\t });\r\n\t };\r\n\t GameView.prototype.start = function () {\r\n\t return tslib.__awaiter(this, void 0, void 0, function () {\r\n\t var actidx, tex, type1, result, res, picarr, mwid, mhei, picnames, gap, r, c, ipicx, ipicy, npicname, ipic, rl, cl;\r\n\t return tslib.__generator(this, function (_a) {\r\n\t switch (_a.label) {\r\n\t case 0:\r\n\t this.removeDiPics();\r\n\t this.movesteps = 0;\r\n\t this.startime = Date.now();\r\n\t this.removeSelectImg();\r\n\t actidx = props.actidx;\r\n\t this.gametime = this.gameTimes[actidx];\r\n\t this.showtime = this.gameTimes[actidx];\r\n\t this.passtime = 0;\r\n\t engine.globalEvent.dispatchEvent(\"pictures-time-update\", {\r\n\t time: this.showtime,\r\n\t });\r\n\t engine.globalEvent.dispatchEvent(\"pictures-time-passtime\", {\r\n\t passtime: this.passtime\r\n\t });\r\n\t this.rows = props.rows;\r\n\t this.cols = props.cols;\r\n\t this.nselectimg = null;\r\n\t if (this.rows == 3) {\r\n\t this.nselectimg = this.selectimg3;\r\n\t }\r\n\t if (this.rows == 4) {\r\n\t this.nselectimg = this.selectimg4;\r\n\t }\r\n\t this.selectImgArr = new Array();\r\n\t this.sucposData = {};\r\n\t tex = this.onegamePics[actidx];\r\n\t type1 = 1;\r\n\t if (!tex) {\r\n\t tex = this.gameUrls[actidx];\r\n\t type1 = 3;\r\n\t }\r\n\t return [4, qietu(tex, type1, this.rows, this.cols, this.dicont)];\r\n\t case 1:\r\n\t result = _a.sent();\r\n\t res = result.res;\r\n\t if (res) {\r\n\t picarr = result.picarr;\r\n\t mwid = result.mwid;\r\n\t mhei = result.mhei;\r\n\t picnames = result.picnames;\r\n\t this.mwid = mwid;\r\n\t this.mhei = mhei;\r\n\t this.picarr = picarr;\r\n\t this.picnames = picnames;\r\n\t gap = 2;\r\n\t for (r = 0; r < this.rows; r++) {\r\n\t for (c = 0; c < this.cols; c++) {\r\n\t ipicx = mwid * c + gap;\r\n\t ipicy = mhei * r + gap;\r\n\t npicname = \"pic_\" + c + \"_\" + r;\r\n\t ipic = picarr[npicname];\r\n\t this.dicont.addChild(ipic);\r\n\t ipic.x = ipicx;\r\n\t ipic.y = ipicy;\r\n\t }\r\n\t }\r\n\t this.lineShape.clear();\r\n\t this.lineShape.beginStroke(0x0069df, 4, engine.LINE_CAP.BUTT, engine.LINE_JOIN.BEVEL, 100);\r\n\t this.lineShape.moveTo(0 + gap, 0 + gap);\r\n\t this.lineShape.lineTo(mhei * this.cols + gap, 0 + gap);\r\n\t this.lineShape.lineTo(mhei * this.cols + gap, mwid * this.rows + gap);\r\n\t this.lineShape.lineTo(0 + gap, mwid * this.rows + gap);\r\n\t this.lineShape.lineTo(0 + gap, 0 + gap);\r\n\t for (rl = 1; rl < this.rows; rl++) {\r\n\t this.lineShape.moveTo(0 + gap, rl * mhei + gap);\r\n\t this.lineShape.lineTo(mwid * this.cols + gap, rl * mhei + gap);\r\n\t }\r\n\t for (cl = 1; cl < this.cols; cl++) {\r\n\t this.lineShape.moveTo(cl * mwid + gap, 0 + gap);\r\n\t this.lineShape.lineTo(cl * mwid + gap, this.rows * mhei + gap);\r\n\t }\r\n\t this.lineShape.endStroke();\r\n\t this.ticker && clearInterval(this.ticker);\r\n\t this.ticker = setInterval(this.update, 10);\r\n\t }\r\n\t else {\r\n\t console.error(\"图片处理失败\");\r\n\t }\r\n\t return [2];\r\n\t }\r\n\t });\r\n\t });\r\n\t };\r\n\t GameView.prototype.luanxu = function () {\r\n\t var gap = 2;\r\n\t for (var r = 0; r < this.rows; r++) {\r\n\t for (var c = 0; c < this.cols; c++) {\r\n\t var ipicx = this.mwid * c + gap;\r\n\t var ipicy = this.mhei * r + gap;\r\n\t var npicname = \"pic_\" + c + \"_\" + r;\r\n\t this.sucposData[npicname] = r + \"_\" + c;\r\n\t var selidx = Math.floor(Math.random() * this.picnames.length);\r\n\t var ipicname = this.picnames[selidx];\r\n\t if (r == c && r != this.rows - 1) {\r\n\t while (ipicname == npicname) {\r\n\t selidx = Math.floor(Math.random() * this.picnames.length);\r\n\t ipicname = this.picnames[selidx];\r\n\t }\r\n\t }\r\n\t var ipic = this.picarr[ipicname];\r\n\t this.picnames.splice(selidx, 1);\r\n\t ipic.x = ipicx;\r\n\t ipic.y = ipicy;\r\n\t ipic[\"postr\"] = r + \"_\" + c;\r\n\t ipic.addEventListener(engine.MouseEvent.MOUSE_DOWN, this.touchPic, this);\r\n\t }\r\n\t }\r\n\t };\r\n\t GameView.prototype.pause = function () {\r\n\t this.ingame = false;\r\n\t };\r\n\t GameView.prototype.resume = function () {\r\n\t this.lastframetime = Date.now();\r\n\t this.ingame = true;\r\n\t };\r\n\t GameView.prototype.update = function () {\r\n\t var ntime = Date.now();\r\n\t if (!this.lastframetime) {\r\n\t this.lastframetime = ntime;\r\n\t return;\r\n\t }\r\n\t if (this.ingame) {\r\n\t var passtime = (ntime - this.lastframetime) / 1000;\r\n\t this.passtime += passtime;\r\n\t engine.globalEvent.dispatchEvent(\"pictures-time-passtime\", {\r\n\t passtime: this.passtime\r\n\t });\r\n\t var showtime1 = Math.round(this.gametime - this.passtime);\r\n\t if (this.showtime != showtime1) {\r\n\t this.showtime = showtime1;\r\n\t if (this.showtime <= 0) {\r\n\t this.showtime = 0;\r\n\t this.gameover(2);\r\n\t }\r\n\t engine.globalEvent.dispatchEvent(\"pictures-time-update\", {\r\n\t time: this.showtime\r\n\t });\r\n\t }\r\n\t }\r\n\t this.lastframetime = ntime;\r\n\t };\r\n\t GameView.prototype.touchPic = function (e) {\r\n\t if (!this.ingame) {\r\n\t return;\r\n\t }\r\n\t var selectname = e.target.name;\r\n\t var spx = e.target.x;\r\n\t var spy = e.target.y;\r\n\t var gap = 2;\r\n\t if (this.selectImgArr.length == 0) {\r\n\t if (this.nselectimg) {\r\n\t this.blockcont.addChild(this.nselectimg);\r\n\t this.nselectimg.x = spx - gap;\r\n\t this.nselectimg.y = spy - gap;\r\n\t }\r\n\t this.selectImgArr.push(selectname);\r\n\t }\r\n\t else if (this.selectImgArr.length == 1) {\r\n\t if (selectname == this.selectImgArr[0]) {\r\n\t if (this.nselectimg) {\r\n\t this.blockcont.removeChild(this.nselectimg);\r\n\t }\r\n\t this.selectImgArr = new Array();\r\n\t return;\r\n\t }\r\n\t else {\r\n\t this.selectImgArr.push(selectname);\r\n\t this.changeImgPos();\r\n\t }\r\n\t }\r\n\t };\r\n\t GameView.prototype.changeImgPos = function () {\r\n\t var img1name = this.selectImgArr[0];\r\n\t var img2name = this.selectImgArr[1];\r\n\t var img1 = this.dicont.getChildByName(img1name);\r\n\t var img2 = this.dicont.getChildByName(img2name);\r\n\t var imgpos1x = img1.x;\r\n\t var imgpos1y = img1.y;\r\n\t var imgpos2x = img2.x;\r\n\t var imgpos2y = img2.y;\r\n\t var imgpostr1 = img1.postr;\r\n\t var imgpostr2 = img2.postr;\r\n\t img1.x = imgpos2x;\r\n\t img1.y = imgpos2y;\r\n\t img1.postr = imgpostr2;\r\n\t img2.x = imgpos1x;\r\n\t img2.y = imgpos1y;\r\n\t img2.postr = imgpostr1;\r\n\t this.selectImgArr = new Array();\r\n\t this.movesteps += 1;\r\n\t if (this.nselectimg) {\r\n\t this.blockcont.removeChild(this.nselectimg);\r\n\t }\r\n\t var isuc = this.checkSuccess();\r\n\t if (isuc) {\r\n\t this.gameover(1);\r\n\t }\r\n\t };\r\n\t GameView.prototype.checkSuccess = function () {\r\n\t var isuc = true;\r\n\t for (var r = 0; r < this.rows; r++) {\r\n\t for (var c = 0; c < this.cols; c++) {\r\n\t var ipicname = \"pic_\" + c + \"_\" + r;\r\n\t var npicstr = r + \"_\" + c;\r\n\t var ipic = this.dicont.getChildByName(ipicname);\r\n\t var ipostr = ipic.postr;\r\n\t if (npicstr != ipostr) {\r\n\t isuc = false;\r\n\t break;\r\n\t }\r\n\t }\r\n\t }\r\n\t return isuc;\r\n\t };\r\n\t GameView.prototype.gameover = function (reason) {\r\n\t this.ingame = false;\r\n\t this.ticker && clearInterval(this.ticker);\r\n\t var ntime = Date.now();\r\n\t var gametime = ntime - this.startime;\r\n\t engine.globalEvent.dispatchEvent('pictures-game-over', {\r\n\t reason: reason,\r\n\t time: this.passtime,\r\n\t number: this.movesteps,\r\n\t gametime: gametime\r\n\t });\r\n\t };\r\n\t return GameView;\r\n\t}(engine.Container));\r\n\t//# sourceMappingURL=GameView.js.map\n\n\tvar GameWrapper = (function (_super) {\r\n\t tslib.__extends(GameWrapper, _super);\r\n\t function GameWrapper() {\r\n\t var _this = _super.call(this) || this;\r\n\t _this._gameView = new GameView();\r\n\t _this.addChild(_this._gameView);\r\n\t engine.globalEvent.addEventListener('pictures-initgame', _this.initgame, _this);\r\n\t engine.globalEvent.addEventListener('pictures-start', _this.start, _this);\r\n\t engine.globalEvent.addEventListener('pictures-luanxu', _this.luanxu, _this);\r\n\t engine.globalEvent.addEventListener('pictures-pause', _this.pause, _this);\r\n\t engine.globalEvent.addEventListener('pictures-resume', _this.resume, _this);\r\n\t return _this;\r\n\t }\r\n\t GameWrapper.prototype.initgame = function (event) {\r\n\t injectProps(event.data);\r\n\t this._gameView.initgame();\r\n\t };\r\n\t GameWrapper.prototype.start = function (event) {\r\n\t injectProps(event.data);\r\n\t this._gameView.start();\r\n\t };\r\n\t GameWrapper.prototype.luanxu = function () {\r\n\t this._gameView.luanxu();\r\n\t };\r\n\t GameWrapper.prototype.pause = function (event) {\r\n\t this._gameView.pause();\r\n\t };\r\n\t GameWrapper.prototype.resume = function (event) {\r\n\t this._gameView.resume();\r\n\t };\r\n\t return GameWrapper;\r\n\t}(engine.Container));\r\n\t//# sourceMappingURL=GameWrapper.js.map\n\n\tfunction index (props) {\r\n\t prepareProps();\r\n\t injectProps(props);\r\n\t var instance = new GameWrapper();\r\n\t return instance;\r\n\t}\r\n\t//# sourceMappingURL=index.js.map\n\n\treturn index;\n\n})));\n"
}
{
"name": "人保财险消消乐",
"desc": "消消乐模块",
"props": {
"threeEscore": {
"alias": "三消加分",
"type": "number",
"default": 1
},
"fourEscore": {
"alias": "四消加分",
"type": "number",
"default": 2
},
"moreEscore": {
"alias": "多消加分",
"type": "number",
"default": 3
}
},
"assets": [
{
"name": "底图",
"url": "//yun.duiba.com.cn/aurora/assets/d2b599cece087d5ab315cd1392f94139941280bb.png",
"uuid": "map",
"ext": ".png"
},
{
"name": "狗",
"url": "//yun.duiba.com.cn/aurora/assets/26780d2fb48d047e111857da9e82fe49b0d310a8.png",
"uuid": "gdog",
"ext": ".png"
},
{
"name": "鸟",
"url": "//yun.duiba.com.cn/aurora/assets/39a1a8865ca101d6fa29325bf1fc37c26190e382.png",
"uuid": "pbird",
"ext": ".png"
},
{
"name": "牛",
"url": "//yun.duiba.com.cn/aurora/assets/2e74dd7faab031f71e644dad340b4c83791b8bf0.png",
"uuid": "hniu",
"ext": ".png"
},
{
"name": "兔子",
"url": "//yun.duiba.com.cn/aurora/assets/6c4033a865bc6c73b680bc31d29de55ac347d397.png",
"uuid": "bribbit",
"ext": ".png"
},
{
"name": "猪",
"url": "//yun.duiba.com.cn/aurora/assets/c14e003bb3847bd7ab30eb6ba0915124f207bc31.png",
"uuid": "rpig",
"ext": ".png"
},
{
"name": "选中框",
"url": "//yun.duiba.com.cn/aurora/assets/c6ed5f3f94958e74fcbfc1da56e99795056fd75a.png",
"uuid": "selected",
"ext": ".png"
},
{
"name": "交换箭头",
"url": "//yun.duiba.com.cn/aurora/assets/438ca6e721eab32728aceaca5df0095e1387f340.png",
"uuid": "jiantou",
"ext": ".png"
},
{
"name": "手指动效",
"url": "//yun.duiba.com.cn/aurora/assets/038f2a14e1bfff4e2fc3f786152f03f56048d426.svga",
"uuid": "shouani",
"ext": ".svga"
},
{
"name": "消除动效",
"url": "//yun.duiba.com.cn/aurora/assets/5cde14d822eb85ac5e8bbcbae795e6107689543c.svga",
"uuid": "diseffect",
"ext": ".svga"
},
{
"name": "炸弹中心",
"url": "//yun.duiba.com.cn/aurora/assets/30795e057013978807e1a52351b6debbf034d174.png",
"uuid": "shine1",
"ext": ".png"
},
{
"name": "爆炸闪光",
"url": "//yun.duiba.com.cn/aurora/assets/e200b34d25020bd1d5430cf6f3e52c6866826076.png",
"uuid": "shine2",
"ext": ".png"
},
{
"name": "爆炸音效",
"url": "//yun.duiba.com.cn/aurora/assets/0223fe1440f0935aa3e9084ad7fa7808ec9f893c.mp3",
"uuid": "boomsound",
"ext": ".mp3"
},
{
"name": "消除音效",
"url": "//yun.duiba.com.cn/aurora/assets/becd6a758767b7bf75738dd5346f7ce84979c1fb.mp3",
"uuid": "elisound",
"ext": ".mp3"
}
],
"events": {
"in": {
"game-init": {
"alias": "初始化第一关",
"data": {}
},
"game-reset": {
"alias": "关卡通过重玩之类的重置关卡",
"data": {}
},
"game-start": {
"alias": "开始"
},
"game-pause": {
"alias": "暂停"
},
"game-resume": {
"alias": "继续"
},
"game-recordcomp": {
"alias": "记录完毕"
},
"game-newuserguide": {
"alias": "新手引导"
},
"game-usetool": {
"alias": "使用道具"
}
},
"out": {
"game-score-update": {
"alias": "分数更新",
"data": {
"score": "分数"
}
},
"game-time-update": {
"alias": "倒计时更新",
"data": {
"time": "剩余时间"
}
},
"game-over": {
"alias": "游戏结束",
"data": {
"score": "分数",
"reason": "结束原因(1:时间到了,2:过关)"
}
},
"game-record": {
"alias": "游戏记录",
"data": {
"score": "操作得分",
"seq": "操作步骤号",
"sptime": "操纵开始时间",
"eptime": "操作结束时间"
}
},
"game-touch": {
"alias": "按钮点击",
"data": {
"cantouch": ""
}
},
"game-guidecomplete": {
"alias": "游戏引导完毕",
"data": {}
},
"game-useboomafter": {
"alias": "炸弹使用完毕",
"data": {}
},
"game-useBoom": {
"alias": "使用炸弹==考虑性能使用上面的方式,直接使用",
"data": {}
}
}
},
"id": "rbcxiaoxiaole",
"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.rbcxiaoxiaole = factory(global.tslib));\n}(this, (function (tslib) { 'use strict';\n\n\tvar props = {};\r\n\tfunction prepareProps() {\r\n\t var metaProps = getProps();\r\n\t engine.injectProp(props, metaProps);\r\n\t}\r\n\tfunction injectProps(p) {\r\n\t engine.injectProp(props, p);\r\n\t}\r\n\t//# sourceMappingURL=props.js.map\n\n\tfunction getTexture(uuid) {\r\n\t return engine.Texture.from(getAssetByUUID(uuid).uuid);\r\n\t}\r\n\tfunction getTextureByName(name) {\r\n\t return getTexture(engine.getAssetByName(name).uuid);\r\n\t}\r\n\tfunction playSound(name) {\r\n\t engine.playSound(engine.getAssetByName(name).uuid, { keep: true });\r\n\t}\r\n\tfunction createSvga(name, anchorName) {\r\n\t var inst = new svga.Svga();\r\n\t inst.source = 'asset://' + engine.getAssetByName(name).uuid;\r\n\t return inst;\r\n\t}\r\n\t//# sourceMappingURL=utils.js.map\n\n\tvar Element = (function (_super) {\r\n\t tslib.__extends(Element, _super);\r\n\t function Element() {\r\n\t var _this = _super.call(this) || this;\r\n\t _this.width = MapData.itemsize;\r\n\t _this.height = MapData.itemsize;\r\n\t _this.anchorX = MapData.itemsize / 2;\r\n\t _this.eimage = new engine.Image();\r\n\t _this.addChild(_this.eimage);\r\n\t _this.touch = true;\r\n\t _this.addEventListener(engine.MouseEvent.MOUSE_DOWN, _this.selectele, _this);\r\n\t _this.addEventListener(engine.MouseEvent.MOUSE_MOVE, _this.changemove, _this);\r\n\t return _this;\r\n\t }\r\n\t Object.defineProperty(Element.prototype, \"touch\", {\r\n\t set: function (touch) {\r\n\t this.mouseEnabled = touch;\r\n\t this.mouseChildren = touch;\r\n\t },\r\n\t enumerable: true,\r\n\t configurable: true\r\n\t });\r\n\t Element.prototype.init = function (type) {\r\n\t this.anchorY = MapData.itemsize;\r\n\t this.scaleX = 1;\r\n\t this.scaleY = 1;\r\n\t this.alpha = 1;\r\n\t this.type = type;\r\n\t var ename = MapData.getEtypeImgName(type);\r\n\t this.eimage.texture = MapData.getEtypeImgTex(type);\r\n\t var imgwid = this.eimage.texture.width;\r\n\t var imghei = this.eimage.texture.height;\r\n\t this.eimage.x = (this.width - imgwid) / 2;\r\n\t this.eimage.y = (this.height - imghei) / 2;\r\n\t };\r\n\t Element.prototype.setrc = function (r, c) {\r\n\t this.inrow = r;\r\n\t this.incol = c;\r\n\t };\r\n\t Element.prototype.selectele = function (e) {\r\n\t engine.globalEvent.dispatchEvent(GameEvent.SelectEle, {\r\n\t r: this.inrow,\r\n\t c: this.incol,\r\n\t type: \"mouse_down\"\r\n\t });\r\n\t };\r\n\t Element.prototype.changemove = function (e) {\r\n\t engine.globalEvent.dispatchEvent(GameEvent.SelectEle, {\r\n\t r: this.inrow,\r\n\t c: this.incol,\r\n\t type: \"mouse_move\"\r\n\t });\r\n\t };\r\n\t Object.defineProperty(Element.prototype, \"factor\", {\r\n\t get: function () {\r\n\t return 0;\r\n\t },\r\n\t set: function (value) {\r\n\t this.x = (1 - value) * (1 - value) * this.p1x + 2 * value * (1 - value) * this.c1x + value * value * this.p2x;\r\n\t this.y = (1 - value) * (1 - value) * this.p1y + 2 * value * (1 - value) * this.c1y + value * value * this.p2y;\r\n\t var mscale = (1 - value) * (1 - value) * 1 + 2 * value * (1 - value) * 0.6 + value * value * 0.35;\r\n\t this.scaleX = mscale;\r\n\t this.scaleY = mscale;\r\n\t },\r\n\t enumerable: true,\r\n\t configurable: true\r\n\t });\r\n\t Element.prototype.flyToHome = function (tx, ty, time) {\r\n\t var _this = this;\r\n\t this.p1x = this.x;\r\n\t this.p1y = this.y + 20;\r\n\t this.c1x = (this.p1x - tx) / 4 + tx;\r\n\t this.c1y = ty;\r\n\t this.p2x = tx;\r\n\t this.p2y = ty;\r\n\t engine.Tween.removeTweens(this);\r\n\t engine.Tween.get(this).to({\r\n\t scaleX: 1.1,\r\n\t scaleY: 1.1\r\n\t }, 200)\r\n\t .to({\r\n\t scaleX: 1.1,\r\n\t scaleY: 0.88\r\n\t }, 100)\r\n\t .to({\r\n\t scaleX: 0.98,\r\n\t scaleY: 0.98,\r\n\t y: this.y + 20\r\n\t }, 100)\r\n\t .call(function () {\r\n\t _this.factor = 0;\r\n\t engine.Tween.get(_this).to({\r\n\t factor: 1\r\n\t }, 450)\r\n\t .call(function () {\r\n\t var nodeparent = _this.parent;\r\n\t nodeparent && nodeparent.removeChild(_this);\r\n\t MapData.recoverEle(_this, _this.type);\r\n\t });\r\n\t });\r\n\t };\r\n\t Element.prototype.changePos = function (tpos) {\r\n\t var _this = this;\r\n\t var nx = this.x;\r\n\t var ny = this.y;\r\n\t var tx = tpos[0];\r\n\t var ty = tpos[1];\r\n\t var dis = MapData.getDistance([nx, ny], tpos);\r\n\t var time = Math.ceil(dis / MapData.anispeed * 1000);\r\n\t engine.Tween.removeTweens(this);\r\n\t var pro = new Promise(function (res) {\r\n\t engine.Tween.get(_this, { loop: false }).to({\r\n\t x: tx,\r\n\t y: ty\r\n\t }, time)\r\n\t .call(function () {\r\n\t res();\r\n\t });\r\n\t });\r\n\t return pro;\r\n\t };\r\n\t return Element;\r\n\t}(engine.Container));\r\n\t//# sourceMappingURL=Element.js.map\n\n\tvar ElementType;\r\n\t(function (ElementType) {\r\n\t ElementType[ElementType[\"gdog\"] = 1] = \"gdog\";\r\n\t ElementType[ElementType[\"pbird\"] = 2] = \"pbird\";\r\n\t ElementType[ElementType[\"hniu\"] = 3] = \"hniu\";\r\n\t ElementType[ElementType[\"bribbit\"] = 4] = \"bribbit\";\r\n\t ElementType[ElementType[\"rpig\"] = 5] = \"rpig\";\r\n\t})(ElementType || (ElementType = {}));\r\n\tvar GameEvent;\r\n\t(function (GameEvent) {\r\n\t GameEvent[\"SelectEle\"] = \"SelectEle\";\r\n\t})(GameEvent || (GameEvent = {}));\r\n\tvar MapData = (function () {\r\n\t function MapData() {\r\n\t }\r\n\t MapData.getRy = function (r) {\r\n\t return this.paddingh + r * (this.itemsize + this.paddinghi);\r\n\t };\r\n\t MapData.getCx = function (c) {\r\n\t return this.paddingw + c * (this.itemsize + this.paddingwi);\r\n\t };\r\n\t MapData.getRCPos = function (r, c) {\r\n\t var x = this.getCx(c);\r\n\t var y = this.getRy(r);\r\n\t return [x, y];\r\n\t };\r\n\t MapData.adaptElePos = function (pos, wid, hei) {\r\n\t var x = pos[0] + (this.itemsize - wid) / 2;\r\n\t var y = pos[1] + (this.itemsize - hei) / 2;\r\n\t return [x, y];\r\n\t };\r\n\t MapData.getEtypeImgName = function (type) {\r\n\t var ename;\r\n\t switch (type) {\r\n\t case ElementType.gdog:\r\n\t ename = \"\";\r\n\t break;\r\n\t case ElementType.pbird:\r\n\t ename = \"\";\r\n\t break;\r\n\t case ElementType.hniu:\r\n\t ename = \"\";\r\n\t break;\r\n\t case ElementType.bribbit:\r\n\t ename = \"兔子\";\r\n\t break;\r\n\t case ElementType.rpig:\r\n\t ename = \"\";\r\n\t break;\r\n\t default:\r\n\t console.error(\"未定义元素类型\");\r\n\t break;\r\n\t }\r\n\t return ename;\r\n\t };\r\n\t MapData.getEtypeImgTex = function (type) {\r\n\t var etex;\r\n\t switch (type) {\r\n\t case ElementType.gdog:\r\n\t if (!this.gdotTex) {\r\n\t this.gdotTex = getTextureByName(\"\");\r\n\t console.log(\"新素材加载---狗\");\r\n\t }\r\n\t etex = this.gdotTex;\r\n\t break;\r\n\t case ElementType.pbird:\r\n\t if (!this.pbirdTex) {\r\n\t this.pbirdTex = getTextureByName(\"\");\r\n\t console.log(\"新素材加载---鸟\");\r\n\t }\r\n\t etex = this.pbirdTex;\r\n\t break;\r\n\t case ElementType.hniu:\r\n\t if (!this.hniuTex) {\r\n\t this.hniuTex = getTextureByName(\"\");\r\n\t console.log(\"新素材加载---牛\");\r\n\t }\r\n\t etex = this.hniuTex;\r\n\t break;\r\n\t case ElementType.bribbit:\r\n\t if (!this.bribbitTex) {\r\n\t this.bribbitTex = getTextureByName(\"兔子\");\r\n\t console.log(\"新素材加载---兔子\");\r\n\t }\r\n\t etex = this.bribbitTex;\r\n\t break;\r\n\t case ElementType.rpig:\r\n\t if (!this.rpigTex) {\r\n\t this.rpigTex = getTextureByName(\"\");\r\n\t console.log(\"新素材加载---猪\");\r\n\t }\r\n\t etex = this.rpigTex;\r\n\t break;\r\n\t default:\r\n\t console.error(\"未定义元素类型\");\r\n\t break;\r\n\t }\r\n\t return etex;\r\n\t };\r\n\t MapData.getRandEtype = function () {\r\n\t var eletypeArr = [ElementType.gdog, ElementType.pbird, ElementType.hniu, ElementType.bribbit, ElementType.rpig];\r\n\t var etype = eletypeArr[Math.floor(Math.random() * eletypeArr.length)];\r\n\t return etype;\r\n\t };\r\n\t MapData.initPoolEle = function () {\r\n\t this.gdotTex = getTextureByName(\"\");\r\n\t this.pbirdTex = getTextureByName(\"\");\r\n\t this.hniuTex = getTextureByName(\"\");\r\n\t this.bribbitTex = getTextureByName(\"兔子\");\r\n\t this.rpigTex = getTextureByName(\"\");\r\n\t var eletypes = [ElementType.gdog, ElementType.pbird, ElementType.hniu, ElementType.bribbit, ElementType.rpig];\r\n\t this.elePool[\"ele\"] = new Array();\r\n\t for (var i = 0; i < eletypes.length; i++) {\r\n\t for (var a = 0; a < 5; a++) {\r\n\t var iele = new Element();\r\n\t this.elePool[\"ele\"].push(iele);\r\n\t }\r\n\t }\r\n\t this.elePool[\"score\"] = new Array();\r\n\t for (var t = 0; t < 8; t++) {\r\n\t var itxt = new engine.Label();\r\n\t itxt.size = 66;\r\n\t itxt.width = 200;\r\n\t itxt.height = 70;\r\n\t itxt.textAlign = engine.TEXT_ALIGN.CENTER;\r\n\t itxt.verticalAlign = engine.VERTICAL_ALIGN.MIDDLE;\r\n\t itxt.anchorY = 35;\r\n\t itxt.anchorX = 100;\r\n\t itxt.bold = true;\r\n\t this.elePool[\"score\"].push(itxt);\r\n\t }\r\n\t };\r\n\t MapData.getOneEle = function (type) {\r\n\t var ele;\r\n\t if (this.elePool[\"ele\"]) {\r\n\t if (this.elePool[\"ele\"].length > 0) {\r\n\t ele = this.elePool[\"ele\"].shift();\r\n\t }\r\n\t }\r\n\t else {\r\n\t this.elePool[\"ele\"] = new Array();\r\n\t }\r\n\t if (!ele) {\r\n\t console.error(\"创建了新的了ele\");\r\n\t ele = new Element();\r\n\t }\r\n\t ele.name = \"ele_\" + this.eleidx;\r\n\t this.eleidx += 1;\r\n\t ele.init(type);\r\n\t return ele;\r\n\t };\r\n\t MapData.getOneTxt = function () {\r\n\t var itxt;\r\n\t if (this.elePool[\"score\"]) {\r\n\t if (this.elePool[\"score\"].length > 0) {\r\n\t itxt = this.elePool[\"score\"].shift();\r\n\t }\r\n\t }\r\n\t else {\r\n\t this.elePool[\"score\"] = new Array();\r\n\t }\r\n\t if (!itxt) {\r\n\t itxt = new engine.Label();\r\n\t itxt.size = 66;\r\n\t itxt.width = 200;\r\n\t itxt.height = 70;\r\n\t itxt.textAlign = engine.TEXT_ALIGN.CENTER;\r\n\t itxt.verticalAlign = engine.VERTICAL_ALIGN.MIDDLE;\r\n\t itxt.anchorY = 35;\r\n\t itxt.anchorX = 100;\r\n\t itxt.bold = true;\r\n\t }\r\n\t itxt.mouseEnabled = false;\r\n\t return itxt;\r\n\t };\r\n\t MapData.recoverEle = function (ele, type) {\r\n\t if (ele.eimage) {\r\n\t ele.eimage.texture = null;\r\n\t }\r\n\t this.elePool[\"ele\"].push(ele);\r\n\t };\r\n\t MapData.recoverTxt = function (txt) {\r\n\t this.elePool[\"score\"].push(txt);\r\n\t };\r\n\t MapData.getDistance = function (p1, p2) {\r\n\t var p1x = p1[0];\r\n\t var p1y = p1[1];\r\n\t var p2x = p2[0];\r\n\t var p2y = p2[1];\r\n\t var dis = Math.sqrt(Math.pow(p1x - p2x, 2) + Math.pow(p1y - p2y, 2));\r\n\t return dis;\r\n\t };\r\n\t MapData.itemsize = 116;\r\n\t MapData.paddingw = 7;\r\n\t MapData.paddingh = 7;\r\n\t MapData.paddingwi = 4;\r\n\t MapData.paddinghi = 2;\r\n\t MapData.row = 5;\r\n\t MapData.col = 5;\r\n\t MapData.posData = {};\r\n\t MapData.eleidx = 1;\r\n\t MapData.elePool = {};\r\n\t MapData.anispeed = 1000;\r\n\t MapData.levelData = [\r\n\t [\r\n\t [2, 3, 4, 5, 4],\r\n\t [4, 5, 3, 2, 4],\r\n\t [2, 5, 3, 5, 1],\r\n\t [3, 4, 4, 5, 3],\r\n\t [1, 5, 2, 1, 4],\r\n\t ],\r\n\t [\r\n\t [5, 2, 1, 2, 1],\r\n\t [3, 1, 4, 5, 4],\r\n\t [2, 5, 3, 5, 1],\r\n\t [5, 4, 1, 2, 3],\r\n\t [4, 1, 3, 1, 2],\r\n\t ],\r\n\t [\r\n\t [2, 4, 1, 5, 2],\r\n\t [2, 3, 4, 1, 3],\r\n\t [4, 1, 3, 2, 3],\r\n\t [3, 2, 1, 1, 4],\r\n\t [1, 1, 3, 5, 4],\r\n\t ],\r\n\t [\r\n\t [3, 2, 1, 4, 5],\r\n\t [2, 4, 1, 2, 3],\r\n\t [2, 3, 2, 3, 3],\r\n\t [4, 4, 5, 5, 4],\r\n\t [3, 3, 1, 2, 4],\r\n\t ],\r\n\t [\r\n\t [4, 5, 1, 2, 4],\r\n\t [3, 2, 3, 4, 2],\r\n\t [1, 5, 2, 3, 5],\r\n\t [4, 5, 5, 1, 3],\r\n\t [1, 2, 3, 2, 4],\r\n\t ]\r\n\t ];\r\n\t return MapData;\r\n\t}());\r\n\t//# sourceMappingURL=MapData.js.map\n\n\tvar boomAni = (function (_super) {\r\n\t tslib.__extends(boomAni, _super);\r\n\t function boomAni() {\r\n\t var _this = _super.call(this) || this;\r\n\t _this.once(engine.Event.ADDED_TO_STAGE, _this.setup, _this);\r\n\t return _this;\r\n\t }\r\n\t boomAni.prototype.setup = function () {\r\n\t this.boomimg = new engine.Image(getTextureByName(\"炸弹中心\"));\r\n\t this.boomimg.anchorX = 95;\r\n\t this.boomimg.anchorY = 108;\r\n\t this.boomimg.x = -32;\r\n\t this.boomimg.y = -47;\r\n\t var boomtex = getTextureByName(\"爆炸闪光\");\r\n\t var boomwid = boomtex.width;\r\n\t var boomhei = boomtex.height;\r\n\t this.hboomimg = new engine.Image();\r\n\t this.vboomimg = new engine.Image();\r\n\t this.hboomimg.texture = boomtex;\r\n\t this.vboomimg.texture = boomtex;\r\n\t this.hboomimg.width = boomwid;\r\n\t this.hboomimg.height = boomhei;\r\n\t this.hboomimg.anchorX = boomwid / 2;\r\n\t this.hboomimg.anchorY = boomhei / 2;\r\n\t this.hboomimg.y = -boomhei / 2 + 65;\r\n\t this.hboomimg.x = -20;\r\n\t this.vboomimg.width = boomwid;\r\n\t this.vboomimg.height = boomhei;\r\n\t this.vboomimg.anchorX = boomwid / 2;\r\n\t this.vboomimg.anchorY = boomhei / 2;\r\n\t this.vboomimg.rotation = 90;\r\n\t this.vboomimg.y = -boomhei / 2 + 65;\r\n\t this.vboomimg.x = -20;\r\n\t this.hboomimg.scaleY = 0.1;\r\n\t this.vboomimg.scaleY = 0.1;\r\n\t this.addChild(this.boomimg);\r\n\t this.addChild(this.hboomimg);\r\n\t this.addChild(this.vboomimg);\r\n\t this.mouseEnabled = false;\r\n\t this.mouseChildren = false;\r\n\t this.alpha = 0;\r\n\t };\r\n\t boomAni.prototype.playBoomAni = function () {\r\n\t var _this = this;\r\n\t this.alpha = 1;\r\n\t this.boomimg.scaleX = 0;\r\n\t this.boomimg.scaleY = 0;\r\n\t engine.Tween.get(this.boomimg)\r\n\t .to({\r\n\t scaleX: 1.2,\r\n\t scaleY: 1.2\r\n\t }, 200, engine.Ease.quadIn);\r\n\t this.hboomimg.scaleY = 0.1;\r\n\t this.hboomimg.alpha = 1;\r\n\t this.vboomimg.scaleY = 0.1;\r\n\t this.vboomimg.alpha = 1;\r\n\t engine.Tween.get(this.hboomimg)\r\n\t .to({\r\n\t scaleY: 1,\r\n\t alpha: 0.8\r\n\t }, 150, engine.Ease.quadIn)\r\n\t .to({\r\n\t alpha: 0\r\n\t }, 50, engine.Ease.quadIn);\r\n\t engine.Tween.get(this.vboomimg)\r\n\t .to({\r\n\t scaleY: 1,\r\n\t alpha: 0.8\r\n\t }, 150, engine.Ease.quadIn)\r\n\t .to({\r\n\t alpha: 0\r\n\t }, 50, engine.Ease.quadIn)\r\n\t .call(function () {\r\n\t _this.alpha = 0;\r\n\t });\r\n\t };\r\n\t return boomAni;\r\n\t}(engine.Container));\r\n\t//# sourceMappingURL=boomAni.js.map\n\n\tvar GameView = (function (_super) {\r\n\t tslib.__extends(GameView, _super);\r\n\t function GameView() {\r\n\t var _this = _super.call(this) || this;\r\n\t _this.lattices = {};\r\n\t _this.eliminateArr = [];\r\n\t _this.selectArr = [];\r\n\t _this.conty = 0;\r\n\t _this.homex = 562;\r\n\t _this.homey = -20;\r\n\t _this.ination = false;\r\n\t _this.canation = true;\r\n\t _this._gametime = 60;\r\n\t _this._gamestat = 2;\r\n\t _this.ingameover = false;\r\n\t _this.ingame = true;\r\n\t _this.level = 0;\r\n\t _this.inrecord = false;\r\n\t _this.requestGameOver = false;\r\n\t _this.elitype = 1;\r\n\t _this.inguide = false;\r\n\t _this.diseffectArr = [];\r\n\t _this.mute = 1;\r\n\t _this._seq = 1;\r\n\t _this.sptime = Date.now();\r\n\t _this.useBoom = false;\r\n\t _this._score = 0;\r\n\t _this.inEliminate = false;\r\n\t _this.newSelect = false;\r\n\t _this.once(engine.Event.ADDED_TO_STAGE, _this.setup, _this);\r\n\t return _this;\r\n\t }\r\n\t Object.defineProperty(GameView.prototype, \"gamestat\", {\r\n\t get: function () {\r\n\t return this._gamestat;\r\n\t },\r\n\t set: function (stat) {\r\n\t this._gamestat = stat;\r\n\t if (stat == 2) {\r\n\t this.changeEnable(false);\r\n\t }\r\n\t },\r\n\t enumerable: true,\r\n\t configurable: true\r\n\t });\r\n\t Object.defineProperty(GameView.prototype, \"seq\", {\r\n\t get: function () {\r\n\t return this._seq;\r\n\t },\r\n\t set: function (num) {\r\n\t this._seq = num;\r\n\t },\r\n\t enumerable: true,\r\n\t configurable: true\r\n\t });\r\n\t GameView.prototype.setup = function () {\r\n\t console.log(\"setup----game\");\r\n\t MapData.initPoolEle();\r\n\t this.selectimg = new engine.Image(getTextureByName(\"选中框\"));\r\n\t this.selectimg.mouseEnabled = false;\r\n\t this.selectw = this.selectimg.texture.width;\r\n\t this.selecth = this.selectimg.texture.height;\r\n\t this.selectimg.anchorX = this.selectw / 2;\r\n\t this.selectimg.anchorY = this.selecth / 2;\r\n\t this.jiantou1 = new engine.Image(getTextureByName(\"交换箭头\"));\r\n\t this.jiantou2 = new engine.Image(getTextureByName(\"交换箭头\"));\r\n\t this.jiantou1.mouseEnabled = false;\r\n\t this.jiantou2.mouseEnabled = false;\r\n\t var jiantwid = 31;\r\n\t var jianthei = 24;\r\n\t this.jiantou1.anchorX = jiantwid / 2;\r\n\t this.jiantou1.anchorY = jianthei / 2;\r\n\t this.jiantou2.anchorX = jiantwid / 2;\r\n\t this.jiantou2.anchorY = jianthei / 2;\r\n\t this.jiantoucont = new engine.Container();\r\n\t this.jiantoucont.width = MapData.itemsize;\r\n\t this.jiantoucont.height = MapData.itemsize;\r\n\t this.jtsx1 = MapData.itemsize / 2 - jiantwid / 2;\r\n\t this.jtsx2 = MapData.itemsize / 2 - jiantwid / 2;\r\n\t this.jtsy1 = MapData.itemsize / 2 - jianthei;\r\n\t this.jtsy2 = MapData.itemsize / 2;\r\n\t this.jtex1 = this.jtsx1 - 10;\r\n\t this.jtex2 = this.jtsx2 + 10;\r\n\t this.jtey1 = this.jtsy1;\r\n\t this.jtey2 = this.jtsy2;\r\n\t this.jiantou1.x = this.jtsx1;\r\n\t this.jiantou2.rotation = 180;\r\n\t this.jiantou2.x = this.jtsx2;\r\n\t this.jiantou1.y = this.jtsy1;\r\n\t this.jiantou2.y = this.jtsy2;\r\n\t this.jiantoucont.addChild(this.jiantou1);\r\n\t this.jiantoucont.addChild(this.jiantou2);\r\n\t var row = MapData.row;\r\n\t var col = MapData.col;\r\n\t this.shoueffect = createSvga(\"手指动效\");\r\n\t this.container = new engine.Container();\r\n\t this.addChild(this.container);\r\n\t this.container.y = this.conty;\r\n\t var maskimg = new engine.Graphics();\r\n\t this.container.addChild(maskimg);\r\n\t this.container.mask = maskimg;\r\n\t maskimg.moveTo(0, 0);\r\n\t maskimg.beginFill(0);\r\n\t maskimg.lineTo(681, 0);\r\n\t maskimg.lineTo(681, 679);\r\n\t maskimg.lineTo(0, 679);\r\n\t maskimg.lineTo(0, 0);\r\n\t maskimg.endFill();\r\n\t this.anicontainer = new engine.Container();\r\n\t this.addChild(this.anicontainer);\r\n\t this.anicontainer.mouseEnabled = false;\r\n\t this.anicontainer.mouseChildren = false;\r\n\t this.txtcontainer = new engine.Container();\r\n\t this.addChild(this.txtcontainer);\r\n\t var map = new engine.Image(getTextureByName(\"底图\"));\r\n\t this.container.addChild(map);\r\n\t for (var r = 0; r < row; r++) {\r\n\t for (var c = 0; c < col; c++) {\r\n\t var rcpos = MapData.getRCPos(r, c);\r\n\t MapData.posData[r + \"_\" + c] = rcpos;\r\n\t }\r\n\t }\r\n\t this.tanix = this.homex + 30;\r\n\t this.taniy = this.homey;\r\n\t engine.globalEvent.addEventListener(GameEvent.SelectEle, this.selectele, this);\r\n\t this.removeEventListener(engine.Event.ADDED_TO_STAGE, this.setup, this);\r\n\t this.lastframeTime = Date.now();\r\n\t this.lastatime = Date.now();\r\n\t this.addEventListener(engine.Event.ENTER_FRAME, this.onUpdate, this);\r\n\t this.guideCont = new engine.Container();\r\n\t this.addChild(this.guideCont);\r\n\t this.guideDraw = new engine.Shape();\r\n\t this.guideCont.addChild(this.guideDraw);\r\n\t this.guideCont.visible = false;\r\n\t this.guideCont.mouseEnabled = false;\r\n\t this.guideCont.addChild(this.shoueffect);\r\n\t this.shoueffect.mouseEnabled = false;\r\n\t this.shoueffect.mouseChildren = false;\r\n\t this.shoueffect.visible = false;\r\n\t this.setGuidePath();\r\n\t this.boomani = new boomAni();\r\n\t this.anicontainer.addChild(this.boomani);\r\n\t };\r\n\t GameView.prototype.changeAni = function () {\r\n\t this.changeHomeShow(\"night\");\r\n\t };\r\n\t GameView.prototype.playComp = function () {\r\n\t };\r\n\t GameView.prototype.init = function (time, level, mode, mute) {\r\n\t if (mute === void 0) { mute = 1; }\r\n\t this.score = 0;\r\n\t this.gametime = time;\r\n\t this.seq = 1;\r\n\t this.level = level;\r\n\t this.ingameover = false;\r\n\t this.mute = mute;\r\n\t this.changeHomeShow(mode);\r\n\t this.initContainer();\r\n\t this.sptime = Date.now();\r\n\t };\r\n\t Object.defineProperty(GameView.prototype, \"score\", {\r\n\t get: function () {\r\n\t return this._score;\r\n\t },\r\n\t set: function (num) {\r\n\t this._score = num;\r\n\t engine.globalEvent.dispatchEvent('game-score-update', { score: this._score });\r\n\t },\r\n\t enumerable: true,\r\n\t configurable: true\r\n\t });\r\n\t Object.defineProperty(GameView.prototype, \"gametime\", {\r\n\t get: function () {\r\n\t return this._gametime;\r\n\t },\r\n\t set: function (time) {\r\n\t var lshowtime = Math.round(this._gametime);\r\n\t var nshowtime = Math.round(time);\r\n\t if (lshowtime != nshowtime) {\r\n\t if (this.gamestat == 1 && nshowtime < 1) {\r\n\t this.gameOver();\r\n\t }\r\n\t if (nshowtime < 0) {\r\n\t nshowtime = 0;\r\n\t }\r\n\t engine.globalEvent.dispatchEvent('game-time-update', { time: nshowtime });\r\n\t }\r\n\t if (time < 0) {\r\n\t time = 0;\r\n\t }\r\n\t this._gametime = time;\r\n\t },\r\n\t enumerable: true,\r\n\t configurable: true\r\n\t });\r\n\t GameView.prototype.gameOver = function () {\r\n\t this.gamestat = 2;\r\n\t this.unShowEleAttion();\r\n\t this.anicontainer.removeChild(this.selectimg);\r\n\t this.ingameover = true;\r\n\t console.log(\"倒计时结束1=============\", this.ingameover, this.inEliminate, this.inrecord);\r\n\t this.checkGameOver(\"time-over\");\r\n\t };\r\n\t GameView.prototype.checkGameOver = function (type) {\r\n\t if (this.ingameover) {\r\n\t console.log(\"倒计时已结束2==========\", this.inEliminate, this.inrecord, type);\r\n\t }\r\n\t if (this.ingameover && !this.inEliminate && !this.inrecord && !this.requestGameOver) {\r\n\t this.requestGameOver = true;\r\n\t this.unShowEleAttion();\r\n\t this.anicontainer.removeChild(this.jiantoucont);\r\n\t engine.globalEvent.dispatchEvent(\"game-over\", {\r\n\t score: this.score\r\n\t });\r\n\t }\r\n\t };\r\n\t GameView.prototype.reset = function (time, level, mode) {\r\n\t return tslib.__awaiter(this, void 0, void 0, function () {\r\n\t return tslib.__generator(this, function (_a) {\r\n\t this.anicontainer.removeChild(this.selectimg);\r\n\t this.gamestat = 1;\r\n\t this.selectArr = new Array();\r\n\t this.gametime = time;\r\n\t this.level = level;\r\n\t this.ingameover = false;\r\n\t this.seq = 1;\r\n\t this.changeHomeShow(mode);\r\n\t this.changeEnable(false);\r\n\t this.fall();\r\n\t return [2];\r\n\t });\r\n\t });\r\n\t };\r\n\t GameView.prototype.start = function () {\r\n\t console.log(\"game-start\");\r\n\t this.gamestat = 1;\r\n\t this.requestGameOver = false;\r\n\t this.selectArr = new Array();\r\n\t this.changeEnable(true);\r\n\t };\r\n\t GameView.prototype.pause = function () {\r\n\t this.ingame = false;\r\n\t this.unShowEleAttion();\r\n\t };\r\n\t GameView.prototype.resume = function () {\r\n\t this.lastframeTime = Date.now();\r\n\t this.ingame = true;\r\n\t };\r\n\t GameView.prototype.onUpdate = function () {\r\n\t var ntime = Date.now();\r\n\t if (this.gamestat == 1 && this.ingame && !this.inguide && !this.requestGameOver) {\r\n\t var passtime = ntime - this.lastframeTime;\r\n\t if (ntime - this.lastatime >= 5000 && !this.ination && this.canation && this.selectArr.length == 0) {\r\n\t this.attionEliShow();\r\n\t }\r\n\t if (this.gametime && this.gametime > 0) {\r\n\t var ngtime = this.gametime - (passtime / 1000);\r\n\t this.gametime = ngtime;\r\n\t }\r\n\t }\r\n\t this.lastframeTime = ntime;\r\n\t };\r\n\t GameView.prototype.initContainer = function () {\r\n\t if (this.lattices) {\r\n\t for (var key in this.lattices) {\r\n\t var rcname = this.lattices[key];\r\n\t var rcele = this.container.getChildByName(rcname);\r\n\t if (rcele) {\r\n\t var rcetype = rcele.type;\r\n\t this.container.removeChild(rcele);\r\n\t this.lattices[key] = \"empty\";\r\n\t MapData.recoverEle(rcele, rcetype);\r\n\t }\r\n\t }\r\n\t }\r\n\t else {\r\n\t this.lattices = {};\r\n\t }\r\n\t var testdata = MapData.levelData[this.level - 1];\r\n\t this.levelData = testdata;\r\n\t for (var r = 0; r < testdata.length; r++) {\r\n\t var rdata = testdata[r];\r\n\t for (var c = 0; c < rdata.length; c++) {\r\n\t var rctype = rdata[c];\r\n\t var rcele = MapData.getOneEle(rctype);\r\n\t var rcpos = MapData.getRCPos(r, c);\r\n\t this.container.addChild(rcele);\r\n\t rcele.x = rcpos[0];\r\n\t rcele.y = rcpos[1];\r\n\t var rcidx = r + \"_\" + c;\r\n\t this.lattices[rcidx] = rcele.name;\r\n\t this.setLatticeEleRc(rcidx);\r\n\t }\r\n\t }\r\n\t this.checkInit();\r\n\t };\r\n\t GameView.prototype.checkInit = function () {\r\n\t this.checkEliminate();\r\n\t if (this.eliminateArr.length > 0) {\r\n\t return this.eliminate();\r\n\t }\r\n\t else {\r\n\t this.selectArr = new Array();\r\n\t var isdiedata = this.attionEliminate();\r\n\t if (isdiedata && isdiedata.length == 3) {\r\n\t this.changeEnable(true);\r\n\t }\r\n\t else {\r\n\t this.solveDieMap();\r\n\t }\r\n\t }\r\n\t };\r\n\t GameView.prototype.setLatticeEleRc = function (rcidx) {\r\n\t var rename = this.lattices[rcidx];\r\n\t var rcnode = this.container.getChildByName(rename);\r\n\t if (rcnode) {\r\n\t var er = Number(rcidx.split(\"_\")[0]);\r\n\t var ec = Number(rcidx.split(\"_\")[1]);\r\n\t rcnode.setrc(er, ec);\r\n\t }\r\n\t };\r\n\t GameView.prototype.unShowEleAttion = function () {\r\n\t if (this.ination) {\r\n\t this.ination = false;\r\n\t this.lastatime = Date.now();\r\n\t var arrcidx1 = this.attiondata[0];\r\n\t var arrcidx2 = this.attiondata[1];\r\n\t var atname1 = this.lattices[arrcidx1];\r\n\t var atname2 = this.lattices[arrcidx2];\r\n\t var atnode1 = this.container.getChildByName(atname1);\r\n\t var atnode2 = this.container.getChildByName(atname2);\r\n\t var aboutnames = this.attiondata[2];\r\n\t if (!atnode1 || !atnode2) {\r\n\t this.attiondata = new Array();\r\n\t return;\r\n\t }\r\n\t var atpos1 = MapData.getRCPos(arrcidx1.split(\"_\")[0], arrcidx1.split(\"_\")[1]);\r\n\t var atpos2 = MapData.getRCPos(arrcidx2.split(\"_\")[0], arrcidx2.split(\"_\")[1]);\r\n\t engine.Tween.removeTweens(atnode1);\r\n\t engine.Tween.removeTweens(atnode2);\r\n\t atnode1.x = atpos1[0];\r\n\t atnode1.y = atpos1[1];\r\n\t atnode2.x = atpos2[0];\r\n\t atnode2.y = atpos2[1];\r\n\t for (var i = 0; i < aboutnames.length; i++) {\r\n\t var ircidx = aboutnames[i];\r\n\t var iname1 = this.lattices[ircidx];\r\n\t var inode1 = this.container.getChildByName(iname1);\r\n\t if (inode1) {\r\n\t engine.Tween.removeTweens(inode1);\r\n\t var ipos1 = MapData.getRCPos(ircidx.split(\"_\")[0], ircidx.split(\"_\")[1]);\r\n\t inode1.x = ipos1[0];\r\n\t inode1.y = ipos1[1];\r\n\t }\r\n\t }\r\n\t this.anicontainer.removeChild(this.jiantoucont);\r\n\t }\r\n\t };\r\n\t GameView.prototype.selectele = function (e) {\r\n\t if (!this.ingame) {\r\n\t return;\r\n\t }\r\n\t var data = e.data;\r\n\t var sr = data.r;\r\n\t var sc = data.c;\r\n\t var type = data.type;\r\n\t var sname = sr + \"_\" + sc;\r\n\t if (this.useBoom) {\r\n\t if (type == \"mouse_down\") {\r\n\t this.changeEnable(false);\r\n\t this.boomeEle(sr, sc);\r\n\t }\r\n\t return;\r\n\t }\r\n\t var lnewSelect = this.newSelect;\r\n\t var newCanSel = false;\r\n\t if (this.selectArr.length == 0) {\r\n\t newCanSel = true;\r\n\t }\r\n\t else if (this.selectArr.length == 1) {\r\n\t var nname = this.selectArr[0];\r\n\t if (sname == nname) {\r\n\t newCanSel = false;\r\n\t }\r\n\t else {\r\n\t newCanSel = true;\r\n\t }\r\n\t }\r\n\t if (type == \"mouse_down\") {\r\n\t this.newSelect = true;\r\n\t }\r\n\t else if (type == \"mouse_move\") {\r\n\t if (newCanSel) {\r\n\t this.newSelect = false;\r\n\t }\r\n\t }\r\n\t if ((lnewSelect || this.newSelect) && newCanSel) ;\r\n\t else {\r\n\t return;\r\n\t }\r\n\t this.unShowEleAttion();\r\n\t if (this.selectArr.length == 0) {\r\n\t this.sptime = Date.now();\r\n\t this.seqscore = 0;\r\n\t this.selectArr.push(sname);\r\n\t }\r\n\t else if (this.selectArr.length == 1) {\r\n\t var aselect = this.selectArr[0];\r\n\t var asr = aselect.split(\"_\")[0];\r\n\t var asc = aselect.split(\"_\")[1];\r\n\t if ((sr == asr && Math.abs(sc - asc) == 1) || (sc == asc && Math.abs(sr - asr) == 1)) {\r\n\t this.selectArr.push(sname);\r\n\t }\r\n\t else {\r\n\t if (sr == asr && sc == asc) {\r\n\t this.selectArr = new Array();\r\n\t this.anicontainer.removeChild(this.selectimg);\r\n\t }\r\n\t else {\r\n\t this.selectArr[0] = sname;\r\n\t }\r\n\t }\r\n\t }\r\n\t if (this.selectArr.length == 1) {\r\n\t this.setSelectShow();\r\n\t }\r\n\t else if (this.selectArr.length == 2) {\r\n\t this.changeElePos();\r\n\t }\r\n\t };\r\n\t GameView.prototype.setSelectShow = function () {\r\n\t var rcname = this.selectArr[0];\r\n\t var r = rcname.split(\"_\")[0];\r\n\t var c = rcname.split(\"_\")[1];\r\n\t var rcpos = MapData.getRCPos(r, c);\r\n\t engine.Tween.removeTweens(this.selectimg);\r\n\t this.anicontainer.addChild(this.selectimg);\r\n\t this.selectimg.x = rcpos[0] - 3;\r\n\t this.selectimg.y = rcpos[1] + this.conty - 3;\r\n\t this.startTweenSelectImg();\r\n\t };\r\n\t GameView.prototype.startTweenSelectImg = function () {\r\n\t this.selectimg.scaleX = 1;\r\n\t this.selectimg.scaleY = 1;\r\n\t engine.Tween.get(this.selectimg, { loop: true })\r\n\t .to({\r\n\t scaleX: 0.9,\r\n\t scaleY: 0.9\r\n\t }, 500)\r\n\t .to({\r\n\t scaleX: 1,\r\n\t scaleY: 1\r\n\t }, 500);\r\n\t };\r\n\t GameView.prototype.changeElePos = function () {\r\n\t var _this = this;\r\n\t this.anicontainer.removeChild(this.selectimg);\r\n\t this.changeEnable(false);\r\n\t var sname1 = this.selectArr[0];\r\n\t var sname2 = this.selectArr[1];\r\n\t var sename1 = this.lattices[sname1];\r\n\t var sename2 = this.lattices[sname2];\r\n\t this.lattices[sname1] = sename2;\r\n\t this.lattices[sname2] = sename1;\r\n\t this.setLatticeEleRc(sname1);\r\n\t this.setLatticeEleRc(sname2);\r\n\t this.checkEliminate();\r\n\t var snode1 = this.container.getChildByName(sename1);\r\n\t var snode2 = this.container.getChildByName(sename2);\r\n\t if (!snode1 || !snode2) {\r\n\t this.selectArr = new Array();\r\n\t return;\r\n\t }\r\n\t var snode1x = snode1.x;\r\n\t var snode1y = snode1.y;\r\n\t var snode2x = snode2.x;\r\n\t var snode2y = snode2.y;\r\n\t var changetime = Math.ceil((MapData.itemsize / MapData.anispeed) * 2 * 1000);\r\n\t engine.Tween.removeTweens(snode1);\r\n\t engine.Tween.removeTweens(snode2);\r\n\t if (this.eliminateArr.length > 0) {\r\n\t if (this.inguide) {\r\n\t this.shoueffect.stop(0);\r\n\t this.shoueffect.visible = false;\r\n\t this.inguide = false;\r\n\t engine.Tween.removeTweens(this.guideCont);\r\n\t engine.Tween.get(this.guideCont)\r\n\t .to({\r\n\t alpha: 0\r\n\t }, 200)\r\n\t .call(function () {\r\n\t _this.guideCont.visible = false;\r\n\t engine.globalEvent.dispatchEvent('game-guidecomplete', {});\r\n\t });\r\n\t }\r\n\t this.inEliminate = true;\r\n\t engine.Tween.get(snode1).to({\r\n\t x: snode2x,\r\n\t y: snode2y\r\n\t }, changetime);\r\n\t engine.Tween.get(snode2).to({\r\n\t x: snode1x,\r\n\t y: snode1y\r\n\t }, changetime)\r\n\t .call(function () {\r\n\t _this.eliminate();\r\n\t });\r\n\t }\r\n\t else {\r\n\t engine.Tween.get(snode1).to({\r\n\t x: snode2x,\r\n\t y: snode2y\r\n\t }, changetime)\r\n\t .wait(100)\r\n\t .to({\r\n\t x: snode1x,\r\n\t y: snode1y\r\n\t }, changetime);\r\n\t engine.Tween.get(snode2).to({\r\n\t x: snode1x,\r\n\t y: snode1y\r\n\t }, changetime)\r\n\t .wait(100)\r\n\t .to({\r\n\t x: snode2x,\r\n\t y: snode2y\r\n\t }, changetime)\r\n\t .call(function () {\r\n\t _this.lattices[sname1] = sename1;\r\n\t _this.lattices[sname2] = sename2;\r\n\t _this.setLatticeEleRc(sname1);\r\n\t _this.setLatticeEleRc(sname2);\r\n\t _this.selectArr = new Array();\r\n\t _this.recordGame();\r\n\t _this.changeEnable(true);\r\n\t _this.checkGameOver(\"changeElePos\");\r\n\t });\r\n\t }\r\n\t };\r\n\t GameView.prototype.eliminate = function () {\r\n\t return tslib.__awaiter(this, void 0, void 0, function () {\r\n\t var i, ielidata1, ielileng, addscore, j, ielidata, ielidxname, ielitype, ieliname, ielinode, ielix, ieliy, ietype;\r\n\t return tslib.__generator(this, function (_a) {\r\n\t switch (_a.label) {\r\n\t case 0:\r\n\t this.inEliminate = true;\r\n\t this.playEffect(\"消除音效\");\r\n\t for (i = 0; i < this.eliminateArr.length; i++) {\r\n\t ielidata1 = this.eliminateArr[i];\r\n\t ielileng = ielidata1.length;\r\n\t addscore = 0;\r\n\t if (ielileng <= 3) {\r\n\t addscore = props.threeEscore;\r\n\t }\r\n\t else if (ielileng == 4) {\r\n\t addscore = props.fourEscore;\r\n\t }\r\n\t else {\r\n\t addscore = props.moreEscore;\r\n\t }\r\n\t this.seqscore += addscore * ielileng;\r\n\t for (j = 0; j < ielidata1.length; j++) {\r\n\t ielidata = ielidata1[j];\r\n\t ielidxname = ielidata.idxname;\r\n\t ielitype = ielidata.type;\r\n\t ieliname = this.lattices[ielidxname];\r\n\t ielinode = this.container.getChildByName(ieliname);\r\n\t if (!ielinode) {\r\n\t continue;\r\n\t }\r\n\t ielix = ielinode.x;\r\n\t ieliy = ielinode.y;\r\n\t ietype = ielinode.type;\r\n\t if (this.elitype == 1) {\r\n\t this.lattices[ielidxname] = \"empty\";\r\n\t this.addScoreAni(ielix, ieliy, ietype, addscore);\r\n\t this.goDisplayAni1(ielinode, ietype, ielix, ieliy);\r\n\t }\r\n\t else {\r\n\t this.container.removeChild(ielinode);\r\n\t MapData.recoverEle(ielinode, ietype);\r\n\t this.addScoreAni(ielix, ieliy, ietype, addscore);\r\n\t this.lattices[ielidxname] = \"empty\";\r\n\t this.goHomeAni(ielitype, ielix, ieliy);\r\n\t }\r\n\t }\r\n\t }\r\n\t return [4, new Promise(function (res) {\r\n\t setTimeout(function () {\r\n\t res();\r\n\t }, 400);\r\n\t })];\r\n\t case 1:\r\n\t _a.sent();\r\n\t this.fall();\r\n\t return [4, new Promise(function (res1) {\r\n\t setTimeout(function () {\r\n\t res1();\r\n\t }, 500);\r\n\t })];\r\n\t case 2:\r\n\t _a.sent();\r\n\t return [2];\r\n\t }\r\n\t });\r\n\t });\r\n\t };\r\n\t GameView.prototype.fall = function (type) {\r\n\t if (type === void 0) { type = \"normal\"; }\r\n\t return tslib.__awaiter(this, void 0, void 0, function () {\r\n\t var fallData, fcutr, fc, r, c, idxname, elename, frcname, fetype, fele, cutr, fepos, fallPromise, _loop_1, this_1, f, isdiedata;\r\n\t return tslib.__generator(this, function (_a) {\r\n\t switch (_a.label) {\r\n\t case 0:\r\n\t fallData = new Array();\r\n\t fcutr = new Array();\r\n\t for (fc = 0; fc < MapData.col; fc++) {\r\n\t fcutr.push(-1);\r\n\t }\r\n\t for (r = MapData.row - 1; r > -1; r--) {\r\n\t for (c = MapData.col - 1; c > -1; c--) {\r\n\t idxname = r + \"_\" + c;\r\n\t elename = this.lattices[idxname];\r\n\t if (elename == \"empty\") {\r\n\t frcname = this.getFallRcEle(r, c);\r\n\t if (!frcname) {\r\n\t fetype = void 0;\r\n\t if (type == \"normal\") {\r\n\t fetype = MapData.getRandEtype();\r\n\t }\r\n\t else {\r\n\t fetype = this.levelData[r][c];\r\n\t }\r\n\t fele = MapData.getOneEle(fetype);\r\n\t cutr = fcutr[c];\r\n\t fepos = MapData.getRCPos(cutr, c);\r\n\t fcutr[c] = cutr - 1;\r\n\t this.container.addChild(fele);\r\n\t fele.x = fepos[0];\r\n\t fele.y = fepos[1];\r\n\t frcname = fele.name;\r\n\t }\r\n\t this.lattices[idxname] = frcname;\r\n\t this.setLatticeEleRc(idxname);\r\n\t fallData.push({\r\n\t rcname: frcname,\r\n\t trow: r,\r\n\t tcol: c\r\n\t });\r\n\t }\r\n\t }\r\n\t }\r\n\t fallPromise = new Array();\r\n\t _loop_1 = function (f) {\r\n\t var fdata = fallData[f];\r\n\t var frcname = fdata.rcname;\r\n\t var ftrow = fdata.trow;\r\n\t var ftcol = fdata.tcol;\r\n\t var ftpos = MapData.getRCPos(ftrow, ftcol);\r\n\t var frcnode = this_1.container.getChildByName(frcname);\r\n\t if (!frcnode) {\r\n\t return \"continue\";\r\n\t }\r\n\t var nepos = [frcnode.x, frcnode.y];\r\n\t var fdis = MapData.getDistance(ftpos, nepos);\r\n\t var ftime = Math.ceil((fdis / MapData.anispeed) * 1000);\r\n\t engine.Tween.removeTweens(frcnode);\r\n\t var ifallpromise = new Promise(function (res) {\r\n\t engine.Tween.get(frcnode)\r\n\t .to({\r\n\t x: ftpos[0],\r\n\t y: ftpos[1]\r\n\t }, ftime)\r\n\t .to({\r\n\t scaleY: 0.85\r\n\t }, 80)\r\n\t .to({\r\n\t scaleY: 1\r\n\t }, 80)\r\n\t .call(function () {\r\n\t res();\r\n\t });\r\n\t });\r\n\t fallPromise.push(ifallpromise);\r\n\t };\r\n\t this_1 = this;\r\n\t for (f = 0; f < fallData.length; f++) {\r\n\t _loop_1(f);\r\n\t }\r\n\t return [4, Promise.all(fallPromise)];\r\n\t case 1:\r\n\t _a.sent();\r\n\t if (type == \"newlevel\") {\r\n\t this.sptime = Date.now();\r\n\t }\r\n\t this.checkEliminate();\r\n\t if (this.eliminateArr.length > 0) {\r\n\t return [2, this.eliminate()];\r\n\t }\r\n\t else {\r\n\t this.selectArr = new Array();\r\n\t isdiedata = this.attionEliminate();\r\n\t if (isdiedata && isdiedata.length == 3) {\r\n\t this.inEliminate = false;\r\n\t if (type != \"newlevel\") {\r\n\t this.recordGame();\r\n\t }\r\n\t this.changeEnable(true);\r\n\t this.checkGameOver(\"fall\");\r\n\t }\r\n\t else {\r\n\t this.solveDieMap(\"fall\");\r\n\t }\r\n\t }\r\n\t return [2];\r\n\t }\r\n\t });\r\n\t });\r\n\t };\r\n\t GameView.prototype.goDisplayAni1 = function (rcele, rcetype, rcelex, rceley) {\r\n\t var _this = this;\r\n\t rcele.touch = false;\r\n\t engine.Tween.removeTweens(rcele);\r\n\t rcele.x = rcelex;\r\n\t rcele.y = rceley;\r\n\t rcele.anchorY = MapData.itemsize / 2;\r\n\t engine.Tween.get(rcele)\r\n\t .to({\r\n\t scaleX: 0,\r\n\t scaleY: 0,\r\n\t alpha: 0\r\n\t }, 300)\r\n\t .call(function () {\r\n\t _this.container.removeChild(rcele);\r\n\t MapData.recoverEle(rcele, rcetype);\r\n\t });\r\n\t var oneffect = this.getOneEffect();\r\n\t oneffect.x = rcelex;\r\n\t oneffect.y = rceley;\r\n\t this.anicontainer.addChild(oneffect);\r\n\t oneffect.play(1);\r\n\t };\r\n\t GameView.prototype.goDisplayAni = function (ielitype, ielix, ieliy) {\r\n\t var _this = this;\r\n\t var aniele = MapData.getOneEle(ielitype);\r\n\t aniele.alpha = 0;\r\n\t var anix = ielix;\r\n\t var aniy = ieliy + this.conty;\r\n\t this.anicontainer.addChild(aniele);\r\n\t aniele.touch = false;\r\n\t aniele.x = anix;\r\n\t aniele.y = aniy;\r\n\t aniele.alpha = 1;\r\n\t aniele.anchorY = MapData.itemsize / 2;\r\n\t engine.Tween.removeTweens(aniele);\r\n\t engine.Tween.get(aniele)\r\n\t .to({\r\n\t scaleX: 0,\r\n\t scaleY: 0,\r\n\t alpha: 0\r\n\t }, 300)\r\n\t .call(function () {\r\n\t _this.anicontainer.removeChild(aniele);\r\n\t MapData.recoverEle(aniele, ielitype);\r\n\t });\r\n\t };\r\n\t GameView.prototype.goHomeAni = function (ielitype, ielix, ieliy) {\r\n\t var aniele = MapData.getOneEle(ielitype);\r\n\t aniele.alpha = 0;\r\n\t var anix = ielix;\r\n\t var aniy = ieliy + this.conty;\r\n\t this.anicontainer.addChild(aniele);\r\n\t aniele.touch = false;\r\n\t aniele.x = anix;\r\n\t aniele.y = aniy;\r\n\t aniele.alpha = 1;\r\n\t var anidis = MapData.getDistance([this.tanix, this.taniy], [anix, aniy]);\r\n\t var anitime = Math.ceil((anidis / MapData.anispeed) * 1000);\r\n\t aniele.flyToHome(this.tanix, this.taniy, anitime);\r\n\t };\r\n\t GameView.prototype.changeEnable = function (v) {\r\n\t var changeable = false;\r\n\t if (this.gamestat == 1) {\r\n\t changeable = true;\r\n\t }\r\n\t else {\r\n\t if (!v) {\r\n\t changeable = true;\r\n\t }\r\n\t }\r\n\t if (changeable) {\r\n\t for (var key in this.lattices) {\r\n\t var kname = this.lattices[key];\r\n\t var ele = this.container.getChildByName(kname);\r\n\t if (ele) {\r\n\t ele.touch = v;\r\n\t }\r\n\t }\r\n\t engine.globalEvent.dispatchEvent('game-touch', {\r\n\t cantouch: v\r\n\t });\r\n\t if (v) {\r\n\t this.lastatime = Date.now();\r\n\t this.ination = false;\r\n\t }\r\n\t }\r\n\t this.canation = v;\r\n\t };\r\n\t GameView.prototype.attionEliShow = function () {\r\n\t var attiondata = this.attionEliminate();\r\n\t if (attiondata && attiondata.length == 3) {\r\n\t this.ination = true;\r\n\t this.attiondata = [attiondata[0], attiondata[1], attiondata[2]];\r\n\t var atname1 = this.lattices[attiondata[0]];\r\n\t var atname2 = this.lattices[attiondata[1]];\r\n\t var aboutnames = attiondata[2];\r\n\t var atnode1 = this.container.getChildByName(atname1);\r\n\t var atnode2 = this.container.getChildByName(atname2);\r\n\t if (!atnode1 || !atnode2) {\r\n\t return;\r\n\t }\r\n\t var atx1 = atnode1.x;\r\n\t var aty1 = atnode1.y;\r\n\t var atx2 = atnode2.x;\r\n\t var aty2 = atnode2.y;\r\n\t var lerpnum = 0.1;\r\n\t var atpos1 = [(atx2 - atx1) * lerpnum + atx1, (aty2 - aty1) * lerpnum + aty1];\r\n\t engine.Tween.removeTweens(atnode1);\r\n\t engine.Tween.removeTweens(atnode2);\r\n\t engine.Tween.get(atnode1, {\r\n\t loop: true\r\n\t }).to({\r\n\t x: atpos1[0],\r\n\t y: atpos1[1]\r\n\t }, 500)\r\n\t .to({\r\n\t x: atx1,\r\n\t y: aty1\r\n\t }, 500);\r\n\t var jtx = (atx2 - atx1) * 0.5 + atx1;\r\n\t var jty = (aty2 - aty1) * 0.5 + aty1 + this.conty;\r\n\t var chax1 = atx1 - atpos1[0];\r\n\t var chay1 = aty1 - atpos1[1];\r\n\t var roa1 = 0;\r\n\t var movex1 = 0;\r\n\t var movey1 = 0;\r\n\t if (Math.abs(chax1) > Math.abs(chay1)) {\r\n\t jty += 25;\r\n\t movex1 = chax1;\r\n\t }\r\n\t else {\r\n\t jtx += MapData.itemsize;\r\n\t roa1 = 90;\r\n\t movey1 = chay1;\r\n\t }\r\n\t for (var i = 0; i < aboutnames.length; i++) {\r\n\t var iname1 = this.lattices[aboutnames[i]];\r\n\t var inode1 = this.container.getChildByName(iname1);\r\n\t engine.Tween.removeTweens(inode1);\r\n\t var iatx1 = inode1.x;\r\n\t var iaty1 = inode1.y;\r\n\t if (inode1) {\r\n\t engine.Tween.get(inode1, { loop: true })\r\n\t .to({\r\n\t x: iatx1 + movex1,\r\n\t y: iaty1 + movey1\r\n\t }, 500)\r\n\t .to({\r\n\t x: iatx1,\r\n\t y: iaty1\r\n\t }, 500);\r\n\t }\r\n\t }\r\n\t this.anicontainer.addChild(this.jiantoucont);\r\n\t this.jiantoucont.x = jtx;\r\n\t this.jiantoucont.y = jty;\r\n\t this.jiantoucont.rotation = roa1;\r\n\t this.startJtAni();\r\n\t }\r\n\t else {\r\n\t this.solveDieMap();\r\n\t }\r\n\t };\r\n\t GameView.prototype.startJtAni = function () {\r\n\t engine.Tween.removeTweens(this.jiantou1);\r\n\t engine.Tween.removeTweens(this.jiantou2);\r\n\t this.jiantou1.x = this.jtex1;\r\n\t this.jiantou1.y = this.jtey1;\r\n\t this.jiantou2.x = this.jtex2;\r\n\t this.jiantou2.y = this.jtey2;\r\n\t this.jiantou1.alpha = 1;\r\n\t this.jiantou2.alpha = 1;\r\n\t engine.Tween.get(this.jiantou1, { loop: true })\r\n\t .to({\r\n\t x: this.jtsx1,\r\n\t y: this.jtsy1,\r\n\t alpha: 0\r\n\t }, 500)\r\n\t .to({\r\n\t x: this.jtex1,\r\n\t y: this.jtey1,\r\n\t alpha: 1\r\n\t }, 500);\r\n\t engine.Tween.get(this.jiantou2, { loop: true })\r\n\t .to({\r\n\t x: this.jtsx2,\r\n\t y: this.jtsy2,\r\n\t alpha: 0\r\n\t }, 500)\r\n\t .to({\r\n\t x: this.jtex2,\r\n\t y: this.jtey2,\r\n\t alpha: 1\r\n\t }, 500);\r\n\t };\r\n\t GameView.prototype.solveDieMap = function (type) {\r\n\t if (type === void 0) { type = \"normal\"; }\r\n\t if (this.gamestat != 1) {\r\n\t if (this.ingameover) {\r\n\t this.inEliminate = false;\r\n\t this.checkGameOver(\"changeToFuHuoPos222\");\r\n\t }\r\n\t return;\r\n\t }\r\n\t this.changeEnable(false);\r\n\t var elearr = new Array();\r\n\t for (var key in this.lattices) {\r\n\t var keyval = this.lattices[key];\r\n\t elearr.push(keyval);\r\n\t }\r\n\t for (var key in this.lattices) {\r\n\t var changeval = elearr.splice(Math.floor(Math.random() * elearr.length), 1)[0];\r\n\t this.lattices[key] = changeval;\r\n\t }\r\n\t var isdiedata = this.attionEliminate();\r\n\t if (isdiedata && isdiedata.length == 3) {\r\n\t this.changeToFuHuoPos(type);\r\n\t }\r\n\t else {\r\n\t return this.solveDieMap();\r\n\t }\r\n\t };\r\n\t GameView.prototype.changeToFuHuoPos = function (type) {\r\n\t return tslib.__awaiter(this, void 0, void 0, function () {\r\n\t var prolist, key, keyval, keynode, keynodex, keynodey, tpos, ipro;\r\n\t return tslib.__generator(this, function (_a) {\r\n\t switch (_a.label) {\r\n\t case 0:\r\n\t prolist = new Array();\r\n\t for (key in this.lattices) {\r\n\t keyval = this.lattices[key];\r\n\t keynode = this.container.getChildByName(keyval);\r\n\t if (!keynode) {\r\n\t continue;\r\n\t }\r\n\t keynodex = keynode.x;\r\n\t keynodey = keynode.y;\r\n\t tpos = MapData.getRCPos(key.split(\"_\")[0], key.split(\"_\")[1]);\r\n\t ipro = keynode.changePos(tpos);\r\n\t prolist.push(ipro);\r\n\t this.setLatticeEleRc(key);\r\n\t }\r\n\t return [4, Promise.all(prolist)];\r\n\t case 1:\r\n\t _a.sent();\r\n\t this.checkEliminate();\r\n\t if (this.eliminateArr.length > 0) {\r\n\t this.eliminate();\r\n\t }\r\n\t else {\r\n\t if (type == \"fall\") {\r\n\t this.recordGame();\r\n\t }\r\n\t this.changeEnable(true);\r\n\t this.inEliminate = false;\r\n\t this.checkGameOver(\"changeToFuHuoPos\");\r\n\t }\r\n\t return [2];\r\n\t }\r\n\t });\r\n\t });\r\n\t };\r\n\t GameView.prototype.recordcomp = function () {\r\n\t this.inrecord = false;\r\n\t this.checkGameOver(\"recordcomp\");\r\n\t };\r\n\t GameView.prototype.recordGame = function () {\r\n\t if (!this.requestGameOver) {\r\n\t this.inrecord = true;\r\n\t this.eptime = Date.now();\r\n\t engine.globalEvent.dispatchEvent('game-record', {\r\n\t score: this.seqscore,\r\n\t seq: this.seq,\r\n\t sptime: this.sptime,\r\n\t eptime: this.eptime\r\n\t });\r\n\t this.seq += 1;\r\n\t this.seqscore = 0;\r\n\t this.sptime = Date.now();\r\n\t }\r\n\t };\r\n\t GameView.prototype.attionEliminate = function () {\r\n\t var attiondata;\r\n\t for (var r = MapData.row - 1; r > -1; r--) {\r\n\t if (attiondata && attiondata.length == 3) {\r\n\t break;\r\n\t }\r\n\t for (var c = MapData.col - 1; c > -1; c--) {\r\n\t var checktype = this.getEleTypeByRc(r, c);\r\n\t var edatarow = this.getEliminateRow(r, c);\r\n\t var edatacol = this.getEliminateCol(r, c);\r\n\t if (edatarow.length > 2 || edatacol.length > 2) ;\r\n\t if (edatarow.length == 2) {\r\n\t var releidx1 = edatarow[0];\r\n\t var releidx2 = edatarow[1];\r\n\t var relerow1 = Number(releidx1.split(\"_\")[0]);\r\n\t var relerow2 = Number(releidx2.split(\"_\")[0]);\r\n\t var relecol = Number(releidx1.split(\"_\")[1]);\r\n\t var downrow = relerow1 + 1;\r\n\t var uprow = relerow2 - 1;\r\n\t var rightcol = relecol + 1;\r\n\t var leftcol = relecol - 1;\r\n\t var uprow1 = relerow2 - 2;\r\n\t var downrow1 = relerow1 + 2;\r\n\t if (downrow < MapData.row) {\r\n\t if (rightcol < MapData.col) {\r\n\t var nexttype = this.getEleTypeByRc(downrow, rightcol);\r\n\t if (nexttype == checktype) {\r\n\t attiondata = [downrow + \"_\" + rightcol, downrow + \"_\" + relecol, edatarow];\r\n\t break;\r\n\t }\r\n\t }\r\n\t if (leftcol > -1) {\r\n\t var nexttype = this.getEleTypeByRc(downrow, leftcol);\r\n\t if (nexttype == checktype) {\r\n\t attiondata = [downrow + \"_\" + leftcol, downrow + \"_\" + relecol, edatarow];\r\n\t break;\r\n\t }\r\n\t }\r\n\t }\r\n\t if (uprow > -1) {\r\n\t if (rightcol < MapData.col) {\r\n\t var nexttype = this.getEleTypeByRc(uprow, rightcol);\r\n\t if (nexttype == checktype) {\r\n\t attiondata = [uprow + \"_\" + rightcol, uprow + \"_\" + relecol, edatarow];\r\n\t break;\r\n\t }\r\n\t }\r\n\t if (leftcol > -1) {\r\n\t var nexttype = this.getEleTypeByRc(uprow, leftcol);\r\n\t if (nexttype == checktype) {\r\n\t attiondata = [uprow + \"_\" + leftcol, uprow + \"_\" + relecol, edatarow];\r\n\t break;\r\n\t }\r\n\t }\r\n\t }\r\n\t if (uprow1 > -1) {\r\n\t var nexttype = this.getEleTypeByRc(uprow1, relecol);\r\n\t if (nexttype == checktype) {\r\n\t attiondata = [uprow1 + \"_\" + relecol, uprow + \"_\" + relecol, edatarow];\r\n\t break;\r\n\t }\r\n\t }\r\n\t if (downrow1 < MapData.row) {\r\n\t var nexttype = this.getEleTypeByRc(downrow1, relecol);\r\n\t if (nexttype == checktype) {\r\n\t attiondata = [downrow1 + \"_\" + relecol, downrow + \"_\" + relecol, edatarow];\r\n\t break;\r\n\t }\r\n\t }\r\n\t }\r\n\t if (edatacol.length == 2) {\r\n\t var releidx1 = edatacol[0];\r\n\t var releidx2 = edatacol[1];\r\n\t var relerow = Number(releidx1.split(\"_\")[0]);\r\n\t var relecol1 = Number(releidx1.split(\"_\")[1]);\r\n\t var relecol2 = Number(releidx2.split(\"_\")[1]);\r\n\t var rightcol = relecol1 + 1;\r\n\t var leftcol = relecol2 - 1;\r\n\t var uprow = relerow - 1;\r\n\t var downrow = relerow + 1;\r\n\t var rightcol1 = relecol1 + 2;\r\n\t var leftcol1 = relecol2 - 2;\r\n\t if (leftcol > -1) {\r\n\t if (uprow > -1) {\r\n\t var nexttype = this.getEleTypeByRc(uprow, leftcol);\r\n\t if (nexttype == checktype) {\r\n\t attiondata = [uprow + \"_\" + leftcol, relerow + \"_\" + leftcol, edatacol];\r\n\t break;\r\n\t }\r\n\t }\r\n\t if (downrow < MapData.row) {\r\n\t var nexttype = this.getEleTypeByRc(downrow, leftcol);\r\n\t if (nexttype == checktype) {\r\n\t attiondata = [downrow + \"_\" + leftcol, relerow + \"_\" + leftcol, edatacol];\r\n\t break;\r\n\t }\r\n\t }\r\n\t }\r\n\t if (rightcol < MapData.col) {\r\n\t if (uprow > -1) {\r\n\t var nexttype = this.getEleTypeByRc(uprow, rightcol);\r\n\t if (nexttype == checktype) {\r\n\t attiondata = [uprow + \"_\" + rightcol, relerow + \"_\" + rightcol, edatacol];\r\n\t break;\r\n\t }\r\n\t }\r\n\t if (downrow < MapData.row) {\r\n\t var nexttype = this.getEleTypeByRc(downrow, rightcol);\r\n\t if (nexttype == checktype) {\r\n\t attiondata = [downrow + \"_\" + rightcol, relerow + \"_\" + rightcol, edatacol];\r\n\t break;\r\n\t }\r\n\t }\r\n\t }\r\n\t if (rightcol1 < MapData.col) {\r\n\t var nexttype = this.getEleTypeByRc(relerow, rightcol1);\r\n\t if (nexttype == checktype) {\r\n\t attiondata = [relerow + \"_\" + rightcol1, relerow + \"_\" + rightcol, edatacol];\r\n\t break;\r\n\t }\r\n\t }\r\n\t if (leftcol1 > -1) {\r\n\t var nexttype = this.getEleTypeByRc(relerow, leftcol1);\r\n\t if (nexttype == checktype) {\r\n\t attiondata = [relerow + \"_\" + leftcol1, relerow + \"_\" + leftcol, edatacol];\r\n\t break;\r\n\t }\r\n\t }\r\n\t }\r\n\t var jianrow = this.getEliminateRowR(r, c);\r\n\t if (jianrow.length == 2) {\r\n\t var jianr = Number(jianrow[0].split(\"_\")[0]) - 1;\r\n\t var jianc = Number(jianrow[0].split(\"_\")[1]);\r\n\t var ljianc = jianc - 1;\r\n\t if (ljianc > -1) {\r\n\t var nexttype = this.getEleTypeByRc(jianr, ljianc);\r\n\t if (nexttype == checktype) {\r\n\t attiondata = [jianr + \"_\" + ljianc, jianr + \"_\" + jianc, jianrow];\r\n\t break;\r\n\t }\r\n\t }\r\n\t var rjianc = jianc + 1;\r\n\t if (rjianc < MapData.col) {\r\n\t var nexttype = this.getEleTypeByRc(jianr, rjianc);\r\n\t if (nexttype == checktype) {\r\n\t attiondata = [jianr + \"_\" + rjianc, jianr + \"_\" + jianc, jianrow];\r\n\t break;\r\n\t }\r\n\t }\r\n\t }\r\n\t var jiancol = this.getEliminateRowC(r, c);\r\n\t if (jiancol.length == 2) {\r\n\t var jianr = Number(jiancol[0].split(\"_\")[0]);\r\n\t var jianc = Number(jianrow[0].split(\"_\")[1]) - 1;\r\n\t var ujianr = jianr - 1;\r\n\t if (ujianr > -1) {\r\n\t var nexttype = this.getEleTypeByRc(ujianr, jianc);\r\n\t if (nexttype == checktype) {\r\n\t attiondata = [ujianr + \"_\" + jianc, jianr + \"_\" + jianc, jiancol];\r\n\t break;\r\n\t }\r\n\t }\r\n\t var djianr = jianr + 1;\r\n\t if (djianr < MapData.row) {\r\n\t var nexttype = this.getEleTypeByRc(djianr, jianc);\r\n\t if (nexttype == checktype) {\r\n\t attiondata = [djianr + \"_\" + jianc, jianr + \"_\" + jianc, jiancol];\r\n\t break;\r\n\t }\r\n\t }\r\n\t }\r\n\t }\r\n\t }\r\n\t return attiondata;\r\n\t };\r\n\t GameView.prototype.checkEliminate = function () {\r\n\t this.eliminateArr = new Array();\r\n\t for (var r = MapData.row - 1; r > -1; r--) {\r\n\t for (var c = MapData.col - 1; c > -1; c--) {\r\n\t var edata = this.getEliminate(r, c);\r\n\t if (edata) {\r\n\t var etype = edata.etype;\r\n\t var earr = edata.arr;\r\n\t this.checkAddEli(etype, earr);\r\n\t }\r\n\t }\r\n\t }\r\n\t };\r\n\t GameView.prototype.getEliminateRowR = function (x, y) {\r\n\t var checktype = this.getEleTypeByRc(x, y);\r\n\t var jianrow = x - 2;\r\n\t var relearr = new Array();\r\n\t relearr.push(x + \"_\" + y);\r\n\t if (jianrow > -1) {\r\n\t var jiantype = this.getEleTypeByRc(jianrow, y);\r\n\t if (jiantype == checktype) {\r\n\t relearr.push(jianrow + \"_\" + y);\r\n\t }\r\n\t }\r\n\t return relearr;\r\n\t };\r\n\t GameView.prototype.getEliminateRowC = function (x, y) {\r\n\t var checktype = this.getEleTypeByRc(x, y);\r\n\t var jiancol = y - 2;\r\n\t var relearr = new Array();\r\n\t relearr.push(x + \"_\" + y);\r\n\t if (jiancol > -1) {\r\n\t var jiantype = this.getEleTypeByRc(x, jiancol);\r\n\t if (jiantype == checktype) {\r\n\t relearr.push(x + \"_\" + jiancol);\r\n\t }\r\n\t }\r\n\t return relearr;\r\n\t };\r\n\t GameView.prototype.getEliminateRow = function (x, y) {\r\n\t var checktype = this.getEleTypeByRc(x, y);\r\n\t var relearr = new Array();\r\n\t relearr.push(x + \"_\" + y);\r\n\t for (var r = x - 1; r > -1; r--) {\r\n\t var reletype = this.getEleTypeByRc(r, y);\r\n\t if (checktype == reletype) {\r\n\t relearr.push(r + \"_\" + y);\r\n\t }\r\n\t else {\r\n\t break;\r\n\t }\r\n\t }\r\n\t return relearr;\r\n\t };\r\n\t GameView.prototype.getEliminateCol = function (x, y) {\r\n\t var checktype = this.getEleTypeByRc(x, y);\r\n\t var celearr = new Array();\r\n\t celearr.push(x + \"_\" + y);\r\n\t for (var c = y - 1; c > -1; c--) {\r\n\t var celetype = this.getEleTypeByRc(x, c);\r\n\t if (checktype == celetype) {\r\n\t celearr.push(x + \"_\" + c);\r\n\t }\r\n\t else {\r\n\t break;\r\n\t }\r\n\t }\r\n\t return celearr;\r\n\t };\r\n\t GameView.prototype.getEliminate = function (x, y) {\r\n\t var checktype = this.getEleTypeByRc(x, y);\r\n\t var relearr = this.getEliminateRow(x, y);\r\n\t var celearr = this.getEliminateCol(x, y);\r\n\t var eliminatearr = new Array();\r\n\t if (relearr.length >= 3) {\r\n\t eliminatearr.push.apply(eliminatearr, relearr);\r\n\t }\r\n\t if (celearr.length >= 3) {\r\n\t eliminatearr.push.apply(eliminatearr, celearr);\r\n\t }\r\n\t if (eliminatearr.length > 0) {\r\n\t return {\r\n\t etype: checktype,\r\n\t arr: eliminatearr\r\n\t };\r\n\t }\r\n\t else {\r\n\t return false;\r\n\t }\r\n\t };\r\n\t GameView.prototype.getEleTypeByRc = function (r, c) {\r\n\t var rc = r + \"_\" + c;\r\n\t var elename = this.lattices[rc];\r\n\t var ele = this.container.getChildByName(elename);\r\n\t if (ele) {\r\n\t var eletype = ele.type;\r\n\t return eletype;\r\n\t }\r\n\t };\r\n\t GameView.prototype.checkAddEli = function (etype, earr) {\r\n\t var addnew = true;\r\n\t var inaidx;\r\n\t for (var i1 = 0; i1 < this.eliminateArr.length; i1++) {\r\n\t var i1data = this.eliminateArr[i1];\r\n\t for (var i2 = 0; i2 < i1data.length; i2++) {\r\n\t var i2data = i1data[i2];\r\n\t var i2eliname = i2data.idxname;\r\n\t var inidx = earr.indexOf(i2eliname);\r\n\t if (inidx != -1) {\r\n\t addnew = false;\r\n\t break;\r\n\t }\r\n\t }\r\n\t if (!addnew) {\r\n\t inaidx = i1;\r\n\t break;\r\n\t }\r\n\t }\r\n\t if (addnew) {\r\n\t var addarr = new Array();\r\n\t for (var i1 = 0; i1 < earr.length; i1++) {\r\n\t var i1name = earr[i1];\r\n\t addarr.push({\r\n\t idxname: i1name,\r\n\t type: etype\r\n\t });\r\n\t }\r\n\t this.eliminateArr.push(addarr);\r\n\t }\r\n\t else {\r\n\t for (var i4 = 0; i4 < earr.length; i4++) {\r\n\t var i4name = earr[i4];\r\n\t var addele = true;\r\n\t for (var i3 = 0; i3 < this.eliminateArr[inaidx].length; i3++) {\r\n\t var i3data = this.eliminateArr[inaidx][i3];\r\n\t var i3eliname = i3data.idxname;\r\n\t if (i3eliname == i4name) {\r\n\t addele = false;\r\n\t break;\r\n\t }\r\n\t }\r\n\t if (addele) {\r\n\t this.eliminateArr[inaidx].push({\r\n\t idxname: i4name,\r\n\t type: etype\r\n\t });\r\n\t }\r\n\t }\r\n\t }\r\n\t };\r\n\t GameView.prototype.getFallRcEle = function (r, c) {\r\n\t for (var fr = r - 1; fr > -1; fr--) {\r\n\t var frc = fr + \"_\" + c;\r\n\t var frcname = this.lattices[frc];\r\n\t if (frcname != \"empty\") {\r\n\t this.lattices[frc] = \"empty\";\r\n\t return frcname;\r\n\t }\r\n\t }\r\n\t return false;\r\n\t };\r\n\t GameView.prototype.addScoreAni = function (ielix, ieliy, ietype, addscore) {\r\n\t var _this = this;\r\n\t var anitxt = MapData.getOneTxt();\r\n\t anitxt.alpha = 0;\r\n\t var txtcolor = \"#bd882f\";\r\n\t switch (ietype) {\r\n\t case ElementType.gdog:\r\n\t txtcolor = \"#d3ff6d\";\r\n\t break;\r\n\t case ElementType.pbird:\r\n\t txtcolor = \"#ff51d4\";\r\n\t break;\r\n\t case ElementType.hniu:\r\n\t txtcolor = \"#ffab55\";\r\n\t break;\r\n\t case ElementType.bribbit:\r\n\t txtcolor = \"#b3d4ff\";\r\n\t break;\r\n\t case ElementType.rpig:\r\n\t txtcolor = \"#f2453b\";\r\n\t break;\r\n\t default:\r\n\t console.error(\"未定义类型,检查\");\r\n\t break;\r\n\t }\r\n\t anitxt.fillColor = txtcolor;\r\n\t var anix = ielix + MapData.itemsize / 2 - 100;\r\n\t var aniy = ieliy + this.conty + MapData.itemsize / 2 - 35;\r\n\t anitxt.text = \"+\" + addscore;\r\n\t this.txtcontainer.addChild(anitxt);\r\n\t anitxt.x = anix;\r\n\t anitxt.y = aniy;\r\n\t anitxt.scaleX = 0;\r\n\t anitxt.scaleY = 0;\r\n\t anitxt.alpha = 1;\r\n\t engine.Tween.get(anitxt, { loop: false }).set({\r\n\t x: anix,\r\n\t y: aniy,\r\n\t scaleX: 0,\r\n\t scaleY: 0\r\n\t })\r\n\t .to({\r\n\t y: aniy - 50,\r\n\t scaleX: 1,\r\n\t scaleY: 1,\r\n\t }, 300)\r\n\t .to({\r\n\t y: aniy - 120,\r\n\t alpha: 0\r\n\t }, 500)\r\n\t .call(function () {\r\n\t _this.txtcontainer.removeChild(anitxt);\r\n\t _this.score += addscore;\r\n\t MapData.recoverTxt(anitxt);\r\n\t });\r\n\t };\r\n\t GameView.prototype.changeHomeShow = function (mode) {\r\n\t };\r\n\t GameView.prototype.boomeEle = function (row, col) {\r\n\t this.playEffect(\"爆炸音效\");\r\n\t this.unShowEleAttion();\r\n\t this.useBoom = false;\r\n\t engine.globalEvent.dispatchEvent('game-useboomafter', {});\r\n\t this.anicontainer.removeChild(this.selectimg);\r\n\t this.selectArr = new Array();\r\n\t this.eliminateArr = new Array();\r\n\t for (var r = 0; r < MapData.row; r++) {\r\n\t var irc = r + \"_\" + col;\r\n\t var ielename = this.lattices[irc];\r\n\t var iele = this.container.getChildByName(ielename);\r\n\t if (iele) {\r\n\t var eletype = iele.type;\r\n\t this.eliminateArr.push([\r\n\t {\r\n\t idxname: irc,\r\n\t type: eletype\r\n\t }\r\n\t ]);\r\n\t }\r\n\t }\r\n\t for (var c = 0; c < MapData.col; c++) {\r\n\t if (c != col) {\r\n\t var irc = row + \"_\" + c;\r\n\t var ielename = this.lattices[irc];\r\n\t var iele = this.container.getChildByName(ielename);\r\n\t if (iele) {\r\n\t var eletype = iele.type;\r\n\t this.eliminateArr.push([\r\n\t {\r\n\t idxname: irc,\r\n\t type: eletype\r\n\t }\r\n\t ]);\r\n\t }\r\n\t }\r\n\t }\r\n\t this.boomani.x = MapData.getCx(col);\r\n\t this.boomani.y = MapData.getRy(row);\r\n\t this.boomani.playBoomAni();\r\n\t this.eliminate();\r\n\t };\r\n\t GameView.prototype.setGuidePath = function () {\r\n\t var path = [\r\n\t [364, 7],\r\n\t [364, 479],\r\n\t [484, 479],\r\n\t [484, 7],\r\n\t ];\r\n\t this.guideDraw.clear();\r\n\t this.guideDraw.beginFill(0x000000, 0.7);\r\n\t this.guideDraw.moveTo(0, 0);\r\n\t this.guideDraw.lineTo(609, 0);\r\n\t this.guideDraw.lineTo(609, 607);\r\n\t this.guideDraw.lineTo(0, 607);\r\n\t this.guideDraw.lineTo(0, 0);\r\n\t this.shoueffect.x = 409;\r\n\t this.shoueffect.y = -40;\r\n\t this.guideDraw.moveTo(path[0][0], path[0][1]);\r\n\t for (var i = 1; i < path.length; i++) {\r\n\t var idotx = path[i][0];\r\n\t var idoty = path[i][1];\r\n\t this.guideDraw.lineTo(idotx, idoty);\r\n\t }\r\n\t this.guideDraw.lineTo(path[0][0], path[0][1]);\r\n\t this.guideDraw.endFill();\r\n\t };\r\n\t GameView.prototype.setGuideShow = function () {\r\n\t this.inguide = true;\r\n\t this.guideCont.visible = true;\r\n\t this.guideCont.alpha = 0;\r\n\t this.shoueffect.visible = true;\r\n\t this.shoueffect.play(1);\r\n\t var ableidx = [\"0_3\", \"1_3\"];\r\n\t for (var key in this.lattices) {\r\n\t var isinable = ableidx.indexOf(key);\r\n\t var ieliname = this.lattices[key];\r\n\t var ielinode = this.container.getChildByName(ieliname);\r\n\t if (ielinode) {\r\n\t if (isinable == -1) {\r\n\t ielinode.touch = false;\r\n\t }\r\n\t else {\r\n\t ielinode.touch = true;\r\n\t }\r\n\t }\r\n\t }\r\n\t engine.Tween.removeTweens(this.guideCont);\r\n\t engine.Tween.get(this.guideCont)\r\n\t .to({\r\n\t alpha: 1\r\n\t }, 200);\r\n\t };\r\n\t GameView.prototype.usetool = function (data) {\r\n\t var tooltype = data.tooltype;\r\n\t if (tooltype == \"time\") {\r\n\t var addtime = data.addtime;\r\n\t var ngtime = this.gametime + addtime;\r\n\t this.gametime = ngtime;\r\n\t }\r\n\t else if (tooltype == \"boom\") {\r\n\t var use = data.useboom;\r\n\t this.useBoom = use;\r\n\t }\r\n\t };\r\n\t GameView.prototype.getOneEffect = function () {\r\n\t var oneffect;\r\n\t if (this.diseffectArr.length > 0) {\r\n\t oneffect = this.diseffectArr.shift();\r\n\t }\r\n\t else {\r\n\t oneffect = createSvga(\"消除动效\");\r\n\t oneffect.addEventListener(engine.Event.ENTER_FRAME, this.playDisEffectComplete, this);\r\n\t oneffect.mouseEnabled = false;\r\n\t oneffect.mouseChildren = false;\r\n\t }\r\n\t return oneffect;\r\n\t };\r\n\t GameView.prototype.playDisEffectComplete = function (e) {\r\n\t var target = e.target;\r\n\t var curframe = target.currentFrame;\r\n\t var totalframe = target.totalFrames;\r\n\t if (curframe >= totalframe) {\r\n\t target.stop(1);\r\n\t this.anicontainer.removeChild(target);\r\n\t this.diseffectArr.push(target);\r\n\t }\r\n\t };\r\n\t GameView.prototype.playEffect = function (sound) {\r\n\t console.log(\"音效播放\", sound);\r\n\t if (this.mute == 1) {\r\n\t playSound(sound);\r\n\t }\r\n\t };\r\n\t return GameView;\r\n\t}(engine.Container));\n\n\tvar GameWrapper = (function (_super) {\r\n\t tslib.__extends(GameWrapper, _super);\r\n\t function GameWrapper() {\r\n\t var _this = _super.call(this) || this;\r\n\t _this._gameView = new GameView();\r\n\t _this.addChild(_this._gameView);\r\n\t engine.globalEvent.addEventListener('game-init', _this.init, _this);\r\n\t engine.globalEvent.addEventListener('game-reset', _this.reset, _this);\r\n\t engine.globalEvent.addEventListener('game-start', _this.start, _this);\r\n\t engine.globalEvent.addEventListener('game-pause', _this.pause, _this);\r\n\t engine.globalEvent.addEventListener('game-resume', _this.resume, _this);\r\n\t engine.globalEvent.addEventListener('game-recordcomp', _this.recordcomp, _this);\r\n\t engine.globalEvent.addEventListener('game-newuserguide', _this.newUserGuide, _this);\r\n\t engine.globalEvent.addEventListener('game-usetool', _this.usetool, _this);\r\n\t return _this;\r\n\t }\r\n\t GameWrapper.prototype.init = function (event) {\r\n\t var time = event.data.time;\r\n\t var level = event.data.level;\r\n\t var mode = event.data.mode;\r\n\t var mute = event.data.mute;\r\n\t this._gameView.init(time, level, mode, mute);\r\n\t };\r\n\t GameWrapper.prototype.reset = function (event) {\r\n\t var time = event.data.time;\r\n\t var level = event.data.level;\r\n\t var mode = event.data.mode;\r\n\t this._gameView.reset(time, level, mode);\r\n\t };\r\n\t GameWrapper.prototype.start = function () {\r\n\t this._gameView.start();\r\n\t };\r\n\t GameWrapper.prototype.pause = function () {\r\n\t this._gameView.pause();\r\n\t };\r\n\t GameWrapper.prototype.resume = function () {\r\n\t this._gameView.resume();\r\n\t };\r\n\t GameWrapper.prototype.recordcomp = function () {\r\n\t this._gameView.recordcomp();\r\n\t };\r\n\t GameWrapper.prototype.newUserGuide = function () {\r\n\t this._gameView.setGuideShow();\r\n\t };\r\n\t GameWrapper.prototype.usetool = function (event) {\r\n\t var data = event.data;\r\n\t this._gameView.usetool(data);\r\n\t };\r\n\t return GameWrapper;\r\n\t}(engine.Container));\r\n\t//# sourceMappingURL=GameWrapper.js.map\n\n\tfunction index (props) {\r\n\t prepareProps();\r\n\t injectProps(props);\r\n\t var instance = new GameWrapper();\r\n\t return instance;\r\n\t}\r\n\t//# sourceMappingURL=index.js.map\n\n\treturn index;\n\n})));\n"
}
...@@ -6,6 +6,11 @@ ...@@ -6,6 +6,11 @@
"alias": "图片分成几列", "alias": "图片分成几列",
"type": "number", "type": "number",
"default": 3 "default": 3
},
"isNewPlayer": {
"alias": "isNewPlayer",
"type": "number",
"default": 1
} }
}, },
"assets": [ "assets": [
...@@ -460,5 +465,5 @@ ...@@ -460,5 +465,5 @@
} }
}, },
"id": "recycling", "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) {\r\n\t return engine.Texture.from(getAssetByUUID(uuid).uuid);\r\n\t}\r\n\tfunction getTextureByName(name) {\r\n\t return getTexture(engine.getAssetByName(name).uuid);\r\n\t}\r\n\tfunction playSound(name) {\r\n\t engine.playSound(engine.getAssetByName(name).uuid, { keep: true });\r\n\t}\r\n\tfunction createSvga(name, anchorName) {\r\n\t var inst = new svga.Svga();\r\n\t inst.source = 'asset://' + engine.getAssetByName(name).uuid;\r\n\t return inst;\r\n\t}\r\n\t//# sourceMappingURL=utils.js.map\n\n\tvar props = {};\r\n\tfunction prepareProps() {\r\n\t var metaProps = getProps();\r\n\t engine.injectProp(props, metaProps);\r\n\t}\r\n\tfunction injectProps(p) {\r\n\t engine.injectProp(props, p);\r\n\t}\r\n\t//# sourceMappingURL=props.js.map\n\n\tvar Conveyor = (function (_super) {\r\n\t tslib.__extends(Conveyor, _super);\r\n\t function Conveyor() {\r\n\t var _this = _super.call(this) || this;\r\n\t _this.y = 904.21;\r\n\t var sp = new engine.Sprite(getTextureByName('conveyor'));\r\n\t _this.addChild(sp);\r\n\t _this.idx0 = _this.createItem(75, 50);\r\n\t _this.idx1 = _this.createItem(225, 50);\r\n\t _this.idx2 = _this.createItem(375, 50);\r\n\t _this.idx3 = _this.createItem(525, 50);\r\n\t _this.idx4 = _this.createItem(675, 50);\r\n\t return _this;\r\n\t }\r\n\t Conveyor.prototype.clear = function () {\r\n\t this.clearItem(this.idx0);\r\n\t this.clearItem(this.idx1);\r\n\t this.clearItem(this.idx2);\r\n\t this.clearItem(this.idx3);\r\n\t this.clearItem(this.idx4);\r\n\t };\r\n\t Conveyor.prototype.clearItem = function (idx) {\r\n\t if (idx.children.length > 0)\r\n\t idx.removeChildAt(0);\r\n\t };\r\n\t Conveyor.prototype.createItem = function (x, y) {\r\n\t var sp = new engine.Sprite();\r\n\t this.addChild(sp);\r\n\t sp.x = x;\r\n\t sp.y = y;\r\n\t return sp;\r\n\t };\r\n\t return Conveyor;\r\n\t}(engine.Sprite));\r\n\t//# sourceMappingURL=Conveyor.js.map\n\n\tvar GarbageTypes;\r\n\t(function (GarbageTypes) {\r\n\t GarbageTypes[\"recoverableWaste\"] = \"recoverableWaste\";\r\n\t GarbageTypes[\"harmfulWaste\"] = \"harmfulWaste\";\r\n\t GarbageTypes[\"wetWaste\"] = \"wetWaste\";\r\n\t GarbageTypes[\"dryWaste\"] = \"dryWaste\";\r\n\t})(GarbageTypes || (GarbageTypes = {}));\r\n\t//# sourceMappingURL=GarbageTypes.js.map\n\n\tvar GarbageConfig = (function () {\r\n\t function GarbageConfig() {\r\n\t }\r\n\t GarbageConfig.config = [\r\n\t { name: \"保鲜盒\", source: \"g00\", type: GarbageTypes.recoverableWaste, width: 129, height: 111 },\r\n\t { name: \"报纸\", source: \"g01\", type: GarbageTypes.recoverableWaste, width: 138, height: 144 },\r\n\t { name: \"贝壳\", source: \"g02\", type: GarbageTypes.dryWaste, width: 79, height: 117 },\r\n\t { name: \"冰箱\", source: \"g03\", type: GarbageTypes.recoverableWaste, width: 63, height: 151 },\r\n\t { name: \"菜梗菜叶\", source: \"g04\", type: GarbageTypes.wetWaste, width: 144, height: 98 },\r\n\t { name: \"残枝落叶\", source: \"g05\", type: GarbageTypes.wetWaste, width: 120, height: 99 },\r\n\t { name: \"茶叶渣\", source: \"g06\", type: GarbageTypes.wetWaste, width: 86, height: 96 },\r\n\t { name: \"尘土\", source: \"g07\", type: GarbageTypes.dryWaste, width: 109, height: 114 },\r\n\t { name: \"创口贴\", source: \"g08\", type: GarbageTypes.dryWaste, width: 112, height: 90 },\r\n\t { name: \"大骨头\", source: \"g09\", type: GarbageTypes.dryWaste, width: 89, height: 101 },\r\n\t { name: \"普通干电池\", source: \"g11\", type: GarbageTypes.dryWaste, width: 89, height: 131 },\r\n\t { name: \"方便面盒\", source: \"g12\", type: GarbageTypes.dryWaste, width: 89, height: 168 },\r\n\t { name: \"废弃食用油脂\", source: \"g13\", type: GarbageTypes.wetWaste, width: 131, height: 164 },\r\n\t { name: \"骨骼内脏\", source: \"g14\", type: GarbageTypes.wetWaste, width: 104, height: 82 },\r\n\t { name: \"锅具\", source: \"g15\", type: GarbageTypes.recoverableWaste, width: 119, height: 149 },\r\n\t { name: \"果核\", source: \"g16\", type: GarbageTypes.wetWaste, width: 99, height: 95 },\r\n\t { name: \"果皮\", source: \"g17\", type: GarbageTypes.wetWaste, width: 115, height: 127 },\r\n\t { name: \"化妆品\", source: \"g18\", type: GarbageTypes.harmfulWaste, width: 67, height: 151 },\r\n\t { name: \"鸡蛋壳\", source: \"g19\", type: GarbageTypes.wetWaste, width: 99, height: 107 },\r\n\t { name: \"剪刀\", source: \"g20\", type: GarbageTypes.recoverableWaste, width: 96, height: 127 },\r\n\t { name: \"胶带\", source: \"g21\", type: GarbageTypes.dryWaste, width: 87, height: 113 },\r\n\t { name: \"榴莲壳\", source: \"g22\", type: GarbageTypes.dryWaste, width: 136, height: 116 },\r\n\t { name: \"毛巾\", source: \"g23\", type: GarbageTypes.recoverableWaste, width: 108, height: 96 },\r\n\t { name: \"纽扣电池\", source: \"g24\", type: GarbageTypes.harmfulWaste, width: 87, height: 89 },\r\n\t { name: \"破旧陶瓷罐\", source: \"g25\", type: GarbageTypes.dryWaste, width: 110, height: 125 },\r\n\t { name: \"杀虫剂\", source: \"g26\", type: GarbageTypes.harmfulWaste, width: 64, height: 160 },\r\n\t { name: \"剩菜剩饭\", source: \"g27\", type: GarbageTypes.wetWaste, width: 128, height: 96 },\r\n\t { name: \"手机\", source: \"g28\", type: GarbageTypes.recoverableWaste, width: 82, height: 142 },\r\n\t { name: \"书本\", source: \"g29\", type: GarbageTypes.recoverableWaste, width: 106, height: 132 },\r\n\t { name: \"玻璃杯\", source: \"g30\", type: GarbageTypes.recoverableWaste, width: 62, height: 119 },\r\n\t { name: \"水银温度计\", source: \"g31\", type: GarbageTypes.harmfulWaste, width: 109, height: 162 },\r\n\t { name: \"水银血压计\", source: \"g32\", type: GarbageTypes.harmfulWaste, width: 115, height: 147 },\r\n\t { name: \"塑料桶\", source: \"g33\", type: GarbageTypes.recoverableWaste, width: 92, height: 131 },\r\n\t { name: \"卫生纸\", source: \"g34\", type: GarbageTypes.dryWaste, width: 92, height: 132 },\r\n\t { name: \"污染织物\", source: \"g35\", type: GarbageTypes.dryWaste, width: 128, height: 139 },\r\n\t { name: \"污染纸张\", source: \"g36\", type: GarbageTypes.dryWaste, width: 96, height: 136 },\r\n\t { name: \"洗衣机\", source: \"g37\", type: GarbageTypes.recoverableWaste, width: 87, height: 157 },\r\n\t { name: \"烟蒂\", source: \"g38\", type: GarbageTypes.dryWaste, width: 87, height: 124 },\r\n\t { name: \"药品\", source: \"g39\", type: GarbageTypes.harmfulWaste, width: 109, height: 131 },\r\n\t { name: \"药品包装\", source: \"g40\", type: GarbageTypes.harmfulWaste, width: 108, height: 125 },\r\n\t { name: \"椰子壳\", source: \"g41\", type: GarbageTypes.dryWaste, width: 104, height: 119 },\r\n\t { name: \"衣服\", source: \"g42\", type: GarbageTypes.recoverableWaste, width: 83, height: 137 },\r\n\t { name: \"衣架\", source: \"g43\", type: GarbageTypes.recoverableWaste, width: 132, height: 125 },\r\n\t { name: \"易拉罐\", source: \"g44\", type: GarbageTypes.recoverableWaste, width: 65, height: 133 },\r\n\t { name: \"荧光灯\", source: \"g45\", type: GarbageTypes.harmfulWaste, width: 90, height: 118 },\r\n\t { name: \"油漆桶\", source: \"g46\", type: GarbageTypes.harmfulWaste, width: 65, height: 143 },\r\n\t { name: \"一次性纸杯\", source: \"g47\", type: GarbageTypes.dryWaste, width: 76, height: 116 },\r\n\t { name: \"纸尿裤\", source: \"g48\", type: GarbageTypes.dryWaste, width: 93, height: 138 },\r\n\t { name: \"纸箱\", source: \"g49\", type: GarbageTypes.recoverableWaste, width: 112, height: 118 },\r\n\t { name: \"指甲油\", source: \"g50\", type: GarbageTypes.harmfulWaste, width: 64, height: 138 },\r\n\t ];\r\n\t return GarbageConfig;\r\n\t}());\r\n\t//# sourceMappingURL=GarbageConfig.js.map\n\n\tvar transStores = (function (list) {\r\n\t var tmp = [];\r\n\t var contains = function (val) {\r\n\t for (var _i = 0, tmp_1 = tmp; _i < tmp_1.length; _i++) {\r\n\t var i = tmp_1[_i];\r\n\t if (val.targetType == i.targetType && val.itemType == i.itemType && val.itemName == i.itemName)\r\n\t return true;\r\n\t }\r\n\t return false;\r\n\t };\r\n\t list.forEach(function (i) {\r\n\t if (!contains(i))\r\n\t tmp.push(i);\r\n\t });\r\n\t list = tmp;\r\n\t tmp = [];\r\n\t var nameList = [];\r\n\t var contains2 = function (val) {\r\n\t for (var _i = 0, tmp_2 = tmp; _i < tmp_2.length; _i++) {\r\n\t var i = tmp_2[_i];\r\n\t if (val.itemName == i.itemName) {\r\n\t nameList.push(i.itemName);\r\n\t return true;\r\n\t }\r\n\t }\r\n\t return false;\r\n\t };\r\n\t list.forEach(function (i) {\r\n\t if (!contains2(i))\r\n\t tmp.push(i);\r\n\t });\r\n\t list = tmp;\r\n\t list.forEach(function (i) {\r\n\t if (nameList.indexOf(i.itemName) != -1) {\r\n\t i.targetType = i.itemType;\r\n\t }\r\n\t });\r\n\t return list.map(function (i) {\r\n\t return {\r\n\t 'targetName': getTargetName(i.targetType),\r\n\t 'isCorrect': i.targetType == i.itemType,\r\n\t 'itemName': i.itemName,\r\n\t 'itemTypeName': getTargetName(i.itemType)\r\n\t };\r\n\t });\r\n\t});\r\n\tvar getTargetName = function (type) {\r\n\t switch (type) {\r\n\t case GarbageTypes.recoverableWaste:\r\n\t return '可回收物';\r\n\t case GarbageTypes.harmfulWaste:\r\n\t return '有害垃圾';\r\n\t case GarbageTypes.wetWaste:\r\n\t return '湿垃圾';\r\n\t case GarbageTypes.dryWaste:\r\n\t return '其他垃圾';\r\n\t }\r\n\t};\r\n\t//# sourceMappingURL=transStores.js.map\n\n\tvar checkHit = (function (view, rect) {\r\n\t var x = view.x, y = view.y;\r\n\t var _a = view.texture, width = _a.width, height = _a.height;\r\n\t if (x > rect.x && y > rect.y && (x + width) < (rect.x + rect.width) && (y + height) < (rect.y + rect.height)) {\r\n\t return true;\r\n\t }\r\n\t return false;\r\n\t});\r\n\t//# sourceMappingURL=checkHit.js.map\n\n\tvar removeChild = (function (d) {\r\n\t if (d && d.parent) {\r\n\t d.parent.removeChild(d);\r\n\t }\r\n\t});\r\n\t//# sourceMappingURL=removeChild.js.map\n\n\tvar removeEle = (function (e, arr) {\r\n\t var index = arr.indexOf(e);\r\n\t if (index >= 0) {\r\n\t arr.splice(index, 1);\r\n\t }\r\n\t});\r\n\t//# sourceMappingURL=removeEle.js.map\n\n\tvar shuffle = (function (arr) {\r\n\t var _a;\r\n\t var i = arr.length;\r\n\t while (i) {\r\n\t var j = Math.floor(Math.random() * i--);\r\n\t _a = [arr[i], arr[j]], arr[j] = _a[0], arr[i] = _a[1];\r\n\t }\r\n\t return arr;\r\n\t});\r\n\t//# sourceMappingURL=shuffle.js.map\n\n\tvar WrongTips = (function (_super) {\r\n\t tslib.__extends(WrongTips, _super);\r\n\t function WrongTips() {\r\n\t var _this = _super.call(this) || this;\r\n\t _this.img = new engine.Image();\r\n\t _this.img.texture = getTextureByName('wrongTips');\r\n\t _this.addChild(_this.img);\r\n\t _this.img.anchorX = 88 / 2;\r\n\t _this.img.anchorY = 85 / 2;\r\n\t _this.visible = false;\r\n\t return _this;\r\n\t }\r\n\t WrongTips.prototype.play = function (rect) {\r\n\t this.visible = true;\r\n\t if (props.sound) {\r\n\t playSound(\"wrongTipsMp3\");\r\n\t }\r\n\t var dur = 70;\r\n\t var stren = 20;\r\n\t engine.Tween.get(this.img).set({ x: 0, y: 0, scaleX: 1, scaleY: 1, alpha: 1 })\r\n\t .to({ x: stren }, dur)\r\n\t .to({ x: 0 }, dur)\r\n\t .to({ x: -stren }, dur)\r\n\t .to({ x: 0 }, dur)\r\n\t .wait(200)\r\n\t .to({ alpha: 0 }, 300);\r\n\t this.x = rect.x + 180;\r\n\t this.y = rect.y;\r\n\t };\r\n\t return WrongTips;\r\n\t}(engine.Sprite));\r\n\tvar getTargetRect = function (targetType, gameview) {\r\n\t switch (targetType) {\r\n\t case GarbageTypes.dryWaste:\r\n\t return gameview.dryWaste;\r\n\t case GarbageTypes.wetWaste:\r\n\t return gameview.wetWaste;\r\n\t case GarbageTypes.harmfulWaste:\r\n\t return gameview.harmfulWaste;\r\n\t case GarbageTypes.recoverableWaste:\r\n\t return gameview.recoverableWaste;\r\n\t }\r\n\t};\r\n\t//# sourceMappingURL=WrongTips.js.map\n\n\tvar Conveyors = (function (_super) {\r\n\t tslib.__extends(Conveyors, _super);\r\n\t function Conveyors(p) {\r\n\t var _this = _super.call(this) || this;\r\n\t _this.conveyorsPool = [];\r\n\t _this.GarbageConfig = GarbageConfig.config;\r\n\t _this.datas = [];\r\n\t _this.wrapper = p;\r\n\t return _this;\r\n\t }\r\n\t Conveyors.prototype.initData = function (conveyor0, conveyor1) {\r\n\t this.conveyor0 = conveyor0;\r\n\t this.conveyor1 = conveyor1;\r\n\t };\r\n\t Conveyors.prototype.setDefault = function () {\r\n\t this.score = 0;\r\n\t this.conveyorsPool.push(this.conveyor0);\r\n\t this.conveyorsPool.push(this.conveyor1);\r\n\t var allConfigs = shuffle(this.GarbageConfig.concat([]));\r\n\t for (var i = 0; i < GarbageConfig.config.length; i++) {\r\n\t allConfigs[i].idx = i;\r\n\t allConfigs[i].isRight = false;\r\n\t allConfigs[i].isMistake = false;\r\n\t allConfigs[i].isOnStage = false;\r\n\t this.datas.push(allConfigs[i]);\r\n\t }\r\n\t for (var i = 0; i < 5; i++) {\r\n\t var data = this.datas[i];\r\n\t var view = new engine.Sprite(getTextureByName(data.source));\r\n\t view.isWrong = false;\r\n\t view.isRight = false;\r\n\t data.isOnStage = true;\r\n\t view.data = data;\r\n\t view.type = data.type;\r\n\t view.name = data.name;\r\n\t view.anchorX = data.width / 2;\r\n\t view.anchorY = data.height;\r\n\t view.x = -data.width / 2;\r\n\t view.y = -data.height + 40;\r\n\t this.conveyor1[\"idx\" + i].addChild(view);\r\n\t view.addEventListener(engine.MouseEvent.MOUSE_DOWN, this.onDown_garbage, this);\r\n\t }\r\n\t };\r\n\t Conveyors.prototype.startConveyors = function () {\r\n\t this.setDefault();\r\n\t engine.gameStage.addEventListener(engine.Event.ENTER_FRAME, this.onEnterFrame, this);\r\n\t };\r\n\t Conveyors.prototype.onEnterFrame = function (ENTER_FRAME, onEnterFrame, arg2) {\r\n\t if (this.score == (props.maxScore || 100)) {\r\n\t this.gameOver();\r\n\t this.wrapper.stop();\r\n\t if (props.sound)\r\n\t playSound(\"gameOverMp3\");\r\n\t }\r\n\t this.conveyorsPool.forEach(function (conveyor) {\r\n\t conveyor.x -= props.speed || 3;\r\n\t });\r\n\t if (this.conveyorsPool[this.conveyorsPool.length - 1].x <= 764) {\r\n\t var conveyor = new Conveyor();\r\n\t conveyor.x = this.conveyorsPool[this.conveyorsPool.length - 1].x + 764;\r\n\t this.wrapper.addChild(conveyor);\r\n\t this.conveyorsPool.push(conveyor);\r\n\t }\r\n\t else {\r\n\t var dataList = [];\r\n\t for (var n = 0; n < this.datas.length; n++) {\r\n\t var dataItem = this.datas[n];\r\n\t if (!dataItem.isRight && !dataItem.isOnStage) {\r\n\t dataList.push(dataItem);\r\n\t }\r\n\t }\r\n\t var lastConveyor = this.conveyorsPool[this.conveyorsPool.length - 1];\r\n\t for (var m = 0; m < 5; m++) {\r\n\t if (!lastConveyor[\"idx\" + m].children[0]) {\r\n\t var data = dataList.shift();\r\n\t if (data) {\r\n\t data.isOnStage = true;\r\n\t var view = new engine.Sprite(getTextureByName(data.source));\r\n\t view.data = data;\r\n\t view.isWrong = false;\r\n\t view.isRight = false;\r\n\t view.type = data.type;\r\n\t view.name = data.name;\r\n\t view.anchorX = data.width / 2;\r\n\t view.anchorY = data.height;\r\n\t view.x = -data.width / 2;\r\n\t view.y = -data.height + 40;\r\n\t lastConveyor[\"idx\" + m].addChild(view);\r\n\t view.addEventListener(engine.MouseEvent.MOUSE_DOWN, this.onDown_garbage, this);\r\n\t }\r\n\t else {\r\n\t break;\r\n\t }\r\n\t }\r\n\t }\r\n\t }\r\n\t if (this.conveyorsPool[0].x < -750) {\r\n\t for (var k = 0; k < this.datas.length; k++) {\r\n\t var dataItem = this.datas[k];\r\n\t var idx4 = this.conveyorsPool[0][\"idx\" + 4];\r\n\t if (idx4.children[0]) {\r\n\t if (dataItem.name == idx4.children[0].name) {\r\n\t dataItem.isOnStage = false;\r\n\t removeEle(dataItem, this.datas);\r\n\t this.datas.push(dataItem);\r\n\t idx4.removeChild(idx4.children[0]);\r\n\t break;\r\n\t }\r\n\t }\r\n\t }\r\n\t this.conveyorsPool.shift();\r\n\t }\r\n\t else if (this.conveyorsPool[0].x < -600) {\r\n\t for (var k = 0; k < this.datas.length; k++) {\r\n\t var dataItem = this.datas[k];\r\n\t var idx3 = this.conveyorsPool[0][\"idx\" + 3];\r\n\t if (idx3.children[0]) {\r\n\t if (dataItem.name == idx3.children[0].name) {\r\n\t dataItem.isOnStage = false;\r\n\t removeEle(dataItem, this.datas);\r\n\t this.datas.push(dataItem);\r\n\t idx3.removeChild(idx3.children[0]);\r\n\t break;\r\n\t }\r\n\t }\r\n\t }\r\n\t }\r\n\t else if (this.conveyorsPool[0].x < -450) {\r\n\t for (var k = 0; k < this.datas.length; k++) {\r\n\t var dataItem = this.datas[k];\r\n\t var idx2 = this.conveyorsPool[0][\"idx\" + 2];\r\n\t if (idx2.children[0]) {\r\n\t if (dataItem.name == idx2.children[0].name) {\r\n\t dataItem.isOnStage = false;\r\n\t removeEle(dataItem, this.datas);\r\n\t this.datas.push(dataItem);\r\n\t idx2.removeChild(idx2.children[0]);\r\n\t break;\r\n\t }\r\n\t }\r\n\t }\r\n\t }\r\n\t else if (this.conveyorsPool[0].x < -300) {\r\n\t for (var k = 0; k < this.datas.length; k++) {\r\n\t var dataItem = this.datas[k];\r\n\t var idx1 = this.conveyorsPool[0][\"idx\" + 1];\r\n\t if (idx1.children[0]) {\r\n\t if (dataItem.name == idx1.children[0].name) {\r\n\t dataItem.isOnStage = false;\r\n\t removeEle(dataItem, this.datas);\r\n\t this.datas.push(dataItem);\r\n\t idx1.removeChild(idx1.children[0]);\r\n\t break;\r\n\t }\r\n\t }\r\n\t }\r\n\t }\r\n\t else if (this.conveyorsPool[0].x < -150) {\r\n\t for (var k = 0; k < this.datas.length; k++) {\r\n\t var dataItem = this.datas[k];\r\n\t var idx0 = this.conveyorsPool[0][\"idx\" + 0];\r\n\t if (idx0.children[0]) {\r\n\t if (dataItem.name == idx0.children[0].name) {\r\n\t dataItem.isOnStage = false;\r\n\t removeEle(dataItem, this.datas);\r\n\t this.datas.push(dataItem);\r\n\t idx0.removeChild(idx0.children[0]);\r\n\t break;\r\n\t }\r\n\t }\r\n\t }\r\n\t }\r\n\t };\r\n\t Conveyors.prototype.addscore = function () {\r\n\t this.score += (props.onceScore || 2);\r\n\t engine.globalEvent.dispatchEvent('recycling-score-update', {\r\n\t score: this.score\r\n\t });\r\n\t };\r\n\t Conveyors.prototype.gameOver = function () {\r\n\t engine.gameStage.removeEventListener(engine.Event.ENTER_FRAME, this.onEnterFrame, this);\r\n\t engine.globalEvent.dispatchEvent('recycling-game-end', transStores(this.stores));\r\n\t };\r\n\t Conveyors.prototype.onDown_garbage = function (e) {\r\n\t if (this._currentDragView) {\r\n\t removeChild(this._currentDragView);\r\n\t }\r\n\t var target = e.target;\r\n\t var view = new engine.Sprite(target.texture);\r\n\t this._currentDragView = view;\r\n\t this._currentTarget = target;\r\n\t target.scaleX = target.scaleY = 0;\r\n\t this.wrapper.addChild(view);\r\n\t view.x = e.stageX - target.texture.width / 2;\r\n\t view.y = e.stageY - target.texture.height / 2;\r\n\t view.type = target['type'];\r\n\t view.name = target['name'];\r\n\t this.wrapper.addEventListener(engine.MouseEvent.MOUSE_UP, this.onStageMouseUp, this);\r\n\t this.wrapper.addEventListener(engine.MouseEvent.MOUSE_MOVE, this.onStageMouseMove, this);\r\n\t };\r\n\t Conveyors.prototype.onStageMouseMove = function (e) {\r\n\t var view = this._currentDragView;\r\n\t view.x = e.stageX - view.texture.width / 2;\r\n\t view.y = e.stageY - view.texture.height / 2;\r\n\t };\r\n\t Conveyors.prototype.onStageMouseUp = function (e) {\r\n\t var _this = this;\r\n\t this.wrapper.removeEventListener(engine.MouseEvent.MOUSE_UP, this.onStageMouseUp, this);\r\n\t this.wrapper.removeEventListener(engine.MouseEvent.MOUSE_MOVE, this.onStageMouseMove, this);\r\n\t if (!this._currentDragView)\r\n\t return;\r\n\t var result = this.checkHitRect();\r\n\t if (result) {\r\n\t if (result == this._currentDragView['type']) {\r\n\t this.addscore();\r\n\t this.wrapper.rightTips.play(getTargetRect(result, this.wrapper));\r\n\t this._currentTarget.data.isRight = true;\r\n\t }\r\n\t else {\r\n\t engine.Tween.get(this._currentTarget).to({ scaleX: 1, scaleY: 1 }, 300).call(function () { });\r\n\t this.wrapper.wrongTips.play(getTargetRect(result, this.wrapper));\r\n\t }\r\n\t this.stores.push({ targetType: result, itemType: this._currentDragView['type'], itemName: this._currentDragView['name'] });\r\n\t }\r\n\t else {\r\n\t engine.Tween.get(this._currentTarget).to({ scaleX: 1, scaleY: 1 }, 300).call(function () { });\r\n\t }\r\n\t this._currentDragView.anchorX = this._currentDragView.texture.width / 2;\r\n\t this._currentDragView.anchorY = this._currentDragView.texture.height / 2;\r\n\t engine.Tween.get(this._currentDragView).to({ scaleX: 0, scaleY: 0 }, 300).call(function () {\r\n\t removeChild(_this._currentDragView);\r\n\t });\r\n\t };\r\n\t Conveyors.prototype.clear = function () {\r\n\t this.conveyor0.x = 0;\r\n\t this.conveyor1.x = 764;\r\n\t this.conveyorsPool.forEach(function (i) {\r\n\t i.clear();\r\n\t });\r\n\t this.conveyorsPool = [];\r\n\t this.datas = [];\r\n\t this.stores = [];\r\n\t };\r\n\t Conveyors.prototype.timeout = function () {\r\n\t if (this._currentDragView) {\r\n\t removeChild(this._currentDragView);\r\n\t }\r\n\t this.wrapper.removeEventListener(engine.MouseEvent.MOUSE_UP, this.onStageMouseUp, this);\r\n\t this.wrapper.removeEventListener(engine.MouseEvent.MOUSE_MOVE, this.onStageMouseMove, this);\r\n\t this.gameOver();\r\n\t };\r\n\t Conveyors.prototype.checkHitRect = function () {\r\n\t if (checkHit(this._currentDragView, this.wrapper.wetWaste)) {\r\n\t return GarbageTypes.wetWaste;\r\n\t }\r\n\t if (checkHit(this._currentDragView, this.wrapper.harmfulWaste)) {\r\n\t return GarbageTypes.harmfulWaste;\r\n\t }\r\n\t if (checkHit(this._currentDragView, this.wrapper.dryWaste)) {\r\n\t return GarbageTypes.dryWaste;\r\n\t }\r\n\t if (checkHit(this._currentDragView, this.wrapper.recoverableWaste)) {\r\n\t return GarbageTypes.recoverableWaste;\r\n\t }\r\n\t return null;\r\n\t };\r\n\t return Conveyors;\r\n\t}(engine.Sprite));\r\n\t//# sourceMappingURL=Conveyors.js.map\n\n\tvar uiConfig = (function () {\r\n\t return [\r\n\t {\r\n\t id: 'playBg',\r\n\t texture: 'playBg'\r\n\t },\r\n\t {\r\n\t id: 'idler0',\r\n\t texture: 'idlerWheel',\r\n\t pos: [75, 1038],\r\n\t anchor: [20, 21.5]\r\n\t },\r\n\t {\r\n\t id: 'idler1',\r\n\t texture: 'idlerWheel',\r\n\t pos: [175, 1038],\r\n\t anchor: [20, 21.5]\r\n\t },\r\n\t {\r\n\t id: 'idler2',\r\n\t texture: 'idlerWheel',\r\n\t pos: [275, 1038],\r\n\t anchor: [20, 21.5]\r\n\t },\r\n\t {\r\n\t id: 'idler3',\r\n\t texture: 'idlerWheel',\r\n\t pos: [375, 1038],\r\n\t anchor: [20, 21.5]\r\n\t },\r\n\t {\r\n\t id: 'idler4',\r\n\t texture: 'idlerWheel',\r\n\t pos: [475, 1038],\r\n\t anchor: [20, 21.5]\r\n\t },\r\n\t {\r\n\t id: 'idler5',\r\n\t texture: 'idlerWheel',\r\n\t pos: [575, 1038],\r\n\t anchor: [20, 21.5]\r\n\t },\r\n\t {\r\n\t id: 'idler6',\r\n\t texture: 'idlerWheel',\r\n\t pos: [675, 1038],\r\n\t anchor: [20, 21.5]\r\n\t },\r\n\t ];\r\n\t});\r\n\t//# sourceMappingURL=uiConfig.js.map\n\n\tvar getGuideInfo = (function () {\r\n\t if (!window.localStorage) {\r\n\t return 0;\r\n\t }\r\n\t return localStorage.getItem('recyclingGuide');\r\n\t});\r\n\tvar setGuide = function () {\r\n\t if (window.localStorage)\r\n\t localStorage.setItem('recyclingGuide', '1');\r\n\t};\r\n\t//# sourceMappingURL=getGuideInfo.js.map\n\n\tvar createBg = (function (a) {\r\n\t if (a === void 0) { a = 1; }\r\n\t var rect = new engine.Graphics();\r\n\t rect.beginFill(0);\r\n\t rect.drawRect(0, 0, 750, 1624);\r\n\t rect.endFill();\r\n\t rect.alpha = a;\r\n\t return rect;\r\n\t});\r\n\t//# sourceMappingURL=createBg.js.map\n\n\tvar createImg = (function (texture) {\r\n\t return new engine.Sprite(getTextureByName(texture));\r\n\t});\r\n\t//# sourceMappingURL=createImg.js.map\n\n\tvar CountDownGroup = (function (_super) {\r\n\t tslib.__extends(CountDownGroup, _super);\r\n\t function CountDownGroup() {\r\n\t var _this = _super.call(this) || this;\r\n\t _this.addChild(createBg(.6));\r\n\t _this.num1 = createImg('num1');\r\n\t _this.num2 = createImg('num2');\r\n\t _this.num3 = createImg('num3');\r\n\t _this.go = createImg('go');\r\n\t _this.go.anchorX = 240;\r\n\t _this.go.anchorY = 171.5;\r\n\t _this.num1.anchorX = 125.5;\r\n\t _this.num1.anchorY = 189;\r\n\t _this.num2.anchorX = 149.5;\r\n\t _this.num2.anchorY = 191.5;\r\n\t _this.num3.anchorX = 148.5;\r\n\t _this.num3.anchorY = 191.5;\r\n\t _this.go.x = 750 / 2 - 240;\r\n\t _this.go.y = 525 - 171.5;\r\n\t _this.num1.x = 750 / 2 - 125.5;\r\n\t _this.num1.y = 529 - 189;\r\n\t _this.num2.x = 750 / 2 - 149.5;\r\n\t _this.num2.y = 526 - 191.5;\r\n\t _this.num3.x = 750 / 2 - 148.5;\r\n\t _this.num3.y = 525 - 191.5;\r\n\t _this.addChild(_this.num1);\r\n\t _this.addChild(_this.num2);\r\n\t _this.addChild(_this.num3);\r\n\t _this.addChild(_this.go);\r\n\t _this.visible = false;\r\n\t _this.reset();\r\n\t return _this;\r\n\t }\r\n\t CountDownGroup.prototype.reset = function () {\r\n\t this.go.alpha = this.num1.alpha = this.num2.alpha = this.num3.alpha = 0;\r\n\t this.go.scaleX = this.num1.scaleX = this.num2.scaleX = this.num3.scaleX = 3;\r\n\t this.go.scaleY = this.num1.scaleY = this.num2.scaleY = this.num3.scaleY = 3;\r\n\t };\r\n\t CountDownGroup.prototype.startCountDown = function () {\r\n\t return tslib.__awaiter(this, void 0, void 0, function () {\r\n\t var _this = this;\r\n\t return tslib.__generator(this, function (_a) {\r\n\t return [2, new Promise(function (r) {\r\n\t _this.reset();\r\n\t _this.visible = true;\r\n\t _this.num3.alpha = 1;\r\n\t var n3 = engine.Tween.get(_this.num3);\r\n\t if (props.sound) {\r\n\t playSound(\"numCountDown\");\r\n\t }\r\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 () {\r\n\t _this.num2.alpha = 1;\r\n\t var n2 = engine.Tween.get(_this.num2);\r\n\t if (props.sound) {\r\n\t playSound(\"numCountDown\");\r\n\t }\r\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 () {\r\n\t _this.num1.alpha = 1;\r\n\t var n1 = engine.Tween.get(_this.num1);\r\n\t if (props.sound) {\r\n\t playSound(\"numCountDown\");\r\n\t }\r\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 () {\r\n\t _this.go.alpha = 1;\r\n\t var go = engine.Tween.get(_this.go);\r\n\t if (props.sound) {\r\n\t if (props.sound)\r\n\t playSound(\"goMp3\");\r\n\t }\r\n\t go.to({ scaleX: 0.8, scaleY: 0.8 }, 200).to({ scaleX: 1, scaleY: 1 }, 100).wait(500).call(function () {\r\n\t _this.visible = false;\r\n\t r();\r\n\t });\r\n\t });\r\n\t });\r\n\t });\r\n\t })];\r\n\t });\r\n\t });\r\n\t };\r\n\t return CountDownGroup;\r\n\t}(engine.Sprite));\r\n\t//# sourceMappingURL=CountDownGroup.js.map\n\n\tvar GuideView = (function (_super) {\r\n\t tslib.__extends(GuideView, _super);\r\n\t function GuideView() {\r\n\t var _this = _super.call(this) || this;\r\n\t _this.initUI();\r\n\t _this.visible = false;\r\n\t return _this;\r\n\t }\r\n\t GuideView.prototype.initUI = function () {\r\n\t this.addChild(createBg(.6));\r\n\t this.guideBg = createImg('guideBg');\r\n\t this.addChild(this.guideBg);\r\n\t this.guideEle = createImg('guideEle');\r\n\t this.addChild(this.guideEle);\r\n\t this.guideBg.x = 403;\r\n\t this.guideBg.y = 565;\r\n\t this.guideEle.x = 361;\r\n\t this.guideEle.y = 877;\r\n\t this.guideEle.anchorX = 14;\r\n\t this.guideEle.anchorY = 88;\r\n\t this.guideEle.mouseEnabled = this.guideEle.mouseChildren = true;\r\n\t var svga = createSvga(\"guideTips\");\r\n\t this.svga = svga;\r\n\t this.addChild(svga);\r\n\t svga.gotoAndStop(1);\r\n\t svga.mouseEnabled = svga.mouseChildren = false;\r\n\t };\r\n\t GuideView.prototype.checkHit = function (x, y, w, h) {\r\n\t var rect = new engine.Rectangle(403, 565, 252, 297);\r\n\t if (x > rect.x && y > rect.y && (x + w) < (rect.x + rect.width) && (y + h) < (rect.y + rect.height)) {\r\n\t return true;\r\n\t }\r\n\t return false;\r\n\t };\r\n\t GuideView.prototype.startGuide = function () {\r\n\t return tslib.__awaiter(this, void 0, void 0, function () {\r\n\t var _this = this;\r\n\t return tslib.__generator(this, function (_a) {\r\n\t return [2, new Promise(function (r) {\r\n\t _this.visible = true;\r\n\t _this.svga.gotoAndStop(1);\r\n\t _this.svga.play(false, true);\r\n\t _this.guideEle.scaleX = 1;\r\n\t _this.guideEle.scaleY = 1;\r\n\t var offset = [0, 0];\r\n\t var guideOver = function () {\r\n\t _this.guideEle.removeEventListener(engine.MouseEvent.MOUSE_DOWN, ondown, _this);\r\n\t _this.guideEle.anchorX = 14;\r\n\t _this.guideEle.anchorY = 44;\r\n\t engine.Tween.get(_this.guideEle).to({ scaleX: 0, scaleY: 0 }, 300).call(function () {\r\n\t _this.visible = false;\r\n\t r();\r\n\t });\r\n\t };\r\n\t var onUp = function (e) {\r\n\t _this.stage.removeEventListener(engine.MouseEvent.MOUSE_MOVE, onMove, _this);\r\n\t if (_this.checkHit(_this.guideEle.x, _this.guideEle.y, _this.guideEle.width, _this.guideEle.height)) {\r\n\t guideOver();\r\n\t }\r\n\t else {\r\n\t _this.svga.visible = true;\r\n\t _this.guideEle.x = 361;\r\n\t _this.guideEle.y = 877;\r\n\t engine.Tween.get(_this.guideEle).set({ scaleX: 0, scaleY: 0 }).to({ scaleX: 1, scaleY: 1 }, 300);\r\n\t }\r\n\t };\r\n\t var onMove = function (e) {\r\n\t _this.guideEle.x = e.stageX - offset[0];\r\n\t _this.guideEle.y = e.stageY - offset[1];\r\n\t };\r\n\t var ondown = function (e) {\r\n\t offset = [e.localX, e.localY];\r\n\t _this.svga.visible = false;\r\n\t _this.stage.once(engine.MouseEvent.MOUSE_UP, onUp, _this);\r\n\t _this.stage.addEventListener(engine.MouseEvent.MOUSE_MOVE, onMove, _this);\r\n\t };\r\n\t _this.guideEle.addEventListener(engine.MouseEvent.MOUSE_DOWN, ondown, _this);\r\n\t })];\r\n\t });\r\n\t });\r\n\t };\r\n\t return GuideView;\r\n\t}(engine.Sprite));\r\n\t//# sourceMappingURL=guideView.js.map\n\n\tvar RightTips = (function (_super) {\r\n\t tslib.__extends(RightTips, _super);\r\n\t function RightTips() {\r\n\t var _this = _super.call(this) || this;\r\n\t _this.SCORE = props.onceScore || 2;\r\n\t _this.img = new engine.Image();\r\n\t _this.img.texture = getTextureByName('rightTips');\r\n\t _this.addChild(_this.img);\r\n\t _this.img.anchorX = 88 / 2;\r\n\t _this.img.anchorY = 85 / 2;\r\n\t _this.visible = false;\r\n\t _this.txt = new engine.TextField();\r\n\t _this.addChild(_this.txt);\r\n\t _this.txt.text = '+' + _this.SCORE;\r\n\t _this.txt.size = 60;\r\n\t _this.txt.fillColor = '#437726';\r\n\t engine.playSound;\r\n\t return _this;\r\n\t }\r\n\t RightTips.prototype.play = function (rect) {\r\n\t if (props.sound) {\r\n\t playSound(\"rightTipsSound\");\r\n\t }\r\n\t this.visible = true;\r\n\t this.txt.x = 100;\r\n\t engine.Tween.get(this.txt).set({ y: 60, alpha: 1 })\r\n\t .to({ y: -50 }, 500)\r\n\t .to({ alpha: 0 });\r\n\t engine.Tween.get(this.img).set({ x: 0, y: 0, scaleX: 0, scaleY: 0, alpha: 1 })\r\n\t .to({ scaleX: 1, scaleY: 1 }, 200, engine.Ease.getBackOut(1))\r\n\t .wait(200)\r\n\t .to({ alpha: 0 }, 300);\r\n\t this.x = rect.x + 180;\r\n\t this.y = rect.y;\r\n\t };\r\n\t return RightTips;\r\n\t}(engine.Sprite));\r\n\t//# sourceMappingURL=RightTips.js.map\n\n\tvar GameView = (function (_super) {\r\n\t tslib.__extends(GameView, _super);\r\n\t function GameView() {\r\n\t var _this = _super.call(this) || this;\r\n\t _this._timeCounter = 0;\r\n\t _this.once(engine.Event.ADDED_TO_STAGE, _this.setup, _this);\r\n\t return _this;\r\n\t }\r\n\t GameView.prototype.configUI = function () {\r\n\t var uiMap = {};\r\n\t this.uiMap = uiMap;\r\n\t var config = uiConfig();\r\n\t for (var _i = 0, config_1 = config; _i < config_1.length; _i++) {\r\n\t var item = config_1[_i];\r\n\t var id = item.id, texture = item.texture, pos = item.pos, anchor = item.anchor;\r\n\t var sp = new engine.Sprite(getTextureByName(texture));\r\n\t this.addChild(sp);\r\n\t uiMap[id] = sp;\r\n\t if (anchor) {\r\n\t sp.anchorX = anchor[0];\r\n\t sp.anchorY = anchor[1];\r\n\t }\r\n\t if (pos) {\r\n\t sp.x = pos[0];\r\n\t sp.y = pos[1];\r\n\t if (anchor) {\r\n\t sp.x = pos[0] - sp.anchorX;\r\n\t sp.y = pos[1] - sp.anchorY;\r\n\t }\r\n\t }\r\n\t }\r\n\t this.configConveyors();\r\n\t this.createRects();\r\n\t this.countdown = new CountDownGroup();\r\n\t this.addChild(this.countdown);\r\n\t this.guide = new GuideView();\r\n\t this.addChild(this.guide);\r\n\t this.wrongTips = new WrongTips();\r\n\t this.rightTips = new RightTips();\r\n\t this.addChild(this.wrongTips);\r\n\t this.addChild(this.rightTips);\r\n\t };\r\n\t GameView.prototype.createRects = function () {\r\n\t this.wetWaste = this.createRect(104, 565, 252, 297, 0xffffff);\r\n\t this.harmfulWaste = this.createRect(104, 232, 252, 297, 0xff0000);\r\n\t this.dryWaste = this.createRect(403, 232, 252, 297, 0x000000);\r\n\t this.recoverableWaste = this.createRect(403, 565, 252, 297, 0x0000ff);\r\n\t };\r\n\t GameView.prototype.createRect = function (x, y, w, h, c) {\r\n\t var rect = new engine.Rectangle(x, y, w, h);\r\n\t var sp = new engine.Sprite();\r\n\t this.addChild(sp);\r\n\t sp.x = x;\r\n\t sp.y = y;\r\n\t var g = new engine.Graphics;\r\n\t g.alpha = 0.0;\r\n\t g.beginFill(c);\r\n\t g.drawRect(0, 0, w, h);\r\n\t g.endFill();\r\n\t sp.addChild(g);\r\n\t return rect;\r\n\t };\r\n\t GameView.prototype.configConveyors = function () {\r\n\t var conveyor0 = new Conveyor();\r\n\t var conveyor1 = new Conveyor();\r\n\t this.addChild(conveyor0);\r\n\t this.addChild(conveyor1);\r\n\t conveyor0.x = 0;\r\n\t conveyor1.x = 764;\r\n\t this.conveyors = new Conveyors(this);\r\n\t this.conveyors.initData(conveyor0, conveyor1);\r\n\t };\r\n\t GameView.prototype.playAni = function () {\r\n\t var _this = this;\r\n\t var idlerWheels = ['idler0', 'idler1', 'idler2', 'idler3', 'idler4', 'idler5', 'idler6'];\r\n\t idlerWheels = idlerWheels.map(function (i) { return _this.uiMap[i]; });\r\n\t idlerWheels.forEach(function (i) {\r\n\t engine.Tween.get(i, { loop: true }).to({ rotation: -360 }, 1000);\r\n\t });\r\n\t };\r\n\t GameView.prototype.stopAni = function () {\r\n\t var _this = this;\r\n\t var idlerWheels = ['idler0', 'idler1', 'idler2', 'idler3', 'idler4', 'idler5', 'idler6'];\r\n\t idlerWheels = idlerWheels.map(function (i) { return _this.uiMap[i]; });\r\n\t idlerWheels.forEach(function (i) {\r\n\t engine.Tween.removeTweens(i);\r\n\t });\r\n\t };\r\n\t GameView.prototype.start = function () {\r\n\t return tslib.__awaiter(this, void 0, void 0, function () {\r\n\t var _this = this;\r\n\t return tslib.__generator(this, function (_a) {\r\n\t switch (_a.label) {\r\n\t case 0:\r\n\t console.log('on start');\r\n\t this._timeCounter = 0;\r\n\t if (!!getGuideInfo()) return [3, 2];\r\n\t return [4, this.guide.startGuide()];\r\n\t case 1:\r\n\t _a.sent();\r\n\t setGuide();\r\n\t _a.label = 2;\r\n\t case 2:\r\n\t this.conveyors.clear();\r\n\t return [4, this.countdown.startCountDown()];\r\n\t case 3:\r\n\t _a.sent();\r\n\t this.startGame();\r\n\t engine.globalEvent.dispatchEvent('recycling-time-update', {\r\n\t second: this.getSecond(),\r\n\t });\r\n\t this._timer = setInterval(function () {\r\n\t _this.onTimer();\r\n\t }, 1000);\r\n\t return [2];\r\n\t }\r\n\t });\r\n\t });\r\n\t };\r\n\t GameView.prototype.startGame = function () {\r\n\t this.playAni();\r\n\t this.conveyors.startConveyors();\r\n\t };\r\n\t GameView.prototype.stopGame = function () {\r\n\t this.stopAni();\r\n\t };\r\n\t GameView.prototype.getSecond = function () {\r\n\t return props.time - this._timeCounter;\r\n\t };\r\n\t GameView.prototype.onTimer = function () {\r\n\t this._timeCounter++;\r\n\t engine.globalEvent.dispatchEvent('recycling-time-update', {\r\n\t second: this.getSecond(),\r\n\t });\r\n\t if (this.getSecond() == 0) {\r\n\t this.stop();\r\n\t this.conveyors.timeout();\r\n\t if (props.sound)\r\n\t playSound(\"gameOverMp3\");\r\n\t }\r\n\t };\r\n\t GameView.prototype.stop = function () {\r\n\t clearInterval(this._timer);\r\n\t this.stopGame();\r\n\t };\r\n\t GameView.prototype.setup = function () {\r\n\t console.log('onSteup', props);\r\n\t this.configUI();\r\n\t };\r\n\t GameView.prototype.onDown = function (e) {\r\n\t };\r\n\t GameView.prototype.stageOnUp = function (e) {\r\n\t };\r\n\t GameView.prototype.onSuccess = function () {\r\n\t };\r\n\t GameView.prototype.onMove = function (e) {\r\n\t };\r\n\t return GameView;\r\n\t}(engine.Container));\r\n\t//# sourceMappingURL=GameView.js.map\n\n\tvar GameWrapper = (function (_super) {\r\n\t tslib.__extends(GameWrapper, _super);\r\n\t function GameWrapper() {\r\n\t var _this = _super.call(this) || this;\r\n\t engine.globalEvent.addEventListener('recycling-start', _this.start, _this);\r\n\t engine.globalEvent.addEventListener('recycling-sound-update', _this.updateSound, _this);\r\n\t engine.globalEvent.addEventListener('recycling-stop', _this.stop, _this);\r\n\t var gameView = _this._gameView = new GameView();\r\n\t _this.addChild(gameView);\r\n\t return _this;\r\n\t }\r\n\t GameWrapper.prototype.updateSound = function (event) {\r\n\t injectProps(event.data);\r\n\t };\r\n\t GameWrapper.prototype.start = function (event) {\r\n\t injectProps(event.data);\r\n\t this._gameView.start();\r\n\t };\r\n\t GameWrapper.prototype.stop = function (event) {\r\n\t this._gameView.stop();\r\n\t };\r\n\t return GameWrapper;\r\n\t}(engine.Container));\r\n\t//# sourceMappingURL=GameWrapper.js.map\n\n\tfunction index (props) {\r\n\t prepareProps();\r\n\t injectProps(props);\r\n\t var instance = new GameWrapper();\r\n\t return instance;\r\n\t}\r\n\t//# sourceMappingURL=index.js.map\n\n\treturn index;\n\n})));\n" "code": "\"use strict\";var tslib=require(\"tslib\");function getTexture(e){return engine.Texture.from(getAssetByUUID(e).uuid)}function getTextureByName(e){return getTexture(engine.getAssetByName(e).uuid)}function playSound(e){engine.playSound(engine.getAssetByName(e).uuid,{keep:!0})}function createSvga(e,t){var i=new svga.Svga;return i.source=\"asset://\"+engine.getAssetByName(e).uuid,i}var props={};function prepareProps(){var e=getProps();engine.injectProp(props,e)}function injectProps(e){engine.injectProp(props,e)}var GarbageTypes,Conveyor=function(i){function e(){var e=i.call(this)||this;e.y=904.21;var t=new engine.Sprite(getTextureByName(\"conveyor\"));return e.addChild(t),e.idx0=e.createItem(75,50),e.idx1=e.createItem(225,50),e.idx2=e.createItem(375,50),e.idx3=e.createItem(525,50),e.idx4=e.createItem(675,50),e}return tslib.__extends(e,i),e.prototype.clear=function(){this.clearItem(this.idx0),this.clearItem(this.idx1),this.clearItem(this.idx2),this.clearItem(this.idx3),this.clearItem(this.idx4)},e.prototype.clearItem=function(e){0<e.children.length&&e.removeChildAt(0)},e.prototype.createItem=function(e,t){var i=new engine.Sprite;return this.addChild(i),i.x=e,i.y=t,i},e}(engine.Sprite);!function(e){e.recoverableWaste=\"recoverableWaste\",e.harmfulWaste=\"harmfulWaste\",e.wetWaste=\"wetWaste\",e.dryWaste=\"dryWaste\"}(GarbageTypes=GarbageTypes||{});var GarbageConfig=function(){function e(){}return e.config=[{name:\"保鲜盒\",source:\"g00\",type:GarbageTypes.recoverableWaste,width:129,height:111},{name:\"报纸\",source:\"g01\",type:GarbageTypes.recoverableWaste,width:138,height:144},{name:\"贝壳\",source:\"g02\",type:GarbageTypes.dryWaste,width:79,height:117},{name:\"冰箱\",source:\"g03\",type:GarbageTypes.recoverableWaste,width:63,height:151},{name:\"菜梗菜叶\",source:\"g04\",type:GarbageTypes.wetWaste,width:144,height:98},{name:\"残枝落叶\",source:\"g05\",type:GarbageTypes.wetWaste,width:120,height:99},{name:\"茶叶渣\",source:\"g06\",type:GarbageTypes.wetWaste,width:86,height:96},{name:\"尘土\",source:\"g07\",type:GarbageTypes.dryWaste,width:109,height:114},{name:\"创口贴\",source:\"g08\",type:GarbageTypes.dryWaste,width:112,height:90},{name:\"大骨头\",source:\"g09\",type:GarbageTypes.dryWaste,width:89,height:101},{name:\"普通干电池\",source:\"g11\",type:GarbageTypes.dryWaste,width:89,height:131},{name:\"方便面盒\",source:\"g12\",type:GarbageTypes.dryWaste,width:89,height:168},{name:\"废弃食用油脂\",source:\"g13\",type:GarbageTypes.wetWaste,width:131,height:164},{name:\"骨骼内脏\",source:\"g14\",type:GarbageTypes.wetWaste,width:104,height:82},{name:\"锅具\",source:\"g15\",type:GarbageTypes.recoverableWaste,width:119,height:149},{name:\"果核\",source:\"g16\",type:GarbageTypes.wetWaste,width:99,height:95},{name:\"果皮\",source:\"g17\",type:GarbageTypes.wetWaste,width:115,height:127},{name:\"化妆品\",source:\"g18\",type:GarbageTypes.harmfulWaste,width:67,height:151},{name:\"鸡蛋壳\",source:\"g19\",type:GarbageTypes.wetWaste,width:99,height:107},{name:\"剪刀\",source:\"g20\",type:GarbageTypes.recoverableWaste,width:96,height:127},{name:\"胶带\",source:\"g21\",type:GarbageTypes.dryWaste,width:87,height:113},{name:\"榴莲壳\",source:\"g22\",type:GarbageTypes.dryWaste,width:136,height:116},{name:\"毛巾\",source:\"g23\",type:GarbageTypes.recoverableWaste,width:108,height:96},{name:\"纽扣电池\",source:\"g24\",type:GarbageTypes.harmfulWaste,width:87,height:89},{name:\"破旧陶瓷罐\",source:\"g25\",type:GarbageTypes.dryWaste,width:110,height:125},{name:\"杀虫剂\",source:\"g26\",type:GarbageTypes.harmfulWaste,width:64,height:160},{name:\"剩菜剩饭\",source:\"g27\",type:GarbageTypes.wetWaste,width:128,height:96},{name:\"手机\",source:\"g28\",type:GarbageTypes.recoverableWaste,width:82,height:142},{name:\"书本\",source:\"g29\",type:GarbageTypes.recoverableWaste,width:106,height:132},{name:\"玻璃杯\",source:\"g30\",type:GarbageTypes.recoverableWaste,width:62,height:119},{name:\"水银温度计\",source:\"g31\",type:GarbageTypes.harmfulWaste,width:109,height:162},{name:\"水银血压计\",source:\"g32\",type:GarbageTypes.harmfulWaste,width:115,height:147},{name:\"塑料桶\",source:\"g33\",type:GarbageTypes.recoverableWaste,width:92,height:131},{name:\"卫生纸\",source:\"g34\",type:GarbageTypes.dryWaste,width:92,height:132},{name:\"污染织物\",source:\"g35\",type:GarbageTypes.dryWaste,width:128,height:139},{name:\"污染纸张\",source:\"g36\",type:GarbageTypes.dryWaste,width:96,height:136},{name:\"洗衣机\",source:\"g37\",type:GarbageTypes.recoverableWaste,width:87,height:157},{name:\"烟蒂\",source:\"g38\",type:GarbageTypes.dryWaste,width:87,height:124},{name:\"药品\",source:\"g39\",type:GarbageTypes.harmfulWaste,width:109,height:131},{name:\"药品包装\",source:\"g40\",type:GarbageTypes.harmfulWaste,width:108,height:125},{name:\"椰子壳\",source:\"g41\",type:GarbageTypes.dryWaste,width:104,height:119},{name:\"衣服\",source:\"g42\",type:GarbageTypes.recoverableWaste,width:83,height:137},{name:\"衣架\",source:\"g43\",type:GarbageTypes.recoverableWaste,width:132,height:125},{name:\"易拉罐\",source:\"g44\",type:GarbageTypes.recoverableWaste,width:65,height:133},{name:\"荧光灯\",source:\"g45\",type:GarbageTypes.harmfulWaste,width:90,height:118},{name:\"油漆桶\",source:\"g46\",type:GarbageTypes.harmfulWaste,width:65,height:143},{name:\"一次性纸杯\",source:\"g47\",type:GarbageTypes.dryWaste,width:76,height:116},{name:\"纸尿裤\",source:\"g48\",type:GarbageTypes.dryWaste,width:93,height:138},{name:\"纸箱\",source:\"g49\",type:GarbageTypes.recoverableWaste,width:112,height:118},{name:\"指甲油\",source:\"g50\",type:GarbageTypes.harmfulWaste,width:64,height:138}],e}(),transStores=function(e){var n=[];e.forEach(function(e){!function(e){for(var t=0,i=n;t<i.length;t++){var r=i[t];if(e.targetType==r.targetType&&e.itemType==r.itemType&&e.itemName==r.itemName)return!0}return!1}(e)&&n.push(e)}),e=n,n=[];var a=[];return e.forEach(function(e){!function(e){for(var t=0,i=n;t<i.length;t++){var r=i[t];if(e.itemName==r.itemName)return a.push(r.itemName),!0}return!1}(e)&&n.push(e)}),(e=n).forEach(function(e){-1!=a.indexOf(e.itemName)&&(e.targetType=e.itemType)}),e.map(function(e){return{targetName:getTargetName(e.targetType),isCorrect:e.targetType==e.itemType,itemName:e.itemName,itemTypeName:getTargetName(e.itemType)}})},getTargetName=function(e){switch(e){case GarbageTypes.recoverableWaste:return\"可回收物\";case GarbageTypes.harmfulWaste:return\"有害垃圾\";case GarbageTypes.wetWaste:return\"湿垃圾\";case GarbageTypes.dryWaste:return\"其他垃圾\"}},checkHit=function(e,t){var i=e.x,r=e.y,n=e.texture,a=n.width,s=n.height;return i>t.x&&r>t.y&&i+a<t.x+t.width&&r+s<t.y+t.height},removeChild=function(e){e&&e.parent&&e.parent.removeChild(e)},removeEle=function(e,t){var i=t.indexOf(e);0<=i&&t.splice(i,1)},shuffle=function(e){for(var t=e.length;t;){var i=Math.floor(Math.random()*t--),r=[e[t],e[i]];e[i]=r[0],e[t]=r[1]}return e},WrongTips=function(t){function e(){var e=t.call(this)||this;return e.img=new engine.Image,e.img.texture=getTextureByName(\"wrongTips\"),e.addChild(e.img),e.img.anchorX=44,e.img.anchorY=42.5,e.visible=!1,e}return tslib.__extends(e,t),e.prototype.play=function(e){this.visible=!0,props.sound&&playSound(\"wrongTipsMp3\");engine.Tween.get(this.img).set({x:0,y:0,scaleX:1,scaleY:1,alpha:1}).to({x:20},70).to({x:0},70).to({x:-20},70).to({x:0},70).wait(200).to({alpha:0},300),this.x=e.x+180,this.y=e.y},e}(engine.Sprite),getTargetRect=function(e,t){switch(e){case GarbageTypes.dryWaste:return t.dryWaste;case GarbageTypes.wetWaste:return t.wetWaste;case GarbageTypes.harmfulWaste:return t.harmfulWaste;case GarbageTypes.recoverableWaste:return t.recoverableWaste}},Conveyors=function(i){function e(e){var t=i.call(this)||this;return t.conveyorsPool=[],t.GarbageConfig=GarbageConfig.config,t.datas=[],t.wrapper=e,t}return tslib.__extends(e,i),e.prototype.initData=function(e,t){this.conveyor0=e,this.conveyor1=t},e.prototype.setDefault=function(){this.score=0,this.conveyorsPool.push(this.conveyor0),this.conveyorsPool.push(this.conveyor1);for(var e=shuffle(this.GarbageConfig.concat([])),t=0;t<GarbageConfig.config.length;t++)e[t].idx=t,e[t].isRight=!1,e[t].isMistake=!1,e[t].isOnStage=!1,this.datas.push(e[t]);for(t=0;t<5;t++){var i=this.datas[t],r=new engine.Sprite(getTextureByName(i.source));r.isWrong=!1,r.isRight=!1,i.isOnStage=!0,r.data=i,r.type=i.type,r.name=i.name,r.anchorX=i.width/2,r.anchorY=i.height,r.x=-i.width/2,r.y=40-i.height,this.conveyor1[\"idx\"+t].addChild(r),r.addEventListener(engine.MouseEvent.MOUSE_DOWN,this.onDown_garbage,this)}},e.prototype.startConveyors=function(){this.setDefault(),engine.gameStage.addEventListener(engine.Event.ENTER_FRAME,this.onEnterFrame,this)},e.prototype.onEnterFrame=function(e,t,i){if(this.score==(props.maxScore||100)&&(this.gameOver(),this.wrapper.stop(),props.sound&&playSound(\"gameOverMp3\")),this.conveyorsPool.forEach(function(e){e.x-=props.speed||3}),this.conveyorsPool[this.conveyorsPool.length-1].x<=764){var r=new Conveyor;r.x=this.conveyorsPool[this.conveyorsPool.length-1].x+764,this.wrapper.addChild(r),this.conveyorsPool.push(r)}else{for(var n=[],a=0;a<this.datas.length;a++){(u=this.datas[a]).isRight||u.isOnStage||n.push(u)}for(var s=this.conveyorsPool[this.conveyorsPool.length-1],o=0;o<5;o++)if(!s[\"idx\"+o].children[0]){var h=n.shift();if(!h)break;h.isOnStage=!0;var g=new engine.Sprite(getTextureByName(h.source));g.data=h,g.isWrong=!1,g.isRight=!1,g.type=h.type,g.name=h.name,g.anchorX=h.width/2,g.anchorY=h.height,g.x=-h.width/2,g.y=40-h.height,s[\"idx\"+o].addChild(g),g.addEventListener(engine.MouseEvent.MOUSE_DOWN,this.onDown_garbage,this)}}if(this.conveyorsPool[0].x<-750){for(var c=0;c<this.datas.length;c++){var u=this.datas[c],p=this.conveyorsPool[0].idx4;if(p.children[0]&&u.name==p.children[0].name){u.isOnStage=!1,removeEle(u,this.datas),this.datas.push(u),p.removeChild(p.children[0]);break}}this.conveyorsPool.shift()}else if(this.conveyorsPool[0].x<-600)for(c=0;c<this.datas.length;c++){var u=this.datas[c],l=this.conveyorsPool[0].idx3;if(l.children[0]&&u.name==l.children[0].name){u.isOnStage=!1,removeEle(u,this.datas),this.datas.push(u),l.removeChild(l.children[0]);break}}else if(this.conveyorsPool[0].x<-450)for(c=0;c<this.datas.length;c++){var u=this.datas[c],d=this.conveyorsPool[0].idx2;if(d.children[0]&&u.name==d.children[0].name){u.isOnStage=!1,removeEle(u,this.datas),this.datas.push(u),d.removeChild(d.children[0]);break}}else if(this.conveyorsPool[0].x<-300)for(c=0;c<this.datas.length;c++){var u=this.datas[c],y=this.conveyorsPool[0].idx1;if(y.children[0]&&u.name==y.children[0].name){u.isOnStage=!1,removeEle(u,this.datas),this.datas.push(u),y.removeChild(y.children[0]);break}}else if(this.conveyorsPool[0].x<-150)for(c=0;c<this.datas.length;c++){var u=this.datas[c],m=this.conveyorsPool[0].idx0;if(m.children[0]&&u.name==m.children[0].name){u.isOnStage=!1,removeEle(u,this.datas),this.datas.push(u),m.removeChild(m.children[0]);break}}},e.prototype.addscore=function(){this.score+=props.onceScore||2,engine.globalEvent.dispatchEvent(\"recycling-score-update\",{score:this.score})},e.prototype.gameOver=function(){engine.gameStage.removeEventListener(engine.Event.ENTER_FRAME,this.onEnterFrame,this),engine.globalEvent.dispatchEvent(\"recycling-game-end\",transStores(this.stores))},e.prototype.onDown_garbage=function(e){this._currentDragView&&removeChild(this._currentDragView);var t=e.target,i=new engine.Sprite(t.texture);this._currentDragView=i,(this._currentTarget=t).scaleX=t.scaleY=0,this.wrapper.addChild(i),i.x=e.stageX-t.texture.width/2,i.y=e.stageY-t.texture.height/2,i.type=t.type,i.name=t.name,this.wrapper.addEventListener(engine.MouseEvent.MOUSE_UP,this.onStageMouseUp,this),this.wrapper.addEventListener(engine.MouseEvent.MOUSE_MOVE,this.onStageMouseMove,this)},e.prototype.onStageMouseMove=function(e){var t=this._currentDragView;t.x=e.stageX-t.texture.width/2,t.y=e.stageY-t.texture.height/2},e.prototype.onStageMouseUp=function(e){var t,i=this;this.wrapper.removeEventListener(engine.MouseEvent.MOUSE_UP,this.onStageMouseUp,this),this.wrapper.removeEventListener(engine.MouseEvent.MOUSE_MOVE,this.onStageMouseMove,this),this._currentDragView&&((t=this.checkHitRect())?(t==this._currentDragView.type?(this.addscore(),this.wrapper.rightTips.play(getTargetRect(t,this.wrapper)),this._currentTarget.data.isRight=!0):(engine.Tween.get(this._currentTarget).to({scaleX:1,scaleY:1},300).call(function(){}),this.wrapper.wrongTips.play(getTargetRect(t,this.wrapper))),this.stores.push({targetType:t,itemType:this._currentDragView.type,itemName:this._currentDragView.name})):engine.Tween.get(this._currentTarget).to({scaleX:1,scaleY:1},300).call(function(){}),this._currentDragView.anchorX=this._currentDragView.texture.width/2,this._currentDragView.anchorY=this._currentDragView.texture.height/2,engine.Tween.get(this._currentDragView).to({scaleX:0,scaleY:0},300).call(function(){removeChild(i._currentDragView)}))},e.prototype.clear=function(){this.conveyor0.x=0,this.conveyor1.x=764,this.conveyorsPool.forEach(function(e){e.clear()}),this.conveyorsPool=[],this.datas=[],this.stores=[]},e.prototype.timeout=function(){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()},e.prototype.checkHitRect=function(){return checkHit(this._currentDragView,this.wrapper.wetWaste)?GarbageTypes.wetWaste:checkHit(this._currentDragView,this.wrapper.harmfulWaste)?GarbageTypes.harmfulWaste:checkHit(this._currentDragView,this.wrapper.dryWaste)?GarbageTypes.dryWaste:checkHit(this._currentDragView,this.wrapper.recoverableWaste)?GarbageTypes.recoverableWaste:null},e}(engine.Sprite),uiConfig=function(){return[{id:\"playBg\",texture:\"playBg\"},{id:\"idler0\",texture:\"idlerWheel\",pos:[75,1038],anchor:[20,21.5]},{id:\"idler1\",texture:\"idlerWheel\",pos:[175,1038],anchor:[20,21.5]},{id:\"idler2\",texture:\"idlerWheel\",pos:[275,1038],anchor:[20,21.5]},{id:\"idler3\",texture:\"idlerWheel\",pos:[375,1038],anchor:[20,21.5]},{id:\"idler4\",texture:\"idlerWheel\",pos:[475,1038],anchor:[20,21.5]},{id:\"idler5\",texture:\"idlerWheel\",pos:[575,1038],anchor:[20,21.5]},{id:\"idler6\",texture:\"idlerWheel\",pos:[675,1038],anchor:[20,21.5]}]},setGuide=function(){try{window.localStorage&&window.localStorage.setItem&&localStorage.setItem(\"recyclingGuide\",\"1\")}catch(e){console.log(\"setguide--err\",e)}},createBg=function(e){void 0===e&&(e=1);var t=new engine.Graphics;return t.beginFill(0),t.drawRect(0,0,750,1624),t.endFill(),t.alpha=e,t},createImg=function(e){return new engine.Sprite(getTextureByName(e))},CountDownGroup=function(t){function e(){var e=t.call(this)||this;return e.addChild(createBg(.6)),e.num1=createImg(\"num1\"),e.num2=createImg(\"num2\"),e.num3=createImg(\"num3\"),e.go=createImg(\"go\"),e.go.anchorX=240,e.go.anchorY=171.5,e.num1.anchorX=125.5,e.num1.anchorY=189,e.num2.anchorX=149.5,e.num2.anchorY=191.5,e.num3.anchorX=148.5,e.num3.anchorY=191.5,e.go.x=135,e.go.y=353.5,e.num1.x=249.5,e.num1.y=340,e.num2.x=225.5,e.num2.y=334.5,e.num3.x=226.5,e.num3.y=333.5,e.addChild(e.num1),e.addChild(e.num2),e.addChild(e.num3),e.addChild(e.go),e.visible=!1,e.reset(),e}return tslib.__extends(e,t),e.prototype.reset=function(){this.go.alpha=this.num1.alpha=this.num2.alpha=this.num3.alpha=0,this.go.scaleX=this.num1.scaleX=this.num2.scaleX=this.num3.scaleX=3,this.go.scaleY=this.num1.scaleY=this.num2.scaleY=this.num3.scaleY=3},e.prototype.startCountDown=function(){return tslib.__awaiter(this,void 0,void 0,function(){var i=this;return tslib.__generator(this,function(e){return[2,new Promise(function(t){i.reset(),i.visible=!0,i.num3.alpha=1;var e=engine.Tween.get(i.num3);props.sound&&playSound(\"numCountDown\"),e.to({scaleX:.8,scaleY:.8},200).to({scaleX:1,scaleY:1},100).wait(500).to({scaleX:0,scaleY:0},200).call(function(){i.num2.alpha=1;var e=engine.Tween.get(i.num2);props.sound&&playSound(\"numCountDown\"),e.to({scaleX:.8,scaleY:.8},200).to({scaleX:1,scaleY:1},100).wait(500).to({scaleX:0,scaleY:0},200).call(function(){i.num1.alpha=1;var e=engine.Tween.get(i.num1);props.sound&&playSound(\"numCountDown\"),e.to({scaleX:.8,scaleY:.8},200).to({scaleX:1,scaleY:1},100).wait(500).to({scaleX:0,scaleY:0},200).call(function(){i.go.alpha=1;var e=engine.Tween.get(i.go);props.sound&&props.sound&&playSound(\"goMp3\"),e.to({scaleX:.8,scaleY:.8},200).to({scaleX:1,scaleY:1},100).wait(500).call(function(){i.visible=!1,t()})})})})})]})})},e}(engine.Sprite),GuideView=function(t){function e(){var e=t.call(this)||this;return e.initUI(),e.visible=!1,e}return tslib.__extends(e,t),e.prototype.initUI=function(){this.addChild(createBg(.6)),this.guideBg=createImg(\"guideBg\"),this.addChild(this.guideBg),this.guideEle=createImg(\"guideEle\"),this.addChild(this.guideEle),this.guideBg.x=403,this.guideBg.y=565,this.guideEle.x=361,this.guideEle.y=877,this.guideEle.anchorX=14,this.guideEle.anchorY=88,this.guideEle.mouseEnabled=this.guideEle.mouseChildren=!0;var e=createSvga(\"guideTips\");this.svga=e,this.addChild(e),e.gotoAndStop(1),e.mouseEnabled=e.mouseChildren=!1},e.prototype.checkHit=function(e,t,i,r){var n=new engine.Rectangle(403,565,252,297);return e>n.x&&t>n.y&&e+i<n.x+n.width&&t+r<n.y+n.height},e.prototype.startGuide=function(){return tslib.__awaiter(this,void 0,void 0,function(){var s=this;return tslib.__generator(this,function(e){return[2,new Promise(function(t){s.visible=!0,s.svga.gotoAndStop(1),s.svga.play(!1,!0),s.guideEle.scaleX=1,s.guideEle.scaleY=1;function i(e){s.stage.removeEventListener(engine.MouseEvent.MOUSE_MOVE,n,s),s.checkHit(s.guideEle.x,s.guideEle.y,s.guideEle.width,s.guideEle.height)?(s.guideEle.removeEventListener(engine.MouseEvent.MOUSE_DOWN,a,s),s.guideEle.anchorX=14,s.guideEle.anchorY=44,engine.Tween.get(s.guideEle).to({scaleX:0,scaleY:0},300).call(function(){s.visible=!1,t()})):(s.svga.visible=!0,s.guideEle.x=361,s.guideEle.y=877,engine.Tween.get(s.guideEle).set({scaleX:0,scaleY:0}).to({scaleX:1,scaleY:1},300))}var r=[0,0],n=function(e){s.guideEle.x=e.stageX-r[0],s.guideEle.y=e.stageY-r[1]},a=function(e){r=[e.localX,e.localY],s.svga.visible=!1,s.stage.once(engine.MouseEvent.MOUSE_UP,i,s),s.stage.addEventListener(engine.MouseEvent.MOUSE_MOVE,n,s)};s.guideEle.addEventListener(engine.MouseEvent.MOUSE_DOWN,a,s)})]})})},e}(engine.Sprite),RightTips=function(t){function e(){var e=t.call(this)||this;return e.SCORE=props.onceScore||2,e.img=new engine.Image,e.img.texture=getTextureByName(\"rightTips\"),e.addChild(e.img),e.img.anchorX=44,e.img.anchorY=42.5,e.visible=!1,e.txt=new engine.TextField,e.addChild(e.txt),e.txt.text=\"+\"+e.SCORE,e.txt.size=60,e.txt.fillColor=\"#437726\",engine.playSound,e}return tslib.__extends(e,t),e.prototype.play=function(e){props.sound&&playSound(\"rightTipsSound\"),this.visible=!0,this.txt.x=100,engine.Tween.get(this.txt).set({y:60,alpha:1}).to({y:-50},500).to({alpha:0}),engine.Tween.get(this.img).set({x:0,y:0,scaleX:0,scaleY:0,alpha:1}).to({scaleX:1,scaleY:1},200,engine.Ease.getBackOut(1)).wait(200).to({alpha:0},300),this.x=e.x+180,this.y=e.y},e}(engine.Sprite),GameView=function(t){function e(){var e=t.call(this)||this;return e._timeCounter=0,e.guidenew=!1,e.once(engine.Event.ADDED_TO_STAGE,e.setup,e),e}return tslib.__extends(e,t),e.prototype.configUI=function(){var e={};this.uiMap=e;for(var t=0,i=uiConfig();t<i.length;t++){var r=i[t],n=r.id,a=r.texture,s=r.pos,o=r.anchor,h=new engine.Sprite(getTextureByName(a));this.addChild(h),e[n]=h,o&&(h.anchorX=o[0],h.anchorY=o[1]),s&&(h.x=s[0],h.y=s[1],o&&(h.x=s[0]-h.anchorX,h.y=s[1]-h.anchorY))}this.configConveyors(),this.createRects(),this.countdown=new CountDownGroup,this.addChild(this.countdown),this.guide=new GuideView,this.addChild(this.guide),this.wrongTips=new WrongTips,this.rightTips=new RightTips,this.addChild(this.wrongTips),this.addChild(this.rightTips)},e.prototype.createRects=function(){this.wetWaste=this.createRect(104,565,252,297,16777215),this.harmfulWaste=this.createRect(104,232,252,297,16711680),this.dryWaste=this.createRect(403,232,252,297,0),this.recoverableWaste=this.createRect(403,565,252,297,255)},e.prototype.createRect=function(e,t,i,r,n){var a=new engine.Rectangle(e,t,i,r),s=new engine.Sprite;this.addChild(s),s.x=e,s.y=t;var o=new engine.Graphics;return o.alpha=0,o.beginFill(n),o.drawRect(0,0,i,r),o.endFill(),s.addChild(o),a},e.prototype.configConveyors=function(){var e=new Conveyor,t=new Conveyor;this.addChild(e),this.addChild(t),e.x=0,t.x=764,this.conveyors=new Conveyors(this),this.conveyors.initData(e,t)},e.prototype.playAni=function(){var t=this;[\"idler0\",\"idler1\",\"idler2\",\"idler3\",\"idler4\",\"idler5\",\"idler6\"].map(function(e){return t.uiMap[e]}).forEach(function(e){engine.Tween.get(e,{loop:!0}).to({rotation:-360},1e3)})},e.prototype.stopAni=function(){var t=this;[\"idler0\",\"idler1\",\"idler2\",\"idler3\",\"idler4\",\"idler5\",\"idler6\"].map(function(e){return t.uiMap[e]}).forEach(function(e){engine.Tween.removeTweens(e)})},e.prototype.start=function(){return tslib.__awaiter(this,void 0,void 0,function(){var t=this;return tslib.__generator(this,function(e){switch(e.label){case 0:return this._timeCounter=0,props.isNewPlayer||this.guidenew?[3,2]:[4,this.guide.startGuide()];case 1:e.sent(),setGuide(),this.guidenew=!0,e.label=2;case 2:return this.conveyors.clear(),[4,this.countdown.startCountDown()];case 3:return e.sent(),this.startGame(),engine.globalEvent.dispatchEvent(\"recycling-time-update\",{second:this.getSecond()}),this._timer=setInterval(function(){t.onTimer()},1e3),[2]}})})},e.prototype.startGame=function(){this.playAni(),this.conveyors.startConveyors()},e.prototype.stopGame=function(){this.stopAni()},e.prototype.getSecond=function(){return props.time-this._timeCounter},e.prototype.onTimer=function(){this._timeCounter++,engine.globalEvent.dispatchEvent(\"recycling-time-update\",{second:this.getSecond()}),0==this.getSecond()&&(this.stop(),this.conveyors.timeout(),props.sound&&playSound(\"gameOverMp3\"))},e.prototype.stop=function(){clearInterval(this._timer),this.stopGame()},e.prototype.setup=function(){console.log(\"onSteup\",props),this.configUI()},e.prototype.onDown=function(e){},e.prototype.stageOnUp=function(e){},e.prototype.onSuccess=function(){},e.prototype.onMove=function(e){},e}(engine.Container),GameWrapper=function(i){function e(){var e=i.call(this)||this;engine.globalEvent.addEventListener(\"recycling-start\",e.start,e),engine.globalEvent.addEventListener(\"recycling-sound-update\",e.updateSound,e),engine.globalEvent.addEventListener(\"recycling-stop\",e.stop,e);var t=e._gameView=new GameView;return e.addChild(t),e}return tslib.__extends(e,i),e.prototype.updateSound=function(e){injectProps(e.data)},e.prototype.start=function(e){injectProps(e.data),this._gameView.start()},e.prototype.stop=function(e){this._gameView.stop()},e}(engine.Container);function index(e){return prepareProps(),injectProps(e),new GameWrapper}module.exports=index;\n"
} }
{
"name": "大转盘",
"desc": "大转盘模块",
"props": {
"iconSize": {
"alias": "奖品图的大小",
"type": "array<number>",
"default": "80,80"
},
"diameter": {
"alias": "圆盘直径",
"type": "number",
"default": "600"
},
"prizesRadius": {
"alias": "奖品距离圆心的距离",
"type": "number",
"default": 250
},
"nameColor": {
"alias": "奖品名称的字体颜色",
"type": "string",
"default": "#444444"
},
"nameSize": {
"alias": "奖品名称的字体大小",
"type": "number",
"default": 20
},
"iconY": {
"alias": "奖品名称的Y轴偏移",
"type": "number",
"default": 30
},
"rotationBg": {
"alias": "背景旋转",
"type": "number",
"default": 30
}
},
"assets": [
{
"name": "大转盘背景",
"url": "//yun.duiba.com.cn/aurora/assets/559177b3c0d4245d245b5cdfa31ba9d9dc20223c.png",
"uuid": "d3ce99da-89e1-447d-8c52-b3f391925c3c",
"ext": ".png"
}
],
"events": {
"in": {
"turnplate-reset": {
"alias": "重置",
"data": {
"prizes": "所有奖品"
}
},
"turnplate-start": {
"alias": "开始",
"data": {
"prizeId": "中奖的奖品id"
}
}
},
"out": {
"turnplate-over": {
"alias": "转盘停止",
"data": {
"prizeId": "中奖的奖品id"
}
}
}
},
"id": "turnplate",
"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.turnplate = 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\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 _this.wheelPrizeRotation = [];\n\t _this.items = [];\n\t _this.itemsCon = [];\n\t _this.itemsLabel = [];\n\t _this.itemsIcon = [];\n\t _this.once(engine.Event.ADDED_TO_STAGE, _this.setup, _this);\n\t engine.globalEvent.addEventListener('turnplate-reset', _this.reset, _this);\n\t engine.globalEvent.addEventListener('turnplate-start', _this.start, _this);\n\t return _this;\n\t }\n\t GameWrapper.prototype.setup = function () {\n\t this.turnplate = new engine.Container();\n\t this.turnplate.x = 0;\n\t this.turnplate.y = 0;\n\t this.turnplate.rotation = -90;\n\t this.turnplate.width = props.diameter;\n\t this.turnplate.height = props.diameter;\n\t this.turnplate.anchorX = this.turnplate.width / 2;\n\t this.turnplate.anchorY = this.turnplate.height / 2;\n\t this.addChild(this.turnplate);\n\t this._turnplateBG = new engine.Container();\n\t this._turnplateBG.width = props.diameter;\n\t this._turnplateBG.height = props.diameter;\n\t this._turnplateBG.anchorX = this.turnplate.width / 2;\n\t this._turnplateBG.anchorY = this.turnplate.height / 2;\n\t this._turnplateBG.rotation = props.rotationBg;\n\t this.turnplate.addChild(this._turnplateBG);\n\t this.turnplateBg = new engine.Sprite(getTextureByName('大转盘背景'));\n\t this.turnplateBg.x = 0;\n\t this.turnplateBg.y = 0;\n\t this.turnplateBg.width = this.turnplate.width;\n\t this.turnplateBg.height = this.turnplate.height;\n\t this._turnplateBG.addChild(this.turnplateBg);\n\t };\n\t GameWrapper.prototype.reset = function (event) {\n\t injectProps(event.data);\n\t this.prizes = event.data.prizes;\n\t console.log(this.prizes);\n\t for (var i = 0; i < this.items.length; i++) {\n\t this.itemsCon[i].removeChild(this.itemsLabel[i]);\n\t this.itemsCon[i].removeChild(this.itemsIcon[i]);\n\t this.items[i].removeChild(this.itemsCon[i]);\n\t this.turnplate.removeChild(this.items[i]);\n\t }\n\t for (var i = 0; i < this.prizes.length; i++) {\n\t this.items[i] = new engine.Container();\n\t this.itemsCon[i] = new engine.Container();\n\t this.itemsCon[i].x = props.prizesRadius;\n\t this.itemsCon[i].rotation = 90;\n\t this.items[i].x = this.turnplate.width / 2;\n\t this.items[i].y = this.turnplate.height / 2;\n\t this.turnplate.addChild(this.items[i]);\n\t this.itemsLabel[i] = new engine.Label();\n\t this.itemsLabel[i].text = this.prizes[i].name;\n\t this.itemsLabel[i].width = 200;\n\t this.itemsLabel[i].x = -this.itemsLabel[i].width / 2;\n\t this.itemsLabel[i].textAlign = \"center\";\n\t this.itemsLabel[i].fillColor = props.nameColor;\n\t this.itemsLabel[i].size = props.nameSize;\n\t this.itemsIcon[i] = new engine.Sprite();\n\t this.itemsIcon[i].width = props.iconSize[0];\n\t this.itemsIcon[i].height = props.iconSize[1];\n\t this.itemsIcon[i].x = -this.itemsIcon[i].width / 2;\n\t this.itemsIcon[i].y = props.iconY;\n\t this.itemsIcon[i].texture = engine.Texture.from(this.prizes[i].icon);\n\t this.itemsCon[i].addChild(this.itemsLabel[i]);\n\t this.itemsCon[i].addChild(this.itemsIcon[i]);\n\t this.items[i].addChild(this.itemsCon[i]);\n\t var _rotation = (i) * (360 / this.prizes.length);\n\t this.items[i].rotation = _rotation;\n\t this.wheelPrizeRotation[this.prizes[i].prizeId] = _rotation;\n\t }\n\t this.turnplate.rotation = -90;\n\t engine.Tween.removeTweens(this.turnplate);\n\t engine.Tween.get(this.turnplate, { loop: true })\n\t .to({ rotation: 360 - 90 }, 5000);\n\t };\n\t GameWrapper.prototype.start = function (event) {\n\t var _this = this;\n\t injectProps(event.data);\n\t engine.Tween.removeTweens(this.turnplate);\n\t var prizeId = event.data.prizeId;\n\t engine.Tween.get(this.turnplate)\n\t .to({ rotation: 7200 - this.wheelPrizeRotation[prizeId] - 90 }, 8000, engine.Ease.circInOut)\n\t .wait(500)\n\t .call(function () {\n\t _this.turnplate.rotation = 360 - _this.wheelPrizeRotation[prizeId] + 0.001 - 90;\n\t engine.globalEvent.dispatchEvent('turnplate-over', {\n\t prizeId: prizeId\n\t });\n\t });\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"
}
{
"name": "消消乐",
"desc": "消消乐模块",
"props": {
"threeEscore": {
"alias": "三消加分",
"type": "number",
"default": 1
},
"fourEscore": {
"alias": "四消加分",
"type": "number",
"default": 2
},
"moreEscore": {
"alias": "多消加分",
"type": "number",
"default": 3
}
},
"assets": [
{
"name": "底图",
"url": "//yun.duiba.com.cn/aurora/assets/d2b599cece087d5ab315cd1392f94139941280bb.png",
"uuid": "map",
"ext": ".png"
},
{
"name": "狗",
"url": "//yun.duiba.com.cn/aurora/assets/26780d2fb48d047e111857da9e82fe49b0d310a8.png",
"uuid": "gdog",
"ext": ".png"
},
{
"name": "鸟",
"url": "//yun.duiba.com.cn/aurora/assets/39a1a8865ca101d6fa29325bf1fc37c26190e382.png",
"uuid": "pbird",
"ext": ".png"
},
{
"name": "牛",
"url": "//yun.duiba.com.cn/aurora/assets/2e74dd7faab031f71e644dad340b4c83791b8bf0.png",
"uuid": "hniu",
"ext": ".png"
},
{
"name": "兔子",
"url": "//yun.duiba.com.cn/aurora/assets/6c4033a865bc6c73b680bc31d29de55ac347d397.png",
"uuid": "bribbit",
"ext": ".png"
},
{
"name": "猪",
"url": "//yun.duiba.com.cn/aurora/assets/c14e003bb3847bd7ab30eb6ba0915124f207bc31.png",
"uuid": "rpig",
"ext": ".png"
},
{
"name": "选中框",
"url": "//yun.duiba.com.cn/aurora/assets/c6ed5f3f94958e74fcbfc1da56e99795056fd75a.png",
"uuid": "selected",
"ext": ".png"
},
{
"name": "交换箭头",
"url": "//yun.duiba.com.cn/aurora/assets/438ca6e721eab32728aceaca5df0095e1387f340.png",
"uuid": "jiantou",
"ext": ".png"
},
{
"name": "房子动画",
"url": "//yun.duiba.com.cn/aurora/assets/10d6c3c657e4f26eee2e6f1edca36ec468d57353.svga",
"uuid": "homeani",
"ext": ".svga"
},
{
"name": "夜晚房子",
"url": "//yun.duiba.com.cn/aurora/assets/aa9261273423b4b9343b4526b7e5f71a6a35a345.svga",
"uuid": "homenight",
"ext": ".svga"
}
],
"events": {
"in": {
"game-init": {
"alias": "初始化第一关",
"data": {}
},
"game-reset": {
"alias": "关卡通过重玩之类的重置关卡",
"data": {}
},
"game-start": {
"alias": "开始"
},
"game-pause": {
"alias": "暂停"
},
"game-resume": {
"alias": "继续"
},
"game-recordcomp": {
"alias": "记录完毕"
}
},
"out": {
"game-score-update": {
"alias": "分数更新",
"data": {
"score": "分数"
}
},
"game-time-update": {
"alias": "倒计时更新",
"data": {
"time": "剩余时间"
}
},
"game-over": {
"alias": "游戏结束",
"data": {
"score": "分数",
"reason": "结束原因(1:时间到了,2:过关)"
}
},
"game-record": {
"alias": "游戏记录",
"data": {
"score": "操作得分",
"seq": "操作步骤号",
"sptime": "操纵开始时间",
"eptime": "操作结束时间"
}
}
}
},
"id": "xiaoxiaole",
"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.xiaoxiaole = factory(global.tslib));\n}(this, (function (tslib) { 'use strict';\n\n\tvar props = {};\r\n\tfunction prepareProps() {\r\n\t var metaProps = getProps();\r\n\t engine.injectProp(props, metaProps);\r\n\t}\r\n\tfunction injectProps(p) {\r\n\t engine.injectProp(props, p);\r\n\t}\r\n\t//# sourceMappingURL=props.js.map\n\n\tfunction getTexture(uuid) {\r\n\t return engine.Texture.from(getAssetByUUID(uuid).uuid);\r\n\t}\r\n\tfunction getTextureByName(name) {\r\n\t return getTexture(engine.getAssetByName(name).uuid);\r\n\t}\r\n\t//# sourceMappingURL=utils.js.map\n\n\tvar Element = (function (_super) {\r\n\t tslib.__extends(Element, _super);\r\n\t function Element() {\r\n\t var _this = _super.call(this) || this;\r\n\t _this.width = MapData.itemsize;\r\n\t _this.height = MapData.itemsize;\r\n\t _this.anchorX = MapData.itemsize / 2;\r\n\t _this.eimage = new engine.Image();\r\n\t _this.addChild(_this.eimage);\r\n\t _this.touch = true;\r\n\t _this.addEventListener(engine.MouseEvent.MOUSE_DOWN, _this.selectele, _this);\r\n\t _this.addEventListener(engine.MouseEvent.MOUSE_MOVE, _this.changemove, _this);\r\n\t return _this;\r\n\t }\r\n\t Object.defineProperty(Element.prototype, \"touch\", {\r\n\t set: function (touch) {\r\n\t this.mouseEnabled = touch;\r\n\t this.mouseChildren = touch;\r\n\t },\r\n\t enumerable: true,\r\n\t configurable: true\r\n\t });\r\n\t Element.prototype.init = function (type) {\r\n\t this.anchorY = MapData.itemsize;\r\n\t this.scaleX = 1;\r\n\t this.scaleY = 1;\r\n\t this.alpha = 1;\r\n\t this.type = type;\r\n\t var ename = MapData.getEtypeImgName(type);\r\n\t this.eimage.texture = MapData.getEtypeImgTex(type);\r\n\t var imgwid = this.eimage.texture.width;\r\n\t var imghei = this.eimage.texture.height;\r\n\t this.eimage.x = (this.width - imgwid) / 2;\r\n\t this.eimage.y = (this.height - imghei) / 2;\r\n\t };\r\n\t Element.prototype.setrc = function (r, c) {\r\n\t this.inrow = r;\r\n\t this.incol = c;\r\n\t };\r\n\t Element.prototype.selectele = function (e) {\r\n\t engine.globalEvent.dispatchEvent(GameEvent.SelectEle, {\r\n\t r: this.inrow,\r\n\t c: this.incol,\r\n\t type: \"mouse_down\"\r\n\t });\r\n\t };\r\n\t Element.prototype.changemove = function (e) {\r\n\t engine.globalEvent.dispatchEvent(GameEvent.SelectEle, {\r\n\t r: this.inrow,\r\n\t c: this.incol,\r\n\t type: \"mouse_move\"\r\n\t });\r\n\t };\r\n\t Object.defineProperty(Element.prototype, \"factor\", {\r\n\t get: function () {\r\n\t return 0;\r\n\t },\r\n\t set: function (value) {\r\n\t this.x = (1 - value) * (1 - value) * this.p1x + 2 * value * (1 - value) * this.c1x + value * value * this.p2x;\r\n\t this.y = (1 - value) * (1 - value) * this.p1y + 2 * value * (1 - value) * this.c1y + value * value * this.p2y;\r\n\t var mscale = (1 - value) * (1 - value) * 1 + 2 * value * (1 - value) * 0.6 + value * value * 0.35;\r\n\t this.scaleX = mscale;\r\n\t this.scaleY = mscale;\r\n\t },\r\n\t enumerable: true,\r\n\t configurable: true\r\n\t });\r\n\t Element.prototype.flyToHome = function (tx, ty, time) {\r\n\t var _this = this;\r\n\t this.p1x = this.x;\r\n\t this.p1y = this.y + 20;\r\n\t this.c1x = (this.p1x - tx) / 4 + tx;\r\n\t this.c1y = ty;\r\n\t this.p2x = tx;\r\n\t this.p2y = ty;\r\n\t engine.Tween.removeTweens(this);\r\n\t engine.Tween.get(this).to({\r\n\t scaleX: 1.1,\r\n\t scaleY: 1.1\r\n\t }, 200)\r\n\t .to({\r\n\t scaleX: 1.1,\r\n\t scaleY: 0.88\r\n\t }, 100)\r\n\t .to({\r\n\t scaleX: 0.98,\r\n\t scaleY: 0.98,\r\n\t y: this.y + 20\r\n\t }, 100)\r\n\t .call(function () {\r\n\t _this.factor = 0;\r\n\t engine.Tween.get(_this).to({\r\n\t factor: 1\r\n\t }, 450)\r\n\t .call(function () {\r\n\t var nodeparent = _this.parent;\r\n\t nodeparent && nodeparent.removeChild(_this);\r\n\t MapData.recoverEle(_this, _this.type);\r\n\t });\r\n\t });\r\n\t };\r\n\t Element.prototype.changePos = function (tpos) {\r\n\t var _this = this;\r\n\t var nx = this.x;\r\n\t var ny = this.y;\r\n\t var tx = tpos[0];\r\n\t var ty = tpos[1];\r\n\t var dis = MapData.getDistance([nx, ny], tpos);\r\n\t var time = Math.ceil(dis / MapData.anispeed * 1000);\r\n\t engine.Tween.removeTweens(this);\r\n\t var pro = new Promise(function (res) {\r\n\t engine.Tween.get(_this, { loop: false }).to({\r\n\t x: tx,\r\n\t y: ty\r\n\t }, time)\r\n\t .call(function () {\r\n\t res();\r\n\t });\r\n\t });\r\n\t return pro;\r\n\t };\r\n\t return Element;\r\n\t}(engine.Container));\r\n\t//# sourceMappingURL=Element.js.map\n\n\tvar ElementType;\r\n\t(function (ElementType) {\r\n\t ElementType[ElementType[\"gdog\"] = 1] = \"gdog\";\r\n\t ElementType[ElementType[\"pbird\"] = 2] = \"pbird\";\r\n\t ElementType[ElementType[\"hniu\"] = 3] = \"hniu\";\r\n\t ElementType[ElementType[\"bribbit\"] = 4] = \"bribbit\";\r\n\t ElementType[ElementType[\"rpig\"] = 5] = \"rpig\";\r\n\t})(ElementType || (ElementType = {}));\r\n\tvar GameEvent;\r\n\t(function (GameEvent) {\r\n\t GameEvent[\"SelectEle\"] = \"SelectEle\";\r\n\t})(GameEvent || (GameEvent = {}));\r\n\tvar MapData = (function () {\r\n\t function MapData() {\r\n\t }\r\n\t MapData.getRy = function (r) {\r\n\t return this.paddingh + r * (this.itemsize + this.paddinghi);\r\n\t };\r\n\t MapData.getCx = function (c) {\r\n\t return this.paddingw + c * (this.itemsize + this.paddingwi);\r\n\t };\r\n\t MapData.getRCPos = function (r, c) {\r\n\t var x = this.getCx(c);\r\n\t var y = this.getRy(r);\r\n\t return [x, y];\r\n\t };\r\n\t MapData.adaptElePos = function (pos, wid, hei) {\r\n\t var x = pos[0] + (this.itemsize - wid) / 2;\r\n\t var y = pos[1] + (this.itemsize - hei) / 2;\r\n\t return [x, y];\r\n\t };\r\n\t MapData.getEtypeImgName = function (type) {\r\n\t var ename;\r\n\t switch (type) {\r\n\t case ElementType.gdog:\r\n\t ename = \"\";\r\n\t break;\r\n\t case ElementType.pbird:\r\n\t ename = \"\";\r\n\t break;\r\n\t case ElementType.hniu:\r\n\t ename = \"\";\r\n\t break;\r\n\t case ElementType.bribbit:\r\n\t ename = \"兔子\";\r\n\t break;\r\n\t case ElementType.rpig:\r\n\t ename = \"\";\r\n\t break;\r\n\t default:\r\n\t console.error(\"未定义元素类型\");\r\n\t break;\r\n\t }\r\n\t return ename;\r\n\t };\r\n\t MapData.getEtypeImgTex = function (type) {\r\n\t var etex;\r\n\t switch (type) {\r\n\t case ElementType.gdog:\r\n\t if (!this.gdotTex) {\r\n\t this.gdotTex = getTextureByName(\"\");\r\n\t console.log(\"新素材加载---狗\");\r\n\t }\r\n\t etex = this.gdotTex;\r\n\t break;\r\n\t case ElementType.pbird:\r\n\t if (!this.pbirdTex) {\r\n\t this.pbirdTex = getTextureByName(\"\");\r\n\t console.log(\"新素材加载---鸟\");\r\n\t }\r\n\t etex = this.pbirdTex;\r\n\t break;\r\n\t case ElementType.hniu:\r\n\t if (!this.hniuTex) {\r\n\t this.hniuTex = getTextureByName(\"\");\r\n\t console.log(\"新素材加载---牛\");\r\n\t }\r\n\t etex = this.hniuTex;\r\n\t break;\r\n\t case ElementType.bribbit:\r\n\t if (!this.bribbitTex) {\r\n\t this.bribbitTex = getTextureByName(\"兔子\");\r\n\t console.log(\"新素材加载---兔子\");\r\n\t }\r\n\t etex = this.bribbitTex;\r\n\t break;\r\n\t case ElementType.rpig:\r\n\t if (!this.rpigTex) {\r\n\t this.rpigTex = getTextureByName(\"\");\r\n\t console.log(\"新素材加载---猪\");\r\n\t }\r\n\t etex = this.rpigTex;\r\n\t break;\r\n\t default:\r\n\t console.error(\"未定义元素类型\");\r\n\t break;\r\n\t }\r\n\t return etex;\r\n\t };\r\n\t MapData.getRandEtype = function () {\r\n\t var eletypeArr = [ElementType.gdog, ElementType.pbird, ElementType.hniu, ElementType.bribbit, ElementType.rpig];\r\n\t var etype = eletypeArr[Math.floor(Math.random() * eletypeArr.length)];\r\n\t return etype;\r\n\t };\r\n\t MapData.initPoolEle = function () {\r\n\t this.gdotTex = getTextureByName(\"\");\r\n\t this.pbirdTex = getTextureByName(\"\");\r\n\t this.hniuTex = getTextureByName(\"\");\r\n\t this.bribbitTex = getTextureByName(\"兔子\");\r\n\t this.rpigTex = getTextureByName(\"\");\r\n\t var eletypes = [ElementType.gdog, ElementType.pbird, ElementType.hniu, ElementType.bribbit, ElementType.rpig];\r\n\t this.elePool[\"ele\"] = new Array();\r\n\t for (var i = 0; i < eletypes.length; i++) {\r\n\t for (var a = 0; a < 5; a++) {\r\n\t var iele = new Element();\r\n\t this.elePool[\"ele\"].push(iele);\r\n\t }\r\n\t }\r\n\t this.elePool[\"score\"] = new Array();\r\n\t for (var t = 0; t < 8; t++) {\r\n\t var itxt = new engine.Label();\r\n\t itxt.size = 66;\r\n\t itxt.width = 200;\r\n\t itxt.height = 70;\r\n\t itxt.textAlign = engine.TEXT_ALIGN.CENTER;\r\n\t itxt.verticalAlign = engine.VERTICAL_ALIGN.MIDDLE;\r\n\t itxt.anchorY = 35;\r\n\t itxt.anchorX = 100;\r\n\t itxt.bold = true;\r\n\t this.elePool[\"score\"].push(itxt);\r\n\t }\r\n\t };\r\n\t MapData.getOneEle = function (type) {\r\n\t var ele;\r\n\t if (this.elePool[\"ele\"]) {\r\n\t if (this.elePool[\"ele\"].length > 0) {\r\n\t ele = this.elePool[\"ele\"].shift();\r\n\t }\r\n\t }\r\n\t else {\r\n\t this.elePool[\"ele\"] = new Array();\r\n\t }\r\n\t if (!ele) {\r\n\t console.error(\"创建了新的了ele\");\r\n\t ele = new Element();\r\n\t }\r\n\t ele.name = \"ele_\" + this.eleidx;\r\n\t this.eleidx += 1;\r\n\t ele.init(type);\r\n\t return ele;\r\n\t };\r\n\t MapData.getOneTxt = function () {\r\n\t var itxt;\r\n\t if (this.elePool[\"score\"]) {\r\n\t if (this.elePool[\"score\"].length > 0) {\r\n\t itxt = this.elePool[\"score\"].shift();\r\n\t }\r\n\t }\r\n\t else {\r\n\t this.elePool[\"score\"] = new Array();\r\n\t }\r\n\t if (!itxt) {\r\n\t itxt = new engine.Label();\r\n\t itxt.size = 66;\r\n\t itxt.width = 200;\r\n\t itxt.height = 70;\r\n\t itxt.textAlign = engine.TEXT_ALIGN.CENTER;\r\n\t itxt.verticalAlign = engine.VERTICAL_ALIGN.MIDDLE;\r\n\t itxt.anchorY = 35;\r\n\t itxt.anchorX = 100;\r\n\t itxt.bold = true;\r\n\t }\r\n\t itxt.mouseEnabled = false;\r\n\t return itxt;\r\n\t };\r\n\t MapData.recoverEle = function (ele, type) {\r\n\t if (ele.eimage) {\r\n\t ele.eimage.texture = null;\r\n\t }\r\n\t this.elePool[\"ele\"].push(ele);\r\n\t };\r\n\t MapData.recoverTxt = function (txt) {\r\n\t this.elePool[\"score\"].push(txt);\r\n\t };\r\n\t MapData.getDistance = function (p1, p2) {\r\n\t var p1x = p1[0];\r\n\t var p1y = p1[1];\r\n\t var p2x = p2[0];\r\n\t var p2y = p2[1];\r\n\t var dis = Math.sqrt(Math.pow(p1x - p2x, 2) + Math.pow(p1y - p2y, 2));\r\n\t return dis;\r\n\t };\r\n\t MapData.itemsize = 116;\r\n\t MapData.paddingw = 7;\r\n\t MapData.paddingh = 7;\r\n\t MapData.paddingwi = 4;\r\n\t MapData.paddinghi = 2;\r\n\t MapData.row = 5;\r\n\t MapData.col = 5;\r\n\t MapData.posData = {};\r\n\t MapData.eleidx = 1;\r\n\t MapData.elePool = {};\r\n\t MapData.anispeed = 1000;\r\n\t MapData.levelData = [\r\n\t [\r\n\t [1, 2, 5, 3, 4],\r\n\t [3, 1, 2, 4, 5],\r\n\t [2, 5, 3, 4, 1],\r\n\t [5, 4, 1, 2, 3],\r\n\t [4, 1, 3, 5, 2],\r\n\t ],\r\n\t [\r\n\t [5, 2, 1, 2, 1],\r\n\t [3, 1, 4, 5, 4],\r\n\t [2, 5, 3, 5, 1],\r\n\t [5, 4, 1, 2, 3],\r\n\t [4, 1, 3, 1, 2],\r\n\t ],\r\n\t [\r\n\t [2, 4, 1, 5, 2],\r\n\t [2, 3, 4, 1, 3],\r\n\t [4, 1, 3, 2, 3],\r\n\t [3, 2, 1, 1, 4],\r\n\t [1, 1, 3, 5, 4],\r\n\t ],\r\n\t [\r\n\t [3, 2, 1, 4, 5],\r\n\t [2, 4, 1, 2, 3],\r\n\t [2, 3, 2, 3, 3],\r\n\t [4, 4, 5, 5, 4],\r\n\t [3, 3, 1, 2, 4],\r\n\t ],\r\n\t [\r\n\t [4, 5, 1, 2, 4],\r\n\t [3, 2, 3, 4, 2],\r\n\t [1, 5, 2, 3, 5],\r\n\t [4, 5, 5, 1, 3],\r\n\t [1, 2, 3, 2, 4],\r\n\t ]\r\n\t ];\r\n\t return MapData;\r\n\t}());\r\n\t//# sourceMappingURL=MapData.js.map\n\n\tvar GameView = (function (_super) {\r\n\t tslib.__extends(GameView, _super);\r\n\t function GameView() {\r\n\t var _this = _super.call(this) || this;\r\n\t _this.lattices = {};\r\n\t _this.eliminateArr = [];\r\n\t _this.selectArr = [];\r\n\t _this.conty = 140;\r\n\t _this.homex = 562;\r\n\t _this.homey = -20;\r\n\t _this.ination = false;\r\n\t _this.canation = true;\r\n\t _this._gametime = 60;\r\n\t _this._gamestat = 2;\r\n\t _this.ingameover = false;\r\n\t _this.ingame = true;\r\n\t _this.level = 0;\r\n\t _this.inrecord = false;\r\n\t _this.requestGameOver = false;\r\n\t _this.elitype = 1;\r\n\t _this._seq = 1;\r\n\t _this.sptime = Date.now();\r\n\t _this.useBoom = false;\r\n\t _this._score = 0;\r\n\t _this.inEliminate = false;\r\n\t _this.newSelect = false;\r\n\t _this.once(engine.Event.ADDED_TO_STAGE, _this.setup, _this);\r\n\t return _this;\r\n\t }\r\n\t Object.defineProperty(GameView.prototype, \"gamestat\", {\r\n\t get: function () {\r\n\t return this._gamestat;\r\n\t },\r\n\t set: function (stat) {\r\n\t this._gamestat = stat;\r\n\t if (stat == 2) {\r\n\t this.changeEnable(false);\r\n\t }\r\n\t },\r\n\t enumerable: true,\r\n\t configurable: true\r\n\t });\r\n\t Object.defineProperty(GameView.prototype, \"seq\", {\r\n\t get: function () {\r\n\t return this._seq;\r\n\t },\r\n\t set: function (num) {\r\n\t this._seq = num;\r\n\t },\r\n\t enumerable: true,\r\n\t configurable: true\r\n\t });\r\n\t GameView.prototype.setup = function () {\r\n\t MapData.initPoolEle();\r\n\t this.selectimg = new engine.Image(getTextureByName(\"选中框\"));\r\n\t this.selectimg.mouseEnabled = false;\r\n\t this.selectw = this.selectimg.texture.width;\r\n\t this.selecth = this.selectimg.texture.height;\r\n\t this.selectimg.anchorX = this.selectw / 2;\r\n\t this.selectimg.anchorY = this.selecth / 2;\r\n\t this.jiantou1 = new engine.Image(getTextureByName(\"交换箭头\"));\r\n\t this.jiantou2 = new engine.Image(getTextureByName(\"交换箭头\"));\r\n\t this.jiantou1.mouseEnabled = false;\r\n\t this.jiantou2.mouseEnabled = false;\r\n\t var jiantwid = 31;\r\n\t var jianthei = 24;\r\n\t this.jiantou1.anchorX = jiantwid / 2;\r\n\t this.jiantou1.anchorY = jianthei / 2;\r\n\t this.jiantou2.anchorX = jiantwid / 2;\r\n\t this.jiantou2.anchorY = jianthei / 2;\r\n\t this.jiantoucont = new engine.Container();\r\n\t this.jiantoucont.width = MapData.itemsize;\r\n\t this.jiantoucont.height = MapData.itemsize;\r\n\t this.jtsx1 = MapData.itemsize / 2 - jiantwid / 2;\r\n\t this.jtsx2 = MapData.itemsize / 2 - jiantwid / 2;\r\n\t this.jtsy1 = MapData.itemsize / 2 - jianthei;\r\n\t this.jtsy2 = MapData.itemsize / 2;\r\n\t this.jtex1 = this.jtsx1 - 10;\r\n\t this.jtex2 = this.jtsx2 + 10;\r\n\t this.jtey1 = this.jtsy1;\r\n\t this.jtey2 = this.jtsy2;\r\n\t this.jiantou1.x = this.jtsx1;\r\n\t this.jiantou2.rotation = 180;\r\n\t this.jiantou2.x = this.jtsx2;\r\n\t this.jiantou1.y = this.jtsy1;\r\n\t this.jiantou2.y = this.jtsy2;\r\n\t this.jiantoucont.addChild(this.jiantou1);\r\n\t this.jiantoucont.addChild(this.jiantou2);\r\n\t var row = MapData.row;\r\n\t var col = MapData.col;\r\n\t this.container = new engine.Container();\r\n\t this.addChild(this.container);\r\n\t this.container.y = this.conty;\r\n\t var maskimg = new engine.Graphics();\r\n\t this.container.addChild(maskimg);\r\n\t this.container.mask = maskimg;\r\n\t maskimg.moveTo(0, 0);\r\n\t maskimg.beginFill(0);\r\n\t maskimg.lineTo(681, 0);\r\n\t maskimg.lineTo(681, 679);\r\n\t maskimg.lineTo(0, 679);\r\n\t maskimg.lineTo(0, 0);\r\n\t maskimg.endFill();\r\n\t this.anicontainer = new engine.Container();\r\n\t this.addChild(this.anicontainer);\r\n\t this.anicontainer.mouseEnabled = false;\r\n\t this.anicontainer.mouseChildren = false;\r\n\t this.txtcontainer = new engine.Container();\r\n\t this.addChild(this.txtcontainer);\r\n\t var map = new engine.Image(getTextureByName(\"底图\"));\r\n\t this.container.addChild(map);\r\n\t for (var r = 0; r < row; r++) {\r\n\t for (var c = 0; c < col; c++) {\r\n\t var rcpos = MapData.getRCPos(r, c);\r\n\t MapData.posData[r + \"_\" + c] = rcpos;\r\n\t }\r\n\t }\r\n\t this.tanix = this.homex + 30;\r\n\t this.taniy = this.homey;\r\n\t engine.globalEvent.addEventListener(GameEvent.SelectEle, this.selectele, this);\r\n\t this.removeEventListener(engine.Event.ADDED_TO_STAGE, this.setup, this);\r\n\t this.lastframeTime = Date.now();\r\n\t this.lastatime = Date.now();\r\n\t this.addEventListener(engine.Event.ENTER_FRAME, this.onUpdate, this);\r\n\t var zhadanbtn = new engine.Label();\r\n\t zhadanbtn.text = \"炸弹\";\r\n\t zhadanbtn.size = 56;\r\n\t zhadanbtn.width = 200;\r\n\t zhadanbtn.height = 100;\r\n\t this.addChild(zhadanbtn);\r\n\t zhadanbtn.y = 900;\r\n\t zhadanbtn.fillColor = \"red\";\r\n\t zhadanbtn.addEventListener(engine.MouseEvent.CLICK, this.zhadanFunc, this);\r\n\t var timebtn = new engine.Label();\r\n\t timebtn.text = \"加时\";\r\n\t timebtn.size = 56;\r\n\t timebtn.width = 200;\r\n\t timebtn.height = 100;\r\n\t this.addChild(timebtn);\r\n\t timebtn.y = 900;\r\n\t timebtn.x = 500;\r\n\t timebtn.fillColor = \"red\";\r\n\t timebtn.addEventListener(engine.MouseEvent.CLICK, this.addTimeFunc, this);\r\n\t };\r\n\t GameView.prototype.zhadanFunc = function () {\r\n\t this.useBoom = true;\r\n\t };\r\n\t GameView.prototype.addTimeFunc = function () {\r\n\t console.log(\"加时间\");\r\n\t };\r\n\t GameView.prototype.changeAni = function () {\r\n\t this.changeHomeShow(\"night\");\r\n\t };\r\n\t GameView.prototype.playComp = function () {\r\n\t };\r\n\t GameView.prototype.init = function (time, level, mode) {\r\n\t this.score = 0;\r\n\t this.gametime = time;\r\n\t this.seq = 1;\r\n\t this.level = level;\r\n\t this.ingameover = false;\r\n\t this.changeHomeShow(mode);\r\n\t this.initContainer();\r\n\t this.sptime = Date.now();\r\n\t };\r\n\t Object.defineProperty(GameView.prototype, \"score\", {\r\n\t get: function () {\r\n\t return this._score;\r\n\t },\r\n\t set: function (num) {\r\n\t this._score = num;\r\n\t engine.globalEvent.dispatchEvent('game-score-update', { score: this._score });\r\n\t },\r\n\t enumerable: true,\r\n\t configurable: true\r\n\t });\r\n\t Object.defineProperty(GameView.prototype, \"gametime\", {\r\n\t get: function () {\r\n\t return this._gametime;\r\n\t },\r\n\t set: function (time) {\r\n\t var lshowtime = Math.round(this._gametime);\r\n\t var nshowtime = Math.round(time);\r\n\t if (lshowtime != nshowtime) {\r\n\t if (this.gamestat == 1 && nshowtime < 1) {\r\n\t this.gameOver();\r\n\t }\r\n\t if (nshowtime < 0) {\r\n\t nshowtime = 0;\r\n\t }\r\n\t engine.globalEvent.dispatchEvent('game-time-update', { time: nshowtime });\r\n\t }\r\n\t if (time < 0) {\r\n\t time = 0;\r\n\t }\r\n\t this._gametime = time;\r\n\t },\r\n\t enumerable: true,\r\n\t configurable: true\r\n\t });\r\n\t GameView.prototype.gameOver = function () {\r\n\t this.gamestat = 2;\r\n\t this.unShowEleAttion();\r\n\t this.anicontainer.removeChild(this.selectimg);\r\n\t this.ingameover = true;\r\n\t console.log(\"倒计时结束1=============\", this.ingameover, this.inEliminate, this.inrecord);\r\n\t this.checkGameOver(\"time-over\");\r\n\t };\r\n\t GameView.prototype.checkGameOver = function (type) {\r\n\t if (this.ingameover) {\r\n\t console.log(\"倒计时已结束2==========\", this.inEliminate, this.inrecord, type);\r\n\t }\r\n\t if (this.ingameover && !this.inEliminate && !this.inrecord && !this.requestGameOver) {\r\n\t this.requestGameOver = true;\r\n\t this.unShowEleAttion();\r\n\t this.anicontainer.removeChild(this.jiantoucont);\r\n\t engine.globalEvent.dispatchEvent(\"game-over\", {\r\n\t score: this.score\r\n\t });\r\n\t }\r\n\t };\r\n\t GameView.prototype.reset = function (time, level, mode) {\r\n\t return tslib.__awaiter(this, void 0, void 0, function () {\r\n\t var key, rcname, rcele, rcelex, rceley, rcetype, fallpro, testdata;\r\n\t return tslib.__generator(this, function (_a) {\r\n\t switch (_a.label) {\r\n\t case 0:\r\n\t this.anicontainer.removeChild(this.selectimg);\r\n\t this.selectArr = new Array();\r\n\t this.gametime = time;\r\n\t this.level = level;\r\n\t this.ingameover = false;\r\n\t this.requestGameOver = false;\r\n\t this.seq = 1;\r\n\t this.changeHomeShow(mode);\r\n\t this.changeEnable(false);\r\n\t for (key in this.lattices) {\r\n\t rcname = this.lattices[key];\r\n\t rcele = this.container.getChildByName(rcname);\r\n\t if (rcele) {\r\n\t rcelex = rcele.x;\r\n\t rceley = rcele.y;\r\n\t rcetype = rcele.type;\r\n\t this.lattices[key] = \"empty\";\r\n\t this.goDisplayAni1(rcele, rcetype, rcelex, rceley);\r\n\t }\r\n\t }\r\n\t fallpro = new Promise(function (res) {\r\n\t setTimeout(function () {\r\n\t res();\r\n\t }, 400);\r\n\t });\r\n\t return [4, fallpro];\r\n\t case 1:\r\n\t _a.sent();\r\n\t testdata = MapData.levelData[this.level];\r\n\t this.levelData = testdata;\r\n\t this.fall(\"newlevel\");\r\n\t return [2];\r\n\t }\r\n\t });\r\n\t });\r\n\t };\r\n\t GameView.prototype.start = function () {\r\n\t this.gamestat = 1;\r\n\t this.requestGameOver = false;\r\n\t this.selectArr = new Array();\r\n\t this.changeEnable(true);\r\n\t };\r\n\t GameView.prototype.pause = function () {\r\n\t this.ingame = false;\r\n\t };\r\n\t GameView.prototype.resume = function () {\r\n\t this.lastframeTime = Date.now();\r\n\t this.ingame = true;\r\n\t };\r\n\t GameView.prototype.onUpdate = function () {\r\n\t var ntime = Date.now();\r\n\t if (this.gamestat == 1 && this.ingame) {\r\n\t var passtime = ntime - this.lastframeTime;\r\n\t if (ntime - this.lastatime >= 5000 && !this.ination && this.canation && this.selectArr.length == 0) {\r\n\t this.attionEliShow();\r\n\t }\r\n\t if (this.gametime && this.gametime > 0) {\r\n\t var ngtime = this.gametime - (passtime / 1000);\r\n\t this.gametime = ngtime;\r\n\t }\r\n\t }\r\n\t this.lastframeTime = ntime;\r\n\t };\r\n\t GameView.prototype.initContainer = function () {\r\n\t if (this.lattices) {\r\n\t for (var key in this.lattices) {\r\n\t var rcname = this.lattices[key];\r\n\t var rcele = this.container.getChildByName(rcname);\r\n\t if (rcele) {\r\n\t var rcetype = rcele.type;\r\n\t this.container.removeChild(rcele);\r\n\t this.lattices[key] = \"empty\";\r\n\t MapData.recoverEle(rcele, rcetype);\r\n\t }\r\n\t }\r\n\t }\r\n\t else {\r\n\t this.lattices = {};\r\n\t }\r\n\t var testdata = MapData.levelData[this.level];\r\n\t this.levelData = testdata;\r\n\t for (var r = 0; r < testdata.length; r++) {\r\n\t var rdata = testdata[r];\r\n\t for (var c = 0; c < rdata.length; c++) {\r\n\t var rctype = rdata[c];\r\n\t var rcele = MapData.getOneEle(rctype);\r\n\t var rcpos = MapData.getRCPos(r, c);\r\n\t this.container.addChild(rcele);\r\n\t rcele.x = rcpos[0];\r\n\t rcele.y = rcpos[1];\r\n\t var rcidx = r + \"_\" + c;\r\n\t this.lattices[rcidx] = rcele.name;\r\n\t this.setLatticeEleRc(rcidx);\r\n\t }\r\n\t }\r\n\t this.checkInit();\r\n\t };\r\n\t GameView.prototype.checkInit = function () {\r\n\t this.checkEliminate();\r\n\t if (this.eliminateArr.length > 0) {\r\n\t return this.eliminate();\r\n\t }\r\n\t else {\r\n\t this.selectArr = new Array();\r\n\t var isdiedata = this.attionEliminate();\r\n\t if (isdiedata && isdiedata.length == 3) {\r\n\t this.changeEnable(true);\r\n\t }\r\n\t else {\r\n\t this.solveDieMap();\r\n\t }\r\n\t }\r\n\t };\r\n\t GameView.prototype.setLatticeEleRc = function (rcidx) {\r\n\t var rename = this.lattices[rcidx];\r\n\t var rcnode = this.container.getChildByName(rename);\r\n\t if (rcnode) {\r\n\t var er = Number(rcidx.split(\"_\")[0]);\r\n\t var ec = Number(rcidx.split(\"_\")[1]);\r\n\t rcnode.setrc(er, ec);\r\n\t }\r\n\t };\r\n\t GameView.prototype.unShowEleAttion = function () {\r\n\t if (this.ination) {\r\n\t this.ination = false;\r\n\t this.lastatime = Date.now();\r\n\t var arrcidx1 = this.attiondata[0];\r\n\t var arrcidx2 = this.attiondata[1];\r\n\t var atname1 = this.lattices[arrcidx1];\r\n\t var atname2 = this.lattices[arrcidx2];\r\n\t var atnode1 = this.container.getChildByName(atname1);\r\n\t var atnode2 = this.container.getChildByName(atname2);\r\n\t var aboutnames = this.attiondata[2];\r\n\t if (!atnode1 || !atnode2) {\r\n\t this.attiondata = new Array();\r\n\t return;\r\n\t }\r\n\t var atpos1 = MapData.getRCPos(arrcidx1.split(\"_\")[0], arrcidx1.split(\"_\")[1]);\r\n\t var atpos2 = MapData.getRCPos(arrcidx2.split(\"_\")[0], arrcidx2.split(\"_\")[1]);\r\n\t engine.Tween.removeTweens(atnode1);\r\n\t engine.Tween.removeTweens(atnode2);\r\n\t atnode1.x = atpos1[0];\r\n\t atnode1.y = atpos1[1];\r\n\t atnode2.x = atpos2[0];\r\n\t atnode2.y = atpos2[1];\r\n\t for (var i = 0; i < aboutnames.length; i++) {\r\n\t var ircidx = aboutnames[i];\r\n\t var iname1 = this.lattices[ircidx];\r\n\t var inode1 = this.container.getChildByName(iname1);\r\n\t if (inode1) {\r\n\t engine.Tween.removeTweens(inode1);\r\n\t var ipos1 = MapData.getRCPos(ircidx.split(\"_\")[0], ircidx.split(\"_\")[1]);\r\n\t inode1.x = ipos1[0];\r\n\t inode1.y = ipos1[1];\r\n\t }\r\n\t }\r\n\t this.anicontainer.removeChild(this.jiantoucont);\r\n\t }\r\n\t };\r\n\t GameView.prototype.selectele = function (e) {\r\n\t var data = e.data;\r\n\t var sr = data.r;\r\n\t var sc = data.c;\r\n\t var type = data.type;\r\n\t var sname = sr + \"_\" + sc;\r\n\t if (this.useBoom) {\r\n\t if (type == \"mouse_down\") {\r\n\t this.unShowEleAttion();\r\n\t this.boomeEle(sr, sc);\r\n\t }\r\n\t return;\r\n\t }\r\n\t var lnewSelect = this.newSelect;\r\n\t var newCanSel = false;\r\n\t if (this.selectArr.length == 0) {\r\n\t newCanSel = true;\r\n\t }\r\n\t else if (this.selectArr.length == 1) {\r\n\t var nname = this.selectArr[0];\r\n\t if (sname == nname) {\r\n\t newCanSel = false;\r\n\t }\r\n\t else {\r\n\t newCanSel = true;\r\n\t }\r\n\t }\r\n\t if (type == \"mouse_down\") {\r\n\t this.newSelect = true;\r\n\t }\r\n\t else if (type == \"mouse_move\") {\r\n\t if (newCanSel) {\r\n\t this.newSelect = false;\r\n\t }\r\n\t }\r\n\t if ((lnewSelect || this.newSelect) && newCanSel) ;\r\n\t else {\r\n\t return;\r\n\t }\r\n\t this.unShowEleAttion();\r\n\t if (this.selectArr.length == 0) {\r\n\t this.sptime = Date.now();\r\n\t this.seqscore = 0;\r\n\t this.selectArr.push(sname);\r\n\t }\r\n\t else if (this.selectArr.length == 1) {\r\n\t var aselect = this.selectArr[0];\r\n\t var asr = aselect.split(\"_\")[0];\r\n\t var asc = aselect.split(\"_\")[1];\r\n\t if ((sr == asr && Math.abs(sc - asc) == 1) || (sc == asc && Math.abs(sr - asr) == 1)) {\r\n\t this.selectArr.push(sname);\r\n\t }\r\n\t else {\r\n\t if (sr == asr && sc == asc) {\r\n\t this.selectArr = new Array();\r\n\t this.anicontainer.removeChild(this.selectimg);\r\n\t }\r\n\t else {\r\n\t this.selectArr[0] = sname;\r\n\t }\r\n\t }\r\n\t }\r\n\t if (this.selectArr.length == 1) {\r\n\t this.setSelectShow();\r\n\t }\r\n\t else if (this.selectArr.length == 2) {\r\n\t this.changeElePos();\r\n\t }\r\n\t };\r\n\t GameView.prototype.setSelectShow = function () {\r\n\t var rcname = this.selectArr[0];\r\n\t var r = rcname.split(\"_\")[0];\r\n\t var c = rcname.split(\"_\")[1];\r\n\t var rcpos = MapData.getRCPos(r, c);\r\n\t engine.Tween.removeTweens(this.selectimg);\r\n\t this.anicontainer.addChild(this.selectimg);\r\n\t this.selectimg.x = rcpos[0] - 3;\r\n\t this.selectimg.y = rcpos[1] + this.conty - 3;\r\n\t this.startTweenSelectImg();\r\n\t };\r\n\t GameView.prototype.startTweenSelectImg = function () {\r\n\t this.selectimg.scaleX = 1;\r\n\t this.selectimg.scaleY = 1;\r\n\t engine.Tween.get(this.selectimg, { loop: true })\r\n\t .to({\r\n\t scaleX: 0.9,\r\n\t scaleY: 0.9\r\n\t }, 500)\r\n\t .to({\r\n\t scaleX: 1,\r\n\t scaleY: 1\r\n\t }, 500);\r\n\t };\r\n\t GameView.prototype.changeElePos = function () {\r\n\t var _this = this;\r\n\t this.anicontainer.removeChild(this.selectimg);\r\n\t this.changeEnable(false);\r\n\t var sname1 = this.selectArr[0];\r\n\t var sname2 = this.selectArr[1];\r\n\t var sename1 = this.lattices[sname1];\r\n\t var sename2 = this.lattices[sname2];\r\n\t this.lattices[sname1] = sename2;\r\n\t this.lattices[sname2] = sename1;\r\n\t this.setLatticeEleRc(sname1);\r\n\t this.setLatticeEleRc(sname2);\r\n\t this.checkEliminate();\r\n\t var snode1 = this.container.getChildByName(sename1);\r\n\t var snode2 = this.container.getChildByName(sename2);\r\n\t if (!snode1 || !snode2) {\r\n\t this.selectArr = new Array();\r\n\t return;\r\n\t }\r\n\t var snode1x = snode1.x;\r\n\t var snode1y = snode1.y;\r\n\t var snode2x = snode2.x;\r\n\t var snode2y = snode2.y;\r\n\t var changetime = Math.ceil((MapData.itemsize / MapData.anispeed) * 2 * 1000);\r\n\t engine.Tween.removeTweens(snode1);\r\n\t engine.Tween.removeTweens(snode2);\r\n\t if (this.eliminateArr.length > 0) {\r\n\t this.inEliminate = true;\r\n\t engine.Tween.get(snode1).to({\r\n\t x: snode2x,\r\n\t y: snode2y\r\n\t }, changetime);\r\n\t engine.Tween.get(snode2).to({\r\n\t x: snode1x,\r\n\t y: snode1y\r\n\t }, changetime)\r\n\t .call(function () {\r\n\t _this.eliminate();\r\n\t });\r\n\t }\r\n\t else {\r\n\t engine.Tween.get(snode1).to({\r\n\t x: snode2x,\r\n\t y: snode2y\r\n\t }, changetime)\r\n\t .wait(100)\r\n\t .to({\r\n\t x: snode1x,\r\n\t y: snode1y\r\n\t }, changetime);\r\n\t engine.Tween.get(snode2).to({\r\n\t x: snode1x,\r\n\t y: snode1y\r\n\t }, changetime)\r\n\t .wait(100)\r\n\t .to({\r\n\t x: snode2x,\r\n\t y: snode2y\r\n\t }, changetime)\r\n\t .call(function () {\r\n\t _this.lattices[sname1] = sename1;\r\n\t _this.lattices[sname2] = sename2;\r\n\t _this.setLatticeEleRc(sname1);\r\n\t _this.setLatticeEleRc(sname2);\r\n\t _this.selectArr = new Array();\r\n\t _this.recordGame();\r\n\t _this.changeEnable(true);\r\n\t _this.checkGameOver(\"changeElePos\");\r\n\t });\r\n\t }\r\n\t };\r\n\t GameView.prototype.eliminate = function () {\r\n\t return tslib.__awaiter(this, void 0, void 0, function () {\r\n\t var i, ielidata1, ielileng, addscore, j, ielidata, ielidxname, ielitype, ieliname, ielinode, ielix, ieliy, ietype;\r\n\t return tslib.__generator(this, function (_a) {\r\n\t switch (_a.label) {\r\n\t case 0:\r\n\t this.inEliminate = true;\r\n\t for (i = 0; i < this.eliminateArr.length; i++) {\r\n\t ielidata1 = this.eliminateArr[i];\r\n\t ielileng = ielidata1.length;\r\n\t addscore = 0;\r\n\t if (ielileng <= 3) {\r\n\t addscore = props.threeEscore;\r\n\t }\r\n\t else if (ielileng == 4) {\r\n\t addscore = props.fourEscore;\r\n\t }\r\n\t else {\r\n\t addscore = props.moreEscore;\r\n\t }\r\n\t this.seqscore += addscore * ielileng;\r\n\t for (j = 0; j < ielidata1.length; j++) {\r\n\t ielidata = ielidata1[j];\r\n\t ielidxname = ielidata.idxname;\r\n\t ielitype = ielidata.type;\r\n\t ieliname = this.lattices[ielidxname];\r\n\t ielinode = this.container.getChildByName(ieliname);\r\n\t if (!ielinode) {\r\n\t continue;\r\n\t }\r\n\t ielix = ielinode.x;\r\n\t ieliy = ielinode.y;\r\n\t ietype = ielinode.type;\r\n\t if (this.elitype == 1) {\r\n\t this.lattices[ielidxname] = \"empty\";\r\n\t this.addScoreAni(ielix, ieliy, ietype, addscore);\r\n\t this.goDisplayAni1(ielinode, ietype, ielix, ieliy);\r\n\t }\r\n\t else {\r\n\t this.container.removeChild(ielinode);\r\n\t MapData.recoverEle(ielinode, ietype);\r\n\t this.addScoreAni(ielix, ieliy, ietype, addscore);\r\n\t this.lattices[ielidxname] = \"empty\";\r\n\t this.goHomeAni(ielitype, ielix, ieliy);\r\n\t }\r\n\t }\r\n\t }\r\n\t return [4, new Promise(function (res) {\r\n\t setTimeout(function () {\r\n\t res();\r\n\t }, 400);\r\n\t })];\r\n\t case 1:\r\n\t _a.sent();\r\n\t this.fall();\r\n\t return [4, new Promise(function (res1) {\r\n\t setTimeout(function () {\r\n\t res1();\r\n\t }, 500);\r\n\t })];\r\n\t case 2:\r\n\t _a.sent();\r\n\t return [2];\r\n\t }\r\n\t });\r\n\t });\r\n\t };\r\n\t GameView.prototype.fall = function (type) {\r\n\t if (type === void 0) { type = \"normal\"; }\r\n\t return tslib.__awaiter(this, void 0, void 0, function () {\r\n\t var fallData, fcutr, fc, r, c, idxname, elename, frcname, fetype, fele, cutr, fepos, fallPromise, _loop_1, this_1, f, isdiedata;\r\n\t return tslib.__generator(this, function (_a) {\r\n\t switch (_a.label) {\r\n\t case 0:\r\n\t fallData = new Array();\r\n\t fcutr = new Array();\r\n\t for (fc = 0; fc < MapData.col; fc++) {\r\n\t fcutr.push(-1);\r\n\t }\r\n\t for (r = MapData.row - 1; r > -1; r--) {\r\n\t for (c = MapData.col - 1; c > -1; c--) {\r\n\t idxname = r + \"_\" + c;\r\n\t elename = this.lattices[idxname];\r\n\t if (elename == \"empty\") {\r\n\t frcname = this.getFallRcEle(r, c);\r\n\t if (!frcname) {\r\n\t fetype = void 0;\r\n\t if (type == \"normal\") {\r\n\t fetype = MapData.getRandEtype();\r\n\t }\r\n\t else {\r\n\t fetype = this.levelData[r][c];\r\n\t }\r\n\t fele = MapData.getOneEle(fetype);\r\n\t cutr = fcutr[c];\r\n\t fepos = MapData.getRCPos(cutr, c);\r\n\t fcutr[c] = cutr - 1;\r\n\t this.container.addChild(fele);\r\n\t fele.x = fepos[0];\r\n\t fele.y = fepos[1];\r\n\t frcname = fele.name;\r\n\t }\r\n\t this.lattices[idxname] = frcname;\r\n\t this.setLatticeEleRc(idxname);\r\n\t fallData.push({\r\n\t rcname: frcname,\r\n\t trow: r,\r\n\t tcol: c\r\n\t });\r\n\t }\r\n\t }\r\n\t }\r\n\t fallPromise = new Array();\r\n\t _loop_1 = function (f) {\r\n\t var fdata = fallData[f];\r\n\t var frcname = fdata.rcname;\r\n\t var ftrow = fdata.trow;\r\n\t var ftcol = fdata.tcol;\r\n\t var ftpos = MapData.getRCPos(ftrow, ftcol);\r\n\t var frcnode = this_1.container.getChildByName(frcname);\r\n\t if (!frcnode) {\r\n\t return \"continue\";\r\n\t }\r\n\t var nepos = [frcnode.x, frcnode.y];\r\n\t var fdis = MapData.getDistance(ftpos, nepos);\r\n\t var ftime = Math.ceil((fdis / MapData.anispeed) * 1000);\r\n\t engine.Tween.removeTweens(frcnode);\r\n\t var ifallpromise = new Promise(function (res) {\r\n\t engine.Tween.get(frcnode)\r\n\t .to({\r\n\t x: ftpos[0],\r\n\t y: ftpos[1]\r\n\t }, ftime)\r\n\t .to({\r\n\t scaleY: 0.85\r\n\t }, 80)\r\n\t .to({\r\n\t scaleY: 1\r\n\t }, 80)\r\n\t .call(function () {\r\n\t res();\r\n\t });\r\n\t });\r\n\t fallPromise.push(ifallpromise);\r\n\t };\r\n\t this_1 = this;\r\n\t for (f = 0; f < fallData.length; f++) {\r\n\t _loop_1(f);\r\n\t }\r\n\t return [4, Promise.all(fallPromise)];\r\n\t case 1:\r\n\t _a.sent();\r\n\t if (type == \"newlevel\") {\r\n\t this.sptime = Date.now();\r\n\t }\r\n\t this.checkEliminate();\r\n\t if (this.eliminateArr.length > 0) {\r\n\t return [2, this.eliminate()];\r\n\t }\r\n\t else {\r\n\t this.selectArr = new Array();\r\n\t isdiedata = this.attionEliminate();\r\n\t if (isdiedata && isdiedata.length == 3) {\r\n\t this.inEliminate = false;\r\n\t if (type != \"newlevel\") {\r\n\t this.recordGame();\r\n\t }\r\n\t this.changeEnable(true);\r\n\t this.checkGameOver(\"fall\");\r\n\t }\r\n\t else {\r\n\t this.solveDieMap(\"fall\");\r\n\t }\r\n\t }\r\n\t return [2];\r\n\t }\r\n\t });\r\n\t });\r\n\t };\r\n\t GameView.prototype.goDisplayAni1 = function (rcele, rcetype, rcelex, rceley) {\r\n\t var _this = this;\r\n\t rcele.touch = false;\r\n\t engine.Tween.removeTweens(rcele);\r\n\t rcele.x = rcelex;\r\n\t rcele.y = rceley;\r\n\t rcele.anchorY = MapData.itemsize / 2;\r\n\t engine.Tween.get(rcele)\r\n\t .to({\r\n\t scaleX: 0,\r\n\t scaleY: 0,\r\n\t alpha: 0\r\n\t }, 300)\r\n\t .call(function () {\r\n\t _this.container.removeChild(rcele);\r\n\t MapData.recoverEle(rcele, rcetype);\r\n\t });\r\n\t };\r\n\t GameView.prototype.goDisplayAni = function (ielitype, ielix, ieliy) {\r\n\t var _this = this;\r\n\t var aniele = MapData.getOneEle(ielitype);\r\n\t aniele.alpha = 0;\r\n\t var anix = ielix;\r\n\t var aniy = ieliy + this.conty;\r\n\t this.anicontainer.addChild(aniele);\r\n\t aniele.touch = false;\r\n\t aniele.x = anix;\r\n\t aniele.y = aniy;\r\n\t aniele.alpha = 1;\r\n\t aniele.anchorY = MapData.itemsize / 2;\r\n\t engine.Tween.removeTweens(aniele);\r\n\t engine.Tween.get(aniele)\r\n\t .to({\r\n\t scaleX: 0,\r\n\t scaleY: 0,\r\n\t alpha: 0\r\n\t }, 300)\r\n\t .call(function () {\r\n\t _this.anicontainer.removeChild(aniele);\r\n\t MapData.recoverEle(aniele, ielitype);\r\n\t });\r\n\t };\r\n\t GameView.prototype.goHomeAni = function (ielitype, ielix, ieliy) {\r\n\t var aniele = MapData.getOneEle(ielitype);\r\n\t aniele.alpha = 0;\r\n\t var anix = ielix;\r\n\t var aniy = ieliy + this.conty;\r\n\t this.anicontainer.addChild(aniele);\r\n\t aniele.touch = false;\r\n\t aniele.x = anix;\r\n\t aniele.y = aniy;\r\n\t aniele.alpha = 1;\r\n\t var anidis = MapData.getDistance([this.tanix, this.taniy], [anix, aniy]);\r\n\t var anitime = Math.ceil((anidis / MapData.anispeed) * 1000);\r\n\t aniele.flyToHome(this.tanix, this.taniy, anitime);\r\n\t };\r\n\t GameView.prototype.changeEnable = function (v) {\r\n\t var changeable = false;\r\n\t if (this.gamestat == 1) {\r\n\t changeable = true;\r\n\t }\r\n\t else {\r\n\t if (!v) {\r\n\t changeable = true;\r\n\t }\r\n\t }\r\n\t if (changeable) {\r\n\t for (var key in this.lattices) {\r\n\t var kname = this.lattices[key];\r\n\t var ele = this.container.getChildByName(kname);\r\n\t if (ele) {\r\n\t ele.touch = v;\r\n\t }\r\n\t }\r\n\t if (v) {\r\n\t this.lastatime = Date.now();\r\n\t this.ination = false;\r\n\t }\r\n\t }\r\n\t this.canation = v;\r\n\t };\r\n\t GameView.prototype.attionEliShow = function () {\r\n\t var attiondata = this.attionEliminate();\r\n\t if (attiondata && attiondata.length == 3) {\r\n\t this.ination = true;\r\n\t this.attiondata = [attiondata[0], attiondata[1], attiondata[2]];\r\n\t var atname1 = this.lattices[attiondata[0]];\r\n\t var atname2 = this.lattices[attiondata[1]];\r\n\t var aboutnames = attiondata[2];\r\n\t var atnode1 = this.container.getChildByName(atname1);\r\n\t var atnode2 = this.container.getChildByName(atname2);\r\n\t if (!atnode1 || !atnode2) {\r\n\t return;\r\n\t }\r\n\t var atx1 = atnode1.x;\r\n\t var aty1 = atnode1.y;\r\n\t var atx2 = atnode2.x;\r\n\t var aty2 = atnode2.y;\r\n\t var lerpnum = 0.1;\r\n\t var atpos1 = [(atx2 - atx1) * lerpnum + atx1, (aty2 - aty1) * lerpnum + aty1];\r\n\t engine.Tween.removeTweens(atnode1);\r\n\t engine.Tween.removeTweens(atnode2);\r\n\t engine.Tween.get(atnode1, {\r\n\t loop: true\r\n\t }).to({\r\n\t x: atpos1[0],\r\n\t y: atpos1[1]\r\n\t }, 500)\r\n\t .to({\r\n\t x: atx1,\r\n\t y: aty1\r\n\t }, 500);\r\n\t var jtx = (atx2 - atx1) * 0.5 + atx1;\r\n\t var jty = (aty2 - aty1) * 0.5 + aty1 + this.conty;\r\n\t var chax1 = atx1 - atpos1[0];\r\n\t var chay1 = aty1 - atpos1[1];\r\n\t var roa1 = 0;\r\n\t var movex1 = 0;\r\n\t var movey1 = 0;\r\n\t if (Math.abs(chax1) > Math.abs(chay1)) {\r\n\t jty += 25;\r\n\t movex1 = chax1;\r\n\t }\r\n\t else {\r\n\t jtx += MapData.itemsize;\r\n\t roa1 = 90;\r\n\t movey1 = chay1;\r\n\t }\r\n\t for (var i = 0; i < aboutnames.length; i++) {\r\n\t var iname1 = this.lattices[aboutnames[i]];\r\n\t var inode1 = this.container.getChildByName(iname1);\r\n\t engine.Tween.removeTweens(inode1);\r\n\t var iatx1 = inode1.x;\r\n\t var iaty1 = inode1.y;\r\n\t if (inode1) {\r\n\t engine.Tween.get(inode1, { loop: true })\r\n\t .to({\r\n\t x: iatx1 + movex1,\r\n\t y: iaty1 + movey1\r\n\t }, 500)\r\n\t .to({\r\n\t x: iatx1,\r\n\t y: iaty1\r\n\t }, 500);\r\n\t }\r\n\t }\r\n\t this.anicontainer.addChild(this.jiantoucont);\r\n\t this.jiantoucont.x = jtx;\r\n\t this.jiantoucont.y = jty;\r\n\t this.jiantoucont.rotation = roa1;\r\n\t this.startJtAni();\r\n\t }\r\n\t else {\r\n\t this.solveDieMap();\r\n\t }\r\n\t };\r\n\t GameView.prototype.startJtAni = function () {\r\n\t engine.Tween.removeTweens(this.jiantou1);\r\n\t engine.Tween.removeTweens(this.jiantou2);\r\n\t this.jiantou1.x = this.jtex1;\r\n\t this.jiantou1.y = this.jtey1;\r\n\t this.jiantou2.x = this.jtex2;\r\n\t this.jiantou2.y = this.jtey2;\r\n\t this.jiantou1.alpha = 1;\r\n\t this.jiantou2.alpha = 1;\r\n\t engine.Tween.get(this.jiantou1, { loop: true })\r\n\t .to({\r\n\t x: this.jtsx1,\r\n\t y: this.jtsy1,\r\n\t alpha: 0\r\n\t }, 500)\r\n\t .to({\r\n\t x: this.jtex1,\r\n\t y: this.jtey1,\r\n\t alpha: 1\r\n\t }, 500);\r\n\t engine.Tween.get(this.jiantou2, { loop: true })\r\n\t .to({\r\n\t x: this.jtsx2,\r\n\t y: this.jtsy2,\r\n\t alpha: 0\r\n\t }, 500)\r\n\t .to({\r\n\t x: this.jtex2,\r\n\t y: this.jtey2,\r\n\t alpha: 1\r\n\t }, 500);\r\n\t };\r\n\t GameView.prototype.solveDieMap = function (type) {\r\n\t if (type === void 0) { type = \"normal\"; }\r\n\t if (this.gamestat != 1) {\r\n\t if (this.ingameover) {\r\n\t this.inEliminate = false;\r\n\t this.checkGameOver(\"changeToFuHuoPos222\");\r\n\t }\r\n\t return;\r\n\t }\r\n\t this.changeEnable(false);\r\n\t var elearr = new Array();\r\n\t for (var key in this.lattices) {\r\n\t var keyval = this.lattices[key];\r\n\t elearr.push(keyval);\r\n\t }\r\n\t for (var key in this.lattices) {\r\n\t var changeval = elearr.splice(Math.floor(Math.random() * elearr.length), 1)[0];\r\n\t this.lattices[key] = changeval;\r\n\t }\r\n\t var isdiedata = this.attionEliminate();\r\n\t if (isdiedata && isdiedata.length == 3) {\r\n\t this.changeToFuHuoPos(type);\r\n\t }\r\n\t else {\r\n\t return this.solveDieMap();\r\n\t }\r\n\t };\r\n\t GameView.prototype.changeToFuHuoPos = function (type) {\r\n\t return tslib.__awaiter(this, void 0, void 0, function () {\r\n\t var prolist, key, keyval, keynode, keynodex, keynodey, tpos, ipro;\r\n\t return tslib.__generator(this, function (_a) {\r\n\t switch (_a.label) {\r\n\t case 0:\r\n\t prolist = new Array();\r\n\t for (key in this.lattices) {\r\n\t keyval = this.lattices[key];\r\n\t keynode = this.container.getChildByName(keyval);\r\n\t if (!keynode) {\r\n\t continue;\r\n\t }\r\n\t keynodex = keynode.x;\r\n\t keynodey = keynode.y;\r\n\t tpos = MapData.getRCPos(key.split(\"_\")[0], key.split(\"_\")[1]);\r\n\t ipro = keynode.changePos(tpos);\r\n\t prolist.push(ipro);\r\n\t this.setLatticeEleRc(key);\r\n\t }\r\n\t return [4, Promise.all(prolist)];\r\n\t case 1:\r\n\t _a.sent();\r\n\t this.checkEliminate();\r\n\t if (this.eliminateArr.length > 0) {\r\n\t this.eliminate();\r\n\t }\r\n\t else {\r\n\t if (type == \"fall\") {\r\n\t this.recordGame();\r\n\t }\r\n\t this.changeEnable(true);\r\n\t this.inEliminate = false;\r\n\t this.checkGameOver(\"changeToFuHuoPos\");\r\n\t }\r\n\t return [2];\r\n\t }\r\n\t });\r\n\t });\r\n\t };\r\n\t GameView.prototype.recordcomp = function () {\r\n\t this.inrecord = false;\r\n\t this.checkGameOver(\"recordcomp\");\r\n\t };\r\n\t GameView.prototype.recordGame = function () {\r\n\t if (!this.requestGameOver) {\r\n\t this.inrecord = true;\r\n\t this.eptime = Date.now();\r\n\t engine.globalEvent.dispatchEvent('game-record', {\r\n\t score: this.seqscore,\r\n\t seq: this.seq,\r\n\t sptime: this.sptime,\r\n\t eptime: this.eptime\r\n\t });\r\n\t this.seq += 1;\r\n\t this.seqscore = 0;\r\n\t this.sptime = Date.now();\r\n\t }\r\n\t };\r\n\t GameView.prototype.attionEliminate = function () {\r\n\t var attiondata;\r\n\t for (var r = MapData.row - 1; r > -1; r--) {\r\n\t if (attiondata && attiondata.length == 3) {\r\n\t break;\r\n\t }\r\n\t for (var c = MapData.col - 1; c > -1; c--) {\r\n\t var checktype = this.getEleTypeByRc(r, c);\r\n\t var edatarow = this.getEliminateRow(r, c);\r\n\t var edatacol = this.getEliminateCol(r, c);\r\n\t if (edatarow.length > 2 || edatacol.length > 2) ;\r\n\t if (edatarow.length == 2) {\r\n\t var releidx1 = edatarow[0];\r\n\t var releidx2 = edatarow[1];\r\n\t var relerow1 = Number(releidx1.split(\"_\")[0]);\r\n\t var relerow2 = Number(releidx2.split(\"_\")[0]);\r\n\t var relecol = Number(releidx1.split(\"_\")[1]);\r\n\t var downrow = relerow1 + 1;\r\n\t var uprow = relerow2 - 1;\r\n\t var rightcol = relecol + 1;\r\n\t var leftcol = relecol - 1;\r\n\t var uprow1 = relerow2 - 2;\r\n\t var downrow1 = relerow1 + 2;\r\n\t if (downrow < MapData.row) {\r\n\t if (rightcol < MapData.col) {\r\n\t var nexttype = this.getEleTypeByRc(downrow, rightcol);\r\n\t if (nexttype == checktype) {\r\n\t attiondata = [downrow + \"_\" + rightcol, downrow + \"_\" + relecol, edatarow];\r\n\t break;\r\n\t }\r\n\t }\r\n\t if (leftcol > -1) {\r\n\t var nexttype = this.getEleTypeByRc(downrow, leftcol);\r\n\t if (nexttype == checktype) {\r\n\t attiondata = [downrow + \"_\" + leftcol, downrow + \"_\" + relecol, edatarow];\r\n\t break;\r\n\t }\r\n\t }\r\n\t }\r\n\t if (uprow > -1) {\r\n\t if (rightcol < MapData.col) {\r\n\t var nexttype = this.getEleTypeByRc(uprow, rightcol);\r\n\t if (nexttype == checktype) {\r\n\t attiondata = [uprow + \"_\" + rightcol, uprow + \"_\" + relecol, edatarow];\r\n\t break;\r\n\t }\r\n\t }\r\n\t if (leftcol > -1) {\r\n\t var nexttype = this.getEleTypeByRc(uprow, leftcol);\r\n\t if (nexttype == checktype) {\r\n\t attiondata = [uprow + \"_\" + leftcol, uprow + \"_\" + relecol, edatarow];\r\n\t break;\r\n\t }\r\n\t }\r\n\t }\r\n\t if (uprow1 > -1) {\r\n\t var nexttype = this.getEleTypeByRc(uprow1, relecol);\r\n\t if (nexttype == checktype) {\r\n\t attiondata = [uprow1 + \"_\" + relecol, uprow + \"_\" + relecol, edatarow];\r\n\t break;\r\n\t }\r\n\t }\r\n\t if (downrow1 < MapData.row) {\r\n\t var nexttype = this.getEleTypeByRc(downrow1, relecol);\r\n\t if (nexttype == checktype) {\r\n\t attiondata = [downrow1 + \"_\" + relecol, downrow + \"_\" + relecol, edatarow];\r\n\t break;\r\n\t }\r\n\t }\r\n\t }\r\n\t if (edatacol.length == 2) {\r\n\t var releidx1 = edatacol[0];\r\n\t var releidx2 = edatacol[1];\r\n\t var relerow = Number(releidx1.split(\"_\")[0]);\r\n\t var relecol1 = Number(releidx1.split(\"_\")[1]);\r\n\t var relecol2 = Number(releidx2.split(\"_\")[1]);\r\n\t var rightcol = relecol1 + 1;\r\n\t var leftcol = relecol2 - 1;\r\n\t var uprow = relerow - 1;\r\n\t var downrow = relerow + 1;\r\n\t var rightcol1 = relecol1 + 2;\r\n\t var leftcol1 = relecol2 - 2;\r\n\t if (leftcol > -1) {\r\n\t if (uprow > -1) {\r\n\t var nexttype = this.getEleTypeByRc(uprow, leftcol);\r\n\t if (nexttype == checktype) {\r\n\t attiondata = [uprow + \"_\" + leftcol, relerow + \"_\" + leftcol, edatacol];\r\n\t break;\r\n\t }\r\n\t }\r\n\t if (downrow < MapData.row) {\r\n\t var nexttype = this.getEleTypeByRc(downrow, leftcol);\r\n\t if (nexttype == checktype) {\r\n\t attiondata = [downrow + \"_\" + leftcol, relerow + \"_\" + leftcol, edatacol];\r\n\t break;\r\n\t }\r\n\t }\r\n\t }\r\n\t if (rightcol < MapData.col) {\r\n\t if (uprow > -1) {\r\n\t var nexttype = this.getEleTypeByRc(uprow, rightcol);\r\n\t if (nexttype == checktype) {\r\n\t attiondata = [uprow + \"_\" + rightcol, relerow + \"_\" + rightcol, edatacol];\r\n\t break;\r\n\t }\r\n\t }\r\n\t if (downrow < MapData.row) {\r\n\t var nexttype = this.getEleTypeByRc(downrow, rightcol);\r\n\t if (nexttype == checktype) {\r\n\t attiondata = [downrow + \"_\" + rightcol, relerow + \"_\" + rightcol, edatacol];\r\n\t break;\r\n\t }\r\n\t }\r\n\t }\r\n\t if (rightcol1 < MapData.col) {\r\n\t var nexttype = this.getEleTypeByRc(relerow, rightcol1);\r\n\t if (nexttype == checktype) {\r\n\t attiondata = [relerow + \"_\" + rightcol1, relerow + \"_\" + rightcol, edatacol];\r\n\t break;\r\n\t }\r\n\t }\r\n\t if (leftcol1 > -1) {\r\n\t var nexttype = this.getEleTypeByRc(relerow, leftcol1);\r\n\t if (nexttype == checktype) {\r\n\t attiondata = [relerow + \"_\" + leftcol1, relerow + \"_\" + leftcol, edatacol];\r\n\t break;\r\n\t }\r\n\t }\r\n\t }\r\n\t var jianrow = this.getEliminateRowR(r, c);\r\n\t if (jianrow.length == 2) {\r\n\t var jianr = Number(jianrow[0].split(\"_\")[0]) - 1;\r\n\t var jianc = Number(jianrow[0].split(\"_\")[1]);\r\n\t var ljianc = jianc - 1;\r\n\t if (ljianc > -1) {\r\n\t var nexttype = this.getEleTypeByRc(jianr, ljianc);\r\n\t if (nexttype == checktype) {\r\n\t attiondata = [jianr + \"_\" + ljianc, jianr + \"_\" + jianc, jianrow];\r\n\t break;\r\n\t }\r\n\t }\r\n\t var rjianc = jianc + 1;\r\n\t if (rjianc < MapData.col) {\r\n\t var nexttype = this.getEleTypeByRc(jianr, rjianc);\r\n\t if (nexttype == checktype) {\r\n\t attiondata = [jianr + \"_\" + rjianc, jianr + \"_\" + jianc, jianrow];\r\n\t break;\r\n\t }\r\n\t }\r\n\t }\r\n\t var jiancol = this.getEliminateRowC(r, c);\r\n\t if (jiancol.length == 2) {\r\n\t var jianr = Number(jiancol[0].split(\"_\")[0]);\r\n\t var jianc = Number(jianrow[0].split(\"_\")[1]) - 1;\r\n\t var ujianr = jianr - 1;\r\n\t if (ujianr > -1) {\r\n\t var nexttype = this.getEleTypeByRc(ujianr, jianc);\r\n\t if (nexttype == checktype) {\r\n\t attiondata = [ujianr + \"_\" + jianc, jianr + \"_\" + jianc, jiancol];\r\n\t break;\r\n\t }\r\n\t }\r\n\t var djianr = jianr + 1;\r\n\t if (djianr < MapData.row) {\r\n\t var nexttype = this.getEleTypeByRc(djianr, jianc);\r\n\t if (nexttype == checktype) {\r\n\t attiondata = [djianr + \"_\" + jianc, jianr + \"_\" + jianc, jiancol];\r\n\t break;\r\n\t }\r\n\t }\r\n\t }\r\n\t }\r\n\t }\r\n\t return attiondata;\r\n\t };\r\n\t GameView.prototype.checkEliminate = function () {\r\n\t this.eliminateArr = new Array();\r\n\t for (var r = MapData.row - 1; r > -1; r--) {\r\n\t for (var c = MapData.col - 1; c > -1; c--) {\r\n\t var edata = this.getEliminate(r, c);\r\n\t if (edata) {\r\n\t var etype = edata.etype;\r\n\t var earr = edata.arr;\r\n\t this.checkAddEli(etype, earr);\r\n\t }\r\n\t }\r\n\t }\r\n\t };\r\n\t GameView.prototype.getEliminateRowR = function (x, y) {\r\n\t var checktype = this.getEleTypeByRc(x, y);\r\n\t var jianrow = x - 2;\r\n\t var relearr = new Array();\r\n\t relearr.push(x + \"_\" + y);\r\n\t if (jianrow > -1) {\r\n\t var jiantype = this.getEleTypeByRc(jianrow, y);\r\n\t if (jiantype == checktype) {\r\n\t relearr.push(jianrow + \"_\" + y);\r\n\t }\r\n\t }\r\n\t return relearr;\r\n\t };\r\n\t GameView.prototype.getEliminateRowC = function (x, y) {\r\n\t var checktype = this.getEleTypeByRc(x, y);\r\n\t var jiancol = y - 2;\r\n\t var relearr = new Array();\r\n\t relearr.push(x + \"_\" + y);\r\n\t if (jiancol > -1) {\r\n\t var jiantype = this.getEleTypeByRc(x, jiancol);\r\n\t if (jiantype == checktype) {\r\n\t relearr.push(x + \"_\" + jiancol);\r\n\t }\r\n\t }\r\n\t return relearr;\r\n\t };\r\n\t GameView.prototype.getEliminateRow = function (x, y) {\r\n\t var checktype = this.getEleTypeByRc(x, y);\r\n\t var relearr = new Array();\r\n\t relearr.push(x + \"_\" + y);\r\n\t for (var r = x - 1; r > -1; r--) {\r\n\t var reletype = this.getEleTypeByRc(r, y);\r\n\t if (checktype == reletype) {\r\n\t relearr.push(r + \"_\" + y);\r\n\t }\r\n\t else {\r\n\t break;\r\n\t }\r\n\t }\r\n\t return relearr;\r\n\t };\r\n\t GameView.prototype.getEliminateCol = function (x, y) {\r\n\t var checktype = this.getEleTypeByRc(x, y);\r\n\t var celearr = new Array();\r\n\t celearr.push(x + \"_\" + y);\r\n\t for (var c = y - 1; c > -1; c--) {\r\n\t var celetype = this.getEleTypeByRc(x, c);\r\n\t if (checktype == celetype) {\r\n\t celearr.push(x + \"_\" + c);\r\n\t }\r\n\t else {\r\n\t break;\r\n\t }\r\n\t }\r\n\t return celearr;\r\n\t };\r\n\t GameView.prototype.getEliminate = function (x, y) {\r\n\t var checktype = this.getEleTypeByRc(x, y);\r\n\t var relearr = this.getEliminateRow(x, y);\r\n\t var celearr = this.getEliminateCol(x, y);\r\n\t var eliminatearr = new Array();\r\n\t if (relearr.length >= 3) {\r\n\t eliminatearr.push.apply(eliminatearr, relearr);\r\n\t }\r\n\t if (celearr.length >= 3) {\r\n\t eliminatearr.push.apply(eliminatearr, celearr);\r\n\t }\r\n\t if (eliminatearr.length > 0) {\r\n\t return {\r\n\t etype: checktype,\r\n\t arr: eliminatearr\r\n\t };\r\n\t }\r\n\t else {\r\n\t return false;\r\n\t }\r\n\t };\r\n\t GameView.prototype.getEleTypeByRc = function (r, c) {\r\n\t var rc = r + \"_\" + c;\r\n\t var elename = this.lattices[rc];\r\n\t var ele = this.container.getChildByName(elename);\r\n\t if (ele) {\r\n\t var eletype = ele.type;\r\n\t return eletype;\r\n\t }\r\n\t };\r\n\t GameView.prototype.checkAddEli = function (etype, earr) {\r\n\t var addnew = true;\r\n\t var inaidx;\r\n\t for (var i1 = 0; i1 < this.eliminateArr.length; i1++) {\r\n\t var i1data = this.eliminateArr[i1];\r\n\t for (var i2 = 0; i2 < i1data.length; i2++) {\r\n\t var i2data = i1data[i2];\r\n\t var i2eliname = i2data.idxname;\r\n\t var inidx = earr.indexOf(i2eliname);\r\n\t if (inidx != -1) {\r\n\t addnew = false;\r\n\t break;\r\n\t }\r\n\t }\r\n\t if (!addnew) {\r\n\t inaidx = i1;\r\n\t break;\r\n\t }\r\n\t }\r\n\t if (addnew) {\r\n\t var addarr = new Array();\r\n\t for (var i1 = 0; i1 < earr.length; i1++) {\r\n\t var i1name = earr[i1];\r\n\t addarr.push({\r\n\t idxname: i1name,\r\n\t type: etype\r\n\t });\r\n\t }\r\n\t this.eliminateArr.push(addarr);\r\n\t }\r\n\t else {\r\n\t for (var i4 = 0; i4 < earr.length; i4++) {\r\n\t var i4name = earr[i4];\r\n\t var addele = true;\r\n\t for (var i3 = 0; i3 < this.eliminateArr[inaidx].length; i3++) {\r\n\t var i3data = this.eliminateArr[inaidx][i3];\r\n\t var i3eliname = i3data.idxname;\r\n\t if (i3eliname == i4name) {\r\n\t addele = false;\r\n\t break;\r\n\t }\r\n\t }\r\n\t if (addele) {\r\n\t this.eliminateArr[inaidx].push({\r\n\t idxname: i4name,\r\n\t type: etype\r\n\t });\r\n\t }\r\n\t }\r\n\t }\r\n\t };\r\n\t GameView.prototype.getFallRcEle = function (r, c) {\r\n\t for (var fr = r - 1; fr > -1; fr--) {\r\n\t var frc = fr + \"_\" + c;\r\n\t var frcname = this.lattices[frc];\r\n\t if (frcname != \"empty\") {\r\n\t this.lattices[frc] = \"empty\";\r\n\t return frcname;\r\n\t }\r\n\t }\r\n\t return false;\r\n\t };\r\n\t GameView.prototype.addScoreAni = function (ielix, ieliy, ietype, addscore) {\r\n\t var _this = this;\r\n\t var anitxt = MapData.getOneTxt();\r\n\t anitxt.alpha = 0;\r\n\t var txtcolor = \"#bd882f\";\r\n\t switch (ietype) {\r\n\t case ElementType.gdog:\r\n\t txtcolor = \"#d3ff6d\";\r\n\t break;\r\n\t case ElementType.pbird:\r\n\t txtcolor = \"#ff51d4\";\r\n\t break;\r\n\t case ElementType.hniu:\r\n\t txtcolor = \"#ffab55\";\r\n\t break;\r\n\t case ElementType.bribbit:\r\n\t txtcolor = \"#b3d4ff\";\r\n\t break;\r\n\t case ElementType.rpig:\r\n\t txtcolor = \"#f2453b\";\r\n\t break;\r\n\t default:\r\n\t console.error(\"未定义类型,检查\");\r\n\t break;\r\n\t }\r\n\t anitxt.fillColor = txtcolor;\r\n\t var anix = ielix + MapData.itemsize / 2 - 100;\r\n\t var aniy = ieliy + this.conty + MapData.itemsize / 2 - 35;\r\n\t anitxt.text = \"+\" + addscore;\r\n\t this.txtcontainer.addChild(anitxt);\r\n\t anitxt.x = anix;\r\n\t anitxt.y = aniy;\r\n\t anitxt.scaleX = 0;\r\n\t anitxt.scaleY = 0;\r\n\t anitxt.alpha = 1;\r\n\t engine.Tween.get(anitxt, { loop: false }).set({\r\n\t x: anix,\r\n\t y: aniy,\r\n\t scaleX: 0,\r\n\t scaleY: 0\r\n\t })\r\n\t .to({\r\n\t y: aniy - 50,\r\n\t scaleX: 1,\r\n\t scaleY: 1,\r\n\t }, 300)\r\n\t .to({\r\n\t y: aniy - 120,\r\n\t alpha: 0\r\n\t }, 500)\r\n\t .call(function () {\r\n\t _this.txtcontainer.removeChild(anitxt);\r\n\t _this.score += addscore;\r\n\t MapData.recoverTxt(anitxt);\r\n\t });\r\n\t };\r\n\t GameView.prototype.changeHomeShow = function (mode) {\r\n\t };\r\n\t GameView.prototype.boomeEle = function (row, col) {\r\n\t this.useBoom = false;\r\n\t this.anicontainer.removeChild(this.selectimg);\r\n\t this.changeEnable(false);\r\n\t this.selectArr = new Array();\r\n\t this.eliminateArr = new Array();\r\n\t for (var r = 0; r < MapData.row; r++) {\r\n\t var irc = r + \"_\" + col;\r\n\t var ielename = this.lattices[irc];\r\n\t var iele = this.container.getChildByName(ielename);\r\n\t if (iele) {\r\n\t var eletype = iele.type;\r\n\t this.eliminateArr.push([\r\n\t {\r\n\t idxname: irc,\r\n\t type: eletype\r\n\t }\r\n\t ]);\r\n\t }\r\n\t }\r\n\t for (var c = 0; c < MapData.col; c++) {\r\n\t if (c != col) {\r\n\t var irc = row + \"_\" + c;\r\n\t var ielename = this.lattices[irc];\r\n\t var iele = this.container.getChildByName(ielename);\r\n\t if (iele) {\r\n\t var eletype = iele.type;\r\n\t this.eliminateArr.push([\r\n\t {\r\n\t idxname: irc,\r\n\t type: eletype\r\n\t }\r\n\t ]);\r\n\t }\r\n\t }\r\n\t }\r\n\t this.eliminate();\r\n\t };\r\n\t return GameView;\r\n\t}(engine.Container));\r\n\t//# sourceMappingURL=GameView.js.map\n\n\tvar GameWrapper = (function (_super) {\r\n\t tslib.__extends(GameWrapper, _super);\r\n\t function GameWrapper() {\r\n\t var _this = _super.call(this) || this;\r\n\t _this._gameView = new GameView();\r\n\t _this.addChild(_this._gameView);\r\n\t engine.globalEvent.addEventListener('game-init', _this.init, _this);\r\n\t engine.globalEvent.addEventListener('game-reset', _this.reset, _this);\r\n\t engine.globalEvent.addEventListener('game-start', _this.start, _this);\r\n\t engine.globalEvent.addEventListener('game-pause', _this.pause, _this);\r\n\t engine.globalEvent.addEventListener('game-resume', _this.resume, _this);\r\n\t engine.globalEvent.addEventListener('game-recordcomp', _this.recordcomp, _this);\r\n\t return _this;\r\n\t }\r\n\t GameWrapper.prototype.init = function (event) {\r\n\t console.log(\"gamewrapper-init\", event);\r\n\t var time = event.data.time;\r\n\t var level = event.data.level;\r\n\t var mode = event.data.mode;\r\n\t this._gameView.init(time, level, mode);\r\n\t };\r\n\t GameWrapper.prototype.reset = function (event) {\r\n\t var time = event.data.time;\r\n\t var level = event.data.level;\r\n\t var mode = event.data.mode;\r\n\t this._gameView.reset(time, level, mode);\r\n\t };\r\n\t GameWrapper.prototype.start = function () {\r\n\t this._gameView.start();\r\n\t };\r\n\t GameWrapper.prototype.pause = function () {\r\n\t this._gameView.pause();\r\n\t };\r\n\t GameWrapper.prototype.resume = function () {\r\n\t this._gameView.resume();\r\n\t };\r\n\t GameWrapper.prototype.recordcomp = function () {\r\n\t this._gameView.recordcomp();\r\n\t };\r\n\t return GameWrapper;\r\n\t}(engine.Container));\r\n\t//# sourceMappingURL=GameWrapper.js.map\n\n\tfunction index (props) {\r\n\t prepareProps();\r\n\t injectProps(props);\r\n\t var instance = new GameWrapper();\r\n\t return instance;\r\n\t}\r\n\t//# sourceMappingURL=index.js.map\n\n\treturn index;\n\n})));\n"
}
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
"typescript": "^3.7.2" "typescript": "^3.7.2"
}, },
"dependencies": { "dependencies": {
"cnpm": "^6.1.1",
"commander": "^4.1.0", "commander": "^4.1.0",
"watchr": "^5.6.0" "watchr": "^5.6.0"
} }
......
/**
* Created by rockyl on 2019-12-16.
*/
const customId = 'bjxd-game';
(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('bjxd-game-start', {guide: 1});
}, 500);
setTimeout(() => {
engine.globalEvent.dispatchEvent('bjxd-game-reset', {guide: 2});
}, 600);
});
engine.globalEvent.addEventListener('dxbcyj-game-result', (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: transparent;
}
</style>
</head>
<body>
<div id="game-container" style="line-height:0;font-size:0"></div>
<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/svga.fd3923ae6e664251ca7981801a65809cc5f36bc3.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 = [
];
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['bjxd-game'] = 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
var ObjectPool = engine.ObjectPool;
var Road = (function (_super) {
tslib.__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.pierCount + 1) {
var childrenNum = this.children.length;
var randomPos = this.makeRandomFloat(props.pierMaxDistance, props.pierMinDistance);
var pier = ObjectPool.getObject('pier');
this.addChild(pier);
pier.changeBg();
if (childrenNum == 0) {
pier.x = 0;
}
else {
pier.x = this.lastPos + randomPos;
}
this.lastPos = pier.x;
}
};
Road.prototype.changeBg = function () {
var nume = this.children.length;
for (var i = 0; i < nume; i++) {
var ipier = this.getChildAt(i);
ipier.changeBg();
}
};
Road.prototype.moveAddPier = function () {
var randomPos = this.makeRandomFloat(props.pierMaxDistance, props.pierMinDistance);
var pier = ObjectPool.getObject('pier');
var lastChild = this.getChildAt(this.children.length - 1);
pier.x = lastChild.x + randomPos;
this.addChild(pier);
pier.changeBg();
};
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.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));
//# sourceMappingURL=Road.js.map
function getTexture(uuid) {
return engine.Texture.from(getAssetByUUID(uuid).uuid);
}
function getTextureByName(name) {
return getTexture(engine.getAssetByName(name).uuid);
}
function getStage() {
return engine.gameStage.stage;
}
function createSvga(name) {
var inst = new svga.Svga();
inst.source = engine.getAssetByName(name).uuid;
return inst;
}
//# sourceMappingURL=utils.js.map
var GuideLayer = (function (_super) {
tslib.__extends(GuideLayer, _super);
function GuideLayer() {
var _this = _super.call(this) || this;
_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) {
var _a = this.stage, width = _a.width, height = _a.height;
this.guideMask = new engine.Container();
this.addChild(this.guideMask);
this.guideImg = new engine.Image();
this.guideMask.addChild(this.guideImg);
this.shouzhi = new engine.Image(getTextureByName("shouzhi"));
this.guideMask.addChild(this.shouzhi);
}
this.guideImg.texture = getTextureByName("yindao" + id);
this.guideStep(id);
this.once(engine.MouseEvent.CLICK, function () {
this.visible = false;
if (this._callBack) {
this._callBack();
}
}, this);
};
GuideLayer.prototype.guideStep = function (id) {
if (id == 1) {
this.shouzhi.x = 244;
this.shouzhi.y = 812;
}
if (id == 2) {
this.shouzhi.x = 346;
this.shouzhi.y = 1108;
}
};
return GuideLayer;
}(engine.Container));
//# sourceMappingURL=GuideLayer.js.map
var LoopComponent = (function (_super) {
tslib.__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') {
if (item.length > 0) {
part = new engine.Sprite(getTextureByName(item));
}
else {
part = new engine.Sprite();
}
}
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) {
if (changName && changName.length > 0) {
item.texture = 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));
//# sourceMappingURL=LoopComponent.js.map
var Background = (function (_super) {
tslib.__extends(Background, _super);
function Background() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this.partResHHL = ['bg1', ''];
_this.partResHB = ['bg2', ''];
_this.partResWH = ['bg3', ''];
_this.speeds = [];
_this.resArray = [];
_this.frameMovePos = 0;
return _this;
}
Background.prototype.initBg = function () {
this.sumMovePos = 0;
this.speeds.push(props.afterBGMoveSpeed);
this.speeds.push(props.frontBGMoveSpeed);
var bottomBg = new engine.Rect();
bottomBg.x = 0;
bottomBg.y = 0;
bottomBg.width = 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);
var parts = [];
for (var i = 0; i < 2; i++) {
var part = new 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.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;
}
}
};
return Background;
}(engine.Container));
//# sourceMappingURL=Background.js.map
var Pier = (function (_super) {
tslib.__extends(Pier, _super);
function Pier() {
var _this = _super.call(this) || this;
_this.part1tex = "zhuzi1";
_this.part2tex = "zhuzi2";
_this.part3tex = "zhuzi3";
_this.texname = "";
_this.zhuy = 1006;
_this.bmp = new engine.Sprite();
_this.addChild(_this.bmp);
return _this;
}
Pier.prototype.init = function () {
var bmp = this.bmp;
bmp.alpha = 1;
this.changeBg();
bmp.x = 0;
bmp.y = this.zhuy;
};
Pier.prototype.changeBg = function () {
var texstr;
if (GameView.bgIndex == 0) {
texstr = this.part1tex;
}
else if (GameView.bgIndex == 1) {
texstr = this.part2tex;
}
else {
texstr = this.part3tex;
}
if (this.texname != texstr) {
this.texname = texstr;
this.bmp.texture = getTextureByName(texstr);
}
};
Pier.prototype.setShowGold = function () {
var nodeGold = this.getChildByName('gold');
var randomWard = Math.random();
nodeGold.alpha = 1;
var isShow = randomWard < 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 = this.zhuy - 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));
//# sourceMappingURL=Pier.js.map
var Player = (function (_super) {
tslib.__extends(Player, _super);
function Player() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this.playery = 878;
return _this;
}
Player.prototype.initPlayer = function (pierWidth) {
this.pierWidth = pierWidth;
this._container = new engine.Container();
this.addChild(this._container);
this.playerNode = createSvga('walk');
this._container.addChild(this.playerNode);
this.playerNode.y = this.playery;
this.playerNode.x = pierWidth / 2 - 50;
this.playerNode.play();
this._container.visible = false;
};
Player.prototype.revive = function () {
this._container.x = 0;
this._container.y = 0;
this.playerNode.x = this.pierWidth / 2 - 50;
this.playerNode.y = this.playery;
};
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.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.pierMoveTime)
.call(function () {
engine.Tween.removeTweens(_this._container);
if (callBack) {
callBack();
}
});
};
return Player;
}(engine.Container));
//# sourceMappingURL=Player.js.map
var Strut = (function (_super) {
tslib.__extends(Strut, _super);
function Strut() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this.gany = 1005;
return _this;
}
Strut.prototype.init = function () {
this._strut = new engine.Image(getTextureByName("ganzi"));
this.addChild(this._strut);
this._strut.y = this.gany;
this._strut.rotation = 180;
};
Strut.prototype.onMouseDown = function (pierWidth, distance, callBack) {
var paddingx = 20;
if (GameView.bgIndex == 0) {
paddingx = 20;
}
else if (GameView.bgIndex == 1) {
paddingx = 30;
}
else if (GameView.bgIndex == 2) {
paddingx = 20;
}
this._strut.x = pierWidth - paddingx;
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.strutRotationSpeed)
.call(function () {
_this.judgeResult();
engine.Tween.removeTweens(_this._strut);
});
};
Strut.prototype.judgeResult = function () {
var isSuccess = false;
var paddingx = 20;
var chax = 20;
if (GameView.bgIndex == 0) {
paddingx = 20;
chax = 20;
}
else if (GameView.bgIndex == 1) {
paddingx = 3;
chax = 39;
}
else if (GameView.bgIndex == 2) {
paddingx = 20;
chax = 20;
}
var mindis = this._distance[0] - this._distance[1] + chax;
var maxdis = this._distance[0] + paddingx;
if (mindis <= this._strut.height && this._strut.height <= maxdis) {
isSuccess = true;
}
if (this._callBack) {
this._callBack(isSuccess);
}
};
Strut.prototype.frameStrut = function () {
var maxdis = 700;
if (this._strut.height < maxdis) {
if (this._strut.height + GameView.speed > maxdis) {
this._strut.height = maxdis;
}
else {
this._strut.height += GameView.speed;
}
}
};
Strut.prototype.rest = function () {
this._strut.y = this.gany;
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));
//# sourceMappingURL=Strut.js.map
var ObjectPool$1 = engine.ObjectPool;
var PoolName = 'pier';
ObjectPool$1.registerPool(PoolName, function () {
return new Pier();
}, function (item, data) {
item.init();
});
var GameView = (function (_super) {
tslib.__extends(GameView, _super);
function GameView() {
var _this = _super.call(this) || this;
_this.moveX = 0;
_this.playery = 878;
_this.inani = true;
_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();
this.addChild(this._backgroud);
this._backgroud.initBg();
var road = this._road = new Road();
this.addChild(road);
road.setup();
var pierWidth = this._road.getFristPier();
var player = this._player = new Player();
this.addChild(player);
player.initPlayer(pierWidth);
this.pierWidth = pierWidth;
this.xiacheNode = createSvga("xiache");
this.addChild(this.xiacheNode);
this.xiacheNode.y = this.playery - 35;
this.xiacheNode.x = this.pierWidth / 2 - 100;
this.xiacheNode.stop();
this.xiacheNode.name = "xiacheanm";
console.log("下车动画帧数", this.xiacheNode.totalFrames, this.xiacheNode);
this.xiacheNode.visible = false;
var strut = this._strut = new Strut();
this.addChild(strut);
strut.init();
};
GameView.prototype.playComp = function () {
var curframe = this.xiacheNode.currentFrame;
if (curframe == this.xiacheNode.totalFrames) {
this.inani = false;
this.xiacheNode.stop();
this.xiacheNode.removeEventListener(engine.Event.ENTER_FRAME, this.playComp, this);
for (var i = 0; i < 15; i++) {
if (i < 12) {
this.xiacheNode.getChildAt(i).visible = false;
}
}
this._player._container.visible = true;
}
};
GameView.prototype.start = function (guide) {
return tslib.__awaiter(this, void 0, void 0, function () {
var initScore;
return tslib.__generator(this, function (_a) {
this._isTouchLayer = true;
this._sumScore = 0;
this._isMouseDown = false;
this._guide = guide;
this._player.revive();
this.closeStrut();
initScore = 0;
this.updateScore(initScore);
if (this.xiacheNode.x < this.pierWidth / 2 - 105) {
this.startAnm();
}
if (this._guide == '1') {
this.setGuide();
}
else {
this.initTouch();
this.registerEvent();
}
engine.globalEvent.dispatchEvent("bjxd-game-inmove", {
"canstop": true
});
return [2];
});
});
};
GameView.prototype.startAnm = function () {
this.inani = true;
this.xiacheNode.visible = true;
for (var i = 0; i < 15; i++) {
if (i < 12) {
this.xiacheNode.getChildAt(i).visible = true;
}
}
this.xiacheNode.x = this.pierWidth / 2 - 100;
this._player._container.visible = false;
this.xiacheNode.gotoAndPlay(1);
this.xiacheNode.addEventListener(engine.Event.ENTER_FRAME, this.playComp, this);
};
GameView.prototype.reset = function () {
this._sumScore = 0;
engine.globalEvent.dispatchEvent('bjxd-game-score', { score: this._sumScore });
this._player.revive();
this.closeStrut();
this.changeBg(GameView.bgIndex);
this.startAnm();
engine.globalEvent.dispatchEvent("bjxd-game-inmove", {
"canstop": true
});
};
GameView.prototype.revive = function () {
this._player.revive();
this.startAnm();
this._isTouchLayer = true;
this.closeStrut();
engine.globalEvent.dispatchEvent("bjxd-game-inmove", {
"canstop": true
});
};
GameView.prototype.setGuide = function () {
var _this = this;
this._road.setGuide();
var guideLayer = this.guideLayer = new GuideLayer();
this.addChild(guideLayer);
this.guideLayer.show(1, { x: 20, y: 650, guideText: props.guideText1 }, function () {
var posX = _this._road.getMovePos();
_this.guideLayer.show(2, { x: posX + 20, y: 620, guideText: props.guideText2 }, function () {
_this.initTouch();
_this.registerEvent();
});
});
};
GameView.prototype.initLabScore = function () {
};
GameView.prototype.registerEvent = function () {
this.removeListener();
this.addEventListener(engine.MouseEvent.MOUSE_DOWN, this.onMouseDown, this);
this.addEventListener(engine.MouseEvent.MOUSE_UP, this.onMouseUp, this);
};
GameView.prototype.removeListener = function () {
this.removeEventListener(engine.MouseEvent.MOUSE_DOWN, this.onMouseDown, this);
this.removeEventListener(engine.MouseEvent.MOUSE_UP, this.onMouseUp, this);
};
GameView.prototype.initTouch = function () {
};
GameView.prototype.setScoreShow = function () {
};
GameView.prototype.onMouseDown = function () {
if (this._isTouchLayer && !this.inani) {
engine.globalEvent.dispatchEvent("bjxd-game-inmove", {
"canstop": false
});
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) {
var movePos = this._road.getMovePos();
if (this._road.getStartGold(1, false)) {
this.updateScore(props.singleScore + props.goldScore);
}
else {
this.updateScore(props.singleScore);
}
this._player.setViewport(movePos, this.complete.bind(this));
}
else {
this._player.setViewport(this._strut.getStrutHeight(), function () {
engine.globalEvent.dispatchEvent('bjxd-game-over', { 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;
});
var carx = this.xiacheNode.x;
if (carx > -200) {
carx -= movePos;
engine.Tween.get(this.xiacheNode, { loop: false })
.to({
x: carx
}, props.pierMoveTime);
}
engine.globalEvent.dispatchEvent("bjxd-game-inmove", {
"canstop": true
});
this.closeStrut();
};
GameView.prototype.closeStrut = function () {
this._strut.rest();
};
GameView.prototype.updateScore = function (score) {
this._sumScore += score;
engine.globalEvent.dispatchEvent('bjxd-game-score', { score: this._sumScore });
};
GameView.prototype.getScore = function () {
return this._sumScore;
};
GameView.prototype.changeBg = function (index) {
if (GameView.bgIndex != index) {
GameView.bgIndex = index;
this._backgroud.changeBg(index);
this._road.changeBg();
}
};
GameView.prototype.changeSpeed = function (speed) {
if (GameView.speed != speed) {
GameView.speed = speed;
}
};
GameView.bgIndex = 0;
GameView.speed = 20;
return GameView;
}(engine.Container));
//# sourceMappingURL=GameView.js.map
var GameWrapper = (function (_super) {
tslib.__extends(GameWrapper, _super);
function GameWrapper() {
var _this = _super.call(this) || this;
engine.globalEvent.addEventListener('bjxd-game-start', _this.start, _this);
engine.globalEvent.addEventListener('bjxd-game-reset', _this.reset, _this);
engine.globalEvent.addEventListener('bjxd-game-revive', _this.revive, _this);
engine.globalEvent.addEventListener('bjxd-game-change', _this.change, _this);
engine.globalEvent.addEventListener('bjxd-game-speed', _this.speed, _this);
var gameView = _this._gameView = new GameView();
_this.addChild(gameView);
return _this;
}
GameWrapper.prototype.start = function (event) {
this._gameView.start(event.data.guide);
};
GameWrapper.prototype.reset = function () {
this._gameView.reset();
};
GameWrapper.prototype.revive = function () {
this._gameView.revive();
};
GameWrapper.prototype.change = function (event) {
this._gameView.changeBg(event.data.index);
};
GameWrapper.prototype.speed = function (event) {
this._gameView.changeSpeed(event.data.speed);
};
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/bjxd-game/src/props.ts","src/custom/bjxd-game/src/game/Road.ts","src/custom/bjxd-game/src/game/utils.ts","src/custom/bjxd-game/src/game/GuideLayer.ts","src/custom/bjxd-game/src/game/LoopComponent.ts","src/custom/bjxd-game/src/game/Background.ts","src/custom/bjxd-game/src/game/Pier.ts","src/custom/bjxd-game/src/game/Player.ts","src/custom/bjxd-game/src/game/Strut.ts","src/custom/bjxd-game/src/game/GameView.ts","src/custom/bjxd-game/src/game/GameWrapper.ts","src/custom/bjxd-game/src/index.ts"],"sourcesContent":["/**\r\n * Created by rockyl on 2020-01-21.\r\n */\r\n\r\nexport let props: any = {};\r\n\r\nexport function prepareProps() {\r\n\tlet metaProps = getProps();\r\n\r\n\tengine.injectProp(props, metaProps);\r\n}\r\n\r\nexport function injectProps(p) {\r\n\tengine.injectProp(props, p);\r\n}\r\n","\r\n\r\nimport { props } from './../props';\r\nimport ObjectPool = engine.ObjectPool;\r\nimport {getTextureByName,getStage} from \"./utils\";\r\nimport { Pier } from './Pier';\r\nimport GameView from './GameView';\r\n\r\nexport class Road extends engine.Container{\r\n //container: engine.Container;\r\n lastPos;\r\n setup(){\r\n // this.container = new engine.Container();\r\n // this.addChild(this.container);\r\n this.lastPos = 0;\r\n this.addPier();\r\n\r\n }\r\n getFristPier(){\r\n return this.getChildAt(0).width;\r\n }\r\n getDistance(){\r\n let distance = [];\r\n let pier1 = this.getChildAt(0);\r\n let pier2 = this.getChildAt(1);\r\n distance.push(pier2.x - pier1.x);\r\n distance.push(pier2.width);\r\n\r\n return distance;\r\n }\r\n addPier(){ \r\n while(this.children.length < props.pierCount + 1){\r\n let childrenNum = this.children.length;\r\n let randomPos = this.makeRandomFloat(props.pierMaxDistance,props.pierMinDistance);\r\n const pier: Pier = ObjectPool.getObject('pier');\r\n this.addChild(pier);\r\n pier.changeBg();\r\n if(childrenNum == 0){\r\n pier.x = 0;\r\n }else{\r\n pier.x = this.lastPos + randomPos;\r\n }\r\n this.lastPos = pier.x;\r\n }\r\n }\r\n changeBg(){\r\n let nume = this.children.length;\r\n\r\n for(let i=0;i<nume;i++){\r\n let ipier = this.getChildAt(i) as Pier;\r\n ipier.changeBg();\r\n }\r\n }\r\n moveAddPier(){\r\n let randomPos = this.makeRandomFloat(props.pierMaxDistance,props.pierMinDistance);\r\n const pier: Pier = ObjectPool.getObject('pier');\r\n let lastChild = this.getChildAt(this.children.length -1);\r\n pier.x = lastChild.x + randomPos;\r\n this.addChild(pier);\r\n pier.changeBg();\r\n\r\n }\r\n makeRandomFloat(max: number, min: number = 0): number {\r\n return Math.random() * (max - min) + min;\r\n }\r\n setViewport(){\r\n let tmpMovepos = this.getMovePos();\r\n this.children.forEach((item,index) => {\r\n this.playTween(item,index,tmpMovepos);\r\n })\r\n }\r\n //获得移动位移\r\n getMovePos(){\r\n let movePos:any = this.getChildAt(1);\r\n return movePos.x;\r\n }\r\n playTween(item,index,tmpMovepos){\r\n engine.Tween.get(item,{loop:false})\r\n .to({x : item.x - tmpMovepos},props.pierMoveTime)\r\n .call(()=>{\r\n if(this.getChildIndex(item) == 0){\r\n engine.Tween.removeTweens(item);\r\n this.removeChild(item);\r\n ObjectPool.recycleObject('pier',item);\r\n }\r\n if(index == 0){\r\n this.moveAddPier();\r\n }\r\n })\r\n }\r\n //桥墩是否有金币\r\n getStartGold(index,isClose = true){\r\n let tmpNode:any = this.getChildAt(index);\r\n let haveGold = tmpNode.haveGold;\r\n if(haveGold && isClose){\r\n tmpNode.closeGold();\r\n }\r\n return haveGold;\r\n } \r\n //设置新手引导 第二个桥墩要有金币\r\n setGuide(){\r\n let tmpNode:any = this.getChildAt(1);\r\n if(!tmpNode.haveGold){\r\n tmpNode.children.forEach((item) => {\r\n if(item.name == 'gold'){\r\n item.visible = true;\r\n }\r\n })\r\n tmpNode.haveGold = true;\r\n }\r\n }\r\n}","/**\r\n * Created by rockyl on 2020-01-21.\r\n */\r\n\r\nexport function getTexture(uuid) {\r\n\treturn engine.Texture.from(getAssetByUUID(uuid).uuid);\r\n}\r\n\r\nexport function getTextureByName(name) {\r\n\t// console.log(\"资源加载\",name);\r\n\treturn getTexture(engine.getAssetByName(name).uuid);\r\n}\r\n\r\nexport function playSound(name) {\r\n\tengine.playSound(engine.getAssetByName(name).uuid, {keep: true});\r\n}\r\nexport function getStage(){\r\n\treturn engine.gameStage.stage;\r\n}\r\n\r\nexport function createSvga(name) {\r\n\tlet inst = new svga.Svga();\r\n\tinst.source = engine.getAssetByName(name).uuid;\r\n\t// let anchor = props[(anchorName)];\r\n\t// if (anchor) {\r\n\t// \tinst.x = -anchor.x;\r\n\t// \tinst.y = -anchor.y;\r\n\r\n\t// \tinst.anchorX = anchor.x;\r\n\t// \tinst.anchorY = anchor.y;\r\n\t// }\r\n\treturn inst;\r\n}\r\n","/**\r\n * Created by rockyl on 2020-01-30.\r\n */\r\nimport {props} from \"../props\";\r\nimport {getTextureByName} from \"./utils\";\r\n\r\nexport class GuideLayer extends engine.Container {\r\n\tprivate guideMask: engine.Container;\r\n\tguideImg:engine.Image;\r\n\tshouzhi:engine.Image;\r\n\t_options;\r\n\t_callBack;\r\n\r\n\tconstructor() {\r\n\t\tsuper();\r\n\t\tthis.setup();\r\n\t}\r\n\r\n\tprivate setup() {\r\n\r\n\t}\r\n\r\n\tshow(id, options,callback?) {\r\n\t\tthis.visible = true;\r\n\t\tthis._callBack = callback?callback:null;\r\n\r\n\t\tif (!this.guideMask) {\r\n\t\t\tconst {width, height} = this.stage;\r\n\t\t\tthis.guideMask = new engine.Container();\r\n\t\t\tthis.addChild(this.guideMask);\r\n\r\n\t\t\tthis.guideImg = new engine.Image();\r\n\t\t\tthis.guideMask.addChild(this.guideImg);\r\n\r\n\t\t\tthis.shouzhi = new engine.Image(getTextureByName(\"shouzhi\"));\r\n\t\t\tthis.guideMask.addChild(this.shouzhi);\r\n\t\t}\r\n\t\tthis.guideImg.texture = getTextureByName(\"yindao\"+id);\r\n\t\tthis.guideStep(id);\r\n\t\t\r\n\t\tthis.once(engine.MouseEvent.CLICK, function(){\r\n\t\t\tthis.visible = false;\r\n\t\t\tif(this._callBack){\r\n\t\t\t\tthis._callBack();\r\n\t\t\t}\r\n\t\t}, this);\r\n\t}\r\n\tguideStep(id){\r\n\t\tif(id == 1){\r\n\t\t\tthis.shouzhi.x = 244;\r\n\t\t\tthis.shouzhi.y = 812;\r\n\t\t}\r\n\t\tif(id == 2){\r\n\t\t\tthis.shouzhi.x = 346;\r\n\t\t\tthis.shouzhi.y = 1108;\r\n\t\t}\r\n\t}\r\n}\r\n","\r\nimport {getTextureByName} from \"./utils\";\r\nexport class LoopComponent extends engine.Container{\r\n parts: any[];\r\n\r\n\tonceInfo: any = {width: 0, height: 0, count: 0};\r\n\tloopInfo: any = {width: 0, height: 0, count: 0};\r\n\r\n\tconstructor() {\r\n\t\tsuper();\r\n\r\n\t\tthis.parts = [];\r\n }\r\n private setup(parts, info) {\r\n parts.forEach((item, index) => {\r\n\t\t\tlet part;\r\n\t\t\tif(typeof item == 'string'){\r\n\t\t\t\tif(item.length>0){\r\n\t\t\t\t\tpart = new engine.Sprite(getTextureByName(item));\r\n\t\t\t\t}else{\r\n\t\t\t\t\tpart = new engine.Sprite();\r\n\t\t\t\t}\r\n\t\t\t}else if(item instanceof engine.Texture){\r\n\t\t\t\tpart = new engine.Sprite(item);\r\n\t\t\t}else {\r\n\t\t\t\tpart = item;\r\n\t\t\t}\r\n\t\t\tthis.addChild(part);\r\n\t\t\tthis.parts.push(part);\r\n\r\n\t\t\tif (index == 0) {\r\n\t\t\t\tinfo.width = part.width;\r\n\t\t\t\tinfo.height = part.height;\r\n\t\t\t}\r\n\t\t});\r\n\t\tinfo.count = parts.length;\r\n\r\n\t\tthis.setViewport(0, 0)\r\n }\r\n\r\n\tchangeBg(changName){\r\n\t\tthis.parts.forEach((item, index) => {\r\n\t\t\tif(changName&&changName.length>0){\r\n\t\t\t\titem.texture = getTextureByName(changName)\r\n\t\t\t}\r\n\t\t});\r\n\t}\r\n\tsetupLoop(resArr) {\r\n\t\tthis.setup(resArr, this.loopInfo);\r\n }\r\n setViewport(x, y = 0) {\r\n\t\tconst sizeField = y == 0 ? 'width' : 'height';\r\n\t\tconst posField = y == 0 ? 'x' : 'y';\r\n\t\tconst pos = y == 0 ? x : y;\r\n\r\n\t\tlet index;\r\n\t\tconst onceSize = this.onceInfo[sizeField];\r\n\t\tconst onceCount = this.onceInfo.count;\r\n\t\tconst loopCount = this.loopInfo.count;\r\n\t\tconst loopSize = this.loopInfo[sizeField];\r\n\t\tindex = onceSize == 0 ? -1 : Math.floor(pos / onceSize);\r\n\r\n\t\tif (index < 0 || index >= onceCount) {\r\n\t\t\tconst loopIndex = Math.floor((pos - onceCount * onceSize) / this.loopInfo[sizeField]);\r\n\t\t\tindex = onceCount + loopIndex;\r\n\t\t}\r\n\r\n\t\tlet formerIndex = index < onceCount ? index : (index) % loopCount + onceCount;\r\n\t\tlet latterIndex = index < onceCount ? index + 1 : (index - onceCount + 1) % loopCount + onceCount;\r\n\t\tlet former = this.parts[formerIndex];\r\n\t\tlet latter = this.parts[latterIndex];\r\n\t\tif(!former || !latter){\r\n\t\t\tconsole.log(formerIndex, latterIndex);\r\n\t\t}\r\n\t\tformer[posField] = -(pos - loopSize * (index < onceCount ? index : index - onceCount) - (index < onceCount ? 0 : onceCount * onceSize));\r\n\t\tlatter[posField] = former.x + (index < onceCount ? onceSize : loopSize);\r\n\t}\r\n}","\r\n\r\nimport {getTextureByName} from \"./utils\";\r\nimport {getStage} from \"./utils\";\r\nimport {LoopComponent} from \"./LoopComponent\";\r\nimport { props } from './../props';\r\n\r\nexport class Background extends engine.Container{\r\n partResHHL = ['bg1',''];\r\n partResHB = ['bg2',''];\r\n partResWH = ['bg3',''];\r\n speeds = [];\r\n resArray=[];\r\n frameMovePos = 0;\r\n frameIndex;\r\n sumMovePos;\r\n //需要的总帧数\r\n needFrameSum;\r\n initBg(){\r\n this.sumMovePos = 0;\r\n this.speeds.push(props.afterBGMoveSpeed);\r\n this.speeds.push(props.frontBGMoveSpeed);\r\n \r\n let bottomBg = new engine.Rect();\r\n bottomBg.x = 0;\r\n bottomBg.y = 0;\r\n bottomBg.width = getStage().width;\r\n bottomBg.height = 0;\r\n bottomBg.fillColor = 0x75c9f5;\r\n\r\n this.addChild(bottomBg);\r\n this.resArray.push(this.partResHHL)\r\n this.resArray.push(this.partResHB)\r\n this.resArray.push(this.partResWH)\r\n \r\n\t\tconst parts = [];\r\n\t\tfor(let i = 0; i < 2; i++){\r\n\t\t\tlet part = new LoopComponent();\r\n\t\t\tpart.setupLoop([\r\n\t\t\t\tthis.resArray[0][i],\r\n\t\t\t\tthis.resArray[0][i],\r\n\t\t\t]);\r\n\t\t\tparts.push(part);\r\n this.addChild(part);\r\n }\r\n \r\n //(height - parts[1].height) / 2 - 200\r\n parts[1].y = 200;\r\n }\r\n \r\n setViewport(pos) {\r\n this.needFrameSum = (props.pierMoveTime/1000)*60;\r\n this.frameMovePos = pos/this.needFrameSum;\r\n this.frameIndex = 0;\r\n this.addEventListener(engine.Event.ENTER_FRAME,this.frameBack,this);\r\n }\r\n frameBack(){\r\n if( this.frameIndex < this.needFrameSum){\r\n for (let i = 0; i < 2; i++) {\r\n const part = <LoopComponent>this.getChildAt(i + 1);\r\n const speed = this.speeds[i];\r\n let tmpPos = ((this.frameMovePos * this.frameIndex) + this.sumMovePos ) * speed;\r\n part.setViewport(tmpPos)\r\n }\r\n this.frameIndex++\r\n }else{\r\n this.sumMovePos += this.frameMovePos * this.needFrameSum;\r\n this.frameIndex = 0\r\n this.removeEventListener(engine.Event.ENTER_FRAME,this.frameBack,this);\r\n } \r\n }\r\n changeBg(index){\r\n for (let i = 0; i < 2; i++) {\r\n const part = <LoopComponent>this.getChildAt(i + 1);\r\n part.changeBg(this.resArray[index][i]);\r\n if(i == 1 && index ==1){\r\n part.y = 400;\r\n } \r\n if(i == 1 && index ==2){\r\n part.y = 250;\r\n } \r\n }\r\n }\r\n}","import { props } from './../props';\r\nimport {getTextureByName,getStage} from \"./utils\";\r\nimport GameView from './GameView';\r\nexport class Pier extends engine.Container {\r\n bmp:engine.Sprite;\r\n public haveGold;\r\n part1tex = \"zhuzi1\";\r\n part2tex = \"zhuzi2\";\r\n part3tex = \"zhuzi3\";\r\n\r\n texname:string = \"\";\r\n constructor() {\r\n\t\tsuper();\r\n this.bmp = new engine.Sprite();\r\n this.addChild(this.bmp);\r\n }\r\n zhuy:number = 1006;\r\n init(){\r\n\t\tconst bmp = this.bmp;\r\n bmp.alpha = 1;\r\n this.changeBg();\r\n\r\n\t\tbmp.x = 0;\r\n bmp.y = this.zhuy;\r\n // if(this.children.length < 2){\r\n // const gold = new engine.Sprite();\r\n // gold.texture = getTextureByName('gold');\r\n // gold.name = 'gold';\r\n // this.addChild(gold);\r\n // }\r\n // this.setGoldPosX(bmp);\r\n // this.setShowGold();\r\n }\r\n changeBg(){\r\n let texstr;\r\n if(GameView.bgIndex==0){\r\n texstr = this.part1tex;\r\n }else if(GameView.bgIndex==1){\r\n texstr = this.part2tex;\r\n }else{\r\n texstr = this.part3tex;\r\n }\r\n if(this.texname!=texstr){\r\n this.texname = texstr;\r\n\t\t this.bmp.texture = getTextureByName(texstr);\r\n }\r\n }\r\n setShowGold(){\r\n let nodeGold = this.getChildByName('gold');\r\n let randomWard = Math.random();\r\n nodeGold.alpha = 1;\r\n let isShow = randomWard < props.reward ? true : false ;\r\n nodeGold.visible = isShow;\r\n this.haveGold = isShow;\r\n }\r\n setGoldPosX(bmp){\r\n let nodeGold = this.getChildByName('gold');\r\n let pos = bmp.width / 2 - nodeGold.width/2;\r\n nodeGold.x = pos\r\n nodeGold.y = this.zhuy - nodeGold.height - 50;\r\n nodeGold.visible = false;\r\n }\r\n closeGold(){\r\n this.children.forEach((item) => {\r\n if(item.name == 'gold')\r\n {\r\n item.anchorX = item.width/2;\r\n item.anchorY = item.height/2;\r\n engine.Tween.get(item,{loop:false})\r\n .to({scaleX:2.5,scaleY:2.5},200,engine.Ease.cubicOut)\r\n .to({scaleX:1,scaleY:1,alpha:0},200,engine.Ease.cubicIn)\r\n .call(()=>{\r\n item.visible = false;\r\n this.haveGold = false;\r\n })\r\n }\r\n })\r\n }\r\n}","import {props} from \"../props\";\r\nimport {createSvga, playSound} from \"./utils\";\r\nexport class Player extends engine.Container{\r\n _container;\r\n private playerNode: svga.Svga;\r\n\r\n pierWidth\r\n playery:number = 878;\r\n initPlayer(pierWidth){\r\n this.pierWidth = pierWidth;\r\n this._container = new engine.Container();\r\n this.addChild(this._container);\r\n\r\n\r\n this.playerNode = createSvga('walk');\r\n this._container.addChild(this.playerNode);\r\n this.playerNode.y = this.playery;\r\n this.playerNode.x = pierWidth/2 - 50;\r\n this.playerNode.play();\r\n this._container.visible = false;\r\n }\r\n\r\n revive(){\r\n this._container.x = 0;\r\n this._container.y = 0;\r\n this.playerNode.x = this.pierWidth/2 - 50;\r\n this.playerNode.y = this.playery;\r\n }\r\n setViewport(pos,callBack,pierWidth?){\r\n let tmpPos = 0;\r\n let isSuccess = false;\r\n if(!pierWidth){\r\n tmpPos = pos;\r\n isSuccess = true;\r\n }else{\r\n tmpPos = pierWidth - this.playerNode.x + pos - 60;\r\n }\r\n this.playGoTween(tmpPos,callBack,isSuccess)\r\n }\r\n playGoTween(pos,callBack,isSuccess){\r\n engine.Tween.get(this._container,{loop:false})\r\n .to({x : pos},props.playerMoveSpeed)\r\n .call(()=>{\r\n engine.Tween.removeTweens(this._container);\r\n if(isSuccess){\r\n if(callBack){\r\n callBack();\r\n }\r\n }else{\r\n this.playDropTween(callBack);\r\n }\r\n \r\n })\r\n }\r\n playDropTween(callBack){\r\n engine.Tween.get(this._container,{loop:false})\r\n .to({y : 2000},1000)\r\n .call(()=>{\r\n engine.Tween.removeTweens(this._container);\r\n if(callBack){\r\n callBack();\r\n }\r\n })\r\n }\r\n setBackViewport(callBack){\r\n engine.Tween.get(this._container,{loop:false})\r\n .to({x : 0},props.pierMoveTime)\r\n .call(()=>{\r\n engine.Tween.removeTweens(this._container);\r\n if(callBack){\r\n callBack();\r\n }\r\n })\r\n }\r\n\r\n}","import { props } from \"../props\";\r\nimport GameView from \"./GameView\";\r\nimport {getTextureByName} from \"./utils\";\r\nexport class Strut extends engine.Container{\r\n _strut: engine.Image;\r\n _distance;\r\n _callBack;\r\n gany = 1005;\r\n init(){\r\n this._strut = new engine.Image(getTextureByName(\"ganzi\"));\r\n this.addChild(this._strut);\r\n // this._strut.width = props.strutWidth;\r\n this._strut.y = this.gany;\r\n // this._strut.fillColor = props.strutColor;\r\n this._strut.rotation = 180;\r\n }\r\n onMouseDown(pierWidth,distance,callBack){\r\n let paddingx = 20;\r\n if(GameView.bgIndex==0){\r\n paddingx = 20;\r\n }else if(GameView.bgIndex==1){\r\n paddingx = 30;\r\n }else if(GameView.bgIndex==2){\r\n paddingx = 20;\r\n }\r\n this._strut.x = pierWidth - paddingx;\r\n\r\n this._distance = distance;\r\n this._callBack = callBack;\r\n this._strut.visible = true;\r\n this.addEventListener(engine.Event.ENTER_FRAME,this.frameStrut,this);\r\n }\r\n onMouseUp(){\r\n this.removeEventListener(engine.Event.ENTER_FRAME,this.frameStrut,this);\r\n setTimeout(() => {\r\n this.strutRotation();\r\n }, 200);\r\n }\r\n strutRotation(){\r\n engine.Tween.get(this._strut,{loop:false})\r\n .to({rotation:270},props.strutRotationSpeed)\r\n .call(()=>{\r\n this.judgeResult();\r\n engine.Tween.removeTweens(this._strut);\r\n })\r\n }\r\n judgeResult(){\r\n let isSuccess = false;\r\n\r\n let paddingx = 20;\r\n let chax = 20;\r\n if(GameView.bgIndex==0){\r\n paddingx = 20;\r\n chax = 20;\r\n }else if(GameView.bgIndex==1){\r\n paddingx = 3;\r\n chax = 39;\r\n }else if(GameView.bgIndex==2){\r\n paddingx = 20;\r\n chax = 20;\r\n }\r\n\r\n let mindis = this._distance[0] - this._distance[1] + chax;\r\n let maxdis = this._distance[0] + paddingx;\r\n // console.log(\"成功失败判断\",mindis,this._strut.height,maxdis);\r\n if(mindis <= this._strut.height && this._strut.height <= maxdis){\r\n isSuccess = true;\r\n }\r\n if(this._callBack){\r\n this._callBack(isSuccess);\r\n }\r\n }\r\n frameStrut(){\r\n // let paddingx = 20;\r\n // let chax = 20;\r\n // if(GameView.bgIndex==0){\r\n // paddingx = 20;\r\n // chax = 20;\r\n // }else if(GameView.bgIndex==1){\r\n // paddingx = 3;\r\n // chax = 39;\r\n // }else if(GameView.bgIndex==2){\r\n // paddingx = 20;\r\n // chax = 20;\r\n // }\r\n // let tmindis = this._distance[0] - this._distance[1] + chax;\r\n // let tmaxdis = this._distance[0] + paddingx;\r\n\r\n let maxdis = 700;\r\n \r\n // maxdis = 700;\r\n // console.log(\"测试杆长\",maxdis);\r\n if(this._strut.height < maxdis){\r\n if(this._strut.height+GameView.speed>maxdis){\r\n this._strut.height = maxdis\r\n }else{\r\n this._strut.height += GameView.speed;\r\n }\r\n }\r\n }\r\n rest(){\r\n // this._strut.width = props.strutWidth;\r\n this._strut.y = this.gany;\r\n // this._strut.fillColor = props.strutColor;\r\n this._strut.rotation = 180;\r\n this._strut.height = 0;\r\n this._strut.visible = false;\r\n }\r\n getStrutHeight(){\r\n let distance = this._strut.height > 1000 ? 1000 :this._strut.height;\r\n return distance;\r\n }\r\n\r\n}","\r\nimport { Road } from './Road';\r\n/**\r\n * Created by rockyl on 2018/8/16.\r\n */\r\n\r\nimport {props} from \"../props\";\r\nimport {getStage,getTextureByName,createSvga} from \"./utils\";\r\nimport {GuideLayer} from \"./GuideLayer\";\r\nimport { Background } from \"./Background\";\r\nimport ObjectPool = engine.ObjectPool;\r\nimport { Pier } from './Pier';\r\nimport { Player } from './Player';\r\nimport { Strut } from './Strut';\r\nimport { ScoreLabel } from './ScoreLabel';\r\n\r\nexport const PoolName: string = 'pier';\r\n\r\nObjectPool.registerPool(PoolName, function () {\r\n\treturn new Pier();\r\n}, function (item: Pier, data) {\r\n\titem.init();\r\n});\r\n\r\nexport default class GameView extends engine.Container {\r\n\tguideLayer: GuideLayer;\r\n\t\r\n\tprivate _hasSetup;\r\n\t_backgroud:Background;\r\n\t_road:Road;\r\n\t_player:Player;\r\n\t\r\n\t_strut:Strut;\r\n\t// _touchLayer: engine.Rect;\r\n\t_isTouchLayer;\r\n\t// _scoreContainer;\r\n\tmoveX = 0;\r\n\t// labScore:ScoreLabel;\r\n\t_sumScore;\r\n\t_isMouseDown;\r\n\r\n\t_guide;\r\n\r\n\ttestrevive:engine.Label;\r\n\ttestchange:engine.Label;\r\n\r\n\tstatic bgIndex:number = 0;\r\n\r\n\r\n private xiacheNode:svga.Svga;\r\n\tplayery:number = 878;\r\n\tinani:boolean = true;\r\n\r\n\tpierWidth;\r\n\tconstructor() {\r\n\t\tsuper();\t\r\n\t\tthis.once(engine.Event.ADDED_TO_STAGE, this.setup, this);\r\n\t}\r\n\tsetup(){\r\n\t\tif (this._hasSetup) {\r\n\t\t\treturn;\r\n\t\t}\r\n\t\tthis._hasSetup = true;\r\n\t\t\r\n\t\tthis._backgroud = new Background();\r\n\t\tthis.addChild(this._backgroud);\r\n\t\tthis._backgroud.initBg();\r\n\r\n\t\tconst road = this._road = new Road();\r\n\t\tthis.addChild(road);\r\n\t\troad.setup();\r\n\r\n\t\tlet pierWidth = this._road.getFristPier();\r\n\t\tconst player = this._player = new Player();\r\n\t\tthis.addChild(player);\r\n\t\tplayer.initPlayer(pierWidth);\r\n\r\n\t\tthis.pierWidth = pierWidth;\r\n\t\tthis.xiacheNode = createSvga(\"xiache\");\r\n this.addChild(this.xiacheNode);\r\n this.xiacheNode.y = this.playery-35;\r\n this.xiacheNode.x = this.pierWidth/2 - 100;\r\n\t\tthis.xiacheNode.stop();\r\n\t\tthis.xiacheNode.name = \"xiacheanm\";\r\n\t\tconsole.log(\"下车动画帧数\",this.xiacheNode.totalFrames,this.xiacheNode);\r\n // this.xiacheNode.addEventListener(engine.Event.ENTER_FRAME,this.playComp,this);\r\n\t\tthis.xiacheNode.visible = false;\r\n\r\n\t\tconst strut = this._strut = new Strut();\r\n\t\tthis.addChild(strut);\r\n\t\tstrut.init();\r\n\r\n\t\t// this.startAnm();\r\n\t\t// this._scoreContainer = new engine.Container();\r\n\t\t// this.addChild(this._scoreContainer);\r\n\t\t// this.initLabScore();\r\n\t}\r\n\tplayComp(){\r\n let curframe = this.xiacheNode.currentFrame;\r\n if(curframe==this.xiacheNode.totalFrames){\r\n\t\t\tthis.inani = false;\r\n // console.log(\"下车动画播放完毕\",curframe,this.xiacheNode);\r\n this.xiacheNode.stop();\r\n this.xiacheNode.removeEventListener(engine.Event.ENTER_FRAME,this.playComp,this);\r\n for(let i=0;i<15;i++){\r\n if(i<12){\r\n this.xiacheNode.getChildAt(i).visible = false;\r\n }\r\n }\r\n\t\t\tthis._player._container.visible = true;\r\n }\r\n }\r\n\tasync start(guide) {\r\n\t\tthis._isTouchLayer = true;\r\n\t\tthis._sumScore = 0;\r\n\t\tthis._isMouseDown = false;\r\n\t\tthis._guide = guide;\r\n\t\tthis._player.revive();\r\n\t\tthis.closeStrut();\r\n\r\n\t\tlet initScore = 0;//this._road.getStartGold(0) ? props.goldScore : 0;\r\n\t\tthis.updateScore(initScore);\r\n\r\n\t\tif(this.xiacheNode.x<this.pierWidth/2-105){\r\n\t\t\tthis.startAnm();\r\n\t\t}\r\n\t\t//是否是新手\r\n\t\tif(this._guide == '1'){\r\n\t\t\tthis.setGuide();\r\n\t\t}else{\r\n\t\t\tthis.initTouch();\r\n\t\t\tthis.registerEvent();\r\n\t\t}\r\n\t\tengine.globalEvent.dispatchEvent(\"bjxd-game-inmove\",{\r\n\t\t\t\"canstop\":true\r\n\t\t});\r\n\t}\r\n\tstartAnm(){\r\n\t\tthis.inani = true;\r\n\t\tthis.xiacheNode.visible = true;\r\n\t\tfor(let i=0;i<15;i++){\r\n\t\t\tif(i<12){\r\n\t\t\t\tthis.xiacheNode.getChildAt(i).visible = true;\r\n\t\t\t}\r\n\t\t}\r\n\t\tthis.xiacheNode.x = this.pierWidth/2 - 100;\r\n\t\tthis._player._container.visible = false;\r\n\t\tthis.xiacheNode.gotoAndPlay(1);\r\n\t\tthis.xiacheNode.addEventListener(engine.Event.ENTER_FRAME,this.playComp,this);\r\n\t}\r\n\t//重置\r\n\treset(){\r\n\t\tthis._sumScore = 0;\r\n\t\tengine.globalEvent.dispatchEvent('bjxd-game-score',{score:this._sumScore});\r\n\t\tthis._player.revive();\r\n\t\tthis.closeStrut();\r\n\t\tthis.changeBg(GameView.bgIndex);\r\n\t\tthis.startAnm();\r\n\t\tengine.globalEvent.dispatchEvent(\"bjxd-game-inmove\",{\r\n\t\t\t\"canstop\":true\r\n\t\t});\r\n\t}\r\n\t//复活\r\n\trevive(){\r\n\t\t// console.log(\"复活---------\");\r\n\t\tthis._player.revive();\r\n\t\tthis.startAnm();\r\n\t\tthis._isTouchLayer = true;\r\n\t\tthis.closeStrut();\r\n\t\tengine.globalEvent.dispatchEvent(\"bjxd-game-inmove\",{\r\n\t\t\t\"canstop\":true\r\n\t\t});\r\n\t}\r\n\t//新手引导\r\n\tsetGuide(){\r\n\t\tthis._road.setGuide();\r\n\t\tconst guideLayer = this.guideLayer = new GuideLayer();\r\n\t\tthis.addChild(guideLayer);\r\n\t\tthis.guideLayer.show(1, {x:20,y: 650,guideText:props.guideText1},()=>{\r\n\t\t\tlet posX = this._road.getMovePos();\r\n\t\t\tthis.guideLayer.show(2, {x:posX + 20,y: 620,guideText:props.guideText2},()=>{\r\n\t\t\t\tthis.initTouch();\r\n\t\t\t\tthis.registerEvent();\r\n\t\t\t})\r\n\t\t});\r\n\t}\r\n\t//分数显示\r\n\tinitLabScore(){\r\n\r\n\t\t// this.labScore = new ScoreLabel();\r\n // this.labScore.fillColor = 0xff7646;\r\n\t\t// this.labScore.size = 70;\r\n\t\t// this.labScore.width = getStage().width;\r\n\t\t// this.labScore.textAlign = engine.TEXT_ALIGN.CENTER;\r\n\t\t// this.labScore.x = 0;\r\n\t\t// this._scoreContainer.addChild(this.labScore);\r\n }\r\n\tregisterEvent(){\r\n\t\t// console.log(\"注册mouse监听1\");\r\n\t\tthis.removeListener();\r\n\t\t// if(!this.hasEventListener(engine.MouseEvent.MOUSE_DOWN)){\r\n\t\t\t// console.log(\"注册mouse监听2\");\r\n\t\t\tthis.addEventListener(engine.MouseEvent.MOUSE_DOWN,this.onMouseDown,this);\r\n\t\t// }\r\n\t\t// if(!this.hasEventListener(engine.MouseEvent.MOUSE_UP)){\r\n\t\t\t// console.log(\"注册mouse监听3\");\r\n\t\t\tthis.addEventListener(engine.MouseEvent.MOUSE_UP,this.onMouseUp,this);\r\n\t\t// }\r\n \r\n // this._touchLayer.addEventListener(engine.MouseEvent.MOUSE_DOWN,this.onMouseDown,this);\r\n // this._touchLayer.addEventListener(engine.MouseEvent.MOUSE_UP,this.onMouseUp,this);\r\n\t}\r\n\tremoveListener(){\r\n\t\tthis.removeEventListener(engine.MouseEvent.MOUSE_DOWN,this.onMouseDown,this);\r\n this.removeEventListener(engine.MouseEvent.MOUSE_UP,this.onMouseUp,this);\r\n // this._touchLayer.removeEventListener(engine.MouseEvent.MOUSE_DOWN,this.onMouseDown,this);\r\n // this._touchLayer.removeEventListener(engine.MouseEvent.MOUSE_UP,this.onMouseUp,this);\r\n\t}\r\n\t//触碰层\r\n\tinitTouch(){\r\n // this._touchLayer = new engine.Rect();\r\n // this.addChild(this._touchLayer);\r\n // this._touchLayer.width = getStage().width;\r\n // this._touchLayer.height = getStage().height;\r\n // this._touchLayer.x = 0;\r\n // this._touchLayer.y = 0;\r\n\t\t// this._touchLayer.alpha = 0;\r\n\r\n\r\n\t\t// this.testrevive = new engine.Label();\r\n\t\t// this.addChild(this.testrevive);\r\n\t\t// this.testrevive.size = 55;\r\n\t\t// this.testrevive.text = \"复活\";\r\n\t\t// this.testrevive.width = 500;\r\n\t\t// this.testrevive.height = 200;\r\n\t\t// this.testrevive.mouseEnabled = true;\r\n\t\t// this.testrevive.addEventListener(engine.MouseEvent.CLICK,this.revive,this);\r\n\t\r\n\t\t// this.testchange = new engine.Label();\r\n\t\t// this.addChild(this.testchange);\r\n\t\t// this.testchange.size = 55;\r\n\t\t// this.testchange.text = \"复活\";\r\n\t\t\r\n\t\t// this.testchange.width = 500;\r\n\t\t// this.testchange.height = 200;\r\n\t\t// this.testchange.mouseEnabled = true;\r\n\t\t// this.testchange.addEventListener(engine.MouseEvent.CLICK,this.changeBg,this);\r\n\t}\r\n\tsetScoreShow(){\r\n\r\n\t}\r\n\t//鼠标事件\r\n\tonMouseDown(){\r\n\t\tif(this._isTouchLayer&&!this.inani){\r\n\t\t\tengine.globalEvent.dispatchEvent(\"bjxd-game-inmove\",{\r\n\t\t\t\t\"canstop\":false\r\n\t\t\t});\r\n\t\t\tthis._isMouseDown = true;\r\n\t\t\tthis._strut.onMouseDown(this._road.getFristPier(),this._road.getDistance(),this.goCallBcak.bind(this));\r\n\t\t}\r\n\t}\r\n\tonMouseUp(){\r\n\t\tif(this._isTouchLayer && this._isMouseDown){\r\n\t\t\tthis._strut.onMouseUp();\r\n\t\t\tthis._isMouseDown = false;\r\n\t\t\tthis._isTouchLayer = false;\r\n\t\t}\r\n\t}\r\n\t//撑杆回调\r\n\tgoCallBcak(isSuccess){\r\n\t\tif(isSuccess){\r\n\t\t\t// console.log('成功了');\r\n\t\t\tlet movePos = this._road.getMovePos();\r\n\t\t\tif(this._road.getStartGold(1,false)){\r\n\t\t\t\tthis.updateScore(props.singleScore + props.goldScore);\r\n\t\t\t}else{\r\n\t\t\t\tthis.updateScore(props.singleScore);\r\n\t\t\t}\r\n\t\t\t//人物前行\r\n\t\t\tthis._player.setViewport(movePos,this.complete.bind(this));\r\n\t\t\t\r\n\t\t}else{\r\n\t\t\t// console.log('失败了');\r\n\t\t\tthis._player.setViewport(this._strut.getStrutHeight(),()=>{\r\n\t\t\t\t// console.log('掉下去了');\r\n\t\t\t\tengine.globalEvent.dispatchEvent('bjxd-game-over',{score:this._sumScore});\r\n\t\t\t},this._road.getFristPier())\r\n\t\t}\r\n\t}\r\n\t//人物前行结束回调\r\n\tcomplete(){\r\n\t\t//关闭金币\r\n\t\tthis._road.getStartGold(1);\r\n\t\t//获得位移距离\r\n\t\tlet movePos = this._road.getMovePos();\r\n\t\tthis._road.setViewport();\r\n\t\tthis._backgroud.setViewport(movePos);\r\n\t\t//移动完成 可以再次操作\r\n\t\tthis._player.setBackViewport(()=>{\r\n\t\t\tthis._isTouchLayer = true;\r\n\t\t});\r\n\r\n\t\tlet carx = this.xiacheNode.x;\r\n\t\tif(carx>-200){\r\n\t\t\tcarx -= movePos;\r\n\t\t\tengine.Tween.get(this.xiacheNode,{loop:false})\r\n\t\t\t.to({\r\n\t\t\t\tx:carx\r\n\t\t\t},props.pierMoveTime)\r\n\t\t}\r\n\t\tengine.globalEvent.dispatchEvent(\"bjxd-game-inmove\",{\r\n\t\t\t\"canstop\":true\r\n\t\t});\r\n\r\n\t\tthis.closeStrut();\r\n\t}\r\n\t//重置撑杆\r\n\tcloseStrut(){\r\n\t\tthis._strut.rest();\r\n\t}\r\n\t//分数更新\r\n\tupdateScore(score){\r\n\t\tthis._sumScore += score;\r\n\t\t// if(0 <= this._sumScore && this._sumScore <= props.bgFristScore){\r\n\t\t// \tthis.changeBg(0);\r\n\t\t// }else if(props.bgFristScore < this._sumScore && this._sumScore <= props.bgSecondScore){\r\n\t\t// \tthis.changeBg(1);\r\n\t\t// }else{\r\n\t\t// \tthis.changeBg(2);\r\n\t\t// }\r\n\t\t// this.labScore.updateScore(this._sumScore);\r\n\t\t// console.log(\"新分数\",this._sumScore);\r\n\t\tengine.globalEvent.dispatchEvent('bjxd-game-score',{score:this._sumScore});\r\n\t}\r\n\tgetScore(){\r\n\t\treturn this._sumScore;\r\n\t}\r\n\r\n\tchangeBg(index){\r\n\t\t// index = (GameView.bgIndex +1)%3;\r\n\t\t// console.log(\"切换图片\",index);\r\n\t\tif(GameView.bgIndex != index){\r\n\t\t\tGameView.bgIndex = index;\r\n\t\t\tthis._backgroud.changeBg(index);\r\n\t\t\tthis._road.changeBg();\r\n\t\t}\r\n\t}\r\n\tstatic speed = 20;\r\n\tchangeSpeed(speed){\r\n\t\tif(GameView.speed!=speed){\r\n\t\t\tGameView.speed = speed;\r\n\t\t}\r\n\t}\r\n}\r\n","\r\n\r\n/**\r\n * Created by rockyl on 2020-01-09.\r\n */\r\n\r\nimport GameView from \"./GameView\";\r\n\r\nexport class GameWrapper extends engine.Container {\r\n\tprivate _gameView: GameView;\r\n\r\n\tconstructor() {\r\n\t\tsuper();\r\n\r\n\t\tengine.globalEvent.addEventListener('bjxd-game-start', this.start, this);\r\n\t\tengine.globalEvent.addEventListener('bjxd-game-reset', this.reset, this);\r\n\t\tengine.globalEvent.addEventListener('bjxd-game-revive',this.revive,this);\r\n\t\tengine.globalEvent.addEventListener('bjxd-game-change',this.change,this);\r\n\t\tengine.globalEvent.addEventListener('bjxd-game-speed',this.speed,this);\r\n\t\tlet gameView = this._gameView = new GameView();\r\n\t\tthis.addChild(gameView);\r\n\r\n\t\t//this.once(engine.Event.ENTER_FRAME, this.onAddedToStage, this);\r\n\t}\r\n\r\n\tstart(event: engine.Event) {\r\n\t\tthis._gameView.start(event.data.guide);\r\n\t}\r\n\treset(){\r\n\t\tthis._gameView.reset();\r\n\t}\r\n\trevive(){\r\n\t\tthis._gameView.revive();\r\n\t}\r\n\tchange(event:engine.Event){\r\n\t\t// console.log(\"切换图片显示\");\r\n\t\tthis._gameView.changeBg(event.data.index);\r\n\t}\r\n\tspeed(event:engine.Event){\r\n\t\tthis._gameView.changeSpeed(event.data.speed);\r\n\t}\r\n}\r\n","/**\r\n * Created by rockyl on 2019-11-20.\r\n */\r\n\r\nimport {GameWrapper} from \"./game/GameWrapper\";\r\nimport {injectProps, prepareProps} from \"./props\";\r\n\r\nexport default function (props) {\r\n\tprepareProps();\r\n\tinjectProps(props);\r\n\r\n\tlet instance = new GameWrapper();\r\n\treturn instance;\r\n}\r\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;;;CCXD,IAAO,UAAU,GAAG,MAAM,CAAC,UAAU,CAAC;CAKtC;KAA0BA,8BAAgB;KAA1C;;MAuGC;KApGG,oBAAK,GAAL;SAGI,IAAI,CAAC,OAAO,GAAG,CAAC,CAAC;SACjB,IAAI,CAAC,OAAO,EAAE,CAAC;MAElB;KACD,2BAAY,GAAZ;SACI,OAAO,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;MACnC;KACD,0BAAW,GAAX;SACI,IAAI,QAAQ,GAAG,EAAE,CAAC;SAClB,IAAI,KAAK,GAAG,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;SAC/B,IAAI,KAAK,GAAG,IAAI,C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MAAM,EAAC,KAAI,CAAC,CAAC;SACzE,MAAM,CAAC,WAAW,CAAC,gBAAgB,CAAC,kBAAkB,EAAC,KAAI,CAAC,MAAM,EAAC,KAAI,CAAC,CAAC;SACzE,MAAM,CAAC,WAAW,CAAC,gBAAgB,CAAC,iBAAiB,EAAC,KAAI,CAAC,KAAK,EAAC,KAAI,CAAC,CAAC;SACvE,IAAI,QAAQ,GAAG,KAAI,CAAC,SAAS,GAAG,IAAI,QAAQ,EAAE,CAAC;SAC/C,KAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;;MAGxB;KAED,2BAAK,GAAL,UAAM,KAAmB;SACxB,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;MACvC;KACD,2BAAK,GAAL;SACC,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,CAAC;MACvB;KACD,4BAAM,GAAN;SACC,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,CAAC;MACxB;KACD,4BAAM,GAAN,UAAO,KAAkB;SAExB,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;MAC1C;KACD,2BAAK,GAAL,UAAM,KAAkB;SACvB,IAAI,CAAC,SAAS,CAAC,WAAW,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;MAC7C;KACF,kBAAC;CAAD,CAAC,CAjCgC,MAAM,CAAC,SAAS,GAiChD;;;iBClCwB,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": {
"guideText1": {
"alias": "引导1的文本",
"type": "string",
"default": "长按屏幕\n杆子变长即可通过"
},
"guideText2": {
"alias": "引导2的文本",
"type": "string",
"default": "当度小宝获得金币时积分+5"
},
"pierMinDistance": {
"alias": "障碍物最小间距",
"type": "number",
"default": 350
},
"pierMaxDistance": {
"alias": "障碍物最大间距",
"type": "number",
"default": 500
},
"frontBGMoveSpeed": {
"alias": "前背影移动速度",
"type": "number",
"default": 0.5
},
"afterBGMoveSpeed": {
"alias": "后背影移动速度",
"type": "number",
"default": 0.2
},
"reward": {
"alias": "出现金币的概率(0-1区间 1为必出现 0为必不出现)",
"type": "number",
"default": 0
},
"pierCount": {
"alias": "一屏中最多出现的桥墩数量(最好默认为2)",
"type": "number",
"default": 2
},
"pierMoveTime": {
"alias": "一个周期内桥墩移动的总时长(毫秒)",
"type": "number",
"default": 1000
},
"strutUpSpeed": {
"alias": "撑杆上升速度(每帧上升增量,一秒60帧)",
"type": "number",
"default": 30
},
"strutWidth": {
"alias": "撑杆宽度",
"type": "number",
"default": 5
},
"strutColor": {
"alias": "撑杆颜色",
"type": "string",
"default": "#ffffff"
},
"strutRotationSpeed": {
"alias": "撑杆旋转总时长(毫秒)",
"type": "number",
"default": 300
},
"playerMoveSpeed": {
"alias": "人物移动总时长(毫秒)",
"type": "number",
"default": 1200
},
"singleScore": {
"alias": "每个桥墩分数",
"type": "number",
"default": 5
},
"goldScore": {
"alias": "每个金币分数",
"type": "number",
"default": 5
},
"bgFristScore": {
"alias": "第一张图的分数区间最大值(超过此值就更换第二张背景图)",
"type": "number",
"default": 30
},
"bgSecondScore": {
"alias": "第二张图的分数区间最大值(超过此值就更换第三张背景图)",
"type": "number",
"default": 80
}
},
"assets": [
{
"name": "bg1",
"url": "//yun.duiba.com.cn/aurora/assets/f3fda198741657d9cab9418bd5d47248af065487.jpg",
"uuid": "bg1",
"ext": ".jpg"
},
{
"name": "bg2",
"url": "//yun.duiba.com.cn/aurora/assets/8fa1de1570023f21b676a8602ec9315cee83a99b.jpg",
"uuid": "bg2",
"ext": ".jpg"
},
{
"name": "bg3",
"url": "//yun.duiba.com.cn/aurora/assets/517fc529c79b18ff4881d206c942c8f2888ad6fd.jpg",
"uuid": "bg3",
"ext": ".jpg"
},
{
"name": "car1",
"url": "//yun.duiba.com.cn/aurora/assets/c1e80aee4eee3665e0f0bce08233b05be4b4ee9c.png",
"uuid": "car1",
"ext": ".png"
},
{
"name": "yindao1",
"url": "//yun.duiba.com.cn/aurora/assets/4449285320882460ae0dd0b59b3c73e0bb92def6.png",
"uuid": "yindao1",
"ext": ".png"
},
{
"name": "yindao2",
"url": "//yun.duiba.com.cn/aurora/assets/1c914031834736b93e9b2a94a4e8a643871795f7.png",
"uuid": "yindao2",
"ext": ".png"
},
{
"name": "shouzhi",
"url": "//yun.duiba.com.cn/aurora/assets/fd62b438bfd67345fe441f5e68e4394d650fac8d.png",
"uuid": "shouzhi",
"ext": ".png"
},
{
"name": "zhuzi1",
"url": "//yun.duiba.com.cn/aurora/assets/cb779c9ebf4bfbd5bec1d817a6ef824d4ae5d751.png",
"uuid": "zhuzi1",
"ext": ".png"
},
{
"name": "zhuzi2",
"url": "//yun.duiba.com.cn/aurora/assets/c5187595bec08c211c8e45bf5f163ff02fd659ab.png",
"uuid": "zhuzi2",
"ext": ".png"
},
{
"name": "zhuzi3",
"url": "//yun.duiba.com.cn/aurora/assets/08dc255864c2af52dac7a993a4c62b1970dd6db4.png",
"uuid": "zhuzi3",
"ext": ".png"
},
{
"name": "person",
"url": "//yun.duiba.com.cn/aurora/assets/094526243496c8ebf1002f73f3cbbf3c9e12892a.png",
"uuid": "person",
"ext": ".png"
},
{
"name": "gold",
"url": "//yun.duiba.com.cn/aurora/assets/ae210ad26cee13f8fb6e69be62f7f5498be50a5b.png",
"uuid": "7f4e19f2-c80f-4a65-bec2-1f3c3dc6d210",
"ext": ".png"
},
{
"name": "walk",
"url": "//yun.duiba.com.cn/aurora/assets/5b31481f8d5669213da518b156aac7cadf5d9374",
"uuid": "10cd1fdd-4fd8-43cf-a1c7-6ff5846d8a91",
"ext": ".svga"
},
{
"name": "xiache",
"url": "//yun.duiba.com.cn/aurora/assets/57ad75aa036c04e13abcf32c464ff5ae37419495",
"uuid": "xiache",
"ext": ".svga"
},
{
"name": "ganzi",
"url": "//yun.duiba.com.cn/aurora/assets/501972d5960c29b7db1e476422e6fd3cb3a92c8f.png",
"uuid": "ganzi",
"ext": ".png"
}
],
"events": {
"in": {
"bjxd-game-start": {
"alias": "开始",
"data": {
}
},
"bjxd-game-revive": {
"alias": "复活",
"data": {
}
},
"bjxd-game-reset": {
"alias": "重置",
"data": {
}
},
"bjxd-game-change": {
"alias": "替换显示",
"data": {
"index":1
}
},
"bjxd-game-speed": {
"alias": "修改速度",
"data": {
"speed":10
}
}
},
"out": {
"bjxd-game-over": {
"alias": "游戏结束",
"data": {
"score":0
}
},
"bjxd-game-score": {
"alias": "分数",
"data": {
"score":0
}
},
"bjxd-game-inmove": {
"alias": "游戏进行状态",
"data": {
"canstop":false
}
}
}
}
}
\ No newline at end of file
import {getTextureByName} from "./utils";
import {getStage} from "./utils";
import {LoopComponent} from "./LoopComponent";
import { props } from './../props';
export class Background extends engine.Container{
partResHHL = ['bg1',''];
partResHB = ['bg2',''];
partResWH = ['bg3',''];
speeds = [];
resArray=[];
frameMovePos = 0;
frameIndex;
sumMovePos;
//需要的总帧数
needFrameSum;
initBg(){
this.sumMovePos = 0;
this.speeds.push(props.afterBGMoveSpeed);
this.speeds.push(props.frontBGMoveSpeed);
let bottomBg = new engine.Rect();
bottomBg.x = 0;
bottomBg.y = 0;
bottomBg.width = 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)
const parts = [];
for(let i = 0; i < 2; i++){
let part = new LoopComponent();
part.setupLoop([
this.resArray[0][i],
this.resArray[0][i],
]);
parts.push(part);
this.addChild(part);
}
//(height - parts[1].height) / 2 - 200
parts[1].y = 200;
}
setViewport(pos) {
this.needFrameSum = (props.pierMoveTime/1000)*60;
this.frameMovePos = pos/this.needFrameSum;
this.frameIndex = 0;
this.addEventListener(engine.Event.ENTER_FRAME,this.frameBack,this);
}
frameBack(){
if( this.frameIndex < this.needFrameSum){
for (let i = 0; i < 2; i++) {
const part = <LoopComponent>this.getChildAt(i + 1);
const speed = this.speeds[i];
let 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);
}
}
changeBg(index){
for (let i = 0; i < 2; i++) {
const part = <LoopComponent>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;
}
}
}
}
\ No newline at end of file
import { Road } from './Road';
/**
* Created by rockyl on 2018/8/16.
*/
import {props} from "../props";
import {getStage,getTextureByName,createSvga} from "./utils";
import {GuideLayer} from "./GuideLayer";
import { Background } from "./Background";
import ObjectPool = engine.ObjectPool;
import { Pier } from './Pier';
import { Player } from './Player';
import { Strut } from './Strut';
import { ScoreLabel } from './ScoreLabel';
export const PoolName: string = 'pier';
ObjectPool.registerPool(PoolName, function () {
return new Pier();
}, function (item: Pier, data) {
item.init();
});
export default class GameView extends engine.Container {
guideLayer: GuideLayer;
private _hasSetup;
_backgroud:Background;
_road:Road;
_player:Player;
_strut:Strut;
// _touchLayer: engine.Rect;
_isTouchLayer;
// _scoreContainer;
moveX = 0;
// labScore:ScoreLabel;
_sumScore;
_isMouseDown;
_guide;
testrevive:engine.Label;
testchange:engine.Label;
static bgIndex:number = 0;
private xiacheNode:svga.Svga;
playery:number = 878;
inani:boolean = true;
pierWidth;
constructor() {
super();
this.once(engine.Event.ADDED_TO_STAGE, this.setup, this);
}
setup(){
if (this._hasSetup) {
return;
}
this._hasSetup = true;
this._backgroud = new Background();
this.addChild(this._backgroud);
this._backgroud.initBg();
const road = this._road = new Road();
this.addChild(road);
road.setup();
let pierWidth = this._road.getFristPier();
const player = this._player = new Player();
this.addChild(player);
player.initPlayer(pierWidth);
this.pierWidth = pierWidth;
this.xiacheNode = createSvga("xiache");
this.addChild(this.xiacheNode);
this.xiacheNode.y = this.playery-35;
this.xiacheNode.x = this.pierWidth/2 - 100;
this.xiacheNode.stop();
this.xiacheNode.name = "xiacheanm";
console.log("下车动画帧数",this.xiacheNode.totalFrames,this.xiacheNode);
// this.xiacheNode.addEventListener(engine.Event.ENTER_FRAME,this.playComp,this);
this.xiacheNode.visible = false;
const strut = this._strut = new Strut();
this.addChild(strut);
strut.init();
// this.startAnm();
// this._scoreContainer = new engine.Container();
// this.addChild(this._scoreContainer);
// this.initLabScore();
}
playComp(){
let curframe = this.xiacheNode.currentFrame;
if(curframe==this.xiacheNode.totalFrames){
this.inani = false;
// console.log("下车动画播放完毕",curframe,this.xiacheNode);
this.xiacheNode.stop();
this.xiacheNode.removeEventListener(engine.Event.ENTER_FRAME,this.playComp,this);
for(let i=0;i<15;i++){
if(i<12){
this.xiacheNode.getChildAt(i).visible = false;
}
}
this._player._container.visible = true;
}
}
async start(guide) {
this._isTouchLayer = true;
this._sumScore = 0;
this._isMouseDown = false;
this._guide = guide;
this._player.revive();
this.closeStrut();
let initScore = 0;//this._road.getStartGold(0) ? props.goldScore : 0;
this.updateScore(initScore);
if(this.xiacheNode.x<this.pierWidth/2-105){
this.startAnm();
}
//是否是新手
if(this._guide == '1'){
this.setGuide();
}else{
this.initTouch();
this.registerEvent();
}
engine.globalEvent.dispatchEvent("bjxd-game-inmove",{
"canstop":true
});
}
startAnm(){
this.inani = true;
this.xiacheNode.visible = true;
for(let i=0;i<15;i++){
if(i<12){
this.xiacheNode.getChildAt(i).visible = true;
}
}
this.xiacheNode.x = this.pierWidth/2 - 100;
this._player._container.visible = false;
this.xiacheNode.gotoAndPlay(1);
this.xiacheNode.addEventListener(engine.Event.ENTER_FRAME,this.playComp,this);
}
//重置
reset(){
this._sumScore = 0;
engine.globalEvent.dispatchEvent('bjxd-game-score',{score:this._sumScore});
this._player.revive();
this.closeStrut();
this.changeBg(GameView.bgIndex);
this.startAnm();
engine.globalEvent.dispatchEvent("bjxd-game-inmove",{
"canstop":true
});
}
//复活
revive(){
// console.log("复活---------");
this._player.revive();
this.startAnm();
this._isTouchLayer = true;
this.closeStrut();
engine.globalEvent.dispatchEvent("bjxd-game-inmove",{
"canstop":true
});
}
//新手引导
setGuide(){
this._road.setGuide();
const guideLayer = this.guideLayer = new GuideLayer();
this.addChild(guideLayer);
this.guideLayer.show(1, {x:20,y: 650,guideText:props.guideText1},()=>{
let posX = this._road.getMovePos();
this.guideLayer.show(2, {x:posX + 20,y: 620,guideText:props.guideText2},()=>{
this.initTouch();
this.registerEvent();
})
});
}
//分数显示
initLabScore(){
// this.labScore = new ScoreLabel();
// this.labScore.fillColor = 0xff7646;
// this.labScore.size = 70;
// this.labScore.width = getStage().width;
// this.labScore.textAlign = engine.TEXT_ALIGN.CENTER;
// this.labScore.x = 0;
// this._scoreContainer.addChild(this.labScore);
}
registerEvent(){
// console.log("注册mouse监听1");
this.removeListener();
// if(!this.hasEventListener(engine.MouseEvent.MOUSE_DOWN)){
// console.log("注册mouse监听2");
this.addEventListener(engine.MouseEvent.MOUSE_DOWN,this.onMouseDown,this);
// }
// if(!this.hasEventListener(engine.MouseEvent.MOUSE_UP)){
// console.log("注册mouse监听3");
this.addEventListener(engine.MouseEvent.MOUSE_UP,this.onMouseUp,this);
// }
// this._touchLayer.addEventListener(engine.MouseEvent.MOUSE_DOWN,this.onMouseDown,this);
// this._touchLayer.addEventListener(engine.MouseEvent.MOUSE_UP,this.onMouseUp,this);
}
removeListener(){
this.removeEventListener(engine.MouseEvent.MOUSE_DOWN,this.onMouseDown,this);
this.removeEventListener(engine.MouseEvent.MOUSE_UP,this.onMouseUp,this);
// this._touchLayer.removeEventListener(engine.MouseEvent.MOUSE_DOWN,this.onMouseDown,this);
// this._touchLayer.removeEventListener(engine.MouseEvent.MOUSE_UP,this.onMouseUp,this);
}
//触碰层
initTouch(){
// this._touchLayer = new engine.Rect();
// this.addChild(this._touchLayer);
// this._touchLayer.width = getStage().width;
// this._touchLayer.height = getStage().height;
// this._touchLayer.x = 0;
// this._touchLayer.y = 0;
// this._touchLayer.alpha = 0;
// this.testrevive = new engine.Label();
// this.addChild(this.testrevive);
// this.testrevive.size = 55;
// this.testrevive.text = "复活";
// this.testrevive.width = 500;
// this.testrevive.height = 200;
// this.testrevive.mouseEnabled = true;
// this.testrevive.addEventListener(engine.MouseEvent.CLICK,this.revive,this);
// this.testchange = new engine.Label();
// this.addChild(this.testchange);
// this.testchange.size = 55;
// this.testchange.text = "复活";
// this.testchange.width = 500;
// this.testchange.height = 200;
// this.testchange.mouseEnabled = true;
// this.testchange.addEventListener(engine.MouseEvent.CLICK,this.changeBg,this);
}
setScoreShow(){
}
//鼠标事件
onMouseDown(){
if(this._isTouchLayer&&!this.inani){
engine.globalEvent.dispatchEvent("bjxd-game-inmove",{
"canstop":false
});
this._isMouseDown = true;
this._strut.onMouseDown(this._road.getFristPier(),this._road.getDistance(),this.goCallBcak.bind(this));
}
}
onMouseUp(){
if(this._isTouchLayer && this._isMouseDown){
this._strut.onMouseUp();
this._isMouseDown = false;
this._isTouchLayer = false;
}
}
//撑杆回调
goCallBcak(isSuccess){
if(isSuccess){
// console.log('成功了');
let movePos = this._road.getMovePos();
if(this._road.getStartGold(1,false)){
this.updateScore(props.singleScore + props.goldScore);
}else{
this.updateScore(props.singleScore);
}
//人物前行
this._player.setViewport(movePos,this.complete.bind(this));
}else{
// console.log('失败了');
this._player.setViewport(this._strut.getStrutHeight(),()=>{
// console.log('掉下去了');
engine.globalEvent.dispatchEvent('bjxd-game-over',{score:this._sumScore});
},this._road.getFristPier())
}
}
//人物前行结束回调
complete(){
//关闭金币
this._road.getStartGold(1);
//获得位移距离
let movePos = this._road.getMovePos();
this._road.setViewport();
this._backgroud.setViewport(movePos);
//移动完成 可以再次操作
this._player.setBackViewport(()=>{
this._isTouchLayer = true;
});
let carx = this.xiacheNode.x;
if(carx>-200){
carx -= movePos;
engine.Tween.get(this.xiacheNode,{loop:false})
.to({
x:carx
},props.pierMoveTime)
}
engine.globalEvent.dispatchEvent("bjxd-game-inmove",{
"canstop":true
});
this.closeStrut();
}
//重置撑杆
closeStrut(){
this._strut.rest();
}
//分数更新
updateScore(score){
this._sumScore += score;
// if(0 <= this._sumScore && this._sumScore <= props.bgFristScore){
// this.changeBg(0);
// }else if(props.bgFristScore < this._sumScore && this._sumScore <= props.bgSecondScore){
// this.changeBg(1);
// }else{
// this.changeBg(2);
// }
// this.labScore.updateScore(this._sumScore);
// console.log("新分数",this._sumScore);
engine.globalEvent.dispatchEvent('bjxd-game-score',{score:this._sumScore});
}
getScore(){
return this._sumScore;
}
changeBg(index){
// index = (GameView.bgIndex +1)%3;
// console.log("切换图片",index);
if(GameView.bgIndex != index){
GameView.bgIndex = index;
this._backgroud.changeBg(index);
this._road.changeBg();
}
}
static speed = 20;
changeSpeed(speed){
if(GameView.speed!=speed){
GameView.speed = speed;
}
}
}
/**
* Created by rockyl on 2020-01-09.
*/
import GameView from "./GameView";
export class GameWrapper extends engine.Container {
private _gameView: GameView;
constructor() {
super();
engine.globalEvent.addEventListener('bjxd-game-start', this.start, this);
engine.globalEvent.addEventListener('bjxd-game-reset', this.reset, this);
engine.globalEvent.addEventListener('bjxd-game-revive',this.revive,this);
engine.globalEvent.addEventListener('bjxd-game-change',this.change,this);
engine.globalEvent.addEventListener('bjxd-game-speed',this.speed,this);
let gameView = this._gameView = new GameView();
this.addChild(gameView);
//this.once(engine.Event.ENTER_FRAME, this.onAddedToStage, this);
}
start(event: engine.Event) {
this._gameView.start(event.data.guide);
}
reset(){
this._gameView.reset();
}
revive(){
this._gameView.revive();
}
change(event:engine.Event){
// console.log("切换图片显示");
this._gameView.changeBg(event.data.index);
}
speed(event:engine.Event){
this._gameView.changeSpeed(event.data.speed);
}
}
/**
* Created by rockyl on 2020-01-30.
*/
import {props} from "../props";
import {getTextureByName} from "./utils";
export class GuideLayer extends engine.Container {
private guideMask: engine.Container;
guideImg:engine.Image;
shouzhi:engine.Image;
_options;
_callBack;
constructor() {
super();
this.setup();
}
private setup() {
}
show(id, options,callback?) {
this.visible = true;
this._callBack = callback?callback:null;
if (!this.guideMask) {
const {width, height} = this.stage;
this.guideMask = new engine.Container();
this.addChild(this.guideMask);
this.guideImg = new engine.Image();
this.guideMask.addChild(this.guideImg);
this.shouzhi = new engine.Image(getTextureByName("shouzhi"));
this.guideMask.addChild(this.shouzhi);
}
this.guideImg.texture = getTextureByName("yindao"+id);
this.guideStep(id);
this.once(engine.MouseEvent.CLICK, function(){
this.visible = false;
if(this._callBack){
this._callBack();
}
}, this);
}
guideStep(id){
if(id == 1){
this.shouzhi.x = 244;
this.shouzhi.y = 812;
}
if(id == 2){
this.shouzhi.x = 346;
this.shouzhi.y = 1108;
}
}
}
import {getTextureByName} from "./utils";
export class LoopComponent extends engine.Container{
parts: any[];
onceInfo: any = {width: 0, height: 0, count: 0};
loopInfo: any = {width: 0, height: 0, count: 0};
constructor() {
super();
this.parts = [];
}
private setup(parts, info) {
parts.forEach((item, index) => {
let part;
if(typeof item == 'string'){
if(item.length>0){
part = new engine.Sprite(getTextureByName(item));
}else{
part = new engine.Sprite();
}
}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)
}
changeBg(changName){
this.parts.forEach((item, index) => {
if(changName&&changName.length>0){
item.texture = getTextureByName(changName)
}
});
}
setupLoop(resArr) {
this.setup(resArr, this.loopInfo);
}
setViewport(x, y = 0) {
const sizeField = y == 0 ? 'width' : 'height';
const posField = y == 0 ? 'x' : 'y';
const pos = y == 0 ? x : y;
let index;
const onceSize = this.onceInfo[sizeField];
const onceCount = this.onceInfo.count;
const loopCount = this.loopInfo.count;
const loopSize = this.loopInfo[sizeField];
index = onceSize == 0 ? -1 : Math.floor(pos / onceSize);
if (index < 0 || index >= onceCount) {
const loopIndex = Math.floor((pos - onceCount * onceSize) / this.loopInfo[sizeField]);
index = onceCount + loopIndex;
}
let formerIndex = index < onceCount ? index : (index) % loopCount + onceCount;
let latterIndex = index < onceCount ? index + 1 : (index - onceCount + 1) % loopCount + onceCount;
let former = this.parts[formerIndex];
let 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);
}
}
\ No newline at end of file
import { props } from './../props';
import {getTextureByName,getStage} from "./utils";
import GameView from './GameView';
export class Pier extends engine.Container {
bmp:engine.Sprite;
public haveGold;
part1tex = "zhuzi1";
part2tex = "zhuzi2";
part3tex = "zhuzi3";
texname:string = "";
constructor() {
super();
this.bmp = new engine.Sprite();
this.addChild(this.bmp);
}
zhuy:number = 1006;
init(){
const bmp = this.bmp;
bmp.alpha = 1;
this.changeBg();
bmp.x = 0;
bmp.y = this.zhuy;
// if(this.children.length < 2){
// const gold = new engine.Sprite();
// gold.texture = getTextureByName('gold');
// gold.name = 'gold';
// this.addChild(gold);
// }
// this.setGoldPosX(bmp);
// this.setShowGold();
}
changeBg(){
let texstr;
if(GameView.bgIndex==0){
texstr = this.part1tex;
}else if(GameView.bgIndex==1){
texstr = this.part2tex;
}else{
texstr = this.part3tex;
}
if(this.texname!=texstr){
this.texname = texstr;
this.bmp.texture = getTextureByName(texstr);
}
}
setShowGold(){
let nodeGold = this.getChildByName('gold');
let randomWard = Math.random();
nodeGold.alpha = 1;
let isShow = randomWard < props.reward ? true : false ;
nodeGold.visible = isShow;
this.haveGold = isShow;
}
setGoldPosX(bmp){
let nodeGold = this.getChildByName('gold');
let pos = bmp.width / 2 - nodeGold.width/2;
nodeGold.x = pos
nodeGold.y = this.zhuy - nodeGold.height - 50;
nodeGold.visible = false;
}
closeGold(){
this.children.forEach((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(()=>{
item.visible = false;
this.haveGold = false;
})
}
})
}
}
\ No newline at end of file
import {props} from "../props";
import {createSvga, playSound} from "./utils";
export class Player extends engine.Container{
_container;
private playerNode: svga.Svga;
pierWidth
playery:number = 878;
initPlayer(pierWidth){
this.pierWidth = pierWidth;
this._container = new engine.Container();
this.addChild(this._container);
this.playerNode = createSvga('walk');
this._container.addChild(this.playerNode);
this.playerNode.y = this.playery;
this.playerNode.x = pierWidth/2 - 50;
this.playerNode.play();
this._container.visible = false;
}
revive(){
this._container.x = 0;
this._container.y = 0;
this.playerNode.x = this.pierWidth/2 - 50;
this.playerNode.y = this.playery;
}
setViewport(pos,callBack,pierWidth?){
let tmpPos = 0;
let isSuccess = false;
if(!pierWidth){
tmpPos = pos;
isSuccess = true;
}else{
tmpPos = pierWidth - this.playerNode.x + pos - 60;
}
this.playGoTween(tmpPos,callBack,isSuccess)
}
playGoTween(pos,callBack,isSuccess){
engine.Tween.get(this._container,{loop:false})
.to({x : pos},props.playerMoveSpeed)
.call(()=>{
engine.Tween.removeTweens(this._container);
if(isSuccess){
if(callBack){
callBack();
}
}else{
this.playDropTween(callBack);
}
})
}
playDropTween(callBack){
engine.Tween.get(this._container,{loop:false})
.to({y : 2000},1000)
.call(()=>{
engine.Tween.removeTweens(this._container);
if(callBack){
callBack();
}
})
}
setBackViewport(callBack){
engine.Tween.get(this._container,{loop:false})
.to({x : 0},props.pierMoveTime)
.call(()=>{
engine.Tween.removeTweens(this._container);
if(callBack){
callBack();
}
})
}
}
\ No newline at end of file
import { props } from './../props';
import ObjectPool = engine.ObjectPool;
import {getTextureByName,getStage} from "./utils";
import { Pier } from './Pier';
import GameView from './GameView';
export class Road extends engine.Container{
//container: engine.Container;
lastPos;
setup(){
// this.container = new engine.Container();
// this.addChild(this.container);
this.lastPos = 0;
this.addPier();
}
getFristPier(){
return this.getChildAt(0).width;
}
getDistance(){
let distance = [];
let pier1 = this.getChildAt(0);
let pier2 = this.getChildAt(1);
distance.push(pier2.x - pier1.x);
distance.push(pier2.width);
return distance;
}
addPier(){
while(this.children.length < props.pierCount + 1){
let childrenNum = this.children.length;
let randomPos = this.makeRandomFloat(props.pierMaxDistance,props.pierMinDistance);
const pier: Pier = ObjectPool.getObject('pier');
this.addChild(pier);
pier.changeBg();
if(childrenNum == 0){
pier.x = 0;
}else{
pier.x = this.lastPos + randomPos;
}
this.lastPos = pier.x;
}
}
changeBg(){
let nume = this.children.length;
for(let i=0;i<nume;i++){
let ipier = this.getChildAt(i) as Pier;
ipier.changeBg();
}
}
moveAddPier(){
let randomPos = this.makeRandomFloat(props.pierMaxDistance,props.pierMinDistance);
const pier: Pier = ObjectPool.getObject('pier');
let lastChild = this.getChildAt(this.children.length -1);
pier.x = lastChild.x + randomPos;
this.addChild(pier);
pier.changeBg();
}
makeRandomFloat(max: number, min: number = 0): number {
return Math.random() * (max - min) + min;
}
setViewport(){
let tmpMovepos = this.getMovePos();
this.children.forEach((item,index) => {
this.playTween(item,index,tmpMovepos);
})
}
//获得移动位移
getMovePos(){
let movePos:any = this.getChildAt(1);
return movePos.x;
}
playTween(item,index,tmpMovepos){
engine.Tween.get(item,{loop:false})
.to({x : item.x - tmpMovepos},props.pierMoveTime)
.call(()=>{
if(this.getChildIndex(item) == 0){
engine.Tween.removeTweens(item);
this.removeChild(item);
ObjectPool.recycleObject('pier',item);
}
if(index == 0){
this.moveAddPier();
}
})
}
//桥墩是否有金币
getStartGold(index,isClose = true){
let tmpNode:any = this.getChildAt(index);
let haveGold = tmpNode.haveGold;
if(haveGold && isClose){
tmpNode.closeGold();
}
return haveGold;
}
//设置新手引导 第二个桥墩要有金币
setGuide(){
let tmpNode:any = this.getChildAt(1);
if(!tmpNode.haveGold){
tmpNode.children.forEach((item) => {
if(item.name == 'gold'){
item.visible = true;
}
})
tmpNode.haveGold = true;
}
}
}
\ No newline at end of file
/**
* Created by rockyl on 2018/9/10.
*
* 分数标签
*/
export class ScoreLabel extends engine.Label {
_value;
_tmp;
updateScore(score,animation = true) {
this._value = score;
if (animation && this._tmp) {
this.animationUpdate();
} else {
this.updateLocal(score);
}
}
animationUpdate(){
let tmpInterval = setInterval(()=>{
this._tmp += 1;
if(this._tmp <= this._value){
this.text = this._tmp
}else{
this._tmp = this._value;
clearInterval(tmpInterval);
}
},50)
}
updateLocal(v){
this._tmp = v;
this.text = v;
}
}
import { props } from "../props";
import GameView from "./GameView";
import {getTextureByName} from "./utils";
export class Strut extends engine.Container{
_strut: engine.Image;
_distance;
_callBack;
gany = 1005;
init(){
this._strut = new engine.Image(getTextureByName("ganzi"));
this.addChild(this._strut);
// this._strut.width = props.strutWidth;
this._strut.y = this.gany;
// this._strut.fillColor = props.strutColor;
this._strut.rotation = 180;
}
onMouseDown(pierWidth,distance,callBack){
let paddingx = 20;
if(GameView.bgIndex==0){
paddingx = 20;
}else if(GameView.bgIndex==1){
paddingx = 30;
}else if(GameView.bgIndex==2){
paddingx = 20;
}
this._strut.x = pierWidth - paddingx;
this._distance = distance;
this._callBack = callBack;
this._strut.visible = true;
this.addEventListener(engine.Event.ENTER_FRAME,this.frameStrut,this);
}
onMouseUp(){
this.removeEventListener(engine.Event.ENTER_FRAME,this.frameStrut,this);
setTimeout(() => {
this.strutRotation();
}, 200);
}
strutRotation(){
engine.Tween.get(this._strut,{loop:false})
.to({rotation:270},props.strutRotationSpeed)
.call(()=>{
this.judgeResult();
engine.Tween.removeTweens(this._strut);
})
}
judgeResult(){
let isSuccess = false;
let paddingx = 20;
let chax = 20;
if(GameView.bgIndex==0){
paddingx = 20;
chax = 20;
}else if(GameView.bgIndex==1){
paddingx = 3;
chax = 39;
}else if(GameView.bgIndex==2){
paddingx = 20;
chax = 20;
}
let mindis = this._distance[0] - this._distance[1] + chax;
let maxdis = this._distance[0] + paddingx;
// console.log("成功失败判断",mindis,this._strut.height,maxdis);
if(mindis <= this._strut.height && this._strut.height <= maxdis){
isSuccess = true;
}
if(this._callBack){
this._callBack(isSuccess);
}
}
frameStrut(){
// let paddingx = 20;
// let chax = 20;
// if(GameView.bgIndex==0){
// paddingx = 20;
// chax = 20;
// }else if(GameView.bgIndex==1){
// paddingx = 3;
// chax = 39;
// }else if(GameView.bgIndex==2){
// paddingx = 20;
// chax = 20;
// }
// let tmindis = this._distance[0] - this._distance[1] + chax;
// let tmaxdis = this._distance[0] + paddingx;
let maxdis = 700;
// maxdis = 700;
// console.log("测试杆长",maxdis);
if(this._strut.height < maxdis){
if(this._strut.height+GameView.speed>maxdis){
this._strut.height = maxdis
}else{
this._strut.height += GameView.speed;
}
}
}
rest(){
// this._strut.width = props.strutWidth;
this._strut.y = this.gany;
// this._strut.fillColor = props.strutColor;
this._strut.rotation = 180;
this._strut.height = 0;
this._strut.visible = false;
}
getStrutHeight(){
let distance = this._strut.height > 1000 ? 1000 :this._strut.height;
return distance;
}
}
\ No newline at end of file
import { Pier } from './Pier';
/**
* Created by rockyl on 2020-02-03.
*/
import ObjectPool = engine.ObjectPool;
export const PoolName: string = 'pier';
ObjectPool.registerPool(PoolName, function () {
return new Pier();
}, function (item: Pier, data) {
item.init();
});
/**
* Created by rockyl on 2020-01-21.
*/
export function getTexture(uuid) {
return engine.Texture.from(getAssetByUUID(uuid).uuid);
}
export function getTextureByName(name) {
// console.log("资源加载",name);
return getTexture(engine.getAssetByName(name).uuid);
}
export function playSound(name) {
engine.playSound(engine.getAssetByName(name).uuid, {keep: true});
}
export function getStage(){
return engine.gameStage.stage;
}
export function createSvga(name) {
let inst = new svga.Svga();
inst.source = engine.getAssetByName(name).uuid;
// let anchor = props[(anchorName)];
// if (anchor) {
// inst.x = -anchor.x;
// inst.y = -anchor.y;
// inst.anchorX = anchor.x;
// inst.anchorY = anchor.y;
// }
return inst;
}
/**
* 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);
}
...@@ -45,7 +45,7 @@ function launchWithCustomModule(customModule) { ...@@ -45,7 +45,7 @@ function launchWithCustomModule(customModule) {
}, 100); }, 100);
setTimeout(() => { setTimeout(() => {
//engine.globalEvent.dispatchEvent('dxbcyj-game-start', {guide: 0}); engine.globalEvent.dispatchEvent('dxbcyj-game-start', {guide: 1});
}, 500); }, 500);
}); });
......
...@@ -420,6 +420,7 @@ ...@@ -420,6 +420,7 @@
return _super !== null && _super.apply(this, arguments) || this; return _super !== null && _super.apply(this, arguments) || this;
} }
Player.prototype.initPlayer = function (pierWidth) { Player.prototype.initPlayer = function (pierWidth) {
this.pierWidth = pierWidth;
this._container = new engine.Container(); this._container = new engine.Container();
this.addChild(this._container); this.addChild(this._container);
this.playerNode = createSvga('walk'); this.playerNode = createSvga('walk');
...@@ -428,6 +429,12 @@ ...@@ -428,6 +429,12 @@
this.playerNode.x = pierWidth / 2 - 80; this.playerNode.x = pierWidth / 2 - 80;
this.playerNode.play(); this.playerNode.play();
}; };
Player.prototype.revive = function () {
this._container.x = 0;
this._container.y = 0;
this.playerNode.x = this.pierWidth / 2 - 80;
this.playerNode.y = 675;
};
Player.prototype.setViewport = function (pos, callBack, pierWidth) { Player.prototype.setViewport = function (pos, callBack, pierWidth) {
var tmpPos = 0; var tmpPos = 0;
var isSuccess = false; var isSuccess = false;
...@@ -639,6 +646,12 @@ ...@@ -639,6 +646,12 @@
}); });
}); });
}; };
GameView.prototype.revive = function () {
console.log("复活---------");
this._player.revive();
this._isTouchLayer = true;
this.closeStrut();
};
GameView.prototype.setGuide = function () { GameView.prototype.setGuide = function () {
var _this = this; var _this = this;
this._road.setGuide(); this._road.setGuide();
...@@ -686,6 +699,14 @@ ...@@ -686,6 +699,14 @@
this._touchLayer.x = 0; this._touchLayer.x = 0;
this._touchLayer.y = 0; this._touchLayer.y = 0;
this._touchLayer.alpha = 0; this._touchLayer.alpha = 0;
this.testrevive = new engine.Label();
this.addChild(this.testrevive);
this.testrevive.size = 55;
this.testrevive.text = "复活";
this.testrevive.width = 500;
this.testrevive.height = 200;
this.testrevive.mouseEnabled = true;
this.testrevive.addEventListener(engine.MouseEvent.CLICK, this.revive, this);
}; };
GameView.prototype.setScoreShow = function () { GameView.prototype.setScoreShow = function () {
}; };
...@@ -766,6 +787,7 @@ ...@@ -766,6 +787,7 @@
function GameWrapper() { function GameWrapper() {
var _this = _super.call(this) || this; var _this = _super.call(this) || this;
engine.globalEvent.addEventListener('dxbcyj-game-start', _this.start, _this); engine.globalEvent.addEventListener('dxbcyj-game-start', _this.start, _this);
engine.globalEvent.addEventListener('dxbcyj-game-revive', _this.revive);
var gameView = _this._gameView = new GameView(); var gameView = _this._gameView = new GameView();
_this.addChild(gameView); _this.addChild(gameView);
return _this; return _this;
...@@ -773,6 +795,9 @@ ...@@ -773,6 +795,9 @@
GameWrapper.prototype.start = function (event) { GameWrapper.prototype.start = function (event) {
this._gameView.start(event.data.guide); this._gameView.start(event.data.guide);
}; };
GameWrapper.prototype.revive = function () {
this._gameView.revive();
};
return GameWrapper; return GameWrapper;
}(engine.Container)); }(engine.Container));
......
...@@ -50,7 +50,7 @@ ...@@ -50,7 +50,7 @@
"strutUpSpeed": { "strutUpSpeed": {
"alias": "撑杆上升速度(每帧上升增量,一秒60帧)", "alias": "撑杆上升速度(每帧上升增量,一秒60帧)",
"type": "number", "type": "number",
"default": 10 "default": 30
}, },
"strutWidth": { "strutWidth": {
"alias": "撑杆宽度", "alias": "撑杆宽度",
......
...@@ -39,6 +39,8 @@ export default class GameView extends engine.Container { ...@@ -39,6 +39,8 @@ export default class GameView extends engine.Container {
_isMouseDown; _isMouseDown;
_guide; _guide;
testrevive:engine.Label;
constructor() { constructor() {
super(); super();
this.once(engine.Event.ADDED_TO_STAGE, this.setup, this); this.once(engine.Event.ADDED_TO_STAGE, this.setup, this);
...@@ -70,6 +72,7 @@ export default class GameView extends engine.Container { ...@@ -70,6 +72,7 @@ export default class GameView extends engine.Container {
this.addChild(this._scoreContainer); this.addChild(this._scoreContainer);
this.initLabScore(); this.initLabScore();
} }
async start(guide) { async start(guide) {
this._isTouchLayer = true; this._isTouchLayer = true;
...@@ -88,6 +91,13 @@ export default class GameView extends engine.Container { ...@@ -88,6 +91,13 @@ export default class GameView extends engine.Container {
this.registerEvent(); this.registerEvent();
} }
} }
//复活
revive(){
console.log("复活---------");
this._player.revive();
this._isTouchLayer = true;
this.closeStrut();
}
//新手引导 //新手引导
setGuide(){ setGuide(){
this._road.setGuide(); this._road.setGuide();
...@@ -140,6 +150,16 @@ export default class GameView extends engine.Container { ...@@ -140,6 +150,16 @@ export default class GameView extends engine.Container {
this._touchLayer.x = 0; this._touchLayer.x = 0;
this._touchLayer.y = 0; this._touchLayer.y = 0;
this._touchLayer.alpha = 0; this._touchLayer.alpha = 0;
this.testrevive = new engine.Label();
this.addChild(this.testrevive);
this.testrevive.size = 55;
this.testrevive.text = "复活";
this.testrevive.width = 500;
this.testrevive.height = 200;
this.testrevive.mouseEnabled = true;
this.testrevive.addEventListener(engine.MouseEvent.CLICK,this.revive,this);
} }
setScoreShow(){ setScoreShow(){
......
...@@ -4,8 +4,9 @@ export class Player extends engine.Container{ ...@@ -4,8 +4,9 @@ export class Player extends engine.Container{
_container; _container;
private playerNode: svga.Svga; private playerNode: svga.Svga;
pierWidth
initPlayer(pierWidth){ initPlayer(pierWidth){
this.pierWidth = pierWidth;
this._container = new engine.Container(); this._container = new engine.Container();
this.addChild(this._container); this.addChild(this._container);
...@@ -16,6 +17,12 @@ export class Player extends engine.Container{ ...@@ -16,6 +17,12 @@ export class Player extends engine.Container{
this.playerNode.x = pierWidth/2 - 80; this.playerNode.x = pierWidth/2 - 80;
this.playerNode.play(); this.playerNode.play();
} }
revive(){
this._container.x = 0;
this._container.y = 0;
this.playerNode.x = this.pierWidth/2 - 80;
this.playerNode.y = 675;
}
setViewport(pos,callBack,pierWidth?){ setViewport(pos,callBack,pierWidth?){
let tmpPos = 0; let tmpPos = 0;
let isSuccess = false; let isSuccess = false;
......
/**
* Created by renjianfeng on 2020-03-13.
*/
const customId = 'pintu';
(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('pictures-initgame', {
gameUrls:[
"https://yun.duiba.com.cn/aurora/assets/5906e5670cb7061dfc77306087e9a79d4bbcb2501.jpg",
"https://yun.duiba.com.cn/aurora/assets/61fd0754d7924305fd2851be86a480d71d2c2981.jpg",
"https://yun.duiba.com.cn/aurora/assets/6b70d7ec626f35f21347bf5bc3e61bedc44167be.jpg"
],
gameTimes:[
10000,
10000,
10000,
]
})
},1000);
setTimeout(() => {
// engine.globalEvent.dispatchEvent('pictures-start', {
// actidx:0,
// rows:3,
// cols:3,
// gametime:30000
// });
// const d = engine.gameStage.sceneContainer.getChildAt(0);
// engine.gameStage.sceneContainer.getChildAt(0).x = (d.stage.width-props.W)/2;
// engine.gameStage.sceneContainer.getChildAt(0).y = (d.stage.height-props.H)/2;
}, 3000);
// setTimeout(() => {
// engine.globalEvent.dispatchEvent('pictures-start', {
// picUrl: "http://yun.duiba.com.cn/aurora/assets/e1593b97c27077b85b92f7eaaeae1ed64a1eb79a.png",
// // picUrl: "http://yun.duiba.com.cn/aurora/assets/d23e73d37ec01931e48cbd0a4095367044c5675c.png"
// blockUrl: "888"
// });
// }, 30*1000);
});
engine.globalEvent.addEventListener('pictures-time-update', (e) => {
// console.log(e.type, e.data);
});
engine.globalEvent.addEventListener('pictures-game-fail', (e) => {
console.log(e.type, e.data);
});
engine.globalEvent.addEventListener('pictures-game-success', (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: gray;
}
.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.1de84ff79dba19e949088de63aa75af51a515e5c.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": "玩家icon",
"url": "//yun.duiba.com.cn/aurora/assets/5b3e30496b2d9fdafb0cf3835fd6704ce10e45b4.png",
"uuid": "888",
"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": "玩家",
"url": "//yun.duiba.com.cn/aurora/assets/b66300c5d4f27134b0aac3dc90a3220e8ae572eb.svga",
"uuid": "71d8dcbc-3931-471a-b585-b3ae01b25aa6",
"ext": ".svga"
}
];
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.pintu = 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(engine.getAssetByName(name).uuid);
}
function loadImageByUrl(url) {
return tslib.__awaiter(this, void 0, void 0, function () {
return tslib.__generator(this, function (_a) {
try {
return [2, new Promise(function (resolve) {
var t1 = setTimeout(function () {
return resolve(null);
}, 2000);
if (engine.TextureCache[url]) {
clearTimeout(t1);
resolve(engine.TextureCache[url]);
}
else {
var t = engine.Texture.from(url);
t.addEventListener("loaded", function () { clearTimeout(t1); resolve(t); });
}
})];
}
catch (e) {
return [2, null];
}
return [2];
});
});
}
//# sourceMappingURL=utils.js.map
var Tool = (function () {
function Tool() {
}
Tool.getOnePic = function () {
if (this.picPool.length > 0) {
return this.picPool.shift();
}
else {
var ipic = new engine.Container();
var isprite = new engine.ScrollView();
isprite.name = "iscrollv";
var nsp = new engine.Sprite();
nsp.name = "isprite";
nsp.texture;
isprite.addChild(nsp);
ipic.addChild(isprite);
isprite.mouseEnabled = false;
nsp.mouseEnabled = false;
return ipic;
}
};
Tool.repushToPool = function (icont) {
this.picPool.push(icont);
};
Tool.picPool = new Array();
return Tool;
}());
//# sourceMappingURL=Tool.js.map
var qietu = (function (url, type1, rows, cols, parent) { return tslib.__awaiter(void 0, void 0, void 0, function () {
var t, t1, setimgwid, mwid1, mhei1, picarr, picnames, startlix, addlix, startliy, addliy, twid1, thei1, r, startx, c, starty, nsprite, isprite, nsp, ispritename, e_1;
return tslib.__generator(this, function (_a) {
switch (_a.label) {
case 0:
_a.trys.push([0, 6, , 8]);
t = void 0;
if (!(type1 == 1)) return [3, 1];
t = url;
return [3, 5];
case 1:
if (!(type1 == 2)) return [3, 3];
return [4, loadImageByUrl(url)];
case 2:
t1 = _a.sent();
if (t1) {
t = t1;
}
return [3, 5];
case 3:
if (!(type1 == 3)) return [3, 5];
return [4, getTextureByName("testimg")];
case 4:
t = (_a.sent());
_a.label = 5;
case 5:
if (!t) {
return [2, qietu("testimg", 3, rows, cols)];
}
setimgwid = 612;
mwid1 = setimgwid / rows;
mhei1 = setimgwid / cols;
picarr = {};
picnames = [];
startlix = 0;
addlix = 1 / rows;
startliy = 0;
addliy = 1 / cols;
twid1 = setimgwid;
thei1 = setimgwid;
for (r = 0; r < rows; r++) {
startx = startlix + addlix * r;
for (c = 0; c < cols; c++) {
starty = startliy + addliy * c;
nsprite = Tool.getOnePic();
isprite = nsprite.getChildByName("iscrollv");
nsp = isprite.getChildByName("isprite");
nsp.texture = t;
nsp.width = twid1;
nsp.height = thei1;
nsp.x = -starty * twid1;
nsp.y = -startx * thei1;
isprite.width = mwid1;
isprite.height = mhei1;
nsprite.width = mwid1;
nsprite.height = mhei1;
ispritename = "pic_" + c + "_" + r;
nsprite.name = ispritename;
picarr[ispritename] = nsprite;
picnames.push(ispritename);
}
}
return [2, {
res: true,
picarr: picarr,
mwid: mwid1,
mhei: mhei1,
picnames: picnames
}];
case 6:
e_1 = _a.sent();
return [4, new Promise(function (res) {
setTimeout(function () {
res();
}, 200);
})];
case 7:
_a.sent();
return [2, qietu("testimg", 3, rows, cols)];
case 8: return [2];
}
});
}); });
//# sourceMappingURL=qietu.js.map
var GameView = (function (_super) {
tslib.__extends(GameView, _super);
function GameView() {
var _this = _super.call(this) || this;
_this.ingame = false;
_this.selectImgArr = [];
_this.sucposData = {};
_this.gameUrls = [];
_this.gameTimes = [];
_this.onegamePics = [];
_this.movesteps = 0;
_this.startime = 0;
_this.once(engine.Event.ADDED_TO_STAGE, _this.initScene, _this);
return _this;
}
GameView.prototype.initScene = function () {
this.lineShape = new engine.Shape();
this.selectimg3 = new engine.Image(getTextureByName("框3"));
this.selectimg4 = new engine.Image(getTextureByName("框4"));
this.selectimg3.mouseEnabled = false;
this.selectimg4.mouseEnabled = false;
this.dicont = new engine.Container();
this.linecont = new engine.Container();
this.blockcont = new engine.Container();
this.addChild(this.dicont);
this.addChild(this.linecont);
this.addChild(this.blockcont);
this.linecont.addChild(this.lineShape);
engine.globalEvent.dispatchEvent("pictures-time-initcomp", {});
this.removeEventListener(engine.Event.ADDED_TO_STAGE, this.initScene, this);
};
GameView.prototype.initgame = function () {
return tslib.__awaiter(this, void 0, void 0, function () {
var l, lurl, lt;
return tslib.__generator(this, function (_a) {
switch (_a.label) {
case 0:
this.gameUrls = props.gameUrls || ["https://yun.duiba.com.cn/db_games/activity/game/1596074071/resource/assets/ptimgs/28.jpg", "https://yun.duiba.com.cn/db_games/activity/game/1596074071/resource/assets/ptimgs/29.jpg", "https://yun.duiba.com.cn/db_games/activity/game/1596074071/resource/assets/ptimgs/30.jpg"];
this.gameTimes = props.gameTimes || [30, 60, 60];
this.onegamePics = new Array();
l = 0;
_a.label = 1;
case 1:
if (!(l < this.gameUrls.length)) return [3, 4];
lurl = this.gameUrls[l];
return [4, loadImageByUrl(lurl)];
case 2:
lt = _a.sent();
if (lt) {
lt = lt;
}
else {
lt = null;
}
this.onegamePics.push(lt);
if (this.onegamePics.length == 1) {
this.startfirst();
}
_a.label = 3;
case 3:
l++;
return [3, 1];
case 4:
this.removeSelectImg();
return [2];
}
});
});
};
GameView.prototype.removeSelectImg = function () {
if (this.selectimg3) {
this.blockcont.removeChild(this.selectimg3);
}
if (this.selectimg4) {
this.blockcont.removeChild(this.selectimg4);
}
};
GameView.prototype.removeDiPics = function () {
var nume = this.dicont.children.length;
for (var i = nume - 1; i >= 0; i--) {
var ichild = this.dicont.getChildAt(i);
if (ichild) {
ichild.removeEventListener(engine.MouseEvent.MOUSE_DOWN, this.touchPic, this);
this.dicont.removeChild(ichild);
Tool.repushToPool(ichild);
}
}
};
GameView.prototype.startfirst = function () {
return tslib.__awaiter(this, void 0, void 0, function () {
var actidx, tex, type1, result, res, picarr, mwid, mhei, picnames, gap, r, c, ipicx, ipicy, npicname, ipic, rl, cl;
return tslib.__generator(this, function (_a) {
switch (_a.label) {
case 0:
this.removeDiPics();
this.movesteps = 0;
this.startime = Date.now();
this.removeSelectImg();
actidx = 0;
this.gametime = this.gameTimes[actidx];
this.showtime = this.gameTimes[actidx];
this.passtime = 0;
engine.globalEvent.dispatchEvent("pictures-time-update", {
time: this.showtime,
});
engine.globalEvent.dispatchEvent("pictures-time-passtime", {
passtime: this.passtime
});
this.rows = 3;
this.cols = 3;
this.nselectimg = null;
if (this.rows == 3) {
this.nselectimg = this.selectimg3;
}
if (this.rows == 4) {
this.nselectimg = this.selectimg4;
}
this.selectImgArr = new Array();
this.sucposData = {};
tex = this.onegamePics[actidx];
type1 = 1;
if (!tex) {
tex = this.gameUrls[actidx];
type1 = 3;
}
return [4, qietu(tex, type1, this.rows, this.cols, this.dicont)];
case 1:
result = _a.sent();
res = result.res;
if (res) {
picarr = result.picarr;
mwid = result.mwid;
mhei = result.mhei;
picnames = result.picnames;
this.mwid = mwid;
this.mhei = mhei;
this.picarr = picarr;
this.picnames = picnames;
gap = 2;
for (r = 0; r < this.rows; r++) {
for (c = 0; c < this.cols; c++) {
ipicx = mwid * c + gap;
ipicy = mhei * r + gap;
npicname = "pic_" + c + "_" + r;
ipic = picarr[npicname];
this.dicont.addChild(ipic);
ipic.x = ipicx;
ipic.y = ipicy;
}
}
this.lineShape.clear();
this.lineShape.beginStroke(0x0069df, 4, engine.LINE_CAP.BUTT, engine.LINE_JOIN.BEVEL, 100);
this.lineShape.moveTo(0 + gap, 0 + gap);
this.lineShape.lineTo(mhei * this.cols + gap, 0 + gap);
this.lineShape.lineTo(mhei * this.cols + gap, mwid * this.rows + gap);
this.lineShape.lineTo(0 + gap, mwid * this.rows + gap);
this.lineShape.lineTo(0 + gap, 0 + gap);
for (rl = 1; rl < this.rows; rl++) {
this.lineShape.moveTo(0 + gap, rl * mhei + gap);
this.lineShape.lineTo(mwid * this.cols + gap, rl * mhei + gap);
}
for (cl = 1; cl < this.cols; cl++) {
this.lineShape.moveTo(cl * mwid + gap, 0 + gap);
this.lineShape.lineTo(cl * mwid + gap, this.rows * mhei + gap);
}
this.lineShape.endStroke();
engine.globalEvent.dispatchEvent("pictures-load-complete");
this.ticker && clearInterval(this.ticker);
this.ticker = setInterval(this.update, 10);
}
else {
console.error("图片处理失败");
}
return [2];
}
});
});
};
GameView.prototype.start = function () {
return tslib.__awaiter(this, void 0, void 0, function () {
var actidx, tex, type1, result, res, picarr, mwid, mhei, picnames, gap, r, c, ipicx, ipicy, npicname, ipic, rl, cl;
return tslib.__generator(this, function (_a) {
switch (_a.label) {
case 0:
this.removeDiPics();
this.movesteps = 0;
this.startime = Date.now();
this.removeSelectImg();
actidx = props.actidx;
this.gametime = this.gameTimes[actidx];
this.showtime = this.gameTimes[actidx];
this.passtime = 0;
engine.globalEvent.dispatchEvent("pictures-time-update", {
time: this.showtime,
});
engine.globalEvent.dispatchEvent("pictures-time-passtime", {
passtime: this.passtime
});
this.rows = props.rows;
this.cols = props.cols;
this.nselectimg = null;
if (this.rows == 3) {
this.nselectimg = this.selectimg3;
}
if (this.rows == 4) {
this.nselectimg = this.selectimg4;
}
this.selectImgArr = new Array();
this.sucposData = {};
tex = this.onegamePics[actidx];
type1 = 1;
if (!tex) {
tex = this.gameUrls[actidx];
type1 = 3;
}
return [4, qietu(tex, type1, this.rows, this.cols, this.dicont)];
case 1:
result = _a.sent();
res = result.res;
if (res) {
picarr = result.picarr;
mwid = result.mwid;
mhei = result.mhei;
picnames = result.picnames;
this.mwid = mwid;
this.mhei = mhei;
this.picarr = picarr;
this.picnames = picnames;
gap = 2;
for (r = 0; r < this.rows; r++) {
for (c = 0; c < this.cols; c++) {
ipicx = mwid * c + gap;
ipicy = mhei * r + gap;
npicname = "pic_" + c + "_" + r;
ipic = picarr[npicname];
this.dicont.addChild(ipic);
ipic.x = ipicx;
ipic.y = ipicy;
}
}
this.lineShape.clear();
this.lineShape.beginStroke(0x0069df, 4, engine.LINE_CAP.BUTT, engine.LINE_JOIN.BEVEL, 100);
this.lineShape.moveTo(0 + gap, 0 + gap);
this.lineShape.lineTo(mhei * this.cols + gap, 0 + gap);
this.lineShape.lineTo(mhei * this.cols + gap, mwid * this.rows + gap);
this.lineShape.lineTo(0 + gap, mwid * this.rows + gap);
this.lineShape.lineTo(0 + gap, 0 + gap);
for (rl = 1; rl < this.rows; rl++) {
this.lineShape.moveTo(0 + gap, rl * mhei + gap);
this.lineShape.lineTo(mwid * this.cols + gap, rl * mhei + gap);
}
for (cl = 1; cl < this.cols; cl++) {
this.lineShape.moveTo(cl * mwid + gap, 0 + gap);
this.lineShape.lineTo(cl * mwid + gap, this.rows * mhei + gap);
}
this.lineShape.endStroke();
this.ticker && clearInterval(this.ticker);
this.ticker = setInterval(this.update, 10);
}
else {
console.error("图片处理失败");
}
return [2];
}
});
});
};
GameView.prototype.luanxu = function () {
var gap = 2;
for (var r = 0; r < this.rows; r++) {
for (var c = 0; c < this.cols; c++) {
var ipicx = this.mwid * c + gap;
var ipicy = this.mhei * r + gap;
var npicname = "pic_" + c + "_" + r;
this.sucposData[npicname] = r + "_" + c;
var selidx = Math.floor(Math.random() * this.picnames.length);
var ipicname = this.picnames[selidx];
if (r == c && r != this.rows - 1) {
while (ipicname == npicname) {
selidx = Math.floor(Math.random() * this.picnames.length);
ipicname = this.picnames[selidx];
}
}
var ipic = this.picarr[ipicname];
this.picnames.splice(selidx, 1);
ipic.x = ipicx;
ipic.y = ipicy;
ipic["postr"] = r + "_" + c;
ipic.addEventListener(engine.MouseEvent.MOUSE_DOWN, this.touchPic, this);
}
}
};
GameView.prototype.pause = function () {
this.ingame = false;
};
GameView.prototype.resume = function () {
this.lastframetime = Date.now();
this.ingame = true;
};
GameView.prototype.update = function () {
var ntime = Date.now();
if (!this.lastframetime) {
this.lastframetime = ntime;
return;
}
if (this.ingame) {
var passtime = (ntime - this.lastframetime) / 1000;
this.passtime += passtime;
engine.globalEvent.dispatchEvent("pictures-time-passtime", {
passtime: this.passtime
});
var showtime1 = Math.round(this.gametime - this.passtime);
if (this.showtime != showtime1) {
this.showtime = showtime1;
if (this.showtime <= 0) {
this.showtime = 0;
this.gameover(2);
}
engine.globalEvent.dispatchEvent("pictures-time-update", {
time: this.showtime
});
}
}
this.lastframetime = ntime;
};
GameView.prototype.touchPic = function (e) {
if (!this.ingame) {
return;
}
var selectname = e.target.name;
var spx = e.target.x;
var spy = e.target.y;
var gap = 2;
if (this.selectImgArr.length == 0) {
if (this.nselectimg) {
this.blockcont.addChild(this.nselectimg);
this.nselectimg.x = spx - gap;
this.nselectimg.y = spy - gap;
}
this.selectImgArr.push(selectname);
}
else if (this.selectImgArr.length == 1) {
if (selectname == this.selectImgArr[0]) {
if (this.nselectimg) {
this.blockcont.removeChild(this.nselectimg);
}
this.selectImgArr = new Array();
return;
}
else {
this.selectImgArr.push(selectname);
this.changeImgPos();
}
}
};
GameView.prototype.changeImgPos = function () {
var img1name = this.selectImgArr[0];
var img2name = this.selectImgArr[1];
var img1 = this.dicont.getChildByName(img1name);
var img2 = this.dicont.getChildByName(img2name);
var imgpos1x = img1.x;
var imgpos1y = img1.y;
var imgpos2x = img2.x;
var imgpos2y = img2.y;
var imgpostr1 = img1.postr;
var imgpostr2 = img2.postr;
img1.x = imgpos2x;
img1.y = imgpos2y;
img1.postr = imgpostr2;
img2.x = imgpos1x;
img2.y = imgpos1y;
img2.postr = imgpostr1;
this.selectImgArr = new Array();
this.movesteps += 1;
if (this.nselectimg) {
this.blockcont.removeChild(this.nselectimg);
}
var isuc = this.checkSuccess();
if (isuc) {
this.gameover(1);
}
};
GameView.prototype.checkSuccess = function () {
var isuc = true;
for (var r = 0; r < this.rows; r++) {
for (var c = 0; c < this.cols; c++) {
var ipicname = "pic_" + c + "_" + r;
var npicstr = r + "_" + c;
var ipic = this.dicont.getChildByName(ipicname);
var ipostr = ipic.postr;
if (npicstr != ipostr) {
isuc = false;
break;
}
}
}
return isuc;
};
GameView.prototype.gameover = function (reason) {
this.ingame = false;
this.ticker && clearInterval(this.ticker);
var ntime = Date.now();
var gametime = ntime - this.startime;
engine.globalEvent.dispatchEvent('pictures-game-over', {
reason: reason,
time: this.passtime,
number: this.movesteps,
gametime: gametime
});
};
return GameView;
}(engine.Container));
//# sourceMappingURL=GameView.js.map
var GameWrapper = (function (_super) {
tslib.__extends(GameWrapper, _super);
function GameWrapper() {
var _this = _super.call(this) || this;
_this._gameView = new GameView();
_this.addChild(_this._gameView);
engine.globalEvent.addEventListener('pictures-initgame', _this.initgame, _this);
engine.globalEvent.addEventListener('pictures-start', _this.start, _this);
engine.globalEvent.addEventListener('pictures-luanxu', _this.luanxu, _this);
engine.globalEvent.addEventListener('pictures-pause', _this.pause, _this);
engine.globalEvent.addEventListener('pictures-resume', _this.resume, _this);
return _this;
}
GameWrapper.prototype.initgame = function (event) {
injectProps(event.data);
this._gameView.initgame();
};
GameWrapper.prototype.start = function (event) {
injectProps(event.data);
this._gameView.start();
};
GameWrapper.prototype.luanxu = function () {
this._gameView.luanxu();
};
GameWrapper.prototype.pause = function (event) {
this._gameView.pause();
};
GameWrapper.prototype.resume = function (event) {
this._gameView.resume();
};
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/pintu/src/props.ts","src/custom/pintu/src/game/utils.ts","src/custom/pintu/src/game/Tool.ts","src/custom/pintu/src/game/qietu.ts","src/custom/pintu/src/game/GameView.ts","src/custom/pintu/src/game/GameWrapper.ts","src/custom/pintu/src/index.ts"],"sourcesContent":["/**\r\n * Created by rockyl on 2020-01-21.\r\n */\r\n\r\nexport let props: any = {};\r\n\r\nexport function prepareProps() {\r\n\tlet metaProps = getProps();\r\n\r\n\tengine.injectProp(props, metaProps);\r\n}\r\n\r\nexport function injectProps(p) {\r\n\tengine.injectProp(props, p);\r\n}\r\n","/**\r\n * Created by rockyl on 2020-01-21.\r\n */\r\n\r\nexport function getTexture(uuid) {\r\n\treturn engine.Texture.from(getAssetByUUID(uuid).uuid);\r\n}\r\n\r\nexport function getTextureByName(name) {\r\n\treturn getTexture(engine.getAssetByName(name).uuid);\r\n}\r\n\r\nexport function playSound(name) {\r\n\tengine.playSound(engine.getAssetByName(name).uuid, {keep: true});\r\n}\r\nexport function createSvga(name, anchorName?) {\r\n\tlet inst = new svga.Svga();\r\n\tinst.source = 'asset://' + engine.getAssetByName(name).uuid;\r\n\treturn inst;\r\n}\r\n\r\nexport async function loadImageByUrl(url){\r\n\t// console.log('loadImageByUrl----------:',url);\r\n\ttry{\r\n\t\t// console.log(\"尝试加载44\");\r\n\t\treturn new Promise((resolve) => {\r\n\t\t\tlet t1 = setTimeout(()=>{\r\n\t\t\t\treturn resolve(null);\r\n\t\t\t},2000);\r\n\r\n\t\t\tif (engine.TextureCache[url]) {\r\n\t\t\t\tclearTimeout(t1);\r\n\t\t\t\tresolve(engine.TextureCache[url])\r\n\t\t\t} else {\r\n\t\t\t\tvar t = engine.Texture.from(url);\r\n\t\t\t\tt.addEventListener(\"loaded\", () => { clearTimeout(t1);resolve(t) });\r\n\t\t\t}\r\n\t\t})\r\n\t}catch(e){\r\n\t\treturn null;\r\n\t}\r\n}","export default class Tool{\r\n static picPool:Array<engine.Container> = new Array();\r\n static getOnePic(){\r\n if(this.picPool.length>0){\r\n return this.picPool.shift();\r\n }else{\r\n let ipic = new engine.Container();\r\n \r\n let isprite = new engine.ScrollView();\r\n isprite.name = \"iscrollv\";\r\n let nsp = new engine.Sprite();\r\n nsp.name = \"isprite\";\r\n nsp.texture\r\n\r\n isprite.addChild(nsp);\r\n\r\n ipic.addChild(isprite);\r\n\r\n isprite.mouseEnabled = false;\r\n nsp.mouseEnabled = false;\r\n\r\n return ipic;\r\n }\r\n }\r\n\r\n static repushToPool(icont:engine.Container){\r\n this.picPool.push(icont);\r\n }\r\n}","import { props } from \"../props\";\r\nimport { loadImageByUrl, getTextureByName ,getTexture} from \"./utils\";\r\nimport qietu from \"./qietu\";\r\nimport Tool from \"./Tool\";\r\nconst urls = [];\r\nconst picMap = {};\r\nconst posMap = {};\r\nexport default async(url:any,type1:number, rows:number, cols:number,parent:engine.Container) => {\r\n try{\r\n let t:engine.Texture;\r\n if(type1==1){\r\n t = url;\r\n }else if(type1==2){\r\n let t1 = await loadImageByUrl(url);// as engine.Texture;\r\n if(t1){\r\n t = t1 as engine.Texture;\r\n }\r\n }else if(type1==3){\r\n t = await getTextureByName(\"testimg\") as engine.Texture;\r\n }\r\n if(!t){\r\n return qietu(\"testimg\",3,rows,cols,parent);\r\n }\r\n \r\n let setimgwid = 612;\r\n let mwid1 = setimgwid/rows;\r\n let mhei1 = setimgwid/cols;\r\n\r\n // let mwid = t.width;\r\n // let mhei = t.height;\r\n // if(mwid<10||mhei<10){\r\n // await new Promise(res=>{\r\n // setTimeout(function(){\r\n // res();\r\n // },200);\r\n // })\r\n // return qietu(t,1,rows,cols,parent);\r\n // }\r\n // if(mwid>mhei){\r\n // if(mhei<setimgwid){\r\n // mwid = mwid*setimgwid/mhei;\r\n // mhei = setimgwid;\r\n // }\r\n // }else{\r\n // if(mwid<setimgwid){\r\n // mhei = mhei*setimgwid/mwid;\r\n // mwid = setimgwid;\r\n // }\r\n // }\r\n\r\n let picarr = {};\r\n let picnames = [];\r\n\r\n let chax;\r\n let chay;\r\n let startlix = 0;\r\n let addlix = 1/rows;\r\n let startliy = 0;\r\n let addliy = 1/cols;\r\n\r\n let twid1 = setimgwid;\r\n let thei1 = setimgwid;\r\n // if(mwid>mhei){\r\n // chax = (mwid-mhei)/2;\r\n // startlix = chax/mwid;\r\n // addlix = (mhei/cols)/mwid;\r\n\r\n // startliy = 0;\r\n // addliy = 1/rows;\r\n\r\n // twid1 = mwid*setimgwid/mhei;\r\n // thei1 = setimgwid;\r\n // }else{\r\n // startlix = 0;\r\n // addlix = 1/cols;\r\n\r\n // chay = (mhei-mwid)/2;\r\n // startliy = chay/mhei;\r\n // addliy = (mwid/rows)/mhei;\r\n\r\n // thei1 = mhei*setimgwid/mwid;\r\n // twid1 = setimgwid;\r\n // }\r\n \r\n // console.log(\"切图准备\",startlix,addlix,startliy,addliy,mwid,mhei);\r\n // let txt1 = new engine.Label();\r\n // txt1.fillColor = \"red\";\r\n // txt1.size = 24;\r\n // txt1.text = startlix.toFixed(2)+\";\"+addlix.toFixed(2)+\";\"+startliy.toFixed(2)+\";\"+addliy.toFixed(2)+\";\"+mwid.toFixed(2)+\";\"+mhei.toFixed(2)+\";\"\r\n // parent.addChild(txt1);\r\n // txt1.y = -100;\r\n for(let r=0;r<rows;r++){\r\n let startx = startlix+addlix*r;\r\n let endx = startx + addlix;\r\n for(let c=0;c<cols;c++){\r\n let starty = startliy+addliy*c;\r\n let endy = starty+addliy;\r\n\r\n // let uvs = new Float32Array([\r\n // starty,\r\n // startx,\r\n // endy,\r\n // startx,\r\n // endy,\r\n // endx,\r\n // starty,\r\n // endx\r\n // ])\r\n //方案1\r\n // let isprite = new engine.Sprite(t);\r\n // isprite.uvs = uvs;\r\n\r\n //方案2\r\n let nsprite = Tool.getOnePic();\r\n let isprite = nsprite.getChildByName(\"iscrollv\");\r\n let nsp = isprite.getChildByName(\"isprite\");\r\n nsp.texture = t;\r\n\r\n nsp.width = twid1;\r\n nsp.height = thei1;\r\n\r\n // let nsprite = new engine.Container();\r\n\r\n // let isprite = new engine.ScrollView();\r\n // let nsp = new engine.Sprite(t);\r\n // isprite.addChild(nsp);\r\n // nsp.width = twid1;\r\n // nsp.height = thei1;\r\n\r\n // isprite.mouseEnabled = false;\r\n // isprite.mouseChildren = false;\r\n nsp.x = -starty*twid1;\r\n nsp.y = -startx*thei1;\r\n\r\n isprite.width = mwid1;\r\n isprite.height = mhei1;\r\n\r\n // nsprite.addChild(isprite);\r\n nsprite.width = mwid1;\r\n nsprite.height = mhei1;\r\n\r\n let ispritename = \"pic_\"+c+\"_\"+r;\r\n nsprite.name = ispritename;\r\n picarr[ispritename] = nsprite;\r\n picnames.push(ispritename);\r\n }\r\n }\r\n return {\r\n res:true,\r\n picarr:picarr,\r\n mwid:mwid1,\r\n mhei:mhei1,\r\n picnames:picnames\r\n };\r\n }catch(e){\r\n //获取那图失败\r\n\r\n // return {\r\n // res:false\r\n // };\r\n await new Promise(res=>{\r\n setTimeout(function(){\r\n res();\r\n },200);\r\n })\r\n return qietu(\"testimg\",3,rows,cols,parent);\r\n }\r\n};\r\n","/**\r\n * Created by rockyl on 2018/8/16.\r\n */\r\n\r\nimport { props } from \"../props\";\r\nimport qietu from \"./qietu\";\r\nimport { getTexture, loadImageByUrl,getTextureByName } from \"./utils\";\r\nimport ObjectPool = engine.ObjectPool;\r\nimport Tool from \"./Tool\";\r\n\r\nexport default class GameView extends engine.Container {\r\n rows:number;\r\n cols:number;\r\n\r\n passtime:number;\r\n gametime:number;\r\n showtime:number;\r\n\r\n lastframetime:number;\r\n\r\n ingame:boolean = false;\r\n\r\n ticker;\r\n\r\n selectimg3:engine.Image;\r\n selectimg4:engine.Image;\r\n nselectimg:engine.Image;\r\n\r\n selectImgArr:Array<string> = [];\r\n sucposData:Object = {};\r\n\r\n dicont:engine.Container;\r\n linecont:engine.Container;\r\n blockcont:engine.Container;\r\n\r\n lineShape:engine.Shape;\r\n\r\n mwid:number;\r\n mhei:number;\r\n picnames:Array<string>;\r\n picarr;\r\n\r\n gameUrls:Array<string> = [];\r\n gameTimes:Array<number> = [];\r\n onegamePics:Array<any> = [];\r\n movesteps:number = 0;\r\n startime:number = 0;\r\n constructor() {\r\n super();\r\n this.once(engine.Event.ADDED_TO_STAGE, this.initScene, this);\r\n }\r\n initScene(){\r\n this.lineShape = new engine.Shape();\r\n this.selectimg3 = new engine.Image(getTextureByName(\"框3\"));\r\n this.selectimg4 = new engine.Image(getTextureByName(\"框4\"));\r\n this.selectimg3.mouseEnabled = false;\r\n this.selectimg4.mouseEnabled = false;\r\n //底图\r\n this.dicont = new engine.Container();\r\n //线\r\n this.linecont = new engine.Container();\r\n //亮片\r\n this.blockcont = new engine.Container();\r\n\r\n this.addChild(this.dicont);\r\n this.addChild(this.linecont);\r\n this.addChild(this.blockcont);\r\n \r\n this.linecont.addChild(this.lineShape);\r\n\r\n // console.log(\"拼图初始化完毕--------------\");\r\n engine.globalEvent.dispatchEvent(\"pictures-time-initcomp\",{});\r\n this.removeEventListener(engine.Event.ADDED_TO_STAGE,this.initScene,this);\r\n\r\n // let testsuc = new engine.Label();\r\n // testsuc.text = \"直接成功\";\r\n // testsuc.size = 66;\r\n // testsuc.fillColor = \"red\";\r\n // this.addChild(testsuc);\r\n // testsuc.y = 500;\r\n // testsuc.width = 300;\r\n // testsuc.height = 200;\r\n // testsuc.addEventListener(engine.MouseEvent.CLICK,this.zhijieSuc,this);\r\n }\r\n // //测试直接成功\r\n // zhijieSuc(){\r\n // this.gameover(1);\r\n // }\r\n\r\n async initgame(){\r\n // console.log(\"initgame---------\");\r\n this.gameUrls = props.gameUrls||[\"https://yun.duiba.com.cn/db_games/activity/game/1596074071/resource/assets/ptimgs/28.jpg\", \"https://yun.duiba.com.cn/db_games/activity/game/1596074071/resource/assets/ptimgs/29.jpg\", \"https://yun.duiba.com.cn/db_games/activity/game/1596074071/resource/assets/ptimgs/30.jpg\"];\r\n this.gameTimes = props.gameTimes||[30,60,60];\r\n \r\n this.onegamePics = new Array();\r\n for(let l=0;l<this.gameUrls.length;l++){\r\n let lurl = this.gameUrls[l];\r\n let lt = await loadImageByUrl(lurl);\r\n // console.log(lt);\r\n if(lt){\r\n lt = lt as engine.Texture\r\n }else{\r\n lt = null;\r\n }\r\n this.onegamePics.push(lt);\r\n if(this.onegamePics.length==1){//第一张图加载完毕,自动填充\r\n this.startfirst();\r\n }\r\n }\r\n this.removeSelectImg();\r\n }\r\n removeSelectImg(){\r\n if(this.selectimg3){\r\n this.blockcont.removeChild(this.selectimg3);\r\n }\r\n if(this.selectimg4){\r\n this.blockcont.removeChild(this.selectimg4);\r\n }\r\n }\r\n removeDiPics(){\r\n let nume = this.dicont.children.length;\r\n for(let i=nume-1;i>=0;i--){\r\n let ichild = this.dicont.getChildAt(i) as engine.Container;\r\n if(ichild){\r\n ichild.removeEventListener(engine.MouseEvent.MOUSE_DOWN,\r\n this.touchPic,this);\r\n this.dicont.removeChild(ichild);\r\n Tool.repushToPool(ichild);\r\n }\r\n }\r\n }\r\n async startfirst(){\r\n // this.dicont.removeChildren();\r\n this.removeDiPics();\r\n\r\n this.movesteps = 0;\r\n this.startime = Date.now();\r\n this.removeSelectImg();\r\n\r\n let actidx = 0;\r\n this.gametime = this.gameTimes[actidx];\r\n this.showtime = this.gameTimes[actidx];\r\n this.passtime = 0;\r\n engine.globalEvent.dispatchEvent(\"pictures-time-update\",{\r\n time:this.showtime,\r\n });\r\n engine.globalEvent.dispatchEvent(\"pictures-time-passtime\",{\r\n passtime:this.passtime\r\n });\r\n // console.log(\"start-----------------\",actidx);\r\n this.rows = 3;\r\n this.cols = 3;\r\n\r\n this.nselectimg = null;\r\n if(this.rows==3){\r\n this.nselectimg = this.selectimg3;\r\n }\r\n if(this.rows==4){\r\n this.nselectimg = this.selectimg4;\r\n }\r\n\r\n \r\n \r\n this.selectImgArr = new Array();\r\n this.sucposData = {};\r\n\r\n let tex:any = this.onegamePics[actidx];\r\n let type1 = 1;\r\n if(!tex){\r\n tex = this.gameUrls[actidx];\r\n type1 = 3;\r\n }\r\n // type1 = 3;\r\n let result = await qietu(tex,type1,this.rows,this.cols,this.dicont);\r\n let res = result.res;\r\n if(res){\r\n let picarr = result.picarr;\r\n let mwid = result.mwid;\r\n let mhei = result.mhei;\r\n let picnames = result.picnames;\r\n\r\n this.mwid = mwid;\r\n this.mhei = mhei;\r\n this.picarr = picarr;\r\n this.picnames = picnames;\r\n\r\n let gap = 2;\r\n for(let r=0;r<this.rows;r++){\r\n for(let c=0;c<this.cols;c++){\r\n let ipicx = mwid*c+gap;\r\n let ipicy = mhei*r+gap;\r\n let npicname = \"pic_\"+c+\"_\"+r;\r\n let ipic = picarr[npicname];\r\n this.dicont.addChild(ipic);\r\n ipic.x = ipicx;\r\n ipic.y = ipicy;\r\n }\r\n }\r\n //框线\r\n this.lineShape.clear();\r\n this.lineShape.beginStroke(0x0069df,4,engine.LINE_CAP.BUTT,engine.LINE_JOIN.BEVEL,100);\r\n\r\n this.lineShape.moveTo(0+gap,0+gap);\r\n this.lineShape.lineTo(mhei*this.cols+gap,0+gap);\r\n this.lineShape.lineTo(mhei*this.cols+gap,mwid*this.rows+gap);\r\n this.lineShape.lineTo(0+gap,mwid*this.rows+gap);\r\n this.lineShape.lineTo(0+gap,0+gap);\r\n\r\n for(let rl=1;rl<this.rows;rl++){\r\n this.lineShape.moveTo(0+gap,rl*mhei+gap);\r\n this.lineShape.lineTo(mwid*this.cols+gap,rl*mhei+gap);\r\n }\r\n for(let cl=1;cl<this.cols;cl++){\r\n this.lineShape.moveTo(cl*mwid+gap,0+gap);\r\n this.lineShape.lineTo(cl*mwid+gap,this.rows*mhei+gap);\r\n }\r\n this.lineShape.endStroke();\r\n \r\n engine.globalEvent.dispatchEvent(\"pictures-load-complete\");\r\n this.ticker&&clearInterval(this.ticker);\r\n this.ticker = setInterval(this.update, 10);\r\n }else{\r\n console.error(\"图片处理失败\");\r\n }\r\n }\r\n async start() {\r\n \r\n // this.dicont.removeChildren();\r\n this.removeDiPics();\r\n this.movesteps = 0;\r\n this.startime = Date.now();\r\n this.removeSelectImg();\r\n\r\n let actidx = props.actidx;\r\n this.gametime = this.gameTimes[actidx];\r\n this.showtime = this.gameTimes[actidx];\r\n this.passtime = 0;\r\n engine.globalEvent.dispatchEvent(\"pictures-time-update\",{\r\n time:this.showtime,\r\n });\r\n engine.globalEvent.dispatchEvent(\"pictures-time-passtime\",{\r\n passtime:this.passtime\r\n });\r\n this.rows = props.rows;\r\n this.cols = props.cols;\r\n\r\n this.nselectimg = null;\r\n if(this.rows==3){\r\n this.nselectimg = this.selectimg3;\r\n }\r\n if(this.rows==4){\r\n this.nselectimg = this.selectimg4;\r\n }\r\n\r\n \r\n \r\n this.selectImgArr = new Array();\r\n this.sucposData = {};\r\n\r\n let tex:any = this.onegamePics[actidx];\r\n let type1 = 1;\r\n if(!tex){\r\n tex = this.gameUrls[actidx];\r\n type1 = 3;\r\n }\r\n let result = await qietu(tex,type1,this.rows,this.cols,this.dicont);\r\n let res = result.res;\r\n if(res){\r\n let picarr = result.picarr;\r\n let mwid = result.mwid;\r\n let mhei = result.mhei;\r\n let picnames = result.picnames;\r\n\r\n this.mwid = mwid;\r\n this.mhei = mhei;\r\n this.picarr = picarr;\r\n this.picnames = picnames;\r\n\r\n let gap = 2;\r\n for(let r=0;r<this.rows;r++){\r\n for(let c=0;c<this.cols;c++){\r\n let ipicx = mwid*c+gap;\r\n let ipicy = mhei*r+gap;\r\n let npicname = \"pic_\"+c+\"_\"+r;\r\n\r\n // this.sucposData[npicname] = r+\"_\"+c;\r\n\r\n // let selidx = Math.floor(Math.random()*picnames.length);\r\n // let ipicname:string = picnames[selidx];\r\n // if(r==c&&r!=this.rows-1){\r\n // while(ipicname==npicname){\r\n // selidx = Math.floor(Math.random()*picnames.length);\r\n // ipicname = picnames[selidx];\r\n // }\r\n // }\r\n let ipic = picarr[npicname];\r\n // picnames.splice(selidx,1);\r\n this.dicont.addChild(ipic);\r\n ipic.x = ipicx;\r\n ipic.y = ipicy;\r\n // ipic[\"postr\"] = r+\"_\"+c;\r\n\r\n // ipic.addEventListener(engine.MouseEvent.MOUSE_DOWN,\r\n // this.touchPic,this);\r\n }\r\n }\r\n //框线\r\n this.lineShape.clear();\r\n this.lineShape.beginStroke(0x0069df,4,engine.LINE_CAP.BUTT,engine.LINE_JOIN.BEVEL,100);\r\n\r\n this.lineShape.moveTo(0+gap,0+gap);\r\n this.lineShape.lineTo(mhei*this.cols+gap,0+gap);\r\n this.lineShape.lineTo(mhei*this.cols+gap,mwid*this.rows+gap);\r\n this.lineShape.lineTo(0+gap,mwid*this.rows+gap);\r\n this.lineShape.lineTo(0+gap,0+gap);\r\n\r\n for(let rl=1;rl<this.rows;rl++){\r\n this.lineShape.moveTo(0+gap,rl*mhei+gap);\r\n this.lineShape.lineTo(mwid*this.cols+gap,rl*mhei+gap);\r\n }\r\n for(let cl=1;cl<this.cols;cl++){\r\n this.lineShape.moveTo(cl*mwid+gap,0+gap);\r\n this.lineShape.lineTo(cl*mwid+gap,this.rows*mhei+gap);\r\n }\r\n this.lineShape.endStroke();\r\n \r\n this.ticker&&clearInterval(this.ticker);\r\n this.ticker = setInterval(this.update, 10);\r\n }else{\r\n console.error(\"图片处理失败\");\r\n }\r\n }\r\n luanxu(){\r\n let gap = 2;\r\n for(let r=0;r<this.rows;r++){\r\n for(let c=0;c<this.cols;c++){\r\n let ipicx = this.mwid*c+gap;\r\n let ipicy = this.mhei*r+gap;\r\n let npicname = \"pic_\"+c+\"_\"+r;\r\n\r\n this.sucposData[npicname] = r+\"_\"+c;\r\n\r\n let selidx = Math.floor(Math.random()*this.picnames.length);\r\n let ipicname:string = this.picnames[selidx];\r\n if(r==c&&r!=this.rows-1){\r\n while(ipicname==npicname){\r\n selidx = Math.floor(Math.random()*this.picnames.length);\r\n ipicname = this.picnames[selidx];\r\n }\r\n }\r\n let ipic = this.picarr[ipicname];\r\n this.picnames.splice(selidx,1);\r\n ipic.x = ipicx;\r\n ipic.y = ipicy;\r\n ipic[\"postr\"] = r+\"_\"+c;\r\n\r\n ipic.addEventListener(engine.MouseEvent.MOUSE_DOWN,\r\n this.touchPic,this);\r\n }\r\n }\r\n }\r\n pause(){\r\n this.ingame = false;\r\n // console.error(\"拼图暂停\");\r\n }\r\n resume(){\r\n this.lastframetime = Date.now();\r\n this.ingame = true;\r\n // console.error(\"拼图继续\");\r\n }\r\n\r\n\r\n update() {\r\n let ntime = Date.now();\r\n if(!this.lastframetime){\r\n this.lastframetime = ntime;\r\n return;\r\n }\r\n if(this.ingame){\r\n let passtime = (ntime - this.lastframetime)/1000;\r\n this.passtime += passtime;\r\n engine.globalEvent.dispatchEvent(\"pictures-time-passtime\",{\r\n passtime:this.passtime\r\n });\r\n let showtime1 = Math.round(this.gametime - this.passtime);\r\n // console.log(passtime,this.passtime,this.gametime,this.showtime);\r\n if(this.showtime!=showtime1){\r\n this.showtime = showtime1;\r\n if(this.showtime<=0){\r\n this.showtime = 0;\r\n this.gameover(2);\r\n }\r\n // console.log(\"倒计时\",this.showtime);\r\n engine.globalEvent.dispatchEvent(\"pictures-time-update\",{\r\n time:this.showtime\r\n });\r\n }\r\n }\r\n this.lastframetime = ntime;\r\n }\r\n\r\n touchPic(e:engine.MouseEvent){\r\n if(!this.ingame){\r\n return;\r\n }\r\n // console.log(e.target.name);\r\n let selectname = e.target.name;\r\n let spx = e.target.x;\r\n let spy = e.target.y;\r\n let gap = 2;\r\n if(this.selectImgArr.length==0){\r\n if(this.nselectimg){\r\n this.blockcont.addChild(this.nselectimg);\r\n this.nselectimg.x = spx-gap;\r\n this.nselectimg.y = spy-gap;\r\n }\r\n this.selectImgArr.push(selectname);\r\n }else if(this.selectImgArr.length==1){\r\n if(selectname==this.selectImgArr[0]){\r\n if(this.nselectimg){\r\n this.blockcont.removeChild(this.nselectimg);\r\n }\r\n this.selectImgArr = new Array();\r\n return;\r\n }else{\r\n this.selectImgArr.push(selectname);\r\n this.changeImgPos();\r\n }\r\n }\r\n }\r\n changeImgPos(){\r\n let img1name = this.selectImgArr[0];\r\n let img2name = this.selectImgArr[1];\r\n\r\n let img1 = this.dicont.getChildByName(img1name);\r\n let img2 = this.dicont.getChildByName(img2name);\r\n\r\n let imgpos1x = img1.x;\r\n let imgpos1y = img1.y;\r\n let imgpos2x = img2.x;\r\n let imgpos2y = img2.y;\r\n\r\n let imgpostr1 = img1.postr;\r\n let imgpostr2 = img2.postr;\r\n\r\n img1.x = imgpos2x;\r\n img1.y = imgpos2y;\r\n img1.postr = imgpostr2;\r\n\r\n img2.x = imgpos1x;\r\n img2.y = imgpos1y;\r\n img2.postr = imgpostr1;\r\n\r\n this.selectImgArr = new Array();\r\n \r\n this.movesteps += 1;\r\n\r\n if(this.nselectimg){\r\n this.blockcont.removeChild(this.nselectimg);\r\n }\r\n let isuc = this.checkSuccess();\r\n if(isuc){\r\n // console.error(\"成功过关\");\r\n this.gameover(1);\r\n }\r\n }\r\n checkSuccess(){\r\n let isuc:boolean = true;\r\n for(let r=0;r<this.rows;r++){\r\n for(let c=0;c<this.cols;c++){\r\n let ipicname = \"pic_\"+c+\"_\"+r;\r\n let npicstr = r+\"_\"+c;\r\n let ipic = this.dicont.getChildByName(ipicname);\r\n let ipostr = ipic.postr;\r\n if(npicstr!=ipostr){\r\n isuc = false;\r\n break;\r\n }\r\n }\r\n }\r\n\r\n return isuc;\r\n\r\n }\r\n /**\r\n * \r\n * @param reason 1成功,2失败\r\n */\r\n private gameover(reason:number) {\r\n this.ingame = false;\r\n this.ticker&&clearInterval(this.ticker);\r\n\r\n let ntime = Date.now();\r\n let gametime = ntime - this.startime;\r\n engine.globalEvent.dispatchEvent('pictures-game-over', {\r\n reason:reason,\r\n time: this.passtime,\r\n number:this.movesteps,\r\n gametime:gametime\r\n });\r\n }\r\n\r\n}\r\n","/**\r\n * Created by rockyl on 2020-01-09.\r\n */\r\n\r\nimport GameView from \"./GameView\";\r\nimport { injectProps } from \"../props\";\r\n\r\n\r\nexport class GameWrapper extends engine.Container {\r\n\t// private _status;\r\n\tprivate _gameView: GameView;\r\n\r\n\r\n\r\n\r\n\r\n\tconstructor() {\r\n\t\tsuper();\r\n\r\n\t\t//创建实例\r\n\t\tthis._gameView = new GameView();\r\n\t\tthis.addChild(this._gameView);\r\n\r\n\t\tengine.globalEvent.addEventListener('pictures-initgame', this.initgame, this);\r\n\t\tengine.globalEvent.addEventListener('pictures-start', this.start, this);\r\n\t\tengine.globalEvent.addEventListener('pictures-luanxu', this.luanxu, this);\r\n\t\tengine.globalEvent.addEventListener('pictures-pause', this.pause, this);\r\n\t\tengine.globalEvent.addEventListener('pictures-resume', this.resume, this);\r\n\t}\r\n\tinitgame(event: engine.Event) {\r\n\t\tinjectProps(event.data);\r\n\r\n\t\t// this._status = 1;\r\n\r\n\t\tthis._gameView.initgame();\r\n\t}\r\n\tstart(event: engine.Event) {\r\n\t\tinjectProps(event.data);\r\n\r\n\t\t// this._status = 1;\r\n\r\n\t\tthis._gameView.start();\r\n\t}\r\n\tluanxu(){\r\n\t\tthis._gameView.luanxu();\r\n\t}\r\n\tpause(event: engine.Event) {\r\n\t\t\r\n\t\tthis._gameView.pause();\r\n\t}\r\n\tresume(event:engine.Event){\r\n\t\tthis._gameView.resume();\r\n\t}\r\n}\r\n","/**\r\n * Created by rockyl on 2019-11-20.\r\n */\r\n\r\nimport {GameWrapper} from \"./game/GameWrapper\";\r\nimport {injectProps, prepareProps} from \"./props\";\r\n\r\nexport default function (props) {\r\n\tprepareProps();\r\n\tinjectProps(props);\r\n\r\n\tlet instance = new GameWrapper();\r\n\t\r\n\treturn instance;\r\n}\r\n"],"names":["__extends"],"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;;;UCVe,UAAU,CAAC,IAAI;KAC9B,OAAO,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC;CACvD,CAAC;AAED,UAAgB,gBAAgB,CAAC,IAAI;KACpC,OAAO,UAAU,CAAC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AC;CAAD,CAAC,CA7CgC,MAAM,CAAC,SAAS,GA6ChD;;;iBC9CwB,KAAK;KAC7B,YAAY,EAAE,CAAC;KACf,WAAW,CAAC,KAAK,CAAC,CAAC;KAEnB,IAAI,QAAQ,GAAG,IAAI,WAAW,EAAE,CAAC;KAEjC,OAAO,QAAQ,CAAC;CACjB,CAAC;;;;;;;;;"}
\ No newline at end of file
/**
* Created by rockyl on 2020-01-21.
*/
let customModuleProps = {
};
{
"name": "拼图",
"desc": "拼图模块1.0",
"props": {
"MAX_COL": {
"alias": "图片分成几列",
"type": "number",
"default": 3
},
"MAX_ROW": {
"alias": "图片分成几行",
"type": "number",
"default": 4
},
"W": {
"alias": "图片的宽度",
"type": "number",
"default": 620
},
"H": {
"alias": "图片的高度",
"type": "number",
"default": 620
},
"OFFSET_X": {
"alias": "OFFSET_X",
"type": "number",
"default": 0
},
"OFFSET_Y": {
"alias": "OFFSET_Y",
"type": "number",
"default": 0
},
"GAP": {
"alias": "图片间隙",
"type": "number",
"default": 0
},
"GAME_TIME": {
"alias": "游戏时间",
"type": "number",
"default": 30
}
},
"assets": [
{
"name": "遮罩",
"url": "//yun.duiba.com.cn/aurora/assets/5b3e30496b2d9fdafb0cf3835fd6704ce10e45b4.png",
"uuid": "888",
"ext": ".png"
},
{
"name": "框3",
"url": "//yun.duiba.com.cn/aurora/assets/521e08c574bd76c7dcf708cd6f8c4906e3707f06.png",
"uuid": "kuang3",
"ext": ".png"
},
{
"name": "框4",
"url": "//yun.duiba.com.cn/aurora/assets/1c384d986504d5aabfffeb5125dc67e73ce1b539.png",
"uuid": "kuang4",
"ext": ".png"
},
{
"name":"testimg",
"url":"//yun.duiba.com.cn/aurora/assets/2628186c60c3b80013ae3178ff21a73ffbe71d43.jpg",
"uuid":"morentu",
"ext":".jpg"
}
],
"events": {
"in": {
"pictures-initgame": {
"alias": "初始化",
"data":{
"gameUrls":[
"https://yun.duiba.com.cn/aurora/assets/1456b2a9d72e56f075abb29df99052d87a0f1e48.jpg",
"https://yun.duiba.com.cn/aurora/assets/61fd0754d7924305fd2851be86a480d71d2c2981.jpg",
"https://yun.duiba.com.cn/aurora/assets/6b70d7ec626f35f21347bf5bc3e61bedc44167be.jpg"
]
}
},
"pictures-start": {
"alias": "开始",
"data": {
"actidx":1,
"rows":3,
"cols":3,
"gametime":30
}
},
"pictures-luanxu": {
"alias": "乱序"
},
"pictures-pause": {
"alias": "停止"
},
"pictures-resume":{
"alias":"继续"
}
},
"out": {
"pictures-time-update": {
"alias": "倒计时更新",
"data": {
"time":"剩余时间"
}
},
"pictures-game-over": {
"alias": "游戏结束",
"data": {
"reason": "结束(1:成功,2失败)"
}
},
"pictures-load-complete": {
"alias": "图片加载完毕",
"data": {
"reason": "结束(1:成功,2失败)"
}
},
"pictures-time-passtime": {
"alias": "倒计时进度条",
"data": {
"passtime": 0
}
},
"pictures-time-initcomp": {
"alias": "倒计时进度条",
"data": {
"passtime": 0
}
}
}
}
}
\ No newline at end of file
/**
* Created by rockyl on 2018/8/16.
*/
import { props } from "../props";
import qietu from "./qietu";
import { getTexture, loadImageByUrl,getTextureByName } from "./utils";
import ObjectPool = engine.ObjectPool;
import Tool from "./Tool";
export default class GameView extends engine.Container {
rows:number;
cols:number;
passtime:number;
gametime:number;
showtime:number;
lastframetime:number;
ingame:boolean = false;
ticker;
selectimg3:engine.Image;
selectimg4:engine.Image;
nselectimg:engine.Image;
selectImgArr:Array<string> = [];
sucposData:Object = {};
dicont:engine.Container;
linecont:engine.Container;
blockcont:engine.Container;
lineShape:engine.Shape;
mwid:number;
mhei:number;
picnames:Array<string>;
picarr;
gameUrls:Array<string> = [];
gameTimes:Array<number> = [];
onegamePics:Array<any> = [];
movesteps:number = 0;
startime:number = 0;
constructor() {
super();
this.once(engine.Event.ADDED_TO_STAGE, this.initScene, this);
}
initScene(){
this.lineShape = new engine.Shape();
this.selectimg3 = new engine.Image(getTextureByName("框3"));
this.selectimg4 = new engine.Image(getTextureByName("框4"));
this.selectimg3.mouseEnabled = false;
this.selectimg4.mouseEnabled = false;
//底图
this.dicont = new engine.Container();
//线
this.linecont = new engine.Container();
//亮片
this.blockcont = new engine.Container();
this.addChild(this.dicont);
this.addChild(this.linecont);
this.addChild(this.blockcont);
this.linecont.addChild(this.lineShape);
// console.log("拼图初始化完毕--------------");
engine.globalEvent.dispatchEvent("pictures-time-initcomp",{});
this.removeEventListener(engine.Event.ADDED_TO_STAGE,this.initScene,this);
// let testsuc = new engine.Label();
// testsuc.text = "直接成功";
// testsuc.size = 66;
// testsuc.fillColor = "red";
// this.addChild(testsuc);
// testsuc.y = 500;
// testsuc.width = 300;
// testsuc.height = 200;
// testsuc.addEventListener(engine.MouseEvent.CLICK,this.zhijieSuc,this);
}
// //测试直接成功
// zhijieSuc(){
// this.gameover(1);
// }
async initgame(){
// console.log("initgame---------");
this.gameUrls = props.gameUrls||["https://yun.duiba.com.cn/db_games/activity/game/1596074071/resource/assets/ptimgs/28.jpg", "https://yun.duiba.com.cn/db_games/activity/game/1596074071/resource/assets/ptimgs/29.jpg", "https://yun.duiba.com.cn/db_games/activity/game/1596074071/resource/assets/ptimgs/30.jpg"];
this.gameTimes = props.gameTimes||[30,60,60];
this.onegamePics = new Array();
for(let l=0;l<this.gameUrls.length;l++){
let lurl = this.gameUrls[l];
let lt = await loadImageByUrl(lurl);
// console.log(lt);
if(lt){
lt = lt as engine.Texture
}else{
lt = null;
}
this.onegamePics.push(lt);
if(this.onegamePics.length==1){//第一张图加载完毕,自动填充
this.startfirst();
}
}
this.removeSelectImg();
}
removeSelectImg(){
if(this.selectimg3){
this.blockcont.removeChild(this.selectimg3);
}
if(this.selectimg4){
this.blockcont.removeChild(this.selectimg4);
}
}
removeDiPics(){
let nume = this.dicont.children.length;
for(let i=nume-1;i>=0;i--){
let ichild = this.dicont.getChildAt(i) as engine.Container;
if(ichild){
ichild.removeEventListener(engine.MouseEvent.MOUSE_DOWN,
this.touchPic,this);
this.dicont.removeChild(ichild);
Tool.repushToPool(ichild);
}
}
}
async startfirst(){
// this.dicont.removeChildren();
this.removeDiPics();
this.movesteps = 0;
this.startime = Date.now();
this.removeSelectImg();
let actidx = 0;
this.gametime = this.gameTimes[actidx];
this.showtime = this.gameTimes[actidx];
this.passtime = 0;
engine.globalEvent.dispatchEvent("pictures-time-update",{
time:this.showtime,
});
engine.globalEvent.dispatchEvent("pictures-time-passtime",{
passtime:this.passtime
});
// console.log("start-----------------",actidx);
this.rows = 3;
this.cols = 3;
this.nselectimg = null;
if(this.rows==3){
this.nselectimg = this.selectimg3;
}
if(this.rows==4){
this.nselectimg = this.selectimg4;
}
this.selectImgArr = new Array();
this.sucposData = {};
let tex:any = this.onegamePics[actidx];
let type1 = 1;
if(!tex){
tex = this.gameUrls[actidx];
type1 = 3;
}
// type1 = 3;
let result = await qietu(tex,type1,this.rows,this.cols,this.dicont);
let res = result.res;
if(res){
let picarr = result.picarr;
let mwid = result.mwid;
let mhei = result.mhei;
let picnames = result.picnames;
this.mwid = mwid;
this.mhei = mhei;
this.picarr = picarr;
this.picnames = picnames;
let gap = 2;
for(let r=0;r<this.rows;r++){
for(let c=0;c<this.cols;c++){
let ipicx = mwid*c+gap;
let ipicy = mhei*r+gap;
let npicname = "pic_"+c+"_"+r;
let ipic = picarr[npicname];
this.dicont.addChild(ipic);
ipic.x = ipicx;
ipic.y = ipicy;
}
}
//框线
this.lineShape.clear();
this.lineShape.beginStroke(0x0069df,4,engine.LINE_CAP.BUTT,engine.LINE_JOIN.BEVEL,100);
this.lineShape.moveTo(0+gap,0+gap);
this.lineShape.lineTo(mhei*this.cols+gap,0+gap);
this.lineShape.lineTo(mhei*this.cols+gap,mwid*this.rows+gap);
this.lineShape.lineTo(0+gap,mwid*this.rows+gap);
this.lineShape.lineTo(0+gap,0+gap);
for(let rl=1;rl<this.rows;rl++){
this.lineShape.moveTo(0+gap,rl*mhei+gap);
this.lineShape.lineTo(mwid*this.cols+gap,rl*mhei+gap);
}
for(let cl=1;cl<this.cols;cl++){
this.lineShape.moveTo(cl*mwid+gap,0+gap);
this.lineShape.lineTo(cl*mwid+gap,this.rows*mhei+gap);
}
this.lineShape.endStroke();
engine.globalEvent.dispatchEvent("pictures-load-complete");
this.ticker&&clearInterval(this.ticker);
this.ticker = setInterval(this.update, 10);
}else{
console.error("图片处理失败");
}
}
async start() {
// this.dicont.removeChildren();
this.removeDiPics();
this.movesteps = 0;
this.startime = Date.now();
this.removeSelectImg();
let actidx = props.actidx;
this.gametime = this.gameTimes[actidx];
this.showtime = this.gameTimes[actidx];
this.passtime = 0;
engine.globalEvent.dispatchEvent("pictures-time-update",{
time:this.showtime,
});
engine.globalEvent.dispatchEvent("pictures-time-passtime",{
passtime:this.passtime
});
this.rows = props.rows;
this.cols = props.cols;
this.nselectimg = null;
if(this.rows==3){
this.nselectimg = this.selectimg3;
}
if(this.rows==4){
this.nselectimg = this.selectimg4;
}
this.selectImgArr = new Array();
this.sucposData = {};
let tex:any = this.onegamePics[actidx];
let type1 = 1;
if(!tex){
tex = this.gameUrls[actidx];
type1 = 3;
}
let result = await qietu(tex,type1,this.rows,this.cols,this.dicont);
let res = result.res;
if(res){
let picarr = result.picarr;
let mwid = result.mwid;
let mhei = result.mhei;
let picnames = result.picnames;
this.mwid = mwid;
this.mhei = mhei;
this.picarr = picarr;
this.picnames = picnames;
let gap = 2;
for(let r=0;r<this.rows;r++){
for(let c=0;c<this.cols;c++){
let ipicx = mwid*c+gap;
let ipicy = mhei*r+gap;
let npicname = "pic_"+c+"_"+r;
// this.sucposData[npicname] = r+"_"+c;
// let selidx = Math.floor(Math.random()*picnames.length);
// let ipicname:string = picnames[selidx];
// if(r==c&&r!=this.rows-1){
// while(ipicname==npicname){
// selidx = Math.floor(Math.random()*picnames.length);
// ipicname = picnames[selidx];
// }
// }
let ipic = picarr[npicname];
// picnames.splice(selidx,1);
this.dicont.addChild(ipic);
ipic.x = ipicx;
ipic.y = ipicy;
// ipic["postr"] = r+"_"+c;
// ipic.addEventListener(engine.MouseEvent.MOUSE_DOWN,
// this.touchPic,this);
}
}
//框线
this.lineShape.clear();
this.lineShape.beginStroke(0x0069df,4,engine.LINE_CAP.BUTT,engine.LINE_JOIN.BEVEL,100);
this.lineShape.moveTo(0+gap,0+gap);
this.lineShape.lineTo(mhei*this.cols+gap,0+gap);
this.lineShape.lineTo(mhei*this.cols+gap,mwid*this.rows+gap);
this.lineShape.lineTo(0+gap,mwid*this.rows+gap);
this.lineShape.lineTo(0+gap,0+gap);
for(let rl=1;rl<this.rows;rl++){
this.lineShape.moveTo(0+gap,rl*mhei+gap);
this.lineShape.lineTo(mwid*this.cols+gap,rl*mhei+gap);
}
for(let cl=1;cl<this.cols;cl++){
this.lineShape.moveTo(cl*mwid+gap,0+gap);
this.lineShape.lineTo(cl*mwid+gap,this.rows*mhei+gap);
}
this.lineShape.endStroke();
this.ticker&&clearInterval(this.ticker);
this.ticker = setInterval(this.update, 10);
}else{
console.error("图片处理失败");
}
}
luanxu(){
let gap = 2;
for(let r=0;r<this.rows;r++){
for(let c=0;c<this.cols;c++){
let ipicx = this.mwid*c+gap;
let ipicy = this.mhei*r+gap;
let npicname = "pic_"+c+"_"+r;
this.sucposData[npicname] = r+"_"+c;
let selidx = Math.floor(Math.random()*this.picnames.length);
let ipicname:string = this.picnames[selidx];
if(r==c&&r!=this.rows-1){
while(ipicname==npicname){
selidx = Math.floor(Math.random()*this.picnames.length);
ipicname = this.picnames[selidx];
}
}
let ipic = this.picarr[ipicname];
this.picnames.splice(selidx,1);
ipic.x = ipicx;
ipic.y = ipicy;
ipic["postr"] = r+"_"+c;
ipic.addEventListener(engine.MouseEvent.MOUSE_DOWN,
this.touchPic,this);
}
}
}
pause(){
this.ingame = false;
// console.error("拼图暂停");
}
resume(){
this.lastframetime = Date.now();
this.ingame = true;
// console.error("拼图继续");
}
update() {
let ntime = Date.now();
if(!this.lastframetime){
this.lastframetime = ntime;
return;
}
if(this.ingame){
let passtime = (ntime - this.lastframetime)/1000;
this.passtime += passtime;
engine.globalEvent.dispatchEvent("pictures-time-passtime",{
passtime:this.passtime
});
let showtime1 = Math.round(this.gametime - this.passtime);
// console.log(passtime,this.passtime,this.gametime,this.showtime);
if(this.showtime!=showtime1){
this.showtime = showtime1;
if(this.showtime<=0){
this.showtime = 0;
this.gameover(2);
}
// console.log("倒计时",this.showtime);
engine.globalEvent.dispatchEvent("pictures-time-update",{
time:this.showtime
});
}
}
this.lastframetime = ntime;
}
touchPic(e:engine.MouseEvent){
if(!this.ingame){
return;
}
// console.log(e.target.name);
let selectname = e.target.name;
let spx = e.target.x;
let spy = e.target.y;
let gap = 2;
if(this.selectImgArr.length==0){
if(this.nselectimg){
this.blockcont.addChild(this.nselectimg);
this.nselectimg.x = spx-gap;
this.nselectimg.y = spy-gap;
}
this.selectImgArr.push(selectname);
}else if(this.selectImgArr.length==1){
if(selectname==this.selectImgArr[0]){
if(this.nselectimg){
this.blockcont.removeChild(this.nselectimg);
}
this.selectImgArr = new Array();
return;
}else{
this.selectImgArr.push(selectname);
this.changeImgPos();
}
}
}
changeImgPos(){
let img1name = this.selectImgArr[0];
let img2name = this.selectImgArr[1];
let img1 = this.dicont.getChildByName(img1name);
let img2 = this.dicont.getChildByName(img2name);
let imgpos1x = img1.x;
let imgpos1y = img1.y;
let imgpos2x = img2.x;
let imgpos2y = img2.y;
let imgpostr1 = img1.postr;
let imgpostr2 = img2.postr;
img1.x = imgpos2x;
img1.y = imgpos2y;
img1.postr = imgpostr2;
img2.x = imgpos1x;
img2.y = imgpos1y;
img2.postr = imgpostr1;
this.selectImgArr = new Array();
this.movesteps += 1;
if(this.nselectimg){
this.blockcont.removeChild(this.nselectimg);
}
let isuc = this.checkSuccess();
if(isuc){
// console.error("成功过关");
this.gameover(1);
}
}
checkSuccess(){
let isuc:boolean = true;
for(let r=0;r<this.rows;r++){
for(let c=0;c<this.cols;c++){
let ipicname = "pic_"+c+"_"+r;
let npicstr = r+"_"+c;
let ipic = this.dicont.getChildByName(ipicname);
let ipostr = ipic.postr;
if(npicstr!=ipostr){
isuc = false;
break;
}
}
}
return isuc;
}
/**
*
* @param reason 1成功,2失败
*/
private gameover(reason:number) {
this.ingame = false;
this.ticker&&clearInterval(this.ticker);
let ntime = Date.now();
let gametime = ntime - this.startime;
engine.globalEvent.dispatchEvent('pictures-game-over', {
reason:reason,
time: this.passtime,
number:this.movesteps,
gametime:gametime
});
}
}
/**
* 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();
//创建实例
this._gameView = new GameView();
this.addChild(this._gameView);
engine.globalEvent.addEventListener('pictures-initgame', this.initgame, this);
engine.globalEvent.addEventListener('pictures-start', this.start, this);
engine.globalEvent.addEventListener('pictures-luanxu', this.luanxu, this);
engine.globalEvent.addEventListener('pictures-pause', this.pause, this);
engine.globalEvent.addEventListener('pictures-resume', this.resume, this);
}
initgame(event: engine.Event) {
injectProps(event.data);
// this._status = 1;
this._gameView.initgame();
}
start(event: engine.Event) {
injectProps(event.data);
// this._status = 1;
this._gameView.start();
}
luanxu(){
this._gameView.luanxu();
}
pause(event: engine.Event) {
this._gameView.pause();
}
resume(event:engine.Event){
this._gameView.resume();
}
}
export default class Tool{
static picPool:Array<engine.Container> = new Array();
static getOnePic(){
if(this.picPool.length>0){
return this.picPool.shift();
}else{
let ipic = new engine.Container();
let isprite = new engine.ScrollView();
isprite.name = "iscrollv";
let nsp = new engine.Sprite();
nsp.name = "isprite";
nsp.texture
isprite.addChild(nsp);
ipic.addChild(isprite);
isprite.mouseEnabled = false;
nsp.mouseEnabled = false;
return ipic;
}
}
static repushToPool(icont:engine.Container){
this.picPool.push(icont);
}
}
\ No newline at end of file
import { props } from "../props";
import { loadImageByUrl, getTextureByName ,getTexture} from "./utils";
import qietu from "./qietu";
import Tool from "./Tool";
const urls = [];
const picMap = {};
const posMap = {};
export default async(url:any,type1:number, rows:number, cols:number,parent:engine.Container) => {
try{
let t:engine.Texture;
if(type1==1){
t = url;
}else if(type1==2){
let t1 = await loadImageByUrl(url);// as engine.Texture;
if(t1){
t = t1 as engine.Texture;
}
}else if(type1==3){
t = await getTextureByName("testimg") as engine.Texture;
}
if(!t){
return qietu("testimg",3,rows,cols,parent);
}
let setimgwid = 612;
let mwid1 = setimgwid/rows;
let mhei1 = setimgwid/cols;
// let mwid = t.width;
// let mhei = t.height;
// if(mwid<10||mhei<10){
// await new Promise(res=>{
// setTimeout(function(){
// res();
// },200);
// })
// return qietu(t,1,rows,cols,parent);
// }
// if(mwid>mhei){
// if(mhei<setimgwid){
// mwid = mwid*setimgwid/mhei;
// mhei = setimgwid;
// }
// }else{
// if(mwid<setimgwid){
// mhei = mhei*setimgwid/mwid;
// mwid = setimgwid;
// }
// }
let picarr = {};
let picnames = [];
let chax;
let chay;
let startlix = 0;
let addlix = 1/rows;
let startliy = 0;
let addliy = 1/cols;
let twid1 = setimgwid;
let thei1 = setimgwid;
// if(mwid>mhei){
// chax = (mwid-mhei)/2;
// startlix = chax/mwid;
// addlix = (mhei/cols)/mwid;
// startliy = 0;
// addliy = 1/rows;
// twid1 = mwid*setimgwid/mhei;
// thei1 = setimgwid;
// }else{
// startlix = 0;
// addlix = 1/cols;
// chay = (mhei-mwid)/2;
// startliy = chay/mhei;
// addliy = (mwid/rows)/mhei;
// thei1 = mhei*setimgwid/mwid;
// twid1 = setimgwid;
// }
// console.log("切图准备",startlix,addlix,startliy,addliy,mwid,mhei);
// let txt1 = new engine.Label();
// txt1.fillColor = "red";
// txt1.size = 24;
// txt1.text = startlix.toFixed(2)+";"+addlix.toFixed(2)+";"+startliy.toFixed(2)+";"+addliy.toFixed(2)+";"+mwid.toFixed(2)+";"+mhei.toFixed(2)+";"
// parent.addChild(txt1);
// txt1.y = -100;
for(let r=0;r<rows;r++){
let startx = startlix+addlix*r;
let endx = startx + addlix;
for(let c=0;c<cols;c++){
let starty = startliy+addliy*c;
let endy = starty+addliy;
// let uvs = new Float32Array([
// starty,
// startx,
// endy,
// startx,
// endy,
// endx,
// starty,
// endx
// ])
//方案1
// let isprite = new engine.Sprite(t);
// isprite.uvs = uvs;
//方案2
let nsprite = Tool.getOnePic();
let isprite = nsprite.getChildByName("iscrollv");
let nsp = isprite.getChildByName("isprite");
nsp.texture = t;
nsp.width = twid1;
nsp.height = thei1;
// let nsprite = new engine.Container();
// let isprite = new engine.ScrollView();
// let nsp = new engine.Sprite(t);
// isprite.addChild(nsp);
// nsp.width = twid1;
// nsp.height = thei1;
// isprite.mouseEnabled = false;
// isprite.mouseChildren = false;
nsp.x = -starty*twid1;
nsp.y = -startx*thei1;
isprite.width = mwid1;
isprite.height = mhei1;
// nsprite.addChild(isprite);
nsprite.width = mwid1;
nsprite.height = mhei1;
let ispritename = "pic_"+c+"_"+r;
nsprite.name = ispritename;
picarr[ispritename] = nsprite;
picnames.push(ispritename);
}
}
return {
res:true,
picarr:picarr,
mwid:mwid1,
mhei:mhei1,
picnames:picnames
};
}catch(e){
//获取那图失败
// return {
// res:false
// };
await new Promise(res=>{
setTimeout(function(){
res();
},200);
})
return qietu("testimg",3,rows,cols,parent);
}
};
/**
* 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;
}
export async function loadImageByUrl(url){
// console.log('loadImageByUrl----------:',url);
try{
// console.log("尝试加载44");
return new Promise((resolve) => {
let t1 = setTimeout(()=>{
return resolve(null);
},2000);
if (engine.TextureCache[url]) {
clearTimeout(t1);
resolve(engine.TextureCache[url])
} else {
var t = engine.Texture.from(url);
t.addEventListener("loaded", () => { clearTimeout(t1);resolve(t) });
}
})
}catch(e){
return null;
}
}
\ 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 = 'rbcxiaoxiaole';
(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('game-init',{
time:100000,
level:1,
mode:"day"
});
}, 500);
// setTimeout(() => {
// engine.globalEvent.dispatchEvent('game-newuserguide');
// }, 700);
// setTimeout(() => {
// engine.globalEvent.dispatchEvent('game-start');
// }, 700);
});
}
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 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 = [
];
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.rbcxiaoxiaole = 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(engine.getAssetByName(name).uuid);
}
function playSound(name) {
engine.playSound(engine.getAssetByName(name).uuid, { keep: true });
}
function createSvga(name, anchorName) {
var inst = new svga.Svga();
inst.source = 'asset://' + engine.getAssetByName(name).uuid;
return inst;
}
//# sourceMappingURL=utils.js.map
var Element = (function (_super) {
tslib.__extends(Element, _super);
function Element() {
var _this = _super.call(this) || this;
_this.width = MapData.itemsize;
_this.height = MapData.itemsize;
_this.anchorX = MapData.itemsize / 2;
_this.eimage = new engine.Image();
_this.addChild(_this.eimage);
_this.touch = true;
_this.addEventListener(engine.MouseEvent.MOUSE_DOWN, _this.selectele, _this);
_this.addEventListener(engine.MouseEvent.MOUSE_MOVE, _this.changemove, _this);
return _this;
}
Object.defineProperty(Element.prototype, "touch", {
set: function (touch) {
this.mouseEnabled = touch;
this.mouseChildren = touch;
},
enumerable: true,
configurable: true
});
Element.prototype.init = function (type) {
this.anchorY = MapData.itemsize;
this.scaleX = 1;
this.scaleY = 1;
this.alpha = 1;
this.type = type;
var ename = MapData.getEtypeImgName(type);
this.eimage.texture = MapData.getEtypeImgTex(type);
var imgwid = this.eimage.texture.width;
var imghei = this.eimage.texture.height;
this.eimage.x = (this.width - imgwid) / 2;
this.eimage.y = (this.height - imghei) / 2;
};
Element.prototype.setrc = function (r, c) {
this.inrow = r;
this.incol = c;
};
Element.prototype.selectele = function (e) {
engine.globalEvent.dispatchEvent(GameEvent.SelectEle, {
r: this.inrow,
c: this.incol,
type: "mouse_down"
});
};
Element.prototype.changemove = function (e) {
engine.globalEvent.dispatchEvent(GameEvent.SelectEle, {
r: this.inrow,
c: this.incol,
type: "mouse_move"
});
};
Object.defineProperty(Element.prototype, "factor", {
get: function () {
return 0;
},
set: function (value) {
this.x = (1 - value) * (1 - value) * this.p1x + 2 * value * (1 - value) * this.c1x + value * value * this.p2x;
this.y = (1 - value) * (1 - value) * this.p1y + 2 * value * (1 - value) * this.c1y + value * value * this.p2y;
var mscale = (1 - value) * (1 - value) * 1 + 2 * value * (1 - value) * 0.6 + value * value * 0.35;
this.scaleX = mscale;
this.scaleY = mscale;
},
enumerable: true,
configurable: true
});
Element.prototype.flyToHome = function (tx, ty, time) {
var _this = this;
this.p1x = this.x;
this.p1y = this.y + 20;
this.c1x = (this.p1x - tx) / 4 + tx;
this.c1y = ty;
this.p2x = tx;
this.p2y = ty;
engine.Tween.removeTweens(this);
engine.Tween.get(this).to({
scaleX: 1.1,
scaleY: 1.1
}, 200)
.to({
scaleX: 1.1,
scaleY: 0.88
}, 100)
.to({
scaleX: 0.98,
scaleY: 0.98,
y: this.y + 20
}, 100)
.call(function () {
_this.factor = 0;
engine.Tween.get(_this).to({
factor: 1
}, 450)
.call(function () {
var nodeparent = _this.parent;
nodeparent && nodeparent.removeChild(_this);
MapData.recoverEle(_this, _this.type);
});
});
};
Element.prototype.changePos = function (tpos) {
var _this = this;
var nx = this.x;
var ny = this.y;
var tx = tpos[0];
var ty = tpos[1];
var dis = MapData.getDistance([nx, ny], tpos);
var time = Math.ceil(dis / MapData.anispeed * 1000);
engine.Tween.removeTweens(this);
var pro = new Promise(function (res) {
engine.Tween.get(_this, { loop: false }).to({
x: tx,
y: ty
}, time)
.call(function () {
res();
});
});
return pro;
};
return Element;
}(engine.Container));
//# sourceMappingURL=Element.js.map
var ElementType;
(function (ElementType) {
ElementType[ElementType["gdog"] = 1] = "gdog";
ElementType[ElementType["pbird"] = 2] = "pbird";
ElementType[ElementType["hniu"] = 3] = "hniu";
ElementType[ElementType["bribbit"] = 4] = "bribbit";
ElementType[ElementType["rpig"] = 5] = "rpig";
})(ElementType || (ElementType = {}));
var GameEvent;
(function (GameEvent) {
GameEvent["SelectEle"] = "SelectEle";
})(GameEvent || (GameEvent = {}));
var MapData = (function () {
function MapData() {
}
MapData.getRy = function (r) {
return this.paddingh + r * (this.itemsize + this.paddinghi);
};
MapData.getCx = function (c) {
return this.paddingw + c * (this.itemsize + this.paddingwi);
};
MapData.getRCPos = function (r, c) {
var x = this.getCx(c);
var y = this.getRy(r);
return [x, y];
};
MapData.adaptElePos = function (pos, wid, hei) {
var x = pos[0] + (this.itemsize - wid) / 2;
var y = pos[1] + (this.itemsize - hei) / 2;
return [x, y];
};
MapData.getEtypeImgName = function (type) {
var ename;
switch (type) {
case ElementType.gdog:
ename = "狗";
break;
case ElementType.pbird:
ename = "鸟";
break;
case ElementType.hniu:
ename = "牛";
break;
case ElementType.bribbit:
ename = "兔子";
break;
case ElementType.rpig:
ename = "猪";
break;
default:
console.error("未定义元素类型");
break;
}
return ename;
};
MapData.getEtypeImgTex = function (type) {
var etex;
switch (type) {
case ElementType.gdog:
if (!this.gdotTex) {
this.gdotTex = getTextureByName("狗");
console.log("新素材加载---狗");
}
etex = this.gdotTex;
break;
case ElementType.pbird:
if (!this.pbirdTex) {
this.pbirdTex = getTextureByName("鸟");
console.log("新素材加载---鸟");
}
etex = this.pbirdTex;
break;
case ElementType.hniu:
if (!this.hniuTex) {
this.hniuTex = getTextureByName("牛");
console.log("新素材加载---牛");
}
etex = this.hniuTex;
break;
case ElementType.bribbit:
if (!this.bribbitTex) {
this.bribbitTex = getTextureByName("兔子");
console.log("新素材加载---兔子");
}
etex = this.bribbitTex;
break;
case ElementType.rpig:
if (!this.rpigTex) {
this.rpigTex = getTextureByName("猪");
console.log("新素材加载---猪");
}
etex = this.rpigTex;
break;
default:
console.error("未定义元素类型");
break;
}
return etex;
};
MapData.getRandEtype = function () {
var eletypeArr = [ElementType.gdog, ElementType.pbird, ElementType.hniu, ElementType.bribbit, ElementType.rpig];
var etype = eletypeArr[Math.floor(Math.random() * eletypeArr.length)];
return etype;
};
MapData.initPoolEle = function () {
this.gdotTex = getTextureByName("狗");
this.pbirdTex = getTextureByName("鸟");
this.hniuTex = getTextureByName("牛");
this.bribbitTex = getTextureByName("兔子");
this.rpigTex = getTextureByName("猪");
var eletypes = [ElementType.gdog, ElementType.pbird, ElementType.hniu, ElementType.bribbit, ElementType.rpig];
this.elePool["ele"] = new Array();
for (var i = 0; i < eletypes.length; i++) {
for (var a = 0; a < 5; a++) {
var iele = new Element();
this.elePool["ele"].push(iele);
}
}
this.elePool["score"] = new Array();
for (var t = 0; t < 8; t++) {
var itxt = new engine.Label();
itxt.size = 66;
itxt.width = 200;
itxt.height = 70;
itxt.textAlign = engine.TEXT_ALIGN.CENTER;
itxt.verticalAlign = engine.VERTICAL_ALIGN.MIDDLE;
itxt.anchorY = 35;
itxt.anchorX = 100;
itxt.bold = true;
this.elePool["score"].push(itxt);
}
};
MapData.getOneEle = function (type) {
var ele;
if (this.elePool["ele"]) {
if (this.elePool["ele"].length > 0) {
ele = this.elePool["ele"].shift();
}
}
else {
this.elePool["ele"] = new Array();
}
if (!ele) {
console.error("创建了新的了ele");
ele = new Element();
}
ele.name = "ele_" + this.eleidx;
this.eleidx += 1;
ele.init(type);
return ele;
};
MapData.getOneTxt = function () {
var itxt;
if (this.elePool["score"]) {
if (this.elePool["score"].length > 0) {
itxt = this.elePool["score"].shift();
}
}
else {
this.elePool["score"] = new Array();
}
if (!itxt) {
itxt = new engine.Label();
itxt.size = 66;
itxt.width = 200;
itxt.height = 70;
itxt.textAlign = engine.TEXT_ALIGN.CENTER;
itxt.verticalAlign = engine.VERTICAL_ALIGN.MIDDLE;
itxt.anchorY = 35;
itxt.anchorX = 100;
itxt.bold = true;
}
itxt.mouseEnabled = false;
return itxt;
};
MapData.recoverEle = function (ele, type) {
if (ele.eimage) {
ele.eimage.texture = null;
}
this.elePool["ele"].push(ele);
};
MapData.recoverTxt = function (txt) {
this.elePool["score"].push(txt);
};
MapData.getDistance = function (p1, p2) {
var p1x = p1[0];
var p1y = p1[1];
var p2x = p2[0];
var p2y = p2[1];
var dis = Math.sqrt(Math.pow(p1x - p2x, 2) + Math.pow(p1y - p2y, 2));
return dis;
};
MapData.itemsize = 116;
MapData.paddingw = 7;
MapData.paddingh = 7;
MapData.paddingwi = 4;
MapData.paddinghi = 2;
MapData.row = 5;
MapData.col = 5;
MapData.posData = {};
MapData.eleidx = 1;
MapData.elePool = {};
MapData.anispeed = 1000;
MapData.levelData = [
[
[2, 3, 4, 5, 4],
[4, 5, 3, 2, 4],
[2, 5, 3, 5, 1],
[3, 4, 4, 5, 3],
[1, 5, 2, 1, 4],
],
[
[5, 2, 1, 2, 1],
[3, 1, 4, 5, 4],
[2, 5, 3, 5, 1],
[5, 4, 1, 2, 3],
[4, 1, 3, 1, 2],
],
[
[2, 4, 1, 5, 2],
[2, 3, 4, 1, 3],
[4, 1, 3, 2, 3],
[3, 2, 1, 1, 4],
[1, 1, 3, 5, 4],
],
[
[3, 2, 1, 4, 5],
[2, 4, 1, 2, 3],
[2, 3, 2, 3, 3],
[4, 4, 5, 5, 4],
[3, 3, 1, 2, 4],
],
[
[4, 5, 1, 2, 4],
[3, 2, 3, 4, 2],
[1, 5, 2, 3, 5],
[4, 5, 5, 1, 3],
[1, 2, 3, 2, 4],
]
];
return MapData;
}());
//# sourceMappingURL=MapData.js.map
var boomAni = (function (_super) {
tslib.__extends(boomAni, _super);
function boomAni() {
var _this = _super.call(this) || this;
_this.once(engine.Event.ADDED_TO_STAGE, _this.setup, _this);
return _this;
}
boomAni.prototype.setup = function () {
this.boomimg = new engine.Image(getTextureByName("炸弹中心"));
this.boomimg.anchorX = 95;
this.boomimg.anchorY = 108;
this.boomimg.x = -32;
this.boomimg.y = -47;
var boomtex = getTextureByName("爆炸闪光");
var boomwid = boomtex.width;
var boomhei = boomtex.height;
this.hboomimg = new engine.Image();
this.vboomimg = new engine.Image();
this.hboomimg.texture = boomtex;
this.vboomimg.texture = boomtex;
this.hboomimg.width = boomwid;
this.hboomimg.height = boomhei;
this.hboomimg.anchorX = boomwid / 2;
this.hboomimg.anchorY = boomhei / 2;
this.hboomimg.y = -boomhei / 2 + 65;
this.hboomimg.x = -20;
this.vboomimg.width = boomwid;
this.vboomimg.height = boomhei;
this.vboomimg.anchorX = boomwid / 2;
this.vboomimg.anchorY = boomhei / 2;
this.vboomimg.rotation = 90;
this.vboomimg.y = -boomhei / 2 + 65;
this.vboomimg.x = -20;
this.hboomimg.scaleY = 0.1;
this.vboomimg.scaleY = 0.1;
this.addChild(this.boomimg);
this.addChild(this.hboomimg);
this.addChild(this.vboomimg);
this.mouseEnabled = false;
this.mouseChildren = false;
this.alpha = 0;
};
boomAni.prototype.playBoomAni = function () {
var _this = this;
this.alpha = 1;
this.boomimg.scaleX = 0;
this.boomimg.scaleY = 0;
engine.Tween.get(this.boomimg)
.to({
scaleX: 1.2,
scaleY: 1.2
}, 200, engine.Ease.quadIn);
this.hboomimg.scaleY = 0.1;
this.hboomimg.alpha = 1;
this.vboomimg.scaleY = 0.1;
this.vboomimg.alpha = 1;
engine.Tween.get(this.hboomimg)
.to({
scaleY: 1,
alpha: 0.8
}, 150, engine.Ease.quadIn)
.to({
alpha: 0
}, 50, engine.Ease.quadIn);
engine.Tween.get(this.vboomimg)
.to({
scaleY: 1,
alpha: 0.8
}, 150, engine.Ease.quadIn)
.to({
alpha: 0
}, 50, engine.Ease.quadIn)
.call(function () {
_this.alpha = 0;
});
};
return boomAni;
}(engine.Container));
//# sourceMappingURL=boomAni.js.map
var GameView = (function (_super) {
tslib.__extends(GameView, _super);
function GameView() {
var _this = _super.call(this) || this;
_this.lattices = {};
_this.eliminateArr = [];
_this.selectArr = [];
_this.conty = 0;
_this.homex = 562;
_this.homey = -20;
_this.ination = false;
_this.canation = true;
_this._gametime = 60;
_this._gamestat = 2;
_this.ingameover = false;
_this.ingame = true;
_this.level = 0;
_this.inrecord = false;
_this.requestGameOver = false;
_this.elitype = 1;
_this.inguide = false;
_this.diseffectArr = [];
_this.mute = 1;
_this._seq = 1;
_this.sptime = Date.now();
_this.useBoom = false;
_this._score = 0;
_this.inEliminate = false;
_this.newSelect = false;
_this.once(engine.Event.ADDED_TO_STAGE, _this.setup, _this);
return _this;
}
Object.defineProperty(GameView.prototype, "gamestat", {
get: function () {
return this._gamestat;
},
set: function (stat) {
this._gamestat = stat;
if (stat == 2) {
this.changeEnable(false);
}
},
enumerable: true,
configurable: true
});
Object.defineProperty(GameView.prototype, "seq", {
get: function () {
return this._seq;
},
set: function (num) {
this._seq = num;
},
enumerable: true,
configurable: true
});
GameView.prototype.setup = function () {
console.log("setup----game");
MapData.initPoolEle();
this.selectimg = new engine.Image(getTextureByName("选中框"));
this.selectimg.mouseEnabled = false;
this.selectw = this.selectimg.texture.width;
this.selecth = this.selectimg.texture.height;
this.selectimg.anchorX = this.selectw / 2;
this.selectimg.anchorY = this.selecth / 2;
this.jiantou1 = new engine.Image(getTextureByName("交换箭头"));
this.jiantou2 = new engine.Image(getTextureByName("交换箭头"));
this.jiantou1.mouseEnabled = false;
this.jiantou2.mouseEnabled = false;
var jiantwid = 31;
var jianthei = 24;
this.jiantou1.anchorX = jiantwid / 2;
this.jiantou1.anchorY = jianthei / 2;
this.jiantou2.anchorX = jiantwid / 2;
this.jiantou2.anchorY = jianthei / 2;
this.jiantoucont = new engine.Container();
this.jiantoucont.width = MapData.itemsize;
this.jiantoucont.height = MapData.itemsize;
this.jtsx1 = MapData.itemsize / 2 - jiantwid / 2;
this.jtsx2 = MapData.itemsize / 2 - jiantwid / 2;
this.jtsy1 = MapData.itemsize / 2 - jianthei;
this.jtsy2 = MapData.itemsize / 2;
this.jtex1 = this.jtsx1 - 10;
this.jtex2 = this.jtsx2 + 10;
this.jtey1 = this.jtsy1;
this.jtey2 = this.jtsy2;
this.jiantou1.x = this.jtsx1;
this.jiantou2.rotation = 180;
this.jiantou2.x = this.jtsx2;
this.jiantou1.y = this.jtsy1;
this.jiantou2.y = this.jtsy2;
this.jiantoucont.addChild(this.jiantou1);
this.jiantoucont.addChild(this.jiantou2);
var row = MapData.row;
var col = MapData.col;
this.shoueffect = createSvga("手指动效");
this.container = new engine.Container();
this.addChild(this.container);
this.container.y = this.conty;
var maskimg = new engine.Graphics();
this.container.addChild(maskimg);
this.container.mask = maskimg;
maskimg.moveTo(0, 0);
maskimg.beginFill(0);
maskimg.lineTo(681, 0);
maskimg.lineTo(681, 679);
maskimg.lineTo(0, 679);
maskimg.lineTo(0, 0);
maskimg.endFill();
this.anicontainer = new engine.Container();
this.addChild(this.anicontainer);
this.anicontainer.mouseEnabled = false;
this.anicontainer.mouseChildren = false;
this.txtcontainer = new engine.Container();
this.addChild(this.txtcontainer);
var map = new engine.Image(getTextureByName("底图"));
this.container.addChild(map);
for (var r = 0; r < row; r++) {
for (var c = 0; c < col; c++) {
var rcpos = MapData.getRCPos(r, c);
MapData.posData[r + "_" + c] = rcpos;
}
}
this.tanix = this.homex + 30;
this.taniy = this.homey;
engine.globalEvent.addEventListener(GameEvent.SelectEle, this.selectele, this);
this.removeEventListener(engine.Event.ADDED_TO_STAGE, this.setup, this);
this.lastframeTime = Date.now();
this.lastatime = Date.now();
this.addEventListener(engine.Event.ENTER_FRAME, this.onUpdate, this);
this.guideCont = new engine.Container();
this.addChild(this.guideCont);
this.guideDraw = new engine.Shape();
this.guideCont.addChild(this.guideDraw);
this.guideCont.visible = false;
this.guideCont.mouseEnabled = false;
this.guideCont.addChild(this.shoueffect);
this.shoueffect.mouseEnabled = false;
this.shoueffect.mouseChildren = false;
this.shoueffect.visible = false;
this.setGuidePath();
this.boomani = new boomAni();
this.anicontainer.addChild(this.boomani);
};
GameView.prototype.changeAni = function () {
this.changeHomeShow("night");
};
GameView.prototype.playComp = function () {
};
GameView.prototype.init = function (time, level, mode, mute) {
if (mute === void 0) { mute = 1; }
this.score = 0;
this.gametime = time;
this.seq = 1;
this.level = level;
this.ingameover = false;
this.mute = mute;
this.changeHomeShow(mode);
this.initContainer();
this.sptime = Date.now();
};
Object.defineProperty(GameView.prototype, "score", {
get: function () {
return this._score;
},
set: function (num) {
this._score = num;
engine.globalEvent.dispatchEvent('game-score-update', { score: this._score });
},
enumerable: true,
configurable: true
});
Object.defineProperty(GameView.prototype, "gametime", {
get: function () {
return this._gametime;
},
set: function (time) {
var lshowtime = Math.round(this._gametime);
var nshowtime = Math.round(time);
if (lshowtime != nshowtime) {
if (this.gamestat == 1 && nshowtime < 1) {
this.gameOver();
}
if (nshowtime < 0) {
nshowtime = 0;
}
engine.globalEvent.dispatchEvent('game-time-update', { time: nshowtime });
}
if (time < 0) {
time = 0;
}
this._gametime = time;
},
enumerable: true,
configurable: true
});
GameView.prototype.gameOver = function () {
this.gamestat = 2;
this.unShowEleAttion();
this.anicontainer.removeChild(this.selectimg);
this.ingameover = true;
console.log("倒计时结束1=============", this.ingameover, this.inEliminate, this.inrecord);
this.checkGameOver("time-over");
};
GameView.prototype.checkGameOver = function (type) {
if (this.ingameover) {
console.log("倒计时已结束2==========", this.inEliminate, this.inrecord, type);
}
if (this.ingameover && !this.inEliminate && !this.inrecord && !this.requestGameOver) {
this.requestGameOver = true;
this.unShowEleAttion();
this.anicontainer.removeChild(this.jiantoucont);
engine.globalEvent.dispatchEvent("game-over", {
score: this.score
});
}
};
GameView.prototype.reset = function (time, level, mode) {
return tslib.__awaiter(this, void 0, void 0, function () {
return tslib.__generator(this, function (_a) {
this.anicontainer.removeChild(this.selectimg);
this.gamestat = 1;
this.selectArr = new Array();
this.gametime = time;
this.level = level;
this.ingameover = false;
this.seq = 1;
this.changeHomeShow(mode);
this.changeEnable(false);
this.fall();
return [2];
});
});
};
GameView.prototype.start = function () {
console.log("game-start");
this.gamestat = 1;
this.requestGameOver = false;
this.selectArr = new Array();
this.changeEnable(true);
};
GameView.prototype.pause = function () {
this.ingame = false;
this.unShowEleAttion();
};
GameView.prototype.resume = function () {
this.lastframeTime = Date.now();
this.ingame = true;
};
GameView.prototype.onUpdate = function () {
var ntime = Date.now();
if (this.gamestat == 1 && this.ingame && !this.inguide && !this.requestGameOver) {
var passtime = ntime - this.lastframeTime;
if (ntime - this.lastatime >= 5000 && !this.ination && this.canation && this.selectArr.length == 0) {
this.attionEliShow();
}
if (this.gametime && this.gametime > 0) {
var ngtime = this.gametime - (passtime / 1000);
this.gametime = ngtime;
}
}
this.lastframeTime = ntime;
};
GameView.prototype.initContainer = function () {
if (this.lattices) {
for (var key in this.lattices) {
var rcname = this.lattices[key];
var rcele = this.container.getChildByName(rcname);
if (rcele) {
var rcetype = rcele.type;
this.container.removeChild(rcele);
this.lattices[key] = "empty";
MapData.recoverEle(rcele, rcetype);
}
}
}
else {
this.lattices = {};
}
var testdata = MapData.levelData[this.level - 1];
this.levelData = testdata;
for (var r = 0; r < testdata.length; r++) {
var rdata = testdata[r];
for (var c = 0; c < rdata.length; c++) {
var rctype = rdata[c];
var rcele = MapData.getOneEle(rctype);
var rcpos = MapData.getRCPos(r, c);
this.container.addChild(rcele);
rcele.x = rcpos[0];
rcele.y = rcpos[1];
var rcidx = r + "_" + c;
this.lattices[rcidx] = rcele.name;
this.setLatticeEleRc(rcidx);
}
}
this.checkInit();
};
GameView.prototype.checkInit = function () {
this.checkEliminate();
if (this.eliminateArr.length > 0) {
return this.eliminate();
}
else {
this.selectArr = new Array();
var isdiedata = this.attionEliminate();
if (isdiedata && isdiedata.length == 3) {
this.changeEnable(true);
}
else {
this.solveDieMap();
}
}
};
GameView.prototype.setLatticeEleRc = function (rcidx) {
var rename = this.lattices[rcidx];
var rcnode = this.container.getChildByName(rename);
if (rcnode) {
var er = Number(rcidx.split("_")[0]);
var ec = Number(rcidx.split("_")[1]);
rcnode.setrc(er, ec);
}
};
GameView.prototype.unShowEleAttion = function () {
if (this.ination) {
this.ination = false;
this.lastatime = Date.now();
var arrcidx1 = this.attiondata[0];
var arrcidx2 = this.attiondata[1];
var atname1 = this.lattices[arrcidx1];
var atname2 = this.lattices[arrcidx2];
var atnode1 = this.container.getChildByName(atname1);
var atnode2 = this.container.getChildByName(atname2);
var aboutnames = this.attiondata[2];
if (!atnode1 || !atnode2) {
this.attiondata = new Array();
return;
}
var atpos1 = MapData.getRCPos(arrcidx1.split("_")[0], arrcidx1.split("_")[1]);
var atpos2 = MapData.getRCPos(arrcidx2.split("_")[0], arrcidx2.split("_")[1]);
engine.Tween.removeTweens(atnode1);
engine.Tween.removeTweens(atnode2);
atnode1.x = atpos1[0];
atnode1.y = atpos1[1];
atnode2.x = atpos2[0];
atnode2.y = atpos2[1];
for (var i = 0; i < aboutnames.length; i++) {
var ircidx = aboutnames[i];
var iname1 = this.lattices[ircidx];
var inode1 = this.container.getChildByName(iname1);
if (inode1) {
engine.Tween.removeTweens(inode1);
var ipos1 = MapData.getRCPos(ircidx.split("_")[0], ircidx.split("_")[1]);
inode1.x = ipos1[0];
inode1.y = ipos1[1];
}
}
this.anicontainer.removeChild(this.jiantoucont);
}
};
GameView.prototype.selectele = function (e) {
if (!this.ingame) {
return;
}
var data = e.data;
var sr = data.r;
var sc = data.c;
var type = data.type;
var sname = sr + "_" + sc;
if (this.useBoom) {
if (type == "mouse_down") {
this.changeEnable(false);
this.boomeEle(sr, sc);
}
return;
}
var lnewSelect = this.newSelect;
var newCanSel = false;
if (this.selectArr.length == 0) {
newCanSel = true;
}
else if (this.selectArr.length == 1) {
var nname = this.selectArr[0];
if (sname == nname) {
newCanSel = false;
}
else {
newCanSel = true;
}
}
if (type == "mouse_down") {
this.newSelect = true;
}
else if (type == "mouse_move") {
if (newCanSel) {
this.newSelect = false;
}
}
if ((lnewSelect || this.newSelect) && newCanSel) ;
else {
return;
}
this.unShowEleAttion();
if (this.selectArr.length == 0) {
this.sptime = Date.now();
this.seqscore = 0;
this.selectArr.push(sname);
}
else if (this.selectArr.length == 1) {
var aselect = this.selectArr[0];
var asr = aselect.split("_")[0];
var asc = aselect.split("_")[1];
if ((sr == asr && Math.abs(sc - asc) == 1) || (sc == asc && Math.abs(sr - asr) == 1)) {
this.selectArr.push(sname);
}
else {
if (sr == asr && sc == asc) {
this.selectArr = new Array();
this.anicontainer.removeChild(this.selectimg);
}
else {
this.selectArr[0] = sname;
}
}
}
if (this.selectArr.length == 1) {
this.setSelectShow();
}
else if (this.selectArr.length == 2) {
this.changeElePos();
}
};
GameView.prototype.setSelectShow = function () {
var rcname = this.selectArr[0];
var r = rcname.split("_")[0];
var c = rcname.split("_")[1];
var rcpos = MapData.getRCPos(r, c);
engine.Tween.removeTweens(this.selectimg);
this.anicontainer.addChild(this.selectimg);
this.selectimg.x = rcpos[0] - 3;
this.selectimg.y = rcpos[1] + this.conty - 3;
this.startTweenSelectImg();
};
GameView.prototype.startTweenSelectImg = function () {
this.selectimg.scaleX = 1;
this.selectimg.scaleY = 1;
engine.Tween.get(this.selectimg, { loop: true })
.to({
scaleX: 0.9,
scaleY: 0.9
}, 500)
.to({
scaleX: 1,
scaleY: 1
}, 500);
};
GameView.prototype.changeElePos = function () {
var _this = this;
this.anicontainer.removeChild(this.selectimg);
this.changeEnable(false);
var sname1 = this.selectArr[0];
var sname2 = this.selectArr[1];
var sename1 = this.lattices[sname1];
var sename2 = this.lattices[sname2];
this.lattices[sname1] = sename2;
this.lattices[sname2] = sename1;
this.setLatticeEleRc(sname1);
this.setLatticeEleRc(sname2);
this.checkEliminate();
var snode1 = this.container.getChildByName(sename1);
var snode2 = this.container.getChildByName(sename2);
if (!snode1 || !snode2) {
this.selectArr = new Array();
return;
}
var snode1x = snode1.x;
var snode1y = snode1.y;
var snode2x = snode2.x;
var snode2y = snode2.y;
var changetime = Math.ceil((MapData.itemsize / MapData.anispeed) * 2 * 1000);
engine.Tween.removeTweens(snode1);
engine.Tween.removeTweens(snode2);
if (this.eliminateArr.length > 0) {
if (this.inguide) {
this.shoueffect.stop(0);
this.shoueffect.visible = false;
this.inguide = false;
engine.Tween.removeTweens(this.guideCont);
engine.Tween.get(this.guideCont)
.to({
alpha: 0
}, 200)
.call(function () {
_this.guideCont.visible = false;
engine.globalEvent.dispatchEvent('game-guidecomplete', {});
});
}
this.inEliminate = true;
engine.Tween.get(snode1).to({
x: snode2x,
y: snode2y
}, changetime);
engine.Tween.get(snode2).to({
x: snode1x,
y: snode1y
}, changetime)
.call(function () {
_this.eliminate();
});
}
else {
engine.Tween.get(snode1).to({
x: snode2x,
y: snode2y
}, changetime)
.wait(100)
.to({
x: snode1x,
y: snode1y
}, changetime);
engine.Tween.get(snode2).to({
x: snode1x,
y: snode1y
}, changetime)
.wait(100)
.to({
x: snode2x,
y: snode2y
}, changetime)
.call(function () {
_this.lattices[sname1] = sename1;
_this.lattices[sname2] = sename2;
_this.setLatticeEleRc(sname1);
_this.setLatticeEleRc(sname2);
_this.selectArr = new Array();
_this.recordGame();
_this.changeEnable(true);
_this.checkGameOver("changeElePos");
});
}
};
GameView.prototype.eliminate = function () {
return tslib.__awaiter(this, void 0, void 0, function () {
var i, ielidata1, ielileng, addscore, j, ielidata, ielidxname, ielitype, ieliname, ielinode, ielix, ieliy, ietype;
return tslib.__generator(this, function (_a) {
switch (_a.label) {
case 0:
this.inEliminate = true;
this.playEffect("消除音效");
for (i = 0; i < this.eliminateArr.length; i++) {
ielidata1 = this.eliminateArr[i];
ielileng = ielidata1.length;
addscore = 0;
if (ielileng <= 3) {
addscore = props.threeEscore;
}
else if (ielileng == 4) {
addscore = props.fourEscore;
}
else {
addscore = props.moreEscore;
}
this.seqscore += addscore * ielileng;
for (j = 0; j < ielidata1.length; j++) {
ielidata = ielidata1[j];
ielidxname = ielidata.idxname;
ielitype = ielidata.type;
ieliname = this.lattices[ielidxname];
ielinode = this.container.getChildByName(ieliname);
if (!ielinode) {
continue;
}
ielix = ielinode.x;
ieliy = ielinode.y;
ietype = ielinode.type;
if (this.elitype == 1) {
this.lattices[ielidxname] = "empty";
this.addScoreAni(ielix, ieliy, ietype, addscore);
this.goDisplayAni1(ielinode, ietype, ielix, ieliy);
}
else {
this.container.removeChild(ielinode);
MapData.recoverEle(ielinode, ietype);
this.addScoreAni(ielix, ieliy, ietype, addscore);
this.lattices[ielidxname] = "empty";
this.goHomeAni(ielitype, ielix, ieliy);
}
}
}
return [4, new Promise(function (res) {
setTimeout(function () {
res();
}, 400);
})];
case 1:
_a.sent();
this.fall();
return [4, new Promise(function (res1) {
setTimeout(function () {
res1();
}, 500);
})];
case 2:
_a.sent();
return [2];
}
});
});
};
GameView.prototype.fall = function (type) {
if (type === void 0) { type = "normal"; }
return tslib.__awaiter(this, void 0, void 0, function () {
var fallData, fcutr, fc, r, c, idxname, elename, frcname, fetype, fele, cutr, fepos, fallPromise, _loop_1, this_1, f, isdiedata;
return tslib.__generator(this, function (_a) {
switch (_a.label) {
case 0:
fallData = new Array();
fcutr = new Array();
for (fc = 0; fc < MapData.col; fc++) {
fcutr.push(-1);
}
for (r = MapData.row - 1; r > -1; r--) {
for (c = MapData.col - 1; c > -1; c--) {
idxname = r + "_" + c;
elename = this.lattices[idxname];
if (elename == "empty") {
frcname = this.getFallRcEle(r, c);
if (!frcname) {
fetype = void 0;
if (type == "normal") {
fetype = MapData.getRandEtype();
}
else {
fetype = this.levelData[r][c];
}
fele = MapData.getOneEle(fetype);
cutr = fcutr[c];
fepos = MapData.getRCPos(cutr, c);
fcutr[c] = cutr - 1;
this.container.addChild(fele);
fele.x = fepos[0];
fele.y = fepos[1];
frcname = fele.name;
}
this.lattices[idxname] = frcname;
this.setLatticeEleRc(idxname);
fallData.push({
rcname: frcname,
trow: r,
tcol: c
});
}
}
}
fallPromise = new Array();
_loop_1 = function (f) {
var fdata = fallData[f];
var frcname = fdata.rcname;
var ftrow = fdata.trow;
var ftcol = fdata.tcol;
var ftpos = MapData.getRCPos(ftrow, ftcol);
var frcnode = this_1.container.getChildByName(frcname);
if (!frcnode) {
return "continue";
}
var nepos = [frcnode.x, frcnode.y];
var fdis = MapData.getDistance(ftpos, nepos);
var ftime = Math.ceil((fdis / MapData.anispeed) * 1000);
engine.Tween.removeTweens(frcnode);
var ifallpromise = new Promise(function (res) {
engine.Tween.get(frcnode)
.to({
x: ftpos[0],
y: ftpos[1]
}, ftime)
.to({
scaleY: 0.85
}, 80)
.to({
scaleY: 1
}, 80)
.call(function () {
res();
});
});
fallPromise.push(ifallpromise);
};
this_1 = this;
for (f = 0; f < fallData.length; f++) {
_loop_1(f);
}
return [4, Promise.all(fallPromise)];
case 1:
_a.sent();
if (type == "newlevel") {
this.sptime = Date.now();
}
this.checkEliminate();
if (this.eliminateArr.length > 0) {
return [2, this.eliminate()];
}
else {
this.selectArr = new Array();
isdiedata = this.attionEliminate();
if (isdiedata && isdiedata.length == 3) {
this.inEliminate = false;
if (type != "newlevel") {
this.recordGame();
}
this.changeEnable(true);
this.checkGameOver("fall");
}
else {
this.solveDieMap("fall");
}
}
return [2];
}
});
});
};
GameView.prototype.goDisplayAni1 = function (rcele, rcetype, rcelex, rceley) {
var _this = this;
rcele.touch = false;
engine.Tween.removeTweens(rcele);
rcele.x = rcelex;
rcele.y = rceley;
rcele.anchorY = MapData.itemsize / 2;
engine.Tween.get(rcele)
.to({
scaleX: 0,
scaleY: 0,
alpha: 0
}, 300)
.call(function () {
_this.container.removeChild(rcele);
MapData.recoverEle(rcele, rcetype);
});
var oneffect = this.getOneEffect();
oneffect.x = rcelex;
oneffect.y = rceley;
this.anicontainer.addChild(oneffect);
oneffect.play(1);
};
GameView.prototype.goDisplayAni = function (ielitype, ielix, ieliy) {
var _this = this;
var aniele = MapData.getOneEle(ielitype);
aniele.alpha = 0;
var anix = ielix;
var aniy = ieliy + this.conty;
this.anicontainer.addChild(aniele);
aniele.touch = false;
aniele.x = anix;
aniele.y = aniy;
aniele.alpha = 1;
aniele.anchorY = MapData.itemsize / 2;
engine.Tween.removeTweens(aniele);
engine.Tween.get(aniele)
.to({
scaleX: 0,
scaleY: 0,
alpha: 0
}, 300)
.call(function () {
_this.anicontainer.removeChild(aniele);
MapData.recoverEle(aniele, ielitype);
});
};
GameView.prototype.goHomeAni = function (ielitype, ielix, ieliy) {
var aniele = MapData.getOneEle(ielitype);
aniele.alpha = 0;
var anix = ielix;
var aniy = ieliy + this.conty;
this.anicontainer.addChild(aniele);
aniele.touch = false;
aniele.x = anix;
aniele.y = aniy;
aniele.alpha = 1;
var anidis = MapData.getDistance([this.tanix, this.taniy], [anix, aniy]);
var anitime = Math.ceil((anidis / MapData.anispeed) * 1000);
aniele.flyToHome(this.tanix, this.taniy, anitime);
};
GameView.prototype.changeEnable = function (v) {
var changeable = false;
if (this.gamestat == 1) {
changeable = true;
}
else {
if (!v) {
changeable = true;
}
}
if (changeable) {
for (var key in this.lattices) {
var kname = this.lattices[key];
var ele = this.container.getChildByName(kname);
if (ele) {
ele.touch = v;
}
}
engine.globalEvent.dispatchEvent('game-touch', {
cantouch: v
});
if (v) {
this.lastatime = Date.now();
this.ination = false;
}
}
this.canation = v;
};
GameView.prototype.attionEliShow = function () {
var attiondata = this.attionEliminate();
if (attiondata && attiondata.length == 3) {
this.ination = true;
this.attiondata = [attiondata[0], attiondata[1], attiondata[2]];
var atname1 = this.lattices[attiondata[0]];
var atname2 = this.lattices[attiondata[1]];
var aboutnames = attiondata[2];
var atnode1 = this.container.getChildByName(atname1);
var atnode2 = this.container.getChildByName(atname2);
if (!atnode1 || !atnode2) {
return;
}
var atx1 = atnode1.x;
var aty1 = atnode1.y;
var atx2 = atnode2.x;
var aty2 = atnode2.y;
var lerpnum = 0.1;
var atpos1 = [(atx2 - atx1) * lerpnum + atx1, (aty2 - aty1) * lerpnum + aty1];
engine.Tween.removeTweens(atnode1);
engine.Tween.removeTweens(atnode2);
engine.Tween.get(atnode1, {
loop: true
}).to({
x: atpos1[0],
y: atpos1[1]
}, 500)
.to({
x: atx1,
y: aty1
}, 500);
var jtx = (atx2 - atx1) * 0.5 + atx1;
var jty = (aty2 - aty1) * 0.5 + aty1 + this.conty;
var chax1 = atx1 - atpos1[0];
var chay1 = aty1 - atpos1[1];
var roa1 = 0;
var movex1 = 0;
var movey1 = 0;
if (Math.abs(chax1) > Math.abs(chay1)) {
jty += 25;
movex1 = chax1;
}
else {
jtx += MapData.itemsize;
roa1 = 90;
movey1 = chay1;
}
for (var i = 0; i < aboutnames.length; i++) {
var iname1 = this.lattices[aboutnames[i]];
var inode1 = this.container.getChildByName(iname1);
engine.Tween.removeTweens(inode1);
var iatx1 = inode1.x;
var iaty1 = inode1.y;
if (inode1) {
engine.Tween.get(inode1, { loop: true })
.to({
x: iatx1 + movex1,
y: iaty1 + movey1
}, 500)
.to({
x: iatx1,
y: iaty1
}, 500);
}
}
this.anicontainer.addChild(this.jiantoucont);
this.jiantoucont.x = jtx;
this.jiantoucont.y = jty;
this.jiantoucont.rotation = roa1;
this.startJtAni();
}
else {
this.solveDieMap();
}
};
GameView.prototype.startJtAni = function () {
engine.Tween.removeTweens(this.jiantou1);
engine.Tween.removeTweens(this.jiantou2);
this.jiantou1.x = this.jtex1;
this.jiantou1.y = this.jtey1;
this.jiantou2.x = this.jtex2;
this.jiantou2.y = this.jtey2;
this.jiantou1.alpha = 1;
this.jiantou2.alpha = 1;
engine.Tween.get(this.jiantou1, { loop: true })
.to({
x: this.jtsx1,
y: this.jtsy1,
alpha: 0
}, 500)
.to({
x: this.jtex1,
y: this.jtey1,
alpha: 1
}, 500);
engine.Tween.get(this.jiantou2, { loop: true })
.to({
x: this.jtsx2,
y: this.jtsy2,
alpha: 0
}, 500)
.to({
x: this.jtex2,
y: this.jtey2,
alpha: 1
}, 500);
};
GameView.prototype.solveDieMap = function (type) {
if (type === void 0) { type = "normal"; }
if (this.gamestat != 1) {
if (this.ingameover) {
this.inEliminate = false;
this.checkGameOver("changeToFuHuoPos222");
}
return;
}
this.changeEnable(false);
var elearr = new Array();
for (var key in this.lattices) {
var keyval = this.lattices[key];
elearr.push(keyval);
}
for (var key in this.lattices) {
var changeval = elearr.splice(Math.floor(Math.random() * elearr.length), 1)[0];
this.lattices[key] = changeval;
}
var isdiedata = this.attionEliminate();
if (isdiedata && isdiedata.length == 3) {
this.changeToFuHuoPos(type);
}
else {
return this.solveDieMap();
}
};
GameView.prototype.changeToFuHuoPos = function (type) {
return tslib.__awaiter(this, void 0, void 0, function () {
var prolist, key, keyval, keynode, keynodex, keynodey, tpos, ipro;
return tslib.__generator(this, function (_a) {
switch (_a.label) {
case 0:
prolist = new Array();
for (key in this.lattices) {
keyval = this.lattices[key];
keynode = this.container.getChildByName(keyval);
if (!keynode) {
continue;
}
keynodex = keynode.x;
keynodey = keynode.y;
tpos = MapData.getRCPos(key.split("_")[0], key.split("_")[1]);
ipro = keynode.changePos(tpos);
prolist.push(ipro);
this.setLatticeEleRc(key);
}
return [4, Promise.all(prolist)];
case 1:
_a.sent();
this.checkEliminate();
if (this.eliminateArr.length > 0) {
this.eliminate();
}
else {
if (type == "fall") {
this.recordGame();
}
this.changeEnable(true);
this.inEliminate = false;
this.checkGameOver("changeToFuHuoPos");
}
return [2];
}
});
});
};
GameView.prototype.recordcomp = function () {
this.inrecord = false;
this.checkGameOver("recordcomp");
};
GameView.prototype.recordGame = function () {
if (!this.requestGameOver) {
this.inrecord = true;
this.eptime = Date.now();
engine.globalEvent.dispatchEvent('game-record', {
score: this.seqscore,
seq: this.seq,
sptime: this.sptime,
eptime: this.eptime
});
this.seq += 1;
this.seqscore = 0;
this.sptime = Date.now();
}
};
GameView.prototype.attionEliminate = function () {
var attiondata;
for (var r = MapData.row - 1; r > -1; r--) {
if (attiondata && attiondata.length == 3) {
break;
}
for (var c = MapData.col - 1; c > -1; c--) {
var checktype = this.getEleTypeByRc(r, c);
var edatarow = this.getEliminateRow(r, c);
var edatacol = this.getEliminateCol(r, c);
if (edatarow.length > 2 || edatacol.length > 2) ;
if (edatarow.length == 2) {
var releidx1 = edatarow[0];
var releidx2 = edatarow[1];
var relerow1 = Number(releidx1.split("_")[0]);
var relerow2 = Number(releidx2.split("_")[0]);
var relecol = Number(releidx1.split("_")[1]);
var downrow = relerow1 + 1;
var uprow = relerow2 - 1;
var rightcol = relecol + 1;
var leftcol = relecol - 1;
var uprow1 = relerow2 - 2;
var downrow1 = relerow1 + 2;
if (downrow < MapData.row) {
if (rightcol < MapData.col) {
var nexttype = this.getEleTypeByRc(downrow, rightcol);
if (nexttype == checktype) {
attiondata = [downrow + "_" + rightcol, downrow + "_" + relecol, edatarow];
break;
}
}
if (leftcol > -1) {
var nexttype = this.getEleTypeByRc(downrow, leftcol);
if (nexttype == checktype) {
attiondata = [downrow + "_" + leftcol, downrow + "_" + relecol, edatarow];
break;
}
}
}
if (uprow > -1) {
if (rightcol < MapData.col) {
var nexttype = this.getEleTypeByRc(uprow, rightcol);
if (nexttype == checktype) {
attiondata = [uprow + "_" + rightcol, uprow + "_" + relecol, edatarow];
break;
}
}
if (leftcol > -1) {
var nexttype = this.getEleTypeByRc(uprow, leftcol);
if (nexttype == checktype) {
attiondata = [uprow + "_" + leftcol, uprow + "_" + relecol, edatarow];
break;
}
}
}
if (uprow1 > -1) {
var nexttype = this.getEleTypeByRc(uprow1, relecol);
if (nexttype == checktype) {
attiondata = [uprow1 + "_" + relecol, uprow + "_" + relecol, edatarow];
break;
}
}
if (downrow1 < MapData.row) {
var nexttype = this.getEleTypeByRc(downrow1, relecol);
if (nexttype == checktype) {
attiondata = [downrow1 + "_" + relecol, downrow + "_" + relecol, edatarow];
break;
}
}
}
if (edatacol.length == 2) {
var releidx1 = edatacol[0];
var releidx2 = edatacol[1];
var relerow = Number(releidx1.split("_")[0]);
var relecol1 = Number(releidx1.split("_")[1]);
var relecol2 = Number(releidx2.split("_")[1]);
var rightcol = relecol1 + 1;
var leftcol = relecol2 - 1;
var uprow = relerow - 1;
var downrow = relerow + 1;
var rightcol1 = relecol1 + 2;
var leftcol1 = relecol2 - 2;
if (leftcol > -1) {
if (uprow > -1) {
var nexttype = this.getEleTypeByRc(uprow, leftcol);
if (nexttype == checktype) {
attiondata = [uprow + "_" + leftcol, relerow + "_" + leftcol, edatacol];
break;
}
}
if (downrow < MapData.row) {
var nexttype = this.getEleTypeByRc(downrow, leftcol);
if (nexttype == checktype) {
attiondata = [downrow + "_" + leftcol, relerow + "_" + leftcol, edatacol];
break;
}
}
}
if (rightcol < MapData.col) {
if (uprow > -1) {
var nexttype = this.getEleTypeByRc(uprow, rightcol);
if (nexttype == checktype) {
attiondata = [uprow + "_" + rightcol, relerow + "_" + rightcol, edatacol];
break;
}
}
if (downrow < MapData.row) {
var nexttype = this.getEleTypeByRc(downrow, rightcol);
if (nexttype == checktype) {
attiondata = [downrow + "_" + rightcol, relerow + "_" + rightcol, edatacol];
break;
}
}
}
if (rightcol1 < MapData.col) {
var nexttype = this.getEleTypeByRc(relerow, rightcol1);
if (nexttype == checktype) {
attiondata = [relerow + "_" + rightcol1, relerow + "_" + rightcol, edatacol];
break;
}
}
if (leftcol1 > -1) {
var nexttype = this.getEleTypeByRc(relerow, leftcol1);
if (nexttype == checktype) {
attiondata = [relerow + "_" + leftcol1, relerow + "_" + leftcol, edatacol];
break;
}
}
}
var jianrow = this.getEliminateRowR(r, c);
if (jianrow.length == 2) {
var jianr = Number(jianrow[0].split("_")[0]) - 1;
var jianc = Number(jianrow[0].split("_")[1]);
var ljianc = jianc - 1;
if (ljianc > -1) {
var nexttype = this.getEleTypeByRc(jianr, ljianc);
if (nexttype == checktype) {
attiondata = [jianr + "_" + ljianc, jianr + "_" + jianc, jianrow];
break;
}
}
var rjianc = jianc + 1;
if (rjianc < MapData.col) {
var nexttype = this.getEleTypeByRc(jianr, rjianc);
if (nexttype == checktype) {
attiondata = [jianr + "_" + rjianc, jianr + "_" + jianc, jianrow];
break;
}
}
}
var jiancol = this.getEliminateRowC(r, c);
if (jiancol.length == 2) {
var jianr = Number(jiancol[0].split("_")[0]);
var jianc = Number(jianrow[0].split("_")[1]) - 1;
var ujianr = jianr - 1;
if (ujianr > -1) {
var nexttype = this.getEleTypeByRc(ujianr, jianc);
if (nexttype == checktype) {
attiondata = [ujianr + "_" + jianc, jianr + "_" + jianc, jiancol];
break;
}
}
var djianr = jianr + 1;
if (djianr < MapData.row) {
var nexttype = this.getEleTypeByRc(djianr, jianc);
if (nexttype == checktype) {
attiondata = [djianr + "_" + jianc, jianr + "_" + jianc, jiancol];
break;
}
}
}
}
}
return attiondata;
};
GameView.prototype.checkEliminate = function () {
this.eliminateArr = new Array();
for (var r = MapData.row - 1; r > -1; r--) {
for (var c = MapData.col - 1; c > -1; c--) {
var edata = this.getEliminate(r, c);
if (edata) {
var etype = edata.etype;
var earr = edata.arr;
this.checkAddEli(etype, earr);
}
}
}
};
GameView.prototype.getEliminateRowR = function (x, y) {
var checktype = this.getEleTypeByRc(x, y);
var jianrow = x - 2;
var relearr = new Array();
relearr.push(x + "_" + y);
if (jianrow > -1) {
var jiantype = this.getEleTypeByRc(jianrow, y);
if (jiantype == checktype) {
relearr.push(jianrow + "_" + y);
}
}
return relearr;
};
GameView.prototype.getEliminateRowC = function (x, y) {
var checktype = this.getEleTypeByRc(x, y);
var jiancol = y - 2;
var relearr = new Array();
relearr.push(x + "_" + y);
if (jiancol > -1) {
var jiantype = this.getEleTypeByRc(x, jiancol);
if (jiantype == checktype) {
relearr.push(x + "_" + jiancol);
}
}
return relearr;
};
GameView.prototype.getEliminateRow = function (x, y) {
var checktype = this.getEleTypeByRc(x, y);
var relearr = new Array();
relearr.push(x + "_" + y);
for (var r = x - 1; r > -1; r--) {
var reletype = this.getEleTypeByRc(r, y);
if (checktype == reletype) {
relearr.push(r + "_" + y);
}
else {
break;
}
}
return relearr;
};
GameView.prototype.getEliminateCol = function (x, y) {
var checktype = this.getEleTypeByRc(x, y);
var celearr = new Array();
celearr.push(x + "_" + y);
for (var c = y - 1; c > -1; c--) {
var celetype = this.getEleTypeByRc(x, c);
if (checktype == celetype) {
celearr.push(x + "_" + c);
}
else {
break;
}
}
return celearr;
};
GameView.prototype.getEliminate = function (x, y) {
var checktype = this.getEleTypeByRc(x, y);
var relearr = this.getEliminateRow(x, y);
var celearr = this.getEliminateCol(x, y);
var eliminatearr = new Array();
if (relearr.length >= 3) {
eliminatearr.push.apply(eliminatearr, relearr);
}
if (celearr.length >= 3) {
eliminatearr.push.apply(eliminatearr, celearr);
}
if (eliminatearr.length > 0) {
return {
etype: checktype,
arr: eliminatearr
};
}
else {
return false;
}
};
GameView.prototype.getEleTypeByRc = function (r, c) {
var rc = r + "_" + c;
var elename = this.lattices[rc];
var ele = this.container.getChildByName(elename);
if (ele) {
var eletype = ele.type;
return eletype;
}
};
GameView.prototype.checkAddEli = function (etype, earr) {
var addnew = true;
var inaidx;
for (var i1 = 0; i1 < this.eliminateArr.length; i1++) {
var i1data = this.eliminateArr[i1];
for (var i2 = 0; i2 < i1data.length; i2++) {
var i2data = i1data[i2];
var i2eliname = i2data.idxname;
var inidx = earr.indexOf(i2eliname);
if (inidx != -1) {
addnew = false;
break;
}
}
if (!addnew) {
inaidx = i1;
break;
}
}
if (addnew) {
var addarr = new Array();
for (var i1 = 0; i1 < earr.length; i1++) {
var i1name = earr[i1];
addarr.push({
idxname: i1name,
type: etype
});
}
this.eliminateArr.push(addarr);
}
else {
for (var i4 = 0; i4 < earr.length; i4++) {
var i4name = earr[i4];
var addele = true;
for (var i3 = 0; i3 < this.eliminateArr[inaidx].length; i3++) {
var i3data = this.eliminateArr[inaidx][i3];
var i3eliname = i3data.idxname;
if (i3eliname == i4name) {
addele = false;
break;
}
}
if (addele) {
this.eliminateArr[inaidx].push({
idxname: i4name,
type: etype
});
}
}
}
};
GameView.prototype.getFallRcEle = function (r, c) {
for (var fr = r - 1; fr > -1; fr--) {
var frc = fr + "_" + c;
var frcname = this.lattices[frc];
if (frcname != "empty") {
this.lattices[frc] = "empty";
return frcname;
}
}
return false;
};
GameView.prototype.addScoreAni = function (ielix, ieliy, ietype, addscore) {
var _this = this;
var anitxt = MapData.getOneTxt();
anitxt.alpha = 0;
var txtcolor = "#bd882f";
switch (ietype) {
case ElementType.gdog:
txtcolor = "#d3ff6d";
break;
case ElementType.pbird:
txtcolor = "#ff51d4";
break;
case ElementType.hniu:
txtcolor = "#ffab55";
break;
case ElementType.bribbit:
txtcolor = "#b3d4ff";
break;
case ElementType.rpig:
txtcolor = "#f2453b";
break;
default:
console.error("未定义类型,检查");
break;
}
anitxt.fillColor = txtcolor;
var anix = ielix + MapData.itemsize / 2 - 100;
var aniy = ieliy + this.conty + MapData.itemsize / 2 - 35;
anitxt.text = "+" + addscore;
this.txtcontainer.addChild(anitxt);
anitxt.x = anix;
anitxt.y = aniy;
anitxt.scaleX = 0;
anitxt.scaleY = 0;
anitxt.alpha = 1;
engine.Tween.get(anitxt, { loop: false }).set({
x: anix,
y: aniy,
scaleX: 0,
scaleY: 0
})
.to({
y: aniy - 50,
scaleX: 1,
scaleY: 1,
}, 300)
.to({
y: aniy - 120,
alpha: 0
}, 500)
.call(function () {
_this.txtcontainer.removeChild(anitxt);
_this.score += addscore;
MapData.recoverTxt(anitxt);
});
};
GameView.prototype.changeHomeShow = function (mode) {
};
GameView.prototype.boomeEle = function (row, col) {
this.playEffect("爆炸音效");
this.unShowEleAttion();
this.useBoom = false;
engine.globalEvent.dispatchEvent('game-useboomafter', {});
this.anicontainer.removeChild(this.selectimg);
this.selectArr = new Array();
this.eliminateArr = new Array();
for (var r = 0; r < MapData.row; r++) {
var irc = r + "_" + col;
var ielename = this.lattices[irc];
var iele = this.container.getChildByName(ielename);
if (iele) {
var eletype = iele.type;
this.eliminateArr.push([
{
idxname: irc,
type: eletype
}
]);
}
}
for (var c = 0; c < MapData.col; c++) {
if (c != col) {
var irc = row + "_" + c;
var ielename = this.lattices[irc];
var iele = this.container.getChildByName(ielename);
if (iele) {
var eletype = iele.type;
this.eliminateArr.push([
{
idxname: irc,
type: eletype
}
]);
}
}
}
this.boomani.x = MapData.getCx(col);
this.boomani.y = MapData.getRy(row);
this.boomani.playBoomAni();
this.eliminate();
};
GameView.prototype.setGuidePath = function () {
var path = [
[364, 7],
[364, 479],
[484, 479],
[484, 7],
];
this.guideDraw.clear();
this.guideDraw.beginFill(0x000000, 0.7);
this.guideDraw.moveTo(0, 0);
this.guideDraw.lineTo(609, 0);
this.guideDraw.lineTo(609, 607);
this.guideDraw.lineTo(0, 607);
this.guideDraw.lineTo(0, 0);
this.shoueffect.x = 409;
this.shoueffect.y = -40;
this.guideDraw.moveTo(path[0][0], path[0][1]);
for (var i = 1; i < path.length; i++) {
var idotx = path[i][0];
var idoty = path[i][1];
this.guideDraw.lineTo(idotx, idoty);
}
this.guideDraw.lineTo(path[0][0], path[0][1]);
this.guideDraw.endFill();
};
GameView.prototype.setGuideShow = function () {
this.inguide = true;
this.guideCont.visible = true;
this.guideCont.alpha = 0;
this.shoueffect.visible = true;
this.shoueffect.play(1);
var ableidx = ["0_3", "1_3"];
for (var key in this.lattices) {
var isinable = ableidx.indexOf(key);
var ieliname = this.lattices[key];
var ielinode = this.container.getChildByName(ieliname);
if (ielinode) {
if (isinable == -1) {
ielinode.touch = false;
}
else {
ielinode.touch = true;
}
}
}
engine.Tween.removeTweens(this.guideCont);
engine.Tween.get(this.guideCont)
.to({
alpha: 1
}, 200);
};
GameView.prototype.usetool = function (data) {
var tooltype = data.tooltype;
if (tooltype == "time") {
var addtime = data.addtime;
var ngtime = this.gametime + addtime;
this.gametime = ngtime;
}
else if (tooltype == "boom") {
var use = data.useboom;
this.useBoom = use;
}
};
GameView.prototype.getOneEffect = function () {
var oneffect;
if (this.diseffectArr.length > 0) {
oneffect = this.diseffectArr.shift();
}
else {
oneffect = createSvga("消除动效");
oneffect.addEventListener(engine.Event.ENTER_FRAME, this.playDisEffectComplete, this);
oneffect.mouseEnabled = false;
oneffect.mouseChildren = false;
}
return oneffect;
};
GameView.prototype.playDisEffectComplete = function (e) {
var target = e.target;
var curframe = target.currentFrame;
var totalframe = target.totalFrames;
if (curframe >= totalframe) {
target.stop(1);
this.anicontainer.removeChild(target);
this.diseffectArr.push(target);
}
};
GameView.prototype.playEffect = function (sound) {
console.log("音效播放", sound);
if (this.mute == 1) {
playSound(sound);
}
};
return GameView;
}(engine.Container));
var GameWrapper = (function (_super) {
tslib.__extends(GameWrapper, _super);
function GameWrapper() {
var _this = _super.call(this) || this;
_this._gameView = new GameView();
_this.addChild(_this._gameView);
engine.globalEvent.addEventListener('game-init', _this.init, _this);
engine.globalEvent.addEventListener('game-reset', _this.reset, _this);
engine.globalEvent.addEventListener('game-start', _this.start, _this);
engine.globalEvent.addEventListener('game-pause', _this.pause, _this);
engine.globalEvent.addEventListener('game-resume', _this.resume, _this);
engine.globalEvent.addEventListener('game-recordcomp', _this.recordcomp, _this);
engine.globalEvent.addEventListener('game-newuserguide', _this.newUserGuide, _this);
engine.globalEvent.addEventListener('game-usetool', _this.usetool, _this);
return _this;
}
GameWrapper.prototype.init = function (event) {
var time = event.data.time;
var level = event.data.level;
var mode = event.data.mode;
var mute = event.data.mute;
this._gameView.init(time, level, mode, mute);
};
GameWrapper.prototype.reset = function (event) {
var time = event.data.time;
var level = event.data.level;
var mode = event.data.mode;
this._gameView.reset(time, level, mode);
};
GameWrapper.prototype.start = function () {
this._gameView.start();
};
GameWrapper.prototype.pause = function () {
this._gameView.pause();
};
GameWrapper.prototype.resume = function () {
this._gameView.resume();
};
GameWrapper.prototype.recordcomp = function () {
this._gameView.recordcomp();
};
GameWrapper.prototype.newUserGuide = function () {
this._gameView.setGuideShow();
};
GameWrapper.prototype.usetool = function (event) {
var data = event.data;
this._gameView.usetool(data);
};
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
This source diff could not be displayed because it is too large. You can view the blob instead.
/**
* Created by rockyl on 2020-01-21.
*/
let customModuleProps = {
};
{
"name": "人保财险消消乐",
"desc": "消消乐模块",
"props": {
"threeEscore":{
"alias":"三消加分",
"type":"number",
"default":1
},
"fourEscore":{
"alias":"四消加分",
"type":"number",
"default":2
},
"moreEscore":{
"alias":"多消加分",
"type":"number",
"default":3
}
},
"assets": [
{
"name": "底图",
"url": "//yun.duiba.com.cn/aurora/assets/d2b599cece087d5ab315cd1392f94139941280bb.png",
"uuid": "map",
"ext": ".png"
},
{
"name": "狗",
"url": "//yun.duiba.com.cn/aurora/assets/26780d2fb48d047e111857da9e82fe49b0d310a8.png",
"uuid": "gdog",
"ext": ".png"
},
{
"name": "鸟",
"url": "//yun.duiba.com.cn/aurora/assets/39a1a8865ca101d6fa29325bf1fc37c26190e382.png",
"uuid": "pbird",
"ext": ".png"
},
{
"name": "牛",
"url": "//yun.duiba.com.cn/aurora/assets/2e74dd7faab031f71e644dad340b4c83791b8bf0.png",
"uuid": "hniu",
"ext": ".png"
},
{
"name": "兔子",
"url": "//yun.duiba.com.cn/aurora/assets/6c4033a865bc6c73b680bc31d29de55ac347d397.png",
"uuid": "bribbit",
"ext": ".png"
},
{
"name": "猪",
"url": "//yun.duiba.com.cn/aurora/assets/c14e003bb3847bd7ab30eb6ba0915124f207bc31.png",
"uuid": "rpig",
"ext": ".png"
},
{
"name": "选中框",
"url": "//yun.duiba.com.cn/aurora/assets/c6ed5f3f94958e74fcbfc1da56e99795056fd75a.png",
"uuid": "selected",
"ext": ".png"
},
{
"name": "交换箭头",
"url": "//yun.duiba.com.cn/aurora/assets/438ca6e721eab32728aceaca5df0095e1387f340.png",
"uuid": "jiantou",
"ext": ".png"
},
{
"name": "手指动效",
"url": "//yun.duiba.com.cn/aurora/assets/038f2a14e1bfff4e2fc3f786152f03f56048d426.svga",
"uuid": "shouani",
"ext": ".svga"
},
{
"name": "消除动效",
"url": "//yun.duiba.com.cn/aurora/assets/5cde14d822eb85ac5e8bbcbae795e6107689543c.svga",
"uuid": "diseffect",
"ext": ".svga"
},
{
"name": "炸弹中心",
"url": "//yun.duiba.com.cn/aurora/assets/30795e057013978807e1a52351b6debbf034d174.png",
"uuid": "shine1",
"ext": ".png"
},
{
"name": "爆炸闪光",
"url": "//yun.duiba.com.cn/aurora/assets/e200b34d25020bd1d5430cf6f3e52c6866826076.png",
"uuid": "shine2",
"ext": ".png"
},
{
"name": "爆炸音效",
"url": "//yun.duiba.com.cn/aurora/assets/0223fe1440f0935aa3e9084ad7fa7808ec9f893c.mp3",
"uuid": "boomsound",
"ext": ".mp3"
},
{
"name": "消除音效",
"url": "//yun.duiba.com.cn/aurora/assets/becd6a758767b7bf75738dd5346f7ce84979c1fb.mp3",
"uuid": "elisound",
"ext": ".mp3"
}
],
"events": {
"in": {
"game-init":{
"alias": "初始化第一关",
"data": {
}
},
"game-reset": {
"alias": "关卡通过重玩之类的重置关卡",
"data": {
}
},
"game-start": {
"alias": "开始"
},
"game-pause": {
"alias": "暂停"
},
"game-resume": {
"alias": "继续"
},
"game-recordcomp": {
"alias": "记录完毕"
},
"game-newuserguide":{
"alias": "新手引导"
},
"game-usetool":{
"alias": "使用道具"
}
},
"out": {
"game-score-update": {
"alias": "分数更新",
"data": {
"score":"分数"
}
},
"game-time-update": {
"alias": "倒计时更新",
"data": {
"time":"剩余时间"
}
},
"game-over": {
"alias": "游戏结束",
"data": {
"score":"分数",
"reason": "结束原因(1:时间到了,2:过关)"
}
},
"game-record": {
"alias": "游戏记录",
"data": {
"score":"操作得分",
"seq": "操作步骤号",
"sptime":"操纵开始时间",
"eptime":"操作结束时间"
}
},
"game-touch": {
"alias": "按钮点击",
"data": {
"cantouch":""
}
},
"game-guidecomplete": {
"alias": "游戏引导完毕",
"data": {
}
},
"game-useboomafter": {
"alias": "炸弹使用完毕",
"data": {
}
},
"game-useBoom": {
"alias": "使用炸弹==考虑性能使用上面的方式,直接使用",
"data": {
}
}
}
}
}
\ No newline at end of file
/**
* Created by zjz on 2020/7/10.
*/
import { props } from "../props";
import { playSound, createSvga,getTextureByName } from "./utils";
import ObjectPool = engine.ObjectPool;
import MapData, { GameEvent, ElementType } from "./MapData";
import Element from "./ele/Element";
import boomAni from "./boomAni";
export default class GameView extends engine.Container {
constructor() {
super();
this.once(engine.Event.ADDED_TO_STAGE, this.setup, this);
}
//元素容器
container:engine.Container;
//动画层
anicontainer:engine.Container;
//加分文字层
txtcontainer:engine.Container;
//格子,位置-name
lattices = {};
//一次消除组
eliminateArr = [];
//选中
selectArr = [];
selectimg:engine.Image;
selectw:number;
selecth:number;
//屋子
// homeimgday;
// homeimgnight;
conty = 0;
homex = 562;
homey = -20;
tanix;
taniy;
//5秒不操作,给提示
lastframeTime;
attiondata;
lastatime;
ination = false;
canation = true;
_gametime = 60;
_gamestat=2;
ingameover = false;
jiantou1:engine.Image;
jiantou2:engine.Image;
jiantoucont:engine.Container;
jtsx1;
jtsy1;
jtsx2;
jtsy2;
jtex1;
jtey1;
jtex2;
jtey2;
ingame = true;
level = 0;
inrecord = false;
requestGameOver = false;
elitype = 1;//1原地消失,2飞到目标位置
//新增新手引导
guideCont:engine.Container;
guideDraw:engine.Shape;
inguide:boolean = false;
//手指动效
shoueffect;
diseffectArr:Array<any> = [];
//mute
mute = 1;//声音默认开启
set gamestat(stat){//1游戏中,2,游戏外
this._gamestat = stat;
if(stat==2){
this.changeEnable(false);
}
}
get gamestat(){
return this._gamestat;
}
_seq = 1;
set seq(num){
this._seq = num;
}
get seq(){
return this._seq;
}
sptime = Date.now();
eptime;
seqscore;
//使用炸弹
useBoom:boolean = false;
boomani:boomAni;//炸弹动效
setup() {
console.log("setup----game");
MapData.initPoolEle();
this.selectimg = new engine.Image(getTextureByName("选中框"));
this.selectimg.mouseEnabled = false;
this.selectw = this.selectimg.texture.width;
this.selecth = this.selectimg.texture.height;
this.selectimg.anchorX = this.selectw/2;
this.selectimg.anchorY = this.selecth/2;
//箭头cont
this.jiantou1 = new engine.Image(getTextureByName("交换箭头"));
this.jiantou2 = new engine.Image(getTextureByName("交换箭头"));
this.jiantou1.mouseEnabled = false;
this.jiantou2.mouseEnabled = false;
let jiantwid = 31;
let jianthei = 24;
this.jiantou1.anchorX = jiantwid/2;
this.jiantou1.anchorY = jianthei/2;
this.jiantou2.anchorX = jiantwid/2;
this.jiantou2.anchorY = jianthei/2;
this.jiantoucont = new engine.Container();
this.jiantoucont.width = MapData.itemsize;
this.jiantoucont.height = MapData.itemsize;
this.jtsx1 = MapData.itemsize/2-jiantwid/2;
this.jtsx2 = MapData.itemsize/2-jiantwid/2;
this.jtsy1 = MapData.itemsize/2-jianthei;
this.jtsy2 = MapData.itemsize/2;
this.jtex1 = this.jtsx1-10;
this.jtex2 = this.jtsx2+10;
this.jtey1 = this.jtsy1;
this.jtey2 = this.jtsy2;
this.jiantou1.x = this.jtsx1;
this.jiantou2.rotation = 180;
this.jiantou2.x = this.jtsx2;
this.jiantou1.y = this.jtsy1;
this.jiantou2.y = this.jtsy2;
this.jiantoucont.addChild(this.jiantou1);
this.jiantoucont.addChild(this.jiantou2);
let row = MapData.row;
let col = MapData.col;
//手指动效
this.shoueffect = createSvga("手指动效");
// console.log("手指动效",this.shoueffect);
// this.homeimgday = createSvga("房子动画");
// this.homeimgday.x = this.homex;
// this.homeimgday.y = this.homey;
// this.homeimgday.stop();
// this.homeimgday.visible = false;
// this.addChild(this.homeimgday);
// this.homeimgnight = createSvga("夜晚房子");
// this.homeimgnight.x = this.homex;
// this.homeimgnight.y = this.homey;
// this.homeimgnight.stop();
// this.homeimgnight.visible = false;
// this.addChild(this.homeimgnight);
this.container = new engine.Container();
this.addChild(this.container);
this.container.y = this.conty;
let maskimg = new engine.Graphics();
this.container.addChild(maskimg);
this.container.mask = maskimg;
maskimg.moveTo(0,0);
maskimg.beginFill(0);
maskimg.lineTo(681,0);
maskimg.lineTo(681,679);
maskimg.lineTo(0,679);
maskimg.lineTo(0,0);
maskimg.endFill();
this.anicontainer = new engine.Container();
this.addChild(this.anicontainer);
this.anicontainer.mouseEnabled = false;
this.anicontainer.mouseChildren = false;
this.txtcontainer = new engine.Container();
this.addChild(this.txtcontainer);
let map = new engine.Image(getTextureByName("底图"));
this.container.addChild(map);
//初始化底图
for(let r=0;r<row;r++){
for(let c=0;c<col;c++){
let rcpos = MapData.getRCPos(r,c);
MapData.posData[r+"_"+c] = rcpos;
}
}
this.tanix = this.homex+30;
this.taniy = this.homey;// - MapData.itemsize/2;
engine.globalEvent.addEventListener(GameEvent.SelectEle,this.selectele,this);
this.removeEventListener(engine.Event.ADDED_TO_STAGE,this.setup,this);
this.lastframeTime = Date.now();
this.lastatime = Date.now();
this.addEventListener(engine.Event.ENTER_FRAME,this.onUpdate,this);
//新手引导遮罩
this.guideCont = new engine.Container();
this.addChild(this.guideCont);
this.guideDraw = new engine.Shape();
this.guideCont.addChild(this.guideDraw);
this.guideCont.visible = false;
this.guideCont.mouseEnabled = false;
this.guideCont.addChild(this.shoueffect);
this.shoueffect.mouseEnabled = false;
this.shoueffect.mouseChildren = false;
this.shoueffect.visible = false;
this.setGuidePath();
this.boomani = new boomAni();
this.anicontainer.addChild(this.boomani);
// this.setGuideShow();
// //测试
// let testbtn = new engine.Label();
// testbtn.text = "reset";
// testbtn.size = 56;
// testbtn.width = 200;
// testbtn.height = 100;
// this.addChild(testbtn);
// testbtn.y = 900;
// testbtn.fillColor = "red";
// testbtn.addEventListener(engine.MouseEvent.CLICK,this.reset,this);
//炸弹道具
// let zhadanbtn = new engine.Label();
// zhadanbtn.text = "炸弹";
// zhadanbtn.size = 56;
// zhadanbtn.width = 200;
// zhadanbtn.height = 100;
// this.addChild(zhadanbtn);
// zhadanbtn.y = 900;
// zhadanbtn.fillColor = "red";
// zhadanbtn.addEventListener(engine.MouseEvent.CLICK,this.zhadanFunc,this);
// //加时间道具
// let timebtn = new engine.Label();
// timebtn.text = "加时";
// timebtn.size = 56;
// timebtn.width = 200;
// timebtn.height = 100;
// this.addChild(timebtn);
// timebtn.y = 900;
// timebtn.x = 500;
// timebtn.fillColor = "red";
// timebtn.addEventListener(engine.MouseEvent.CLICK,this.addTimeFunc,this);
}
changeAni(){
this.changeHomeShow("night");
}
playComp(){
// this.homeimgday.stop(1);
// this.homeimgnight.stop(1);
}
init(time,level,mode,mute=1){
this.score = 0;
this.gametime = time;
this.seq = 1;
this.level = level;
this.ingameover = false;
this.mute = mute;
this.changeHomeShow(mode);
this.initContainer();
this.sptime = Date.now();
}
_score = 0;
set score(num){
this._score = num;
engine.globalEvent.dispatchEvent('game-score-update',{score:this._score});
}
get score(){
return this._score;
}
set gametime(time){
let lshowtime = Math.round(this._gametime);
let nshowtime = Math.round(time);
if(lshowtime!=nshowtime){
// console.log("倒计时更新",nshowtime);
if(this.gamestat==1&&nshowtime<1){
this.gameOver();
}
if(nshowtime<0){
nshowtime = 0;
}
engine.globalEvent.dispatchEvent('game-time-update',{time:nshowtime});
}
if(time<0){
time = 0;
}
this._gametime = time;
}
get gametime(){
return this._gametime;
}
inEliminate:boolean = false;
gameOver(){
this.gamestat = 2;
this.unShowEleAttion();
this.anicontainer.removeChild(this.selectimg);
this.ingameover = true;
console.log("倒计时结束1=============",this.ingameover,this.inEliminate,this.inrecord);
this.checkGameOver("time-over");
};
checkGameOver(type){
if(this.ingameover){
console.log("倒计时已结束2==========",this.inEliminate,this.inrecord,type);
}
if(this.ingameover&&!this.inEliminate&&!this.inrecord&&!this.requestGameOver){
this.requestGameOver = true;
this.unShowEleAttion();
this.anicontainer.removeChild(this.jiantoucont);
engine.globalEvent.dispatchEvent("game-over",{
score:this.score
})
}
}
levelData;
async reset(time,level,mode){
this.anicontainer.removeChild(this.selectimg);
this.gamestat = 1;
this.selectArr = new Array();
this.gametime = time;
this.level = level;
this.ingameover = false;
this.seq = 1;
this.changeHomeShow(mode);
this.changeEnable(false);
// for(let key in this.lattices){
// let rcname = this.lattices[key];
// let rcele:Element = this.container.getChildByName(rcname);
// if(rcele){
// let rcelex = rcele.x;
// let rceley = rcele.y;
// let rcetype = rcele.type;
// // this.container.removeChild(rcele);
// // MapData.recoverEle(rcele,rcetype);
// this.lattices[key] = "empty";
// // this.goDisplayAni(rcetype,rcelex,rceley);
// this.goDisplayAni1(rcele,rcetype,rcelex,rceley);
// }
// }
// let fallpro = new Promise(res=>{
// setTimeout(function(){
// res();
// },400);
// })
// await fallpro;
// let testdata = MapData.levelData[this.level-1];
// this.levelData = testdata;
this.fall();
}
start(){
console.log("game-start");
this.gamestat = 1;
this.requestGameOver = false;
this.selectArr = new Array();
this.changeEnable(true);
}
pause(){
// console.log("游戏暂停");
this.ingame = false;
this.unShowEleAttion();
}
resume(){
// console.log("游戏继续");
this.lastframeTime = Date.now();
this.ingame = true;
}
onUpdate(){
let ntime = Date.now();
if(this.gamestat==1&&this.ingame&&!this.inguide&&!this.requestGameOver){
let passtime = ntime - this.lastframeTime;
if(ntime-this.lastatime>=5000&&!this.ination&&this.canation&&this.selectArr.length==0){
this.attionEliShow();
}
if(this.gametime&&this.gametime>0){
let ngtime = this.gametime-(passtime/1000);
this.gametime = ngtime;
}
}
// if(this.homeimgday&&this.homeimgday.visible){
// let curframe = this.homeimgday.currentFrame;
// if(curframe==this.homeimgday.totalFrames){
// this.homeimgday.gotoAndStop(1);
// }
// }
// if(this.homeimgnight&&this.homeimgnight.visible){
// let curframe = this.homeimgnight.currentFrame;
// if(curframe==this.homeimgnight.totalFrames){
// this.homeimgnight.gotoAndStop(1);
// }
// }
this.lastframeTime = ntime;
}
initContainer(){
if(this.lattices){
for(let key in this.lattices){
let rcname = this.lattices[key];
let rcele:Element = this.container.getChildByName(rcname);
if(rcele){
let rcetype = rcele.type;
this.container.removeChild(rcele);
this.lattices[key] = "empty";
MapData.recoverEle(rcele,rcetype);
}
}
}else{
this.lattices = {};
}
let testdata = MapData.levelData[this.level-1];
this.levelData = testdata;
for(let r=0;r<testdata.length;r++){
let rdata = testdata[r];
for(let c=0;c<rdata.length;c++){
let rctype = rdata[c];
let rcele = MapData.getOneEle(rctype);
let rcpos = MapData.getRCPos(r,c);
this.container.addChild(rcele);
rcele.x = rcpos[0];
rcele.y = rcpos[1];
let rcidx = r+"_"+c;
this.lattices[rcidx] = rcele.name;
this.setLatticeEleRc(rcidx);
}
}
//初始化,检测消除,死图
this.checkInit();
}
checkInit(){
this.checkEliminate();
if(this.eliminateArr.length>0){
return this.eliminate();
}else{//一次操作完毕
this.selectArr = new Array();
let isdiedata = this.attionEliminate();
if(isdiedata&&isdiedata.length==3){//没死
this.changeEnable(true);
}else{//死图处理
this.solveDieMap();
}
//检查死图
}
}
//关联
setLatticeEleRc(rcidx){
let rename = this.lattices[rcidx];
let rcnode:Element = this.container.getChildByName(rename);
if(rcnode){
let er = Number(rcidx.split("_")[0]);
let ec = Number(rcidx.split("_")[1]);
rcnode.setrc(er,ec);
}
}
//取消提示选择
unShowEleAttion(){
if(this.ination){
this.ination = false;
this.lastatime = Date.now();
let arrcidx1 = this.attiondata[0];
let arrcidx2 = this.attiondata[1];
let atname1 = this.lattices[arrcidx1];
let atname2 = this.lattices[arrcidx2];
let atnode1:Element = this.container.getChildByName(atname1);
let atnode2:Element = this.container.getChildByName(atname2);
let aboutnames = this.attiondata[2];
if(!atnode1||!atnode2){
this.attiondata = new Array();
return;
}
let atpos1 = MapData.getRCPos(arrcidx1.split("_")[0],arrcidx1.split("_")[1]);
let atpos2 = MapData.getRCPos(arrcidx2.split("_")[0],arrcidx2.split("_")[1]);
engine.Tween.removeTweens(atnode1);
engine.Tween.removeTweens(atnode2);
atnode1.x = atpos1[0];
atnode1.y = atpos1[1];
atnode2.x = atpos2[0];
atnode2.y = atpos2[1];
for(let i=0;i<aboutnames.length;i++){
let ircidx = aboutnames[i];
let iname1 = this.lattices[ircidx];
let inode1:Element = this.container.getChildByName(iname1);
if(inode1){
engine.Tween.removeTweens(inode1);
let ipos1 = MapData.getRCPos(ircidx.split("_")[0],ircidx.split("_")[1]);
inode1.x = ipos1[0];
inode1.y = ipos1[1];
}
}
this.anicontainer.removeChild(this.jiantoucont);
}
}
newSelect:boolean = false;
//选择元素
selectele(e:engine.Event){
if(!this.ingame){
return;
}
let data = e.data;
let sr = data.r;
let sc = data.c;
let type = data.type;
let sname = sr+"_"+sc;
//使用炸弹
if(this.useBoom){
if(type=="mouse_down"){
this.changeEnable(false);
// //使用炸弹
// engine.globalEvent.dispatchEvent('game-useBoom',{
// boomr:sr,
// boomc:sc
// });
this.boomeEle(sr,sc);
}
return;
}
//新增滑动操作
let lnewSelect = this.newSelect;
let newCanSel = false;
if(this.selectArr.length==0){
newCanSel = true;
}else if(this.selectArr.length==1){
let nname = this.selectArr[0];
if(sname==nname){
newCanSel = false
}else{
newCanSel = true;
}
}
if(type=="mouse_down"){
this.newSelect = true;
}else if(type=="mouse_move"){
if(newCanSel){
this.newSelect = false;
}
}
// console.log(lnewSelect,this.newSelect,newCanSel,type,this.selectArr.length,sname);
if((lnewSelect||this.newSelect)&&newCanSel){
}else{
return;
}
// console.log("continue");
this.unShowEleAttion();
if(this.selectArr.length==0){
// console.log("选中元素",data);
this.sptime = Date.now();
this.seqscore = 0;
this.selectArr.push(sname);
}else if(this.selectArr.length==1){
let aselect = this.selectArr[0];
let asr = aselect.split("_")[0];
let asc = aselect.split("_")[1];
if((sr==asr&&Math.abs(sc-asc)==1)||(sc==asc&&Math.abs(sr-asr)==1)){
this.selectArr.push(sname);
}else{
//重选自己,取消选择,否则选中新的
if(sr==asr&&sc==asc){
this.selectArr = new Array();
this.anicontainer.removeChild(this.selectimg);
}else{
this.selectArr[0] = sname;
}
}
}
if(this.selectArr.length==1){
this.setSelectShow();
}else if(this.selectArr.length==2){
this.changeElePos();
}
}
setSelectShow(){
let rcname = this.selectArr[0];
let r = rcname.split("_")[0];
let c = rcname.split("_")[1];
let rcpos = MapData.getRCPos(r,c);
engine.Tween.removeTweens(this.selectimg);
this.anicontainer.addChild(this.selectimg);
this.selectimg.x = rcpos[0]-3;
this.selectimg.y = rcpos[1]+this.conty-3;
this.startTweenSelectImg()
}
startTweenSelectImg(){
this.selectimg.scaleX = 1;
this.selectimg.scaleY = 1;
engine.Tween.get(this.selectimg,{loop:true})
.to({
scaleX:0.9,
scaleY:0.9
},500)
.to({
scaleX:1,
scaleY:1
},500);
}
changeElePos(){
this.anicontainer.removeChild(this.selectimg);
this.changeEnable(false);
let sname1 = this.selectArr[0];
let sname2 = this.selectArr[1];
let sename1 = this.lattices[sname1];
let sename2 = this.lattices[sname2];
// console.log("交换测试",sname1,sname2,this.lattices);
this.lattices[sname1] = sename2;
this.lattices[sname2] = sename1;
this.setLatticeEleRc(sname1);
this.setLatticeEleRc(sname2);
this.checkEliminate();
let snode1 = this.container.getChildByName(sename1);
let snode2 = this.container.getChildByName(sename2);
if(!snode1||!snode2){
this.selectArr = new Array();
return;
}
let snode1x = snode1.x;
let snode1y = snode1.y;
let snode2x = snode2.x;
let snode2y = snode2.y;
let changetime = Math.ceil((MapData.itemsize/MapData.anispeed)*2*1000);
engine.Tween.removeTweens(snode1);
engine.Tween.removeTweens(snode2);
if(this.eliminateArr.length>0){
if(this.inguide){
this.shoueffect.stop(0);
this.shoueffect.visible = false;
this.inguide = false;
engine.Tween.removeTweens(this.guideCont);
engine.Tween.get(this.guideCont)
.to({
alpha:0
},200)
.call(()=>{
this.guideCont.visible = false;
//引导完毕
engine.globalEvent.dispatchEvent('game-guidecomplete',{});
// this.start();
})
}
this.inEliminate = true;
engine.Tween.get(snode1).to({
x:snode2x,
y:snode2y
},changetime)
engine.Tween.get(snode2).to({
x:snode1x,
y:snode1y
},changetime)
.call(()=>{
this.eliminate();
})
}else{
engine.Tween.get(snode1).to({
x:snode2x,
y:snode2y
},changetime)
.wait(100)
.to({
x:snode1x,
y:snode1y
},changetime)
engine.Tween.get(snode2).to({
x:snode1x,
y:snode1y
},changetime)
.wait(100)
.to({
x:snode2x,
y:snode2y
},changetime)
.call(()=>{
this.lattices[sname1] = sename1;
this.lattices[sname2] = sename2;
this.setLatticeEleRc(sname1);
this.setLatticeEleRc(sname2);
this.selectArr = new Array();
this.recordGame();
this.changeEnable(true);
this.checkGameOver("changeElePos");
})
}
}
//消除
async eliminate(){
this.inEliminate = true;
this.playEffect("消除音效");
for(let i=0;i<this.eliminateArr.length;i++){
let ielidata1 = this.eliminateArr[i];
let ielileng = ielidata1.length;
let addscore = 0;
if(ielileng<=3){
addscore = props.threeEscore;
}else if(ielileng==4){
addscore = props.fourEscore;
}else{
addscore = props.moreEscore;
}
// console.log("消除单个加分",addscore);
this.seqscore += addscore*ielileng;
for(let j=0;j<ielidata1.length;j++){
let ielidata = ielidata1[j];
let ielidxname = ielidata.idxname;
let ielitype = ielidata.type;
let ieliname = this.lattices[ielidxname];
let ielinode:Element = this.container.getChildByName(ieliname);
if(!ielinode){
continue;
}
let ielix = ielinode.x;
let ieliy = ielinode.y;
let ietype = ielinode.type;
if(this.elitype==1){//原地消失
this.lattices[ielidxname] = "empty";
this.addScoreAni(ielix,ieliy,ietype,addscore);
this.goDisplayAni1(ielinode,ietype,ielix,ieliy);
}else{//飞到目标位置
this.container.removeChild(ielinode);
MapData.recoverEle(ielinode,ietype);
this.addScoreAni(ielix,ieliy,ietype,addscore);
this.lattices[ielidxname] = "empty";
//元素层消除,动画层添加
this.goHomeAni(ielitype,ielix,ieliy);
}
}
}
await new Promise(res=>{
setTimeout(function(){
res();
},400);
})
this.fall();
await new Promise(res1=>{
setTimeout(function(){
res1();
},500)
})
// this.homeimgday.play(1,1);
// this.homeimgnight.play(1,1);
}
//掉落
async fall(type="normal"){
let fallData = new Array();
let fcutr = new Array();
for(let fc=0;fc<MapData.col;fc++){
fcutr.push(-1);
}
for(let r = MapData.row-1;r>-1;r--){
for(let c=MapData.col-1;c>-1;c--){
let idxname = r+"_"+c;
let elename = this.lattices[idxname];
if(elename=="empty"){
let frcname = this.getFallRcEle(r,c);
if(!frcname){
let fetype;
if(type=="normal"){
fetype = MapData.getRandEtype();
}else{
fetype = this.levelData[r][c];
}
let fele = MapData.getOneEle(fetype);
let cutr = fcutr[c];
let fepos = MapData.getRCPos(cutr,c);
fcutr[c] = cutr-1;
this.container.addChild(fele);
fele.x = fepos[0];
fele.y = fepos[1];
frcname = fele.name;
}
this.lattices[idxname] = frcname;
this.setLatticeEleRc(idxname);
fallData.push({
rcname:frcname,
trow:r,
tcol:c
});
}
}
}
// return;
// console.log("动画掉落组准备完毕",fallData);
let fallPromise = new Array();
for(let f=0;f<fallData.length;f++){
let fdata = fallData[f];
let frcname = fdata.rcname;
let ftrow = fdata.trow;
let ftcol = fdata.tcol;
let ftpos = MapData.getRCPos(ftrow,ftcol);
let frcnode = this.container.getChildByName(frcname);
if(!frcnode){
continue;
}
let nepos = [frcnode.x,frcnode.y];
let fdis = MapData.getDistance(ftpos,nepos);
let ftime = Math.ceil((fdis/MapData.anispeed)*1000);
engine.Tween.removeTweens(frcnode);
let ifallpromise = new Promise(res=>{
engine.Tween.get(frcnode)
.to({
x:ftpos[0],
y:ftpos[1]
},ftime)
.to({
scaleY:0.85
},80)
.to({
scaleY:1
},80)
.call(()=>{
res();
})
})
fallPromise.push(ifallpromise);
}
await Promise.all(fallPromise);
if(type=="newlevel"){
this.sptime = Date.now();
}
this.checkEliminate();
if(this.eliminateArr.length>0){
return this.eliminate();
}else{//一次操作完毕
this.selectArr = new Array();
let isdiedata = this.attionEliminate();
if(isdiedata&&isdiedata.length==3){//没死
this.inEliminate = false;
if(type!="newlevel"){
this.recordGame();
}
this.changeEnable(true);
this.checkGameOver("fall");
}else{//死图处理
this.solveDieMap("fall");
}
//检查死图
}
}
//原地显示改
goDisplayAni1(rcele:Element,rcetype:ElementType,rcelex,rceley){
rcele.touch = false;
engine.Tween.removeTweens(rcele);
rcele.x = rcelex;
rcele.y = rceley;
rcele.anchorY = MapData.itemsize/2;
engine.Tween.get(rcele)
.to({
scaleX:0,
scaleY:0,
alpha:0
},300)
.call(()=>{
this.container.removeChild(rcele);
MapData.recoverEle(rcele,rcetype);
})
let oneffect = this.getOneEffect();
oneffect.x = rcelex;
oneffect.y = rceley;
this.anicontainer.addChild(oneffect);
oneffect.play(1);
}
//原地消失
goDisplayAni(ielitype,ielix,ieliy){
// console.log("老原地消失");
let aniele = MapData.getOneEle(ielitype);
aniele.alpha = 0;
let anix = ielix;
let aniy = ieliy+this.conty;
this.anicontainer.addChild(aniele);
aniele.touch = false;
aniele.x = anix;
aniele.y = aniy;
aniele.alpha = 1;
aniele.anchorY = MapData.itemsize/2;
engine.Tween.removeTweens(aniele);
engine.Tween.get(aniele)
.to({
scaleX:0,
scaleY:0,
alpha:0
},300)
.call(()=>{
this.anicontainer.removeChild(aniele);
MapData.recoverEle(aniele,ielitype);
})
}
//飞到小屋
goHomeAni(ielitype,ielix,ieliy){
let aniele = MapData.getOneEle(ielitype);
aniele.alpha = 0;
let anix = ielix;
let aniy = ieliy + this.conty;
this.anicontainer.addChild(aniele);
aniele.touch = false;
aniele.x = anix;
aniele.y = aniy;
aniele.alpha = 1;
let anidis = MapData.getDistance([this.tanix,this.taniy],[anix,aniy]);
let anitime = Math.ceil((anidis/MapData.anispeed)*1000);
aniele.flyToHome(this.tanix,this.taniy,anitime);
}
//修改元素点击
changeEnable(v:boolean){
let changeable = false;
if(this.gamestat==1){
changeable = true;
}else{
if(!v){
changeable = true;
}
}
if(changeable){
for(let key in this.lattices){
let kname = this.lattices[key];
let ele:Element = this.container.getChildByName(kname);
if(ele){
ele.touch = v;
}
}
engine.globalEvent.dispatchEvent('game-touch',{
cantouch:v
});
if(v){
this.lastatime = Date.now();
this.ination = false;
}
}
this.canation = v;
}
//相邻显性提示
attionEliShow(){
let attiondata = this.attionEliminate();
// console.log("测试333",attiondata);
if(attiondata&&attiondata.length==3){
this.ination = true;
this.attiondata = [attiondata[0],attiondata[1],attiondata[2]];
let atname1 = this.lattices[attiondata[0]];
let atname2 = this.lattices[attiondata[1]];
let aboutnames = attiondata[2];
let atnode1:Element = this.container.getChildByName(atname1);
let atnode2:Element = this.container.getChildByName(atname2);
if(!atnode1||!atnode2){
return;
}
let atx1 = atnode1.x;
let aty1 = atnode1.y;
let atx2 = atnode2.x;
let aty2 = atnode2.y;
let lerpnum = 0.1;
let atpos1 = [(atx2-atx1)*lerpnum+atx1,(aty2-aty1)*lerpnum+aty1];
let atpos2 = [(atx1-atx2)*lerpnum+atx2,(aty1-aty2)*lerpnum+aty2];
engine.Tween.removeTweens(atnode1);
engine.Tween.removeTweens(atnode2);
engine.Tween.get(atnode1,{
loop:true
}).to({
x:atpos1[0],
y:atpos1[1]
},500)
.to({
x:atx1,
y:aty1
},500);
//箭头动画
let jtx = (atx2-atx1)*0.5+atx1;
let jty = (aty2-aty1)*0.5+aty1+this.conty;
let chax1 = atx1-atpos1[0];
let chay1 = aty1-atpos1[1];
let roa1 = 0;
let movex1 = 0;
let movey1 = 0;
if(Math.abs(chax1)>Math.abs(chay1)){
jty += 25;
// console.log("横向移动");
movex1 = chax1;
}else{
jtx += MapData.itemsize;
roa1 = 90;
movey1 = chay1;
// console.log("竖向移动");
}
// console.log("位移llll",aboutnames);
for(let i=0;i<aboutnames.length;i++){
let iname1 = this.lattices[aboutnames[i]];
let inode1:Element = this.container.getChildByName(iname1);
engine.Tween.removeTweens(inode1);
let iatx1 = inode1.x;
let iaty1 = inode1.y;
if(inode1){
engine.Tween.get(inode1,{loop:true})
.to({
x:iatx1+movex1,
y:iaty1+movey1
},500)
.to({
x:iatx1,
y:iaty1
},500)
}
}
// engine.Tween.get(atnode2,{loop:true})
// .to({
// x:atpos2[0],
// y:atpos2[1]
// },500)
// .to({
// x:atx2,
// y:aty2
// },500);
this.anicontainer.addChild(this.jiantoucont);
this.jiantoucont.x = jtx;
this.jiantoucont.y = jty;
this.jiantoucont.rotation = roa1;
this.startJtAni();
}else{//死图处理
this.solveDieMap();
}
}
startJtAni(){
engine.Tween.removeTweens(this.jiantou1);
engine.Tween.removeTweens(this.jiantou2);
this.jiantou1.x = this.jtex1;
this.jiantou1.y = this.jtey1;
this.jiantou2.x = this.jtex2;
this.jiantou2.y = this.jtey2;
this.jiantou1.alpha = 1;
this.jiantou2.alpha = 1;
// console.log("欢动测试",this.jtsx1,this.jtsy1,this.jtex1,this.jtey1);
// return;
engine.Tween.get(this.jiantou1,{loop:true})
.to({
x:this.jtsx1,
y:this.jtsy1,
alpha:0
},500)
.to({
x:this.jtex1,
y:this.jtey1,
alpha:1
},500)
engine.Tween.get(this.jiantou2,{loop:true})
.to({
x:this.jtsx2,
y:this.jtsy2,
alpha:0
},500)
.to({
x:this.jtex2,
y:this.jtey2,
alpha:1
},500)
}
//死图调整
solveDieMap(type="normal"){
if(this.gamestat!=1){
if(this.ingameover){
this.inEliminate = false;
this.checkGameOver("changeToFuHuoPos222");
}
return;
}
this.changeEnable(false);
// console.error("死图调整");
// console.log(this.lattices);
// return false;
let elearr = new Array();
for(let key in this.lattices){
let keyval = this.lattices[key];
elearr.push(keyval);
}
for(let key in this.lattices){
let changeval = elearr.splice(Math.floor(Math.random()*elearr.length),1)[0];
this.lattices[key] = changeval;
}
let isdiedata = this.attionEliminate();
if(isdiedata&&isdiedata.length==3){
// console.error("可以复活了,转移位置");
this.changeToFuHuoPos(type);
}else{
// console.error("依然死亡,寻求复活");
return this.solveDieMap();
}
}
//转移到复活pos
async changeToFuHuoPos(type){
let prolist = new Array();
for(let key in this.lattices){
let keyval = this.lattices[key];
var keynode:Element = this.container.getChildByName(keyval);
if(!keynode){
continue;
}
let keynodex = keynode.x;
let keynodey = keynode.y;
let tpos = MapData.getRCPos(key.split("_")[0],key.split("_")[1]);
let ipro = keynode.changePos(tpos);
prolist.push(ipro);
this.setLatticeEleRc(key);
}
await Promise.all(prolist)
this.checkEliminate();
if(this.eliminateArr.length>0){
this.eliminate();
}else{
if(type=="fall"){
this.recordGame();
}
this.changeEnable(true);
this.inEliminate = false;
this.checkGameOver("changeToFuHuoPos");
}
}
recordcomp(){
this.inrecord = false;
this.checkGameOver("recordcomp");
}
//游戏记录
recordGame(){
if(!this.requestGameOver){
//操作记录
this.inrecord = true;
this.eptime = Date.now();
engine.globalEvent.dispatchEvent('game-record',
{
score:this.seqscore,
seq:this.seq,
sptime:this.sptime,
eptime:this.eptime
}
);
this.seq+=1;
this.seqscore = 0;
this.sptime = Date.now();
}
}
//相邻检测
attionEliminate(){
let attiondata;
for(let r=MapData.row-1;r>-1;r--){
if(attiondata&&attiondata.length==3){
break;
}
for(let c=MapData.col-1;c>-1;c--){
let checktype = this.getEleTypeByRc(r,c);
let edatarow = this.getEliminateRow(r,c);
let edatacol = this.getEliminateCol(r,c);
if(edatarow.length>2||edatacol.length>2){
// console.error("啥情况,检查----------------");
}
if(edatarow.length==2){
// console.log("横向查找",edatarow,checktype);
let releidx1 = edatarow[0];
let releidx2 = edatarow[1];
let relerow1 = Number(releidx1.split("_")[0]);
let relerow2 = Number(releidx2.split("_")[0]);
let relecol = Number(releidx1.split("_")[1]);
let downrow = relerow1+1;
let uprow = relerow2-1;
let rightcol = relecol+1;
let leftcol = relecol-1;
let uprow1 = relerow2-2;
let downrow1 = relerow1+2;
if(downrow<MapData.row){
if(rightcol<MapData.col){
let nexttype = this.getEleTypeByRc(downrow,rightcol);
if(nexttype==checktype){
attiondata = [downrow+"_"+rightcol,downrow+"_"+relecol,edatarow];
break;
}
}
if(leftcol>-1){
let nexttype = this.getEleTypeByRc(downrow,leftcol);
if(nexttype==checktype){
attiondata = [downrow+"_"+leftcol,downrow+"_"+relecol,edatarow];
break;
}
}
}
if(uprow>-1){
if(rightcol<MapData.col){
let nexttype = this.getEleTypeByRc(uprow,rightcol);
if(nexttype==checktype){
attiondata = [uprow+"_"+rightcol,uprow+"_"+relecol,edatarow];
break;
}
}
if(leftcol>-1){
let nexttype = this.getEleTypeByRc(uprow,leftcol);
if(nexttype==checktype){
attiondata = [uprow+"_"+leftcol,uprow+"_"+relecol,edatarow];
break;
}
}
}
if(uprow1>-1){
let nexttype = this.getEleTypeByRc(uprow1,relecol);
if(nexttype==checktype){
attiondata = [uprow1+"_"+relecol,uprow+"_"+relecol,edatarow];
break;
}
}
if(downrow1<MapData.row){
let nexttype = this.getEleTypeByRc(downrow1,relecol);
if(nexttype==checktype){
attiondata = [downrow1+"_"+relecol,downrow+"_"+relecol,edatarow];
break;
}
}
}
if(edatacol.length==2){
// console.log("竖向查找",edatacol,checktype);
let releidx1 = edatacol[0];
let releidx2 = edatacol[1];
let relerow = Number(releidx1.split("_")[0]);
let relecol1 = Number(releidx1.split("_")[1]);
let relecol2 = Number(releidx2.split("_")[1]);
let rightcol = relecol1+1;
let leftcol = relecol2-1;
let uprow = relerow-1;
let downrow = relerow+1;
let rightcol1 = relecol1+2;
let leftcol1 = relecol2-2;
if(leftcol>-1){
if(uprow>-1){
let nexttype = this.getEleTypeByRc(uprow,leftcol);
if(nexttype==checktype){
attiondata = [uprow+"_"+leftcol,relerow+"_"+leftcol,edatacol];
break;
}
}
if(downrow<MapData.row){
let nexttype = this.getEleTypeByRc(downrow,leftcol);
if(nexttype==checktype){
attiondata = [downrow+"_"+leftcol,relerow+"_"+leftcol,edatacol];
break;
}
}
}
if(rightcol<MapData.col){
if(uprow>-1){
let nexttype = this.getEleTypeByRc(uprow,rightcol);
if(nexttype==checktype){
attiondata = [uprow+"_"+rightcol,relerow+"_"+rightcol,edatacol];
break;
}
}
if(downrow<MapData.row){
let nexttype = this.getEleTypeByRc(downrow,rightcol);
if(nexttype==checktype){
attiondata = [downrow+"_"+rightcol,relerow+"_"+rightcol,edatacol];
break;
}
}
}
if(rightcol1<MapData.col){
let nexttype = this.getEleTypeByRc(relerow,rightcol1);
if(nexttype==checktype){
attiondata = [relerow+"_"+rightcol1,relerow+"_"+rightcol,edatacol];
break;
}
}
if(leftcol1>-1){
let nexttype = this.getEleTypeByRc(relerow,leftcol1);
if(nexttype==checktype){
attiondata = [relerow+"_"+leftcol1,relerow+"_"+leftcol,edatacol];
break;
}
}
// console.log("竖向检查啦啦啦",relerow,relecol1,relecol2);
}
//中间插的,俩边一样的这种
let jianrow = this.getEliminateRowR(r,c);
if(jianrow.length==2){
// console.log("中间插入33",jianrow);
let jianr = Number(jianrow[0].split("_")[0])-1;
let jianc = Number(jianrow[0].split("_")[1]);
let ljianc = jianc-1;
if(ljianc>-1){
let nexttype = this.getEleTypeByRc(jianr,ljianc);
if(nexttype==checktype){
attiondata = [jianr+"_"+ljianc,jianr+"_"+jianc,jianrow];
break;
}
}
let rjianc = jianc+1;
if(rjianc<MapData.col){
let nexttype = this.getEleTypeByRc(jianr,rjianc);
if(nexttype==checktype){
attiondata = [jianr+"_"+rjianc,jianr+"_"+jianc,jianrow];
break;
}
}
}
let jiancol = this.getEliminateRowC(r,c);
if(jiancol.length==2){
// console.log("中间插入44",jiancol);
let jianr = Number(jiancol[0].split("_")[0]);
let jianc = Number(jianrow[0].split("_")[1])-1;
let ujianr = jianr-1;
if(ujianr>-1){
let nexttype = this.getEleTypeByRc(ujianr,jianc);
if(nexttype==checktype){
attiondata = [ujianr+"_"+jianc,jianr+"_"+jianc,jiancol];
break;
}
}
let djianr = jianr+1;
if(djianr<MapData.row){
let nexttype = this.getEleTypeByRc(djianr,jianc);
if(nexttype==checktype){
attiondata = [djianr+"_"+jianc,jianr+"_"+jianc,jiancol];
break;
}
}
}
}
}
// console.log("相邻检测--------------",attiondata);
return attiondata;
}
//检测消除
checkEliminate(){
this.eliminateArr = new Array();
for(let r=MapData.row-1;r>-1;r--){
for(let c=MapData.col-1;c>-1;c--){
let edata = this.getEliminate(r,c);
if(edata){
let etype = edata.etype;
let earr = edata.arr;
this.checkAddEli(etype,earr);
}
}
}
}
//两边一样,中间插入,row
getEliminateRowR(x,y){
let checktype = this.getEleTypeByRc(x,y);
let jianrow = x-2;
let relearr = new Array();
relearr.push(x+"_"+y);
if(jianrow>-1){
let jiantype = this.getEleTypeByRc(jianrow,y);
if(jiantype==checktype){
relearr.push(jianrow+"_"+y);
}
}
return relearr;
}
//两边一样,中间插入,col
getEliminateRowC(x,y){
let checktype = this.getEleTypeByRc(x,y);
let jiancol = y-2;
let relearr = new Array();
relearr.push(x+"_"+y);
if(jiancol>-1){
let jiantype = this.getEleTypeByRc(x,jiancol);
if(jiantype==checktype){
relearr.push(x+"_"+jiancol);
}
}
return relearr;
}
getEliminateRow(x,y){
let checktype = this.getEleTypeByRc(x,y);
let relearr = new Array();
relearr.push(x+"_"+y);
for(let r=x-1;r>-1;r--){
let reletype = this.getEleTypeByRc(r,y);
if(checktype==reletype){
relearr.push(r+"_"+y);
}else{
break;
}
}
return relearr;
}
getEliminateCol(x,y){
let checktype = this.getEleTypeByRc(x,y);
let celearr = new Array();
celearr.push(x+"_"+y);
for(let c=y-1;c>-1;c--){
let celetype = this.getEleTypeByRc(x,c);
if(checktype==celetype){
celearr.push(x+"_"+c);
}else{
break;
}
}
return celearr;
}
getEliminate(x,y){
let checktype = this.getEleTypeByRc(x,y);
let relearr = this.getEliminateRow(x,y);
let celearr = this.getEliminateCol(x,y);
let eliminatearr = new Array();
if(relearr.length>=3){
eliminatearr.push(...relearr);
}
if(celearr.length>=3){
eliminatearr.push(...celearr);
}
if(eliminatearr.length>0){
return {
etype:checktype,
arr:eliminatearr
}
}else{
return false;
}
}
getEleTypeByRc(r,c){
let rc = r+"_"+c;
let elename = this.lattices[rc];
let ele:Element = this.container.getChildByName(elename);
if(ele){
let eletype = ele.type;
return eletype;
}
}
checkAddEli(etype,earr:Array<string>){
let addnew = true;
let inaidx;
for(let i1=0;i1<this.eliminateArr.length;i1++){
let i1data = this.eliminateArr[i1];
for(let i2=0;i2<i1data.length;i2++){
let i2data = i1data[i2];
let i2eliname = i2data.idxname;
let inidx = earr.indexOf(i2eliname);
if(inidx!=-1){
addnew = false;
break;
}
}
if(!addnew){
inaidx = i1;
break;
}
}
if(addnew){
let addarr = new Array();
for(let i1=0;i1<earr.length;i1++){
let i1name = earr[i1];
addarr.push({
idxname:i1name,
type:etype
})
}
this.eliminateArr.push(addarr);
}else{
for(let i4=0;i4<earr.length;i4++){
let i4name = earr[i4];
let addele = true;
for(let i3=0;i3<this.eliminateArr[inaidx].length;i3++){
let i3data = this.eliminateArr[inaidx][i3];
let i3eliname = i3data.idxname;
if(i3eliname==i4name){
addele = false;
break;
}
}
if(addele){
this.eliminateArr[inaidx].push({
idxname:i4name,
type:etype
})
}
}
}
}
//获得这个位置掉落的元素
getFallRcEle(r,c){
for(let fr=r-1;fr>-1;fr--){
let frc = fr+"_"+c;
let frcname = this.lattices[frc];
if(frcname!="empty"){
this.lattices[frc] = "empty";
return frcname;
}
}
return false;
}
addScoreAni(ielix,ieliy,ietype,addscore){
let anitxt = MapData.getOneTxt();
anitxt.alpha = 0;
let txtcolor = "#bd882f";
switch(ietype){
case ElementType.gdog:
txtcolor = "#d3ff6d";
break;
case ElementType.pbird:
txtcolor = "#ff51d4";
break;
case ElementType.hniu:
txtcolor = "#ffab55";
break;
case ElementType.bribbit:
txtcolor = "#b3d4ff";
break;
case ElementType.rpig:
txtcolor = "#f2453b";
break;
default:
console.error("未定义类型,检查");
break;
}
anitxt.fillColor = txtcolor;
let anix = ielix+MapData.itemsize/2-100;
let aniy = ieliy+this.conty+MapData.itemsize/2-35;
anitxt.text = "+"+addscore;
this.txtcontainer.addChild(anitxt);
anitxt.x = anix;
anitxt.y = aniy;
anitxt.scaleX = 0;
anitxt.scaleY = 0;
anitxt.alpha = 1;
engine.Tween.get(anitxt,{loop:false}).set({
x:anix,
y:aniy,
scaleX:0,
scaleY:0
})
.to({
y:aniy-50,
scaleX:1,
scaleY:1,
},300)
.to({
y:aniy-120,
alpha:0
},500)
.call(()=>{
this.txtcontainer.removeChild(anitxt);
this.score += addscore;
MapData.recoverTxt(anitxt);
})
}
changeHomeShow(mode="day"){
let _v = true;
if(mode=="day"){
_v = true;
}else{
_v = false;
}
// this.homeimgday.visible = _v;
// this.homeimgnight.visible = !_v;
}
//使用炸弹
boomeEle(row,col){
this.playEffect("爆炸音效");
this.unShowEleAttion();
this.useBoom = false;
//炸弹使用完毕
engine.globalEvent.dispatchEvent('game-useboomafter',{});
this.anicontainer.removeChild(this.selectimg);
// this.changeEnable(false);
this.selectArr = new Array();
// console.log("使用炸弹rc",row,col);
this.eliminateArr = new Array();
for(let r=0;r<MapData.row;r++){
let irc = r+"_"+col;
let ielename = this.lattices[irc];
let iele:Element = this.container.getChildByName(ielename);
if(iele){
let eletype = iele.type;
this.eliminateArr.push([
{
idxname:irc,
type:eletype
}
])
}
}
for(let c=0;c<MapData.col;c++){
if(c!=col){
let irc = row+"_"+c;
let ielename = this.lattices[irc];
let iele:Element = this.container.getChildByName(ielename);
if(iele){
let eletype = iele.type;
this.eliminateArr.push([
{
idxname:irc,
type:eletype
}
])
}
}
}
// console.log("使用炸弹消除的元素",this.eliminateArr);
this.boomani.x = MapData.getCx(col);
this.boomani.y = MapData.getRy(row);
this.boomani.playBoomAni();
this.eliminate();
}
//指定新手引导
setGuidePath(){
let showidx = ["0_3","1_3","2_3","3_3"];
//非自动,手动算出path
let path = [
[364,7],
[364,479],
[484,479],
[484,7],
]
//画遮罩
//底框609,607
this.guideDraw.clear();
this.guideDraw.beginFill(0x000000,0.7);
this.guideDraw.moveTo(0,0);
this.guideDraw.lineTo(609,0);
this.guideDraw.lineTo(609,607);
this.guideDraw.lineTo(0,607);
this.guideDraw.lineTo(0,0);
this.shoueffect.x = 409;
this.shoueffect.y = -40;
this.guideDraw.moveTo(path[0][0],path[0][1]);
for(let i=1;i<path.length;i++){
let idotx = path[i][0];
let idoty = path[i][1];
this.guideDraw.lineTo(idotx,idoty);
}
this.guideDraw.lineTo(path[0][0],path[0][1]);
this.guideDraw.endFill();
}
setGuideShow(){
this.inguide = true;
this.guideCont.visible = true;
this.guideCont.alpha = 0;
this.shoueffect.visible = true;
this.shoueffect.play(1);
let ableidx = ["0_3","1_3"];
for(let key in this.lattices){
let isinable = ableidx.indexOf(key);
let ieliname = this.lattices[key];
let ielinode:Element = this.container.getChildByName(ieliname);
if(ielinode){
if(isinable==-1){
ielinode.touch = false;
}else{
ielinode.touch = true;
}
}
}
engine.Tween.removeTweens(this.guideCont);
engine.Tween.get(this.guideCont)
.to({
alpha:1
},200)
}
//使用道具
usetool(data){
let tooltype = data.tooltype;
if(tooltype=="time"){//加时道具
let addtime = data.addtime;
let ngtime = this.gametime+addtime;
this.gametime = ngtime;
}else if(tooltype=="boom"){//炸弹道具
let use = data.useboom;
this.useBoom = use;
}
}
//获取一个消除特效
getOneEffect(){
let oneffect;
if(this.diseffectArr.length>0){
oneffect = this.diseffectArr.shift();
}else{
oneffect = createSvga("消除动效");
oneffect.addEventListener(engine.Event.ENTER_FRAME,this.playDisEffectComplete,this);
oneffect.mouseEnabled = false;
oneffect.mouseChildren = false;
}
return oneffect;
}
//消除动效播放完毕
playDisEffectComplete(e){
let target = e.target;
let curframe = target.currentFrame;
let totalframe = target.totalFrames;
if(curframe>=totalframe){
target.stop(1);
this.anicontainer.removeChild(target);
this.diseffectArr.push(target);
}
}
//音效播放
playEffect(sound:string){
console.log("音效播放",sound);
if(this.mute==1){
playSound(sound);
}
}
}
/**
* Created by rockyl on 2020-01-09.
*/
import GameView from "./GameView";
import {injectProps} from "../props";
export class GameWrapper extends engine.Container {
private _gameView: GameView;
constructor() {
super();
this._gameView = new GameView();
this.addChild(this._gameView);
engine.globalEvent.addEventListener('game-init',this.init,this);
engine.globalEvent.addEventListener('game-reset',this.reset,this);
engine.globalEvent.addEventListener('game-start',this.start,this);
engine.globalEvent.addEventListener('game-pause',this.pause,this);
engine.globalEvent.addEventListener('game-resume',this.resume,this);
engine.globalEvent.addEventListener('game-recordcomp',this.recordcomp,this);
engine.globalEvent.addEventListener('game-newuserguide',this.newUserGuide,this);
engine.globalEvent.addEventListener('game-usetool',this.usetool,this);
}
init(event:engine.Event){
// console.log("gamewrapper-init",event);
let time = event.data.time;
let level = event.data.level;
let mode = event.data.mode;
let mute = event.data.mute;
this._gameView.init(time,level,mode,mute);
}
reset(event:engine.Event){
// console.log("gamewrapper-reset",event);
let time = event.data.time;
let level = event.data.level;
let mode = event.data.mode;
this._gameView.reset(time,level,mode);;
}
start(){
this._gameView.start();
}
pause(){
this._gameView.pause();
}
resume(){
this._gameView.resume();
}
recordcomp(){
this._gameView.recordcomp();
}
newUserGuide(){
this._gameView.setGuideShow();
}
usetool(event:engine.Event){
let data = event.data;
this._gameView.usetool(data);
}
}
import Element from "./ele/Element";
import { getTextureByName } from "./utils";
export enum ElementType{
gdog = 1,
pbird,
hniu,
bribbit,
rpig
}
export enum GameEvent{
SelectEle = "SelectEle",
}
export default class MapData{
//单格大小
static itemsize = 116;
//
static paddingw = 7;
static paddingh = 7;
static paddingwi = 4;
static paddinghi = 2;
//
static row = 5;
static col = 5;
//行-列,对应位置
static posData = {
};
static eleidx = 1;
static elePool = {};
static anispeed = 1000;
static gdotTex:engine.Texture;
static pbirdTex:engine.Texture;
static hniuTex:engine.Texture;
static bribbitTex:engine.Texture;
static rpigTex:engine.Texture;
static levelData:Array<Array<Array<number>>> = [
[
[2,3,4,5,4],
[4,5,3,2,4],
[2,5,3,5,1],
[3,4,4,5,3],
[1,5,2,1,4],
],
[
[5,2,1,2,1],
[3,1,4,5,4],
[2,5,3,5,1],
[5,4,1,2,3],
[4,1,3,1,2],
],
[
[2,4,1,5,2],
[2,3,4,1,3],
[4,1,3,2,3],
[3,2,1,1,4],
[1,1,3,5,4],
],
[
[3,2,1,4,5],
[2,4,1,2,3],
[2,3,2,3,3],
[4,4,5,5,4],
[3,3,1,2,4],
],
[
[4,5,1,2,4],
[3,2,3,4,2],
[1,5,2,3,5],
[4,5,5,1,3],
[1,2,3,2,4],
]
]
static getRy(r){
return this.paddingh+r*(this.itemsize+this.paddinghi);
}
static getCx(c){
return this.paddingw+c*(this.itemsize+this.paddingwi);
}
static getRCPos(r,c){
let x = this.getCx(c);
let y = this.getRy(r);
return [x,y];
}
static adaptElePos(pos,wid,hei){
let x = pos[0]+(this.itemsize-wid)/2;
let y = pos[1]+(this.itemsize-hei)/2;
return [x,y];
}
static getEtypeImgName(type:ElementType){
let ename:string;
switch(type){
case ElementType.gdog:
ename = "狗";
break;
case ElementType.pbird:
ename = "鸟";
break;
case ElementType.hniu:
ename = "牛";
break;
case ElementType.bribbit:
ename = "兔子";
break;
case ElementType.rpig:
ename = "猪";
break;
default:
console.error("未定义元素类型");
break;
}
return ename;
}
static getEtypeImgTex(type:ElementType){
let etex:engine.Texture;
switch(type){
case ElementType.gdog:
if(!this.gdotTex){
this.gdotTex = getTextureByName("狗");
console.log("新素材加载---狗");
}
etex = this.gdotTex;
break;
case ElementType.pbird:
if(!this.pbirdTex){
this.pbirdTex = getTextureByName("鸟");
console.log("新素材加载---鸟");
}
etex = this.pbirdTex;
break;
case ElementType.hniu:
if(!this.hniuTex){
this.hniuTex = getTextureByName("牛");
console.log("新素材加载---牛");
}
etex = this.hniuTex;
break;
case ElementType.bribbit:
if(!this.bribbitTex){
this.bribbitTex = getTextureByName("兔子");
console.log("新素材加载---兔子");
}
etex = this.bribbitTex;
break;
case ElementType.rpig:
if(!this.rpigTex){
this.rpigTex = getTextureByName("猪");
console.log("新素材加载---猪");
}
etex = this.rpigTex;
break;
default:
console.error("未定义元素类型");
break;
}
return etex;
}
static getRandEtype(){
let eletypeArr = [ElementType.gdog,ElementType.pbird,ElementType.hniu,ElementType.bribbit,ElementType.rpig];
let etype = eletypeArr[Math.floor(Math.random()*eletypeArr.length)];
return etype;
}
static initPoolEle(){
// console.error("初始化元素池");
this.gdotTex = getTextureByName("狗");
this.pbirdTex = getTextureByName("鸟");
this.hniuTex = getTextureByName("牛");
this.bribbitTex = getTextureByName("兔子");
this.rpigTex = getTextureByName("猪");
let eletypes = [ElementType.gdog,ElementType.pbird,ElementType.hniu,ElementType.bribbit,ElementType.rpig];
this.elePool["ele"] = new Array();
//初始5*5个元素备用;
for(let i=0;i<eletypes.length;i++){
let itype = eletypes[i];
// this.elePool[itype] = new Array();
for(let a=0;a<5;a++){
let iele = new Element();
// iele.eimage.texture = this.getEtypeImgTex(itype);
this.elePool["ele"].push(iele);
}
}
//得分得txt
this.elePool["score"] = new Array();
for(let t=0;t<8;t++){
let itxt = new engine.Label();
itxt.size = 66;
itxt.width = 200;
itxt.height = 70;
itxt.textAlign = engine.TEXT_ALIGN.CENTER;
itxt.verticalAlign = engine.VERTICAL_ALIGN.MIDDLE;
itxt.anchorY = 35;
itxt.anchorX = 100;
itxt.bold = true;
this.elePool["score"].push(itxt);
}
}
static getOneEle(type:ElementType):Element{
let ele:Element;
if(this.elePool["ele"]){
if(this.elePool["ele"].length>0){
ele = this.elePool["ele"].shift();
}
}else{
this.elePool["ele"] = new Array();
}
if(!ele){
console.error("创建了新的了ele");
ele = new Element();
// ele.eimage.texture = getTextureByName(this.getEtypeImgName(type));
}
ele.name = "ele_"+this.eleidx;
this.eleidx += 1;
ele.init(type)
return ele;
}
static getOneTxt():engine.Label{
let itxt:engine.Label;
if(this.elePool["score"]){
if(this.elePool["score"].length>0){
itxt = this.elePool["score"].shift();
}
}else{
this.elePool["score"] = new Array();
}
if(!itxt){
itxt = new engine.Label();
itxt.size = 66;
itxt.width = 200;
itxt.height = 70;
itxt.textAlign = engine.TEXT_ALIGN.CENTER;
itxt.verticalAlign = engine.VERTICAL_ALIGN.MIDDLE;
itxt.anchorY = 35;
itxt.anchorX = 100;
itxt.bold = true;
// console.log("创建了新的txt");
}
itxt.mouseEnabled = false;
return itxt;
}
static recoverEle(ele:Element,type:ElementType){
if(ele.eimage){
ele.eimage.texture = null;
}
this.elePool["ele"].push(ele);
}
static recoverTxt(txt:engine.Label){
this.elePool["score"].push(txt);
}
static getDistance(p1,p2){
let p1x = p1[0];
let p1y = p1[1];
let p2x = p2[0];
let p2y = p2[1];
let dis = Math.sqrt(Math.pow(p1x-p2x,2)+Math.pow(p1y-p2y,2));
return dis;
}
}
\ No newline at end of file
import { getTextureByName } from "./utils";
export default class boomAni extends engine.Container{
constructor(){
super();
this.once(engine.Event.ADDED_TO_STAGE,this.setup,this);
}
boomimg:engine.Image;
hboomimg:engine.Image;
vboomimg:engine.Image;
setup(){
this.boomimg = new engine.Image(getTextureByName("炸弹中心"));
this.boomimg.anchorX = 95;
this.boomimg.anchorY = 108;
this.boomimg.x = -32;
this.boomimg.y = -47;
let boomtex:engine.Texture = getTextureByName("爆炸闪光");
let boomwid = boomtex.width;
let boomhei = boomtex.height;
this.hboomimg = new engine.Image();
this.vboomimg = new engine.Image();
this.hboomimg.texture = boomtex;
this.vboomimg.texture = boomtex;
this.hboomimg.width = boomwid;
this.hboomimg.height = boomhei;
this.hboomimg.anchorX = boomwid/2;
this.hboomimg.anchorY = boomhei/2;
this.hboomimg.y = -boomhei/2+65;
this.hboomimg.x = -20;
this.vboomimg.width = boomwid;
this.vboomimg.height = boomhei;
this.vboomimg.anchorX = boomwid/2;
this.vboomimg.anchorY = boomhei/2;
this.vboomimg.rotation = 90;
this.vboomimg.y = -boomhei/2+65;
this.vboomimg.x = -20;
this.hboomimg.scaleY = 0.1;
this.vboomimg.scaleY = 0.1;
this.addChild(this.boomimg);
this.addChild(this.hboomimg);
this.addChild(this.vboomimg);
this.mouseEnabled = false;
this.mouseChildren = false;
this.alpha = 0;
// this.playBoomAni();
}
playBoomAni(){
this.alpha = 1;
this.boomimg.scaleX = 0;
this.boomimg.scaleY = 0;
engine.Tween.get(this.boomimg)
.to({
scaleX:1.2,
scaleY:1.2
},200,engine.Ease.quadIn);
this.hboomimg.scaleY = 0.1;
this.hboomimg.alpha = 1;
this.vboomimg.scaleY = 0.1;
this.vboomimg.alpha = 1;
engine.Tween.get(this.hboomimg)
.to({
scaleY:1,
alpha:0.8
},150,engine.Ease.quadIn)
.to({
alpha:0
},50,engine.Ease.quadIn);
engine.Tween.get(this.vboomimg)
.to({
scaleY:1,
alpha:0.8
},150,engine.Ease.quadIn)
.to({
alpha:0
},50,engine.Ease.quadIn)
.call(()=>{
this.alpha = 0;
})
}
}
\ No newline at end of file
import MapData, { ElementType, GameEvent } from "../MapData";
import { getTextureByName } from "../utils";
export default class Element extends engine.Container{
type:ElementType;
eimage:engine.Image;
inrow;
incol;
set touch(touch){
this.mouseEnabled = touch;
this.mouseChildren = touch;
}
constructor(){
super();
this.width = MapData.itemsize;
this.height = MapData.itemsize;
this.anchorX = MapData.itemsize/2;
this.eimage = new engine.Image();
this.addChild(this.eimage);
this.touch = true;
// this.addEventListener(engine.MouseEvent.CLICK,this.selectele,this);
this.addEventListener(engine.MouseEvent.MOUSE_DOWN,this.selectele,this);
this.addEventListener(engine.MouseEvent.MOUSE_MOVE,this.changemove,this);
}
init(type:ElementType){
this.anchorY = MapData.itemsize;
this.scaleX = 1;
this.scaleY = 1;
this.alpha = 1;
this.type = type;
let ename = MapData.getEtypeImgName(type);
this.eimage.texture = MapData.getEtypeImgTex(type);
let imgwid = this.eimage.texture.width;
let imghei = this.eimage.texture.height;
// console.log("大小",imgwid,imghei);
this.eimage.x = (this.width - imgwid)/2;
this.eimage.y = (this.height-imghei)/2;
}
setrc(r,c){
this.inrow = r;
this.incol = c;
}
selectele(e:engine.MouseEvent){
engine.globalEvent.dispatchEvent(GameEvent.SelectEle,{
r:this.inrow,
c:this.incol,
type:"mouse_down"
})
}
changemove(e:engine.MouseEvent){
// console.log(this.inrow+":"+this.incol);
engine.globalEvent.dispatchEvent(GameEvent.SelectEle,{
r:this.inrow,
c:this.incol,
type:"mouse_move"
})
}
public get factor():number {
return 0;
}
public set factor(value:number) {
this.x = (1 - value) * (1 - value) * this.p1x + 2 * value * (1 - value) * this.c1x + value * value * this.p2x;
this.y = (1 - value) * (1 - value) * this.p1y + 2 * value * (1 - value) * this.c1y + value * value * this.p2y;
var mscale = (1 - value) * (1 - value) * 1 + 2 * value * (1 - value) * 0.6 + value * value * 0.35;
this.scaleX = mscale;
this.scaleY = mscale;
}
p1x;
p1y;
c1x;
c1y;
p2x;
p2y;
//飞到小屋
flyToHome(tx,ty,time){
this.p1x = this.x;
this.p1y = this.y+20;
this.c1x = (this.p1x-tx)/4+tx;
this.c1y = ty;
this.p2x = tx;
this.p2y = ty;
engine.Tween.removeTweens(this);
engine.Tween.get(this).to({
scaleX:1.1,
scaleY:1.1
},200)
.to({
scaleX:1.1,
scaleY:0.88
},100)
.to({
scaleX:0.98,
scaleY:0.98,
y:this.y+20
},100)
.call(()=>{
this.factor = 0;
engine.Tween.get(this).to({
factor:1
},450)
.call(()=>{
let nodeparent:engine.Container = this.parent;
nodeparent&&nodeparent.removeChild(this);
MapData.recoverEle(this,this.type);
})
})
}
changePos(tpos:Array<number>){
let nx = this.x;
let ny = this.y;
let tx = tpos[0];
let ty = tpos[1];
let dis = MapData.getDistance([nx,ny],tpos);
let time = Math.ceil(dis/MapData.anispeed*1000);
engine.Tween.removeTweens(this);
let pro = new Promise(res=>{
engine.Tween.get(this,{loop:false}).to({
x:tx,
y:ty
},time)
.call(()=>{
// console.log("单个移动完毕");
res();
})
})
return pro;
}
}
\ No newline at end of file
/**
* 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);
}
...@@ -46,7 +46,7 @@ function launchWithCustomModule(customModule) { ...@@ -46,7 +46,7 @@ function launchWithCustomModule(customModule) {
}, 100); }, 100);
setTimeout(() => { setTimeout(() => {
engine.globalEvent.dispatchEvent('recycling-start', { time: 1500, maxScore: 200, speed: 3, sound: 1 }); engine.globalEvent.dispatchEvent('recycling-start', { time: 1500, maxScore: 200, speed: 3, sound: 1,isNewPlayer:0 });
const d = engine.gameStage.sceneContainer.getChildAt(0); const d = engine.gameStage.sceneContainer.getChildAt(0);
}, 2000); }, 2000);
......
(function (global, factory) { "use strict";var tslib=require("tslib");function getTexture(e){return engine.Texture.from(getAssetByUUID(e).uuid)}function getTextureByName(e){return getTexture(engine.getAssetByName(e).uuid)}function playSound(e){engine.playSound(engine.getAssetByName(e).uuid,{keep:!0})}function createSvga(e,t){var i=new svga.Svga;return i.source="asset://"+engine.getAssetByName(e).uuid,i}var props={};function prepareProps(){var e=getProps();engine.injectProp(props,e)}function injectProps(e){engine.injectProp(props,e)}var GarbageTypes,Conveyor=function(i){function e(){var e=i.call(this)||this;e.y=904.21;var t=new engine.Sprite(getTextureByName("conveyor"));return e.addChild(t),e.idx0=e.createItem(75,50),e.idx1=e.createItem(225,50),e.idx2=e.createItem(375,50),e.idx3=e.createItem(525,50),e.idx4=e.createItem(675,50),e}return tslib.__extends(e,i),e.prototype.clear=function(){this.clearItem(this.idx0),this.clearItem(this.idx1),this.clearItem(this.idx2),this.clearItem(this.idx3),this.clearItem(this.idx4)},e.prototype.clearItem=function(e){0<e.children.length&&e.removeChildAt(0)},e.prototype.createItem=function(e,t){var i=new engine.Sprite;return this.addChild(i),i.x=e,i.y=t,i},e}(engine.Sprite);!function(e){e.recoverableWaste="recoverableWaste",e.harmfulWaste="harmfulWaste",e.wetWaste="wetWaste",e.dryWaste="dryWaste"}(GarbageTypes=GarbageTypes||{});var GarbageConfig=function(){function e(){}return e.config=[{name:"保鲜盒",source:"g00",type:GarbageTypes.recoverableWaste,width:129,height:111},{name:"报纸",source:"g01",type:GarbageTypes.recoverableWaste,width:138,height:144},{name:"贝壳",source:"g02",type:GarbageTypes.dryWaste,width:79,height:117},{name:"冰箱",source:"g03",type:GarbageTypes.recoverableWaste,width:63,height:151},{name:"菜梗菜叶",source:"g04",type:GarbageTypes.wetWaste,width:144,height:98},{name:"残枝落叶",source:"g05",type:GarbageTypes.wetWaste,width:120,height:99},{name:"茶叶渣",source:"g06",type:GarbageTypes.wetWaste,width:86,height:96},{name:"尘土",source:"g07",type:GarbageTypes.dryWaste,width:109,height:114},{name:"创口贴",source:"g08",type:GarbageTypes.dryWaste,width:112,height:90},{name:"大骨头",source:"g09",type:GarbageTypes.dryWaste,width:89,height:101},{name:"普通干电池",source:"g11",type:GarbageTypes.dryWaste,width:89,height:131},{name:"方便面盒",source:"g12",type:GarbageTypes.dryWaste,width:89,height:168},{name:"废弃食用油脂",source:"g13",type:GarbageTypes.wetWaste,width:131,height:164},{name:"骨骼内脏",source:"g14",type:GarbageTypes.wetWaste,width:104,height:82},{name:"锅具",source:"g15",type:GarbageTypes.recoverableWaste,width:119,height:149},{name:"果核",source:"g16",type:GarbageTypes.wetWaste,width:99,height:95},{name:"果皮",source:"g17",type:GarbageTypes.wetWaste,width:115,height:127},{name:"化妆品",source:"g18",type:GarbageTypes.harmfulWaste,width:67,height:151},{name:"鸡蛋壳",source:"g19",type:GarbageTypes.wetWaste,width:99,height:107},{name:"剪刀",source:"g20",type:GarbageTypes.recoverableWaste,width:96,height:127},{name:"胶带",source:"g21",type:GarbageTypes.dryWaste,width:87,height:113},{name:"榴莲壳",source:"g22",type:GarbageTypes.dryWaste,width:136,height:116},{name:"毛巾",source:"g23",type:GarbageTypes.recoverableWaste,width:108,height:96},{name:"纽扣电池",source:"g24",type:GarbageTypes.harmfulWaste,width:87,height:89},{name:"破旧陶瓷罐",source:"g25",type:GarbageTypes.dryWaste,width:110,height:125},{name:"杀虫剂",source:"g26",type:GarbageTypes.harmfulWaste,width:64,height:160},{name:"剩菜剩饭",source:"g27",type:GarbageTypes.wetWaste,width:128,height:96},{name:"手机",source:"g28",type:GarbageTypes.recoverableWaste,width:82,height:142},{name:"书本",source:"g29",type:GarbageTypes.recoverableWaste,width:106,height:132},{name:"玻璃杯",source:"g30",type:GarbageTypes.recoverableWaste,width:62,height:119},{name:"水银温度计",source:"g31",type:GarbageTypes.harmfulWaste,width:109,height:162},{name:"水银血压计",source:"g32",type:GarbageTypes.harmfulWaste,width:115,height:147},{name:"塑料桶",source:"g33",type:GarbageTypes.recoverableWaste,width:92,height:131},{name:"卫生纸",source:"g34",type:GarbageTypes.dryWaste,width:92,height:132},{name:"污染织物",source:"g35",type:GarbageTypes.dryWaste,width:128,height:139},{name:"污染纸张",source:"g36",type:GarbageTypes.dryWaste,width:96,height:136},{name:"洗衣机",source:"g37",type:GarbageTypes.recoverableWaste,width:87,height:157},{name:"烟蒂",source:"g38",type:GarbageTypes.dryWaste,width:87,height:124},{name:"药品",source:"g39",type:GarbageTypes.harmfulWaste,width:109,height:131},{name:"药品包装",source:"g40",type:GarbageTypes.harmfulWaste,width:108,height:125},{name:"椰子壳",source:"g41",type:GarbageTypes.dryWaste,width:104,height:119},{name:"衣服",source:"g42",type:GarbageTypes.recoverableWaste,width:83,height:137},{name:"衣架",source:"g43",type:GarbageTypes.recoverableWaste,width:132,height:125},{name:"易拉罐",source:"g44",type:GarbageTypes.recoverableWaste,width:65,height:133},{name:"荧光灯",source:"g45",type:GarbageTypes.harmfulWaste,width:90,height:118},{name:"油漆桶",source:"g46",type:GarbageTypes.harmfulWaste,width:65,height:143},{name:"一次性纸杯",source:"g47",type:GarbageTypes.dryWaste,width:76,height:116},{name:"纸尿裤",source:"g48",type:GarbageTypes.dryWaste,width:93,height:138},{name:"纸箱",source:"g49",type:GarbageTypes.recoverableWaste,width:112,height:118},{name:"指甲油",source:"g50",type:GarbageTypes.harmfulWaste,width:64,height:138}],e}(),transStores=function(e){var n=[];e.forEach(function(e){!function(e){for(var t=0,i=n;t<i.length;t++){var r=i[t];if(e.targetType==r.targetType&&e.itemType==r.itemType&&e.itemName==r.itemName)return!0}return!1}(e)&&n.push(e)}),e=n,n=[];var a=[];return e.forEach(function(e){!function(e){for(var t=0,i=n;t<i.length;t++){var r=i[t];if(e.itemName==r.itemName)return a.push(r.itemName),!0}return!1}(e)&&n.push(e)}),(e=n).forEach(function(e){-1!=a.indexOf(e.itemName)&&(e.targetType=e.itemType)}),e.map(function(e){return{targetName:getTargetName(e.targetType),isCorrect:e.targetType==e.itemType,itemName:e.itemName,itemTypeName:getTargetName(e.itemType)}})},getTargetName=function(e){switch(e){case GarbageTypes.recoverableWaste:return"可回收物";case GarbageTypes.harmfulWaste:return"有害垃圾";case GarbageTypes.wetWaste:return"湿垃圾";case GarbageTypes.dryWaste:return"其他垃圾"}},checkHit=function(e,t){var i=e.x,r=e.y,n=e.texture,a=n.width,s=n.height;return i>t.x&&r>t.y&&i+a<t.x+t.width&&r+s<t.y+t.height},removeChild=function(e){e&&e.parent&&e.parent.removeChild(e)},removeEle=function(e,t){var i=t.indexOf(e);0<=i&&t.splice(i,1)},shuffle=function(e){for(var t=e.length;t;){var i=Math.floor(Math.random()*t--),r=[e[t],e[i]];e[i]=r[0],e[t]=r[1]}return e},WrongTips=function(t){function e(){var e=t.call(this)||this;return e.img=new engine.Image,e.img.texture=getTextureByName("wrongTips"),e.addChild(e.img),e.img.anchorX=44,e.img.anchorY=42.5,e.visible=!1,e}return tslib.__extends(e,t),e.prototype.play=function(e){this.visible=!0,props.sound&&playSound("wrongTipsMp3");engine.Tween.get(this.img).set({x:0,y:0,scaleX:1,scaleY:1,alpha:1}).to({x:20},70).to({x:0},70).to({x:-20},70).to({x:0},70).wait(200).to({alpha:0},300),this.x=e.x+180,this.y=e.y},e}(engine.Sprite),getTargetRect=function(e,t){switch(e){case GarbageTypes.dryWaste:return t.dryWaste;case GarbageTypes.wetWaste:return t.wetWaste;case GarbageTypes.harmfulWaste:return t.harmfulWaste;case GarbageTypes.recoverableWaste:return t.recoverableWaste}},Conveyors=function(i){function e(e){var t=i.call(this)||this;return t.conveyorsPool=[],t.GarbageConfig=GarbageConfig.config,t.datas=[],t.wrapper=e,t}return tslib.__extends(e,i),e.prototype.initData=function(e,t){this.conveyor0=e,this.conveyor1=t},e.prototype.setDefault=function(){this.score=0,this.conveyorsPool.push(this.conveyor0),this.conveyorsPool.push(this.conveyor1);for(var e=shuffle(this.GarbageConfig.concat([])),t=0;t<GarbageConfig.config.length;t++)e[t].idx=t,e[t].isRight=!1,e[t].isMistake=!1,e[t].isOnStage=!1,this.datas.push(e[t]);for(t=0;t<5;t++){var i=this.datas[t],r=new engine.Sprite(getTextureByName(i.source));r.isWrong=!1,r.isRight=!1,i.isOnStage=!0,r.data=i,r.type=i.type,r.name=i.name,r.anchorX=i.width/2,r.anchorY=i.height,r.x=-i.width/2,r.y=40-i.height,this.conveyor1["idx"+t].addChild(r),r.addEventListener(engine.MouseEvent.MOUSE_DOWN,this.onDown_garbage,this)}},e.prototype.startConveyors=function(){this.setDefault(),engine.gameStage.addEventListener(engine.Event.ENTER_FRAME,this.onEnterFrame,this)},e.prototype.onEnterFrame=function(e,t,i){if(this.score==(props.maxScore||100)&&(this.gameOver(),this.wrapper.stop(),props.sound&&playSound("gameOverMp3")),this.conveyorsPool.forEach(function(e){e.x-=props.speed||3}),this.conveyorsPool[this.conveyorsPool.length-1].x<=764){var r=new Conveyor;r.x=this.conveyorsPool[this.conveyorsPool.length-1].x+764,this.wrapper.addChild(r),this.conveyorsPool.push(r)}else{for(var n=[],a=0;a<this.datas.length;a++){(u=this.datas[a]).isRight||u.isOnStage||n.push(u)}for(var s=this.conveyorsPool[this.conveyorsPool.length-1],o=0;o<5;o++)if(!s["idx"+o].children[0]){var h=n.shift();if(!h)break;h.isOnStage=!0;var g=new engine.Sprite(getTextureByName(h.source));g.data=h,g.isWrong=!1,g.isRight=!1,g.type=h.type,g.name=h.name,g.anchorX=h.width/2,g.anchorY=h.height,g.x=-h.width/2,g.y=40-h.height,s["idx"+o].addChild(g),g.addEventListener(engine.MouseEvent.MOUSE_DOWN,this.onDown_garbage,this)}}if(this.conveyorsPool[0].x<-750){for(var c=0;c<this.datas.length;c++){var u=this.datas[c],p=this.conveyorsPool[0].idx4;if(p.children[0]&&u.name==p.children[0].name){u.isOnStage=!1,removeEle(u,this.datas),this.datas.push(u),p.removeChild(p.children[0]);break}}this.conveyorsPool.shift()}else if(this.conveyorsPool[0].x<-600)for(c=0;c<this.datas.length;c++){var u=this.datas[c],l=this.conveyorsPool[0].idx3;if(l.children[0]&&u.name==l.children[0].name){u.isOnStage=!1,removeEle(u,this.datas),this.datas.push(u),l.removeChild(l.children[0]);break}}else if(this.conveyorsPool[0].x<-450)for(c=0;c<this.datas.length;c++){var u=this.datas[c],d=this.conveyorsPool[0].idx2;if(d.children[0]&&u.name==d.children[0].name){u.isOnStage=!1,removeEle(u,this.datas),this.datas.push(u),d.removeChild(d.children[0]);break}}else if(this.conveyorsPool[0].x<-300)for(c=0;c<this.datas.length;c++){var u=this.datas[c],y=this.conveyorsPool[0].idx1;if(y.children[0]&&u.name==y.children[0].name){u.isOnStage=!1,removeEle(u,this.datas),this.datas.push(u),y.removeChild(y.children[0]);break}}else if(this.conveyorsPool[0].x<-150)for(c=0;c<this.datas.length;c++){var u=this.datas[c],m=this.conveyorsPool[0].idx0;if(m.children[0]&&u.name==m.children[0].name){u.isOnStage=!1,removeEle(u,this.datas),this.datas.push(u),m.removeChild(m.children[0]);break}}},e.prototype.addscore=function(){this.score+=props.onceScore||2,engine.globalEvent.dispatchEvent("recycling-score-update",{score:this.score})},e.prototype.gameOver=function(){engine.gameStage.removeEventListener(engine.Event.ENTER_FRAME,this.onEnterFrame,this),engine.globalEvent.dispatchEvent("recycling-game-end",transStores(this.stores))},e.prototype.onDown_garbage=function(e){this._currentDragView&&removeChild(this._currentDragView);var t=e.target,i=new engine.Sprite(t.texture);this._currentDragView=i,(this._currentTarget=t).scaleX=t.scaleY=0,this.wrapper.addChild(i),i.x=e.stageX-t.texture.width/2,i.y=e.stageY-t.texture.height/2,i.type=t.type,i.name=t.name,this.wrapper.addEventListener(engine.MouseEvent.MOUSE_UP,this.onStageMouseUp,this),this.wrapper.addEventListener(engine.MouseEvent.MOUSE_MOVE,this.onStageMouseMove,this)},e.prototype.onStageMouseMove=function(e){var t=this._currentDragView;t.x=e.stageX-t.texture.width/2,t.y=e.stageY-t.texture.height/2},e.prototype.onStageMouseUp=function(e){var t,i=this;this.wrapper.removeEventListener(engine.MouseEvent.MOUSE_UP,this.onStageMouseUp,this),this.wrapper.removeEventListener(engine.MouseEvent.MOUSE_MOVE,this.onStageMouseMove,this),this._currentDragView&&((t=this.checkHitRect())?(t==this._currentDragView.type?(this.addscore(),this.wrapper.rightTips.play(getTargetRect(t,this.wrapper)),this._currentTarget.data.isRight=!0):(engine.Tween.get(this._currentTarget).to({scaleX:1,scaleY:1},300).call(function(){}),this.wrapper.wrongTips.play(getTargetRect(t,this.wrapper))),this.stores.push({targetType:t,itemType:this._currentDragView.type,itemName:this._currentDragView.name})):engine.Tween.get(this._currentTarget).to({scaleX:1,scaleY:1},300).call(function(){}),this._currentDragView.anchorX=this._currentDragView.texture.width/2,this._currentDragView.anchorY=this._currentDragView.texture.height/2,engine.Tween.get(this._currentDragView).to({scaleX:0,scaleY:0},300).call(function(){removeChild(i._currentDragView)}))},e.prototype.clear=function(){this.conveyor0.x=0,this.conveyor1.x=764,this.conveyorsPool.forEach(function(e){e.clear()}),this.conveyorsPool=[],this.datas=[],this.stores=[]},e.prototype.timeout=function(){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()},e.prototype.checkHitRect=function(){return checkHit(this._currentDragView,this.wrapper.wetWaste)?GarbageTypes.wetWaste:checkHit(this._currentDragView,this.wrapper.harmfulWaste)?GarbageTypes.harmfulWaste:checkHit(this._currentDragView,this.wrapper.dryWaste)?GarbageTypes.dryWaste:checkHit(this._currentDragView,this.wrapper.recoverableWaste)?GarbageTypes.recoverableWaste:null},e}(engine.Sprite),uiConfig=function(){return[{id:"playBg",texture:"playBg"},{id:"idler0",texture:"idlerWheel",pos:[75,1038],anchor:[20,21.5]},{id:"idler1",texture:"idlerWheel",pos:[175,1038],anchor:[20,21.5]},{id:"idler2",texture:"idlerWheel",pos:[275,1038],anchor:[20,21.5]},{id:"idler3",texture:"idlerWheel",pos:[375,1038],anchor:[20,21.5]},{id:"idler4",texture:"idlerWheel",pos:[475,1038],anchor:[20,21.5]},{id:"idler5",texture:"idlerWheel",pos:[575,1038],anchor:[20,21.5]},{id:"idler6",texture:"idlerWheel",pos:[675,1038],anchor:[20,21.5]}]},setGuide=function(){try{window.localStorage&&window.localStorage.setItem&&localStorage.setItem("recyclingGuide","1")}catch(e){console.log("setguide--err",e)}},createBg=function(e){void 0===e&&(e=1);var t=new engine.Graphics;return t.beginFill(0),t.drawRect(0,0,750,1624),t.endFill(),t.alpha=e,t},createImg=function(e){return new engine.Sprite(getTextureByName(e))},CountDownGroup=function(t){function e(){var e=t.call(this)||this;return e.addChild(createBg(.6)),e.num1=createImg("num1"),e.num2=createImg("num2"),e.num3=createImg("num3"),e.go=createImg("go"),e.go.anchorX=240,e.go.anchorY=171.5,e.num1.anchorX=125.5,e.num1.anchorY=189,e.num2.anchorX=149.5,e.num2.anchorY=191.5,e.num3.anchorX=148.5,e.num3.anchorY=191.5,e.go.x=135,e.go.y=353.5,e.num1.x=249.5,e.num1.y=340,e.num2.x=225.5,e.num2.y=334.5,e.num3.x=226.5,e.num3.y=333.5,e.addChild(e.num1),e.addChild(e.num2),e.addChild(e.num3),e.addChild(e.go),e.visible=!1,e.reset(),e}return tslib.__extends(e,t),e.prototype.reset=function(){this.go.alpha=this.num1.alpha=this.num2.alpha=this.num3.alpha=0,this.go.scaleX=this.num1.scaleX=this.num2.scaleX=this.num3.scaleX=3,this.go.scaleY=this.num1.scaleY=this.num2.scaleY=this.num3.scaleY=3},e.prototype.startCountDown=function(){return tslib.__awaiter(this,void 0,void 0,function(){var i=this;return tslib.__generator(this,function(e){return[2,new Promise(function(t){i.reset(),i.visible=!0,i.num3.alpha=1;var e=engine.Tween.get(i.num3);props.sound&&playSound("numCountDown"),e.to({scaleX:.8,scaleY:.8},200).to({scaleX:1,scaleY:1},100).wait(500).to({scaleX:0,scaleY:0},200).call(function(){i.num2.alpha=1;var e=engine.Tween.get(i.num2);props.sound&&playSound("numCountDown"),e.to({scaleX:.8,scaleY:.8},200).to({scaleX:1,scaleY:1},100).wait(500).to({scaleX:0,scaleY:0},200).call(function(){i.num1.alpha=1;var e=engine.Tween.get(i.num1);props.sound&&playSound("numCountDown"),e.to({scaleX:.8,scaleY:.8},200).to({scaleX:1,scaleY:1},100).wait(500).to({scaleX:0,scaleY:0},200).call(function(){i.go.alpha=1;var e=engine.Tween.get(i.go);props.sound&&props.sound&&playSound("goMp3"),e.to({scaleX:.8,scaleY:.8},200).to({scaleX:1,scaleY:1},100).wait(500).call(function(){i.visible=!1,t()})})})})})]})})},e}(engine.Sprite),GuideView=function(t){function e(){var e=t.call(this)||this;return e.initUI(),e.visible=!1,e}return tslib.__extends(e,t),e.prototype.initUI=function(){this.addChild(createBg(.6)),this.guideBg=createImg("guideBg"),this.addChild(this.guideBg),this.guideEle=createImg("guideEle"),this.addChild(this.guideEle),this.guideBg.x=403,this.guideBg.y=565,this.guideEle.x=361,this.guideEle.y=877,this.guideEle.anchorX=14,this.guideEle.anchorY=88,this.guideEle.mouseEnabled=this.guideEle.mouseChildren=!0;var e=createSvga("guideTips");this.svga=e,this.addChild(e),e.gotoAndStop(1),e.mouseEnabled=e.mouseChildren=!1},e.prototype.checkHit=function(e,t,i,r){var n=new engine.Rectangle(403,565,252,297);return e>n.x&&t>n.y&&e+i<n.x+n.width&&t+r<n.y+n.height},e.prototype.startGuide=function(){return tslib.__awaiter(this,void 0,void 0,function(){var s=this;return tslib.__generator(this,function(e){return[2,new Promise(function(t){s.visible=!0,s.svga.gotoAndStop(1),s.svga.play(!1,!0),s.guideEle.scaleX=1,s.guideEle.scaleY=1;function i(e){s.stage.removeEventListener(engine.MouseEvent.MOUSE_MOVE,n,s),s.checkHit(s.guideEle.x,s.guideEle.y,s.guideEle.width,s.guideEle.height)?(s.guideEle.removeEventListener(engine.MouseEvent.MOUSE_DOWN,a,s),s.guideEle.anchorX=14,s.guideEle.anchorY=44,engine.Tween.get(s.guideEle).to({scaleX:0,scaleY:0},300).call(function(){s.visible=!1,t()})):(s.svga.visible=!0,s.guideEle.x=361,s.guideEle.y=877,engine.Tween.get(s.guideEle).set({scaleX:0,scaleY:0}).to({scaleX:1,scaleY:1},300))}var r=[0,0],n=function(e){s.guideEle.x=e.stageX-r[0],s.guideEle.y=e.stageY-r[1]},a=function(e){r=[e.localX,e.localY],s.svga.visible=!1,s.stage.once(engine.MouseEvent.MOUSE_UP,i,s),s.stage.addEventListener(engine.MouseEvent.MOUSE_MOVE,n,s)};s.guideEle.addEventListener(engine.MouseEvent.MOUSE_DOWN,a,s)})]})})},e}(engine.Sprite),RightTips=function(t){function e(){var e=t.call(this)||this;return e.SCORE=props.onceScore||2,e.img=new engine.Image,e.img.texture=getTextureByName("rightTips"),e.addChild(e.img),e.img.anchorX=44,e.img.anchorY=42.5,e.visible=!1,e.txt=new engine.TextField,e.addChild(e.txt),e.txt.text="+"+e.SCORE,e.txt.size=60,e.txt.fillColor="#437726",engine.playSound,e}return tslib.__extends(e,t),e.prototype.play=function(e){props.sound&&playSound("rightTipsSound"),this.visible=!0,this.txt.x=100,engine.Tween.get(this.txt).set({y:60,alpha:1}).to({y:-50},500).to({alpha:0}),engine.Tween.get(this.img).set({x:0,y:0,scaleX:0,scaleY:0,alpha:1}).to({scaleX:1,scaleY:1},200,engine.Ease.getBackOut(1)).wait(200).to({alpha:0},300),this.x=e.x+180,this.y=e.y},e}(engine.Sprite),GameView=function(t){function e(){var e=t.call(this)||this;return e._timeCounter=0,e.guidenew=!1,e.once(engine.Event.ADDED_TO_STAGE,e.setup,e),e}return tslib.__extends(e,t),e.prototype.configUI=function(){var e={};this.uiMap=e;for(var t=0,i=uiConfig();t<i.length;t++){var r=i[t],n=r.id,a=r.texture,s=r.pos,o=r.anchor,h=new engine.Sprite(getTextureByName(a));this.addChild(h),e[n]=h,o&&(h.anchorX=o[0],h.anchorY=o[1]),s&&(h.x=s[0],h.y=s[1],o&&(h.x=s[0]-h.anchorX,h.y=s[1]-h.anchorY))}this.configConveyors(),this.createRects(),this.countdown=new CountDownGroup,this.addChild(this.countdown),this.guide=new GuideView,this.addChild(this.guide),this.wrongTips=new WrongTips,this.rightTips=new RightTips,this.addChild(this.wrongTips),this.addChild(this.rightTips)},e.prototype.createRects=function(){this.wetWaste=this.createRect(104,565,252,297,16777215),this.harmfulWaste=this.createRect(104,232,252,297,16711680),this.dryWaste=this.createRect(403,232,252,297,0),this.recoverableWaste=this.createRect(403,565,252,297,255)},e.prototype.createRect=function(e,t,i,r,n){var a=new engine.Rectangle(e,t,i,r),s=new engine.Sprite;this.addChild(s),s.x=e,s.y=t;var o=new engine.Graphics;return o.alpha=0,o.beginFill(n),o.drawRect(0,0,i,r),o.endFill(),s.addChild(o),a},e.prototype.configConveyors=function(){var e=new Conveyor,t=new Conveyor;this.addChild(e),this.addChild(t),e.x=0,t.x=764,this.conveyors=new Conveyors(this),this.conveyors.initData(e,t)},e.prototype.playAni=function(){var t=this;["idler0","idler1","idler2","idler3","idler4","idler5","idler6"].map(function(e){return t.uiMap[e]}).forEach(function(e){engine.Tween.get(e,{loop:!0}).to({rotation:-360},1e3)})},e.prototype.stopAni=function(){var t=this;["idler0","idler1","idler2","idler3","idler4","idler5","idler6"].map(function(e){return t.uiMap[e]}).forEach(function(e){engine.Tween.removeTweens(e)})},e.prototype.start=function(){return tslib.__awaiter(this,void 0,void 0,function(){var t=this;return tslib.__generator(this,function(e){switch(e.label){case 0:return this._timeCounter=0,props.isNewPlayer||this.guidenew?[3,2]:[4,this.guide.startGuide()];case 1:e.sent(),setGuide(),this.guidenew=!0,e.label=2;case 2:return this.conveyors.clear(),[4,this.countdown.startCountDown()];case 3:return e.sent(),this.startGame(),engine.globalEvent.dispatchEvent("recycling-time-update",{second:this.getSecond()}),this._timer=setInterval(function(){t.onTimer()},1e3),[2]}})})},e.prototype.startGame=function(){this.playAni(),this.conveyors.startConveyors()},e.prototype.stopGame=function(){this.stopAni()},e.prototype.getSecond=function(){return props.time-this._timeCounter},e.prototype.onTimer=function(){this._timeCounter++,engine.globalEvent.dispatchEvent("recycling-time-update",{second:this.getSecond()}),0==this.getSecond()&&(this.stop(),this.conveyors.timeout(),props.sound&&playSound("gameOverMp3"))},e.prototype.stop=function(){clearInterval(this._timer),this.stopGame()},e.prototype.setup=function(){console.log("onSteup",props),this.configUI()},e.prototype.onDown=function(e){},e.prototype.stageOnUp=function(e){},e.prototype.onSuccess=function(){},e.prototype.onMove=function(e){},e}(engine.Container),GameWrapper=function(i){function e(){var e=i.call(this)||this;engine.globalEvent.addEventListener("recycling-start",e.start,e),engine.globalEvent.addEventListener("recycling-sound-update",e.updateSound,e),engine.globalEvent.addEventListener("recycling-stop",e.stop,e);var t=e._gameView=new GameView;return e.addChild(t),e}return tslib.__extends(e,i),e.prototype.updateSound=function(e){injectProps(e.data)},e.prototype.start=function(e){injectProps(e.data),this._gameView.start()},e.prototype.stop=function(e){this._gameView.stop()},e}(engine.Container);function index(e){return prepareProps(),injectProps(e),new GameWrapper}module.exports=index;
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('tslib')) :
typeof define === 'function' && define.amd ? define(['tslib'], factory) :
(global = global || self, global.recycling = factory(global.tslib));
}(this, (function (tslib) { 'use strict';
function getTexture(uuid) {
return engine.Texture.from(getAssetByUUID(uuid).uuid);
}
function getTextureByName(name) {
return getTexture(engine.getAssetByName(name).uuid);
}
function playSound(name) {
engine.playSound(engine.getAssetByName(name).uuid, { keep: true });
}
function createSvga(name, anchorName) {
var inst = new svga.Svga();
inst.source = 'asset://' + engine.getAssetByName(name).uuid;
return inst;
}
//# sourceMappingURL=utils.js.map
var props = {};
function prepareProps() {
var metaProps = getProps();
engine.injectProp(props, metaProps);
}
function injectProps(p) {
engine.injectProp(props, p);
}
//# sourceMappingURL=props.js.map
var Conveyor = (function (_super) {
tslib.__extends(Conveyor, _super);
function Conveyor() {
var _this = _super.call(this) || this;
_this.y = 904.21;
var sp = new engine.Sprite(getTextureByName('conveyor'));
_this.addChild(sp);
_this.idx0 = _this.createItem(75, 50);
_this.idx1 = _this.createItem(225, 50);
_this.idx2 = _this.createItem(375, 50);
_this.idx3 = _this.createItem(525, 50);
_this.idx4 = _this.createItem(675, 50);
return _this;
}
Conveyor.prototype.clear = function () {
this.clearItem(this.idx0);
this.clearItem(this.idx1);
this.clearItem(this.idx2);
this.clearItem(this.idx3);
this.clearItem(this.idx4);
};
Conveyor.prototype.clearItem = function (idx) {
if (idx.children.length > 0)
idx.removeChildAt(0);
};
Conveyor.prototype.createItem = function (x, y) {
var sp = new engine.Sprite();
this.addChild(sp);
sp.x = x;
sp.y = y;
return sp;
};
return Conveyor;
}(engine.Sprite));
//# sourceMappingURL=Conveyor.js.map
var GarbageTypes;
(function (GarbageTypes) {
GarbageTypes["recoverableWaste"] = "recoverableWaste";
GarbageTypes["harmfulWaste"] = "harmfulWaste";
GarbageTypes["wetWaste"] = "wetWaste";
GarbageTypes["dryWaste"] = "dryWaste";
})(GarbageTypes || (GarbageTypes = {}));
//# sourceMappingURL=GarbageTypes.js.map
var GarbageConfig = (function () {
function GarbageConfig() {
}
GarbageConfig.config = [
{ name: "保鲜盒", source: "g00", type: GarbageTypes.recoverableWaste, width: 129, height: 111 },
{ name: "报纸", source: "g01", type: GarbageTypes.recoverableWaste, width: 138, height: 144 },
{ name: "贝壳", source: "g02", type: GarbageTypes.dryWaste, width: 79, height: 117 },
{ name: "冰箱", source: "g03", type: GarbageTypes.recoverableWaste, width: 63, height: 151 },
{ name: "菜梗菜叶", source: "g04", type: GarbageTypes.wetWaste, width: 144, height: 98 },
{ name: "残枝落叶", source: "g05", type: GarbageTypes.wetWaste, width: 120, height: 99 },
{ name: "茶叶渣", source: "g06", type: GarbageTypes.wetWaste, width: 86, height: 96 },
{ name: "尘土", source: "g07", type: GarbageTypes.dryWaste, width: 109, height: 114 },
{ name: "创口贴", source: "g08", type: GarbageTypes.dryWaste, width: 112, height: 90 },
{ name: "大骨头", source: "g09", type: GarbageTypes.dryWaste, width: 89, height: 101 },
{ name: "普通干电池", source: "g11", type: GarbageTypes.dryWaste, width: 89, height: 131 },
{ name: "方便面盒", source: "g12", type: GarbageTypes.dryWaste, width: 89, height: 168 },
{ name: "废弃食用油脂", source: "g13", type: GarbageTypes.wetWaste, width: 131, height: 164 },
{ name: "骨骼内脏", source: "g14", type: GarbageTypes.wetWaste, width: 104, height: 82 },
{ name: "锅具", source: "g15", type: GarbageTypes.recoverableWaste, width: 119, height: 149 },
{ name: "果核", source: "g16", type: GarbageTypes.wetWaste, width: 99, height: 95 },
{ name: "果皮", source: "g17", type: GarbageTypes.wetWaste, width: 115, height: 127 },
{ name: "化妆品", source: "g18", type: GarbageTypes.harmfulWaste, width: 67, height: 151 },
{ name: "鸡蛋壳", source: "g19", type: GarbageTypes.wetWaste, width: 99, height: 107 },
{ name: "剪刀", source: "g20", type: GarbageTypes.recoverableWaste, width: 96, height: 127 },
{ name: "胶带", source: "g21", type: GarbageTypes.dryWaste, width: 87, height: 113 },
{ name: "榴莲壳", source: "g22", type: GarbageTypes.dryWaste, width: 136, height: 116 },
{ name: "毛巾", source: "g23", type: GarbageTypes.recoverableWaste, width: 108, height: 96 },
{ name: "纽扣电池", source: "g24", type: GarbageTypes.harmfulWaste, width: 87, height: 89 },
{ name: "破旧陶瓷罐", source: "g25", type: GarbageTypes.dryWaste, width: 110, height: 125 },
{ name: "杀虫剂", source: "g26", type: GarbageTypes.harmfulWaste, width: 64, height: 160 },
{ name: "剩菜剩饭", source: "g27", type: GarbageTypes.wetWaste, width: 128, height: 96 },
{ name: "手机", source: "g28", type: GarbageTypes.recoverableWaste, width: 82, height: 142 },
{ name: "书本", source: "g29", type: GarbageTypes.recoverableWaste, width: 106, height: 132 },
{ name: "玻璃杯", source: "g30", type: GarbageTypes.recoverableWaste, width: 62, height: 119 },
{ name: "水银温度计", source: "g31", type: GarbageTypes.harmfulWaste, width: 109, height: 162 },
{ name: "水银血压计", source: "g32", type: GarbageTypes.harmfulWaste, width: 115, height: 147 },
{ name: "塑料桶", source: "g33", type: GarbageTypes.recoverableWaste, width: 92, height: 131 },
{ name: "卫生纸", source: "g34", type: GarbageTypes.dryWaste, width: 92, height: 132 },
{ name: "污染织物", source: "g35", type: GarbageTypes.dryWaste, width: 128, height: 139 },
{ name: "污染纸张", source: "g36", type: GarbageTypes.dryWaste, width: 96, height: 136 },
{ name: "洗衣机", source: "g37", type: GarbageTypes.recoverableWaste, width: 87, height: 157 },
{ name: "烟蒂", source: "g38", type: GarbageTypes.dryWaste, width: 87, height: 124 },
{ name: "药品", source: "g39", type: GarbageTypes.harmfulWaste, width: 109, height: 131 },
{ name: "药品包装", source: "g40", type: GarbageTypes.harmfulWaste, width: 108, height: 125 },
{ name: "椰子壳", source: "g41", type: GarbageTypes.dryWaste, width: 104, height: 119 },
{ name: "衣服", source: "g42", type: GarbageTypes.recoverableWaste, width: 83, height: 137 },
{ name: "衣架", source: "g43", type: GarbageTypes.recoverableWaste, width: 132, height: 125 },
{ name: "易拉罐", source: "g44", type: GarbageTypes.recoverableWaste, width: 65, height: 133 },
{ name: "荧光灯", source: "g45", type: GarbageTypes.harmfulWaste, width: 90, height: 118 },
{ name: "油漆桶", source: "g46", type: GarbageTypes.harmfulWaste, width: 65, height: 143 },
{ name: "一次性纸杯", source: "g47", type: GarbageTypes.dryWaste, width: 76, height: 116 },
{ name: "纸尿裤", source: "g48", type: GarbageTypes.dryWaste, width: 93, height: 138 },
{ name: "纸箱", source: "g49", type: GarbageTypes.recoverableWaste, width: 112, height: 118 },
{ name: "指甲油", source: "g50", type: GarbageTypes.harmfulWaste, width: 64, height: 138 },
];
return GarbageConfig;
}());
//# sourceMappingURL=GarbageConfig.js.map
var transStores = (function (list) {
var tmp = [];
var contains = function (val) {
for (var _i = 0, tmp_1 = tmp; _i < tmp_1.length; _i++) {
var i = tmp_1[_i];
if (val.targetType == i.targetType && val.itemType == i.itemType && val.itemName == i.itemName)
return true;
}
return false;
};
list.forEach(function (i) {
if (!contains(i))
tmp.push(i);
});
list = tmp;
tmp = [];
var nameList = [];
var contains2 = function (val) {
for (var _i = 0, tmp_2 = tmp; _i < tmp_2.length; _i++) {
var i = tmp_2[_i];
if (val.itemName == i.itemName) {
nameList.push(i.itemName);
return true;
}
}
return false;
};
list.forEach(function (i) {
if (!contains2(i))
tmp.push(i);
});
list = tmp;
list.forEach(function (i) {
if (nameList.indexOf(i.itemName) != -1) {
i.targetType = i.itemType;
}
});
return list.map(function (i) {
return {
'targetName': getTargetName(i.targetType),
'isCorrect': i.targetType == i.itemType,
'itemName': i.itemName,
'itemTypeName': getTargetName(i.itemType)
};
});
});
var getTargetName = function (type) {
switch (type) {
case GarbageTypes.recoverableWaste:
return '可回收物';
case GarbageTypes.harmfulWaste:
return '有害垃圾';
case GarbageTypes.wetWaste:
return '湿垃圾';
case GarbageTypes.dryWaste:
return '其他垃圾';
}
};
//# sourceMappingURL=transStores.js.map
var checkHit = (function (view, rect) {
var x = view.x, y = view.y;
var _a = view.texture, width = _a.width, height = _a.height;
if (x > rect.x && y > rect.y && (x + width) < (rect.x + rect.width) && (y + height) < (rect.y + rect.height)) {
return true;
}
return false;
});
//# sourceMappingURL=checkHit.js.map
var removeChild = (function (d) {
if (d && d.parent) {
d.parent.removeChild(d);
}
});
//# sourceMappingURL=removeChild.js.map
var removeEle = (function (e, arr) {
var index = arr.indexOf(e);
if (index >= 0) {
arr.splice(index, 1);
}
});
//# sourceMappingURL=removeEle.js.map
var shuffle = (function (arr) {
var _a;
var i = arr.length;
while (i) {
var j = Math.floor(Math.random() * i--);
_a = [arr[i], arr[j]], arr[j] = _a[0], arr[i] = _a[1];
}
return arr;
});
//# sourceMappingURL=shuffle.js.map
var WrongTips = (function (_super) {
tslib.__extends(WrongTips, _super);
function WrongTips() {
var _this = _super.call(this) || this;
_this.img = new engine.Image();
_this.img.texture = getTextureByName('wrongTips');
_this.addChild(_this.img);
_this.img.anchorX = 88 / 2;
_this.img.anchorY = 85 / 2;
_this.visible = false;
return _this;
}
WrongTips.prototype.play = function (rect) {
this.visible = true;
if (props.sound) {
playSound("wrongTipsMp3");
}
var dur = 70;
var stren = 20;
engine.Tween.get(this.img).set({ x: 0, y: 0, scaleX: 1, scaleY: 1, alpha: 1 })
.to({ x: stren }, dur)
.to({ x: 0 }, dur)
.to({ x: -stren }, dur)
.to({ x: 0 }, dur)
.wait(200)
.to({ alpha: 0 }, 300);
this.x = rect.x + 180;
this.y = rect.y;
};
return WrongTips;
}(engine.Sprite));
var getTargetRect = function (targetType, gameview) {
switch (targetType) {
case GarbageTypes.dryWaste:
return gameview.dryWaste;
case GarbageTypes.wetWaste:
return gameview.wetWaste;
case GarbageTypes.harmfulWaste:
return gameview.harmfulWaste;
case GarbageTypes.recoverableWaste:
return gameview.recoverableWaste;
}
};
//# sourceMappingURL=WrongTips.js.map
var Conveyors = (function (_super) {
tslib.__extends(Conveyors, _super);
function Conveyors(p) {
var _this = _super.call(this) || this;
_this.conveyorsPool = [];
_this.GarbageConfig = GarbageConfig.config;
_this.datas = [];
_this.wrapper = p;
return _this;
}
Conveyors.prototype.initData = function (conveyor0, conveyor1) {
this.conveyor0 = conveyor0;
this.conveyor1 = conveyor1;
};
Conveyors.prototype.setDefault = function () {
this.score = 0;
this.conveyorsPool.push(this.conveyor0);
this.conveyorsPool.push(this.conveyor1);
var allConfigs = shuffle(this.GarbageConfig.concat([]));
for (var i = 0; i < GarbageConfig.config.length; i++) {
allConfigs[i].idx = i;
allConfigs[i].isRight = false;
allConfigs[i].isMistake = false;
allConfigs[i].isOnStage = false;
this.datas.push(allConfigs[i]);
}
for (var i = 0; i < 5; i++) {
var data = this.datas[i];
var view = new engine.Sprite(getTextureByName(data.source));
view.isWrong = false;
view.isRight = false;
data.isOnStage = true;
view.data = data;
view.type = data.type;
view.name = data.name;
view.anchorX = data.width / 2;
view.anchorY = data.height;
view.x = -data.width / 2;
view.y = -data.height + 40;
this.conveyor1["idx" + i].addChild(view);
view.addEventListener(engine.MouseEvent.MOUSE_DOWN, this.onDown_garbage, this);
}
};
Conveyors.prototype.startConveyors = function () {
this.setDefault();
engine.gameStage.addEventListener(engine.Event.ENTER_FRAME, this.onEnterFrame, this);
};
Conveyors.prototype.onEnterFrame = function (ENTER_FRAME, onEnterFrame, arg2) {
if (this.score == (props.maxScore || 100)) {
this.gameOver();
this.wrapper.stop();
if (props.sound)
playSound("gameOverMp3");
}
this.conveyorsPool.forEach(function (conveyor) {
conveyor.x -= props.speed || 3;
});
if (this.conveyorsPool[this.conveyorsPool.length - 1].x <= 764) {
var conveyor = new Conveyor();
conveyor.x = this.conveyorsPool[this.conveyorsPool.length - 1].x + 764;
this.wrapper.addChild(conveyor);
this.conveyorsPool.push(conveyor);
}
else {
var dataList = [];
for (var n = 0; n < this.datas.length; n++) {
var dataItem = this.datas[n];
if (!dataItem.isRight && !dataItem.isOnStage) {
dataList.push(dataItem);
}
}
var lastConveyor = this.conveyorsPool[this.conveyorsPool.length - 1];
for (var m = 0; m < 5; m++) {
if (!lastConveyor["idx" + m].children[0]) {
var data = dataList.shift();
if (data) {
data.isOnStage = true;
var view = new engine.Sprite(getTextureByName(data.source));
view.data = data;
view.isWrong = false;
view.isRight = false;
view.type = data.type;
view.name = data.name;
view.anchorX = data.width / 2;
view.anchorY = data.height;
view.x = -data.width / 2;
view.y = -data.height + 40;
lastConveyor["idx" + m].addChild(view);
view.addEventListener(engine.MouseEvent.MOUSE_DOWN, this.onDown_garbage, this);
}
else {
break;
}
}
}
}
if (this.conveyorsPool[0].x < -750) {
for (var k = 0; k < this.datas.length; k++) {
var dataItem = this.datas[k];
var idx4 = this.conveyorsPool[0]["idx" + 4];
if (idx4.children[0]) {
if (dataItem.name == idx4.children[0].name) {
dataItem.isOnStage = false;
removeEle(dataItem, this.datas);
this.datas.push(dataItem);
idx4.removeChild(idx4.children[0]);
break;
}
}
}
this.conveyorsPool.shift();
}
else if (this.conveyorsPool[0].x < -600) {
for (var k = 0; k < this.datas.length; k++) {
var dataItem = this.datas[k];
var idx3 = this.conveyorsPool[0]["idx" + 3];
if (idx3.children[0]) {
if (dataItem.name == idx3.children[0].name) {
dataItem.isOnStage = false;
removeEle(dataItem, this.datas);
this.datas.push(dataItem);
idx3.removeChild(idx3.children[0]);
break;
}
}
}
}
else if (this.conveyorsPool[0].x < -450) {
for (var k = 0; k < this.datas.length; k++) {
var dataItem = this.datas[k];
var idx2 = this.conveyorsPool[0]["idx" + 2];
if (idx2.children[0]) {
if (dataItem.name == idx2.children[0].name) {
dataItem.isOnStage = false;
removeEle(dataItem, this.datas);
this.datas.push(dataItem);
idx2.removeChild(idx2.children[0]);
break;
}
}
}
}
else if (this.conveyorsPool[0].x < -300) {
for (var k = 0; k < this.datas.length; k++) {
var dataItem = this.datas[k];
var idx1 = this.conveyorsPool[0]["idx" + 1];
if (idx1.children[0]) {
if (dataItem.name == idx1.children[0].name) {
dataItem.isOnStage = false;
removeEle(dataItem, this.datas);
this.datas.push(dataItem);
idx1.removeChild(idx1.children[0]);
break;
}
}
}
}
else if (this.conveyorsPool[0].x < -150) {
for (var k = 0; k < this.datas.length; k++) {
var dataItem = this.datas[k];
var idx0 = this.conveyorsPool[0]["idx" + 0];
if (idx0.children[0]) {
if (dataItem.name == idx0.children[0].name) {
dataItem.isOnStage = false;
removeEle(dataItem, this.datas);
this.datas.push(dataItem);
idx0.removeChild(idx0.children[0]);
break;
}
}
}
}
};
Conveyors.prototype.addscore = function () {
this.score += (props.onceScore || 2);
engine.globalEvent.dispatchEvent('recycling-score-update', {
score: this.score
});
};
Conveyors.prototype.gameOver = function () {
engine.gameStage.removeEventListener(engine.Event.ENTER_FRAME, this.onEnterFrame, this);
engine.globalEvent.dispatchEvent('recycling-game-end', transStores(this.stores));
};
Conveyors.prototype.onDown_garbage = function (e) {
if (this._currentDragView) {
removeChild(this._currentDragView);
}
var target = e.target;
var view = new engine.Sprite(target.texture);
this._currentDragView = view;
this._currentTarget = target;
target.scaleX = target.scaleY = 0;
this.wrapper.addChild(view);
view.x = e.stageX - target.texture.width / 2;
view.y = e.stageY - target.texture.height / 2;
view.type = target['type'];
view.name = target['name'];
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) {
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;
this.wrapper.removeEventListener(engine.MouseEvent.MOUSE_UP, this.onStageMouseUp, this);
this.wrapper.removeEventListener(engine.MouseEvent.MOUSE_MOVE, this.onStageMouseMove, this);
if (!this._currentDragView)
return;
var result = this.checkHitRect();
if (result) {
if (result == this._currentDragView['type']) {
this.addscore();
this.wrapper.rightTips.play(getTargetRect(result, this.wrapper));
this._currentTarget.data.isRight = true;
}
else {
engine.Tween.get(this._currentTarget).to({ scaleX: 1, scaleY: 1 }, 300).call(function () { });
this.wrapper.wrongTips.play(getTargetRect(result, this.wrapper));
}
this.stores.push({ targetType: result, itemType: this._currentDragView['type'], itemName: this._currentDragView['name'] });
}
else {
engine.Tween.get(this._currentTarget).to({ scaleX: 1, scaleY: 1 }, 300).call(function () { });
}
this._currentDragView.anchorX = this._currentDragView.texture.width / 2;
this._currentDragView.anchorY = this._currentDragView.texture.height / 2;
engine.Tween.get(this._currentDragView).to({ scaleX: 0, scaleY: 0 }, 300).call(function () {
removeChild(_this._currentDragView);
});
};
Conveyors.prototype.clear = function () {
this.conveyor0.x = 0;
this.conveyor1.x = 764;
this.conveyorsPool.forEach(function (i) {
i.clear();
});
this.conveyorsPool = [];
this.datas = [];
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 () {
if (checkHit(this._currentDragView, this.wrapper.wetWaste)) {
return GarbageTypes.wetWaste;
}
if (checkHit(this._currentDragView, this.wrapper.harmfulWaste)) {
return GarbageTypes.harmfulWaste;
}
if (checkHit(this._currentDragView, this.wrapper.dryWaste)) {
return GarbageTypes.dryWaste;
}
if (checkHit(this._currentDragView, this.wrapper.recoverableWaste)) {
return GarbageTypes.recoverableWaste;
}
return null;
};
return Conveyors;
}(engine.Sprite));
//# sourceMappingURL=Conveyors.js.map
var uiConfig = (function () {
return [
{
id: 'playBg',
texture: 'playBg'
},
{
id: 'idler0',
texture: 'idlerWheel',
pos: [75, 1038],
anchor: [20, 21.5]
},
{
id: 'idler1',
texture: 'idlerWheel',
pos: [175, 1038],
anchor: [20, 21.5]
},
{
id: 'idler2',
texture: 'idlerWheel',
pos: [275, 1038],
anchor: [20, 21.5]
},
{
id: 'idler3',
texture: 'idlerWheel',
pos: [375, 1038],
anchor: [20, 21.5]
},
{
id: 'idler4',
texture: 'idlerWheel',
pos: [475, 1038],
anchor: [20, 21.5]
},
{
id: 'idler5',
texture: 'idlerWheel',
pos: [575, 1038],
anchor: [20, 21.5]
},
{
id: 'idler6',
texture: 'idlerWheel',
pos: [675, 1038],
anchor: [20, 21.5]
},
];
});
//# sourceMappingURL=uiConfig.js.map
var getGuideInfo = (function () {
if (!window.localStorage) {
return 0;
}
return localStorage.getItem('recyclingGuide');
});
var setGuide = function () {
if (window.localStorage)
localStorage.setItem('recyclingGuide', '1');
};
//# sourceMappingURL=getGuideInfo.js.map
var createBg = (function (a) {
if (a === void 0) { a = 1; }
var rect = new engine.Graphics();
rect.beginFill(0);
rect.drawRect(0, 0, 750, 1624);
rect.endFill();
rect.alpha = a;
return rect;
});
//# sourceMappingURL=createBg.js.map
var createImg = (function (texture) {
return new engine.Sprite(getTextureByName(texture));
});
//# sourceMappingURL=createImg.js.map
var CountDownGroup = (function (_super) {
tslib.__extends(CountDownGroup, _super);
function CountDownGroup() {
var _this = _super.call(this) || this;
_this.addChild(createBg(.6));
_this.num1 = createImg('num1');
_this.num2 = createImg('num2');
_this.num3 = createImg('num3');
_this.go = createImg('go');
_this.go.anchorX = 240;
_this.go.anchorY = 171.5;
_this.num1.anchorX = 125.5;
_this.num1.anchorY = 189;
_this.num2.anchorX = 149.5;
_this.num2.anchorY = 191.5;
_this.num3.anchorX = 148.5;
_this.num3.anchorY = 191.5;
_this.go.x = 750 / 2 - 240;
_this.go.y = 525 - 171.5;
_this.num1.x = 750 / 2 - 125.5;
_this.num1.y = 529 - 189;
_this.num2.x = 750 / 2 - 149.5;
_this.num2.y = 526 - 191.5;
_this.num3.x = 750 / 2 - 148.5;
_this.num3.y = 525 - 191.5;
_this.addChild(_this.num1);
_this.addChild(_this.num2);
_this.addChild(_this.num3);
_this.addChild(_this.go);
_this.visible = false;
_this.reset();
return _this;
}
CountDownGroup.prototype.reset = function () {
this.go.alpha = this.num1.alpha = this.num2.alpha = this.num3.alpha = 0;
this.go.scaleX = this.num1.scaleX = this.num2.scaleX = this.num3.scaleX = 3;
this.go.scaleY = this.num1.scaleY = this.num2.scaleY = this.num3.scaleY = 3;
};
CountDownGroup.prototype.startCountDown = function () {
return tslib.__awaiter(this, void 0, void 0, function () {
var _this = this;
return tslib.__generator(this, function (_a) {
return [2, new Promise(function (r) {
_this.reset();
_this.visible = true;
_this.num3.alpha = 1;
var n3 = engine.Tween.get(_this.num3);
if (props.sound) {
playSound("numCountDown");
}
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 () {
_this.num2.alpha = 1;
var n2 = engine.Tween.get(_this.num2);
if (props.sound) {
playSound("numCountDown");
}
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 () {
_this.num1.alpha = 1;
var n1 = engine.Tween.get(_this.num1);
if (props.sound) {
playSound("numCountDown");
}
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 () {
_this.go.alpha = 1;
var go = engine.Tween.get(_this.go);
if (props.sound) {
if (props.sound)
playSound("goMp3");
}
go.to({ scaleX: 0.8, scaleY: 0.8 }, 200).to({ scaleX: 1, scaleY: 1 }, 100).wait(500).call(function () {
_this.visible = false;
r();
});
});
});
});
})];
});
});
};
return CountDownGroup;
}(engine.Sprite));
//# sourceMappingURL=CountDownGroup.js.map
var GuideView = (function (_super) {
tslib.__extends(GuideView, _super);
function GuideView() {
var _this = _super.call(this) || this;
_this.initUI();
_this.visible = false;
return _this;
}
GuideView.prototype.initUI = function () {
this.addChild(createBg(.6));
this.guideBg = createImg('guideBg');
this.addChild(this.guideBg);
this.guideEle = createImg('guideEle');
this.addChild(this.guideEle);
this.guideBg.x = 403;
this.guideBg.y = 565;
this.guideEle.x = 361;
this.guideEle.y = 877;
this.guideEle.anchorX = 14;
this.guideEle.anchorY = 88;
this.guideEle.mouseEnabled = this.guideEle.mouseChildren = true;
var svga = createSvga("guideTips");
this.svga = svga;
this.addChild(svga);
svga.gotoAndStop(1);
svga.mouseEnabled = svga.mouseChildren = false;
};
GuideView.prototype.checkHit = function (x, y, w, h) {
var rect = new engine.Rectangle(403, 565, 252, 297);
if (x > rect.x && y > rect.y && (x + w) < (rect.x + rect.width) && (y + h) < (rect.y + rect.height)) {
return true;
}
return false;
};
GuideView.prototype.startGuide = function () {
return tslib.__awaiter(this, void 0, void 0, function () {
var _this = this;
return tslib.__generator(this, function (_a) {
return [2, new Promise(function (r) {
_this.visible = true;
_this.svga.gotoAndStop(1);
_this.svga.play(false, true);
_this.guideEle.scaleX = 1;
_this.guideEle.scaleY = 1;
var offset = [0, 0];
var guideOver = function () {
_this.guideEle.removeEventListener(engine.MouseEvent.MOUSE_DOWN, ondown, _this);
_this.guideEle.anchorX = 14;
_this.guideEle.anchorY = 44;
engine.Tween.get(_this.guideEle).to({ scaleX: 0, scaleY: 0 }, 300).call(function () {
_this.visible = false;
r();
});
};
var onUp = function (e) {
_this.stage.removeEventListener(engine.MouseEvent.MOUSE_MOVE, onMove, _this);
if (_this.checkHit(_this.guideEle.x, _this.guideEle.y, _this.guideEle.width, _this.guideEle.height)) {
guideOver();
}
else {
_this.svga.visible = true;
_this.guideEle.x = 361;
_this.guideEle.y = 877;
engine.Tween.get(_this.guideEle).set({ scaleX: 0, scaleY: 0 }).to({ scaleX: 1, scaleY: 1 }, 300);
}
};
var onMove = function (e) {
_this.guideEle.x = e.stageX - offset[0];
_this.guideEle.y = e.stageY - offset[1];
};
var ondown = function (e) {
offset = [e.localX, e.localY];
_this.svga.visible = false;
_this.stage.once(engine.MouseEvent.MOUSE_UP, onUp, _this);
_this.stage.addEventListener(engine.MouseEvent.MOUSE_MOVE, onMove, _this);
};
_this.guideEle.addEventListener(engine.MouseEvent.MOUSE_DOWN, ondown, _this);
})];
});
});
};
return GuideView;
}(engine.Sprite));
//# sourceMappingURL=guideView.js.map
var RightTips = (function (_super) {
tslib.__extends(RightTips, _super);
function RightTips() {
var _this = _super.call(this) || this;
_this.SCORE = props.onceScore || 2;
_this.img = new engine.Image();
_this.img.texture = getTextureByName('rightTips');
_this.addChild(_this.img);
_this.img.anchorX = 88 / 2;
_this.img.anchorY = 85 / 2;
_this.visible = false;
_this.txt = new engine.TextField();
_this.addChild(_this.txt);
_this.txt.text = '+' + _this.SCORE;
_this.txt.size = 60;
_this.txt.fillColor = '#437726';
engine.playSound;
return _this;
}
RightTips.prototype.play = function (rect) {
if (props.sound) {
playSound("rightTipsSound");
}
this.visible = true;
this.txt.x = 100;
engine.Tween.get(this.txt).set({ y: 60, alpha: 1 })
.to({ y: -50 }, 500)
.to({ alpha: 0 });
engine.Tween.get(this.img).set({ x: 0, y: 0, scaleX: 0, scaleY: 0, alpha: 1 })
.to({ scaleX: 1, scaleY: 1 }, 200, engine.Ease.getBackOut(1))
.wait(200)
.to({ alpha: 0 }, 300);
this.x = rect.x + 180;
this.y = rect.y;
};
return RightTips;
}(engine.Sprite));
//# sourceMappingURL=RightTips.js.map
var GameView = (function (_super) {
tslib.__extends(GameView, _super);
function GameView() {
var _this = _super.call(this) || this;
_this._timeCounter = 0;
_this.once(engine.Event.ADDED_TO_STAGE, _this.setup, _this);
return _this;
}
GameView.prototype.configUI = function () {
var uiMap = {};
this.uiMap = uiMap;
var config = uiConfig();
for (var _i = 0, config_1 = config; _i < config_1.length; _i++) {
var item = config_1[_i];
var id = item.id, texture = item.texture, pos = item.pos, anchor = item.anchor;
var sp = new engine.Sprite(getTextureByName(texture));
this.addChild(sp);
uiMap[id] = sp;
if (anchor) {
sp.anchorX = anchor[0];
sp.anchorY = anchor[1];
}
if (pos) {
sp.x = pos[0];
sp.y = pos[1];
if (anchor) {
sp.x = pos[0] - sp.anchorX;
sp.y = pos[1] - sp.anchorY;
}
}
}
this.configConveyors();
this.createRects();
this.countdown = new CountDownGroup();
this.addChild(this.countdown);
this.guide = new GuideView();
this.addChild(this.guide);
this.wrongTips = new WrongTips();
this.rightTips = new RightTips();
this.addChild(this.wrongTips);
this.addChild(this.rightTips);
};
GameView.prototype.createRects = function () {
this.wetWaste = this.createRect(104, 565, 252, 297, 0xffffff);
this.harmfulWaste = this.createRect(104, 232, 252, 297, 0xff0000);
this.dryWaste = this.createRect(403, 232, 252, 297, 0x000000);
this.recoverableWaste = this.createRect(403, 565, 252, 297, 0x0000ff);
};
GameView.prototype.createRect = function (x, y, w, h, c) {
var rect = new engine.Rectangle(x, y, w, h);
var sp = new engine.Sprite();
this.addChild(sp);
sp.x = x;
sp.y = y;
var g = new engine.Graphics;
g.alpha = 0.0;
g.beginFill(c);
g.drawRect(0, 0, w, h);
g.endFill();
sp.addChild(g);
return rect;
};
GameView.prototype.configConveyors = function () {
var conveyor0 = new Conveyor();
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);
};
GameView.prototype.playAni = function () {
var _this = this;
var idlerWheels = ['idler0', 'idler1', 'idler2', 'idler3', 'idler4', 'idler5', 'idler6'];
idlerWheels = idlerWheels.map(function (i) { return _this.uiMap[i]; });
idlerWheels.forEach(function (i) {
engine.Tween.get(i, { loop: true }).to({ rotation: -360 }, 1000);
});
};
GameView.prototype.stopAni = function () {
var _this = this;
var idlerWheels = ['idler0', 'idler1', 'idler2', 'idler3', 'idler4', 'idler5', 'idler6'];
idlerWheels = idlerWheels.map(function (i) { return _this.uiMap[i]; });
idlerWheels.forEach(function (i) {
engine.Tween.removeTweens(i);
});
};
GameView.prototype.start = function () {
return tslib.__awaiter(this, void 0, void 0, function () {
var _this = this;
return tslib.__generator(this, function (_a) {
switch (_a.label) {
case 0:
console.log('on start');
this._timeCounter = 0;
if (!!getGuideInfo()) return [3, 2];
return [4, this.guide.startGuide()];
case 1:
_a.sent();
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._timer = setInterval(function () {
_this.onTimer();
}, 1000);
return [2];
}
});
});
};
GameView.prototype.startGame = function () {
this.playAni();
this.conveyors.startConveyors();
};
GameView.prototype.stopGame = function () {
this.stopAni();
};
GameView.prototype.getSecond = function () {
return props.time - this._timeCounter;
};
GameView.prototype.onTimer = function () {
this._timeCounter++;
engine.globalEvent.dispatchEvent('recycling-time-update', {
second: this.getSecond(),
});
if (this.getSecond() == 0) {
this.stop();
this.conveyors.timeout();
if (props.sound)
playSound("gameOverMp3");
}
};
GameView.prototype.stop = function () {
clearInterval(this._timer);
this.stopGame();
};
GameView.prototype.setup = function () {
console.log('onSteup', props);
this.configUI();
};
GameView.prototype.onDown = function (e) {
};
GameView.prototype.stageOnUp = function (e) {
};
GameView.prototype.onSuccess = function () {
};
GameView.prototype.onMove = function (e) {
};
return GameView;
}(engine.Container));
//# sourceMappingURL=GameView.js.map
var GameWrapper = (function (_super) {
tslib.__extends(GameWrapper, _super);
function GameWrapper() {
var _this = _super.call(this) || this;
engine.globalEvent.addEventListener('recycling-start', _this.start, _this);
engine.globalEvent.addEventListener('recycling-sound-update', _this.updateSound, _this);
engine.globalEvent.addEventListener('recycling-stop', _this.stop, _this);
var gameView = _this._gameView = new GameView();
_this.addChild(gameView);
return _this;
}
GameWrapper.prototype.updateSound = function (event) {
injectProps(event.data);
};
GameWrapper.prototype.start = function (event) {
injectProps(event.data);
this._gameView.start();
};
GameWrapper.prototype.stop = function (event) {
this._gameView.stop();
};
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
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -6,6 +6,11 @@ ...@@ -6,6 +6,11 @@
"alias": "图片分成几列", "alias": "图片分成几列",
"type": "number", "type": "number",
"default": 3 "default": 3
},
"isNewPlayer":{
"alias": "isNewPlayer",
"type": "number",
"default": 1
} }
}, },
"assets": [{ "assets": [{
......
...@@ -124,22 +124,19 @@ export default class GameView extends engine.Container { ...@@ -124,22 +124,19 @@ export default class GameView extends engine.Container {
engine.Tween.removeTweens(i); engine.Tween.removeTweens(i);
}) })
} }
guidenew:boolean = false;
async start() { async start() {
console.log('on start') // console.log('on start',getGuideInfo());
this._timeCounter = 0; this._timeCounter = 0;
if (!getGuideInfo()) { if (!props.isNewPlayer&&!this.guidenew) {
await this.guide.startGuide(); await this.guide.startGuide();
setGuide(); setGuide();
this.guidenew = true;
} }
this.conveyors.clear() this.conveyors.clear()
await this.countdown.startCountDown(); await this.countdown.startCountDown();
this.startGame(); this.startGame();
engine.globalEvent.dispatchEvent('recycling-time-update', { engine.globalEvent.dispatchEvent('recycling-time-update', {
second: this.getSecond(), second: this.getSecond(),
}); });
......
export default () => { export default () => {
//0 未引导 //0 未引导
if (!window.localStorage) { try{
if(window.localStorage&&window.localStorage.getItem){
return localStorage.getItem('recyclingGuide')
}else{
return 0 return 0
} }
}catch(e){
return localStorage.getItem('recyclingGuide') console.log("getguideinfo--error",e);
return 0;
}
} }
export const setGuide = () => { export const setGuide = () => {
if (window.localStorage) try{
localStorage.setItem('recyclingGuide', '1') if (window.localStorage&&window.localStorage.setItem){
localStorage.setItem('recyclingGuide', '1');
}
}catch(e){
console.log("setguide--err",e);
}
} }
\ No newline at end of file
/**
* Created by renjianfeng on 2020-03-13.
*/
const customId = 'turnplate';
(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('turnplate-reset', {
prizes:[
{
"icon":"//yun.dui88.com/images/201907/ui83og75fr.png",
"id":"o8c947e58",
"index":1,
"name":"优惠券1",
"prizeId":"ga58ef339",
"prizeType":2
},
{
"icon":"//yun.duiba.com.cn/db-m/app/turntable/circle/images/prize/谢谢参与_6311f27.png",
"id":"thanks",
"index":2,
"name":"谢谢参与",
"prizeId":"thanks",
"prizeType":0
},
// {
// "icon":"//yun.duiba.com.cn/db-m/app/turntable/circle/images/prize/谢谢参与_6311f27.png",
// "id":"thanks",
// "index":2,
// "name":"谢谢参与",
// "prizeId":"thanks2",
// "prizeType":0
// },
{
"icon":"//yun.dui88.com/images/201907/xsit2cvmyl.jpeg",
"id":"ob52caaca",
"index":3,
"name":"实物1",
"prizeId":"gb87b2592",
"prizeType":2
},
{
"icon":"//yun.dui88.com/projectxh5/alipay-250-250.png",
"id":"ob7dc936f",
"index":4,
"name":"支付宝10元",
"prizeId":"g1f8062fe",
"prizeType":2
},
{
"icon":"//yun.dui88.com/projectxh5/phonebill-250-250.png",
"id":"o56bf97cc",
"index":5,
"name":"话费30元",
"prizeId":"gbeeb3187",
"prizeType":2
},
{
"icon":"//yun.dui88.com/projectxh5/qb-250-250.png",
"id":"o6c455e84",
"index":6,
"name":"Q币10个",
"prizeId":"g4c4c3edd",
"prizeType":2
}
]
});
},100)
setTimeout(() => {
engine.globalEvent.dispatchEvent('turnplate-start',{"prizeId":"g1f8062fe"});
}, 5000);
setTimeout(() => {
engine.globalEvent.dispatchEvent('turnplate-reset', {
prizes:[
{
"icon":"//yun.dui88.com/images/201907/ui83og75fr.png",
"id":"o8c947e58",
"index":1,
"name":"优惠券1",
"prizeId":"ga58ef339",
"prizeType":2
},
{
"icon":"//yun.duiba.com.cn/db-m/app/turntable/circle/images/prize/谢谢参与_6311f27.png",
"id":"thanks",
"index":2,
"name":"谢谢参与",
"prizeId":"thanks",
"prizeType":0
},
// {
// "icon":"//yun.duiba.com.cn/db-m/app/turntable/circle/images/prize/谢谢参与_6311f27.png",
// "id":"thanks",
// "index":2,
// "name":"谢谢参与",
// "prizeId":"thanks2",
// "prizeType":0
// },
{
"icon":"//yun.dui88.com/images/201907/xsit2cvmyl.jpeg",
"id":"ob52caaca",
"index":3,
"name":"实物1",
"prizeId":"gb87b2592",
"prizeType":2
},
{
"icon":"//yun.dui88.com/projectxh5/alipay-250-250.png",
"id":"ob7dc936f",
"index":4,
"name":"支付宝10元",
"prizeId":"g1f8062fe",
"prizeType":2
},
{
"icon":"//yun.dui88.com/projectxh5/phonebill-250-250.png",
"id":"o56bf97cc",
"index":5,
"name":"话费30元",
"prizeId":"gbeeb3187",
"prizeType":2
},
{
"icon":"//yun.dui88.com/projectxh5/qb-250-250.png",
"id":"o6c455e84",
"index":6,
"name":"Q币1000个",
"prizeId":"g4c4c3edd",
"prizeType":2
}
]
});
}, 20000);
});
engine.globalEvent.addEventListener('turnplate-over', (e) => {
console.log(e.type, e.data);
});
}
function reset(){
}
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.turnplate = 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);
}
var GameWrapper = (function (_super) {
tslib.__extends(GameWrapper, _super);
function GameWrapper() {
var _this = _super.call(this) || this;
_this.wheelPrizeRotation = [];
_this.items = [];
_this.itemsCon = [];
_this.itemsLabel = [];
_this.itemsIcon = [];
_this.once(engine.Event.ADDED_TO_STAGE, _this.setup, _this);
engine.globalEvent.addEventListener('turnplate-reset', _this.reset, _this);
engine.globalEvent.addEventListener('turnplate-start', _this.start, _this);
return _this;
}
GameWrapper.prototype.setup = function () {
this.turnplate = new engine.Container();
this.turnplate.x = 0;
this.turnplate.y = 0;
this.turnplate.rotation = -90;
this.turnplate.width = props.diameter;
this.turnplate.height = props.diameter;
this.turnplate.anchorX = this.turnplate.width / 2;
this.turnplate.anchorY = this.turnplate.height / 2;
this.addChild(this.turnplate);
this._turnplateBG = new engine.Container();
this._turnplateBG.width = props.diameter;
this._turnplateBG.height = props.diameter;
this._turnplateBG.anchorX = this.turnplate.width / 2;
this._turnplateBG.anchorY = this.turnplate.height / 2;
this._turnplateBG.rotation = props.rotationBg;
this.turnplate.addChild(this._turnplateBG);
this.turnplateBg = new engine.Sprite(getTextureByName('大转盘背景'));
this.turnplateBg.x = 0;
this.turnplateBg.y = 0;
this.turnplateBg.width = this.turnplate.width;
this.turnplateBg.height = this.turnplate.height;
this._turnplateBG.addChild(this.turnplateBg);
};
GameWrapper.prototype.reset = function (event) {
injectProps(event.data);
this.prizes = event.data.prizes;
console.log(this.prizes);
for (var i = 0; i < this.items.length; i++) {
this.itemsCon[i].removeChild(this.itemsLabel[i]);
this.itemsCon[i].removeChild(this.itemsIcon[i]);
this.items[i].removeChild(this.itemsCon[i]);
this.turnplate.removeChild(this.items[i]);
}
for (var i = 0; i < this.prizes.length; i++) {
this.items[i] = new engine.Container();
this.itemsCon[i] = new engine.Container();
this.itemsCon[i].x = props.prizesRadius;
this.itemsCon[i].rotation = 90;
this.items[i].x = this.turnplate.width / 2;
this.items[i].y = this.turnplate.height / 2;
this.turnplate.addChild(this.items[i]);
this.itemsLabel[i] = new engine.Label();
this.itemsLabel[i].text = this.prizes[i].name;
this.itemsLabel[i].width = 200;
this.itemsLabel[i].x = -this.itemsLabel[i].width / 2;
this.itemsLabel[i].textAlign = "center";
this.itemsLabel[i].fillColor = props.nameColor;
this.itemsLabel[i].size = props.nameSize;
this.itemsIcon[i] = new engine.Sprite();
this.itemsIcon[i].width = props.iconSize[0];
this.itemsIcon[i].height = props.iconSize[1];
this.itemsIcon[i].x = -this.itemsIcon[i].width / 2;
this.itemsIcon[i].y = props.iconY;
this.itemsIcon[i].texture = engine.Texture.from(this.prizes[i].icon);
this.itemsCon[i].addChild(this.itemsLabel[i]);
this.itemsCon[i].addChild(this.itemsIcon[i]);
this.items[i].addChild(this.itemsCon[i]);
var _rotation = (i) * (360 / this.prizes.length);
this.items[i].rotation = _rotation;
this.wheelPrizeRotation[this.prizes[i].prizeId] = _rotation;
}
this.turnplate.rotation = -90;
engine.Tween.removeTweens(this.turnplate);
engine.Tween.get(this.turnplate, { loop: true })
.to({ rotation: 360 - 90 }, 5000);
};
GameWrapper.prototype.start = function (event) {
var _this = this;
injectProps(event.data);
engine.Tween.removeTweens(this.turnplate);
var prizeId = event.data.prizeId;
engine.Tween.get(this.turnplate)
.to({ rotation: 7200 - this.wheelPrizeRotation[prizeId] - 90 }, 8000, engine.Ease.circInOut)
.wait(500)
.call(function () {
_this.turnplate.rotation = 360 - _this.wheelPrizeRotation[prizeId] + 0.001 - 90;
engine.globalEvent.dispatchEvent('turnplate-over', {
prizeId: prizeId
});
});
};
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/turnplate/src/props.ts","src/custom/turnplate/src/game/utils.ts","src/custom/turnplate/src/game/GameWrapper.ts","src/custom/turnplate/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\nexport function getStage(){\n\treturn engine.gameStage.stage;\n}","/**\n * Created by rockyl on 2020-01-09.\n */\n\nimport {injectProps,props} from \"../props\";\nimport { getTextureByName, getStage } from \"./utils\";\n\n\nexport class GameWrapper extends engine.Container {\n\tprivate _status;\n\tconstructor() {\n\t\tsuper();\n\t\tthis.once(engine.Event.ADDED_TO_STAGE, this.setup, this);\n\t\tengine.globalEvent.addEventListener('turnplate-reset', this.reset, this);\n\t\tengine.globalEvent.addEventListener('turnplate-start', this.start, this);\n\t}\n\n\tturnplate\n\tturnplateBg\n\t_turnplateBG\n\twheelPrizeRotation=[]\n\titems=[]\n\titemsCon=[]\n\titemsLabel=[]\n\titemsIcon=[]\n\n\tsetup(){\n\t\tthis.turnplate = new engine.Container();\n\t\tthis.turnplate.x=0\n\t\tthis.turnplate.y=0\n\t\tthis.turnplate.rotation=-90;\n\t\tthis.turnplate.width = props.diameter;\n\t\tthis.turnplate.height = props.diameter;\n\t\tthis.turnplate.anchorX=this.turnplate.width/2\n\t\tthis.turnplate.anchorY=this.turnplate.height/2\n\t\tthis.addChild(this.turnplate)\n\n\t\tthis._turnplateBG = new engine.Container();\n\t\tthis._turnplateBG.width = props.diameter;\n\t\tthis._turnplateBG.height = props.diameter;\n\t\tthis._turnplateBG.anchorX=this.turnplate.width/2\n\t\tthis._turnplateBG.anchorY=this.turnplate.height/2\n\t\tthis._turnplateBG.rotation=props.rotationBg;\n\t\tthis.turnplate.addChild(this._turnplateBG)\n\t\t\n\t\tthis.turnplateBg = new engine.Sprite(getTextureByName('大转盘背景'));\n\t\tthis.turnplateBg.x=0;\n\t\tthis.turnplateBg.y=0;\n\t\tthis.turnplateBg.width=this.turnplate.width;\n\t\tthis.turnplateBg.height=this.turnplate.height;\n\t\tthis._turnplateBG.addChild(this.turnplateBg)\n\t}\n\n\tprizes\n\n\treset(event: engine.Event) {\t\t\n\t\tinjectProps(event.data);\n\t\t\n\t\tthis.prizes=event.data.prizes\n\t\tconsole.log(this.prizes)\n\n\t\tfor(let i=0;i<this.items.length;i++){\n\t\t\tthis.itemsCon[i].removeChild(this.itemsLabel[i])\n\t\t\tthis.itemsCon[i].removeChild(this.itemsIcon[i])\n\t\t\tthis.items[i].removeChild(this.itemsCon[i])\n\t\t\tthis.turnplate.removeChild(this.items[i])\n\t\t}\n\n\t\tfor(let i=0;i<this.prizes.length;i++){\n\t\t\tthis.items[i] = new engine.Container();\n\t\t\tthis.itemsCon[i] = new engine.Container();\n\t\t\tthis.itemsCon[i].x=props.prizesRadius\n\t\t\tthis.itemsCon[i].rotation=90;\n\t\t\tthis.items[i].x=this.turnplate.width/2\n\t\t\tthis.items[i].y=this.turnplate.height/2\n\t\t\tthis.turnplate.addChild(this.items[i])\n\t\t\tthis.itemsLabel[i] = new engine.Label();\n\t\t\t\n\t\t\tthis.itemsLabel[i].text=this.prizes[i].name;\n\t\t\tthis.itemsLabel[i].width=200;\n\t\t\tthis.itemsLabel[i].x=-this.itemsLabel[i].width/2\n\t\t\tthis.itemsLabel[i].textAlign=\"center\";\n\t\t\tthis.itemsLabel[i].fillColor=props.nameColor;\n\t\t\tthis.itemsLabel[i].size=props.nameSize;\n\n\t\t\tthis.itemsIcon[i] =new engine.Sprite();\n\t\t\tthis.itemsIcon[i].width=props.iconSize[0]\n\t\t\tthis.itemsIcon[i].height=props.iconSize[1]\n\t\t\tthis.itemsIcon[i].x=-this.itemsIcon[i].width/2;\n\t\t\tthis.itemsIcon[i].y=props.iconY\n\t\t\tthis.itemsIcon[i].texture =engine.Texture.from(this.prizes[i].icon)\n\t\t\tthis.itemsCon[i].addChild(this.itemsLabel[i])\n\t\t\tthis.itemsCon[i].addChild(this.itemsIcon[i])\n\t\t\tthis.items[i].addChild(this.itemsCon[i])\n\n\t\t\tlet _rotation=(i)*(360/this.prizes.length)\n\t\t\tthis.items[i].rotation=_rotation\n\t\t\tthis.wheelPrizeRotation[this.prizes[i].prizeId]=_rotation;\n\t }\n\t this.turnplate.rotation=-90;\n\t engine.Tween.removeTweens(this.turnplate)\n\t engine.Tween.get( this.turnplate,{loop:true})\n\t\t.to({rotation:360-90}, 5000,)\n\t}\n\n\tstart(event: engine.Event) {\n\t\t//this.turnplate.rotation=-90;\n\t\tinjectProps(event.data);\n\t\tengine.Tween.removeTweens(this.turnplate)\n\t\tlet prizeId=event.data.prizeId\n\t\tengine.Tween.get( this.turnplate )\n\t\t.to({rotation:7200-this.wheelPrizeRotation[prizeId]-90}, 8000,engine.Ease.circInOut)\n\t\t.wait(500)\n\t\t.call(()=>{\n\t\t\tthis.turnplate.rotation=360-this.wheelPrizeRotation[prizeId]+0.001-90\n\t\t\tengine.globalEvent.dispatchEvent('turnplate-over', {\n\t\t\t\tprizeId\n\t\t\t});\n\t\t\t// disRect.visible=false;\n\t\t\t// if(prizeId!=\"thanks\"){\n\t\t\t// \t\tnext(\"success\",args)\n\t\t\t// }else{\n\t\t\t// \t\tnext(\"failed\",args)\n\t\t\t// }\n\t\t})\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"],"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,g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AAC,SAAS,CAAC,CAAA;SACzC,IAAI,OAAO,GAAC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAA;SAC9B,MAAM,CAAC,KAAK,CAAC,GAAG,CAAE,IAAI,CAAC,SAAS,CAAE;cACjC,EAAE,CAAC,EAAC,QAAQ,EAAC,IAAI,GAAC,IAAI,CAAC,kBAAkB,CAAC,OAAO,CAAC,GAAC,EAAE,EAAC,EAAE,IAAI,EAAC,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC;cACnF,IAAI,CAAC,GAAG,CAAC;cACT,IAAI,CAAC;aACL,KAAI,CAAC,SAAS,CAAC,QAAQ,GAAC,GAAG,GAAC,KAAI,CAAC,kBAAkB,CAAC,OAAO,CAAC,GAAC,KAAK,GAAC,EAAE,CAAA;aACrE,MAAM,CAAC,WAAW,CAAC,aAAa,CAAC,gBAAgB,EAAE;iBAClD,OAAO,SAAA;cACP,CAAC,CAAC;UAOH,CAAC,CAAA;MACF;KACF,kBAAC;CAAD,CAAC,CAtHgC,MAAM,CAAC,SAAS,GAsHhD;;iBCvHwB,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": {
"iconSize": {
"alias": "奖品图的大小",
"type": "array<number>",
"default": "80,80"
},
"diameter": {
"alias": "圆盘直径",
"type": "number",
"default": "600"
},
"prizesRadius": {
"alias": "奖品距离圆心的距离",
"type": "number",
"default": 250
},
"nameColor": {
"alias": "奖品名称的字体颜色",
"type": "string",
"default": "#444444"
},
"nameSize": {
"alias": "奖品名称的字体大小",
"type": "number",
"default": 20
},
"iconY": {
"alias": "奖品名称的Y轴偏移",
"type": "number",
"default": 30
},
"rotationBg": {
"alias": "背景旋转",
"type": "number",
"default": 30
}
},
"assets": [
{
"name": "大转盘背景",
"url": "//yun.duiba.com.cn/aurora/assets/559177b3c0d4245d245b5cdfa31ba9d9dc20223c.png",
"uuid": "d3ce99da-89e1-447d-8c52-b3f391925c3c",
"ext": ".png"
}
],
"events": {
"in": {
"turnplate-reset": {
"alias": "重置",
"data":{
"prizes":"所有奖品"
}
},
"turnplate-start": {
"alias": "开始",
"data":{
"prizeId":"中奖的奖品id"
}
}
},
"out": {
"turnplate-over": {
"alias": "转盘停止",
"data": {
"prizeId":"中奖的奖品id"
}
}
}
}
}
\ No newline at end of file
/**
* Created by rockyl on 2020-01-09.
*/
import {injectProps,props} from "../props";
import { getTextureByName, getStage } from "./utils";
export class GameWrapper extends engine.Container {
private _status;
constructor() {
super();
this.once(engine.Event.ADDED_TO_STAGE, this.setup, this);
engine.globalEvent.addEventListener('turnplate-reset', this.reset, this);
engine.globalEvent.addEventListener('turnplate-start', this.start, this);
}
turnplate
turnplateBg
_turnplateBG
wheelPrizeRotation=[]
items=[]
itemsCon=[]
itemsLabel=[]
itemsIcon=[]
setup(){
this.turnplate = new engine.Container();
this.turnplate.x=0
this.turnplate.y=0
this.turnplate.rotation=-90;
this.turnplate.width = props.diameter;
this.turnplate.height = props.diameter;
this.turnplate.anchorX=this.turnplate.width/2
this.turnplate.anchorY=this.turnplate.height/2
this.addChild(this.turnplate)
this._turnplateBG = new engine.Container();
this._turnplateBG.width = props.diameter;
this._turnplateBG.height = props.diameter;
this._turnplateBG.anchorX=this.turnplate.width/2
this._turnplateBG.anchorY=this.turnplate.height/2
this._turnplateBG.rotation=props.rotationBg;
this.turnplate.addChild(this._turnplateBG)
this.turnplateBg = new engine.Sprite(getTextureByName('大转盘背景'));
this.turnplateBg.x=0;
this.turnplateBg.y=0;
this.turnplateBg.width=this.turnplate.width;
this.turnplateBg.height=this.turnplate.height;
this._turnplateBG.addChild(this.turnplateBg)
}
prizes
reset(event: engine.Event) {
injectProps(event.data);
this.prizes=event.data.prizes
console.log(this.prizes)
for(let i=0;i<this.items.length;i++){
this.itemsCon[i].removeChild(this.itemsLabel[i])
this.itemsCon[i].removeChild(this.itemsIcon[i])
this.items[i].removeChild(this.itemsCon[i])
this.turnplate.removeChild(this.items[i])
}
for(let i=0;i<this.prizes.length;i++){
this.items[i] = new engine.Container();
this.itemsCon[i] = new engine.Container();
this.itemsCon[i].x=props.prizesRadius
this.itemsCon[i].rotation=90;
this.items[i].x=this.turnplate.width/2
this.items[i].y=this.turnplate.height/2
this.turnplate.addChild(this.items[i])
this.itemsLabel[i] = new engine.Label();
this.itemsLabel[i].text=this.prizes[i].name;
this.itemsLabel[i].width=200;
this.itemsLabel[i].x=-this.itemsLabel[i].width/2
this.itemsLabel[i].textAlign="center";
this.itemsLabel[i].fillColor=props.nameColor;
this.itemsLabel[i].size=props.nameSize;
this.itemsIcon[i] =new engine.Sprite();
this.itemsIcon[i].width=props.iconSize[0]
this.itemsIcon[i].height=props.iconSize[1]
this.itemsIcon[i].x=-this.itemsIcon[i].width/2;
this.itemsIcon[i].y=props.iconY
this.itemsIcon[i].texture =engine.Texture.from(this.prizes[i].icon)
this.itemsCon[i].addChild(this.itemsLabel[i])
this.itemsCon[i].addChild(this.itemsIcon[i])
this.items[i].addChild(this.itemsCon[i])
let _rotation=(i)*(360/this.prizes.length)
this.items[i].rotation=_rotation
this.wheelPrizeRotation[this.prizes[i].prizeId]=_rotation;
}
this.turnplate.rotation=-90;
engine.Tween.removeTweens(this.turnplate)
engine.Tween.get( this.turnplate,{loop:true})
.to({rotation:360-90}, 5000,)
}
start(event: engine.Event) {
//this.turnplate.rotation=-90;
injectProps(event.data);
engine.Tween.removeTweens(this.turnplate)
let prizeId=event.data.prizeId
engine.Tween.get( this.turnplate )
.to({rotation:7200-this.wheelPrizeRotation[prizeId]-90}, 8000,engine.Ease.circInOut)
.wait(500)
.call(()=>{
this.turnplate.rotation=360-this.wheelPrizeRotation[prizeId]+0.001-90
engine.globalEvent.dispatchEvent('turnplate-over', {
prizeId
});
// disRect.visible=false;
// if(prizeId!="thanks"){
// next("success",args)
// }else{
// next("failed",args)
// }
})
}
}
/**
* 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;
}
export function getStage(){
return engine.gameStage.stage;
}
\ 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);
}
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* Created by renjianfeng on 2020-03-13. * Created by renjianfeng on 2020-03-13.
*/ */
const customId = 'food-fell'; const customId = 'xiaoxiaole';
(async function () { (async function () {
let customModule = await fetch(`../meta.json`); let customModule = await fetch(`../meta.json`);
...@@ -45,22 +45,15 @@ function launchWithCustomModule(customModule) { ...@@ -45,22 +45,15 @@ function launchWithCustomModule(customModule) {
}, 100); }, 100);
setTimeout(() => { setTimeout(() => {
engine.globalEvent.dispatchEvent('food-fell-reset', { engine.globalEvent.dispatchEvent('game-init',{
"goodsProbability": [0.8,0.1,0.1], time:100000,
"countDown": 30, level:1,
"acceleratedSpeed":0.1 mode:"day"
}); });
engine.globalEvent.dispatchEvent('food-fell-start');
}, 500); }, 500);
}); setTimeout(() => {
engine.globalEvent.addEventListener('food-fell-time-update', (e) => { engine.globalEvent.dispatchEvent('game-start');
console.log(e.type, e.data); }, 700);
});
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);
}); });
} }
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
<head> <head>
<meta charset="UTF-8"> <meta charset="UTF-8">
<title>美食从天而降</title> <title>消消乐</title>
<meta name="viewport" <meta name="viewport"
content="width=device-width,initial-scale=1, minimum-scale=1, maximum-scale=1, user-scalable=no"/> 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="apple-mobile-web-app-capable" content="yes"/>
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
height: 100%; height: 100%;
overflow: hidden; overflow: hidden;
position: absolute; position: absolute;
background-color: red; /* background-color: red; */
} }
</style> </style>
</head> </head>
......
...@@ -3,48 +3,7 @@ ...@@ -3,48 +3,7 @@
*/ */
const assets = [ 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": "玩家",
"url": "//yun.duiba.com.cn/aurora/assets/b66300c5d4f27134b0aac3dc90a3220e8ae572eb.svga",
"uuid": "71d8dcbc-3931-471a-b585-b3ae01b25aa6",
"ext": ".svga"
}
]; ];
function loadAssets(customModuleAssets, onProgress, onComplete){ function loadAssets(customModuleAssets, onProgress, onComplete){
......
"use strict";var tslib=require("tslib"),props={};function prepareProps(){var e=getProps();engine.injectProp(props,e)}function injectProps(e){engine.injectProp(props,e)}function getTexture(e){return engine.Texture.from(getAssetByUUID(e).uuid)}function getTextureByName(e){return getTexture(engine.getAssetByName(e).uuid)}function createSvga(e,t){var o=new svga.Svga;return o.source="asset://"+engine.getAssetByName(e).uuid,o}var Goods=function(s){function e(){var e,t=s.call(this)||this;e=t._body=new engine.Rect;var o=new engine.Sprite(getTextureByName("雨滴"));o.npcType="rain";var n=new engine.Sprite(getTextureByName("石块"));n.npcType="stone";var i=new engine.Sprite(getTextureByName("炸弹"));return i.npcType="boom",o.visible=!1,n.visible=!1,i.visible=!1,e.addChild(o),e.addChild(n),e.addChild(i),t.addChild(e),e.width=1e-4,e.height=1e-4,e.mouseEnabled=!1,t}return tslib.__extends(e,s),e.prototype.getRandomNumberByRange=function(e,t){return Math.floor(Math.random()*(t-e)+e)},e.prototype.reset=function(){this.visible=!0,this.rotation=0,this.anchorOffsetY=0,this.y=0,this.x=630*Math.random()+30,this.rotation=0;var e=Math.random();e<props.goodsProbability[0]?this.showNpc("rain"):e>=props.goodsProbability[0]&&e<=props.goodsProbability[0]+props.goodsProbability[1]?this.showNpc("stone"):e>props.goodsProbability[0]+props.goodsProbability[1]&&this.showNpc("boom")},e.prototype.showNpc=function(e){for(var t=0;t<this._body.children.length;t++)this._body.children[t].visible=!1,this._body.children[t].mouseEnabled=!1;for(t=0;t<this._body.children.length;t++)this._body.children[t].npcType==e&&(this.npcType=e,this._body.children[t].visible=!0,this._body.children[t].mouseEnabled=!1)},Object.defineProperty(e.prototype,"anchorOffsetY",{set:function(e){this._body.y=e},enumerable:!0,configurable:!0}),e}(engine.Container),ObjectPool=engine.ObjectPool,PoolName="goods";ObjectPool.registerPool(PoolName,function(){return new Goods},function(e,t){e.reset()});var ObjectPool$1=engine.ObjectPool,GameView=function(e){function t(){var t=e.call(this)||this;return t.goodsItems=[],t.moveCatchX=0,t.playerCatchX=0,t.onDownStage=function(e){t.moveCatchX=e.localX,t.playerCatchX=t.player.x},t.onMoveStage=function(e){t.gameIng&&(t.player.x=t.playerCatchX+(e.localX-t.moveCatchX))},t.onOutStage=function(e){t.moveCatchX=0},t.once(engine.Event.ADDED_TO_STAGE,t.setup,t),t}return tslib.__extends(t,e),t.prototype.setup=function(){var e=this;this._hasSetup||(this._hasSetup=!0,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=!1,this.addChild(this.player),this.waterSvga=createSvga("水花"),this.playerSvga=createSvga("玩家"),this.boomSvga=createSvga("炸弹svga"),this.player.addChild(this.playerSvga),this.player.addChild(this.waterSvga),this.player.addChild(this.boomSvga),this.playerSvga.gotoAndPlay(1),this.visible=!1,setTimeout(function(){e.visible=!0,e.player.anchorY=e.player.height/2,e.player.anchorX=e.player.width/2,console.log(e.player.width),console.log(e.playerSvga.width),e.player.x=375-e.player.width/2,e.player.y=props.playerPositionY},300),this.rectBg=new engine.Rect,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))},t.prototype.reset=function(){this.recycleGoods()},t.prototype.start=function(){var e=this;this.score=0,this.speed=1,this.gameIng=!0,this.creatNpc(),this.beginNpc(),this.countdown=props.countDown,this.countdownTimer=setInterval(function(){e.gameIng&&(0<e.countdown?(engine.globalEvent.dispatchEvent("food-fell-time-update",{time:e.countdown}),e.countdown-=1):(engine.globalEvent.dispatchEvent("food-fell-game-over",{score:e.score,reason:1}),e.died()))},1e3)},t.prototype.beginNpc=function(){var e=this;this.timer=setTimeout(function(){e.gameIng&&(e.speed+=props.acceleratedSpeed,e.creatNpc()),e.beginNpc()},2e3/this.speed)},t.prototype.pause=function(){this.gameIng=!1},t.prototype.revive=function(){this.gameIng=!0},t.prototype.resume=function(){this.reset(),this.start()},t.prototype.creatNpc=function(){var e=this,t=this._goods=ObjectPool$1.getObject(PoolName);this.goodsItems.push(t),this.NpcBg.addChild(t),t.addEventListener(engine.Event.ENTER_FRAME,t.onGoodsEnter=function(){1624<t.y?e.removeNpc(t):e.gameIng&&(t.y+=4*e.speed,e.hasHit(e.player,t)&&("rain"==t.npcType?(console.log("碰到雨滴"),e.score+=props.rainScore,e.waterSvga.visible=!0,e.waterSvga.play(!1,!1),e.waterSvga.once(engine.Event.END_FRAME,function(){e.waterSvga.visible=!1},e)):"stone"==t.npcType?(console.log("碰到石头"),e.score+=props.stoneScore):"boom"==t.npcType&&(console.log("碰到炸弹"),e.boomSvga.visible=!0,e.boomSvga.play(!1,!1),e.boomSvga.once(engine.Event.END_FRAME,function(){e.boomSvga.visible=!1},e),engine.globalEvent.dispatchEvent("food-fell-game-over",{score:e.score,reason:2}),e.died()),engine.globalEvent.dispatchEvent("food-fell-score-update",{score:e.score}),e.removeNpc(t)))},this)},t.prototype.died=function(){this.score=0,this.pause()},t.prototype.removeNpc=function(e){this.NpcBg.removeChild(e),ObjectPool$1.recycleObject(PoolName,e),e.removeEventListener(engine.Event.ENTER_FRAME,e.onGoodsEnter,this);var t=this.goodsItems.indexOf(e);-1<t&&this.goodsItems.splice(t,1)},t.prototype.recycleGoods=function(){clearTimeout(this.timer),clearInterval(this.countdownTimer);for(var e=0,t=this.goodsItems;e<t.length;e++){var o=t[e];o&&(this.removeChild(o),ObjectPool$1.recycleObject(PoolName,o),o.removeEventListener(engine.Event.ENTER_FRAME,o.onGoodsEnter,this))}this.goodsItems=[]},t.prototype.hasHit=function(e,t){return Math.abs(e.x+e.width/2-(t.x+t.width/2))<e.width/2+t.width/2&&Math.abs(e.y+e.height/2-(t.y+t.height/2))<e.height/2+t.height/2},t}(engine.Container),GameWrapper=function(o){function e(){var e=o.call(this)||this;engine.globalEvent.addEventListener("food-fell-reset",e.reset,e),engine.globalEvent.addEventListener("food-fell-start",e.start,e),engine.globalEvent.addEventListener("food-fell-pause",e.pause,e),engine.globalEvent.addEventListener("food-fell-resume",e.resume,e),engine.globalEvent.addEventListener("food-fell-revive",e.revive,e),engine.globalEvent.addEventListener("food-fell-clear",e.clear,e),e.addEventListener(engine.MouseEvent.CLICK,e.onTap,e);var t=e._gameView=new GameView;return e.addChild(t),e}return tslib.__extends(e,o),e.prototype.reset=function(e){injectProps(e.data),this._gameView.visible=!0,this._gameView.reset()},e.prototype.start=function(e){injectProps(e.data),this._status=1,this._gameView.start()},e.prototype.pause=function(){this._gameView.pause()},e.prototype.resume=function(){this._gameView.resume()},e.prototype.revive=function(){this._gameView.revive()},e.prototype.clear=function(){this._gameView.visible=!1},e.prototype.onTap=function(e){},e}(engine.Container);function index(e){return prepareProps(),injectProps(e),new GameWrapper}module.exports=index; (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.xiaoxiaole = 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 Element = (function (_super) {
tslib.__extends(Element, _super);
function Element() {
var _this = _super.call(this) || this;
_this.width = MapData.itemsize;
_this.height = MapData.itemsize;
_this.anchorX = MapData.itemsize / 2;
_this.eimage = new engine.Image();
_this.addChild(_this.eimage);
_this.touch = true;
_this.addEventListener(engine.MouseEvent.MOUSE_DOWN, _this.selectele, _this);
_this.addEventListener(engine.MouseEvent.MOUSE_MOVE, _this.changemove, _this);
return _this;
}
Object.defineProperty(Element.prototype, "touch", {
set: function (touch) {
this.mouseEnabled = touch;
this.mouseChildren = touch;
},
enumerable: false,
configurable: true
});
Element.prototype.init = function (type) {
this.anchorY = MapData.itemsize;
this.scaleX = 1;
this.scaleY = 1;
this.alpha = 1;
this.type = type;
var ename = MapData.getEtypeImgName(type);
this.eimage.texture = MapData.getEtypeImgTex(type);
var imgwid = this.eimage.texture.width;
var imghei = this.eimage.texture.height;
this.eimage.x = (this.width - imgwid) / 2;
this.eimage.y = (this.height - imghei) / 2;
};
Element.prototype.setrc = function (r, c) {
this.inrow = r;
this.incol = c;
};
Element.prototype.selectele = function (e) {
engine.globalEvent.dispatchEvent(GameEvent.SelectEle, {
r: this.inrow,
c: this.incol,
type: "mouse_down"
});
};
Element.prototype.changemove = function (e) {
engine.globalEvent.dispatchEvent(GameEvent.SelectEle, {
r: this.inrow,
c: this.incol,
type: "mouse_move"
});
};
Object.defineProperty(Element.prototype, "factor", {
get: function () {
return 0;
},
set: function (value) {
this.x = (1 - value) * (1 - value) * this.p1x + 2 * value * (1 - value) * this.c1x + value * value * this.p2x;
this.y = (1 - value) * (1 - value) * this.p1y + 2 * value * (1 - value) * this.c1y + value * value * this.p2y;
var mscale = (1 - value) * (1 - value) * 1 + 2 * value * (1 - value) * 0.6 + value * value * 0.35;
this.scaleX = mscale;
this.scaleY = mscale;
},
enumerable: false,
configurable: true
});
Element.prototype.flyToHome = function (tx, ty, time) {
var _this = this;
this.p1x = this.x;
this.p1y = this.y + 20;
this.c1x = (this.p1x - tx) / 4 + tx;
this.c1y = ty;
this.p2x = tx;
this.p2y = ty;
engine.Tween.removeTweens(this);
engine.Tween.get(this).to({
scaleX: 1.1,
scaleY: 1.1
}, 200)
.to({
scaleX: 1.1,
scaleY: 0.88
}, 100)
.to({
scaleX: 0.98,
scaleY: 0.98,
y: this.y + 20
}, 100)
.call(function () {
_this.factor = 0;
engine.Tween.get(_this).to({
factor: 1
}, 450)
.call(function () {
var nodeparent = _this.parent;
nodeparent && nodeparent.removeChild(_this);
MapData.recoverEle(_this, _this.type);
});
});
};
Element.prototype.changePos = function (tpos) {
var _this = this;
var nx = this.x;
var ny = this.y;
var tx = tpos[0];
var ty = tpos[1];
var dis = MapData.getDistance([nx, ny], tpos);
var time = Math.ceil(dis / MapData.anispeed * 1000);
engine.Tween.removeTweens(this);
var pro = new Promise(function (res) {
engine.Tween.get(_this, { loop: false }).to({
x: tx,
y: ty
}, time)
.call(function () {
res();
});
});
return pro;
};
return Element;
}(engine.Container));
var ElementType;
(function (ElementType) {
ElementType[ElementType["btiger"] = 1] = "btiger";
ElementType[ElementType["gtiger"] = 2] = "gtiger";
ElementType[ElementType["monkey"] = 3] = "monkey";
ElementType[ElementType["bird"] = 4] = "bird";
ElementType[ElementType["koala"] = 5] = "koala";
})(ElementType || (ElementType = {}));
var GameEvent;
(function (GameEvent) {
GameEvent["SelectEle"] = "SelectEle";
})(GameEvent || (GameEvent = {}));
var MapData = (function () {
function MapData() {
}
MapData.getRy = function (r) {
return this.paddingb + r * (this.itemsize + this.paddingi);
};
MapData.getCx = function (c) {
return this.paddingb + c * (this.itemsize + this.paddingi);
};
MapData.getRCPos = function (r, c) {
var x = this.getCx(c);
var y = this.getRy(r);
return [x, y];
};
MapData.adaptElePos = function (pos, wid, hei) {
var x = pos[0] + (this.itemsize - wid) / 2;
var y = pos[1] + (this.itemsize - hei) / 2;
return [x, y];
};
MapData.getEtypeImgName = function (type) {
var ename;
switch (type) {
case ElementType.btiger:
ename = "白虎";
break;
case ElementType.gtiger:
ename = "雌虎";
break;
case ElementType.monkey:
ename = "猴子";
break;
case ElementType.bird:
ename = "鸟";
break;
case ElementType.koala:
ename = "树熊";
break;
default:
console.error("未定义元素类型");
break;
}
return ename;
};
MapData.getEtypeImgTex = function (type) {
var etex;
switch (type) {
case ElementType.btiger:
if (!this.btigerTex) {
this.btigerTex = getTextureByName("白虎");
console.log("新素材加载---白虎");
}
etex = this.btigerTex;
break;
case ElementType.gtiger:
if (!this.gtigerTex) {
this.gtigerTex = getTextureByName("雌虎");
console.log("新素材加载---雌虎");
}
etex = this.gtigerTex;
break;
case ElementType.monkey:
if (!this.monkeyTex) {
this.monkeyTex = getTextureByName("猴子");
console.log("新素材加载---猴子");
}
etex = this.monkeyTex;
break;
case ElementType.bird:
if (!this.birdTex) {
this.birdTex = getTextureByName("鸟");
console.log("新素材加载---鸟");
}
etex = this.birdTex;
break;
case ElementType.koala:
if (!this.koalaTex) {
this.koalaTex = getTextureByName("树熊");
console.log("新素材加载---树熊");
}
etex = this.koalaTex;
break;
default:
console.error("未定义元素类型");
break;
}
return etex;
};
MapData.getRandEtype = function () {
var eletypeArr = [ElementType.btiger, ElementType.gtiger, ElementType.monkey, ElementType.bird, ElementType.koala];
var etype = eletypeArr[Math.floor(Math.random() * eletypeArr.length)];
return etype;
};
MapData.initPoolEle = function () {
this.btigerTex = getTextureByName("白虎");
this.gtigerTex = getTextureByName("雌虎");
this.monkeyTex = getTextureByName("猴子");
this.birdTex = getTextureByName("鸟");
this.koalaTex = getTextureByName("树熊");
var eletypes = [ElementType.btiger, ElementType.gtiger, ElementType.monkey, ElementType.bird, ElementType.koala];
this.elePool["ele"] = new Array();
for (var i = 0; i < eletypes.length; i++) {
for (var a = 0; a < 5; a++) {
var iele = new Element();
this.elePool["ele"].push(iele);
}
}
this.elePool["score"] = new Array();
for (var t = 0; t < 8; t++) {
var itxt = new engine.Label();
itxt.size = 66;
itxt.width = 200;
itxt.height = 70;
itxt.textAlign = engine.TEXT_ALIGN.CENTER;
itxt.verticalAlign = engine.VERTICAL_ALIGN.MIDDLE;
itxt.anchorY = 35;
itxt.anchorX = 100;
itxt.bold = true;
this.elePool["score"].push(itxt);
}
};
MapData.getOneEle = function (type) {
var ele;
if (this.elePool["ele"]) {
if (this.elePool["ele"].length > 0) {
ele = this.elePool["ele"].shift();
}
}
else {
this.elePool["ele"] = new Array();
}
if (!ele) {
console.error("创建了新的了ele");
ele = new Element();
}
ele.name = "ele_" + this.eleidx;
this.eleidx += 1;
ele.init(type);
return ele;
};
MapData.getOneTxt = function () {
var itxt;
if (this.elePool["score"]) {
if (this.elePool["score"].length > 0) {
itxt = this.elePool["score"].shift();
}
}
else {
this.elePool["score"] = new Array();
}
if (!itxt) {
itxt = new engine.Label();
itxt.size = 66;
itxt.width = 200;
itxt.height = 70;
itxt.textAlign = engine.TEXT_ALIGN.CENTER;
itxt.verticalAlign = engine.VERTICAL_ALIGN.MIDDLE;
itxt.anchorY = 35;
itxt.anchorX = 100;
itxt.bold = true;
}
itxt.mouseEnabled = false;
return itxt;
};
MapData.recoverEle = function (ele, type) {
if (ele.eimage) {
ele.eimage.texture = null;
}
this.elePool["ele"].push(ele);
};
MapData.recoverTxt = function (txt) {
this.elePool["score"].push(txt);
};
MapData.getDistance = function (p1, p2) {
var p1x = p1[0];
var p1y = p1[1];
var p2x = p2[0];
var p2y = p2[1];
var dis = Math.sqrt(Math.pow(p1x - p2x, 2) + Math.pow(p1y - p2y, 2));
return dis;
};
MapData.itemsize = 129;
MapData.paddingb = 10;
MapData.paddingi = 5;
MapData.row = 5;
MapData.col = 5;
MapData.posData = {};
MapData.eleidx = 1;
MapData.elePool = {};
MapData.anispeed = 1000;
MapData.levelData = [
[
[1, 2, 5, 3, 4],
[3, 1, 2, 4, 5],
[2, 5, 3, 4, 1],
[5, 4, 1, 2, 3],
[4, 1, 3, 5, 2],
],
[
[5, 2, 1, 2, 1],
[3, 1, 4, 5, 4],
[2, 5, 3, 5, 1],
[5, 4, 1, 2, 3],
[4, 1, 3, 1, 2],
],
[
[2, 4, 1, 5, 2],
[2, 3, 4, 1, 3],
[4, 1, 3, 2, 3],
[3, 2, 1, 1, 4],
[1, 1, 3, 5, 4],
],
[
[3, 2, 1, 4, 5],
[2, 4, 1, 2, 3],
[2, 3, 2, 3, 3],
[4, 4, 5, 5, 4],
[3, 3, 1, 2, 4],
],
[
[4, 5, 1, 2, 4],
[3, 2, 3, 4, 2],
[1, 5, 2, 3, 5],
[4, 5, 5, 1, 3],
[1, 2, 3, 2, 4],
]
];
return MapData;
}());
var GameView = (function (_super) {
tslib.__extends(GameView, _super);
function GameView() {
var _this = _super.call(this) || this;
_this.lattices = {};
_this.eliminateArr = [];
_this.selectArr = [];
_this.conty = 140;
_this.homex = 562;
_this.homey = -20;
_this.ination = false;
_this.canation = true;
_this._gametime = 60;
_this._gamestat = 2;
_this.ingameover = false;
_this.ingame = true;
_this.level = 0;
_this.inrecord = false;
_this.requestGameOver = false;
_this._seq = 1;
_this.sptime = Date.now();
_this._score = 0;
_this.inEliminate = false;
_this.newSelect = false;
_this.once(engine.Event.ADDED_TO_STAGE, _this.setup, _this);
return _this;
}
Object.defineProperty(GameView.prototype, "gamestat", {
get: function () {
return this._gamestat;
},
set: function (stat) {
this._gamestat = stat;
if (stat == 2) {
this.changeEnable(false);
}
},
enumerable: false,
configurable: true
});
Object.defineProperty(GameView.prototype, "seq", {
get: function () {
return this._seq;
},
set: function (num) {
this._seq = num;
},
enumerable: false,
configurable: true
});
GameView.prototype.setup = function () {
MapData.initPoolEle();
this.selectimg = new engine.Image(getTextureByName("选中框"));
this.selectimg.mouseEnabled = false;
this.jiantou1 = new engine.Image(getTextureByName("交换箭头"));
this.jiantou2 = new engine.Image(getTextureByName("交换箭头"));
this.jiantou1.mouseEnabled = false;
this.jiantou2.mouseEnabled = false;
var jiantwid = 31;
var jianthei = 24;
this.jiantou1.anchorX = jiantwid / 2;
this.jiantou1.anchorY = jianthei / 2;
this.jiantou2.anchorX = jiantwid / 2;
this.jiantou2.anchorY = jianthei / 2;
this.jiantoucont = new engine.Container();
this.jiantoucont.width = MapData.itemsize;
this.jiantoucont.height = MapData.itemsize;
this.jtsx1 = MapData.itemsize / 2 - jiantwid / 2;
this.jtsx2 = MapData.itemsize / 2 - jiantwid / 2;
this.jtsy1 = MapData.itemsize / 2 - jianthei;
this.jtsy2 = MapData.itemsize / 2;
this.jtex1 = this.jtsx1 - 10;
this.jtex2 = this.jtsx2 + 10;
this.jtey1 = this.jtsy1;
this.jtey2 = this.jtsy2;
this.jiantou1.x = this.jtsx1;
this.jiantou2.rotation = 180;
this.jiantou2.x = this.jtsx2;
this.jiantou1.y = this.jtsy1;
this.jiantou2.y = this.jtsy2;
this.jiantoucont.addChild(this.jiantou1);
this.jiantoucont.addChild(this.jiantou2);
var row = MapData.row;
var col = MapData.col;
this.homeimgday = createSvga("房子动画");
this.homeimgday.x = this.homex;
this.homeimgday.y = this.homey;
this.homeimgday.stop();
this.homeimgday.visible = false;
this.addChild(this.homeimgday);
this.homeimgnight = createSvga("夜晚房子");
this.homeimgnight.x = this.homex;
this.homeimgnight.y = this.homey;
this.homeimgnight.stop();
this.homeimgnight.visible = false;
this.addChild(this.homeimgnight);
this.container = new engine.Container();
this.addChild(this.container);
this.container.y = this.conty;
var maskimg = new engine.Graphics();
this.container.addChild(maskimg);
this.container.mask = maskimg;
maskimg.moveTo(0, 0);
maskimg.beginFill(0);
maskimg.lineTo(681, 0);
maskimg.lineTo(681, 679);
maskimg.lineTo(0, 679);
maskimg.lineTo(0, 0);
maskimg.endFill();
this.anicontainer = new engine.Container();
this.addChild(this.anicontainer);
this.anicontainer.mouseEnabled = false;
this.anicontainer.mouseChildren = false;
this.txtcontainer = new engine.Container();
this.addChild(this.txtcontainer);
var map = new engine.Image(getTextureByName("底图"));
this.container.addChild(map);
for (var r = 0; r < row; r++) {
for (var c = 0; c < col; c++) {
var rcpos = MapData.getRCPos(r, c);
MapData.posData[r + "_" + c] = rcpos;
}
}
this.tanix = this.homex + 30;
this.taniy = this.homey;
engine.globalEvent.addEventListener(GameEvent.SelectEle, this.selectele, this);
this.removeEventListener(engine.Event.ADDED_TO_STAGE, this.setup, this);
this.lastframeTime = Date.now();
this.lastatime = Date.now();
this.addEventListener(engine.Event.ENTER_FRAME, this.onUpdate, this);
};
GameView.prototype.changeAni = function () {
this.changeHomeShow("night");
};
GameView.prototype.playComp = function () {
this.homeimgday.stop(1);
this.homeimgnight.stop(1);
};
GameView.prototype.init = function (time, level, mode) {
this.score = 0;
this.gametime = time;
this.seq = 1;
this.level = level;
this.ingameover = false;
this.changeHomeShow(mode);
this.initContainer();
this.sptime = Date.now();
};
Object.defineProperty(GameView.prototype, "score", {
get: function () {
return this._score;
},
set: function (num) {
this._score = num;
engine.globalEvent.dispatchEvent('game-score-update', { score: this._score });
},
enumerable: false,
configurable: true
});
Object.defineProperty(GameView.prototype, "gametime", {
get: function () {
return this._gametime;
},
set: function (time) {
var lshowtime = Math.round(this._gametime);
var nshowtime = Math.round(time);
if (lshowtime != nshowtime) {
if (this.gamestat == 1 && nshowtime < 1) {
this.gameOver();
}
if (nshowtime < 0) {
nshowtime = 0;
}
engine.globalEvent.dispatchEvent('game-time-update', { time: nshowtime });
}
if (time < 0) {
time = 0;
}
this._gametime = time;
},
enumerable: false,
configurable: true
});
GameView.prototype.gameOver = function () {
this.gamestat = 2;
this.unShowEleAttion();
this.anicontainer.removeChild(this.selectimg);
this.ingameover = true;
console.log("倒计时结束1=============", this.ingameover, this.inEliminate, this.inrecord);
this.checkGameOver("time-over");
};
GameView.prototype.checkGameOver = function (type) {
if (this.ingameover) {
console.log("倒计时已结束2==========", this.inEliminate, this.inrecord, type);
}
if (this.ingameover && !this.inEliminate && !this.inrecord && !this.requestGameOver) {
this.requestGameOver = true;
this.unShowEleAttion();
this.anicontainer.removeChild(this.jiantoucont);
engine.globalEvent.dispatchEvent("game-over", {
score: this.score
});
}
};
GameView.prototype.reset = function (time, level, mode) {
return tslib.__awaiter(this, void 0, void 0, function () {
var key, rcname, rcele, rcelex, rceley, rcetype, fallpro, testdata;
return tslib.__generator(this, function (_a) {
switch (_a.label) {
case 0:
this.anicontainer.removeChild(this.selectimg);
this.selectArr = new Array();
this.gametime = time;
this.level = level;
this.ingameover = false;
this.requestGameOver = false;
this.seq = 1;
this.changeHomeShow(mode);
this.changeEnable(false);
for (key in this.lattices) {
rcname = this.lattices[key];
rcele = this.container.getChildByName(rcname);
if (rcele) {
rcelex = rcele.x;
rceley = rcele.y;
rcetype = rcele.type;
this.lattices[key] = "empty";
this.goDisplayAni1(rcele, rcetype, rcelex, rceley);
}
}
fallpro = new Promise(function (res) {
setTimeout(function () {
res();
}, 400);
});
return [4, fallpro];
case 1:
_a.sent();
testdata = MapData.levelData[this.level];
this.levelData = testdata;
this.fall("newlevel");
return [2];
}
});
});
};
GameView.prototype.start = function () {
this.gamestat = 1;
this.requestGameOver = false;
this.selectArr = new Array();
this.changeEnable(true);
};
GameView.prototype.pause = function () {
this.ingame = false;
};
GameView.prototype.resume = function () {
this.lastframeTime = Date.now();
this.ingame = true;
};
GameView.prototype.onUpdate = function () {
var ntime = Date.now();
if (this.gamestat == 1 && this.ingame) {
var passtime = ntime - this.lastframeTime;
if (ntime - this.lastatime >= 5000 && !this.ination && this.canation && this.selectArr.length == 0) {
this.attionEliShow();
}
if (this.gametime && this.gametime > 0) {
var ngtime = this.gametime - (passtime / 1000);
this.gametime = ngtime;
}
}
if (this.homeimgday && this.homeimgday.visible) {
var curframe = this.homeimgday.currentFrame;
if (curframe == this.homeimgday.totalFrames) {
this.homeimgday.gotoAndStop(1);
}
}
if (this.homeimgnight && this.homeimgnight.visible) {
var curframe = this.homeimgnight.currentFrame;
if (curframe == this.homeimgnight.totalFrames) {
this.homeimgnight.gotoAndStop(1);
}
}
this.lastframeTime = ntime;
};
GameView.prototype.initContainer = function () {
if (this.lattices) {
for (var key in this.lattices) {
var rcname = this.lattices[key];
var rcele = this.container.getChildByName(rcname);
if (rcele) {
var rcetype = rcele.type;
this.container.removeChild(rcele);
this.lattices[key] = "empty";
MapData.recoverEle(rcele, rcetype);
}
}
}
else {
this.lattices = {};
}
var testdata = MapData.levelData[this.level];
this.levelData = testdata;
for (var r = 0; r < testdata.length; r++) {
var rdata = testdata[r];
for (var c = 0; c < rdata.length; c++) {
var rctype = rdata[c];
var rcele = MapData.getOneEle(rctype);
var rcpos = MapData.getRCPos(r, c);
this.container.addChild(rcele);
rcele.x = rcpos[0];
rcele.y = rcpos[1];
var rcidx = r + "_" + c;
this.lattices[rcidx] = rcele.name;
this.setLatticeEleRc(rcidx);
}
}
this.checkInit();
};
GameView.prototype.checkInit = function () {
this.checkEliminate();
if (this.eliminateArr.length > 0) {
return this.eliminate();
}
else {
this.selectArr = new Array();
var isdiedata = this.attionEliminate();
if (isdiedata && isdiedata.length == 3) {
this.changeEnable(true);
}
else {
this.solveDieMap();
}
}
};
GameView.prototype.setLatticeEleRc = function (rcidx) {
var rename = this.lattices[rcidx];
var rcnode = this.container.getChildByName(rename);
if (rcnode) {
var er = Number(rcidx.split("_")[0]);
var ec = Number(rcidx.split("_")[1]);
rcnode.setrc(er, ec);
}
};
GameView.prototype.unShowEleAttion = function () {
if (this.ination) {
this.ination = false;
this.lastatime = Date.now();
var arrcidx1 = this.attiondata[0];
var arrcidx2 = this.attiondata[1];
var atname1 = this.lattices[arrcidx1];
var atname2 = this.lattices[arrcidx2];
var atnode1 = this.container.getChildByName(atname1);
var atnode2 = this.container.getChildByName(atname2);
var aboutnames = this.attiondata[2];
if (!atnode1 || !atnode2) {
this.attiondata = new Array();
return;
}
var atpos1 = MapData.getRCPos(arrcidx1.split("_")[0], arrcidx1.split("_")[1]);
var atpos2 = MapData.getRCPos(arrcidx2.split("_")[0], arrcidx2.split("_")[1]);
engine.Tween.removeTweens(atnode1);
engine.Tween.removeTweens(atnode2);
atnode1.x = atpos1[0];
atnode1.y = atpos1[1];
atnode2.x = atpos2[0];
atnode2.y = atpos2[1];
for (var i = 0; i < aboutnames.length; i++) {
var ircidx = aboutnames[i];
var iname1 = this.lattices[ircidx];
var inode1 = this.container.getChildByName(iname1);
if (inode1) {
engine.Tween.removeTweens(inode1);
var ipos1 = MapData.getRCPos(ircidx.split("_")[0], ircidx.split("_")[1]);
inode1.x = ipos1[0];
inode1.y = ipos1[1];
}
}
this.anicontainer.removeChild(this.jiantoucont);
}
};
GameView.prototype.selectele = function (e) {
var data = e.data;
var sr = data.r;
var sc = data.c;
var type = data.type;
var sname = sr + "_" + sc;
var lnewSelect = this.newSelect;
var newCanSel = false;
if (this.selectArr.length == 0) {
newCanSel = true;
}
else if (this.selectArr.length == 1) {
var nname = this.selectArr[0];
if (sname == nname) {
newCanSel = false;
}
else {
newCanSel = true;
}
}
if (type == "mouse_down") {
this.newSelect = true;
}
else if (type == "mouse_move") {
if (newCanSel) {
this.newSelect = false;
}
}
if ((lnewSelect || this.newSelect) && newCanSel) ;
else {
return;
}
this.unShowEleAttion();
if (this.selectArr.length == 0) {
this.sptime = Date.now();
this.seqscore = 0;
this.selectArr.push(sname);
}
else if (this.selectArr.length == 1) {
var aselect = this.selectArr[0];
var asr = aselect.split("_")[0];
var asc = aselect.split("_")[1];
if ((sr == asr && Math.abs(sc - asc) == 1) || (sc == asc && Math.abs(sr - asr) == 1)) {
this.selectArr.push(sname);
}
else {
if (sr == asr && sc == asc) {
this.selectArr = new Array();
this.anicontainer.removeChild(this.selectimg);
}
else {
this.selectArr[0] = sname;
}
}
}
if (this.selectArr.length == 1) {
this.setSelectShow();
}
else if (this.selectArr.length == 2) {
this.changeElePos();
}
};
GameView.prototype.setSelectShow = function () {
var rcname = this.selectArr[0];
var r = rcname.split("_")[0];
var c = rcname.split("_")[1];
var rcpos = MapData.getRCPos(r, c);
this.anicontainer.addChild(this.selectimg);
this.selectimg.x = rcpos[0];
this.selectimg.y = rcpos[1] + this.conty;
};
GameView.prototype.changeElePos = function () {
var _this = this;
this.anicontainer.removeChild(this.selectimg);
this.changeEnable(false);
var sname1 = this.selectArr[0];
var sname2 = this.selectArr[1];
var sename1 = this.lattices[sname1];
var sename2 = this.lattices[sname2];
this.lattices[sname1] = sename2;
this.lattices[sname2] = sename1;
this.setLatticeEleRc(sname1);
this.setLatticeEleRc(sname2);
this.checkEliminate();
var snode1 = this.container.getChildByName(sename1);
var snode2 = this.container.getChildByName(sename2);
if (!snode1 || !snode2) {
this.selectArr = new Array();
return;
}
var snode1x = snode1.x;
var snode1y = snode1.y;
var snode2x = snode2.x;
var snode2y = snode2.y;
var changetime = Math.ceil((MapData.itemsize / MapData.anispeed) * 2 * 1000);
engine.Tween.removeTweens(snode1);
engine.Tween.removeTweens(snode2);
if (this.eliminateArr.length > 0) {
this.inEliminate = true;
engine.Tween.get(snode1).to({
x: snode2x,
y: snode2y
}, changetime);
engine.Tween.get(snode2).to({
x: snode1x,
y: snode1y
}, changetime)
.call(function () {
_this.eliminate();
});
}
else {
engine.Tween.get(snode1).to({
x: snode2x,
y: snode2y
}, changetime)
.wait(100)
.to({
x: snode1x,
y: snode1y
}, changetime);
engine.Tween.get(snode2).to({
x: snode1x,
y: snode1y
}, changetime)
.wait(100)
.to({
x: snode2x,
y: snode2y
}, changetime)
.call(function () {
_this.lattices[sname1] = sename1;
_this.lattices[sname2] = sename2;
_this.setLatticeEleRc(sname1);
_this.setLatticeEleRc(sname2);
_this.selectArr = new Array();
_this.recordGame();
_this.changeEnable(true);
_this.checkGameOver("changeElePos");
});
}
};
GameView.prototype.eliminate = function () {
return tslib.__awaiter(this, void 0, void 0, function () {
var i, ielidata1, ielileng, addscore, j, ielidata, ielidxname, ielitype, ieliname, ielinode, ielix, ieliy, ietype;
return tslib.__generator(this, function (_a) {
switch (_a.label) {
case 0:
this.inEliminate = true;
for (i = 0; i < this.eliminateArr.length; i++) {
ielidata1 = this.eliminateArr[i];
ielileng = ielidata1.length;
addscore = 0;
if (ielileng == 3) {
addscore = props.threeEscore;
}
else if (ielileng == 4) {
addscore = props.fourEscore;
}
else {
addscore = props.moreEscore;
}
this.seqscore += addscore * ielileng;
for (j = 0; j < ielidata1.length; j++) {
ielidata = ielidata1[j];
ielidxname = ielidata.idxname;
ielitype = ielidata.type;
ieliname = this.lattices[ielidxname];
ielinode = this.container.getChildByName(ieliname);
if (!ielinode) {
continue;
}
ielix = ielinode.x;
ieliy = ielinode.y;
ietype = ielinode.type;
this.container.removeChild(ielinode);
MapData.recoverEle(ielinode, ietype);
this.addScoreAni(ielix, ieliy, ietype, addscore);
this.lattices[ielidxname] = "empty";
this.goHomeAni(ielitype, ielix, ieliy);
}
}
return [4, new Promise(function (res) {
setTimeout(function () {
res();
}, 400);
})];
case 1:
_a.sent();
this.fall();
return [4, new Promise(function (res1) {
setTimeout(function () {
res1();
}, 500);
})];
case 2:
_a.sent();
this.homeimgday.play(1, 1);
this.homeimgnight.play(1, 1);
return [2];
}
});
});
};
GameView.prototype.fall = function (type) {
if (type === void 0) { type = "normal"; }
return tslib.__awaiter(this, void 0, void 0, function () {
var fallData, fcutr, fc, r, c, idxname, elename, frcname, fetype, fele, cutr, fepos, fallPromise, _loop_1, this_1, f, isdiedata;
return tslib.__generator(this, function (_a) {
switch (_a.label) {
case 0:
fallData = new Array();
fcutr = new Array();
for (fc = 0; fc < MapData.col; fc++) {
fcutr.push(-1);
}
for (r = MapData.row - 1; r > -1; r--) {
for (c = MapData.col - 1; c > -1; c--) {
idxname = r + "_" + c;
elename = this.lattices[idxname];
if (elename == "empty") {
frcname = this.getFallRcEle(r, c);
if (!frcname) {
fetype = void 0;
if (type == "normal") {
fetype = MapData.getRandEtype();
}
else {
fetype = this.levelData[r][c];
}
fele = MapData.getOneEle(fetype);
cutr = fcutr[c];
fepos = MapData.getRCPos(cutr, c);
fcutr[c] = cutr - 1;
this.container.addChild(fele);
fele.x = fepos[0];
fele.y = fepos[1];
frcname = fele.name;
}
this.lattices[idxname] = frcname;
this.setLatticeEleRc(idxname);
fallData.push({
rcname: frcname,
trow: r,
tcol: c
});
}
}
}
fallPromise = new Array();
_loop_1 = function (f) {
var fdata = fallData[f];
var frcname = fdata.rcname;
var ftrow = fdata.trow;
var ftcol = fdata.tcol;
var ftpos = MapData.getRCPos(ftrow, ftcol);
var frcnode = this_1.container.getChildByName(frcname);
if (!frcnode) {
return "continue";
}
var nepos = [frcnode.x, frcnode.y];
var fdis = MapData.getDistance(ftpos, nepos);
var ftime = Math.ceil((fdis / MapData.anispeed) * 1000);
engine.Tween.removeTweens(frcnode);
var ifallpromise = new Promise(function (res) {
engine.Tween.get(frcnode)
.to({
x: ftpos[0],
y: ftpos[1]
}, ftime)
.to({
scaleY: 0.85
}, 80)
.to({
scaleY: 1
}, 80)
.call(function () {
res();
});
});
fallPromise.push(ifallpromise);
};
this_1 = this;
for (f = 0; f < fallData.length; f++) {
_loop_1(f);
}
return [4, Promise.all(fallPromise)];
case 1:
_a.sent();
if (type == "newlevel") {
this.sptime = Date.now();
}
this.checkEliminate();
if (this.eliminateArr.length > 0) {
return [2, this.eliminate()];
}
else {
this.selectArr = new Array();
isdiedata = this.attionEliminate();
if (isdiedata && isdiedata.length == 3) {
this.inEliminate = false;
if (type != "newlevel") {
this.recordGame();
}
this.changeEnable(true);
this.checkGameOver("fall");
}
else {
this.solveDieMap("fall");
}
}
return [2];
}
});
});
};
GameView.prototype.goDisplayAni1 = function (rcele, rcetype, rcelex, rceley) {
var _this = this;
rcele.touch = false;
engine.Tween.removeTweens(rcele);
rcele.x = rcelex;
rcele.y = rceley;
rcele.anchorY = MapData.itemsize / 2;
engine.Tween.get(rcele)
.to({
scaleX: 0,
scaleY: 0,
alpha: 0
}, 300)
.call(function () {
_this.container.removeChild(rcele);
MapData.recoverEle(rcele, rcetype);
});
};
GameView.prototype.goDisplayAni = function (ielitype, ielix, ieliy) {
var _this = this;
console.log("老原地消失");
var aniele = MapData.getOneEle(ielitype);
aniele.alpha = 0;
var anix = ielix;
var aniy = ieliy + this.conty;
this.anicontainer.addChild(aniele);
aniele.touch = false;
aniele.x = anix;
aniele.y = aniy;
aniele.alpha = 1;
aniele.anchorY = MapData.itemsize / 2;
engine.Tween.removeTweens(aniele);
engine.Tween.get(aniele)
.to({
scaleX: 0,
scaleY: 0,
alpha: 0
}, 300)
.call(function () {
_this.anicontainer.removeChild(aniele);
MapData.recoverEle(aniele, ielitype);
});
};
GameView.prototype.goHomeAni = function (ielitype, ielix, ieliy) {
var aniele = MapData.getOneEle(ielitype);
aniele.alpha = 0;
var anix = ielix;
var aniy = ieliy + this.conty;
this.anicontainer.addChild(aniele);
aniele.touch = false;
aniele.x = anix;
aniele.y = aniy;
aniele.alpha = 1;
var anidis = MapData.getDistance([this.tanix, this.taniy], [anix, aniy]);
var anitime = Math.ceil((anidis / MapData.anispeed) * 1000);
aniele.flyToHome(this.tanix, this.taniy, anitime);
};
GameView.prototype.changeEnable = function (v) {
var changeable = false;
if (this.gamestat == 1) {
changeable = true;
}
else {
if (!v) {
changeable = true;
}
}
if (changeable) {
for (var key in this.lattices) {
var kname = this.lattices[key];
var ele = this.container.getChildByName(kname);
if (ele) {
ele.touch = v;
}
}
if (v) {
this.lastatime = Date.now();
this.ination = false;
}
}
this.canation = v;
};
GameView.prototype.attionEliShow = function () {
var attiondata = this.attionEliminate();
if (attiondata && attiondata.length == 3) {
this.ination = true;
this.attiondata = [attiondata[0], attiondata[1], attiondata[2]];
var atname1 = this.lattices[attiondata[0]];
var atname2 = this.lattices[attiondata[1]];
var aboutnames = attiondata[2];
var atnode1 = this.container.getChildByName(atname1);
var atnode2 = this.container.getChildByName(atname2);
if (!atnode1 || !atnode2) {
return;
}
var atx1 = atnode1.x;
var aty1 = atnode1.y;
var atx2 = atnode2.x;
var aty2 = atnode2.y;
var lerpnum = 0.1;
var atpos1 = [(atx2 - atx1) * lerpnum + atx1, (aty2 - aty1) * lerpnum + aty1];
engine.Tween.removeTweens(atnode1);
engine.Tween.removeTweens(atnode2);
engine.Tween.get(atnode1, {
loop: true
}).to({
x: atpos1[0],
y: atpos1[1]
}, 500)
.to({
x: atx1,
y: aty1
}, 500);
var jtx = (atx2 - atx1) * 0.5 + atx1;
var jty = (aty2 - aty1) * 0.5 + aty1 + this.conty;
var chax1 = atx1 - atpos1[0];
var chay1 = aty1 - atpos1[1];
var roa1 = 0;
var movex1 = 0;
var movey1 = 0;
if (Math.abs(chax1) > Math.abs(chay1)) {
jty += 25;
movex1 = chax1;
}
else {
jtx += MapData.itemsize;
roa1 = 90;
movey1 = chay1;
}
for (var i = 0; i < aboutnames.length; i++) {
var iname1 = this.lattices[aboutnames[i]];
var inode1 = this.container.getChildByName(iname1);
engine.Tween.removeTweens(inode1);
var iatx1 = inode1.x;
var iaty1 = inode1.y;
if (inode1) {
engine.Tween.get(inode1, { loop: true })
.to({
x: iatx1 + movex1,
y: iaty1 + movey1
}, 500)
.to({
x: iatx1,
y: iaty1
}, 500);
}
}
this.anicontainer.addChild(this.jiantoucont);
this.jiantoucont.x = jtx;
this.jiantoucont.y = jty;
this.jiantoucont.rotation = roa1;
this.startJtAni();
}
else {
this.solveDieMap();
}
};
GameView.prototype.startJtAni = function () {
engine.Tween.removeTweens(this.jiantou1);
engine.Tween.removeTweens(this.jiantou2);
this.jiantou1.x = this.jtex1;
this.jiantou1.y = this.jtey1;
this.jiantou2.x = this.jtex2;
this.jiantou2.y = this.jtey2;
this.jiantou1.alpha = 1;
this.jiantou2.alpha = 1;
engine.Tween.get(this.jiantou1, { loop: true })
.to({
x: this.jtsx1,
y: this.jtsy1,
alpha: 0
}, 500)
.to({
x: this.jtex1,
y: this.jtey1,
alpha: 1
}, 500);
engine.Tween.get(this.jiantou2, { loop: true })
.to({
x: this.jtsx2,
y: this.jtsy2,
alpha: 0
}, 500)
.to({
x: this.jtex2,
y: this.jtey2,
alpha: 1
}, 500);
};
GameView.prototype.solveDieMap = function (type) {
if (type === void 0) { type = "normal"; }
if (this.gamestat != 1) {
if (this.ingameover) {
this.inEliminate = false;
this.checkGameOver("changeToFuHuoPos222");
}
return;
}
this.changeEnable(false);
var elearr = new Array();
for (var key in this.lattices) {
var keyval = this.lattices[key];
elearr.push(keyval);
}
for (var key in this.lattices) {
var changeval = elearr.splice(Math.floor(Math.random() * elearr.length), 1)[0];
this.lattices[key] = changeval;
}
var isdiedata = this.attionEliminate();
if (isdiedata && isdiedata.length == 3) {
this.changeToFuHuoPos(type);
}
else {
return this.solveDieMap();
}
};
GameView.prototype.changeToFuHuoPos = function (type) {
return tslib.__awaiter(this, void 0, void 0, function () {
var prolist, key, keyval, keynode, keynodex, keynodey, tpos, ipro;
return tslib.__generator(this, function (_a) {
switch (_a.label) {
case 0:
prolist = new Array();
for (key in this.lattices) {
keyval = this.lattices[key];
keynode = this.container.getChildByName(keyval);
if (!keynode) {
continue;
}
keynodex = keynode.x;
keynodey = keynode.y;
tpos = MapData.getRCPos(key.split("_")[0], key.split("_")[1]);
ipro = keynode.changePos(tpos);
prolist.push(ipro);
this.setLatticeEleRc(key);
}
return [4, Promise.all(prolist)];
case 1:
_a.sent();
this.checkEliminate();
if (this.eliminateArr.length > 0) {
this.eliminate();
}
else {
if (type == "fall") {
this.recordGame();
}
this.changeEnable(true);
this.inEliminate = false;
this.checkGameOver("changeToFuHuoPos");
}
return [2];
}
});
});
};
GameView.prototype.recordcomp = function () {
this.inrecord = false;
this.checkGameOver("recordcomp");
};
GameView.prototype.recordGame = function () {
if (!this.requestGameOver) {
this.inrecord = true;
this.eptime = Date.now();
engine.globalEvent.dispatchEvent('game-record', {
score: this.seqscore,
seq: this.seq,
sptime: this.sptime,
eptime: this.eptime
});
this.seq += 1;
this.seqscore = 0;
this.sptime = Date.now();
}
};
GameView.prototype.attionEliminate = function () {
var attiondata;
for (var r = MapData.row - 1; r > -1; r--) {
if (attiondata && attiondata.length == 3) {
break;
}
for (var c = MapData.col - 1; c > -1; c--) {
var checktype = this.getEleTypeByRc(r, c);
var edatarow = this.getEliminateRow(r, c);
var edatacol = this.getEliminateCol(r, c);
if (edatarow.length > 2 || edatacol.length > 2) ;
if (edatarow.length == 2) {
var releidx1 = edatarow[0];
var releidx2 = edatarow[1];
var relerow1 = Number(releidx1.split("_")[0]);
var relerow2 = Number(releidx2.split("_")[0]);
var relecol = Number(releidx1.split("_")[1]);
var downrow = relerow1 + 1;
var uprow = relerow2 - 1;
var rightcol = relecol + 1;
var leftcol = relecol - 1;
var uprow1 = relerow2 - 2;
var downrow1 = relerow1 + 2;
if (downrow < MapData.row) {
if (rightcol < MapData.col) {
var nexttype = this.getEleTypeByRc(downrow, rightcol);
if (nexttype == checktype) {
attiondata = [downrow + "_" + rightcol, downrow + "_" + relecol, edatarow];
break;
}
}
if (leftcol > -1) {
var nexttype = this.getEleTypeByRc(downrow, leftcol);
if (nexttype == checktype) {
attiondata = [downrow + "_" + leftcol, downrow + "_" + relecol, edatarow];
break;
}
}
}
if (uprow > -1) {
if (rightcol < MapData.col) {
var nexttype = this.getEleTypeByRc(uprow, rightcol);
if (nexttype == checktype) {
attiondata = [uprow + "_" + rightcol, uprow + "_" + relecol, edatarow];
break;
}
}
if (leftcol > -1) {
var nexttype = this.getEleTypeByRc(uprow, leftcol);
if (nexttype == checktype) {
attiondata = [uprow + "_" + leftcol, uprow + "_" + relecol, edatarow];
break;
}
}
}
if (uprow1 > -1) {
var nexttype = this.getEleTypeByRc(uprow1, relecol);
if (nexttype == checktype) {
attiondata = [uprow1 + "_" + relecol, uprow + "_" + relecol, edatarow];
break;
}
}
if (downrow1 < MapData.row) {
var nexttype = this.getEleTypeByRc(downrow1, relecol);
if (nexttype == checktype) {
attiondata = [downrow1 + "_" + relecol, downrow + "_" + relecol, edatarow];
break;
}
}
}
if (edatacol.length == 2) {
var releidx1 = edatacol[0];
var releidx2 = edatacol[1];
var relerow = Number(releidx1.split("_")[0]);
var relecol1 = Number(releidx1.split("_")[1]);
var relecol2 = Number(releidx2.split("_")[1]);
var rightcol = relecol1 + 1;
var leftcol = relecol2 - 1;
var uprow = relerow - 1;
var downrow = relerow + 1;
var rightcol1 = relecol1 + 2;
var leftcol1 = relecol2 - 2;
if (leftcol > -1) {
if (uprow > -1) {
var nexttype = this.getEleTypeByRc(uprow, leftcol);
if (nexttype == checktype) {
attiondata = [uprow + "_" + leftcol, relerow + "_" + leftcol, edatacol];
break;
}
}
if (downrow < MapData.row) {
var nexttype = this.getEleTypeByRc(downrow, leftcol);
if (nexttype == checktype) {
attiondata = [downrow + "_" + leftcol, relerow + "_" + leftcol, edatacol];
break;
}
}
}
if (rightcol < MapData.col) {
if (uprow > -1) {
var nexttype = this.getEleTypeByRc(uprow, rightcol);
if (nexttype == checktype) {
attiondata = [uprow + "_" + rightcol, relerow + "_" + rightcol, edatacol];
break;
}
}
if (downrow < MapData.row) {
var nexttype = this.getEleTypeByRc(downrow, rightcol);
if (nexttype == checktype) {
attiondata = [downrow + "_" + rightcol, relerow + "_" + rightcol, edatacol];
break;
}
}
}
if (rightcol1 < MapData.col) {
var nexttype = this.getEleTypeByRc(relerow, rightcol1);
if (nexttype == checktype) {
attiondata = [relerow + "_" + rightcol1, relerow + "_" + rightcol, edatacol];
break;
}
}
if (leftcol1 > -1) {
var nexttype = this.getEleTypeByRc(relerow, leftcol1);
if (nexttype == checktype) {
attiondata = [relerow + "_" + leftcol1, relerow + "_" + leftcol, edatacol];
break;
}
}
}
var jianrow = this.getEliminateRowR(r, c);
if (jianrow.length == 2) {
var jianr = Number(jianrow[0].split("_")[0]) - 1;
var jianc = Number(jianrow[0].split("_")[1]);
var ljianc = jianc - 1;
if (ljianc > -1) {
var nexttype = this.getEleTypeByRc(jianr, ljianc);
if (nexttype == checktype) {
attiondata = [jianr + "_" + ljianc, jianr + "_" + jianc, jianrow];
break;
}
}
var rjianc = jianc + 1;
if (rjianc < MapData.col) {
var nexttype = this.getEleTypeByRc(jianr, rjianc);
if (nexttype == checktype) {
attiondata = [jianr + "_" + rjianc, jianr + "_" + jianc, jianrow];
break;
}
}
}
var jiancol = this.getEliminateRowC(r, c);
if (jiancol.length == 2) {
var jianr = Number(jiancol[0].split("_")[0]);
var jianc = Number(jianrow[0].split("_")[1]) - 1;
var ujianr = jianr - 1;
if (ujianr > -1) {
var nexttype = this.getEleTypeByRc(ujianr, jianc);
if (nexttype == checktype) {
attiondata = [ujianr + "_" + jianc, jianr + "_" + jianc, jiancol];
break;
}
}
var djianr = jianr + 1;
if (djianr < MapData.row) {
var nexttype = this.getEleTypeByRc(djianr, jianc);
if (nexttype == checktype) {
attiondata = [djianr + "_" + jianc, jianr + "_" + jianc, jiancol];
break;
}
}
}
}
}
return attiondata;
};
GameView.prototype.checkEliminate = function () {
this.eliminateArr = new Array();
for (var r = MapData.row - 1; r > -1; r--) {
for (var c = MapData.col - 1; c > -1; c--) {
var edata = this.getEliminate(r, c);
if (edata) {
var etype = edata.etype;
var earr = edata.arr;
this.checkAddEli(etype, earr);
}
}
}
};
GameView.prototype.getEliminateRowR = function (x, y) {
var checktype = this.getEleTypeByRc(x, y);
var jianrow = x - 2;
var relearr = new Array();
relearr.push(x + "_" + y);
if (jianrow > -1) {
var jiantype = this.getEleTypeByRc(jianrow, y);
if (jiantype == checktype) {
relearr.push(jianrow + "_" + y);
}
}
return relearr;
};
GameView.prototype.getEliminateRowC = function (x, y) {
var checktype = this.getEleTypeByRc(x, y);
var jiancol = y - 2;
var relearr = new Array();
relearr.push(x + "_" + y);
if (jiancol > -1) {
var jiantype = this.getEleTypeByRc(x, jiancol);
if (jiantype == checktype) {
relearr.push(x + "_" + jiancol);
}
}
return relearr;
};
GameView.prototype.getEliminateRow = function (x, y) {
var checktype = this.getEleTypeByRc(x, y);
var relearr = new Array();
relearr.push(x + "_" + y);
for (var r = x - 1; r > -1; r--) {
var reletype = this.getEleTypeByRc(r, y);
if (checktype == reletype) {
relearr.push(r + "_" + y);
}
else {
break;
}
}
return relearr;
};
GameView.prototype.getEliminateCol = function (x, y) {
var checktype = this.getEleTypeByRc(x, y);
var celearr = new Array();
celearr.push(x + "_" + y);
for (var c = y - 1; c > -1; c--) {
var celetype = this.getEleTypeByRc(x, c);
if (checktype == celetype) {
celearr.push(x + "_" + c);
}
else {
break;
}
}
return celearr;
};
GameView.prototype.getEliminate = function (x, y) {
var checktype = this.getEleTypeByRc(x, y);
var relearr = this.getEliminateRow(x, y);
var celearr = this.getEliminateCol(x, y);
var eliminatearr = new Array();
if (relearr.length >= 3) {
eliminatearr.push.apply(eliminatearr, relearr);
}
if (celearr.length >= 3) {
eliminatearr.push.apply(eliminatearr, celearr);
}
if (eliminatearr.length > 0) {
return {
etype: checktype,
arr: eliminatearr
};
}
else {
return false;
}
};
GameView.prototype.getEleTypeByRc = function (r, c) {
var rc = r + "_" + c;
var elename = this.lattices[rc];
var ele = this.container.getChildByName(elename);
if (ele) {
var eletype = ele.type;
return eletype;
}
};
GameView.prototype.checkAddEli = function (etype, earr) {
var addnew = true;
var inaidx;
for (var i1 = 0; i1 < this.eliminateArr.length; i1++) {
var i1data = this.eliminateArr[i1];
for (var i2 = 0; i2 < i1data.length; i2++) {
var i2data = i1data[i2];
var i2eliname = i2data.idxname;
var inidx = earr.indexOf(i2eliname);
if (inidx != -1) {
addnew = false;
break;
}
}
if (!addnew) {
inaidx = i1;
break;
}
}
if (addnew) {
var addarr = new Array();
for (var i1 = 0; i1 < earr.length; i1++) {
var i1name = earr[i1];
addarr.push({
idxname: i1name,
type: etype
});
}
this.eliminateArr.push(addarr);
}
else {
for (var i4 = 0; i4 < earr.length; i4++) {
var i4name = earr[i4];
var addele = true;
for (var i3 = 0; i3 < this.eliminateArr[inaidx].length; i3++) {
var i3data = this.eliminateArr[inaidx][i3];
var i3eliname = i3data.idxname;
if (i3eliname == i4name) {
addele = false;
break;
}
}
if (addele) {
this.eliminateArr[inaidx].push({
idxname: i4name,
type: etype
});
}
}
}
};
GameView.prototype.getFallRcEle = function (r, c) {
for (var fr = r - 1; fr > -1; fr--) {
var frc = fr + "_" + c;
var frcname = this.lattices[frc];
if (frcname != "empty") {
this.lattices[frc] = "empty";
return frcname;
}
}
return false;
};
GameView.prototype.addScoreAni = function (ielix, ieliy, ietype, addscore) {
var _this = this;
var anitxt = MapData.getOneTxt();
anitxt.alpha = 0;
var txtcolor = "#bd882f";
switch (ietype) {
case ElementType.btiger:
txtcolor = "#ffffff";
break;
case ElementType.gtiger:
txtcolor = "#f5a900";
break;
case ElementType.monkey:
txtcolor = "#bd882f";
break;
case ElementType.bird:
txtcolor = "#54c1ef";
break;
case ElementType.koala:
txtcolor = "#c7c8c9";
break;
default:
console.error("未定义类型,检查");
break;
}
anitxt.fillColor = txtcolor;
var anix = ielix + MapData.itemsize / 2 - 100;
var aniy = ieliy + this.conty + MapData.itemsize / 2 - 35;
anitxt.text = "+" + addscore;
this.txtcontainer.addChild(anitxt);
anitxt.x = anix;
anitxt.y = aniy;
anitxt.scaleX = 0;
anitxt.scaleY = 0;
anitxt.alpha = 1;
engine.Tween.get(anitxt, { loop: false }).set({
x: anix,
y: aniy,
scaleX: 0,
scaleY: 0
})
.to({
y: aniy - 50,
scaleX: 1,
scaleY: 1,
}, 300)
.to({
y: aniy - 120,
alpha: 0
}, 500)
.call(function () {
_this.txtcontainer.removeChild(anitxt);
_this.score += addscore;
MapData.recoverTxt(anitxt);
});
};
GameView.prototype.changeHomeShow = function (mode) {
if (mode === void 0) { mode = "day"; }
var _v = true;
if (mode == "day") {
_v = true;
}
else {
_v = false;
}
this.homeimgday.visible = _v;
this.homeimgnight.visible = !_v;
};
return GameView;
}(engine.Container));
var GameWrapper = (function (_super) {
tslib.__extends(GameWrapper, _super);
function GameWrapper() {
var _this = _super.call(this) || this;
_this._gameView = new GameView();
_this.addChild(_this._gameView);
engine.globalEvent.addEventListener('game-init', _this.init, _this);
engine.globalEvent.addEventListener('game-reset', _this.reset, _this);
engine.globalEvent.addEventListener('game-start', _this.start, _this);
engine.globalEvent.addEventListener('game-pause', _this.pause, _this);
engine.globalEvent.addEventListener('game-resume', _this.resume, _this);
engine.globalEvent.addEventListener('game-recordcomp', _this.recordcomp, _this);
return _this;
}
GameWrapper.prototype.init = function (event) {
console.log("gamewrapper-init", event);
var time = event.data.time;
var level = event.data.level;
var mode = event.data.mode;
this._gameView.init(time, level, mode);
};
GameWrapper.prototype.reset = function (event) {
var time = event.data.time;
var level = event.data.level;
var mode = event.data.mode;
this._gameView.reset(time, level, mode);
};
GameWrapper.prototype.start = function () {
this._gameView.start();
};
GameWrapper.prototype.pause = function () {
this._gameView.pause();
};
GameWrapper.prototype.resume = function () {
this._gameView.resume();
};
GameWrapper.prototype.recordcomp = function () {
this._gameView.recordcomp();
};
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
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -2,62 +2,109 @@ ...@@ -2,62 +2,109 @@
"name": "消消乐", "name": "消消乐",
"desc": "消消乐模块", "desc": "消消乐模块",
"props": { "props": {
"threeEscore":{
"alias":"三消加分",
"type":"number",
"default":1
},
"fourEscore":{
"alias":"四消加分",
"type":"number",
"default":2
},
"moreEscore":{
"alias":"多消加分",
"type":"number",
"default":3
}
}, },
"assets": [ "assets": [
{ {
"name": "玩家icon", "name": "底图",
"url": "//yun.duiba.com.cn/aurora/assets/50a7212a113175fa18c866b005d98f07c558dc77.png", "url": "//yun.duiba.com.cn/aurora/assets/109e30fa662276e0ee4f2e2c35b85bee6f300050.png",
"uuid": "66f23d13-82a5-4cec-9496-301ec240d087", "uuid": "map",
"ext": ".png" "ext": ".png"
}, },
{ {
"name": "雨滴", "name": "白虎",
"url": "//yun.duiba.com.cn/aurora/assets/8564c8c9be3aead71b05a0bab8d7d07ac3f778a1.png", "url": "//yun.duiba.com.cn/aurora/assets/b486b4a72c58850bbd1930b994e08802e34fb3e3.png",
"uuid": "264a6192-d7bf-45e8-8f15-6ba2c439a532", "uuid": "btiger",
"ext": ".png" "ext": ".png"
}, },
{ {
"name": "炸弹", "name": "雌虎",
"url": "//yun.duiba.com.cn/aurora/assets/171e92283cd13c013ee1b76d28d252ff08815d47.png", "url": "//yun.duiba.com.cn/aurora/assets/c41afceb285432ed2c17c643df96efc20893adc8.png",
"uuid": "eb88b42d-e151-4c1b-94b9-7c16f7bfac29", "uuid": "gtiger",
"ext": ".png" "ext": ".png"
}, },
{ {
"name": "石块", "name": "猴子",
"url": "//yun.duiba.com.cn/aurora/assets/99b0af0c59fe79a415a3f032149cfacc27e3ac2c.png", "url": "//yun.duiba.com.cn/aurora/assets/ef7bc5d1fc38267adba71e07d517330f249d23ba.png",
"uuid": "ab1bdabc-21ba-46bf-9299-6c638f766c88", "uuid": "monkey",
"ext": ".png" "ext": ".png"
}, },
{ {
"name": "水花", "name": "",
"url": "//yun.duiba.com.cn/aurora/assets/93d37b4a0e367e80e375308a6b4414d72d7666fc.svga", "url": "//yun.duiba.com.cn/aurora/assets/9ad18dfa34e1729e9893ac362975f9e062263f70.png",
"uuid": "b521bf94-20e1-44dd-8eca-d24996cbaeae", "uuid": "bird",
"ext": ".svga" "ext": ".png"
}, },
{ {
"name": "炸弹svga", "name": "树熊",
"url": "//yun.duiba.com.cn/aurora/assets/4dd18f0689c663bbcf710a7afc4d929084d97d36.svga", "url": "//yun.duiba.com.cn/aurora/assets/277aa43d9f1bf3dd7a18e627335a166f0509684c.png",
"uuid": "322edf39-805b-4e84-9d07-5573dfeebc0e", "uuid": "koala",
"ext": ".png"
},
{
"name": "选中框",
"url": "//yun.duiba.com.cn/aurora/assets/a3ce52a41ed53ccfa7ce404dbc10102961c4a805.png",
"uuid": "selected",
"ext": ".png"
},
{
"name": "交换箭头",
"url": "//yun.duiba.com.cn/aurora/assets/438ca6e721eab32728aceaca5df0095e1387f340.png",
"uuid": "jiantou",
"ext": ".png"
},
{
"name": "房子动画",
"url": "//yun.duiba.com.cn/aurora/assets/10d6c3c657e4f26eee2e6f1edca36ec468d57353.svga",
"uuid": "homeani",
"ext": ".svga" "ext": ".svga"
}, },
{ {
"name": "玩家", "name": "夜晚房子",
"url": "//yun.duiba.com.cn/aurora/assets/b66300c5d4f27134b0aac3dc90a3220e8ae572eb.svga", "url": "//yun.duiba.com.cn/aurora/assets/aa9261273423b4b9343b4526b7e5f71a6a35a345.svga",
"uuid": "71d8dcbc-3931-471a-b585-b3ae01b25aa6", "uuid": "homenight",
"ext": ".svga" "ext": ".svga"
} }
], ],
"events": { "events": {
"in": { "in": {
"game-init":{
"alias": "初始化第一关",
"data": {
}
},
"game-reset": { "game-reset": {
"alias": "重置", "alias": "关卡通过重玩之类的重置关卡",
"data": { "data": {
} }
}, },
"game-start": { "game-start": {
"alias": "开始" "alias": "开始"
},
"game-pause": {
"alias": "暂停"
},
"game-resume": {
"alias": "继续"
},
"game-recordcomp": {
"alias": "记录完毕"
} }
}, },
"out": { "out": {
...@@ -77,7 +124,16 @@ ...@@ -77,7 +124,16 @@
"alias": "游戏结束", "alias": "游戏结束",
"data": { "data": {
"score":"分数", "score":"分数",
"reason": "结束原因(1:时间到了,2:玩家死亡)" "reason": "结束原因(1:时间到了,2:过关)"
}
},
"game-record": {
"alias": "游戏记录",
"data": {
"score":"操作得分",
"seq": "操作步骤号",
"sptime":"操纵开始时间",
"eptime":"操作结束时间"
} }
} }
} }
......
/** /**
* Created by rockyl on 2018/8/16. * Created by zjz on 2020/7/10.
*/ */
import { props } from "../props"; import { props } from "../props";
import { playSound, createSvga } from "./utils"; import { playSound, createSvga,getTextureByName } from "./utils";
import ObjectPool = engine.ObjectPool; import ObjectPool = engine.ObjectPool;
import { getTextureByName } from "./utils"; import MapData, { GameEvent, ElementType } from "./MapData";
import Element from "./ele/Element";
import CountDownGroup from "../../../recycling/src/game/views/CountDownGroup";
...@@ -14,7 +16,1565 @@ export default class GameView extends engine.Container { ...@@ -14,7 +16,1565 @@ export default class GameView extends engine.Container {
super(); super();
this.once(engine.Event.ADDED_TO_STAGE, this.setup, this); this.once(engine.Event.ADDED_TO_STAGE, this.setup, this);
} }
//元素容器
container:engine.Container;
//动画层
anicontainer:engine.Container;
//加分文字层
txtcontainer:engine.Container;
//格子,位置-name
lattices = {};
//一次消除组
eliminateArr = [];
//选中
selectArr = [];
selectimg:engine.Image;
//屋子
homeimgday;
homeimgnight;
conty = 140;
homex = 562;
homey = -20;
tanix;
taniy;
//5秒不操作,给提示
lastframeTime;
attiondata;
lastatime;
ination = false;
canation = true;
_gametime = 60;
_gamestat=2;
ingameover = false;
jiantou1:engine.Image;
jiantou2:engine.Image;
jiantoucont:engine.Container;
jtsx1;
jtsy1;
jtsx2;
jtsy2;
jtex1;
jtey1;
jtex2;
jtey2;
ingame = true;
level = 0;
inrecord = false;
requestGameOver = false;
set gamestat(stat){//1游戏中,2,游戏外
this._gamestat = stat;
if(stat==2){
this.changeEnable(false);
}
}
get gamestat(){
return this._gamestat;
}
_seq = 1;
set seq(num){
this._seq = num;
}
get seq(){
return this._seq;
}
sptime = Date.now();
eptime;
seqscore;
setup() { setup() {
MapData.initPoolEle();
this.selectimg = new engine.Image(getTextureByName("选中框"));
this.selectimg.mouseEnabled = false;
//箭头cont
this.jiantou1 = new engine.Image(getTextureByName("交换箭头"));
this.jiantou2 = new engine.Image(getTextureByName("交换箭头"));
this.jiantou1.mouseEnabled = false;
this.jiantou2.mouseEnabled = false;
let jiantwid = 31;
let jianthei = 24;
this.jiantou1.anchorX = jiantwid/2;
this.jiantou1.anchorY = jianthei/2;
this.jiantou2.anchorX = jiantwid/2;
this.jiantou2.anchorY = jianthei/2;
this.jiantoucont = new engine.Container();
this.jiantoucont.width = MapData.itemsize;
this.jiantoucont.height = MapData.itemsize;
this.jtsx1 = MapData.itemsize/2-jiantwid/2;
this.jtsx2 = MapData.itemsize/2-jiantwid/2;
this.jtsy1 = MapData.itemsize/2-jianthei;
this.jtsy2 = MapData.itemsize/2;
this.jtex1 = this.jtsx1-10;
this.jtex2 = this.jtsx2+10;
this.jtey1 = this.jtsy1;
this.jtey2 = this.jtsy2;
this.jiantou1.x = this.jtsx1;
this.jiantou2.rotation = 180;
this.jiantou2.x = this.jtsx2;
this.jiantou1.y = this.jtsy1;
this.jiantou2.y = this.jtsy2;
this.jiantoucont.addChild(this.jiantou1);
this.jiantoucont.addChild(this.jiantou2);
let row = MapData.row;
let col = MapData.col;
this.homeimgday = createSvga("房子动画");
this.homeimgday.x = this.homex;
this.homeimgday.y = this.homey;
this.homeimgday.stop();
this.homeimgday.visible = false;
this.addChild(this.homeimgday);
this.homeimgnight = createSvga("夜晚房子");
this.homeimgnight.x = this.homex;
this.homeimgnight.y = this.homey;
this.homeimgnight.stop();
this.homeimgnight.visible = false;
this.addChild(this.homeimgnight);
this.container = new engine.Container();
this.addChild(this.container);
this.container.y = this.conty;
let maskimg = new engine.Graphics();
this.container.addChild(maskimg);
this.container.mask = maskimg;
maskimg.moveTo(0,0);
maskimg.beginFill(0);
maskimg.lineTo(681,0);
maskimg.lineTo(681,679);
maskimg.lineTo(0,679);
maskimg.lineTo(0,0);
maskimg.endFill();
this.anicontainer = new engine.Container();
this.addChild(this.anicontainer);
this.anicontainer.mouseEnabled = false;
this.anicontainer.mouseChildren = false;
this.txtcontainer = new engine.Container();
this.addChild(this.txtcontainer);
let map = new engine.Image(getTextureByName("底图"));
this.container.addChild(map);
//初始化底图
for(let r=0;r<row;r++){
for(let c=0;c<col;c++){
let rcpos = MapData.getRCPos(r,c);
MapData.posData[r+"_"+c] = rcpos;
}
}
this.tanix = this.homex+30;
this.taniy = this.homey;// - MapData.itemsize/2;
engine.globalEvent.addEventListener(GameEvent.SelectEle,this.selectele,this);
this.removeEventListener(engine.Event.ADDED_TO_STAGE,this.setup,this);
this.lastframeTime = Date.now();
this.lastatime = Date.now();
this.addEventListener(engine.Event.ENTER_FRAME,this.onUpdate,this);
// //测试
// let testbtn = new engine.Label();
// testbtn.text = "reset";
// testbtn.size = 56;
// testbtn.width = 200;
// testbtn.height = 100;
// this.addChild(testbtn);
// testbtn.y = 900;
// testbtn.fillColor = "red";
// testbtn.addEventListener(engine.MouseEvent.CLICK,this.reset,this);
}
changeAni(){
this.changeHomeShow("night");
}
playComp(){
this.homeimgday.stop(1);
this.homeimgnight.stop(1);
}
init(time,level,mode){
this.score = 0;
this.gametime = time;
this.seq = 1;
this.level = level;
this.ingameover = false;
this.changeHomeShow(mode);
this.initContainer();
this.sptime = Date.now();
}
_score = 0;
set score(num){
this._score = num;
engine.globalEvent.dispatchEvent('game-score-update',{score:this._score});
}
get score(){
return this._score;
}
set gametime(time){
let lshowtime = Math.round(this._gametime);
let nshowtime = Math.round(time);
if(lshowtime!=nshowtime){
// console.log("倒计时更新",nshowtime);
if(this.gamestat==1&&nshowtime<1){
this.gameOver();
}
if(nshowtime<0){
nshowtime = 0;
}
engine.globalEvent.dispatchEvent('game-time-update',{time:nshowtime});
}
if(time<0){
time = 0;
}
this._gametime = time;
}
get gametime(){
return this._gametime;
}
inEliminate:boolean = false;
gameOver(){
this.gamestat = 2;
this.unShowEleAttion();
this.anicontainer.removeChild(this.selectimg);
this.ingameover = true;
console.log("倒计时结束1=============",this.ingameover,this.inEliminate,this.inrecord);
this.checkGameOver("time-over");
};
checkGameOver(type){
if(this.ingameover){
console.log("倒计时已结束2==========",this.inEliminate,this.inrecord,type);
}
if(this.ingameover&&!this.inEliminate&&!this.inrecord&&!this.requestGameOver){
this.requestGameOver = true;
this.unShowEleAttion();
this.anicontainer.removeChild(this.jiantoucont);
engine.globalEvent.dispatchEvent("game-over",{
score:this.score
})
}
}
levelData;
async reset(time,level,mode){
this.anicontainer.removeChild(this.selectimg);
this.selectArr = new Array();
this.gametime = time;
this.level = level;
this.ingameover = false;
this.requestGameOver = false;
this.seq = 1;
this.changeHomeShow(mode);
this.changeEnable(false);
for(let key in this.lattices){
let rcname = this.lattices[key];
let rcele:Element = this.container.getChildByName(rcname);
if(rcele){
let rcelex = rcele.x;
let rceley = rcele.y;
let rcetype = rcele.type;
// this.container.removeChild(rcele);
// MapData.recoverEle(rcele,rcetype);
this.lattices[key] = "empty";
// this.goDisplayAni(rcetype,rcelex,rceley);
this.goDisplayAni1(rcele,rcetype,rcelex,rceley);
}
}
let fallpro = new Promise(res=>{
setTimeout(function(){
res();
},400);
})
await fallpro;
let testdata = MapData.levelData[this.level];
this.levelData = testdata;
this.fall("newlevel");
}
start(){
this.gamestat = 1;
this.requestGameOver = false;
this.selectArr = new Array();
this.changeEnable(true);
}
pause(){
// console.log("游戏暂停");
this.ingame = false;
}
resume(){
// console.log("游戏继续");
this.lastframeTime = Date.now();
this.ingame = true;
}
onUpdate(){
let ntime = Date.now();
if(this.gamestat==1&&this.ingame){
let passtime = ntime - this.lastframeTime;
if(ntime-this.lastatime>=5000&&!this.ination&&this.canation&&this.selectArr.length==0){
this.attionEliShow();
}
if(this.gametime&&this.gametime>0){
let ngtime = this.gametime-(passtime/1000);
this.gametime = ngtime;
}
}
if(this.homeimgday&&this.homeimgday.visible){
let curframe = this.homeimgday.currentFrame;
if(curframe==this.homeimgday.totalFrames){
this.homeimgday.gotoAndStop(1);
}
}
if(this.homeimgnight&&this.homeimgnight.visible){
let curframe = this.homeimgnight.currentFrame;
if(curframe==this.homeimgnight.totalFrames){
this.homeimgnight.gotoAndStop(1);
}
}
this.lastframeTime = ntime;
}
initContainer(){
if(this.lattices){
for(let key in this.lattices){
let rcname = this.lattices[key];
let rcele:Element = this.container.getChildByName(rcname);
if(rcele){
let rcetype = rcele.type;
this.container.removeChild(rcele);
this.lattices[key] = "empty";
MapData.recoverEle(rcele,rcetype);
}
}
}else{
this.lattices = {};
}
let testdata = MapData.levelData[this.level];
this.levelData = testdata;
for(let r=0;r<testdata.length;r++){
let rdata = testdata[r];
for(let c=0;c<rdata.length;c++){
let rctype = rdata[c];
let rcele = MapData.getOneEle(rctype);
let rcpos = MapData.getRCPos(r,c);
this.container.addChild(rcele);
rcele.x = rcpos[0];
rcele.y = rcpos[1];
let rcidx = r+"_"+c;
this.lattices[rcidx] = rcele.name;
this.setLatticeEleRc(rcidx);
}
}
//初始化,检测消除,死图
this.checkInit();
}
checkInit(){
this.checkEliminate();
if(this.eliminateArr.length>0){
return this.eliminate();
}else{//一次操作完毕
this.selectArr = new Array();
let isdiedata = this.attionEliminate();
if(isdiedata&&isdiedata.length==3){//没死
this.changeEnable(true);
}else{//死图处理
this.solveDieMap();
}
//检查死图
}
}
//关联
setLatticeEleRc(rcidx){
let rename = this.lattices[rcidx];
let rcnode:Element = this.container.getChildByName(rename);
if(rcnode){
let er = Number(rcidx.split("_")[0]);
let ec = Number(rcidx.split("_")[1]);
rcnode.setrc(er,ec);
}
}
//取消提示选择
unShowEleAttion(){
if(this.ination){
this.ination = false;
this.lastatime = Date.now();
let arrcidx1 = this.attiondata[0];
let arrcidx2 = this.attiondata[1];
let atname1 = this.lattices[arrcidx1];
let atname2 = this.lattices[arrcidx2];
let atnode1:Element = this.container.getChildByName(atname1);
let atnode2:Element = this.container.getChildByName(atname2);
let aboutnames = this.attiondata[2];
if(!atnode1||!atnode2){
this.attiondata = new Array();
return;
}
let atpos1 = MapData.getRCPos(arrcidx1.split("_")[0],arrcidx1.split("_")[1]);
let atpos2 = MapData.getRCPos(arrcidx2.split("_")[0],arrcidx2.split("_")[1]);
engine.Tween.removeTweens(atnode1);
engine.Tween.removeTweens(atnode2);
atnode1.x = atpos1[0];
atnode1.y = atpos1[1];
atnode2.x = atpos2[0];
atnode2.y = atpos2[1];
for(let i=0;i<aboutnames.length;i++){
let ircidx = aboutnames[i];
let iname1 = this.lattices[ircidx];
let inode1:Element = this.container.getChildByName(iname1);
if(inode1){
engine.Tween.removeTweens(inode1);
let ipos1 = MapData.getRCPos(ircidx.split("_")[0],ircidx.split("_")[1]);
inode1.x = ipos1[0];
inode1.y = ipos1[1];
}
}
this.anicontainer.removeChild(this.jiantoucont);
}
}
newSelect:boolean = false;
//选择元素
selectele(e:engine.Event){
let data = e.data;
let sr = data.r;
let sc = data.c;
let type = data.type;
let sname = sr+"_"+sc;
//新增滑动操作
let lnewSelect = this.newSelect;
let newCanSel = false;
if(this.selectArr.length==0){
newCanSel = true;
}else if(this.selectArr.length==1){
let nname = this.selectArr[0];
if(sname==nname){
newCanSel = false
}else{
newCanSel = true;
}
}
if(type=="mouse_down"){
this.newSelect = true;
}else if(type=="mouse_move"){
if(newCanSel){
this.newSelect = false;
}
}
// console.log(lnewSelect,this.newSelect,newCanSel,type,this.selectArr.length,sname);
if((lnewSelect||this.newSelect)&&newCanSel){
}else{
return;
}
// console.log("continue");
this.unShowEleAttion();
if(this.selectArr.length==0){
// console.log("选中元素",data);
this.sptime = Date.now();
this.seqscore = 0;
this.selectArr.push(sname);
}else if(this.selectArr.length==1){
let aselect = this.selectArr[0];
let asr = aselect.split("_")[0];
let asc = aselect.split("_")[1];
if((sr==asr&&Math.abs(sc-asc)==1)||(sc==asc&&Math.abs(sr-asr)==1)){
this.selectArr.push(sname);
}else{
//重选自己,取消选择,否则选中新的
if(sr==asr&&sc==asc){
this.selectArr = new Array();
this.anicontainer.removeChild(this.selectimg);
}else{
this.selectArr[0] = sname;
}
}
}
if(this.selectArr.length==1){
this.setSelectShow();
}else if(this.selectArr.length==2){
this.changeElePos();
}
}
setSelectShow(){
let rcname = this.selectArr[0];
let r = rcname.split("_")[0];
let c = rcname.split("_")[1];
let rcpos = MapData.getRCPos(r,c);
this.anicontainer.addChild(this.selectimg);
this.selectimg.x = rcpos[0];
this.selectimg.y = rcpos[1]+this.conty;
}
changeElePos(){
this.anicontainer.removeChild(this.selectimg);
this.changeEnable(false);
let sname1 = this.selectArr[0];
let sname2 = this.selectArr[1];
let sename1 = this.lattices[sname1];
let sename2 = this.lattices[sname2];
// console.log("交换测试",sname1,sname2,this.lattices);
this.lattices[sname1] = sename2;
this.lattices[sname2] = sename1;
this.setLatticeEleRc(sname1);
this.setLatticeEleRc(sname2);
this.checkEliminate();
let snode1 = this.container.getChildByName(sename1);
let snode2 = this.container.getChildByName(sename2);
if(!snode1||!snode2){
this.selectArr = new Array();
return;
}
let snode1x = snode1.x;
let snode1y = snode1.y;
let snode2x = snode2.x;
let snode2y = snode2.y;
let changetime = Math.ceil((MapData.itemsize/MapData.anispeed)*2*1000);
engine.Tween.removeTweens(snode1);
engine.Tween.removeTweens(snode2);
if(this.eliminateArr.length>0){
this.inEliminate = true;
engine.Tween.get(snode1).to({
x:snode2x,
y:snode2y
},changetime)
engine.Tween.get(snode2).to({
x:snode1x,
y:snode1y
},changetime)
.call(()=>{
this.eliminate();
})
}else{
engine.Tween.get(snode1).to({
x:snode2x,
y:snode2y
},changetime)
.wait(100)
.to({
x:snode1x,
y:snode1y
},changetime)
engine.Tween.get(snode2).to({
x:snode1x,
y:snode1y
},changetime)
.wait(100)
.to({
x:snode2x,
y:snode2y
},changetime)
.call(()=>{
this.lattices[sname1] = sename1;
this.lattices[sname2] = sename2;
this.setLatticeEleRc(sname1);
this.setLatticeEleRc(sname2);
this.selectArr = new Array();
this.recordGame();
this.changeEnable(true);
this.checkGameOver("changeElePos");
})
}
}
//消除
async eliminate(){
this.inEliminate = true;
for(let i=0;i<this.eliminateArr.length;i++){
let ielidata1 = this.eliminateArr[i];
let ielileng = ielidata1.length;
let addscore = 0;
if(ielileng==3){
addscore = props.threeEscore;
}else if(ielileng==4){
addscore = props.fourEscore;
}else{
addscore = props.moreEscore;
}
// console.log("消除单个加分",addscore);
this.seqscore += addscore*ielileng;
for(let j=0;j<ielidata1.length;j++){
let ielidata = ielidata1[j];
let ielidxname = ielidata.idxname;
let ielitype = ielidata.type;
let ieliname = this.lattices[ielidxname];
let ielinode:Element = this.container.getChildByName(ieliname);
if(!ielinode){
continue;
}
let ielix = ielinode.x;
let ieliy = ielinode.y;
let ietype = ielinode.type;
this.container.removeChild(ielinode);
MapData.recoverEle(ielinode,ietype);
this.addScoreAni(ielix,ieliy,ietype,addscore);
this.lattices[ielidxname] = "empty";
//元素层消除,动画层添加
this.goHomeAni(ielitype,ielix,ieliy);
}
}
await new Promise(res=>{
setTimeout(function(){
res();
},400);
})
this.fall();
await new Promise(res1=>{
setTimeout(function(){
res1();
},500)
})
this.homeimgday.play(1,1);
this.homeimgnight.play(1,1);
}
//掉落
async fall(type="normal"){
let fallData = new Array();
let fcutr = new Array();
for(let fc=0;fc<MapData.col;fc++){
fcutr.push(-1);
}
for(let r = MapData.row-1;r>-1;r--){
for(let c=MapData.col-1;c>-1;c--){
let idxname = r+"_"+c;
let elename = this.lattices[idxname];
if(elename=="empty"){
let frcname = this.getFallRcEle(r,c);
if(!frcname){
let fetype;
if(type=="normal"){
fetype = MapData.getRandEtype();
}else{
fetype = this.levelData[r][c];
}
let fele = MapData.getOneEle(fetype);
let cutr = fcutr[c];
let fepos = MapData.getRCPos(cutr,c);
fcutr[c] = cutr-1;
this.container.addChild(fele);
fele.x = fepos[0];
fele.y = fepos[1];
frcname = fele.name;
}
this.lattices[idxname] = frcname;
this.setLatticeEleRc(idxname);
fallData.push({
rcname:frcname,
trow:r,
tcol:c
});
}
}
}
// return;
// console.log("动画掉落组准备完毕",fallData);
let fallPromise = new Array();
for(let f=0;f<fallData.length;f++){
let fdata = fallData[f];
let frcname = fdata.rcname;
let ftrow = fdata.trow;
let ftcol = fdata.tcol;
let ftpos = MapData.getRCPos(ftrow,ftcol);
let frcnode = this.container.getChildByName(frcname);
if(!frcnode){
continue;
}
let nepos = [frcnode.x,frcnode.y];
let fdis = MapData.getDistance(ftpos,nepos);
let ftime = Math.ceil((fdis/MapData.anispeed)*1000);
engine.Tween.removeTweens(frcnode);
let ifallpromise = new Promise(res=>{
engine.Tween.get(frcnode)
.to({
x:ftpos[0],
y:ftpos[1]
},ftime)
.to({
scaleY:0.85
},80)
.to({
scaleY:1
},80)
.call(()=>{
res();
})
})
fallPromise.push(ifallpromise);
}
await Promise.all(fallPromise);
if(type=="newlevel"){
this.sptime = Date.now();
}
this.checkEliminate();
if(this.eliminateArr.length>0){
return this.eliminate();
}else{//一次操作完毕
this.selectArr = new Array();
let isdiedata = this.attionEliminate();
if(isdiedata&&isdiedata.length==3){//没死
this.inEliminate = false;
if(type!="newlevel"){
this.recordGame();
}
this.changeEnable(true);
this.checkGameOver("fall");
}else{//死图处理
this.solveDieMap("fall");
}
//检查死图
}
}
//原地显示改
goDisplayAni1(rcele:Element,rcetype:ElementType,rcelex,rceley){
rcele.touch = false;
engine.Tween.removeTweens(rcele);
rcele.x = rcelex;
rcele.y = rceley;
rcele.anchorY = MapData.itemsize/2;
engine.Tween.get(rcele)
.to({
scaleX:0,
scaleY:0,
alpha:0
},300)
.call(()=>{
this.container.removeChild(rcele);
MapData.recoverEle(rcele,rcetype);
})
}
//原地消失
goDisplayAni(ielitype,ielix,ieliy){
console.log("老原地消失");
let aniele = MapData.getOneEle(ielitype);
aniele.alpha = 0;
let anix = ielix;
let aniy = ieliy+this.conty;
this.anicontainer.addChild(aniele);
aniele.touch = false;
aniele.x = anix;
aniele.y = aniy;
aniele.alpha = 1;
aniele.anchorY = MapData.itemsize/2;
engine.Tween.removeTweens(aniele);
engine.Tween.get(aniele)
.to({
scaleX:0,
scaleY:0,
alpha:0
},300)
.call(()=>{
this.anicontainer.removeChild(aniele);
MapData.recoverEle(aniele,ielitype);
})
}
//飞到小屋
goHomeAni(ielitype,ielix,ieliy){
let aniele = MapData.getOneEle(ielitype);
aniele.alpha = 0;
let anix = ielix;
let aniy = ieliy + this.conty;
this.anicontainer.addChild(aniele);
aniele.touch = false;
aniele.x = anix;
aniele.y = aniy;
aniele.alpha = 1;
let anidis = MapData.getDistance([this.tanix,this.taniy],[anix,aniy]);
let anitime = Math.ceil((anidis/MapData.anispeed)*1000);
aniele.flyToHome(this.tanix,this.taniy,anitime);
}
//修改元素点击
changeEnable(v:boolean){
let changeable = false;
if(this.gamestat==1){
changeable = true;
}else{
if(!v){
changeable = true;
}
}
if(changeable){
for(let key in this.lattices){
let kname = this.lattices[key];
let ele:Element = this.container.getChildByName(kname);
if(ele){
ele.touch = v;
}
}
if(v){
this.lastatime = Date.now();
this.ination = false;
}
}
this.canation = v;
}
//相邻显性提示
attionEliShow(){
let attiondata = this.attionEliminate();
// console.log("测试333",attiondata);
if(attiondata&&attiondata.length==3){
this.ination = true;
this.attiondata = [attiondata[0],attiondata[1],attiondata[2]];
let atname1 = this.lattices[attiondata[0]];
let atname2 = this.lattices[attiondata[1]];
let aboutnames = attiondata[2];
let atnode1:Element = this.container.getChildByName(atname1);
let atnode2:Element = this.container.getChildByName(atname2);
if(!atnode1||!atnode2){
return;
}
let atx1 = atnode1.x;
let aty1 = atnode1.y;
let atx2 = atnode2.x;
let aty2 = atnode2.y;
let lerpnum = 0.1;
let atpos1 = [(atx2-atx1)*lerpnum+atx1,(aty2-aty1)*lerpnum+aty1];
let atpos2 = [(atx1-atx2)*lerpnum+atx2,(aty1-aty2)*lerpnum+aty2];
engine.Tween.removeTweens(atnode1);
engine.Tween.removeTweens(atnode2);
engine.Tween.get(atnode1,{
loop:true
}).to({
x:atpos1[0],
y:atpos1[1]
},500)
.to({
x:atx1,
y:aty1
},500);
//箭头动画
let jtx = (atx2-atx1)*0.5+atx1;
let jty = (aty2-aty1)*0.5+aty1+this.conty;
let chax1 = atx1-atpos1[0];
let chay1 = aty1-atpos1[1];
let roa1 = 0;
let movex1 = 0;
let movey1 = 0;
if(Math.abs(chax1)>Math.abs(chay1)){
jty += 25;
// console.log("横向移动");
movex1 = chax1;
}else{
jtx += MapData.itemsize;
roa1 = 90;
movey1 = chay1;
// console.log("竖向移动");
}
// console.log("位移llll",aboutnames);
for(let i=0;i<aboutnames.length;i++){
let iname1 = this.lattices[aboutnames[i]];
let inode1:Element = this.container.getChildByName(iname1);
engine.Tween.removeTweens(inode1);
let iatx1 = inode1.x;
let iaty1 = inode1.y;
if(inode1){
engine.Tween.get(inode1,{loop:true})
.to({
x:iatx1+movex1,
y:iaty1+movey1
},500)
.to({
x:iatx1,
y:iaty1
},500)
}
}
// engine.Tween.get(atnode2,{loop:true})
// .to({
// x:atpos2[0],
// y:atpos2[1]
// },500)
// .to({
// x:atx2,
// y:aty2
// },500);
this.anicontainer.addChild(this.jiantoucont);
this.jiantoucont.x = jtx;
this.jiantoucont.y = jty;
this.jiantoucont.rotation = roa1;
this.startJtAni();
}else{//死图处理
this.solveDieMap();
}
}
startJtAni(){
engine.Tween.removeTweens(this.jiantou1);
engine.Tween.removeTweens(this.jiantou2);
this.jiantou1.x = this.jtex1;
this.jiantou1.y = this.jtey1;
this.jiantou2.x = this.jtex2;
this.jiantou2.y = this.jtey2;
this.jiantou1.alpha = 1;
this.jiantou2.alpha = 1;
// console.log("欢动测试",this.jtsx1,this.jtsy1,this.jtex1,this.jtey1);
// return;
engine.Tween.get(this.jiantou1,{loop:true})
.to({
x:this.jtsx1,
y:this.jtsy1,
alpha:0
},500)
.to({
x:this.jtex1,
y:this.jtey1,
alpha:1
},500)
engine.Tween.get(this.jiantou2,{loop:true})
.to({
x:this.jtsx2,
y:this.jtsy2,
alpha:0
},500)
.to({
x:this.jtex2,
y:this.jtey2,
alpha:1
},500)
}
//死图调整
solveDieMap(type="normal"){
if(this.gamestat!=1){
if(this.ingameover){
this.inEliminate = false;
this.checkGameOver("changeToFuHuoPos222");
}
return;
}
this.changeEnable(false);
// console.error("死图调整");
// console.log(this.lattices);
// return false;
let elearr = new Array();
for(let key in this.lattices){
let keyval = this.lattices[key];
elearr.push(keyval);
}
for(let key in this.lattices){
let changeval = elearr.splice(Math.floor(Math.random()*elearr.length),1)[0];
this.lattices[key] = changeval;
}
let isdiedata = this.attionEliminate();
if(isdiedata&&isdiedata.length==3){
// console.error("可以复活了,转移位置");
this.changeToFuHuoPos(type);
}else{
// console.error("依然死亡,寻求复活");
return this.solveDieMap();
}
}
//转移到复活pos
async changeToFuHuoPos(type){
let prolist = new Array();
for(let key in this.lattices){
let keyval = this.lattices[key];
var keynode:Element = this.container.getChildByName(keyval);
if(!keynode){
continue;
}
let keynodex = keynode.x;
let keynodey = keynode.y;
let tpos = MapData.getRCPos(key.split("_")[0],key.split("_")[1]);
let ipro = keynode.changePos(tpos);
prolist.push(ipro);
this.setLatticeEleRc(key);
}
await Promise.all(prolist)
this.checkEliminate();
if(this.eliminateArr.length>0){
this.eliminate();
}else{
if(type=="fall"){
this.recordGame();
}
this.changeEnable(true);
this.inEliminate = false;
this.checkGameOver("changeToFuHuoPos");
}
}
recordcomp(){
this.inrecord = false;
this.checkGameOver("recordcomp");
}
//游戏记录
recordGame(){
if(!this.requestGameOver){
//操作记录
this.inrecord = true;
this.eptime = Date.now();
engine.globalEvent.dispatchEvent('game-record',
{
score:this.seqscore,
seq:this.seq,
sptime:this.sptime,
eptime:this.eptime
}
);
this.seq+=1;
this.seqscore = 0;
this.sptime = Date.now();
}
}
//相邻检测
attionEliminate(){
let attiondata;
for(let r=MapData.row-1;r>-1;r--){
if(attiondata&&attiondata.length==3){
break;
}
for(let c=MapData.col-1;c>-1;c--){
let checktype = this.getEleTypeByRc(r,c);
let edatarow = this.getEliminateRow(r,c);
let edatacol = this.getEliminateCol(r,c);
if(edatarow.length>2||edatacol.length>2){
// console.error("啥情况,检查----------------");
}
if(edatarow.length==2){
// console.log("横向查找",edatarow,checktype);
let releidx1 = edatarow[0];
let releidx2 = edatarow[1];
let relerow1 = Number(releidx1.split("_")[0]);
let relerow2 = Number(releidx2.split("_")[0]);
let relecol = Number(releidx1.split("_")[1]);
let downrow = relerow1+1;
let uprow = relerow2-1;
let rightcol = relecol+1;
let leftcol = relecol-1;
let uprow1 = relerow2-2;
let downrow1 = relerow1+2;
if(downrow<MapData.row){
if(rightcol<MapData.col){
let nexttype = this.getEleTypeByRc(downrow,rightcol);
if(nexttype==checktype){
attiondata = [downrow+"_"+rightcol,downrow+"_"+relecol,edatarow];
break;
}
}
if(leftcol>-1){
let nexttype = this.getEleTypeByRc(downrow,leftcol);
if(nexttype==checktype){
attiondata = [downrow+"_"+leftcol,downrow+"_"+relecol,edatarow];
break;
}
}
}
if(uprow>-1){
if(rightcol<MapData.col){
let nexttype = this.getEleTypeByRc(uprow,rightcol);
if(nexttype==checktype){
attiondata = [uprow+"_"+rightcol,uprow+"_"+relecol,edatarow];
break;
}
}
if(leftcol>-1){
let nexttype = this.getEleTypeByRc(uprow,leftcol);
if(nexttype==checktype){
attiondata = [uprow+"_"+leftcol,uprow+"_"+relecol,edatarow];
break;
}
}
}
if(uprow1>-1){
let nexttype = this.getEleTypeByRc(uprow1,relecol);
if(nexttype==checktype){
attiondata = [uprow1+"_"+relecol,uprow+"_"+relecol,edatarow];
break;
}
}
if(downrow1<MapData.row){
let nexttype = this.getEleTypeByRc(downrow1,relecol);
if(nexttype==checktype){
attiondata = [downrow1+"_"+relecol,downrow+"_"+relecol,edatarow];
break;
}
}
}
if(edatacol.length==2){
// console.log("竖向查找",edatacol,checktype);
let releidx1 = edatacol[0];
let releidx2 = edatacol[1];
let relerow = Number(releidx1.split("_")[0]);
let relecol1 = Number(releidx1.split("_")[1]);
let relecol2 = Number(releidx2.split("_")[1]);
let rightcol = relecol1+1;
let leftcol = relecol2-1;
let uprow = relerow-1;
let downrow = relerow+1;
let rightcol1 = relecol1+2;
let leftcol1 = relecol2-2;
if(leftcol>-1){
if(uprow>-1){
let nexttype = this.getEleTypeByRc(uprow,leftcol);
if(nexttype==checktype){
attiondata = [uprow+"_"+leftcol,relerow+"_"+leftcol,edatacol];
break;
}
}
if(downrow<MapData.row){
let nexttype = this.getEleTypeByRc(downrow,leftcol);
if(nexttype==checktype){
attiondata = [downrow+"_"+leftcol,relerow+"_"+leftcol,edatacol];
break;
}
}
}
if(rightcol<MapData.col){
if(uprow>-1){
let nexttype = this.getEleTypeByRc(uprow,rightcol);
if(nexttype==checktype){
attiondata = [uprow+"_"+rightcol,relerow+"_"+rightcol,edatacol];
break;
}
}
if(downrow<MapData.row){
let nexttype = this.getEleTypeByRc(downrow,rightcol);
if(nexttype==checktype){
attiondata = [downrow+"_"+rightcol,relerow+"_"+rightcol,edatacol];
break;
}
}
}
if(rightcol1<MapData.col){
let nexttype = this.getEleTypeByRc(relerow,rightcol1);
if(nexttype==checktype){
attiondata = [relerow+"_"+rightcol1,relerow+"_"+rightcol,edatacol];
break;
}
}
if(leftcol1>-1){
let nexttype = this.getEleTypeByRc(relerow,leftcol1);
if(nexttype==checktype){
attiondata = [relerow+"_"+leftcol1,relerow+"_"+leftcol,edatacol];
break;
}
}
// console.log("竖向检查啦啦啦",relerow,relecol1,relecol2);
}
//中间插的,俩边一样的这种
let jianrow = this.getEliminateRowR(r,c);
if(jianrow.length==2){
// console.log("中间插入33",jianrow);
let jianr = Number(jianrow[0].split("_")[0])-1;
let jianc = Number(jianrow[0].split("_")[1]);
let ljianc = jianc-1;
if(ljianc>-1){
let nexttype = this.getEleTypeByRc(jianr,ljianc);
if(nexttype==checktype){
attiondata = [jianr+"_"+ljianc,jianr+"_"+jianc,jianrow];
break;
}
}
let rjianc = jianc+1;
if(rjianc<MapData.col){
let nexttype = this.getEleTypeByRc(jianr,rjianc);
if(nexttype==checktype){
attiondata = [jianr+"_"+rjianc,jianr+"_"+jianc,jianrow];
break;
}
}
}
let jiancol = this.getEliminateRowC(r,c);
if(jiancol.length==2){
// console.log("中间插入44",jiancol);
let jianr = Number(jiancol[0].split("_")[0]);
let jianc = Number(jianrow[0].split("_")[1])-1;
let ujianr = jianr-1;
if(ujianr>-1){
let nexttype = this.getEleTypeByRc(ujianr,jianc);
if(nexttype==checktype){
attiondata = [ujianr+"_"+jianc,jianr+"_"+jianc,jiancol];
break;
}
}
let djianr = jianr+1;
if(djianr<MapData.row){
let nexttype = this.getEleTypeByRc(djianr,jianc);
if(nexttype==checktype){
attiondata = [djianr+"_"+jianc,jianr+"_"+jianc,jiancol];
break;
}
}
}
}
}
// console.log("相邻检测--------------",attiondata);
return attiondata;
}
//检测消除
checkEliminate(){
this.eliminateArr = new Array();
for(let r=MapData.row-1;r>-1;r--){
for(let c=MapData.col-1;c>-1;c--){
let edata = this.getEliminate(r,c);
if(edata){
let etype = edata.etype;
let earr = edata.arr;
this.checkAddEli(etype,earr);
}
}
}
}
//两边一样,中间插入,row
getEliminateRowR(x,y){
let checktype = this.getEleTypeByRc(x,y);
let jianrow = x-2;
let relearr = new Array();
relearr.push(x+"_"+y);
if(jianrow>-1){
let jiantype = this.getEleTypeByRc(jianrow,y);
if(jiantype==checktype){
relearr.push(jianrow+"_"+y);
}
}
return relearr;
}
//两边一样,中间插入,col
getEliminateRowC(x,y){
let checktype = this.getEleTypeByRc(x,y);
let jiancol = y-2;
let relearr = new Array();
relearr.push(x+"_"+y);
if(jiancol>-1){
let jiantype = this.getEleTypeByRc(x,jiancol);
if(jiantype==checktype){
relearr.push(x+"_"+jiancol);
}
}
return relearr;
}
getEliminateRow(x,y){
let checktype = this.getEleTypeByRc(x,y);
let relearr = new Array();
relearr.push(x+"_"+y);
for(let r=x-1;r>-1;r--){
let reletype = this.getEleTypeByRc(r,y);
if(checktype==reletype){
relearr.push(r+"_"+y);
}else{
break;
}
}
return relearr;
}
getEliminateCol(x,y){
let checktype = this.getEleTypeByRc(x,y);
let celearr = new Array();
celearr.push(x+"_"+y);
for(let c=y-1;c>-1;c--){
let celetype = this.getEleTypeByRc(x,c);
if(checktype==celetype){
celearr.push(x+"_"+c);
}else{
break;
}
}
return celearr;
}
getEliminate(x,y){
let checktype = this.getEleTypeByRc(x,y);
let relearr = this.getEliminateRow(x,y);
let celearr = this.getEliminateCol(x,y);
let eliminatearr = new Array();
if(relearr.length>=3){
eliminatearr.push(...relearr);
}
if(celearr.length>=3){
eliminatearr.push(...celearr);
}
if(eliminatearr.length>0){
return {
etype:checktype,
arr:eliminatearr
}
}else{
return false;
}
}
getEleTypeByRc(r,c){
let rc = r+"_"+c;
let elename = this.lattices[rc];
let ele:Element = this.container.getChildByName(elename);
if(ele){
let eletype = ele.type;
return eletype;
}
}
checkAddEli(etype,earr:Array<string>){
let addnew = true;
let inaidx;
for(let i1=0;i1<this.eliminateArr.length;i1++){
let i1data = this.eliminateArr[i1];
for(let i2=0;i2<i1data.length;i2++){
let i2data = i1data[i2];
let i2eliname = i2data.idxname;
let inidx = earr.indexOf(i2eliname);
if(inidx!=-1){
addnew = false;
break;
}
}
if(!addnew){
inaidx = i1;
break;
}
}
if(addnew){
let addarr = new Array();
for(let i1=0;i1<earr.length;i1++){
let i1name = earr[i1];
addarr.push({
idxname:i1name,
type:etype
})
}
this.eliminateArr.push(addarr);
}else{
for(let i4=0;i4<earr.length;i4++){
let i4name = earr[i4];
let addele = true;
for(let i3=0;i3<this.eliminateArr[inaidx].length;i3++){
let i3data = this.eliminateArr[inaidx][i3];
let i3eliname = i3data.idxname;
if(i3eliname==i4name){
addele = false;
break;
}
}
if(addele){
this.eliminateArr[inaidx].push({
idxname:i4name,
type:etype
})
}
}
}
}
//获得这个位置掉落的元素
getFallRcEle(r,c){
for(let fr=r-1;fr>-1;fr--){
let frc = fr+"_"+c;
let frcname = this.lattices[frc];
if(frcname!="empty"){
this.lattices[frc] = "empty";
return frcname;
}
}
return false;
}
addScoreAni(ielix,ieliy,ietype,addscore){
let anitxt = MapData.getOneTxt();
anitxt.alpha = 0;
let txtcolor = "#bd882f";
switch(ietype){
case ElementType.btiger:
txtcolor = "#ffffff";
break;
case ElementType.gtiger:
txtcolor = "#f5a900";
break;
case ElementType.monkey:
txtcolor = "#bd882f";
break;
case ElementType.bird:
txtcolor = "#54c1ef";
break;
case ElementType.koala:
txtcolor = "#c7c8c9";
break;
default:
console.error("未定义类型,检查");
break;
}
anitxt.fillColor = txtcolor;
let anix = ielix+MapData.itemsize/2-100;
let aniy = ieliy+this.conty+MapData.itemsize/2-35;
anitxt.text = "+"+addscore;
this.txtcontainer.addChild(anitxt);
anitxt.x = anix;
anitxt.y = aniy;
anitxt.scaleX = 0;
anitxt.scaleY = 0;
anitxt.alpha = 1;
engine.Tween.get(anitxt,{loop:false}).set({
x:anix,
y:aniy,
scaleX:0,
scaleY:0
})
.to({
y:aniy-50,
scaleX:1,
scaleY:1,
},300)
.to({
y:aniy-120,
alpha:0
},500)
.call(()=>{
this.txtcontainer.removeChild(anitxt);
this.score += addscore;
MapData.recoverTxt(anitxt);
})
}
changeHomeShow(mode="day"){
let _v = true;
if(mode=="day"){
_v = true;
}else{
_v = false;
}
this.homeimgday.visible = _v;
this.homeimgnight.visible = !_v;
} }
} }
...@@ -7,12 +7,45 @@ import {injectProps} from "../props"; ...@@ -7,12 +7,45 @@ import {injectProps} from "../props";
export class GameWrapper extends engine.Container { export class GameWrapper extends engine.Container {
private _status;
private _gameView: GameView; private _gameView: GameView;
constructor() { constructor() {
super(); super();
let gameView = this._gameView = new GameView(); this._gameView = new GameView();
this.addChild(gameView); this.addChild(this._gameView);
engine.globalEvent.addEventListener('game-init',this.init,this);
engine.globalEvent.addEventListener('game-reset',this.reset,this);
engine.globalEvent.addEventListener('game-start',this.start,this);
engine.globalEvent.addEventListener('game-pause',this.pause,this);
engine.globalEvent.addEventListener('game-resume',this.resume,this);
engine.globalEvent.addEventListener('game-recordcomp',this.recordcomp,this);
}
init(event:engine.Event){
console.log("gamewrapper-init",event);
let time = event.data.time;
let level = event.data.level;
let mode = event.data.mode;
this._gameView.init(time,level,mode);
}
reset(event:engine.Event){
// console.log("gamewrapper-reset",event);
let time = event.data.time;
let level = event.data.level;
let mode = event.data.mode;
this._gameView.reset(time,level,mode);;
}
start(){
this._gameView.start();
}
pause(){
this._gameView.pause();
}
resume(){
this._gameView.resume();
}
recordcomp(){
this._gameView.recordcomp();
} }
} }
import Element from "./ele/Element";
import { getTextureByName } from "./utils";
export enum ElementType{
btiger = 1,
gtiger,
monkey,
bird,
koala
}
export enum GameEvent{
SelectEle = "SelectEle",
}
export default class MapData{
//单格大小
static itemsize = 129;
//
static paddingb = 10;
static paddingi = 5;
//
static row = 5;
static col = 5;
//行-列,对应位置
static posData = {
};
static eleidx = 1;
static elePool = {};
static anispeed = 1000;
static btigerTex:engine.Texture;
static gtigerTex:engine.Texture;
static monkeyTex:engine.Texture;
static birdTex:engine.Texture;
static koalaTex:engine.Texture;
static levelData:Array<Array<Array<number>>> = [
[
[1,2,5,3,4],
[3,1,2,4,5],
[2,5,3,4,1],
[5,4,1,2,3],
[4,1,3,5,2],
],
[
[5,2,1,2,1],
[3,1,4,5,4],
[2,5,3,5,1],
[5,4,1,2,3],
[4,1,3,1,2],
],
[
[2,4,1,5,2],
[2,3,4,1,3],
[4,1,3,2,3],
[3,2,1,1,4],
[1,1,3,5,4],
],
[
[3,2,1,4,5],
[2,4,1,2,3],
[2,3,2,3,3],
[4,4,5,5,4],
[3,3,1,2,4],
],
[
[4,5,1,2,4],
[3,2,3,4,2],
[1,5,2,3,5],
[4,5,5,1,3],
[1,2,3,2,4],
]
]
static getRy(r){
return this.paddingb+r*(this.itemsize+this.paddingi);
}
static getCx(c){
return this.paddingb+c*(this.itemsize+this.paddingi);
}
static getRCPos(r,c){
let x = this.getCx(c);
let y = this.getRy(r);
return [x,y];
}
static adaptElePos(pos,wid,hei){
let x = pos[0]+(this.itemsize-wid)/2;
let y = pos[1]+(this.itemsize-hei)/2;
return [x,y];
}
static getEtypeImgName(type:ElementType){
let ename:string;
switch(type){
case ElementType.btiger:
ename = "白虎";
break;
case ElementType.gtiger:
ename = "雌虎";
break;
case ElementType.monkey:
ename = "猴子";
break;
case ElementType.bird:
ename = "鸟";
break;
case ElementType.koala:
ename = "树熊";
break;
default:
console.error("未定义元素类型");
break;
}
return ename;
}
static getEtypeImgTex(type:ElementType){
let etex:engine.Texture;
switch(type){
case ElementType.btiger:
if(!this.btigerTex){
this.btigerTex = getTextureByName("白虎");
console.log("新素材加载---白虎");
}
etex = this.btigerTex;
break;
case ElementType.gtiger:
if(!this.gtigerTex){
this.gtigerTex = getTextureByName("雌虎");
console.log("新素材加载---雌虎");
}
etex = this.gtigerTex;
break;
case ElementType.monkey:
if(!this.monkeyTex){
this.monkeyTex = getTextureByName("猴子");
console.log("新素材加载---猴子");
}
etex = this.monkeyTex;
break;
case ElementType.bird:
if(!this.birdTex){
this.birdTex = getTextureByName("鸟");
console.log("新素材加载---鸟");
}
etex = this.birdTex;
break;
case ElementType.koala:
if(!this.koalaTex){
this.koalaTex = getTextureByName("树熊");
console.log("新素材加载---树熊");
}
etex = this.koalaTex;
break;
default:
console.error("未定义元素类型");
break;
}
return etex;
}
static getRandEtype(){
let eletypeArr = [ElementType.btiger,ElementType.gtiger,ElementType.monkey,ElementType.bird,ElementType.koala];
let etype = eletypeArr[Math.floor(Math.random()*eletypeArr.length)];
return etype;
}
static initPoolEle(){
// console.error("初始化元素池");
this.btigerTex = getTextureByName("白虎");
this.gtigerTex = getTextureByName("雌虎");
this.monkeyTex = getTextureByName("猴子");
this.birdTex = getTextureByName("鸟");
this.koalaTex = getTextureByName("树熊");
let eletypes = [ElementType.btiger,ElementType.gtiger,ElementType.monkey,ElementType.bird,ElementType.koala];
this.elePool["ele"] = new Array();
//初始5*5个元素备用;
for(let i=0;i<eletypes.length;i++){
let itype = eletypes[i];
// this.elePool[itype] = new Array();
for(let a=0;a<5;a++){
let iele = new Element();
// iele.eimage.texture = this.getEtypeImgTex(itype);
this.elePool["ele"].push(iele);
}
}
//得分得txt
this.elePool["score"] = new Array();
for(let t=0;t<8;t++){
let itxt = new engine.Label();
itxt.size = 66;
itxt.width = 200;
itxt.height = 70;
itxt.textAlign = engine.TEXT_ALIGN.CENTER;
itxt.verticalAlign = engine.VERTICAL_ALIGN.MIDDLE;
itxt.anchorY = 35;
itxt.anchorX = 100;
itxt.bold = true;
this.elePool["score"].push(itxt);
}
}
static getOneEle(type:ElementType):Element{
let ele:Element;
if(this.elePool["ele"]){
if(this.elePool["ele"].length>0){
ele = this.elePool["ele"].shift();
}
}else{
this.elePool["ele"] = new Array();
}
if(!ele){
console.error("创建了新的了ele");
ele = new Element();
// ele.eimage.texture = getTextureByName(this.getEtypeImgName(type));
}
ele.name = "ele_"+this.eleidx;
this.eleidx += 1;
ele.init(type)
return ele;
}
static getOneTxt():engine.Label{
let itxt:engine.Label;
if(this.elePool["score"]){
if(this.elePool["score"].length>0){
itxt = this.elePool["score"].shift();
}
}else{
this.elePool["score"] = new Array();
}
if(!itxt){
itxt = new engine.Label();
itxt.size = 66;
itxt.width = 200;
itxt.height = 70;
itxt.textAlign = engine.TEXT_ALIGN.CENTER;
itxt.verticalAlign = engine.VERTICAL_ALIGN.MIDDLE;
itxt.anchorY = 35;
itxt.anchorX = 100;
itxt.bold = true;
// console.log("创建了新的txt");
}
itxt.mouseEnabled = false;
return itxt;
}
static recoverEle(ele:Element,type:ElementType){
if(ele.eimage){
ele.eimage.texture = null;
}
this.elePool["ele"].push(ele);
}
static recoverTxt(txt:engine.Label){
this.elePool["score"].push(txt);
}
static getDistance(p1,p2){
let p1x = p1[0];
let p1y = p1[1];
let p2x = p2[0];
let p2y = p2[1];
let dis = Math.sqrt(Math.pow(p1x-p2x,2)+Math.pow(p1y-p2y,2));
return dis;
}
}
\ No newline at end of file
import MapData, { ElementType, GameEvent } from "../MapData";
import { getTextureByName } from "../utils";
export default class Element extends engine.Container{
type:ElementType;
eimage:engine.Image;
inrow;
incol;
set touch(touch){
this.mouseEnabled = touch;
this.mouseChildren = touch;
}
constructor(){
super();
this.width = MapData.itemsize;
this.height = MapData.itemsize;
this.anchorX = MapData.itemsize/2;
this.eimage = new engine.Image();
this.addChild(this.eimage);
this.touch = true;
// this.addEventListener(engine.MouseEvent.CLICK,this.selectele,this);
this.addEventListener(engine.MouseEvent.MOUSE_DOWN,this.selectele,this);
this.addEventListener(engine.MouseEvent.MOUSE_MOVE,this.changemove,this);
}
init(type:ElementType){
this.anchorY = MapData.itemsize;
this.scaleX = 1;
this.scaleY = 1;
this.alpha = 1;
this.type = type;
let ename = MapData.getEtypeImgName(type);
this.eimage.texture = MapData.getEtypeImgTex(type);
let imgwid = this.eimage.texture.width;
let imghei = this.eimage.texture.height;
// console.log("大小",imgwid,imghei);
this.eimage.x = (this.width - imgwid)/2;
this.eimage.y = (this.height-imghei)/2;
}
setrc(r,c){
this.inrow = r;
this.incol = c;
}
selectele(e:engine.MouseEvent){
engine.globalEvent.dispatchEvent(GameEvent.SelectEle,{
r:this.inrow,
c:this.incol,
type:"mouse_down"
})
}
changemove(e:engine.MouseEvent){
// console.log(this.inrow+":"+this.incol);
engine.globalEvent.dispatchEvent(GameEvent.SelectEle,{
r:this.inrow,
c:this.incol,
type:"mouse_move"
})
}
public get factor():number {
return 0;
}
public set factor(value:number) {
this.x = (1 - value) * (1 - value) * this.p1x + 2 * value * (1 - value) * this.c1x + value * value * this.p2x;
this.y = (1 - value) * (1 - value) * this.p1y + 2 * value * (1 - value) * this.c1y + value * value * this.p2y;
var mscale = (1 - value) * (1 - value) * 1 + 2 * value * (1 - value) * 0.6 + value * value * 0.35;
this.scaleX = mscale;
this.scaleY = mscale;
}
p1x;
p1y;
c1x;
c1y;
p2x;
p2y;
//飞到小屋
flyToHome(tx,ty,time){
this.p1x = this.x;
this.p1y = this.y+20;
this.c1x = (this.p1x-tx)/4+tx;
this.c1y = ty;
this.p2x = tx;
this.p2y = ty;
engine.Tween.removeTweens(this);
engine.Tween.get(this).to({
scaleX:1.1,
scaleY:1.1
},200)
.to({
scaleX:1.1,
scaleY:0.88
},100)
.to({
scaleX:0.98,
scaleY:0.98,
y:this.y+20
},100)
.call(()=>{
this.factor = 0;
engine.Tween.get(this).to({
factor:1
},450)
.call(()=>{
let nodeparent:engine.Container = this.parent;
nodeparent&&nodeparent.removeChild(this);
MapData.recoverEle(this,this.type);
})
})
}
changePos(tpos:Array<number>){
let nx = this.x;
let ny = this.y;
let tx = tpos[0];
let ty = tpos[1];
let dis = MapData.getDistance([nx,ny],tpos);
let time = Math.ceil(dis/MapData.anispeed*1000);
engine.Tween.removeTweens(this);
let pro = new Promise(res=>{
engine.Tween.get(this,{loop:false}).to({
x:tx,
y:ty
},time)
.call(()=>{
// console.log("单个移动完毕");
res();
})
})
return pro;
}
}
\ No newline at end of file
This source diff could not be displayed because it is too large. You can view the blob instead.
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