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

View File

@ -26,6 +26,8 @@ class Home extends Phaser.Scene {
} }
create() { create() {
this.registry.get('ws').sendAccountPlayers();
this.registry.events.on('changedata', this.updateData, this); this.registry.events.on('changedata', this.updateData, this);
this.registry.events.on('setdata', this.updateData, this); this.registry.events.on('setdata', this.updateData, this);
this.scene.manager.add('HomeCryps', HomeCryps, true); 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) .text(ready.getCenter().x, ready.getCenter().y, 'Ready', TEXT.HEADER)
.setOrigin(0.5, 0.5); .setOrigin(0.5, 0.5);
ready.on('pointerdown', () => { ready.on('pointerdown', () => {
console.log(player);
ws.sendInstanceReady(player.instance); ws.sendInstanceReady(player.instance);
}); });

View File

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