Commit e87cb514 authored by lujinlei's avatar lujinlei

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

parents 13f91edf 75054211
File added
...@@ -89,3 +89,4 @@ typings/ ...@@ -89,3 +89,4 @@ typings/
# DynamoDB Local files # DynamoDB Local files
.dynamodb/ .dynamodb/
.DS_Store
\ No newline at end of file
{
"liveServer.settings.port": 5501
}
\ No newline at end of file
File added
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
{
"name": "拆礼盒",
"desc": "拆礼盒模块",
"props": {
"initX": {
"alias": "游戏场景初始X位置",
"type": "number",
"default": 0
},
"initY": {
"alias": "游戏场景初始Y位置",
"type": "number",
"default": 0
},
"gameStageWidth": {
"alias": "游戏场景宽度",
"type": "number",
"default": 534
},
"gameStageHeight": {
"alias": "游戏场景高度",
"type": "number",
"default": 408
}
},
"assets": [
{
"name": "底座",
"url": "//yun.duiba.com.cn/aurora/assets/d6ed718f0d236febaa4d1331950e5a190f225cb5.png",
"uuid": "7a0f8b48-449c-46d9-bd80-64455a30e641",
"ext": ".png"
},
{
"name": "点缀",
"url": "//yun.duiba.com.cn/aurora/assets/e08f680bbd26c4dcc47fd67ee2e145c46d6fcd1a.png",
"uuid": "c7426dc4-d631-4947-accc-015666277208",
"ext": ".png"
},
{
"name": "初始礼盒",
"url": "//yun.duiba.com.cn/aurora/assets/b9bb4e52c3734025fc96a92cb574c92209927b61.svga",
"uuid": "947cb448-1992-49f1-a9ed-e359b944953a",
"ext": ".svga"
},
{
"name": "拆礼盒",
"url": "//yun.duiba.com.cn/aurora/assets/8e86f8696710de414f0f36dc330db6e4bd0683d6.svga",
"uuid": "d9222991-064c-4816-85ee-6964ba78fbd0",
"ext": ".svga"
}
],
"events": {
"in": {
"open-gift-game-init": {
"alias": "重置"
},
"open-gift-game-start": {
"alias": "开始",
"data": {
"prize": true
}
}
},
"out": {
"open-gift-game-end": {
"alias": "动画完毕",
"data": null
}
}
},
"id": "open-gift",
"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['open-gift'] = factory(global.tslib));\n}(this, (function (tslib) { 'use strict';\n\n\tvar props = {};\n\tfunction prepareProps() {\n\t var metaProps = getProps();\n\t engine.injectProp(props, metaProps);\n\t}\n\tfunction injectProps(p) {\n\t engine.injectProp(props, p);\n\t}\n\t//# sourceMappingURL=props.js.map\n\n\tfunction getTexture(uuid) {\n\t return engine.Texture.from(getAssetByUUID(uuid).uuid);\n\t}\n\tfunction getTextureByName(name) {\n\t return getTexture(engine.getAssetByName(name).uuid);\n\t}\n\tfunction createSvga(name, anchorName) {\n\t var inst = new svga.Svga();\n\t inst.source = 'asset://' + engine.getAssetByName(name).uuid;\n\t return inst;\n\t}\n\t//# sourceMappingURL=utils.js.map\n\n\tvar GameView = (function (_super) {\n\t tslib.__extends(GameView, _super);\n\t function GameView() {\n\t var _this = _super.call(this) || this;\n\t _this.once(engine.Event.ADDED_TO_STAGE, _this.setup, _this);\n\t return _this;\n\t }\n\t GameView.prototype.setup = function () {\n\t if (this._hasSetup) {\n\t return;\n\t }\n\t this._hasSetup = true;\n\t this.NpcBg = new engine.Container();\n\t this.NpcBg.x = props.initX;\n\t this.NpcBg.y = props.initY;\n\t this.addChild(this.NpcBg);\n\t this.bottomCircle = new engine.Sprite(getTextureByName('底座'));\n\t this.bottomCircle.x = 17;\n\t this.bottomCircle.y = 305;\n\t this.loveDot = new engine.Sprite(getTextureByName('点缀'));\n\t this.loveDot.x = 0;\n\t this.loveDot.y = 6;\n\t this.giftboxSvga = createSvga('初始礼盒');\n\t this.giftboxSvga.x = 105;\n\t this.giftboxSvga.y = 37;\n\t this.giftAfterSvga = createSvga(\"拆礼盒\");\n\t this.giftAfterSvga.x = 105;\n\t this.giftAfterSvga.y = 0;\n\t this.giftAfterSvga.visible = false;\n\t this.NpcBg.addChild(this.bottomCircle);\n\t this.NpcBg.addChild(this.giftboxSvga);\n\t this.NpcBg.addChild(this.giftAfterSvga);\n\t this.NpcBg.addChild(this.loveDot);\n\t this.giftboxSvga.play(false, true);\n\t };\n\t GameView.prototype.reset = function () {\n\t this.giftboxSvga.visible = true;\n\t this.giftAfterSvga.visible = false;\n\t };\n\t GameView.prototype.start = function () {\n\t this.giftAfterSvga.visible = true;\n\t this.giftboxSvga.visible = false;\n\t this.giftAfterSvga.play(false, false);\n\t this.giftAfterSvga.once(engine.Event.END_FRAME, function () {\n\t engine.globalEvent.dispatchEvent('open-gift-game-end');\n\t }, this);\n\t };\n\t GameView.prototype.resume = function () {\n\t this.reset();\n\t this.start();\n\t };\n\t return GameView;\n\t}(engine.Container));\n\n\tvar GameWrapper = (function (_super) {\n\t tslib.__extends(GameWrapper, _super);\n\t function GameWrapper() {\n\t var _this = _super.call(this) || this;\n\t engine.globalEvent.addEventListener('open-gift-game-init', _this.reset, _this);\n\t engine.globalEvent.addEventListener('open-gift-game-start', _this.start, _this);\n\t var gameView = _this._gameView = new GameView();\n\t _this.addChild(gameView);\n\t return _this;\n\t }\n\t GameWrapper.prototype.reset = function (event) {\n\t injectProps(event.data);\n\t this._gameView.visible = true;\n\t this._gameView.reset();\n\t };\n\t GameWrapper.prototype.start = function (event) {\n\t console.log('监听开始');\n\t injectProps(event.data);\n\t this._gameView.start();\n\t };\n\t GameWrapper.prototype.clear = function () {\n\t this._gameView.visible = false;\n\t };\n\t return GameWrapper;\n\t}(engine.Container));\n\t//# sourceMappingURL=GameWrapper.js.map\n\n\tfunction index (props) {\n\t prepareProps();\n\t injectProps(props);\n\t var instance = new GameWrapper();\n\t return instance;\n\t}\n\t//# sourceMappingURL=index.js.map\n\n\treturn index;\n\n})));\n"
}
{
"name": "拼图",
"desc": "拼图模块1.0",
"props": {
"MAX_COL": {
"alias": "图片分成几列",
"type": "number",
"default": 3
},
"MAX_ROW": {
"alias": "图片分成几行",
"type": "number",
"default": 4
},
"W": {
"alias": "图片的宽度",
"type": "number",
"default": 618
},
"H": {
"alias": "图片的高度",
"type": "number",
"default": 827
},
"OFFSET_X": {
"alias": "OFFSET_X",
"type": "number",
"default": 0
},
"OFFSET_Y": {
"alias": "OFFSET_Y",
"type": "number",
"default": 0
},
"GAP": {
"alias": "图片间隙",
"type": "number",
"default": 0
},
"GAME_TIME": {
"alias": "游戏时间",
"type": "number",
"default": 50
}
},
"assets": [
{
"name": "遮罩",
"url": "//yun.duiba.com.cn/aurora/assets/5b3e30496b2d9fdafb0cf3835fd6704ce10e45b4.png",
"uuid": "888",
"ext": ".png"
}
],
"events": {
"in": {
"pictures-start": {
"alias": "开始",
"data": {
"picUrl": "图片路径",
"blockUrl": "blockUrl"
}
},
"pictures-stop": {
"alias": "停止"
}
},
"out": {
"pictures-time-update": {
"alias": "倒计时更新",
"data": {
"time": "剩余时间"
}
},
"pictures-game-fail": {
"alias": "游戏结束",
"data": {
"reason": "结束原因(1:时间到了)"
}
},
"pictures-game-success": {
"alias": "游戏成功",
"data": {
"time": "游戏消耗时间"
}
}
}
},
"id": "pictures",
"code": "\"use strict\";var tslib=require(\"tslib\"),props={};function prepareProps(){var t=getProps();engine.injectProp(props,t)}function injectProps(t){engine.injectProp(props,t)}var MAX_COL,MAX_ROW,W,H,GAP,GAME_TIME,w,h,picMap={},posMap={},qietu=function(n,r,o,a){if(picMap[r]){for(var t=0,e=picMap[r];t<e.length;t++){var i=e[t];n.addChild(i)}return[picMap[r],posMap[r]]}for(var p=props.W,h=props.H,c=props.GAP,d=[],u=[],s=function(s){for(var t=function(e){var i=engine.Sprite.fromImage(r);d.push(i),i.scaleX=1/o,i.scaleY=1/a,n.addChild(i),i.x=e*(p/o+c),i.y=s*(h/a+c),u.push([i.x,i.y]),i.addEventListener(engine.Event.COMPLETE,function(){var t=new Float32Array([e/o,s/a,(e+1)/o,s/a,(e+1)/o,(s+1)/a,e/o,(s+1)/a]);i.uvs=t})},e=0;e<o;e++)t(e)},g=0;g<a;g++)s(g);return picMap[r]=d.concat([]),posMap[r]=u.concat([]),[d,u]};function getIndexFromRC(t,e,i){return t*i+e}function getRandomArray(t){t.sort(function(){return.5-Math.random()})}var GameView=function(e){function t(){var t=e.call(this)||this;return t._timeCounter=0,t.listenStageOn=1,t.once(engine.Event.ADDED_TO_STAGE,t.setup,t),t}return tslib.__extends(t,e),t.prototype.start=function(){var t=this;if(this.guideHole||(this.guideHole=new engine.Image,this.guideHole.source=\"asset://\"+props.blockUrl,this.guideHole.mouseChildren=this.guideHole.mouseEnabled=!1),this.pictures)for(var e=0,i=this.pictures;e<i.length;e++){var s=i[e];s&&s.parent&&s.parent.removeChild(s)}console.log(\"on start\"),engine.globalEvent.dispatchEvent(\"pictures-time-update\",{second:this.getSecond()});var n=qietu(this.picturesWrapper,props.picUrl,MAX_COL,MAX_ROW);this.picturesWrapper.addChild(this.guideHole),console.log(this.picturesWrapper),this.pictures=n[0],this.rightList=this.pictures.concat([]);var r=n[1];getRandomArray(this.pictures);var o,a=0;for(o=this.pictures.length;a<o;a++){this.dragPic=this.pictures[a],this.pictures[a].addEventListener(engine.MouseEvent.MOUSE_DOWN,this.onDown,this);var p=r[a],h=p[0],c=p[1];this.dragPic.x=h,this.dragPic.y=c}this._timer=setInterval(function(){t.onTimer()},10)},t.prototype.onTimer=function(){GAME_TIME-=.01,(GAME_TIME=(GAME_TIME=this.afterPointTwo(GAME_TIME)).toFixed(2))<10&&(GAME_TIME=\"0\"+GAME_TIME),engine.globalEvent.dispatchEvent(\"pictures-time-update\",{second:this.getSecond()}),0==this.getSecond()&&(this.stop(),engine.globalEvent.dispatchEvent(\"pictures-game-fail\",{reason:1}))},t.prototype.afterPointTwo=function(t){var e=parseFloat(t);if(!isNaN(e))return e=Math.round(100*e)/100},t.prototype.getSecond=function(){return GAME_TIME},t.prototype.stop=function(){GAME_TIME=props.GAME_TIME,clearInterval(this._timer)},t.prototype.createRects=function(){},t.prototype.setup=function(){MAX_COL=props.MAX_COL,MAX_ROW=props.MAX_ROW,GAME_TIME=props.GAME_TIME,W=props.W,H=props.H,GAP=props.GAP,w=W/MAX_COL,h=H/MAX_ROW,console.log(\"onSteup\",props);var t=new engine.Sprite;this.picturesWrapper=t,this.addChild(t)},t.prototype.onDown=function(t){this.dragPic=t.target,this.picturesWrapper.addChild(this.dragPic),this.localPicX=t.localX/MAX_COL,this.localPicY=t.localY/MAX_ROW,this.distanceX=this.dragPic.x,this.distanceY=this.dragPic.y,this.indexJ=Math.floor(this.distanceX/(w+GAP)),this.indexI=Math.floor(this.distanceY/(h+GAP)),this.index=this.indexI*MAX_COL+this.indexJ,this.centerX=Math.floor(t.clientX/w)*w+w/2,this.centerY=Math.floor(t.clientY/h)*h+h/2,this.stage.addEventListener(engine.MouseEvent.MOUSE_MOVE,this.onMove,this),this.stage.addEventListener(engine.MouseEvent.MOUSE_UP,this.stageOnUp,this)},t.prototype.stageOnUp=function(t){this.stage.removeEventListener(engine.MouseEvent.MOUSE_MOVE,this.onMove,this),this.stage.removeEventListener(engine.MouseEvent.MOUSE_UP,this.stageOnUp,this),(this.centerY<0||this.centerX<0)&&(this.dragPic.x=this.distanceX,this.dragPic.y=this.distanceY),this.picturesWrapper.addChild(this.guideHole);var e=Math.floor(this.centerX/(w+GAP)),i=Math.floor(this.centerY/(h+GAP));if(e<MAX_COL&&i<MAX_ROW){var s=getIndexFromRC(i,e,MAX_COL),n=this.pictures[s],r=n.x,o=n.y;n.x=this.distanceX,n.y=this.distanceY,this.dragPic.x=r,this.dragPic.y=o;var a=this.pictures.indexOf(n),p=this.pictures.indexOf(this.dragPic);this.pictures[a]=this.dragPic,this.pictures[p]=n,p===a&&(this.dragPic.x=this.distanceX,this.dragPic.y=this.distanceY);for(var c=!0,d=0;d<this.rightList.length;d++)if(this.rightList[d]!=this.pictures[d]){c=!1;break}c&&this.onSuccess()}else this.dragPic.x=this.distanceX,this.dragPic.y=this.distanceY},t.prototype.onSuccess=function(){console.log(\"拼图成功!\"),engine.globalEvent.dispatchEvent(\"pictures-game-success\",{time:this._timeCounter}),this.stop()},t.prototype.onMove=function(t){this.dragPic.x=t.stageX-this.localPicX-(750-props.W)/2,this.dragPic.y=t.stageY-this.localPicY-(this.stage.height-props.H)/2,console.log(\"fuck on this.stage.height\",this.stage.height),this.centerX=this.dragPic.x+w/2,this.centerY=this.dragPic.y+h/2},t}(engine.Container),GameWrapper=function(i){function t(){var t=i.call(this)||this;engine.globalEvent.addEventListener(\"pictures-start\",t.start,t),engine.globalEvent.addEventListener(\"pictures-stop\",t.stop,t);var e=t._gameView=new GameView;return t.addChild(e),t}return tslib.__extends(t,i),t.prototype.start=function(t){injectProps(t.data),this._gameView.start()},t.prototype.stop=function(t){this._gameView.stop()},t}(engine.Container);function index(t){return prepareProps(),injectProps(t),new GameWrapper}module.exports=index;\n"
}
This diff is collapsed.
This diff is collapsed.
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
"complete" "complete"
], ],
"id": "wait", "id": "wait",
"script": "var duration = engine.findVariable('duration', args, props);\nsetTimeout(function () {\n next('complete');\n}, duration);\n", "script": "var duration = engine.findVariable('duration', args, props);\nsetTimeout(function () {\n next('complete', args);\n}, duration);\n",
"group": "base", "group": "base",
"type": "builtin" "type": "builtin"
} }
{
"name": "选择图片",
"desc": "选择一个图片文件",
"props": {},
"output": [
"success"
],
"id": "pick-image",
"script": "pick(function (imgData) {\n next('success', imgData);\n});\nfunction getExif(img, callback) {\n EXIF.getData(img, function () {\n var allMetaData = EXIF.getAllTags(this);\n callback(allMetaData);\n });\n}\nfunction pick(callback) {\n var fileInput = document.createElement(\"input\");\n fileInput.type = \"file\";\n fileInput.accept = \"image/*\";\n fileInput.style.display = \"none\";\n document.body.insertBefore(fileInput, document.body.firstChild);\n fileInput.addEventListener(\"change\", function (evt) {\n var mime = { \"png\": \"image/png\", \"jpg\": \"image/jpeg\", \"jpeg\": \"image/jpeg\", \"bmp\": \"image/bmp\" };\n var file = evt.target.files[0];\n var type = file.type;\n if (!type) {\n type = mime[file.name.match(/\\.([^\\.]+)$/i)[1]];\n }\n var fileReader = new FileReader();\n fileReader.onload = function () {\n getExif(file, function (exif) {\n var orientation = -1;\n if (exif) {\n orientation = exif[\"Orientation\"];\n }\n var image = new Image();\n image.onload = function () {\n var canvas = document.createElement(\"canvas\");\n var ctx = canvas.getContext(\"2d\");\n canvas.width = image.width;\n canvas.height = image.height;\n if (orientation > 4) {\n canvas.width = image.height;\n canvas.height = image.width;\n }\n ctx.clearRect(0, 0, canvas.width, canvas.height);\n switch (orientation) {\n case 2:\n ctx.translate(canvas.width, 0);\n ctx.scale(-1, 1);\n break;\n case 3:\n ctx.translate(canvas.width, canvas.height);\n ctx.rotate(Math.PI);\n break;\n case 4:\n ctx.translate(0, canvas.height);\n ctx.scale(1, -1);\n break;\n case 5:\n ctx.rotate(0.5 * Math.PI);\n ctx.scale(1, -1);\n break;\n case 6:\n ctx.rotate(0.5 * Math.PI);\n ctx.translate(0, -image.height);\n break;\n case 7:\n ctx.rotate(0.5 * Math.PI);\n ctx.translate(canvas.width, -canvas.height);\n ctx.scale(-1, 1);\n break;\n case 8:\n ctx.rotate(-0.5 * Math.PI);\n ctx.translate(-canvas.height, 0);\n break;\n default:\n ctx.transform(1, 0, 0, 1, 0, 0);\n }\n ctx.drawImage(image, 0, 0);\n var imagetype = \"png\";\n if (orientation !== -1) {\n imagetype = \"jpeg\";\n }\n var resultURL = \"\";\n if (imagetype === \"jpg\" || imagetype === \"jpeg\") {\n resultURL = canvas.toDataURL(\"image/\" + imagetype);\n }\n else {\n resultURL = canvas.toDataURL(\"image/\" + imagetype);\n }\n callback(resultURL);\n image.parentNode.removeChild(image);\n fileInput.parentNode.removeChild(fileInput);\n };\n image.src = fileReader.result;\n image.style.display = \"none\";\n document.body.appendChild(image);\n fileInput.value = \"\";\n });\n };\n fileReader.readAsDataURL(file);\n }, false);\n fileInput.click();\n}\n",
"group": "other",
"type": "builtin"
}
{
"name": "缩放图片",
"desc": "缩放图片",
"props": {
"width": {
"type": "number",
"alias": "目标宽度"
},
"height": {
"type": "number",
"alias": "目标高度"
},
"cutType": {
"type": "enum",
"enum": [
"inner",
"outer"
],
"alias": "裁剪类型",
"default": "inner"
},
"type": {
"type": "enum",
"enum": [
"png",
"jpeg"
],
"alias": "输出类型",
"default": "png"
},
"quality": {
"type": "number",
"alias": "图片质量",
"default": 0.7
}
},
"output": [
"success"
],
"id": "resize-image",
"script": "var width = engine.findVariable('width', args, props);\nvar height = engine.findVariable('height', args, props);\nvar cutType = engine.findVariable('cutType', args, props);\nvar type = engine.findVariable('type', args, props);\nvar quality = engine.findVariable('quality', args, props);\nvar img = args;\nif (typeof args === 'string') {\n img = new Image();\n img.onload = function () {\n deal();\n };\n img.onerror = function (e) {\n console.log(e);\n };\n img.src = args;\n}\nelse {\n deal();\n}\nfunction deal() {\n var m = cutType === 'inner' ? Math.min : Math.max;\n var r = m(width / img.width, height / img.height);\n var imgWidth = img.width * r;\n var imgHeight = img.height * r;\n var x = (width - imgWidth) / 2;\n var y = (height - imgHeight) / 2;\n var canvas = document.createElement('canvas');\n canvas.width = width;\n canvas.height = height;\n var ctx = canvas.getContext('2d');\n ctx.translate(x, y);\n ctx.scale(r, r);\n ctx.drawImage(img, 0, 0);\n var dataUrl = canvas.toDataURL('image/' + type, quality);\n next('success', dataUrl);\n}\n",
"group": "other",
"type": "builtin"
}
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
"showLoading": { "showLoading": {
"alias": "展示加载视图", "alias": "展示加载视图",
"type": "boolean", "type": "boolean",
"default": true "default": false
}, },
"center": { "center": {
"alias": "是否居中展示", "alias": "是否居中展示",
...@@ -58,7 +58,7 @@ ...@@ -58,7 +58,7 @@
"complete" "complete"
], ],
"id": "push-dialog", "id": "push-dialog",
"script": "var effect = engine.findVariable('effect', args, props);\nvar effectParams = engine.findVariable('effectParams', args, props);\nvar showLoading = engine.findVariable('showLoading', args, props);\nif (!props.viewName) {\n console.log('没有设置视图名');\n next('exception', '没有设置视图名');\n}\nelse {\n var gameStage_1 = engine.gameStage;\n gameStage_1.instantiateView(props.viewName, true, showLoading).then(function (view) {\n if (view) {\n var options = {\n effect: effect,\n effectParams: effectParams,\n center: props.center,\n modalAlpha: props.modalAlpha,\n };\n gameStage_1.popupContainer.push(view, options);\n }\n });\n next('complete');\n}\n", "script": "var effect = engine.findVariable('effect', args, props);\nvar effectParams = engine.findVariable('effectParams', args, props);\nvar showLoading = engine.findVariable('showLoading', args, props);\nif (showLoading !== undefined) {\n showLoading = false;\n}\nif (!props.viewName) {\n console.log('没有设置视图名');\n next('exception', '没有设置视图名');\n}\nelse {\n var gameStage_1 = engine.gameStage;\n gameStage_1.instantiateView(props.viewName, true, showLoading).then(function (view) {\n if (view) {\n var options = {\n effect: effect,\n effectParams: effectParams,\n center: props.center,\n modalAlpha: props.modalAlpha,\n };\n gameStage_1.popupContainer.push(view, options);\n }\n });\n next('complete');\n}\n",
"group": "view", "group": "view",
"type": "builtin" "type": "builtin"
} }
...@@ -6,13 +6,42 @@ ...@@ -6,13 +6,42 @@
}, },
"text": { "text": {
"type": "string", "type": "string",
"alias": "内容" "alias": "文本内容"
},
"labelAlign": {
"alias": "文本对齐",
"type": "enum",
"enum": [
{
"label": "左对齐",
"value": "left"
},
{
"label": "居中对齐",
"value": "center"
},
{
"label": "右对齐",
"value": "right"
}
],
"default": "center"
},
"labSize": {
"alias": "文本大小",
"type": "number",
"default": 30
}, },
"padding": { "padding": {
"type": "number", "type": "number",
"default": 10, "default": 10,
"alias": "边距" "alias": "边距"
}, },
"bgAlpha": {
"type": "number",
"default": 0.7,
"alias": "背景透明度"
},
"paddingH": { "paddingH": {
"type": "number", "type": "number",
"alias": "横向边距" "alias": "横向边距"
......
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var ObjectPool = engine.ObjectPool;
var utils_1 = require("./utils");
var object_pool_init_1 = require("./object-pool-init");
var frontBox_1 = require("./frontBox");
var backBox_1 = require("./backBox");
var Zhuazi_1 = require("./Zhuazi");
var GameView = (function (_super) {
__extends(GameView, _super);
function GameView() {
var _this = _super.call(this) || this;
_this.startstatus = false;
_this.ifPrize = false;
_this.goodsItems = [];
_this.once(engine.Event.ADDED_TO_STAGE, _this.setup, _this);
return _this;
}
GameView.prototype.setup = function () {
if (this._hasSetup) {
return;
}
this._hasSetup = true;
var frontBoxs = (this._frontBoxs = new frontBox_1.FrontBoxs());
this._frontBoxs.GameView = this;
var backBoxs = (this._backBoxs = new backBox_1.BackBoxs());
this._Zhuazi = new Zhuazi_1.Zhuazi();
this._Zhuazi.GameView = this;
this.frontTransfer = new engine.Container();
this.backTransfer = new engine.Container();
this.frontTransfer.width = 0;
this.frontTransfer.height = 0;
this.frontTransfer.alpha = 1;
this.backTransfer.width = 0;
this.backTransfer.height = 0;
this.backTransfer.alpha = 1;
this.rect = new engine.Rect();
this.rect.width = 611;
this.rect.height = 704;
this.rect.x = 65;
this.rect.y = 263;
this.NpcBg = new engine.Container();
this.addChild(this.NpcBg);
this.addChild(this.rect);
var gameBg = new engine.Sprite(utils_1.getTextureByName("游戏背景"));
gameBg.x = 65;
gameBg.y = 263;
this.NpcBg.addChild(gameBg);
this.frontDesk = new engine.Sprite(utils_1.getTextureByName("前传输带"));
this.frontDesk.x = 60;
this.frontDesk.y = 781;
this.backDesk = new engine.Sprite(utils_1.getTextureByName("后传输带"));
this.backDesk.x = 60;
this.backDesk.y = 712;
this.NpcBg.addChild(this.backDesk);
this.NpcBg.addChild(this.frontDesk);
this.NpcBg.addChild(this.backTransfer);
this.NpcBg.addChild(this.frontTransfer);
this.NpcBg.addChild(this._Zhuazi);
this.NpcBg.mask = this.rect;
this._Zhuazi.setup();
this.backTransfer.addChild(this._backBoxs);
this._backBoxs.setup();
this.frontTransfer.addChild(this._frontBoxs);
this._frontBoxs.setup();
};
GameView.prototype.stopMove = function () {
this._frontBoxs.stop();
};
GameView.prototype.setMoveX = function (x, item) {
this.moveTime = x;
this.prizeBox = item;
this._Zhuazi.move();
};
GameView.prototype.setVisible = function (isshow) {
this._frontBoxs.showHidePrizeBox(isshow);
};
GameView.prototype.getMoveX = function () {
return this.moveTime;
};
GameView.prototype.resetMoveX = function () {
this.moveTime = null;
};
GameView.prototype.getBox = function () {
return this.prizeBox;
};
GameView.prototype.reset = function () {
this.startstatus = false;
this.ifPrize = false;
this._Zhuazi.getReset();
};
GameView.prototype.start = function (type) {
if (type === void 0) { type = null; }
this.speed = 1;
this.gameIng = true;
console.log('执行', type);
this.startstatus = true;
this.ifPrize = type && type.prize || false;
};
GameView.prototype.beginNpc = function () {
var _this = this;
this.timer = setTimeout(function () {
if (_this.gameIng) {
}
}, 2000 / this.speed);
};
GameView.prototype.pause = function () {
this.gameIng = false;
};
GameView.prototype.revive = function () {
this.gameIng = true;
};
GameView.prototype.resume = function () {
this.reset();
this.start();
};
GameView.prototype.initNpc = function () {
this.box1 = new engine.Sprite(utils_1.getTextureByName("草泥马盒"));
this.box2 = new engine.Sprite(utils_1.getTextureByName("狗盒"));
this.box3 = new engine.Sprite(utils_1.getTextureByName("猫盒"));
this.box4 = new engine.Sprite(utils_1.getTextureByName("草泥马盒"));
this.box5 = new engine.Sprite(utils_1.getTextureByName("猫盒"));
this.box1.x = 120;
this.box1.y = 434;
this.box2.x = 306;
this.box2.y = 434;
this.box3.x = 487;
this.box3.y = 434;
this.box4.x = 240;
this.box4.scaleX = 0.5;
this.box4.scaleY = 0.5;
this.box4.y = 390;
this.box5.x = 434;
this.box5.y = 390;
this.box5.scaleX = 0.5;
this.box5.scaleY = 0.5;
this.backTransfer.addChild(this.box4);
this.backTransfer.addChild(this.box5);
this.frontTransfer.addChild(this.box1);
this.frontTransfer.addChild(this.box2);
this.frontTransfer.addChild(this.box3);
};
GameView.prototype.died = function () {
this.score = 0;
this.pause();
};
GameView.prototype.removeNpc = function (goods) {
this.NpcBg.removeChild(goods);
ObjectPool.recycleObject(object_pool_init_1.PoolName, goods);
goods.removeEventListener(engine.Event.ENTER_FRAME, goods["onGoodsEnter"], this);
var index = this.goodsItems.indexOf(goods);
if (index > -1) {
this.goodsItems.splice(index, 1);
}
};
GameView.prototype.recycleGoods = function () {
clearTimeout(this.timer);
clearInterval(this.countdownTimer);
for (var _i = 0, _a = this.goodsItems; _i < _a.length; _i++) {
var goods = _a[_i];
if (goods) {
this.removeChild(goods);
ObjectPool.recycleObject(object_pool_init_1.PoolName, goods);
goods.removeEventListener(engine.Event.ENTER_FRAME, goods["onGoodsEnter"], this);
}
}
this.goodsItems = [];
};
GameView.prototype.hasHit = function (a, b) {
if (Math.abs(a.x + a.width / 2 - (b.x + b.width / 2)) <
a.width / 2 + b.width / 2 &&
Math.abs(a.y + a.height / 2 - (b.y + b.height / 2)) <
a.height / 2 + b.height / 2) {
return true;
}
else {
return false;
}
};
return GameView;
}(engine.Container));
exports.default = GameView;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var GameView_1 = require("./GameView");
var props_1 = require("../props");
var GameWrapper = (function (_super) {
__extends(GameWrapper, _super);
function GameWrapper() {
var _this = _super.call(this) || this;
engine.globalEvent.addEventListener('doll-machine-reset', _this.reset, _this);
engine.globalEvent.addEventListener('doll-machine-prize', _this.start, _this);
var gameView = _this._gameView = new GameView_1.default();
_this.addChild(gameView);
return _this;
}
GameWrapper.prototype.reset = function (event) {
props_1.injectProps(event.data);
this._gameView.visible = true;
this._gameView.reset();
};
GameWrapper.prototype.start = function (event) {
console.log('监听开始');
props_1.injectProps(event.data);
this._gameView.start(event.data);
};
GameWrapper.prototype.pause = function () {
this._gameView.pause();
};
GameWrapper.prototype.resume = function () {
this._gameView.resume();
};
GameWrapper.prototype.revive = function () {
this._gameView.revive();
};
GameWrapper.prototype.clear = function () {
this._gameView.visible = false;
};
GameWrapper.prototype.onTap = function (event) {
};
return GameWrapper;
}(engine.Container));
exports.GameWrapper = GameWrapper;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var utils_1 = require("./utils");
var Goods = (function (_super) {
__extends(Goods, _super);
function Goods() {
var _this = _super.call(this) || this;
var body;
body = _this._body = new engine.Rect();
var box1 = new engine.Sprite(utils_1.getTextureByName("草泥马盒"));
box1["npcType"] = "box1";
var box2 = new engine.Sprite(utils_1.getTextureByName("狗盒"));
box2["npcType"] = "box2";
var box3 = new engine.Sprite(utils_1.getTextureByName("猫盒"));
box3["npcType"] = "box3";
box1.visible = false;
box2.visible = false;
box3.visible = false;
body.addChild(box1);
body.addChild(box2);
body.addChild(box3);
_this.addChild(body);
body.width = 0.0001;
body.height = 0.0001;
body.mouseEnabled = false;
return _this;
}
Goods.prototype.getRandomNumberByRange = function (start, end) {
return Math.floor(Math.random() * (end - start) + start);
};
Goods.prototype.reset = function () {
this.visible = true;
this.y = 200;
this.x = 0;
this.rotation = 0;
var random = Math.random();
if (random < 0.3) {
this.showNpc("box1");
}
else if (random < 0.6) {
this.showNpc("box2");
}
else {
this.showNpc("box3");
}
};
Goods.prototype.showNpc = function (type) {
for (var i = 0; i < this._body.children.length; i++) {
this._body.children[i].visible = false;
this._body.children[i].mouseEnabled = false;
}
for (var i = 0; i < this._body.children.length; i++) {
if (this._body.children[i]["npcType"] == type) {
this["npcType"] = type;
console.log(type);
this._body.children[i].visible = true;
this._body.children[i].mouseEnabled = false;
}
}
};
Object.defineProperty(Goods.prototype, "anchorOffsetY", {
set: function (v) {
this._body.y = v;
},
enumerable: true,
configurable: true
});
return Goods;
}(engine.Container));
exports.Goods = Goods;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var utils_1 = require("./utils");
var props_1 = require("../props");
var Zhuazi = (function (_super) {
__extends(Zhuazi, _super);
function Zhuazi() {
var _this = _super.call(this) || this;
_this.moveArr = [];
_this.prizeBoxs = [];
return _this;
}
Zhuazi.prototype.setup = function () {
this.ganNode = new engine.Container();
this.moveNode = new engine.Container();
this.ganNode.x = 280;
this.ganNode.y = 350;
this.bashouGan = new engine.Sprite(utils_1.getTextureByName("把手杆子"));
this.bashouGan.x = 60;
this.bashouGan.y = 275;
this.bashou = new engine.Sprite(utils_1.getTextureByName("把手"));
this.bashou.x = 0;
this.bashou.y = 263;
this.ganzi = new engine.Sprite(utils_1.getTextureByName("伸缩杆"));
this.ganzi.x = 97;
this.ganzi.y = 290;
this.connect = new engine.Sprite(utils_1.getTextureByName("连接点"));
this.connect.x = 18;
this.connect.y = -5;
this.left_zhuazi = new engine.Sprite(utils_1.getTextureByName("左爪"));
this.left_zhuazi.x = -15;
this.left_zhuazi.y = 60;
this.left_zhuazi.anchorX = this.left_zhuazi.width;
this.left_zhuazi.anchorY = 0;
this.right_zhuazi = new engine.Sprite(utils_1.getTextureByName("右爪"));
this.right_zhuazi.x = 98;
this.right_zhuazi.y = 60;
this.ganNode.addChild(this.left_zhuazi);
this.ganNode.addChild(this.right_zhuazi);
this.ganNode.addChild(this.connect);
this.ganNode.x = 30;
this.zhuaziY = this.ganNode.y;
this.moveNode.addChild(this.ganzi);
this.moveNode.addChild(this.ganNode);
this.moveNode.addChild(this.bashou);
this.moveNode.x = 262;
this.addChild(this.bashouGan);
this.addChild(this.moveNode);
this.createPrizeBox();
};
Zhuazi.prototype.createPrizeBox = function () {
var _this = this;
this.box1 = new engine.Sprite(utils_1.getTextureByName("中奖狗盒"));
this.box1["npcType"] = "box1";
this.box2 = new engine.Sprite(utils_1.getTextureByName("中奖猫盒"));
this.box2["npcType"] = "box2";
this.box3 = new engine.Sprite(utils_1.getTextureByName("中奖草泥马盒"));
this.box3["npcType"] = "box3";
this.box4 = new engine.Sprite(utils_1.getTextureByName("中奖狗盒"));
this.box4["npcType"] = "box4";
this.box5 = new engine.Sprite(utils_1.getTextureByName("中奖猫盒"));
this.box5["npcType"] = "box5";
this.prizeBoxs = [this.box1, this.box2, this.box3, this.box4, this.box5];
this.prizeBoxs.forEach(function (item) {
_this.ganNode.addChild(item);
item.visible = false;
item.x = 15;
item.y = 48;
});
};
Zhuazi.prototype.showPrizeBox = function () {
var _this = this;
this.prizeBoxs.forEach(function (item) {
console.log(_this.GameView.getBox()['npcType']);
if (item['npcType'] === _this.GameView.getBox()['npcType']) {
item.visible = true;
_this.itemShow = item;
}
else {
item.visible = false;
}
});
};
Zhuazi.prototype.move = function () {
var _this = this;
var rndist = Math.random();
var halfWidth = this.bashou.width / 2;
var randomX = rndist * (rndist > 0.5 ? 1 : -1) * props_1.props.bashouMoveDist;
console.log(randomX);
engine.Tween.get(this.moveNode).to({ x: 370 + halfWidth - 71 }, 1000).call(function () {
_this.zhangkai();
});
};
Zhuazi.prototype.zhangkai = function () {
var _this = this;
this.left_zhuazi.anchorX = this.left_zhuazi.width;
this.left_zhuazi.anchorY = 0;
engine.Tween.get(this.left_zhuazi, { loop: false }).to({ rotation: props_1.props.leftRotation }, 1000);
engine.Tween.get(this.right_zhuazi, { loop: false }).to({ rotation: props_1.props.rightRotation }, 1000);
setTimeout(function () {
_this.getLong();
}, 500);
};
Zhuazi.prototype.getLong = function () {
var _this = this;
var droptime = Number((this.GameView.getMoveX() / 60 - 1).toFixed(2)) * 1000;
console.log('dr', droptime);
var times = (props_1.props.ganMoveEndY - this.ganzi.y) / this.ganzi.height;
console.log(Number(times.toFixed(2)));
engine.Tween.get(this.ganzi).to({ scaleY: Number(times.toFixed(2)) }, droptime).to({ scaleY: 1 }, droptime);
console.log('node', this.zhuaziY);
engine.Tween.get(this.ganNode).to({ y: props_1.props.ganMoveEndY }, droptime).call(function () {
_this.GameView.stopMove();
if (_this.GameView.ifPrize) {
_this.showPrizeBox();
_this.GameView.setVisible(false);
}
}).to({ y: this.zhuaziY }, droptime).call(function () {
if (_this.GameView.ifPrize) {
_this.itemShow.visible = false;
}
engine.globalEvent.dispatchEvent('doll-machine-gameover');
});
};
Zhuazi.prototype.getReset = function () {
this.left_zhuazi.anchorX = this.left_zhuazi.width;
this.left_zhuazi.anchorY = 0;
engine.Tween.get(this.moveNode, { loop: false }).to({ x: 262 }, 1000);
engine.Tween.get(this.left_zhuazi, { loop: false }).to({ rotation: 0 }, 1000);
engine.Tween.get(this.right_zhuazi, { loop: false }).to({ rotation: 0 }, 1000);
this.GameView.resetMoveX();
};
return Zhuazi;
}(engine.Container));
exports.Zhuazi = Zhuazi;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var utils_1 = require("./utils");
var props_1 = require("../props");
var BackBoxs = (function (_super) {
__extends(BackBoxs, _super);
function BackBoxs() {
var _this = _super.call(this) || this;
_this.backBoxs = [];
return _this;
}
BackBoxs.prototype.setup = function () {
var initX, initY = 0;
this.box1 = new engine.Sprite(utils_1.getTextureByName("后狗盒"));
initX = this.box1.x = 188;
initY = this.box1.y = 616;
this.box2 = new engine.Sprite(utils_1.getTextureByName("后猫盒"));
this.box3 = new engine.Sprite(utils_1.getTextureByName("后草泥马盒"));
this.box4 = new engine.Sprite(utils_1.getTextureByName("后狗盒"));
this.box5 = new engine.Sprite(utils_1.getTextureByName("后猫盒"));
this.backBoxs = [this.box1, this.box2, this.box3, this.box4, this.box5];
for (var i = 0; i < this.backBoxs.length; i++) {
if (i == 0) {
this.backBoxs[i].x = initX;
}
else {
this.backBoxs[i].x = this.backBoxs[i - 1].x + this.backBoxs[i].width + props_1.props.backmargin;
}
this.backBoxs[i].y = initY;
this.addChild(this.backBoxs[i]);
}
this.addEventListener(engine.Event.ENTER_FRAME, this.frameMove, this);
};
BackBoxs.prototype.frameMove = function () {
var _this = this;
this.backBoxs.forEach(function (item) {
item.x -= props_1.props.moveSpeed;
if (item.x <= 0) {
var lastitem = _this.backBoxs.shift();
lastitem.x = _this.backBoxs[_this.backBoxs.length - 1].x + item.width + props_1.props.backmargin;
_this.backBoxs.push(lastitem);
}
});
};
return BackBoxs;
}(engine.Container));
exports.BackBoxs = BackBoxs;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var utils_1 = require("./utils");
var props_1 = require("../props");
var FrontBoxs = (function (_super) {
__extends(FrontBoxs, _super);
function FrontBoxs() {
var _this = _super.call(this) || this;
_this.frontBoxs = [];
return _this;
}
FrontBoxs.prototype.setup = function () {
var initX, initY = 0;
this.box1 = new engine.Sprite(utils_1.getTextureByName("狗盒"));
this.box1["npcType"] = "box1";
initX = this.box1.x = 435;
initY = this.box1.y = 614;
this.box2 = new engine.Sprite(utils_1.getTextureByName("猫盒"));
this.box2["npcType"] = "box2";
this.box3 = new engine.Sprite(utils_1.getTextureByName("草泥马盒"));
this.box3["npcType"] = "box3";
this.box4 = new engine.Sprite(utils_1.getTextureByName("狗盒"));
this.box4["npcType"] = "box4";
this.box5 = new engine.Sprite(utils_1.getTextureByName("猫盒"));
this.box5["npcType"] = "box5";
this.frontBoxs = [this.box1, this.box2, this.box3, this.box4];
for (var i = 0; i < this.frontBoxs.length; i++) {
if (i == 0) {
this.frontBoxs[i].x = initX;
}
else {
this.frontBoxs[i].x = this.frontBoxs[i - 1].x - this.box1.width - props_1.props.frontmargin;
}
this.frontBoxs[i].y = initY;
this.addChild(this.frontBoxs[i]);
}
this.addEventListener(engine.Event.ENTER_FRAME, this.frameMove, this);
};
FrontBoxs.prototype.frameMove = function () {
var _this = this;
this.frontBoxs.forEach(function (item, index) {
item.x += props_1.props.moveSpeed;
if (item.x <= 0 && !item.visible) {
item.visible = true;
}
if (item.x >= 750) {
var lastitem = _this.frontBoxs.shift();
lastitem.x = _this.frontBoxs[_this.frontBoxs.length - 1].x - _this.box1.width - props_1.props.frontmargin;
if (!_this.GameView.getMoveX() && item.x <= 0 && _this.GameView.startstatus) {
_this.GameView.setMoveX((370 - item.x - 13) / props_1.props.moveSpeed, item);
_this.hideBox = item;
}
_this.frontBoxs.push(lastitem);
}
});
};
FrontBoxs.prototype.stop = function () {
};
FrontBoxs.prototype.showHidePrizeBox = function (isshow) {
this.hideBox.visible = isshow;
};
return FrontBoxs;
}(engine.Container));
exports.FrontBoxs = FrontBoxs;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var Goods_1 = require("./Goods");
var ObjectPool = engine.ObjectPool;
exports.PoolName = 'goods';
ObjectPool.registerPool(exports.PoolName, function () {
return new Goods_1.Goods();
}, function (item, data) {
item.reset();
});
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
function getTexture(uuid) {
return engine.Texture.from(getAssetByUUID(uuid).uuid);
}
exports.getTexture = getTexture;
function getTextureByName(name) {
return getTexture(engine.getAssetByName(name).uuid);
}
exports.getTextureByName = getTextureByName;
function playSound(name) {
engine.playSound(engine.getAssetByName(name).uuid, { keep: true });
}
exports.playSound = playSound;
function createSvga(name, anchorName) {
var inst = new svga.Svga();
inst.source = 'asset://' + engine.getAssetByName(name).uuid;
return inst;
}
exports.createSvga = createSvga;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var GameWrapper_1 = require("./game/GameWrapper");
var props_1 = require("./props");
function default_1(props) {
props_1.prepareProps();
props_1.injectProps(props);
var instance = new GameWrapper_1.GameWrapper();
return instance;
}
exports.default = default_1;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.props = {};
function prepareProps() {
var metaProps = getProps();
engine.injectProp(exports.props, metaProps);
}
exports.prepareProps = prepareProps;
function injectProps(p) {
engine.injectProp(exports.props, p);
}
exports.injectProps = injectProps;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var props_1 = require("../props");
var utils_1 = require("./utils");
var frontBox_1 = require("./frontBox");
var backBox_1 = require("./backBox");
var Zhuazi_1 = require("./Zhuazi");
var GameView = (function (_super) {
__extends(GameView, _super);
function GameView() {
var _this = _super.call(this) || this;
_this.startstatus = false;
_this.ifPrize = false;
_this.goodsItems = [];
_this.once(engine.Event.ADDED_TO_STAGE, _this.setup, _this);
return _this;
}
GameView.prototype.setup = function () {
var _this = this;
if (this._hasSetup) {
return;
}
this._hasSetup = true;
var frontBoxs = (this._frontBoxs = new frontBox_1.FrontBoxs());
this._frontBoxs.GameView = this;
var backBoxs = (this._backBoxs = new backBox_1.BackBoxs());
this._Zhuazi = new Zhuazi_1.Zhuazi();
this._Zhuazi.GameView = this;
this.frontTransfer = new engine.Container();
this.backTransfer = new engine.Container();
this.frontTransfer.width = 0;
this.frontTransfer.height = 0;
this.frontTransfer.alpha = 1;
this.backTransfer.width = 0;
this.backTransfer.height = 0;
this.backTransfer.alpha = 1;
this.rect = new engine.Rect();
this.rect.width = props_1.props.gameStageWidth;
this.rect.height = props_1.props.gameStageHeight;
this.rect.x = 65;
this.rect.y = 0;
this.NpcBg = new engine.Container();
this.NpcBg.x = 0;
this.NpcBg.y = 0;
this.addChild(this.NpcBg);
this.addChild(this.rect);
this.frontDesk = new engine.Sprite(utils_1.getTextureByName("前传输带"));
this.frontDesk.x = props_1.props.initOffsetLeft;
this.frontDesk.y = props_1.props.frontDeskY - props_1.props.initOffsetTop;
this.backDesk = new engine.Sprite(utils_1.getTextureByName("后传输带"));
this.backDesk.x = props_1.props.initOffsetLeft;
this.backDesk.y = props_1.props.backDeskY - props_1.props.initOffsetTop;
if (props_1.props.single) {
this.backDesk.visible = false;
}
var pcarr = [this.backDesk, this.frontDesk, this.backTransfer, this.frontTransfer, this._Zhuazi];
pcarr.forEach(function (item) {
_this.NpcBg.addChild(item);
});
this.NpcBg.mask = this.rect;
this._Zhuazi.setup();
this.backTransfer.addChild(this._backBoxs);
this._backBoxs.setup();
if (props_1.props.single) {
this.backTransfer.visible = false;
}
this.frontTransfer.addChild(this._frontBoxs);
this._frontBoxs.setup();
};
GameView.prototype.stopMove = function () {
this._frontBoxs.stop();
};
GameView.prototype.setMoveX = function (x, item) {
this.moveTime = x;
this.prizeBox = item;
this._Zhuazi.move();
};
GameView.prototype.setVisible = function (isshow) {
this._frontBoxs.showHidePrizeBox(isshow);
};
GameView.prototype.getMoveX = function () {
return this.moveTime;
};
GameView.prototype.resetMoveX = function () {
this.moveTime = null;
};
GameView.prototype.getBox = function () {
return this.prizeBox;
};
GameView.prototype.reset = function () {
this.startstatus = false;
this.ifPrize = false;
this._Zhuazi.getReset();
};
GameView.prototype.start = function (type) {
if (type === void 0) { type = null; }
this.speed = 1;
this.gameIng = true;
console.log('执行', type);
this.startstatus = true;
this.ifPrize = type && type.prize || false;
};
GameView.prototype.beginNpc = function () {
var _this = this;
this.timer = setTimeout(function () {
if (_this.gameIng) {
}
}, 2000 / this.speed);
};
GameView.prototype.pause = function () {
this.gameIng = false;
};
GameView.prototype.revive = function () {
this.gameIng = true;
};
GameView.prototype.resume = function () {
this.reset();
this.start();
};
return GameView;
}(engine.Container));
exports.default = GameView;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var GameView_1 = require("./GameView");
var props_1 = require("../props");
var GameWrapper = (function (_super) {
__extends(GameWrapper, _super);
function GameWrapper() {
var _this = _super.call(this) || this;
engine.globalEvent.addEventListener('doll-machine2-game-init', _this.reset, _this);
engine.globalEvent.addEventListener('doll-machine2-game-start', _this.start, _this);
var gameView = _this._gameView = new GameView_1.default();
_this.addChild(gameView);
return _this;
}
GameWrapper.prototype.reset = function (event) {
props_1.injectProps(event.data);
this._gameView.visible = true;
this._gameView.reset();
};
GameWrapper.prototype.start = function (event) {
console.log('监听开始');
props_1.injectProps(event.data);
this._gameView.start(event.data);
};
GameWrapper.prototype.pause = function () {
this._gameView.pause();
};
GameWrapper.prototype.resume = function () {
this._gameView.resume();
};
GameWrapper.prototype.revive = function () {
this._gameView.revive();
};
GameWrapper.prototype.clear = function () {
this._gameView.visible = false;
};
GameWrapper.prototype.onTap = function (event) {
};
return GameWrapper;
}(engine.Container));
exports.GameWrapper = GameWrapper;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var utils_1 = require("./utils");
var Goods = (function (_super) {
__extends(Goods, _super);
function Goods() {
var _this = _super.call(this) || this;
var body;
body = _this._body = new engine.Rect();
var box1 = new engine.Sprite(utils_1.getTextureByName("草泥马盒"));
box1["npcType"] = "box1";
var box2 = new engine.Sprite(utils_1.getTextureByName("狗盒"));
box2["npcType"] = "box2";
var box3 = new engine.Sprite(utils_1.getTextureByName("猫盒"));
box3["npcType"] = "box3";
box1.visible = false;
box2.visible = false;
box3.visible = false;
body.addChild(box1);
body.addChild(box2);
body.addChild(box3);
_this.addChild(body);
body.width = 0.0001;
body.height = 0.0001;
body.mouseEnabled = false;
return _this;
}
Goods.prototype.getRandomNumberByRange = function (start, end) {
return Math.floor(Math.random() * (end - start) + start);
};
Goods.prototype.reset = function () {
this.visible = true;
this.y = 200;
this.x = 0;
this.rotation = 0;
var random = Math.random();
if (random < 0.3) {
this.showNpc("box1");
}
else if (random < 0.6) {
this.showNpc("box2");
}
else {
this.showNpc("box3");
}
};
Goods.prototype.showNpc = function (type) {
for (var i = 0; i < this._body.children.length; i++) {
this._body.children[i].visible = false;
this._body.children[i].mouseEnabled = false;
}
for (var i = 0; i < this._body.children.length; i++) {
if (this._body.children[i]["npcType"] == type) {
this["npcType"] = type;
console.log(type);
this._body.children[i].visible = true;
this._body.children[i].mouseEnabled = false;
}
}
};
Object.defineProperty(Goods.prototype, "anchorOffsetY", {
set: function (v) {
this._body.y = v;
},
enumerable: true,
configurable: true
});
return Goods;
}(engine.Container));
exports.Goods = Goods;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var utils_1 = require("./utils");
var props_1 = require("../props");
var Zhuazi = (function (_super) {
__extends(Zhuazi, _super);
function Zhuazi() {
var _this = _super.call(this) || this;
_this.moveArr = [];
_this.prizeBoxs = [];
return _this;
}
Zhuazi.prototype.setup = function () {
this.ganNode = new engine.Container();
this.moveNode = new engine.Container();
this.ganNode.x = 280;
this.ganNode.y = 350;
this.bashouGan = new engine.Sprite(utils_1.getTextureByName("把手杆子"));
this.bashouGan.x = 60;
this.bashouGan.y = 12;
this.bashou = new engine.Sprite(utils_1.getTextureByName("把手"));
this.bashou.x = 0;
this.bashou.y = 0;
this.ganzi = new engine.Sprite(utils_1.getTextureByName("伸缩杆"));
this.ganzi.x = 97;
this.ganzi.y = 27;
this.connect = new engine.Sprite(utils_1.getTextureByName("连接点"));
this.connect.x = 18;
this.connect.y = -5;
this.left_zhuazi = new engine.Sprite(utils_1.getTextureByName("左爪"));
this.left_zhuazi.x = props_1.props.leftLocX;
this.left_zhuazi.y = props_1.props.leftLocY;
this.left_zhuazi.anchorX = this.left_zhuazi.width;
this.left_zhuazi.anchorY = 0;
this.right_zhuazi = new engine.Sprite(utils_1.getTextureByName("右爪"));
this.right_zhuazi.x = props_1.props.rightLocX;
this.right_zhuazi.y = props_1.props.rightLocY;
this.ganNode.addChild(this.left_zhuazi);
this.ganNode.addChild(this.right_zhuazi);
this.ganNode.addChild(this.connect);
this.ganNode.x = 30;
this.ganNode.y = this.ganNode.y - 263;
this.zhuaziY = this.ganNode.y;
this.moveNode.addChild(this.ganzi);
this.moveNode.addChild(this.ganNode);
this.moveNode.addChild(this.bashou);
this.moveNode.x = 262;
this.bashouGan.y = this.bashouGan.y;
this.moveNode.y = this.moveNode.y;
this.addChild(this.bashouGan);
this.addChild(this.moveNode);
if (!props_1.props.ganziShow) {
this.bashouGan.visible = false;
}
if (!props_1.props.bashouShow) {
this.bashou.visible = false;
}
this.createPrizeBox();
};
Zhuazi.prototype.createPrizeBox = function () {
var _this = this;
for (var i = 0; i < props_1.props.dollNum; i++) {
if (!new engine.Sprite(utils_1.getTextureByName('prizebox_' + i))) {
return;
}
this.prizeBoxs[i] = new engine.Sprite(utils_1.getTextureByName('prizebox_' + i));
this.prizeBoxs[i]['npcType'] = 'box' + i;
}
this.prizeBoxs[props_1.props.dollNum] = new engine.Sprite(utils_1.getTextureByName('prizebox_0'));
this.prizeBoxs[props_1.props.dollNum]['npcType'] = 'box' + props_1.props.dollNum;
this.prizeBoxs.forEach(function (item) {
_this.ganNode.addChild(item);
item.visible = false;
item.x = props_1.props.prizeBoxInitX;
item.y = props_1.props.prizeBoxInitY;
});
};
Zhuazi.prototype.showPrizeBox = function () {
var _this = this;
this.prizeBoxs.forEach(function (item) {
console.log(_this.GameView.getBox()['npcType']);
if (item['npcType'] === _this.GameView.getBox()['npcType']) {
item.visible = true;
_this.itemShow = item;
}
else {
item.visible = false;
}
});
};
Zhuazi.prototype.move = function () {
var _this = this;
var rndist = Math.random();
var halfWidth = this.bashou.width / 2;
var randomX = rndist * (rndist > 0.5 ? 1 : -1) * props_1.props.bashouMoveDist;
console.log(randomX);
engine.Tween.get(this.moveNode).to({ x: 370 + halfWidth - 71 }, 1000).call(function () {
_this.zhangkai();
});
};
Zhuazi.prototype.zhangkai = function () {
var _this = this;
this.left_zhuazi.anchorX = this.left_zhuazi.width;
this.left_zhuazi.anchorY = 0;
engine.Tween.get(this.left_zhuazi, { loop: false }).to({ rotation: props_1.props.leftRotation }, 1000);
engine.Tween.get(this.right_zhuazi, { loop: false }).to({ rotation: props_1.props.rightRotation }, 1000);
setTimeout(function () {
_this.getLong();
}, 500);
};
Zhuazi.prototype.getLong = function () {
var _this = this;
var droptime = Number((this.GameView.getMoveX() / 60 - 1).toFixed(2)) * 1000 - 130;
console.log('dr', droptime);
var times = (props_1.props.ganMoveEndY - this.ganzi.y) / this.ganzi.height;
console.log(Number(times.toFixed(2)));
engine.Tween.get(this.ganzi).to({ scaleY: Number(times.toFixed(2)) }, droptime).to({ scaleY: 1 }, droptime);
console.log('node', this.zhuaziY);
engine.Tween.get(this.ganNode).to({ y: props_1.props.ganMoveEndY }, droptime).call(function () {
_this.GameView.stopMove();
if (_this.GameView.ifPrize) {
_this.showPrizeBox();
_this.GameView.setVisible(false);
}
}).to({ y: this.zhuaziY }, droptime).call(function () {
if (_this.GameView.ifPrize) {
_this.itemShow.visible = false;
}
engine.globalEvent.dispatchEvent('doll-machine2-game-end');
});
};
Zhuazi.prototype.getReset = function () {
this.left_zhuazi.anchorX = this.left_zhuazi.width;
this.left_zhuazi.anchorY = 0;
engine.Tween.get(this.moveNode, { loop: false }).to({ x: 262 }, 1000);
engine.Tween.get(this.left_zhuazi, { loop: false }).to({ rotation: 0 }, 1000);
engine.Tween.get(this.right_zhuazi, { loop: false }).to({ rotation: 0 }, 1000);
this.GameView.resetMoveX();
};
return Zhuazi;
}(engine.Container));
exports.Zhuazi = Zhuazi;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var utils_1 = require("./utils");
var props_1 = require("../props");
var BackBoxs = (function (_super) {
__extends(BackBoxs, _super);
function BackBoxs() {
var _this = _super.call(this) || this;
_this.backBoxs = [];
return _this;
}
BackBoxs.prototype.setup = function () {
var initX, initY = 0;
for (var i = 0; i < props_1.props.dollNum; i++) {
this.backBoxs[i] = new engine.Sprite(utils_1.getTextureByName('backbox_' + i));
initX = this.backBoxs[0].x = props_1.props.backInitX;
initY = this.backBoxs[0].y = props_1.props.backInitY - props_1.props.initOffsetTop;
this.backBoxs[i]['npcType'] = 'box' + i;
}
this.backBoxs[props_1.props.dollNum] = new engine.Sprite(utils_1.getTextureByName('backbox_0'));
this.backBoxs[props_1.props.dollNum]['npcType'] = 'box' + props_1.props.dollNum;
for (var i = 0; i < this.backBoxs.length; i++) {
if (i == 0) {
this.backBoxs[i].x = initX;
}
else {
this.backBoxs[i].x = this.backBoxs[i - 1].x + this.backBoxs[i].width + props_1.props.backmargin;
}
this.backBoxs[i].y = initY;
this.addChild(this.backBoxs[i]);
}
this.addEventListener(engine.Event.ENTER_FRAME, this.frameMove, this);
};
BackBoxs.prototype.frameMove = function () {
var _this = this;
this.backBoxs.forEach(function (item) {
item.x -= props_1.props.moveSpeed;
if (item.x <= 0) {
var lastitem = _this.backBoxs.shift();
lastitem.x = _this.backBoxs[_this.backBoxs.length - 1].x + item.width + props_1.props.backmargin;
_this.backBoxs.push(lastitem);
}
});
};
return BackBoxs;
}(engine.Container));
exports.BackBoxs = BackBoxs;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var utils_1 = require("./utils");
var props_1 = require("../props");
var FrontBoxs = (function (_super) {
__extends(FrontBoxs, _super);
function FrontBoxs() {
var _this = _super.call(this) || this;
_this.frontBoxs = [];
return _this;
}
FrontBoxs.prototype.setup = function () {
var initX, initY = 0;
for (var i = 0; i < props_1.props.dollNum; i++) {
if (!new engine.Sprite(utils_1.getTextureByName('frontbox_' + i))) {
return;
}
this.frontBoxs[i] = new engine.Sprite(utils_1.getTextureByName('frontbox_' + i));
initX = this.frontBoxs[0].x = props_1.props.frontInitX;
initY = this.frontBoxs[0].y = props_1.props.frontInitY;
this.frontBoxs[i]['npcType'] = 'box' + i;
}
this.frontBoxs[props_1.props.dollNum] = new engine.Sprite(utils_1.getTextureByName('frontbox_0'));
this.frontBoxs[props_1.props.dollNum]['npcType'] = 'box' + props_1.props.dollNum;
console.log(this.frontBoxs);
for (var i = 0; i < this.frontBoxs.length; i++) {
if (i == 0) {
this.frontBoxs[i].x = initX;
}
else {
this.frontBoxs[i].x = this.frontBoxs[i - 1].x - this.frontBoxs[0].width - props_1.props.frontmargin;
}
console.log(this.frontBoxs[i].x);
this.frontBoxs[i].y = initY;
this.addChild(this.frontBoxs[i]);
console.log('aaa', this.frontBoxs[i].x);
}
this.addEventListener(engine.Event.ENTER_FRAME, this.frameMove, this);
};
FrontBoxs.prototype.frameMove = function () {
var _this = this;
this.frontBoxs.forEach(function (item, index) {
item.x += props_1.props.moveSpeed;
if (item.x <= 0 && !item.visible) {
item.visible = true;
}
if (item.x >= 750) {
var tmpIndex = 0;
if (index <= 0) {
tmpIndex = _this.frontBoxs.length - 1;
}
else {
tmpIndex = index - 1;
}
item.x = _this.frontBoxs[tmpIndex].x - _this.frontBoxs[0].width - props_1.props.frontmargin;
if (!_this.GameView.getMoveX() && item.x <= 0 && _this.GameView.startstatus) {
_this.GameView.setMoveX((370 - item.x - 13) / props_1.props.moveSpeed, item);
_this.hideBox = item;
}
}
});
};
FrontBoxs.prototype.stop = function () {
};
FrontBoxs.prototype.showHidePrizeBox = function (isshow) {
this.hideBox.visible = isshow;
};
return FrontBoxs;
}(engine.Container));
exports.FrontBoxs = FrontBoxs;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var Goods_1 = require("./Goods");
var ObjectPool = engine.ObjectPool;
exports.PoolName = 'goods';
ObjectPool.registerPool(exports.PoolName, function () {
return new Goods_1.Goods();
}, function (item, data) {
item.reset();
});
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
function getTexture(uuid) {
return engine.Texture.from(getAssetByUUID(uuid).uuid);
}
exports.getTexture = getTexture;
function getTextureByName(name) {
return getTexture(engine.getAssetByName(name).uuid);
}
exports.getTextureByName = getTextureByName;
function playSound(name) {
engine.playSound(engine.getAssetByName(name).uuid, { keep: true });
}
exports.playSound = playSound;
function createSvga(name, anchorName) {
var inst = new svga.Svga();
inst.source = 'asset://' + engine.getAssetByName(name).uuid;
return inst;
}
exports.createSvga = createSvga;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var GameWrapper_1 = require("./game/GameWrapper");
var props_1 = require("./props");
function default_1(props) {
props_1.prepareProps();
props_1.injectProps(props);
var instance = new GameWrapper_1.GameWrapper();
return instance;
}
exports.default = default_1;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.props = {};
function prepareProps() {
var metaProps = getProps();
engine.injectProp(exports.props, metaProps);
}
exports.prepareProps = prepareProps;
function injectProps(p) {
engine.injectProp(exports.props, p);
}
exports.injectProps = injectProps;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var utils_1 = require("./utils");
var LoopComponent_1 = require("./LoopComponent");
var props_1 = require("./../props");
var Background = (function (_super) {
__extends(Background, _super);
function Background() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this.partResHHL = ['hhl_after', 'hhl_front'];
_this.partResHB = ['hb_after', 'hb_front'];
_this.partResWH = ['wh_after', 'wh_front'];
_this.speeds = [];
_this.resArray = [];
_this.frameMovePos = 0;
return _this;
}
Background.prototype.initBg = function () {
this.sumMovePos = 0;
this.speeds.push(props_1.props.afterBGMoveSpeed);
this.speeds.push(props_1.props.frontBGMoveSpeed);
var bottomBg = new engine.Rect();
bottomBg.x = 0;
bottomBg.y = 0;
bottomBg.width = utils_1.getStage().width;
bottomBg.height = 0;
bottomBg.fillColor = 0x75c9f5;
this.addChild(bottomBg);
this.resArray.push(this.partResHHL);
this.resArray.push(this.partResHB);
this.resArray.push(this.partResWH);
this._bgIndex = 0;
var parts = [];
for (var i = 0; i < 2; i++) {
var part = new LoopComponent_1.LoopComponent();
part.setupLoop([
this.resArray[0][i],
this.resArray[0][i],
]);
parts.push(part);
this.addChild(part);
}
parts[1].y = 200;
};
Background.prototype.setViewport = function (pos) {
this.needFrameSum = (props_1.props.pierMoveTime / 1000) * 60;
this.frameMovePos = pos / this.needFrameSum;
this.frameIndex = 0;
this.addEventListener(engine.Event.ENTER_FRAME, this.frameBack, this);
};
Background.prototype.frameBack = function () {
if (this.frameIndex < this.needFrameSum) {
for (var i = 0; i < 2; i++) {
var part = this.getChildAt(i + 1);
var speed = this.speeds[i];
var tmpPos = ((this.frameMovePos * this.frameIndex) + this.sumMovePos) * speed;
part.setViewport(tmpPos);
}
this.frameIndex++;
}
else {
this.sumMovePos += this.frameMovePos * this.needFrameSum;
this.frameIndex = 0;
this.removeEventListener(engine.Event.ENTER_FRAME, this.frameBack, this);
}
};
Background.prototype.changeBg = function (index) {
for (var i = 0; i < 2; i++) {
var part = this.getChildAt(i + 1);
part.changeBg(this.resArray[index][i]);
if (i == 1 && index == 1) {
part.y = 400;
}
if (i == 1 && index == 2) {
part.y = 250;
}
}
this._bgIndex = index;
};
Background.prototype.getBgIndex = function () {
return this._bgIndex;
};
return Background;
}(engine.Container));
exports.Background = Background;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var Road_1 = require("./Road");
var props_1 = require("../props");
var utils_1 = require("./utils");
var GuideLayer_1 = require("./GuideLayer");
var Background_1 = require("./Background");
var ObjectPool = engine.ObjectPool;
var Pier_1 = require("./Pier");
var Player_1 = require("./Player");
var Strut_1 = require("./Strut");
var ScoreLabel_1 = require("./ScoreLabel");
exports.PoolName = 'pier';
ObjectPool.registerPool(exports.PoolName, function () {
return new Pier_1.Pier();
}, function (item, data) {
item.init();
});
var GameView = (function (_super) {
__extends(GameView, _super);
function GameView() {
var _this = _super.call(this) || this;
_this.moveX = 0;
_this.once(engine.Event.ADDED_TO_STAGE, _this.setup, _this);
return _this;
}
GameView.prototype.setup = function () {
if (this._hasSetup) {
return;
}
this._hasSetup = true;
this._backgroud = new Background_1.Background();
this.addChild(this._backgroud);
this._backgroud.initBg();
var road = this._road = new Road_1.Road();
this.addChild(road);
road.setup();
var pierWidth = this._road.getFristPier();
var player = this._player = new Player_1.Player();
this.addChild(player);
player.initPlayer(pierWidth);
var strut = this._strut = new Strut_1.Strut();
this.addChild(strut);
strut.init();
this._scoreContainer = new engine.Container();
this.addChild(this._scoreContainer);
this.initLabScore();
};
GameView.prototype.start = function (guide) {
return __awaiter(this, void 0, void 0, function () {
var initScore;
return __generator(this, function (_a) {
this._isTouchLayer = true;
this._sumScore = 0;
this._isMouseDown = false;
this._guide = guide;
initScore = this._road.getStartGold(0) ? props_1.props.goldScore : 0;
this.updateScore(initScore);
if (this._guide == '1') {
this.setGuide();
}
else {
this.initTouch();
this.registerEvent();
}
return [2];
});
});
};
GameView.prototype.setGuide = function () {
var _this = this;
this._road.setGuide();
var guideLayer = this.guideLayer = new GuideLayer_1.GuideLayer();
this.addChild(guideLayer);
this.guideLayer.show(1, { x: 20, y: 650, guideText: props_1.props.guideText1 }, function () {
var posX = _this._road.getMovePos();
_this.guideLayer.show(2, { x: posX + 20, y: 620, guideText: props_1.props.guideText2 }, function () {
_this.initTouch();
_this.registerEvent();
});
});
};
GameView.prototype.initLabScore = function () {
var scoreBg = new engine.Sprite(utils_1.getTextureByName('scoreBg'));
scoreBg.x = utils_1.getStage().width / 2 - scoreBg.width / 2;
scoreBg.y = 80;
var scoreHint = new engine.Sprite(utils_1.getTextureByName('scoreHint'));
scoreHint.x = utils_1.getStage().width / 2 - scoreHint.width / 2;
scoreHint.y = 40;
this._scoreContainer.addChild(scoreHint);
this.labScore = new ScoreLabel_1.ScoreLabel();
this.labScore.fillColor = 0xff7646;
this.labScore.size = 70;
this.labScore.width = utils_1.getStage().width;
this.labScore.height = scoreBg.height;
this.labScore.textAlign = engine.TEXT_ALIGN.CENTER;
this.labScore.x = 0;
this.labScore.y = scoreBg.y + 10;
this._scoreContainer.addChild(this.labScore);
};
GameView.prototype.registerEvent = function () {
this._touchLayer.addEventListener(engine.MouseEvent.MOUSE_DOWN, this.onMouseDown, this);
this._touchLayer.addEventListener(engine.MouseEvent.MOUSE_UP, this.onMouseUp, this);
};
GameView.prototype.removeListener = function () {
this._touchLayer.removeEventListener(engine.MouseEvent.MOUSE_DOWN, this.onMouseDown, this);
this._touchLayer.removeEventListener(engine.MouseEvent.MOUSE_UP, this.onMouseUp, this);
};
GameView.prototype.initTouch = function () {
this._touchLayer = new engine.Rect();
this.addChild(this._touchLayer);
this._touchLayer.width = utils_1.getStage().width;
this._touchLayer.height = utils_1.getStage().height;
this._touchLayer.x = 0;
this._touchLayer.y = 0;
this._touchLayer.alpha = 0;
};
GameView.prototype.setScoreShow = function () {
};
GameView.prototype.onMouseDown = function () {
if (this._isTouchLayer) {
this._isMouseDown = true;
this._strut.onMouseDown(this._road.getFristPier(), this._road.getDistance(), this.goCallBcak.bind(this));
}
};
GameView.prototype.onMouseUp = function () {
if (this._isTouchLayer && this._isMouseDown) {
this._strut.onMouseUp();
this._isMouseDown = false;
this._isTouchLayer = false;
}
};
GameView.prototype.goCallBcak = function (isSuccess) {
var _this = this;
if (isSuccess) {
console.log('成功了');
var movePos = this._road.getMovePos();
if (this._road.getStartGold(1, false)) {
this.updateScore(props_1.props.singleScore + props_1.props.goldScore);
}
else {
this.updateScore(props_1.props.singleScore);
}
this._player.setViewport(movePos, this.complete.bind(this));
}
else {
console.log('失败了');
this._player.setViewport(this._strut.getStrutHeight(), function () {
console.log('掉下去了');
engine.globalEvent.dispatchEvent('dxbcyj-game-result', { score: _this._sumScore });
}, this._road.getFristPier());
}
};
GameView.prototype.complete = function () {
var _this = this;
this._road.getStartGold(1);
var movePos = this._road.getMovePos();
this._road.setViewport();
this._backgroud.setViewport(movePos);
this._player.setBackViewport(function () {
_this._isTouchLayer = true;
});
this.closeStrut();
};
GameView.prototype.closeStrut = function () {
this._strut.rest();
};
GameView.prototype.updateScore = function (score) {
this._sumScore += score;
if (0 <= this._sumScore && this._sumScore <= props_1.props.bgFristScore) {
this.changeBg(0);
}
else if (props_1.props.bgFristScore < this._sumScore && this._sumScore <= props_1.props.bgSecondScore) {
this.changeBg(1);
}
else {
this.changeBg(2);
}
this.labScore.updateScore(this._sumScore);
};
GameView.prototype.getScore = function () {
return this._sumScore;
};
GameView.prototype.changeBg = function (index) {
if (this._backgroud.getBgIndex() != index) {
this._backgroud.changeBg(index);
}
};
return GameView;
}(engine.Container));
exports.default = GameView;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var GameView_1 = require("./GameView");
var GameWrapper = (function (_super) {
__extends(GameWrapper, _super);
function GameWrapper() {
var _this = _super.call(this) || this;
engine.globalEvent.addEventListener('dxbcyj-game-start', _this.start, _this);
var gameView = _this._gameView = new GameView_1.default();
_this.addChild(gameView);
return _this;
}
GameWrapper.prototype.start = function (event) {
this._gameView.start(event.data.guide);
};
return GameWrapper;
}(engine.Container));
exports.GameWrapper = GameWrapper;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var props_1 = require("./../props");
var utils_1 = require("./utils");
var Pier = (function (_super) {
__extends(Pier, _super);
function Pier() {
var _this = _super.call(this) || this;
_this.bmp = new engine.Sprite();
_this.addChild(_this.bmp);
return _this;
}
Pier.prototype.init = function () {
var bmp = this.bmp;
bmp.alpha = 1;
bmp.texture = utils_1.getTextureByName('pier');
bmp.x = 0;
bmp.y = bmp.height;
if (this.children.length < 2) {
var gold = new engine.Sprite();
gold.texture = utils_1.getTextureByName('gold');
gold.name = 'gold';
this.addChild(gold);
}
this.setGoldPosX(bmp);
this.setShowGold();
};
Pier.prototype.setShowGold = function () {
var nodeGold = this.getChildByName('gold');
var randomWard = Math.random();
nodeGold.alpha = 1;
var isShow = randomWard < props_1.props.reward ? true : false;
nodeGold.visible = isShow;
this.haveGold = isShow;
};
Pier.prototype.setGoldPosX = function (bmp) {
var nodeGold = this.getChildByName('gold');
var pos = bmp.width / 2 - nodeGold.width / 2;
nodeGold.x = pos;
nodeGold.y = bmp.height - nodeGold.height - 50;
nodeGold.visible = false;
};
Pier.prototype.closeGold = function () {
var _this = this;
this.children.forEach(function (item) {
if (item.name == 'gold') {
item.anchorX = item.width / 2;
item.anchorY = item.height / 2;
engine.Tween.get(item, { loop: false })
.to({ scaleX: 2.5, scaleY: 2.5 }, 200, engine.Ease.cubicOut)
.to({ scaleX: 1, scaleY: 1, alpha: 0 }, 200, engine.Ease.cubicIn)
.call(function () {
item.visible = false;
_this.haveGold = false;
});
}
});
};
return Pier;
}(engine.Container));
exports.Pier = Pier;
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var Pier_1 = require("./Pier");
var ObjectPool = engine.ObjectPool;
exports.PoolName = 'pier';
ObjectPool.registerPool(exports.PoolName, function () {
return new Pier_1.Pier();
}, function (item, data) {
item.init();
});
This diff is collapsed.
This diff is collapsed.
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.props = {};
function prepareProps() {
var metaProps = getProps();
engine.injectProp(exports.props, metaProps);
}
exports.prepareProps = prepareProps;
function injectProps(p) {
engine.injectProp(exports.props, p);
}
exports.injectProps = injectProps;
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
...@@ -10,7 +10,7 @@ declare type NodeClass = ...@@ -10,7 +10,7 @@ declare type NodeClass =
declare const args: any; declare const args: any;
declare const scope: any; declare const scope: any;
declare const props: ProcessProps; declare const props: ProcessProps | any;
declare const target: NodeClass; declare const target: NodeClass;
declare const global: { declare const global: {
gameStage: engine.GameStage, gameStage: engine.GameStage,
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
/**
* Created by rockyl on 2020-01-21.
*/
let customModuleProps = {
};
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
/**
* Created by rockyl on 2019-11-20.
*/
import Gameinit from "./game/Gameinit";
import { injectProps, prepareProps } from "./props";
export default function (props) {
prepareProps();
injectProps(props);
let instance = new Gameinit();
return instance;
}
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
/**
* Created by rockyl on 2020-01-21.
*/
let customModuleProps = {
};
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
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