MAPG-44 modify game to use pov of place
This commit is contained in:
parent
b736ce8970
commit
3123643bb7
@ -8,6 +8,7 @@
|
||||
rounds: [],
|
||||
scoreSum: 0,
|
||||
panoId: null,
|
||||
pov: null,
|
||||
panorama: null,
|
||||
map: null,
|
||||
guessMarker: null,
|
||||
@ -35,6 +36,7 @@
|
||||
}
|
||||
|
||||
Game.panoId = this.response.panoId;
|
||||
Game.pov = this.response.pov;
|
||||
|
||||
if (this.response.history) {
|
||||
for (var i = 0; i < this.response.history.length; ++i) {
|
||||
@ -116,7 +118,7 @@
|
||||
|
||||
document.getElementById('currentRound').innerHTML = String(Game.rounds.length) + '/' + String(Game.NUMBER_OF_ROUNDS);
|
||||
|
||||
Game.loadPano(Game.panoId);
|
||||
Game.loadPano(Game.panoId, Game.pov);
|
||||
},
|
||||
|
||||
handleErrorResponse: function (error) {
|
||||
@ -129,13 +131,13 @@
|
||||
});
|
||||
},
|
||||
|
||||
loadPano: function (panoId) {
|
||||
loadPano: function (panoId, pov) {
|
||||
if (Game.adaptGuess) {
|
||||
document.getElementById('guess').classList.add('adapt');
|
||||
}
|
||||
|
||||
Game.panorama.setPov({ heading: 0, pitch: 0 });
|
||||
Game.panorama.setZoom(0);
|
||||
Game.panorama.setPov({ heading: pov.heading, pitch: pov.pitch });
|
||||
Game.panorama.setZoom(pov.zoom);
|
||||
Game.panorama.setPano(panoId);
|
||||
},
|
||||
|
||||
@ -199,6 +201,7 @@
|
||||
}
|
||||
|
||||
Game.panoId = this.response.panoId;
|
||||
Game.pov = this.response.pov;
|
||||
}, data);
|
||||
},
|
||||
|
||||
|
@ -41,7 +41,10 @@ class GameFlowController
|
||||
|
||||
$session->set('state', $state);
|
||||
|
||||
$data = ['panoId' => $place->getPanoIdCached()];
|
||||
$data = [
|
||||
'panoId' => $place->getPanoIdCached(),
|
||||
'pov' => $place->getPov()->toArray()
|
||||
];
|
||||
} else {
|
||||
$rounds = count($state['rounds']);
|
||||
$last = $state['rounds'][$rounds - 1];
|
||||
@ -59,7 +62,10 @@ class GameFlowController
|
||||
|
||||
$data = [
|
||||
'history' => $history,
|
||||
'panoId' => $last['panoId']
|
||||
'panoId' => $last['panoId'],
|
||||
'pov' => isset($last['pov']) ? // should be checked not to break with old sessions
|
||||
$last['pov']->toArray() :
|
||||
['heading' => 0.0, 'pitch' => 0.0, 'zoom' => 0.0],
|
||||
];
|
||||
}
|
||||
|
||||
@ -103,10 +109,12 @@ class GameFlowController
|
||||
$this->addNewRoundToState($state, $place, $placesWithoutPano);
|
||||
|
||||
$panoId = $place->getPanoIdCached();
|
||||
$pov = $place->getPov()->toArray();
|
||||
} else {
|
||||
$state['rounds'] = [];
|
||||
|
||||
$panoId = null;
|
||||
$pov = null;
|
||||
}
|
||||
|
||||
$session->set('state', $state);
|
||||
@ -117,7 +125,8 @@ class GameFlowController
|
||||
'distance' => $distance,
|
||||
'score' => $score
|
||||
],
|
||||
'panoId' => $panoId
|
||||
'panoId' => $panoId,
|
||||
'pov' => $pov
|
||||
];
|
||||
return new JsonContent($data);
|
||||
}
|
||||
@ -128,7 +137,8 @@ class GameFlowController
|
||||
'placesWithoutPano' => $placesWithoutPano,
|
||||
'placeId' => $place->getId(),
|
||||
'position' => $place->getPosition(),
|
||||
'panoId' => $place->getPanoIdCached()
|
||||
'panoId' => $place->getPanoIdCached(),
|
||||
'pov' => $place->getPov()
|
||||
];
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user