Commit 716c4811 authored by wildfirecode's avatar wildfirecode

1

parent 34d1bd4a
This diff is collapsed.
...@@ -46,15 +46,21 @@ function launchWithCustomModule(customModule) { ...@@ -46,15 +46,21 @@ function launchWithCustomModule(customModule) {
}, 100); }, 100);
setTimeout(() => { setTimeout(() => {
engine.globalEvent.dispatchEvent('recycling-start', {}); engine.globalEvent.dispatchEvent('recycling-start', { time: 2 });
const d = engine.gameStage.sceneContainer.getChildAt(0); const d = engine.gameStage.sceneContainer.getChildAt(0);
}, 200); }, 200);
setTimeout(() => {
engine.globalEvent.dispatchEvent('recycling-start', { time: 2 });
const d = engine.gameStage.sceneContainer.getChildAt(0);
}, 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-game-fail', (e) => { engine.globalEvent.addEventListener('recycling-game-end', (e) => {
console.log(e.type, e.data); console.log(e.type, e.data);
}); });
engine.globalEvent.addEventListener('recycling-game-success', (e) => { engine.globalEvent.addEventListener('recycling-game-success', (e) => {
......
...@@ -45,6 +45,6 @@ ...@@ -45,6 +45,6 @@
<script src="load-assets.js"></script> <script src="load-assets.js"></script>
<script src="main.js"></script> <script src="main.js"></script>
<script> <script>
localStorage.clear() // localStorage.clear()
</script> </script>
</body> </body>
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
...@@ -74,10 +74,13 @@ ...@@ -74,10 +74,13 @@
"recycling-start": { "recycling-start": {
"alias": "开始", "alias": "开始",
"data": { "data": {
"picUrl": "图片路径", "time": "游戏时间"
"blockUrl": "blockUrl"
} }
}, },
"recycling-end": {
"alias": "游戏结束",
"data": {}
},
"recycling-stop": { "recycling-stop": {
"alias": "停止" "alias": "停止"
} }
...@@ -89,12 +92,16 @@ ...@@ -89,12 +92,16 @@
"time": "剩余时间" "time": "剩余时间"
} }
}, },
"recycling-game-fail": { "recycling-score-update": {
"alias": "游戏结束", "alias": "分数更新",
"data": { "data": {
"reason": "结束原因(1:时间到了)" "score": "分数"
} }
}, },
"recycling-game-end": {
"alias": "游戏结束",
"data": {}
},
"recycling-game-success": { "recycling-game-success": {
"alias": "游戏成功", "alias": "游戏成功",
"data": { "data": {
......
...@@ -4,15 +4,16 @@ ...@@ -4,15 +4,16 @@
import { getTextureByName } from "../../../recycling/src/game/utils"; import { getTextureByName } from "../../../recycling/src/game/utils";
import { props } from "../props"; import { props } from "../props";
import uiConfig from "./uiConfig";
import Conveyor from "./Conveyor"; import Conveyor from "./Conveyor";
import CountDownGroup from "./views/CountDownGroup"; import uiConfig from "./uiConfig";
import getGuideInfo, { setGuide } from "./utils/getGuideInfo"; import getGuideInfo, { setGuide } from "./utils/getGuideInfo";
import CountDownGroup from "./views/CountDownGroup";
import GuideView from "./views/guideView"; import GuideView from "./views/guideView";
export default class GameView extends engine.Container { export default class GameView extends engine.Container {
private _timer; private _timer;
private _timeCounter = 0; private _timeCounter = 0;
score = 0;
uiMap: any; uiMap: any;
wetWaste: engine.Rectangle; wetWaste: engine.Rectangle;
harmfulWaste: engine.Rectangle; harmfulWaste: engine.Rectangle;
...@@ -69,7 +70,7 @@ export default class GameView extends engine.Container { ...@@ -69,7 +70,7 @@ export default class GameView extends engine.Container {
this.recoverableWaste = this.createRect(389, 551, 287, 292, 0x0000ff); this.recoverableWaste = this.createRect(389, 551, 287, 292, 0x0000ff);
} }
createRect(x, y, w, h,c) { createRect(x, y, w, h, c) {
const rect = new engine.Rectangle(x, y, w, h); const rect = new engine.Rectangle(x, y, w, h);
const sp = new engine.Sprite(); const sp = new engine.Sprite();
...@@ -78,7 +79,7 @@ export default class GameView extends engine.Container { ...@@ -78,7 +79,7 @@ export default class GameView extends engine.Container {
sp.y = y; sp.y = y;
const g = new engine.Graphics; const g = new engine.Graphics;
g.alpha=0.0; g.alpha = 0.0;
g.beginFill(c); g.beginFill(c);
g.drawRect(0, 0, w, h); g.drawRect(0, 0, w, h);
g.endFill(); g.endFill();
...@@ -111,8 +112,10 @@ export default class GameView extends engine.Container { ...@@ -111,8 +112,10 @@ export default class GameView extends engine.Container {
} }
async start() { async start() {
console.log('on start')
this._timeCounter = 0;
if(!getGuideInfo()) { if (!getGuideInfo()) {
await this.guide.startGuide(); await this.guide.startGuide();
setGuide(); setGuide();
} }
...@@ -121,7 +124,6 @@ export default class GameView extends engine.Container { ...@@ -121,7 +124,6 @@ export default class GameView extends engine.Container {
this.playAni(); this.playAni();
console.log('on start')
engine.globalEvent.dispatchEvent('recycling-time-update', { engine.globalEvent.dispatchEvent('recycling-time-update', {
second: this.getSecond(), second: this.getSecond(),
...@@ -132,25 +134,25 @@ export default class GameView extends engine.Container { ...@@ -132,25 +134,25 @@ export default class GameView extends engine.Container {
}, 1000) }, 1000)
} }
getSecond() { return 0 } getSecond() {
return props.time - this._timeCounter
}
onTimer() { onTimer() {
this._timeCounter++;
engine.globalEvent.dispatchEvent('recycling-time-update', { engine.globalEvent.dispatchEvent('recycling-time-update', {
second: this.getSecond(), second: this.getSecond(),
}); });
if (this.getSecond() == 0) { if (this.getSecond() == 0) {
// GAME_TIME = props.GAME_TIME
this.stop(); this.stop();
engine.globalEvent.dispatchEvent('recycling-game-fail', { engine.globalEvent.dispatchEvent('recycling-game-end', { });
reason: 1
});
} }
} }
stop() { stop() {
clearInterval(this._timer);
} }
setup() { setup() {
......
...@@ -36,11 +36,11 @@ export default class CountDownGroup extends engine.Sprite { ...@@ -36,11 +36,11 @@ export default class CountDownGroup extends engine.Sprite {
this.addChild(this.num3) this.addChild(this.num3)
this.addChild(this.go) this.addChild(this.go)
this.visible = false;
this.reset(); this.reset();
} }
private reset() { private reset() {
this.visible = false;
this.go.alpha = this.num1.alpha = this.num2.alpha = this.num3.alpha = 0; 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.scaleX = this.num1.scaleX = this.num2.scaleX = this.num3.scaleX = 3;
this.go.scaleY = this.num1.scaleY = this.num2.scaleY = this.num3.scaleY = 3; this.go.scaleY = this.num1.scaleY = this.num2.scaleY = this.num3.scaleY = 3;
...@@ -48,7 +48,7 @@ export default class CountDownGroup extends engine.Sprite { ...@@ -48,7 +48,7 @@ export default class CountDownGroup extends engine.Sprite {
async startCountDown() { async startCountDown() {
return new Promise((r) => { return new Promise((r) => {
this.reset();
this.visible = true; this.visible = true;
this.num3.alpha = 1; this.num3.alpha = 1;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment