GeoSus
This commit is contained in:
@@ -42,14 +42,26 @@ public class GameManager : MonoBehaviour
|
||||
[Header("Lobby Settings")]
|
||||
public double pendingRadius = 500;
|
||||
public int pendingImpostorCount = 1;
|
||||
public int pendingTaskCount = 5;
|
||||
public int pendingTaskCount = 5;
|
||||
/// <summary>
|
||||
/// P13b/c: full settings overrides accumulated by HostLobbyUI before the
|
||||
/// host taps "Create". Null = host didn't change anything beyond the three
|
||||
/// flat fields above; server falls through to its current defaults for
|
||||
/// every field. Each field is independently nullable so the host can
|
||||
/// opt into changing only what they care about.
|
||||
/// </summary>
|
||||
public GameSettingsOverrides pendingSettings;
|
||||
|
||||
[Header("Task Minigames (round-robin)")]
|
||||
// Names MUST match the scene file names in Assets/Scenes (case-sensitive)
|
||||
// and each one MUST be enabled in EditorBuildSettings, or LoadSceneAsync
|
||||
// will silently fail and the task button will appear dead.
|
||||
[SerializeField] public string[] minigameScenes = {
|
||||
"MiniGame-Kabely",
|
||||
"MiniGame-InsertKeys",
|
||||
"MiniGame-Kabely V10",
|
||||
"MiniGame-insertkeys",
|
||||
"MiniGame-FlappyBird",
|
||||
"MiniGame-ThrowInHole"
|
||||
"MiniGame-ThrowInHole",
|
||||
"MiniGame-Satelit"
|
||||
};
|
||||
|
||||
[Header("Debug")]
|
||||
@@ -94,6 +106,13 @@ public class GameManager : MonoBehaviour
|
||||
|
||||
networkSubsystem.OpenConnection();
|
||||
|
||||
// Start GPS immediately at app launch. Acquiring a fix on a cold
|
||||
// device can take 5-30 seconds; if we wait until CreateLobby is
|
||||
// pressed, the lobby will be seeded with bad coords. Starting here
|
||||
// means the user's normal navigation through the menus gives the
|
||||
// GPS subsystem time to settle.
|
||||
inputSubsystem?.EnsureGPSStarted();
|
||||
|
||||
// Load main menu after GameManager is ready
|
||||
if (!string.IsNullOrEmpty(firstMenuScene))
|
||||
SceneManager.LoadScene(firstMenuScene, LoadSceneMode.Single);
|
||||
@@ -164,11 +183,18 @@ public class GameManager : MonoBehaviour
|
||||
}
|
||||
|
||||
// ── Wire canvases (after HUD is built) ──
|
||||
uiSubsystem?.BindClientScene(
|
||||
FindCanvas(CanvasNameJoinCreate),
|
||||
FindCanvas(CanvasNameInLobby),
|
||||
FindCanvas(CanvasNameLoading),
|
||||
FindCanvas(CanvasNameGame));
|
||||
// Apply our standard CanvasScaler (1080x1920 reference, match=0.5)
|
||||
// to every canvas in the scene before binding so layouts scale
|
||||
// identically across phones and tablets without per-device tweaks.
|
||||
var cJoin = FindCanvas(CanvasNameJoinCreate);
|
||||
var cLobby = FindCanvas(CanvasNameInLobby);
|
||||
var cLoad = FindCanvas(CanvasNameLoading);
|
||||
var cGame = FindCanvas(CanvasNameGame);
|
||||
InGameHUDBuilder.ConfigureCanvasScaler(cJoin);
|
||||
InGameHUDBuilder.ConfigureCanvasScaler(cLobby);
|
||||
InGameHUDBuilder.ConfigureCanvasScaler(cLoad);
|
||||
InGameHUDBuilder.ConfigureCanvasScaler(cGame);
|
||||
uiSubsystem?.BindClientScene(cJoin, cLobby, cLoad, cGame);
|
||||
|
||||
// ── Wire map center point and player capsule ──
|
||||
var mapCenter = FindGO("MapCenterPoint");
|
||||
@@ -229,6 +255,14 @@ public class GameManager : MonoBehaviour
|
||||
|
||||
bool isImpostor = gameClient?.MyRole == PlayerRole.Impostor;
|
||||
|
||||
// P13b: pull per-lobby distances from the server-snapshotted settings
|
||||
// instead of hardcoding 5m for every check. ?? fallback keeps the
|
||||
// pre-P13b behavior on old server builds that don't ship settings.
|
||||
var settings = networkSubsystem?.State?.Settings;
|
||||
double reportDist = settings?.ReportDistanceM ?? 5.0;
|
||||
double emergencyDist = settings?.EmergencyMeetingCallRadiusM ?? 5.0;
|
||||
double killDist = settings?.KillDistanceM ?? 5.0;
|
||||
|
||||
// 1. Nearby task → USE
|
||||
var nearbyTask = taskSubsystem?.NearbyTask;
|
||||
if (nearbyTask != null && !isImpostor)
|
||||
@@ -240,7 +274,7 @@ public class GameManager : MonoBehaviour
|
||||
// 2. Nearby body → REPORT
|
||||
if (!uiSubsystem.IsCommsBlackout)
|
||||
{
|
||||
var nearbyBody = gameClient?.FindNearbyBody(5.0);
|
||||
var nearbyBody = gameClient?.FindNearbyBody(reportDist);
|
||||
if (nearbyBody != null)
|
||||
{
|
||||
gameClient.ReportBody(nearbyBody.BodyId);
|
||||
@@ -251,7 +285,7 @@ public class GameManager : MonoBehaviour
|
||||
if (gameClient?.CurrentLobbyState?.MapData != null)
|
||||
{
|
||||
double distToCenter = gameClient.MyPosition.DistanceTo(gameClient.CurrentLobbyState.MapData.Center);
|
||||
if (distToCenter <= 5.0)
|
||||
if (distToCenter <= emergencyDist)
|
||||
{
|
||||
gameClient.CallEmergencyMeeting();
|
||||
return;
|
||||
@@ -262,7 +296,7 @@ public class GameManager : MonoBehaviour
|
||||
// 4. Impostor kill
|
||||
if (isImpostor && _killCooldownSeconds <= 0)
|
||||
{
|
||||
var targetUuid = gameClient?.FindNearbyPlayer(5.0);
|
||||
var targetUuid = gameClient?.FindNearbyPlayer(killDist);
|
||||
if (!string.IsNullOrEmpty(targetUuid))
|
||||
{
|
||||
gameClient.Kill(targetUuid);
|
||||
@@ -295,14 +329,29 @@ public class GameManager : MonoBehaviour
|
||||
// Called by HostLobbyUI
|
||||
public void CreateLobbyButton()
|
||||
{
|
||||
// Use current GPS position if available, else hardcoded fallback
|
||||
double lat = 50.7727264, lon = 15.0719876;
|
||||
if (inputSubsystem?.LastKnownPosition != null)
|
||||
// Refuse to create a lobby without a real GPS fix. The previous
|
||||
// behavior of silently using a hardcoded Czechia fallback meant the
|
||||
// game always started at the same place no matter where the host was,
|
||||
// and the player capsule would spawn miles away in coordinate space
|
||||
// because they're at their real GPS while the map was built around
|
||||
// the fallback. Both bugs share this single gate.
|
||||
if (inputSubsystem?.LastKnownPosition == null)
|
||||
{
|
||||
lat = inputSubsystem.LastKnownPosition.Value.Lat;
|
||||
lon = inputSubsystem.LastKnownPosition.Value.Lon;
|
||||
// testMode bypasses the GPS gate entirely so debug runs still work.
|
||||
if (!testMode)
|
||||
{
|
||||
Debug.LogWarning("[GameManager] CreateLobby blocked: no GPS fix yet. " +
|
||||
"Make sure location permission is granted and you have signal.");
|
||||
uiSubsystem?.ShowToast("Waiting for GPS fix... grant location permission and try again.");
|
||||
inputSubsystem?.EnsureGPSStarted();
|
||||
return;
|
||||
}
|
||||
}
|
||||
networkSubsystem.CreateLobby(lat, lon, pendingRadius, pendingImpostorCount, pendingTaskCount);
|
||||
|
||||
var pos = inputSubsystem?.LastKnownPosition;
|
||||
double lat = pos?.Lat ?? 0;
|
||||
double lon = pos?.Lon ?? 0;
|
||||
networkSubsystem.CreateLobby(lat, lon, pendingRadius, pendingImpostorCount, pendingTaskCount, pendingSettings);
|
||||
if (testMode) StartCoroutine(ConnectTestClients());
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user