AbilityConfirmPanelUI

Overview

Confirmation overlay for triggering a selected ChairmanAbility. When an ability is clicked, this panel displays the title, description, and a localized cooldown string, then pauses gameplay until the player confirms or cancels. On confirm it sets the shared cooldown, invokes the ability effect, refreshes its UI, and resumes time.

Serialized Atoms & Events

  • GameObjectEvent abilitySelected — raised by ability buttons/cards; payload is the ability GameObject.
  • IntVariable sharedAbilityCooldown, IntVariable lastAbilityCooldown — global cooldown bookkeeping.
  • BoolVariable paused — toggled true when the panel opens; false on confirm/deny.
  • VoidEvent enableTimeControls, VoidEvent disableTimeControls — disable while confirming; re-enable afterwards.

UI References

  • GameObject abilityConfirmPanel — the modal panel root.
  • TextMeshProUGUI abilityTitle, cooldownText, descText — strings filled from the selected ability.

Flow

  1. Start()abilitySelected.Register(OnAbilitySelected).
  2. OnAbilitySelected(GameObject abilityObj)
    • selectedAbility = abilityObj.GetComponent<ChairmanAbility>().
    • Gate: only proceed if sharedAbilityCooldown.Value <= 0 and selectedAbility.IsValid().
    • Show panel and fill text:
      • abilityTitle.text = selectedAbility.AbilityTitle()
      • descText.text = selectedAbility.AbilityDescription()
      • cooldownText is set from I2 key ABILITY_COOLDOWN, replacing {time} with selectedAbility.AbilityCooldown * 0.4f (seconds at normal tick rate).
    • Pause and disable time controls: paused.SetValue(true, true); disableTimeControls.Raise();
  3. OnConfirmButtonPressed()
    • Hide panel.
    • Commit cooldown: sharedAbilityCooldown.Value = lastAbilityCooldown.Value = selectedAbility.AbilityCooldown.
    • Execute: selectedAbility.ApplyEffect(); selectedAbility.UpdateUI();
    • Unpause and re-enable controls: paused.SetValue(false, true); enableTimeControls.Raise();
  4. OnDenyButtonPressed()
    • Hide panel, unpause, and re-enable time controls.

Localization

Uses I2 Localization to build the cooldown line:
LocalizationManager.GetTranslation("ABILITY_COOLDOWN").Replace("{time}", (AbilityCooldown * 0.4f).ToString())
Make sure your I2 Language Source defines ABILITY_COOLDOWN, e.g.:

  • EN: Cooldown: {time}s
  • ES: Enfriamiento: {time}s

Notes

  • The hardcoded multiplier 0.4f converts cooldown ticks to seconds at the project’s normal tick duration. If your tick timing changes, update this multiplier or compute it from your time system.
  • Pausing uses BoolVariable.SetValue(value, raiseEvent: true) so any listeners react immediately.

Integration Checklist

  • Wire the five Atom references and the three TMP fields.
  • Ensure all ability buttons raise abilitySelected with their GameObject.
  • Provide the ABILITY_COOLDOWN key in your localization tables.