Commit de1aa037 authored by 李维's avatar 李维

完成结束界面

parent 8e7f2ef6
......@@ -72,6 +72,7 @@ cc.Class({
// }
// },
audioBeforeTest: "",
testTime: 10,
recordWaitCount: 0,
},
......@@ -81,8 +82,9 @@ cc.Class({
start() {},
init(audio_url) {
init(audio_url, testTime) {
this.audioBeforeTest = audio_url;
this.testTime = testTime;
},
showVoice(node, testLetter) {
......@@ -120,8 +122,7 @@ cc.Class({
playAudioByUrl(url, () => {
asyncPlayDragonBoneAnimation(cat, "record", 0);
cc.tween(progressBar)
.delay(1)
.to(3, { progress: 0 })
.to(this.testTime, { progress: 0 })
.call(() => {})
.start();
......@@ -273,7 +274,7 @@ cc.Class({
return resolve(false);
}
}); //结束录音
}, 4000);
}, this.testTime * 1000);
});
});
},
......@@ -290,9 +291,10 @@ cc.Class({
cc.tween(imgLight).by(3, { angle: 360 }).repeatForever().start();
imgGood.active = true;
imgTry.active = false;
setTimeout(() => {
this.scheduleOnce(() => {
resolve("");
}, 2000);
}, 2);
});
},
......@@ -308,9 +310,9 @@ cc.Class({
cc.tween(imgLight).by(3, { angle: 360 }).repeatForever().start();
imgGood.active = false;
imgTry.active = true;
setTimeout(() => {
this.scheduleOnce(() => {
resolve("");
}, 2000);
}, 2);
});
},
......
......@@ -26,8 +26,9 @@ const MSG_PLAYER_TO_TREE = "msg_player_to_tree";
const MSG_PLAYER_TO_HOME = "msg_player_to_home";
const MSG_PROFIX_END = "__END__";
const DEBUG = true;
const TOTAL_SCORE = 42; // 总分 - 双方分数之和等于 TOTAL_SCORE
const AI_SUCCESS_RATE = 0.85; // ai评测成功率
const TOTAL_SCORE = 10; // 总分 - 双方分数之和等于 TOTAL_SCORE
const AI_SUCCESS_RATE = 1; // ai评测成功率
const AUTO_GAME = true; // 自动游戏-调试使用
@ccclass
export default class SceneComponent extends MyCocosSceneComponent {
......@@ -191,8 +192,15 @@ export default class SceneComponent extends MyCocosSceneComponent {
this.loadingLayer.setMaxPlayerNumber(2);
this.loadingLayer.onLoadFinished(() => {
this.initSide();
this.initTimer();
this.timerHandle = this.initTimer();
this.initPlayerInfo();
// 自动游戏模式 - 调试使用
if(AUTO_GAME) {
this.turntable.stopBlink();
const nextGem = this.getNextQuestionIndex();
this.runEvent(MSG_ROLLING, {nextGem: nextGem});
}
});
}
......@@ -212,7 +220,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
initPronunciationTestLayer() {
const loadingLayerBase = cc.find("Canvas/PronunciationTestLayer");
this.pronunciationTestLayer = loadingLayerBase.getComponent("PronunciationTestLayer");
this.pronunciationTestLayer.init("http://staging-teach.cdn.ireadabc.com/31952573236dd316a8ee1672d1614a1c.mp3")
this.pronunciationTestLayer.init("http://staging-teach.cdn.ireadabc.com/31952573236dd316a8ee1672d1614a1c.mp3", DEBUG?1:10)
}
redPlayerNode = null;
......@@ -293,7 +301,6 @@ export default class SceneComponent extends MyCocosSceneComponent {
// 小人回家
playerToHome(playerNode, homeNode, gemNode) {
const pos = localPosTolocalPos(playerNode, homeNode);
playerNode.scaleX = 1; // 右看
let playerDB = null;
if(playerNode.parent.name.indexOf('red') != -1) {
......@@ -301,11 +308,12 @@ export default class SceneComponent extends MyCocosSceneComponent {
} else {
playerDB = this.bluePlayerDB;
}
asyncPlayDragonBoneAnimation(playerDB, 'normal', -1);
asyncPlayDragonBoneAnimation(playerDB, 'jump', -1);
return new Promise((resovle, reject) =>{
cc.tween(playerNode).to(0.5, {x: pos.x, y: pos.y}).call(()=>{
cc.tween(playerNode).to(0.5, {x: 205, y: 23}).call(()=>{
gemNode.__node_text.active = true;
asyncPlayDragonBoneAnimation(playerDB, 'normal', -1);
resovle(null);
}).start();
})
......@@ -431,6 +439,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
timerCount = 300;
timeLabel = null;
timerHandle = null;
// 初始化倒计时
initTimer() {
const timerHandle = () => {
......@@ -448,20 +457,38 @@ export default class SceneComponent extends MyCocosSceneComponent {
}
this.timeLabel = cc.find("Canvas/timer/count").getComponent(cc.Label);
this.schedule(timerHandle,1);
return timerHandle;
}
// 停止计时器
stopTimer() {
if(this.timerHandle) {
this.unschedule(this.timerHandle);
}
}
scoreRed = 0;
scoreBlue = 0;
scoreRedComponent = null;
scoreBlueComponent = null;
scoreRedFinishComponent = null;
scoreBlueFinishComponent = null;
masterRedNode = null;
masterBlueNode = null;
// 初始化分数
initScore() {
this.scoreRedComponent = cc.find("Canvas/playerLand/red/bag/score").getComponent(cc.Label);
this.scoreBlueComponent = cc.find("Canvas/playerLand/blue/bag/score").getComponent(cc.Label);
this.scoreRedFinishComponent = cc.find("Canvas/finishLayer/red/bag/score").getComponent(cc.Label);
this.scoreBlueFinishComponent = cc.find("Canvas/finishLayer/blue/bag/score").getComponent(cc.Label);
this.masterRedNode = cc.find("Canvas/finishLayer/red/master");
this.masterBlueNode = cc.find("Canvas/finishLayer/blue/master");
this.scoreRed = 0;
this.scoreBlue = 0;
this.scoreRedComponent.string = this.scoreRed;
this.scoreBlueComponent.string = this.scoreBlue;
this.scoreRedFinishComponent.string = this.scoreRed;
this.scoreBlueFinishComponent.string = this.scoreBlue;
}
// 加分
......@@ -469,9 +496,22 @@ export default class SceneComponent extends MyCocosSceneComponent {
if(side == RED) {
this.scoreRed+=score;
this.scoreRedComponent.string = this.scoreRed;
this.scoreRedFinishComponent.string = this.scoreRed;
} else {
this.scoreBlue+=score;
this.scoreBlueComponent.string = this.scoreBlue;
this.scoreBlueFinishComponent.string = this.scoreBlue;
}
if(this.scoreRed > this.scoreBlue) {
this.masterRedNode.active = true;
this.masterBlueNode.active = false;
} else if(this.scoreRed < this.scoreBlue) {
this.masterRedNode.active = false;
this.masterBlueNode.active = true;
} else {
this.masterRedNode.active = false;
this.masterBlueNode.active = false;
}
}
......@@ -744,6 +784,10 @@ export default class SceneComponent extends MyCocosSceneComponent {
// 结束
this.registerEvent(MSG_FINISH, (param, next) => {
console.log("游戏结束")
this.stopTimer();
this.redPlayerHomeNode.active = false;
this.bluePlayerHomeNode.active = false;
cc.find("Canvas/finishLayer").active = true;
})
}
......@@ -848,8 +892,12 @@ export default class SceneComponent extends MyCocosSceneComponent {
initPlayerInfo() {
const red = cc.find("Canvas/playerLand/red/header/image");
const blue = cc.find("Canvas/playerLand/blue/header/image");
const redFinish = cc.find("Canvas/finishLayer/red/header/image");
const blueFinish = cc.find("Canvas/finishLayer/blue/header/image");
const redName = cc.find("Canvas/playerLand/red/name/label").getComponent(cc.Label);
const blueName = cc.find("Canvas/playerLand/blue/name/label").getComponent(cc.Label);
const redNameFinish = cc.find("Canvas/finishLayer/red/name/label").getComponent(cc.Label);
const blueNameFinish = cc.find("Canvas/finishLayer/blue/name/label").getComponent(cc.Label);
this.allPlayerList.forEach((player) => {
if(player.uuid.indexOf("ai_") != -1) {
this.withAiPlayer = true;
......@@ -860,23 +908,37 @@ export default class SceneComponent extends MyCocosSceneComponent {
red.width = 140;
red.height = 140;
redName.string = player.name;
redFinish.getComponent(cc.Sprite).spriteFrame = sf;
redFinish.width = 140;
redFinish.height = 140;
redNameFinish.string = player.name;
} else {
blue.getComponent(cc.Sprite).spriteFrame = sf;
blue.width = 140;
blue.height = 140;
blueName.string = player.name;
blueFinish.getComponent(cc.Sprite).spriteFrame = sf;
blueFinish.width = 140;
blueFinish.height = 140;
blueNameFinish.string = player.name;
}
});
});
}
// 处理换边
handleSwitchSide() {
async handleSwitchSide() {
if(this.side == this.currentGameSide) {
this.turntable.enable();
this.turntable.blink();
// 当前玩家上树
this.runEvent(MSG_PLAYER_TO_TREE,{});
if(AUTO_GAME) {
await asyncDelay(1);
this.turntable.stopBlink();
const nextGem = this.getNextQuestionIndex();
this.runEvent(MSG_ROLLING, {nextGem: nextGem});
}
} else {
this.turntable.disable();
this.turntable.stopBlink();
......
const { ccclass, property } = cc._decorator;
/**
* 图片限制尺寸
* @author chenkai 2021.6.24
*/
@ccclass
export default class OPW_BoardGame_L5R4_ImgFixedSize extends cc.Component {
@property({ type: cc.Integer, tooltip: "固定尺寸" })
fixedSize: number = 0;
onLoad() {
this.node.on(cc.Node.EventType.SIZE_CHANGED, this.onSizeChanged, this);
this.onSizeChanged();
}
/**当尺寸变化时,重置node节点大小 */
onSizeChanged() {
var width = this.node.width;
var height = this.node.height;
var max = Math.max(width, height);
this.node.scale = this.fixedSize / max;
}
}
\ No newline at end of file
{
"ver": "1.0.8",
"uuid": "f7ff93f5-8f67-4d4c-93f9-eb3a6a883482",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}
\ No newline at end of file
{
"ver": "2.3.5",
"uuid": "2bfe8755-b225-4ba0-a7c2-b82807f7025a",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 999,
"height": 805,
"platformSettings": {},
"subMetas": {
"finish_bg": {
"ver": "1.0.4",
"uuid": "a41299ba-5b02-4c53-8b81-7acc6606a742",
"rawTextureUuid": "2bfe8755-b225-4ba0-a7c2-b82807f7025a",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 4,
"offsetY": -41,
"trimX": 8,
"trimY": 82,
"width": 991,
"height": 723,
"rawWidth": 999,
"rawHeight": 805,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}
\ No newline at end of file
{
"ver": "2.3.5",
"uuid": "8df078d3-c828-4b74-85c3-a2732352056a",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 112,
"height": 25,
"platformSettings": {},
"subMetas": {
"finish_bg_blue_name": {
"ver": "1.0.4",
"uuid": "9a19a478-8483-4967-a7fa-e5d79a9552d2",
"rawTextureUuid": "8df078d3-c828-4b74-85c3-a2732352056a",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": 0,
"trimX": 0,
"trimY": 0,
"width": 112,
"height": 25,
"rawWidth": 112,
"rawHeight": 25,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}
\ No newline at end of file
{
"ver": "2.3.5",
"uuid": "91cffc52-82d0-4961-bdd4-fdd60804ebb2",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 112,
"height": 25,
"platformSettings": {},
"subMetas": {
"finish_bg_red_name": {
"ver": "1.0.4",
"uuid": "fad279d6-7a6b-4292-9277-fe6b88ffc4af",
"rawTextureUuid": "91cffc52-82d0-4961-bdd4-fdd60804ebb2",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": 0,
"trimX": 0,
"trimY": 0,
"width": 112,
"height": 25,
"rawWidth": 112,
"rawHeight": 25,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}
\ No newline at end of file
{
"ver": "2.3.5",
"uuid": "b15b9459-0eee-4d72-952e-6463cb6fb8cf",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 413,
"height": 413,
"platformSettings": {},
"subMetas": {
"finish_light": {
"ver": "1.0.4",
"uuid": "3c157c72-5a82-49a0-b358-2c06fe2d405e",
"rawTextureUuid": "b15b9459-0eee-4d72-952e-6463cb6fb8cf",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": 0,
"trimX": 0,
"trimY": 0,
"width": 413,
"height": 413,
"rawWidth": 413,
"rawHeight": 413,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}
\ No newline at end of file
{
"ver": "2.3.5",
"uuid": "ba12af45-2473-4cad-beb3-a3476596435f",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 334,
"height": 225,
"platformSettings": {},
"subMetas": {
"finish_map": {
"ver": "1.0.4",
"uuid": "c6803b58-aab6-435e-ae43-74fc9501f05f",
"rawTextureUuid": "ba12af45-2473-4cad-beb3-a3476596435f",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": 0,
"trimX": 0,
"trimY": 0,
"width": 334,
"height": 225,
"rawWidth": 334,
"rawHeight": 225,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}
\ No newline at end of file
{
"ver": "2.3.5",
"uuid": "391c931c-bc52-4632-90b1-d206a82c1132",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"genMipmaps": false,
"packable": true,
"width": 121,
"height": 60,
"platformSettings": {},
"subMetas": {
"finish_master": {
"ver": "1.0.4",
"uuid": "dca02c0c-19d6-4448-bb07-d7ee8ea14e07",
"rawTextureUuid": "391c931c-bc52-4632-90b1-d206a82c1132",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": 0,
"trimX": 0,
"trimY": 0,
"width": 121,
"height": 60,
"rawWidth": 121,
"rawHeight": 60,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}
\ 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