Commit be749228 authored by yu's avatar yu

1

parent 4804c9ff
......@@ -144,16 +144,6 @@ export default class SceneComponent extends MyCocosSceneComponent {
}
private gameOver() {
Game.getIns().state = GAME_STATE.OVER;
let data: any = {};
data.total = Game.getIns().total;
data.right = Game.getIns().player.right;
data.scores = Game.getIns().player.voices;
data.stone = Math.floor(10 * data.right / data.total);
this.log("total: " + data.total + " right: " + data.right + " stone: " + data.stone);
onHomeworkFinish(data)
}
gameStart() {
Game.getIns().state = GAME_STATE.RUNNING;
......@@ -276,12 +266,20 @@ export default class SceneComponent extends MyCocosSceneComponent {
ice_img.active = false;
ice_melt.active = true;
img_dian.active = true;
target.off(cc.Node.EventType.TOUCH_START, this.onItemTouchStart, this);
target.off(cc.Node.EventType.TOUCH_MOVE, this.onItemTouchMove, this);
target.off(cc.Node.EventType.TOUCH_END, this.onItemTouchEnd, this);
this.playLocalAudio("right");
cc.tween(target).delay(1.5).to(0.2, { opacity: 0 }).call(() => {
target.parent = null;
target.destroy();
bg_bar_font.active = true;
bg_bar_img.active = false;
if (this.layout_card.children.length <= 0) {
this.gameOver();
}
}).start();
......@@ -351,12 +349,49 @@ export default class SceneComponent extends MyCocosSceneComponent {
}
}
private sendData(score) {
return new Promise(res => {
let upData: any = {
word_count: this.data.word_count || 0,
sentence_count: this.data.sentence_count || 0,
zi_count: this.data.zi_count || 0,
score: score,
};
let recordList = pg.hw.getRecord();
if (recordList && recordList.length > 0) {
upData.recordList = recordList
}
let mid = cc.find('middleLayer');
if (!mid) return;
const middleLayer = mid.getComponent('middleLayer');
console.log('upload->' + JSON.stringify(upData))
middleLayer.onHomeworkFinish(upData, () => {
res('');
})
})
}
private gameOver() {
Game.getIns().state = GAME_STATE.OVER;
this.sendData(this.data.questions.length * 3).then(() => {
let mid = cc.find('middleLayer');
if (!mid) return;
const middleLayer = mid.getComponent('middleLayer');
middleLayer.saveGolds(this.data.questions.length * 3); // 保存金币数量; num 是获得金币的数量,数字类
middleLayer.goNextPage(); //跳转到下一页
})
this.log("over~~~~~")
}
private gameCount;
private playCount = true;
update(dt) {
if (Game.getIns().state != GAME_STATE.RUNNING) return;
if (!this.gameCount || this.gameCount <= 0) {
this.isFinish = true;
this.gameOver();
return;
}
if (this.gameCount < 9 && this.playCount) {
......
......@@ -612,7 +612,14 @@ let pg = {
const id = cc.audioEngine.playEffect(audio.clip, loop);
resolve(id);
})
}
},
records: [],
addRecord(data) {
pg.hw.records.push(data)
},
getRecord() {
return pg.hw.records.concat();
},
},
event: Emitter.getInstance()
};
......
......@@ -79,6 +79,15 @@
<input type="text" nz-input [(ngModel)]="item.title" (blur)="save()">
<span style="font-size: 20px;">时间: </span>
<input type="text" nz-input [(ngModel)]="item.time" (blur)="save()">
<span style="font-size: 20px;">掌握单词数: </span>
<input type="text" nz-input [(ngModel)]="item.word_count" (blur)="save()">
<span style="font-size: 20px;">掌握短语数: </span>
<input type="text" nz-input [(ngModel)]="item.sentence_count" (blur)="save()">
<span style="font-size: 20px;">掌握字数: </span>
<input type="text" nz-input [(ngModel)]="item.zi_count" (blur)="save()">
</div>
<div style="margin: 20px;width: 1000px;">
<div *ngFor="let question of item.questions; let i = index">
......
......@@ -30,6 +30,9 @@ export class FormComponent extends ComponentBase implements OnInit, OnChanges, O
title: "sn04-分类",
time: 60,
opleng: 0,
word_count: '0',
sentence_count: '0',
zi_count: '0',
};
isVisible = false;
......@@ -48,6 +51,9 @@ export class FormComponent extends ComponentBase implements OnInit, OnChanges, O
this.handleCancel();
}
init(): void {
if (!this.item.word_count) this.item.word_count = '0';
if (!this.item.sentence_count) this.item.sentence_count = '0';
if (!this.item.zi_count) this.item.zi_count = '0';
console.log(new MetaFormCreator().create());
}
updateOpleng() {
......
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