Merge branch 'master' of ssh://cryps.gg:40022/~/cryps
This commit is contained in:
commit
b4cf3f4eb4
@ -6,7 +6,6 @@ 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');
|
||||
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -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;
|
||||
|
||||
24
client/src/scenes/menu.score.js
Normal file
24
client/src/scenes/menu.score.js
Normal file
@ -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;
|
||||
Loading…
x
Reference in New Issue
Block a user