Commit b0afd988 authored by 汪欢's avatar 汪欢

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

parents 0a4fe5ff a9c7ec84
No preview for this file type
{
"liveServer.settings.port": 5501
}
\ No newline at end of file
No preview for this file type
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.
......@@ -12,7 +12,7 @@
"complete"
],
"id": "wait",
"script": "var duration = engine.findVariable('duration', args, props);\nsetTimeout(function () {\n next('complete');\n}, duration);\n",
"script": "var duration = engine.findVariable('duration', args, props);\nsetTimeout(function () {\n next('complete', args);\n}, duration);\n",
"group": "base",
"type": "builtin"
}
{
"name": "选择图片",
"desc": "选择一个图片文件",
"props": {},
"output": [
"success"
],
"id": "pick-image",
"script": "pick(function (imgData) {\n next('success', imgData);\n});\nfunction getExif(img, callback) {\n EXIF.getData(img, function () {\n var allMetaData = EXIF.getAllTags(this);\n callback(allMetaData);\n });\n}\nfunction pick(callback) {\n var fileInput = document.createElement(\"input\");\n fileInput.type = \"file\";\n fileInput.accept = \"image/*\";\n fileInput.style.display = \"none\";\n document.body.insertBefore(fileInput, document.body.firstChild);\n fileInput.addEventListener(\"change\", function (evt) {\n var mime = { \"png\": \"image/png\", \"jpg\": \"image/jpeg\", \"jpeg\": \"image/jpeg\", \"bmp\": \"image/bmp\" };\n var file = evt.target.files[0];\n var type = file.type;\n if (!type) {\n type = mime[file.name.match(/\\.([^\\.]+)$/i)[1]];\n }\n var fileReader = new FileReader();\n fileReader.onload = function () {\n getExif(file, function (exif) {\n var orientation = -1;\n if (exif) {\n orientation = exif[\"Orientation\"];\n }\n var image = new Image();\n image.onload = function () {\n var canvas = document.createElement(\"canvas\");\n var ctx = canvas.getContext(\"2d\");\n canvas.width = image.width;\n canvas.height = image.height;\n if (orientation > 4) {\n canvas.width = image.height;\n canvas.height = image.width;\n }\n ctx.clearRect(0, 0, canvas.width, canvas.height);\n switch (orientation) {\n case 2:\n ctx.translate(canvas.width, 0);\n ctx.scale(-1, 1);\n break;\n case 3:\n ctx.translate(canvas.width, canvas.height);\n ctx.rotate(Math.PI);\n break;\n case 4:\n ctx.translate(0, canvas.height);\n ctx.scale(1, -1);\n break;\n case 5:\n ctx.rotate(0.5 * Math.PI);\n ctx.scale(1, -1);\n break;\n case 6:\n ctx.rotate(0.5 * Math.PI);\n ctx.translate(0, -image.height);\n break;\n case 7:\n ctx.rotate(0.5 * Math.PI);\n ctx.translate(canvas.width, -canvas.height);\n ctx.scale(-1, 1);\n break;\n case 8:\n ctx.rotate(-0.5 * Math.PI);\n ctx.translate(-canvas.height, 0);\n break;\n default:\n ctx.transform(1, 0, 0, 1, 0, 0);\n }\n ctx.drawImage(image, 0, 0);\n var imagetype = \"png\";\n if (orientation !== -1) {\n imagetype = \"jpeg\";\n }\n var resultURL = \"\";\n if (imagetype === \"jpg\" || imagetype === \"jpeg\") {\n resultURL = canvas.toDataURL(\"image/\" + imagetype);\n }\n else {\n resultURL = canvas.toDataURL(\"image/\" + imagetype);\n }\n callback(resultURL);\n image.parentNode.removeChild(image);\n fileInput.parentNode.removeChild(fileInput);\n };\n image.src = fileReader.result;\n image.style.display = \"none\";\n document.body.appendChild(image);\n fileInput.value = \"\";\n });\n };\n fileReader.readAsDataURL(file);\n }, false);\n fileInput.click();\n}\n",
"group": "other",
"type": "builtin"
}
{
"name": "缩放图片",
"desc": "缩放图片",
"props": {
"width": {
"type": "number",
"alias": "目标宽度"
},
"height": {
"type": "number",
"alias": "目标高度"
},
"cutType": {
"type": "enum",
"enum": [
"inner",
"outer"
],
"alias": "裁剪类型",
"default": "inner"
},
"type": {
"type": "enum",
"enum": [
"png",
"jpeg"
],
"alias": "输出类型",
"default": "png"
},
"quality": {
"type": "number",
"alias": "图片质量",
"default": 0.7
}
},
"output": [
"success"
],
"id": "resize-image",
"script": "var width = engine.findVariable('width', args, props);\nvar height = engine.findVariable('height', args, props);\nvar cutType = engine.findVariable('cutType', args, props);\nvar type = engine.findVariable('type', args, props);\nvar quality = engine.findVariable('quality', args, props);\nvar img = args;\nif (typeof args === 'string') {\n img = new Image();\n img.onload = function () {\n deal();\n };\n img.onerror = function (e) {\n console.log(e);\n };\n img.src = args;\n}\nelse {\n deal();\n}\nfunction deal() {\n var m = cutType === 'inner' ? Math.min : Math.max;\n var r = m(width / img.width, height / img.height);\n var imgWidth = img.width * r;\n var imgHeight = img.height * r;\n var x = (width - imgWidth) / 2;\n var y = (height - imgHeight) / 2;\n var canvas = document.createElement('canvas');\n canvas.width = width;\n canvas.height = height;\n var ctx = canvas.getContext('2d');\n ctx.translate(x, y);\n ctx.scale(r, r);\n ctx.drawImage(img, 0, 0);\n var dataUrl = canvas.toDataURL('image/' + type, quality);\n next('success', dataUrl);\n}\n",
"group": "other",
"type": "builtin"
}
......@@ -6,13 +6,42 @@
},
"text": {
"type": "string",
"alias": "内容"
"alias": "文本内容"
},
"labelAlign": {
"alias": "文本对齐",
"type": "enum",
"enum": [
{
"label": "左对齐",
"value": "left"
},
{
"label": "居中对齐",
"value": "center"
},
{
"label": "右对齐",
"value": "right"
}
],
"default": "center"
},
"labSize": {
"alias": "文本大小",
"type": "number",
"default": 30
},
"padding": {
"type": "number",
"default": 10,
"alias": "边距"
},
"bgAlpha": {
"type": "number",
"default": 0.7,
"alias": "背景透明度"
},
"paddingH": {
"type": "number",
"alias": "横向边距"
......
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var ObjectPool = engine.ObjectPool;
var utils_1 = require("./utils");
var object_pool_init_1 = require("./object-pool-init");
var frontBox_1 = require("./frontBox");
var backBox_1 = require("./backBox");
var Zhuazi_1 = require("./Zhuazi");
var GameView = (function (_super) {
__extends(GameView, _super);
function GameView() {
var _this = _super.call(this) || this;
_this.startstatus = false;
_this.ifPrize = false;
_this.goodsItems = [];
_this.once(engine.Event.ADDED_TO_STAGE, _this.setup, _this);
return _this;
}
GameView.prototype.setup = function () {
if (this._hasSetup) {
return;
}
this._hasSetup = true;
var frontBoxs = (this._frontBoxs = new frontBox_1.FrontBoxs());
this._frontBoxs.GameView = this;
var backBoxs = (this._backBoxs = new backBox_1.BackBoxs());
this._Zhuazi = new Zhuazi_1.Zhuazi();
this._Zhuazi.GameView = this;
this.frontTransfer = new engine.Container();
this.backTransfer = new engine.Container();
this.frontTransfer.width = 0;
this.frontTransfer.height = 0;
this.frontTransfer.alpha = 1;
this.backTransfer.width = 0;
this.backTransfer.height = 0;
this.backTransfer.alpha = 1;
this.rect = new engine.Rect();
this.rect.width = 611;
this.rect.height = 704;
this.rect.x = 65;
this.rect.y = 263;
this.NpcBg = new engine.Container();
this.addChild(this.NpcBg);
this.addChild(this.rect);
var gameBg = new engine.Sprite(utils_1.getTextureByName("游戏背景"));
gameBg.x = 65;
gameBg.y = 263;
this.NpcBg.addChild(gameBg);
this.frontDesk = new engine.Sprite(utils_1.getTextureByName("前传输带"));
this.frontDesk.x = 60;
this.frontDesk.y = 781;
this.backDesk = new engine.Sprite(utils_1.getTextureByName("后传输带"));
this.backDesk.x = 60;
this.backDesk.y = 712;
this.NpcBg.addChild(this.backDesk);
this.NpcBg.addChild(this.frontDesk);
this.NpcBg.addChild(this.backTransfer);
this.NpcBg.addChild(this.frontTransfer);
this.NpcBg.addChild(this._Zhuazi);
this.NpcBg.mask = this.rect;
this._Zhuazi.setup();
this.backTransfer.addChild(this._backBoxs);
this._backBoxs.setup();
this.frontTransfer.addChild(this._frontBoxs);
this._frontBoxs.setup();
};
GameView.prototype.stopMove = function () {
this._frontBoxs.stop();
};
GameView.prototype.setMoveX = function (x, item) {
this.moveTime = x;
this.prizeBox = item;
this._Zhuazi.move();
};
GameView.prototype.setVisible = function (isshow) {
this._frontBoxs.showHidePrizeBox(isshow);
};
GameView.prototype.getMoveX = function () {
return this.moveTime;
};
GameView.prototype.resetMoveX = function () {
this.moveTime = null;
};
GameView.prototype.getBox = function () {
return this.prizeBox;
};
GameView.prototype.reset = function () {
this.startstatus = false;
this.ifPrize = false;
this._Zhuazi.getReset();
};
GameView.prototype.start = function (type) {
if (type === void 0) { type = null; }
this.speed = 1;
this.gameIng = true;
console.log('执行', type);
this.startstatus = true;
this.ifPrize = type && type.prize || false;
};
GameView.prototype.beginNpc = function () {
var _this = this;
this.timer = setTimeout(function () {
if (_this.gameIng) {
}
}, 2000 / this.speed);
};
GameView.prototype.pause = function () {
this.gameIng = false;
};
GameView.prototype.revive = function () {
this.gameIng = true;
};
GameView.prototype.resume = function () {
this.reset();
this.start();
};
GameView.prototype.initNpc = function () {
this.box1 = new engine.Sprite(utils_1.getTextureByName("草泥马盒"));
this.box2 = new engine.Sprite(utils_1.getTextureByName("狗盒"));
this.box3 = new engine.Sprite(utils_1.getTextureByName("猫盒"));
this.box4 = new engine.Sprite(utils_1.getTextureByName("草泥马盒"));
this.box5 = new engine.Sprite(utils_1.getTextureByName("猫盒"));
this.box1.x = 120;
this.box1.y = 434;
this.box2.x = 306;
this.box2.y = 434;
this.box3.x = 487;
this.box3.y = 434;
this.box4.x = 240;
this.box4.scaleX = 0.5;
this.box4.scaleY = 0.5;
this.box4.y = 390;
this.box5.x = 434;
this.box5.y = 390;
this.box5.scaleX = 0.5;
this.box5.scaleY = 0.5;
this.backTransfer.addChild(this.box4);
this.backTransfer.addChild(this.box5);
this.frontTransfer.addChild(this.box1);
this.frontTransfer.addChild(this.box2);
this.frontTransfer.addChild(this.box3);
};
GameView.prototype.died = function () {
this.score = 0;
this.pause();
};
GameView.prototype.removeNpc = function (goods) {
this.NpcBg.removeChild(goods);
ObjectPool.recycleObject(object_pool_init_1.PoolName, goods);
goods.removeEventListener(engine.Event.ENTER_FRAME, goods["onGoodsEnter"], this);
var index = this.goodsItems.indexOf(goods);
if (index > -1) {
this.goodsItems.splice(index, 1);
}
};
GameView.prototype.recycleGoods = function () {
clearTimeout(this.timer);
clearInterval(this.countdownTimer);
for (var _i = 0, _a = this.goodsItems; _i < _a.length; _i++) {
var goods = _a[_i];
if (goods) {
this.removeChild(goods);
ObjectPool.recycleObject(object_pool_init_1.PoolName, goods);
goods.removeEventListener(engine.Event.ENTER_FRAME, goods["onGoodsEnter"], this);
}
}
this.goodsItems = [];
};
GameView.prototype.hasHit = function (a, b) {
if (Math.abs(a.x + a.width / 2 - (b.x + b.width / 2)) <
a.width / 2 + b.width / 2 &&
Math.abs(a.y + a.height / 2 - (b.y + b.height / 2)) <
a.height / 2 + b.height / 2) {
return true;
}
else {
return false;
}
};
return GameView;
}(engine.Container));
exports.default = GameView;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var GameView_1 = require("./GameView");
var props_1 = require("../props");
var GameWrapper = (function (_super) {
__extends(GameWrapper, _super);
function GameWrapper() {
var _this = _super.call(this) || this;
engine.globalEvent.addEventListener('doll-machine-reset', _this.reset, _this);
engine.globalEvent.addEventListener('doll-machine-prize', _this.start, _this);
var gameView = _this._gameView = new GameView_1.default();
_this.addChild(gameView);
return _this;
}
GameWrapper.prototype.reset = function (event) {
props_1.injectProps(event.data);
this._gameView.visible = true;
this._gameView.reset();
};
GameWrapper.prototype.start = function (event) {
console.log('监听开始');
props_1.injectProps(event.data);
this._gameView.start(event.data);
};
GameWrapper.prototype.pause = function () {
this._gameView.pause();
};
GameWrapper.prototype.resume = function () {
this._gameView.resume();
};
GameWrapper.prototype.revive = function () {
this._gameView.revive();
};
GameWrapper.prototype.clear = function () {
this._gameView.visible = false;
};
GameWrapper.prototype.onTap = function (event) {
};
return GameWrapper;
}(engine.Container));
exports.GameWrapper = GameWrapper;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var utils_1 = require("./utils");
var Goods = (function (_super) {
__extends(Goods, _super);
function Goods() {
var _this = _super.call(this) || this;
var body;
body = _this._body = new engine.Rect();
var box1 = new engine.Sprite(utils_1.getTextureByName("草泥马盒"));
box1["npcType"] = "box1";
var box2 = new engine.Sprite(utils_1.getTextureByName("狗盒"));
box2["npcType"] = "box2";
var box3 = new engine.Sprite(utils_1.getTextureByName("猫盒"));
box3["npcType"] = "box3";
box1.visible = false;
box2.visible = false;
box3.visible = false;
body.addChild(box1);
body.addChild(box2);
body.addChild(box3);
_this.addChild(body);
body.width = 0.0001;
body.height = 0.0001;
body.mouseEnabled = false;
return _this;
}
Goods.prototype.getRandomNumberByRange = function (start, end) {
return Math.floor(Math.random() * (end - start) + start);
};
Goods.prototype.reset = function () {
this.visible = true;
this.y = 200;
this.x = 0;
this.rotation = 0;
var random = Math.random();
if (random < 0.3) {
this.showNpc("box1");
}
else if (random < 0.6) {
this.showNpc("box2");
}
else {
this.showNpc("box3");
}
};
Goods.prototype.showNpc = function (type) {
for (var i = 0; i < this._body.children.length; i++) {
this._body.children[i].visible = false;
this._body.children[i].mouseEnabled = false;
}
for (var i = 0; i < this._body.children.length; i++) {
if (this._body.children[i]["npcType"] == type) {
this["npcType"] = type;
console.log(type);
this._body.children[i].visible = true;
this._body.children[i].mouseEnabled = false;
}
}
};
Object.defineProperty(Goods.prototype, "anchorOffsetY", {
set: function (v) {
this._body.y = v;
},
enumerable: true,
configurable: true
});
return Goods;
}(engine.Container));
exports.Goods = Goods;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var utils_1 = require("./utils");
var props_1 = require("../props");
var Zhuazi = (function (_super) {
__extends(Zhuazi, _super);
function Zhuazi() {
var _this = _super.call(this) || this;
_this.moveArr = [];
_this.prizeBoxs = [];
return _this;
}
Zhuazi.prototype.setup = function () {
this.ganNode = new engine.Container();
this.moveNode = new engine.Container();
this.ganNode.x = 280;
this.ganNode.y = 350;
this.bashouGan = new engine.Sprite(utils_1.getTextureByName("把手杆子"));
this.bashouGan.x = 60;
this.bashouGan.y = 275;
this.bashou = new engine.Sprite(utils_1.getTextureByName("把手"));
this.bashou.x = 0;
this.bashou.y = 263;
this.ganzi = new engine.Sprite(utils_1.getTextureByName("伸缩杆"));
this.ganzi.x = 97;
this.ganzi.y = 290;
this.connect = new engine.Sprite(utils_1.getTextureByName("连接点"));
this.connect.x = 18;
this.connect.y = -5;
this.left_zhuazi = new engine.Sprite(utils_1.getTextureByName("左爪"));
this.left_zhuazi.x = -15;
this.left_zhuazi.y = 60;
this.left_zhuazi.anchorX = this.left_zhuazi.width;
this.left_zhuazi.anchorY = 0;
this.right_zhuazi = new engine.Sprite(utils_1.getTextureByName("右爪"));
this.right_zhuazi.x = 98;
this.right_zhuazi.y = 60;
this.ganNode.addChild(this.left_zhuazi);
this.ganNode.addChild(this.right_zhuazi);
this.ganNode.addChild(this.connect);
this.ganNode.x = 30;
this.zhuaziY = this.ganNode.y;
this.moveNode.addChild(this.ganzi);
this.moveNode.addChild(this.ganNode);
this.moveNode.addChild(this.bashou);
this.moveNode.x = 262;
this.addChild(this.bashouGan);
this.addChild(this.moveNode);
this.createPrizeBox();
};
Zhuazi.prototype.createPrizeBox = function () {
var _this = this;
this.box1 = new engine.Sprite(utils_1.getTextureByName("中奖狗盒"));
this.box1["npcType"] = "box1";
this.box2 = new engine.Sprite(utils_1.getTextureByName("中奖猫盒"));
this.box2["npcType"] = "box2";
this.box3 = new engine.Sprite(utils_1.getTextureByName("中奖草泥马盒"));
this.box3["npcType"] = "box3";
this.box4 = new engine.Sprite(utils_1.getTextureByName("中奖狗盒"));
this.box4["npcType"] = "box4";
this.box5 = new engine.Sprite(utils_1.getTextureByName("中奖猫盒"));
this.box5["npcType"] = "box5";
this.prizeBoxs = [this.box1, this.box2, this.box3, this.box4, this.box5];
this.prizeBoxs.forEach(function (item) {
_this.ganNode.addChild(item);
item.visible = false;
item.x = 15;
item.y = 48;
});
};
Zhuazi.prototype.showPrizeBox = function () {
var _this = this;
this.prizeBoxs.forEach(function (item) {
console.log(_this.GameView.getBox()['npcType']);
if (item['npcType'] === _this.GameView.getBox()['npcType']) {
item.visible = true;
_this.itemShow = item;
}
else {
item.visible = false;
}
});
};
Zhuazi.prototype.move = function () {
var _this = this;
var rndist = Math.random();
var halfWidth = this.bashou.width / 2;
var randomX = rndist * (rndist > 0.5 ? 1 : -1) * props_1.props.bashouMoveDist;
console.log(randomX);
engine.Tween.get(this.moveNode).to({ x: 370 + halfWidth - 71 }, 1000).call(function () {
_this.zhangkai();
});
};
Zhuazi.prototype.zhangkai = function () {
var _this = this;
this.left_zhuazi.anchorX = this.left_zhuazi.width;
this.left_zhuazi.anchorY = 0;
engine.Tween.get(this.left_zhuazi, { loop: false }).to({ rotation: props_1.props.leftRotation }, 1000);
engine.Tween.get(this.right_zhuazi, { loop: false }).to({ rotation: props_1.props.rightRotation }, 1000);
setTimeout(function () {
_this.getLong();
}, 500);
};
Zhuazi.prototype.getLong = function () {
var _this = this;
var droptime = Number((this.GameView.getMoveX() / 60 - 1).toFixed(2)) * 1000;
console.log('dr', droptime);
var times = (props_1.props.ganMoveEndY - this.ganzi.y) / this.ganzi.height;
console.log(Number(times.toFixed(2)));
engine.Tween.get(this.ganzi).to({ scaleY: Number(times.toFixed(2)) }, droptime).to({ scaleY: 1 }, droptime);
console.log('node', this.zhuaziY);
engine.Tween.get(this.ganNode).to({ y: props_1.props.ganMoveEndY }, droptime).call(function () {
_this.GameView.stopMove();
if (_this.GameView.ifPrize) {
_this.showPrizeBox();
_this.GameView.setVisible(false);
}
}).to({ y: this.zhuaziY }, droptime).call(function () {
if (_this.GameView.ifPrize) {
_this.itemShow.visible = false;
}
engine.globalEvent.dispatchEvent('doll-machine-gameover');
});
};
Zhuazi.prototype.getReset = function () {
this.left_zhuazi.anchorX = this.left_zhuazi.width;
this.left_zhuazi.anchorY = 0;
engine.Tween.get(this.moveNode, { loop: false }).to({ x: 262 }, 1000);
engine.Tween.get(this.left_zhuazi, { loop: false }).to({ rotation: 0 }, 1000);
engine.Tween.get(this.right_zhuazi, { loop: false }).to({ rotation: 0 }, 1000);
this.GameView.resetMoveX();
};
return Zhuazi;
}(engine.Container));
exports.Zhuazi = Zhuazi;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var utils_1 = require("./utils");
var props_1 = require("../props");
var BackBoxs = (function (_super) {
__extends(BackBoxs, _super);
function BackBoxs() {
var _this = _super.call(this) || this;
_this.backBoxs = [];
return _this;
}
BackBoxs.prototype.setup = function () {
var initX, initY = 0;
this.box1 = new engine.Sprite(utils_1.getTextureByName("后狗盒"));
initX = this.box1.x = 188;
initY = this.box1.y = 616;
this.box2 = new engine.Sprite(utils_1.getTextureByName("后猫盒"));
this.box3 = new engine.Sprite(utils_1.getTextureByName("后草泥马盒"));
this.box4 = new engine.Sprite(utils_1.getTextureByName("后狗盒"));
this.box5 = new engine.Sprite(utils_1.getTextureByName("后猫盒"));
this.backBoxs = [this.box1, this.box2, this.box3, this.box4, this.box5];
for (var i = 0; i < this.backBoxs.length; i++) {
if (i == 0) {
this.backBoxs[i].x = initX;
}
else {
this.backBoxs[i].x = this.backBoxs[i - 1].x + this.backBoxs[i].width + props_1.props.backmargin;
}
this.backBoxs[i].y = initY;
this.addChild(this.backBoxs[i]);
}
this.addEventListener(engine.Event.ENTER_FRAME, this.frameMove, this);
};
BackBoxs.prototype.frameMove = function () {
var _this = this;
this.backBoxs.forEach(function (item) {
item.x -= props_1.props.moveSpeed;
if (item.x <= 0) {
var lastitem = _this.backBoxs.shift();
lastitem.x = _this.backBoxs[_this.backBoxs.length - 1].x + item.width + props_1.props.backmargin;
_this.backBoxs.push(lastitem);
}
});
};
return BackBoxs;
}(engine.Container));
exports.BackBoxs = BackBoxs;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var utils_1 = require("./utils");
var props_1 = require("../props");
var FrontBoxs = (function (_super) {
__extends(FrontBoxs, _super);
function FrontBoxs() {
var _this = _super.call(this) || this;
_this.frontBoxs = [];
return _this;
}
FrontBoxs.prototype.setup = function () {
var initX, initY = 0;
this.box1 = new engine.Sprite(utils_1.getTextureByName("狗盒"));
this.box1["npcType"] = "box1";
initX = this.box1.x = 435;
initY = this.box1.y = 614;
this.box2 = new engine.Sprite(utils_1.getTextureByName("猫盒"));
this.box2["npcType"] = "box2";
this.box3 = new engine.Sprite(utils_1.getTextureByName("草泥马盒"));
this.box3["npcType"] = "box3";
this.box4 = new engine.Sprite(utils_1.getTextureByName("狗盒"));
this.box4["npcType"] = "box4";
this.box5 = new engine.Sprite(utils_1.getTextureByName("猫盒"));
this.box5["npcType"] = "box5";
this.frontBoxs = [this.box1, this.box2, this.box3, this.box4];
for (var i = 0; i < this.frontBoxs.length; i++) {
if (i == 0) {
this.frontBoxs[i].x = initX;
}
else {
this.frontBoxs[i].x = this.frontBoxs[i - 1].x - this.box1.width - props_1.props.frontmargin;
}
this.frontBoxs[i].y = initY;
this.addChild(this.frontBoxs[i]);
}
this.addEventListener(engine.Event.ENTER_FRAME, this.frameMove, this);
};
FrontBoxs.prototype.frameMove = function () {
var _this = this;
this.frontBoxs.forEach(function (item, index) {
item.x += props_1.props.moveSpeed;
if (item.x <= 0 && !item.visible) {
item.visible = true;
}
if (item.x >= 750) {
var lastitem = _this.frontBoxs.shift();
lastitem.x = _this.frontBoxs[_this.frontBoxs.length - 1].x - _this.box1.width - props_1.props.frontmargin;
if (!_this.GameView.getMoveX() && item.x <= 0 && _this.GameView.startstatus) {
_this.GameView.setMoveX((370 - item.x - 13) / props_1.props.moveSpeed, item);
_this.hideBox = item;
}
_this.frontBoxs.push(lastitem);
}
});
};
FrontBoxs.prototype.stop = function () {
};
FrontBoxs.prototype.showHidePrizeBox = function (isshow) {
this.hideBox.visible = isshow;
};
return FrontBoxs;
}(engine.Container));
exports.FrontBoxs = FrontBoxs;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var Goods_1 = require("./Goods");
var ObjectPool = engine.ObjectPool;
exports.PoolName = 'goods';
ObjectPool.registerPool(exports.PoolName, function () {
return new Goods_1.Goods();
}, function (item, data) {
item.reset();
});
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
function getTexture(uuid) {
return engine.Texture.from(getAssetByUUID(uuid).uuid);
}
exports.getTexture = getTexture;
function getTextureByName(name) {
return getTexture(engine.getAssetByName(name).uuid);
}
exports.getTextureByName = getTextureByName;
function playSound(name) {
engine.playSound(engine.getAssetByName(name).uuid, { keep: true });
}
exports.playSound = playSound;
function createSvga(name, anchorName) {
var inst = new svga.Svga();
inst.source = 'asset://' + engine.getAssetByName(name).uuid;
return inst;
}
exports.createSvga = createSvga;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var GameWrapper_1 = require("./game/GameWrapper");
var props_1 = require("./props");
function default_1(props) {
props_1.prepareProps();
props_1.injectProps(props);
var instance = new GameWrapper_1.GameWrapper();
return instance;
}
exports.default = default_1;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.props = {};
function prepareProps() {
var metaProps = getProps();
engine.injectProp(exports.props, metaProps);
}
exports.prepareProps = prepareProps;
function injectProps(p) {
engine.injectProp(exports.props, p);
}
exports.injectProps = injectProps;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var props_1 = require("../props");
var utils_1 = require("./utils");
var frontBox_1 = require("./frontBox");
var backBox_1 = require("./backBox");
var Zhuazi_1 = require("./Zhuazi");
var GameView = (function (_super) {
__extends(GameView, _super);
function GameView() {
var _this = _super.call(this) || this;
_this.startstatus = false;
_this.ifPrize = false;
_this.goodsItems = [];
_this.once(engine.Event.ADDED_TO_STAGE, _this.setup, _this);
return _this;
}
GameView.prototype.setup = function () {
var _this = this;
if (this._hasSetup) {
return;
}
this._hasSetup = true;
var frontBoxs = (this._frontBoxs = new frontBox_1.FrontBoxs());
this._frontBoxs.GameView = this;
var backBoxs = (this._backBoxs = new backBox_1.BackBoxs());
this._Zhuazi = new Zhuazi_1.Zhuazi();
this._Zhuazi.GameView = this;
this.frontTransfer = new engine.Container();
this.backTransfer = new engine.Container();
this.frontTransfer.width = 0;
this.frontTransfer.height = 0;
this.frontTransfer.alpha = 1;
this.backTransfer.width = 0;
this.backTransfer.height = 0;
this.backTransfer.alpha = 1;
this.rect = new engine.Rect();
this.rect.width = props_1.props.gameStageWidth;
this.rect.height = props_1.props.gameStageHeight;
this.rect.x = 65;
this.rect.y = 0;
this.NpcBg = new engine.Container();
this.NpcBg.x = 0;
this.NpcBg.y = 0;
this.addChild(this.NpcBg);
this.addChild(this.rect);
this.frontDesk = new engine.Sprite(utils_1.getTextureByName("前传输带"));
this.frontDesk.x = props_1.props.initOffsetLeft;
this.frontDesk.y = props_1.props.frontDeskY - props_1.props.initOffsetTop;
this.backDesk = new engine.Sprite(utils_1.getTextureByName("后传输带"));
this.backDesk.x = props_1.props.initOffsetLeft;
this.backDesk.y = props_1.props.backDeskY - props_1.props.initOffsetTop;
if (props_1.props.single) {
this.backDesk.visible = false;
}
var pcarr = [this.backDesk, this.frontDesk, this.backTransfer, this.frontTransfer, this._Zhuazi];
pcarr.forEach(function (item) {
_this.NpcBg.addChild(item);
});
this.NpcBg.mask = this.rect;
this._Zhuazi.setup();
this.backTransfer.addChild(this._backBoxs);
this._backBoxs.setup();
if (props_1.props.single) {
this.backTransfer.visible = false;
}
this.frontTransfer.addChild(this._frontBoxs);
this._frontBoxs.setup();
};
GameView.prototype.stopMove = function () {
this._frontBoxs.stop();
};
GameView.prototype.setMoveX = function (x, item) {
this.moveTime = x;
this.prizeBox = item;
this._Zhuazi.move();
};
GameView.prototype.setVisible = function (isshow) {
this._frontBoxs.showHidePrizeBox(isshow);
};
GameView.prototype.getMoveX = function () {
return this.moveTime;
};
GameView.prototype.resetMoveX = function () {
this.moveTime = null;
};
GameView.prototype.getBox = function () {
return this.prizeBox;
};
GameView.prototype.reset = function () {
this.startstatus = false;
this.ifPrize = false;
this._Zhuazi.getReset();
};
GameView.prototype.start = function (type) {
if (type === void 0) { type = null; }
this.speed = 1;
this.gameIng = true;
console.log('执行', type);
this.startstatus = true;
this.ifPrize = type && type.prize || false;
};
GameView.prototype.beginNpc = function () {
var _this = this;
this.timer = setTimeout(function () {
if (_this.gameIng) {
}
}, 2000 / this.speed);
};
GameView.prototype.pause = function () {
this.gameIng = false;
};
GameView.prototype.revive = function () {
this.gameIng = true;
};
GameView.prototype.resume = function () {
this.reset();
this.start();
};
return GameView;
}(engine.Container));
exports.default = GameView;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var GameView_1 = require("./GameView");
var props_1 = require("../props");
var GameWrapper = (function (_super) {
__extends(GameWrapper, _super);
function GameWrapper() {
var _this = _super.call(this) || this;
engine.globalEvent.addEventListener('doll-machine2-game-init', _this.reset, _this);
engine.globalEvent.addEventListener('doll-machine2-game-start', _this.start, _this);
var gameView = _this._gameView = new GameView_1.default();
_this.addChild(gameView);
return _this;
}
GameWrapper.prototype.reset = function (event) {
props_1.injectProps(event.data);
this._gameView.visible = true;
this._gameView.reset();
};
GameWrapper.prototype.start = function (event) {
console.log('监听开始');
props_1.injectProps(event.data);
this._gameView.start(event.data);
};
GameWrapper.prototype.pause = function () {
this._gameView.pause();
};
GameWrapper.prototype.resume = function () {
this._gameView.resume();
};
GameWrapper.prototype.revive = function () {
this._gameView.revive();
};
GameWrapper.prototype.clear = function () {
this._gameView.visible = false;
};
GameWrapper.prototype.onTap = function (event) {
};
return GameWrapper;
}(engine.Container));
exports.GameWrapper = GameWrapper;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var utils_1 = require("./utils");
var Goods = (function (_super) {
__extends(Goods, _super);
function Goods() {
var _this = _super.call(this) || this;
var body;
body = _this._body = new engine.Rect();
var box1 = new engine.Sprite(utils_1.getTextureByName("草泥马盒"));
box1["npcType"] = "box1";
var box2 = new engine.Sprite(utils_1.getTextureByName("狗盒"));
box2["npcType"] = "box2";
var box3 = new engine.Sprite(utils_1.getTextureByName("猫盒"));
box3["npcType"] = "box3";
box1.visible = false;
box2.visible = false;
box3.visible = false;
body.addChild(box1);
body.addChild(box2);
body.addChild(box3);
_this.addChild(body);
body.width = 0.0001;
body.height = 0.0001;
body.mouseEnabled = false;
return _this;
}
Goods.prototype.getRandomNumberByRange = function (start, end) {
return Math.floor(Math.random() * (end - start) + start);
};
Goods.prototype.reset = function () {
this.visible = true;
this.y = 200;
this.x = 0;
this.rotation = 0;
var random = Math.random();
if (random < 0.3) {
this.showNpc("box1");
}
else if (random < 0.6) {
this.showNpc("box2");
}
else {
this.showNpc("box3");
}
};
Goods.prototype.showNpc = function (type) {
for (var i = 0; i < this._body.children.length; i++) {
this._body.children[i].visible = false;
this._body.children[i].mouseEnabled = false;
}
for (var i = 0; i < this._body.children.length; i++) {
if (this._body.children[i]["npcType"] == type) {
this["npcType"] = type;
console.log(type);
this._body.children[i].visible = true;
this._body.children[i].mouseEnabled = false;
}
}
};
Object.defineProperty(Goods.prototype, "anchorOffsetY", {
set: function (v) {
this._body.y = v;
},
enumerable: true,
configurable: true
});
return Goods;
}(engine.Container));
exports.Goods = Goods;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var utils_1 = require("./utils");
var props_1 = require("../props");
var Zhuazi = (function (_super) {
__extends(Zhuazi, _super);
function Zhuazi() {
var _this = _super.call(this) || this;
_this.moveArr = [];
_this.prizeBoxs = [];
return _this;
}
Zhuazi.prototype.setup = function () {
this.ganNode = new engine.Container();
this.moveNode = new engine.Container();
this.ganNode.x = 280;
this.ganNode.y = 350;
this.bashouGan = new engine.Sprite(utils_1.getTextureByName("把手杆子"));
this.bashouGan.x = 60;
this.bashouGan.y = 12;
this.bashou = new engine.Sprite(utils_1.getTextureByName("把手"));
this.bashou.x = 0;
this.bashou.y = 0;
this.ganzi = new engine.Sprite(utils_1.getTextureByName("伸缩杆"));
this.ganzi.x = 97;
this.ganzi.y = 27;
this.connect = new engine.Sprite(utils_1.getTextureByName("连接点"));
this.connect.x = 18;
this.connect.y = -5;
this.left_zhuazi = new engine.Sprite(utils_1.getTextureByName("左爪"));
this.left_zhuazi.x = props_1.props.leftLocX;
this.left_zhuazi.y = props_1.props.leftLocY;
this.left_zhuazi.anchorX = this.left_zhuazi.width;
this.left_zhuazi.anchorY = 0;
this.right_zhuazi = new engine.Sprite(utils_1.getTextureByName("右爪"));
this.right_zhuazi.x = props_1.props.rightLocX;
this.right_zhuazi.y = props_1.props.rightLocY;
this.ganNode.addChild(this.left_zhuazi);
this.ganNode.addChild(this.right_zhuazi);
this.ganNode.addChild(this.connect);
this.ganNode.x = 30;
this.ganNode.y = this.ganNode.y - 263;
this.zhuaziY = this.ganNode.y;
this.moveNode.addChild(this.ganzi);
this.moveNode.addChild(this.ganNode);
this.moveNode.addChild(this.bashou);
this.moveNode.x = 262;
this.bashouGan.y = this.bashouGan.y;
this.moveNode.y = this.moveNode.y;
this.addChild(this.bashouGan);
this.addChild(this.moveNode);
if (!props_1.props.ganziShow) {
this.bashouGan.visible = false;
}
if (!props_1.props.bashouShow) {
this.bashou.visible = false;
}
this.createPrizeBox();
};
Zhuazi.prototype.createPrizeBox = function () {
var _this = this;
for (var i = 0; i < props_1.props.dollNum; i++) {
if (!new engine.Sprite(utils_1.getTextureByName('prizebox_' + i))) {
return;
}
this.prizeBoxs[i] = new engine.Sprite(utils_1.getTextureByName('prizebox_' + i));
this.prizeBoxs[i]['npcType'] = 'box' + i;
}
this.prizeBoxs[props_1.props.dollNum] = new engine.Sprite(utils_1.getTextureByName('prizebox_0'));
this.prizeBoxs[props_1.props.dollNum]['npcType'] = 'box' + props_1.props.dollNum;
this.prizeBoxs.forEach(function (item) {
_this.ganNode.addChild(item);
item.visible = false;
item.x = props_1.props.prizeBoxInitX;
item.y = props_1.props.prizeBoxInitY;
});
};
Zhuazi.prototype.showPrizeBox = function () {
var _this = this;
this.prizeBoxs.forEach(function (item) {
console.log(_this.GameView.getBox()['npcType']);
if (item['npcType'] === _this.GameView.getBox()['npcType']) {
item.visible = true;
_this.itemShow = item;
}
else {
item.visible = false;
}
});
};
Zhuazi.prototype.move = function () {
var _this = this;
var rndist = Math.random();
var halfWidth = this.bashou.width / 2;
var randomX = rndist * (rndist > 0.5 ? 1 : -1) * props_1.props.bashouMoveDist;
console.log(randomX);
engine.Tween.get(this.moveNode).to({ x: 370 + halfWidth - 71 }, 1000).call(function () {
_this.zhangkai();
});
};
Zhuazi.prototype.zhangkai = function () {
var _this = this;
this.left_zhuazi.anchorX = this.left_zhuazi.width;
this.left_zhuazi.anchorY = 0;
engine.Tween.get(this.left_zhuazi, { loop: false }).to({ rotation: props_1.props.leftRotation }, 1000);
engine.Tween.get(this.right_zhuazi, { loop: false }).to({ rotation: props_1.props.rightRotation }, 1000);
setTimeout(function () {
_this.getLong();
}, 500);
};
Zhuazi.prototype.getLong = function () {
var _this = this;
var droptime = Number((this.GameView.getMoveX() / 60 - 1).toFixed(2)) * 1000 - 130;
console.log('dr', droptime);
var times = (props_1.props.ganMoveEndY - this.ganzi.y) / this.ganzi.height;
console.log(Number(times.toFixed(2)));
engine.Tween.get(this.ganzi).to({ scaleY: Number(times.toFixed(2)) }, droptime).to({ scaleY: 1 }, droptime);
console.log('node', this.zhuaziY);
engine.Tween.get(this.ganNode).to({ y: props_1.props.ganMoveEndY }, droptime).call(function () {
_this.GameView.stopMove();
if (_this.GameView.ifPrize) {
_this.showPrizeBox();
_this.GameView.setVisible(false);
}
}).to({ y: this.zhuaziY }, droptime).call(function () {
if (_this.GameView.ifPrize) {
_this.itemShow.visible = false;
}
engine.globalEvent.dispatchEvent('doll-machine2-game-end');
});
};
Zhuazi.prototype.getReset = function () {
this.left_zhuazi.anchorX = this.left_zhuazi.width;
this.left_zhuazi.anchorY = 0;
engine.Tween.get(this.moveNode, { loop: false }).to({ x: 262 }, 1000);
engine.Tween.get(this.left_zhuazi, { loop: false }).to({ rotation: 0 }, 1000);
engine.Tween.get(this.right_zhuazi, { loop: false }).to({ rotation: 0 }, 1000);
this.GameView.resetMoveX();
};
return Zhuazi;
}(engine.Container));
exports.Zhuazi = Zhuazi;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var utils_1 = require("./utils");
var props_1 = require("../props");
var BackBoxs = (function (_super) {
__extends(BackBoxs, _super);
function BackBoxs() {
var _this = _super.call(this) || this;
_this.backBoxs = [];
return _this;
}
BackBoxs.prototype.setup = function () {
var initX, initY = 0;
for (var i = 0; i < props_1.props.dollNum; i++) {
this.backBoxs[i] = new engine.Sprite(utils_1.getTextureByName('backbox_' + i));
initX = this.backBoxs[0].x = props_1.props.backInitX;
initY = this.backBoxs[0].y = props_1.props.backInitY - props_1.props.initOffsetTop;
this.backBoxs[i]['npcType'] = 'box' + i;
}
this.backBoxs[props_1.props.dollNum] = new engine.Sprite(utils_1.getTextureByName('backbox_0'));
this.backBoxs[props_1.props.dollNum]['npcType'] = 'box' + props_1.props.dollNum;
for (var i = 0; i < this.backBoxs.length; i++) {
if (i == 0) {
this.backBoxs[i].x = initX;
}
else {
this.backBoxs[i].x = this.backBoxs[i - 1].x + this.backBoxs[i].width + props_1.props.backmargin;
}
this.backBoxs[i].y = initY;
this.addChild(this.backBoxs[i]);
}
this.addEventListener(engine.Event.ENTER_FRAME, this.frameMove, this);
};
BackBoxs.prototype.frameMove = function () {
var _this = this;
this.backBoxs.forEach(function (item) {
item.x -= props_1.props.moveSpeed;
if (item.x <= 0) {
var lastitem = _this.backBoxs.shift();
lastitem.x = _this.backBoxs[_this.backBoxs.length - 1].x + item.width + props_1.props.backmargin;
_this.backBoxs.push(lastitem);
}
});
};
return BackBoxs;
}(engine.Container));
exports.BackBoxs = BackBoxs;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var utils_1 = require("./utils");
var props_1 = require("../props");
var FrontBoxs = (function (_super) {
__extends(FrontBoxs, _super);
function FrontBoxs() {
var _this = _super.call(this) || this;
_this.frontBoxs = [];
return _this;
}
FrontBoxs.prototype.setup = function () {
var initX, initY = 0;
for (var i = 0; i < props_1.props.dollNum; i++) {
if (!new engine.Sprite(utils_1.getTextureByName('frontbox_' + i))) {
return;
}
this.frontBoxs[i] = new engine.Sprite(utils_1.getTextureByName('frontbox_' + i));
initX = this.frontBoxs[0].x = props_1.props.frontInitX;
initY = this.frontBoxs[0].y = props_1.props.frontInitY;
this.frontBoxs[i]['npcType'] = 'box' + i;
}
this.frontBoxs[props_1.props.dollNum] = new engine.Sprite(utils_1.getTextureByName('frontbox_0'));
this.frontBoxs[props_1.props.dollNum]['npcType'] = 'box' + props_1.props.dollNum;
console.log(this.frontBoxs);
for (var i = 0; i < this.frontBoxs.length; i++) {
if (i == 0) {
this.frontBoxs[i].x = initX;
}
else {
this.frontBoxs[i].x = this.frontBoxs[i - 1].x - this.frontBoxs[0].width - props_1.props.frontmargin;
}
console.log(this.frontBoxs[i].x);
this.frontBoxs[i].y = initY;
this.addChild(this.frontBoxs[i]);
console.log('aaa', this.frontBoxs[i].x);
}
this.addEventListener(engine.Event.ENTER_FRAME, this.frameMove, this);
};
FrontBoxs.prototype.frameMove = function () {
var _this = this;
this.frontBoxs.forEach(function (item, index) {
item.x += props_1.props.moveSpeed;
if (item.x <= 0 && !item.visible) {
item.visible = true;
}
if (item.x >= 750) {
var tmpIndex = 0;
if (index <= 0) {
tmpIndex = _this.frontBoxs.length - 1;
}
else {
tmpIndex = index - 1;
}
item.x = _this.frontBoxs[tmpIndex].x - _this.frontBoxs[0].width - props_1.props.frontmargin;
if (!_this.GameView.getMoveX() && item.x <= 0 && _this.GameView.startstatus) {
_this.GameView.setMoveX((370 - item.x - 13) / props_1.props.moveSpeed, item);
_this.hideBox = item;
}
}
});
};
FrontBoxs.prototype.stop = function () {
};
FrontBoxs.prototype.showHidePrizeBox = function (isshow) {
this.hideBox.visible = isshow;
};
return FrontBoxs;
}(engine.Container));
exports.FrontBoxs = FrontBoxs;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var Goods_1 = require("./Goods");
var ObjectPool = engine.ObjectPool;
exports.PoolName = 'goods';
ObjectPool.registerPool(exports.PoolName, function () {
return new Goods_1.Goods();
}, function (item, data) {
item.reset();
});
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
function getTexture(uuid) {
return engine.Texture.from(getAssetByUUID(uuid).uuid);
}
exports.getTexture = getTexture;
function getTextureByName(name) {
return getTexture(engine.getAssetByName(name).uuid);
}
exports.getTextureByName = getTextureByName;
function playSound(name) {
engine.playSound(engine.getAssetByName(name).uuid, { keep: true });
}
exports.playSound = playSound;
function createSvga(name, anchorName) {
var inst = new svga.Svga();
inst.source = 'asset://' + engine.getAssetByName(name).uuid;
return inst;
}
exports.createSvga = createSvga;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var GameWrapper_1 = require("./game/GameWrapper");
var props_1 = require("./props");
function default_1(props) {
props_1.prepareProps();
props_1.injectProps(props);
var instance = new GameWrapper_1.GameWrapper();
return instance;
}
exports.default = default_1;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.props = {};
function prepareProps() {
var metaProps = getProps();
engine.injectProp(exports.props, metaProps);
}
exports.prepareProps = prepareProps;
function injectProps(p) {
engine.injectProp(exports.props, p);
}
exports.injectProps = injectProps;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var utils_1 = require("./utils");
var LoopComponent_1 = require("./LoopComponent");
var props_1 = require("./../props");
var Background = (function (_super) {
__extends(Background, _super);
function Background() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this.partResHHL = ['hhl_after', 'hhl_front'];
_this.partResHB = ['hb_after', 'hb_front'];
_this.partResWH = ['wh_after', 'wh_front'];
_this.speeds = [];
_this.resArray = [];
_this.frameMovePos = 0;
return _this;
}
Background.prototype.initBg = function () {
this.sumMovePos = 0;
this.speeds.push(props_1.props.afterBGMoveSpeed);
this.speeds.push(props_1.props.frontBGMoveSpeed);
var bottomBg = new engine.Rect();
bottomBg.x = 0;
bottomBg.y = 0;
bottomBg.width = utils_1.getStage().width;
bottomBg.height = 0;
bottomBg.fillColor = 0x75c9f5;
this.addChild(bottomBg);
this.resArray.push(this.partResHHL);
this.resArray.push(this.partResHB);
this.resArray.push(this.partResWH);
this._bgIndex = 0;
var parts = [];
for (var i = 0; i < 2; i++) {
var part = new LoopComponent_1.LoopComponent();
part.setupLoop([
this.resArray[0][i],
this.resArray[0][i],
]);
parts.push(part);
this.addChild(part);
}
parts[1].y = 200;
};
Background.prototype.setViewport = function (pos) {
this.needFrameSum = (props_1.props.pierMoveTime / 1000) * 60;
this.frameMovePos = pos / this.needFrameSum;
this.frameIndex = 0;
this.addEventListener(engine.Event.ENTER_FRAME, this.frameBack, this);
};
Background.prototype.frameBack = function () {
if (this.frameIndex < this.needFrameSum) {
for (var i = 0; i < 2; i++) {
var part = this.getChildAt(i + 1);
var speed = this.speeds[i];
var tmpPos = ((this.frameMovePos * this.frameIndex) + this.sumMovePos) * speed;
part.setViewport(tmpPos);
}
this.frameIndex++;
}
else {
this.sumMovePos += this.frameMovePos * this.needFrameSum;
this.frameIndex = 0;
this.removeEventListener(engine.Event.ENTER_FRAME, this.frameBack, this);
}
};
Background.prototype.changeBg = function (index) {
for (var i = 0; i < 2; i++) {
var part = this.getChildAt(i + 1);
part.changeBg(this.resArray[index][i]);
if (i == 1 && index == 1) {
part.y = 400;
}
if (i == 1 && index == 2) {
part.y = 250;
}
}
this._bgIndex = index;
};
Background.prototype.getBgIndex = function () {
return this._bgIndex;
};
return Background;
}(engine.Container));
exports.Background = Background;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var Road_1 = require("./Road");
var props_1 = require("../props");
var utils_1 = require("./utils");
var GuideLayer_1 = require("./GuideLayer");
var Background_1 = require("./Background");
var ObjectPool = engine.ObjectPool;
var Pier_1 = require("./Pier");
var Player_1 = require("./Player");
var Strut_1 = require("./Strut");
var ScoreLabel_1 = require("./ScoreLabel");
exports.PoolName = 'pier';
ObjectPool.registerPool(exports.PoolName, function () {
return new Pier_1.Pier();
}, function (item, data) {
item.init();
});
var GameView = (function (_super) {
__extends(GameView, _super);
function GameView() {
var _this = _super.call(this) || this;
_this.moveX = 0;
_this.once(engine.Event.ADDED_TO_STAGE, _this.setup, _this);
return _this;
}
GameView.prototype.setup = function () {
if (this._hasSetup) {
return;
}
this._hasSetup = true;
this._backgroud = new Background_1.Background();
this.addChild(this._backgroud);
this._backgroud.initBg();
var road = this._road = new Road_1.Road();
this.addChild(road);
road.setup();
var pierWidth = this._road.getFristPier();
var player = this._player = new Player_1.Player();
this.addChild(player);
player.initPlayer(pierWidth);
var strut = this._strut = new Strut_1.Strut();
this.addChild(strut);
strut.init();
this._scoreContainer = new engine.Container();
this.addChild(this._scoreContainer);
this.initLabScore();
};
GameView.prototype.start = function (guide) {
return __awaiter(this, void 0, void 0, function () {
var initScore;
return __generator(this, function (_a) {
this._isTouchLayer = true;
this._sumScore = 0;
this._isMouseDown = false;
this._guide = guide;
initScore = this._road.getStartGold(0) ? props_1.props.goldScore : 0;
this.updateScore(initScore);
if (this._guide == '1') {
this.setGuide();
}
else {
this.initTouch();
this.registerEvent();
}
return [2];
});
});
};
GameView.prototype.setGuide = function () {
var _this = this;
this._road.setGuide();
var guideLayer = this.guideLayer = new GuideLayer_1.GuideLayer();
this.addChild(guideLayer);
this.guideLayer.show(1, { x: 20, y: 650, guideText: props_1.props.guideText1 }, function () {
var posX = _this._road.getMovePos();
_this.guideLayer.show(2, { x: posX + 20, y: 620, guideText: props_1.props.guideText2 }, function () {
_this.initTouch();
_this.registerEvent();
});
});
};
GameView.prototype.initLabScore = function () {
var scoreBg = new engine.Sprite(utils_1.getTextureByName('scoreBg'));
scoreBg.x = utils_1.getStage().width / 2 - scoreBg.width / 2;
scoreBg.y = 80;
var scoreHint = new engine.Sprite(utils_1.getTextureByName('scoreHint'));
scoreHint.x = utils_1.getStage().width / 2 - scoreHint.width / 2;
scoreHint.y = 40;
this._scoreContainer.addChild(scoreHint);
this.labScore = new ScoreLabel_1.ScoreLabel();
this.labScore.fillColor = 0xff7646;
this.labScore.size = 70;
this.labScore.width = utils_1.getStage().width;
this.labScore.height = scoreBg.height;
this.labScore.textAlign = engine.TEXT_ALIGN.CENTER;
this.labScore.x = 0;
this.labScore.y = scoreBg.y + 10;
this._scoreContainer.addChild(this.labScore);
};
GameView.prototype.registerEvent = function () {
this._touchLayer.addEventListener(engine.MouseEvent.MOUSE_DOWN, this.onMouseDown, this);
this._touchLayer.addEventListener(engine.MouseEvent.MOUSE_UP, this.onMouseUp, this);
};
GameView.prototype.removeListener = function () {
this._touchLayer.removeEventListener(engine.MouseEvent.MOUSE_DOWN, this.onMouseDown, this);
this._touchLayer.removeEventListener(engine.MouseEvent.MOUSE_UP, this.onMouseUp, this);
};
GameView.prototype.initTouch = function () {
this._touchLayer = new engine.Rect();
this.addChild(this._touchLayer);
this._touchLayer.width = utils_1.getStage().width;
this._touchLayer.height = utils_1.getStage().height;
this._touchLayer.x = 0;
this._touchLayer.y = 0;
this._touchLayer.alpha = 0;
};
GameView.prototype.setScoreShow = function () {
};
GameView.prototype.onMouseDown = function () {
if (this._isTouchLayer) {
this._isMouseDown = true;
this._strut.onMouseDown(this._road.getFristPier(), this._road.getDistance(), this.goCallBcak.bind(this));
}
};
GameView.prototype.onMouseUp = function () {
if (this._isTouchLayer && this._isMouseDown) {
this._strut.onMouseUp();
this._isMouseDown = false;
this._isTouchLayer = false;
}
};
GameView.prototype.goCallBcak = function (isSuccess) {
var _this = this;
if (isSuccess) {
console.log('成功了');
var movePos = this._road.getMovePos();
if (this._road.getStartGold(1, false)) {
this.updateScore(props_1.props.singleScore + props_1.props.goldScore);
}
else {
this.updateScore(props_1.props.singleScore);
}
this._player.setViewport(movePos, this.complete.bind(this));
}
else {
console.log('失败了');
this._player.setViewport(this._strut.getStrutHeight(), function () {
console.log('掉下去了');
engine.globalEvent.dispatchEvent('dxbcyj-game-result', { score: _this._sumScore });
}, this._road.getFristPier());
}
};
GameView.prototype.complete = function () {
var _this = this;
this._road.getStartGold(1);
var movePos = this._road.getMovePos();
this._road.setViewport();
this._backgroud.setViewport(movePos);
this._player.setBackViewport(function () {
_this._isTouchLayer = true;
});
this.closeStrut();
};
GameView.prototype.closeStrut = function () {
this._strut.rest();
};
GameView.prototype.updateScore = function (score) {
this._sumScore += score;
if (0 <= this._sumScore && this._sumScore <= props_1.props.bgFristScore) {
this.changeBg(0);
}
else if (props_1.props.bgFristScore < this._sumScore && this._sumScore <= props_1.props.bgSecondScore) {
this.changeBg(1);
}
else {
this.changeBg(2);
}
this.labScore.updateScore(this._sumScore);
};
GameView.prototype.getScore = function () {
return this._sumScore;
};
GameView.prototype.changeBg = function (index) {
if (this._backgroud.getBgIndex() != index) {
this._backgroud.changeBg(index);
}
};
return GameView;
}(engine.Container));
exports.default = GameView;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var GameView_1 = require("./GameView");
var GameWrapper = (function (_super) {
__extends(GameWrapper, _super);
function GameWrapper() {
var _this = _super.call(this) || this;
engine.globalEvent.addEventListener('dxbcyj-game-start', _this.start, _this);
var gameView = _this._gameView = new GameView_1.default();
_this.addChild(gameView);
return _this;
}
GameWrapper.prototype.start = function (event) {
this._gameView.start(event.data.guide);
};
return GameWrapper;
}(engine.Container));
exports.GameWrapper = GameWrapper;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var props_1 = require("../props");
var utils_1 = require("./utils");
var GuideLayer = (function (_super) {
__extends(GuideLayer, _super);
function GuideLayer() {
var _this = _super.call(this) || this;
_this._canClear = [];
_this.setup();
return _this;
}
GuideLayer.prototype.setup = function () {
};
GuideLayer.prototype.show = function (id, options, callback) {
this.visible = true;
this._callBack = callback ? callback : null;
if (!this.guideMask) {
this._options = options;
var _a = this.stage, width = _a.width, height = _a.height;
var guideMask = this.guideMask = new engine.Container();
var guideHole = this._guideHole = new engine.Image(utils_1.getTextureByName('guide'));
guideHole.x = options.x;
guideHole.y = options.y;
guideHole.width = 250;
guideHole.height = 250;
guideHole.name = 'guideHole';
guideMask.addChild(guideHole);
this.createRect(guideMask, 0, 0, width, guideHole.y);
this.createRect(guideMask, 0, guideHole.y, guideHole.x, guideHole.height);
this.createRect(guideMask, guideHole.x + guideHole.width, guideHole.y, width - guideHole.x - guideHole.width, guideHole.height);
this.createRect(guideMask, 0, guideHole.y + guideHole.height, width, height - guideHole.y - guideHole.height);
this.guideStep(id);
var label = this.label = new engine.Label();
label.fillColor = 'white';
label.size = 30;
label.text = options.guideText;
label.x = (width - label.width) / 2;
label.y = guideHole.y + guideHole.height + 50;
label.textAlign = engine.TEXT_ALIGN.CENTER;
label.name = 'labHint';
guideMask.addChild(label);
this.addChild(guideMask);
}
this.once(engine.MouseEvent.CLICK, function () {
this.removeChild(this.guideMask);
this.guideMask = null;
if (this._callBack) {
this._callBack();
}
}, this);
};
GuideLayer.prototype.createRect = function (container, x, y, width, height) {
var rect = new engine.Rect();
rect.x = x;
rect.y = y;
rect.width = width;
rect.height = height;
rect.fillColor = 'black';
rect.alpha = 0.7;
container.addChild(rect);
};
GuideLayer.prototype.guideStep = function (id) {
if (id == 1) {
var guideHand = new engine.Image(utils_1.getTextureByName('guideHand'));
guideHand.x = this._options.x + 300;
guideHand.y = this._options.y + 100;
this.guideMask.addChild(guideHand);
var rect = new engine.Rect();
rect.x = this._options.x + 200;
rect.y = this._options.y - 15;
rect.width = props_1.props.strutWidth;
rect.height = 200;
rect.fillColor = props_1.props.strutColor;
this.guideMask.addChild(rect);
this._canClear.push(guideHand);
this._canClear.push(rect);
}
if (id == 2) {
var know = new engine.Image(utils_1.getTextureByName('know'));
know.x = (this.stage.width - know.width) / 2;
know.y = this._options.y + 400;
this.guideMask.addChild(know);
this._canClear.push(know);
}
};
return GuideLayer;
}(engine.Container));
exports.GuideLayer = GuideLayer;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var utils_1 = require("./utils");
var LoopComponent = (function (_super) {
__extends(LoopComponent, _super);
function LoopComponent() {
var _this = _super.call(this) || this;
_this.onceInfo = { width: 0, height: 0, count: 0 };
_this.loopInfo = { width: 0, height: 0, count: 0 };
_this.parts = [];
return _this;
}
LoopComponent.prototype.setup = function (parts, info) {
var _this = this;
parts.forEach(function (item, index) {
var part;
if (typeof item == 'string') {
part = new engine.Sprite(utils_1.getTextureByName(item));
}
else if (item instanceof engine.Texture) {
part = new engine.Sprite(item);
}
else {
part = item;
}
_this.addChild(part);
_this.parts.push(part);
if (index == 0) {
info.width = part.width;
info.height = part.height;
}
});
info.count = parts.length;
this.setViewport(0, 0);
};
LoopComponent.prototype.changeBg = function (changName) {
this.parts.forEach(function (item, index) {
item.texture = utils_1.getTextureByName(changName);
});
};
LoopComponent.prototype.setupLoop = function (resArr) {
this.setup(resArr, this.loopInfo);
};
LoopComponent.prototype.setViewport = function (x, y) {
if (y === void 0) { y = 0; }
var sizeField = y == 0 ? 'width' : 'height';
var posField = y == 0 ? 'x' : 'y';
var pos = y == 0 ? x : y;
var index;
var onceSize = this.onceInfo[sizeField];
var onceCount = this.onceInfo.count;
var loopCount = this.loopInfo.count;
var loopSize = this.loopInfo[sizeField];
index = onceSize == 0 ? -1 : Math.floor(pos / onceSize);
if (index < 0 || index >= onceCount) {
var loopIndex = Math.floor((pos - onceCount * onceSize) / this.loopInfo[sizeField]);
index = onceCount + loopIndex;
}
var formerIndex = index < onceCount ? index : (index) % loopCount + onceCount;
var latterIndex = index < onceCount ? index + 1 : (index - onceCount + 1) % loopCount + onceCount;
var former = this.parts[formerIndex];
var latter = this.parts[latterIndex];
if (!former || !latter) {
console.log(formerIndex, latterIndex);
}
former[posField] = -(pos - loopSize * (index < onceCount ? index : index - onceCount) - (index < onceCount ? 0 : onceCount * onceSize));
latter[posField] = former.x + (index < onceCount ? onceSize : loopSize);
};
return LoopComponent;
}(engine.Container));
exports.LoopComponent = LoopComponent;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var props_1 = require("./../props");
var utils_1 = require("./utils");
var Pier = (function (_super) {
__extends(Pier, _super);
function Pier() {
var _this = _super.call(this) || this;
_this.bmp = new engine.Sprite();
_this.addChild(_this.bmp);
return _this;
}
Pier.prototype.init = function () {
var bmp = this.bmp;
bmp.alpha = 1;
bmp.texture = utils_1.getTextureByName('pier');
bmp.x = 0;
bmp.y = bmp.height;
if (this.children.length < 2) {
var gold = new engine.Sprite();
gold.texture = utils_1.getTextureByName('gold');
gold.name = 'gold';
this.addChild(gold);
}
this.setGoldPosX(bmp);
this.setShowGold();
};
Pier.prototype.setShowGold = function () {
var nodeGold = this.getChildByName('gold');
var randomWard = Math.random();
nodeGold.alpha = 1;
var isShow = randomWard < props_1.props.reward ? true : false;
nodeGold.visible = isShow;
this.haveGold = isShow;
};
Pier.prototype.setGoldPosX = function (bmp) {
var nodeGold = this.getChildByName('gold');
var pos = bmp.width / 2 - nodeGold.width / 2;
nodeGold.x = pos;
nodeGold.y = bmp.height - nodeGold.height - 50;
nodeGold.visible = false;
};
Pier.prototype.closeGold = function () {
var _this = this;
this.children.forEach(function (item) {
if (item.name == 'gold') {
item.anchorX = item.width / 2;
item.anchorY = item.height / 2;
engine.Tween.get(item, { loop: false })
.to({ scaleX: 2.5, scaleY: 2.5 }, 200, engine.Ease.cubicOut)
.to({ scaleX: 1, scaleY: 1, alpha: 0 }, 200, engine.Ease.cubicIn)
.call(function () {
item.visible = false;
_this.haveGold = false;
});
}
});
};
return Pier;
}(engine.Container));
exports.Pier = Pier;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var props_1 = require("../props");
var utils_1 = require("./utils");
var Player = (function (_super) {
__extends(Player, _super);
function Player() {
return _super !== null && _super.apply(this, arguments) || this;
}
Player.prototype.initPlayer = function (pierWidth) {
this._container = new engine.Container();
this.addChild(this._container);
this.playerNode = utils_1.createSvga('walk');
this._container.addChild(this.playerNode);
this.playerNode.y = 675;
this.playerNode.x = pierWidth / 2 - 80;
this.playerNode.play();
};
Player.prototype.setViewport = function (pos, callBack, pierWidth) {
var tmpPos = 0;
var isSuccess = false;
if (!pierWidth) {
tmpPos = pos;
isSuccess = true;
}
else {
tmpPos = pierWidth - this.playerNode.x + pos - 60;
}
this.playGoTween(tmpPos, callBack, isSuccess);
};
Player.prototype.playGoTween = function (pos, callBack, isSuccess) {
var _this = this;
engine.Tween.get(this._container, { loop: false })
.to({ x: pos }, props_1.props.playerMoveSpeed)
.call(function () {
engine.Tween.removeTweens(_this._container);
if (isSuccess) {
if (callBack) {
callBack();
}
}
else {
_this.playDropTween(callBack);
}
});
};
Player.prototype.playDropTween = function (callBack) {
var _this = this;
engine.Tween.get(this._container, { loop: false })
.to({ y: 2000 }, 1000)
.call(function () {
engine.Tween.removeTweens(_this._container);
if (callBack) {
callBack();
}
});
};
Player.prototype.setBackViewport = function (callBack) {
var _this = this;
engine.Tween.get(this._container, { loop: false })
.to({ x: 0 }, props_1.props.pierMoveTime)
.call(function () {
engine.Tween.removeTweens(_this._container);
if (callBack) {
callBack();
}
});
};
return Player;
}(engine.Container));
exports.Player = Player;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var props_1 = require("./../props");
var ObjectPool = engine.ObjectPool;
var Road = (function (_super) {
__extends(Road, _super);
function Road() {
return _super !== null && _super.apply(this, arguments) || this;
}
Road.prototype.setup = function () {
this.lastPos = 0;
this.addPier();
};
Road.prototype.getFristPier = function () {
return this.getChildAt(0).width;
};
Road.prototype.getDistance = function () {
var distance = [];
var pier1 = this.getChildAt(0);
var pier2 = this.getChildAt(1);
distance.push(pier2.x - pier1.x);
distance.push(pier2.width);
return distance;
};
Road.prototype.addPier = function () {
while (this.children.length < props_1.props.pierCount + 1) {
var childrenNum = this.children.length;
var randomPos = this.makeRandomFloat(props_1.props.pierMaxDistance, props_1.props.pierMinDistance);
var pier = ObjectPool.getObject('pier');
this.addChild(pier);
if (childrenNum == 0) {
pier.x = 0;
}
else {
pier.x = this.lastPos + randomPos;
}
this.lastPos = pier.x;
}
};
Road.prototype.moveAddPier = function () {
var randomPos = this.makeRandomFloat(props_1.props.pierMaxDistance, props_1.props.pierMinDistance);
var pier = ObjectPool.getObject('pier');
var lastChild = this.getChildAt(this.children.length - 1);
pier.x = lastChild.x + randomPos;
this.addChild(pier);
};
Road.prototype.makeRandomFloat = function (max, min) {
if (min === void 0) { min = 0; }
return Math.random() * (max - min) + min;
};
Road.prototype.setViewport = function () {
var _this = this;
var tmpMovepos = this.getMovePos();
this.children.forEach(function (item, index) {
_this.playTween(item, index, tmpMovepos);
});
};
Road.prototype.getMovePos = function () {
var movePos = this.getChildAt(1);
return movePos.x;
};
Road.prototype.playTween = function (item, index, tmpMovepos) {
var _this = this;
engine.Tween.get(item, { loop: false })
.to({ x: item.x - tmpMovepos }, props_1.props.pierMoveTime)
.call(function () {
if (_this.getChildIndex(item) == 0) {
engine.Tween.removeTweens(item);
_this.removeChild(item);
ObjectPool.recycleObject('pier', item);
}
if (index == 0) {
_this.moveAddPier();
}
});
};
Road.prototype.getStartGold = function (index, isClose) {
if (isClose === void 0) { isClose = true; }
var tmpNode = this.getChildAt(index);
var haveGold = tmpNode.haveGold;
if (haveGold && isClose) {
tmpNode.closeGold();
}
return haveGold;
};
Road.prototype.setGuide = function () {
var tmpNode = this.getChildAt(1);
if (!tmpNode.haveGold) {
tmpNode.children.forEach(function (item) {
if (item.name == 'gold') {
item.visible = true;
}
});
tmpNode.haveGold = true;
}
};
return Road;
}(engine.Container));
exports.Road = Road;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var ScoreLabel = (function (_super) {
__extends(ScoreLabel, _super);
function ScoreLabel() {
return _super !== null && _super.apply(this, arguments) || this;
}
ScoreLabel.prototype.updateScore = function (score, animation) {
if (animation === void 0) { animation = true; }
this._value = score;
if (animation && this._tmp) {
this.animationUpdate();
}
else {
this.updateLocal(score);
}
};
ScoreLabel.prototype.animationUpdate = function () {
var _this = this;
var tmpInterval = setInterval(function () {
_this._tmp += 1;
if (_this._tmp <= _this._value) {
_this.text = _this._tmp;
}
else {
_this._tmp = _this._value;
clearInterval(tmpInterval);
}
}, 50);
};
ScoreLabel.prototype.updateLocal = function (v) {
this._tmp = v;
this.text = v;
};
return ScoreLabel;
}(engine.Label));
exports.ScoreLabel = ScoreLabel;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var props_1 = require("../props");
var Strut = (function (_super) {
__extends(Strut, _super);
function Strut() {
return _super !== null && _super.apply(this, arguments) || this;
}
Strut.prototype.init = function () {
this._strut = new engine.Rect();
this.addChild(this._strut);
this._strut.width = props_1.props.strutWidth;
this._strut.y = 833;
this._strut.fillColor = props_1.props.strutColor;
this._strut.rotation = 180;
};
Strut.prototype.onMouseDown = function (pierWidth, distance, callBack) {
this._strut.x = pierWidth - 60;
this._distance = distance;
this._callBack = callBack;
this._strut.visible = true;
this.addEventListener(engine.Event.ENTER_FRAME, this.frameStrut, this);
};
Strut.prototype.onMouseUp = function () {
var _this = this;
this.removeEventListener(engine.Event.ENTER_FRAME, this.frameStrut, this);
setTimeout(function () {
_this.strutRotation();
}, 200);
};
Strut.prototype.strutRotation = function () {
var _this = this;
engine.Tween.get(this._strut, { loop: false })
.to({ rotation: 270 }, props_1.props.strutRotationSpeed)
.call(function () {
_this.judgeResult();
engine.Tween.removeTweens(_this._strut);
});
};
Strut.prototype.judgeResult = function () {
var isSuccess = false;
if (this._distance[0] - this._distance[1] + 100 <= this._strut.height && this._strut.height <= this._distance[0] + 20) {
isSuccess = true;
}
if (this._callBack) {
this._callBack(isSuccess);
}
};
Strut.prototype.frameStrut = function () {
if (this._strut.height < 1000) {
this._strut.height += props_1.props.strutUpSpeed;
}
};
Strut.prototype.rest = function () {
this._strut.width = props_1.props.strutWidth;
this._strut.y = 833;
this._strut.fillColor = props_1.props.strutColor;
this._strut.rotation = 180;
this._strut.height = 0;
this._strut.visible = false;
};
Strut.prototype.getStrutHeight = function () {
var distance = this._strut.height > 1000 ? 1000 : this._strut.height;
return distance;
};
return Strut;
}(engine.Container));
exports.Strut = Strut;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var Pier_1 = require("./Pier");
var ObjectPool = engine.ObjectPool;
exports.PoolName = 'pier';
ObjectPool.registerPool(exports.PoolName, function () {
return new Pier_1.Pier();
}, function (item, data) {
item.init();
});
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
function getTexture(uuid) {
return engine.Texture.from(getAssetByUUID(uuid).uuid);
}
exports.getTexture = getTexture;
function getTextureByName(name) {
return getTexture(engine.getAssetByName(name).uuid);
}
exports.getTextureByName = getTextureByName;
function playSound(name) {
engine.playSound(engine.getAssetByName(name).uuid, { keep: true });
}
exports.playSound = playSound;
function getStage() {
return engine.gameStage.stage;
}
exports.getStage = getStage;
function createSvga(name) {
var inst = new svga.Svga();
inst.source = engine.getAssetByName(name).uuid;
return inst;
}
exports.createSvga = createSvga;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var GameWrapper_1 = require("./game/GameWrapper");
var props_1 = require("./props");
function default_1(props) {
props_1.prepareProps();
props_1.injectProps(props);
var instance = new GameWrapper_1.GameWrapper();
return instance;
}
exports.default = default_1;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.props = {};
function prepareProps() {
var metaProps = getProps();
engine.injectProp(exports.props, metaProps);
}
exports.prepareProps = prepareProps;
function injectProps(p) {
engine.injectProp(exports.props, p);
}
exports.injectProps = injectProps;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var props_1 = require("../props");
var utils_1 = require("./utils");
var GameView = (function (_super) {
__extends(GameView, _super);
function GameView() {
var _this = _super.call(this) || this;
_this.once(engine.Event.ADDED_TO_STAGE, _this.setup, _this);
return _this;
}
GameView.prototype.setup = function () {
if (this._hasSetup) {
return;
}
this._hasSetup = true;
this.NpcBg = new engine.Container();
this.NpcBg.x = props_1.props.initX;
this.NpcBg.y = props_1.props.initY;
this.addChild(this.NpcBg);
this.bottomCircle = new engine.Sprite(utils_1.getTextureByName('底座'));
this.bottomCircle.x = 17;
this.bottomCircle.y = 305;
this.loveDot = new engine.Sprite(utils_1.getTextureByName('点缀'));
this.loveDot.x = 0;
this.loveDot.y = 6;
this.giftboxSvga = utils_1.createSvga('初始礼盒');
this.giftboxSvga.x = 105;
this.giftboxSvga.y = 37;
this.giftAfterSvga = utils_1.createSvga("拆礼盒");
this.giftAfterSvga.x = 105;
this.giftAfterSvga.y = 0;
this.giftAfterSvga.visible = false;
this.NpcBg.addChild(this.bottomCircle);
this.NpcBg.addChild(this.giftboxSvga);
this.NpcBg.addChild(this.giftAfterSvga);
this.NpcBg.addChild(this.loveDot);
this.giftboxSvga.play(false, true);
};
GameView.prototype.reset = function () {
this.giftboxSvga.visible = true;
this.giftAfterSvga.visible = false;
};
GameView.prototype.start = function () {
this.giftAfterSvga.visible = true;
this.giftboxSvga.visible = false;
this.giftAfterSvga.play(false, false);
this.giftAfterSvga.once(engine.Event.END_FRAME, function () {
engine.globalEvent.dispatchEvent('open-gift-game-end');
}, this);
};
GameView.prototype.resume = function () {
this.reset();
this.start();
};
return GameView;
}(engine.Container));
exports.default = GameView;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var GameView_1 = require("./GameView");
var props_1 = require("../props");
var GameWrapper = (function (_super) {
__extends(GameWrapper, _super);
function GameWrapper() {
var _this = _super.call(this) || this;
engine.globalEvent.addEventListener('open-gift-game-init', _this.reset, _this);
engine.globalEvent.addEventListener('open-gift-game-start', _this.start, _this);
var gameView = _this._gameView = new GameView_1.default();
_this.addChild(gameView);
return _this;
}
GameWrapper.prototype.reset = function (event) {
props_1.injectProps(event.data);
this._gameView.visible = true;
this._gameView.reset();
};
GameWrapper.prototype.start = function (event) {
console.log('监听开始');
props_1.injectProps(event.data);
this._gameView.start();
};
GameWrapper.prototype.clear = function () {
this._gameView.visible = false;
};
return GameWrapper;
}(engine.Container));
exports.GameWrapper = GameWrapper;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
function getTexture(uuid) {
return engine.Texture.from(getAssetByUUID(uuid).uuid);
}
exports.getTexture = getTexture;
function getTextureByName(name) {
return getTexture(engine.getAssetByName(name).uuid);
}
exports.getTextureByName = getTextureByName;
function playSound(name) {
engine.playSound(engine.getAssetByName(name).uuid, { keep: true });
}
exports.playSound = playSound;
function createSvga(name, anchorName) {
var inst = new svga.Svga();
inst.source = 'asset://' + engine.getAssetByName(name).uuid;
return inst;
}
exports.createSvga = createSvga;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var GameWrapper_1 = require("./game/GameWrapper");
var props_1 = require("./props");
function default_1(props) {
props_1.prepareProps();
props_1.injectProps(props);
var instance = new GameWrapper_1.GameWrapper();
return instance;
}
exports.default = default_1;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.props = {};
function prepareProps() {
var metaProps = getProps();
engine.injectProp(exports.props, metaProps);
}
exports.prepareProps = prepareProps;
function injectProps(p) {
engine.injectProp(exports.props, p);
}
exports.injectProps = injectProps;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var utils_1 = require("./utils");
var LoopComponent_1 = require("./LoopComponent");
var utils_2 = require("./utils");
var Background = (function (_super) {
__extends(Background, _super);
function Background() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this.partRes = ['bg_far', 'bg_mid', 'bg_near'];
_this.speeds = [0.05, 0.5, 1];
return _this;
}
Background.prototype.setup = function () {
var bottomBg = new engine.Rect();
bottomBg.x = 0;
bottomBg.y = 0;
bottomBg.width = utils_2.getStage().width;
bottomBg.height = 0;
bottomBg.fillColor = 0x75c9f5;
this.addChild(bottomBg);
var parts = [];
for (var i = 0; i < 3; i++) {
var part = new LoopComponent_1.LoopComponent();
part.setupLoop([
this.partRes[i],
this.partRes[i],
]);
parts.push(part);
this.addChild(part);
}
var height = utils_2.getStage().height;
parts[0].y = (height - parts[0].height) / 2 - 400;
parts[1].y = (height - parts[1].height) / 2 - 120;
parts[2].y = (height - parts[2].height) / 2 + 300;
bottomBg.y = parts[2].y;
bottomBg.height = height - parts[2].y;
var moon = new engine.Sprite(utils_1.getTextureByName('moon'));
moon.x = 100;
moon.y = 100;
this.addChild(moon);
};
Background.prototype.setViewport = function (pos) {
for (var i = 0; i < 3; i++) {
var part = this.getChildAt(i + 1);
var speed = this.speeds[i];
part.setViewport(pos * speed);
}
};
Background.prototype.reset = function (revive) {
if (revive === void 0) { revive = false; }
};
return Background;
}(engine.Container));
exports.Background = Background;
This diff is collapsed.
This diff is collapsed.
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var GameView_1 = require("./GameView");
var props_1 = require("../props");
var GameWrapper = (function (_super) {
__extends(GameWrapper, _super);
function GameWrapper() {
var _this = _super.call(this) || this;
engine.globalEvent.addEventListener('walking-cat-start', _this.start, _this);
engine.globalEvent.addEventListener('walking-cat-revive', _this.revive, _this);
engine.globalEvent.addEventListener('walking-cat-showScore', _this.revive, _this);
var gameView = _this._gameView = new GameView_1.default();
_this.addChild(gameView);
return _this;
}
GameWrapper.prototype.start = function (event) {
props_1.injectProps(event.data);
this._gameView.eventStart();
};
GameWrapper.prototype.revive = function () {
console.log('复活');
this._gameView.reset(true);
this._gameView.start(true);
};
return GameWrapper;
}(engine.Container));
exports.GameWrapper = GameWrapper;
This diff is collapsed.
This diff is collapsed.
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var Block_1 = require("./Block");
var ObjectPool = engine.ObjectPool;
exports.PoolName = 'block';
ObjectPool.registerPool(exports.PoolName, function () {
return new Block_1.Block();
}, function (item, data) {
item.reset(data);
});
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
function getTexture(uuid) {
return engine.Texture.from(getAssetByUUID(uuid).uuid);
}
exports.getTexture = getTexture;
function getTextureByName(name) {
return getTexture(engine.getAssetByName(name).uuid);
}
exports.getTextureByName = getTextureByName;
function playSound(name) {
engine.playSound(engine.getAssetByName(name).uuid, { keep: true });
}
exports.playSound = playSound;
function getStage() {
return engine.gameStage.stage;
}
exports.getStage = getStage;
function getfactor() {
return 10;
}
exports.getfactor = getfactor;
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -10,7 +10,7 @@ declare type NodeClass =
declare const args: any;
declare const scope: any;
declare const props: ProcessProps;
declare const props: ProcessProps | any;
declare const target: NodeClass;
declare const global: {
gameStage: engine.GameStage,
......
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.
/**
* Created by rockyl on 2020-01-21.
*/
export let props: any = {};
export function prepareProps() {
let metaProps = getProps();
engine.injectProp(props, metaProps);
}
export function injectProps(p) {
engine.injectProp(props, p);
}
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.
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