---
name: countdown_timer.aicomponent
description: 倒计时显示器。使用七段数码管风格显示剩余秒数，时间不足时触发闪烁警告动画，归零时通知 LevelLifecycle 触发超时失败。
triggers: 需要实现倒计时 UI 组件时触发。
---

# 倒计时显示器（Countdown Timer Display）

## Scaffold

`src/game/scenes/GameUI/CountdownDisplay.ts`

## Recipe

| 决策 | 原因 |
|------|------|
| **封装 display + 计时 + 警告 + 通知** | 倒计时组件的四个职责（显示、计时、闪烁警告、超时回调）高度关联，分开会造成 GameScene 过多编排逻辑 |
| **依赖 DigitRenderer 而非系统字体** | 七段数码管风格保持视觉一致性；DigitRenderer 是项目内部组件，无字体加载依赖 |
| **闪烁警告阈值** | 最后 10 秒（可配置）才开始闪烁，避免整个关卡都闪烁让玩家焦虑；阈值可通过 GameConfig 调整 |

## Adapter

- **Role**: `countdownTimer` — 倒计时显示器（七段数码管风格 + 警告闪烁 + 超时通知）
- **Provides**: `CountdownDisplay` 类（`start(seconds)`、`stop()`、`update(delta)` 每帧调用）
- **Requires**: `phaser.aicomponent`、`digit_renderer.aicomponent`（七段数码管 Graphics 渲染）
- **Consumed by**: `game_scene.aicomponent`（在 `update()` 中调用 `countdownDisplay.update(delta)`，接收超时回调）
- **Integration point**: `src/game/scenes/GameUI/CountdownDisplay.ts` → 顶部 UI 条或 GameScene 中实例化，`game_scene` `update()` 循环中每帧更新

## Imports

- `phaser.aicomponent`（硬依赖）
- `digit_renderer.aicomponent`（硬依赖：七段数码管绘制）

## Skill Definition

```yaml
tools:
  - read_file
  - write_file
inputs:
  - source: src/game/scenes/GameUI/CountdownDisplay.ts
outputs:
  - countdownDisplay: CountdownDisplay class
```
