Commit 085f72db authored by 李维's avatar 李维

Bug fix for 7 8 and result event

parent 2d849519
...@@ -1015,20 +1015,7 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -1015,20 +1015,7 @@ export class PlayComponent implements OnInit, OnDestroy {
this.subscribeMapDownEvent(btnMore.id, async ()=>{ this.subscribeMapDownEvent(btnMore.id, async ()=>{
this.g_cartoon.playAudio("sm_moreinfo") this.g_cartoon.playAudio("sm_moreinfo")
await this.buttonPressAnimation(btnMore.id, btnMoreShadow.id) await this.buttonPressAnimation(btnMore.id, btnMoreShadow.id)
let resultDataStr = [] window.parent.postMessage( {action: 'temp_show_more', data: ""}, "*")
this.m_blockGroup.forEach(group => {
let rightLetters = "";
let currentLetters = "";
group.forEach(block => {
rightLetters += block.getRightLetter();
currentLetters += block.getContentText();
});
resultDataStr.push({
rightLetters, currentLetters
})
});
// console.log(JSON.stringify(resultDataStr))
window.parent.postMessage( {action: 'temp_send_result', data: JSON.stringify(resultDataStr)}, "*")
this.g_enableMapDown = true; this.g_enableMapDown = true;
}) })
...@@ -1101,6 +1088,23 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -1101,6 +1088,23 @@ export class PlayComponent implements OnInit, OnDestroy {
} }
} }
sendResult() {
let resultDataStr = []
this.m_blockGroup.forEach(group => {
let rightLetters = "";
let currentLetters = "";
group.forEach(block => {
rightLetters += block.getRightLetter();
currentLetters += block.getContentText();
});
resultDataStr.push({
rightLetters, currentLetters
})
});
// console.log(JSON.stringify(resultDataStr))
window.parent.postMessage( {action: 'temp_send_result', data: JSON.stringify(resultDataStr)}, "*")
}
initSlider() { initSlider() {
const updateSlider = (len) => { const updateSlider = (len) => {
let top = this.g_cartoon.getCartoonElement("slider-top"); let top = this.g_cartoon.getCartoonElement("slider-top");
...@@ -1349,14 +1353,14 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -1349,14 +1353,14 @@ export class PlayComponent implements OnInit, OnDestroy {
} }
}, (w, h)=>{ }, (w, h)=>{
return { return {
x: scrollContent.ref.width / 2, x: scrollContent.ref.width / 2 - 28,
y: 0 y: 0
} }
}) })
heightData.rightRef = ele.ref heightData.rightRef = ele.ref
let word = this.g_cartoon.createCartoonElementLabel("text-label", data.rightWord, "Aileron-Bold", "#ffe9b1", 52) let word = this.g_cartoon.createCartoonElementLabel("text-label", data.rightWord, "Aileron-Bold", "#ffe9b1", 52)
word.ref.x = -797 / 2 + 150 word.ref.x = -797 / 2 + 120 + word.ref.width / 2
word.ref.y = 0 word.ref.y = 0
ele.ref.addChild(word.ref) ele.ref.addChild(word.ref)
...@@ -1416,8 +1420,8 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -1416,8 +1420,8 @@ export class PlayComponent implements OnInit, OnDestroy {
} }
if(item.rightRef) { if(item.rightRef) {
item.rightRef.y = countY + item.right /2; item.rightRef.y = countY + item.right /2 + 10;
countY += item.right + padding countY += item.right + padding + 10
} }
if(item.lineRef) { if(item.lineRef) {
...@@ -1510,6 +1514,7 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -1510,6 +1514,7 @@ export class PlayComponent implements OnInit, OnDestroy {
let status = false; let status = false;
let hasIncorrect = false; let hasIncorrect = false;
this.m_hasActiveBlock = false; this.m_hasActiveBlock = false;
let errorIndex = -1;
this.m_blockGroup.forEach((group, index) => { this.m_blockGroup.forEach((group, index) => {
status = this.updateStatusByGroupIndex(index) status = this.updateStatusByGroupIndex(index)
let word = "" let word = ""
...@@ -1526,6 +1531,7 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -1526,6 +1531,7 @@ export class PlayComponent implements OnInit, OnDestroy {
} }
if(!hasIncorrect && !status) { if(!hasIncorrect && !status) {
hasIncorrect = true; hasIncorrect = true;
errorIndex = index;
} }
}) })
if(hasIncorrect) { if(hasIncorrect) {
...@@ -1540,10 +1546,15 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -1540,10 +1546,15 @@ export class PlayComponent implements OnInit, OnDestroy {
}); });
}); });
if(errorIndex>=0) {
this.switchQuestion(this.m_currentQuestionIndex, errorIndex)
}
if(this.m_submitedTimes>=2 || (this.m_submitedTimes<2 && !hasIncorrect)) { if(this.m_submitedTimes>=2 || (this.m_submitedTimes<2 && !hasIncorrect)) {
let qp = this.g_cartoon.getCartoonElement("question_container") let qp = this.g_cartoon.getCartoonElement("question_container")
let keyboard = this.g_cartoon.getCartoonElement("keyboard_container") let keyboard = this.g_cartoon.getCartoonElement("keyboard_container")
let submitButton = this.g_cartoon.getCartoonElement("button_submit") let submitButton = this.g_cartoon.getCartoonElement("button_submit");
await qp.out() await qp.out()
await keyboard.out() await keyboard.out()
await submitButton.out() await submitButton.out()
...@@ -1710,6 +1721,7 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -1710,6 +1721,7 @@ export class PlayComponent implements OnInit, OnDestroy {
endGame() { endGame() {
console.log("游戏结束") console.log("游戏结束")
this.sendResult();
this.m_endGame = true; this.m_endGame = true;
this.m_blockGroup.forEach(group => { this.m_blockGroup.forEach(group => {
group.forEach(block => { group.forEach(block => {
......
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