Trying to join the big leagues

This commit is contained in:
Mashy
2018-12-20 15:10:58 +10:00
parent c5d7a72fdc
commit 2cac857f2c
6 changed files with 67 additions and 27 deletions
+18 -14
View File
@@ -208,20 +208,7 @@ class CombatCryps extends Phaser.Scene {
}
if (key === 'crypStatusUpdate' && data) {
const targetCryp = this.cryps.children.entries
.find(c => c.cryp.id === data.id);
if (this.phase === 'Skill') {
targetCryp.statusText.text = data.target === targetCryp.cryp.account
? `${data.skill} on ally team`
: `${data.skill} on enemy team`;
}
if (this.phase === 'Target') {
const sourceCryp = this.cryps.children.entries
.find(c => c.cryp.id === data.skill.source_cryp_id);
targetCryp.statusText.text = `${sourceCryp.cryp.name} ${data.skill.skill} ${targetCryp.cryp.name}`;
}
this.updateCrypStatus(data);
}
return true;
@@ -260,6 +247,23 @@ class CombatCryps extends Phaser.Scene {
if (crypId) this.cryps.children.entries.find(c => c.cryp.id === crypId).select();
}
updateCrypStatus(status) {
const targetCryp = this.cryps.children.entries
.find(c => c.cryp.id === status.id);
if (this.phase === 'Skill') {
targetCryp.statusText.text = status.target === targetCryp.cryp.account
? `${status.skill} on ally team`
: `${status.skill} on enemy team`;
}
if (this.phase === 'Target') {
const sourceCryp = this.cryps.children.entries
.find(c => c.cryp.id === status.skill.source_cryp_id);
targetCryp.statusText.text = `${sourceCryp.cryp.name} ${status.skill.skill} ${targetCryp.cryp.name}`;
}
}
cleanUp() {
this.registry.events.off('changedata', this.updateData);
this.scene.remove();
-2
View File
@@ -24,8 +24,6 @@ class Combat extends Phaser.Scene {
aztecImg.onload = () => {
this.textures.addAtlas('aztec', aztecImg, aztecAtlas);
};
// this.textures.addBase64('alk', `data:image/png;base64,${new Buffer.from(fs.readFileSync('./assets/magmar.png')).toString('base64')}`);
// this.textures.addBase64('magmar', `data:image/png;base64,${new Buffer.from(fs.readFileSync('./assets/magmar.png')).toString('base64')}`);
this.load.image('proj', 'https://labs.phaser.io/assets/sprites/bullet.png');
this.load.image('blue', 'https://labs.phaser.io/assets/particles/blue.png');
this.load.image('green', 'https://labs.phaser.io/assets/particles/green.png');
+18 -1
View File
@@ -44,6 +44,16 @@ class GameList extends Phaser.GameObjects.Group {
.text(pve.getCenter().x, pve.getCenter().y, 'new PVE\ngame', TEXT.HEADER)
.setOrigin(0.5, 0.5));
const boss = list.add
.rectangle(X, GAME_LIST.y(2), WIDTH, HEIGHT, 0x441122)
.setInteractive()
.setOrigin(0);
this.add(list.add
.text(boss.getCenter().x, boss.getCenter().y, 'new Boss\ngame', TEXT.HEADER)
.setOrigin(0.5, 0.5));
const refresh = list.add
.rectangle(X + WIDTH, GAME_LIST.y(1), WIDTH, HEIGHT, 0x000044)
.setInteractive()
@@ -88,9 +98,16 @@ class GameList extends Phaser.GameObjects.Group {
pve.on('pointerdown', () => {
const team = cryps.filter(c => c.active).map(c => c.id);
if (team.length === 0) return false;
return ws.sendGamePve(team);
return ws.sendGamePve(team, 'normal');
});
boss.on('pointerdown', () => {
const team = cryps.filter(c => c.active).map(c => c.id);
if (team.length === 0) return false;
return ws.sendGamePve(team, 'boss');
});
refresh.on('pointerdown', () => {
return ws.sendGameJoinableList();
});
+2 -2
View File
@@ -64,8 +64,8 @@ function createSocket(events) {
send({ method: 'game_state', params: { id } });
}
function sendGamePve(crypIds) {
send({ method: 'game_pve', params: { cryp_ids: crypIds } });
function sendGamePve(crypIds, mode) {
send({ method: 'game_pve', params: { cryp_ids: crypIds, mode } });
}
function sendGamePvp(crypIds) {