Commit 07c58a54 authored by 范雪寒's avatar 范雪寒

fix: bugs

parent 2551facb
...@@ -76,6 +76,27 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -76,6 +76,27 @@ export default class SceneComponent extends MyCocosSceneComponent {
}); });
this.server.startMatch(); this.server.startMatch();
} }
await this.initHeadImgAndName();
}
async initHeadImgAndName() {
const playerInfo: any = {
playerHeadUrl: "http://staging-teach.cdn.ireadabc.com/0751c28419a0e8ffb1f0e84435b081ce.png",
playerName: "test",
};
const middleLayer = cc.find("middleLayer");
if (middleLayer) {
const kidInfo = await middleLayer.getComponent('middleLayer').getUserInfo();
const playerHeadUrl = middleLayer.getComponent('middleLayer').getHeadUrl(kidInfo.avatar_url || kidInfo.id);
playerInfo.playerHeadUrl = playerHeadUrl;
playerInfo.playerName = kidInfo.nick_name;
}
this.networkHelper.sendFrame({
type: "playerInfo",
playerId: this.playerId,
playerName: playerInfo.playerName,
playerHeadUrl: playerInfo.playerHeadUrl,
});
} }
initView() { initView() {
......
...@@ -63,17 +63,18 @@ export class GameServer { ...@@ -63,17 +63,18 @@ export class GameServer {
headUrl: this.headUrls.splice(0, 1)[0], headUrl: this.headUrls.splice(0, 1)[0],
}); });
await asyncDelay(1); if (player.isAI) {
this.networkHelper.sendFrame({ await asyncDelay(1);
type: "SERVER_allPlayerInfo", this.networkHelper.sendFrame({
playerData: this.playerList, type: "SERVER_allPlayerInfo",
}); playerData: this.playerList,
});
if (this.playerList.length == this.playerMaxNumber) { if (this.playerList.length == this.playerMaxNumber) {
this.networkHelper.closeRoom(); this.networkHelper.closeRoom();
await asyncDelay(0.5); await asyncDelay(0.5);
this.startGame(); this.startGame();
this.startAI(); this.startAI();
}
} }
} }
...@@ -142,6 +143,20 @@ export class GameServer { ...@@ -142,6 +143,20 @@ export class GameServer {
}); });
this.gameStatus['gameOver'] = true; this.gameStatus['gameOver'] = true;
} }
} else if (data.type == "playerInfo") {
const player = this.playerList.find(p => p.uuid == data.playerId);
player.name = data.playerName;
player.headUrl = data.playerHeadUrl;
this.networkHelper.sendFrame({
type: "SERVER_allPlayerInfo",
playerData: this.playerList,
});
if (this.playerList.length == this.playerMaxNumber) {
this.networkHelper.closeRoom();
await asyncDelay(0.5);
this.startGame();
this.startAI();
}
} else if (data.type == "right") { } else if (data.type == "right") {
if (this.gameStatus.letter != "") { if (this.gameStatus.letter != "") {
this.gameStatus.letter = ""; this.gameStatus.letter = "";
......
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