Commit ca0b8e93 authored by yu's avatar yu

新增无对错

parent b4de7d17
...@@ -9471,7 +9471,7 @@ ...@@ -9471,7 +9471,7 @@
}, },
{ {
"__type__": "cc.Node", "__type__": "cc.Node",
"_name": "New Sprite(Splash)", "_name": "mask",
"_objFlags": 0, "_objFlags": 0,
"_parent": { "_parent": {
"__id__": 200 "__id__": 200
......
import { asyncDelay, onHomeworkFinish } from "../script/util"; import { asyncDelay, onHomeworkFinish } from "../script/util";
import { MyCocosSceneComponent } from "../script/MyCocosSceneComponent"; import { MyCocosSceneComponent } from "../script/MyCocosSceneComponent";
import Game, { GAME_STATE } from "./tool/Game"; import Game, { GAME_STATE, Item } from "./tool/Game";
import pg from "./tool/pg"; import pg from "./tool/pg";
const { ccclass, property } = cc._decorator; const { ccclass, property } = cc._decorator;
...@@ -56,10 +56,12 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -56,10 +56,12 @@ export default class SceneComponent extends MyCocosSceneComponent {
} }
_cantouch = null; _cantouch = null;
public isFinish: boolean; public isFinish: boolean;
private tryData: Array<Item>;
initData() { initData() {
// 所有全局变量 默认都是null // 所有全局变量 默认都是null
this._cantouch = true; this._cantouch = true;
this.isFinish = false; this.isFinish = false;
this.tryData = [];
Game.getIns().init(this.data); Game.getIns().init(this.data);
Game.getIns().reset(); Game.getIns().reset();
} }
...@@ -137,6 +139,7 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -137,6 +139,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
pic.on(cc.Node.EventType.TOUCH_END, this.showBigPic, this); pic.on(cc.Node.EventType.TOUCH_END, this.showBigPic, this);
this.showLayoutImg() this.showLayoutImg()
} }
cc.find("btn_voice", this.node).active = question.audio != "";
} }
private showRecordWord(word) { private showRecordWord(word) {
...@@ -247,6 +250,8 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -247,6 +250,8 @@ export default class SceneComponent extends MyCocosSceneComponent {
private labaIntervalId; private labaIntervalId;
private showLaba(show = false) { private showLaba(show = false) {
let question = Game.getIns().getCurrentPage();
if (question.audio == "") return;
this.btn_laba.active = false; this.btn_laba.active = false;
let btn_kaba2 = cc.find("btn_voice2", this.img_laba); let btn_kaba2 = cc.find("btn_voice2", this.img_laba);
let btn_kaba3 = cc.find("btn_voice3", this.img_laba); let btn_kaba3 = cc.find("btn_voice3", this.img_laba);
...@@ -267,7 +272,6 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -267,7 +272,6 @@ export default class SceneComponent extends MyCocosSceneComponent {
clearInterval(this.labaIntervalId); clearInterval(this.labaIntervalId);
} }
}, 150); }, 150);
let question = Game.getIns().getCurrentPage();
pg.audio.playAudioByUrl(question.audio).then(() => { pg.audio.playAudioByUrl(question.audio).then(() => {
stop = true; stop = true;
show && this.showTip(); show && this.showTip();
...@@ -300,7 +304,9 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -300,7 +304,9 @@ export default class SceneComponent extends MyCocosSceneComponent {
this.btn_record.active = true; this.btn_record.active = true;
this.img_record.active = false; this.img_record.active = false;
this.showRecordWord(data.text) this.showRecordWord(data.text)
if (data.text.split(" ").join("") == Game.getIns().getCurrentPage().word.split(" ").join("")) { let question = Game.getIns().getCurrentPage();
if (!question.isRecord) {
if (data.text.split(" ").join("") == question.word.split(" ").join("") || question.noWord) {
this.playLocalAudio("right").then(() => { this.playLocalAudio("right").then(() => {
this.playLocalAudio("diaoluo"); this.playLocalAudio("diaoluo");
}); });
...@@ -308,10 +314,24 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -308,10 +314,24 @@ export default class SceneComponent extends MyCocosSceneComponent {
pg.event.emit("mouse_10_add"); pg.event.emit("mouse_10_add");
Game.getIns().player.addRight(); Game.getIns().player.addRight();
} else { } else {
//提示失败
this.playLocalAudio("error").then(() => { this.playLocalAudio("error").then(() => {
pg.event.emit("mouse_10_add_error"); pg.event.emit("mouse_10_add_error");
}) })
Game.getIns().player.addError(); Game.getIns().player.addError();
this.tryData.push(question);
this.showErrorNPC();
}
question.isRecord = true;
} else if (this.tryData.some(td => td.page == question.page)) {
if (data.text.split(" ").join("") == question.word.split(" ").join("")) {
this.playLocalAudio("right").then(() => {
});
} else {
this.playLocalAudio("error").then(() => {
})
}
pg.event.emit("mouse_10_num_game_end")
} }
} }
...@@ -390,7 +410,36 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -390,7 +410,36 @@ export default class SceneComponent extends MyCocosSceneComponent {
}); });
} }
private showErrorNPC() {
let start_ske = cc.find("layout_start/start_ske", this.node);
let mask = cc.find("mask", this.layout_start);
mask.opacity = 1;
this.layout_start.active = true;
pg.load.loadDB(start_ske, { ske: Game.getIns().aniEnter.ske.url, tex: Game.getIns().aniEnter.tex.url, png: Game.getIns().aniEnter.png.url }).then((animationName) => {
if (animationName && animationName != "") {
let db = start_ske.getComponent(dragonBones.ArmatureDisplay);
let anis = db.getAnimationNames(db.armatureName);
db.playAnimation(anis[0], 0);
cc.tween(start_ske).by(0.5, { x: -500 }).call(() => {
pg.audio.playAudioByUrl(Game.getIns().errorAudio).then(() => {
cc.tween(start_ske).delay(0.2).by(0.5, { x: 500 }).call(() => {
this.layout_start.active = false;
this.showTip();
this.showRecordWord("");
}).start();
});
}).start();
} else {
this.layout_start.active = false;
this.showTip();
this.showRecordWord("");
}
})
}
private initStart() { private initStart() {
let mask = cc.find("mask", this.layout_start);
mask.opacity = 110;
//生成橘子 //生成橘子
pg.event.emit('box2d_init', Game.getIns().getTotalPageNum()); pg.event.emit('box2d_init', Game.getIns().getTotalPageNum());
this.layout_start.active = true; this.layout_start.active = true;
......
...@@ -126,7 +126,7 @@ export default class Ngt_star_10 extends cc.Component { ...@@ -126,7 +126,7 @@ export default class Ngt_star_10 extends cc.Component {
star.x = 0; star.x = 0;
star.y = 0; star.y = 0;
star.scale = 1 / bigStarBg.scale; star.scale = 1 / bigStarBg.scale;
pg.event.emit("mouse_10_num_game_end") // pg.event.emit("mouse_10_num_game_end")
} }
showBigStar(isRight) { showBigStar(isRight) {
if (!this.bigStarArr || this.bigStarArr.length <= 0) { if (!this.bigStarArr || this.bigStarArr.length <= 0) {
......
...@@ -48,14 +48,16 @@ export class Item { ...@@ -48,14 +48,16 @@ export class Item {
public word; public word;
public picUrl; public picUrl;
public type; public type;
public noWord;
public text: string; public text: string;
public isClick: boolean; public isRecord: boolean;
constructor(data, page) { constructor(data, page) {
this.audio = data.audio; this.audio = data.audio || "";
this.text = data.text; this.text = data.text;
this.word = data.word.toLowerCase(); this.word = data.word.toLowerCase();
this.type = data.type; this.type = data.type;
this.duration = data.time; this.duration = data.time;
this.noWord = data.noWord == "0";
this.picUrl = data.image; this.picUrl = data.image;
this.page = page; this.page = page;
...@@ -66,7 +68,7 @@ export class Item { ...@@ -66,7 +68,7 @@ export class Item {
// this.optionList.sort(function () { // this.optionList.sort(function () {
// return (0.5 - Math.random()); // return (0.5 - Math.random());
// }); // });
this.isClick = false; this.isRecord = false;
} }
} }
class Role { class Role {
...@@ -150,11 +152,13 @@ export default class Game { ...@@ -150,11 +152,13 @@ export default class Game {
public dispelCount; public dispelCount;
public aniEnter; public aniEnter;
public startAudio: string; public startAudio: string;
public errorAudio: string;
// public questionText: string; // public questionText: string;
public init(data) { public init(data) {
// this.question = { text: data.questionText, audio: data.questionTextAudio }; // this.question = { text: data.questionText, audio: data.questionTextAudio };
this.title = data.title; this.title = data.title;
this.startAudio = data.startAudio || ""; this.startAudio = data.startAudio || "";
this.errorAudio = data.errorAudio || "";
// this.questionText = data.questionText; // this.questionText = data.questionText;
this.start = false; this.start = false;
this.lists = []; this.lists = [];
......
...@@ -14,18 +14,20 @@ export const defaultData = { ...@@ -14,18 +14,20 @@ export const defaultData = {
} }
}, },
"tipSwitch": 1, "tipSwitch": 1,
"startAudio": "http://staging-teach.cdn.ireadabc.com/36067f9e2415d59fa37c3795a3929087_l.mp3", "startAudio": "",// "http://staging-teach.cdn.ireadabc.com/36067f9e2415d59fa37c3795a3929087_l.mp3",
"errorAudio": "http://staging-teach.cdn.ireadabc.com/36067f9e2415d59fa37c3795a3929087_l.mp3",
"audioName": "bear_3.mp3", "audioName": "bear_3.mp3",
"title": "听音对话", "title": "听音对话",
"questions": [ "questions": [
{ {
"type": "txt", "type": "txt",
"audio": "http://staging-teach.cdn.ireadabc.com/449e65975d358514cc3494f9f67bc012_l.mp3", "audio": "",// "http://staging-teach.cdn.ireadabc.com/449e65975d358514cc3494f9f67bc012_l.mp3",
"text": "what are you kettle ?", "text": "what are you kettle ?",
"image": "", "image": "",
"time": 10, "time": 10,
"audioName": "cape.mp3", "audioName": "cape.mp3",
"word": "Oh no" "word": "Oh no",
"noWord": "0"
}, },
{ {
"type": "img", "type": "img",
...@@ -34,7 +36,8 @@ export const defaultData = { ...@@ -34,7 +36,8 @@ export const defaultData = {
"image": "http://staging-teach.cdn.ireadabc.com/95c760f287a3c55bacc6c12ea47259ea.jpg", "image": "http://staging-teach.cdn.ireadabc.com/95c760f287a3c55bacc6c12ea47259ea.jpg",
"time": 10, "time": 10,
"audioName": "bear_2.mp3", "audioName": "bear_2.mp3",
"word": "join" "word": "join",
"noWord": "1"
}, },
{ {
"type": "txt", "type": "txt",
...@@ -43,7 +46,8 @@ export const defaultData = { ...@@ -43,7 +46,8 @@ export const defaultData = {
"image": "", "image": "",
"time": 20, "time": 20,
"audioName": "bear_3.mp3", "audioName": "bear_3.mp3",
"word": "why" "word": "why",
"noWord": "0"
} }
] ]
} }
\ No newline at end of file
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