diff --git a/client/src/scenes/combat.js b/client/src/scenes/combat.js index e0e5b607..dd8a39a9 100644 --- a/client/src/scenes/combat.js +++ b/client/src/scenes/combat.js @@ -1,12 +1,11 @@ const Phaser = require('phaser'); const { throttle } = require('lodash'); -const { TEXT, POSITIONS: { COMBAT }} = require('./constants'); +const { TEXT, POSITIONS: { COMBAT } } = require('./constants'); const CombatLog = require('./combat.log'); const CombatCryps = require('./combat.cryps'); const CombatSkills = require('./combat.skills'); const CombatHitBox = require('./combat.hitbox'); -const Button = require('./elements/box'); const renderResolutions = require('./combat.render.resolutions'); diff --git a/client/src/scenes/item.list.js b/client/src/scenes/item.list.js index 2018822a..01db0c23 100644 --- a/client/src/scenes/item.list.js +++ b/client/src/scenes/item.list.js @@ -262,27 +262,30 @@ class ItemList extends Phaser.Scene { this.input.on('dragend', (pointer, item) => { if (!(item instanceof Item)) return false; - - // Allocate to combiner if clicked without movement form inventory (return 0) - if (!Math.hypot(item.x - item.origX, item.y - item.origY)) { - const cBox = findUnallocated(); - if (cBox) allocate(item, cBox); - return true; - } - // Check for hitboxes + // Check first for hitbox interaction const hitBox = itemCheckHitbox(this, pointer); if (hitBox) { + // hitbox can only be the combinerhitbox, deletehitbox or cryp avatar hitBox.itemDeselect(); - // Allocate to specific combiner slot if (hitBox instanceof CombinerHitBox) { allocate(item, hitBox); + } else if (hitBox instanceof DeleteHitBox) { + ws.sendVboxDrop(vbox.instance, item.index); + } else { + ws.sendVboxApply(vbox.instance, hitBox.cryp.id, item.index); + } return true; + } + // If not interacting with hitbox and didn't move much try to allocate the item + if (Math.hypot(item.x - item.origX, item.y - item.origY) < Math.hypot(item.width, item.height)) { + // Check theres a free combiner slot + const cBox = findUnallocated(); + if (cBox) { + allocate(item, cBox); return true; } - // Allocate to cryp hitbox - if (hitBox instanceof DeleteHitBox) ws.sendVboxDrop(vbox.instance, item.index); - else ws.sendVboxApply(vbox.instance, hitBox.cryp.id, item.index); } - // If the item hasn't been allocated deallocate the item + // If the item hasn't been allocated above reset to natural location + // Check if item needs to be deallocated // Scene will restart if there is vbox change deallocate(item); return true; diff --git a/client/src/scenes/menu.js b/client/src/scenes/menu.js index 3b8a6b48..48644f19 100644 --- a/client/src/scenes/menu.js +++ b/client/src/scenes/menu.js @@ -3,6 +3,7 @@ const Phaser = require('phaser'); // Scenes constantly showing const MenuCrypList = require('./menu.cryps.list'); const MenuNavigation = require('./menu.navigation'); +const MenuScore = require('./menu.score'); const ItemList = require('./item.list'); // Scenes which change depending on menu context const Zones = require('./zones'); @@ -14,6 +15,7 @@ const FIXED_MENU_SCENES = [ 'MenuCrypList', 'MenuNavigation', 'ItemList', + 'MenuScore', ]; const MAIN_MENU_SCENES = [ @@ -37,6 +39,7 @@ class Menu extends Phaser.Scene { this.scene.manager.add('MenuCrypList', MenuCrypList, true); this.scene.manager.add('MenuNavigation', MenuNavigation, true); + this.scene.manager.add('MenuScore', MenuScore, true); this.scene.manager.add('ItemList', ItemList, true); this.registry.set('inMenu', true); return true; diff --git a/client/src/scenes/menu.score.js b/client/src/scenes/menu.score.js new file mode 100644 index 00000000..24e29e33 --- /dev/null +++ b/client/src/scenes/menu.score.js @@ -0,0 +1,24 @@ +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;