Basic graph display
This commit is contained in:
parent
79374a3cd5
commit
8b60f26fc5
@ -8,28 +8,26 @@ const CrypSpawnContainer = require('./cryp.spawn.container');
|
|||||||
const GameJoinButton = require('./game.join.button');
|
const GameJoinButton = require('./game.join.button');
|
||||||
const CrypListContainer = require('./cryp.list.container');
|
const CrypListContainer = require('./cryp.list.container');
|
||||||
const GameContainer = require('./game.container');
|
const GameContainer = require('./game.container');
|
||||||
|
const Passives = require('./passive.container');
|
||||||
|
|
||||||
const addState = connect(
|
const addState = connect(
|
||||||
(state) => {
|
(state) => {
|
||||||
const { game, ws } = state;
|
const { game, ws, account } = state;
|
||||||
|
|
||||||
if (!game) {
|
if (!game) {
|
||||||
console.log('out of game');
|
|
||||||
ws.clearGameStateInterval();
|
ws.clearGameStateInterval();
|
||||||
}
|
}
|
||||||
|
return state;
|
||||||
return { game };
|
|
||||||
},
|
},
|
||||||
(dispatch) => {
|
(dispatch) => {
|
||||||
function setGame(game) {
|
function setGame(game) {
|
||||||
dispatch(actions.setGame(game));
|
dispatch(actions.setGame(game));
|
||||||
}
|
}
|
||||||
return { setGame };
|
return { setGame };
|
||||||
},
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
function renderBody(props) {
|
function renderBody(props) {
|
||||||
const { game, setGame } = props;
|
const { game, setGame, account } = props;
|
||||||
if (game) {
|
if (game) {
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
@ -44,26 +42,33 @@ function renderBody(props) {
|
|||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return (
|
if (account) {
|
||||||
<section className="columns">
|
return (
|
||||||
<div className="column is-4">
|
<section className="columns">
|
||||||
<div className="column">
|
<div className="column is-4">
|
||||||
<GameJoinButton />
|
<div className="column">
|
||||||
<CrypSpawnContainer />
|
<GameJoinButton />
|
||||||
</div>
|
<CrypSpawnContainer />
|
||||||
<div className="column">
|
</div>
|
||||||
<div className="columns">
|
<div className="column">
|
||||||
<div className="column is-8">
|
<div className="columns">
|
||||||
<CrypListContainer />
|
<div className="column is-8">
|
||||||
</div>
|
<CrypListContainer />
|
||||||
<div className="column">
|
</div>
|
||||||
<ItemListContainer />
|
<div className="column">
|
||||||
|
<ItemListContainer />
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
<div className ="column">
|
||||||
</section>
|
<Passives />
|
||||||
);
|
</div>
|
||||||
|
</section>
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
return <div>not ready</div>;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = addState(renderBody);
|
module.exports = addState(renderBody);
|
||||||
|
|||||||
49
client/src/components/passive.container.jsx
Executable file
49
client/src/components/passive.container.jsx
Executable file
@ -0,0 +1,49 @@
|
|||||||
|
const preact = require('preact');
|
||||||
|
const { connect } = require('preact-redux');
|
||||||
|
const Phaser = require('phaser');
|
||||||
|
const PhaserPassives = require('./phaser.passives');
|
||||||
|
|
||||||
|
const addState = connect(
|
||||||
|
function receiveState(state) {
|
||||||
|
const {
|
||||||
|
game, activeSkill, activeIncoming, account,
|
||||||
|
} = state;
|
||||||
|
return {
|
||||||
|
game, activeSkill, activeIncoming, account,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
class PhaserInstance extends preact.Component {
|
||||||
|
constructor(props) {
|
||||||
|
super(props);
|
||||||
|
this.props = props;
|
||||||
|
}
|
||||||
|
|
||||||
|
componentDidMount() {
|
||||||
|
// now mounted, can freely modify the DOM:
|
||||||
|
this.PhaserPassives = new PhaserPassives();
|
||||||
|
const config = {
|
||||||
|
type: Phaser.DOM.FILL,
|
||||||
|
width: 1200,
|
||||||
|
height: 900,
|
||||||
|
parent: 'passives',
|
||||||
|
physics: {
|
||||||
|
default: 'arcade',
|
||||||
|
arcade: {
|
||||||
|
gravity: { y: 0 },
|
||||||
|
},
|
||||||
|
},
|
||||||
|
scene: this.PhaserPassives,
|
||||||
|
};
|
||||||
|
const game = new Phaser.Game(config);
|
||||||
|
}
|
||||||
|
|
||||||
|
render() {
|
||||||
|
return (
|
||||||
|
<div id="passives" style="overflow: hidden;">
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
module.exports = addState(PhaserInstance);
|
||||||
36
client/src/components/passive.node.js
Executable file
36
client/src/components/passive.node.js
Executable file
@ -0,0 +1,36 @@
|
|||||||
|
const Phaser = require('phaser');
|
||||||
|
|
||||||
|
class PassiveNode extends Phaser.GameObjects.Sprite {
|
||||||
|
constructor(scene, x, y, id, alloc) {
|
||||||
|
super(scene, x, y);
|
||||||
|
this.setTexture('eye');
|
||||||
|
|
||||||
|
this.scene = scene;
|
||||||
|
this.alloc = alloc;
|
||||||
|
this.id = id;
|
||||||
|
this.setPosition(x, y);
|
||||||
|
this.setScale(0.25);
|
||||||
|
|
||||||
|
if (this.alloc) {
|
||||||
|
this.setTint(0xff0000);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
allocate() {
|
||||||
|
if (this.alloc) {
|
||||||
|
this.clearTint();
|
||||||
|
this.alloc = false;
|
||||||
|
} else {
|
||||||
|
this.alloc = true;
|
||||||
|
this.setTint(0xff0000);
|
||||||
|
}
|
||||||
|
for (let i = 0; i < this.scene.passiveNodes.length; i += 1) {
|
||||||
|
if (this.scene.passiveNodes[i].id === this.id) {
|
||||||
|
this.scene.passiveNodes[i].alloc = this.alloc;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this.scene.drawPassiveEdges();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = PassiveNode;
|
||||||
Loading…
x
Reference in New Issue
Block a user