update
This commit is contained in:
+194
-150
@@ -1,13 +1,14 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:game_test/game/model/item.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import '../providers/battle_provider.dart';
|
||||
import '../game/model/entity.dart';
|
||||
import '../game/enums.dart';
|
||||
|
||||
import '../game/model/item.dart';
|
||||
import '../game/model/damage_event.dart';
|
||||
import '../game/model/effect_event.dart';
|
||||
import 'dart:async'; // StreamSubscription
|
||||
import 'dart:async';
|
||||
import '../widgets/responsive_container.dart';
|
||||
import '../utils/item_utils.dart';
|
||||
|
||||
class BattleScreen extends StatefulWidget {
|
||||
const BattleScreen({super.key});
|
||||
@@ -24,18 +25,17 @@ class _BattleScreenState extends State<BattleScreen> {
|
||||
StreamSubscription<EffectEvent>? _effectSubscription;
|
||||
final GlobalKey _playerKey = GlobalKey();
|
||||
final GlobalKey _enemyKey = GlobalKey();
|
||||
final GlobalKey _stackKey = GlobalKey();
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
// Scroll to the bottom of the log when new messages are added
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
if (_scrollController.hasClients) {
|
||||
_scrollController.jumpTo(_scrollController.position.maxScrollExtent);
|
||||
}
|
||||
});
|
||||
|
||||
// Subscribe to Damage Stream
|
||||
final battleProvider = context.read<BattleProvider>();
|
||||
_damageSubscription = battleProvider.damageStream.listen(
|
||||
_addFloatingDamageText,
|
||||
@@ -68,13 +68,13 @@ class _BattleScreenState extends State<BattleScreen> {
|
||||
|
||||
Offset position = renderBox.localToGlobal(Offset.zero);
|
||||
|
||||
RenderBox? stackRenderBox = context.findRenderObject() as RenderBox?;
|
||||
RenderBox? stackRenderBox =
|
||||
_stackKey.currentContext?.findRenderObject() as RenderBox?;
|
||||
if (stackRenderBox != null) {
|
||||
Offset stackOffset = stackRenderBox.localToGlobal(Offset.zero);
|
||||
position = position - stackOffset;
|
||||
}
|
||||
|
||||
// 중앙 정렬 보정 및 위쪽으로 이동
|
||||
position = position + Offset(renderBox.size.width / 2 - 20, -20);
|
||||
|
||||
final String id = UniqueKey().toString();
|
||||
@@ -119,13 +119,14 @@ class _BattleScreenState extends State<BattleScreen> {
|
||||
if (renderBox == null) return;
|
||||
|
||||
Offset position = renderBox.localToGlobal(Offset.zero);
|
||||
RenderBox? stackRenderBox = context.findRenderObject() as RenderBox?;
|
||||
|
||||
RenderBox? stackRenderBox =
|
||||
_stackKey.currentContext?.findRenderObject() as RenderBox?;
|
||||
if (stackRenderBox != null) {
|
||||
Offset stackOffset = stackRenderBox.localToGlobal(Offset.zero);
|
||||
position = position - stackOffset;
|
||||
}
|
||||
|
||||
// 중앙 정렬
|
||||
position =
|
||||
position +
|
||||
Offset(renderBox.size.width / 2 - 30, renderBox.size.height / 2 - 30);
|
||||
@@ -248,7 +249,6 @@ class _BattleScreenState extends State<BattleScreen> {
|
||||
onPressed: () {
|
||||
context.read<BattleProvider>().playerAction(actionType, risk);
|
||||
Navigator.pop(context);
|
||||
// Ensure the log scrolls to the bottom after action
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
_scrollController.animateTo(
|
||||
_scrollController.position.maxScrollExtent,
|
||||
@@ -279,132 +279,135 @@ class _BattleScreenState extends State<BattleScreen> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Consumer<BattleProvider>(
|
||||
builder: (context, provider, child) => Text(
|
||||
"Colosseum - Stage ${provider.stage} (${provider.currentStage.type.name.toUpperCase()})",
|
||||
),
|
||||
),
|
||||
actions: [
|
||||
IconButton(
|
||||
icon: const Icon(Icons.refresh),
|
||||
onPressed: () => context.read<BattleProvider>().initializeBattle(),
|
||||
),
|
||||
],
|
||||
),
|
||||
body: Consumer<BattleProvider>(
|
||||
return ResponsiveContainer(
|
||||
child: Consumer<BattleProvider>(
|
||||
builder: (context, battleProvider, child) {
|
||||
// UI Switching based on Stage Type
|
||||
if (battleProvider.currentStage.type == StageType.shop) {
|
||||
return Center(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
const Icon(Icons.store, size: 64, color: Colors.amber),
|
||||
const SizedBox(height: 16),
|
||||
const Text("Merchant Shop", style: TextStyle(fontSize: 24)),
|
||||
const SizedBox(height: 8),
|
||||
const Text("Buying/Selling feature coming soon!"),
|
||||
const SizedBox(height: 32),
|
||||
ElevatedButton(
|
||||
onPressed: () => battleProvider.proceedToNextStage(),
|
||||
child: const Text("Leave Shop"),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
return _buildShopUI(context, battleProvider);
|
||||
} else if (battleProvider.currentStage.type == StageType.rest) {
|
||||
return Center(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
const Icon(Icons.local_hotel, size: 64, color: Colors.blue),
|
||||
const SizedBox(height: 16),
|
||||
const Text("Rest Area", style: TextStyle(fontSize: 24)),
|
||||
const SizedBox(height: 8),
|
||||
const Text("Take a breath and heal."),
|
||||
const SizedBox(height: 32),
|
||||
ElevatedButton(
|
||||
onPressed: () {
|
||||
battleProvider.player.heal(20); // Simple heal
|
||||
battleProvider.proceedToNextStage();
|
||||
},
|
||||
child: const Text("Rest & Leave (+20 HP)"),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
return _buildRestUI(context, battleProvider);
|
||||
}
|
||||
|
||||
// Default: Battle UI (for Battle and Elite)
|
||||
return Stack(
|
||||
key: _stackKey,
|
||||
children: [
|
||||
Container(color: Colors.black87),
|
||||
Column(
|
||||
children: [
|
||||
// Top (Status Area)
|
||||
// Top Bar
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
_buildCharacterStatus(
|
||||
battleProvider.enemy,
|
||||
isEnemy: true,
|
||||
key: _enemyKey,
|
||||
Text(
|
||||
"Stage ${battleProvider.stage}",
|
||||
style: const TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 18,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
_buildCharacterStatus(
|
||||
battleProvider.player,
|
||||
isEnemy: false,
|
||||
key: _playerKey,
|
||||
Text(
|
||||
"Turn ${battleProvider.turnCount}",
|
||||
style: const TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 18,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
// Middle (Log Area)
|
||||
|
||||
// Battle Area
|
||||
Expanded(
|
||||
child: Container(
|
||||
color: Colors.black87,
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: ListView.builder(
|
||||
controller: _scrollController,
|
||||
itemCount: battleProvider.battleLogs.length,
|
||||
itemBuilder: (context, index) {
|
||||
return Text(
|
||||
battleProvider.battleLogs[index],
|
||||
style: const TextStyle(
|
||||
color: Colors.white,
|
||||
fontFamily: 'Monospace',
|
||||
fontSize: 12,
|
||||
),
|
||||
);
|
||||
},
|
||||
child: Center(
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
||||
children: [
|
||||
_buildCharacterStatus(
|
||||
battleProvider.player,
|
||||
isPlayer: true,
|
||||
isTurn: battleProvider.isPlayerTurn,
|
||||
key: _playerKey,
|
||||
),
|
||||
// const Text(
|
||||
// "VS",
|
||||
// style: TextStyle(
|
||||
// color: Colors.red,
|
||||
// fontSize: 24,
|
||||
// fontWeight: FontWeight.bold,
|
||||
// ),
|
||||
// ),
|
||||
_buildCharacterStatus(
|
||||
battleProvider.enemy,
|
||||
isPlayer: false,
|
||||
isTurn: !battleProvider.isPlayerTurn,
|
||||
key: _enemyKey,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
// Bottom (Control Area)
|
||||
|
||||
// Action Buttons
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
child: Column(
|
||||
children: [
|
||||
_buildActionButton(
|
||||
context,
|
||||
"ATTACK",
|
||||
ActionType.attack,
|
||||
battleProvider.isPlayerTurn &&
|
||||
!battleProvider.player.isDead &&
|
||||
!battleProvider.enemy.isDead &&
|
||||
!battleProvider.showRewardPopup,
|
||||
),
|
||||
_buildActionButton(
|
||||
context,
|
||||
"DEFEND",
|
||||
ActionType.defend,
|
||||
battleProvider.isPlayerTurn &&
|
||||
!battleProvider.player.isDead &&
|
||||
!battleProvider.enemy.isDead &&
|
||||
!battleProvider.showRewardPopup,
|
||||
if (battleProvider.logs.isNotEmpty)
|
||||
Container(
|
||||
height: 60,
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.black54,
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
child: ListView.builder(
|
||||
reverse: true,
|
||||
itemCount: battleProvider.logs.length,
|
||||
itemBuilder: (context, index) {
|
||||
final logIndex =
|
||||
battleProvider.logs.length - 1 - index;
|
||||
return Text(
|
||||
battleProvider.logs[logIndex],
|
||||
style: const TextStyle(
|
||||
color: Colors.white70,
|
||||
fontSize: 12,
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
Card(
|
||||
color: Colors.grey[900],
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||
children: [
|
||||
_buildActionButton(
|
||||
context,
|
||||
"ATTACK",
|
||||
ActionType.attack,
|
||||
battleProvider.isPlayerTurn &&
|
||||
!battleProvider.player.isDead &&
|
||||
!battleProvider.enemy.isDead &&
|
||||
!battleProvider.showRewardPopup,
|
||||
),
|
||||
_buildActionButton(
|
||||
context,
|
||||
"DEFEND",
|
||||
ActionType.defend,
|
||||
battleProvider.isPlayerTurn &&
|
||||
!battleProvider.player.isDead &&
|
||||
!battleProvider.enemy.isDead &&
|
||||
!battleProvider.showRewardPopup,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
@@ -425,13 +428,32 @@ class _BattleScreenState extends State<BattleScreen> {
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
item.name,
|
||||
style: const TextStyle(
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
Row(
|
||||
children: [
|
||||
Container(
|
||||
padding: const EdgeInsets.all(4),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.blueGrey[700],
|
||||
borderRadius: BorderRadius.circular(4),
|
||||
border: Border.all(color: Colors.grey),
|
||||
),
|
||||
child: Icon(
|
||||
ItemUtils.getIcon(item.slot),
|
||||
color: ItemUtils.getColor(item.slot),
|
||||
size: 24,
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 12),
|
||||
Text(
|
||||
item.name,
|
||||
style: const TextStyle(
|
||||
fontWeight: FontWeight.bold,
|
||||
fontSize: 16,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
_buildItemStatText(item), // Display stats here
|
||||
_buildItemStatText(item),
|
||||
Text(
|
||||
item.description,
|
||||
style: const TextStyle(
|
||||
@@ -455,6 +477,49 @@ class _BattleScreenState extends State<BattleScreen> {
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildShopUI(BuildContext context, BattleProvider battleProvider) {
|
||||
return Center(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
const Icon(Icons.store, size: 64, color: Colors.amber),
|
||||
const SizedBox(height: 16),
|
||||
const Text("Merchant Shop", style: TextStyle(fontSize: 24)),
|
||||
const SizedBox(height: 8),
|
||||
const Text("Buying/Selling feature coming soon!"),
|
||||
const SizedBox(height: 32),
|
||||
ElevatedButton(
|
||||
onPressed: () => battleProvider.proceedToNextStage(),
|
||||
child: const Text("Leave Shop"),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildRestUI(BuildContext context, BattleProvider battleProvider) {
|
||||
return Center(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
const Icon(Icons.local_hotel, size: 64, color: Colors.blue),
|
||||
const SizedBox(height: 16),
|
||||
const Text("Rest Area", style: TextStyle(fontSize: 24)),
|
||||
const SizedBox(height: 8),
|
||||
const Text("Take a breath and heal."),
|
||||
const SizedBox(height: 32),
|
||||
ElevatedButton(
|
||||
onPressed: () {
|
||||
battleProvider.player.heal(20);
|
||||
battleProvider.proceedToNextStage();
|
||||
},
|
||||
child: const Text("Rest & Leave (+20 HP)"),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildItemStatText(Item item) {
|
||||
List<String> stats = [];
|
||||
if (item.atkBonus > 0) stats.add("+${item.atkBonus} ATK");
|
||||
@@ -490,12 +555,14 @@ class _BattleScreenState extends State<BattleScreen> {
|
||||
|
||||
Widget _buildCharacterStatus(
|
||||
Character character, {
|
||||
bool isEnemy = false,
|
||||
bool isPlayer = false,
|
||||
bool isTurn = false,
|
||||
Key? key,
|
||||
}) {
|
||||
return Column(
|
||||
key: key,
|
||||
children: [
|
||||
Text("Armor: ${character.armor}"),
|
||||
Text(
|
||||
"${character.name}: HP ${character.hp}/${character.totalMaxHp}",
|
||||
style: TextStyle(
|
||||
@@ -509,11 +576,10 @@ class _BattleScreenState extends State<BattleScreen> {
|
||||
value: character.totalMaxHp > 0
|
||||
? character.hp / character.totalMaxHp
|
||||
: 0,
|
||||
color: isEnemy ? Colors.red : Colors.green,
|
||||
color: !isPlayer ? Colors.red : Colors.green,
|
||||
backgroundColor: Colors.grey,
|
||||
),
|
||||
),
|
||||
// Display Active Status Effects
|
||||
if (character.statusEffects.isNotEmpty)
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(top: 4.0),
|
||||
@@ -541,7 +607,10 @@ class _BattleScreenState extends State<BattleScreen> {
|
||||
}).toList(),
|
||||
),
|
||||
),
|
||||
if (isEnemy)
|
||||
Text("ATK: ${character.totalAtk}"),
|
||||
Text("DEF: ${character.totalDefense}"),
|
||||
|
||||
if (!isPlayer)
|
||||
Consumer<BattleProvider>(
|
||||
builder: (context, provider, child) {
|
||||
if (provider.currentEnemyIntent != null && !character.isDead) {
|
||||
@@ -593,11 +662,6 @@ class _BattleScreenState extends State<BattleScreen> {
|
||||
return const SizedBox.shrink();
|
||||
},
|
||||
),
|
||||
if (!isEnemy) ...[
|
||||
Text("Armor: ${character.armor}"),
|
||||
Text("ATK: ${character.totalAtk}"),
|
||||
Text("DEF: ${character.totalDefense}"),
|
||||
],
|
||||
],
|
||||
);
|
||||
}
|
||||
@@ -655,24 +719,19 @@ class __FloatingDamageTextState extends State<_FloatingDamageText>
|
||||
|
||||
_offsetAnimation = Tween<Offset>(
|
||||
begin: const Offset(0.0, 0.0),
|
||||
end: const Offset(0.0, -1.5), // 위로 띄울 높이
|
||||
end: const Offset(0.0, -1.5),
|
||||
).animate(CurvedAnimation(parent: _controller, curve: Curves.easeOut));
|
||||
|
||||
_opacityAnimation = Tween<double>(begin: 1.0, end: 0.0).animate(
|
||||
CurvedAnimation(
|
||||
parent: _controller,
|
||||
curve: const Interval(
|
||||
0.5,
|
||||
1.0,
|
||||
curve: Curves.easeOut,
|
||||
), // 절반 이후부터 투명도 감소
|
||||
curve: const Interval(0.5, 1.0, curve: Curves.easeOut),
|
||||
),
|
||||
);
|
||||
|
||||
_controller.forward().then((_) {
|
||||
if (mounted) {
|
||||
widget.onRemove(); // 애니메이션 완료 후 콜백 호출하여 위젯 제거 요청
|
||||
// _controller.dispose(); // 제거: dispose() 메서드에서 처리됨
|
||||
widget.onRemove();
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -719,7 +778,6 @@ class __FloatingDamageTextState extends State<_FloatingDamageText>
|
||||
|
||||
class _DamageTextData {
|
||||
final String id;
|
||||
|
||||
final Widget widget;
|
||||
|
||||
_DamageTextData({required this.id, required this.widget});
|
||||
@@ -733,13 +791,9 @@ class _FloatingEffect extends StatefulWidget {
|
||||
|
||||
const _FloatingEffect({
|
||||
Key? key,
|
||||
|
||||
required this.icon,
|
||||
|
||||
required this.color,
|
||||
|
||||
required this.size,
|
||||
|
||||
required this.onRemove,
|
||||
}) : super(key: key);
|
||||
|
||||
@@ -750,18 +804,14 @@ class _FloatingEffect extends StatefulWidget {
|
||||
class __FloatingEffectState extends State<_FloatingEffect>
|
||||
with SingleTickerProviderStateMixin {
|
||||
late AnimationController _controller;
|
||||
|
||||
late Animation<double> _scaleAnimation;
|
||||
|
||||
late Animation<double> _opacityAnimation;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
|
||||
_controller = AnimationController(
|
||||
duration: const Duration(milliseconds: 800),
|
||||
|
||||
vsync: this,
|
||||
);
|
||||
|
||||
@@ -773,7 +823,6 @@ class __FloatingEffectState extends State<_FloatingEffect>
|
||||
_opacityAnimation = Tween<double>(begin: 1.0, end: 0.0).animate(
|
||||
CurvedAnimation(
|
||||
parent: _controller,
|
||||
|
||||
curve: const Interval(0.5, 1.0, curve: Curves.easeOut),
|
||||
),
|
||||
);
|
||||
@@ -788,7 +837,6 @@ class __FloatingEffectState extends State<_FloatingEffect>
|
||||
@override
|
||||
void dispose() {
|
||||
_controller.dispose();
|
||||
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@@ -796,14 +844,11 @@ class __FloatingEffectState extends State<_FloatingEffect>
|
||||
Widget build(BuildContext context) {
|
||||
return AnimatedBuilder(
|
||||
animation: _controller,
|
||||
|
||||
builder: (context, child) {
|
||||
return Transform.scale(
|
||||
scale: _scaleAnimation.value,
|
||||
|
||||
child: Opacity(
|
||||
opacity: _opacityAnimation.value,
|
||||
|
||||
child: Icon(widget.icon, color: widget.color, size: widget.size),
|
||||
),
|
||||
);
|
||||
@@ -814,7 +859,6 @@ class __FloatingEffectState extends State<_FloatingEffect>
|
||||
|
||||
class _FloatingEffectData {
|
||||
final String id;
|
||||
|
||||
final Widget widget;
|
||||
|
||||
_FloatingEffectData({required this.id, required this.widget});
|
||||
|
||||
@@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import '../providers/battle_provider.dart';
|
||||
import 'main_wrapper.dart';
|
||||
import '../widgets/responsive_container.dart';
|
||||
|
||||
class CharacterSelectionScreen extends StatelessWidget {
|
||||
const CharacterSelectionScreen({super.key});
|
||||
@@ -9,63 +10,85 @@ class CharacterSelectionScreen extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: const Text("Choose Your Hero"),
|
||||
centerTitle: true,
|
||||
),
|
||||
backgroundColor: Colors.black, // Outer background
|
||||
body: Center(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
child: InkWell(
|
||||
onTap: () {
|
||||
// Initialize Game
|
||||
context.read<BattleProvider>().initializeBattle();
|
||||
|
||||
// Navigate to Game Screen (MainWrapper)
|
||||
// Using pushReplacement to prevent going back to selection
|
||||
Navigator.pushAndRemoveUntil(
|
||||
context,
|
||||
MaterialPageRoute(builder: (context) => const MainWrapper()),
|
||||
(route) => false,
|
||||
);
|
||||
},
|
||||
child: Card(
|
||||
color: Colors.blueGrey[800],
|
||||
elevation: 8,
|
||||
child: Container(
|
||||
width: 300,
|
||||
padding: const EdgeInsets.all(24.0),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
const Icon(Icons.shield, size: 80, color: Colors.blue),
|
||||
const SizedBox(height: 16),
|
||||
const Text(
|
||||
"Warrior",
|
||||
style: TextStyle(
|
||||
fontSize: 24,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Colors.white,
|
||||
child: ResponsiveContainer(
|
||||
child: Scaffold(
|
||||
appBar: AppBar(
|
||||
title: const Text("Choose Your Hero"),
|
||||
centerTitle: true,
|
||||
),
|
||||
body: Center(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
child: InkWell(
|
||||
onTap: () {
|
||||
// Initialize Game
|
||||
context.read<BattleProvider>().initializeBattle();
|
||||
|
||||
// Navigate to Game Screen (MainWrapper)
|
||||
// Using pushReplacement to prevent going back to selection
|
||||
Navigator.pushAndRemoveUntil(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => const MainWrapper(),
|
||||
),
|
||||
(route) => false,
|
||||
);
|
||||
},
|
||||
child: Card(
|
||||
color: Colors.blueGrey[800],
|
||||
elevation: 8,
|
||||
child: Container(
|
||||
width: 300,
|
||||
padding: const EdgeInsets.all(24.0),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
const Icon(
|
||||
Icons.shield,
|
||||
size: 80,
|
||||
color: Colors.blue,
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
const Text(
|
||||
"Warrior",
|
||||
style: TextStyle(
|
||||
fontSize: 24,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Colors.white,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
const Text(
|
||||
"A balanced fighter with a sword and shield. Great for beginners.",
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(color: Colors.grey),
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
const Divider(),
|
||||
const SizedBox(height: 8),
|
||||
const Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||
children: [
|
||||
Text(
|
||||
"HP: 80",
|
||||
style: TextStyle(fontWeight: FontWeight.bold),
|
||||
),
|
||||
Text(
|
||||
"ATK: 5",
|
||||
style: TextStyle(fontWeight: FontWeight.bold),
|
||||
),
|
||||
Text(
|
||||
"DEF: 5",
|
||||
style: TextStyle(fontWeight: FontWeight.bold),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
const Text(
|
||||
"A balanced fighter with a sword and shield. Great for beginners.",
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(color: Colors.grey),
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
const Divider(),
|
||||
const SizedBox(height: 8),
|
||||
const Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||
children: [
|
||||
Text("HP: 100", style: TextStyle(fontWeight: FontWeight.bold)),
|
||||
Text("ATK: 10", style: TextStyle(fontWeight: FontWeight.bold)),
|
||||
Text("DEF: 5", style: TextStyle(fontWeight: FontWeight.bold)),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
@@ -3,6 +3,7 @@ import 'package:provider/provider.dart';
|
||||
import '../providers/battle_provider.dart';
|
||||
import '../game/model/item.dart';
|
||||
import '../game/enums.dart';
|
||||
import '../utils/item_utils.dart';
|
||||
|
||||
class InventoryScreen extends StatelessWidget {
|
||||
const InventoryScreen({super.key});
|
||||
@@ -101,10 +102,10 @@ class InventoryScreen extends StatelessWidget {
|
||||
),
|
||||
const SizedBox(height: 4),
|
||||
Icon(
|
||||
_getIconForSlot(slot),
|
||||
ItemUtils.getIcon(slot),
|
||||
size: 24,
|
||||
color: item != null
|
||||
? Colors.white
|
||||
? ItemUtils.getColor(slot)
|
||||
: Colors.grey,
|
||||
),
|
||||
const SizedBox(height: 4),
|
||||
@@ -171,7 +172,11 @@ class InventoryScreen extends StatelessWidget {
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
const Icon(Icons.backpack, size: 32),
|
||||
Icon(
|
||||
ItemUtils.getIcon(item.slot),
|
||||
size: 32,
|
||||
color: ItemUtils.getColor(item.slot),
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(4.0),
|
||||
child: Text(
|
||||
@@ -208,19 +213,6 @@ class InventoryScreen extends StatelessWidget {
|
||||
);
|
||||
}
|
||||
|
||||
IconData _getIconForSlot(EquipmentSlot slot) {
|
||||
switch (slot) {
|
||||
case EquipmentSlot.weapon:
|
||||
return Icons.g_mobiledata; // Using a generic 'game' icon for weapon
|
||||
case EquipmentSlot.armor:
|
||||
return Icons.checkroom;
|
||||
case EquipmentSlot.shield:
|
||||
return Icons.shield;
|
||||
case EquipmentSlot.accessory:
|
||||
return Icons.diamond;
|
||||
}
|
||||
}
|
||||
|
||||
Widget _buildStatItem(String label, String value, {Color? color}) {
|
||||
return Column(
|
||||
children: [
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'character_selection_screen.dart';
|
||||
import '../widgets/responsive_container.dart';
|
||||
|
||||
class MainMenuScreen extends StatelessWidget {
|
||||
const MainMenuScreen({super.key});
|
||||
@@ -16,50 +17,56 @@ class MainMenuScreen extends StatelessWidget {
|
||||
colors: [Colors.black, Colors.blueGrey[900]!],
|
||||
),
|
||||
),
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
const Icon(Icons.gavel, size: 100, color: Colors.amber),
|
||||
const SizedBox(height: 20),
|
||||
const Text(
|
||||
"COLOSSEUM'S CHOICE",
|
||||
style: TextStyle(
|
||||
fontSize: 32,
|
||||
fontWeight: FontWeight.bold,
|
||||
letterSpacing: 2.0,
|
||||
color: Colors.white,
|
||||
child: ResponsiveContainer(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
const Icon(Icons.gavel, size: 100, color: Colors.amber),
|
||||
const SizedBox(height: 20),
|
||||
const Text(
|
||||
"COLOSSEUM'S CHOICE",
|
||||
style: TextStyle(
|
||||
fontSize: 32,
|
||||
fontWeight: FontWeight.bold,
|
||||
letterSpacing: 2.0,
|
||||
color: Colors.white,
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
const Text(
|
||||
"Rise as a Legend",
|
||||
style: TextStyle(
|
||||
fontSize: 16,
|
||||
color: Colors.grey,
|
||||
fontStyle: FontStyle.italic,
|
||||
const SizedBox(height: 10),
|
||||
const Text(
|
||||
"Rise as a Legend",
|
||||
style: TextStyle(
|
||||
fontSize: 16,
|
||||
color: Colors.grey,
|
||||
fontStyle: FontStyle.italic,
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 60),
|
||||
ElevatedButton(
|
||||
onPressed: () {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => const CharacterSelectionScreen(),
|
||||
const SizedBox(height: 60),
|
||||
ElevatedButton(
|
||||
onPressed: () {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => const CharacterSelectionScreen(),
|
||||
),
|
||||
);
|
||||
},
|
||||
style: ElevatedButton.styleFrom(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 50,
|
||||
vertical: 15,
|
||||
),
|
||||
);
|
||||
},
|
||||
style: ElevatedButton.styleFrom(
|
||||
padding:
|
||||
const EdgeInsets.symmetric(horizontal: 50, vertical: 15),
|
||||
backgroundColor: Colors.amber[700],
|
||||
foregroundColor: Colors.black,
|
||||
textStyle:
|
||||
const TextStyle(fontSize: 20, fontWeight: FontWeight.bold),
|
||||
backgroundColor: Colors.amber[700],
|
||||
foregroundColor: Colors.black,
|
||||
textStyle: const TextStyle(
|
||||
fontSize: 20,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
child: const Text("START GAME"),
|
||||
),
|
||||
child: const Text("START GAME"),
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'battle_screen.dart';
|
||||
import 'inventory_screen.dart';
|
||||
import '../widgets/responsive_container.dart';
|
||||
|
||||
class MainWrapper extends StatefulWidget {
|
||||
const MainWrapper({super.key});
|
||||
@@ -12,35 +13,36 @@ class MainWrapper extends StatefulWidget {
|
||||
class _MainWrapperState extends State<MainWrapper> {
|
||||
int _currentIndex = 0;
|
||||
|
||||
final List<Widget> _screens = [
|
||||
const BattleScreen(),
|
||||
const InventoryScreen(),
|
||||
];
|
||||
final List<Widget> _screens = [const BattleScreen(), const InventoryScreen()];
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
body: IndexedStack(
|
||||
index: _currentIndex,
|
||||
children: _screens,
|
||||
),
|
||||
bottomNavigationBar: BottomNavigationBar(
|
||||
currentIndex: _currentIndex,
|
||||
onTap: (index) {
|
||||
setState(() {
|
||||
_currentIndex = index;
|
||||
});
|
||||
},
|
||||
items: const [
|
||||
BottomNavigationBarItem(
|
||||
icon: Icon(Icons.flash_on),
|
||||
label: 'Battle',
|
||||
backgroundColor: Colors.black, // Outer background for web
|
||||
body: Center(
|
||||
child: ResponsiveContainer(
|
||||
child: Scaffold(
|
||||
body: IndexedStack(index: _currentIndex, children: _screens),
|
||||
bottomNavigationBar: BottomNavigationBar(
|
||||
currentIndex: _currentIndex,
|
||||
onTap: (index) {
|
||||
setState(() {
|
||||
_currentIndex = index;
|
||||
});
|
||||
},
|
||||
items: const [
|
||||
BottomNavigationBarItem(
|
||||
icon: Icon(Icons.flash_on),
|
||||
label: 'Battle',
|
||||
),
|
||||
BottomNavigationBarItem(
|
||||
icon: Icon(Icons.backpack),
|
||||
label: 'Inventory',
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
BottomNavigationBarItem(
|
||||
icon: Icon(Icons.backpack),
|
||||
label: 'Inventory',
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user