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

fix: bugs

parent 2551facb
......@@ -76,6 +76,27 @@ export default class SceneComponent extends MyCocosSceneComponent {
});
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() {
......
......@@ -63,17 +63,18 @@ export class GameServer {
headUrl: this.headUrls.splice(0, 1)[0],
});
await asyncDelay(1);
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();
if (player.isAI) {
await asyncDelay(1);
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();
}
}
}
......@@ -142,6 +143,20 @@ export class GameServer {
});
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") {
if (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