Working airplane ability revamp
This commit is contained in:
@@ -23,6 +23,10 @@ namespace Minigames.Airplane.UI
|
||||
[SerializeField] private Image cooldownFill;
|
||||
[SerializeField] private TextMeshProUGUI cooldownText;
|
||||
|
||||
[Header("Active State Visual")]
|
||||
[Tooltip("Visual element shown when ability is active (e.g., glowing border, pulsing overlay)")]
|
||||
[SerializeField] private GameObject activeStateVisual;
|
||||
|
||||
[Header("Debug")]
|
||||
[SerializeField] private bool showDebugLogs;
|
||||
|
||||
@@ -46,6 +50,12 @@ namespace Minigames.Airplane.UI
|
||||
button.onClick.AddListener(OnButtonClick);
|
||||
}
|
||||
|
||||
// Hide active state visual by default
|
||||
if (activeStateVisual != null)
|
||||
{
|
||||
activeStateVisual.SetActive(false);
|
||||
}
|
||||
|
||||
// Hide by default
|
||||
gameObject.SetActive(false);
|
||||
}
|
||||
@@ -54,11 +64,29 @@ namespace Minigames.Airplane.UI
|
||||
{
|
||||
if (currentAbility == null) return;
|
||||
|
||||
// Update cooldown display
|
||||
if (currentAbility.IsOnCooldown)
|
||||
// Priority 1: Show active duration if ability is active
|
||||
if (currentAbility.IsActive && currentAbility.HasActiveDuration)
|
||||
{
|
||||
// Fill starts at 1 and reduces to 0 over cooldown duration
|
||||
float fillAmount = currentAbility.CooldownRemaining / currentAbility.CooldownDuration;
|
||||
// NO fill during active duration - only text and active visual
|
||||
if (cooldownFill != null)
|
||||
{
|
||||
cooldownFill.fillAmount = 0f;
|
||||
}
|
||||
|
||||
// Show remaining active time
|
||||
if (cooldownText != null)
|
||||
{
|
||||
cooldownText.text = $"{currentAbility.ActiveDurationRemaining:F1}s";
|
||||
}
|
||||
}
|
||||
// Priority 2: Show cooldown if on cooldown
|
||||
else if (currentAbility.IsOnCooldown)
|
||||
{
|
||||
// Fill always starts at 1 (full) and reduces to 0, regardless of actual cooldown duration
|
||||
float fillAmount = currentAbility.InitialCooldownDuration > 0f
|
||||
? currentAbility.CooldownRemaining / currentAbility.InitialCooldownDuration
|
||||
: 0f;
|
||||
|
||||
if (cooldownFill != null)
|
||||
{
|
||||
cooldownFill.fillAmount = fillAmount;
|
||||
@@ -72,7 +100,7 @@ namespace Minigames.Airplane.UI
|
||||
}
|
||||
else
|
||||
{
|
||||
// Cooldown complete - fill at 0, no text
|
||||
// Normal state - fill at 0, no text
|
||||
if (cooldownFill != null)
|
||||
cooldownFill.fillAmount = 0f;
|
||||
|
||||
@@ -89,6 +117,7 @@ namespace Minigames.Airplane.UI
|
||||
currentAbility.OnAbilityActivated -= HandleAbilityActivated;
|
||||
currentAbility.OnAbilityDeactivated -= HandleAbilityDeactivated;
|
||||
currentAbility.OnCooldownChanged -= HandleCooldownChanged;
|
||||
currentAbility.OnActiveDurationChanged -= HandleActiveDurationChanged;
|
||||
}
|
||||
|
||||
// Unregister from input system
|
||||
@@ -129,8 +158,8 @@ namespace Minigames.Airplane.UI
|
||||
cooldownText.text = "";
|
||||
}
|
||||
|
||||
// Check if this is a hold ability (Jet)
|
||||
isHoldAbility = ability is JetAbility;
|
||||
// Check if this is a hold ability (Jet or Drop - abilities with active duration that can be interrupted)
|
||||
isHoldAbility = ability is JetAbility || ability is DropAbility;
|
||||
|
||||
// Subscribe to ability events
|
||||
if (ability != null)
|
||||
@@ -138,6 +167,7 @@ namespace Minigames.Airplane.UI
|
||||
ability.OnAbilityActivated += HandleAbilityActivated;
|
||||
ability.OnAbilityDeactivated += HandleAbilityDeactivated;
|
||||
ability.OnCooldownChanged += HandleCooldownChanged;
|
||||
ability.OnActiveDurationChanged += HandleActiveDurationChanged;
|
||||
|
||||
if (showDebugLogs)
|
||||
{
|
||||
@@ -164,6 +194,7 @@ namespace Minigames.Airplane.UI
|
||||
currentAbility.OnAbilityActivated -= HandleAbilityActivated;
|
||||
currentAbility.OnAbilityDeactivated -= HandleAbilityDeactivated;
|
||||
currentAbility.OnCooldownChanged -= HandleCooldownChanged;
|
||||
currentAbility.OnActiveDurationChanged -= HandleActiveDurationChanged;
|
||||
}
|
||||
|
||||
// Unregister from input system
|
||||
@@ -172,6 +203,9 @@ namespace Minigames.Airplane.UI
|
||||
InputManager.Instance.UnregisterOverrideConsumer(this);
|
||||
}
|
||||
|
||||
// Hide active state visual
|
||||
HideActiveState();
|
||||
|
||||
currentAbility = null;
|
||||
currentAirplane = null;
|
||||
isHolding = false;
|
||||
@@ -216,6 +250,12 @@ namespace Minigames.Airplane.UI
|
||||
|
||||
private void HandleAbilityActivated(BaseAirplaneAbility ability)
|
||||
{
|
||||
// Show active state visual if ability has active duration
|
||||
if (ability.HasActiveDuration)
|
||||
{
|
||||
ShowActiveState();
|
||||
}
|
||||
|
||||
if (showDebugLogs)
|
||||
{
|
||||
Logging.Debug($"[AirplaneAbilityButton] Ability activated: {ability.AbilityName}");
|
||||
@@ -224,6 +264,9 @@ namespace Minigames.Airplane.UI
|
||||
|
||||
private void HandleAbilityDeactivated(BaseAirplaneAbility ability)
|
||||
{
|
||||
// Hide active state visual
|
||||
HideActiveState();
|
||||
|
||||
if (showDebugLogs)
|
||||
{
|
||||
Logging.Debug($"[AirplaneAbilityButton] Ability deactivated: {ability.AbilityName}");
|
||||
@@ -249,6 +292,14 @@ namespace Minigames.Airplane.UI
|
||||
}
|
||||
}
|
||||
|
||||
private void HandleActiveDurationChanged(float remaining, float total)
|
||||
{
|
||||
if (showDebugLogs)
|
||||
{
|
||||
Logging.Debug($"[AirplaneAbilityButton] OnActiveDurationChanged: remaining={remaining:F2}, total={total:F2}");
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ITouchInputConsumer Implementation
|
||||
@@ -295,6 +346,43 @@ namespace Minigames.Airplane.UI
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Active State Visual API
|
||||
|
||||
/// <summary>
|
||||
/// Show active state visual (placeholder API).
|
||||
/// Override or assign activeStateVisual GameObject in inspector for custom visuals.
|
||||
/// </summary>
|
||||
private void ShowActiveState()
|
||||
{
|
||||
if (activeStateVisual != null)
|
||||
{
|
||||
activeStateVisual.SetActive(true);
|
||||
|
||||
if (showDebugLogs)
|
||||
{
|
||||
Logging.Debug("[AirplaneAbilityButton] Active state visual shown");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Hide active state visual (placeholder API).
|
||||
/// </summary>
|
||||
private void HideActiveState()
|
||||
{
|
||||
if (activeStateVisual != null)
|
||||
{
|
||||
activeStateVisual.SetActive(false);
|
||||
|
||||
if (showDebugLogs)
|
||||
{
|
||||
Logging.Debug("[AirplaneAbilityButton] Active state visual hidden");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user