Commit fbd8d630 authored by 范雪寒's avatar 范雪寒

feat:

parent f14dd5c9
{
"ver": "2.0.1",
"uuid": "cd66da6e-40cf-4972-8a9a-89699473d49e",
"downloadMode": 0,
"duration": 3.448163,
"subMetas": {}
}
\ No newline at end of file
{
"ver": "2.0.1",
"uuid": "0731f98b-1e5f-4a24-b41e-7c8c3c90c7bc",
"downloadMode": 0,
"duration": 0.873878,
"subMetas": {}
}
\ No newline at end of file
{
"ver": "2.0.1",
"uuid": "dc1b381f-a4e0-4624-a4a0-ad757397b984",
"downloadMode": 0,
"duration": 0.372875,
"subMetas": {}
}
\ No newline at end of file
{
"ver": "2.0.1",
"uuid": "d09a171d-9e26-4029-97ae-692222ef32de",
"downloadMode": 0,
"duration": 0.45102,
"subMetas": {}
}
\ No newline at end of file
{
"ver": "2.0.1",
"uuid": "2d0bc438-c8ca-4d5e-bbe4-bcbafce286a8",
"downloadMode": 0,
"duration": 1.808583,
"subMetas": {}
}
\ No newline at end of file
{
"ver": "2.0.1",
"uuid": "8e9346e6-8b60-49c6-9ef3-904e4ae03327",
"downloadMode": 0,
"duration": 0.6818,
"subMetas": {}
}
\ No newline at end of file
......@@ -364,7 +364,11 @@ export default class SceneComponent extends MyCocosSceneComponent {
showGoodJob() {
return new Promise((resolve) => {
this.playAudioByUrl(this.data.audioRight);
if (this.data.audioRight) {
this.playAudioByUrl(this.data.audioRight);
} else {
}
const result = cc.find('Canvas/testBg/result');
result.active = true;
const goodjob = cc.find('Canvas/testBg/result/goodjob');
......@@ -723,4 +727,10 @@ export default class SceneComponent extends MyCocosSceneComponent {
let variant1 = cc.MaterialVariant.create(material, sprite);
sprite.setMaterial(0, variant1);
}
playEffect(effectName) {
const effectNode = cc.find(`res/${effectName}`);
const clip = effectNode.getComponent(cc.AudioSource).clip;
cc.audioEngine.play(clip, false, 0.8);
}
}
import { ApplicationRef, ChangeDetectorRef, ElementRef, ViewChild } from "@angular/core";
export class ComponentBase {
// 储存数据用
saveKey = "";
// 储存对象
item: any = {};
ngOnChanges() { }
ngOnDestroy() { }
constructor(private appRef: ApplicationRef, private changeDetectorRef: ChangeDetectorRef) { }
ngOnInit() {
// 获取存储的数据
(<any>window).courseware.getData((data) => {
if (data) {
this.item = data;
this.itemStr = JSON.stringify(this.item, null, 4).trim();
}
this.init();
this.changeDetectorRef.markForCheck();
this.changeDetectorRef.detectChanges();
this.refresh();
}, this.saveKey);
}
@ViewChild("itemTextarea", { static: true }) itemTextarea: ElementRef;
copyData() {
this.itemTextarea.nativeElement.select();
document.execCommand("copy");
}
/**
* 储存图片数据
* @param e
*/
onAssetUploadSuccess(e: any, ...key: Array<string>) {
let item = this.item;
for (let i = 0; i < key.length; i++) {
if (i + 1 == key.length) {
item[key[i]] = e.url;
this.save();
return;
}
item = item[key[i]];
}
}
save() {
(<any>window).courseware.setData(this.item, null, this.saveKey);
this.itemStr = JSON.stringify(this.item, null, 4).trim();
this.refresh();
console.log('this.item = ' + JSON.stringify(this.item));
}
itemStr = "";
load() {
this.itemStr = this.itemTextarea.nativeElement.value;
if (this.isJSON(this.itemStr)) {
this.item = JSON.parse(this.itemStr);
this.init();
this.changeDetectorRef.markForCheck();
this.changeDetectorRef.detectChanges();
this.refresh();
}
}
isJSON(str) {
if (typeof str == 'string') {
try {
var obj = JSON.parse(str);
if (typeof obj == 'object' && obj) {
return true;
}
return false;
} catch (e) {
return false;
}
}
return false;
}
/**
* 刷新 渲染页面
*/
refresh() {
setTimeout(() => {
this.appRef.tick();
}, 1);
}
init() { }
}
......@@ -20,10 +20,10 @@
border-style: dashed;
padding: 20px;
margin: 20px;
/*width: 500px; */
/*//border-radius: 20px;*/
/*//border-width: 2px;*/
/*//border-color: #000000;*/
width: 500px;
border-radius: 20px;
border-width: 2px;
border-color: #000000;
}
......@@ -33,30 +33,3 @@
padding: 10px;
margin: 10px;
}
.button-right {
border-style: dotted;
border-color: rgb(42, 142, 72);
width: 100px;
height: 50px;
color: rgb(42, 142, 72);
background-color: white;
}
.button-wrong {
border-style: dotted;
border-color: rgb(180, 0, 0);
width: 100px;
height: 50px;
color: rgb(180, 0, 0);
background-color: white;
}
.button-disable {
border-style: dotted;
border-color: black;
width: 100px;
height: 50px;
color: black;
background-color: white;
}
\ No newline at end of file
<div class="model-content">
<div style="padding: 10px;">
<div class="border" style="width: 1000px;">
<textarea style="width: 955px; height: 300px;" (blur)="load()" #itemTextarea>{{itemStr}}</textarea>
<button (click)="copyData();">Copy</button>
</div>
<div class="border" style="width: 1000px;">
<span style="font-size: 20px;">标题: </span>
<input type="text" nz-input [(ngModel)]="item.title" (blur)="save()">
<span style="font-size: 20px;">题目说明: </span>
<input type="text" nz-input [(ngModel)]="item.questionText" (blur)="save()">
<span style="font-size: 20px;">题目说明音频: </span>
<app-audio-recorder
[audioUrl]="item.questionTextAudio"
(audioUploaded)="onAssetUploadSuccess($event, 'questionTextAudio')"
[_audioName]="item.audioFileName"
(audioName)="saveAudioFileName($event)"
></app-audio-recorder>
</div>
<div class="border" style="width: 1000px;">
<div *ngFor="let question of item.questions; let i = index">
<div class="border" style="width: 950px;">
<span style="font-size: 20px;">选项类型: </span>
<div *ngIf="question.type=='img'">
<button class="button-right">图片</button>
&nbsp;
<button class="button-disable" (click)="question.type='txt'; save();">文字</button>
</div>
<div *ngIf="question.type=='txt'">
<button class="button-disable" (click)="question.type='img'; save();">图片</button>
&nbsp;
<button class="button-right">文字</button>
</div>
<div *ngIf="question.type=='img'">
图片:
<div style="width: 300px;">
<app-upload-image-with-preview [picUrl]="question.image"
(imageUploaded)="onAssetUploadSuccess($event, 'questions', i, 'image')">
</app-upload-image-with-preview>
</div>
</div>
<span>音频: </span>
<app-audio-recorder [audioUrl]="question.audio"
(audioUploaded)="onAssetUploadSuccess($event, 'questions', i, 'audio')">
</app-audio-recorder>
<div *ngIf="question.type=='txt'">
<span>文本: </span>
<input type="text" nz-input [(ngModel)]="question.text" (blur)="save()">
</div>
<br>
<button style="width: 900px; height: 30px; color: red;" (click)="removeQuestion(i)">删除题目</button>
</div>
</div>
<div class="border" style="width: 950px;">
<button style="width: 900px; height: 100px;" (click)="addQuestion()">增加题目</button>
</div>
<div class="border" style="padding: 50px; width: 800px;">
<span style="font-size: 20px;">游戏时长(秒): </span>
<input type="number" nz-input [(ngModel)]="item.roundTime" (blur)="save()">
<br>
<span style="font-size: 20px;">语音评测时长(秒): </span>
<input type="number" nz-input [(ngModel)]="item.testDuration" (blur)="save()">
</div>
<div class="border" style="padding: 50px; width: 800px;">
<div style="margin-bottom: 20px;">
<span style="font-size: 20px;">匹配界面刚进去的时候: </span>
<app-audio-recorder [audioUrl]="item.audioOnEnterMatch"
(audioUploaded)="onAudioUploadSuccess($event, 'audioOnEnterMatch')">
</app-audio-recorder>
<br>
<span style="font-size: 20px;">进入游戏: </span>
<app-audio-recorder [audioUrl]="item.audioOnEnterGame"
(audioUploaded)="onAudioUploadSuccess($event, 'audioOnEnterGame')">
</app-audio-recorder>
<br>
<span style="font-size: 20px;">开始倒计时之后点击猫咪: </span>
<app-audio-recorder [audioUrl]="item.auidoDuringGame"
(audioUploaded)="onAudioUploadSuccess($event, 'auidoDuringGame')">
</app-audio-recorder>
<br>
<span style="font-size: 20px;">点击录音按钮,第一次进入录音页面: </span>
<app-audio-recorder [audioUrl]="item.audioOnFirstTest"
(audioUploaded)="onAudioUploadSuccess($event, 'audioOnFirstTest')">
</app-audio-recorder>
<br>
<span style="font-size: 20px;">在录音界面点击猫咪: </span>
<app-audio-recorder [audioUrl]="item.audioDuringTest"
(audioUploaded)="onAudioUploadSuccess($event, 'audioDuringTest')">
</app-audio-recorder>
<br>
<span style="font-size: 20px;">正确: </span>
<app-audio-recorder [audioUrl]="item.audioRight"
(audioUploaded)="onAudioUploadSuccess($event, 'audioRight')">
</app-audio-recorder>
<br>
<span style="font-size: 20px;">错误: </span>
<app-audio-recorder [audioUrl]="item.audioWrong"
(audioUploaded)="onAudioUploadSuccess($event, 'audioWrong')">
</app-audio-recorder>
<br>
<span style="font-size: 20px;">时间内送走所有小船(较快): </span>
<app-audio-recorder [audioUrl]="item.audioWinInTime"
(audioUploaded)="onAudioUploadSuccess($event, 'audioWinInTime')">
</app-audio-recorder>
<br>
<span style="font-size: 20px;">时间内送走所有小船(较慢): </span>
<app-audio-recorder [audioUrl]="item.audioLossInTime"
(audioUploaded)="onAudioUploadSuccess($event, 'audioLossInTime')">
</app-audio-recorder>
<br>
<span style="font-size: 20px;">时间到,没有送走所有小船(对方送走更多): </span>
<app-audio-recorder [audioUrl]="item.audioLossOutTime"
(audioUploaded)="onAudioUploadSuccess($event, 'audioLossOutTime')">
</app-audio-recorder>
<br>
<span style="font-size: 20px;">时间到,没有送走所有小船(对方送走更少): </span>
<app-audio-recorder [audioUrl]="item.audioWinOutTime"
(audioUploaded)="onAudioUploadSuccess($event, 'audioWinOutTime')">
</app-audio-recorder>
<br>
<span style="font-size: 20px;">游戏结束后点击猫咪: </span>
<app-audio-recorder [audioUrl]="item.audioAfterGame"
(audioUploaded)="onAudioUploadSuccess($event, 'audioAfterGame')">
</app-audio-recorder>
</div>
</div>
</div>
\ No newline at end of file
import { Component, EventEmitter, Input, OnDestroy, OnChanges, OnInit, Output, ApplicationRef, ChangeDetectorRef } from '@angular/core';
import { JsonPipe } from '@angular/common';
import { ComponentBase } from './ComponentBase';
@Component({
......@@ -8,36 +7,99 @@ import { ComponentBase } from './ComponentBase';
templateUrl: './form.component.html',
styleUrls: ['./form.component.css']
})
export class FormComponent extends ComponentBase implements OnInit, OnChanges, OnDestroy {
export class FormComponent implements OnInit, OnChanges, OnDestroy {
// 储存数据用
saveKey = "card_machine";
saveKey = "OP_Boardgame_L3R4";
// 储存对象
item: any = {
title: '',
questionText: '',
questionTextAudio: '',
audioFileName: '',
questions: [],
};
addQuestion() {
this.item.questions.push({
type: 'img',
audio: '',
text: '',
image: ''
});
this.save();
item;
constructor(private appRef: ApplicationRef, private changeDetectorRef: ChangeDetectorRef) {
}
removeQuestion(idx) {
this.item.questions.splice(idx, 1);
ngOnInit() {
this.item = {
roundTime: 80,
testDuration: 5,
audioOnEnterMatch: '',
audioOnEnterGame: '',
auidoDuringGame: '', // TODO:
audioOnFirstTest: '',
audioDuringTest: '', // TODO:
audioRight: '',
audioWrong: '',
audioWinInTime: '',
audioLossInTime: '',
audioWinOutTime: '',
audioLossOutTime: '',
audioAfterGame: '', // TODO:
};
// 获取存储的数据
(<any>window).courseware.getData((data) => {
if (data) {
this.item = data;
}
this.init();
this.changeDetectorRef.markForCheck();
this.changeDetectorRef.detectChanges();
this.refresh();
}, this.saveKey);
}
ngOnChanges() {
}
ngOnDestroy() {
}
init() {
}
/**
* 储存图片数据
* @param e
*/
onImageUploadSuccess(e, key) {
this.item[key] = e.url;
this.save();
}
saveAudioFileName(name) {
this.item.audioFileName=name;
/**
* 储存音频数据
* @param e
*/
onAudioUploadSuccess(e, key) {
this.item[key] = e.url;
this.save();
}
/**
* 储存数据
*/
save() {
(<any>window).courseware.setData(this.item, null, this.saveKey);
this.refresh();
console.log('this.item = ' + JSON.stringify(this.item));
}
/**
* 刷新 渲染页面
*/
refresh() {
setTimeout(() => {
this.appRef.tick();
}, 1);
}
}
\ 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