Commit 61961e74 authored by 范雪寒's avatar 范雪寒

fix: bugs

parent 1e642681
......@@ -417,6 +417,9 @@ cc.Class({
this.networkHelper.on("frameEvent", (event) => {
event.data.frame.items.forEach((item) => {
if (this.server) {
this.server.onFrameEvent(item.data);
}
if (item.data.type == "all_player_info") {
item.data.playerData.forEach((player) => {
if (!this.allPlayerList) {
......@@ -467,10 +470,6 @@ cc.Class({
duration: this._gameDuration
});
}
} else if (item.data.type == "complete") {
if (this.server) {
this.server.onPlayerComplete(item.data.uuid, item.data.duration);
}
}
});
});
......@@ -494,6 +493,27 @@ cc.Class({
} catch (e) {
this.log(e.toString());
}
await this.initHeadImgAndName();
},
async initHeadImgAndName() {
const playerInfo = {
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,
});
},
//TODO:copy---start
......
......@@ -40,15 +40,35 @@ export class GameServer {
duration: null
});
if (this.playerList.length == this.playerMaxNumber) {
this.networkHelper.closeRoom();
this.startAIDuration();
if (player.isAI) {
if (this.playerList.length == this.playerMaxNumber) {
this.networkHelper.closeRoom();
this.startAIDuration();
}
this.networkHelper.sendFrame({
type: 'all_player_info',
playerData: this.playerList
});
}
}
this.networkHelper.sendFrame({
type: 'all_player_info',
playerData: this.playerList
});
onFrameEvent(event) {
if (event.type == "complete") {
this.onPlayerComplete(event.uuid, event.duration);
} else if (event.type == "playerInfo") {
const player = this.playerList.find(p => p.uuid == event.playerId);
player.name = event.playerName;
player.headUrl = event.playerHeadUrl;
if (this.playerList.length == this.playerMaxNumber) {
this.networkHelper.closeRoom();
this.startAIDuration();
}
this.networkHelper.sendFrame({
type: 'all_player_info',
playerData: this.playerList
});
}
}
onPlayerComplete(uuid: string, duration: number) {
......
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