91 lines
3.1 KiB
Dart
91 lines
3.1 KiB
Dart
// lib/screens/game_over_screen.dart
|
|
|
|
import 'package:flutter/material.dart';
|
|
import 'package:provider/provider.dart';
|
|
import 'package:kzeduca_app/providers/game_state_provider.dart';
|
|
import 'package:kzeduca_app/screens/character_selection_screen.dart';
|
|
import 'package:kzeduca_app/models/character.dart';
|
|
|
|
class GameOverScreen extends StatelessWidget {
|
|
const GameOverScreen({super.key});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final gameState = Provider.of<GameStateProvider>(context);
|
|
final character = gameState.playerCharacter;
|
|
|
|
String causeOfLoss = '';
|
|
if (character != null) {
|
|
if (character.attributes.money <= 0) {
|
|
causeOfLoss = "Você ficou sem dinheiro e não pôde continuar.";
|
|
} else if (character.attributes.health <= 0) {
|
|
causeOfLoss = "Sua saúde chegou a zero. Infelizmente, você não resistiu.";
|
|
} else if (character.attributes.happiness <= 0) {
|
|
causeOfLoss = "Sua felicidade se esgotou. A falta de ânimo te impediu de seguir em frente.";
|
|
}
|
|
}
|
|
|
|
return Scaffold(
|
|
backgroundColor: const Color(0xFF1E1C3A),
|
|
body: Center(
|
|
child: Padding(
|
|
padding: const EdgeInsets.all(24.0),
|
|
child: Column(
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
children: [
|
|
const Icon(
|
|
Icons.sentiment_dissatisfied,
|
|
color: Colors.redAccent,
|
|
size: 80,
|
|
),
|
|
const SizedBox(height: 20),
|
|
const Text(
|
|
"Fim do Jogo!",
|
|
style: TextStyle(
|
|
fontSize: 32,
|
|
fontWeight: FontWeight.bold,
|
|
color: Colors.white,
|
|
),
|
|
),
|
|
const SizedBox(height: 10),
|
|
Text(
|
|
causeOfLoss,
|
|
textAlign: TextAlign.center,
|
|
style: const TextStyle(
|
|
fontSize: 18,
|
|
color: Colors.white70,
|
|
),
|
|
),
|
|
const SizedBox(height: 40),
|
|
ElevatedButton(
|
|
onPressed: () {
|
|
// Ao pressionar, reinicia o estado do jogo e navega para a tela de seleção
|
|
gameState.restartGame();
|
|
Navigator.of(context).pushAndRemoveUntil(
|
|
MaterialPageRoute(builder: (context) => const CharacterSelectionScreen()),
|
|
(Route<dynamic> route) => false,
|
|
);
|
|
},
|
|
style: ElevatedButton.styleFrom(
|
|
backgroundColor: const Color(0xFFDA70D6),
|
|
padding: const EdgeInsets.symmetric(horizontal: 40, vertical: 15),
|
|
shape: RoundedRectangleBorder(
|
|
borderRadius: BorderRadius.circular(12),
|
|
),
|
|
),
|
|
child: const Text(
|
|
"Tentar Novamente",
|
|
style: TextStyle(
|
|
fontSize: 18,
|
|
fontWeight: FontWeight.bold,
|
|
color: Colors.white,
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
} |