Commit 087be0a1 authored by Tt's avatar Tt

游戏内部的数据传输

parent cdc4ae86
...@@ -292,11 +292,11 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -292,11 +292,11 @@ export default class SceneComponent extends MyCocosSceneComponent {
} }
} }
async recrodEnd(data?: any) { async recrodEnd(data?: any) {
pg.hw.addRecord(data)
this.hideVoiceFlash(); this.hideVoiceFlash();
let score = data.result.overall; let score = data.result.overall;
pg.event.emit('layer_record_score', score); pg.event.emit('layer_record_score', score);
this.recording = false; this.recording = false;
this.startPlay(score); this.startPlay(score);
} }
startPlay(score) { startPlay(score) {
...@@ -418,9 +418,26 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -418,9 +418,26 @@ export default class SceneComponent extends MyCocosSceneComponent {
cc.Tween.stopAllByTarget(icon_mountain); cc.Tween.stopAllByTarget(icon_mountain);
pg.view.visible(icon_mountain, false) pg.view.visible(icon_mountain, false)
} }
sendData() {
return new Promise(res => {
let upData: any = {
word_count: this.data.word_count,
sentence_count: this.data.sentence_count,
zi_count: this.data.zi_count,
score: this.score,
};
let details = pg.hw.getRecord();
if (details && details.length > 0) {
upData.details = details
}
const middleLayer = cc.find('middleLayer').getComponent('middleLayer');
middleLayer.onHomeworkFinish(upData, () => {
res('');
})
})
}
gameOver() { gameOver() {
this.sendData()
pg.view.visible(this.sentence_box, false) pg.view.visible(this.sentence_box, false)
// pg.event.emit('layer_ending_show', { // pg.event.emit('layer_ending_show', {
// coin: this.score // coin: this.score
......
...@@ -676,6 +676,13 @@ let pg = { ...@@ -676,6 +676,13 @@ let pg = {
const id = cc.audioEngine.playEffect(audio.clip, loop); const id = cc.audioEngine.playEffect(audio.clip, loop);
resolve(id); resolve(id);
}) })
},
records: [],
addRecord(data) {
this.records.push(data)
},
getRecord() {
return this.records.concat();
} }
}, },
signal: { signal: {
......
export const defaultData = export const defaultData =
{ {
npcTitle:"123", word_count: 1,
sentence_count: 1,
zi_count: 1,
npcTitle: "123",
"recordFlag": false, "title": "", "questionText": "", "questionTextAudio": "", "questions": [ "recordFlag": false, "title": "", "questionText": "", "questionTextAudio": "", "questions": [
{ "text": "apple", "time": 2 }, { "text": "apple", "time": 2 },
{ "text": "pear", "time": 2 }, { "text": "pear", "time": 2 },
......
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