RewardBubble
Overview
Clickable UI bubble that pops in, waits for a short lifetime, and either times out or pops out when clicked, granting a reward. Rewards can affect Money, Loyalty, or any of the three Affinities (Mobster, Schemer, Subterfuge).
Atoms & UI
- BoolVariable
paused— lifetime timer stops while paused. - FloatVariable
currentMoney,moneyGain,loyalty,affinityMobster,affinitySchemer,affinitySubterfuge. - Image
icon— sprite set per reward type. - Sprite set for each reward (money/loyalty/affinities).
Rewards
- Money:
currentMoney += moneyReward * moneyGain.Value - Loyalty:
loyalty += loyaltyReward - Affinities:
affinityX += affinityXReward
Default values (tweakable): moneyReward=50, loyaltyReward=0.1, affinityXReward=1.
Lifecycle
Spawn(RewardType, Vector2)- Positions the bubble, sets sprite, resets scale to 0, starts pop-in animation and lifetime countdown.
OnClick()- Applies the reward immediately and triggers a faster pop-out animation.
- Lifetime (
lifetime, default2s)- Counts down only when not paused. When it expires, the bubble hides itself.
Animation
- Pop curve: customizable
AnimationCurvewith overshoot for a bouncy feel. - popDuration:
0.55s - clickSpeedMultiplier: speeds up the reverse animation on click (default
1.5).
Enum
public enum RewardType { MONEY, LOYALTY, AFFINITY_MOBSTER, AFFINITY_SCHEMER, AFFINITY_SUBTERFUGE, LAST }
Notes
- Internally safeguards against double-clicks during the close animation.
- Resets
transform.localScaleto 1 after timeout; to 0 after a click-out.