zone mission update
This commit is contained in:
parent
28bda483f1
commit
119d4d8c9a
@ -36,7 +36,6 @@ function registerEvents(registry, events, tutorial) {
|
||||
registry.set('zone', zone);
|
||||
}
|
||||
|
||||
|
||||
function setGameList(gameList) {
|
||||
registry.set('gameList', gameList);
|
||||
}
|
||||
|
||||
@ -124,7 +124,7 @@ class MenuGameList extends Phaser.Scene {
|
||||
|
||||
zones.on('pointerdown', () => {
|
||||
this.scene.add('Missions', Missions, true);
|
||||
return ws.sendAccountZone();
|
||||
return ws.sendZoneCreate();
|
||||
});
|
||||
|
||||
|
||||
|
||||
@ -1,5 +1,4 @@
|
||||
const Phaser = require('phaser');
|
||||
const MenuGameList = require('./menu.game.list');
|
||||
|
||||
const {
|
||||
TEXT,
|
||||
@ -12,6 +11,9 @@ class MissionsControls extends Phaser.Scene {
|
||||
}
|
||||
|
||||
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 HEIGHT = GAME_LIST.height();
|
||||
|
||||
@ -26,6 +28,7 @@ class MissionsControls extends Phaser.Scene {
|
||||
|
||||
menu.on('pointerdown', () => {
|
||||
this.scene.get('Missions').cleanUp();
|
||||
this.ws.sendZoneClose(this.zone.id);
|
||||
this.cleanUp();
|
||||
});
|
||||
|
||||
|
||||
@ -18,11 +18,12 @@ class Missions extends Phaser.Scene {
|
||||
create() {
|
||||
const zone = this.registry.get('zone');
|
||||
if (!zone) return false;
|
||||
console.log(zone);
|
||||
|
||||
this.scene.manager.add('MissionControls', MissionControls, true);
|
||||
this.graphics = this.add.graphics();
|
||||
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(),
|
||||
COMBAT.width() * 0.8, COMBAT.height());
|
||||
this.addNodes(nodeData);
|
||||
@ -35,8 +36,8 @@ class Missions extends Phaser.Scene {
|
||||
addNodes(nodeData) {
|
||||
this.nodes = [];
|
||||
nodeData.forEach((n, i) => {
|
||||
this.nodes[n.id] = this.add.existing(
|
||||
new Node(this, 500, 850 + i * -100, n.id, n.success, n.tag)
|
||||
this.nodes[i] = this.add.existing(
|
||||
new Node(this, 500, 850 + i * -100, i, n.success, n.tag)
|
||||
).setInteractive();
|
||||
});
|
||||
}
|
||||
@ -76,8 +77,10 @@ class Missions extends Phaser.Scene {
|
||||
const team = this.registry.get('cryps').filter(c => c.active).map(c => c.id);
|
||||
if (team.length === 0) return false;
|
||||
|
||||
const zone = this.registry.get('zone');
|
||||
// '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();
|
||||
}
|
||||
@ -97,11 +100,11 @@ class Missions extends Phaser.Scene {
|
||||
}, 0, this);
|
||||
}
|
||||
|
||||
drawEdges(nodeData) {
|
||||
drawEdges() {
|
||||
this.graphics.clear();
|
||||
this.edgeData.forEach((e) => {
|
||||
const drawEdge = nodeData.filter(n => (
|
||||
e[0].id === n.id || e[1].id === n.id
|
||||
const drawEdge = this.nodes.filter(n => (
|
||||
e[0] === n.id || e[1] === n.id
|
||||
));
|
||||
if (drawEdge[0].success && drawEdge[1].success) {
|
||||
this.graphics.lineStyle(10, 0xfff00f, 0.2);
|
||||
|
||||
@ -108,6 +108,14 @@ function createSocket(events) {
|
||||
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
|
||||
@ -173,6 +181,8 @@ function createSocket(events) {
|
||||
account_items: accountItems,
|
||||
zone_create: res => console.log(res),
|
||||
zone_state: zoneState,
|
||||
zone_close: res => console.log(res),
|
||||
|
||||
};
|
||||
|
||||
// decodes the cbor and
|
||||
@ -250,6 +260,8 @@ function createSocket(events) {
|
||||
sendCrypForget,
|
||||
sendItemUse,
|
||||
sendZoneCreate,
|
||||
sendZoneJoin,
|
||||
sendZoneClose,
|
||||
connect,
|
||||
};
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user