Skip to content

Commit f794d5f

Browse files
committed
Adjust Shop For Heal Button
Remove health label to use PlayerPuppet in the scene Adjust Shop UI because the heal button was too big for the container Adjust Translation to specify cost and heal amount Fixed issue where removing note didn't update money label
1 parent 1f1951b commit f794d5f

4 files changed

Lines changed: 56 additions & 117 deletions

File tree

Globals/Translations/Translations.csv

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ SHOP_REMOVAL,Remove A Note,移除音符
3434
SHOP_CONFIRM,Confirm Purchase,购买已确认
3535
SHOP_CANCEL,Cancel,取消操作
3636
REMOVAL_COST,Removal Fee,删除费用
37-
SHOP_HEAL, Heal, 愈合
37+
SHOP_HEAL,Heal 25%: 30g,愈合 25%: 30硬币
3838
BATTLE_ROOM_BEGIN_BUTTON,Begin Battle [Enter],开始战斗 [Enter]
3939
BATTLE_ROOM_PERFECT,Perfect,Perfect
4040
BATTLE_ROOM_GOOD,Good,良好

Scenes/ShopScene/Scripts/ShopScene.cs

Lines changed: 21 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,6 @@ public partial class ShopScene : Control
1111
[Export]
1212
private Label _moneyLabel;
1313

14-
[Export]
15-
private Label _currentHealthLabel;
16-
1714
[Export]
1815
private Button _exitButton;
1916

@@ -56,15 +53,19 @@ public partial class ShopScene : Control
5653
[Export]
5754
private Label _removalCostLabel;
5855

56+
[Export]
57+
private PlayerPuppet _player;
58+
5959
private ButtonGroup _bGroup;
6060

6161
private readonly int[] _priceByRarity = [100, 90, 80, 70, 60, 50, 9];
6262
const int NoteCost = 45;
6363

6464
private List<ShopItem> _shopItems = new List<ShopItem>();
6565

66-
public override void _Ready()
66+
public override void _EnterTree()
6767
{
68+
BgAudioPlayer.LiveInstance.ResumeLevelMusic();
6869
_bGroup = new ButtonGroup();
6970
Initialize();
7071
_confirmationButton.Pressed += TryPurchase;
@@ -75,18 +76,12 @@ public override void _Ready()
7576
_healButton.Pressed += TryHeal;
7677
}
7778

78-
public override void _EnterTree()
79-
{
80-
BgAudioPlayer.LiveInstance.ResumeLevelMusic();
81-
}
82-
8379
private void Initialize()
8480
{
8581
UpdateMoneyLabel();
86-
UpdateCurrentHealthLabel();
8782
GenerateShopItems();
8883
PopulatePossessedNotes();
89-
HealButtonStatus();
84+
UpdateHealButton();
9085
}
9186

9287
public override void _Input(InputEvent @event)
@@ -115,12 +110,6 @@ private void UpdateMoneyLabel()
115110
_moneyLabel.Text = StageProducer.PlayerStats.Money.ToString();
116111
}
117112

118-
private void UpdateCurrentHealthLabel()
119-
{
120-
_currentHealthLabel.Text =
121-
$"{StageProducer.PlayerStats.CurrentHealth}/{StageProducer.PlayerStats.MaxHealth}";
122-
}
123-
124113
private const int RelicOptions = 3;
125114
private const int NoteOptions = 5;
126115

@@ -224,6 +213,7 @@ private void TryPurchase()
224213
_currentUItem = null;
225214

226215
RefreshShopPrices();
216+
UpdateHealButton();
227217
}
228218

229219
private Control _lastFocused;
@@ -336,45 +326,37 @@ private void RemoveNote()
336326
StageProducer.PlayerStats.RemoveNote(_toRemove);
337327
_selectedRemoveButton.QueueFree();
338328
CloseRemovalPane();
329+
UpdateMoneyLabel();
330+
UpdateHealButton();
339331
}
340332

