Get playerlist on home page

This commit is contained in:
Mashy 2019-03-01 10:54:56 +10:00
parent dafbf145f8
commit 750a81c29f
4 changed files with 12 additions and 13 deletions

View File

@ -15,20 +15,19 @@ class HomeRankings extends Phaser.Scene {
this.add.text(X, Y, 'Instances Scene', TEXT.HEADER);
const playerList = this.registry.get('playerList');
const addInstance = (player, i) => {
const joinNormal = this.add
.rectangle(X, Y + HEIGHT * 0.15 * (i + 1), WIDTH * 0.5, HEIGHT * 0.1, 0x888888)
.setInteractive()
.setOrigin(0)
.on('pointerdown', () => {
this.game.events.emit('SET_PLAYER', player);
});
this.add
.text(joinNormal.getCenter().x, joinNormal.getCenter().y, `${player.instance}`, TEXT.NORMAL)
.setOrigin(0.5, 0.5);
const joinNormal = this.add
.rectangle(X, Y + HEIGHT * 0.15 * (i + 1), WIDTH * 0.5, HEIGHT * 0.1, 0x888888)
.setInteractive()
.setOrigin(0)
.on('pointerdown', () => {
this.game.events.emit('SET_PLAYER', player);
});
this.add
.text(joinNormal.getCenter().x, joinNormal.getCenter().y, `${player.instance}`, TEXT.NORMAL)
.setOrigin(0.5, 0.5);
};
playerList.forEach(addInstance);
}
cleanUp() {

View File

@ -26,6 +26,8 @@ class Home extends Phaser.Scene {
}
create() {
this.registry.get('ws').sendAccountPlayers();
this.registry.events.on('changedata', this.updateData, this);
this.registry.events.on('setdata', this.updateData, this);
this.scene.manager.add('HomeCryps', HomeCryps, true);

View File

@ -28,7 +28,6 @@ class MenuNavigation extends Phaser.Scene {
.text(ready.getCenter().x, ready.getCenter().y, 'Ready', TEXT.HEADER)
.setOrigin(0.5, 0.5);
ready.on('pointerdown', () => {
console.log(player);
ws.sendInstanceReady(player.instance);
});

View File

@ -157,7 +157,6 @@ function createSocket(events) {
account = login;
events.setAccount(login);
sendAccountCryps();
sendAccountPlayers();
}
function accountPlayerList(res) {