Commit 07d69699 authored by yu's avatar yu

8.16调整

parent ae298c79
...@@ -144,7 +144,8 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -144,7 +144,8 @@ export default class SceneComponent extends MyCocosSceneComponent {
data.total = Game.getIns().getTotla; data.total = Game.getIns().getTotla;
data.right = Game.getIns().player.right; data.right = Game.getIns().player.right;
data.scores = Game.getIns().player.voices; data.scores = Game.getIns().player.voices;
this.log("total: " + data.total + " right: " + data.right); data.stone = Math.floor(10 * data.right / data.total);
this.log("total: " + data.total + " right: " + data.right + " stone: " + data.stone);
onHomeworkFinish(data) onHomeworkFinish(data)
}) })
} }
...@@ -155,8 +156,6 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -155,8 +156,6 @@ export default class SceneComponent extends MyCocosSceneComponent {
private count: number; private count: number;
private list: Option[];
private fishs: cc.Node[];
gameStart() { gameStart() {
Game.getIns().state = GAME_STATE.RUNNING; Game.getIns().state = GAME_STATE.RUNNING;
//游戏开始小鱼出现等等 //游戏开始小鱼出现等等
...@@ -166,29 +165,9 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -166,29 +165,9 @@ export default class SceneComponent extends MyCocosSceneComponent {
pg.audio.stopAudio(this.audioId); pg.audio.stopAudio(this.audioId);
} }
//开始 //开始
// //根据数据随机热气球
// let page = Game.getIns().getCurrentPage();
// let list = page.optionList.concat();
// list = JSON.parse(JSON.stringify(list));
// list.sort((A, B) => { return Math.random() < 0.5 });
// Game.getIns().player.addScore(this.list.length);
this.count = 0; this.count = 0;
this.lastCount = null;
this.fishs = [];
this.viewFishs = [];
this.touchFishs = [];
//根据顺序生成对应的鱼。
//顺序根据时间来进行跳动。当顺序跳动之后,就会产生新的鱼。
} }
private lastCount: number;
private viewFishs: Option[];
private touchFishs: Option[];
update(dt) { update(dt) {
if (Game.getIns().state != GAME_STATE.RUNNING) return;
// if (this.fishLen < 5) this.count++;
// let fish = this.getFishByCount(this.count);
// if (fish) this.fishs.push(fish);
} }
playLocalAudio(audioName) { playLocalAudio(audioName) {
...@@ -215,7 +194,9 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -215,7 +194,9 @@ export default class SceneComponent extends MyCocosSceneComponent {
if (stop && count % 3 == 2) clearInterval(this.intervalId); if (stop && count % 3 == 2) clearInterval(this.intervalId);
}, 150) }, 150)
pg.audio.playAudioByUrl(Game.getIns().getCurrentPage().audio).then(() => { stop = true; }) pg.audio.playAudioByUrl(Game.getIns().getCurrentPage().audio, (() => {
stop = true;
}))
} }
......
...@@ -41,6 +41,10 @@ export default class layout_game extends cc.Component { ...@@ -41,6 +41,10 @@ export default class layout_game extends cc.Component {
this.rightNum = 0; this.rightNum = 0;
this.initEvent(); this.initEvent();
} }
protected onDestroy(): void {
cc.Tween.stopAll();
cc.audioEngine.stopAll();
}
private initEvent() { private initEvent() {
pg.event.on("game_start", () => { pg.event.on("game_start", () => {
...@@ -60,7 +64,7 @@ export default class layout_game extends cc.Component { ...@@ -60,7 +64,7 @@ export default class layout_game extends cc.Component {
list = JSON.parse(JSON.stringify(list)); list = JSON.parse(JSON.stringify(list));
list.sort((A, B) => { return Math.random() < 0.5 }); list.sort((A, B) => { return Math.random() < 0.5 });
this.layout_same.removeAllChildren(); this.layout_same.removeAllChildren();
let isPic = this.checkIsAllPic(list); let isPic = this.checkIsAllPic(list) && list.length == 4;
list.forEach((data, idx) => { list.forEach((data, idx) => {
data.id = idx; data.id = idx;
if (data.type == "txt") { if (data.type == "txt") {
...@@ -79,8 +83,9 @@ export default class layout_game extends cc.Component { ...@@ -79,8 +83,9 @@ export default class layout_game extends cc.Component {
this.layout_same.getComponent(cc.Layout).paddingLeft = isPic ? 30 : 0; this.layout_same.getComponent(cc.Layout).paddingLeft = isPic ? 30 : 0;
cc.find("bg_ornament", this.node).active = isPic; cc.find("bg_ornament", this.node).active = isPic;
cc.find("bg_ornament2", this.node).active = !isPic; cc.find("bg_ornament2", this.node).active = !isPic;
let img_player = cc.find("Canvas/bg/bg_could/img_player"); let img_player = cc.find("Canvas/player/img_player");
img_player.y = -260; let start = cc.find("Canvas/bg/bg_could/startPos");
img_player.y = -330;
img_player.scale = 1; img_player.scale = 1;
} }
private initWordItem(item, data) { private initWordItem(item, data) {
...@@ -113,6 +118,7 @@ export default class layout_game extends cc.Component { ...@@ -113,6 +118,7 @@ export default class layout_game extends cc.Component {
pg.audio.playAudioByUrl(data.audioUrl, () => { pg.audio.playAudioByUrl(data.audioUrl, () => {
let pag = Game.getIns().getCurrentPage() let pag = Game.getIns().getCurrentPage()
if (!pag.checkMore || this.rightNum > 1) { if (!pag.checkMore || this.rightNum > 1) {
this.layout_same.removeAllChildren();
this.clickRight().then(() => { this.clickRight().then(() => {
pg.event.emit("game_time_over"); pg.event.emit("game_time_over");
}); });
...@@ -152,28 +158,30 @@ export default class layout_game extends cc.Component { ...@@ -152,28 +158,30 @@ export default class layout_game extends cc.Component {
} }
private clickRight() { private clickRight() {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
let img_player = cc.find("Canvas/bg/bg_could/img_player"); let img_player = cc.find("Canvas/player/img_player");
let endPos = cc.find("Canvas/bg/bg_could/endPos"); let endPos = cc.find("Canvas/bg/bg_could/endPos");
let start = cc.find("Canvas/bg/bg_could/startPos");
cc.tween(img_player) cc.tween(img_player)
.delay(0.1) .delay(0.1)
.call(() => { this.playLocalAudio("huaxue"); }) .call(() => { this.playLocalAudio("huaxue"); })
.to(1, { x: img_player.x, y: endPos.y, scale: 0.16 }) .to(1, { y: endPos.y, scale: 0.16 })
.call(() => { pg.event.emit("skiing_show_firework") }) .call(() => { pg.event.emit("skiing_show_firework") })
.delay(1) .delay(3)
.call(() => { return resolve('') }) .call(() => { return resolve('') })
.start(); .start();
}) })
} }
private clickError() { private clickError() {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
let img_player = cc.find("Canvas/bg/bg_could/img_player"); let img_player = cc.find("Canvas/player/img_player");
let errorPos = cc.find("Canvas/bg/bg_could/errorPos"); let errorPos = cc.find("Canvas/bg/bg_could/errorPos");
let startPos = img_player.getPosition(); let start = cc.find("Canvas/bg/bg_could/startPos");
let startPos = start.getPosition();
cc.tween(img_player).to(1, { y: errorPos.y, scale: 0.65 }) cc.tween(img_player).to(1, { y: errorPos.y, scale: 0.65 })
.delay(1) .delay(1)
.call(() => { this.playLocalAudio("error"); })
.to(1, { y: startPos.y, scale: 1 }) .to(1, { y: startPos.y, scale: 1 })
.call(() => { .call(() => {
this.playLocalAudio("error");
return resolve('') return resolve('')
}) })
.start(); .start();
......
...@@ -46,6 +46,7 @@ export class Item { ...@@ -46,6 +46,7 @@ export class Item {
public duration; public duration;
public optionList; public optionList;
public checkMore: boolean; public checkMore: boolean;
public rNum: number;
constructor(data, page) { constructor(data, page) {
this.audio = data.questionAudio; this.audio = data.questionAudio;
this.duration = data.duration; this.duration = data.duration;
...@@ -58,11 +59,11 @@ export class Item { ...@@ -58,11 +59,11 @@ export class Item {
this.optionList.sort(function () { this.optionList.sort(function () {
return (0.5 - Math.random()); return (0.5 - Math.random());
}); });
let rNum = 0; this.rNum = 0;
for (let i = 0; i < this.optionList.length; i++) { for (let i = 0; i < this.optionList.length; i++) {
if (this.optionList[i].right) rNum++; if (this.optionList[i].right) this.rNum++;
} }
this.checkMore = rNum > 1; this.checkMore = this.rNum > 1;
this.page = page; this.page = page;
} }
} }
...@@ -128,6 +129,7 @@ export default class Game { ...@@ -128,6 +129,7 @@ export default class Game {
public player: Player; public player: Player;
public robot: Robot; public robot: Robot;
public state: GAME_STATE; public state: GAME_STATE;
public total: number;
constructor() { constructor() {
this.start = false; this.start = false;
...@@ -160,6 +162,7 @@ export default class Game { ...@@ -160,6 +162,7 @@ export default class Game {
this.page = 1; this.page = 1;
this.start = true; this.start = true;
this.lists = []; this.lists = [];
this.total = 0;
for (let i = 0; i < this.data.length; i++) { for (let i = 0; i < this.data.length; i++) {
let data = this.data[i]; let data = this.data[i];
this.lists.push(new Item(data, i + 1)); this.lists.push(new Item(data, i + 1));
...@@ -196,7 +199,11 @@ export default class Game { ...@@ -196,7 +199,11 @@ export default class Game {
this.page += 1; this.page += 1;
} }
get getTotla() { get getTotla() {
return this.data.length; this.total = 0;
this.lists.forEach((item) => {
this.total += item.rNum;
})
return this.total;
} }
get isOver() { get isOver() {
return this.page > this.lists.length; return this.page > this.lists.length;
......
export const defaultData = { export const defaultData = {
"title": "急速滑雪", "title": "急速滑雪",
"questionText": "可恶的小偷将魔法卡牌藏在热气球里,准备偷走!快击落热气球,夺回魔法卡牌。游戏开始,请点击弹弓,发射小球,击落热气球,魔法卡牌就会掉落下来。请仔细观察魔法卡牌,并大声说出魔法咒语。魔法咒语正确,你将获得该张魔法卡牌。游戏结束后,根据获得的魔法卡牌数量,你将获得相应的能量石奖励!开始挑战吧!", "questionText": "雪地里有许多不同的指示牌,运动员要选择哪一个呢?亲爱的小玩家,请你认真听游戏指令,帮助运动员选择正确的指示牌吧!游戏结束后,根据收集到的指示牌数量,你将获得相应的能量石奖励哟!开始挑战吧!",
"questionTextAudio": "https://staging-teach.cdn.ireadabc.com/3152e0ea17b07406a002b2c05028b0cc.mp3", "questionTextAudio": "http://staging-teach.cdn.ireadabc.com/c3b69ad3d51385eac7d4195773ef59f7_l.mp3",
"questions": [ "questions": [
{ {
"questionAudio": "https://teach.cdn.ireadabc.com/73dae647c4099fe65bc28f568e351e96.mp3",
"options": [ "options": [
{ {
"type": "img", "type": "img",
"image": "https://staging-teach.cdn.ireadabc.com/1832bc553f77f876e0bba64062bd6b38.jpg", "image": "http://staging-teach.cdn.ireadabc.com/0af1f16b7143f5027c8efcea56c4d8fb.png",
"audio": "https://staging-teach.cdn.ireadabc.com/7c18e0838dcf0707f885842ed09e1579.mp3", "audio": "http://staging-teach.cdn.ireadabc.com/416b6d52f024005d31898ef1da23daa7_l.mp3",
"text": "Please apple", "text": "",
"right": false "time": "",
"right": true,
"audioName": "sahua.mp3"
}, },
{ {
"type": "img", "type": "txt",
"image": "https://staging-teach.cdn.ireadabc.com/52e8f2868ab7ea8b584bf6beb6b9672d.png", "image": "",
"audio": "https://staging-teach.cdn.ireadabc.com/6b3846cee6afa2ae450234aeec835beb.mp3", "audio": "http://staging-teach.cdn.ireadabc.com/5f5d6834729bb822158a4c9a70cc955d_l.mp3",
"text": "Please take some Bag", "text": "good",
"right": false "time": "",
"right": true,
"audioName": "huaxue.mp3"
}, },
// {
// "type": "txt",
// "image": "https://staging-teach.cdn.ireadabc.com/8c6fef67a0095c2564e8df4b536fc540.png",
// "audio": "https://staging-teach.cdn.ireadabc.com/b44fa51172b19b555fda30717c773027.mp3",
// "text": "take cat",
// "right": true
// },
// {
// "type": "txt",
// "image": "",
// "audio": "https://staging-teach.cdn.ireadabc.com/7c18e0838dcf0707f885842ed09e1579.mp3",
// "text": "Please take some cookies",
// "right": false
// },
{ {
"type": "img", "type": "txt",
"image": "https://staging-teach.cdn.ireadabc.com/7b315ba7227294d63933cd659d5372fb.png", "image": "",
"audio": "https://staging-teach.cdn.ireadabc.com/a6a5c388c636bc6d063946e91b4bd21a.mp3", "audio": "http://staging-teach.cdn.ireadabc.com/0913981cdeb2c6bc785de1054e80a500_l.mp3",
"text": "egg", "text": "ghnggfgf",
"right": true "time": "",
"right": false,
"audioName": "error.mp3"
}, },
{ {
"type": "img", "type": "txt",
"image": "http://staging-teach.cdn.ireadabc.com/1410f63265ca58cb612df0ee2911b287.png", "image": "",
"audio": "https://staging-teach.cdn.ireadabc.com/a6a5c388c636bc6d063946e91b4bd21a.mp3", "audio": "http://staging-teach.cdn.ireadabc.com/f7fb9f71ab7d460ac2f78c85efba7610_l.mp3",
"text": "egg", "text": "gfdgdf ",
"right": true "time": "",
"right": false,
"audioName": "btn.mp3"
} }
] ],
"type": "",
"questionAudio": "http://staging-teach.cdn.ireadabc.com/cdc41b6682e155c385093c52d2a4adff_l.mp3",
"audioName": "完成-全部答题完成或点击了答题完成按钮.mp3"
}, },
{ {
"questionAudio": "https://teach.cdn.ireadabc.com/73dae647c4099fe65bc28f568e351e96.mp3",
"options": [ "options": [
{ {
"type": "txt", "type": "img",
"image": "", "image": "http://staging-teach.cdn.ireadabc.com/2bc20ac5b284dd8cf379bb1e1c75848a.png",
"audio": "https://staging-teach.cdn.ireadabc.com/d948ef84a50e6ac36bc31110f9062878.mp3", "audio": "http://staging-teach.cdn.ireadabc.com/b004c86f1a26a367cfa329b11e365f0f_l.mp3",
"text": "umbrella", "text": "",
"right": true "time": "",
"right": true,
"audioName": "选项被选择(该音效指选项属性无对错概念时候用的).mp3"
}, },
{ {
"type": "txt", "type": "txt",
"image": "", "image": "",
"audio": "https://staging-teach.cdn.ireadabc.com/8d6a8d7764011afb0ef537d5a44d1d10.mp3", "audio": "http://staging-teach.cdn.ireadabc.com/0913981cdeb2c6bc785de1054e80a500_l.mp3",
"text": "key", "text": "ame",
"right": true "time": "",
"right": false,
"audioName": "error.mp3"
}, },
{ {
"type": "txt", "type": "txt",
"image": "", "image": "",
"audio": "https://staging-teach.cdn.ireadabc.com/6b3846cee6afa2ae450234aeec835beb.mp3", "audio": "http://staging-teach.cdn.ireadabc.com/5f5d6834729bb822158a4c9a70cc955d_l.mp3",
"text": "bag", "text": "chilce",
"right": false "time": "",
"right": false,
"audioName": "huaxue.mp3"
}, },
{ {
"type": "img", "type": "txt",
"image": "https://staging-teach.cdn.ireadabc.com/7b315ba7227294d63933cd659d5372fb.png", "image": "",
"audio": "https://staging-teach.cdn.ireadabc.com/a6a5c388c636bc6d063946e91b4bd21a.mp3", "audio": "http://staging-teach.cdn.ireadabc.com/416b6d52f024005d31898ef1da23daa7_l.mp3",
"text": "egg", "text": "xnory",
"right": true "time": "",
"right": false,
"audioName": "sahua.mp3"
} }
] ],
"type": "",
"questionAudio": "http://staging-teach.cdn.ireadabc.com/fb08783926362bf64232e2ec6966011d_l.mp3",
"audioName": "选择正确.mp3"
} }
] ],
"audioName": "极速滑雪 游戏说明.MP3"
} }
\ No newline at end of file
...@@ -99,6 +99,23 @@ ...@@ -99,6 +99,23 @@
<div class="word-type-title"> <div class="word-type-title">
题目{{i+1}} 题目{{i+1}}
</div> </div>
<div class="option-audio">
<div class="word-input-title">
题目音频:
</div>
<div style="display: flex">
<div>
<app-audio-recorder [audioUrl]="question.questionAudio"
(audioUploaded)="onAudioUploadSuccess($event, 'questionAudio', question)">
</app-audio-recorder>
</div>
<div style="margin: 5px">
<span>
{{ question.audioName}}
</span>
</div>
</div>
</div>
<div class="word-type-option-title" style="margin-top:20px;"> <div class="word-type-option-title" style="margin-top:20px;">
选项内容: 选项内容:
</div> </div>
...@@ -163,33 +180,32 @@ ...@@ -163,33 +180,32 @@
</div> </div>
</div> </div>
</div> </div>
<div class="option-text"> <div *ngIf="option.type=='txt'" class="option-text">
<div class="word-input-title"> <div class="word-input-title">
<span style="color:red;margin-left:-15px">* </span> <!-- <span style="color:red;margin-left:-15px">* </span> -->
<span>文本: </span> <span>文本: </span>
</div> </div>
<input class="input-place-red" type="text" placeholder="必填,语音评测是根据文本内容去对比打分的" nz-input <input class="input-place-red" type="text" nz-input [(ngModel)]="option.text" (blur)="save()">
[(ngModel)]="option.text" (blur)="save()">
</div> </div>
<div class="option-time"> <!-- <div class="option-time">
<div class="word-input-title"> <div class="word-input-title">
<span>录音时间: </span> <span>录音时间: </span>
</div> </div>
<input type="number" placeholder="录音超过时间将自动提交成绩" nz-input [(ngModel)]="option.time" <input type="number" placeholder="录音超过时间将自动提交成绩" nz-input [(ngModel)]="option.time"
(blur)="save()"> (blur)="save()">
</div> </div> -->
</div> </div>
</div> </div>
<div class="option-btns"> <div class="option-btns">
<button class="btn-red" nz-button nzType="default" nzDanger (click)="removeoption(i,j)">删除选项</button> <button class="btn-red" nz-button nzType="default" nzDanger (click)="removeoption(i,j)">删除选项</button>
<button class="btn-blue" style="margin-top: 10px;" nz-button nzType="default" nzDanger <button *ngIf="question.options.length <4" class="btn-blue" style="margin-top: 10px;" nz-button
(click)="copyoption(i,j)">复制选项</button> nzType="default" nzDanger (click)="copyoption(i,j)">复制选项</button>
</div> </div>
</div> </div>
</div> </div>
<div style="margin-left: 69px;margin-top: 15px;"> <div *ngIf="question.options.length <4" style="margin-left: 69px;margin-top: 15px;">
<button class="btn-blue" nz-button nzType="default" nzDanger (click)="addoption(i)">+增加选项</button> <button class="btn-blue" nz-button nzType="default" nzDanger (click)="addoption(i)">+增加选项</button>
</div> </div>
</div> </div>
......
...@@ -13,8 +13,8 @@ export class FormComponent extends ComponentBase implements OnInit, OnChanges, O ...@@ -13,8 +13,8 @@ export class FormComponent extends ComponentBase implements OnInit, OnChanges, O
item = { item = {
title: "急速滑雪", title: "急速滑雪",
questionText: "可恶的小偷将魔法卡牌藏在热气球里,准备偷走!快来夺回魔法卡牌吧!只要击落热气球,魔法卡牌就会掉落下来。请仔细观察魔法卡牌,并大声说出魔法咒语。魔法咒语正确,你将获得该张魔法卡牌。游戏结束后,根据获得的魔法卡牌数量,你将获得相应的能量石奖励!开始挑战吧!", questionText: "雪地里有许多不同的指示牌,运动员要选择哪一个呢?亲爱的小玩家,请你认真听游戏指令,帮助运动员选择正确的指示牌吧!游戏结束后,根据收集到的指示牌数量,你将获得相应的能量石奖励哟!开始挑战吧!",
questionTextAudio: "http://staging-teach.cdn.ireadabc.com/d60710f8580f77d494a6ab95d5cc46c5.mp3", questionTextAudio: "http://staging-teach.cdn.ireadabc.com/c3b69ad3d51385eac7d4195773ef59f7_l.mp3",
questions: [], questions: [],
audioName: "" audioName: ""
}; };
...@@ -52,7 +52,7 @@ export class FormComponent extends ComponentBase implements OnInit, OnChanges, O ...@@ -52,7 +52,7 @@ export class FormComponent extends ComponentBase implements OnInit, OnChanges, O
addoption(i) { addoption(i) {
this.item.questions[i].options.push({ this.item.questions[i].options.push({
type: "", type: "txt",
image: "", image: "",
audio: "", audio: "",
text: "", text: "",
...@@ -72,7 +72,9 @@ export class FormComponent extends ComponentBase implements OnInit, OnChanges, O ...@@ -72,7 +72,9 @@ export class FormComponent extends ComponentBase implements OnInit, OnChanges, O
addquestion() { addquestion() {
this.item.questions.push({ this.item.questions.push({
options: [], options: [],
type: "" type: "",
questionAudio:"",
audioName:"",
}); });
this.save(); this.save();
} }
......
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