341-
private bool _hasHealed = false;
333+
private bool _hasHealed;
342334
private const int HealCost = 30;
343335
private int _healAmount = (StageProducer.PlayerStats.MaxHealth / 4);
344336

345-
private void HealButtonStatus()
337+
private void UpdateHealButton()
346338
{
347-
if (
339+
_healButton.Disabled =
348340
StageProducer.PlayerStats.Money <= HealCost
349341
|| StageProducer.PlayerStats.CurrentHealth == StageProducer.PlayerStats.MaxHealth
350-
|| _hasHealed
351-
)
352-
{
353-
_healButton.Disabled = true;
354-
}
342+
|| _hasHealed;
355343
}
356344

357345
private void TryHeal()
358346
{
359-
if (_hasHealed)
347+
if (
348+
StageProducer.PlayerStats.Money <= HealCost
349+
|| StageProducer.PlayerStats.CurrentHealth == StageProducer.PlayerStats.MaxHealth
350+
|| _hasHealed
351+
)
360352
{
361353
return;
362354
}
363-
HealPlayer();
364-
}
365-
366-
private void HealPlayer()
367-
{
368-
StageProducer.PlayerStats.CurrentHealth += _healAmount;
369-
if (StageProducer.PlayerStats.CurrentHealth > StageProducer.PlayerStats.MaxHealth)
370-
{
371-
StageProducer.PlayerStats.CurrentHealth = StageProducer.PlayerStats.MaxHealth;
372-
}
373355

374-
StageProducer.PlayerStats.Money -= 30;
375-
UpdateCurrentHealthLabel();
356+
StageProducer.PlayerStats.Money -= HealCost;
376357
UpdateMoneyLabel();
358+
UpdateHealButton();
377359
_hasHealed = true;
378-
HealButtonStatus();
360+
_player.Heal(_healAmount);
379361
}
380362
}

Scenes/ShopScene/ShopScene.tscn

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ offset_bottom = 180.0
5555
texture = ExtResource("2_dt33i")
5656
script = ExtResource("3_n34g6")
5757

58-
[node name="ShopUI" parent="." instance=ExtResource("8_2xatg")]
58+
[node name="ShopUI" parent="." node_paths=PackedStringArray("_player") instance=ExtResource("8_2xatg")]
5959
offset_right = 640.0
6060
offset_bottom = 360.0
61+
_player = NodePath("../PlayerMarker/PlayerPuppet")

Scenes/ShopScene/ShopUI.tscn

Lines changed: 32 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
[gd_scene load_steps=9 format=3 uid="uid://bk0js6ji42xrt"]
1+
[gd_scene load_steps=8 format=3 uid="uid://bk0js6ji42xrt"]
22

33
[ext_resource type="Texture2D" uid="uid://djd6iw2g84bba" path="res://Scenes/UI/Assets/UI_CenterFrame.png" id="1_67his"]
44
[ext_resource type="Script" uid="uid://dg0xaieus84ns" path="res://Scenes/ShopScene/Scripts/ShopScene.cs" id="1_bmt43"]
@@ -7,9 +7,8 @@
77
[ext_resource type="Theme" uid="uid://d37e3tpsbxwak" path="res://Scenes/UI/Assets/GeneralTheme.tres" id="4_3vktw"]
88
[ext_resource type="Script" uid="uid://cahjluc6v7ked" path="res://Scenes/UI/TitleScreen/Scripts/SceneChange.cs" id="5_w0f8r"]
99
[ext_resource type="Texture2D" uid="uid://dyt1cvag13aik" path="res://SharedAssets/Money.png" id="6_tf865"]
10-
[ext_resource type="Texture2D" uid="uid://dtaf4wcsur721" path="res://SharedAssets/Heart.png" id="8_r34tc"]
1110

