From 692cf282da4ec469cdebeb59dba7dfef77aca6ed Mon Sep 17 00:00:00 2001 From: LifeHckr Date: Tue, 11 Feb 2025 12:05:38 -0800 Subject: [PATCH 1/6] Simple Inventory menu implemented --- Classes/Notes/Note.cs | 9 +- Classes/Relics/RelicTemplate.cs | 16 +++- Globals/Scribe.cs | 31 +++--- project.godot | 5 + .../BattleDirector/scripts/BattleDirector.cs | 9 +- scenes/BattleDirector/test_battle_scene.tscn | 8 -- scenes/UI/display_button.tscn | 11 +++ scenes/UI/inventory.tscn | 95 +++++++++++++++++++ scenes/UI/scripts/DisplayButton.cs | 22 +++++ scenes/UI/scripts/Inventory.cs | 75 +++++++++++++++ 10 files changed, 245 insertions(+), 36 deletions(-) create mode 100644 scenes/UI/display_button.tscn create mode 100644 scenes/UI/inventory.tscn create mode 100644 scenes/UI/scripts/DisplayButton.cs create mode 100644 scenes/UI/scripts/Inventory.cs diff --git a/Classes/Notes/Note.cs b/Classes/Notes/Note.cs index 9c16e50f..1533856f 100644 --- a/Classes/Notes/Note.cs +++ b/Classes/Notes/Note.cs @@ -13,21 +13,20 @@ public partial class Note : Resource private int _baseVal; private Action NoteEffect; //TODO: Where/How to deal with timing. + public string Tooltip; public Texture2D Texture; - //public string Tooltip; - public Note( string name, - PuppetTemplate owner = null, + string tooltip, Texture2D texture = null, + PuppetTemplate owner = null, int baseVal = 1, Action noteEffect = null ) { Name = name; Owner = owner; - Texture = texture; NoteEffect = noteEffect ?? ( @@ -37,6 +36,8 @@ public Note( } ); _baseVal = baseVal; + Texture = texture; + Tooltip = tooltip; } public void OnHit(BattleDirector BD, Timing timing) diff --git a/Classes/Relics/RelicTemplate.cs b/Classes/Relics/RelicTemplate.cs index 892e1bdf..ad317192 100644 --- a/Classes/Relics/RelicTemplate.cs +++ b/Classes/Relics/RelicTemplate.cs @@ -7,12 +7,20 @@ public partial class RelicTemplate : Resource public RelicEffect[] Effects; public string Name; - //public Texture2D Texture - //public string Tooltip - public RelicTemplate(string Name = "", RelicEffect[] EffectTags = null) + public Texture2D Texture; + public string Tooltip; + + public RelicTemplate( + string name = "", + string tooltip = "", + Texture2D texture = null, + RelicEffect[] EffectTags = null + ) { Effects = EffectTags; - this.Name = Name; + Name = name; + Tooltip = tooltip; + Texture = texture; } public RelicTemplate Clone() diff --git a/Globals/Scribe.cs b/Globals/Scribe.cs index 7a7d4775..75ee36a4 100644 --- a/Globals/Scribe.cs +++ b/Globals/Scribe.cs @@ -12,7 +12,8 @@ public partial class Scribe : Node { new Note( "EnemyBase", - null, + "Basic enemy note, deals damage to player.", + GD.Load("res://scenes/BattleDirector/assets/Character1.png"), null, 1, (director, note, timing) => @@ -22,8 +23,9 @@ public partial class Scribe : Node ), new Note( "PlayerBase", - null, + "Basic player note, deals damage to enemy", GD.Load("res://Classes/Notes/assets/single_note.png"), + null, 1, (director, note, timing) => { @@ -32,8 +34,9 @@ public partial class Scribe : Node ), new Note( "PlayerDouble", + "Basic player note, deals damage to enemy", + GD.Load("res://Classes/Notes/assets/single_note.png"), null, - GD.Load("res://Classes/Notes/assets/double_note.png"), 1, (director, note, timing) => { @@ -48,11 +51,13 @@ public partial class Scribe : Node { new RelicTemplate( "Breakfast", //Reference ha ha, Item to give when relic pool is empty. + "Breakfast, currently does nothing :).", //TODO: Description can include the relics values? + GD.Load("res://scenes/BattleDirector/assets/Character1.png"), new RelicEffect[] { new RelicEffect( BattleEffectTrigger.NotePlaced, - 1, + 0, (director, val) => { director.Player.Heal(val); @@ -62,25 +67,13 @@ public partial class Scribe : Node ), new RelicTemplate( "Good Vibes", + "Good vibes, heals the player whenever they place a note.", //TODO: Description can include the relics values? + GD.Load("res://scenes/BattleDirector/assets/Character1.png"), new RelicEffect[] { new RelicEffect( BattleEffectTrigger.NotePlaced, - 5, - (director, val) => - { - director.Player.Heal(val); - } - ), - } - ), - new RelicTemplate( - "Dummy Item", - new RelicEffect[] - { - new RelicEffect( - BattleEffectTrigger.NotePlaced, - 100, + 1, (director, val) => { director.Player.Heal(val); diff --git a/project.godot b/project.godot index 7258ddc5..94e0cab0 100644 --- a/project.godot +++ b/project.godot @@ -63,6 +63,11 @@ Pause={ "events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194305,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null) ] } +Inventory={ +"deadzone": 0.5, +"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":73,"key_label":0,"unicode":105,"location":0,"echo":false,"script":null) +] +} [rendering] diff --git a/scenes/BattleDirector/scripts/BattleDirector.cs b/scenes/BattleDirector/scripts/BattleDirector.cs index 524b712d..39643e62 100644 --- a/scenes/BattleDirector/scripts/BattleDirector.cs +++ b/scenes/BattleDirector/scripts/BattleDirector.cs @@ -134,6 +134,14 @@ public override void _UnhandledInput(InputEvent @event) GetNode("UILayer").AddChild(pauseMenu.Instantiate()); GetTree().Paused = true; } + if (@event.IsActionPressed("Inventory")) + { + var invenMenu = GD.Load("res://scenes/UI/inventory.tscn") + .Instantiate(); + GetNode("UILayer").AddChild(invenMenu); + invenMenu.Display(Player.Stats); + GetTree().Paused = true; + } } private void OnNotePressed(ArrowType type) @@ -224,7 +232,6 @@ private void EventizeRelics() { foreach (var relic in Player.Stats.CurRelics) { - GetNode