From f3b130e37a413c8c30061f92144a945fe33648f8 Mon Sep 17 00:00:00 2001 From: LifeHckr Date: Thu, 17 Apr 2025 22:17:26 -0700 Subject: [PATCH 1/3] Added rerolls Added reroll functionality to rewardSelectionUI Added applicable player stat Added player stat for additional rewards --- Globals/Scribe.cs | 12 ++-- Globals/Translations/Translations.csv | 1 + Scenes/BattleDirector/NotePoofParticles.tscn | 2 +- Scenes/ChartViewport/ChartViewport.tscn | 6 +- Scenes/ChartViewport/HitParticles.tscn | 2 +- Scenes/NoteManager/HoldArrow.tscn | 2 +- Scenes/NoteManager/NoteArrow.tscn | 2 +- Scenes/NoteManager/NoteManager.tscn | 4 +- Scenes/Puppets/Scripts/PlayerStats.cs | 2 + Scenes/UI/RewardSelectionUI.tscn | 15 ++++- Scenes/UI/Scripts/RewardSelect.cs | 67 ++++++++++++++++---- 11 files changed, 87 insertions(+), 28 deletions(-) diff --git a/Globals/Scribe.cs b/Globals/Scribe.cs index 846f9edb..e6b090d2 100644 --- a/Globals/Scribe.cs +++ b/Globals/Scribe.cs @@ -355,14 +355,18 @@ public partial class Scribe : Node //TODO: Item pool(s) - public static RelicTemplate[] GetRandomRelics(RelicTemplate[] excludedRelics, int count) + public static RelicTemplate[] GetRandomRelics( + RelicTemplate[] excludedRelics, + int count, + int lootOffset + ) { var availableRelics = Scribe .RelicDictionary.Where(r => excludedRelics.All(o => o.Name != r.Name)) .ToArray(); RandomNumberGenerator lootRng = new RandomNumberGenerator(); - lootRng.SetSeed(StageProducer.GlobalRng.Seed + (ulong)StageProducer.CurRoom); + lootRng.SetSeed(StageProducer.GlobalRng.Seed + (ulong)lootOffset); availableRelics = availableRelics .OrderBy(_ => lootRng.Randi()) @@ -378,14 +382,14 @@ public static RelicTemplate[] GetRandomRelics(RelicTemplate[] excludedRelics, in return availableRelics; } - public static Note[] GetRandomRewardNotes(int count) + public static Note[] GetRandomRewardNotes(int count, int lootOffset) { var availableNotes = Scribe .NoteDictionary.Where(r => r.Name.Contains("Player")) //TODO: Classifications/pools .ToArray(); RandomNumberGenerator lootRng = new RandomNumberGenerator(); - lootRng.SetSeed(StageProducer.GlobalRng.Seed + (ulong)StageProducer.CurRoom); + lootRng.SetSeed(StageProducer.GlobalRng.Seed + (ulong)lootOffset); availableNotes = availableNotes .OrderBy(_ => lootRng.Randi()) diff --git a/Globals/Translations/Translations.csv b/Globals/Translations/Translations.csv index 3957214b..447b3c47 100644 --- a/Globals/Translations/Translations.csv +++ b/Globals/Translations/Translations.csv @@ -20,6 +20,7 @@ ESCAPE_MENU_TITLE,Quit to Title,返回标题 CHEST_ROOM_REWARDS,Reward Selection!,奖励! CHEST_ROOM_SKIP,Skip,跳过 CHEST_ROOM_ACCEPT,Accept,接受 +CHEST_ROOM_REROLL,Rerolls: ,重刷: BATTLE_ROOM_BEGIN_BUTTON,"Begin Battle [Enter]","开始战斗 [Enter]" BATTLE_ROOM_PERFECT,Perfect,精准 BATTLE_ROOM_GOOD,Good,良好 diff --git a/Scenes/BattleDirector/NotePoofParticles.tscn b/Scenes/BattleDirector/NotePoofParticles.tscn index 7f5970d9..d2384f7c 100644 --- a/Scenes/BattleDirector/NotePoofParticles.tscn +++ b/Scenes/BattleDirector/NotePoofParticles.tscn @@ -25,9 +25,9 @@ scale_curve = SubResource("CurveTexture_h7u0t") [node name="NotePoof" type="GPUParticles2D"] emitting = false amount = 10 -process_material = SubResource("ParticleProcessMaterial_k0qar") texture = ExtResource("1_hjrch") lifetime = 0.75 one_shot = true preprocess = 0.1 explosiveness = 1.0 +process_material = SubResource("ParticleProcessMaterial_k0qar") diff --git a/Scenes/ChartViewport/ChartViewport.tscn b/Scenes/ChartViewport/ChartViewport.tscn index db3c8af3..f65b608e 100644 --- a/Scenes/ChartViewport/ChartViewport.tscn +++ b/Scenes/ChartViewport/ChartViewport.tscn @@ -1,10 +1,10 @@ [gd_scene load_steps=7 format=3 uid="uid://dfevfib11kou1"] -[ext_resource type="Script" path="res://Scenes/ChartViewport/Scripts/ChartManager.cs" id="1_ruh2l"] +[ext_resource type="Script" uid="uid://btgmfxqoe2wqx" path="res://Scenes/ChartViewport/Scripts/ChartManager.cs" id="1_ruh2l"] [ext_resource type="Texture2D" uid="uid://cp78odda2doab" path="res://Scenes/ChartViewport/LoopMarker.png" id="2_q5cjc"] -[ext_resource type="Script" path="res://Scenes/ChartViewport/Scripts/Loopable.cs" id="3_5u57h"] +[ext_resource type="Script" uid="uid://cf58ep1c2o0q2" path="res://Scenes/ChartViewport/Scripts/Loopable.cs" id="3_5u57h"] [ext_resource type="PackedScene" uid="uid://bn8txx53xlguw" path="res://Scenes/NoteManager/NoteManager.tscn" id="4_fd5fw"] -[ext_resource type="Shader" path="res://SharedAssets/StarryNight.gdshader" id="5_kqrxg"] +[ext_resource type="Shader" uid="uid://dp36iuuy414k1" path="res://SharedAssets/StarryNight.gdshader" id="5_kqrxg"] [sub_resource type="ShaderMaterial" id="ShaderMaterial_5uw0y"] shader = ExtResource("5_kqrxg") diff --git a/Scenes/ChartViewport/HitParticles.tscn b/Scenes/ChartViewport/HitParticles.tscn index 1a9315fe..0e30982d 100644 --- a/Scenes/ChartViewport/HitParticles.tscn +++ b/Scenes/ChartViewport/HitParticles.tscn @@ -1,6 +1,6 @@ [gd_scene load_steps=2 format=3 uid="uid://bcf6vs4aqoxr5"] -[ext_resource type="Script" path="res://Scenes/ChartViewport/Scripts/HitParticles.cs" id="1_7gkj5"] +[ext_resource type="Script" uid="uid://bjj3132iu8lrc" path="res://Scenes/ChartViewport/Scripts/HitParticles.cs" id="1_7gkj5"] [node name="HitParticles" type="CPUParticles2D"] z_index = -1 diff --git a/Scenes/NoteManager/HoldArrow.tscn b/Scenes/NoteManager/HoldArrow.tscn index 32978d70..7b749f03 100644 --- a/Scenes/NoteManager/HoldArrow.tscn +++ b/Scenes/NoteManager/HoldArrow.tscn @@ -1,7 +1,7 @@ [gd_scene load_steps=5 format=3 uid="uid://b3owchvgq1l87"] [ext_resource type="Texture2D" uid="uid://hfxynr5jdgsp" path="res://Scenes/NoteManager/Assets/New_Arrow.png" id="1_nn8ao"] -[ext_resource type="Script" path="res://Scenes/NoteManager/Scripts/HoldArrow.cs" id="2_hehcu"] +[ext_resource type="Script" uid="uid://ci5tt447bivmk" path="res://Scenes/NoteManager/Scripts/HoldArrow.cs" id="2_hehcu"] [ext_resource type="Texture2D" uid="uid://cgq2ar3pdmkac" path="res://Scenes/NoteManager/Assets/Arrow_Outline.png" id="3_pvvea"] [ext_resource type="Texture2D" uid="uid://dbnvl0gbhl5b4" path="res://Scenes/NoteManager/Assets/Arrow_Trail.png" id="4_xgcwb"] diff --git a/Scenes/NoteManager/NoteArrow.tscn b/Scenes/NoteManager/NoteArrow.tscn index c1daacb8..dc5521ce 100644 --- a/Scenes/NoteManager/NoteArrow.tscn +++ b/Scenes/NoteManager/NoteArrow.tscn @@ -1,7 +1,7 @@ [gd_scene load_steps=4 format=3 uid="uid://ck3bfqy30rjbq"] [ext_resource type="Texture2D" uid="uid://hfxynr5jdgsp" path="res://Scenes/NoteManager/Assets/New_Arrow.png" id="1_wq1hy"] -[ext_resource type="Script" path="res://Scenes/NoteManager/Scripts/NoteArrow.cs" id="2_lbl4b"] +[ext_resource type="Script" uid="uid://cfdthf532wby7" path="res://Scenes/NoteManager/Scripts/NoteArrow.cs" id="2_lbl4b"] [ext_resource type="Texture2D" uid="uid://cgq2ar3pdmkac" path="res://Scenes/NoteManager/Assets/Arrow_Outline.png" id="3_5g4ja"] [node name="Right-arrow" type="Sprite2D" node_paths=PackedStringArray("OutlineSprite", "IconSprite")] diff --git a/Scenes/NoteManager/NoteManager.tscn b/Scenes/NoteManager/NoteManager.tscn index 00a8f0cc..fc5e75d8 100644 --- a/Scenes/NoteManager/NoteManager.tscn +++ b/Scenes/NoteManager/NoteManager.tscn @@ -1,8 +1,8 @@ [gd_scene load_steps=7 format=3 uid="uid://bn8txx53xlguw"] -[ext_resource type="Script" path="res://Scenes/NoteManager/Scripts/InputHandler.cs" id="1_2oeuf"] +[ext_resource type="Script" uid="uid://bok6bnyemsgck" path="res://Scenes/NoteManager/Scripts/InputHandler.cs" id="1_2oeuf"] [ext_resource type="Texture2D" uid="uid://hfxynr5jdgsp" path="res://Scenes/NoteManager/Assets/New_Arrow.png" id="2_pb1qk"] -[ext_resource type="Script" path="res://Scenes/NoteManager/Scripts/NoteChecker.cs" id="3_0cioe"] +[ext_resource type="Script" uid="uid://coukobemtvmah" path="res://Scenes/NoteManager/Scripts/NoteChecker.cs" id="3_0cioe"] [ext_resource type="Texture2D" uid="uid://cgq2ar3pdmkac" path="res://Scenes/NoteManager/Assets/Arrow_Outline.png" id="4_3mttx"] [ext_resource type="Texture2D" uid="uid://b0tvsewgnf2x7" path="res://icon.svg" id="4_foklt"] [ext_resource type="PackedScene" uid="uid://bcf6vs4aqoxr5" path="res://Scenes/ChartViewport/HitParticles.tscn" id="5_jv1tr"] diff --git a/Scenes/Puppets/Scripts/PlayerStats.cs b/Scenes/Puppets/Scripts/PlayerStats.cs index f41bc6eb..7c0c4a96 100644 --- a/Scenes/Puppets/Scripts/PlayerStats.cs +++ b/Scenes/Puppets/Scripts/PlayerStats.cs @@ -8,6 +8,8 @@ public partial class PlayerStats : Resource public int MaxHealth = 100; public int CurrentHealth = 100; public int MaxComboBar = 80; + public int RewardAmountModifier = 0; + public int Rerolls = 2; public Note[] CurNotes = new Note[] { Scribe.NoteDictionary[1].Clone(), diff --git a/Scenes/UI/RewardSelectionUI.tscn b/Scenes/UI/RewardSelectionUI.tscn index 49e0598c..4196d1be 100644 --- a/Scenes/UI/RewardSelectionUI.tscn +++ b/Scenes/UI/RewardSelectionUI.tscn @@ -6,13 +6,14 @@ [ext_resource type="Theme" uid="uid://d37e3tpsbxwak" path="res://Scenes/UI/Assets/GeneralTheme.tres" id="4_gfac6"] [ext_resource type="Texture2D" uid="uid://burj10os057fx" path="res://Scenes/UI/Assets/UI_CrystalFrameInset.png" id="4_gufce"] -[node name="CanvasLayer" type="CanvasLayer" node_paths=PackedStringArray("ButtonContainer", "_description", "_acceptButton", "_skipButton")] +[node name="CanvasLayer" type="CanvasLayer" node_paths=PackedStringArray("ButtonContainer", "_description", "_acceptButton", "_skipButton", "_rerollButton")] process_mode = 3 script = ExtResource("1_1m6an") -ButtonContainer = NodePath("MarginContainer/PanelContainer/VBoxContainer/ScrollContainer/CenterContainer/HBoxContainer") +ButtonContainer = NodePath("MarginContainer/PanelContainer/VBoxContainer/ScrollContainer/CenterContainer/SelectionButtonContainer") _description = NodePath("MarginContainer/PanelContainer/VBoxContainer/DescBox/DescMargin/Description") _acceptButton = NodePath("MarginContainer/PanelContainer/VBoxContainer/MarginContainer/HBoxContainer/AcceptButton") _skipButton = NodePath("MarginContainer/PanelContainer/VBoxContainer/MarginContainer/HBoxContainer/SkipButton") +_rerollButton = NodePath("MarginContainer/PanelContainer/VBoxContainer/MarginContainer/HBoxContainer/RerollButton") [node name="Background" type="NinePatchRect" parent="."] self_modulate = Color(1, 1, 1, 0.75) @@ -70,6 +71,7 @@ horizontal_alignment = 1 [node name="ScrollContainer" type="ScrollContainer" parent="MarginContainer/PanelContainer/VBoxContainer"] layout_mode = 2 size_flags_vertical = 3 +follow_focus = true [node name="CenterContainer" type="CenterContainer" parent="MarginContainer/PanelContainer/VBoxContainer/ScrollContainer"] layout_mode = 2 @@ -88,7 +90,7 @@ patch_margin_top = 6 patch_margin_right = 6 patch_margin_bottom = 7 -[node name="HBoxContainer" type="HBoxContainer" parent="MarginContainer/PanelContainer/VBoxContainer/ScrollContainer/CenterContainer"] +[node name="SelectionButtonContainer" type="HBoxContainer" parent="MarginContainer/PanelContainer/VBoxContainer/ScrollContainer/CenterContainer"] layout_mode = 2 size_flags_vertical = 3 @@ -131,6 +133,13 @@ theme_override_constants/margin_bottom = 8 layout_mode = 2 size_flags_vertical = 3 +[node name="RerollButton" type="Button" parent="MarginContainer/PanelContainer/VBoxContainer/MarginContainer/HBoxContainer"] +visible = false +layout_mode = 2 +size_flags_horizontal = 3 +theme = ExtResource("4_gfac6") +text = "CHEST_ROOM_REROLL" + [node name="SkipButton" type="Button" parent="MarginContainer/PanelContainer/VBoxContainer/MarginContainer/HBoxContainer"] layout_mode = 2 size_flags_horizontal = 3 diff --git a/Scenes/UI/Scripts/RewardSelect.cs b/Scenes/UI/Scripts/RewardSelect.cs index dec78c68..694832e1 100644 --- a/Scenes/UI/Scripts/RewardSelect.cs +++ b/Scenes/UI/Scripts/RewardSelect.cs @@ -17,6 +17,9 @@ public partial class RewardSelect : CanvasLayer [Export] private Button _skipButton; + [Export] + private Button _rerollButton; + private ButtonGroup _rewardGroup; public delegate void SelectionMadeHandler(); @@ -32,15 +35,19 @@ private void Initialize(PlayerStats player, int amount, Stages type) { _player = player; _rewardGroup = new ButtonGroup(); - if (type == Stages.Battle) - { - GenerateNoteChoices(amount); - } - else + + _roomType = type; + _amount = amount + player.RewardAmountModifier; + if (player.Rerolls > 0) { - GenerateRelicChoices(amount); + _curRerolls = player.Rerolls; + _rerollButton.Visible = true; + _rerollButton.Text = Tr("CHEST_ROOM_REROLL") + _curRerolls; + _rerollButton.Pressed += Reroll; } + GenerateSelection(); + _acceptButton.Pressed += OnSelect; _acceptButton.FocusEntered += () => ChangeDescription(_selection); _skipButton.Pressed += OnSkip; @@ -62,30 +69,46 @@ private void AddButton(IDisplayable displayable) ButtonContainer.AddChild(button); } + private void GenerateSelection() + { + if (_roomType == Stages.Battle) + { + GenerateNoteChoices(_amount); + } + else + { + GenerateRelicChoices(_amount); + } + } + private void GenerateRelicChoices(int amount = 1) { if (amount < 1) GD.PushError("Error: In RewardSelect: amount < 1"); - _rChoices = Scribe.GetRandomRelics(_player.CurRelics, amount); - + _rChoices = Scribe.GetRandomRelics( + _player.CurRelics, + amount, + StageProducer.CurRoom + 10 * _curRerolls + ); + int numChildren = ButtonContainer.GetChildCount(); foreach (var relic in _rChoices) { AddButton(relic); } - ButtonContainer.GetChild