12-
[node name="ShopUI" type="Control" node_paths=PackedStringArray("_moneyLabel", "_currentHealthLabel", "_exitButton", "_removalButton", "_healButton", "_noteGrid", "_relicGrid", "_confirmationPopup", "_confirmationButton", "_denyButton", "_descriptionLabel", "_removalPanel", "_possessionGrid", "_removalAcceptButton", "_cancelRemoveButton", "_removalCostLabel")]
11+
[node name="ShopUI" type="Control" node_paths=PackedStringArray("_moneyLabel", "_exitButton", "_removalButton", "_healButton", "_noteGrid", "_relicGrid", "_confirmationPopup", "_confirmationButton", "_denyButton", "_descriptionLabel", "_removalPanel", "_possessionGrid", "_removalAcceptButton", "_cancelRemoveButton", "_removalCostLabel")]
1312
z_index = 2
1413
layout_mode = 3
1514
anchors_preset = 15
@@ -19,10 +18,9 @@ grow_horizontal = 2
1918
grow_vertical = 2
2019
script = ExtResource("1_bmt43")
2120
_moneyLabel = NodePath("MoneyContainer/MoneyFrame/MarginContainer/HBoxContainer/MoneyLabel")
22-
_currentHealthLabel = NodePath("HealthContainer/HealthFrame/MarginContainer/HBoxContainer/CurrentHealthLabel")
23-
_exitButton = NodePath("BottomPanel/DescBox/HBoxContainer/OptionsBG/OptionsMargin/OptionsBG/MarginContainer/VBoxContainer/Continue")
24-
_removalButton = NodePath("BottomPanel/DescBox/HBoxContainer/OptionsBG/OptionsMargin/OptionsBG/MarginContainer/VBoxContainer/Removal")
25-
_healButton = NodePath("BottomPanel/DescBox/HBoxContainer/OptionsBG/OptionsMargin/OptionsBG/MarginContainer/VBoxContainer/Heal")
21+
_exitButton = NodePath("OptionsBG/OptionsMargin/OptionsBG/MarginContainer/VBoxContainer/Continue")
22+
_removalButton = NodePath("OptionsBG/OptionsMargin/OptionsBG/MarginContainer/VBoxContainer/Removal")
23+
_healButton = NodePath("OptionsBG/OptionsMargin/OptionsBG/MarginContainer/VBoxContainer/Heal")
2624
_noteGrid = NodePath("TopPanel/MarginContainer/VBoxContainer/NoteSelection/MarginContainer/NotesBox/CenterContainer/NotesGrid")
2725
_relicGrid = NodePath("TopPanel/MarginContainer/VBoxContainer/RelicSelection/MarginContainer/RelicsBox/CenterContainer/RelicsGrid")
2826
_confirmationPopup = NodePath("ConfirmPurchase")
@@ -37,7 +35,7 @@ _removalCostLabel = NodePath("Removal/Panel/MarginContainer/VBoxContainer/Option
3735

3836
[node name="TopPanel" type="NinePatchRect" parent="."]
3937
layout_mode = 0
40-
offset_right = 508.0
38+
offset_right = 463.0
4139
offset_bottom = 211.0
4240
texture = ExtResource("1_67his")
4341
patch_margin_left = 12
@@ -140,7 +138,7 @@ columns = 6
140138
[node name="BottomPanel" type="NinePatchRect" parent="."]
141139
layout_mode = 0
142140
offset_top = 211.0
143-
offset_right = 640.0
141+
offset_right = 463.0
144142
offset_bottom = 360.0
145143
texture = ExtResource("1_67his")
146144
patch_margin_left = 12
@@ -149,10 +147,12 @@ patch_margin_right = 12
149147
patch_margin_bottom = 12
150148

151149
[node name="DescBox" type="MarginContainer" parent="BottomPanel"]
152-
layout_mode = 2
153-
offset_right = 640.0
154-
offset_bottom = 149.0
155-
grow_vertical = 0
150+
layout_mode = 1
151+
anchors_preset = 15
152+
anchor_right = 1.0
153+
anchor_bottom = 1.0
154+
grow_horizontal = 2
155+
grow_vertical = 2
156156
size_flags_vertical = 3
157157
size_flags_stretch_ratio = 0.4
158158
theme_override_constants/margin_left = 10
@@ -213,9 +213,18 @@ autowrap_mode = 2
213213
clip_text = true
214214
text_overrun_behavior = 1
215215

216-
[node name="OptionsBG" type="NinePatchRect" parent="BottomPanel/DescBox/HBoxContainer"]
216+
[node name="OptionsBG" type="NinePatchRect" parent="."]
217217
self_modulate = Color(1, 1, 1, 0.75)
218-
layout_mode = 2
218+
layout_mode = 1
219+
anchors_preset = 3
220+
anchor_left = 1.0
221+
anchor_top = 1.0
222+
anchor_right = 1.0
223+
anchor_bottom = 1.0
224+
offset_left = -176.0
225+
offset_top = -179.0
226+
grow_horizontal = 0
227+
grow_vertical = 0
219228
size_flags_horizontal = 3
220229
size_flags_vertical = 3
221230
size_flags_stretch_ratio = 0.39
@@ -225,7 +234,7 @@ patch_margin_top = 6
225234
patch_margin_right = 6
226235
patch_margin_bottom = 7
227236

228-
[node name="OptionsMargin" type="MarginContainer" parent="BottomPanel/DescBox/HBoxContainer/OptionsBG"]
237+
[node name="OptionsMargin" type="MarginContainer" parent="OptionsBG"]
229238
layout_mode = 1
230239
anchors_preset = 15
231240
anchor_right = 1.0
@@ -238,44 +247,44 @@ theme_override_constants/margin_top = 4
238247
theme_override_constants/margin_right = 4
239248
theme_override_constants/margin_bottom = 4
240249

241-
[node name="OptionsBG" type="NinePatchRect" parent="BottomPanel/DescBox/HBoxContainer/OptionsBG/OptionsMargin"]
250+
[node name="OptionsBG" type="NinePatchRect" parent="OptionsBG/OptionsMargin"]
242251
layout_mode = 2
243252
texture = ExtResource("3_r34tc")
244253
patch_margin_left = 7
245254
patch_margin_top = 7
246255
patch_margin_right = 7
247256
patch_margin_bottom = 7
248257

249-
[node name="MarginContainer" type="MarginContainer" parent="BottomPanel/DescBox/HBoxContainer/OptionsBG/OptionsMargin/OptionsBG"]
258+
[node name="MarginContainer" type="MarginContainer" parent="OptionsBG/OptionsMargin/OptionsBG"]
250259
layout_mode = 1
251260
anchors_preset = 15
252261
anchor_right = 1.0
253262
anchor_bottom = 1.0
254263
grow_horizontal = 2
255264
grow_vertical = 2
256265
theme_override_constants/margin_left = 7
257-
theme_override_constants/margin_top = 7
266+
theme_override_constants/margin_top = 0
258267
theme_override_constants/margin_right = 7
259268

260-
[node name="VBoxContainer" type="VBoxContainer" parent="BottomPanel/DescBox/HBoxContainer/OptionsBG/OptionsMargin/OptionsBG/MarginContainer"]
269+
[node name="VBoxContainer" type="VBoxContainer" parent="OptionsBG/OptionsMargin/OptionsBG/MarginContainer"]
261270
layout_mode = 2
262271
alignment = 1
263272

264-
[node name="Removal" type="Button" parent="BottomPanel/DescBox/HBoxContainer/OptionsBG/OptionsMargin/OptionsBG/MarginContainer/VBoxContainer"]
273+
[node name="Removal" type="Button" parent="OptionsBG/OptionsMargin/OptionsBG/MarginContainer/VBoxContainer"]
265274
layout_mode = 2
266275
size_flags_horizontal = 4
267276
size_flags_vertical = 4
268277
theme = ExtResource("4_3vktw")
269278
text = "SHOP_REMOVAL"
270279

271-
[node name="Heal" type="Button" parent="BottomPanel/DescBox/HBoxContainer/OptionsBG/OptionsMargin/OptionsBG/MarginContainer/VBoxContainer"]
280+
[node name="Heal" type="Button" parent="OptionsBG/OptionsMargin/OptionsBG/MarginContainer/VBoxContainer"]
272281
layout_mode = 2
273282
size_flags_horizontal = 4
274283
size_flags_vertical = 4
275284
theme = ExtResource("4_3vktw")
276285
text = "SHOP_HEAL"
277286

278-
[node name="Continue" type="Button" parent="BottomPanel/DescBox/HBoxContainer/OptionsBG/OptionsMargin/OptionsBG/MarginContainer/VBoxContainer"]
287+
[node name="Continue" type="Button" parent="OptionsBG/OptionsMargin/OptionsBG/MarginContainer/VBoxContainer"]
279288
layout_mode = 2
280289
size_flags_horizontal = 4
281290
size_flags_vertical = 4
@@ -337,59 +346,6 @@ horizontal_alignment = 2
337346
vertical_alignment = 1
338347
clip_text = true
339348

340-
[node name="HealthContainer" type="MarginContainer" parent="."]
341-
layout_mode = 1
342-
anchors_preset = 1
343-
anchor_left = 1.0
344-
anchor_right = 1.0
345-
offset_left = -125.0
346-
offset_top = 24.0
347-
offset_bottom = 53.0
348-
grow_horizontal = 0
349-
theme_override_constants/margin_left = -1
350-
theme_override_constants/margin_top = 5
351-
theme_override_constants/margin_right = 5
352-
theme_override_constants/margin_bottom = 0
353-
354-
[node name="HealthFrame" type="NinePatchRect" parent="HealthContainer"]
355-
layout_mode = 2
356-
texture = ExtResource("2_bmt43")
357-
patch_margin_left = 7
358-
patch_margin_top = 7
359-
patch_margin_right = 7
360-
patch_margin_bottom = 7
361-
362-
[node name="MarginContainer" type="MarginContainer" parent="HealthContainer/HealthFrame"]
363-
layout_mode = 1
364-
anchors_preset = 15
365-
anchor_right = 1.0
366-
anchor_bottom = 1.0
367-
grow_horizontal = 2
368-
grow_vertical = 2
369-
theme_override_constants/margin_right = 8
370-
371-
[node name="HBoxContainer" type="HBoxContainer" parent="HealthContainer/HealthFrame/MarginContainer"]
372-
layout_mode = 2
373-
374-
[node name="MarginContainer" type="MarginContainer" parent="HealthContainer/HealthFrame/MarginContainer/HBoxContainer"]
375-
layout_mode = 2
376-
theme_override_constants/margin_left = 6
377-
378-
[node name="TextureRect" type="TextureRect" parent="HealthContainer/HealthFrame/MarginContainer/HBoxContainer/MarginContainer"]
379-
layout_mode = 2
380-
size_flags_vertical = 4
381-
texture = ExtResource("8_r34tc")
382-
383-
[node name="CurrentHealthLabel" type="Label" parent="HealthContainer/HealthFrame/MarginContainer/HBoxContainer"]
384-
custom_minimum_size = Vector2(91, 0)
385-
layout_mode = 2
386-
size_flags_horizontal = 10
387-
size_flags_vertical = 1
388-
text = "0"
389-
horizontal_alignment = 2
390-
vertical_alignment = 1
391-
clip_text = true
392-
393349
[node name="ConfirmPurchase" type="CenterContainer" parent="."]
394350
visible = false
395351
z_index = 3

0 commit comments

Comments
 (0)