Commit 66c84562 authored by zjz1994's avatar zjz1994

消消乐暂存

parent bea870f5
...@@ -96,21 +96,21 @@ ...@@ -96,21 +96,21 @@
"assets": [ "assets": [
{ {
"name": "bg1", "name": "bg1",
"url": "//yun.duiba.com.cn/aurora/assets/e6ab7c1e191d30a2b068fa4a0e867040b9396226.png", "url": "//yun.duiba.com.cn/aurora/assets/f3fda198741657d9cab9418bd5d47248af065487.jpg",
"uuid": "bg1", "uuid": "bg1",
"ext": ".png" "ext": ".jpg"
}, },
{ {
"name": "bg2", "name": "bg2",
"url": "//yun.duiba.com.cn/aurora/assets/a2d611fa5af2b26ffd57a24ff524d2a0a4fe1564.png", "url": "//yun.duiba.com.cn/aurora/assets/8fa1de1570023f21b676a8602ec9315cee83a99b.jpg",
"uuid": "bg2", "uuid": "bg2",
"ext": ".png" "ext": ".jpg"
}, },
{ {
"name": "bg3", "name": "bg3",
"url": "//yun.duiba.com.cn/aurora/assets/89258aed59e36471a4136ce7fbc4ca7e300caf07.png", "url": "//yun.duiba.com.cn/aurora/assets/517fc529c79b18ff4881d206c942c8f2888ad6fd.jpg",
"uuid": "bg3", "uuid": "bg3",
"ext": ".png" "ext": ".jpg"
}, },
{ {
"name": "car1", "name": "car1",
...@@ -222,5 +222,5 @@ ...@@ -222,5 +222,5 @@
} }
}, },
"id": "bjxd-game", "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.Rect();\r\n\t this.addChild(this._strut);\r\n\t this._strut.width = props.strutWidth;\r\n\t this._strut.y = this.gany;\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 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.width = props.strutWidth;\r\n\t this._strut.y = this.gany;\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));\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 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 };\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 };\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 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 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 = 10;\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('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" "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));\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.Rect();\r\n\t this.addChild(this._strut);\r\n\t this._strut.width = props.strutWidth;\r\n\t this._strut.y = this.gany;\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 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.width = props.strutWidth;\r\n\t this._strut.y = this.gany;\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));\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 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 };\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 };\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 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 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 = 10;\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"
} }
...@@ -95,5 +95,5 @@ ...@@ -95,5 +95,5 @@
} }
}, },
"id": "xiaoxiaole", "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\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 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.anchorY = MapData.itemsize;\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.CLICK, _this.selectele, _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.scaleX = 1;\r\n\t this.scaleY = 1;\r\n\t this.type = type;\r\n\t var ename = MapData.getEtypeImgName(type);\r\n\t this.eimage.texture = getTextureByName(ename);\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 });\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.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 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);\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 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 console.log(\"单个移动完毕\");\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[\"btiger\"] = 1] = \"btiger\";\r\n\t ElementType[ElementType[\"gtiger\"] = 2] = \"gtiger\";\r\n\t ElementType[ElementType[\"monkey\"] = 3] = \"monkey\";\r\n\t ElementType[ElementType[\"bird\"] = 4] = \"bird\";\r\n\t ElementType[ElementType[\"koala\"] = 5] = \"koala\";\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.paddingb + r * (this.itemsize + this.paddingi);\r\n\t };\r\n\t MapData.getCx = function (c) {\r\n\t return this.paddingb + c * (this.itemsize + this.paddingi);\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.btiger:\r\n\t ename = \"白虎\";\r\n\t break;\r\n\t case ElementType.gtiger:\r\n\t ename = \"雌虎\";\r\n\t break;\r\n\t case ElementType.monkey:\r\n\t ename = \"猴子\";\r\n\t break;\r\n\t case ElementType.bird:\r\n\t ename = \"\";\r\n\t break;\r\n\t case ElementType.koala:\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.getRandEtype = function () {\r\n\t var eletypeArr = [ElementType.btiger, ElementType.gtiger, ElementType.monkey, ElementType.bird, ElementType.koala];\r\n\t var etype = eletypeArr[Math.floor(Math.random() * eletypeArr.length)];\r\n\t return etype;\r\n\t };\r\n\t MapData.getOneEle = function (type) {\r\n\t var ele;\r\n\t if (this.elePool.length > 0) {\r\n\t ele = this.elePool.shift();\r\n\t }\r\n\t else {\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.recoverEle = function (ele) {\r\n\t this.elePool.push(ele);\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 = 129;\r\n\t MapData.paddingb = 10;\r\n\t MapData.paddingi = 5;\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 = 860;\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 = 528;\r\n\t _this.homey = -40;\r\n\t _this.ination = false;\r\n\t _this.canation = 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 this.selectimg = new engine.Image(getTextureByName(\"选中框\"));\r\n\t this.selectimg.mouseEnabled = false;\r\n\t var row = MapData.row;\r\n\t var col = MapData.col;\r\n\t this.homeimg = createSvga(\"房子动画\");\r\n\t this.addChild(this.homeimg);\r\n\t this.homeimg.x = this.homex;\r\n\t this.homeimg.y = -40;\r\n\t this.homeimg.stop();\r\n\t console.log(\"房子动画\", this.homeimg);\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 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 + 146 / 2 - MapData.itemsize / 3;\r\n\t this.taniy = this.homey + 120 / 2;\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 };\r\n\t GameView.prototype.playComp = function () {\r\n\t console.log(\"动画播放完毕\");\r\n\t this.homeimg.stop(1);\r\n\t };\r\n\t GameView.prototype.init = function () {\r\n\t this.initContainer();\r\n\t };\r\n\t GameView.prototype.reset = function () {\r\n\t };\r\n\t GameView.prototype.start = function () {\r\n\t };\r\n\t GameView.prototype.onUpdate = function () {\r\n\t var ntime = Date.now();\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.homeimg) {\r\n\t var curframe = this.homeimg.currentFrame;\r\n\t if (curframe == this.homeimg.totalFrames) {\r\n\t this.homeimg.gotoAndStop(1);\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 this.lattices = {};\r\n\t var testdata = [\r\n\t [1, 2, 5, 3, 3],\r\n\t [3, 1, 4, 4, 5],\r\n\t [2, 5, 3, 5, 1],\r\n\t [5, 4, 1, 2, 3],\r\n\t [4, 1, 3, 5, 2],\r\n\t ];\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.checkEliminate();\r\n\t this.fall();\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 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 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 sname = sr + \"_\" + sc;\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 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 }\r\n\t if (this.selectArr.length == 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 this.anicontainer.addChild(this.selectimg);\r\n\t this.selectimg.x = rcpos[0];\r\n\t this.selectimg.y = rcpos[1] + this.conty;\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 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 if (this.eliminateArr.length > 0) {\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.changeEnable(true);\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, ielidata, ielidxname, ielitype, ieliname, ielinode, ielix, ieliy;\r\n\t return tslib.__generator(this, function (_a) {\r\n\t switch (_a.label) {\r\n\t case 0:\r\n\t for (i = 0; i < this.eliminateArr.length; i++) {\r\n\t ielidata = this.eliminateArr[i];\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 ielix = ielinode.x;\r\n\t ieliy = ielinode.y;\r\n\t this.container.removeChild(ielinode);\r\n\t MapData.recoverEle(ielinode);\r\n\t this.lattices[ielidxname] = \"empty\";\r\n\t this.goHomeAni(ielitype, ielix, ieliy);\r\n\t }\r\n\t return [4, new Promise(function (res) {\r\n\t setTimeout(function () {\r\n\t res();\r\n\t }, 800);\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 }, 550);\r\n\t })];\r\n\t case 2:\r\n\t _a.sent();\r\n\t this.homeimg.play();\r\n\t return [2];\r\n\t }\r\n\t });\r\n\t });\r\n\t };\r\n\t GameView.prototype.fall = function () {\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 = MapData.getRandEtype();\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 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 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 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 == 2) {\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 return [2];\r\n\t }\r\n\t });\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 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 ele.touch = v;\r\n\t }\r\n\t if (v) {\r\n\t this.lastatime = Date.now();\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 == 2) {\r\n\t this.ination = true;\r\n\t console.log(\"可以提示\");\r\n\t this.attiondata = [attiondata[0], attiondata[1]];\r\n\t var atname1 = this.lattices[attiondata[0]];\r\n\t var atname2 = this.lattices[attiondata[1]];\r\n\t var atnode1 = this.container.getChildByName(atname1);\r\n\t var atnode2 = this.container.getChildByName(atname2);\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 var atpos2 = [(atx1 - atx2) * lerpnum + atx2, (aty1 - aty2) * lerpnum + aty2];\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 engine.Tween.get(atnode2, { loop: true })\r\n\t .to({\r\n\t x: atpos2[0],\r\n\t y: atpos2[1]\r\n\t }, 500)\r\n\t .to({\r\n\t x: atx2,\r\n\t y: aty2\r\n\t }, 500);\r\n\t }\r\n\t else {\r\n\t this.solveDieMap();\r\n\t }\r\n\t };\r\n\t GameView.prototype.solveDieMap = function () {\r\n\t this.changeEnable(false);\r\n\t console.error(\"死图调整\");\r\n\t console.log(this.lattices);\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 == 2) {\r\n\t console.error(\"可以复活了,转移位置\");\r\n\t this.changeToFuHuoPos();\r\n\t }\r\n\t else {\r\n\t console.error(\"依然死亡,寻求复活\");\r\n\t return this.solveDieMap();\r\n\t }\r\n\t };\r\n\t GameView.prototype.changeToFuHuoPos = function () {\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 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 console.error(\"死亡转移完毕\");\r\n\t this.changeEnable(true);\r\n\t return [2];\r\n\t }\r\n\t });\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 == 2) {\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 console.error(\"啥情况,检查----------------\");\r\n\t }\r\n\t if (edatarow.length == 2) {\r\n\t console.log(\"横向查找\", edatarow, checktype);\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 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 + \"_\" + relecol, downrow + \"_\" + rightcol];\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 + \"_\" + relecol, downrow + \"_\" + leftcol];\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 + \"_\" + relecol, uprow + \"_\" + rightcol];\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 + \"_\" + relecol, uprow + \"_\" + leftcol];\r\n\t break;\r\n\t }\r\n\t }\r\n\t }\r\n\t }\r\n\t if (edatacol.length == 2) {\r\n\t console.log(\"竖向查找\", edatacol, checktype);\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 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 = [relerow + \"_\" + leftcol, uprow + \"_\" + leftcol];\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 = [relerow + \"_\" + leftcol, downrow + \"_\" + leftcol];\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 = [relerow + \"_\" + rightcol, uprow + \"_\" + rightcol];\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 = [relerow + \"_\" + rightcol, downrow + \"_\" + rightcol];\r\n\t break;\r\n\t }\r\n\t }\r\n\t }\r\n\t }\r\n\t }\r\n\t }\r\n\t console.log(\"相邻检测--------------\", attiondata);\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.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 var eletype = ele.type;\r\n\t return eletype;\r\n\t };\r\n\t GameView.prototype.checkAddEli = function (etype, earr) {\r\n\t for (var e = 0; e < earr.length; e++) {\r\n\t var ename = earr[e];\r\n\t var needadd = true;\r\n\t for (var i = 0; i < this.eliminateArr.length; i++) {\r\n\t var ielidata = this.eliminateArr[i];\r\n\t var ielidxname = ielidata.idxname;\r\n\t if (ielidxname == ename) {\r\n\t needadd = false;\r\n\t break;\r\n\t }\r\n\t }\r\n\t if (needadd) {\r\n\t this.eliminateArr.push({\r\n\t idxname: ename,\r\n\t type: etype\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 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 return _this;\r\n\t }\r\n\t GameWrapper.prototype.init = function () {\r\n\t this._gameView.init();\r\n\t };\r\n\t GameWrapper.prototype.reset = function () {\r\n\t this._gameView.reset();\r\n\t };\r\n\t GameWrapper.prototype.start = function () {\r\n\t this._gameView.start();\r\n\t };\r\n\t return GameWrapper;\r\n\t}(engine.Container));\r\n\t//# sourceMappingURL=GameWrapper.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\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": "(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\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 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.anchorY = MapData.itemsize;\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.CLICK, _this.selectele, _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.scaleX = 1;\r\n\t this.scaleY = 1;\r\n\t this.type = type;\r\n\t var ename = MapData.getEtypeImgName(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 });\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.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 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 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 console.log(\"单个移动完毕\");\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[\"btiger\"] = 1] = \"btiger\";\r\n\t ElementType[ElementType[\"gtiger\"] = 2] = \"gtiger\";\r\n\t ElementType[ElementType[\"monkey\"] = 3] = \"monkey\";\r\n\t ElementType[ElementType[\"bird\"] = 4] = \"bird\";\r\n\t ElementType[ElementType[\"koala\"] = 5] = \"koala\";\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.paddingb + r * (this.itemsize + this.paddingi);\r\n\t };\r\n\t MapData.getCx = function (c) {\r\n\t return this.paddingb + c * (this.itemsize + this.paddingi);\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.btiger:\r\n\t ename = \"白虎\";\r\n\t break;\r\n\t case ElementType.gtiger:\r\n\t ename = \"雌虎\";\r\n\t break;\r\n\t case ElementType.monkey:\r\n\t ename = \"猴子\";\r\n\t break;\r\n\t case ElementType.bird:\r\n\t ename = \"\";\r\n\t break;\r\n\t case ElementType.koala:\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.btiger:\r\n\t etex = this.btigerTex || getTextureByName(\"白虎\");\r\n\t break;\r\n\t case ElementType.gtiger:\r\n\t etex = this.gtigerTex || getTextureByName(\"雌虎\");\r\n\t break;\r\n\t case ElementType.monkey:\r\n\t etex = this.monkeyTex || getTextureByName(\"猴子\");\r\n\t break;\r\n\t case ElementType.bird:\r\n\t etex = this.birdTex || getTextureByName(\"\");\r\n\t break;\r\n\t case ElementType.koala:\r\n\t etex = this.koalaTex || getTextureByName(\"树熊\");\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.btiger, ElementType.gtiger, ElementType.monkey, ElementType.bird, ElementType.koala];\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 console.error(\"初始化元素池\");\r\n\t var eletypes = [ElementType.btiger, ElementType.gtiger, ElementType.monkey, ElementType.bird, ElementType.koala];\r\n\t for (var i = 0; i < eletypes.length; i++) {\r\n\t var itype = eletypes[i];\r\n\t this.elePool[itype] = new Array();\r\n\t for (var a = 0; a < 10; a++) {\r\n\t var iele = new Element();\r\n\t iele.eimage.texture = this.getEtypeImgTex(itype);\r\n\t this.elePool[itype].push(iele);\r\n\t }\r\n\t }\r\n\t };\r\n\t MapData.getOneEle = function (type) {\r\n\t var ele;\r\n\t if (this.elePool[type]) {\r\n\t if (this.elePool[type].length > 0) {\r\n\t ele = this.elePool[type].shift();\r\n\t }\r\n\t }\r\n\t else {\r\n\t this.elePool[type] = new Array();\r\n\t }\r\n\t if (!ele) {\r\n\t console.error(\"创建了新的了\");\r\n\t ele = new Element();\r\n\t ele.eimage.texture = getTextureByName(this.getEtypeImgName(type));\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.recoverEle = function (ele, type) {\r\n\t this.elePool[type].push(ele);\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 = 129;\r\n\t MapData.paddingb = 10;\r\n\t MapData.paddingi = 5;\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 = 860;\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 = 528;\r\n\t _this.homey = -40;\r\n\t _this.ination = false;\r\n\t _this.canation = 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 MapData.initPoolEle();\r\n\t this.selectimg = new engine.Image(getTextureByName(\"选中框\"));\r\n\t this.selectimg.mouseEnabled = false;\r\n\t var row = MapData.row;\r\n\t var col = MapData.col;\r\n\t this.homeimg = createSvga(\"房子动画\");\r\n\t this.addChild(this.homeimg);\r\n\t this.homeimg.x = this.homex;\r\n\t this.homeimg.y = -40;\r\n\t this.homeimg.stop();\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 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 + 146 / 2 - MapData.itemsize / 3;\r\n\t this.taniy = this.homey + 120 / 2;\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 };\r\n\t GameView.prototype.playComp = function () {\r\n\t this.homeimg.stop(1);\r\n\t };\r\n\t GameView.prototype.init = function () {\r\n\t this.initContainer();\r\n\t };\r\n\t GameView.prototype.reset = function () {\r\n\t };\r\n\t GameView.prototype.start = function () {\r\n\t };\r\n\t GameView.prototype.onUpdate = function () {\r\n\t var ntime = Date.now();\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.homeimg) {\r\n\t var curframe = this.homeimg.currentFrame;\r\n\t if (curframe == this.homeimg.totalFrames) {\r\n\t this.homeimg.gotoAndStop(1);\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 this.lattices = {};\r\n\t var testdata = [\r\n\t [1, 2, 5, 3, 4],\r\n\t [3, 1, 4, 4, 5],\r\n\t [2, 5, 3, 5, 1],\r\n\t [5, 4, 1, 2, 3],\r\n\t [4, 1, 3, 5, 2],\r\n\t ];\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.checkEliminate();\r\n\t this.fall();\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 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 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 sname = sr + \"_\" + sc;\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 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 }\r\n\t if (this.selectArr.length == 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 this.anicontainer.addChild(this.selectimg);\r\n\t this.selectimg.x = rcpos[0];\r\n\t this.selectimg.y = rcpos[1] + this.conty;\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 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 if (this.eliminateArr.length > 0) {\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.changeEnable(true);\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, 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 for (i = 0; i < this.eliminateArr.length; i++) {\r\n\t ielidata = this.eliminateArr[i];\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 ielix = ielinode.x;\r\n\t ieliy = ielinode.y;\r\n\t ietype = ielinode.type;\r\n\t this.container.removeChild(ielinode);\r\n\t MapData.recoverEle(ielinode, ietype);\r\n\t this.lattices[ielidxname] = \"empty\";\r\n\t this.goHomeAni(ielitype, ielix, ieliy);\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 }, 400);\r\n\t })];\r\n\t case 2:\r\n\t _a.sent();\r\n\t this.homeimg.play();\r\n\t return [2];\r\n\t }\r\n\t });\r\n\t });\r\n\t };\r\n\t GameView.prototype.fall = function () {\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 = MapData.getRandEtype();\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 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 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 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 == 2) {\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 return [2];\r\n\t }\r\n\t });\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 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 ele.touch = v;\r\n\t }\r\n\t if (v) {\r\n\t this.lastatime = Date.now();\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 == 2) {\r\n\t this.ination = true;\r\n\t this.attiondata = [attiondata[0], attiondata[1]];\r\n\t var atname1 = this.lattices[attiondata[0]];\r\n\t var atname2 = this.lattices[attiondata[1]];\r\n\t var atnode1 = this.container.getChildByName(atname1);\r\n\t var atnode2 = this.container.getChildByName(atname2);\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 var atpos2 = [(atx1 - atx2) * lerpnum + atx2, (aty1 - aty2) * lerpnum + aty2];\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 engine.Tween.get(atnode2, { loop: true })\r\n\t .to({\r\n\t x: atpos2[0],\r\n\t y: atpos2[1]\r\n\t }, 500)\r\n\t .to({\r\n\t x: atx2,\r\n\t y: aty2\r\n\t }, 500);\r\n\t }\r\n\t else {\r\n\t this.solveDieMap();\r\n\t }\r\n\t };\r\n\t GameView.prototype.solveDieMap = function () {\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 == 2) {\r\n\t console.error(\"可以复活了,转移位置\");\r\n\t this.changeToFuHuoPos();\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 () {\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 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 this.changeEnable(true);\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.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 == 2) {\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 + \"_\" + relecol, downrow + \"_\" + rightcol];\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 + \"_\" + relecol, downrow + \"_\" + leftcol];\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 + \"_\" + relecol, uprow + \"_\" + rightcol];\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 + \"_\" + relecol, uprow + \"_\" + leftcol];\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 = [uprow + \"_\" + relecol, uprow1 + \"_\" + relecol];\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];\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 = [relerow + \"_\" + leftcol, uprow + \"_\" + leftcol];\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 = [relerow + \"_\" + leftcol, downrow + \"_\" + leftcol];\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 = [relerow + \"_\" + rightcol, uprow + \"_\" + rightcol];\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 = [relerow + \"_\" + rightcol, downrow + \"_\" + rightcol];\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];\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];\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];\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];\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];\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];\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 var eletype = ele.type;\r\n\t return eletype;\r\n\t };\r\n\t GameView.prototype.checkAddEli = function (etype, earr) {\r\n\t for (var e = 0; e < earr.length; e++) {\r\n\t var ename = earr[e];\r\n\t var needadd = true;\r\n\t for (var i = 0; i < this.eliminateArr.length; i++) {\r\n\t var ielidata = this.eliminateArr[i];\r\n\t var ielidxname = ielidata.idxname;\r\n\t if (ielidxname == ename) {\r\n\t needadd = false;\r\n\t break;\r\n\t }\r\n\t }\r\n\t if (needadd) {\r\n\t this.eliminateArr.push({\r\n\t idxname: ename,\r\n\t type: etype\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 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 return _this;\r\n\t }\r\n\t GameWrapper.prototype.init = function () {\r\n\t this._gameView.init();\r\n\t };\r\n\t GameWrapper.prototype.reset = function () {\r\n\t this._gameView.reset();\r\n\t };\r\n\t GameWrapper.prototype.start = function () {\r\n\t this._gameView.start();\r\n\t };\r\n\t return GameWrapper;\r\n\t}(engine.Container));\r\n\t//# sourceMappingURL=GameWrapper.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\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"
} }
...@@ -479,7 +479,6 @@ ...@@ -479,7 +479,6 @@
}; };
return Player; return Player;
}(engine.Container)); }(engine.Container));
//# sourceMappingURL=Player.js.map
var Strut = (function (_super) { var Strut = (function (_super) {
tslib.__extends(Strut, _super); tslib.__extends(Strut, _super);
...@@ -797,6 +796,7 @@ ...@@ -797,6 +796,7 @@
GameView.speed = 10; GameView.speed = 10;
return GameView; return GameView;
}(engine.Container)); }(engine.Container));
//# sourceMappingURL=GameView.js.map
var GameWrapper = (function (_super) { var GameWrapper = (function (_super) {
tslib.__extends(GameWrapper, _super); tslib.__extends(GameWrapper, _super);
......
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -97,21 +97,21 @@ ...@@ -97,21 +97,21 @@
"assets": [ "assets": [
{ {
"name": "bg1", "name": "bg1",
"url": "//yun.duiba.com.cn/aurora/assets/e6ab7c1e191d30a2b068fa4a0e867040b9396226.png", "url": "//yun.duiba.com.cn/aurora/assets/f3fda198741657d9cab9418bd5d47248af065487.jpg",
"uuid": "bg1", "uuid": "bg1",
"ext": ".png" "ext": ".jpg"
}, },
{ {
"name": "bg2", "name": "bg2",
"url": "//yun.duiba.com.cn/aurora/assets/a2d611fa5af2b26ffd57a24ff524d2a0a4fe1564.png", "url": "//yun.duiba.com.cn/aurora/assets/8fa1de1570023f21b676a8602ec9315cee83a99b.jpg",
"uuid": "bg2", "uuid": "bg2",
"ext": ".png" "ext": ".jpg"
}, },
{ {
"name": "bg3", "name": "bg3",
"url": "//yun.duiba.com.cn/aurora/assets/89258aed59e36471a4136ce7fbc4ca7e300caf07.png", "url": "//yun.duiba.com.cn/aurora/assets/517fc529c79b18ff4881d206c942c8f2888ad6fd.jpg",
"uuid": "bg3", "uuid": "bg3",
"ext": ".png" "ext": ".jpg"
}, },
{ {
"name": "car1", "name": "car1",
......
...@@ -16,7 +16,7 @@ export class Player extends engine.Container{ ...@@ -16,7 +16,7 @@ export class Player extends engine.Container{
this._container.addChild(this.playerNode); this._container.addChild(this.playerNode);
this.playerNode.y = this.playery; this.playerNode.y = this.playery;
this.playerNode.x = pierWidth/2 - 50; this.playerNode.x = pierWidth/2 - 50;
this.playerNode.stop(); this.playerNode.play();
this._container.visible = false; this._container.visible = false;
} }
......
...@@ -44,7 +44,6 @@ ...@@ -44,7 +44,6 @@
this.scaleY = 1; this.scaleY = 1;
this.type = type; this.type = type;
var ename = MapData.getEtypeImgName(type); var ename = MapData.getEtypeImgName(type);
this.eimage.texture = getTextureByName(ename);
var imgwid = this.eimage.texture.width; var imgwid = this.eimage.texture.width;
var imghei = this.eimage.texture.height; var imghei = this.eimage.texture.height;
this.eimage.x = (this.width - imgwid) / 2; this.eimage.x = (this.width - imgwid) / 2;
...@@ -102,7 +101,7 @@ ...@@ -102,7 +101,7 @@
.call(function () { .call(function () {
var nodeparent = _this.parent; var nodeparent = _this.parent;
nodeparent && nodeparent.removeChild(_this); nodeparent && nodeparent.removeChild(_this);
MapData.recoverEle(_this); MapData.recoverEle(_this, _this.type);
}); });
}); });
}; };
...@@ -185,26 +184,70 @@ ...@@ -185,26 +184,70 @@
} }
return ename; return ename;
}; };
MapData.getEtypeImgTex = function (type) {
var etex;
switch (type) {
case ElementType.btiger:
etex = this.btigerTex || getTextureByName("白虎");
break;
case ElementType.gtiger:
etex = this.gtigerTex || getTextureByName("雌虎");
break;
case ElementType.monkey:
etex = this.monkeyTex || getTextureByName("猴子");
break;
case ElementType.bird:
etex = this.birdTex || getTextureByName("鸟");
break;
case ElementType.koala:
etex = this.koalaTex || getTextureByName("树熊");
break;
default:
console.error("未定义元素类型");
break;
}
return etex;
};
MapData.getRandEtype = function () { MapData.getRandEtype = function () {
var eletypeArr = [ElementType.btiger, ElementType.gtiger, ElementType.monkey, ElementType.bird, ElementType.koala]; var eletypeArr = [ElementType.btiger, ElementType.gtiger, ElementType.monkey, ElementType.bird, ElementType.koala];
var etype = eletypeArr[Math.floor(Math.random() * eletypeArr.length)]; var etype = eletypeArr[Math.floor(Math.random() * eletypeArr.length)];
return etype; return etype;
}; };
MapData.initPoolEle = function () {
console.error("初始化元素池");
var eletypes = [ElementType.btiger, ElementType.gtiger, ElementType.monkey, ElementType.bird, ElementType.koala];
for (var i = 0; i < eletypes.length; i++) {
var itype = eletypes[i];
this.elePool[itype] = new Array();
for (var a = 0; a < 10; a++) {
var iele = new Element();
iele.eimage.texture = this.getEtypeImgTex(itype);
this.elePool[itype].push(iele);
}
}
};
MapData.getOneEle = function (type) { MapData.getOneEle = function (type) {
var ele; var ele;
if (this.elePool.length > 0) { if (this.elePool[type]) {
ele = this.elePool.shift(); if (this.elePool[type].length > 0) {
ele = this.elePool[type].shift();
}
} }
else { else {
this.elePool[type] = new Array();
}
if (!ele) {
console.error("创建了新的了");
ele = new Element(); ele = new Element();
ele.eimage.texture = getTextureByName(this.getEtypeImgName(type));
} }
ele.name = "ele_" + this.eleidx; ele.name = "ele_" + this.eleidx;
this.eleidx += 1; this.eleidx += 1;
ele.init(type); ele.init(type);
return ele; return ele;
}; };
MapData.recoverEle = function (ele) { MapData.recoverEle = function (ele, type) {
this.elePool.push(ele); this.elePool[type].push(ele);
}; };
MapData.getDistance = function (p1, p2) { MapData.getDistance = function (p1, p2) {
var p1x = p1[0]; var p1x = p1[0];
...@@ -221,7 +264,7 @@ ...@@ -221,7 +264,7 @@
MapData.col = 5; MapData.col = 5;
MapData.posData = {}; MapData.posData = {};
MapData.eleidx = 1; MapData.eleidx = 1;
MapData.elePool = []; MapData.elePool = {};
MapData.anispeed = 860; MapData.anispeed = 860;
return MapData; return MapData;
}()); }());
...@@ -243,6 +286,7 @@ ...@@ -243,6 +286,7 @@
return _this; return _this;
} }
GameView.prototype.setup = function () { GameView.prototype.setup = function () {
MapData.initPoolEle();
this.selectimg = new engine.Image(getTextureByName("选中框")); this.selectimg = new engine.Image(getTextureByName("选中框"));
this.selectimg.mouseEnabled = false; this.selectimg.mouseEnabled = false;
var row = MapData.row; var row = MapData.row;
...@@ -252,7 +296,6 @@ ...@@ -252,7 +296,6 @@
this.homeimg.x = this.homex; this.homeimg.x = this.homex;
this.homeimg.y = -40; this.homeimg.y = -40;
this.homeimg.stop(); this.homeimg.stop();
console.log("房子动画", this.homeimg);
this.container = new engine.Container(); this.container = new engine.Container();
this.addChild(this.container); this.addChild(this.container);
this.container.y = this.conty; this.container.y = this.conty;
...@@ -287,7 +330,6 @@ ...@@ -287,7 +330,6 @@
this.addEventListener(engine.Event.ENTER_FRAME, this.onUpdate, this); this.addEventListener(engine.Event.ENTER_FRAME, this.onUpdate, this);
}; };
GameView.prototype.playComp = function () { GameView.prototype.playComp = function () {
console.log("动画播放完毕");
this.homeimg.stop(1); this.homeimg.stop(1);
}; };
GameView.prototype.init = function () { GameView.prototype.init = function () {
...@@ -314,7 +356,7 @@ ...@@ -314,7 +356,7 @@
GameView.prototype.initContainer = function () { GameView.prototype.initContainer = function () {
this.lattices = {}; this.lattices = {};
var testdata = [ var testdata = [
[1, 2, 5, 3, 3], [1, 2, 5, 3, 4],
[3, 1, 4, 4, 5], [3, 1, 4, 4, 5],
[2, 5, 3, 5, 1], [2, 5, 3, 5, 1],
[5, 4, 1, 2, 3], [5, 4, 1, 2, 3],
...@@ -467,7 +509,7 @@ ...@@ -467,7 +509,7 @@
}; };
GameView.prototype.eliminate = function () { GameView.prototype.eliminate = function () {
return tslib.__awaiter(this, void 0, void 0, function () { return tslib.__awaiter(this, void 0, void 0, function () {
var i, ielidata, ielidxname, ielitype, ieliname, ielinode, ielix, ieliy; var i, ielidata, ielidxname, ielitype, ieliname, ielinode, ielix, ieliy, ietype;
return tslib.__generator(this, function (_a) { return tslib.__generator(this, function (_a) {
switch (_a.label) { switch (_a.label) {
case 0: case 0:
...@@ -479,15 +521,16 @@ ...@@ -479,15 +521,16 @@
ielinode = this.container.getChildByName(ieliname); ielinode = this.container.getChildByName(ieliname);
ielix = ielinode.x; ielix = ielinode.x;
ieliy = ielinode.y; ieliy = ielinode.y;
ietype = ielinode.type;
this.container.removeChild(ielinode); this.container.removeChild(ielinode);
MapData.recoverEle(ielinode); MapData.recoverEle(ielinode, ietype);
this.lattices[ielidxname] = "empty"; this.lattices[ielidxname] = "empty";
this.goHomeAni(ielitype, ielix, ieliy); this.goHomeAni(ielitype, ielix, ieliy);
} }
return [4, new Promise(function (res) { return [4, new Promise(function (res) {
setTimeout(function () { setTimeout(function () {
res(); res();
}, 800); }, 400);
})]; })];
case 1: case 1:
_a.sent(); _a.sent();
...@@ -495,7 +538,7 @@ ...@@ -495,7 +538,7 @@
return [4, new Promise(function (res1) { return [4, new Promise(function (res1) {
setTimeout(function () { setTimeout(function () {
res1(); res1();
}, 550); }, 400);
})]; })];
case 2: case 2:
_a.sent(); _a.sent();
...@@ -627,7 +670,6 @@ ...@@ -627,7 +670,6 @@
var attiondata = this.attionEliminate(); var attiondata = this.attionEliminate();
if (attiondata && attiondata.length == 2) { if (attiondata && attiondata.length == 2) {
this.ination = true; this.ination = true;
console.log("可以提示");
this.attiondata = [attiondata[0], attiondata[1]]; this.attiondata = [attiondata[0], attiondata[1]];
var atname1 = this.lattices[attiondata[0]]; var atname1 = this.lattices[attiondata[0]];
var atname2 = this.lattices[attiondata[1]]; var atname2 = this.lattices[attiondata[1]];
...@@ -666,8 +708,6 @@ ...@@ -666,8 +708,6 @@
}; };
GameView.prototype.solveDieMap = function () { GameView.prototype.solveDieMap = function () {
this.changeEnable(false); this.changeEnable(false);
console.error("死图调整");
console.log(this.lattices);
var elearr = new Array(); var elearr = new Array();
for (var key in this.lattices) { for (var key in this.lattices) {
var keyval = this.lattices[key]; var keyval = this.lattices[key];
...@@ -683,7 +723,6 @@ ...@@ -683,7 +723,6 @@
this.changeToFuHuoPos(); this.changeToFuHuoPos();
} }
else { else {
console.error("依然死亡,寻求复活");
return this.solveDieMap(); return this.solveDieMap();
} }
}; };
...@@ -707,8 +746,13 @@ ...@@ -707,8 +746,13 @@
return [4, Promise.all(prolist)]; return [4, Promise.all(prolist)];
case 1: case 1:
_a.sent(); _a.sent();
console.error("死亡转移完毕"); this.checkEliminate();
if (this.eliminateArr.length > 0) {
this.eliminate();
}
else {
this.changeEnable(true); this.changeEnable(true);
}
return [2]; return [2];
} }
}); });
...@@ -724,11 +768,8 @@ ...@@ -724,11 +768,8 @@
var checktype = this.getEleTypeByRc(r, c); var checktype = this.getEleTypeByRc(r, c);
var edatarow = this.getEliminateRow(r, c); var edatarow = this.getEliminateRow(r, c);
var edatacol = this.getEliminateCol(r, c); var edatacol = this.getEliminateCol(r, c);
if (edatarow.length > 2 || edatacol.length > 2) { if (edatarow.length > 2 || edatacol.length > 2) ;
console.error("啥情况,检查----------------");
}
if (edatarow.length == 2) { if (edatarow.length == 2) {
console.log("横向查找", edatarow, checktype);
var releidx1 = edatarow[0]; var releidx1 = edatarow[0];
var releidx2 = edatarow[1]; var releidx2 = edatarow[1];
var relerow1 = Number(releidx1.split("_")[0]); var relerow1 = Number(releidx1.split("_")[0]);
...@@ -738,6 +779,8 @@ ...@@ -738,6 +779,8 @@
var uprow = relerow2 - 1; var uprow = relerow2 - 1;
var rightcol = relecol + 1; var rightcol = relecol + 1;
var leftcol = relecol - 1; var leftcol = relecol - 1;
var uprow1 = relerow2 - 2;
var downrow1 = relerow1 + 2;
if (downrow < MapData.row) { if (downrow < MapData.row) {
if (rightcol < MapData.col) { if (rightcol < MapData.col) {
var nexttype = this.getEleTypeByRc(downrow, rightcol); var nexttype = this.getEleTypeByRc(downrow, rightcol);
...@@ -770,9 +813,22 @@ ...@@ -770,9 +813,22 @@
} }
} }
} }
if (uprow1 > -1) {
var nexttype = this.getEleTypeByRc(uprow1, relecol);
if (nexttype == checktype) {
attiondata = [uprow + "_" + relecol, uprow1 + "_" + relecol];
break;
}
}
if (downrow1 < MapData.row) {
var nexttype = this.getEleTypeByRc(downrow1, relecol);
if (nexttype == checktype) {
attiondata = [downrow1 + "_" + relecol, downrow + "_" + relecol];
break;
}
}
} }
if (edatacol.length == 2) { if (edatacol.length == 2) {
console.log("竖向查找", edatacol, checktype);
var releidx1 = edatacol[0]; var releidx1 = edatacol[0];
var releidx2 = edatacol[1]; var releidx2 = edatacol[1];
var relerow = Number(releidx1.split("_")[0]); var relerow = Number(releidx1.split("_")[0]);
...@@ -782,6 +838,8 @@ ...@@ -782,6 +838,8 @@
var leftcol = relecol2 - 1; var leftcol = relecol2 - 1;
var uprow = relerow - 1; var uprow = relerow - 1;
var downrow = relerow + 1; var downrow = relerow + 1;
var rightcol1 = relecol1 + 2;
var leftcol1 = relecol2 - 2;
if (leftcol > -1) { if (leftcol > -1) {
if (uprow > -1) { if (uprow > -1) {
var nexttype = this.getEleTypeByRc(uprow, leftcol); var nexttype = this.getEleTypeByRc(uprow, leftcol);
...@@ -814,10 +872,65 @@ ...@@ -814,10 +872,65 @@
} }
} }
} }
if (rightcol1 < MapData.col) {
var nexttype = this.getEleTypeByRc(relerow, rightcol1);
if (nexttype == checktype) {
attiondata = [relerow + "_" + rightcol1, relerow + "_" + rightcol];
break;
}
}
if (leftcol1 > -1) {
var nexttype = this.getEleTypeByRc(relerow, leftcol1);
if (nexttype == checktype) {
attiondata = [relerow + "_" + leftcol1, relerow + "_" + leftcol];
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];
break;
}
}
var rjianc = jianc + 1;
if (rjianc < MapData.col) {
var nexttype = this.getEleTypeByRc(jianr, rjianc);
if (nexttype == checktype) {
attiondata = [jianr + "_" + rjianc, jianr + "_" + jianc];
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];
break;
}
}
var djianr = jianr + 1;
if (djianr < MapData.row) {
var nexttype = this.getEleTypeByRc(djianr, jianc);
if (nexttype == checktype) {
attiondata = [djianr + "_" + jianc, jianr + "_" + jianc];
break;
}
}
} }
} }
} }
console.log("相邻检测--------------", attiondata);
return attiondata; return attiondata;
}; };
GameView.prototype.checkEliminate = function () { GameView.prototype.checkEliminate = function () {
...@@ -833,6 +946,32 @@ ...@@ -833,6 +946,32 @@
} }
} }
}; };
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) { GameView.prototype.getEliminateRow = function (x, y) {
var checktype = this.getEleTypeByRc(x, y); var checktype = this.getEleTypeByRc(x, y);
var relearr = new Array(); var relearr = new Array();
......
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -5,8 +5,9 @@ ...@@ -5,8 +5,9 @@
import { props } from "../props"; import { props } from "../props";
import { playSound, createSvga,getTextureByName } from "./utils"; import { playSound, createSvga,getTextureByName } from "./utils";
import ObjectPool = engine.ObjectPool; import ObjectPool = engine.ObjectPool;
import MapData, { GameEvent } from "./MapData"; import MapData, { GameEvent, ElementType } from "./MapData";
import Element from "./ele/Element"; import Element from "./ele/Element";
import CountDownGroup from "../../../recycling/src/game/views/CountDownGroup";
...@@ -48,6 +49,8 @@ export default class GameView extends engine.Container { ...@@ -48,6 +49,8 @@ export default class GameView extends engine.Container {
canation = true; canation = true;
setup() { setup() {
MapData.initPoolEle();
this.selectimg = new engine.Image(getTextureByName("选中框")); this.selectimg = new engine.Image(getTextureByName("选中框"));
this.selectimg.mouseEnabled = false; this.selectimg.mouseEnabled = false;
...@@ -59,7 +62,7 @@ export default class GameView extends engine.Container { ...@@ -59,7 +62,7 @@ export default class GameView extends engine.Container {
this.homeimg.x = this.homex; this.homeimg.x = this.homex;
this.homeimg.y = -40; this.homeimg.y = -40;
this.homeimg.stop(); this.homeimg.stop();
console.log("房子动画",this.homeimg); // console.log("房子动画",this.homeimg);
this.container = new engine.Container(); this.container = new engine.Container();
this.addChild(this.container); this.addChild(this.container);
...@@ -104,7 +107,6 @@ export default class GameView extends engine.Container { ...@@ -104,7 +107,6 @@ export default class GameView extends engine.Container {
} }
playComp(){ playComp(){
console.log("动画播放完毕");
this.homeimg.stop(1); this.homeimg.stop(1);
} }
...@@ -135,7 +137,7 @@ export default class GameView extends engine.Container { ...@@ -135,7 +137,7 @@ export default class GameView extends engine.Container {
initContainer(){ initContainer(){
this.lattices = {}; this.lattices = {};
let testdata = [ let testdata = [
[1,2,5,3,3], [1,2,5,3,4],
[3,1,4,4,5], [3,1,4,4,5],
[2,5,3,5,1], [2,5,3,5,1],
[5,4,1,2,3], [5,4,1,2,3],
...@@ -318,11 +320,12 @@ export default class GameView extends engine.Container { ...@@ -318,11 +320,12 @@ export default class GameView extends engine.Container {
let ielitype = ielidata.type; let ielitype = ielidata.type;
let ieliname = this.lattices[ielidxname]; let ieliname = this.lattices[ielidxname];
let ielinode = this.container.getChildByName(ieliname); let ielinode:Element = this.container.getChildByName(ieliname);
let ielix = ielinode.x; let ielix = ielinode.x;
let ieliy = ielinode.y; let ieliy = ielinode.y;
let ietype = ielinode.type;
this.container.removeChild(ielinode); this.container.removeChild(ielinode);
MapData.recoverEle(ielinode); MapData.recoverEle(ielinode,ietype);
this.lattices[ielidxname] = "empty"; this.lattices[ielidxname] = "empty";
//元素层消除,动画层添加 //元素层消除,动画层添加
...@@ -332,14 +335,14 @@ export default class GameView extends engine.Container { ...@@ -332,14 +335,14 @@ export default class GameView extends engine.Container {
await new Promise(res=>{ await new Promise(res=>{
setTimeout(function(){ setTimeout(function(){
res(); res();
},800); },400);
}) })
this.fall(); this.fall();
await new Promise(res1=>{ await new Promise(res1=>{
setTimeout(function(){ setTimeout(function(){
res1(); res1();
},550) },400)
}) })
this.homeimg.play() this.homeimg.play()
} }
...@@ -477,7 +480,6 @@ export default class GameView extends engine.Container { ...@@ -477,7 +480,6 @@ export default class GameView extends engine.Container {
let attiondata = this.attionEliminate(); let attiondata = this.attionEliminate();
if(attiondata&&attiondata.length==2){ if(attiondata&&attiondata.length==2){
this.ination = true; this.ination = true;
console.log("可以提示");
this.attiondata = [attiondata[0],attiondata[1]]; this.attiondata = [attiondata[0],attiondata[1]];
let atname1 = this.lattices[attiondata[0]]; let atname1 = this.lattices[attiondata[0]];
let atname2 = this.lattices[attiondata[1]]; let atname2 = this.lattices[attiondata[1]];
...@@ -522,8 +524,9 @@ export default class GameView extends engine.Container { ...@@ -522,8 +524,9 @@ export default class GameView extends engine.Container {
//死图调整 //死图调整
solveDieMap(){ solveDieMap(){
this.changeEnable(false); this.changeEnable(false);
console.error("死图调整"); // console.error("死图调整");
console.log(this.lattices); // console.log(this.lattices);
// return false;
let elearr = new Array(); let elearr = new Array();
for(let key in this.lattices){ for(let key in this.lattices){
let keyval = this.lattices[key]; let keyval = this.lattices[key];
...@@ -539,7 +542,7 @@ export default class GameView extends engine.Container { ...@@ -539,7 +542,7 @@ export default class GameView extends engine.Container {
console.error("可以复活了,转移位置"); console.error("可以复活了,转移位置");
this.changeToFuHuoPos(); this.changeToFuHuoPos();
}else{ }else{
console.error("依然死亡,寻求复活"); // console.error("依然死亡,寻求复活");
return this.solveDieMap(); return this.solveDieMap();
} }
} }
...@@ -558,9 +561,14 @@ export default class GameView extends engine.Container { ...@@ -558,9 +561,14 @@ export default class GameView extends engine.Container {
this.setLatticeEleRc(key); this.setLatticeEleRc(key);
} }
await Promise.all(prolist) await Promise.all(prolist)
console.error("死亡转移完毕");
this.checkEliminate();
if(this.eliminateArr.length>0){
this.eliminate();
}else{
this.changeEnable(true); this.changeEnable(true);
} }
}
//相邻检测 //相邻检测
attionEliminate(){ attionEliminate(){
...@@ -576,10 +584,10 @@ export default class GameView extends engine.Container { ...@@ -576,10 +584,10 @@ export default class GameView extends engine.Container {
let edatacol = this.getEliminateCol(r,c); let edatacol = this.getEliminateCol(r,c);
if(edatarow.length>2||edatacol.length>2){ if(edatarow.length>2||edatacol.length>2){
console.error("啥情况,检查----------------"); // console.error("啥情况,检查----------------");
} }
if(edatarow.length==2){ if(edatarow.length==2){
console.log("横向查找",edatarow,checktype); // console.log("横向查找",edatarow,checktype);
let releidx1 = edatarow[0]; let releidx1 = edatarow[0];
let releidx2 = edatarow[1]; let releidx2 = edatarow[1];
...@@ -592,6 +600,9 @@ export default class GameView extends engine.Container { ...@@ -592,6 +600,9 @@ export default class GameView extends engine.Container {
let rightcol = relecol+1; let rightcol = relecol+1;
let leftcol = relecol-1; let leftcol = relecol-1;
let uprow1 = relerow2-2;
let downrow1 = relerow1+2;
if(downrow<MapData.row){ if(downrow<MapData.row){
if(rightcol<MapData.col){ if(rightcol<MapData.col){
let nexttype = this.getEleTypeByRc(downrow,rightcol); let nexttype = this.getEleTypeByRc(downrow,rightcol);
...@@ -626,6 +637,20 @@ export default class GameView extends engine.Container { ...@@ -626,6 +637,20 @@ export default class GameView extends engine.Container {
} }
} }
} }
if(uprow1>-1){
let nexttype = this.getEleTypeByRc(uprow1,relecol);
if(nexttype==checktype){
attiondata = [uprow+"_"+relecol,uprow1+"_"+relecol];
break;
}
}
if(downrow1<MapData.row){
let nexttype = this.getEleTypeByRc(downrow1,relecol);
if(nexttype==checktype){
attiondata = [downrow1+"_"+relecol,downrow+"_"+relecol];
break;
}
}
// for(let ir=0;ir<mayeleidxs.length;ir++){ // for(let ir=0;ir<mayeleidxs.length;ir++){
// let iridx = mayeleidxs[ir]; // let iridx = mayeleidxs[ir];
// let irename = this.lattices[iridx]; // let irename = this.lattices[iridx];
...@@ -642,7 +667,7 @@ export default class GameView extends engine.Container { ...@@ -642,7 +667,7 @@ export default class GameView extends engine.Container {
// } // }
} }
if(edatacol.length==2){ if(edatacol.length==2){
console.log("竖向查找",edatacol,checktype); // console.log("竖向查找",edatacol,checktype);
let releidx1 = edatacol[0]; let releidx1 = edatacol[0];
let releidx2 = edatacol[1]; let releidx2 = edatacol[1];
...@@ -655,6 +680,9 @@ export default class GameView extends engine.Container { ...@@ -655,6 +680,9 @@ export default class GameView extends engine.Container {
let uprow = relerow-1; let uprow = relerow-1;
let downrow = relerow+1; let downrow = relerow+1;
let rightcol1 = relecol1+2;
let leftcol1 = relecol2-2;
if(leftcol>-1){ if(leftcol>-1){
if(uprow>-1){ if(uprow>-1){
let nexttype = this.getEleTypeByRc(uprow,leftcol); let nexttype = this.getEleTypeByRc(uprow,leftcol);
...@@ -687,12 +715,75 @@ export default class GameView extends engine.Container { ...@@ -687,12 +715,75 @@ export default class GameView extends engine.Container {
} }
} }
} }
if(rightcol1<MapData.col){
let nexttype = this.getEleTypeByRc(relerow,rightcol1);
if(nexttype==checktype){
attiondata = [relerow+"_"+rightcol1,relerow+"_"+rightcol];
break;
}
}
if(leftcol1>-1){
let nexttype = this.getEleTypeByRc(relerow,leftcol1);
if(nexttype==checktype){
attiondata = [relerow+"_"+leftcol1,relerow+"_"+leftcol];
break;
}
}
// console.log("竖向检查啦啦啦",relerow,relecol1,relecol2); // 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];
break;
}
}
let rjianc = jianc+1;
if(rjianc<MapData.col){
let nexttype = this.getEleTypeByRc(jianr,rjianc);
if(nexttype==checktype){
attiondata = [jianr+"_"+rjianc,jianr+"_"+jianc];
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];
break;
}
}
let djianr = jianr+1;
if(djianr<MapData.row){
let nexttype = this.getEleTypeByRc(djianr,jianc);
if(nexttype==checktype){
attiondata = [djianr+"_"+jianc,jianr+"_"+jianc];
break;
}
}
}
} }
} }
console.log("相邻检测--------------",attiondata); // console.log("相邻检测--------------",attiondata);
return attiondata; return attiondata;
} }
//检测消除 //检测消除
...@@ -710,6 +801,38 @@ export default class GameView extends engine.Container { ...@@ -710,6 +801,38 @@ export default class GameView extends engine.Container {
} }
} }
//两边一样,中间插入,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){ getEliminateRow(x,y){
let checktype = this.getEleTypeByRc(x,y); let checktype = this.getEleTypeByRc(x,y);
......
import Element from "./ele/Element"; import Element from "./ele/Element";
import { getTextureByName } from "./utils";
export enum ElementType{ export enum ElementType{
btiger = 1, btiger = 1,
gtiger, gtiger,
...@@ -9,7 +9,6 @@ export enum ElementType{ ...@@ -9,7 +9,6 @@ export enum ElementType{
} }
export enum GameEvent{ export enum GameEvent{
SelectEle = "SelectEle", SelectEle = "SelectEle",
} }
export default class MapData{ export default class MapData{
//单格大小 //单格大小
...@@ -25,9 +24,16 @@ export default class MapData{ ...@@ -25,9 +24,16 @@ export default class MapData{
}; };
static eleidx = 1; static eleidx = 1;
static elePool = []; static elePool = {};
static anispeed = 860; static anispeed = 860;
static btigerTex:engine.Texture;
static gtigerTex:engine.Texture;
static monkeyTex:engine.Texture;
static birdTex:engine.Texture;
static koalaTex:engine.Texture;
static getRy(r){ static getRy(r){
return this.paddingb+r*(this.itemsize+this.paddingi); return this.paddingb+r*(this.itemsize+this.paddingi);
} }
...@@ -69,6 +75,30 @@ export default class MapData{ ...@@ -69,6 +75,30 @@ export default class MapData{
} }
return ename; return ename;
} }
static getEtypeImgTex(type:ElementType){
let etex:engine.Texture;
switch(type){
case ElementType.btiger:
etex = this.btigerTex||getTextureByName("白虎");
break;
case ElementType.gtiger:
etex = this.gtigerTex||getTextureByName("雌虎");
break;
case ElementType.monkey:
etex = this.monkeyTex||getTextureByName("猴子");
break;
case ElementType.bird:
etex = this.birdTex||getTextureByName("鸟");
break;
case ElementType.koala:
etex = this.koalaTex||getTextureByName("树熊");
break;
default:
console.error("未定义元素类型");
break;
}
return etex;
}
static getRandEtype(){ static getRandEtype(){
let eletypeArr = [ElementType.btiger,ElementType.gtiger,ElementType.monkey,ElementType.bird,ElementType.koala]; let eletypeArr = [ElementType.btiger,ElementType.gtiger,ElementType.monkey,ElementType.bird,ElementType.koala];
...@@ -76,22 +106,43 @@ export default class MapData{ ...@@ -76,22 +106,43 @@ export default class MapData{
return etype; return etype;
} }
static initPoolEle(){
console.error("初始化元素池");
let eletypes = [ElementType.btiger,ElementType.gtiger,ElementType.monkey,ElementType.bird,ElementType.koala];
for(let i=0;i<eletypes.length;i++){
let itype = eletypes[i];
this.elePool[itype] = new Array();
for(let a=0;a<10;a++){
let iele = new Element();
iele.eimage.texture = this.getEtypeImgTex(itype);
this.elePool[itype].push(iele);
}
}
}
static getOneEle(type:ElementType):Element{ static getOneEle(type:ElementType):Element{
let ele:Element; let ele:Element;
if(this.elePool.length>0){ if(this.elePool[type]){
ele = this.elePool.shift(); if(this.elePool[type].length>0){
ele = this.elePool[type].shift();
}
}else{ }else{
this.elePool[type] = new Array();
}
if(!ele){
console.error("创建了新的了");
ele = new Element(); ele = new Element();
ele.eimage.texture = getTextureByName(this.getEtypeImgName(type));
} }
ele.name = "ele_"+this.eleidx; ele.name = "ele_"+this.eleidx;
this.eleidx += 1; this.eleidx += 1;
ele.init(type) ele.init(type)
return ele; return ele;
} }
static recoverEle(ele:Element){ static recoverEle(ele:Element,type:ElementType){
this.elePool.push(ele); this.elePool[type].push(ele);
} }
static getDistance(p1,p2){ static getDistance(p1,p2){
let p1x = p1[0]; let p1x = p1[0];
......
...@@ -31,7 +31,7 @@ export default class Element extends engine.Container{ ...@@ -31,7 +31,7 @@ export default class Element extends engine.Container{
this.type = type; this.type = type;
let ename = MapData.getEtypeImgName(type); let ename = MapData.getEtypeImgName(type);
this.eimage.texture = getTextureByName(ename); // this.eimage.texture = MapData.getTextureType(type);
let imgwid = this.eimage.texture.width; let imgwid = this.eimage.texture.width;
let imghei = this.eimage.texture.height; let imghei = this.eimage.texture.height;
...@@ -102,7 +102,7 @@ export default class Element extends engine.Container{ ...@@ -102,7 +102,7 @@ export default class Element extends engine.Container{
.call(()=>{ .call(()=>{
let nodeparent:engine.Container = this.parent; let nodeparent:engine.Container = this.parent;
nodeparent&&nodeparent.removeChild(this); nodeparent&&nodeparent.removeChild(this);
MapData.recoverEle(this); MapData.recoverEle(this,this.type);
}) })
}) })
} }
......
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