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, IntVariablelastAbilityCooldown— global cooldown bookkeeping. - BoolVariable
paused— toggled true when the panel opens; false on confirm/deny. - VoidEvent
enableTimeControls, VoidEventdisableTimeControls— 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
- Start() →
abilitySelected.Register(OnAbilitySelected). - OnAbilitySelected(GameObject abilityObj)
selectedAbility = abilityObj.GetComponent<ChairmanAbility>().- Gate: only proceed if
sharedAbilityCooldown.Value <= 0andselectedAbility.IsValid(). - Show panel and fill text:
abilityTitle.text = selectedAbility.AbilityTitle()descText.text = selectedAbility.AbilityDescription()cooldownTextis set from I2 keyABILITY_COOLDOWN, replacing{time}withselectedAbility.AbilityCooldown * 0.4f(seconds at normal tick rate).
- Pause and disable time controls:
paused.SetValue(true, true); disableTimeControls.Raise();
- 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();
- 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
abilitySelectedwith their GameObject. - Provide the
ABILITY_COOLDOWNkey in your localization tables.