update : gameover

This commit is contained in:
Horoli 2025-12-04 17:22:55 +09:00
parent 37a634643e
commit 0dccab9eec
2 changed files with 74 additions and 0 deletions

View File

@ -13,6 +13,7 @@ import '../widgets/battle/character_status_card.dart';
import '../widgets/battle/battle_log_overlay.dart';
import '../widgets/battle/floating_battle_texts.dart';
import '../widgets/battle/stage_ui.dart';
import 'main_menu_screen.dart';
class BattleScreen extends StatefulWidget {
const BattleScreen({super.key});
@ -527,6 +528,50 @@ class _BattleScreenState extends State<BattleScreen> {
..._floatingDamageTexts.map((e) => e.widget),
..._floatingEffects.map((e) => e.widget),
..._floatingFeedbackTexts.map((e) => e.widget),
// Game Over Overlay
if (battleProvider.player.isDead)
Container(
color: Colors.black87,
child: Center(
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
const Text(
"DEFEAT",
style: TextStyle(
color: Colors.red,
fontSize: 48,
fontWeight: FontWeight.bold,
letterSpacing: 4.0,
),
),
const SizedBox(height: 32),
ElevatedButton(
style: ElevatedButton.styleFrom(
backgroundColor: Colors.grey[800],
padding: const EdgeInsets.symmetric(
horizontal: 32,
vertical: 16,
),
),
onPressed: () {
Navigator.of(context).pushAndRemoveUntil(
MaterialPageRoute(
builder: (context) => const MainMenuScreen(),
),
(route) => false,
);
},
child: const Text(
"Return to Main Menu",
style: TextStyle(color: Colors.white, fontSize: 18),
),
),
],
),
),
),
],
);
},

View File

@ -0,0 +1,29 @@
# 게임 오버 화면 구현 (Game Over Screen)
## 목표
플레이어 사망 시 게임 진행을 중단하고, 패배를 알리는 화면과 함께 메인 메뉴로 돌아갈 수 있는 기능을 제공합니다.
## 요구사항
1. **입력 차단:** 플레이어 사망 시 공격/방어 등 모든 전투 조작 버튼을 비활성화합니다.
2. **패배 화면:**
- 화면 중앙에 "Defeat" 텍스트 또는 이미지 표시.
- "Return to Main Menu" 버튼 표시.
3. **메인 메뉴 이동:** 버튼 클릭 시 현재 게임 상태를 초기화하고 메인 메뉴(`MainMenuScreen`)로 이동합니다.
## 구현 계획
### 1. UI 변경 (`lib/screens/battle_screen.dart`)
- `BattleProvider``player.isDead` 상태를 감지하여 오버레이를 표시합니다.
- 기존 버튼(`FloatingActionButton` 등)의 `onPressed``null`로 처리하거나 화면을 덮는 오버레이로 입력을 막습니다.
### 2. 로직 변경 (`lib/providers/battle_provider.dart`)
- (필요 시) 게임 오버 상태를 명확히 관리하는 플래그 추가 또는 기존 `player.isDead` 활용.
- 메인 메뉴로 돌아갈 때 상태를 초기화하는 메서드(`resetGame` 등) 확인.
## 결과
플레이어 체력이 0이 되면 전투가 멈추고 게임 오버 화면이 출력되며, 버튼을 통해 타이틀 화면으로 돌아갈 수 있습니다.