Skip to content

Commit 651c567

Browse files
Rmojarro1LifeHckr
andauthored
Shop heal (#229)
* Created branch, added sprite * Heal Button functionality Shops now have heal button. Clicking it will restore 1/4 max hp at the cost of 30 money. This will disable the button for the reminder of time spent in shop. If player is at max hp or does not have enough money upon entering shop, button will be disabled automatically. Added display for the player's current health out of max health, with a placeholder heart sprite. * 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 * Adjust tutorial translation --------- Co-authored-by: LifeHckr <jarodthereal@gmail.com>
1 parent c5c9fee commit 651c567

7 files changed

Lines changed: 120 additions & 28 deletions

File tree

Globals/Translations/Translations.csv

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +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 25%: 30g,愈合 25%: 30硬币
3738
BATTLE_ROOM_BEGIN_BUTTON,Begin Battle [Enter],开始战斗 [Enter]
3839
BATTLE_ROOM_PERFECT,Perfect,Perfect
3940
BATTLE_ROOM_GOOD,Good,良好
@@ -122,15 +123,15 @@ TUTORIAL_NODYING,No dying during a tutorial!,教程中不会死亡!
122123
TUTORIAL_DIALOGUE_1,"Hello, welcome to Midnight Riff!",你好!欢迎来到午夜即兴!
123124
TUTORIAL_DIALOGUE_2,This is a rhythm game where notes move right to left.,这是一款节奏游戏,音符从右向左移动。
124125
TUTORIAL_DIALOGUE_3,"Press the correct button as the notes line up to hit the note. Try to time it as well as you can!",音符对齐时按下正确的按键,尽量精准地进行点击!
125-
TUTORIAL_DIALOGUE_4,"What are the correct buttons? I'll help you out and show you. These can be changed from the meu. Once you press continue we can get started!",正确的按键是什么?我会帮你指出来。这些可以在菜单中更改。按下继续后,我们就可以开始了!
126+
TUTORIAL_DIALOGUE_4,"What are the correct buttons? I'll help you out and show you. These can be changed from the menu. Once you press continue we can get started!",正确的按键是什么?我会帮你指出来。这些可以在菜单中更改。按下继续后,我们就可以开始了!
126127
TUTORIAL_LOOP_1,At set intervals the chart loops! This means all notes on the chart repeat. You know a loop is coming up when this symbol scrolls by.,在固定的时间间隔内,乐谱会循环!这意味着乐谱上的所有音符都会重复出现。当这个符号滚动经过时,你就知道循环即将开始。
127128
TUTORIAL_LOOP_2,"In case you haven't noticed, I'll explain these things on the left side. This is your note queue.",如果你还没注意到,我会在左侧解释这些内容。这是你的音符队列。
128129
TUTORIAL_LOOP_3,"This is the combo multiplier, as you hit notes successfully your multiplier will rise. If you miss a note, your multiplier gets reset.",这是连击倍数,成功点击音符后,你的倍数将会上升。如果你错过了一个音符,你的倍数将会重置。
129130
TUTORIAL_LOOP_4,"This is the freestyle bar, as you hit notes successfully, the freestyle bar fills. The higher your multiplier the more this fills.",这是风格条,成功点击音符后,风格条将会填充。你的倍数越高,填充速度越快。
130131
TUTORIAL_LOOP_5,"By now you've probably taken damage. These aren't just cozy songs, these are battles! You take damage when you miss or have bad timing, or from enemy effects. How do you deal damage to enemies? Fill up the bar and I'll tell you.",到目前为止,你可能已经受到伤害了。这些不仅仅是轻松的歌曲,它们是战斗!你错过音符或时机不好,或者受到敌人的效果影响时,都会受到伤害。你如何对敌人造成伤害?填满能量条,我会告诉你。
131132
TUTORIAL_PLACE_1,"Okay, now that the bar is full, you can press a lane button to place your own note. Your notes have special effects. Placing notes consumes the freestyle bar.",好的,现在能量条已满,你可以按下轨道按键放置你自己的音符。你的音符具有特殊效果。放置音符会消耗风格条。
132133
TUTORIAL_PLACE_2,These note effects range from dealing damage to applying status effects!,这些音符效果从造成伤害到施加状态效果不等!
133-
TUTORIAL_PLACE_3,"Your notes can be placed anywhere a note doesn't already exist, and that isn't over the loop marker. But be careful, if you try to place a note while the bar isn't full you may miss a note!",你的音符可以放置在任何没有音符存在且不在循环标记上的位置。但是要小心,如果你试图在能量条未满时放置音符,你可能会错过音符!
134+
TUTORIAL_PLACE_3,"Your notes can be placed anywhere a note doesn't already exist, and that isn't over the loop marker.",你的音符可以放置在任何没有音符存在且不在循环标记上的位置。
134135
TUTORIAL_PLACE_4,"The note you'll place is indicated in the top of the note queue.",你将要放置的音符显示在音符队列顶部。
135136
TUTORIAL_PLACE_5,"Notes are automatically hit when you place them, how helpful, but they come back around when the chart loops, and you need to time hitting them then.",放置音符时会自动击中,这非常方便,但当乐谱循环时它们会再次出现,你需要掌握时机才能击中它们。
136137
TUTORIAL_PLACE_6,"Now go ahead, place a note in the bottom lane!",现在,在最下方的轨道上放置一个音符吧!

Scenes/BattleDirector/Scripts/BattleDirector.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ public override void _UnhandledInput(InputEvent @event)
200200
{
201201
if (@event is InputEventKey eventKey && eventKey.Pressed && !eventKey.Echo)
202202
{
203-
return;
203+
//return;
204204
if (eventKey.Keycode == Key.Key0)
205205
{
206206
DebugKillEnemy();

Scenes/ShopScene/Scripts/ShopScene.cs

Lines changed: 43 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ public partial class ShopScene : Control
1717
[Export]
1818
private Button _removalButton;
1919

20+
[Export]
21+
private Button _healButton;
22+
2023
[Export]
2124
private GridContainer _noteGrid;
2225

@@ -50,34 +53,35 @@ public partial class ShopScene : Control
5053
[Export]
5154
private Label _removalCostLabel;
5255

56+
[Export]
57+
private PlayerPuppet _player;
58+
5359
private ButtonGroup _bGroup;
5460

5561
private readonly int[] _priceByRarity = [100, 90, 80, 70, 60, 50, 9];
5662
const int NoteCost = 45;
5763

5864
private List<ShopItem> _shopItems = new List<ShopItem>();
5965

60-
public override void _Ready()
66+
public override void _EnterTree()
6167
{
68+
BgAudioPlayer.LiveInstance.ResumeLevelMusic();
6269
_bGroup = new ButtonGroup();
6370
Initialize();
6471
_confirmationButton.Pressed += TryPurchase;
6572
_denyButton.Pressed += CloseConfirmationPopup;
6673
_removalButton.Pressed += OpenRemovalPane;
6774
_removalAcceptButton.Pressed += RemoveNote;
6875
_cancelRemoveButton.Pressed += CloseRemovalPane;
69-
}
70-
71-
public override void _EnterTree()
72-
{
73-
BgAudioPlayer.LiveInstance.ResumeLevelMusic();
76+
_healButton.Pressed += TryHeal;
7477
}
7578

7679
private void Initialize()
7780
{
7881
UpdateMoneyLabel();
7982
GenerateShopItems();
8083
PopulatePossessedNotes();
84+
UpdateHealButton();
8185
}
8286

8387
public override void _Input(InputEvent @event)
@@ -209,6 +213,7 @@ private void TryPurchase()
209213
_currentUItem = null;
210214

211215
RefreshShopPrices();
216+
UpdateHealButton();
212217
}
213218

214219
private Control _lastFocused;
@@ -321,5 +326,37 @@ private void RemoveNote()
321326
StageProducer.PlayerStats.RemoveNote(_toRemove);
322327
_selectedRemoveButton.QueueFree();
323328
CloseRemovalPane();
329+
UpdateMoneyLabel();
330+
UpdateHealButton();
331+
}
332+
333+
private bool _hasHealed;
334+
private const int HealCost = 30;
335+
private int _healAmount = (StageProducer.PlayerStats.MaxHealth / 4);
336+
337+
private void UpdateHealButton()
338+
{
339+
_healButton.Disabled =
340+
StageProducer.PlayerStats.Money <= HealCost
341+
|| StageProducer.PlayerStats.CurrentHealth == StageProducer.PlayerStats.MaxHealth
342+
|| _hasHealed;
343+
}
344+
345+
private void TryHeal()
346+
{
347+
if (
348+
StageProducer.PlayerStats.Money <= HealCost
349+
|| StageProducer.PlayerStats.CurrentHealth == StageProducer.PlayerStats.MaxHealth
350+
|| _hasHealed
351+
)
352+
{
353+
return;
354+
}
355+
356+
StageProducer.PlayerStats.Money -= HealCost;
357+
UpdateMoneyLabel();
358+
UpdateHealButton();
359+
_hasHealed = true;
360+
_player.Heal(_healAmount);
324361
}
325362
}

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: 37 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
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"]
1010

11-
[node name="ShopUI" type="Control" node_paths=PackedStringArray("_moneyLabel", "_exitButton", "_removalButton", "_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")]
1212
z_index = 2
1313
layout_mode = 3
1414
anchors_preset = 15
@@ -18,8 +18,9 @@ grow_horizontal = 2
1818
grow_vertical = 2
1919
script = ExtResource("1_bmt43")
2020
_moneyLabel = NodePath("MoneyContainer/MoneyFrame/MarginContainer/HBoxContainer/MoneyLabel")
21-
_exitButton = NodePath("BottomPanel/DescBox/HBoxContainer/OptionsBG/OptionsMargin/OptionsBG/MarginContainer/VBoxContainer/Continue")
22-
_removalButton = NodePath("BottomPanel/DescBox/HBoxContainer/OptionsBG/OptionsMargin/OptionsBG/MarginContainer/VBoxContainer/Removal")
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")
2324
_noteGrid = NodePath("TopPanel/MarginContainer/VBoxContainer/NoteSelection/MarginContainer/NotesBox/CenterContainer/NotesGrid")
2425
_relicGrid = NodePath("TopPanel/MarginContainer/VBoxContainer/RelicSelection/MarginContainer/RelicsBox/CenterContainer/RelicsGrid")
2526
_confirmationPopup = NodePath("ConfirmPurchase")
@@ -34,7 +35,7 @@ _removalCostLabel = NodePath("Removal/Panel/MarginContainer/VBoxContainer/Option
3435

3536
[node name="TopPanel" type="NinePatchRect" parent="."]
3637
layout_mode = 0
37-
offset_right = 508.0
38+
offset_right = 463.0
3839
offset_bottom = 211.0
3940
texture = ExtResource("1_67his")
4041
patch_margin_left = 12
@@ -137,7 +138,7 @@ columns = 6
137138
[node name="BottomPanel" type="NinePatchRect" parent="."]
138139
layout_mode = 0
139140
offset_top = 211.0
140-
offset_right = 640.0
141+
offset_right = 463.0
141142
offset_bottom = 360.0
142143
texture = ExtResource("1_67his")
143144
patch_margin_left = 12
@@ -146,10 +147,12 @@ patch_margin_right = 12
146147
patch_margin_bottom = 12
147148

148149
[node name="DescBox" type="MarginContainer" parent="BottomPanel"]
149-
layout_mode = 2
150-
offset_right = 640.0
151-
offset_bottom = 149.0
152-
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
153156
size_flags_vertical = 3
154157
size_flags_stretch_ratio = 0.4
155158
theme_override_constants/margin_left = 10
@@ -210,9 +213,18 @@ autowrap_mode = 2
210213
clip_text = true
211214
text_overrun_behavior = 1
212215

213-
[node name="OptionsBG" type="NinePatchRect" parent="BottomPanel/DescBox/HBoxContainer"]
216+
[node name="OptionsBG" type="NinePatchRect" parent="."]
214217
self_modulate = Color(1, 1, 1, 0.75)
215-
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
216228
size_flags_horizontal = 3
217229
size_flags_vertical = 3
218230
size_flags_stretch_ratio = 0.39
@@ -222,7 +234,7 @@ patch_margin_top = 6
222234
patch_margin_right = 6
223235
patch_margin_bottom = 7
224236

225-
[node name="OptionsMargin" type="MarginContainer" parent="BottomPanel/DescBox/HBoxContainer/OptionsBG"]
237+
[node name="OptionsMargin" type="MarginContainer" parent="OptionsBG"]
226238
layout_mode = 1
227239
anchors_preset = 15
228240
anchor_right = 1.0
@@ -235,37 +247,44 @@ theme_override_constants/margin_top = 4
235247
theme_override_constants/margin_right = 4
236248
theme_override_constants/margin_bottom = 4
237249

238-
[node name="OptionsBG" type="NinePatchRect" parent="BottomPanel/DescBox/HBoxContainer/OptionsBG/OptionsMargin"]
250+
[node name="OptionsBG" type="NinePatchRect" parent="OptionsBG/OptionsMargin"]
239251
layout_mode = 2
240252
texture = ExtResource("3_r34tc")
241253
patch_margin_left = 7
242254
patch_margin_top = 7
243255
patch_margin_right = 7
244256
patch_margin_bottom = 7
245257

246-
[node name="MarginContainer" type="MarginContainer" parent="BottomPanel/DescBox/HBoxContainer/OptionsBG/OptionsMargin/OptionsBG"]
258+
[node name="MarginContainer" type="MarginContainer" parent="OptionsBG/OptionsMargin/OptionsBG"]
247259
layout_mode = 1
248260
anchors_preset = 15
249261
anchor_right = 1.0
250262
anchor_bottom = 1.0
251263
grow_horizontal = 2
252264
grow_vertical = 2
253265
theme_override_constants/margin_left = 7
254-
theme_override_constants/margin_top = 7
266+
theme_override_constants/margin_top = 0
255267
theme_override_constants/margin_right = 7
256268

257-
[node name="VBoxContainer" type="VBoxContainer" parent="BottomPanel/DescBox/HBoxContainer/OptionsBG/OptionsMargin/OptionsBG/MarginContainer"]
269+
[node name="VBoxContainer" type="VBoxContainer" parent="OptionsBG/OptionsMargin/OptionsBG/MarginContainer"]
258270
layout_mode = 2
259271
alignment = 1
260272

261-
[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"]
262274
layout_mode = 2
263275
size_flags_horizontal = 4
264276
size_flags_vertical = 4
265277
theme = ExtResource("4_3vktw")
266278
text = "SHOP_REMOVAL"
267279

268-
[node name="Continue" type="Button" parent="BottomPanel/DescBox/HBoxContainer/OptionsBG/OptionsMargin/OptionsBG/MarginContainer/VBoxContainer"]
280+
[node name="Heal" type="Button" parent="OptionsBG/OptionsMargin/OptionsBG/MarginContainer/VBoxContainer"]
281+
layout_mode = 2
282+
size_flags_horizontal = 4
283+
size_flags_vertical = 4
284+
theme = ExtResource("4_3vktw")
285+
text = "SHOP_HEAL"
286+
287+
[node name="Continue" type="Button" parent="OptionsBG/OptionsMargin/OptionsBG/MarginContainer/VBoxContainer"]
269288
layout_mode = 2
270289
size_flags_horizontal = 4
271290
size_flags_vertical = 4

SharedAssets/Heart.png

1.49 KB
Loading

SharedAssets/Heart.png.import

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
[remap]
2+
3+
importer="texture"
4+
type="CompressedTexture2D"
5+
uid="uid://dtaf4wcsur721"
6+
path="res://.godot/imported/Heart.png-7dfefac643a1f449fa6e4073fe6379c7.ctex"
7+
metadata={
8+
"vram_texture": false
9+
}
10+
11+
[deps]
12+
13+
source_file="res://SharedAssets/Heart.png"
14+
dest_files=["res://.godot/imported/Heart.png-7dfefac643a1f449fa6e4073fe6379c7.ctex"]
15+
16+
[params]
17+
18+
compress/mode=0
19+
compress/high_quality=false
20+
compress/lossy_quality=0.7
21+
compress/hdr_compression=1
22+
compress/normal_map=0
23+
compress/channel_pack=0
24+
mipmaps/generate=false
25+
mipmaps/limit=-1
26+
roughness/mode=0
27+
roughness/src_normal=""
28+
process/fix_alpha_border=true
29+
process/premult_alpha=false
30+
process/normal_map_invert_y=false
31+
process/hdr_as_srgb=false
32+
process/hdr_clamp_exposure=false
33+
process/size_limit=0
34+
detect_3d/compress_to=1

0 commit comments

Comments
 (0)