Skip to content

Commit 8d1804b

Browse files
authored
Merge pull request #332 from Teicsoft/battle-scene
Final code polish
2 parents 3bea586 + 1ee1e47 commit 8d1804b

11 files changed

Lines changed: 95 additions & 140 deletions

File tree

scenes/sub/transition.tscn

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
[gd_scene load_steps=7 format=3 uid="uid://bkec4arelvorf"]
1+
[gd_scene load_steps=7 format=3 uid="uid://dqv8reex3t0hg"]
22

3-
[ext_resource type="Script" path="res://scripts/battle/transition.cs" id="1_4yu2e"]
4-
[ext_resource type="Texture2D" uid="uid://r72uy6270ak6" path="res://assets/sprites/Dave/Trim.png" id="1_b6e3l"]
5-
[ext_resource type="Theme" uid="uid://bi7ohn58wto5o" path="res://scripts/customresource/roman_font.tres" id="2_4hrw0"]
6-
[ext_resource type="Theme" uid="uid://b4367d11n6l8i" path="res://styles/Nimbus.tres" id="3_p447v"]
7-
[ext_resource type="Texture2D" uid="uid://bd2ts5rilcdyv" path="res://assets/ui/large_button.png" id="4_hv6j5"]
8-
[ext_resource type="FontFile" uid="uid://cb6jcjbshfiq" path="res://assets/fonts/new_jersey/Jersey10-Regular.ttf" id="5_d7tnt"]
3+
[ext_resource type="Script" path="res://scripts/battle/Transition.cs" id="1_lcc5y"]
4+
[ext_resource type="Texture2D" uid="uid://r72uy6270ak6" path="res://assets/sprites/Dave/Trim.png" id="2_j2qka"]
5+
[ext_resource type="Theme" uid="uid://bi7ohn58wto5o" path="res://scripts/customresource/roman_font.tres" id="3_iiwk1"]
6+
[ext_resource type="Theme" uid="uid://b4367d11n6l8i" path="res://styles/Nimbus.tres" id="4_0rr4i"]
7+
[ext_resource type="Texture2D" uid="uid://bd2ts5rilcdyv" path="res://assets/ui/large_button.png" id="5_x35tu"]
8+
[ext_resource type="FontFile" uid="uid://cb6jcjbshfiq" path="res://assets/fonts/new_jersey/Jersey10-Regular.ttf" id="6_l5ira"]
99

1010
[node name="Transition" type="ColorRect"]
1111
anchors_preset = 15
@@ -14,7 +14,7 @@ anchor_bottom = 1.0
1414
grow_horizontal = 2
1515
grow_vertical = 2
1616
color = Color(0.701961, 0.219608, 0.192157, 1)
17-
script = ExtResource("1_4yu2e")
17+
script = ExtResource("1_lcc5y")
1818

1919
[node name="Trims" type="Control" parent="."]
2020
layout_mode = 1
@@ -34,7 +34,7 @@ anchor_bottom = 1.0
3434
offset_left = -52.0
3535
grow_horizontal = 0
3636
grow_vertical = 2
37-
texture = ExtResource("1_b6e3l")
37+
texture = ExtResource("2_j2qka")
3838
flip_v = true
3939

4040
[node name="TrimLeft" type="TextureRect" parent="Trims"]
@@ -43,7 +43,7 @@ anchors_preset = 9
4343
anchor_bottom = 1.0
4444
offset_right = 52.0
4545
grow_vertical = 2
46-
texture = ExtResource("1_b6e3l")
46+
texture = ExtResource("2_j2qka")
4747

4848
[node name="VBoxContainer" type="VBoxContainer" parent="."]
4949
layout_mode = 1
@@ -65,7 +65,7 @@ theme_override_constants/margin_bottom = 20
6565

6666
[node name="Title" type="Label" parent="VBoxContainer/MarginContainer"]
6767
layout_mode = 2
68-
theme = ExtResource("2_4hrw0")
68+
theme = ExtResource("3_iiwk1")
6969
theme_override_font_sizes/font_size = 85
7070
text = "FOE VANQUISHED!"
7171
horizontal_alignment = 1
@@ -78,7 +78,7 @@ theme_override_constants/margin_bottom = 20
7878

7979
[node name="Title2" type="Label" parent="VBoxContainer/MarginContainer3"]
8080
layout_mode = 2
81-
theme = ExtResource("3_p447v")
81+
theme = ExtResource("4_0rr4i")
8282
theme_override_font_sizes/font_size = 37
8383
text = "This round is yours, but CYBIGULA'S BLOODLUST has not yet been SATED!
8484
Will you continue for greater GLORY, or retreat as a COWARD?"
@@ -96,7 +96,7 @@ layout_mode = 2
9696
custom_minimum_size = Vector2(0, 80)
9797
layout_mode = 2
9898
size_flags_horizontal = 3
99-
texture_normal = ExtResource("4_hv6j5")
99+
texture_normal = ExtResource("5_x35tu")
100100
stretch_mode = 5
101101

