Commit 5b24d02f authored by Tt's avatar Tt

修改完成

parent 30e0d1ae
......@@ -588,17 +588,8 @@ export default class SceneComponent extends MyCocosSceneComponent {
}
async pieceFindRightBlock(rightBlock, idx) {
const board = cc.find("Canvas/bg/chessBoard/boardItems");
const color = this._status.current;
const piece = cc.find(`Canvas/bg/chessBoard/piece${color}`);
const prograssbar = cc.find(
`Canvas/bg/Life${color.toLowerCase()}/life_${color.toLowerCase()}/mask/prograssbar`
);
const mask = cc.find(
`Canvas/bg/Life${color.toLowerCase()}/life_${color.toLowerCase()}/mask`
);
let targetHeight =
(idx / (board.children.length - 2)) * prograssbar.height;
// console.log(idx + "_进度条高:" + targetHeight);
const offsetX = { Red: -45, Blue: 45 };
......@@ -643,13 +634,28 @@ export default class SceneComponent extends MyCocosSceneComponent {
piece.stopAllActions();
await this.playLocalAudio("落子");
piece.zIndex = 0;
}
const effectNode = cc.find(`Canvas/bg/Life${color.toLowerCase()}/effect`);
effectNode.active = true;
asyncTweenTo(mask, 1, { height: targetHeight }, { easing: "cubicInOut" });
this.playLocalAudio("进度条升高");
await asyncPlayDragonBoneAnimation(effectNode, "normal", 1);
effectNode.active = false;
updateProgress(idx) {
const color = this._status.current;
return new Promise(async (resolve, reject) => {
const board = cc.find("Canvas/bg/chessBoard/boardItems");
const prograssbar = cc.find(
`Canvas/bg/Life${color.toLowerCase()}/life_${color.toLowerCase()}/mask/prograssbar`
);
const mask = cc.find(
`Canvas/bg/Life${color.toLowerCase()}/life_${color.toLowerCase()}/mask`
);
let targetHeight =
(idx / (board.children.length - 2)) * prograssbar.height;
const effectNode = cc.find(`Canvas/bg/Life${color.toLowerCase()}/effect`);
effectNode.active = true;
asyncTweenTo(mask, 1, { height: targetHeight }, { easing: "cubicInOut" });
this.playLocalAudio("进度条升高");
await asyncPlayDragonBoneAnimation(effectNode, "normal", 1);
effectNode.active = false;
resolve('');
});
}
updateStatus(status = null) {
......@@ -841,7 +847,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
this.updateStatus(item.data.status);
} else if (item.data.type == "SERVER_playerRoll") {
// console.log("SERVER_playerRoll: " + JSON.stringify(item.data));
const status = this._status;
const status = JSON.parse(JSON.stringify(this._status));
status.letter = item.data.letter;
console.log("status.letter = " + status.letter);
// console.log("item.data.letter = " + item.data.letter);
......@@ -851,7 +857,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
if (idx == -1) {
console.log("error")
}
const startIdx = this._status[this._status.current];
const startIdx = status[status.current];
let nextIdx = startIdx + idx + 1;
// const idx = ["G", "H", "I", "J", "K", "L"].findIndex(
// (letter) => letter == status.letter
......@@ -875,13 +881,13 @@ export default class SceneComponent extends MyCocosSceneComponent {
// const idx = this.getNextRightIdx();
const playerMe = this.allPlayerList.find((player) => player.uuid == this.playerId);
// console.log("idx->" + idx);
if (this._status.current == playerMe.color) {
if (status.current == playerMe.color) {
let rightBlock = this.getRightBlock();
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}`
`Canvas/bg/chessBoard/piece${status.current}`
);
node["touchStartPos"] = {
nodeX: node.x,
......@@ -889,13 +895,14 @@ export default class SceneComponent extends MyCocosSceneComponent {
touchX: node.x,
touchY: node.y,
};
let lastIdx = this._status[playerMe.color];
let lastIdx = status[playerMe.color];
pieceRed["cantMove"] = false;
pieceBlue["cantMove"] = false;
await this.pieceFindRightBlock(rightBlock, idx);
let isSuccess = await this.showVoice(rightBlock);
this.hideVoice();
if (isSuccess) {
this.updateProgress(idx);
this.networkHelper.sendFrame({
type: "right",
idx: nextIdx,
......@@ -912,6 +919,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
}
}
} else if (item.data.type == "SERVER_playerRight") {
console.log("SERVER_playerRight: " + JSON.stringify(item.data));
const playerMe = this.allPlayerList.find((player) => player.uuid == this.playerId);
if (this._status.current == playerMe.color) {
// let rightBlock = this.getRightBlock();
......@@ -1282,47 +1290,47 @@ export default class SceneComponent extends MyCocosSceneComponent {
});
}
async movePiece(letter, color) {
const offsetX = { Red: -45, Blue: 45 };
const offsetY = { Red: -90, Blue: -90 };
const pieceNode = cc.find(`Canvas/bg/chessBoard/piece${color}`);
const board = cc.find("Canvas/bg/chessBoard/boardItems");
const startIdx = this._status[color];
for (let i = startIdx + 1; i < board.children.length; i++) {
const targetNode = board.children[i];
const itemData = targetNode.getComponent("BoardGame2_ItemData");
const prograssbar = cc.find(
`Canvas/bg/Life${color.toLowerCase()}/life_${color.toLowerCase()}/mask/prograssbar`
);
const mask = cc.find(
`Canvas/bg/Life${color.toLowerCase()}/life_${color.toLowerCase()}/mask`
);
const targetHeight = (i / board.children.length) * prograssbar.height;
this.playLocalAudio("movePiece 进度条升高");
cc.tween(mask)
.to(1, { height: targetHeight }, { easing: "cubicInOut" })
.start();
await asyncTweenTo(
pieceNode,
1,
{
x: targetNode.x + offsetX[color],
y: targetNode.y + offsetY[color],
},
{ easing: "cubicInOut" }
);
if (itemData.letter.toLowerCase() == letter.toLowerCase()) {
this._status[color] = i;
return;
}
}
this.finish();
}
// async movePiece(letter, color) {
// const offsetX = { Red: -45, Blue: 45 };
// const offsetY = { Red: -90, Blue: -90 };
// const pieceNode = cc.find(`Canvas/bg/chessBoard/piece${color}`);
// const board = cc.find("Canvas/bg/chessBoard/boardItems");
// const startIdx = this._status[color];
// for (let i = startIdx + 1; i < board.children.length; i++) {
// const targetNode = board.children[i];
// const itemData = targetNode.getComponent("BoardGame2_ItemData");
// const prograssbar = cc.find(
// `Canvas/bg/Life${color.toLowerCase()}/life_${color.toLowerCase()}/mask/prograssbar`
// );
// const mask = cc.find(
// `Canvas/bg/Life${color.toLowerCase()}/life_${color.toLowerCase()}/mask`
// );
// const targetHeight = (i / board.children.length) * prograssbar.height;
// this.playLocalAudio("movePiece 进度条升高");
// cc.tween(mask)
// .to(1, { height: targetHeight }, { easing: "cubicInOut" })
// .start();
// await asyncTweenTo(
// pieceNode,
// 1,
// {
// x: targetNode.x + offsetX[color],
// y: targetNode.y + offsetY[color],
// },
// { easing: "cubicInOut" }
// );
// if (itemData.letter.toLowerCase() == letter.toLowerCase()) {
// this._status[color] = i;
// return;
// }
// }
// this.finish();
// }
finish() {
// onHomeworkFinish();
......
......@@ -47,10 +47,10 @@ export class AI {
});
} else {
//调试加速 2 Math.random() * 3 + 4
await asyncDelay(Math.random() * 3 + 4);
await asyncDelay(Math.random() * 1 + 10);
const idx = this.getNextRightIdx();
if (Math.random() < 0.8) {
if (Math.random() < 0) {
this.networkHelper.sendFrame({
type: "right",
idx: idx,
......
......@@ -114,7 +114,7 @@ export class GameServer {
this.addPlayer(playerInfo);
}
//TODO:调试加速
}, 10000)//RandomInt(10000, 15000)
}, 1000)//RandomInt(10000, 15000)
);
}
}
......@@ -125,7 +125,7 @@ export class GameServer {
}
if (data.type == "roll") {
const letterList = this.getLetterList();
console.log('letterList: ', letterList);
console.log('server letterList: ', letterList);
if (letterList.length > 0) {
if (this.gameStatus.letter == "") {
// let max = Math.max(9, 0);
......
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