Commit c67bfeb5 authored by Tt's avatar Tt

完成

parent 26b6f182
......@@ -47,7 +47,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
Red: 0,
Blue: 0,
letter: "",
current: "Blue",
current: "Red",
};
playerId;
isRoomOwner;
......@@ -57,7 +57,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
this.networkHelper = new NetworkHelper();
this.initNetworkListener();
do {
this.playerId = await this.networkHelper.init("op_16_2", 2);
this.playerId = await this.networkHelper.init("l2_boardgame2_tree", 2);
if (this.playerId === null) {
console.log("onDestroy");
this.networkHelper.onDestroy();
......@@ -105,15 +105,13 @@ export default class SceneComponent extends MyCocosSceneComponent {
}
initView() {
this.addComponents();
this.hideVoice();
this.initBg();
this.initLoadingLayer();
this.initPiece();
}
getJumpList() {
const jumpList = [];
addComponents() {
cc.find('Canvas/bg/chessBoard/boardItems').children.forEach(node => {
let itemData = node.getComponent("BoardGame2_ItemData");
if (!itemData) {
......@@ -131,14 +129,18 @@ export default class SceneComponent extends MyCocosSceneComponent {
}
}
});
// cc.find('Canvas/bg/chessBoard/boardItems').children.forEach(node => {
// const itemData = node.getComponent("BoardGame2_ItemData");
// if (itemData.jump) {
// const from = itemData.idx;
// const to = itemData.jump;
// jumpList.push({ from, to });
// }
// });
}
getJumpList() {
const jumpList = [];
cc.find('Canvas/bg/chessBoard/boardItems').children.forEach(node => {
const itemData = node.getComponent("BoardGame2_ItemData");
if (itemData.jump) {
const from = itemData.idx;
const to = itemData.jump;
jumpList.push({ from, to });
}
});
return jumpList;
}
......@@ -492,6 +494,11 @@ export default class SceneComponent extends MyCocosSceneComponent {
.start();
}
getCurrentBlock() {
const board = cc.find("Canvas/bg/chessBoard/boardItems");
const startIdx = this._status[this._status.current];
return board.children[startIdx]
}
getRightBlock() {
const board = cc.find("Canvas/bg/chessBoard/boardItems");
const startIdx = this._status[this._status.current];
......@@ -872,11 +879,19 @@ export default class SceneComponent extends MyCocosSceneComponent {
let idx = this.getNextRightIdx();
const pieceRed = cc.find("Canvas/bg/chessBoard/pieceRed");
const pieceBlue = cc.find("Canvas/bg/chessBoard/pieceBlue");
const node = cc.find(
`Canvas/bg/chessBoard/piece${this._status.current}`
);
node["touchStartPos"] = {
nodeX: node.x,
nodeY: node.y,
touchX: node.x,
touchY: node.y,
};
let lastIdx = this._status[playerMe.color];
pieceRed["cantMove"] = false;
pieceBlue["cantMove"] = false;
await this.pieceFindRightBlock(rightBlock, idx);
pieceRed["cantMove"] = true;
pieceBlue["cantMove"] = true;
let isSuccess = await this.showVoice(rightBlock);
this.hideVoice();
if (isSuccess) {
......@@ -887,6 +902,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
color: playerMe.color,
});
} else {
this._status[playerMe.color] = lastIdx
this.networkHelper.sendFrame({
type: "wrong",
uuid: playerMe.uuid,
......@@ -897,6 +913,19 @@ export default class SceneComponent extends MyCocosSceneComponent {
} else if (item.data.type == "SERVER_playerRight") {
const playerMe = this.allPlayerList.find((player) => player.uuid == this.playerId);
if (this._status.current == playerMe.color) {
// let rightBlock = this.getRightBlock();
let rightBlock = this.getCurrentBlock();
const pieceRed = cc.find("Canvas/bg/chessBoard/pieceRed");
const pieceBlue = cc.find("Canvas/bg/chessBoard/pieceBlue");
const riData = rightBlock.getComponent("BoardGame2_ItemData");
if (riData.jump != "") {
rightBlock = this.jumpBlock(parseInt(riData.jump));
let idx = parseInt(riData.jump);//this.getNextRightIdx();
await this.pieceFindRightBlock(rightBlock, idx);
}
pieceRed["cantMove"] = true;
pieceBlue["cantMove"] = true;
this._status.letter = "";
this.changeSide();
this.updateStatus();
......@@ -1005,6 +1034,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
console.log('startTest->' + this._status.letter);
courseware && courseware.startTest(this._status.letter); //开始录音
setTimeout(async () => {
if (!courseware) {
let testData = {
"dtLastResponse": "2021-09-17 13:36:26:109",
"refText": "I haven't found anything out about him yet.",
......@@ -1016,7 +1046,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
"fluency": 60,
"rhythm": 90,
"kernel_version": "5.2.4",
"overall": 25,//75
"overall": 80,//25
"integrity": 100,
"duration": "6.779",
"rear_tone": "fall",
......@@ -1122,7 +1152,6 @@ export default class SceneComponent extends MyCocosSceneComponent {
"tokenId": "6144295408558b08dd000001",
"applicationId": "154838659000009e"
}
if (!courseware) {
if (this.recrodEnd(testData)) {
await this.showVoiceGood();
return resolve(true)
......@@ -1186,12 +1215,13 @@ export default class SceneComponent extends MyCocosSceneComponent {
});
}
async recrodEnd(data) {
recrodEnd(data) {
// return true;
let score = data.result.overall;
let isSuccess = this.checkWords(data);
this.log("score->" + score);
this.log("isSuccess->" + isSuccess);
if (score >= 70 && isSuccess) {
//提示成功
return true;
} else {
return false;
......@@ -1200,13 +1230,11 @@ export default class SceneComponent extends MyCocosSceneComponent {
private checkWords(data) {
const sentences = data.result.sentences;
if (!sentences) return true;
for (let i = 0; i < sentences.length; i++) {
const details = sentences[i].details;
const isSuccess = details.some(item => item.overall <= 40);
if (isSuccess) {
return false;
}
if (isSuccess) return false;
}
return true;
}
......
......@@ -8,7 +8,7 @@ export class AI {
Red: 0,
Blue: 0,
letter: "",
current: "Blue",
current: "Red",
};
constructor(networkHelper: NetworkHelper, playerData: any) {
......@@ -49,12 +49,21 @@ export class AI {
//调试加速 2 Math.random() * 3 + 4
await asyncDelay(Math.random() * 3 + 4);
const idx = this.getNextRightIdx();
if (Math.random() < 0.8) {
this.networkHelper.sendFrame({
type: "right",
idx: idx,
uuid: this.playerData.uuid,
color: this.playerData.color,
});
} else {
this.networkHelper.sendFrame({
type: "wrong",
uuid: this.playerData.uuid,
color: this.playerData.color,
});
}
}
}
}
......
......@@ -58,7 +58,7 @@ export class GameServer {
name: this.nameList.splice(0, 1)[0],
uuid: player.uuid,
color:
player.uuid == this.networkHelper.room.roomInfo.owner ? "Blue" : "Red",
player.uuid == this.networkHelper.room.roomInfo.owner ? "Red" : "Blue",
isAI: player.isAI,
headUrl: this.headUrls.splice(0, 1)[0],
});
......@@ -82,7 +82,7 @@ export class GameServer {
Red: 0,
Blue: 0,
letter: "",
current: "Blue",
current: "Red",
};
startGame() {
this.networkHelper.sendFrame({
......@@ -108,13 +108,13 @@ export class GameServer {
const playerInfo = {
uuid: "ai_" + i,
isAI: true,
color: "Red",
color: "Blue",
};
this._aiPlayerList.push(new AI(this.networkHelper, playerInfo));
this.addPlayer(playerInfo);
}
//TODO:调试加速
}, 1000)//RandomInt(10000, 15000)
}, 10000)//RandomInt(10000, 15000)
);
}
}
......@@ -128,9 +128,9 @@ export class GameServer {
console.log('letterList: ', letterList);
if (letterList.length > 0) {
if (this.gameStatus.letter == "") {
// let max = Math.max(letterList.length - 2, 0);
// let max = Math.max(9, 0);
// let letter = letterList[max];//[RandomInt(letterList.length) % 3];//转盘只有1-3
// if (this.gameStatus.current != 'Blue') {
// if (this.gameStatus.current == 'Blue') {
// letter = letterList[0]
// }
let letter = letterList[RandomInt(letterList.length) % 3];
......
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