zone mission update

This commit is contained in:
Mashy 2018-12-30 14:25:22 +10:00
parent 28bda483f1
commit 119d4d8c9a
5 changed files with 27 additions and 10 deletions

View File

@ -36,7 +36,6 @@ function registerEvents(registry, events, tutorial) {
registry.set('zone', zone); registry.set('zone', zone);
} }
function setGameList(gameList) { function setGameList(gameList) {
registry.set('gameList', gameList); registry.set('gameList', gameList);
} }

View File

@ -124,7 +124,7 @@ class MenuGameList extends Phaser.Scene {
zones.on('pointerdown', () => { zones.on('pointerdown', () => {
this.scene.add('Missions', Missions, true); this.scene.add('Missions', Missions, true);
return ws.sendAccountZone(); return ws.sendZoneCreate();
}); });

View File

@ -1,5 +1,4 @@
const Phaser = require('phaser'); const Phaser = require('phaser');
const MenuGameList = require('./menu.game.list');
const { const {
TEXT, TEXT,
@ -12,6 +11,9 @@ class MissionsControls extends Phaser.Scene {
} }
create() { create() {
this.ws = this.registry.get('ws');
this.zone = this.registry.get('zone');
console.log(this.registry.get('account'));
const WIDTH = Math.floor(GAME_LIST.width() / 2); const WIDTH = Math.floor(GAME_LIST.width() / 2);
const HEIGHT = GAME_LIST.height(); const HEIGHT = GAME_LIST.height();
@ -26,6 +28,7 @@ class MissionsControls extends Phaser.Scene {
menu.on('pointerdown', () => { menu.on('pointerdown', () => {
this.scene.get('Missions').cleanUp(); this.scene.get('Missions').cleanUp();
this.ws.sendZoneClose(this.zone.id);
this.cleanUp(); this.cleanUp();
}); });

View File

@ -18,11 +18,12 @@ class Missions extends Phaser.Scene {
create() { create() {
const zone = this.registry.get('zone'); const zone = this.registry.get('zone');
if (!zone) return false; if (!zone) return false;
console.log(zone);
this.scene.manager.add('MissionControls', MissionControls, true); this.scene.manager.add('MissionControls', MissionControls, true);
this.graphics = this.add.graphics(); this.graphics = this.add.graphics();
const nodeData = zone.graph.nodes; const nodeData = zone.graph.nodes;
this.edgeData = zone.graph.edges.map(x => x.map(y => nodeData[y])); this.edgeData = zone.graph.edges;
this.cameras.main.setViewport(COMBAT.width() * 0.2, COMBAT.y(), this.cameras.main.setViewport(COMBAT.width() * 0.2, COMBAT.y(),
COMBAT.width() * 0.8, COMBAT.height()); COMBAT.width() * 0.8, COMBAT.height());
this.addNodes(nodeData); this.addNodes(nodeData);
@ -35,8 +36,8 @@ class Missions extends Phaser.Scene {
addNodes(nodeData) { addNodes(nodeData) {
this.nodes = []; this.nodes = [];
nodeData.forEach((n, i) => { nodeData.forEach((n, i) => {
this.nodes[n.id] = this.add.existing( this.nodes[i] = this.add.existing(
new Node(this, 500, 850 + i * -100, n.id, n.success, n.tag) new Node(this, 500, 850 + i * -100, i, n.success, n.tag)
).setInteractive(); ).setInteractive();
}); });
} }
@ -76,8 +77,10 @@ class Missions extends Phaser.Scene {
const team = this.registry.get('cryps').filter(c => c.active).map(c => c.id); const team = this.registry.get('cryps').filter(c => c.active).map(c => c.id);
if (team.length === 0) return false; if (team.length === 0) return false;
const zone = this.registry.get('zone');
// 'Boss' to be replaced with node id for RPC call // 'Boss' to be replaced with node id for RPC call
this.registry.get('ws').sendGamePve(team, 'Boss'); if (gameObjects[0].success) return false;
this.registry.get('ws').sendZoneJoin(zone.id, gameObjects[0].id, team);
this.cleanUp(); this.cleanUp();
} }
@ -97,11 +100,11 @@ class Missions extends Phaser.Scene {
}, 0, this); }, 0, this);
} }
drawEdges(nodeData) { drawEdges() {
this.graphics.clear(); this.graphics.clear();
this.edgeData.forEach((e) => { this.edgeData.forEach((e) => {
const drawEdge = nodeData.filter(n => ( const drawEdge = this.nodes.filter(n => (
e[0].id === n.id || e[1].id === n.id e[0] === n.id || e[1] === n.id
)); ));
if (drawEdge[0].success && drawEdge[1].success) { if (drawEdge[0].success && drawEdge[1].success) {
this.graphics.lineStyle(10, 0xfff00f, 0.2); this.graphics.lineStyle(10, 0xfff00f, 0.2);

View File

@ -108,6 +108,14 @@ function createSocket(events) {
send({ method: 'zone_create', params: {} }); send({ method: 'zone_create', params: {} });
} }
function sendZoneJoin(zoneId, nodeId, crypIds) {
send({ method: 'zone_join', params: { zone_id: zoneId, node_id: nodeId, cryp_ids: crypIds } });
}
function sendZoneClose(zoneId) {
send({ method: 'zone_close', params: { zone_id: zoneId } });
}
// ------------- // -------------
// Incoming // Incoming
@ -173,6 +181,8 @@ function createSocket(events) {
account_items: accountItems, account_items: accountItems,
zone_create: res => console.log(res), zone_create: res => console.log(res),
zone_state: zoneState, zone_state: zoneState,
zone_close: res => console.log(res),
}; };
// decodes the cbor and // decodes the cbor and
@ -250,6 +260,8 @@ function createSocket(events) {
sendCrypForget, sendCrypForget,
sendItemUse, sendItemUse,
sendZoneCreate, sendZoneCreate,
sendZoneJoin,
sendZoneClose,
connect, connect,
}; };
} }