Private
Public Access
1
0

add overlay && game do not start until the opponent came

This commit is contained in:
2016-11-01 08:31:13 +01:00
parent 23d334ab27
commit a566ba8cf8
3 changed files with 69 additions and 1 deletions

View File

@@ -65,7 +65,9 @@ class MineSeeker extends React.Component {
this.refs.gridControl.setState({
grid: this.state.gameInherited ? JSON.parse(Base64.decode(gridServer)) : gridClient,
session: this.state.session,
channel: this.state.channel
channel: this.state.channel,
overlay: true,
overlayTitle: "We are waiting for your opponent..."
});
/** setup the web player && save player name */
@@ -84,6 +86,8 @@ class MineSeeker extends React.Component {
this.state.channel,
(uri, payload, log) => {
var isNotUnsubscribe = typeof payload.msg === 'undefined';
if (typeof payload.data !== 'undefined') {
console.warn(payload.user + " has been stepped to coords: " + payload.data.coords[0] + ', ' + payload.data.coords[1]);
@@ -99,6 +103,11 @@ class MineSeeker extends React.Component {
(typeof payload.user !== 'undefined' ? payload.user : 'user') + " has been subscribed to the channel!"
);
/** remove overlay when every user has been came */
if (isNotUnsubscribe) {
this.refs.gridControl.setState({overlay: payload.userCnt < 2});
}
// /** Save the opponent's player name */
// if (this.state.gameInherited) {
// this.refs.gridControl.refs.userControl.refs.blue.setState({name: payload.user});