Commit 7735f9a1 authored by 李维's avatar 李维

添加头像击用户名

parent 38eb50bc
...@@ -20,7 +20,6 @@ const MSG_TEST = "msg_test"; ...@@ -20,7 +20,6 @@ const MSG_TEST = "msg_test";
const MSG_SWITCHSIDE = "msg_switch_side"; const MSG_SWITCHSIDE = "msg_switch_side";
const MSG_ROLLING = "msg_rolling"; const MSG_ROLLING = "msg_rolling";
const MSG_GO = "msg_go"; const MSG_GO = "msg_go";
const MSG_BACK = "msg_back";
const MSG_TIMEOUT = "msg_timeout"; const MSG_TIMEOUT = "msg_timeout";
const MSG_FINISH = "msg_finish"; const MSG_FINISH = "msg_finish";
const MSG_PLAYER_TO_TREE = "msg_player_to_tree"; const MSG_PLAYER_TO_TREE = "msg_player_to_tree";
...@@ -73,7 +72,6 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -73,7 +72,6 @@ export default class SceneComponent extends MyCocosSceneComponent {
do { do {
this.playerId = await this.networkHelper.init("l2_boardgame2_tree", 2); this.playerId = await this.networkHelper.init("l2_boardgame2_tree", 2);
if (this.playerId === null) { if (this.playerId === null) {
console.log("onDestroy");
this.networkHelper.onDestroy(); this.networkHelper.onDestroy();
} }
console.log("this.playerId = " + this.playerId); console.log("this.playerId = " + this.playerId);
...@@ -187,6 +185,7 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -187,6 +185,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
this.loadingLayer.onLoadFinished(() => { this.loadingLayer.onLoadFinished(() => {
this.initSide(); this.initSide();
this.initTimer(); this.initTimer();
this.initPlayerInfo();
}); });
} }
...@@ -654,7 +653,7 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -654,7 +653,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
// 转盘 // 转盘
this.registerEvent(MSG_ROLLING, (param, next)=>{ this.registerEvent(MSG_ROLLING, (param, next)=>{
console.log("转盘结果:", param.nextGem) // console.log("转盘结果:", param.nextGem)
this.turntable.stopBlink(); this.turntable.stopBlink();
this.turntable.rollNum(param.nextGem.score).then(()=>{ this.turntable.rollNum(param.nextGem.score).then(()=>{
// 异步操作执行完成后调用 // 异步操作执行完成后调用
...@@ -667,11 +666,6 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -667,11 +666,6 @@ export default class SceneComponent extends MyCocosSceneComponent {
// 走棋 // 走棋
this.registerEvent(MSG_GO, (param, next)=>{ this.registerEvent(MSG_GO, (param, next)=>{
console.log("走棋开始");
// setTimeout(() => {
// console.log("走棋结束");
// next()
// }, 2000);
if(this.currentGameSide == RED) { if(this.currentGameSide == RED) {
this.playerToGem(this.redPlayerNode, this.gemstonesAll[param.index]).then(()=>{ this.playerToGem(this.redPlayerNode, this.gemstonesAll[param.index]).then(()=>{
next(param); next(param);
...@@ -700,26 +694,9 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -700,26 +694,9 @@ export default class SceneComponent extends MyCocosSceneComponent {
}) })
}) })
// 后退
this.registerEvent(MSG_BACK, (param, next)=>{
console.log("走棋开始");
setTimeout(() => {
console.log("走棋结束");
next()
}, 2000);
}, ()=>{
// 游戏流程3: 测评 - 对手不会出现测评界面
this.runFunctionMySide(()=>{
console.log("语音评测开始");
setTimeout(() => {
console.log("语音评测结束")
}, 2000);
})
})
// 时间到 // 时间到
this.registerEvent(MSG_TIMEOUT, (param, next) => { this.registerEvent(MSG_TIMEOUT, (param, next) => {
console.log("时间到") // console.log("时间到")
this.turntable.disable(); this.turntable.disable();
this.turntable.stopBlink(); this.turntable.stopBlink();
setTimeout(() => { setTimeout(() => {
...@@ -793,7 +770,6 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -793,7 +770,6 @@ export default class SceneComponent extends MyCocosSceneComponent {
const arrIndex1 = gem.__arrIndex1; const arrIndex1 = gem.__arrIndex1;
const arrIndex2 = gem.__arrIndex2; const arrIndex2 = gem.__arrIndex2;
gem.__isDone = true; gem.__isDone = true;
console.log(this.gemstones[arrIndex1][arrIndex2]);
} }
// 走棋 // 走棋
...@@ -801,6 +777,29 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -801,6 +777,29 @@ export default class SceneComponent extends MyCocosSceneComponent {
} }
// 初始化用户信息 头像 名字
initPlayerInfo() {
const red = cc.find("Canvas/playerLand/red/header/image");
const blue = cc.find("Canvas/playerLand/blue/header/image");
const redName = cc.find("Canvas/playerLand/red/name/label").getComponent(cc.Label);
const blueName = cc.find("Canvas/playerLand/blue/name/label").getComponent(cc.Label);
this.allPlayerList.forEach((player) => {
this.getSpriteFrimeByUrl(player.headUrl, (sf) => {
if (player.color == "Red") {
red.getComponent(cc.Sprite).spriteFrame = sf;
red.width = 140;
red.height = 140;
redName.string = player.name;
} else {
blue.getComponent(cc.Sprite).spriteFrame = sf;
blue.width = 140;
blue.height = 140;
blueName.string = player.name;
}
});
});
}
// 处理换边 // 处理换边
handleSwitchSide() { handleSwitchSide() {
if(this.side == this.currentGameSide) { if(this.side == this.currentGameSide) {
......
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