Commit 6eb5ec8c authored by 范雪寒's avatar 范雪寒

feat:

parent 1155d1ba
No preview for this file type
This diff is collapsed.
...@@ -18,11 +18,11 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -18,11 +18,11 @@ export default class SceneComponent extends MyCocosSceneComponent {
addPreloadAudio() { addPreloadAudio() {
// TODO 根据自己的配置预加载音频资源 // TODO 根据自己的配置预加载音频资源
this._audioResList.push({ url: this.data.gameStartAudio }); this._audioResList.push({ url: this.data.gameStartAudio });
this._audioResList.push({ url: this.data.gameLoadingAudio }); this._audioResList.push({ url: this.data.gameLoadingAudio });
this._audioResList.push({ url: this.data.waitingWheel }); this._audioResList.push({ url: this.data.waitingWheel });
this._audioResList.push({ url: this.data.waitingPiece }); this._audioResList.push({ url: this.data.waitingPiece });
this._audioResList.push({ url: this.data.waitingTurn }); this._audioResList.push({ url: this.data.waitingTurn });
} }
addPreloadAnima() { addPreloadAnima() {
...@@ -80,6 +80,14 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -80,6 +80,14 @@ export default class SceneComponent extends MyCocosSceneComponent {
const bg = cc.find('Canvas/bg'); const bg = cc.find('Canvas/bg');
bg.scale = Math.min(canvas.width / bg.width, canvas.height / bg.height); bg.scale = Math.min(canvas.width / bg.width, canvas.height / bg.height);
const chessBoardBg = cc.find('Canvas/bg/chessBoard/bg');
const offsetX = chessBoardBg.width * chessBoardBg.scaleX / 2 + (canvas.width - chessBoardBg.width * chessBoardBg.scaleX) / 4;
const lifeblue = cc.find('Canvas/bg/Lifeblue');
lifeblue.x = -offsetX;
const lifered = cc.find('Canvas/bg/Lifered');
lifered.x = offsetX;
} }
loadingLayer; loadingLayer;
...@@ -327,6 +335,7 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -327,6 +335,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
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('ItemData'); const itemData = targetNode.getComponent('ItemData');
if (itemData.letter.toLowerCase() == this._status.letter.toLowerCase()) { if (itemData.letter.toLowerCase() == this._status.letter.toLowerCase()) {
return targetNode; return targetNode;
} }
...@@ -539,9 +548,11 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -539,9 +548,11 @@ export default class SceneComponent extends MyCocosSceneComponent {
console.log('SERVER_playerWin: ' + JSON.stringify(item.data)); console.log('SERVER_playerWin: ' + JSON.stringify(item.data));
const node = cc.find(`Canvas/bg/chessBoard/piece${this._status.current}`); const node = cc.find(`Canvas/bg/chessBoard/piece${this._status.current}`);
const playerMe = this.allPlayerList.find(player => player.uuid == this.playerId); const playerMe = this.allPlayerList.find(player => player.uuid == this.playerId);
const rightBlock = this.getRightBlock();
const board = cc.find('Canvas/bg/chessBoard/boardItems'); const board = cc.find('Canvas/bg/chessBoard/boardItems');
const idx = board.children.length; const idx = board.children.length;
const rightBlock = board.children[idx - 1];
this.pieceFindRightBlock(rightBlock, idx); this.pieceFindRightBlock(rightBlock, idx);
if (playerMe.color == this._status.current) { if (playerMe.color == this._status.current) {
this.showWin(); this.showWin();
......
...@@ -10,7 +10,7 @@ export default class SceneComponent extends cc.Component { ...@@ -10,7 +10,7 @@ export default class SceneComponent extends cc.Component {
// 生命周期 onLoad // 生命周期 onLoad
onLoad() { onLoad() {
this.initSize(); // this.initSize();
} }
_designSize; // 设计分辨率 _designSize; // 设计分辨率
......
...@@ -112,15 +112,25 @@ export class GameServer { ...@@ -112,15 +112,25 @@ export class GameServer {
} }
} else if (data.type == 'right') { } else if (data.type == 'right') {
this.gameStatus[data.color] = data.idx; this.gameStatus[data.color] = data.idx;
this.changeSide(); const letterList = this.getLetterList();
this.networkHelper.sendFrame({ console.log('letterList = ' + JSON.stringify(letterList));
type: 'SERVER_playerRight', if (letterList.length > 0) {
idx: data.idx, this.changeSide();
uuid: data.uuid, this.networkHelper.sendFrame({
color: data.color type: 'SERVER_playerRight',
}); idx: data.idx,
uuid: data.uuid,
color: data.color
});
} else {
this.networkHelper.sendFrame({
type: 'SERVER_playerWin',
color: this.gameStatus.current
});
}
} else if (data.type == 'wrong') { } else if (data.type == 'wrong') {
this.gameStatus[data.color] = data.idx; console.log('data = ' + JSON.stringify(data));
// this.gameStatus[data.color] = data.idx;
this.changeSide(); this.changeSide();
this.networkHelper.sendFrame({ this.networkHelper.sendFrame({
type: 'SERVER_playerWrong', type: 'SERVER_playerWrong',
...@@ -137,7 +147,10 @@ export class GameServer { ...@@ -137,7 +147,10 @@ export class GameServer {
getLetterList() { getLetterList() {
const board = cc.find('Canvas/bg/chessBoard/boardItems'); const board = cc.find('Canvas/bg/chessBoard/boardItems');
const color = this.gameStatus.current; const color = this.gameStatus.current;
console.log("color = " + color);
console.log('this.gameStatus = ' + JSON.stringify(this.gameStatus));
const startIdx = this.gameStatus[color]; const startIdx = this.gameStatus[color];
console.log('startIdx = ' + startIdx);
const letterList = []; const letterList = [];
for (let i = startIdx + 1; i < board.children.length; i++) { for (let i = startIdx + 1; i < board.children.length; i++) {
......
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