diff --git a/Globals/SaveSystem.cs b/Globals/SaveSystem.cs index cb522c32..86cb317f 100644 --- a/Globals/SaveSystem.cs +++ b/Globals/SaveSystem.cs @@ -373,6 +373,7 @@ public class SaveFile public int LastRoomIdx { get; init; } public int Area { get; init; } + public int Money { get; init; } public int[] NoteIds { get; init; } public int[] RelicIds { get; init; } public int PlayerHealth { get; init; } @@ -384,7 +385,8 @@ public SaveFile( int[] noteIds, int[] relicIds, int playerHealth, - int area + int area, + int money ) { RngSeed = rngSeed; @@ -394,6 +396,7 @@ int area RelicIds = relicIds; PlayerHealth = playerHealth; Area = area; + Money = money; } } @@ -408,7 +411,8 @@ public static void SaveGame() noteIds, relicIds, StageProducer.PlayerStats.CurrentHealth, - (int)StageProducer.CurArea + (int)StageProducer.CurArea, + StageProducer.PlayerStats.Money ); string json = JsonSerializer.Serialize(sv); diff --git a/Globals/StageProducer.cs b/Globals/StageProducer.cs index 3c435ee2..382404ff 100644 --- a/Globals/StageProducer.cs +++ b/Globals/StageProducer.cs @@ -114,6 +114,7 @@ private bool LoadGame() PlayerStats.AddRelic(Scribe.RelicDictionary[relicId]); } PlayerStats.CurrentHealth = sv.PlayerHealth; + PlayerStats.Money = sv.Money; IsInitialized = true; return true; } diff --git a/Scenes/BattleDirector/Scripts/BattleDirector.cs b/Scenes/BattleDirector/Scripts/BattleDirector.cs index b776ca33..1e73b94f 100644 --- a/Scenes/BattleDirector/Scripts/BattleDirector.cs +++ b/Scenes/BattleDirector/Scripts/BattleDirector.cs @@ -67,6 +67,7 @@ public override void _Ready() Harbinger.Init(this); InitPlayer(); InitEnemies(); + InitScoringGuide(); CD.Initialize(curSong); CD.NoteInputEvent += OnTimedInput; @@ -74,6 +75,33 @@ public override void _Ready() _focusedButton.Pressed += SyncStartWithMix; } + private ScoringScreen.ScoreGuide _battleScore; + + private void InitScoringGuide() + { + int baseMoney = 0; + foreach (EnemyPuppet enem in _enemies) + { + baseMoney += enem.BaseMoney; + } + + _battleScore = new ScoringScreen.ScoreGuide(baseMoney, Player.GetCurrentHealth()); + Harbinger.Instance.NotePlaced += (_) => + { + _battleScore.IncPlaced(); + }; + Harbinger.Instance.NoteHit += (_) => + { + _battleScore.IncHits(); + }; + Harbinger.Instance.NoteHit += (e) => + { + if (e is Harbinger.NoteHitArgs { Timing: Timing.Perfect }) + _battleScore.IncPerfects(); + _battleScore.IncHits(); + }; + } + private void InitPlayer() { Player = GD.Load(PlayerPuppet.LoadPath).Instantiate(); @@ -213,8 +241,21 @@ private void CheckBattleStatus(PuppetTemplate puppet) //Called when a puppet die OnBattleLost(); return; } - if (puppet is EnemyPuppet && IsBattleWon()) - OnBattleWon(); //will have to adjust this to account for when we have multiple enemies at once + + if (puppet is EnemyPuppet) + { + if (IsBattleWon()) + { + CM.ProcessMode = ProcessModeEnum.Disabled; + var tween = CreateTween(); + tween.TweenProperty(puppet, "modulate:a", 0, 2f); + tween.TweenCallback(Callable.From(OnBattleWon)); + } + else + { + puppet.Visible = false; + } + } } private bool IsBattleWon() @@ -224,9 +265,13 @@ private bool IsBattleWon() private void OnBattleWon() { - Audio.StreamPaused = true; CleanUpRelics(); - ShowRewardSelection(3); + _battleScore.SetEndHp(Player.GetCurrentHealth()); + Audio.ProcessMode = ProcessModeEnum.Always; + ScoringScreen.CreateScore(this, _battleScore).Finished += () => + { + ShowRewardSelection(3); + }; } private void OnBattleLost() diff --git a/Scenes/ChestScene/ChestScene.cs b/Scenes/ChestScene/ChestScene.cs index 8d32acbf..4451d014 100644 --- a/Scenes/ChestScene/ChestScene.cs +++ b/Scenes/ChestScene/ChestScene.cs @@ -33,6 +33,7 @@ public override void _Process(double delta) private void GetLoot() { + GetNode("%Audio").ProcessMode = ProcessModeEnum.Always; ChestButton.Disabled = true; RewardSelect.CreateSelection(this, _player.Stats, 3, Stages.Chest).Selected += EndBattle; } diff --git a/Scenes/ChestScene/ChestScene.tscn b/Scenes/ChestScene/ChestScene.tscn index 4ce4a918..92374ac3 100644 --- a/Scenes/ChestScene/ChestScene.tscn +++ b/Scenes/ChestScene/ChestScene.tscn @@ -23,7 +23,8 @@ script = ExtResource("1_ardd2") ChestButton = NodePath("CenterContainer/VBoxContainer/ChestButton") PlayerMarker = NodePath("PlayerMarker") -[node name="AudioStreamPlayer" type="AudioStreamPlayer" parent="."] +[node name="Audio" type="AudioStreamPlayer" parent="."] +unique_name_in_owner = true stream = ExtResource("2_x78jo") autoplay = true diff --git a/Scenes/Puppets/Enemies/BossBlood/P_BossBlood.cs b/Scenes/Puppets/Enemies/BossBlood/P_BossBlood.cs index b37a8ecb..38f7e712 100644 --- a/Scenes/Puppets/Enemies/BossBlood/P_BossBlood.cs +++ b/Scenes/Puppets/Enemies/BossBlood/P_BossBlood.cs @@ -10,6 +10,7 @@ public override void _Ready() { CurrentHealth = 100; MaxHealth = 100; + BaseMoney = 15; base._Ready(); var enemTween = CreateTween(); enemTween.TweenProperty(Sprite, "position", Vector2.Down * 5, 1f).AsRelative(); diff --git a/Scenes/Puppets/Enemies/EnemyPuppet.cs b/Scenes/Puppets/Enemies/EnemyPuppet.cs index c8b5b7d5..5301476c 100644 --- a/Scenes/Puppets/Enemies/EnemyPuppet.cs +++ b/Scenes/Puppets/Enemies/EnemyPuppet.cs @@ -3,6 +3,7 @@ public partial class EnemyPuppet : PuppetTemplate { protected EnemyEffect[] BattleEvents = Array.Empty(); + public int BaseMoney { get; protected set; } = 0; public virtual EnemyEffect[] GetBattleEvents() { diff --git a/Scenes/Puppets/Enemies/Parasifly/P_Parasifly.cs b/Scenes/Puppets/Enemies/Parasifly/P_Parasifly.cs index bd755093..34f3b47b 100644 --- a/Scenes/Puppets/Enemies/Parasifly/P_Parasifly.cs +++ b/Scenes/Puppets/Enemies/Parasifly/P_Parasifly.cs @@ -10,6 +10,7 @@ public override void _Ready() { CurrentHealth = 50; MaxHealth = 50; + BaseMoney = 5; base._Ready(); var enemTween = CreateTween(); enemTween.TweenProperty(Sprite, "position", Vector2.Down * 2, 2f).AsRelative(); diff --git a/Scenes/Puppets/Enemies/TheGWS/P_TheGWS.cs b/Scenes/Puppets/Enemies/TheGWS/P_TheGWS.cs index f720ce0c..034251db 100644 --- a/Scenes/Puppets/Enemies/TheGWS/P_TheGWS.cs +++ b/Scenes/Puppets/Enemies/TheGWS/P_TheGWS.cs @@ -9,6 +9,7 @@ public override void _Ready() { CurrentHealth = 75; MaxHealth = 75; + BaseMoney = 10; base._Ready(); var enemTween = CreateTween(); enemTween.TweenProperty(Sprite, "position", Vector2.Down * 10, 3f).AsRelative(); diff --git a/Scenes/Puppets/Scripts/PlayerStats.cs b/Scenes/Puppets/Scripts/PlayerStats.cs index 8c3735ef..78cd0653 100644 --- a/Scenes/Puppets/Scripts/PlayerStats.cs +++ b/Scenes/Puppets/Scripts/PlayerStats.cs @@ -5,6 +5,8 @@ public partial class PlayerStats : Resource { + public int Money = 0; + public int MaxHealth = 100; public int CurrentHealth = 100; public int MaxComboBar = 60; diff --git a/Scenes/Puppets/Scripts/PuppetTemplate.cs b/Scenes/Puppets/Scripts/PuppetTemplate.cs index 5257d67f..b530fd76 100644 --- a/Scenes/Puppets/Scripts/PuppetTemplate.cs +++ b/Scenes/Puppets/Scripts/PuppetTemplate.cs @@ -111,7 +111,6 @@ protected virtual Tween DamageAnimate(int amount) protected virtual void Kill() { Defeated?.Invoke(this); - Visible = false; } #endregion @@ -127,7 +126,7 @@ public virtual void TakeDamage(DamageInstance dmg) Tween deathTween = DamageAnimate(amount); if (CurrentHealth <= 0) { - deathTween.TweenCallback(Callable.From(Kill)); + deathTween.Finished += Kill; } TextParticle newText = new TextParticle(); diff --git a/Scenes/UI/Inventory.tscn b/Scenes/UI/Inventory.tscn index 963cbad3..47cb4819 100644 --- a/Scenes/UI/Inventory.tscn +++ b/Scenes/UI/Inventory.tscn @@ -5,7 +5,7 @@ [ext_resource type="Texture2D" uid="uid://8u3xvcma81d" path="res://Scenes/UI/Assets/UI_CrystalFrame.png" id="3_s6pj7"] [ext_resource type="Texture2D" uid="uid://burj10os057fx" path="res://Scenes/UI/Assets/UI_CrystalFrameInset.png" id="4_b6trj"] -[node name="Inventory" type="Control" node_paths=PackedStringArray("_relics", "_notes", "_description", "_tabs")] +[node name="Inventory" type="Control" node_paths=PackedStringArray("_relics", "_notes", "_description", "_tabs", "_moneyLabel")] process_mode = 1 layout_mode = 3 anchors_preset = 15 @@ -18,6 +18,7 @@ _relics = NodePath("MarginContainer/InvenVBox/Tabs/INVENTORY_TAB_RELICS/MarginCo _notes = NodePath("MarginContainer/InvenVBox/Tabs/INVENTORY_TAB_NOTES/MarginContainer/NotesBox/NotesGrid") _description = NodePath("MarginContainer/InvenVBox/DescBox/DescMargin/MarginContainer/Description") _tabs = NodePath("MarginContainer/InvenVBox/Tabs") +_moneyLabel = NodePath("MoneyContainer/MoneyFrame/MarginContainer/MoneyLabel") [node name="Background" type="NinePatchRect" parent="."] self_modulate = Color(1, 1, 1, 0.75) @@ -168,3 +169,39 @@ size_flags_vertical = 1 autowrap_mode = 2 clip_text = true text_overrun_behavior = 1 + +[node name="MoneyContainer" type="MarginContainer" parent="."] +layout_mode = 1 +anchors_preset = 1 +anchor_left = 1.0 +anchor_right = 1.0 +offset_left = -130.0 +offset_bottom = 34.0 +grow_horizontal = 0 +theme_override_constants/margin_top = 5 +theme_override_constants/margin_right = 10 +theme_override_constants/margin_bottom = 5 + +[node name="MoneyFrame" type="NinePatchRect" parent="MoneyContainer"] +layout_mode = 2 +texture = ExtResource("3_s6pj7") +patch_margin_left = 7 +patch_margin_top = 7 +patch_margin_right = 7 +patch_margin_bottom = 7 + +[node name="MarginContainer" type="MarginContainer" parent="MoneyContainer/MoneyFrame"] +layout_mode = 1 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +theme_override_constants/margin_right = 8 + +[node name="MoneyLabel" type="Label" parent="MoneyContainer/MoneyFrame/MarginContainer"] +layout_mode = 2 +size_flags_vertical = 1 +text = "0" +horizontal_alignment = 2 +vertical_alignment = 1 diff --git a/Scenes/UI/ScoreScreen.tscn b/Scenes/UI/ScoreScreen.tscn new file mode 100644 index 00000000..79c212ce --- /dev/null +++ b/Scenes/UI/ScoreScreen.tscn @@ -0,0 +1,202 @@ +[gd_scene load_steps=6 format=3 uid="uid://d3ulgssit1dcv"] + +[ext_resource type="Script" uid="uid://b5bw86d25uwdd" path="res://Scenes/UI/Scripts/ScoringScreen.cs" id="1_ma4hf"] +[ext_resource type="Texture2D" uid="uid://ck16vyh1q68ri" path="res://Scenes/UI/Assets/UI_ForestBackground.png" id="1_ws5ov"] +[ext_resource type="Texture2D" uid="uid://8u3xvcma81d" path="res://Scenes/UI/Assets/UI_CrystalFrame.png" id="2_usavq"] +[ext_resource type="Texture2D" uid="uid://burj10os057fx" path="res://Scenes/UI/Assets/UI_CrystalFrameInset.png" id="3_usavq"] +[ext_resource type="Theme" uid="uid://d37e3tpsbxwak" path="res://Scenes/UI/Assets/GeneralTheme.tres" id="4_1rsqt"] + +[node name="ScoreScreen" type="CanvasLayer" node_paths=PackedStringArray("_styleLabel", "_styleAmount", "_perfectsLabel", "_perfectsAmount", "_placedLabel", "_placedAmount", "_totalLabel", "_totalAmount", "_acceptButton")] +process_mode = 3 +script = ExtResource("1_ma4hf") +_styleLabel = NodePath("Bg/WindowMargin/PanelBg/VBoxContainer/MarginContainer/BottomPanelBg/HBoxContainer/LabelMargin/LabelVbox/StyleLabel") +_styleAmount = NodePath("Bg/WindowMargin/PanelBg/VBoxContainer/MarginContainer/BottomPanelBg/HBoxContainer/ScoreMargin/LabelVbox/StyleLabel") +_perfectsLabel = NodePath("Bg/WindowMargin/PanelBg/VBoxContainer/MarginContainer/BottomPanelBg/HBoxContainer/LabelMargin/LabelVbox/PerfectLabel") +_perfectsAmount = NodePath("Bg/WindowMargin/PanelBg/VBoxContainer/MarginContainer/BottomPanelBg/HBoxContainer/ScoreMargin/LabelVbox/PerfectLabel") +_placedLabel = NodePath("Bg/WindowMargin/PanelBg/VBoxContainer/MarginContainer/BottomPanelBg/HBoxContainer/LabelMargin/LabelVbox/PlacedLabel") +_placedAmount = NodePath("Bg/WindowMargin/PanelBg/VBoxContainer/MarginContainer/BottomPanelBg/HBoxContainer/ScoreMargin/LabelVbox/PlacedLabel") +_totalLabel = NodePath("Bg/WindowMargin/PanelBg/VBoxContainer/MarginContainer/BottomPanelBg/HBoxContainer/LabelMargin/LabelVbox/TotalLabel") +_totalAmount = NodePath("Bg/WindowMargin/PanelBg/VBoxContainer/MarginContainer/BottomPanelBg/HBoxContainer/ScoreMargin/LabelVbox/TotalLabel") +_acceptButton = NodePath("Bg/WindowMargin/PanelBg/VBoxContainer/ButtonMargin/AcceptButton") + +[node name="Bg" type="NinePatchRect" parent="."] +self_modulate = Color(1, 1, 1, 0.75) +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +texture = ExtResource("1_ws5ov") +patch_margin_left = 100 +patch_margin_top = 100 +patch_margin_right = 102 +patch_margin_bottom = 100 + +[node name="WindowMargin" type="MarginContainer" parent="Bg"] +layout_mode = 1 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +theme_override_constants/margin_left = 175 +theme_override_constants/margin_top = 50 +theme_override_constants/margin_right = 175 +theme_override_constants/margin_bottom = 50 + +[node name="PanelBg" type="NinePatchRect" parent="Bg/WindowMargin"] +self_modulate = Color(1, 1, 1, 0.75) +layout_mode = 2 +texture = ExtResource("2_usavq") +patch_margin_left = 30 +patch_margin_top = 10 +patch_margin_right = 20 +patch_margin_bottom = 27 + +[node name="VBoxContainer" type="VBoxContainer" parent="Bg/WindowMargin/PanelBg"] +layout_mode = 1 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 + +[node name="TopPanelBg" type="NinePatchRect" parent="Bg/WindowMargin/PanelBg/VBoxContainer"] +self_modulate = Color(1, 1, 1, 0.5) +layout_mode = 2 +size_flags_horizontal = 3 +size_flags_vertical = 3 +size_flags_stretch_ratio = 0.25 +texture = ExtResource("2_usavq") +patch_margin_left = 30 +patch_margin_top = 10 +patch_margin_right = 20 +patch_margin_bottom = 27 + +[node name="Title" type="CenterContainer" parent="Bg/WindowMargin/PanelBg/VBoxContainer/TopPanelBg"] +layout_mode = 1 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 + +[node name="TitleText" type="RichTextLabel" parent="Bg/WindowMargin/PanelBg/VBoxContainer/TopPanelBg/Title"] +custom_minimum_size = Vector2(400, 47) +layout_mode = 2 +theme_override_font_sizes/normal_font_size = 32 +bbcode_enabled = true +text = "SCORING_SCENE_TITLE" +horizontal_alignment = 1 +vertical_alignment = 1 + +[node name="MarginContainer" type="MarginContainer" parent="Bg/WindowMargin/PanelBg/VBoxContainer"] +layout_mode = 2 +size_flags_vertical = 3 +theme_override_constants/margin_left = 4 +theme_override_constants/margin_top = 0 +theme_override_constants/margin_right = 4 +theme_override_constants/margin_bottom = 4 + +[node name="BottomPanelBg" type="NinePatchRect" parent="Bg/WindowMargin/PanelBg/VBoxContainer/MarginContainer"] +self_modulate = Color(1, 1, 1, 0.5) +layout_mode = 2 +size_flags_horizontal = 3 +size_flags_vertical = 3 +texture = ExtResource("3_usavq") +patch_margin_left = 30 +patch_margin_top = 10 +patch_margin_right = 20 +patch_margin_bottom = 27 + +[node name="HBoxContainer" type="HBoxContainer" parent="Bg/WindowMargin/PanelBg/VBoxContainer/MarginContainer/BottomPanelBg"] +layout_mode = 1 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +size_flags_vertical = 3 + +[node name="LabelMargin" type="MarginContainer" parent="Bg/WindowMargin/PanelBg/VBoxContainer/MarginContainer/BottomPanelBg/HBoxContainer"] +layout_mode = 2 +size_flags_horizontal = 3 +theme_override_constants/margin_left = 8 +theme_override_constants/margin_top = 8 +theme_override_constants/margin_right = 8 +theme_override_constants/margin_bottom = 8 + +[node name="LabelVbox" type="VBoxContainer" parent="Bg/WindowMargin/PanelBg/VBoxContainer/MarginContainer/BottomPanelBg/HBoxContainer/LabelMargin"] +layout_mode = 2 +size_flags_horizontal = 3 +theme_override_constants/separation = 11 +alignment = 1 + +[node name="StyleLabel" type="Label" parent="Bg/WindowMargin/PanelBg/VBoxContainer/MarginContainer/BottomPanelBg/HBoxContainer/LabelMargin/LabelVbox"] +layout_mode = 2 +text = "SCORING_STYLE" + +[node name="PerfectLabel" type="Label" parent="Bg/WindowMargin/PanelBg/VBoxContainer/MarginContainer/BottomPanelBg/HBoxContainer/LabelMargin/LabelVbox"] +layout_mode = 2 +text = "SCORING_PERFECTS" + +[node name="PlacedLabel" type="Label" parent="Bg/WindowMargin/PanelBg/VBoxContainer/MarginContainer/BottomPanelBg/HBoxContainer/LabelMargin/LabelVbox"] +layout_mode = 2 +text = "SCORING_PLACED" + +[node name="Placeholder" type="Label" parent="Bg/WindowMargin/PanelBg/VBoxContainer/MarginContainer/BottomPanelBg/HBoxContainer/LabelMargin/LabelVbox"] +layout_mode = 2 + +[node name="TotalLabel" type="Label" parent="Bg/WindowMargin/PanelBg/VBoxContainer/MarginContainer/BottomPanelBg/HBoxContainer/LabelMargin/LabelVbox"] +layout_mode = 2 +text = "SCORING_TOTAL" + +[node name="ScoreMargin" type="MarginContainer" parent="Bg/WindowMargin/PanelBg/VBoxContainer/MarginContainer/BottomPanelBg/HBoxContainer"] +layout_mode = 2 +size_flags_horizontal = 3 +size_flags_stretch_ratio = 0.25 +theme_override_constants/margin_left = 8 +theme_override_constants/margin_top = 8 +theme_override_constants/margin_right = 8 +theme_override_constants/margin_bottom = 8 + +[node name="LabelVbox" type="VBoxContainer" parent="Bg/WindowMargin/PanelBg/VBoxContainer/MarginContainer/BottomPanelBg/HBoxContainer/ScoreMargin"] +layout_mode = 2 +size_flags_horizontal = 3 +theme_override_constants/separation = 11 +alignment = 1 + +[node name="StyleLabel" type="Label" parent="Bg/WindowMargin/PanelBg/VBoxContainer/MarginContainer/BottomPanelBg/HBoxContainer/ScoreMargin/LabelVbox"] +layout_mode = 2 +text = "999" +horizontal_alignment = 2 + +[node name="PerfectLabel" type="Label" parent="Bg/WindowMargin/PanelBg/VBoxContainer/MarginContainer/BottomPanelBg/HBoxContainer/ScoreMargin/LabelVbox"] +layout_mode = 2 +text = "999" +horizontal_alignment = 2 + +[node name="PlacedLabel" type="Label" parent="Bg/WindowMargin/PanelBg/VBoxContainer/MarginContainer/BottomPanelBg/HBoxContainer/ScoreMargin/LabelVbox"] +layout_mode = 2 +text = "999" +horizontal_alignment = 2 + +[node name="Placeholder" type="Label" parent="Bg/WindowMargin/PanelBg/VBoxContainer/MarginContainer/BottomPanelBg/HBoxContainer/ScoreMargin/LabelVbox"] +layout_mode = 2 +horizontal_alignment = 2 + +[node name="TotalLabel" type="Label" parent="Bg/WindowMargin/PanelBg/VBoxContainer/MarginContainer/BottomPanelBg/HBoxContainer/ScoreMargin/LabelVbox"] +layout_mode = 2 +text = "999" +horizontal_alignment = 2 + +[node name="ButtonMargin" type="MarginContainer" parent="Bg/WindowMargin/PanelBg/VBoxContainer"] +layout_mode = 2 +theme_override_constants/margin_top = -3 +theme_override_constants/margin_bottom = 9 + +[node name="AcceptButton" type="Button" parent="Bg/WindowMargin/PanelBg/VBoxContainer/ButtonMargin"] +layout_mode = 2 +size_flags_horizontal = 6 +theme = ExtResource("4_1rsqt") +text = "CHEST_ROOM_ACCEPT" diff --git a/Scenes/UI/Scripts/Inventory.cs b/Scenes/UI/Scripts/Inventory.cs index 2c2bb84c..2f146229 100644 --- a/Scenes/UI/Scripts/Inventory.cs +++ b/Scenes/UI/Scripts/Inventory.cs @@ -17,6 +17,9 @@ public partial class Inventory : Control, IFocusableMenu [Export] private TabContainer _tabs; + [Export] + private Label _moneyLabel; + public IFocusableMenu Prev { get; set; } private static readonly string[] TabNames = new[] { "NOTE", "RELIC" }; @@ -25,6 +28,8 @@ private void Display(PlayerStats playerStats) AddDisplayButtons(playerStats.CurRelics, _relics); AddDisplayButtons(playerStats.CurNotes, _notes); + _moneyLabel.Text = playerStats.Money.ToString(); + _tabs.TabChanged += ClearDescription; } diff --git a/Scenes/UI/Scripts/ScoringScreen.cs b/Scenes/UI/Scripts/ScoringScreen.cs new file mode 100644 index 00000000..1d5a757b --- /dev/null +++ b/Scenes/UI/Scripts/ScoringScreen.cs @@ -0,0 +1,139 @@ +using System; +using Godot; + +public partial class ScoringScreen : CanvasLayer +{ + public static readonly string LoadPath = "res://Scenes/UI/ScoreScreen.tscn"; + + public struct ScoreGuide + { + public int BaseMoney = 0; + public int TotalHits = 0; + public int TotalPerfects = 0; + public int TotalPlaced = 0; + public float StartingHealth = 0; + public float EndingHealth = 0; + + public ScoreGuide(int baseMoney, float startingHealth) + { + BaseMoney = baseMoney; + StartingHealth = startingHealth; + } + + public void IncreaseBase(int amount) + { + BaseMoney += amount; + } + + public void IncHits() + { + TotalHits++; + } + + public void IncPerfects() + { + TotalPerfects++; + } + + public void IncPlaced() + { + TotalPlaced++; + } + + public void SetEndHp(float amount) + { + EndingHealth = amount; + } + } + + [Export] + private Label _styleLabel; + + [Export] + private Label _styleAmount; + + [Export] + private Label _perfectsLabel; + + [Export] + private Label _perfectsAmount; + + [Export] + private Label _placedLabel; + + [Export] + private Label _placedAmount; + + [Export] + private Label _totalLabel; + + [Export] + private Label _totalAmount; + + [Export] + private Button _acceptButton; + + private int _totalBaseMoney; + private float _perfectMulti; + private float _placedMulti; + private int FinalMoney => (int)(_totalBaseMoney * _perfectMulti * _placedMulti); + + public delegate void FinishedHandler(); + public event FinishedHandler Finished; + + public override void _Ready() + { + _acceptButton.Pressed += FinishScoring; + } + + public override void _Process(double delta) + { + _acceptButton.GrabFocus(); + } + + public static ScoringScreen CreateScore(Node2D parent, ScoreGuide info) + { + ScoringScreen result = GD.Load(LoadPath).Instantiate(); + parent.AddChild(result); + result.GenerateScore(info); + parent.ProcessMode = ProcessModeEnum.Disabled; + + return result; + } + + private void GenerateScore(ScoreGuide info) + { + //Arbitrarily deciding on money calcs + _totalBaseMoney = CalcTotalBase(info); + + //Multis + _perfectMulti = 1 + (float)info.TotalPerfects / (info.TotalHits - info.TotalPlaced); + if (float.IsNaN(_perfectMulti)) + _perfectMulti = 1; + _placedMulti = Math.Max(2 - (float)Math.Abs(info.TotalPlaced - info.BaseMoney) / 10, 1); + DrawScoreLabels(); + } + + private int CalcTotalBase(ScoreGuide info) + { + int result = info.BaseMoney; + result += (int)((info.EndingHealth / info.StartingHealth) * 10); + result += StageProducer.GlobalRng.RandiRange(0, 3); + return result; + } + + private void DrawScoreLabels() + { + _styleAmount.Text = $"{_totalBaseMoney}"; + _perfectsAmount.Text = $"X{_perfectMulti:0.00}"; + _placedAmount.Text = $"X{_placedMulti:0.00}"; + _totalAmount.Text = $"{FinalMoney}"; + } + + private void FinishScoring() + { + StageProducer.PlayerStats.Money += FinalMoney; + Finished?.Invoke(); + QueueFree(); + } +} diff --git a/Scenes/UI/Scripts/ScoringScreen.cs.uid b/Scenes/UI/Scripts/ScoringScreen.cs.uid new file mode 100644 index 00000000..e121e48f --- /dev/null +++ b/Scenes/UI/Scripts/ScoringScreen.cs.uid @@ -0,0 +1 @@ +uid://b5bw86d25uwdd