Commit 5b24d02f authored by Tt's avatar Tt

修改完成

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