102102
[node name="Continue" type="Label" parent="VBoxContainer/MarginContainer2/HBoxContainer/Continue Button"]
@@ -115,15 +115,15 @@ grow_vertical = 2
115115
theme_override_colors/font_color = Color(0, 0, 0, 1)
116116
theme_override_colors/font_shadow_color = Color(0.780392, 0.862745, 0.815686, 1)
117117
theme_override_constants/shadow_offset_x = 0
118-
theme_override_fonts/font = ExtResource("5_d7tnt")
118+
theme_override_fonts/font = ExtResource("6_l5ira")
119119
theme_override_font_sizes/font_size = 38
120120
text = "Continue"
121121
horizontal_alignment = 1
122122

123123
[node name="Retreat Button" type="TextureButton" parent="VBoxContainer/MarginContainer2/HBoxContainer"]
124124
layout_mode = 2
125125
size_flags_horizontal = 3
126-
texture_normal = ExtResource("4_hv6j5")
126+
texture_normal = ExtResource("5_x35tu")
127127
stretch_mode = 5
128128

129129
[node name="Retreat" type="Label" parent="VBoxContainer/MarginContainer2/HBoxContainer/Retreat Button"]
@@ -142,7 +142,7 @@ grow_vertical = 2
142142
theme_override_colors/font_color = Color(0, 0, 0, 1)
143143
theme_override_colors/font_shadow_color = Color(0.780392, 0.862745, 0.815686, 1)
144144
theme_override_constants/shadow_offset_x = 0
145-
theme_override_fonts/font = ExtResource("5_d7tnt")
145+
theme_override_fonts/font = ExtResource("6_l5ira")
146146
theme_override_font_sizes/font_size = 38
147147
text = "Retreat"
148148
horizontal_alignment = 1

scripts/autoloads/SceneLoader.cs

Lines changed: 8 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@
55

66
namespace GLADIATE.scripts.autoloads;
77

