improve game && start sound creating
This commit is contained in:
@@ -11,16 +11,58 @@ class UserControl extends React.Component {
|
||||
*/
|
||||
this.state = {
|
||||
activePlayer: 0,
|
||||
mines: 51
|
||||
mines: 51,
|
||||
bombSelected: false,
|
||||
foundMines: false
|
||||
};
|
||||
}
|
||||
|
||||
onClickBombSelector(clickedPlayer) {
|
||||
var activePlayer = this.state.activePlayer ? 'blue' : 'red';
|
||||
|
||||
if (
|
||||
this.refs[activePlayer].state.haveBomb &&
|
||||
this.refs[activePlayer].state.enabledBomb &&
|
||||
this.state.activePlayer === clickedPlayer
|
||||
) {
|
||||
this.state.bombSelected = !this.state.bombSelected;
|
||||
|
||||
if (!this.state.bombSelected) {
|
||||
this.props.bombClear();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
activeMines() {
|
||||
return "active-mines" + (this.state.foundMines ? ' found-mine' : '');
|
||||
}
|
||||
|
||||
render() {
|
||||
return (
|
||||
<div>
|
||||
<User ref="blue" name={this.props.blue}/>
|
||||
<div>Active mines: {this.state.mines} pcs</div>
|
||||
<User ref="red" name={this.props.red}/>
|
||||
<div className="users">
|
||||
<User ref="blue"
|
||||
color="blue"
|
||||
name={this.props.blue}
|
||||
active={this.state.activePlayer === 1}
|
||||
onClickBombSelector={this.onClickBombSelector.bind(this, 1)}/>
|
||||
<div className="active-mines-container">
|
||||
<i className="fa fa-star"></i>
|
||||
<div className={this.activeMines()}>
|
||||
<div className="active-mines-nbr">{this.state.mines}</div>
|
||||
<div className="active-mines-shine"></div>
|
||||
</div>
|
||||
<i className="fa fa-star"></i>
|
||||
</div>
|
||||
<div className="clear"></div>
|
||||
<User ref="red"
|
||||
color="red"
|
||||
name={this.props.red}
|
||||
active={this.state.activePlayer === 0}
|
||||
onClickBombSelector={this.onClickBombSelector.bind(this, 0)}/>
|
||||
<div className="resign">
|
||||
<div className="resign-shine"></div>
|
||||
Resign
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user