Merge branch 'master' of ssh://cryps.gg:40022/~/cryps
This commit is contained in:
commit
629c5f373e
@ -7,29 +7,32 @@ const CANVAS_HEIGHT = () => Math.floor(window.innerHeight);
|
|||||||
const headerWidth = () => CANVAS_WIDTH();
|
const headerWidth = () => CANVAS_WIDTH();
|
||||||
const headerHeight = () => Math.floor(CANVAS_HEIGHT() * 0.05);
|
const headerHeight = () => Math.floor(CANVAS_HEIGHT() * 0.05);
|
||||||
|
|
||||||
|
|
||||||
const menuCrypListWidth = () => Math.floor(CANVAS_WIDTH() * 0.3);
|
const menuCrypListWidth = () => Math.floor(CANVAS_WIDTH() * 0.3);
|
||||||
const menuCrypListHeight = () => Math.floor(CANVAS_HEIGHT() * 0.5);
|
const menuCrypListHeight = () => Math.floor(CANVAS_HEIGHT() * 0.5);
|
||||||
const menuCrypListX = () => 0;
|
const menuCrypListX = () => Math.floor(CANVAS_WIDTH() * 0.3);
|
||||||
const menuCrypListY = () => headerHeight();
|
const menuCrypListY = () => headerHeight();
|
||||||
|
|
||||||
const itemListWidth = () => Math.floor(CANVAS_WIDTH() * 0.5);
|
const itemListWidth = () => Math.floor(CANVAS_WIDTH() * 0.5);
|
||||||
const itemListHeight = () => Math.floor(CANVAS_HEIGHT() * 0.5);
|
const itemListHeight = () => Math.floor(CANVAS_HEIGHT() * 0.95);
|
||||||
const itemListX = () => 0;
|
const itemListX = () => 0;
|
||||||
const itemListY = () => Math.floor(CANVAS_HEIGHT() * 0.5);
|
const itemListY = () => headerHeight();
|
||||||
const itemBlockWidth = () => Math.floor(itemListWidth() * 0.075);
|
const itemBlockWidth = () => Math.floor(itemListWidth() * 0.12);
|
||||||
const itemBlockHeight = () => Math.floor(itemListHeight() * 0.12);
|
const itemBlockHeight = () => Math.floor(itemListHeight() * 0.04);
|
||||||
|
|
||||||
const menuNavigationWidth = () => Math.floor(CANVAS_WIDTH() * 0.5);
|
const menuNavigationWidth = () => Math.floor(CANVAS_WIDTH() * 0.5);
|
||||||
const menuNavigationHeight = () => Math.floor(CANVAS_HEIGHT() * 0.3);
|
const menuNavigationHeight = () => Math.floor(CANVAS_HEIGHT() * 0.3);
|
||||||
const menuNavigationX = () => Math.floor(CANVAS_WIDTH() * 0.5);
|
const menuNavigationX = () => Math.floor(CANVAS_WIDTH() * 0.5);
|
||||||
const menuNavigationY = () => Math.floor(CANVAS_HEIGHT() * 0.7);
|
const menuNavigationY = () => Math.floor(CANVAS_HEIGHT() * 0.7);
|
||||||
|
|
||||||
const menuMainWidth = () => Math.floor(CANVAS_WIDTH() * 0.7);
|
const menuMainWidth = () => Math.floor(CANVAS_WIDTH() * 0.4);
|
||||||
const menuMainHeight = () => Math.floor(CANVAS_HEIGHT() * 0.5);
|
const menuMainHeight = () => Math.floor(CANVAS_HEIGHT() * 0.5);
|
||||||
const menuMainX = () => Math.floor(CANVAS_WIDTH() * 0.4);
|
const menuMainX = () => Math.floor(CANVAS_WIDTH() * 0.6);
|
||||||
const menuMainY = () => headerHeight();
|
const menuMainY = () => headerHeight();
|
||||||
|
|
||||||
|
const homeMainWidth = () => Math.floor(CANVAS_WIDTH() * 0.6);
|
||||||
|
const homeMainHeight = () => Math.floor(CANVAS_HEIGHT() * 0.5);
|
||||||
|
const homeMainX = () => Math.floor(CANVAS_WIDTH() * 0.4);
|
||||||
|
const homeMainY = () => headerHeight();
|
||||||
|
|
||||||
const combatWidth = () => CANVAS_WIDTH();
|
const combatWidth = () => CANVAS_WIDTH();
|
||||||
const combatHeight = () => CANVAS_HEIGHT() - headerHeight();
|
const combatHeight = () => CANVAS_HEIGHT() - headerHeight();
|
||||||
@ -82,6 +85,15 @@ module.exports = {
|
|||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
|
HOME_MAIN: {
|
||||||
|
x: homeMainX,
|
||||||
|
y: homeMainY,
|
||||||
|
width: homeMainWidth,
|
||||||
|
height: homeMainHeight,
|
||||||
|
|
||||||
|
},
|
||||||
|
|
||||||
|
|
||||||
NAVIGATION: {
|
NAVIGATION: {
|
||||||
x: menuNavigationX,
|
x: menuNavigationX,
|
||||||
y: menuNavigationY,
|
y: menuNavigationY,
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
const Phaser = require('phaser');
|
const Phaser = require('phaser');
|
||||||
|
const fs = require('fs');
|
||||||
|
|
||||||
const { TEXT } = require('./constants');
|
const { TEXT } = require('./constants');
|
||||||
const fs = require('fs');
|
|
||||||
|
|
||||||
const aztecAtlas = require('../../assets/aztec.atlas.json');
|
const aztecAtlas = require('../../assets/aztec.atlas.json');
|
||||||
|
|
||||||
|
|||||||
@ -1,10 +1,12 @@
|
|||||||
const Phaser = require('phaser');
|
const Phaser = require('phaser');
|
||||||
const { POSITIONS: { MENU_MAIN }, TEXT } = require('./constants');
|
const { POSITIONS: { HOME_MAIN }, TEXT } = require('./constants');
|
||||||
|
|
||||||
const X = MENU_MAIN.x();
|
const X = HOME_MAIN.x();
|
||||||
const Y = MENU_MAIN.y();
|
const Y = HOME_MAIN.y();
|
||||||
const WIDTH = MENU_MAIN.width();
|
const WIDTH = HOME_MAIN.width();
|
||||||
const HEIGHT = MENU_MAIN.height();
|
const HEIGHT = HOME_MAIN.height();
|
||||||
|
|
||||||
|
const NULL_UUID = '00000000-0000-0000-0000-000000000000';
|
||||||
|
|
||||||
class HomeRankings extends Phaser.Scene {
|
class HomeRankings extends Phaser.Scene {
|
||||||
constructor() {
|
constructor() {
|
||||||
@ -20,10 +22,17 @@ class HomeRankings extends Phaser.Scene {
|
|||||||
.setInteractive()
|
.setInteractive()
|
||||||
.setOrigin(0)
|
.setOrigin(0)
|
||||||
.on('pointerdown', () => {
|
.on('pointerdown', () => {
|
||||||
|
if (player.ready) {
|
||||||
|
this.registry.set('player', player);
|
||||||
|
this.registry.get('ws').sendInstanceReady(player.instance);
|
||||||
|
} else {
|
||||||
this.game.events.emit('SET_PLAYER', player);
|
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);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -1,10 +1,10 @@
|
|||||||
const Phaser = require('phaser');
|
const Phaser = require('phaser');
|
||||||
const { POSITIONS: { MENU_MAIN }, TEXT } = require('./constants');
|
const { POSITIONS: { HOME_MAIN }, TEXT } = require('./constants');
|
||||||
|
|
||||||
const X = MENU_MAIN.x();
|
const X = HOME_MAIN.x();
|
||||||
const Y = MENU_MAIN.y();
|
const Y = HOME_MAIN.y();
|
||||||
const WIDTH = MENU_MAIN.width();
|
const WIDTH = HOME_MAIN.width();
|
||||||
const HEIGHT = MENU_MAIN.height();
|
const HEIGHT = HOME_MAIN.height();
|
||||||
|
|
||||||
class HomeNews extends Phaser.Scene {
|
class HomeNews extends Phaser.Scene {
|
||||||
constructor() {
|
constructor() {
|
||||||
|
|||||||
@ -1,10 +1,10 @@
|
|||||||
const Phaser = require('phaser');
|
const Phaser = require('phaser');
|
||||||
const { POSITIONS: { MENU_MAIN }, TEXT } = require('./constants');
|
const { POSITIONS: { HOME_MAIN }, TEXT } = require('./constants');
|
||||||
|
|
||||||
const X = MENU_MAIN.x();
|
const X = HOME_MAIN.x();
|
||||||
const Y = MENU_MAIN.y();
|
const Y = HOME_MAIN.y();
|
||||||
const WIDTH = MENU_MAIN.width();
|
const WIDTH = HOME_MAIN.width();
|
||||||
const HEIGHT = MENU_MAIN.height();
|
const HEIGHT = HOME_MAIN.height();
|
||||||
|
|
||||||
class HomeRankings extends Phaser.Scene {
|
class HomeRankings extends Phaser.Scene {
|
||||||
constructor() {
|
constructor() {
|
||||||
|
|||||||
@ -1,9 +1,10 @@
|
|||||||
const Phaser = require('phaser');
|
const Phaser = require('phaser');
|
||||||
const { POSITIONS: { MENU_MAIN }, TEXT } = require('./constants');
|
const { POSITIONS: { HOME_MAIN }, TEXT } = require('./constants');
|
||||||
|
|
||||||
const X = MENU_MAIN.x();
|
const X = HOME_MAIN.x();
|
||||||
const Y = MENU_MAIN.y();
|
const Y = HOME_MAIN.y();
|
||||||
const HEIGHT = MENU_MAIN.height();
|
const WIDTH = HOME_MAIN.width();
|
||||||
|
const HEIGHT = HOME_MAIN.height();
|
||||||
|
|
||||||
class HomeShop extends Phaser.Scene {
|
class HomeShop extends Phaser.Scene {
|
||||||
constructor() {
|
constructor() {
|
||||||
|
|||||||
56
client/src/scenes/item.list.js
Normal file → Executable file
56
client/src/scenes/item.list.js
Normal file → Executable file
@ -14,21 +14,20 @@ const HEIGHT = ITEM_LIST.height();
|
|||||||
const ITEM_WIDTH = ITEM_LIST.itemWidth();
|
const ITEM_WIDTH = ITEM_LIST.itemWidth();
|
||||||
const ITEM_HEIGHT = ITEM_LIST.itemHeight();
|
const ITEM_HEIGHT = ITEM_LIST.itemHeight();
|
||||||
|
|
||||||
const INV_X = X + ITEM_WIDTH * 0.325;
|
const BOX_X = X + ITEM_WIDTH * 0.5;
|
||||||
const INV_Y = Y + ITEM_HEIGHT;
|
const BOX_Y = Y + ITEM_HEIGHT + ITEM_HEIGHT * 2;
|
||||||
|
const BOX_ROWS = 6;
|
||||||
|
const BOX_COLUMNS = 3;
|
||||||
|
|
||||||
|
const INV_X = X + ITEM_WIDTH * 0.5;
|
||||||
|
const INV_Y = Y + ITEM_HEIGHT * 12;
|
||||||
const INV_ROWS = 3;
|
const INV_ROWS = 3;
|
||||||
const INV_COLUMNS = 3;
|
const INV_COLUMNS = 3;
|
||||||
|
|
||||||
const COMB_X = INV_X + ITEM_WIDTH * 5.75;
|
const COMB_X = X + ITEM_WIDTH * 0.5;
|
||||||
const COMB_Y = INV_Y;
|
const COMB_Y = Y + ITEM_HEIGHT * 19;
|
||||||
const COMB_ROWS = 2;
|
const COMB_ROWS = 1;
|
||||||
const COMB_COLUMNS = 2;
|
const COMB_COLUMNS = 3;
|
||||||
|
|
||||||
const BOX_X = X + ITEM_WIDTH * 2;
|
|
||||||
const BOX_Y = Y + ITEM_HEIGHT * 5;
|
|
||||||
const BOX_ROWS = 3;
|
|
||||||
const BOX_COLUMNS = 6;
|
|
||||||
|
|
||||||
|
|
||||||
const drawVbox = (graphics) => {
|
const drawVbox = (graphics) => {
|
||||||
const boxDrawX = BOX_X - ITEM_WIDTH * 0.05;
|
const boxDrawX = BOX_X - ITEM_WIDTH * 0.05;
|
||||||
@ -95,10 +94,10 @@ class CombinerHitBox extends Phaser.GameObjects.Rectangle {
|
|||||||
|
|
||||||
class DeleteHitBox extends Phaser.GameObjects.Rectangle {
|
class DeleteHitBox extends Phaser.GameObjects.Rectangle {
|
||||||
constructor(scene, x, y) {
|
constructor(scene, x, y) {
|
||||||
super(scene, x, y, ITEM_WIDTH * 1.25, ITEM_HEIGHT * 1.25, 0x222222);
|
super(scene, x, y, ITEM_WIDTH * 3.4, ITEM_HEIGHT * 1.25, 0x444444);
|
||||||
this.setOrigin(0);
|
this.setOrigin(0);
|
||||||
this.itemSelect = () => this.setFillStyle(0xff0000);
|
this.itemSelect = () => this.setFillStyle(0xff0000);
|
||||||
this.itemDeselect = () => this.setFillStyle(0x222222);
|
this.itemDeselect = () => this.setFillStyle(0x444444);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -134,11 +133,12 @@ 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;
|
||||||
this.combinerItems = this.registry.get('combinerItems');
|
|
||||||
if (!this.combinerItems || vbox.bound.length < this.registry.get('boundLength')) {
|
if (!this.combinerItems || vbox.bound.length < this.registry.get('boundLength')) {
|
||||||
this.combinerItems = [-1, -1, -1];
|
this.combinerItems = [-1, -1, -1];
|
||||||
}
|
}
|
||||||
@ -152,20 +152,22 @@ class ItemList extends Phaser.Scene {
|
|||||||
drawInventory(graphics);
|
drawInventory(graphics);
|
||||||
drawVbox(graphics);
|
drawVbox(graphics);
|
||||||
|
|
||||||
this.add.text(X + WIDTH * 0.1, Y, 'inventory', TEXT.HEADER);
|
this.add.text(X + ITEM_WIDTH * 0.5, Y + ITEM_HEIGHT * 0.5, `vBox - ${vbox.bits}b`, TEXT.HEADER);
|
||||||
this.add.text(X + WIDTH * 0.47, Y, 'iCombinator', TEXT.HEADER);
|
this.add.text(X + ITEM_WIDTH * 0.5, Y + ITEM_HEIGHT * 11, 'inventory', TEXT.HEADER);
|
||||||
this.add.text(X + WIDTH * 0.35, Y + HEIGHT / 2, `vBox - ${vbox.bits}b`, TEXT.HEADER);
|
this.add.text(X + ITEM_WIDTH * 0.5, Y + ITEM_HEIGHT * 18, 'iCombinator', TEXT.HEADER);
|
||||||
|
this.add.text(X + ITEM_WIDTH * 0.5, Y + ITEM_HEIGHT * 23, `Wins: ${player.score.wins}`, TEXT.HEADER);
|
||||||
|
this.add.text(X + ITEM_WIDTH * 0.5, Y + ITEM_HEIGHT * 24, `Losses: ${player.score.losses}`, TEXT.HEADER);
|
||||||
|
|
||||||
const reroll = this.add
|
const reroll = this.add
|
||||||
.rectangle(WIDTH * 0.01, Y + HEIGHT * 0.775, ITEM_WIDTH * 1.25, ITEM_HEIGHT * 1.25, 0x222222)
|
.rectangle(X + ITEM_WIDTH * 0.4, Y + ITEM_HEIGHT * 1.5, ITEM_WIDTH * 3.4, ITEM_HEIGHT * 1.25, 0x444444)
|
||||||
.setInteractive()
|
.setInteractive()
|
||||||
.setOrigin(0)
|
.setOrigin(0)
|
||||||
.on('pointerdown', () => this.registry.get('ws').sendVboxDiscard(vbox.instance));
|
.on('pointerdown', () => this.registry.get('ws').sendVboxDiscard(vbox.instance));
|
||||||
this.add.text(reroll.getCenter().x, reroll.getCenter().y, 'Reroll', TEXT.HEADER)
|
this.add.text(reroll.getCenter().x, reroll.getCenter().y, 'Reroll - $0 cost', TEXT.HEADER)
|
||||||
.setOrigin(0.5, 0.5);
|
.setOrigin(0.5, 0.5);
|
||||||
|
|
||||||
const combine = this.add
|
const combine = this.add
|
||||||
.rectangle(ITEM_WIDTH * 1.1 + COMB_X, ITEM_HEIGHT * 1.1 + COMB_Y, ITEM_WIDTH, ITEM_HEIGHT, 0x222222)
|
.rectangle(X + ITEM_WIDTH * 0.4, Y + ITEM_HEIGHT * 20.25, ITEM_WIDTH * 3.4, ITEM_HEIGHT * 1.25, 0x444444)
|
||||||
.setInteractive()
|
.setInteractive()
|
||||||
.setOrigin(0)
|
.setOrigin(0)
|
||||||
.on('pointerdown', () => {
|
.on('pointerdown', () => {
|
||||||
@ -173,7 +175,7 @@ class ItemList extends Phaser.Scene {
|
|||||||
this.combinerItems = [-1, -1, -1];
|
this.combinerItems = [-1, -1, -1];
|
||||||
this.children.list.filter(obj => obj instanceof CombinerHitBox).forEach(cBox => cBox.deallocate());
|
this.children.list.filter(obj => obj instanceof CombinerHitBox).forEach(cBox => cBox.deallocate());
|
||||||
});
|
});
|
||||||
this.add.text(combine.getCenter().x, combine.getCenter().y, 'C', TEXT.HEADER)
|
this.add.text(combine.getCenter().x, combine.getCenter().y, 'Combine', TEXT.HEADER)
|
||||||
.setOrigin(0.5, 0.5);
|
.setOrigin(0.5, 0.5);
|
||||||
|
|
||||||
for (let i = 0; i < 3; i += 1) {
|
for (let i = 0; i < 3; i += 1) {
|
||||||
@ -181,8 +183,8 @@ class ItemList extends Phaser.Scene {
|
|||||||
const ITEM_Y = ITEM_HEIGHT * 1.1 * Math.floor(i / COMB_COLUMNS) + COMB_Y;
|
const ITEM_Y = ITEM_HEIGHT * 1.1 * Math.floor(i / COMB_COLUMNS) + COMB_Y;
|
||||||
this.add.existing(new CombinerHitBox(this, ITEM_X, ITEM_Y, i));
|
this.add.existing(new CombinerHitBox(this, ITEM_X, ITEM_Y, i));
|
||||||
}
|
}
|
||||||
const del = this.add.existing(new DeleteHitBox(this, WIDTH * 0.01, Y + HEIGHT * 0.6));
|
const del = this.add.existing(new DeleteHitBox(this, X + ITEM_WIDTH * 0.4, Y + ITEM_HEIGHT * 15.5));
|
||||||
this.add.text(del.getCenter().x, del.getCenter().y, 'Del', TEXT.HEADER)
|
this.add.text(del.getCenter().x, del.getCenter().y, 'Sell', TEXT.HEADER)
|
||||||
.setOrigin(0.5, 0.5);
|
.setOrigin(0.5, 0.5);
|
||||||
|
|
||||||
// Generate Items
|
// Generate Items
|
||||||
@ -199,8 +201,8 @@ class ItemList extends Phaser.Scene {
|
|||||||
|
|
||||||
vbox.free.forEach((type, i) => {
|
vbox.free.forEach((type, i) => {
|
||||||
type.forEach((item, j) => {
|
type.forEach((item, j) => {
|
||||||
const ITEM_X = ITEM_WIDTH * 1.1 * j + BOX_X + ITEM_WIDTH * 0.5;
|
const ITEM_X = ITEM_WIDTH * 1.1 * i + BOX_X + ITEM_WIDTH * 0.5;
|
||||||
const ITEM_Y = ITEM_HEIGHT * 1.1 * i + BOX_Y + ITEM_HEIGHT * 0.5;
|
const ITEM_Y = ITEM_HEIGHT * 1.1 * j + BOX_Y + ITEM_HEIGHT * 0.5;
|
||||||
const clickFn = () => {
|
const clickFn = () => {
|
||||||
this.registry.set('itemInfo', item);
|
this.registry.set('itemInfo', item);
|
||||||
ws.sendVboxAccept(vbox.instance, i, j);
|
ws.sendVboxAccept(vbox.instance, i, j);
|
||||||
|
|||||||
@ -3,8 +3,8 @@ const Phaser = require('phaser');
|
|||||||
const { TEXT, COLOURS, POSITIONS: { CRYP_LIST } } = require('./constants');
|
const { TEXT, COLOURS, POSITIONS: { CRYP_LIST } } = require('./constants');
|
||||||
const genAvatar = require('./avatar');
|
const genAvatar = require('./avatar');
|
||||||
|
|
||||||
const ROW_HEIGHT = CRYP_LIST.height() * 0.2;
|
const BOX_WIDTH = Math.floor(CRYP_LIST.width() / 5);
|
||||||
const ROW_WIDTH = CRYP_LIST.width();
|
const BOX_HEIGHT = Math.floor(CRYP_LIST.height() / 5);
|
||||||
|
|
||||||
const TEXT_MARGIN = 24;
|
const TEXT_MARGIN = 24;
|
||||||
|
|
||||||
@ -23,13 +23,12 @@ 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) {
|
||||||
if (key === 'player') {
|
if (key === 'player') {
|
||||||
console.log(data.cryps);
|
|
||||||
// KEY_MAP.forEach(k => this.input.keyboard.removeListener(k));
|
|
||||||
this.drawCryps(data.cryps);
|
this.drawCryps(data.cryps);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -39,9 +38,8 @@ class MenuCrypList extends Phaser.Scene {
|
|||||||
if (this.crypGroup) this.crypGroup.destroy(true);
|
if (this.crypGroup) this.crypGroup.destroy(true);
|
||||||
this.crypGroup = this.add.group();
|
this.crypGroup = this.add.group();
|
||||||
const addCryp = (cryp, i) => {
|
const addCryp = (cryp, i) => {
|
||||||
const BOX_WIDTH = Math.floor(ROW_WIDTH / 5);
|
const ROW_X = CRYP_LIST.x();
|
||||||
const ROW_X = i * BOX_WIDTH * 2;
|
const ROW_Y = CRYP_LIST.y() + BOX_HEIGHT * i * 3;
|
||||||
const ROW_Y = CRYP_LIST.y();
|
|
||||||
|
|
||||||
|
|
||||||
const ACTIVE_FILL = cryp.active
|
const ACTIVE_FILL = cryp.active
|
||||||
@ -56,7 +54,7 @@ class MenuCrypList extends Phaser.Scene {
|
|||||||
|
|
||||||
// Cryp avatar and interaction box
|
// Cryp avatar and interaction box
|
||||||
const crypInteract = this.add
|
const crypInteract = this.add
|
||||||
.rectangle(ROW_X, ROW_Y + ROW_HEIGHT * 2.5, BOX_WIDTH * 2, ROW_HEIGHT, FILL, ACTIVE_FILL)
|
.rectangle(ROW_X, ROW_Y + BOX_HEIGHT * 2, BOX_WIDTH * 4, BOX_HEIGHT * 0.5, FILL, ACTIVE_FILL)
|
||||||
.setInteractive()
|
.setInteractive()
|
||||||
.setOrigin(0)
|
.setOrigin(0)
|
||||||
.on('pointerdown', selectFn);
|
.on('pointerdown', selectFn);
|
||||||
@ -68,15 +66,9 @@ class MenuCrypList extends Phaser.Scene {
|
|||||||
};
|
};
|
||||||
crypInteract.cryp = cryp;
|
crypInteract.cryp = cryp;
|
||||||
|
|
||||||
const crypImage = this.add.image(
|
|
||||||
crypInteract.getCenter().x,
|
|
||||||
crypInteract.getCenter().y,
|
|
||||||
'aztec',
|
|
||||||
genAvatar(cryp.name)
|
|
||||||
);
|
|
||||||
// Cryp information box (names + skills)
|
// Cryp information box (names + skills)
|
||||||
const crypInfo = this.add
|
const crypInfo = this.add
|
||||||
.rectangle(ROW_X, ROW_Y, BOX_WIDTH * 2, ROW_HEIGHT * 2.5, FILL, ACTIVE_FILL)
|
.rectangle(ROW_X, ROW_Y, BOX_WIDTH * 4, BOX_HEIGHT * 2, FILL, ACTIVE_FILL)
|
||||||
.setOrigin(0)
|
.setOrigin(0)
|
||||||
.setInteractive()
|
.setInteractive()
|
||||||
.on('pointerdown', selectFn);
|
.on('pointerdown', selectFn);
|
||||||
@ -84,7 +76,14 @@ class MenuCrypList extends Phaser.Scene {
|
|||||||
const crypInfoText = this.add.text(crypInfo.getCenter().x, crypInfo.y + TEXT_MARGIN, cryp.name, TEXT.HEADER)
|
const crypInfoText = this.add.text(crypInfo.getCenter().x, crypInfo.y + TEXT_MARGIN, cryp.name, TEXT.HEADER)
|
||||||
.setOrigin(0.5, 0.5);
|
.setOrigin(0.5, 0.5);
|
||||||
|
|
||||||
this.crypGroup.addMultiple([crypInteract, crypImage, crypInfo, crypInfoText])
|
const crypImage = this.add.image(
|
||||||
|
crypInfo.getCenter().x + crypInfo.width / 4,
|
||||||
|
crypInfo.getCenter().y,
|
||||||
|
'aztec',
|
||||||
|
genAvatar(cryp.name)
|
||||||
|
);
|
||||||
|
|
||||||
|
this.crypGroup.addMultiple([crypInteract, crypImage, crypInfo, crypInfoText]);
|
||||||
|
|
||||||
const crypGems = (stat, j) => {
|
const crypGems = (stat, j) => {
|
||||||
// Placeholder for when gems are implemented
|
// Placeholder for when gems are implemented
|
||||||
@ -94,16 +93,16 @@ class MenuCrypList extends Phaser.Scene {
|
|||||||
this.crypGroup.add(gemText);
|
this.crypGroup.add(gemText);
|
||||||
};
|
};
|
||||||
|
|
||||||
const CRYP_GEMS = [
|
/* const CRYP_GEMS = [
|
||||||
'Red',
|
'Red',
|
||||||
'Green',
|
'Green',
|
||||||
'Blue',
|
'Blue',
|
||||||
];
|
];
|
||||||
CRYP_GEMS.forEach(crypGems);
|
CRYP_GEMS.forEach(crypGems);
|
||||||
|
*/
|
||||||
const crypSkill = (stat, j) => {
|
const crypSkill = (stat, j) => {
|
||||||
const skillText = this.add
|
const skillText = this.add
|
||||||
.text(crypInfo.getCenter().x, crypInfo.y + TEXT_MARGIN * (6 + j), `${stat.skill}`, TEXT.NORMAL)
|
.text(crypInfo.getCenter().x - crypInfo.width / 4, crypInfo.y + TEXT_MARGIN * (3 + j), `${stat.skill}`, TEXT.NORMAL)
|
||||||
.setOrigin(0.5, 0.5);
|
.setOrigin(0.5, 0.5);
|
||||||
this.crypGroup.add(skillText);
|
this.crypGroup.add(skillText);
|
||||||
};
|
};
|
||||||
|
|||||||
@ -3,7 +3,6 @@ const Phaser = require('phaser');
|
|||||||
// Scenes constantly showing
|
// Scenes constantly showing
|
||||||
const MenuCrypList = require('./menu.cryps.list');
|
const MenuCrypList = require('./menu.cryps.list');
|
||||||
const MenuNavigation = require('./menu.navigation');
|
const MenuNavigation = require('./menu.navigation');
|
||||||
const MenuScore = require('./menu.score');
|
|
||||||
const ItemList = require('./item.list');
|
const ItemList = require('./item.list');
|
||||||
// Scenes which change depending on menu context
|
// Scenes which change depending on menu context
|
||||||
const Zones = require('./zones');
|
const Zones = require('./zones');
|
||||||
@ -15,7 +14,6 @@ const FIXED_MENU_SCENES = [
|
|||||||
'MenuCrypList',
|
'MenuCrypList',
|
||||||
'MenuNavigation',
|
'MenuNavigation',
|
||||||
'ItemList',
|
'ItemList',
|
||||||
'MenuScore',
|
|
||||||
];
|
];
|
||||||
|
|
||||||
const MAIN_MENU_SCENES = [
|
const MAIN_MENU_SCENES = [
|
||||||
@ -34,17 +32,16 @@ class Menu extends Phaser.Scene {
|
|||||||
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);
|
||||||
|
|
||||||
|
// Request the latest player state when we load the scene
|
||||||
|
const player = this.registry.get('player');
|
||||||
|
this.registry.get('ws').sendPlayerState(player.instance);
|
||||||
// When we load the menu request the latest items
|
// When we load the menu request the latest items
|
||||||
// Item list will restart when the data comes in
|
// Item list will restart when the data comes in
|
||||||
this.scene.manager.add('MenuCrypList', MenuCrypList, true);
|
this.scene.manager.add('MenuCrypList', MenuCrypList, true);
|
||||||
this.scene.manager.add('MenuNavigation', MenuNavigation, true);
|
this.scene.manager.add('MenuNavigation', MenuNavigation, true);
|
||||||
this.scene.manager.add('MenuScore', MenuScore, true);
|
|
||||||
this.scene.manager.add('ItemList', ItemList, true);
|
this.scene.manager.add('ItemList', ItemList, true);
|
||||||
this.registry.set('inMenu', true);
|
this.registry.set('inMenu', true);
|
||||||
|
|
||||||
// Request the latest player state when we load the scene
|
|
||||||
const { instance } = this.registry.get('player');
|
|
||||||
this.registry.get('ws').sendPlayerState(instance);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,24 +0,0 @@
|
|||||||
const Phaser = require('phaser');
|
|
||||||
const { POSITIONS: { NAVIGATION }, TEXT } = require('./constants');
|
|
||||||
|
|
||||||
const X = NAVIGATION.x();
|
|
||||||
const Y = NAVIGATION.y();
|
|
||||||
const HEIGHT = NAVIGATION.height();
|
|
||||||
|
|
||||||
class MenuScore extends Phaser.Scene {
|
|
||||||
constructor() {
|
|
||||||
super({ key: 'MenuScore' });
|
|
||||||
}
|
|
||||||
|
|
||||||
create() {
|
|
||||||
const { score } = this.registry.get('player');
|
|
||||||
this.add.text(X, Y, `Wins: ${score.wins}`, TEXT.HEADER);
|
|
||||||
this.add.text(X, Y + HEIGHT * 0.1, `Losses: ${score.losses}`, TEXT.HEADER);
|
|
||||||
}
|
|
||||||
|
|
||||||
cleanUp() {
|
|
||||||
this.scene.remove();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
module.exports = MenuScore;
|
|
||||||
@ -79,7 +79,7 @@ class StatSheet extends Phaser.Scene {
|
|||||||
CRYP_STATS.forEach(crypStat);
|
CRYP_STATS.forEach(crypStat);
|
||||||
this.add.text(X + WIDTH * 0.175, Y, 'Skills', TEXT.HEADER);
|
this.add.text(X + WIDTH * 0.175, Y, 'Skills', TEXT.HEADER);
|
||||||
const knownSkill = (skill, i) => {
|
const knownSkill = (skill, i) => {
|
||||||
const SKILL_X = X + WIDTH * 0.21 + WIDTH * 0.125 * i;
|
const SKILL_X = X + WIDTH * 0.4 + WIDTH * 0.125 * i;
|
||||||
const SKILL_Y = Y + HEIGHT * 0.15;
|
const SKILL_Y = Y + HEIGHT * 0.15;
|
||||||
const itemObj = new Item(this, skill.skill, i, SKILL_X, SKILL_Y, SKILL_WIDTH, Math.floor(SKILL_WIDTH / 2));
|
const itemObj = new Item(this, skill.skill, i, SKILL_X, SKILL_Y, SKILL_WIDTH, Math.floor(SKILL_WIDTH / 2));
|
||||||
// itemObj.on('pointerdown', () => );
|
// itemObj.on('pointerdown', () => );
|
||||||
@ -87,11 +87,11 @@ class StatSheet extends Phaser.Scene {
|
|||||||
this.add.existing(itemObj);
|
this.add.existing(itemObj);
|
||||||
};
|
};
|
||||||
cryp.skills.forEach(knownSkill);
|
cryp.skills.forEach(knownSkill);
|
||||||
this.add.text(X + WIDTH * 0.175, Y, 'Skills', TEXT.HEADER);
|
this.add.text(X + WIDTH * 0.35, Y, 'Skills', TEXT.HEADER);
|
||||||
|
|
||||||
this.add.text(X + WIDTH * 0.175, Y + HEIGHT * 0.25, 'Specs', TEXT.HEADER);
|
this.add.text(X + WIDTH * 0.35, Y + HEIGHT * 0.25, 'Specs', TEXT.HEADER);
|
||||||
const knownSpec = (spec, i) => {
|
const knownSpec = (spec, i) => {
|
||||||
const SKILL_X = X + WIDTH * 0.21 + WIDTH * 0.125 * i;
|
const SKILL_X = X + WIDTH * 0.4 + WIDTH * 0.125 * i;
|
||||||
const SKILL_Y = Y + HEIGHT * 0.4;
|
const SKILL_Y = Y + HEIGHT * 0.4;
|
||||||
const itemObj = new Item(this, spec, i, SKILL_X, SKILL_Y, SKILL_WIDTH, Math.floor(SKILL_WIDTH / 2));
|
const itemObj = new Item(this, spec, i, SKILL_X, SKILL_Y, SKILL_WIDTH, Math.floor(SKILL_WIDTH / 2));
|
||||||
// itemObj.on('pointerdown', () => );
|
// itemObj.on('pointerdown', () => );
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user