shits fucked
This commit is contained in:
parent
7c74018dbf
commit
d9b25e0fc6
@ -5,6 +5,7 @@
|
|||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"start": "parcel index.html --port 40080 --no-hmr",
|
"start": "parcel index.html --port 40080 --no-hmr",
|
||||||
|
"start-lite": "parcel index.html --port 40080 --no-hmr --no-source-maps",
|
||||||
"build": "rm -rf dist && parcel build index.html",
|
"build": "rm -rf dist && parcel build index.html",
|
||||||
"lint": "eslint --fix --ext .jsx src/",
|
"lint": "eslint --fix --ext .jsx src/",
|
||||||
"test": "echo \"Error: no test specified\" && exit 1"
|
"test": "echo \"Error: no test specified\" && exit 1"
|
||||||
|
|||||||
@ -9,8 +9,8 @@ class CrypList extends Phaser.Scene {
|
|||||||
|
|
||||||
create() {
|
create() {
|
||||||
this.registry.events.on('changedata', this.updateData, this);
|
this.registry.events.on('changedata', this.updateData, this);
|
||||||
this.graphics = this.add.graphics();
|
this.input.on('gameobjectup', this.clickHandler, this);
|
||||||
|
console.log('creating');
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -21,30 +21,30 @@ class CrypList extends Phaser.Scene {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
destroyText() {
|
redraw() {
|
||||||
this.children.list.filter(c => c.type === 'Text').forEach(t => t.destroy());
|
this.children.list.forEach(t => {
|
||||||
|
t.disableInteractive();
|
||||||
|
t.destroy();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
renderCryps(cryps) {
|
renderCryps(cryps) {
|
||||||
if (!cryps) return true;
|
if (!cryps) return true;
|
||||||
this.destroyText();
|
console.log(JSON.stringify(this.children.list));
|
||||||
this.graphics.clear();
|
console.log(this.children.length);
|
||||||
|
this.redraw();
|
||||||
|
|
||||||
cryps.forEach((cryp, i) => {
|
cryps.forEach((cryp, i) => {
|
||||||
crypRow(this, cryp, i);
|
crypRow(this, cryp, i);
|
||||||
});
|
});
|
||||||
|
|
||||||
this.input.on('gameobjectup', this.clickHandler, this);
|
window.redraw = this.redraw.bind(this);
|
||||||
|
|
||||||
// seal the boxes in and stop rerendering them
|
|
||||||
this.graphics.generateTexture();
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
clickHandler(pointer, crypBox) {
|
clickHandler(pointer, crypBox) {
|
||||||
console.log(crypBox);
|
console.log(crypBox);
|
||||||
this.registry.set('activeCryp', crypBox.cryp);
|
this.registry.set('activeCryp', Object.create(crypBox.cryp));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -24,11 +24,6 @@ class CrypPage extends Phaser.Scene {
|
|||||||
|
|
||||||
create() {
|
create() {
|
||||||
this.registry.events.on('changedata', this.updateData, this);
|
this.registry.events.on('changedata', this.updateData, this);
|
||||||
|
|
||||||
const cryp = this.registry.get('activeCryp');
|
|
||||||
this.graphics = this.add.graphics();
|
|
||||||
|
|
||||||
this.renderCryp(cryp);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -39,20 +34,17 @@ class CrypPage extends Phaser.Scene {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
destroyText() {
|
redraw() {
|
||||||
this.children.list.filter(c => c.type === 'Text').forEach(t => t.destroy());
|
this.children.list.forEach(t => t.destroy());
|
||||||
}
|
}
|
||||||
|
|
||||||
renderCryp(cryp) {
|
renderCryp(cryp) {
|
||||||
if (!cryp) return true;
|
if (!cryp) return true;
|
||||||
this.destroyText();
|
this.redraw();
|
||||||
|
|
||||||
this.add.text(500, 500, cryp.name, { fontFamily: 'Arial', fontSize: 24, color: '#ffffff', fontStyle: 'bold' });
|
this.add.text(500, 500, cryp.name, { fontFamily: 'Arial', fontSize: 24, color: '#ffffff', fontStyle: 'bold' });
|
||||||
|
|
||||||
cryp.skills.forEach((skill, i) => crypSkill(this, skill, i));
|
cryp.skills.forEach((skill, i) => crypSkill(this, skill, i));
|
||||||
|
|
||||||
// seal the boxes in and stop rerendering them
|
|
||||||
this.graphics.generateTexture();
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -8,10 +8,11 @@ const TOP_MARGIN = 50;
|
|||||||
const ROW_MARGIN = 50;
|
const ROW_MARGIN = 50;
|
||||||
const TEXT_MARGIN = 24;
|
const TEXT_MARGIN = 24;
|
||||||
|
|
||||||
const xPos = i => 0;
|
const xPos = i => Math.random() * 1400;
|
||||||
const yPos = i => (i * ROW_HEIGHT + ROW_MARGIN) + TOP_MARGIN;
|
const yPos = i => (i * ROW_HEIGHT + ROW_MARGIN) + TOP_MARGIN;
|
||||||
|
|
||||||
function crypRow(list, cryp, i) {
|
function crypRow(list, cryp, i) {
|
||||||
|
console.log(i);
|
||||||
const X_ORIGIN = xPos(i);
|
const X_ORIGIN = xPos(i);
|
||||||
const Y_ORIGIN = yPos(i);
|
const Y_ORIGIN = yPos(i);
|
||||||
|
|
||||||
|
|||||||
@ -35,6 +35,8 @@ function renderCryps(store) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
window.addEventListener('resize', () => game.resize(window.innerWidth, window.innerHeight), false);
|
window.addEventListener('resize', () => game.resize(window.innerWidth, window.innerHeight), false);
|
||||||
|
|
||||||
|
return game;
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = renderCryps;
|
module.exports = renderCryps;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user