8-
public partial class SceneLoader : Godot.Node
9-
{
8+
public partial class SceneLoader : Godot.Node {
109
private AudioEngine _audioEngine;
1110
public Node CurrentScene { get; set; }
1211
public List<Dictionary<string, dynamic>> Battles;
@@ -17,9 +16,7 @@ public partial class SceneLoader : Godot.Node
1716
public const string PreBossBattleId = "battle_6";
1817
public const string BossBattleId = "battle_7";
1918

20-
21-
public override void _Ready()
22-
{
19+
public override void _Ready() {
2320
_audioEngine = GetNode<AudioEngine>("/root/audio_engine");
2421

2522
i = 0;
@@ -31,38 +28,26 @@ public override void _Ready()
3128
SpectaclePoints = 0;
3229
}
3330

34-
public void GoToScene(string path)
35-
{
36-
CallDeferred(MethodName.DeferredGotoScene, path);
37-
}
31+
public void GoToScene(string path) { CallDeferred(MethodName.DeferredGotoScene, path); }
3832

39-
public void DeferredGotoScene(string path)
40-
{
33+
public void DeferredGotoScene(string path) {
4134
CurrentScene.Free();
4235
var nextScene = GD.Load<PackedScene>(path);
4336
CurrentScene = nextScene.Instantiate();
4437
GetTree().Root.AddChild(CurrentScene);
4538
GetTree().CurrentScene = CurrentScene;
4639
}
4740

48-
public void GoToNextBattle()
49-
{
50-
if (i < Battles.Count)
51-
{
41+
public void GoToNextBattle() {
42+
if (i < Battles.Count) {
5243
GD.Print("GotoNextBattle");
5344
CallDeferred("DeferredGotoScene", "res://scenes/battle/Battle.tscn");
54-
}
55-
else
56-
{
45+
} else {
5746
GD.Print("GotoVictory");
5847
CallDeferred("DeferredGotoScene", "res://scenes/sub/Victory.tscn");
5948
_audioEngine.PlayMusic("fuck_around_and_find_out_2_electric_boogaloo.mp3");
6049
}
6150
}
6251

63-
64-
public Dictionary<string, dynamic> GetCurrentBattleData()
65-
{
66-
return Battles[i];
67-
}
52+
public Dictionary<string, dynamic> GetCurrentBattleData() { return Battles[i]; }
6853
}

scripts/battle/Battle.cs

Lines changed: 24 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88
using GLADIATE.scripts.battle.target;
99
using GLADIATE.scripts.XmlParsing;
1010
using Godot;
11-
using Godot.Collections;
12-
using Array = Godot.Collections.Array;
1311

1412
namespace GLADIATE.scripts.battle;
1513

@@ -24,36 +22,34 @@ public partial class Battle : Control {
2422
private List<TextureRect> _comboArts = new();
2523

2624
private List<Enemy> _allEnemies;
27-
private System.Collections.Generic.Dictionary<string, List<string>> _allDecks;
25+
private Dictionary<string, List<string>> _allDecks;
2826

2927
public string Id { get; set; }
3028
public string BattleName { get; set; }
3129
public string Music { get; set; }
3230

33-
AudioEngine _audioEngine;
34-
autoloads.SceneLoader _sceneLoader;
31+
private AudioEngine _audioEngine;
32+
private SceneLoader _sceneLoader;
3533

36-
Control cardGlossary;
37-
ComboGlossary comboGlossary;
34+
private Control _cardGlossary;
35+
private ComboGlossary _comboGlossary;
3836

39-
AnimationPlayer animation;
37+
private AnimationPlayer _animation;
4038

4139
public override void _Ready() {
4240
_audioEngine = GetNode<AudioEngine>("/root/audio_engine");
43-
_sceneLoader = GetNode<autoloads.SceneLoader>("/root/SceneLoader");
41+
_sceneLoader = GetNode<SceneLoader>("/root/SceneLoader");
4442

4543
_allEnemies = EnemyXmlParser.ParseAllEnemies();
4644
_allDecks = DeckXmlParser.ParseAllDecks();
4745
_allDecks.TryGetValue(_sceneLoader.DeckSelected, out List<string> playerCardIds);
4846

49-
50-
//UIScaling();
5147
UIScaling();
5248

53-
animation = GetNode<AnimationPlayer>("AnimationPlayer");
54-
animation.Play("RESET");
49+
_animation = GetNode<AnimationPlayer>("AnimationPlayer");
50+
_animation.Play("RESET");
5551

56-
System.Collections.Generic.Dictionary<string, dynamic> battleData = _sceneLoader.GetCurrentBattleData();
52+
Dictionary<string, dynamic> battleData = _sceneLoader.GetCurrentBattleData();
5753
Id = battleData["battle_id"];
5854
BattleName = battleData["battle_name"];
5955
Music = battleData["music"];
@@ -62,11 +58,10 @@ public override void _Ready() {
6258
InitialiseGameState(playerCardIds, enemies);
6359
InitialiseHud();
6460

65-
comboGlossary = GetNode<ComboGlossary>("HUD/ComboGlossary");
66-
comboGlossary.Initialize(_gameState.Hand.Deck, _gameState.AllCombos);
67-
68-
cardGlossary = GetNode<Control>("HUD/CardGlossary");
61+
_comboGlossary = GetNode<ComboGlossary>("HUD/ComboGlossary");
62+
_comboGlossary.Initialize(_gameState.Hand.Deck, _gameState.AllCombos);
6963

64+
_cardGlossary = GetNode<Control>("HUD/CardGlossary");
7065

7166
GetNode<Label>("HUD/VsLabel").Text = BattleName;
7267

@@ -84,7 +79,7 @@ public override void _Process(double delta) {
8479

8580
//this line is needed to prevent a lock situation where bote glossaries and escape menu are opended.
8681
// when the pause menu is closed, the pause state is removed, so glossary stop processing and it is impossible to exit.
87-
if (cardGlossary.Visible || comboGlossary.Visible) { GetTree().Paused = true; }
82+
if (_cardGlossary.Visible || _comboGlossary.Visible) { GetTree().Paused = true; }
8883

8984
if (SceneLoader.BossBattleId == Id) {
9085
foreach (Enemy enemy in _gameState.Enemies) {
@@ -129,7 +124,7 @@ private void InitialiseGameState(List<string> playerCardIds, List<Enemy> enemies
129124
_gameState.AllEnemiesDefeatedCustomEvent += WinBattle;
130125
_gameState.ComboPlayedCustomEvent += DisplayPlayedCombo;
131126
_gameState.Hand.Deck.DeckShuffledCustomEvent += OnDeckShuffled;
132-
_gameState.Player.PlayerModifierChangedCustomEvent += OnPlayerMofifierChanged;
127+
_gameState.Player.PlayerModifierChangedCustomEvent += OnPlayerModifierChanged;
133128
_gameState.Player.Statuses.PlayerStatusesChangedCustomEvent += UpdateStatusesToolTip;
134129

135130

@@ -142,18 +137,17 @@ private void InitialiseGameState(List<string> playerCardIds, List<Enemy> enemies
142137
public void UpdateStatusesToolTip(object sender, EventArgs e) {
143138
TextureRect statusIndicator = GetNode<TextureRect>("HUD/StatusIndicator");
144139
string statusString = "";
145-
146140
foreach (Utils.StatusEnum status in _gameState.Player.Statuses) { statusString += status + "\n"; }
147141
statusIndicator.TooltipText = statusString;
148142
if (statusString.Length > 0) { statusIndicator.Show(); } else { statusIndicator.Hide(); }
149143
}
150144

151-
private void OnPlayerMofifierChanged(object sender, EventArgs e) {
152-
TextureRect PlayerModifierIcon = GetNode<TextureRect>("HUD/PlayerModifierIcon");
153-
if (_gameState.Player.Modifier == Utils.ModifierEnum.None) { PlayerModifierIcon.Visible = false; } else {
154-
PlayerModifierIcon.Texture =
145+
private void OnPlayerModifierChanged(object sender, EventArgs e) {
146+
TextureRect playerModifierIcon = GetNode<TextureRect>("HUD/PlayerModifierIcon");
147+
if (_gameState.Player.Modifier == Utils.ModifierEnum.None) { playerModifierIcon.Visible = false; } else {
148+
playerModifierIcon.Texture =
155149
(Texture2D)GD.Load($"res://assets/images/ModifierIcons/{_gameState.Player.Modifier}.png");
156-
PlayerModifierIcon.Visible = true;
150+
playerModifierIcon.Visible = true;
157151
}
158152
}
159153

@@ -260,7 +254,7 @@ private void OnPlayButtonPressed() {
260254
private void EndTurn() { _gameState.EndTurn(); }
261255

262256
private void WinBattle(object sender, EventArgs eventArgs) {
263-
EmitSignal(Battle.SignalName.BattleWon, _gameState.Player);
257+
EmitSignal(SignalName.BattleWon, _gameState.Player);
264258

265259
if (Id != SceneLoader.PreBossBattleId) { _audioEngine.PlaySoundFx("victory-jingle.wav"); } else {
266260
_audioEngine.PlaySoundFx("male-hurt-1.ogg");
@@ -295,9 +289,9 @@ private void MoveSelectedIndicator(object sender, EventArgs e) {
295289
private void OnPlayerHealthChanged() {
296290
Player playerObject = _gameState.Player;
297291
if (playerObject.Health <= 0) {
298-
EmitSignal(Battle.SignalName.BattleLost);
292+
EmitSignal(SignalName.BattleLost);
299293

300-
_sceneLoader = GetNode<autoloads.SceneLoader>("/root/SceneLoader");
294+
_sceneLoader = GetNode<SceneLoader>("/root/SceneLoader");
301295
_audioEngine.PlayMusic("Lil_tune.wav");
302296
_sceneLoader.GoToScene("res://scenes/sub/GameOver.tscn");
303297
}
@@ -444,6 +438,7 @@ private void UIScaling() {
444438

445439
Path2D hand = GetNode<Path2D>("Hand");
446440
hand.Scale = scaleFactor;
441+
447442
Path2D enemies = GetNode<Path2D>("Enemies");
448443
enemies.Scale = scaleFactor;
449444

scripts/battle/Deck.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,10 @@ public class Deck<T> {
1010
public string Name { get; set; }
1111

1212
public Discard<T> Discard { get; set; }
13-
public List<T> Cards;
13+
public List<T> Cards = new();
1414

1515
public Deck(Discard<T> discard) {
1616
Discard = discard;
17-
Cards = new();
1817
}
1918

2019
public static List<CardSleeve> SleeveCards(List<Card> cards) {
@@ -74,7 +73,6 @@ public List<T> DrawCards(int amount) {
7473

7574
private List<T> OnDeckEmptied(int amount) {
7675
if (Discard.IsEmpty()) { return new(); }
77-
7876
AddCards(Discard.GetCards());
7977
Shuffle();
8078
return DrawCards(amount);

scripts/battle/Discard.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ public class Discard<T> {
99
public List<T> GetCards(bool clear = true) {
1010
List<T> output = new(Cards);
1111
if (clear) { Cards.Clear(); }
12-
1312
return output;
1413
}
1514
}

scripts/battle/Hand.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,7 @@ private void UpdateCardPositions() {
6161
handCardLocation.ProgressRatio = (i + 1f) / (Cards.Count + 1f);
6262
Vector2 cardPosition = handCardLocation.Position;
6363
cardSleeve.ZIndex = i;
64-
if (i == _selectedCardIndex)
65-
{
64+
if (i == _selectedCardIndex) {
6665
cardPosition.Y -= 100;
6766
cardSleeve.ZIndex = i + 100;
6867
}

0 commit comments

Comments
 (0)