Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Z
zeroing-libs
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
劳工
zeroing-libs
Commits
a9eac5bb
Commit
a9eac5bb
authored
Jun 15, 2020
by
wildfirecode
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1
parent
63f061c8
Changes
15
Show whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
310 additions
and
954 deletions
+310
-954
recycling.json
dist/customs/recycling.json
+1
-1
types.d.ts
libs/types.d.ts
+2
-1
GameView.ts
src/custom/pictures/src/game/GameView.ts
+2
-2
app.js
src/custom/recycling/debug/app.js
+2
-2
main.js
src/custom/recycling/debug/main.js
+1
-767
main.js.map
src/custom/recycling/debug/main.js.map
+1
-1
Conveyor.ts
src/custom/recycling/src/game/Conveyor.ts
+26
-14
Conveyors.ts
src/custom/recycling/src/game/Conveyors.ts
+214
-142
GameView.ts
src/custom/recycling/src/game/GameView.ts
+4
-4
Garbage.ts
src/custom/recycling/src/game/datas/Garbage.ts
+0
-14
GarbageTypes.ts
src/custom/recycling/src/game/datas/GarbageTypes.ts
+6
-5
transStores.ts
src/custom/recycling/src/game/datas/transStores.ts
+36
-0
checkHit.ts
src/custom/recycling/src/game/utils/checkHit.ts
+9
-0
removeChild.ts
src/custom/recycling/src/game/utils/removeChild.ts
+5
-0
RedPackRain.ts
src/custom/redpack-rain/src/game/RedPackRain.ts
+1
-1
No files found.
dist/customs/recycling.json
View file @
a9eac5bb
...
@@ -412,5 +412,5 @@
...
@@ -412,5 +412,5 @@
}
}
},
},
"id"
:
"recycling"
,
"id"
:
"recycling"
,
"code"
:
"
(function (global, factory) {
\n\t
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('tslib')) :
\n\t
typeof define === 'function' && define.amd ? define(['tslib'], factory) :
\n\t
(global = global || self, global.recycling = factory(global.tslib));
\n
}(this, (function (tslib) { 'use strict';
\n\n\t
function getTexture(uuid) {
\n\t
return engine.Texture.from(getAssetByUUID(uuid).uuid);
\n\t
}
\n\t
function getTextureByName(name) {
\n\t
return getTexture(engine.getAssetByName(name).uuid);
\n\t
}
\n\t
function 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\t
var props = {};
\n\t
function prepareProps() {
\n\t
var metaProps = getProps();
\n\t
engine.injectProp(props, metaProps);
\n\t
}
\n\t
function injectProps(p) {
\n\t
engine.injectProp(props, p);
\n\t
}
\n\t
//# sourceMappingURL=props.js.map
\n\n\t
var Conveyor = (function (_super) {
\n\t
tslib.__extends(Conveyor, _super);
\n\t
function Conveyor() {
\n\t
var _this = _super.call(this) || this;
\n\t
_this.y = 904.21;
\n\t
var sp = new engine.Sprite(getTextureByName('conveyor'));
\n\t
_this.addChild(sp);
\n\t
_this.idx0 = _this.createItem(75, 50);
\n\t
_this.idx1 = _this.createItem(225, 50);
\n\t
_this.idx2 = _this.createItem(375, 50);
\n\t
_this.idx3 = _this.createItem(525, 50);
\n\t
_this.idx4 = _this.createItem(675, 50);
\n\t
return _this;
\n\t
}
\n\t
Conveyor.prototype.createItem = function (x, y) {
\n\t
var sp = new engine.Sprite();
\n\t
this.addChild(sp);
\n\t
sp.x = x - 50;
\n\t
sp.y = y - 50;
\n\t
var g = new engine.Graphics;
\n\t
g.beginFill(0xff0000);
\n\t
g.drawRect(0, 0, 100, 100);
\n\t
g.endFill();
\n\t
sp.addChild(g);
\n\t
return sp;
\n\t
};
\n\t
return Conveyor;
\n\t
}(engine.Sprite));
\n\t
//# sourceMappingURL=Conveyor.js.map
\n\n\t
var uiConfig = (function () {
\n\t
return [
\n\t
{
\n\t
id: 'playBg',
\n\t
texture: 'playBg'
\n\t
},
\n\t
{
\n\t
id: 'idler0',
\n\t
texture: 'idlerWheel',
\n\t
pos: [75, 1038],
\n\t
anchor: [20, 21.5]
\n\t
},
\n\t
{
\n\t
id: 'idler1',
\n\t
texture: 'idlerWheel',
\n\t
pos: [175, 1038],
\n\t
anchor: [20, 21.5]
\n\t
},
\n\t
{
\n\t
id: 'idler2',
\n\t
texture: 'idlerWheel',
\n\t
pos: [275, 1038],
\n\t
anchor: [20, 21.5]
\n\t
},
\n\t
{
\n\t
id: 'idler3',
\n\t
texture: 'idlerWheel',
\n\t
pos: [375, 1038],
\n\t
anchor: [20, 21.5]
\n\t
},
\n\t
{
\n\t
id: 'idler4',
\n\t
texture: 'idlerWheel',
\n\t
pos: [475, 1038],
\n\t
anchor: [20, 21.5]
\n\t
},
\n\t
{
\n\t
id: 'idler5',
\n\t
texture: 'idlerWheel',
\n\t
pos: [575, 1038],
\n\t
anchor: [20, 21.5]
\n\t
},
\n\t
{
\n\t
id: 'idler6',
\n\t
texture: 'idlerWheel',
\n\t
pos: [675, 1038],
\n\t
anchor: [20, 21.5]
\n\t
},
\n\t
];
\n\t
});
\n\t
//# sourceMappingURL=uiConfig.js.map
\n\n\t
var getGuideInfo = (function () {
\n\t
if (!window.localStorage) {
\n\t
return 0;
\n\t
}
\n\t
return localStorage.getItem('recyclingGuide');
\n\t
});
\n\t
var setGuide = function () {
\n\t
if (window.localStorage)
\n\t
localStorage.setItem('recyclingGuide', '1');
\n\t
};
\n\t
//# sourceMappingURL=getGuideInfo.js.map
\n\n\t
var createBg = (function (a) {
\n\t
if (a === void 0) { a = 1; }
\n\t
var rect = new engine.Graphics();
\n\t
rect.beginFill(0);
\n\t
rect.drawRect(0, 0, 750, 1624);
\n\t
rect.endFill();
\n\t
rect.alpha = a;
\n\t
return rect;
\n\t
});
\n\t
//# sourceMappingURL=createBg.js.map
\n\n\t
var createImg = (function (texture) {
\n\t
return new engine.Sprite(getTextureByName(texture));
\n\t
});
\n\t
//# sourceMappingURL=createImg.js.map
\n\n\t
var CountDownGroup = (function (_super) {
\n\t
tslib.__extends(CountDownGroup, _super);
\n\t
function CountDownGroup() {
\n\t
var _this = _super.call(this) || this;
\n\t
_this.addChild(createBg(.6));
\n\t
_this.num1 = createImg('num1');
\n\t
_this.num2 = createImg('num2');
\n\t
_this.num3 = createImg('num3');
\n\t
_this.go = createImg('go');
\n\t
_this.go.anchorX = 240;
\n\t
_this.go.anchorY = 171.5;
\n\t
_this.num1.anchorX = 125.5;
\n\t
_this.num1.anchorY = 189;
\n\t
_this.num2.anchorX = 149.5;
\n\t
_this.num2.anchorY = 191.5;
\n\t
_this.num3.anchorX = 148.5;
\n\t
_this.num3.anchorY = 191.5;
\n\t
_this.go.x = 750 / 2 - 240;
\n\t
_this.go.y = 525 - 171.5;
\n\t
_this.num1.x = 750 / 2 - 125.5;
\n\t
_this.num1.y = 529 - 189;
\n\t
_this.num2.x = 750 / 2 - 149.5;
\n\t
_this.num2.y = 526 - 191.5;
\n\t
_this.num3.x = 750 / 2 - 148.5;
\n\t
_this.num3.y = 525 - 191.5;
\n\t
_this.addChild(_this.num1);
\n\t
_this.addChild(_this.num2);
\n\t
_this.addChild(_this.num3);
\n\t
_this.addChild(_this.go);
\n\t
_this.visible = false;
\n\t
_this.reset();
\n\t
return _this;
\n\t
}
\n\t
CountDownGroup.prototype.reset = function () {
\n\t
this.go.alpha = this.num1.alpha = this.num2.alpha = this.num3.alpha = 0;
\n\t
this.go.scaleX = this.num1.scaleX = this.num2.scaleX = this.num3.scaleX = 3;
\n\t
this.go.scaleY = this.num1.scaleY = this.num2.scaleY = this.num3.scaleY = 3;
\n\t
};
\n\t
CountDownGroup.prototype.startCountDown = function () {
\n\t
return tslib.__awaiter(this, void 0, void 0, function () {
\n\t
var _this = this;
\n\t
return tslib.__generator(this, function (_a) {
\n\t
return [2, new Promise(function (r) {
\n\t
_this.reset();
\n\t
_this.visible = true;
\n\t
_this.num3.alpha = 1;
\n\t
var n3 = engine.Tween.get(_this.num3);
\n\t
n3.to({ scaleX: 0.8, scaleY: 0.8 }, 200).to({ scaleX: 1, scaleY: 1 }, 100).wait(500).to({ scaleX: 0, scaleY: 0 }, 200).call(function () {
\n\t
_this.num2.alpha = 1;
\n\t
var n2 = engine.Tween.get(_this.num2);
\n\t
n2.to({ scaleX: 0.8, scaleY: 0.8 }, 200).to({ scaleX: 1, scaleY: 1 }, 100).wait(500).to({ scaleX: 0, scaleY: 0 }, 200).call(function () {
\n\t
_this.num1.alpha = 1;
\n\t
var n1 = engine.Tween.get(_this.num1);
\n\t
n1.to({ scaleX: 0.8, scaleY: 0.8 }, 200).to({ scaleX: 1, scaleY: 1 }, 100).wait(500).to({ scaleX: 0, scaleY: 0 }, 200).call(function () {
\n\t
_this.go.alpha = 1;
\n\t
var go = engine.Tween.get(_this.go);
\n\t
go.to({ scaleX: 0.8, scaleY: 0.8 }, 200).to({ scaleX: 1, scaleY: 1 }, 100).wait(500).call(function () {
\n\t
_this.visible = false;
\n\t
r();
\n\t
});
\n\t
});
\n\t
});
\n\t
});
\n\t
})];
\n\t
});
\n\t
});
\n\t
};
\n\t
return CountDownGroup;
\n\t
}(engine.Sprite));
\n\t
//# sourceMappingURL=CountDownGroup.js.map
\n\n\t
var GuideView = (function (_super) {
\n\t
tslib.__extends(GuideView, _super);
\n\t
function GuideView() {
\n\t
var _this = _super.call(this) || this;
\n\t
_this.initUI();
\n\t
_this.visible = false;
\n\t
return _this;
\n\t
}
\n\t
GuideView.prototype.initUI = function () {
\n\t
this.addChild(createBg(.6));
\n\t
this.guideBg = createImg('guideBg');
\n\t
this.addChild(this.guideBg);
\n\t
this.guideEle = createImg('guideEle');
\n\t
this.addChild(this.guideEle);
\n\t
this.guideBg.x = 393;
\n\t
this.guideBg.y = 552;
\n\t
this.guideEle.x = 361;
\n\t
this.guideEle.y = 877;
\n\t
this.guideEle.mouseEnabled = this.guideEle.mouseChildren = true;
\n\t
var svga = createSvga(
\"
guideTips
\"
);
\n\t
this.svga = svga;
\n\t
this.addChild(svga);
\n\t
svga.gotoAndStop(1);
\n\t
svga.mouseEnabled = svga.mouseChildren = false;
\n\t
};
\n\t
GuideView.prototype.checkHit = function (x, y, w, h) {
\n\t
var rect = new engine.Rectangle(393, 552, 281, 320);
\n\t
if (x > rect.x && y > rect.y && (x + w) < (rect.x + rect.width) && (y + h) < (rect.y + rect.height)) {
\n\t
return true;
\n\t
}
\n\t
return false;
\n\t
};
\n\t
GuideView.prototype.startGuide = function () {
\n\t
return tslib.__awaiter(this, void 0, void 0, function () {
\n\t
var _this = this;
\n\t
return tslib.__generator(this, function (_a) {
\n\t
return [2, new Promise(function (r) {
\n\t
_this.visible = true;
\n\t
_this.svga.gotoAndStop(1);
\n\t
_this.svga.play(false, true);
\n\t
_this.guideEle.scaleX = 1;
\n\t
_this.guideEle.scaleY = 1;
\n\t
var offset = [0, 0];
\n\t
var guideOver = function () {
\n\t
_this.guideEle.removeEventListener(engine.MouseEvent.MOUSE_DOWN, ondown, _this);
\n\t
engine.Tween.get(_this.guideEle).to({ scaleX: 0, scaleY: 0 }, 300).call(function () {
\n\t
_this.visible = false;
\n\t
r();
\n\t
});
\n\t
};
\n\t
var onUp = function (e) {
\n\t
_this.stage.removeEventListener(engine.MouseEvent.MOUSE_MOVE, onMove, _this);
\n\t
if (_this.checkHit(_this.guideEle.x, _this.guideEle.y, _this.guideEle.width, _this.guideEle.height)) {
\n\t
guideOver();
\n\t
}
\n\t
else {
\n\t
_this.svga.visible = true;
\n\t
_this.guideEle.x = 361;
\n\t
_this.guideEle.y = 877;
\n\t
}
\n\t
};
\n\t
var onMove = function (e) {
\n\t
_this.guideEle.x = e.stageX - offset[0];
\n\t
_this.guideEle.y = e.stageY - offset[1];
\n\t
};
\n\t
var ondown = function (e) {
\n\t
offset = [e.localX, e.localY];
\n\t
_this.svga.visible = false;
\n\t
_this.stage.once(engine.MouseEvent.MOUSE_UP, onUp, _this);
\n\t
_this.stage.addEventListener(engine.MouseEvent.MOUSE_MOVE, onMove, _this);
\n\t
};
\n\t
_this.guideEle.addEventListener(engine.MouseEvent.MOUSE_DOWN, ondown, _this);
\n\t
})];
\n\t
});
\n\t
});
\n\t
};
\n\t
return GuideView;
\n\t
}(engine.Sprite));
\n\t
//# sourceMappingURL=guideView.js.map
\n\n\t
var Garbage = (function (_super) {
\n\t
tslib.__extends(Garbage, _super);
\n\t
function Garbage(texture) {
\n\t
var _this = _super.call(this, texture) || this;
\n\t
_this.isWrong = false;
\n\t
_this.isRight = false;
\n\t
return _this;
\n\t
}
\n\t
return Garbage;
\n\t
}(engine.Sprite));
\n\n\t
var GarbageTypes;
\n\t
(function (GarbageTypes) {
\n\t
GarbageTypes[GarbageTypes[
\"
recoverableWaste
\"
] = 0] =
\"
recoverableWaste
\"
;
\n\t
GarbageTypes[GarbageTypes[
\"
harmfulWaste
\"
] = 1] =
\"
harmfulWaste
\"
;
\n\t
GarbageTypes[GarbageTypes[
\"
wetWaste
\"
] = 2] =
\"
wetWaste
\"
;
\n\t
GarbageTypes[GarbageTypes[
\"
dryWaste
\"
] = 3] =
\"
dryWaste
\"
;
\n\t
})(GarbageTypes || (GarbageTypes = {}));
\n\t
//# sourceMappingURL=GarbageTypes.js.map
\n\n\t
var GarbageConfig = (function () {
\n\t
function GarbageConfig() {
\n\t
}
\n\t
GarbageConfig.config = [
\n\t
{ name:
\"
电池
\"
, source:
\"
g00
\"
, type: GarbageTypes.harmfulWaste, width: 51, height: 123 },
\n\t
{ name:
\"
温度计
\"
, source:
\"
g01
\"
, type: GarbageTypes.harmfulWaste, width: 65, height: 130 },
\n\t
{ name:
\"
鱼刺
\"
, source:
\"
g02
\"
, type: GarbageTypes.wetWaste, width: 104, height: 82 },
\n\t
{ name:
\"
龙虾
\"
, source:
\"
g03
\"
, type: GarbageTypes.wetWaste, width: 129, height: 122 },
\n\t
{ name:
\"
西瓜
\"
, source:
\"
g04
\"
, type: GarbageTypes.wetWaste, width: 134, height: 111 },
\n\t
{ name:
\"
旧玩具
\"
, source:
\"
g05
\"
, type: GarbageTypes.recoverableWaste, width: 72, height: 135 },
\n\t
{ name:
\"
口红
\"
, source:
\"
g06
\"
, type: GarbageTypes.dryWaste, width: 49, height: 134 },
\n\t
{ name:
\"
面包
\"
, source:
\"
g07
\"
, type: GarbageTypes.wetWaste, width: 96, height: 128 },
\n\t
{ name:
\"
绿植
\"
, source:
\"
g08
\"
, type: GarbageTypes.wetWaste, width: 81, height: 131 },
\n\t
{ name:
\"
保温瓶
\"
, source:
\"
g09
\"
, type: GarbageTypes.recoverableWaste, width: 66, height: 137 },
\n\t
{ name:
\"
破衣服
\"
, source:
\"
g10
\"
, type: GarbageTypes.recoverableWaste, width: 91, height: 121 },
\n\t
{ name:
\"
茶叶渣
\"
, source:
\"
g11
\"
, type: GarbageTypes.wetWaste, width: 108, height: 125 },
\n\t
{ name:
\"
湿巾
\"
, source:
\"
g12
\"
, type: GarbageTypes.dryWaste, width: 106, height: 109 },
\n\t
{ name:
\"
过期药膏
\"
, source:
\"
g13
\"
, type: GarbageTypes.harmfulWaste, width: 107, height: 130 },
\n\t
{ name:
\"
用完的洗发水瓶
\"
, source:
\"
g14
\"
, type: GarbageTypes.recoverableWaste, width: 153, height: 148 },
\n\t
{ name:
\"
婴儿纸尿裤
\"
, source:
\"
g15
\"
, type: GarbageTypes.dryWaste, width: 108, height: 123 },
\n\t
{ name:
\"
香水瓶
\"
, source:
\"
g16
\"
, type: GarbageTypes.recoverableWaste, width: 65, height: 127 },
\n\t
{ name:
\"
花甲壳
\"
, source:
\"
g17
\"
, type: GarbageTypes.wetWaste, width: 99, height: 115 },
\n\t
{ name:
\"
过期调味料
\"
, source:
\"
g18
\"
, type: GarbageTypes.wetWaste, width: 109, height: 130 },
\n\t
{ name:
\"
地毯
\"
, source:
\"
g19
\"
, type: GarbageTypes.recoverableWaste, width: 145, height: 119 },
\n\t
{ name:
\"
甘蔗渣
\"
, source:
\"
g20
\"
, type: GarbageTypes.wetWaste, width: 100, height: 116 },
\n\t
{ name:
\"
玻璃渣
\"
, source:
\"
g21
\"
, type: GarbageTypes.recoverableWaste, width: 95, height: 122 },
\n\t
{ name:
\"
番茄酱
\"
, source:
\"
g22
\"
, type: GarbageTypes.wetWaste, width: 82, height: 125 },
\n\t
{ name:
\"
酒精棉
\"
, source:
\"
g23
\"
, type: GarbageTypes.dryWaste, width: 64, height: 124 },
\n\t
{ name:
\"
指甲油瓶子
\"
, source:
\"
g24
\"
, type: GarbageTypes.harmfulWaste, width: 109, height: 125 },
\n\t
{ name:
\"
肉骨头
\"
, source:
\"
g25
\"
, type: GarbageTypes.dryWaste, width: 67, height: 123 },
\n\t
{ name:
\"
嚼过的口香糖
\"
, source:
\"
g26
\"
, type: GarbageTypes.dryWaste, width: 135, height: 116 },
\n\t
{ name:
\"
充电插头
\"
, source:
\"
g27
\"
, type: GarbageTypes.recoverableWaste, width: 86, height: 128 },
\n\t
{ name:
\"
旧报纸
\"
, source:
\"
g28
\"
, type: GarbageTypes.recoverableWaste, width: 68, height: 124 },
\n\t
{ name:
\"
烟头
\"
, source:
\"
g29
\"
, type: GarbageTypes.dryWaste, width: 108, height: 145 },
\n\t
{ name:
\"
奶茶塑料杯
\"
, source:
\"
g30
\"
, type: GarbageTypes.dryWaste, width: 109, height: 143 },
\n\t
{ name:
\"
瓜子壳
\"
, source:
\"
g31
\"
, type: GarbageTypes.wetWaste, width: 87, height: 121 },
\n\t
{ name:
\"
橘子皮
\"
, source:
\"
g32
\"
, type: GarbageTypes.wetWaste, width: 78, height: 120 },
\n\t
{ name:
\"
气球
\"
, source:
\"
g33
\"
, type: GarbageTypes.dryWaste, width: 78, height: 121 },
\n\t
{ name:
\"
树叶
\"
, source:
\"
g34
\"
, type: GarbageTypes.wetWaste, width: 75, height: 117 },
\n\t
{ name:
\"
感冒药
\"
, source:
\"
g35
\"
, type: GarbageTypes.harmfulWaste, width: 92, height: 121 },
\n\t
{ name:
\"
电话机
\"
, source:
\"
g36
\"
, type: GarbageTypes.recoverableWaste, width: 63, height: 121 },
\n\t
{ name:
\"
奶酪
\"
, source:
\"
g37
\"
, type: GarbageTypes.wetWaste, width: 90, height: 116 },
\n\t
{ name:
\"
啤酒瓶
\"
, source:
\"
g38
\"
, type: GarbageTypes.recoverableWaste, width: 64, height: 123 },
\n\t
{ name:
\"
薯片包装
\"
, source:
\"
g39
\"
, type: GarbageTypes.dryWaste, width: 134, height: 123 },
\n\t
{ name:
\"
过期保健品
\"
, source:
\"
g40
\"
, type: GarbageTypes.harmfulWaste, width: 108, height: 125 },
\n\t
{ name:
\"
雪糕包装袋
\"
, source:
\"
g41
\"
, type: GarbageTypes.dryWaste, width: 109, height: 128 },
\n\t
{ name:
\"
废油漆
\"
, source:
\"
g42
\"
, type: GarbageTypes.harmfulWaste, width: 98, height: 122 },
\n\t
{ name:
\"
食品罐头
\"
, source:
\"
g43
\"
, type: GarbageTypes.recoverableWaste, width: 94, height: 117 },
\n\t
{ name:
\"
陶瓷碗
\"
, source:
\"
g44
\"
, type: GarbageTypes.dryWaste, width: 105, height: 122 },
\n\t
{ name:
\"
蚊香
\"
, source:
\"
g45
\"
, type: GarbageTypes.dryWaste, width: 69, height: 146 },
\n\t
{ name:
\"
电脑机箱
\"
, source:
\"
g46
\"
, type: GarbageTypes.recoverableWaste, width: 84, height: 124 },
\n\t
{ name:
\"
鲜花
\"
, source:
\"
g47
\"
, type: GarbageTypes.wetWaste, width: 62, height: 122 },
\n\t
{ name:
\"
宠物粮食
\"
, source:
\"
g48
\"
, type: GarbageTypes.wetWaste, width: 87, height: 121 },
\n\t
{ name:
\"
银行卡
\"
, source:
\"
g49
\"
, type: GarbageTypes.recoverableWaste, width: 115, height: 123 },
\n\t
];
\n\t
return GarbageConfig;
\n\t
}());
\n\t
//# sourceMappingURL=GarbageConfig.js.map
\n\n\t
var removeEle = (function (e, arr) {
\n\t
var index = arr.indexOf(e);
\n\t
if (index >= 0) {
\n\t
arr.splice(index, 1);
\n\t
}
\n\t
});
\n\t
//# sourceMappingURL=removeEle.js.map
\n\n\t
var shuffle = (function (arr) {
\n\t
var _a;
\n\t
var i = arr.length;
\n\t
while (i) {
\n\t
var j = Math.floor(Math.random() * i--);
\n\t
_a = [arr[i], arr[j]], arr[j] = _a[0], arr[i] = _a[1];
\n\t
}
\n\t
return arr;
\n\t
});
\n\t
//# sourceMappingURL=shuffle.js.map
\n\n\t
var Conveyors = (function (_super) {
\n\t
tslib.__extends(Conveyors, _super);
\n\t
function Conveyors(p) {
\n\t
var _this = _super.call(this) || this;
\n\t
_this.conveyorsPool = [];
\n\t
_this.GarbageConfig = GarbageConfig.config;
\n\t
_this.currConfigPool = [];
\n\t
_this.currGamePool = [];
\n\t
_this.p = p;
\n\t
return _this;
\n\t
}
\n\t
Conveyors.prototype.initData = function (conveyor0, conveyor1) {
\n\t
this.conveyor0 = conveyor0;
\n\t
this.conveyor1 = conveyor1;
\n\t
this.conveyorsPool.push(this.conveyor0);
\n\t
this.conveyorsPool.push(this.conveyor1);
\n\t
};
\n\t
Conveyors.prototype.setDefault = function () {
\n\t
this.score = 0;
\n\t
this.clear();
\n\t
this.currConfigPool = shuffle(this.GarbageConfig);
\n\t
for (var i = 0; i < 20; i++) {
\n\t
this.currConfigPool[i].idx = i;
\n\t
this.currConfigPool[i].isRight = false;
\n\t
this.currConfigPool[i].isMistake = false;
\n\t
this.currConfigPool[i].isOnStage = false;
\n\t
this.currGamePool.push(this.currConfigPool[i]);
\n\t
}
\n\t
var gamePoolIdx = 0;
\n\t
for (var i = 0; i < 5; i++) {
\n\t
var g = this.currGamePool[gamePoolIdx];
\n\t
gamePoolIdx += 1;
\n\t
var garbage = new Garbage(getTextureByName(g.source));
\n\t
g.isOnStage = true;
\n\t
garbage.type = g.type;
\n\t
garbage.name = g.name;
\n\t
garbage.anchorX = g.width / 2;
\n\t
garbage.anchorY = g.height;
\n\t
garbage.x = 0;
\n\t
garbage.y = 90;
\n\t
this.conveyor1[
\"
idx
\"
+ i].addChild(garbage);
\n\t
garbage.addEventListener(engine.MouseEvent.MOUSE_DOWN, this.onDwon_garbage, this);
\n\t
}
\n\t
};
\n\t
Conveyors.prototype.startConveyors = function () {
\n\t
this.setDefault();
\n\t
engine.gameStage.addEventListener(engine.Event.ENTER_FRAME, this.onEnterFrame, this);
\n\t
};
\n\t
Conveyors.prototype.onEnterFrame = function (ENTER_FRAME, onEnterFrame, arg2) {
\n\t
if (this.score == 100) {
\n\t
this.gameOver();
\n\t
}
\n\t
this.conveyorsPool.forEach(function (conveyor) {
\n\t
conveyor.x -= props.speed || 3;
\n\t
});
\n\t
if (this.conveyorsPool.length > 1) {
\n\t
if (this.conveyorsPool[this.conveyorsPool.length - 1].x <= 764) {
\n\t
var conveyor = new Conveyor();
\n\t
conveyor.x = this.conveyorsPool[this.conveyorsPool.length - 1].x + 764;
\n\t
this.p.addChild(conveyor);
\n\t
this.conveyorsPool.push(conveyor);
\n\t
}
\n\t
else {
\n\t
var asdasd = [];
\n\t
for (var n = 0; n < this.currGamePool.length; n++) {
\n\t
var cgg = this.currGamePool[n];
\n\t
if (!cgg.isRight && !cgg.isOnStage) {
\n\t
asdasd.push(cgg);
\n\t
}
\n\t
}
\n\t
var cc = this.conveyorsPool[this.conveyorsPool.length - 1];
\n\t
for (var m = 0; m < 5; m++) {
\n\t
if (!cc[
\"
idx
\"
+ m].children[0]) {
\n\t
var g = asdasd.shift();
\n\t
if (g) {
\n\t
g.isOnStage = true;
\n\t
var garbage = new Garbage(g.source);
\n\t
garbage.type = g.type;
\n\t
garbage.name = g.name;
\n\t
garbage.anchorX = g.width / 2;
\n\t
garbage.anchorY = g.height;
\n\t
garbage.x = 0;
\n\t
garbage.y = 90;
\n\t
cc[
\"
idx
\"
+ m].addChild(garbage);
\n\t
garbage.addEventListener(engine.MouseEvent.MOUSE_DOWN, this.onDwon_garbage, this);
\n\t
}
\n\t
else {
\n\t
break;
\n\t
}
\n\t
}
\n\t
}
\n\t
}
\n\t
if (this.conveyorsPool[0].x < -750) {
\n\t
for (var k = 0; k < this.currGamePool.length; k++) {
\n\t
var garbage = this.currGamePool[k];
\n\t
var cc = this.conveyorsPool[0][
\"
idx
\"
+ 4];
\n\t
if (cc.children[0]) {
\n\t
if (garbage.name == cc.children[0].$name) {
\n\t
garbage.isOnStage = false;
\n\t
removeEle(garbage, this.currGamePool);
\n\t
this.currGamePool.push(garbage);
\n\t
cc.removeChild(cc.children[0]);
\n\t
break;
\n\t
}
\n\t
}
\n\t
}
\n\t
this.conveyorsPool.shift();
\n\t
}
\n\t
else if (this.conveyorsPool[0].x < -600) {
\n\t
for (var k = 0; k < this.currGamePool.length; k++) {
\n\t
var garbage = this.currGamePool[k];
\n\t
var cc = this.conveyorsPool[0][
\"
idx
\"
+ 3];
\n\t
if (cc.children[0]) {
\n\t
if (garbage.name == cc.children[0].$name) {
\n\t
garbage.isOnStage = false;
\n\t
removeEle(garbage, this.currGamePool);
\n\t
this.currGamePool.push(garbage);
\n\t
cc.removeChild(cc.children[0]);
\n\t
break;
\n\t
}
\n\t
}
\n\t
}
\n\t
}
\n\t
else if (this.conveyorsPool[0].x < -450) {
\n\t
for (var k = 0; k < this.currGamePool.length; k++) {
\n\t
var garbage = this.currGamePool[k];
\n\t
var cc = this.conveyorsPool[0][
\"
idx
\"
+ 2];
\n\t
if (cc.children[0]) {
\n\t
if (garbage.name == cc.children[0].$name) {
\n\t
garbage.isOnStage = false;
\n\t
removeEle(garbage, this.currGamePool);
\n\t
this.currGamePool.push(garbage);
\n\t
cc.removeChild(cc.children[0]);
\n\t
break;
\n\t
}
\n\t
}
\n\t
}
\n\t
}
\n\t
else if (this.conveyorsPool[0].x < -300) {
\n\t
for (var k = 0; k < this.currGamePool.length; k++) {
\n\t
var garbage = this.currGamePool[k];
\n\t
var cc = this.conveyorsPool[0][
\"
idx
\"
+ 1];
\n\t
if (cc.children[0]) {
\n\t
if (garbage.name == cc.children[0].$name) {
\n\t
garbage.isOnStage = false;
\n\t
removeEle(garbage, this.currGamePool);
\n\t
this.currGamePool.push(garbage);
\n\t
cc.removeChild(cc.children[0]);
\n\t
break;
\n\t
}
\n\t
}
\n\t
}
\n\t
}
\n\t
else if (this.conveyorsPool[0].x < -150) {
\n\t
for (var k = 0; k < this.currGamePool.length; k++) {
\n\t
var garbage = this.currGamePool[k];
\n\t
var cc = this.conveyorsPool[0][
\"
idx
\"
+ 0];
\n\t
if (cc.children[0]) {
\n\t
if (garbage.name == cc.children[0].$name) {
\n\t
garbage.isOnStage = false;
\n\t
removeEle(garbage, this.currGamePool);
\n\t
this.currGamePool.push(garbage);
\n\t
cc.removeChild(cc.children[0]);
\n\t
break;
\n\t
}
\n\t
}
\n\t
}
\n\t
}
\n\t
}
\n\t
};
\n\t
Conveyors.prototype.addscore = function (n) {
\n\t
this.score += n;
\n\t
engine.globalEvent.dispatchEvent('recycling-score-update', {
\n\t
score: this.score
\n\t
});
\n\t
};
\n\t
Conveyors.prototype.gameOver = function () {
\n\t
engine.gameStage.addEventListener(engine.Event.ENTER_FRAME, this.onEnterFrame, this);
\n\t
};
\n\t
Conveyors.prototype.onDwon_garbage = function () {
\n\t
};
\n\t
Conveyors.prototype.clear = function () {
\n\t
this.currGamePool = [];
\n\t
};
\n\t
Conveyors.prototype.timeout = function () {
\n\t
engine.gameStage.removeEventListener(engine.Event.ENTER_FRAME, this.onEnterFrame, this);
\n\t
};
\n\t
return Conveyors;
\n\t
}(engine.Sprite));
\n\t
//# sourceMappingURL=Conveyors.js.map
\n\n\t
var GameView = (function (_super) {
\n\t
tslib.__extends(GameView, _super);
\n\t
function GameView() {
\n\t
var _this = _super.call(this) || this;
\n\t
_this._timeCounter = 0;
\n\t
_this.once(engine.Event.ADDED_TO_STAGE, _this.setup, _this);
\n\t
return _this;
\n\t
}
\n\t
GameView.prototype.configUI = function () {
\n\t
var uiMap = {};
\n\t
this.uiMap = uiMap;
\n\t
var config = uiConfig();
\n\t
for (var _i = 0, config_1 = config; _i < config_1.length; _i++) {
\n\t
var item = config_1[_i];
\n\t
var id = item.id, texture = item.texture, pos = item.pos, anchor = item.anchor;
\n\t
var sp = new engine.Sprite(getTextureByName(texture));
\n\t
this.addChild(sp);
\n\t
uiMap[id] = sp;
\n\t
if (anchor) {
\n\t
sp.anchorX = anchor[0];
\n\t
sp.anchorY = anchor[1];
\n\t
}
\n\t
if (pos) {
\n\t
sp.x = pos[0];
\n\t
sp.y = pos[1];
\n\t
if (anchor) {
\n\t
sp.x = pos[0] - sp.anchorX;
\n\t
sp.y = pos[1] - sp.anchorY;
\n\t
}
\n\t
}
\n\t
}
\n\t
this.configConveyors();
\n\t
this.createRects();
\n\t
this.countdown = new CountDownGroup();
\n\t
this.addChild(this.countdown);
\n\t
this.guide = new GuideView();
\n\t
this.addChild(this.guide);
\n\t
};
\n\t
GameView.prototype.createRects = function () {
\n\t
this.wetWaste = this.createRect(74, 552, 301, 293, 0xffffff);
\n\t
this.harmfulWaste = this.createRect(75, 247, 300, 293, 0xff0000);
\n\t
this.dryWaste = this.createRect(389, 249, 286, 291, 0x000000);
\n\t
this.recoverableWaste = this.createRect(389, 551, 287, 292, 0x0000ff);
\n\t
};
\n\t
GameView.prototype.createRect = function (x, y, w, h, c) {
\n\t
var rect = new engine.Rectangle(x, y, w, h);
\n\t
var sp = new engine.Sprite();
\n\t
this.addChild(sp);
\n\t
sp.x = x;
\n\t
sp.y = y;
\n\t
var g = new engine.Graphics;
\n\t
g.alpha = 0.0;
\n\t
g.beginFill(c);
\n\t
g.drawRect(0, 0, w, h);
\n\t
g.endFill();
\n\t
sp.addChild(g);
\n\t
return rect;
\n\t
};
\n\t
GameView.prototype.configConveyors = function () {
\n\t
var conveyor0 = new Conveyor();
\n\t
conveyor0.x = 0;
\n\t
var conveyor1 = new Conveyor();
\n\t
this.addChild(conveyor0);
\n\t
this.addChild(conveyor1);
\n\t
conveyor1.x = 764;
\n\t
this.conveyors = new Conveyors(this);
\n\t
this.conveyors.initData(conveyor0, conveyor1);
\n\t
};
\n\t
GameView.prototype.playAni = function () {
\n\t
var _this = this;
\n\t
var idlerWheels = ['idler0', 'idler1', 'idler2', 'idler3', 'idler4', 'idler5', 'idler6'];
\n\t
idlerWheels = idlerWheels.map(function (i) { return _this.uiMap[i]; });
\n\t
idlerWheels.forEach(function (i) {
\n\t
engine.Tween.get(i, { loop: true }).to({ rotation: -360 }, 1000);
\n\t
});
\n\t
};
\n\t
GameView.prototype.stopAni = function () {
\n\t
var _this = this;
\n\t
var idlerWheels = ['idler0', 'idler1', 'idler2', 'idler3', 'idler4', 'idler5', 'idler6'];
\n\t
idlerWheels = idlerWheels.map(function (i) { return _this.uiMap[i]; });
\n\t
idlerWheels.forEach(function (i) {
\n\t
engine.Tween.removeTweens(i);
\n\t
});
\n\t
};
\n\t
GameView.prototype.start = function () {
\n\t
return tslib.__awaiter(this, void 0, void 0, function () {
\n\t
var _this = this;
\n\t
return tslib.__generator(this, function (_a) {
\n\t
switch (_a.label) {
\n\t
case 0:
\n\t
console.log('on start');
\n\t
this._timeCounter = 0;
\n\t
if (!!getGuideInfo()) return [3, 2];
\n\t
return [4, this.guide.startGuide()];
\n\t
case 1:
\n\t
_a.sent();
\n\t
setGuide();
\n\t
_a.label = 2;
\n\t
case 2: return [4, this.countdown.startCountDown()];
\n\t
case 3:
\n\t
_a.sent();
\n\t
this.startGame();
\n\t
engine.globalEvent.dispatchEvent('recycling-time-update', {
\n\t
second: this.getSecond(),
\n\t
});
\n\t
this._timer = setInterval(function () {
\n\t
_this.onTimer();
\n\t
}, 1000);
\n\t
return [2];
\n\t
}
\n\t
});
\n\t
});
\n\t
};
\n\t
GameView.prototype.startGame = function () {
\n\t
this.playAni();
\n\t
this.conveyors.startConveyors();
\n\t
};
\n\t
GameView.prototype.stopGame = function () {
\n\t
this.stopAni();
\n\t
};
\n\t
GameView.prototype.getSecond = function () {
\n\t
return props.time - this._timeCounter;
\n\t
};
\n\t
GameView.prototype.onTimer = function () {
\n\t
this._timeCounter++;
\n\t
engine.globalEvent.dispatchEvent('recycling-time-update', {
\n\t
second: this.getSecond(),
\n\t
});
\n\t
if (this.getSecond() == 0) {
\n\t
this.stop();
\n\t
this.conveyors.timeout();
\n\t
engine.globalEvent.dispatchEvent('recycling-game-end', {});
\n\t
}
\n\t
};
\n\t
GameView.prototype.stop = function () {
\n\t
clearInterval(this._timer);
\n\t
this.stopGame();
\n\t
};
\n\t
GameView.prototype.setup = function () {
\n\t
console.log('onSteup', props);
\n\t
this.configUI();
\n\t
};
\n\t
GameView.prototype.onDown = function (e) {
\n\t
};
\n\t
GameView.prototype.stageOnUp = function (e) {
\n\t
};
\n\t
GameView.prototype.onSuccess = function () {
\n\t
};
\n\t
GameView.prototype.onMove = function (e) {
\n\t
};
\n\t
return GameView;
\n\t
}(engine.Container));
\n\t
//# sourceMappingURL=GameView.js.map
\n\n\t
var GameWrapper = (function (_super) {
\n\t
tslib.__extends(GameWrapper, _super);
\n\t
function GameWrapper() {
\n\t
var _this = _super.call(this) || this;
\n\t
engine.globalEvent.addEventListener('recycling-start', _this.start, _this);
\n\t
engine.globalEvent.addEventListener('recycling-stop', _this.stop, _this);
\n\t
var gameView = _this._gameView = new GameView();
\n\t
_this.addChild(gameView);
\n\t
return _this;
\n\t
}
\n\t
GameWrapper.prototype.start = function (event) {
\n\t
injectProps(event.data);
\n\t
this._gameView.start();
\n\t
};
\n\t
GameWrapper.prototype.stop = function (event) {
\n\t
this._gameView.stop();
\n\t
};
\n\t
return GameWrapper;
\n\t
}(engine.Container));
\n\t
//# sourceMappingURL=GameWrapper.js.map
\n\n\t
function 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\t
return index;
\n\n
})))
;
\n
"
"code"
:
"
\"
use strict
\"
;var tslib=require(
\"
tslib
\"
);function getTexture(e){return engine.Texture.from(getAssetByUUID(e).uuid)}function getTextureByName(e){return getTexture(engine.getAssetByName(e).uuid)}function createSvga(e,t){var i=new svga.Svga;return i.source=
\"
asset://
\"
+engine.getAssetByName(e).uuid,i}var props={};function prepareProps(){var e=getProps();engine.injectProp(props,e)}function injectProps(e){engine.injectProp(props,e)}var GarbageTypes,Conveyor=function(i){function e(){var e=i.call(this)||this;e.y=904.21;var t=new engine.Sprite(getTextureByName(
\"
conveyor
\"
));return e.addChild(t),e.idx0=e.createItem(75,50),e.idx1=e.createItem(225,50),e.idx2=e.createItem(375,50),e.idx3=e.createItem(525,50),e.idx4=e.createItem(675,50),e}return tslib.__extends(e,i),e.prototype.clear=function(){this.clearItem(this.idx0),this.clearItem(this.idx1),this.clearItem(this.idx2),this.clearItem(this.idx3),this.clearItem(this.idx4)},e.prototype.clearItem=function(e){0<e.children.length&&e.removeChildAt(0)},e.prototype.createItem=function(e,t){var i=new engine.Sprite;return this.addChild(i),i.x=e,i.y=t,i},e}(engine.Sprite);!function(e){e.recoverableWaste=
\"
recoverableWaste
\"
,e.harmfulWaste=
\"
harmfulWaste
\"
,e.wetWaste=
\"
wetWaste
\"
,e.dryWaste=
\"
dryWaste
\"
}(GarbageTypes=GarbageTypes||{});var GarbageConfig=function(){function e(){}return e.config=[{name:
\"
电池
\"
,source:
\"
g00
\"
,type:GarbageTypes.harmfulWaste,width:51,height:123},{name:
\"
温度计
\"
,source:
\"
g01
\"
,type:GarbageTypes.harmfulWaste,width:65,height:130},{name:
\"
鱼刺
\"
,source:
\"
g02
\"
,type:GarbageTypes.wetWaste,width:104,height:82},{name:
\"
龙虾
\"
,source:
\"
g03
\"
,type:GarbageTypes.wetWaste,width:129,height:122},{name:
\"
西瓜
\"
,source:
\"
g04
\"
,type:GarbageTypes.wetWaste,width:134,height:111},{name:
\"
旧玩具
\"
,source:
\"
g05
\"
,type:GarbageTypes.recoverableWaste,width:72,height:135},{name:
\"
口红
\"
,source:
\"
g06
\"
,type:GarbageTypes.dryWaste,width:49,height:134},{name:
\"
面包
\"
,source:
\"
g07
\"
,type:GarbageTypes.wetWaste,width:96,height:128},{name:
\"
绿植
\"
,source:
\"
g08
\"
,type:GarbageTypes.wetWaste,width:81,height:131},{name:
\"
保温瓶
\"
,source:
\"
g09
\"
,type:GarbageTypes.recoverableWaste,width:66,height:137},{name:
\"
破衣服
\"
,source:
\"
g10
\"
,type:GarbageTypes.recoverableWaste,width:91,height:121},{name:
\"
茶叶渣
\"
,source:
\"
g11
\"
,type:GarbageTypes.wetWaste,width:108,height:125},{name:
\"
湿巾
\"
,source:
\"
g12
\"
,type:GarbageTypes.dryWaste,width:106,height:109},{name:
\"
过期药膏
\"
,source:
\"
g13
\"
,type:GarbageTypes.harmfulWaste,width:107,height:130},{name:
\"
用完的洗发水瓶
\"
,source:
\"
g14
\"
,type:GarbageTypes.recoverableWaste,width:153,height:148},{name:
\"
婴儿纸尿裤
\"
,source:
\"
g15
\"
,type:GarbageTypes.dryWaste,width:108,height:123},{name:
\"
香水瓶
\"
,source:
\"
g16
\"
,type:GarbageTypes.recoverableWaste,width:65,height:127},{name:
\"
花甲壳
\"
,source:
\"
g17
\"
,type:GarbageTypes.wetWaste,width:99,height:115},{name:
\"
过期调味料
\"
,source:
\"
g18
\"
,type:GarbageTypes.wetWaste,width:109,height:130},{name:
\"
地毯
\"
,source:
\"
g19
\"
,type:GarbageTypes.recoverableWaste,width:145,height:119},{name:
\"
甘蔗渣
\"
,source:
\"
g20
\"
,type:GarbageTypes.wetWaste,width:100,height:116},{name:
\"
玻璃渣
\"
,source:
\"
g21
\"
,type:GarbageTypes.recoverableWaste,width:95,height:122},{name:
\"
番茄酱
\"
,source:
\"
g22
\"
,type:GarbageTypes.wetWaste,width:82,height:125},{name:
\"
酒精棉
\"
,source:
\"
g23
\"
,type:GarbageTypes.dryWaste,width:64,height:124},{name:
\"
指甲油瓶子
\"
,source:
\"
g24
\"
,type:GarbageTypes.harmfulWaste,width:109,height:125},{name:
\"
肉骨头
\"
,source:
\"
g25
\"
,type:GarbageTypes.dryWaste,width:67,height:123},{name:
\"
嚼过的口香糖
\"
,source:
\"
g26
\"
,type:GarbageTypes.dryWaste,width:135,height:116},{name:
\"
充电插头
\"
,source:
\"
g27
\"
,type:GarbageTypes.recoverableWaste,width:86,height:128},{name:
\"
旧报纸
\"
,source:
\"
g28
\"
,type:GarbageTypes.recoverableWaste,width:68,height:124},{name:
\"
烟头
\"
,source:
\"
g29
\"
,type:GarbageTypes.dryWaste,width:108,height:145},{name:
\"
奶茶塑料杯
\"
,source:
\"
g30
\"
,type:GarbageTypes.dryWaste,width:109,height:143},{name:
\"
瓜子壳
\"
,source:
\"
g31
\"
,type:GarbageTypes.wetWaste,width:87,height:121},{name:
\"
橘子皮
\"
,source:
\"
g32
\"
,type:GarbageTypes.wetWaste,width:78,height:120},{name:
\"
气球
\"
,source:
\"
g33
\"
,type:GarbageTypes.dryWaste,width:78,height:121},{name:
\"
树叶
\"
,source:
\"
g34
\"
,type:GarbageTypes.wetWaste,width:75,height:117},{name:
\"
感冒药
\"
,source:
\"
g35
\"
,type:GarbageTypes.harmfulWaste,width:92,height:121},{name:
\"
电话机
\"
,source:
\"
g36
\"
,type:GarbageTypes.recoverableWaste,width:63,height:121},{name:
\"
奶酪
\"
,source:
\"
g37
\"
,type:GarbageTypes.wetWaste,width:90,height:116},{name:
\"
啤酒瓶
\"
,source:
\"
g38
\"
,type:GarbageTypes.recoverableWaste,width:64,height:123},{name:
\"
薯片包装
\"
,source:
\"
g39
\"
,type:GarbageTypes.dryWaste,width:134,height:123},{name:
\"
过期保健品
\"
,source:
\"
g40
\"
,type:GarbageTypes.harmfulWaste,width:108,height:125},{name:
\"
雪糕包装袋
\"
,source:
\"
g41
\"
,type:GarbageTypes.dryWaste,width:109,height:128},{name:
\"
废油漆
\"
,source:
\"
g42
\"
,type:GarbageTypes.harmfulWaste,width:98,height:122},{name:
\"
食品罐头
\"
,source:
\"
g43
\"
,type:GarbageTypes.recoverableWaste,width:94,height:117},{name:
\"
陶瓷碗
\"
,source:
\"
g44
\"
,type:GarbageTypes.dryWaste,width:105,height:122},{name:
\"
蚊香
\"
,source:
\"
g45
\"
,type:GarbageTypes.dryWaste,width:69,height:146},{name:
\"
电脑机箱
\"
,source:
\"
g46
\"
,type:GarbageTypes.recoverableWaste,width:84,height:124},{name:
\"
鲜花
\"
,source:
\"
g47
\"
,type:GarbageTypes.wetWaste,width:62,height:122},{name:
\"
宠物粮食
\"
,source:
\"
g48
\"
,type:GarbageTypes.wetWaste,width:87,height:121},{name:
\"
银行卡
\"
,source:
\"
g49
\"
,type:GarbageTypes.recoverableWaste,width:115,height:123}],e}(),checkHit=function(e,t){var i=e.x,r=e.y,n=e.texture,a=n.width,s=n.height;return i>t.x&&r>t.y&&i+a<t.x+t.width&&r+s<t.y+t.height},removeChild=function(e){e&&e.parent&&e.parent.removeChild(e)},removeEle=function(e,t){var i=t.indexOf(e);0<=i&&t.splice(i,1)},shuffle=function(e){for(var t,i=e.length;i;){var r=Math.floor(Math.random()*i--);t=[e[i],e[r]],e[r]=t[0],e[i]=t[1]}return e},transStores=function(e){return e.map(function(e){return{targetName:getTargetName(e.targetType),isCorrect:e.targetType==e.itemType,itemName:e.itemName}})},getTargetName=function(e){switch(e){case GarbageTypes.recoverableWaste:return
\"
可回收物
\"
;case GarbageTypes.harmfulWaste:return
\"
有害垃圾
\"
;case GarbageTypes.wetWaste:return
\"
湿垃圾
\"
;case GarbageTypes.dryWaste:return
\"
干垃圾
\"
}},Conveyors=function(i){function e(e){var t=i.call(this)||this;return t.conveyorsPool=[],t.GarbageConfig=GarbageConfig.config,t.datas=[],t.wrapper=e,t}return tslib.__extends(e,i),e.prototype.initData=function(e,t){this.conveyor0=e,this.conveyor1=t},e.prototype.setDefault=function(){this.clear(),this.score=0,this.conveyorsPool.push(this.conveyor0),this.conveyorsPool.push(this.conveyor1);for(var e=shuffle(this.GarbageConfig),t=0;t<20;t++)e[t].idx=t,e[t].isRight=!1,e[t].isMistake=!1,e[t].isOnStage=!1,this.datas.push(e[t]);for(t=0;t<5;t++){var i=this.datas[t],r=new engine.Sprite(getTextureByName(i.source));r.isWrong=!1,r.isRight=!1,i.isOnStage=!0,r.type=i.type,r.name=i.name,r.anchorX=i.width/2,r.anchorY=i.height,r.x=-i.width/2,r.y=40-i.height,this.conveyor1[
\"
idx
\"
+t].addChild(r),r.addEventListener(engine.MouseEvent.MOUSE_DOWN,this.onDwon_garbage,this)}},e.prototype.startConveyors=function(){this.setDefault(),engine.gameStage.addEventListener(engine.Event.ENTER_FRAME,this.onEnterFrame,this)},e.prototype.onEnterFrame=function(e,t,i){if(this.score==(props.maxScore||100)&&this.gameOver(),this.conveyorsPool.forEach(function(e){e.x-=props.speed||3}),this.conveyorsPool[this.conveyorsPool.length-1].x<=764){var r=new Conveyor;r.x=this.conveyorsPool[this.conveyorsPool.length-1].x+764,this.wrapper.addChild(r),this.conveyorsPool.push(r)}else{for(var n=[],a=0;a<this.datas.length;a++){(u=this.datas[a]).isRight||u.isOnStage||n.push(u)}for(var s=this.conveyorsPool[this.conveyorsPool.length-1],o=0;o<5;o++)if(!s[
\"
idx
\"
+o].children[0]){var h=n.shift();if(!h)break;h.isOnStage=!0;var c=new engine.Sprite(getTextureByName(h.source));c.isWrong=!1,c.isRight=!1,c.type=h.type,c.name=h.name,c.anchorX=h.width/2,c.anchorY=h.height,c.x=-h.width/2,c.y=40-h.height,s[
\"
idx
\"
+o].addChild(c),c.addEventListener(engine.MouseEvent.MOUSE_DOWN,this.onDwon_garbage,this)}}if(this.conveyorsPool[0].x<-750){for(var g=0;g<this.datas.length;g++){var u=this.datas[g],d=this.conveyorsPool[0].idx4;if(d.children[0]&&u.name==d.children[0].name){u.isOnStage=!1,removeEle(u,this.datas),this.datas.push(u),d.removeChild(d.children[0]);break}}this.conveyorsPool.shift()}else if(this.conveyorsPool[0].x<-600)for(g=0;g<this.datas.length;g++){u=this.datas[g];var l=this.conveyorsPool[0].idx3;if(l.children[0]&&u.name==l.children[0].name){u.isOnStage=!1,removeEle(u,this.datas),this.datas.push(u),l.removeChild(l.children[0]);break}}else if(this.conveyorsPool[0].x<-450)for(g=0;g<this.datas.length;g++){u=this.datas[g];var p=this.conveyorsPool[0].idx2;if(p.children[0]&&u.name==p.children[0].name){u.isOnStage=!1,removeEle(u,this.datas),this.datas.push(u),p.removeChild(p.children[0]);break}}else if(this.conveyorsPool[0].x<-300)for(g=0;g<this.datas.length;g++){u=this.datas[g];var y=this.conveyorsPool[0].idx1;if(y.children[0]&&u.name==y.children[0].name){u.isOnStage=!1,removeEle(u,this.datas),this.datas.push(u),y.removeChild(y.children[0]);break}}else if(this.conveyorsPool[0].x<-150)for(g=0;g<this.datas.length;g++){u=this.datas[g];var m=this.conveyorsPool[0].idx0;if(m.children[0]&&u.name==m.children[0].name){u.isOnStage=!1,removeEle(u,this.datas),this.datas.push(u),m.removeChild(m.children[0]);break}}},e.prototype.addscore=function(){this.score+=props.onceScore||2,engine.globalEvent.dispatchEvent(
\"
recycling-score-update
\"
,{score:this.score})},e.prototype.gameOver=function(){engine.gameStage.removeEventListener(engine.Event.ENTER_FRAME,this.onEnterFrame,this),engine.globalEvent.dispatchEvent(
\"
recycling-game-end
\"
,transStores(this.stores))},e.prototype.onDwon_garbage=function(e){var t=e.target,i=new engine.Sprite(t.texture);this._currentView=i,this.wrapper.addChild(i),i.x=e.stageX-t.texture.width/2,i.y=e.stageY-t.texture.height/2,i.type=t.type,i.name=t.name,this.wrapper.once(engine.MouseEvent.MOUSE_UP,this.onStageMouseUp,this),this.wrapper.addEventListener(engine.MouseEvent.MOUSE_MOVE,this.onStageMouseMove,this)},e.prototype.onStageMouseMove=function(e){var t=this._currentView;t.x=e.stageX-t.texture.width/2,t.y=e.stageY-t.texture.height/2},e.prototype.onStageMouseUp=function(e){var t=this;if(this.wrapper.removeEventListener(engine.MouseEvent.MOUSE_MOVE,this.onStageMouseMove,this),this._currentView){var i=this.checkHitRect();i?(console.log(
\"
落入垃圾桶类型
\"
,i,
\"
垃圾类型
\"
,this._currentView.type),i==this._currentView.type&&this.addscore(),this.stores.push({targetType:i,itemType:this._currentView.type,itemName:this._currentView.name})):console.log(
\"
没有落入
\"
),this._currentView.anchorX=this._currentView.texture.width/2,this._currentView.anchorY=this._currentView.texture.height/2,engine.Tween.get(this._currentView).to({scaleX:0,scaleY:0},300).call(function(){removeChild(t._currentView)})}},e.prototype.clear=function(){this.conveyorsPool.forEach(function(e){e.clear()}),this.conveyorsPool=[],this.datas=[],this.stores=[]},e.prototype.timeout=function(){this.gameOver()},e.prototype.checkHitRect=function(){return checkHit(this._currentView,this.wrapper.wetWaste)?GarbageTypes.wetWaste:checkHit(this._currentView,this.wrapper.harmfulWaste)?GarbageTypes.harmfulWaste:checkHit(this._currentView,this.wrapper.dryWaste)?GarbageTypes.dryWaste:checkHit(this._currentView,this.wrapper.recoverableWaste)?GarbageTypes.recoverableWaste:null},e}(engine.Sprite),uiConfig=function(){return[{id:
\"
playBg
\"
,texture:
\"
playBg
\"
},{id:
\"
idler0
\"
,texture:
\"
idlerWheel
\"
,pos:[75,1038],anchor:[20,21.5]},{id:
\"
idler1
\"
,texture:
\"
idlerWheel
\"
,pos:[175,1038],anchor:[20,21.5]},{id:
\"
idler2
\"
,texture:
\"
idlerWheel
\"
,pos:[275,1038],anchor:[20,21.5]},{id:
\"
idler3
\"
,texture:
\"
idlerWheel
\"
,pos:[375,1038],anchor:[20,21.5]},{id:
\"
idler4
\"
,texture:
\"
idlerWheel
\"
,pos:[475,1038],anchor:[20,21.5]},{id:
\"
idler5
\"
,texture:
\"
idlerWheel
\"
,pos:[575,1038],anchor:[20,21.5]},{id:
\"
idler6
\"
,texture:
\"
idlerWheel
\"
,pos:[675,1038],anchor:[20,21.5]}]},getGuideInfo=function(){return window.localStorage?localStorage.getItem(
\"
recyclingGuide
\"
):0},setGuide=function(){window.localStorage&&localStorage.setItem(
\"
recyclingGuide
\"
,
\"
1
\"
)},createBg=function(e){void 0===e&&(e=1);var t=new engine.Graphics;return t.beginFill(0),t.drawRect(0,0,750,1624),t.endFill(),t.alpha=e,t},createImg=function(e){return new engine.Sprite(getTextureByName(e))},CountDownGroup=function(t){function e(){var e=t.call(this)||this;return e.addChild(createBg(.6)),e.num1=createImg(
\"
num1
\"
),e.num2=createImg(
\"
num2
\"
),e.num3=createImg(
\"
num3
\"
),e.go=createImg(
\"
go
\"
),e.go.anchorX=240,e.go.anchorY=171.5,e.num1.anchorX=125.5,e.num1.anchorY=189,e.num2.anchorX=149.5,e.num2.anchorY=191.5,e.num3.anchorX=148.5,e.num3.anchorY=191.5,e.go.x=135,e.go.y=353.5,e.num1.x=249.5,e.num1.y=340,e.num2.x=225.5,e.num2.y=334.5,e.num3.x=226.5,e.num3.y=333.5,e.addChild(e.num1),e.addChild(e.num2),e.addChild(e.num3),e.addChild(e.go),e.visible=!1,e.reset(),e}return tslib.__extends(e,t),e.prototype.reset=function(){this.go.alpha=this.num1.alpha=this.num2.alpha=this.num3.alpha=0,this.go.scaleX=this.num1.scaleX=this.num2.scaleX=this.num3.scaleX=3,this.go.scaleY=this.num1.scaleY=this.num2.scaleY=this.num3.scaleY=3},e.prototype.startCountDown=function(){return tslib.__awaiter(this,void 0,void 0,function(){var t=this;return tslib.__generator(this,function(e){return[2,new Promise(function(e){t.reset(),t.visible=!0,t.num3.alpha=1,engine.Tween.get(t.num3).to({scaleX:.8,scaleY:.8},200).to({scaleX:1,scaleY:1},100).wait(500).to({scaleX:0,scaleY:0},200).call(function(){t.num2.alpha=1,engine.Tween.get(t.num2).to({scaleX:.8,scaleY:.8},200).to({scaleX:1,scaleY:1},100).wait(500).to({scaleX:0,scaleY:0},200).call(function(){t.num1.alpha=1,engine.Tween.get(t.num1).to({scaleX:.8,scaleY:.8},200).to({scaleX:1,scaleY:1},100).wait(500).to({scaleX:0,scaleY:0},200).call(function(){t.go.alpha=1,engine.Tween.get(t.go).to({scaleX:.8,scaleY:.8},200).to({scaleX:1,scaleY:1},100).wait(500).call(function(){t.visible=!1,e()})})})})})]})})},e}(engine.Sprite),GuideView=function(t){function e(){var e=t.call(this)||this;return e.initUI(),e.visible=!1,e}return tslib.__extends(e,t),e.prototype.initUI=function(){this.addChild(createBg(.6)),this.guideBg=createImg(
\"
guideBg
\"
),this.addChild(this.guideBg),this.guideEle=createImg(
\"
guideEle
\"
),this.addChild(this.guideEle),this.guideBg.x=393,this.guideBg.y=552,this.guideEle.x=361,this.guideEle.y=877,this.guideEle.mouseEnabled=this.guideEle.mouseChildren=!0;var e=createSvga(
\"
guideTips
\"
);this.svga=e,this.addChild(e),e.gotoAndStop(1),e.mouseEnabled=e.mouseChildren=!1},e.prototype.checkHit=function(e,t,i,r){var n=new engine.Rectangle(393,552,281,320);return e>n.x&&t>n.y&&e+i<n.x+n.width&&t+r<n.y+n.height},e.prototype.startGuide=function(){return tslib.__awaiter(this,void 0,void 0,function(){var s=this;return tslib.__generator(this,function(e){return[2,new Promise(function(t){s.visible=!0,s.svga.gotoAndStop(1),s.svga.play(!1,!0),s.guideEle.scaleX=1,s.guideEle.scaleY=1;function i(e){s.stage.removeEventListener(engine.MouseEvent.MOUSE_MOVE,n,s),s.checkHit(s.guideEle.x,s.guideEle.y,s.guideEle.width,s.guideEle.height)?(s.guideEle.removeEventListener(engine.MouseEvent.MOUSE_DOWN,a,s),engine.Tween.get(s.guideEle).to({scaleX:0,scaleY:0},300).call(function(){s.visible=!1,t()})):(s.svga.visible=!0,s.guideEle.x=361,s.guideEle.y=877)}var r=[0,0],n=function(e){s.guideEle.x=e.stageX-r[0],s.guideEle.y=e.stageY-r[1]},a=function(e){r=[e.localX,e.localY],s.svga.visible=!1,s.stage.once(engine.MouseEvent.MOUSE_UP,i,s),s.stage.addEventListener(engine.MouseEvent.MOUSE_MOVE,n,s)};s.guideEle.addEventListener(engine.MouseEvent.MOUSE_DOWN,a,s)})]})})},e}(engine.Sprite),GameView=function(t){function e(){var e=t.call(this)||this;return e._timeCounter=0,e.once(engine.Event.ADDED_TO_STAGE,e.setup,e),e}return tslib.__extends(e,t),e.prototype.configUI=function(){var e={};this.uiMap=e;for(var t=0,i=uiConfig();t<i.length;t++){var r=i[t],n=r.id,a=r.texture,s=r.pos,o=r.anchor,h=new engine.Sprite(getTextureByName(a));this.addChild(h),e[n]=h,o&&(h.anchorX=o[0],h.anchorY=o[1]),s&&(h.x=s[0],h.y=s[1],o&&(h.x=s[0]-h.anchorX,h.y=s[1]-h.anchorY))}this.configConveyors(),this.createRects(),this.countdown=new CountDownGroup,this.addChild(this.countdown),this.guide=new GuideView,this.addChild(this.guide)},e.prototype.createRects=function(){this.wetWaste=this.createRect(74,552,301,293,16777215),this.harmfulWaste=this.createRect(75,247,300,293,16711680),this.dryWaste=this.createRect(389,249,286,291,0),this.recoverableWaste=this.createRect(389,551,287,292,255)},e.prototype.createRect=function(e,t,i,r,n){var a=new engine.Rectangle(e,t,i,r),s=new engine.Sprite;this.addChild(s),s.x=e,s.y=t;var o=new engine.Graphics;return o.alpha=0,o.beginFill(n),o.drawRect(0,0,i,r),o.endFill(),s.addChild(o),a},e.prototype.configConveyors=function(){var e=new Conveyor;e.x=0;var t=new Conveyor;this.addChild(e),this.addChild(t),t.x=764,this.conveyors=new Conveyors(this),this.conveyors.initData(e,t)},e.prototype.playAni=function(){var t=this,e=[
\"
idler0
\"
,
\"
idler1
\"
,
\"
idler2
\"
,
\"
idler3
\"
,
\"
idler4
\"
,
\"
idler5
\"
,
\"
idler6
\"
];(e=e.map(function(e){return t.uiMap[e]})).forEach(function(e){engine.Tween.get(e,{loop:!0}).to({rotation:-360},1e3)})},e.prototype.stopAni=function(){var t=this,e=[
\"
idler0
\"
,
\"
idler1
\"
,
\"
idler2
\"
,
\"
idler3
\"
,
\"
idler4
\"
,
\"
idler5
\"
,
\"
idler6
\"
];(e=e.map(function(e){return t.uiMap[e]})).forEach(function(e){engine.Tween.removeTweens(e)})},e.prototype.start=function(){return tslib.__awaiter(this,void 0,void 0,function(){var t=this;return tslib.__generator(this,function(e){switch(e.label){case 0:return console.log(
\"
on start
\"
),this._timeCounter=0,getGuideInfo()?[3,2]:[4,this.guide.startGuide()];case 1:e.sent(),setGuide(),e.label=2;case 2:return this.startGame(),engine.globalEvent.dispatchEvent(
\"
recycling-time-update
\"
,{second:this.getSecond()}),this._timer=setInterval(function(){t.onTimer()},1e3),[2]}})})},e.prototype.startGame=function(){this.playAni(),this.conveyors.startConveyors()},e.prototype.stopGame=function(){this.stopAni()},e.prototype.getSecond=function(){return props.time-this._timeCounter},e.prototype.onTimer=function(){this._timeCounter++,engine.globalEvent.dispatchEvent(
\"
recycling-time-update
\"
,{second:this.getSecond()}),0==this.getSecond()&&(this.stop(),this.conveyors.timeout())},e.prototype.stop=function(){clearInterval(this._timer),this.stopGame()},e.prototype.setup=function(){console.log(
\"
onSteup
\"
,props),this.configUI()},e.prototype.onDown=function(e){},e.prototype.stageOnUp=function(e){},e.prototype.onSuccess=function(){},e.prototype.onMove=function(e){},e}(engine.Container),GameWrapper=function(i){function e(){var e=i.call(this)||this;engine.globalEvent.addEventListener(
\"
recycling-start
\"
,e.start,e),engine.globalEvent.addEventListener(
\"
recycling-stop
\"
,e.stop,e);var t=e._gameView=new GameView;return e.addChild(t),e}return tslib.__extends(e,i),e.prototype.start=function(e){injectProps(e.data),this._gameView.start()},e.prototype.stop=function(e){this._gameView.stop()},e}(engine.Container);function index(e){return prepareProps(),injectProps(e),new GameWrapper}module.exports=index
;
\n
"
}
}
libs/types.d.ts
View file @
a9eac5bb
...
@@ -5102,6 +5102,7 @@ declare module engine {
...
@@ -5102,6 +5102,7 @@ declare module engine {
}
}
export
class
DisplayObject
extends
EventDispatcher
{
export
class
DisplayObject
extends
EventDispatcher
{
parent
;
/**
/**
* 基础信息
* 基础信息
*/
*/
...
@@ -5121,7 +5122,7 @@ declare module engine {
...
@@ -5121,7 +5122,7 @@ declare module engine {
* @member {Container}
* @member {Container}
* @readonly
* @readonly
*/
*/
parent
:
any
;
wrapper
:
any
;
/**
/**
* 舞台
* 舞台
*/
*/
...
...
src/custom/pictures/src/game/GameView.ts
View file @
a9eac5bb
...
@@ -34,8 +34,8 @@ export default class GameView extends engine.Container {
...
@@ -34,8 +34,8 @@ export default class GameView extends engine.Container {
if
(
this
.
pictures
)
{
if
(
this
.
pictures
)
{
for
(
const
pic
of
this
.
pictures
)
{
for
(
const
pic
of
this
.
pictures
)
{
if
(
pic
&&
pic
.
parent
)
if
(
pic
&&
pic
.
wrapper
)
pic
.
parent
.
removeChild
(
pic
);
pic
.
wrapper
.
removeChild
(
pic
);
}
}
}
}
...
...
src/custom/recycling/debug/app.js
View file @
a9eac5bb
...
@@ -46,7 +46,7 @@ function launchWithCustomModule(customModule) {
...
@@ -46,7 +46,7 @@ function launchWithCustomModule(customModule) {
},
100
);
},
100
);
setTimeout
(()
=>
{
setTimeout
(()
=>
{
engine
.
globalEvent
.
dispatchEvent
(
'recycling-start'
,
{
time
:
200
,
speed
:
3
});
engine
.
globalEvent
.
dispatchEvent
(
'recycling-start'
,
{
time
:
200
,
maxScore
:
6
});
const
d
=
engine
.
gameStage
.
sceneContainer
.
getChildAt
(
0
);
const
d
=
engine
.
gameStage
.
sceneContainer
.
getChildAt
(
0
);
},
200
);
},
200
);
...
@@ -58,7 +58,7 @@ function launchWithCustomModule(customModule) {
...
@@ -58,7 +58,7 @@ function launchWithCustomModule(customModule) {
// }, 1000 * 10);
// }, 1000 * 10);
});
});
engine
.
globalEvent
.
addEventListener
(
'recycling-time-update'
,
(
e
)
=>
{
engine
.
globalEvent
.
addEventListener
(
'recycling-time-update'
,
(
e
)
=>
{
console
.
log
(
e
.
type
,
e
.
data
);
//
console.log(e.type, e.data);
});
});
engine
.
globalEvent
.
addEventListener
(
'recycling-score-update'
,
(
e
)
=>
{
engine
.
globalEvent
.
addEventListener
(
'recycling-score-update'
,
(
e
)
=>
{
console
.
log
(
e
.
type
,
e
.
data
);
console
.
log
(
e
.
type
,
e
.
data
);
...
...
src/custom/recycling/debug/main.js
View file @
a9eac5bb
(
function
(
global
,
factory
)
{
"use strict"
;
var
tslib
=
require
(
"tslib"
);
function
getTexture
(
e
){
return
engine
.
Texture
.
from
(
getAssetByUUID
(
e
).
uuid
)}
function
getTextureByName
(
e
){
return
getTexture
(
engine
.
getAssetByName
(
e
).
uuid
)}
function
createSvga
(
e
,
t
){
var
i
=
new
svga
.
Svga
;
return
i
.
source
=
"asset://"
+
engine
.
getAssetByName
(
e
).
uuid
,
i
}
var
props
=
{};
function
prepareProps
(){
var
e
=
getProps
();
engine
.
injectProp
(
props
,
e
)}
function
injectProps
(
e
){
engine
.
injectProp
(
props
,
e
)}
var
GarbageTypes
,
Conveyor
=
function
(
i
){
function
e
(){
var
e
=
i
.
call
(
this
)
||
this
;
e
.
y
=
904.21
;
var
t
=
new
engine
.
Sprite
(
getTextureByName
(
"conveyor"
));
return
e
.
addChild
(
t
),
e
.
idx0
=
e
.
createItem
(
75
,
50
),
e
.
idx1
=
e
.
createItem
(
225
,
50
),
e
.
idx2
=
e
.
createItem
(
375
,
50
),
e
.
idx3
=
e
.
createItem
(
525
,
50
),
e
.
idx4
=
e
.
createItem
(
675
,
50
),
e
}
return
tslib
.
__extends
(
e
,
i
),
e
.
prototype
.
clear
=
function
(){
this
.
clearItem
(
this
.
idx0
),
this
.
clearItem
(
this
.
idx1
),
this
.
clearItem
(
this
.
idx2
),
this
.
clearItem
(
this
.
idx3
),
this
.
clearItem
(
this
.
idx4
)},
e
.
prototype
.
clearItem
=
function
(
e
){
0
<
e
.
children
.
length
&&
e
.
removeChildAt
(
0
)},
e
.
prototype
.
createItem
=
function
(
e
,
t
){
var
i
=
new
engine
.
Sprite
;
return
this
.
addChild
(
i
),
i
.
x
=
e
,
i
.
y
=
t
,
i
},
e
}(
engine
.
Sprite
);
!
function
(
e
){
e
.
recoverableWaste
=
"recoverableWaste"
,
e
.
harmfulWaste
=
"harmfulWaste"
,
e
.
wetWaste
=
"wetWaste"
,
e
.
dryWaste
=
"dryWaste"
}(
GarbageTypes
=
GarbageTypes
||
{});
var
GarbageConfig
=
function
(){
function
e
(){}
return
e
.
config
=
[{
name
:
"电池"
,
source
:
"g00"
,
type
:
GarbageTypes
.
harmfulWaste
,
width
:
51
,
height
:
123
},{
name
:
"温度计"
,
source
:
"g01"
,
type
:
GarbageTypes
.
harmfulWaste
,
width
:
65
,
height
:
130
},{
name
:
"鱼刺"
,
source
:
"g02"
,
type
:
GarbageTypes
.
wetWaste
,
width
:
104
,
height
:
82
},{
name
:
"龙虾"
,
source
:
"g03"
,
type
:
GarbageTypes
.
wetWaste
,
width
:
129
,
height
:
122
},{
name
:
"西瓜"
,
source
:
"g04"
,
type
:
GarbageTypes
.
wetWaste
,
width
:
134
,
height
:
111
},{
name
:
"旧玩具"
,
source
:
"g05"
,
type
:
GarbageTypes
.
recoverableWaste
,
width
:
72
,
height
:
135
},{
name
:
"口红"
,
source
:
"g06"
,
type
:
GarbageTypes
.
dryWaste
,
width
:
49
,
height
:
134
},{
name
:
"面包"
,
source
:
"g07"
,
type
:
GarbageTypes
.
wetWaste
,
width
:
96
,
height
:
128
},{
name
:
"绿植"
,
source
:
"g08"
,
type
:
GarbageTypes
.
wetWaste
,
width
:
81
,
height
:
131
},{
name
:
"保温瓶"
,
source
:
"g09"
,
type
:
GarbageTypes
.
recoverableWaste
,
width
:
66
,
height
:
137
},{
name
:
"破衣服"
,
source
:
"g10"
,
type
:
GarbageTypes
.
recoverableWaste
,
width
:
91
,
height
:
121
},{
name
:
"茶叶渣"
,
source
:
"g11"
,
type
:
GarbageTypes
.
wetWaste
,
width
:
108
,
height
:
125
},{
name
:
"湿巾"
,
source
:
"g12"
,
type
:
GarbageTypes
.
dryWaste
,
width
:
106
,
height
:
109
},{
name
:
"过期药膏"
,
source
:
"g13"
,
type
:
GarbageTypes
.
harmfulWaste
,
width
:
107
,
height
:
130
},{
name
:
"用完的洗发水瓶"
,
source
:
"g14"
,
type
:
GarbageTypes
.
recoverableWaste
,
width
:
153
,
height
:
148
},{
name
:
"婴儿纸尿裤"
,
source
:
"g15"
,
type
:
GarbageTypes
.
dryWaste
,
width
:
108
,
height
:
123
},{
name
:
"香水瓶"
,
source
:
"g16"
,
type
:
GarbageTypes
.
recoverableWaste
,
width
:
65
,
height
:
127
},{
name
:
"花甲壳"
,
source
:
"g17"
,
type
:
GarbageTypes
.
wetWaste
,
width
:
99
,
height
:
115
},{
name
:
"过期调味料"
,
source
:
"g18"
,
type
:
GarbageTypes
.
wetWaste
,
width
:
109
,
height
:
130
},{
name
:
"地毯"
,
source
:
"g19"
,
type
:
GarbageTypes
.
recoverableWaste
,
width
:
145
,
height
:
119
},{
name
:
"甘蔗渣"
,
source
:
"g20"
,
type
:
GarbageTypes
.
wetWaste
,
width
:
100
,
height
:
116
},{
name
:
"玻璃渣"
,
source
:
"g21"
,
type
:
GarbageTypes
.
recoverableWaste
,
width
:
95
,
height
:
122
},{
name
:
"番茄酱"
,
source
:
"g22"
,
type
:
GarbageTypes
.
wetWaste
,
width
:
82
,
height
:
125
},{
name
:
"酒精棉"
,
source
:
"g23"
,
type
:
GarbageTypes
.
dryWaste
,
width
:
64
,
height
:
124
},{
name
:
"指甲油瓶子"
,
source
:
"g24"
,
type
:
GarbageTypes
.
harmfulWaste
,
width
:
109
,
height
:
125
},{
name
:
"肉骨头"
,
source
:
"g25"
,
type
:
GarbageTypes
.
dryWaste
,
width
:
67
,
height
:
123
},{
name
:
"嚼过的口香糖"
,
source
:
"g26"
,
type
:
GarbageTypes
.
dryWaste
,
width
:
135
,
height
:
116
},{
name
:
"充电插头"
,
source
:
"g27"
,
type
:
GarbageTypes
.
recoverableWaste
,
width
:
86
,
height
:
128
},{
name
:
"旧报纸"
,
source
:
"g28"
,
type
:
GarbageTypes
.
recoverableWaste
,
width
:
68
,
height
:
124
},{
name
:
"烟头"
,
source
:
"g29"
,
type
:
GarbageTypes
.
dryWaste
,
width
:
108
,
height
:
145
},{
name
:
"奶茶塑料杯"
,
source
:
"g30"
,
type
:
GarbageTypes
.
dryWaste
,
width
:
109
,
height
:
143
},{
name
:
"瓜子壳"
,
source
:
"g31"
,
type
:
GarbageTypes
.
wetWaste
,
width
:
87
,
height
:
121
},{
name
:
"橘子皮"
,
source
:
"g32"
,
type
:
GarbageTypes
.
wetWaste
,
width
:
78
,
height
:
120
},{
name
:
"气球"
,
source
:
"g33"
,
type
:
GarbageTypes
.
dryWaste
,
width
:
78
,
height
:
121
},{
name
:
"树叶"
,
source
:
"g34"
,
type
:
GarbageTypes
.
wetWaste
,
width
:
75
,
height
:
117
},{
name
:
"感冒药"
,
source
:
"g35"
,
type
:
GarbageTypes
.
harmfulWaste
,
width
:
92
,
height
:
121
},{
name
:
"电话机"
,
source
:
"g36"
,
type
:
GarbageTypes
.
recoverableWaste
,
width
:
63
,
height
:
121
},{
name
:
"奶酪"
,
source
:
"g37"
,
type
:
GarbageTypes
.
wetWaste
,
width
:
90
,
height
:
116
},{
name
:
"啤酒瓶"
,
source
:
"g38"
,
type
:
GarbageTypes
.
recoverableWaste
,
width
:
64
,
height
:
123
},{
name
:
"薯片包装"
,
source
:
"g39"
,
type
:
GarbageTypes
.
dryWaste
,
width
:
134
,
height
:
123
},{
name
:
"过期保健品"
,
source
:
"g40"
,
type
:
GarbageTypes
.
harmfulWaste
,
width
:
108
,
height
:
125
},{
name
:
"雪糕包装袋"
,
source
:
"g41"
,
type
:
GarbageTypes
.
dryWaste
,
width
:
109
,
height
:
128
},{
name
:
"废油漆"
,
source
:
"g42"
,
type
:
GarbageTypes
.
harmfulWaste
,
width
:
98
,
height
:
122
},{
name
:
"食品罐头"
,
source
:
"g43"
,
type
:
GarbageTypes
.
recoverableWaste
,
width
:
94
,
height
:
117
},{
name
:
"陶瓷碗"
,
source
:
"g44"
,
type
:
GarbageTypes
.
dryWaste
,
width
:
105
,
height
:
122
},{
name
:
"蚊香"
,
source
:
"g45"
,
type
:
GarbageTypes
.
dryWaste
,
width
:
69
,
height
:
146
},{
name
:
"电脑机箱"
,
source
:
"g46"
,
type
:
GarbageTypes
.
recoverableWaste
,
width
:
84
,
height
:
124
},{
name
:
"鲜花"
,
source
:
"g47"
,
type
:
GarbageTypes
.
wetWaste
,
width
:
62
,
height
:
122
},{
name
:
"宠物粮食"
,
source
:
"g48"
,
type
:
GarbageTypes
.
wetWaste
,
width
:
87
,
height
:
121
},{
name
:
"银行卡"
,
source
:
"g49"
,
type
:
GarbageTypes
.
recoverableWaste
,
width
:
115
,
height
:
123
}],
e
}(),
checkHit
=
function
(
e
,
t
){
var
i
=
e
.
x
,
r
=
e
.
y
,
n
=
e
.
texture
,
a
=
n
.
width
,
s
=
n
.
height
;
return
i
>
t
.
x
&&
r
>
t
.
y
&&
i
+
a
<
t
.
x
+
t
.
width
&&
r
+
s
<
t
.
y
+
t
.
height
},
removeChild
=
function
(
e
){
e
&&
e
.
parent
&&
e
.
parent
.
removeChild
(
e
)},
removeEle
=
function
(
e
,
t
){
var
i
=
t
.
indexOf
(
e
);
0
<=
i
&&
t
.
splice
(
i
,
1
)},
shuffle
=
function
(
e
){
for
(
var
t
,
i
=
e
.
length
;
i
;){
var
r
=
Math
.
floor
(
Math
.
random
()
*
i
--
);
t
=
[
e
[
i
],
e
[
r
]],
e
[
r
]
=
t
[
0
],
e
[
i
]
=
t
[
1
]}
return
e
},
transStores
=
function
(
e
){
return
e
.
map
(
function
(
e
){
return
{
targetName
:
getTargetName
(
e
.
targetType
),
isCorrect
:
e
.
targetType
==
e
.
itemType
,
itemName
:
e
.
itemName
}})},
getTargetName
=
function
(
e
){
switch
(
e
){
case
GarbageTypes
.
recoverableWaste
:
return
"可回收物"
;
case
GarbageTypes
.
harmfulWaste
:
return
"有害垃圾"
;
case
GarbageTypes
.
wetWaste
:
return
"湿垃圾"
;
case
GarbageTypes
.
dryWaste
:
return
"干垃圾"
}},
Conveyors
=
function
(
i
){
function
e
(
e
){
var
t
=
i
.
call
(
this
)
||
this
;
return
t
.
conveyorsPool
=
[],
t
.
GarbageConfig
=
GarbageConfig
.
config
,
t
.
datas
=
[],
t
.
wrapper
=
e
,
t
}
return
tslib
.
__extends
(
e
,
i
),
e
.
prototype
.
initData
=
function
(
e
,
t
){
this
.
conveyor0
=
e
,
this
.
conveyor1
=
t
},
e
.
prototype
.
setDefault
=
function
(){
this
.
clear
(),
this
.
score
=
0
,
this
.
conveyorsPool
.
push
(
this
.
conveyor0
),
this
.
conveyorsPool
.
push
(
this
.
conveyor1
);
for
(
var
e
=
shuffle
(
this
.
GarbageConfig
),
t
=
0
;
t
<
20
;
t
++
)
e
[
t
].
idx
=
t
,
e
[
t
].
isRight
=!
1
,
e
[
t
].
isMistake
=!
1
,
e
[
t
].
isOnStage
=!
1
,
this
.
datas
.
push
(
e
[
t
]);
for
(
t
=
0
;
t
<
5
;
t
++
){
var
i
=
this
.
datas
[
t
],
r
=
new
engine
.
Sprite
(
getTextureByName
(
i
.
source
));
r
.
isWrong
=!
1
,
r
.
isRight
=!
1
,
i
.
isOnStage
=!
0
,
r
.
type
=
i
.
type
,
r
.
name
=
i
.
name
,
r
.
anchorX
=
i
.
width
/
2
,
r
.
anchorY
=
i
.
height
,
r
.
x
=-
i
.
width
/
2
,
r
.
y
=
40
-
i
.
height
,
this
.
conveyor1
[
"idx"
+
t
].
addChild
(
r
),
r
.
addEventListener
(
engine
.
MouseEvent
.
MOUSE_DOWN
,
this
.
onDwon_garbage
,
this
)}},
e
.
prototype
.
startConveyors
=
function
(){
this
.
setDefault
(),
engine
.
gameStage
.
addEventListener
(
engine
.
Event
.
ENTER_FRAME
,
this
.
onEnterFrame
,
this
)},
e
.
prototype
.
onEnterFrame
=
function
(
e
,
t
,
i
){
if
(
this
.
score
==
(
props
.
maxScore
||
100
)
&&
this
.
gameOver
(),
this
.
conveyorsPool
.
forEach
(
function
(
e
){
e
.
x
-=
props
.
speed
||
3
}),
this
.
conveyorsPool
[
this
.
conveyorsPool
.
length
-
1
].
x
<=
764
){
var
r
=
new
Conveyor
;
r
.
x
=
this
.
conveyorsPool
[
this
.
conveyorsPool
.
length
-
1
].
x
+
764
,
this
.
wrapper
.
addChild
(
r
),
this
.
conveyorsPool
.
push
(
r
)}
else
{
for
(
var
n
=
[],
a
=
0
;
a
<
this
.
datas
.
length
;
a
++
){(
u
=
this
.
datas
[
a
]).
isRight
||
u
.
isOnStage
||
n
.
push
(
u
)}
for
(
var
s
=
this
.
conveyorsPool
[
this
.
conveyorsPool
.
length
-
1
],
o
=
0
;
o
<
5
;
o
++
)
if
(
!
s
[
"idx"
+
o
].
children
[
0
]){
var
h
=
n
.
shift
();
if
(
!
h
)
break
;
h
.
isOnStage
=!
0
;
var
c
=
new
engine
.
Sprite
(
getTextureByName
(
h
.
source
));
c
.
isWrong
=!
1
,
c
.
isRight
=!
1
,
c
.
type
=
h
.
type
,
c
.
name
=
h
.
name
,
c
.
anchorX
=
h
.
width
/
2
,
c
.
anchorY
=
h
.
height
,
c
.
x
=-
h
.
width
/
2
,
c
.
y
=
40
-
h
.
height
,
s
[
"idx"
+
o
].
addChild
(
c
),
c
.
addEventListener
(
engine
.
MouseEvent
.
MOUSE_DOWN
,
this
.
onDwon_garbage
,
this
)}}
if
(
this
.
conveyorsPool
[
0
].
x
<-
750
){
for
(
var
g
=
0
;
g
<
this
.
datas
.
length
;
g
++
){
var
u
=
this
.
datas
[
g
],
d
=
this
.
conveyorsPool
[
0
].
idx4
;
if
(
d
.
children
[
0
]
&&
u
.
name
==
d
.
children
[
0
].
name
){
u
.
isOnStage
=!
1
,
removeEle
(
u
,
this
.
datas
),
this
.
datas
.
push
(
u
),
d
.
removeChild
(
d
.
children
[
0
]);
break
}}
this
.
conveyorsPool
.
shift
()}
else
if
(
this
.
conveyorsPool
[
0
].
x
<-
600
)
for
(
g
=
0
;
g
<
this
.
datas
.
length
;
g
++
){
u
=
this
.
datas
[
g
];
var
l
=
this
.
conveyorsPool
[
0
].
idx3
;
if
(
l
.
children
[
0
]
&&
u
.
name
==
l
.
children
[
0
].
name
){
u
.
isOnStage
=!
1
,
removeEle
(
u
,
this
.
datas
),
this
.
datas
.
push
(
u
),
l
.
removeChild
(
l
.
children
[
0
]);
break
}}
else
if
(
this
.
conveyorsPool
[
0
].
x
<-
450
)
for
(
g
=
0
;
g
<
this
.
datas
.
length
;
g
++
){
u
=
this
.
datas
[
g
];
var
p
=
this
.
conveyorsPool
[
0
].
idx2
;
if
(
p
.
children
[
0
]
&&
u
.
name
==
p
.
children
[
0
].
name
){
u
.
isOnStage
=!
1
,
removeEle
(
u
,
this
.
datas
),
this
.
datas
.
push
(
u
),
p
.
removeChild
(
p
.
children
[
0
]);
break
}}
else
if
(
this
.
conveyorsPool
[
0
].
x
<-
300
)
for
(
g
=
0
;
g
<
this
.
datas
.
length
;
g
++
){
u
=
this
.
datas
[
g
];
var
y
=
this
.
conveyorsPool
[
0
].
idx1
;
if
(
y
.
children
[
0
]
&&
u
.
name
==
y
.
children
[
0
].
name
){
u
.
isOnStage
=!
1
,
removeEle
(
u
,
this
.
datas
),
this
.
datas
.
push
(
u
),
y
.
removeChild
(
y
.
children
[
0
]);
break
}}
else
if
(
this
.
conveyorsPool
[
0
].
x
<-
150
)
for
(
g
=
0
;
g
<
this
.
datas
.
length
;
g
++
){
u
=
this
.
datas
[
g
];
var
m
=
this
.
conveyorsPool
[
0
].
idx0
;
if
(
m
.
children
[
0
]
&&
u
.
name
==
m
.
children
[
0
].
name
){
u
.
isOnStage
=!
1
,
removeEle
(
u
,
this
.
datas
),
this
.
datas
.
push
(
u
),
m
.
removeChild
(
m
.
children
[
0
]);
break
}}},
e
.
prototype
.
addscore
=
function
(){
this
.
score
+=
props
.
onceScore
||
2
,
engine
.
globalEvent
.
dispatchEvent
(
"recycling-score-update"
,{
score
:
this
.
score
})},
e
.
prototype
.
gameOver
=
function
(){
engine
.
gameStage
.
removeEventListener
(
engine
.
Event
.
ENTER_FRAME
,
this
.
onEnterFrame
,
this
),
engine
.
globalEvent
.
dispatchEvent
(
"recycling-game-end"
,
transStores
(
this
.
stores
))},
e
.
prototype
.
onDwon_garbage
=
function
(
e
){
var
t
=
e
.
target
,
i
=
new
engine
.
Sprite
(
t
.
texture
);
this
.
_currentView
=
i
,
this
.
wrapper
.
addChild
(
i
),
i
.
x
=
e
.
stageX
-
t
.
texture
.
width
/
2
,
i
.
y
=
e
.
stageY
-
t
.
texture
.
height
/
2
,
i
.
type
=
t
.
type
,
i
.
name
=
t
.
name
,
this
.
wrapper
.
once
(
engine
.
MouseEvent
.
MOUSE_UP
,
this
.
onStageMouseUp
,
this
),
this
.
wrapper
.
addEventListener
(
engine
.
MouseEvent
.
MOUSE_MOVE
,
this
.
onStageMouseMove
,
this
)},
e
.
prototype
.
onStageMouseMove
=
function
(
e
){
var
t
=
this
.
_currentView
;
t
.
x
=
e
.
stageX
-
t
.
texture
.
width
/
2
,
t
.
y
=
e
.
stageY
-
t
.
texture
.
height
/
2
},
e
.
prototype
.
onStageMouseUp
=
function
(
e
){
var
t
=
this
;
if
(
this
.
wrapper
.
removeEventListener
(
engine
.
MouseEvent
.
MOUSE_MOVE
,
this
.
onStageMouseMove
,
this
),
this
.
_currentView
){
var
i
=
this
.
checkHitRect
();
i
?(
console
.
log
(
"落入垃圾桶类型"
,
i
,
"垃圾类型"
,
this
.
_currentView
.
type
),
i
==
this
.
_currentView
.
type
&&
this
.
addscore
(),
this
.
stores
.
push
({
targetType
:
i
,
itemType
:
this
.
_currentView
.
type
,
itemName
:
this
.
_currentView
.
name
})):
console
.
log
(
"没有落入"
),
this
.
_currentView
.
anchorX
=
this
.
_currentView
.
texture
.
width
/
2
,
this
.
_currentView
.
anchorY
=
this
.
_currentView
.
texture
.
height
/
2
,
engine
.
Tween
.
get
(
this
.
_currentView
).
to
({
scaleX
:
0
,
scaleY
:
0
},
300
).
call
(
function
(){
removeChild
(
t
.
_currentView
)})}},
e
.
prototype
.
clear
=
function
(){
this
.
conveyorsPool
.
forEach
(
function
(
e
){
e
.
clear
()}),
this
.
conveyorsPool
=
[],
this
.
datas
=
[],
this
.
stores
=
[]},
e
.
prototype
.
timeout
=
function
(){
this
.
gameOver
()},
e
.
prototype
.
checkHitRect
=
function
(){
return
checkHit
(
this
.
_currentView
,
this
.
wrapper
.
wetWaste
)?
GarbageTypes
.
wetWaste
:
checkHit
(
this
.
_currentView
,
this
.
wrapper
.
harmfulWaste
)?
GarbageTypes
.
harmfulWaste
:
checkHit
(
this
.
_currentView
,
this
.
wrapper
.
dryWaste
)?
GarbageTypes
.
dryWaste
:
checkHit
(
this
.
_currentView
,
this
.
wrapper
.
recoverableWaste
)?
GarbageTypes
.
recoverableWaste
:
null
},
e
}(
engine
.
Sprite
),
uiConfig
=
function
(){
return
[{
id
:
"playBg"
,
texture
:
"playBg"
},{
id
:
"idler0"
,
texture
:
"idlerWheel"
,
pos
:[
75
,
1038
],
anchor
:[
20
,
21.5
]},{
id
:
"idler1"
,
texture
:
"idlerWheel"
,
pos
:[
175
,
1038
],
anchor
:[
20
,
21.5
]},{
id
:
"idler2"
,
texture
:
"idlerWheel"
,
pos
:[
275
,
1038
],
anchor
:[
20
,
21.5
]},{
id
:
"idler3"
,
texture
:
"idlerWheel"
,
pos
:[
375
,
1038
],
anchor
:[
20
,
21.5
]},{
id
:
"idler4"
,
texture
:
"idlerWheel"
,
pos
:[
475
,
1038
],
anchor
:[
20
,
21.5
]},{
id
:
"idler5"
,
texture
:
"idlerWheel"
,
pos
:[
575
,
1038
],
anchor
:[
20
,
21.5
]},{
id
:
"idler6"
,
texture
:
"idlerWheel"
,
pos
:[
675
,
1038
],
anchor
:[
20
,
21.5
]}]},
getGuideInfo
=
function
(){
return
window
.
localStorage
?
localStorage
.
getItem
(
"recyclingGuide"
):
0
},
setGuide
=
function
(){
window
.
localStorage
&&
localStorage
.
setItem
(
"recyclingGuide"
,
"1"
)},
createBg
=
function
(
e
){
void
0
===
e
&&
(
e
=
1
);
var
t
=
new
engine
.
Graphics
;
return
t
.
beginFill
(
0
),
t
.
drawRect
(
0
,
0
,
750
,
1624
),
t
.
endFill
(),
t
.
alpha
=
e
,
t
},
createImg
=
function
(
e
){
return
new
engine
.
Sprite
(
getTextureByName
(
e
))},
CountDownGroup
=
function
(
t
){
function
e
(){
var
e
=
t
.
call
(
this
)
||
this
;
return
e
.
addChild
(
createBg
(.
6
)),
e
.
num1
=
createImg
(
"num1"
),
e
.
num2
=
createImg
(
"num2"
),
e
.
num3
=
createImg
(
"num3"
),
e
.
go
=
createImg
(
"go"
),
e
.
go
.
anchorX
=
240
,
e
.
go
.
anchorY
=
171.5
,
e
.
num1
.
anchorX
=
125.5
,
e
.
num1
.
anchorY
=
189
,
e
.
num2
.
anchorX
=
149.5
,
e
.
num2
.
anchorY
=
191.5
,
e
.
num3
.
anchorX
=
148.5
,
e
.
num3
.
anchorY
=
191.5
,
e
.
go
.
x
=
135
,
e
.
go
.
y
=
353.5
,
e
.
num1
.
x
=
249.5
,
e
.
num1
.
y
=
340
,
e
.
num2
.
x
=
225.5
,
e
.
num2
.
y
=
334.5
,
e
.
num3
.
x
=
226.5
,
e
.
num3
.
y
=
333.5
,
e
.
addChild
(
e
.
num1
),
e
.
addChild
(
e
.
num2
),
e
.
addChild
(
e
.
num3
),
e
.
addChild
(
e
.
go
),
e
.
visible
=!
1
,
e
.
reset
(),
e
}
return
tslib
.
__extends
(
e
,
t
),
e
.
prototype
.
reset
=
function
(){
this
.
go
.
alpha
=
this
.
num1
.
alpha
=
this
.
num2
.
alpha
=
this
.
num3
.
alpha
=
0
,
this
.
go
.
scaleX
=
this
.
num1
.
scaleX
=
this
.
num2
.
scaleX
=
this
.
num3
.
scaleX
=
3
,
this
.
go
.
scaleY
=
this
.
num1
.
scaleY
=
this
.
num2
.
scaleY
=
this
.
num3
.
scaleY
=
3
},
e
.
prototype
.
startCountDown
=
function
(){
return
tslib
.
__awaiter
(
this
,
void
0
,
void
0
,
function
(){
var
t
=
this
;
return
tslib
.
__generator
(
this
,
function
(
e
){
return
[
2
,
new
Promise
(
function
(
e
){
t
.
reset
(),
t
.
visible
=!
0
,
t
.
num3
.
alpha
=
1
,
engine
.
Tween
.
get
(
t
.
num3
).
to
({
scaleX
:.
8
,
scaleY
:.
8
},
200
).
to
({
scaleX
:
1
,
scaleY
:
1
},
100
).
wait
(
500
).
to
({
scaleX
:
0
,
scaleY
:
0
},
200
).
call
(
function
(){
t
.
num2
.
alpha
=
1
,
engine
.
Tween
.
get
(
t
.
num2
).
to
({
scaleX
:.
8
,
scaleY
:.
8
},
200
).
to
({
scaleX
:
1
,
scaleY
:
1
},
100
).
wait
(
500
).
to
({
scaleX
:
0
,
scaleY
:
0
},
200
).
call
(
function
(){
t
.
num1
.
alpha
=
1
,
engine
.
Tween
.
get
(
t
.
num1
).
to
({
scaleX
:.
8
,
scaleY
:.
8
},
200
).
to
({
scaleX
:
1
,
scaleY
:
1
},
100
).
wait
(
500
).
to
({
scaleX
:
0
,
scaleY
:
0
},
200
).
call
(
function
(){
t
.
go
.
alpha
=
1
,
engine
.
Tween
.
get
(
t
.
go
).
to
({
scaleX
:.
8
,
scaleY
:.
8
},
200
).
to
({
scaleX
:
1
,
scaleY
:
1
},
100
).
wait
(
500
).
call
(
function
(){
t
.
visible
=!
1
,
e
()})})})})})]})})},
e
}(
engine
.
Sprite
),
GuideView
=
function
(
t
){
function
e
(){
var
e
=
t
.
call
(
this
)
||
this
;
return
e
.
initUI
(),
e
.
visible
=!
1
,
e
}
return
tslib
.
__extends
(
e
,
t
),
e
.
prototype
.
initUI
=
function
(){
this
.
addChild
(
createBg
(.
6
)),
this
.
guideBg
=
createImg
(
"guideBg"
),
this
.
addChild
(
this
.
guideBg
),
this
.
guideEle
=
createImg
(
"guideEle"
),
this
.
addChild
(
this
.
guideEle
),
this
.
guideBg
.
x
=
393
,
this
.
guideBg
.
y
=
552
,
this
.
guideEle
.
x
=
361
,
this
.
guideEle
.
y
=
877
,
this
.
guideEle
.
mouseEnabled
=
this
.
guideEle
.
mouseChildren
=!
0
;
var
e
=
createSvga
(
"guideTips"
);
this
.
svga
=
e
,
this
.
addChild
(
e
),
e
.
gotoAndStop
(
1
),
e
.
mouseEnabled
=
e
.
mouseChildren
=!
1
},
e
.
prototype
.
checkHit
=
function
(
e
,
t
,
i
,
r
){
var
n
=
new
engine
.
Rectangle
(
393
,
552
,
281
,
320
);
return
e
>
n
.
x
&&
t
>
n
.
y
&&
e
+
i
<
n
.
x
+
n
.
width
&&
t
+
r
<
n
.
y
+
n
.
height
},
e
.
prototype
.
startGuide
=
function
(){
return
tslib
.
__awaiter
(
this
,
void
0
,
void
0
,
function
(){
var
s
=
this
;
return
tslib
.
__generator
(
this
,
function
(
e
){
return
[
2
,
new
Promise
(
function
(
t
){
s
.
visible
=!
0
,
s
.
svga
.
gotoAndStop
(
1
),
s
.
svga
.
play
(
!
1
,
!
0
),
s
.
guideEle
.
scaleX
=
1
,
s
.
guideEle
.
scaleY
=
1
;
function
i
(
e
){
s
.
stage
.
removeEventListener
(
engine
.
MouseEvent
.
MOUSE_MOVE
,
n
,
s
),
s
.
checkHit
(
s
.
guideEle
.
x
,
s
.
guideEle
.
y
,
s
.
guideEle
.
width
,
s
.
guideEle
.
height
)?(
s
.
guideEle
.
removeEventListener
(
engine
.
MouseEvent
.
MOUSE_DOWN
,
a
,
s
),
engine
.
Tween
.
get
(
s
.
guideEle
).
to
({
scaleX
:
0
,
scaleY
:
0
},
300
).
call
(
function
(){
s
.
visible
=!
1
,
t
()})):(
s
.
svga
.
visible
=!
0
,
s
.
guideEle
.
x
=
361
,
s
.
guideEle
.
y
=
877
)}
var
r
=
[
0
,
0
],
n
=
function
(
e
){
s
.
guideEle
.
x
=
e
.
stageX
-
r
[
0
],
s
.
guideEle
.
y
=
e
.
stageY
-
r
[
1
]},
a
=
function
(
e
){
r
=
[
e
.
localX
,
e
.
localY
],
s
.
svga
.
visible
=!
1
,
s
.
stage
.
once
(
engine
.
MouseEvent
.
MOUSE_UP
,
i
,
s
),
s
.
stage
.
addEventListener
(
engine
.
MouseEvent
.
MOUSE_MOVE
,
n
,
s
)};
s
.
guideEle
.
addEventListener
(
engine
.
MouseEvent
.
MOUSE_DOWN
,
a
,
s
)})]})})},
e
}(
engine
.
Sprite
),
GameView
=
function
(
t
){
function
e
(){
var
e
=
t
.
call
(
this
)
||
this
;
return
e
.
_timeCounter
=
0
,
e
.
once
(
engine
.
Event
.
ADDED_TO_STAGE
,
e
.
setup
,
e
),
e
}
return
tslib
.
__extends
(
e
,
t
),
e
.
prototype
.
configUI
=
function
(){
var
e
=
{};
this
.
uiMap
=
e
;
for
(
var
t
=
0
,
i
=
uiConfig
();
t
<
i
.
length
;
t
++
){
var
r
=
i
[
t
],
n
=
r
.
id
,
a
=
r
.
texture
,
s
=
r
.
pos
,
o
=
r
.
anchor
,
h
=
new
engine
.
Sprite
(
getTextureByName
(
a
));
this
.
addChild
(
h
),
e
[
n
]
=
h
,
o
&&
(
h
.
anchorX
=
o
[
0
],
h
.
anchorY
=
o
[
1
]),
s
&&
(
h
.
x
=
s
[
0
],
h
.
y
=
s
[
1
],
o
&&
(
h
.
x
=
s
[
0
]
-
h
.
anchorX
,
h
.
y
=
s
[
1
]
-
h
.
anchorY
))}
this
.
configConveyors
(),
this
.
createRects
(),
this
.
countdown
=
new
CountDownGroup
,
this
.
addChild
(
this
.
countdown
),
this
.
guide
=
new
GuideView
,
this
.
addChild
(
this
.
guide
)},
e
.
prototype
.
createRects
=
function
(){
this
.
wetWaste
=
this
.
createRect
(
74
,
552
,
301
,
293
,
16777215
),
this
.
harmfulWaste
=
this
.
createRect
(
75
,
247
,
300
,
293
,
16711680
),
this
.
dryWaste
=
this
.
createRect
(
389
,
249
,
286
,
291
,
0
),
this
.
recoverableWaste
=
this
.
createRect
(
389
,
551
,
287
,
292
,
255
)},
e
.
prototype
.
createRect
=
function
(
e
,
t
,
i
,
r
,
n
){
var
a
=
new
engine
.
Rectangle
(
e
,
t
,
i
,
r
),
s
=
new
engine
.
Sprite
;
this
.
addChild
(
s
),
s
.
x
=
e
,
s
.
y
=
t
;
var
o
=
new
engine
.
Graphics
;
return
o
.
alpha
=
0
,
o
.
beginFill
(
n
),
o
.
drawRect
(
0
,
0
,
i
,
r
),
o
.
endFill
(),
s
.
addChild
(
o
),
a
},
e
.
prototype
.
configConveyors
=
function
(){
var
e
=
new
Conveyor
;
e
.
x
=
0
;
var
t
=
new
Conveyor
;
this
.
addChild
(
e
),
this
.
addChild
(
t
),
t
.
x
=
764
,
this
.
conveyors
=
new
Conveyors
(
this
),
this
.
conveyors
.
initData
(
e
,
t
)},
e
.
prototype
.
playAni
=
function
(){
var
t
=
this
,
e
=
[
"idler0"
,
"idler1"
,
"idler2"
,
"idler3"
,
"idler4"
,
"idler5"
,
"idler6"
];(
e
=
e
.
map
(
function
(
e
){
return
t
.
uiMap
[
e
]})).
forEach
(
function
(
e
){
engine
.
Tween
.
get
(
e
,{
loop
:
!
0
}).
to
({
rotation
:
-
360
},
1
e3
)})},
e
.
prototype
.
stopAni
=
function
(){
var
t
=
this
,
e
=
[
"idler0"
,
"idler1"
,
"idler2"
,
"idler3"
,
"idler4"
,
"idler5"
,
"idler6"
];(
e
=
e
.
map
(
function
(
e
){
return
t
.
uiMap
[
e
]})).
forEach
(
function
(
e
){
engine
.
Tween
.
removeTweens
(
e
)})},
e
.
prototype
.
start
=
function
(){
return
tslib
.
__awaiter
(
this
,
void
0
,
void
0
,
function
(){
var
t
=
this
;
return
tslib
.
__generator
(
this
,
function
(
e
){
switch
(
e
.
label
){
case
0
:
return
console
.
log
(
"on start"
),
this
.
_timeCounter
=
0
,
getGuideInfo
()?[
3
,
2
]:[
4
,
this
.
guide
.
startGuide
()];
case
1
:
e
.
sent
(),
setGuide
(),
e
.
label
=
2
;
case
2
:
return
this
.
startGame
(),
engine
.
globalEvent
.
dispatchEvent
(
"recycling-time-update"
,{
second
:
this
.
getSecond
()}),
this
.
_timer
=
setInterval
(
function
(){
t
.
onTimer
()},
1
e3
),[
2
]}})})},
e
.
prototype
.
startGame
=
function
(){
this
.
playAni
(),
this
.
conveyors
.
startConveyors
()},
e
.
prototype
.
stopGame
=
function
(){
this
.
stopAni
()},
e
.
prototype
.
getSecond
=
function
(){
return
props
.
time
-
this
.
_timeCounter
},
e
.
prototype
.
onTimer
=
function
(){
this
.
_timeCounter
++
,
engine
.
globalEvent
.
dispatchEvent
(
"recycling-time-update"
,{
second
:
this
.
getSecond
()}),
0
==
this
.
getSecond
()
&&
(
this
.
stop
(),
this
.
conveyors
.
timeout
())},
e
.
prototype
.
stop
=
function
(){
clearInterval
(
this
.
_timer
),
this
.
stopGame
()},
e
.
prototype
.
setup
=
function
(){
console
.
log
(
"onSteup"
,
props
),
this
.
configUI
()},
e
.
prototype
.
onDown
=
function
(
e
){},
e
.
prototype
.
stageOnUp
=
function
(
e
){},
e
.
prototype
.
onSuccess
=
function
(){},
e
.
prototype
.
onMove
=
function
(
e
){},
e
}(
engine
.
Container
),
GameWrapper
=
function
(
i
){
function
e
(){
var
e
=
i
.
call
(
this
)
||
this
;
engine
.
globalEvent
.
addEventListener
(
"recycling-start"
,
e
.
start
,
e
),
engine
.
globalEvent
.
addEventListener
(
"recycling-stop"
,
e
.
stop
,
e
);
var
t
=
e
.
_gameView
=
new
GameView
;
return
e
.
addChild
(
t
),
e
}
return
tslib
.
__extends
(
e
,
i
),
e
.
prototype
.
start
=
function
(
e
){
injectProps
(
e
.
data
),
this
.
_gameView
.
start
()},
e
.
prototype
.
stop
=
function
(
e
){
this
.
_gameView
.
stop
()},
e
}(
engine
.
Container
);
function
index
(
e
){
return
prepareProps
(),
injectProps
(
e
),
new
GameWrapper
}
module
.
exports
=
index
;
typeof
exports
===
'object'
&&
typeof
module
!==
'undefined'
?
module
.
exports
=
factory
(
require
(
'tslib'
))
:
typeof
define
===
'function'
&&
define
.
amd
?
define
([
'tslib'
],
factory
)
:
(
global
=
global
||
self
,
global
.
recycling
=
factory
(
global
.
tslib
));
}(
this
,
(
function
(
tslib
)
{
'use strict'
;
function
getTexture
(
uuid
)
{
return
engine
.
Texture
.
from
(
getAssetByUUID
(
uuid
).
uuid
);
}
function
getTextureByName
(
name
)
{
return
getTexture
(
engine
.
getAssetByName
(
name
).
uuid
);
}
function
createSvga
(
name
,
anchorName
)
{
var
inst
=
new
svga
.
Svga
();
inst
.
source
=
'asset://'
+
engine
.
getAssetByName
(
name
).
uuid
;
return
inst
;
}
//# sourceMappingURL=utils.js.map
var
props
=
{};
function
prepareProps
()
{
var
metaProps
=
getProps
();
engine
.
injectProp
(
props
,
metaProps
);
}
function
injectProps
(
p
)
{
engine
.
injectProp
(
props
,
p
);
}
//# sourceMappingURL=props.js.map
var
Conveyor
=
(
function
(
_super
)
{
tslib
.
__extends
(
Conveyor
,
_super
);
function
Conveyor
()
{
var
_this
=
_super
.
call
(
this
)
||
this
;
_this
.
y
=
904.21
;
var
sp
=
new
engine
.
Sprite
(
getTextureByName
(
'conveyor'
));
_this
.
addChild
(
sp
);
_this
.
idx0
=
_this
.
createItem
(
75
,
50
);
_this
.
idx1
=
_this
.
createItem
(
225
,
50
);
_this
.
idx2
=
_this
.
createItem
(
375
,
50
);
_this
.
idx3
=
_this
.
createItem
(
525
,
50
);
_this
.
idx4
=
_this
.
createItem
(
675
,
50
);
return
_this
;
}
Conveyor
.
prototype
.
createItem
=
function
(
x
,
y
)
{
var
sp
=
new
engine
.
Sprite
();
this
.
addChild
(
sp
);
sp
.
x
=
x
-
50
;
sp
.
y
=
y
-
50
;
var
g
=
new
engine
.
Graphics
;
g
.
beginFill
(
0xff0000
);
g
.
drawRect
(
0
,
0
,
100
,
100
);
g
.
endFill
();
sp
.
addChild
(
g
);
return
sp
;
};
return
Conveyor
;
}(
engine
.
Sprite
));
//# sourceMappingURL=Conveyor.js.map
var
uiConfig
=
(
function
()
{
return
[
{
id
:
'playBg'
,
texture
:
'playBg'
},
{
id
:
'idler0'
,
texture
:
'idlerWheel'
,
pos
:
[
75
,
1038
],
anchor
:
[
20
,
21.5
]
},
{
id
:
'idler1'
,
texture
:
'idlerWheel'
,
pos
:
[
175
,
1038
],
anchor
:
[
20
,
21.5
]
},
{
id
:
'idler2'
,
texture
:
'idlerWheel'
,
pos
:
[
275
,
1038
],
anchor
:
[
20
,
21.5
]
},
{
id
:
'idler3'
,
texture
:
'idlerWheel'
,
pos
:
[
375
,
1038
],
anchor
:
[
20
,
21.5
]
},
{
id
:
'idler4'
,
texture
:
'idlerWheel'
,
pos
:
[
475
,
1038
],
anchor
:
[
20
,
21.5
]
},
{
id
:
'idler5'
,
texture
:
'idlerWheel'
,
pos
:
[
575
,
1038
],
anchor
:
[
20
,
21.5
]
},
{
id
:
'idler6'
,
texture
:
'idlerWheel'
,
pos
:
[
675
,
1038
],
anchor
:
[
20
,
21.5
]
},
];
});
//# sourceMappingURL=uiConfig.js.map
var
getGuideInfo
=
(
function
()
{
if
(
!
window
.
localStorage
)
{
return
0
;
}
return
localStorage
.
getItem
(
'recyclingGuide'
);
});
var
setGuide
=
function
()
{
if
(
window
.
localStorage
)
localStorage
.
setItem
(
'recyclingGuide'
,
'1'
);
};
//# sourceMappingURL=getGuideInfo.js.map
var
createBg
=
(
function
(
a
)
{
if
(
a
===
void
0
)
{
a
=
1
;
}
var
rect
=
new
engine
.
Graphics
();
rect
.
beginFill
(
0
);
rect
.
drawRect
(
0
,
0
,
750
,
1624
);
rect
.
endFill
();
rect
.
alpha
=
a
;
return
rect
;
});
//# sourceMappingURL=createBg.js.map
var
createImg
=
(
function
(
texture
)
{
return
new
engine
.
Sprite
(
getTextureByName
(
texture
));
});
//# sourceMappingURL=createImg.js.map
var
CountDownGroup
=
(
function
(
_super
)
{
tslib
.
__extends
(
CountDownGroup
,
_super
);
function
CountDownGroup
()
{
var
_this
=
_super
.
call
(
this
)
||
this
;
_this
.
addChild
(
createBg
(.
6
));
_this
.
num1
=
createImg
(
'num1'
);
_this
.
num2
=
createImg
(
'num2'
);
_this
.
num3
=
createImg
(
'num3'
);
_this
.
go
=
createImg
(
'go'
);
_this
.
go
.
anchorX
=
240
;
_this
.
go
.
anchorY
=
171.5
;
_this
.
num1
.
anchorX
=
125.5
;
_this
.
num1
.
anchorY
=
189
;
_this
.
num2
.
anchorX
=
149.5
;
_this
.
num2
.
anchorY
=
191.5
;
_this
.
num3
.
anchorX
=
148.5
;
_this
.
num3
.
anchorY
=
191.5
;
_this
.
go
.
x
=
750
/
2
-
240
;
_this
.
go
.
y
=
525
-
171.5
;
_this
.
num1
.
x
=
750
/
2
-
125.5
;
_this
.
num1
.
y
=
529
-
189
;
_this
.
num2
.
x
=
750
/
2
-
149.5
;
_this
.
num2
.
y
=
526
-
191.5
;
_this
.
num3
.
x
=
750
/
2
-
148.5
;
_this
.
num3
.
y
=
525
-
191.5
;
_this
.
addChild
(
_this
.
num1
);
_this
.
addChild
(
_this
.
num2
);
_this
.
addChild
(
_this
.
num3
);
_this
.
addChild
(
_this
.
go
);
_this
.
visible
=
false
;
_this
.
reset
();
return
_this
;
}
CountDownGroup
.
prototype
.
reset
=
function
()
{
this
.
go
.
alpha
=
this
.
num1
.
alpha
=
this
.
num2
.
alpha
=
this
.
num3
.
alpha
=
0
;
this
.
go
.
scaleX
=
this
.
num1
.
scaleX
=
this
.
num2
.
scaleX
=
this
.
num3
.
scaleX
=
3
;
this
.
go
.
scaleY
=
this
.
num1
.
scaleY
=
this
.
num2
.
scaleY
=
this
.
num3
.
scaleY
=
3
;
};
CountDownGroup
.
prototype
.
startCountDown
=
function
()
{
return
tslib
.
__awaiter
(
this
,
void
0
,
void
0
,
function
()
{
var
_this
=
this
;
return
tslib
.
__generator
(
this
,
function
(
_a
)
{
return
[
2
,
new
Promise
(
function
(
r
)
{
_this
.
reset
();
_this
.
visible
=
true
;
_this
.
num3
.
alpha
=
1
;
var
n3
=
engine
.
Tween
.
get
(
_this
.
num3
);
n3
.
to
({
scaleX
:
0.8
,
scaleY
:
0.8
},
200
).
to
({
scaleX
:
1
,
scaleY
:
1
},
100
).
wait
(
500
).
to
({
scaleX
:
0
,
scaleY
:
0
},
200
).
call
(
function
()
{
_this
.
num2
.
alpha
=
1
;
var
n2
=
engine
.
Tween
.
get
(
_this
.
num2
);
n2
.
to
({
scaleX
:
0.8
,
scaleY
:
0.8
},
200
).
to
({
scaleX
:
1
,
scaleY
:
1
},
100
).
wait
(
500
).
to
({
scaleX
:
0
,
scaleY
:
0
},
200
).
call
(
function
()
{
_this
.
num1
.
alpha
=
1
;
var
n1
=
engine
.
Tween
.
get
(
_this
.
num1
);
n1
.
to
({
scaleX
:
0.8
,
scaleY
:
0.8
},
200
).
to
({
scaleX
:
1
,
scaleY
:
1
},
100
).
wait
(
500
).
to
({
scaleX
:
0
,
scaleY
:
0
},
200
).
call
(
function
()
{
_this
.
go
.
alpha
=
1
;
var
go
=
engine
.
Tween
.
get
(
_this
.
go
);
go
.
to
({
scaleX
:
0.8
,
scaleY
:
0.8
},
200
).
to
({
scaleX
:
1
,
scaleY
:
1
},
100
).
wait
(
500
).
call
(
function
()
{
_this
.
visible
=
false
;
r
();
});
});
});
});
})];
});
});
};
return
CountDownGroup
;
}(
engine
.
Sprite
));
//# sourceMappingURL=CountDownGroup.js.map
var
GuideView
=
(
function
(
_super
)
{
tslib
.
__extends
(
GuideView
,
_super
);
function
GuideView
()
{
var
_this
=
_super
.
call
(
this
)
||
this
;
_this
.
initUI
();
_this
.
visible
=
false
;
return
_this
;
}
GuideView
.
prototype
.
initUI
=
function
()
{
this
.
addChild
(
createBg
(.
6
));
this
.
guideBg
=
createImg
(
'guideBg'
);
this
.
addChild
(
this
.
guideBg
);
this
.
guideEle
=
createImg
(
'guideEle'
);
this
.
addChild
(
this
.
guideEle
);
this
.
guideBg
.
x
=
393
;
this
.
guideBg
.
y
=
552
;
this
.
guideEle
.
x
=
361
;
this
.
guideEle
.
y
=
877
;
this
.
guideEle
.
mouseEnabled
=
this
.
guideEle
.
mouseChildren
=
true
;
var
svga
=
createSvga
(
"guideTips"
);
this
.
svga
=
svga
;
this
.
addChild
(
svga
);
svga
.
gotoAndStop
(
1
);
svga
.
mouseEnabled
=
svga
.
mouseChildren
=
false
;
};
GuideView
.
prototype
.
checkHit
=
function
(
x
,
y
,
w
,
h
)
{
var
rect
=
new
engine
.
Rectangle
(
393
,
552
,
281
,
320
);
if
(
x
>
rect
.
x
&&
y
>
rect
.
y
&&
(
x
+
w
)
<
(
rect
.
x
+
rect
.
width
)
&&
(
y
+
h
)
<
(
rect
.
y
+
rect
.
height
))
{
return
true
;
}
return
false
;
};
GuideView
.
prototype
.
startGuide
=
function
()
{
return
tslib
.
__awaiter
(
this
,
void
0
,
void
0
,
function
()
{
var
_this
=
this
;
return
tslib
.
__generator
(
this
,
function
(
_a
)
{
return
[
2
,
new
Promise
(
function
(
r
)
{
_this
.
visible
=
true
;
_this
.
svga
.
gotoAndStop
(
1
);
_this
.
svga
.
play
(
false
,
true
);
_this
.
guideEle
.
scaleX
=
1
;
_this
.
guideEle
.
scaleY
=
1
;
var
offset
=
[
0
,
0
];
var
guideOver
=
function
()
{
_this
.
guideEle
.
removeEventListener
(
engine
.
MouseEvent
.
MOUSE_DOWN
,
ondown
,
_this
);
engine
.
Tween
.
get
(
_this
.
guideEle
).
to
({
scaleX
:
0
,
scaleY
:
0
},
300
).
call
(
function
()
{
_this
.
visible
=
false
;
r
();
});
};
var
onUp
=
function
(
e
)
{
_this
.
stage
.
removeEventListener
(
engine
.
MouseEvent
.
MOUSE_MOVE
,
onMove
,
_this
);
if
(
_this
.
checkHit
(
_this
.
guideEle
.
x
,
_this
.
guideEle
.
y
,
_this
.
guideEle
.
width
,
_this
.
guideEle
.
height
))
{
guideOver
();
}
else
{
_this
.
svga
.
visible
=
true
;
_this
.
guideEle
.
x
=
361
;
_this
.
guideEle
.
y
=
877
;
}
};
var
onMove
=
function
(
e
)
{
_this
.
guideEle
.
x
=
e
.
stageX
-
offset
[
0
];
_this
.
guideEle
.
y
=
e
.
stageY
-
offset
[
1
];
};
var
ondown
=
function
(
e
)
{
offset
=
[
e
.
localX
,
e
.
localY
];
_this
.
svga
.
visible
=
false
;
_this
.
stage
.
once
(
engine
.
MouseEvent
.
MOUSE_UP
,
onUp
,
_this
);
_this
.
stage
.
addEventListener
(
engine
.
MouseEvent
.
MOUSE_MOVE
,
onMove
,
_this
);
};
_this
.
guideEle
.
addEventListener
(
engine
.
MouseEvent
.
MOUSE_DOWN
,
ondown
,
_this
);
})];
});
});
};
return
GuideView
;
}(
engine
.
Sprite
));
//# sourceMappingURL=guideView.js.map
var
Garbage
=
(
function
(
_super
)
{
tslib
.
__extends
(
Garbage
,
_super
);
function
Garbage
(
texture
)
{
var
_this
=
_super
.
call
(
this
,
texture
)
||
this
;
_this
.
isWrong
=
false
;
_this
.
isRight
=
false
;
return
_this
;
}
return
Garbage
;
}(
engine
.
Sprite
));
var
GarbageTypes
;
(
function
(
GarbageTypes
)
{
GarbageTypes
[
GarbageTypes
[
"recoverableWaste"
]
=
0
]
=
"recoverableWaste"
;
GarbageTypes
[
GarbageTypes
[
"harmfulWaste"
]
=
1
]
=
"harmfulWaste"
;
GarbageTypes
[
GarbageTypes
[
"wetWaste"
]
=
2
]
=
"wetWaste"
;
GarbageTypes
[
GarbageTypes
[
"dryWaste"
]
=
3
]
=
"dryWaste"
;
})(
GarbageTypes
||
(
GarbageTypes
=
{}));
//# sourceMappingURL=GarbageTypes.js.map
var
GarbageConfig
=
(
function
()
{
function
GarbageConfig
()
{
}
GarbageConfig
.
config
=
[
{
name
:
"电池"
,
source
:
"g00"
,
type
:
GarbageTypes
.
harmfulWaste
,
width
:
51
,
height
:
123
},
{
name
:
"温度计"
,
source
:
"g01"
,
type
:
GarbageTypes
.
harmfulWaste
,
width
:
65
,
height
:
130
},
{
name
:
"鱼刺"
,
source
:
"g02"
,
type
:
GarbageTypes
.
wetWaste
,
width
:
104
,
height
:
82
},
{
name
:
"龙虾"
,
source
:
"g03"
,
type
:
GarbageTypes
.
wetWaste
,
width
:
129
,
height
:
122
},
{
name
:
"西瓜"
,
source
:
"g04"
,
type
:
GarbageTypes
.
wetWaste
,
width
:
134
,
height
:
111
},
{
name
:
"旧玩具"
,
source
:
"g05"
,
type
:
GarbageTypes
.
recoverableWaste
,
width
:
72
,
height
:
135
},
{
name
:
"口红"
,
source
:
"g06"
,
type
:
GarbageTypes
.
dryWaste
,
width
:
49
,
height
:
134
},
{
name
:
"面包"
,
source
:
"g07"
,
type
:
GarbageTypes
.
wetWaste
,
width
:
96
,
height
:
128
},
{
name
:
"绿植"
,
source
:
"g08"
,
type
:
GarbageTypes
.
wetWaste
,
width
:
81
,
height
:
131
},
{
name
:
"保温瓶"
,
source
:
"g09"
,
type
:
GarbageTypes
.
recoverableWaste
,
width
:
66
,
height
:
137
},
{
name
:
"破衣服"
,
source
:
"g10"
,
type
:
GarbageTypes
.
recoverableWaste
,
width
:
91
,
height
:
121
},
{
name
:
"茶叶渣"
,
source
:
"g11"
,
type
:
GarbageTypes
.
wetWaste
,
width
:
108
,
height
:
125
},
{
name
:
"湿巾"
,
source
:
"g12"
,
type
:
GarbageTypes
.
dryWaste
,
width
:
106
,
height
:
109
},
{
name
:
"过期药膏"
,
source
:
"g13"
,
type
:
GarbageTypes
.
harmfulWaste
,
width
:
107
,
height
:
130
},
{
name
:
"用完的洗发水瓶"
,
source
:
"g14"
,
type
:
GarbageTypes
.
recoverableWaste
,
width
:
153
,
height
:
148
},
{
name
:
"婴儿纸尿裤"
,
source
:
"g15"
,
type
:
GarbageTypes
.
dryWaste
,
width
:
108
,
height
:
123
},
{
name
:
"香水瓶"
,
source
:
"g16"
,
type
:
GarbageTypes
.
recoverableWaste
,
width
:
65
,
height
:
127
},
{
name
:
"花甲壳"
,
source
:
"g17"
,
type
:
GarbageTypes
.
wetWaste
,
width
:
99
,
height
:
115
},
{
name
:
"过期调味料"
,
source
:
"g18"
,
type
:
GarbageTypes
.
wetWaste
,
width
:
109
,
height
:
130
},
{
name
:
"地毯"
,
source
:
"g19"
,
type
:
GarbageTypes
.
recoverableWaste
,
width
:
145
,
height
:
119
},
{
name
:
"甘蔗渣"
,
source
:
"g20"
,
type
:
GarbageTypes
.
wetWaste
,
width
:
100
,
height
:
116
},
{
name
:
"玻璃渣"
,
source
:
"g21"
,
type
:
GarbageTypes
.
recoverableWaste
,
width
:
95
,
height
:
122
},
{
name
:
"番茄酱"
,
source
:
"g22"
,
type
:
GarbageTypes
.
wetWaste
,
width
:
82
,
height
:
125
},
{
name
:
"酒精棉"
,
source
:
"g23"
,
type
:
GarbageTypes
.
dryWaste
,
width
:
64
,
height
:
124
},
{
name
:
"指甲油瓶子"
,
source
:
"g24"
,
type
:
GarbageTypes
.
harmfulWaste
,
width
:
109
,
height
:
125
},
{
name
:
"肉骨头"
,
source
:
"g25"
,
type
:
GarbageTypes
.
dryWaste
,
width
:
67
,
height
:
123
},
{
name
:
"嚼过的口香糖"
,
source
:
"g26"
,
type
:
GarbageTypes
.
dryWaste
,
width
:
135
,
height
:
116
},
{
name
:
"充电插头"
,
source
:
"g27"
,
type
:
GarbageTypes
.
recoverableWaste
,
width
:
86
,
height
:
128
},
{
name
:
"旧报纸"
,
source
:
"g28"
,
type
:
GarbageTypes
.
recoverableWaste
,
width
:
68
,
height
:
124
},
{
name
:
"烟头"
,
source
:
"g29"
,
type
:
GarbageTypes
.
dryWaste
,
width
:
108
,
height
:
145
},
{
name
:
"奶茶塑料杯"
,
source
:
"g30"
,
type
:
GarbageTypes
.
dryWaste
,
width
:
109
,
height
:
143
},
{
name
:
"瓜子壳"
,
source
:
"g31"
,
type
:
GarbageTypes
.
wetWaste
,
width
:
87
,
height
:
121
},
{
name
:
"橘子皮"
,
source
:
"g32"
,
type
:
GarbageTypes
.
wetWaste
,
width
:
78
,
height
:
120
},
{
name
:
"气球"
,
source
:
"g33"
,
type
:
GarbageTypes
.
dryWaste
,
width
:
78
,
height
:
121
},
{
name
:
"树叶"
,
source
:
"g34"
,
type
:
GarbageTypes
.
wetWaste
,
width
:
75
,
height
:
117
},
{
name
:
"感冒药"
,
source
:
"g35"
,
type
:
GarbageTypes
.
harmfulWaste
,
width
:
92
,
height
:
121
},
{
name
:
"电话机"
,
source
:
"g36"
,
type
:
GarbageTypes
.
recoverableWaste
,
width
:
63
,
height
:
121
},
{
name
:
"奶酪"
,
source
:
"g37"
,
type
:
GarbageTypes
.
wetWaste
,
width
:
90
,
height
:
116
},
{
name
:
"啤酒瓶"
,
source
:
"g38"
,
type
:
GarbageTypes
.
recoverableWaste
,
width
:
64
,
height
:
123
},
{
name
:
"薯片包装"
,
source
:
"g39"
,
type
:
GarbageTypes
.
dryWaste
,
width
:
134
,
height
:
123
},
{
name
:
"过期保健品"
,
source
:
"g40"
,
type
:
GarbageTypes
.
harmfulWaste
,
width
:
108
,
height
:
125
},
{
name
:
"雪糕包装袋"
,
source
:
"g41"
,
type
:
GarbageTypes
.
dryWaste
,
width
:
109
,
height
:
128
},
{
name
:
"废油漆"
,
source
:
"g42"
,
type
:
GarbageTypes
.
harmfulWaste
,
width
:
98
,
height
:
122
},
{
name
:
"食品罐头"
,
source
:
"g43"
,
type
:
GarbageTypes
.
recoverableWaste
,
width
:
94
,
height
:
117
},
{
name
:
"陶瓷碗"
,
source
:
"g44"
,
type
:
GarbageTypes
.
dryWaste
,
width
:
105
,
height
:
122
},
{
name
:
"蚊香"
,
source
:
"g45"
,
type
:
GarbageTypes
.
dryWaste
,
width
:
69
,
height
:
146
},
{
name
:
"电脑机箱"
,
source
:
"g46"
,
type
:
GarbageTypes
.
recoverableWaste
,
width
:
84
,
height
:
124
},
{
name
:
"鲜花"
,
source
:
"g47"
,
type
:
GarbageTypes
.
wetWaste
,
width
:
62
,
height
:
122
},
{
name
:
"宠物粮食"
,
source
:
"g48"
,
type
:
GarbageTypes
.
wetWaste
,
width
:
87
,
height
:
121
},
{
name
:
"银行卡"
,
source
:
"g49"
,
type
:
GarbageTypes
.
recoverableWaste
,
width
:
115
,
height
:
123
},
];
return
GarbageConfig
;
}());
//# sourceMappingURL=GarbageConfig.js.map
var
removeEle
=
(
function
(
e
,
arr
)
{
var
index
=
arr
.
indexOf
(
e
);
if
(
index
>=
0
)
{
arr
.
splice
(
index
,
1
);
}
});
//# sourceMappingURL=removeEle.js.map
var
shuffle
=
(
function
(
arr
)
{
var
_a
;
var
i
=
arr
.
length
;
while
(
i
)
{
var
j
=
Math
.
floor
(
Math
.
random
()
*
i
--
);
_a
=
[
arr
[
i
],
arr
[
j
]],
arr
[
j
]
=
_a
[
0
],
arr
[
i
]
=
_a
[
1
];
}
return
arr
;
});
//# sourceMappingURL=shuffle.js.map
var
Conveyors
=
(
function
(
_super
)
{
tslib
.
__extends
(
Conveyors
,
_super
);
function
Conveyors
(
p
)
{
var
_this
=
_super
.
call
(
this
)
||
this
;
_this
.
conveyorsPool
=
[];
_this
.
GarbageConfig
=
GarbageConfig
.
config
;
_this
.
currConfigPool
=
[];
_this
.
currGamePool
=
[];
_this
.
p
=
p
;
return
_this
;
}
Conveyors
.
prototype
.
initData
=
function
(
conveyor0
,
conveyor1
)
{
this
.
conveyor0
=
conveyor0
;
this
.
conveyor1
=
conveyor1
;
this
.
conveyorsPool
.
push
(
this
.
conveyor0
);
this
.
conveyorsPool
.
push
(
this
.
conveyor1
);
};
Conveyors
.
prototype
.
setDefault
=
function
()
{
this
.
score
=
0
;
this
.
clear
();
this
.
currConfigPool
=
shuffle
(
this
.
GarbageConfig
);
for
(
var
i
=
0
;
i
<
20
;
i
++
)
{
this
.
currConfigPool
[
i
].
idx
=
i
;
this
.
currConfigPool
[
i
].
isRight
=
false
;
this
.
currConfigPool
[
i
].
isMistake
=
false
;
this
.
currConfigPool
[
i
].
isOnStage
=
false
;
this
.
currGamePool
.
push
(
this
.
currConfigPool
[
i
]);
}
var
gamePoolIdx
=
0
;
for
(
var
i
=
0
;
i
<
5
;
i
++
)
{
var
g
=
this
.
currGamePool
[
gamePoolIdx
];
gamePoolIdx
+=
1
;
var
garbage
=
new
Garbage
(
getTextureByName
(
g
.
source
));
g
.
isOnStage
=
true
;
garbage
.
type
=
g
.
type
;
garbage
.
name
=
g
.
name
;
garbage
.
anchorX
=
g
.
width
/
2
;
garbage
.
anchorY
=
g
.
height
;
garbage
.
x
=
0
;
garbage
.
y
=
90
;
this
.
conveyor1
[
"idx"
+
i
].
addChild
(
garbage
);
garbage
.
addEventListener
(
engine
.
MouseEvent
.
MOUSE_DOWN
,
this
.
onDwon_garbage
,
this
);
}
};
Conveyors
.
prototype
.
startConveyors
=
function
()
{
this
.
setDefault
();
engine
.
gameStage
.
addEventListener
(
engine
.
Event
.
ENTER_FRAME
,
this
.
onEnterFrame
,
this
);
};
Conveyors
.
prototype
.
onEnterFrame
=
function
(
ENTER_FRAME
,
onEnterFrame
,
arg2
)
{
if
(
this
.
score
==
100
)
{
this
.
gameOver
();
}
this
.
conveyorsPool
.
forEach
(
function
(
conveyor
)
{
conveyor
.
x
-=
props
.
speed
||
3
;
});
if
(
this
.
conveyorsPool
.
length
>
1
)
{
if
(
this
.
conveyorsPool
[
this
.
conveyorsPool
.
length
-
1
].
x
<=
764
)
{
var
conveyor
=
new
Conveyor
();
conveyor
.
x
=
this
.
conveyorsPool
[
this
.
conveyorsPool
.
length
-
1
].
x
+
764
;
this
.
p
.
addChild
(
conveyor
);
this
.
conveyorsPool
.
push
(
conveyor
);
}
else
{
var
asdasd
=
[];
for
(
var
n
=
0
;
n
<
this
.
currGamePool
.
length
;
n
++
)
{
var
cgg
=
this
.
currGamePool
[
n
];
if
(
!
cgg
.
isRight
&&
!
cgg
.
isOnStage
)
{
asdasd
.
push
(
cgg
);
}
}
var
cc
=
this
.
conveyorsPool
[
this
.
conveyorsPool
.
length
-
1
];
for
(
var
m
=
0
;
m
<
5
;
m
++
)
{
if
(
!
cc
[
"idx"
+
m
].
children
[
0
])
{
var
g
=
asdasd
.
shift
();
if
(
g
)
{
g
.
isOnStage
=
true
;
var
garbage
=
new
Garbage
(
g
.
source
);
garbage
.
type
=
g
.
type
;
garbage
.
name
=
g
.
name
;
garbage
.
anchorX
=
g
.
width
/
2
;
garbage
.
anchorY
=
g
.
height
;
garbage
.
x
=
0
;
garbage
.
y
=
90
;
cc
[
"idx"
+
m
].
addChild
(
garbage
);
garbage
.
addEventListener
(
engine
.
MouseEvent
.
MOUSE_DOWN
,
this
.
onDwon_garbage
,
this
);
}
else
{
break
;
}
}
}
}
if
(
this
.
conveyorsPool
[
0
].
x
<
-
750
)
{
for
(
var
k
=
0
;
k
<
this
.
currGamePool
.
length
;
k
++
)
{
var
garbage
=
this
.
currGamePool
[
k
];
var
cc
=
this
.
conveyorsPool
[
0
][
"idx"
+
4
];
if
(
cc
.
children
[
0
])
{
if
(
garbage
.
name
==
cc
.
children
[
0
].
$name
)
{
garbage
.
isOnStage
=
false
;
removeEle
(
garbage
,
this
.
currGamePool
);
this
.
currGamePool
.
push
(
garbage
);
cc
.
removeChild
(
cc
.
children
[
0
]);
break
;
}
}
}
this
.
conveyorsPool
.
shift
();
}
else
if
(
this
.
conveyorsPool
[
0
].
x
<
-
600
)
{
for
(
var
k
=
0
;
k
<
this
.
currGamePool
.
length
;
k
++
)
{
var
garbage
=
this
.
currGamePool
[
k
];
var
cc
=
this
.
conveyorsPool
[
0
][
"idx"
+
3
];
if
(
cc
.
children
[
0
])
{
if
(
garbage
.
name
==
cc
.
children
[
0
].
$name
)
{
garbage
.
isOnStage
=
false
;
removeEle
(
garbage
,
this
.
currGamePool
);
this
.
currGamePool
.
push
(
garbage
);
cc
.
removeChild
(
cc
.
children
[
0
]);
break
;
}
}
}
}
else
if
(
this
.
conveyorsPool
[
0
].
x
<
-
450
)
{
for
(
var
k
=
0
;
k
<
this
.
currGamePool
.
length
;
k
++
)
{
var
garbage
=
this
.
currGamePool
[
k
];
var
cc
=
this
.
conveyorsPool
[
0
][
"idx"
+
2
];
if
(
cc
.
children
[
0
])
{
if
(
garbage
.
name
==
cc
.
children
[
0
].
$name
)
{
garbage
.
isOnStage
=
false
;
removeEle
(
garbage
,
this
.
currGamePool
);
this
.
currGamePool
.
push
(
garbage
);
cc
.
removeChild
(
cc
.
children
[
0
]);
break
;
}
}
}
}
else
if
(
this
.
conveyorsPool
[
0
].
x
<
-
300
)
{
for
(
var
k
=
0
;
k
<
this
.
currGamePool
.
length
;
k
++
)
{
var
garbage
=
this
.
currGamePool
[
k
];
var
cc
=
this
.
conveyorsPool
[
0
][
"idx"
+
1
];
if
(
cc
.
children
[
0
])
{
if
(
garbage
.
name
==
cc
.
children
[
0
].
$name
)
{
garbage
.
isOnStage
=
false
;
removeEle
(
garbage
,
this
.
currGamePool
);
this
.
currGamePool
.
push
(
garbage
);
cc
.
removeChild
(
cc
.
children
[
0
]);
break
;
}
}
}
}
else
if
(
this
.
conveyorsPool
[
0
].
x
<
-
150
)
{
for
(
var
k
=
0
;
k
<
this
.
currGamePool
.
length
;
k
++
)
{
var
garbage
=
this
.
currGamePool
[
k
];
var
cc
=
this
.
conveyorsPool
[
0
][
"idx"
+
0
];
if
(
cc
.
children
[
0
])
{
if
(
garbage
.
name
==
cc
.
children
[
0
].
$name
)
{
garbage
.
isOnStage
=
false
;
removeEle
(
garbage
,
this
.
currGamePool
);
this
.
currGamePool
.
push
(
garbage
);
cc
.
removeChild
(
cc
.
children
[
0
]);
break
;
}
}
}
}
}
};
Conveyors
.
prototype
.
addscore
=
function
(
n
)
{
this
.
score
+=
n
;
engine
.
globalEvent
.
dispatchEvent
(
'recycling-score-update'
,
{
score
:
this
.
score
});
};
Conveyors
.
prototype
.
gameOver
=
function
()
{
engine
.
gameStage
.
addEventListener
(
engine
.
Event
.
ENTER_FRAME
,
this
.
onEnterFrame
,
this
);
};
Conveyors
.
prototype
.
onDwon_garbage
=
function
()
{
};
Conveyors
.
prototype
.
clear
=
function
()
{
this
.
currGamePool
=
[];
};
Conveyors
.
prototype
.
timeout
=
function
()
{
engine
.
gameStage
.
removeEventListener
(
engine
.
Event
.
ENTER_FRAME
,
this
.
onEnterFrame
,
this
);
};
return
Conveyors
;
}(
engine
.
Sprite
));
//# sourceMappingURL=Conveyors.js.map
var
GameView
=
(
function
(
_super
)
{
tslib
.
__extends
(
GameView
,
_super
);
function
GameView
()
{
var
_this
=
_super
.
call
(
this
)
||
this
;
_this
.
_timeCounter
=
0
;
_this
.
once
(
engine
.
Event
.
ADDED_TO_STAGE
,
_this
.
setup
,
_this
);
return
_this
;
}
GameView
.
prototype
.
configUI
=
function
()
{
var
uiMap
=
{};
this
.
uiMap
=
uiMap
;
var
config
=
uiConfig
();
for
(
var
_i
=
0
,
config_1
=
config
;
_i
<
config_1
.
length
;
_i
++
)
{
var
item
=
config_1
[
_i
];
var
id
=
item
.
id
,
texture
=
item
.
texture
,
pos
=
item
.
pos
,
anchor
=
item
.
anchor
;
var
sp
=
new
engine
.
Sprite
(
getTextureByName
(
texture
));
this
.
addChild
(
sp
);
uiMap
[
id
]
=
sp
;
if
(
anchor
)
{
sp
.
anchorX
=
anchor
[
0
];
sp
.
anchorY
=
anchor
[
1
];
}
if
(
pos
)
{
sp
.
x
=
pos
[
0
];
sp
.
y
=
pos
[
1
];
if
(
anchor
)
{
sp
.
x
=
pos
[
0
]
-
sp
.
anchorX
;
sp
.
y
=
pos
[
1
]
-
sp
.
anchorY
;
}
}
}
this
.
configConveyors
();
this
.
createRects
();
this
.
countdown
=
new
CountDownGroup
();
this
.
addChild
(
this
.
countdown
);
this
.
guide
=
new
GuideView
();
this
.
addChild
(
this
.
guide
);
};
GameView
.
prototype
.
createRects
=
function
()
{
this
.
wetWaste
=
this
.
createRect
(
74
,
552
,
301
,
293
,
0xffffff
);
this
.
harmfulWaste
=
this
.
createRect
(
75
,
247
,
300
,
293
,
0xff0000
);
this
.
dryWaste
=
this
.
createRect
(
389
,
249
,
286
,
291
,
0x000000
);
this
.
recoverableWaste
=
this
.
createRect
(
389
,
551
,
287
,
292
,
0x0000ff
);
};
GameView
.
prototype
.
createRect
=
function
(
x
,
y
,
w
,
h
,
c
)
{
var
rect
=
new
engine
.
Rectangle
(
x
,
y
,
w
,
h
);
var
sp
=
new
engine
.
Sprite
();
this
.
addChild
(
sp
);
sp
.
x
=
x
;
sp
.
y
=
y
;
var
g
=
new
engine
.
Graphics
;
g
.
alpha
=
0.0
;
g
.
beginFill
(
c
);
g
.
drawRect
(
0
,
0
,
w
,
h
);
g
.
endFill
();
sp
.
addChild
(
g
);
return
rect
;
};
GameView
.
prototype
.
configConveyors
=
function
()
{
var
conveyor0
=
new
Conveyor
();
conveyor0
.
x
=
0
;
var
conveyor1
=
new
Conveyor
();
this
.
addChild
(
conveyor0
);
this
.
addChild
(
conveyor1
);
conveyor1
.
x
=
764
;
this
.
conveyors
=
new
Conveyors
(
this
);
this
.
conveyors
.
initData
(
conveyor0
,
conveyor1
);
};
GameView
.
prototype
.
playAni
=
function
()
{
var
_this
=
this
;
var
idlerWheels
=
[
'idler0'
,
'idler1'
,
'idler2'
,
'idler3'
,
'idler4'
,
'idler5'
,
'idler6'
];
idlerWheels
=
idlerWheels
.
map
(
function
(
i
)
{
return
_this
.
uiMap
[
i
];
});
idlerWheels
.
forEach
(
function
(
i
)
{
engine
.
Tween
.
get
(
i
,
{
loop
:
true
}).
to
({
rotation
:
-
360
},
1000
);
});
};
GameView
.
prototype
.
stopAni
=
function
()
{
var
_this
=
this
;
var
idlerWheels
=
[
'idler0'
,
'idler1'
,
'idler2'
,
'idler3'
,
'idler4'
,
'idler5'
,
'idler6'
];
idlerWheels
=
idlerWheels
.
map
(
function
(
i
)
{
return
_this
.
uiMap
[
i
];
});
idlerWheels
.
forEach
(
function
(
i
)
{
engine
.
Tween
.
removeTweens
(
i
);
});
};
GameView
.
prototype
.
start
=
function
()
{
return
tslib
.
__awaiter
(
this
,
void
0
,
void
0
,
function
()
{
var
_this
=
this
;
return
tslib
.
__generator
(
this
,
function
(
_a
)
{
switch
(
_a
.
label
)
{
case
0
:
console
.
log
(
'on start'
);
this
.
_timeCounter
=
0
;
if
(
!!
getGuideInfo
())
return
[
3
,
2
];
return
[
4
,
this
.
guide
.
startGuide
()];
case
1
:
_a
.
sent
();
setGuide
();
_a
.
label
=
2
;
case
2
:
return
[
4
,
this
.
countdown
.
startCountDown
()];
case
3
:
_a
.
sent
();
this
.
startGame
();
engine
.
globalEvent
.
dispatchEvent
(
'recycling-time-update'
,
{
second
:
this
.
getSecond
(),
});
this
.
_timer
=
setInterval
(
function
()
{
_this
.
onTimer
();
},
1000
);
return
[
2
];
}
});
});
};
GameView
.
prototype
.
startGame
=
function
()
{
this
.
playAni
();
this
.
conveyors
.
startConveyors
();
};
GameView
.
prototype
.
stopGame
=
function
()
{
this
.
stopAni
();
};
GameView
.
prototype
.
getSecond
=
function
()
{
return
props
.
time
-
this
.
_timeCounter
;
};
GameView
.
prototype
.
onTimer
=
function
()
{
this
.
_timeCounter
++
;
engine
.
globalEvent
.
dispatchEvent
(
'recycling-time-update'
,
{
second
:
this
.
getSecond
(),
});
if
(
this
.
getSecond
()
==
0
)
{
this
.
stop
();
this
.
conveyors
.
timeout
();
engine
.
globalEvent
.
dispatchEvent
(
'recycling-game-end'
,
{});
}
};
GameView
.
prototype
.
stop
=
function
()
{
clearInterval
(
this
.
_timer
);
this
.
stopGame
();
};
GameView
.
prototype
.
setup
=
function
()
{
console
.
log
(
'onSteup'
,
props
);
this
.
configUI
();
};
GameView
.
prototype
.
onDown
=
function
(
e
)
{
};
GameView
.
prototype
.
stageOnUp
=
function
(
e
)
{
};
GameView
.
prototype
.
onSuccess
=
function
()
{
};
GameView
.
prototype
.
onMove
=
function
(
e
)
{
};
return
GameView
;
}(
engine
.
Container
));
//# sourceMappingURL=GameView.js.map
var
GameWrapper
=
(
function
(
_super
)
{
tslib
.
__extends
(
GameWrapper
,
_super
);
function
GameWrapper
()
{
var
_this
=
_super
.
call
(
this
)
||
this
;
engine
.
globalEvent
.
addEventListener
(
'recycling-start'
,
_this
.
start
,
_this
);
engine
.
globalEvent
.
addEventListener
(
'recycling-stop'
,
_this
.
stop
,
_this
);
var
gameView
=
_this
.
_gameView
=
new
GameView
();
_this
.
addChild
(
gameView
);
return
_this
;
}
GameWrapper
.
prototype
.
start
=
function
(
event
)
{
injectProps
(
event
.
data
);
this
.
_gameView
.
start
();
};
GameWrapper
.
prototype
.
stop
=
function
(
event
)
{
this
.
_gameView
.
stop
();
};
return
GameWrapper
;
}(
engine
.
Container
));
//# sourceMappingURL=GameWrapper.js.map
function
index
(
props
)
{
prepareProps
();
injectProps
(
props
);
var
instance
=
new
GameWrapper
();
return
instance
;
}
//# sourceMappingURL=index.js.map
return
index
;
})));
//# sourceMappingURL=main.js.map
\ No newline at end of file
src/custom/recycling/debug/main.js.map
View file @
a9eac5bb
This source diff could not be displayed because it is too large. You can
view the blob
instead.
src/custom/recycling/src/game/Conveyor.ts
View file @
a9eac5bb
...
@@ -15,24 +15,36 @@ export default class Conveyor extends engine.Sprite {
...
@@ -15,24 +15,36 @@ export default class Conveyor extends engine.Sprite {
const
sp
=
new
engine
.
Sprite
(
getTextureByName
(
'conveyor'
));
const
sp
=
new
engine
.
Sprite
(
getTextureByName
(
'conveyor'
));
this
.
addChild
(
sp
);
this
.
addChild
(
sp
);
this
.
idx0
=
this
.
createItem
(
75
,
50
);
this
.
idx0
=
this
.
createItem
(
75
,
50
);
this
.
idx1
=
this
.
createItem
(
225
,
50
);
this
.
idx1
=
this
.
createItem
(
225
,
50
);
this
.
idx2
=
this
.
createItem
(
375
,
50
);
this
.
idx2
=
this
.
createItem
(
375
,
50
);
this
.
idx3
=
this
.
createItem
(
525
,
50
);
this
.
idx3
=
this
.
createItem
(
525
,
50
);
this
.
idx4
=
this
.
createItem
(
675
,
50
);
this
.
idx4
=
this
.
createItem
(
675
,
50
);
}
}
createItem
(
x
,
y
)
{
clear
()
{
this
.
clearItem
(
this
.
idx0
)
this
.
clearItem
(
this
.
idx1
)
this
.
clearItem
(
this
.
idx2
)
this
.
clearItem
(
this
.
idx3
)
this
.
clearItem
(
this
.
idx4
)
}
private
clearItem
(
idx
:
engine
.
Sprite
)
{
if
(
idx
.
children
.
length
>
0
)
idx
.
removeChildAt
(
0
)
}
private
createItem
(
x
,
y
)
{
const
sp
=
new
engine
.
Sprite
();
const
sp
=
new
engine
.
Sprite
();
this
.
addChild
(
sp
);
this
.
addChild
(
sp
);
sp
.
x
=
x
-
50
;
sp
.
x
=
x
;
sp
.
y
=
y
-
50
;
sp
.
y
=
y
;
const
g
=
new
engine
.
Graphics
;
//
const g = new engine.Graphics;
g
.
beginFill
(
0xff0000
);
//
g.beginFill(0xff0000);
g
.
drawRect
(
0
,
0
,
100
,
100
);
//
g.drawRect(0,0,100,100);
g
.
endFill
();
//
g.endFill();
sp
.
addChild
(
g
);
//
sp.addChild(g);
return
sp
return
sp
}
}
...
...
src/custom/recycling/src/game/Conveyors.ts
View file @
a9eac5bb
import
{
props
}
from
"../props"
;
import
{
props
}
from
"../props"
;
import
Conveyor
from
"./Conveyor"
;
import
Conveyor
from
"./Conveyor"
;
import
Garbage
from
"./datas/Garbage"
;
import
GarbageConfig
from
"./datas/GarbageConfig"
;
import
GarbageConfig
from
"./datas/GarbageConfig"
;
import
{
GarbageTypes
}
from
"./datas/GarbageTypes"
;
import
GameView
from
"./GameView"
;
import
{
getTextureByName
}
from
"./utils"
;
import
checkHit
from
"./utils/checkHit"
;
import
removeChild
from
"./utils/removeChild"
;
import
removeEle
from
"./utils/removeEle"
;
import
removeEle
from
"./utils/removeEle"
;
import
shuffle
from
"./utils/shuffle"
;
import
shuffle
from
"./utils/shuffle"
;
import
{
getTextureByName
}
from
"./util
s"
;
import
transStores
from
"./datas/transStore
s"
;
export
default
class
Conveyors
extends
engine
.
Sprite
{
export
default
class
Conveyors
extends
engine
.
Sprite
{
conveyor0
:
Conveyor
;
conveyor0
:
Conveyor
;
conveyor1
:
Conveyor
;
conveyor1
:
Conveyor
;
private
conveyorsPool
:
any
[]
=
[];
private
conveyorsPool
:
Conveyor
[]
=
[];
private
GarbageConfig
:
any
[]
=
GarbageConfig
.
config
;
private
GarbageConfig
:
any
[]
=
GarbageConfig
.
config
;
// 本局游戏的20种垃圾
private
datas
:
{
name
,
type
,
isOnStage
,
width
,
height
,
source
,
isRight
}[]
=
[];
private
currConfigPool
:
any
[]
=
[];
private
currGamePool
:
any
[]
=
[];
score
:
number
;
score
:
number
;
p
:
any
;
wrapper
:
GameView
stores
:
any
[];
constructor
(
p
)
{
constructor
(
p
)
{
super
();
super
();
this
.
p
=
p
;
this
.
wrapper
=
p
;
}
}
initData
(
conveyor0
,
conveyor1
)
{
initData
(
conveyor0
,
conveyor1
)
{
this
.
conveyor0
=
conveyor0
;
this
.
conveyor0
=
conveyor0
;
this
.
conveyor1
=
conveyor1
;
this
.
conveyor1
=
conveyor1
;
this
.
conveyorsPool
.
push
(
this
.
conveyor0
);
this
.
conveyorsPool
.
push
(
this
.
conveyor1
);
}
}
private
setDefault
(){
private
setDefault
()
{
this
.
score
=
0
;
this
.
clear
();
this
.
clear
();
this
.
currConfigPool
=
shuffle
(
this
.
GarbageConfig
);
this
.
score
=
0
;
this
.
conveyorsPool
.
push
(
this
.
conveyor0
);
this
.
conveyorsPool
.
push
(
this
.
conveyor1
);
// 本局游戏的20种垃圾
const
allConfigs
=
shuffle
(
this
.
GarbageConfig
);
for
(
let
i
=
0
;
i
<
20
;
i
++
)
{
for
(
let
i
=
0
;
i
<
20
;
i
++
)
{
this
.
currConfigPool
[
i
].
idx
=
i
;
allConfigs
[
i
].
idx
=
i
;
this
.
currConfigPool
[
i
].
isRight
=
false
;
allConfigs
[
i
].
isRight
=
false
;
this
.
currConfigPool
[
i
].
isMistake
=
false
;
allConfigs
[
i
].
isMistake
=
false
;
this
.
currConfigPool
[
i
].
isOnStage
=
false
;
allConfigs
[
i
].
isOnStage
=
false
;
this
.
currGamePool
.
push
(
this
.
currConfigPool
[
i
]);
this
.
datas
.
push
(
allConfigs
[
i
]);
}
}
let
gamePoolIdx
=
0
;
for
(
let
i
=
0
;
i
<
5
;
i
++
)
{
for
(
let
i
=
0
;
i
<
5
;
i
++
)
{
let
g
=
this
.
currGamePool
[
gamePoolIdx
];
let
data
=
this
.
datas
[
i
];
gamePoolIdx
+=
1
;
let
view
:
any
=
new
engine
.
Sprite
(
getTextureByName
(
data
.
source
));
let
garbage
=
new
Garbage
(
getTextureByName
(
g
.
source
));
view
.
isWrong
=
false
;
g
.
isOnStage
=
true
;
view
.
isRight
=
false
;
garbage
.
type
=
g
.
type
;
garbage
.
name
=
g
.
name
;
data
.
isOnStage
=
true
;
garbage
.
anchorX
=
g
.
width
/
2
;
garbage
.
anchorY
=
g
.
height
;
view
.
type
=
data
.
type
;
garbage
.
x
=
0
;
view
.
name
=
data
.
name
;
garbage
.
y
=
90
;
view
.
anchorX
=
data
.
width
/
2
;
this
.
conveyor1
[
`idx
${
i
}
`
].
addChild
(
garbage
)
view
.
anchorY
=
data
.
height
;
garbage
.
addEventListener
(
engine
.
MouseEvent
.
MOUSE_DOWN
,
this
.
onDwon_garbage
,
this
);
view
.
x
=
-
data
.
width
/
2
;
view
.
y
=
-
data
.
height
+
40
;
this
.
conveyor1
[
`idx
${
i
}
`
].
addChild
(
view
)
view
.
addEventListener
(
engine
.
MouseEvent
.
MOUSE_DOWN
,
this
.
onDwon_garbage
,
this
);
}
}
}
}
...
@@ -72,45 +79,50 @@ export default class Conveyors extends engine.Sprite {
...
@@ -72,45 +79,50 @@ export default class Conveyors extends engine.Sprite {
}
}
onEnterFrame
(
ENTER_FRAME
:
string
,
onEnterFrame
:
any
,
arg2
:
this
)
{
onEnterFrame
(
ENTER_FRAME
:
string
,
onEnterFrame
:
any
,
arg2
:
this
)
{
if
(
this
.
score
==
100
)
{
if
(
this
.
score
==
(
props
.
maxScore
||
100
)
)
{
this
.
gameOver
();
this
.
gameOver
();
}
}
// console.log('this.conveyorsPool.length', this.conveyorsPool.length)
this
.
conveyorsPool
.
forEach
(
conveyor
=>
{
this
.
conveyorsPool
.
forEach
(
conveyor
=>
{
conveyor
.
x
-=
props
.
speed
||
3
;
conveyor
.
x
-=
props
.
speed
||
3
;
});
});
if
(
this
.
conveyorsPool
.
length
>
1
)
{
// if (this.conveyorsPool.length > 1) {
if
(
this
.
conveyorsPool
[
this
.
conveyorsPool
.
length
-
1
].
x
<=
764
)
{
if
(
this
.
conveyorsPool
[
this
.
conveyorsPool
.
length
-
1
].
x
<=
764
)
{
// 最后一个传送带完全进入屏幕时 往后添加一个传送带
// 最后一个传送带完全进入屏幕时 往后添加一个传送带
const
conveyor
=
new
Conveyor
();
const
conveyor
=
new
Conveyor
();
conveyor
.
x
=
this
.
conveyorsPool
[
this
.
conveyorsPool
.
length
-
1
].
x
+
764
;
conveyor
.
x
=
this
.
conveyorsPool
[
this
.
conveyorsPool
.
length
-
1
].
x
+
764
;
this
.
p
.
addChild
(
conveyor
);
this
.
wrapper
.
addChild
(
conveyor
);
this
.
conveyorsPool
.
push
(
conveyor
);
this
.
conveyorsPool
.
push
(
conveyor
);
}
else
{
}
else
{
//筛选出currGamePool里还未正确和添加在舞台上的
//筛选出currGamePool里还未正确和添加在舞台上的
let
asdasd
=
[]
let
dataList
=
[]
for
(
var
n
=
0
;
n
<
this
.
currGamePool
.
length
;
n
++
)
{
for
(
var
n
=
0
;
n
<
this
.
datas
.
length
;
n
++
)
{
let
cgg
=
this
.
currGamePool
[
n
];
let
dataItem
=
this
.
datas
[
n
];
if
(
!
cgg
.
isRight
&&
!
cgg
.
isOnStage
)
{
if
(
!
dataItem
.
isRight
&&
!
dataItem
.
isOnStage
)
{
asdasd
.
push
(
cgg
);
dataList
.
push
(
dataItem
);
}
}
}
}
//最后一个传送带
//最后一个传送带
let
cc
=
this
.
conveyorsPool
[
this
.
conveyorsPool
.
length
-
1
]
let
lastConveyor
=
this
.
conveyorsPool
[
this
.
conveyorsPool
.
length
-
1
]
for
(
var
m
=
0
;
m
<
5
;
m
++
)
{
for
(
var
m
=
0
;
m
<
5
;
m
++
)
{
if
(
!
cc
[
`idx
${
m
}
`
].
children
[
0
])
{
if
(
!
lastConveyor
[
`idx
${
m
}
`
].
children
[
0
])
{
let
g
=
asdasd
.
shift
();
let
data
=
dataList
.
shift
();
if
(
g
)
{
if
(
data
)
{
g
.
isOnStage
=
true
;
data
.
isOnStage
=
true
;
let
garbage
=
new
Garbage
(
g
.
source
);
let
view
:
any
=
new
engine
.
Sprite
(
getTextureByName
(
data
.
source
));
garbage
.
type
=
g
.
type
;
view
.
isWrong
=
false
;
garbage
.
name
=
g
.
name
;
view
.
isRight
=
false
;
garbage
.
anchorX
=
g
.
width
/
2
;
view
.
type
=
data
.
type
;
garbage
.
anchorY
=
g
.
height
;
view
.
name
=
data
.
name
;
garbage
.
x
=
0
;
view
.
anchorX
=
data
.
width
/
2
;
garbage
.
y
=
90
;
view
.
anchorY
=
data
.
height
;
cc
[
`idx
${
m
}
`
].
addChild
(
garbage
);
view
.
x
=
-
data
.
width
/
2
;
garbage
.
addEventListener
(
engine
.
MouseEvent
.
MOUSE_DOWN
,
this
.
onDwon_garbage
,
this
);
view
.
y
=
-
data
.
height
+
40
;
lastConveyor
[
`idx
${
m
}
`
].
addChild
(
view
);
view
.
addEventListener
(
engine
.
MouseEvent
.
MOUSE_DOWN
,
this
.
onDwon_garbage
,
this
);
}
else
{
}
else
{
break
break
...
@@ -121,15 +133,15 @@ export default class Conveyors extends engine.Sprite {
...
@@ -121,15 +133,15 @@ export default class Conveyors extends engine.Sprite {
// 从场景移除
// 从场景移除
if
(
this
.
conveyorsPool
[
0
].
x
<
-
750
)
{
if
(
this
.
conveyorsPool
[
0
].
x
<
-
750
)
{
for
(
var
k
=
0
;
k
<
this
.
currGamePool
.
length
;
k
++
)
{
for
(
var
k
=
0
;
k
<
this
.
datas
.
length
;
k
++
)
{
let
garbage
=
this
.
currGamePool
[
k
]
let
dataItem
=
this
.
datas
[
k
]
let
cc
=
this
.
conveyorsPool
[
0
][
`idx
${
4
}
`
]
let
idx4
=
this
.
conveyorsPool
[
0
][
`idx
${
4
}
`
]
if
(
cc
.
children
[
0
])
{
if
(
idx4
.
children
[
0
])
{
if
(
garbage
.
name
==
cc
.
children
[
0
].
$
name
)
{
if
(
dataItem
.
name
==
idx4
.
children
[
0
].
name
)
{
garbage
.
isOnStage
=
false
;
dataItem
.
isOnStage
=
false
;
removeEle
(
garbage
,
this
.
currGamePool
);
removeEle
(
dataItem
,
this
.
datas
);
this
.
currGamePool
.
push
(
garbage
);
this
.
datas
.
push
(
dataItem
);
cc
.
removeChild
(
cc
.
children
[
0
])
idx4
.
removeChild
(
idx4
.
children
[
0
])
break
break
}
}
}
}
...
@@ -138,15 +150,15 @@ export default class Conveyors extends engine.Sprite {
...
@@ -138,15 +150,15 @@ export default class Conveyors extends engine.Sprite {
this
.
conveyorsPool
.
shift
();
this
.
conveyorsPool
.
shift
();
}
}
else
if
(
this
.
conveyorsPool
[
0
].
x
<
-
600
)
{
else
if
(
this
.
conveyorsPool
[
0
].
x
<
-
600
)
{
for
(
var
k
=
0
;
k
<
this
.
currGamePool
.
length
;
k
++
)
{
for
(
var
k
=
0
;
k
<
this
.
datas
.
length
;
k
++
)
{
let
garbage
=
this
.
currGamePool
[
k
]
let
dataItem
=
this
.
datas
[
k
]
let
cc
=
this
.
conveyorsPool
[
0
][
`idx
${
3
}
`
]
let
idx3
=
this
.
conveyorsPool
[
0
][
`idx
${
3
}
`
]
if
(
cc
.
children
[
0
])
{
if
(
idx3
.
children
[
0
])
{
if
(
garbage
.
name
==
cc
.
children
[
0
].
$
name
)
{
if
(
dataItem
.
name
==
idx3
.
children
[
0
].
name
)
{
garbage
.
isOnStage
=
false
;
dataItem
.
isOnStage
=
false
;
removeEle
(
garbage
,
this
.
currGamePool
);
removeEle
(
dataItem
,
this
.
datas
);
this
.
currGamePool
.
push
(
garbage
);
this
.
datas
.
push
(
dataItem
);
cc
.
removeChild
(
cc
.
children
[
0
])
idx3
.
removeChild
(
idx3
.
children
[
0
])
break
break
}
}
}
}
...
@@ -154,15 +166,15 @@ export default class Conveyors extends engine.Sprite {
...
@@ -154,15 +166,15 @@ export default class Conveyors extends engine.Sprite {
}
}
}
}
else
if
(
this
.
conveyorsPool
[
0
].
x
<
-
450
)
{
else
if
(
this
.
conveyorsPool
[
0
].
x
<
-
450
)
{
for
(
var
k
=
0
;
k
<
this
.
currGamePool
.
length
;
k
++
)
{
for
(
var
k
=
0
;
k
<
this
.
datas
.
length
;
k
++
)
{
let
garbage
=
this
.
currGamePool
[
k
]
let
dataItem
=
this
.
datas
[
k
]
let
cc
=
this
.
conveyorsPool
[
0
][
`idx
${
2
}
`
]
let
idx2
=
this
.
conveyorsPool
[
0
][
`idx
${
2
}
`
]
if
(
cc
.
children
[
0
])
{
if
(
idx2
.
children
[
0
])
{
if
(
garbage
.
name
==
cc
.
children
[
0
].
$
name
)
{
if
(
dataItem
.
name
==
idx2
.
children
[
0
].
name
)
{
garbage
.
isOnStage
=
false
;
dataItem
.
isOnStage
=
false
;
removeEle
(
garbage
,
this
.
currGamePool
);
removeEle
(
dataItem
,
this
.
datas
);
this
.
currGamePool
.
push
(
garbage
);
this
.
datas
.
push
(
dataItem
);
cc
.
removeChild
(
cc
.
children
[
0
])
idx2
.
removeChild
(
idx2
.
children
[
0
])
break
break
}
}
}
}
...
@@ -170,15 +182,15 @@ export default class Conveyors extends engine.Sprite {
...
@@ -170,15 +182,15 @@ export default class Conveyors extends engine.Sprite {
}
}
}
}
else
if
(
this
.
conveyorsPool
[
0
].
x
<
-
300
)
{
else
if
(
this
.
conveyorsPool
[
0
].
x
<
-
300
)
{
for
(
var
k
=
0
;
k
<
this
.
currGamePool
.
length
;
k
++
)
{
for
(
var
k
=
0
;
k
<
this
.
datas
.
length
;
k
++
)
{
let
garbage
=
this
.
currGamePool
[
k
]
let
dataItem
=
this
.
datas
[
k
]
let
cc
=
this
.
conveyorsPool
[
0
][
`idx
${
1
}
`
]
let
idx1
=
this
.
conveyorsPool
[
0
][
`idx
${
1
}
`
]
if
(
cc
.
children
[
0
])
{
if
(
idx1
.
children
[
0
])
{
if
(
garbage
.
name
==
cc
.
children
[
0
].
$
name
)
{
if
(
dataItem
.
name
==
idx1
.
children
[
0
].
name
)
{
garbage
.
isOnStage
=
false
;
dataItem
.
isOnStage
=
false
;
removeEle
(
garbage
,
this
.
currGamePool
);
removeEle
(
dataItem
,
this
.
datas
);
this
.
currGamePool
.
push
(
garbage
);
this
.
datas
.
push
(
dataItem
);
cc
.
removeChild
(
cc
.
children
[
0
])
idx1
.
removeChild
(
idx1
.
children
[
0
])
break
break
}
}
}
}
...
@@ -186,15 +198,15 @@ export default class Conveyors extends engine.Sprite {
...
@@ -186,15 +198,15 @@ export default class Conveyors extends engine.Sprite {
}
}
}
}
else
if
(
this
.
conveyorsPool
[
0
].
x
<
-
150
)
{
else
if
(
this
.
conveyorsPool
[
0
].
x
<
-
150
)
{
for
(
var
k
=
0
;
k
<
this
.
currGamePool
.
length
;
k
++
)
{
for
(
var
k
=
0
;
k
<
this
.
datas
.
length
;
k
++
)
{
let
garbage
=
this
.
currGamePool
[
k
]
let
dataItem
=
this
.
datas
[
k
]
let
cc
=
this
.
conveyorsPool
[
0
][
`idx
${
0
}
`
]
let
idx0
=
this
.
conveyorsPool
[
0
][
`idx
${
0
}
`
]
if
(
cc
.
children
[
0
])
{
if
(
idx0
.
children
[
0
])
{
if
(
garbage
.
name
==
cc
.
children
[
0
].
$
name
)
{
if
(
dataItem
.
name
==
idx0
.
children
[
0
].
name
)
{
garbage
.
isOnStage
=
false
;
dataItem
.
isOnStage
=
false
;
removeEle
(
garbage
,
this
.
currGamePool
);
removeEle
(
dataItem
,
this
.
datas
);
this
.
currGamePool
.
push
(
garbage
);
this
.
datas
.
push
(
dataItem
);
cc
.
removeChild
(
cc
.
children
[
0
])
idx0
.
removeChild
(
idx0
.
children
[
0
])
break
break
}
}
}
}
...
@@ -202,29 +214,89 @@ export default class Conveyors extends engine.Sprite {
...
@@ -202,29 +214,89 @@ export default class Conveyors extends engine.Sprite {
}
}
}
}
}
//
}
}
}
addscore
(
n
)
{
addscore
()
{
this
.
score
+=
n
;
this
.
score
+=
(
props
.
onceScore
||
2
)
;
engine
.
globalEvent
.
dispatchEvent
(
'recycling-score-update'
,
{
engine
.
globalEvent
.
dispatchEvent
(
'recycling-score-update'
,
{
score
:
this
.
score
score
:
this
.
score
});
});
}
}
gameOver
()
{
gameOver
()
{
engine
.
gameStage
.
addEventListener
(
engine
.
Event
.
ENTER_FRAME
,
this
.
onEnterFrame
,
this
)
engine
.
gameStage
.
removeEventListener
(
engine
.
Event
.
ENTER_FRAME
,
this
.
onEnterFrame
,
this
);
engine
.
globalEvent
.
dispatchEvent
(
'recycling-game-end'
,
transStores
(
this
.
stores
));
}
}
onDwon_garbage
()
{
private
_currentView
:
engine
.
Sprite
;
onDwon_garbage
(
e
:
engine
.
MouseEvent
)
{
const
target
:
engine
.
Sprite
=
e
.
target
;
let
view
:
any
=
new
engine
.
Sprite
(
target
.
texture
);
this
.
_currentView
=
view
;
this
.
wrapper
.
addChild
(
view
);
view
.
x
=
e
.
stageX
-
target
.
texture
.
width
/
2
;
view
.
y
=
e
.
stageY
-
target
.
texture
.
height
/
2
;
view
.
type
=
target
[
'type'
];
view
.
name
=
target
[
'name'
];
this
.
wrapper
.
once
(
engine
.
MouseEvent
.
MOUSE_UP
,
this
.
onStageMouseUp
,
this
)
this
.
wrapper
.
addEventListener
(
engine
.
MouseEvent
.
MOUSE_MOVE
,
this
.
onStageMouseMove
,
this
)
}
onStageMouseMove
(
e
:
engine
.
MouseEvent
)
{
const
view
=
this
.
_currentView
;
view
.
x
=
e
.
stageX
-
view
.
texture
.
width
/
2
;
view
.
y
=
e
.
stageY
-
view
.
texture
.
height
/
2
;
}
onStageMouseUp
(
e
:
engine
.
MouseEvent
)
{
this
.
wrapper
.
removeEventListener
(
engine
.
MouseEvent
.
MOUSE_MOVE
,
this
.
onStageMouseMove
,
this
)
if
(
!
this
.
_currentView
)
return
;
const
result
:
GarbageTypes
=
this
.
checkHitRect
();
if
(
result
)
{
console
.
log
(
'落入垃圾桶类型'
,
result
,
'垃圾类型'
,
this
.
_currentView
[
'type'
]);
if
(
result
==
this
.
_currentView
[
'type'
])
{
this
.
addscore
();
}
this
.
stores
.
push
({
targetType
:
result
,
itemType
:
this
.
_currentView
[
'type'
],
itemName
:
this
.
_currentView
[
'name'
]
});
}
else
{
console
.
log
(
'没有落入'
)
}
this
.
_currentView
.
anchorX
=
this
.
_currentView
.
texture
.
width
/
2
;
this
.
_currentView
.
anchorY
=
this
.
_currentView
.
texture
.
height
/
2
;
engine
.
Tween
.
get
(
this
.
_currentView
).
to
({
scaleX
:
0
,
scaleY
:
0
},
300
).
call
(()
=>
{
removeChild
(
this
.
_currentView
);
});
}
}
private
clear
()
{
private
clear
()
{
this
.
currGamePool
=
[];
this
.
conveyorsPool
.
forEach
(
i
=>
{
i
.
clear
();
});
this
.
conveyorsPool
=
[];
this
.
datas
=
[];
this
.
stores
=
[];
}
}
timeout
()
{
timeout
()
{
engine
.
gameStage
.
removeEventListener
(
engine
.
Event
.
ENTER_FRAME
,
this
.
onEnterFrame
,
this
)
this
.
gameOver
();
}
checkHitRect
()
{
if
(
checkHit
(
this
.
_currentView
,
this
.
wrapper
.
wetWaste
))
{
return
GarbageTypes
.
wetWaste
}
if
(
checkHit
(
this
.
_currentView
,
this
.
wrapper
.
harmfulWaste
))
{
return
GarbageTypes
.
harmfulWaste
}
if
(
checkHit
(
this
.
_currentView
,
this
.
wrapper
.
dryWaste
))
{
return
GarbageTypes
.
dryWaste
}
if
(
checkHit
(
this
.
_currentView
,
this
.
wrapper
.
recoverableWaste
))
{
return
GarbageTypes
.
recoverableWaste
}
return
null
;
}
}
}
}
\ No newline at end of file
src/custom/recycling/src/game/GameView.ts
View file @
a9eac5bb
...
@@ -5,11 +5,11 @@
...
@@ -5,11 +5,11 @@
import
{
getTextureByName
}
from
"../../../recycling/src/game/utils"
;
import
{
getTextureByName
}
from
"../../../recycling/src/game/utils"
;
import
{
props
}
from
"../props"
;
import
{
props
}
from
"../props"
;
import
Conveyor
from
"./Conveyor"
;
import
Conveyor
from
"./Conveyor"
;
import
Conveyors
from
"./Conveyors"
;
import
uiConfig
from
"./uiConfig"
;
import
uiConfig
from
"./uiConfig"
;
import
getGuideInfo
,
{
setGuide
}
from
"./utils/getGuideInfo"
;
import
getGuideInfo
,
{
setGuide
}
from
"./utils/getGuideInfo"
;
import
CountDownGroup
from
"./views/CountDownGroup"
;
import
CountDownGroup
from
"./views/CountDownGroup"
;
import
GuideView
from
"./views/guideView"
;
import
GuideView
from
"./views/guideView"
;
import
Conveyors
from
"./Conveyors"
;
export
default
class
GameView
extends
engine
.
Container
{
export
default
class
GameView
extends
engine
.
Container
{
private
_timer
;
private
_timer
;
...
@@ -126,7 +126,7 @@ export default class GameView extends engine.Container {
...
@@ -126,7 +126,7 @@ export default class GameView extends engine.Container {
setGuide
();
setGuide
();
}
}
await
this
.
countdown
.
startCountDown
();
//
await this.countdown.startCountDown();
this
.
startGame
();
this
.
startGame
();
...
@@ -162,7 +162,7 @@ export default class GameView extends engine.Container {
...
@@ -162,7 +162,7 @@ export default class GameView extends engine.Container {
if
(
this
.
getSecond
()
==
0
)
{
if
(
this
.
getSecond
()
==
0
)
{
this
.
stop
();
this
.
stop
();
this
.
conveyors
.
timeout
();
this
.
conveyors
.
timeout
();
engine
.
globalEvent
.
dispatchEvent
(
'recycling-game-end'
,
{});
}
}
}
}
...
...
src/custom/recycling/src/game/datas/Garbage.ts
deleted
100644 → 0
View file @
63f061c8
import
{
GarbageTypes
}
from
'./GarbageTypes'
;
export
default
class
Garbage
extends
engine
.
Sprite
{
constructor
(
texture
)
{
super
(
texture
);
}
public
type
:
GarbageTypes
;
public
isWrong
:
boolean
=
false
;
public
isRight
:
boolean
=
false
;
public
}
\ No newline at end of file
src/custom/recycling/src/game/datas/GarbageTypes.ts
View file @
a9eac5bb
export
enum
GarbageTypes
{
export
enum
GarbageTypes
{
recoverableWaste
,
recoverableWaste
=
'recoverableWaste'
,
harmfulWaste
,
harmfulWaste
=
'harmfulWaste'
,
wetWaste
,
wetWaste
=
'wetWaste'
,
dryWaste
dryWaste
=
'dryWaste'
}
}
src/custom/recycling/src/game/datas/transStores.ts
0 → 100644
View file @
a9eac5bb
import
{
GarbageTypes
}
from
"./GarbageTypes"
export
default
(
list
:
any
[])
=>
{
return
list
.
map
(
i
=>
{
return
{
'targetName'
:
getTargetName
(
i
.
targetType
),
'isCorrect'
:
i
.
targetType
==
i
.
itemType
,
'itemName'
:
i
.
itemName
}
})
}
const
getTargetName
=
(
type
:
GarbageTypes
)
=>
{
switch
(
type
)
{
case
GarbageTypes
.
recoverableWaste
:
return
'可回收物'
break
;
case
GarbageTypes
.
harmfulWaste
:
return
'有害垃圾'
break
;
case
GarbageTypes
.
wetWaste
:
return
'湿垃圾'
break
;
case
GarbageTypes
.
dryWaste
:
return
'干垃圾'
break
;
default
:
break
;
}
}
\ No newline at end of file
src/custom/recycling/src/game/utils/checkHit.ts
0 → 100644
View file @
a9eac5bb
export
default
(
view
,
rect
:
engine
.
Rectangle
)
=>
{
const
{
x
,
y
}
=
view
;
const
{
width
,
height
}
=
view
.
texture
if
(
x
>
rect
.
x
&&
y
>
rect
.
y
&&
(
x
+
width
)
<
(
rect
.
x
+
rect
.
width
)
&&
(
y
+
height
)
<
(
rect
.
y
+
rect
.
height
))
{
return
true
}
return
false
;
}
src/custom/recycling/src/game/utils/removeChild.ts
0 → 100644
View file @
a9eac5bb
export
default
(
d
:
engine
.
DisplayObject
)
=>
{
if
(
d
&&
d
.
parent
)
{
d
.
parent
.
removeChild
(
d
)
}
}
\ No newline at end of file
src/custom/redpack-rain/src/game/RedPackRain.ts
View file @
a9eac5bb
...
@@ -46,7 +46,7 @@ class RedPack extends engine.Image {
...
@@ -46,7 +46,7 @@ class RedPack extends engine.Image {
this
.
x
=
this
.
_pos
.
x
+=
speedX
;
this
.
x
=
this
.
_pos
.
x
+=
speedX
;
this
.
y
=
this
.
_pos
.
y
+=
speedY
;
this
.
y
=
this
.
_pos
.
y
+=
speedY
;
this
.
parent
.
localToGlobal
(
this
.
_pos
,
this
.
_globalPos
);
this
.
wrapper
.
localToGlobal
(
this
.
_pos
,
this
.
_globalPos
);
const
{
_globalPos
:
{
x
,
y
}}
=
this
;
const
{
_globalPos
:
{
x
,
y
}}
=
this
;
if
(
y
<
-
height
||
y
>
this
.
stage
.
height
)
{
if
(
y
<
-
height
||
y
>
this
.
stage
.
height
)
{
return
true
;
return
true
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment