join games in progress
This commit is contained in:
parent
2eae21f12f
commit
9a5f92cf7f
@ -5,6 +5,7 @@ const X = MENU_MAIN.x();
|
|||||||
const Y = MENU_MAIN.y();
|
const Y = MENU_MAIN.y();
|
||||||
const WIDTH = MENU_MAIN.width();
|
const WIDTH = MENU_MAIN.width();
|
||||||
const HEIGHT = MENU_MAIN.height();
|
const HEIGHT = MENU_MAIN.height();
|
||||||
|
const NULL_UUID = '00000000-0000-0000-0000-000000000000';
|
||||||
|
|
||||||
class HomeRankings extends Phaser.Scene {
|
class HomeRankings extends Phaser.Scene {
|
||||||
constructor() {
|
constructor() {
|
||||||
@ -20,10 +21,17 @@ class HomeRankings extends Phaser.Scene {
|
|||||||
.setInteractive()
|
.setInteractive()
|
||||||
.setOrigin(0)
|
.setOrigin(0)
|
||||||
.on('pointerdown', () => {
|
.on('pointerdown', () => {
|
||||||
this.game.events.emit('SET_PLAYER', player);
|
if (player.ready) {
|
||||||
|
this.registry.set('player', player);
|
||||||
|
this.registry.get('ws').sendInstanceReady(player.instance);
|
||||||
|
} else {
|
||||||
|
this.game.events.emit('SET_PLAYER', player);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
const name = player.instance === NULL_UUID ? 'Normal Mode' : `${player.instance.substring(0, 5)}`;
|
||||||
|
const disp = player.ready ? name.concat(' - in progress') : name;
|
||||||
this.add
|
this.add
|
||||||
.text(joinNormal.getCenter().x, joinNormal.getCenter().y, `${player.instance}`, TEXT.NORMAL)
|
.text(joinNormal.getCenter().x, joinNormal.getCenter().y, disp, TEXT.NORMAL)
|
||||||
.setOrigin(0.5, 0.5);
|
.setOrigin(0.5, 0.5);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -134,7 +134,9 @@ class ItemList extends Phaser.Scene {
|
|||||||
}
|
}
|
||||||
|
|
||||||
create() {
|
create() {
|
||||||
const { vbox } = this.registry.get('player');
|
const player = this.registry.get('player');
|
||||||
|
if (!player) return false;
|
||||||
|
const { vbox } = player;
|
||||||
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);
|
||||||
if (!vbox.bound) return false;
|
if (!vbox.bound) return false;
|
||||||
|
|||||||
@ -23,7 +23,8 @@ class MenuCrypList extends Phaser.Scene {
|
|||||||
// this.cameras.main.setViewport(CRYP_LIST.x(), CRYP_LIST.y(), CRYP_LIST.width(), CRYP_LIST.height());
|
// this.cameras.main.setViewport(CRYP_LIST.x(), CRYP_LIST.y(), CRYP_LIST.width(), CRYP_LIST.height());
|
||||||
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.drawCryps(this.registry.get('player').cryps);
|
const player = this.registry.get('player');
|
||||||
|
if (player) this.drawCryps(player.cryps);
|
||||||
}
|
}
|
||||||
|
|
||||||
updateData(parent, key, data) {
|
updateData(parent, key, data) {
|
||||||
|
|||||||
@ -43,8 +43,8 @@ class Menu extends Phaser.Scene {
|
|||||||
this.registry.set('inMenu', true);
|
this.registry.set('inMenu', true);
|
||||||
|
|
||||||
// Request the latest player state when we load the scene
|
// Request the latest player state when we load the scene
|
||||||
const { instance } = this.registry.get('player');
|
const player = this.registry.get('player');
|
||||||
this.registry.get('ws').sendPlayerState(instance);
|
this.registry.get('ws').sendPlayerState(player.instance);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -11,9 +11,11 @@ class MenuScore extends Phaser.Scene {
|
|||||||
}
|
}
|
||||||
|
|
||||||
create() {
|
create() {
|
||||||
const { score } = this.registry.get('player');
|
const player = this.registry.get('player');
|
||||||
this.add.text(X, Y, `Wins: ${score.wins}`, TEXT.HEADER);
|
if (!player) return false;
|
||||||
this.add.text(X, Y + HEIGHT * 0.1, `Losses: ${score.losses}`, TEXT.HEADER);
|
this.add.text(X, Y, `Wins: ${player.score.wins}`, TEXT.HEADER);
|
||||||
|
this.add.text(X, Y + HEIGHT * 0.1, `Losses: ${player.score.losses}`, TEXT.HEADER);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
cleanUp() {
|
cleanUp() {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user