Updating HUD, Gold Config, and finishing off Play flow for 9player map.
This commit is contained in:
parent
a7be12fa9b
commit
3dcc0e7edd
28 changed files with 2272 additions and 9601 deletions
|
|
@ -71,22 +71,22 @@ namespace TD.Gameplay
|
|||
}
|
||||
|
||||
// Edge case: the player connected while a match is already in progress.
|
||||
// The Match scene is already loaded, so OnLoadEventCompleted won't fire
|
||||
// The match scene is already loaded, so OnLoadEventCompleted won't fire
|
||||
// again until the next transition. Spawn now.
|
||||
if (SceneManager.GetActiveScene().name == SceneNames.Match)
|
||||
if (IsMatchScene(SceneManager.GetActiveScene().name))
|
||||
TrySpawnBuilder();
|
||||
}
|
||||
|
||||
// NGO fires this on the server once a scene load is acknowledged complete
|
||||
// by every connected client (or timed out). We only act when the Match
|
||||
// scene loads; Lobby / MainMenu loads are no-ops here.
|
||||
// by every connected client (or timed out). We only act when a registered
|
||||
// match scene loads; Lobby / MainMenu loads are no-ops here.
|
||||
private void HandleSceneLoadCompleted(string sceneName,
|
||||
LoadSceneMode loadSceneMode,
|
||||
List<ulong> clientsCompleted,
|
||||
List<ulong> clientsTimedOut)
|
||||
{
|
||||
if (!IsServer) return;
|
||||
if (sceneName != SceneNames.Match) return;
|
||||
if (!IsMatchScene(sceneName)) return;
|
||||
TrySpawnBuilder();
|
||||
}
|
||||
|
||||
|
|
@ -115,9 +115,9 @@ namespace TD.Gameplay
|
|||
var pms = GetComponent<PlayerMatchState>();
|
||||
if (pms != null) pms.SlotReady -= OnOwnerSlotReady;
|
||||
|
||||
// Only spawn if we're in the Match scene. SlotReady can fire in MainMenu
|
||||
// Only spawn if we're in a match scene. SlotReady can fire in MainMenu
|
||||
// (during initial connection) — we don't want a builder there.
|
||||
if (SceneManager.GetActiveScene().name == SceneNames.Match)
|
||||
if (IsMatchScene(SceneManager.GetActiveScene().name))
|
||||
SpawnBuilderForOwner(slot);
|
||||
}
|
||||
|
||||
|
|
@ -185,6 +185,21 @@ namespace TD.Gameplay
|
|||
|
||||
// ----- Helpers ----------------------------------------------------
|
||||
|
||||
// True if the named scene is a registered match map. Source of truth is
|
||||
// MapRegistry — any scene whose LevelData is in the registry counts. Falls back
|
||||
// to comparing against the legacy hardcoded SceneNames.Match when the registry
|
||||
// is missing (editor standalone-scene testing, etc.), so the original 2-player
|
||||
// workflow keeps working.
|
||||
private static bool IsMatchScene(string sceneName)
|
||||
{
|
||||
if (string.IsNullOrEmpty(sceneName)) return false;
|
||||
var registry = MapRegistry.Instance;
|
||||
if (registry != null && registry.ContainsScene(sceneName)) return true;
|
||||
// Fallback for editor testing without MainMenu (no MapRegistry persistent
|
||||
// instance). Keeps the old behavior intact.
|
||||
return sceneName == SceneNames.Match;
|
||||
}
|
||||
|
||||
// Picks the builder prefab to spawn for this player. Race-specific takes
|
||||
// priority when (a) RaceRegistry is in the scene, (b) the player picked
|
||||
// a race, and (c) that race's RaceDefinition has a BuilderPrefab assigned.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue