Commit ec203d1c authored by 范雪寒's avatar 范雪寒

feat: 开始游戏的判断逻辑

parent 409da6cc
......@@ -36,23 +36,21 @@ export default class SceneComponent extends MyCocosSceneComponent {
await this.networkHelper.initRoom();
this.playerId = await this.networkHelper.joinRoom('op_16', 2);
const roomInfo = this.networkHelper.getRoomInfo();
if (roomInfo.playerList.length == roomInfo.maxPlayers) {
if (this.playerId == roomInfo.playerList[0].id) {
this.networkHelper.startGame();
}
}
roomInfo.playerList.forEach(player => {
// const startPos = JSON.parse(player.customProfile);
// this.createTank(player.id, startPos);
});
// const roomInfo = this.networkHelper.getRoomInfo();
// if (roomInfo.playerList.length == roomInfo.maxPlayers) {
// if (this.playerId == roomInfo.playerList[0].id) {
// this.networkHelper.startGame();
// }
// }
// roomInfo.playerList.forEach(player => {
// // const startPos = JSON.parse(player.customProfile);
// // this.createTank(player.id, startPos);
// });
this.networkHelper.on('playerJoin', (event) => {
const roomInfo = this.networkHelper.getRoomInfo();
if (roomInfo.playerList.length == roomInfo.maxPlayers) {
if (this.playerId == roomInfo.playerList[0].id) {
this.networkHelper.startGame();
}
this.networkHelper.startGame();
}
console.log("playerJoin", event);
});
......
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