Skip to content

Commit

Permalink
updated unity builds, pass game level from tourney to wom
Browse files Browse the repository at this point in the history
  • Loading branch information
polats committed Sep 11, 2020
1 parent 0d0beab commit a198ae8
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 11 deletions.
Binary file modified packages/client/public/flappybird/unitygame.data.unityweb
Binary file not shown.
Binary file modified packages/client/public/wom/unitygame.data.unityweb
Binary file not shown.
Binary file modified packages/client/public/wom/unitygame.wasm.code.unityweb
Binary file not shown.
Binary file modified packages/client/public/wom/unitygame.wasm.framework.unityweb
Binary file not shown.
37 changes: 27 additions & 10 deletions packages/client/src/scenes/GameUnity.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,55 +54,70 @@ export class GameUnity extends React.Component<IProps, any> {
playBtnText: "Play",
score: 1,
gameName: '',
doubleTime: null
doubleTime: null,
gameId: ''
};

this.initializeUnity();
this.preparePlayButton();
}

speed = 30;
unityContent = null as any;

preparePlayButton = async () => {
try {
await this.getBlockchainInfo(this.props);
await this.fetchGameNo(this.props.address, this.props.tournamentId);
} catch (e)
{
console.log(e)

}

}

initializeGame = async (playerAddress, tournamentId) => {
let sessionId = await createSessionId(playerAddress, tournamentId);
this.setState({
sessionId
})
let payload = this.produceGamePayload('session');
await makeNewGameSession(this.state.gameName, sessionId, tournamentId, payload);
await this.getBlockchainInfo(this.props);
await this.fetchGameNo(playerAddress, this.props.tournamentId);
await updateGameNo(sessionId, playerAddress, tournamentId);

console.log("GAME NAME FROM STATE", this.state.gameName)

}



getBlockchainInfo = async (props) => {
try {
const { tournamentId, drizzle } = props

const contract = drizzle.contracts.Tournaments;
console.log(contract);
const raw = await contract.methods.getTournament(tournamentId).call();
const data = raw['5'].split(' ').join('').split(",");
const gameId = data[0];
const selectedLevel = data[1];
const maxTries = await contract.methods.getMaxTries(tournamentId).call();
console.log(maxTries);


const tournament = {
maxTries: parseInt(maxTries)
}

this.setState({
gameId,
selectedLevel,
tournament

})

} catch (e) {
console.log("GameUnity: No tourney contract loaded");
console.log(e);
}
}


fetchGameNo = async (account, tournamentId) => {
const gameSessionId = await getGameSessionId(account, tournamentId);
const gameNo = await getGameNo(gameSessionId, account, tournamentId);
Expand All @@ -126,9 +141,11 @@ export class GameUnity extends React.Component<IProps, any> {
const gameId = this.props.path;
let gameServerUrl = "ws://localhost:3001";

console.log(this.state.selectedLevel);

switch (gameId) {
case "wom":
this.unityContent.send("OutplayManager", "SetLevel",
this.unityContent.send("Game3JsManager", "SetLevel",
this.state.selectedLevel ? this.state.selectedLevel : "French Southern and Antarctic Lands");
this.unityContent.send("Game3JsManager", "StartGame", "start");
this.setState({ gameName: Constants.WOM });
Expand Down
2 changes: 1 addition & 1 deletion packages/common/src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ export const WOM_COUNTRIES_ARRAY =
{
"value": "Tourney",
"label": "None"
}
},
{
"value": "Russia",
"label": "Russia"
Expand Down

0 comments on commit a198ae8

Please sign in to comment.