Adding new tower types and concept of tower deck
This commit is contained in:
parent
d1930a6b00
commit
117c77b4a8
16 changed files with 463 additions and 19 deletions
|
|
@ -28,15 +28,21 @@ namespace TD.Dev
|
|||
"Set to Key.None to use the OnGUI button only.")]
|
||||
[SerializeField] private Key hotkey = Key.F9;
|
||||
|
||||
[Tooltip("Keyboard shortcut to grant the local player the next catalog tower not " +
|
||||
"yet in their deck. Stand-in for the draft system so deck growth can be " +
|
||||
"verified now. Set to Key.None to use the OnGUI button only.")]
|
||||
[SerializeField] private Key grantTowerHotkey = Key.F8;
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (hotkey == Key.None) return;
|
||||
|
||||
var kb = Keyboard.current;
|
||||
if (kb == null) return; // no keyboard connected (e.g. headless server)
|
||||
if (!kb[hotkey].wasPressedThisFrame) return;
|
||||
|
||||
TryForceNextWave();
|
||||
if (hotkey != Key.None && kb[hotkey].wasPressedThisFrame)
|
||||
TryForceNextWave();
|
||||
|
||||
if (grantTowerHotkey != Key.None && kb[grantTowerHotkey].wasPressedThisFrame)
|
||||
TryGrantNextTower();
|
||||
}
|
||||
|
||||
private void OnGUI()
|
||||
|
|
@ -48,9 +54,44 @@ namespace TD.Dev
|
|||
|
||||
// Anchored below the top HUD bar so it doesn't overlap gold/wave/lives.
|
||||
const float topOffset = 90f;
|
||||
GUI.Box(new Rect(10, topOffset, 180, 60), "Dev: Wave Controls");
|
||||
GUI.Box(new Rect(10, topOffset, 180, 95), "Dev: Wave Controls");
|
||||
if (GUI.Button(new Rect(20, topOffset + 25, 160, 28), "Force Next Wave"))
|
||||
TryForceNextWave();
|
||||
if (GUI.Button(new Rect(20, topOffset + 58, 160, 28), "Grant Next Tower"))
|
||||
TryGrantNextTower();
|
||||
}
|
||||
|
||||
// Dev stand-in for the draft system: grants the local player the first catalog
|
||||
// tower they haven't unlocked yet, so deck growth + the HUD's live rebuild can be
|
||||
// verified before the real draft exists. Server-only (host); ServerGrantTower
|
||||
// no-ops elsewhere.
|
||||
private void TryGrantNextTower()
|
||||
{
|
||||
if (NetworkManager.Singleton == null || !NetworkManager.Singleton.IsServer)
|
||||
{
|
||||
Debug.LogWarning("[DevWaveControls] Grant-tower requested off the server. Ignored.");
|
||||
return;
|
||||
}
|
||||
|
||||
var placement = TowerPlacementManager.Instance;
|
||||
var deck = PlayerTowerDeck.Local;
|
||||
if (placement == null || deck == null)
|
||||
{
|
||||
Debug.LogWarning("[DevWaveControls] Cannot grant tower — TowerPlacementManager " +
|
||||
"or local PlayerTowerDeck is not ready.");
|
||||
return;
|
||||
}
|
||||
|
||||
foreach (var (def, typeId) in placement.GetAvailableDefinitions())
|
||||
{
|
||||
if (deck.Contains(typeId)) continue;
|
||||
if (deck.ServerGrantTower(typeId))
|
||||
Debug.Log($"[DevWaveControls] Granted '{def.DisplayName}' (typeId {typeId}) " +
|
||||
$"to the local deck.");
|
||||
return;
|
||||
}
|
||||
|
||||
Debug.Log("[DevWaveControls] Local deck already contains every catalog tower.");
|
||||
}
|
||||
|
||||
private void TryForceNextWave()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue