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