Finish work
This commit is contained in:
@@ -19,14 +19,10 @@ namespace Minigames.FortFight.UI
|
||||
[SerializeField] private int playerIndex = 0;
|
||||
|
||||
[Header("References")]
|
||||
[Tooltip("Ammunition manager (shared between both players)")]
|
||||
[SerializeField] private AmmunitionManager ammunitionManager;
|
||||
|
||||
[Tooltip("This player's slingshot controller")]
|
||||
[SerializeField] private SlingshotController slingshotController;
|
||||
|
||||
[Tooltip("Turn manager to subscribe to turn events")]
|
||||
[SerializeField] private TurnManager turnManager;
|
||||
// Note: AmmunitionManager and TurnManager accessed via singletons
|
||||
|
||||
[Header("UI")]
|
||||
[Tooltip("Array of ammo buttons in this panel")]
|
||||
@@ -44,21 +40,11 @@ namespace Minigames.FortFight.UI
|
||||
base.OnManagedAwake();
|
||||
|
||||
// Validate references
|
||||
if (ammunitionManager == null)
|
||||
{
|
||||
Logging.Error($"[AmmunitionPanel] Player {playerIndex}: Ammunition manager not assigned!");
|
||||
}
|
||||
|
||||
if (slingshotController == null)
|
||||
{
|
||||
Logging.Error($"[AmmunitionPanel] Player {playerIndex}: Slingshot controller not assigned!");
|
||||
}
|
||||
|
||||
if (turnManager == null)
|
||||
{
|
||||
Logging.Error($"[AmmunitionPanel] Player {playerIndex}: Turn manager not assigned!");
|
||||
}
|
||||
|
||||
if (ammoButtons == null || ammoButtons.Length == 0)
|
||||
{
|
||||
Logging.Warning($"[AmmunitionPanel] Player {playerIndex}: No ammo buttons assigned!");
|
||||
@@ -78,10 +64,10 @@ namespace Minigames.FortFight.UI
|
||||
// Initialize ammo buttons with player context
|
||||
InitializeButtons();
|
||||
|
||||
// Subscribe to turn events
|
||||
if (turnManager != null)
|
||||
// Subscribe to turn events via singleton
|
||||
if (TurnManager.Instance != null)
|
||||
{
|
||||
turnManager.OnTurnStarted += HandleTurnStarted;
|
||||
TurnManager.Instance.OnTurnStarted += HandleTurnStarted;
|
||||
}
|
||||
|
||||
// Start hidden
|
||||
@@ -93,9 +79,9 @@ namespace Minigames.FortFight.UI
|
||||
base.OnManagedDestroy();
|
||||
|
||||
// Unsubscribe from events
|
||||
if (turnManager != null)
|
||||
if (TurnManager.Instance != null)
|
||||
{
|
||||
turnManager.OnTurnStarted -= HandleTurnStarted;
|
||||
TurnManager.Instance.OnTurnStarted -= HandleTurnStarted;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -104,13 +90,13 @@ namespace Minigames.FortFight.UI
|
||||
/// </summary>
|
||||
private void InitializeButtons()
|
||||
{
|
||||
if (ammunitionManager == null || slingshotController == null || ammoButtons == null)
|
||||
if (AmmunitionManager.Instance == null || slingshotController == null || ammoButtons == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Get available projectile types from settings
|
||||
var availableTypes = ammunitionManager.GetAvailableProjectileTypes();
|
||||
var availableTypes = AmmunitionManager.Instance.GetAvailableProjectileTypes();
|
||||
var settings = GameManager.GetSettingsObject<AppleHills.Core.Settings.IFortFightSettings>();
|
||||
|
||||
if (settings == null)
|
||||
@@ -126,7 +112,7 @@ namespace Minigames.FortFight.UI
|
||||
var config = settings.GetProjectileConfig(availableTypes[i]);
|
||||
if (config != null)
|
||||
{
|
||||
ammoButtons[i].Initialize(config, ammunitionManager, slingshotController, playerIndex);
|
||||
ammoButtons[i].Initialize(config, AmmunitionManager.Instance, slingshotController, playerIndex);
|
||||
Logging.Debug($"[AmmunitionPanel] Player {playerIndex}: Initialized button for {config.displayName}");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user