From e85d3c72207f8fc504ebb08a85278f9db0e9fc4e Mon Sep 17 00:00:00 2001 From: cornerloan Date: Sun, 23 Mar 2025 00:21:35 -0700 Subject: [PATCH 01/36] Added two relics Changed NoteHit in namespace to EnemyNoteHit, since that was what I implied it to be, and it wasn't being used anyway. Added two relics: Chips: deals damage when you hit enemy notes Paper Cut: deals daamge each loop --- Classes/Relics/Assets/Relic_Chips.png | Bin 0 -> 1000 bytes Classes/Relics/Assets/Relic_Chips.png.import | 34 ++++++++++++++++++ Classes/Relics/Assets/Relic_PaperCut.png | Bin 0 -> 1126 bytes .../Relics/Assets/Relic_PaperCut.png.import | 34 ++++++++++++++++++ Globals/FunkEngineNameSpace.cs | 2 +- Globals/Scribe.cs | 34 ++++++++++++++++++ Globals/Translations/translations.csv | 4 +++ .../BattleDirector/scripts/BattleDirector.cs | 10 ++++++ 8 files changed, 117 insertions(+), 1 deletion(-) create mode 100644 Classes/Relics/Assets/Relic_Chips.png create mode 100644 Classes/Relics/Assets/Relic_Chips.png.import create mode 100644 Classes/Relics/Assets/Relic_PaperCut.png create mode 100644 Classes/Relics/Assets/Relic_PaperCut.png.import diff --git a/Classes/Relics/Assets/Relic_Chips.png b/Classes/Relics/Assets/Relic_Chips.png new file mode 100644 index 0000000000000000000000000000000000000000..74bdf235ca1f614e2d568afa7a199d39995296a9 GIT binary patch literal 1000 zcmV>P)EX>4Tx04R}tkv&MmKpe$iQ?()$2MdZQWT;Md@e9XN#UfZJZG~1HOfLNpnlvOS zE{=k0!NHHks)LKOt`4q(Aou~|E;uQ=NQwVT3N2zhIPS;0dyl(!fKV?p)$E7@s%9Cf zcudUZR>Z(7{1`wNrZFNhQ%|H9GVmN<_we!cF2b|C&;2=imAuISpGX{Kx?vHo6VGf~ zI_G`j5GzRv@j3ChK^G)`9%C|}6B ztZ?4qtd^^+c~AbrU|w5JbDice;#foiNr;e9#Rkf-5TR8g#YBqsV;=q?$DbsZOs)+u za?GOw6_Voz|AXJ%nuW;;Hz^ncI$v!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Hm010qNS#tmY zE+YT{E+YYWr9XB6000McNliru=>r!B3K8PrE8zeD02y>eSad^gZEa<4bO1wgWnpw> zWFU8GbZ8()Nlj2!fese{00KTqL_t(o!|jz%NEBfh#-I0_rQO0^5dz&)e_RQ=MI_@% zLFU^WEu5n}PKKMB16jd~wnn)USn!7eP$SZWDRl zTXuCd?U`#RJ6t-JBDVnKKz=l;d3BuUCJb{@DlIaf?@-mtA~FSFU}Z})a)Kc7*B#J8 zAw%GSh+H!D^>t1Vw8+H7+@>G%{Xvq`l1OBCQhc+&;qO!`%`j%xjE}$g7e}yd2Sj8J zBF8kJZ)0Cywf_UDl*{h!1|@CP`w&Y@x!ns;EY1sXf#gG-oLq>keb3I$qaxC;s*kl& sc|+hxRp22N8I3&eOS}_eV)g{T0DOZPds#=Qng9R*07*qoM6N<$f~*?$Gynhq literal 0 HcmV?d00001 diff --git a/Classes/Relics/Assets/Relic_PaperCut.png.import b/Classes/Relics/Assets/Relic_PaperCut.png.import new file mode 100644 index 00000000..f91aa7f4 --- /dev/null +++ b/Classes/Relics/Assets/Relic_PaperCut.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://cmd8hjrxxk4ic" +path="res://.godot/imported/Relic_PaperCut.png-c918160bd88b568b8e8ae4c716d26ae4.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://Classes/Relics/Assets/Relic_PaperCut.png" +dest_files=["res://.godot/imported/Relic_PaperCut.png-c918160bd88b568b8e8ae4c716d26ae4.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/Globals/FunkEngineNameSpace.cs b/Globals/FunkEngineNameSpace.cs index 5ac7013c..e0db9e2c 100644 --- a/Globals/FunkEngineNameSpace.cs +++ b/Globals/FunkEngineNameSpace.cs @@ -57,7 +57,7 @@ public struct BattleConfig public enum BattleEffectTrigger { NotePlaced, - NoteHit, + EnemyNoteHit, SelfNoteHit, OnPickup, OnLoop, diff --git a/Globals/Scribe.cs b/Globals/Scribe.cs index ca108708..ddce0208 100644 --- a/Globals/Scribe.cs +++ b/Globals/Scribe.cs @@ -170,6 +170,40 @@ public partial class Scribe : Node ), } ), + new RelicTemplate( + 4, + "Chips", + "Hitting an enemy note deals a bit of damage.", + GD.Load("res://Classes/Relics/Assets/Relic_Chips.png"), + new RelicEffect[] + { + new RelicEffect( + BattleEffectTrigger.EnemyNoteHit, + 1, + (director, self, val) => + { + director.Enemy.TakeDamage(val); + } + ), + } + ), + new RelicTemplate( + 5, + "Paper Cut", + "Deals damage each loop.", + GD.Load("res://Classes/Relics/Assets/Relic_PaperCut.png"), + new RelicEffect[] + { + new RelicEffect( + BattleEffectTrigger.OnLoop, + 5, + (director, self, val) => + { + director.Enemy.TakeDamage(val); + } + ), + } + ), }; public static readonly SongTemplate[] SongDictionary = new[] diff --git a/Globals/Translations/translations.csv b/Globals/Translations/translations.csv index 36684621..cbdfe8bf 100644 --- a/Globals/Translations/translations.csv +++ b/Globals/Translations/translations.csv @@ -50,6 +50,10 @@ RELIC_AUROBOROS_NAME,Auroboros,无尾蛇 RELIC_AUROBOROS_TOOLTIP,"Bigger number, better person. Increases combo multiplier every riff.","进一步增加综合倍数,每次现场提升" RELIC_COLORBOROS_NAME,Colorboros,彩蛇轮回 RELIC_COLORBOROS_TOOLTIP,"Taste the rainbow. Charges the freestyle bar every riff.","品尝临岛,每次现场充值自由格条" +RELIC_CHIPS_NAME,"Chips",薯片 +RELIC_CHIPS_TOOLTIP,"Hitting an enemy note deals a bit of damage.","击中敌方音符会造成少量伤害" +RELIC_PAPERCUT_NAME,Paper Cut,纸割伤 +RELIC_PAPERCUT_TOOLTIP,"Deals damage each loop.","每轮造成伤害" INVENTORY_TAB_NOTES,Notes,乐谱 INVENTORY_TAB_RELICS,Relics,遗物 OPTIONS_VOLUME_LABEL,Master Volume,最终音量设置 diff --git a/scenes/BattleDirector/scripts/BattleDirector.cs b/scenes/BattleDirector/scripts/BattleDirector.cs index 76ab5963..c375a5ea 100644 --- a/scenes/BattleDirector/scripts/BattleDirector.cs +++ b/scenes/BattleDirector/scripts/BattleDirector.cs @@ -171,6 +171,10 @@ private void OnTimedInput(Note note, ArrowType arrowType, int beat, double beatD Timing timed = CheckTiming(beatDif); note.OnHit(this, timed); + + if (note.Name == "EnemyBase" && timed != Timing.Miss) //TODO: notes have owner field, find a way to determine if the owner is an enemy + EnemyNoteHit?.Invoke(this); + if (timed == Timing.Miss) { NotePlacementBar.MissNote(); @@ -252,6 +256,9 @@ private void ShowRewardSelection(int amount) private delegate void ChartLoopHandler(BattleDirector BD); private event ChartLoopHandler ChartLooped; + private delegate void EnemyNoteHitHandler(BattleDirector BD); + private event EnemyNoteHitHandler EnemyNoteHit; + private void AddEvent(IBattleEvent bEvent) { switch (bEvent.GetTrigger()) //TODO: Look into a way to get eventhandler from string @@ -262,6 +269,9 @@ private void AddEvent(IBattleEvent bEvent) case BattleEffectTrigger.OnLoop: ChartLooped += bEvent.OnTrigger; break; + case BattleEffectTrigger.EnemyNoteHit: + EnemyNoteHit += bEvent.OnTrigger; + break; } } From 5fbe08d53b215e4cff3e12e62024ba2beac712b6 Mon Sep 17 00:00:00 2001 From: cornerloan Date: Wed, 26 Mar 2025 15:09:51 -0700 Subject: [PATCH 02/36] Added block mechanic New note type: shield, gives the player one charge of block - Block now appears above the health bar when any puppet has charge(s). - Block fully negates one source of damage and removes a charge. New relic: Chips, deals one point of damage whenever the player hits any note (should be balanced later) --- Classes/Notes/Assets/Note_PlayerBlock.png | Bin 0 -> 4344 bytes .../Notes/Assets/Note_PlayerBlock.png.import | 34 ++++++++++++++++++ Classes/Relics/Assets/Relic_Chips.png | Bin 1000 -> 2246 bytes Classes/Relics/Assets/Relic_Chips.png.import | 2 +- Globals/Scribe.cs | 14 ++++++++ Globals/Translations/translations.csv | 2 ++ SharedAssets/Shield.png | Bin 0 -> 677 bytes SharedAssets/Shield.png.import | 34 ++++++++++++++++++ scenes/Puppets/Enemies/BossBlood/Boss1.tscn | 19 ++++++++-- scenes/Puppets/Enemies/EnemyPuppet.tscn | 15 +++++++- .../Puppets/Enemies/Parasifly/Parasifly.tscn | 19 ++++++++-- scenes/Puppets/Enemies/TheGWS/GWS.tscn | 19 ++++++++-- scenes/Puppets/PlayerPuppet.tscn | 19 ++++++++-- scenes/Puppets/scripts/PuppetTemplate.cs | 34 ++++++++++++++++++ 14 files changed, 201 insertions(+), 10 deletions(-) create mode 100644 Classes/Notes/Assets/Note_PlayerBlock.png create mode 100644 Classes/Notes/Assets/Note_PlayerBlock.png.import create mode 100644 SharedAssets/Shield.png create mode 100644 SharedAssets/Shield.png.import diff --git a/Classes/Notes/Assets/Note_PlayerBlock.png b/Classes/Notes/Assets/Note_PlayerBlock.png new file mode 100644 index 0000000000000000000000000000000000000000..4e2cf3b960086b579f9c19d3aee4c714fc8fa96c GIT binary patch literal 4344 zcmeHKeNYo;8V{!uOe?na+iKk|?Ny+gY?56_wh0Upl$-_wWH4Gi+3da>R-xwsZx>FJ4dc3-oVv+H{tWHGdIj! z|09`Xcc1rpe(&@Ao{xEVyFF*wG}U~SLZO&u&9>yhD z_yazU_W(pH^8*Bgc}}4SU)z-{?7o1+4ctq75Er*Cu%Q3`o_CvG`u1Rf=gdLR@18>+ z-*)T3gTB7x%7qtq?cIOv(jVjAJl?u6qn7@-N8i)4^48*KH+A+T;YgD@;UBB7Zcb>e zsaU(m{b&KP_4z2)3C3>L*iJhuUSoqKRzqs^rrAc_XhyUx3 zllIj+kE~VTcGD6*`Se$Xy_eIAE>|BpYfv4Z zqTDq5xAE%MbJSVYmd@$h&UYTUgFfH!tC?$B9(MMowN`ZdZ&X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-gjZOzaxBM}6mI!9jSelU literal 0 HcmV?d00001 diff --git a/Classes/Notes/Assets/Note_PlayerBlock.png.import b/Classes/Notes/Assets/Note_PlayerBlock.png.import new file mode 100644 index 00000000..74152ff5 --- /dev/null +++ b/Classes/Notes/Assets/Note_PlayerBlock.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://dhfeoc3nd6t4a" +path="res://.godot/imported/Note_PlayerBlock.png-9b2b822fe3c56ce932bb38c394998018.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://Classes/Notes/Assets/Note_PlayerBlock.png" +dest_files=["res://.godot/imported/Note_PlayerBlock.png-9b2b822fe3c56ce932bb38c394998018.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/Classes/Relics/Assets/Relic_Chips.png b/Classes/Relics/Assets/Relic_Chips.png index 74bdf235ca1f614e2d568afa7a199d39995296a9..60e766e07fc43ef8eb5ebcaea45a721aa5748472 100644 GIT binary patch delta 2235 zcmV;s2t@bj2gVVQBYyw{XF*Lt006O%3;baP0004lX+uL$Nkc;*aB^>EX>4Tx04R}t zkv&MmKpe$iQ>7vm2RmpH%ut=|q9Tr^ibb$c+6t{Ym|Xe=O&XFE7e~Rh;NZt%)xpJC zR|i)?5c~jf7n~Gbq{ROvg%&X$9QWhhy~o`mEM7-bHzq_qjjEfKo6S;1h{sOgAjz4dU5NOXs{#9AafjAwDOb zH0XlFk6f2se&bwnSm2or`)7q9O!+q?T>LFunV*rw*7r<+pQD8{|sDd9e=F}%zcvH=xC86U~n6_xbA53 z9&ot>3_t0TAvuztrcf*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c&QDjR>oR_Zs0W1W7*sK|1c+xJ_D61crWVxhQSH!#fn^Up9qMMXtL#lJ#fZC7c! z|4-Mg?F^KrjiO$^PH7tCK}atN+%Z{pccd`q-hU7{VZ48}YXL=)%u||R2&WLo?=cu0 zl`-c5j1&-gKfW6WxO4iDB%c^XV`gpbOX&)LrzD$@a+1@=`%YnP*Yx|xxv}xFu(k_w z6MzHonbHMjStnRK58xcg7{F@e{n=p$>h(!TZ_Aqh#E?(WXv`wdFA10h&>5OYdH~=u z$bZuUZgXmC2ILu%N6h;AyP=xD8~{Fm91qRr-jR0odXLQV@>fLBGXVQabNcs;ZqAe*Axx!f0$KvvN|FNrUKn!WcaBQNEb7NPpPLXa z%DKZqS^+Sj?d>g+H`r>0zvfq%>cv)6R8;);d("res://Classes/Notes/Assets/Note_PlayerBlock.png"), + null, + 1, + (director, note, timing) => + { + if (timing == Timing.Miss) + return; + director.Player.GainShield(note.GetBaseVal()); //todo: should scale with timing???? + } + ), }; public static readonly RelicTemplate[] RelicDictionary = new[] diff --git a/Globals/Translations/translations.csv b/Globals/Translations/translations.csv index cbdfe8bf..5a454f00 100644 --- a/Globals/Translations/translations.csv +++ b/Globals/Translations/translations.csv @@ -42,6 +42,8 @@ NOTE_PLAYERVAMPIRE_NAME,PlayerVampire,玩家吸血 NOTE_PLAYERVAMPIRE_TOOLTIP,"Steals health from enemy.","从敌人吸取生命值" NOTE_PLAYERQUARTER_NAME,PlayerQuarter,玩家一分之一 NOTE_PLAYERQUARTER_TOOLTIP,"Basic note at a quarter of the cost.","以四分之一的耗费时间量发出基础音符" +NOTE_PLAYERBLOCK_NAME,PlayerBlock,玩家格挡 +NOTE_PLAYERBLOCK_TOOLTIP,"Gives player one charge of block.","给予玩家一层格挡充能。" RELIC_BREAKFAST_NAME,Breakfast,早餐 RELIC_BREAKFAST_TOOLTIP,"Increases max hp.",提高最大生命值 RELIC_GOODVIBES_NAME,Good Vibes,良好消息 diff --git a/SharedAssets/Shield.png b/SharedAssets/Shield.png new file mode 100644 index 0000000000000000000000000000000000000000..ef7ebdcf23db74d012bb61fc66bc4d3e1ccc2e65 GIT binary patch literal 677 zcmV;W0$TlvP)EX>4Tx04R}tkv&MmKpe$iQ>7vm2Qx@<$WWauf)#NrRV;#q(pG5I!Q|2}Xws6T zxHt-~1qVMCs}3&Cx;nTDg5U>;yWphgA|?JWDYS_3;J6>}?mh0_0Ya^gBSkPB8T&FpP1eTCQ3KA4FP(c+IBDCtHm`Kxp+`}Jo{3&uNr-RIxLCBl=lDt02y>eSad^gZEa<4bO1wgWnpw> zWFU8GbZ8()Nlj2!fese{004bSL_t(o!|m0v5r7~NMA3zIti}qgjS8&BdNgww297)A zG;lYA46juSBAbN2%U<9Fwn*bJsHf{!J5SI85KtfpK90vdwNQW#UD2t+&00000 LNkvXXu0mjfbk`YV literal 0 HcmV?d00001 diff --git a/SharedAssets/Shield.png.import b/SharedAssets/Shield.png.import new file mode 100644 index 00000000..642ab775 --- /dev/null +++ b/SharedAssets/Shield.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://bsg8b14xbddb6" +path="res://.godot/imported/Shield.png-c486d1322077e89abfccb7e98914abdd.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://SharedAssets/Shield.png" +dest_files=["res://.godot/imported/Shield.png-c486d1322077e89abfccb7e98914abdd.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/scenes/Puppets/Enemies/BossBlood/Boss1.tscn b/scenes/Puppets/Enemies/BossBlood/Boss1.tscn index f7add1a0..cadd91f1 100644 --- a/scenes/Puppets/Enemies/BossBlood/Boss1.tscn +++ b/scenes/Puppets/Enemies/BossBlood/Boss1.tscn @@ -1,9 +1,10 @@ -[gd_scene load_steps=8 format=3 uid="uid://bi5iqbwpsd381"] +[gd_scene load_steps=9 format=3 uid="uid://bi5iqbwpsd381"] [ext_resource type="Script" path="res://Scenes/Puppets/Enemies/BossBlood/P_BossBlood.cs" id="1_qj2oj"] [ext_resource type="Texture2D" uid="uid://veedngaorx3l" path="res://Scenes/Puppets/Enemies/BossBlood/Assets/Boss1.png" id="2_mul30"] [ext_resource type="Texture2D" uid="uid://b2iptr3o8rg4t" path="res://Scenes/Puppets/Enemies/BossBlood/Assets/Boss1EmissionShape.tres" id="3_yxnso"] [ext_resource type="PackedScene" uid="uid://bgomxovxs7sr8" path="res://Scenes/Puppets/HealthBar.tscn" id="4_ffkxf"] +[ext_resource type="Texture2D" uid="uid://bsg8b14xbddb6" path="res://SharedAssets/Shield.png" id="5_pa2dv"] [sub_resource type="ParticleProcessMaterial" id="ParticleProcessMaterial_3jiu6"] emission_shape = 4 @@ -22,12 +23,14 @@ colors = PackedColorArray(0.641048, 0.0406094, 0.0473231, 1) gradient = SubResource("Gradient_s7p55") width = 1 -[node name="EnemPuppet" type="Node2D" node_paths=PackedStringArray("_healthBar", "Sprite")] +[node name="EnemPuppet" type="Node2D" node_paths=PackedStringArray("_healthBar", "Sprite", "_shieldLogo", "_shieldText")] script = ExtResource("1_qj2oj") _healthBar = NodePath("ProgressBar") Sprite = NodePath("Sprite") StartPos = Vector2(500, 125) InitScale = Vector2(2, 2) +_shieldLogo = NodePath("Shield") +_shieldText = NodePath("Shield/ShieldText") [node name="Sprite" type="Sprite2D" parent="."] position = Vector2(0, -32) @@ -47,3 +50,15 @@ offset_left = -75.0 offset_top = 32.0 offset_right = 75.0 offset_bottom = 52.0 + +[node name="Shield" type="Sprite2D" parent="."] +position = Vector2(56, 20) +texture = ExtResource("5_pa2dv") + +[node name="ShieldText" type="Label" parent="Shield"] +offset_left = -13.0 +offset_top = -10.0 +offset_right = 13.0 +offset_bottom = 13.0 +text = "XX" +horizontal_alignment = 1 diff --git a/scenes/Puppets/Enemies/EnemyPuppet.tscn b/scenes/Puppets/Enemies/EnemyPuppet.tscn index 1c2672fe..eb525ada 100644 --- a/scenes/Puppets/Enemies/EnemyPuppet.tscn +++ b/scenes/Puppets/Enemies/EnemyPuppet.tscn @@ -1,7 +1,8 @@ -[gd_scene load_steps=3 format=3 uid="uid://cwm0n2wu851nx"] +[gd_scene load_steps=4 format=3 uid="uid://cwm0n2wu851nx"] [ext_resource type="Script" path="res://Scenes/Puppets/Scripts/PuppetTemplate.cs" id="1_kgmh0"] [ext_resource type="PackedScene" uid="uid://bgomxovxs7sr8" path="res://Scenes/Puppets/HealthBar.tscn" id="1_sxlrs"] +[ext_resource type="Texture2D" uid="uid://bsg8b14xbddb6" path="res://SharedAssets/Shield.png" id="2_xx60o"] [node name="EnemPuppet" type="Node2D" node_paths=PackedStringArray("_healthBar", "Sprite")] script = ExtResource("1_kgmh0") @@ -10,6 +11,18 @@ Sprite = NodePath("Sprite") [node name="Sprite" type="Sprite2D" parent="."] +[node name="Shield" type="Sprite2D" parent="Sprite"] +position = Vector2(56, 20) +texture = ExtResource("2_xx60o") + +[node name="ShieldText" type="Label" parent="Sprite/Shield"] +offset_left = -13.0 +offset_top = -10.0 +offset_right = 13.0 +offset_bottom = 13.0 +text = "XX" +horizontal_alignment = 1 + [node name="ProgressBar" parent="." instance=ExtResource("1_sxlrs")] offset_left = -75.0 offset_top = 32.0 diff --git a/scenes/Puppets/Enemies/Parasifly/Parasifly.tscn b/scenes/Puppets/Enemies/Parasifly/Parasifly.tscn index f708d2cc..742e60dd 100644 --- a/scenes/Puppets/Enemies/Parasifly/Parasifly.tscn +++ b/scenes/Puppets/Enemies/Parasifly/Parasifly.tscn @@ -1,14 +1,17 @@ -[gd_scene load_steps=4 format=3 uid="uid://uvlux4t6h5de"] +[gd_scene load_steps=5 format=3 uid="uid://uvlux4t6h5de"] [ext_resource type="Script" path="res://Scenes/Puppets/Enemies/Parasifly/P_Parasifly.cs" id="1_ci2ca"] [ext_resource type="Texture2D" uid="uid://pngu3pw1pu4o" path="res://Scenes/Puppets/Enemies/Parasifly/Assets/Parasifly.png" id="2_g4o48"] [ext_resource type="PackedScene" uid="uid://bgomxovxs7sr8" path="res://Scenes/Puppets/HealthBar.tscn" id="3_f74ri"] +[ext_resource type="Texture2D" uid="uid://bsg8b14xbddb6" path="res://SharedAssets/Shield.png" id="4_eemg7"] -[node name="EnemPuppet" type="Node2D" node_paths=PackedStringArray("_healthBar", "Sprite")] +[node name="EnemPuppet" type="Node2D" node_paths=PackedStringArray("_healthBar", "Sprite", "_shieldLogo", "_shieldText")] script = ExtResource("1_ci2ca") _healthBar = NodePath("ProgressBar") Sprite = NodePath("Sprite") StartPos = Vector2(500, 125) +_shieldLogo = NodePath("Shield") +_shieldText = NodePath("Shield/ShieldText") [node name="Sprite" type="Sprite2D" parent="."] position = Vector2(0, -12) @@ -19,3 +22,15 @@ offset_left = -75.0 offset_top = 32.0 offset_right = 75.0 offset_bottom = 52.0 + +[node name="Shield" type="Sprite2D" parent="."] +position = Vector2(56, 20) +texture = ExtResource("4_eemg7") + +[node name="ShieldText" type="Label" parent="Shield"] +offset_left = -13.0 +offset_top = -10.0 +offset_right = 13.0 +offset_bottom = 13.0 +text = "XX" +horizontal_alignment = 1 diff --git a/scenes/Puppets/Enemies/TheGWS/GWS.tscn b/scenes/Puppets/Enemies/TheGWS/GWS.tscn index 58c3fb82..951b9b8d 100644 --- a/scenes/Puppets/Enemies/TheGWS/GWS.tscn +++ b/scenes/Puppets/Enemies/TheGWS/GWS.tscn @@ -1,14 +1,17 @@ -[gd_scene load_steps=4 format=3 uid="uid://d1puw6fvmkrb5"] +[gd_scene load_steps=5 format=3 uid="uid://d1puw6fvmkrb5"] [ext_resource type="Script" path="res://Scenes/Puppets/Enemies/TheGWS/P_TheGWS.cs" id="1_dlike"] [ext_resource type="Texture2D" uid="uid://ci0a2h2eatjht" path="res://Scenes/Puppets/Enemies/TheGWS/Assets/GhostWolfSnake.png" id="2_77v4w"] [ext_resource type="PackedScene" uid="uid://bgomxovxs7sr8" path="res://Scenes/Puppets/HealthBar.tscn" id="3_mr0it"] +[ext_resource type="Texture2D" uid="uid://bsg8b14xbddb6" path="res://SharedAssets/Shield.png" id="4_udalx"] -[node name="EnemPuppet" type="Node2D" node_paths=PackedStringArray("_healthBar", "Sprite")] +[node name="EnemPuppet" type="Node2D" node_paths=PackedStringArray("_healthBar", "Sprite", "_shieldLogo", "_shieldText")] script = ExtResource("1_dlike") _healthBar = NodePath("ProgressBar") Sprite = NodePath("Sprite") StartPos = Vector2(500, 125) +_shieldLogo = NodePath("Shield") +_shieldText = NodePath("Shield/ShieldText") [node name="Sprite" type="Sprite2D" parent="."] position = Vector2(0, -54) @@ -19,3 +22,15 @@ offset_left = -75.0 offset_top = 32.0 offset_right = 75.0 offset_bottom = 52.0 + +[node name="Shield" type="Sprite2D" parent="."] +position = Vector2(56, 20) +texture = ExtResource("4_udalx") + +[node name="ShieldText" type="Label" parent="Shield"] +offset_left = -13.0 +offset_top = -10.0 +offset_right = 13.0 +offset_bottom = 13.0 +text = "XX" +horizontal_alignment = 1 diff --git a/scenes/Puppets/PlayerPuppet.tscn b/scenes/Puppets/PlayerPuppet.tscn index 58e037d1..090dd233 100644 --- a/scenes/Puppets/PlayerPuppet.tscn +++ b/scenes/Puppets/PlayerPuppet.tscn @@ -1,14 +1,17 @@ -[gd_scene load_steps=4 format=3 uid="uid://eus17omen6yk"] +[gd_scene load_steps=5 format=3 uid="uid://eus17omen6yk"] [ext_resource type="Script" path="res://Scenes/Puppets/Scripts/PlayerPuppet.cs" id="1_f4rea"] [ext_resource type="Texture2D" uid="uid://b6fkei0i83vte" path="res://SharedAssets/Character1.png" id="2_affso"] [ext_resource type="PackedScene" uid="uid://bgomxovxs7sr8" path="res://Scenes/Puppets/HealthBar.tscn" id="3_rechw"] +[ext_resource type="Texture2D" uid="uid://bsg8b14xbddb6" path="res://SharedAssets/Shield.png" id="4_5uc4u"] -[node name="PlayerPuppet" type="Node2D" node_paths=PackedStringArray("_healthBar", "Sprite")] +[node name="PlayerPuppet" type="Node2D" node_paths=PackedStringArray("_healthBar", "Sprite", "_shieldLogo", "_shieldText")] script = ExtResource("1_f4rea") _healthBar = NodePath("ProgressBar") Sprite = NodePath("Sprite") StartPos = Vector2(158, 125) +_shieldLogo = NodePath("Shield") +_shieldText = NodePath("Shield/ShieldText") [node name="Sprite" type="Sprite2D" parent="."] texture = ExtResource("2_affso") @@ -18,3 +21,15 @@ offset_left = -75.0 offset_top = 32.0 offset_right = 75.0 offset_bottom = 52.0 + +[node name="Shield" type="Sprite2D" parent="."] +position = Vector2(56, 20) +texture = ExtResource("4_5uc4u") + +[node name="ShieldText" type="Label" parent="Shield"] +offset_left = -13.0 +offset_top = -10.0 +offset_right = 13.0 +offset_bottom = 13.0 +text = "XX" +horizontal_alignment = 1 diff --git a/scenes/Puppets/scripts/PuppetTemplate.cs b/scenes/Puppets/scripts/PuppetTemplate.cs index accc9ec4..0737b8ef 100644 --- a/scenes/Puppets/scripts/PuppetTemplate.cs +++ b/scenes/Puppets/scripts/PuppetTemplate.cs @@ -29,6 +29,13 @@ public partial class PuppetTemplate : Node2D protected int _currentHealth = 100; //Stats would go here. + protected int _numShield = 0; //todo: shield mechanic to block / dodge damage + + [Export] + public Sprite2D _shieldLogo; + + [Export] + public Label _shieldText; protected string UniqName = ""; //Eventually make subclasses/scenes/real stuff @@ -39,6 +46,9 @@ public override void _Ready() Sprite.Scale = InitScale; _healthBar.Visible = !hideHealth; + + if (_numShield == 0) + _shieldLogo.Visible = false; } public override void _Process(double delta) @@ -111,6 +121,22 @@ protected virtual void DamageAnimate(int amount) public virtual void TakeDamage(int amount) { + GD.Print($"Taking Damage: {amount}, with shield count: {_numShield}"); + if (_numShield > 0 && amount > 0) + { + _numShield--; + _shieldText.Text = $"{_numShield}"; + if (_numShield == 0) + _shieldLogo.Visible = false; + + TextParticle blockText = new TextParticle(); + blockText.Modulate = Colors.White; //white text for blocked damage + Sprite.AddChild(blockText); + blockText.Text = "-0"; //blocked damage is 0 + + return; + } + amount = Math.Max(0, amount); //Should not be able to heal from damage. if (_currentHealth <= 0 || amount == 0) return; //Only check if hp would change @@ -120,6 +146,7 @@ public virtual void TakeDamage(int amount) { Defeated?.Invoke(this); } + TextParticle newText = new TextParticle(); newText.Modulate = Colors.Red; Sprite.AddChild(newText); @@ -143,4 +170,11 @@ public int GetCurrentHealth() { return _currentHealth; } + + public virtual void GainShield(int amount) + { + _shieldLogo.Visible = true; + _numShield += amount; + _shieldText.Text = $"{_numShield}"; + } } From cbbe0fa610e3dc89e0d6ab78d68e7ac1aaeb91b7 Mon Sep 17 00:00:00 2001 From: cornerloan Date: Tue, 1 Apr 2025 14:53:51 -0700 Subject: [PATCH 03/36] Fixing errors from merge --- Scenes/BattleDirector/BattleScene.tscn | 4 ++-- scenes/Puppets/Enemies/BossBlood/Boss1.tscn | 6 +++--- scenes/Puppets/Enemies/EnemyPuppet.tscn | 6 ++++-- scenes/Puppets/Enemies/Parasifly/Parasifly.tscn | 6 +++--- scenes/Puppets/Enemies/TheGWS/GWS.tscn | 6 +++--- scenes/Puppets/PlayerPuppet.tscn | 6 +++--- scenes/Puppets/scripts/PuppetTemplate.cs | 16 ++++++++-------- 7 files changed, 26 insertions(+), 24 deletions(-) diff --git a/Scenes/BattleDirector/BattleScene.tscn b/Scenes/BattleDirector/BattleScene.tscn index 3d5d96d2..6af6318e 100644 --- a/Scenes/BattleDirector/BattleScene.tscn +++ b/Scenes/BattleDirector/BattleScene.tscn @@ -17,12 +17,12 @@ gradient = SubResource("Gradient_8uy3a") fill_from = Vector2(1, 0) fill_to = Vector2(0.738532, 1) -[node name="ProtoBattleDirector" type="Node2D" node_paths=PackedStringArray("CM", "NPB", "CD", "Audio", "_focusedButton")] +[node name="ProtoBattleDirector" type="Node2D" node_paths=PackedStringArray("CD", "CM", "NPB", "Audio", "_focusedButton")] process_mode = 1 script = ExtResource("1_jmdo1") +CD = NodePath("Conductor") CM = NodePath("SubViewport") NPB = NodePath("NotePlacementBar") -CD = NodePath("Conductor") Audio = NodePath("AudioStreamPlayer") _focusedButton = NodePath("StartButton") metadata/_edit_lock_ = true diff --git a/scenes/Puppets/Enemies/BossBlood/Boss1.tscn b/scenes/Puppets/Enemies/BossBlood/Boss1.tscn index 3ce17df7..e28e70a4 100644 --- a/scenes/Puppets/Enemies/BossBlood/Boss1.tscn +++ b/scenes/Puppets/Enemies/BossBlood/Boss1.tscn @@ -23,14 +23,14 @@ colors = PackedColorArray(0.641048, 0.0406094, 0.0473231, 1) gradient = SubResource("Gradient_s7p55") width = 1 -[node name="EnemPuppet" type="Node2D" node_paths=PackedStringArray("_healthBar", "Sprite", "_shieldLogo", "_shieldText")] +[node name="EnemPuppet" type="Node2D" node_paths=PackedStringArray("HealthBar", "Sprite", "ShieldLogo", "ShieldText")] script = ExtResource("1_qj2oj") HealthBar = NodePath("ProgressBar") Sprite = NodePath("Sprite") StartPos = Vector2(500, 125) InitScale = Vector2(2, 2) -_shieldLogo = NodePath("Shield") -_shieldText = NodePath("Shield/ShieldText") +ShieldLogo = NodePath("Shield") +ShieldText = NodePath("Shield/ShieldText") [node name="Sprite" type="Sprite2D" parent="."] position = Vector2(0, -32) diff --git a/scenes/Puppets/Enemies/EnemyPuppet.tscn b/scenes/Puppets/Enemies/EnemyPuppet.tscn index eb525ada..627a8d54 100644 --- a/scenes/Puppets/Enemies/EnemyPuppet.tscn +++ b/scenes/Puppets/Enemies/EnemyPuppet.tscn @@ -4,10 +4,12 @@ [ext_resource type="PackedScene" uid="uid://bgomxovxs7sr8" path="res://Scenes/Puppets/HealthBar.tscn" id="1_sxlrs"] [ext_resource type="Texture2D" uid="uid://bsg8b14xbddb6" path="res://SharedAssets/Shield.png" id="2_xx60o"] -[node name="EnemPuppet" type="Node2D" node_paths=PackedStringArray("_healthBar", "Sprite")] +[node name="EnemPuppet" type="Node2D" node_paths=PackedStringArray("HealthBar", "Sprite", "ShieldLogo", "ShieldText")] script = ExtResource("1_kgmh0") -_healthBar = NodePath("ProgressBar") +HealthBar = NodePath("ProgressBar") Sprite = NodePath("Sprite") +ShieldLogo = NodePath("Sprite/Shield") +ShieldText = NodePath("Sprite/Shield/ShieldText") [node name="Sprite" type="Sprite2D" parent="."] diff --git a/scenes/Puppets/Enemies/Parasifly/Parasifly.tscn b/scenes/Puppets/Enemies/Parasifly/Parasifly.tscn index 9027c630..8911c62a 100644 --- a/scenes/Puppets/Enemies/Parasifly/Parasifly.tscn +++ b/scenes/Puppets/Enemies/Parasifly/Parasifly.tscn @@ -5,13 +5,13 @@ [ext_resource type="PackedScene" uid="uid://bgomxovxs7sr8" path="res://Scenes/Puppets/HealthBar.tscn" id="3_f74ri"] [ext_resource type="Texture2D" uid="uid://bsg8b14xbddb6" path="res://SharedAssets/Shield.png" id="4_eemg7"] -[node name="EnemPuppet" type="Node2D" node_paths=PackedStringArray("_healthBar", "Sprite", "_shieldLogo", "_shieldText")] +[node name="EnemPuppet" type="Node2D" node_paths=PackedStringArray("HealthBar", "Sprite", "ShieldLogo", "ShieldText")] script = ExtResource("1_ci2ca") HealthBar = NodePath("ProgressBar") Sprite = NodePath("Sprite") StartPos = Vector2(500, 125) -_shieldLogo = NodePath("Shield") -_shieldText = NodePath("Shield/ShieldText") +ShieldLogo = NodePath("Shield") +ShieldText = NodePath("Shield/ShieldText") [node name="Sprite" type="Sprite2D" parent="."] position = Vector2(0, -12) diff --git a/scenes/Puppets/Enemies/TheGWS/GWS.tscn b/scenes/Puppets/Enemies/TheGWS/GWS.tscn index b0eca09f..7981bef7 100644 --- a/scenes/Puppets/Enemies/TheGWS/GWS.tscn +++ b/scenes/Puppets/Enemies/TheGWS/GWS.tscn @@ -5,13 +5,13 @@ [ext_resource type="PackedScene" uid="uid://bgomxovxs7sr8" path="res://Scenes/Puppets/HealthBar.tscn" id="3_mr0it"] [ext_resource type="Texture2D" uid="uid://bsg8b14xbddb6" path="res://SharedAssets/Shield.png" id="4_udalx"] -[node name="EnemPuppet" type="Node2D" node_paths=PackedStringArray("_healthBar", "Sprite", "_shieldLogo", "_shieldText")] +[node name="EnemPuppet" type="Node2D" node_paths=PackedStringArray("HealthBar", "Sprite", "ShieldLogo", "ShieldText")] script = ExtResource("1_dlike") HealthBar = NodePath("ProgressBar") Sprite = NodePath("Sprite") StartPos = Vector2(500, 125) -_shieldLogo = NodePath("Shield") -_shieldText = NodePath("Shield/ShieldText") +ShieldLogo = NodePath("Shield") +ShieldText = NodePath("Shield/ShieldText") [node name="Sprite" type="Sprite2D" parent="."] position = Vector2(0, -54) diff --git a/scenes/Puppets/PlayerPuppet.tscn b/scenes/Puppets/PlayerPuppet.tscn index 4c933ca8..194a3c3b 100644 --- a/scenes/Puppets/PlayerPuppet.tscn +++ b/scenes/Puppets/PlayerPuppet.tscn @@ -5,13 +5,13 @@ [ext_resource type="PackedScene" uid="uid://bgomxovxs7sr8" path="res://Scenes/Puppets/HealthBar.tscn" id="3_rechw"] [ext_resource type="Texture2D" uid="uid://bsg8b14xbddb6" path="res://SharedAssets/Shield.png" id="4_5uc4u"] -[node name="PlayerPuppet" type="Node2D" node_paths=PackedStringArray("_healthBar", "Sprite", "_shieldLogo", "_shieldText")] +[node name="PlayerPuppet" type="Node2D" node_paths=PackedStringArray("HealthBar", "Sprite", "ShieldLogo", "ShieldText")] script = ExtResource("1_f4rea") HealthBar = NodePath("ProgressBar") Sprite = NodePath("Sprite") StartPos = Vector2(158, 125) -_shieldLogo = NodePath("Shield") -_shieldText = NodePath("Shield/ShieldText") +ShieldLogo = NodePath("Shield") +ShieldText = NodePath("Shield/ShieldText") [node name="Sprite" type="Sprite2D" parent="."] texture = ExtResource("2_affso") diff --git a/scenes/Puppets/scripts/PuppetTemplate.cs b/scenes/Puppets/scripts/PuppetTemplate.cs index bc297927..4837cbdb 100644 --- a/scenes/Puppets/scripts/PuppetTemplate.cs +++ b/scenes/Puppets/scripts/PuppetTemplate.cs @@ -32,10 +32,10 @@ public partial class PuppetTemplate : Node2D protected int _numShield = 0; //todo: shield mechanic to block / dodge damage [Export] - public Sprite2D _shieldLogo; + public Sprite2D ShieldLogo; [Export] - public Label _shieldText; + public Label ShieldText; protected string UniqName = ""; //Eventually make subclasses/scenes/real stuff @@ -45,10 +45,10 @@ public override void _Ready() Position = StartPos; Sprite.Scale = InitScale; - _healthBar.Visible = !hideHealth; + HealthBar.Visible = !HideHealth; if (_numShield == 0) - _shieldLogo.Visible = false; + ShieldLogo.Visible = false; } public override void _Process(double delta) @@ -125,9 +125,9 @@ public virtual void TakeDamage(int amount) if (_numShield > 0 && amount > 0) { _numShield--; - _shieldText.Text = $"{_numShield}"; + ShieldText.Text = $"{_numShield}"; if (_numShield == 0) - _shieldLogo.Visible = false; + ShieldLogo.Visible = false; TextParticle blockText = new TextParticle(); blockText.Modulate = Colors.White; //white text for blocked damage @@ -173,8 +173,8 @@ public int GetCurrentHealth() public virtual void GainShield(int amount) { - _shieldLogo.Visible = true; + ShieldLogo.Visible = true; _numShield += amount; - _shieldText.Text = $"{_numShield}"; + ShieldText.Text = $"{_numShield}"; } } From dbe44ae46f9e116de3a06a8a169c308a35d759cd Mon Sep 17 00:00:00 2001 From: LifeHckr Date: Sat, 5 Apr 2025 15:27:34 -0700 Subject: [PATCH 04/36] Implemented Harbinger event system Singleton instance with new eventargs classes to better pass information where accessible for battle events --- Classes/Relics/RelicEffect.cs | 10 ++- Globals/FunkEngineNameSpace.cs | 8 +- Globals/Scribe.cs | 14 ++-- .../BattleDirector/Scripts/BattleDirector.cs | 73 +++++++++++++++++-- .../Puppets/Enemies/BossBlood/P_BossBlood.cs | 2 +- Scenes/Puppets/Enemies/EnemyEffect.cs | 8 +- 6 files changed, 91 insertions(+), 24 deletions(-) diff --git a/Classes/Relics/RelicEffect.cs b/Classes/Relics/RelicEffect.cs index bb2cedf3..f71bf462 100644 --- a/Classes/Relics/RelicEffect.cs +++ b/Classes/Relics/RelicEffect.cs @@ -10,19 +10,21 @@ public partial class RelicEffect : IBattleEvent private BattleEffectTrigger Trigger { get; set; } private int _baseValue; public int Value; - private Action _onRelicEffect; + private Action _onRelicEffect; private bool _effectPersists = false; public RelicEffect( BattleEffectTrigger trigger, int val, - Action onRelicEffect + Action onRelicEffect, + bool persists = false ) { _baseValue = val; Value = _baseValue; Trigger = trigger; _onRelicEffect = onRelicEffect; + _effectPersists = persists; } public void OnBattleEnd() @@ -31,9 +33,9 @@ public void OnBattleEnd() Value = _baseValue; } - public void OnTrigger(BattleDirector battleDirector) + public void OnTrigger(BattleEventArgs e) { - _onRelicEffect(battleDirector, this, Value); + _onRelicEffect(e, this, Value); } public BattleEffectTrigger GetTrigger() diff --git a/Globals/FunkEngineNameSpace.cs b/Globals/FunkEngineNameSpace.cs index 34c03684..9901b057 100644 --- a/Globals/FunkEngineNameSpace.cs +++ b/Globals/FunkEngineNameSpace.cs @@ -372,12 +372,18 @@ private void AddBossRoom(int width, int height) } #region Interfaces + +public class BattleEventArgs(BattleDirector director) : EventArgs +{ + public BattleDirector BD = director; +} + /** * A BattleDirector driven battle event. Needs an enum defined trigger. */ public interface IBattleEvent { - void OnTrigger(BattleDirector BD); + void OnTrigger(BattleEventArgs e); BattleEffectTrigger GetTrigger(); } diff --git a/Globals/Scribe.cs b/Globals/Scribe.cs index 526a60a0..b148aab8 100644 --- a/Globals/Scribe.cs +++ b/Globals/Scribe.cs @@ -108,7 +108,7 @@ public partial class Scribe : Node new RelicEffect( BattleEffectTrigger.OnPickup, 10, - (director, self, val) => + (e, self, val) => { StageProducer.PlayerStats.MaxHealth += val; StageProducer.PlayerStats.CurrentHealth += val; @@ -126,9 +126,9 @@ public partial class Scribe : Node new RelicEffect( BattleEffectTrigger.NotePlaced, 2, - (director, self, val) => + (e, self, val) => { - director.Player.Heal(val); + e.BD.Player.Heal(val); } ), } @@ -143,9 +143,9 @@ public partial class Scribe : Node new RelicEffect( BattleEffectTrigger.OnLoop, 1, - (director, self, val) => + (e, self, val) => { - director.NPB.IncreaseBonusMult(val); + e.BD.NPB.IncreaseBonusMult(val); self.Value++; } ), @@ -161,9 +161,9 @@ public partial class Scribe : Node new RelicEffect( BattleEffectTrigger.OnLoop, 10, - (director, self, val) => + (e, self, val) => { - director.NPB.IncreaseCharge(val); + e.BD.NPB.IncreaseCharge(val); self.Value += 5; } ), diff --git a/Scenes/BattleDirector/Scripts/BattleDirector.cs b/Scenes/BattleDirector/Scripts/BattleDirector.cs index 329f7d13..b3b6b5f2 100644 --- a/Scenes/BattleDirector/Scripts/BattleDirector.cs +++ b/Scenes/BattleDirector/Scripts/BattleDirector.cs @@ -1,6 +1,7 @@ using System; using FunkEngine; using Godot; +using Melanchall.DryWetMidi.Interaction; /**BattleDirector: Higher priority director to manage battle effects. Can directly access managers, which should signal up to Director WIP */ @@ -42,8 +43,9 @@ private bool PlayerAddNote(ArrowType type, Beat beat) Note noteToPlace = NPB.NotePlaced(); noteToPlace.OnHit(this, Timing.Okay); + CD.AddPlayerNote(noteToPlace, type, beat); - NotePlaced?.Invoke(this); + Harbinger.Instance.InvokeNotePlaced(new ArrowData(type, beat, noteToPlace)); return true; } @@ -84,6 +86,7 @@ public override void _Ready() } TimeKeeper.InitVals(curSong.Bpm); + Harbinger.Init(this); InitPlayer(); InitEnemies(); CD.Initialize(curSong); @@ -128,7 +131,7 @@ private void UpdateBeat(Beat beat) } if (beat.Loop > TimeKeeper.LastBeat.Loop) { - ChartLooped?.Invoke(this); + Harbinger.Instance.InvokeChartLoop(beat.Loop); } TimeKeeper.LastBeat = beat; } @@ -243,21 +246,21 @@ private void TransitionOutOfBattle() #region BattleEffect Handling - private delegate void NotePlacedHandler(BattleDirector BD); + /*private delegate void NotePlacedHandler(BattleDirector BD); private event NotePlacedHandler NotePlaced; private delegate void ChartLoopHandler(BattleDirector BD); - private event ChartLoopHandler ChartLooped; + private event ChartLoopHandler ChartLooped;*/ private void AddEvent(IBattleEvent bEvent) { switch (bEvent.GetTrigger()) //TODO: Look into a way to get eventhandler from string { case BattleEffectTrigger.NotePlaced: - NotePlaced += bEvent.OnTrigger; + Harbinger.Instance.NotePlaced += bEvent.OnTrigger; break; case BattleEffectTrigger.OnLoop: - ChartLooped += bEvent.OnTrigger; + Harbinger.Instance.ChartLooped += bEvent.OnTrigger; break; } } @@ -293,8 +296,64 @@ private void CleanUpRelics() } #endregion + public partial class Harbinger : Resource + { + private static Harbinger _instance; + public static Harbinger Instance => _instance; + + private BattleDirector _curDirector; + + static Harbinger() { } + + private Harbinger(BattleDirector BD) + { + _curDirector = BD; + } + + internal static void Init(BattleDirector BD) + { + _instance = new Harbinger(BD); + } + + /// + /// Event Args to handle event types triggering from the action of a note, without timing. + /// + /// The BattleDirector calling the event. + /// The note data of the passing note. + public class NoteEventArgs(BattleDirector bd, ArrowData data) : BattleEventArgs(bd) + { + public ArrowData Data = data; + } + + /// + /// Event Args to handle event types triggering from the start of a new loop. + /// + /// The BattleDirector calling the event. + /// The loop starting. + public class LoopEventArgs(BattleDirector bd, int incomingLoop) : BattleEventArgs(bd) + { + public int Loop = incomingLoop; + } + + internal delegate void NotePlacedHandler(BattleEventArgs e); + internal event NotePlacedHandler NotePlaced; + + public void InvokeNotePlaced(ArrowData data) + { + NotePlaced?.Invoke(new NoteEventArgs(_curDirector, data)); + } + + internal delegate void ChartLoopHandler(BattleEventArgs e); + internal event ChartLoopHandler ChartLooped; + + public void InvokeChartLoop(int incLoop) + { + ChartLooped?.Invoke(new LoopEventArgs(_curDirector, incLoop)); + } + } + private void DebugKillEnemy() { - //Enemy.TakeDamage(1000); + Enemy.TakeDamage(1000); } } diff --git a/Scenes/Puppets/Enemies/BossBlood/P_BossBlood.cs b/Scenes/Puppets/Enemies/BossBlood/P_BossBlood.cs index 10f2ef92..b37a8ecb 100644 --- a/Scenes/Puppets/Enemies/BossBlood/P_BossBlood.cs +++ b/Scenes/Puppets/Enemies/BossBlood/P_BossBlood.cs @@ -25,7 +25,7 @@ public override void _Ready() this, BattleEffectTrigger.OnLoop, 5, - (director, eff, val) => + (e, eff, val) => { eff.Owner.Heal(val); } diff --git a/Scenes/Puppets/Enemies/EnemyEffect.cs b/Scenes/Puppets/Enemies/EnemyEffect.cs index 70e0171b..8fb1bc1d 100644 --- a/Scenes/Puppets/Enemies/EnemyEffect.cs +++ b/Scenes/Puppets/Enemies/EnemyEffect.cs @@ -7,13 +7,13 @@ public class EnemyEffect : IBattleEvent public EnemyPuppet Owner; private int _baseValue; public int Value; - private Action _onEnemyEffect; + private Action _onEnemyEffect; public EnemyEffect( EnemyPuppet owner, BattleEffectTrigger trigger, int val, - Action onEnemyEffect + Action onEnemyEffect ) { Owner = owner; @@ -23,9 +23,9 @@ Action onEnemyEffect _onEnemyEffect = onEnemyEffect; } - public void OnTrigger(BattleDirector battleDirector) + public void OnTrigger(BattleEventArgs e) { - _onEnemyEffect(battleDirector, this, Value); + _onEnemyEffect(e, this, Value); } public BattleEffectTrigger GetTrigger() From 21310f694d3841a0a6c139ab66edbb2e24e99cb1 Mon Sep 17 00:00:00 2001 From: LifeHckr Date: Sat, 5 Apr 2025 18:56:50 -0700 Subject: [PATCH 05/36] Make NPB fill with input color Could still use some tweaking and juice --- Scenes/BattleDirector/NotePlacementBar.tscn | 27 ++++++------- .../BattleDirector/Scripts/BattleDirector.cs | 4 +- .../Scripts/NotePlacementBar.cs | 38 +++++++++++++++++-- 3 files changed, 51 insertions(+), 18 deletions(-) diff --git a/Scenes/BattleDirector/NotePlacementBar.tscn b/Scenes/BattleDirector/NotePlacementBar.tscn index 34f29a29..8376f287 100644 --- a/Scenes/BattleDirector/NotePlacementBar.tscn +++ b/Scenes/BattleDirector/NotePlacementBar.tscn @@ -1,6 +1,6 @@ [gd_scene load_steps=12 format=3 uid="uid://duhiilcv4tat3"] -[ext_resource type="Script" path="res://Scenes/BattleDirector/Scripts/NotePlacementBar.cs" id="1_456es"] +[ext_resource type="Script" uid="uid://gj666xe815py" path="res://Scenes/BattleDirector/Scripts/NotePlacementBar.cs" id="1_456es"] [ext_resource type="Texture2D" uid="uid://cnyr5usjdv0ni" path="res://Scenes/BattleDirector/Assets/NoteQueue_Frame.png" id="2_3tw16"] [ext_resource type="Texture2D" uid="uid://c3chrsxrulapd" path="res://Classes/Notes/Assets/Note_PlayerBasic.png" id="3_6ylx6"] [ext_resource type="Texture2D" uid="uid://caw70lr5e1yiq" path="res://Classes/Notes/Assets/Note_PlayerDouble.png" id="4_6w8ha"] @@ -14,14 +14,23 @@ width = 34 height = 100 [sub_resource type="Gradient" id="Gradient_xvck1"] -offsets = PackedFloat32Array(0, 0.373239, 0.690141, 1) -colors = PackedColorArray(0, 1, 0, 1, 1, 0, 0.4, 1, 0, 1, 0.95, 1, 1, 0, 0, 1) +offsets = PackedFloat32Array(0) +colors = PackedColorArray(0, 0, 0, 1) [sub_resource type="GradientTexture2D" id="GradientTexture2D_0bqho"] gradient = SubResource("Gradient_xvck1") width = 32 height = 98 -fill_to = Vector2(0, 1) +fill_from = Vector2(0, 1) +fill_to = Vector2(0, 0) + +[sub_resource type="Gradient" id="Gradient_2uknl"] +offsets = PackedFloat32Array(0) +colors = PackedColorArray(0.46, 0.2162, 0.39905, 1) + +[sub_resource type="GradientTexture1D" id="GradientTexture1D_d62c7"] +gradient = SubResource("Gradient_2uknl") +width = 1 [sub_resource type="ParticleProcessMaterial" id="ParticleProcessMaterial_fy2uu"] lifetime_randomness = 0.32 @@ -41,14 +50,6 @@ turbulence_noise_scale = 5.0 turbulence_influence_min = 0.0 turbulence_influence_max = 0.018 -[sub_resource type="Gradient" id="Gradient_2uknl"] -offsets = PackedFloat32Array(0) -colors = PackedColorArray(0.46, 0.2162, 0.39905, 1) - -[sub_resource type="GradientTexture1D" id="GradientTexture1D_d62c7"] -gradient = SubResource("Gradient_2uknl") -width = 1 - [node name="NotePlacementBar" type="Control" node_paths=PackedStringArray("_notePlacementBar", "_particles", "_fullBarParticles", "_currentComboMultText", "_currentNote", "_nextNote")] layout_mode = 3 anchors_preset = 15 @@ -80,12 +81,12 @@ z_index = 1 position = Vector2(-1, -32) emitting = false amount = 22 -process_material = SubResource("ParticleProcessMaterial_fy2uu") texture = SubResource("GradientTexture1D_d62c7") lifetime = 2.0 preprocess = 0.1 explosiveness = 0.3 randomness = 0.05 +process_material = SubResource("ParticleProcessMaterial_fy2uu") [node name="FullBarParticles" type="CPUParticles2D" parent="PlacementBar"] position = Vector2(14, 98) diff --git a/Scenes/BattleDirector/Scripts/BattleDirector.cs b/Scenes/BattleDirector/Scripts/BattleDirector.cs index b3b6b5f2..60771af1 100644 --- a/Scenes/BattleDirector/Scripts/BattleDirector.cs +++ b/Scenes/BattleDirector/Scripts/BattleDirector.cs @@ -167,13 +167,13 @@ private void OnTimedInput(ArrowData data, double beatDif) Timing timed = CheckTiming(beatDif); data.NoteRef.OnHit(this, timed); - NPB.HandleTiming(timed); + NPB.HandleTiming(timed, data.Type); CM.ComboText(timed, data.Type, NPB.GetCurrentCombo()); } private void ForceMiss(ArrowType type) { - NPB.HandleTiming(Timing.Miss); + NPB.HandleTiming(Timing.Miss, type); CM.ComboText(Timing.Miss, type, NPB.GetCurrentCombo()); Player.TakeDamage(4); } diff --git a/Scenes/BattleDirector/Scripts/NotePlacementBar.cs b/Scenes/BattleDirector/Scripts/NotePlacementBar.cs index f9fdca1f..2650895b 100644 --- a/Scenes/BattleDirector/Scripts/NotePlacementBar.cs +++ b/Scenes/BattleDirector/Scripts/NotePlacementBar.cs @@ -28,6 +28,7 @@ private double CurrentBarValue [Export] private TextureProgressBar _notePlacementBar; + private Gradient _gradTex; [Export] private GpuParticles2D _particles; @@ -59,6 +60,10 @@ public override void _Ready() _notesToIncreaseCombo = 4; _barInitPosition = _notePlacementBar.Position; + + if (_notePlacementBar.TextureProgress is GradientTexture2D gradientTexture) + _gradTex = gradientTexture.Gradient; + GD.Print(_gradTex); } public override void _Process(double delta) @@ -151,6 +156,30 @@ private Note GetNote(bool getNextNote = false) } #endregion + #region Helpers + private Color[] _fillColors = [Colors.Green, Colors.Aqua, Colors.Pink, Colors.Red]; + + private void FillWithColor(ArrowType type, Color overrideCol = default) + { + // ReSharper disable once CompareOfFloatsByEqualityOperator + if (CurrentBarValue == MaxValue) + return; + Color color = overrideCol == default ? _fillColors[(int)type] : overrideCol; + + if (_gradTex.GetPointCount() == 1) + _gradTex.SetColor(0, color); + + float offset = (float)((CurrentBarValue) / MaxValue); + _gradTex.AddPoint(offset, color); + } + + private void ClearColors() + { + for (int i = _gradTex.GetPointCount() - 1; i > 0; i--) + _gradTex.RemovePoint(i); + } + #endregion + #region Public Functions public int GetCurrentCombo() { @@ -166,6 +195,7 @@ public void IncreaseBonusMult(int amount = 1) public void IncreaseCharge(int amount = 1) { + FillWithColor(default, Colors.DarkViolet); CurrentBarValue += amount; } @@ -181,10 +211,11 @@ public Note NotePlaced() GD.PushWarning("Note is attempting placement without a full bar!"); Note placedNote = GetNote(Input.IsActionPressed("Secondary")); CurrentBarValue -= placedNote.CostModifier * MaxValue; + ClearColors(); return placedNote; } - public void HandleTiming(Timing timed) + public void HandleTiming(Timing timed, ArrowType type) { if (timed == Timing.Miss) { @@ -192,14 +223,15 @@ public void HandleTiming(Timing timed) } else { - HitNote(); + HitNote(type); } } // Hitting a note increases combo, combo mult, and note placement bar - private void HitNote() + private void HitNote(ArrowType type) { _currentCombo++; + FillWithColor(type); CurrentBarValue += ComboMult; UpdateComboMultText(); } From 9869787c5a439484c626385aec2b76c1b35ff6e1 Mon Sep 17 00:00:00 2001 From: LifeHckr Date: Sun, 6 Apr 2025 19:33:50 -0700 Subject: [PATCH 06/36] Refactored Reward Selection Refactored split functions Left selection array functions as distinct because those will need to be slightly different anyways Added button group to Reward Select Descriptions change on focus change without setting _selection --- Globals/Translations/Translations.csv | 2 +- .../Scripts/NotePlacementBar.cs | 1 - Scenes/UI/RewardSelectionUI.tscn | 2 +- Scenes/UI/Scripts/DisplayButton.cs | 13 ++- Scenes/UI/Scripts/Inventory.cs | 2 +- Scenes/UI/Scripts/RewardSelect.cs | 79 +++++++++++-------- 6 files changed, 61 insertions(+), 38 deletions(-) diff --git a/Globals/Translations/Translations.csv b/Globals/Translations/Translations.csv index 36684621..9de830cf 100644 --- a/Globals/Translations/Translations.csv +++ b/Globals/Translations/Translations.csv @@ -17,7 +17,7 @@ CONTROLS_RETURN_BUTTON,Return,返回 ESCAPE_MENU_RESUME,Resume,继续 ESCAPE_MENU_QUIT,Quit,退出 ESCAPE_MENU_TITLE,Quit to Title,返回标题 -CHEST_ROOM_REWARDS,Rewards!,奖励! +CHEST_ROOM_REWARDS,Reward Selection!,奖励! CHEST_ROOM_SKIP,Skip,跳过 CHEST_ROOM_ACCEPT,Accept,接受 BATTLE_ROOM_BEGIN_BUTTON,"Begin Battle [Enter]","开始战斗 [Enter]" diff --git a/Scenes/BattleDirector/Scripts/NotePlacementBar.cs b/Scenes/BattleDirector/Scripts/NotePlacementBar.cs index 2650895b..60d3ed0f 100644 --- a/Scenes/BattleDirector/Scripts/NotePlacementBar.cs +++ b/Scenes/BattleDirector/Scripts/NotePlacementBar.cs @@ -63,7 +63,6 @@ public override void _Ready() if (_notePlacementBar.TextureProgress is GradientTexture2D gradientTexture) _gradTex = gradientTexture.Gradient; - GD.Print(_gradTex); } public override void _Process(double delta) diff --git a/Scenes/UI/RewardSelectionUI.tscn b/Scenes/UI/RewardSelectionUI.tscn index 3a13753d..5aa2ad24 100644 --- a/Scenes/UI/RewardSelectionUI.tscn +++ b/Scenes/UI/RewardSelectionUI.tscn @@ -1,6 +1,6 @@ [gd_scene load_steps=2 format=3 uid="uid://c6icx2yriud6y"] -[ext_resource type="Script" path="res://Scenes/UI/Scripts/RewardSelect.cs" id="1_1m6an"] +[ext_resource type="Script" uid="uid://dnex3l6lt3yr4" path="res://Scenes/UI/Scripts/RewardSelect.cs" id="1_1m6an"] [node name="CanvasLayer" type="CanvasLayer" node_paths=PackedStringArray("ButtonContainer", "_description", "_acceptButton", "_skipButton")] process_mode = 2 diff --git a/Scenes/UI/Scripts/DisplayButton.cs b/Scenes/UI/Scripts/DisplayButton.cs index 76e160bb..54936e61 100644 --- a/Scenes/UI/Scripts/DisplayButton.cs +++ b/Scenes/UI/Scripts/DisplayButton.cs @@ -17,17 +17,24 @@ public partial class DisplayButton : Button [Export] public string DisplayName; - public void Display(Texture2D texture, string description, string name) + public void Display( + Texture2D texture, + string description, + string name, + bool focusHandling = false + ) { Texture = texture; Description = description; DisplayName = name; Icon = Texture; - FocusEntered += Selected; + if (focusHandling) + FocusEntered += Selected; } - private void Selected() //TODO: Button groups + //Signal pressed on focus enter, if changing focus is equivalent to pressing + private void Selected() { EmitSignal(BaseButton.SignalName.Pressed); SetPressed(true); diff --git a/Scenes/UI/Scripts/Inventory.cs b/Scenes/UI/Scripts/Inventory.cs index f26864ec..bf5f1278 100644 --- a/Scenes/UI/Scripts/Inventory.cs +++ b/Scenes/UI/Scripts/Inventory.cs @@ -34,7 +34,7 @@ private void AddDisplayButtons(IDisplayable[] displayables, Node parentNode) { var newButton = GD.Load(DisplayButton.LoadPath) .Instantiate(); - newButton.Display(item.Texture, item.Tooltip, item.Name); + newButton.Display(item.Texture, item.Tooltip, item.Name, true); newButton.Pressed += () => { DoDescription(newButton); diff --git a/Scenes/UI/Scripts/RewardSelect.cs b/Scenes/UI/Scripts/RewardSelect.cs index 4b0ec2f0..58a7ece5 100644 --- a/Scenes/UI/Scripts/RewardSelect.cs +++ b/Scenes/UI/Scripts/RewardSelect.cs @@ -17,19 +17,21 @@ public partial class RewardSelect : CanvasLayer [Export] private Button _skipButton; + private ButtonGroup _rewardGroup; + public delegate void SelectionMadeHandler(); public event SelectionMadeHandler Selected; private PlayerStats _player; - private RelicTemplate[] _rChoices; //TODO: look into typed functions - private RelicTemplate _rSelection; + private RelicTemplate[] _rChoices; private Note[] _nChoices; - private Note _nSelection; + private IDisplayable _selection; private void Initialize(PlayerStats player, int amount, Stages type) { _player = player; + _rewardGroup = new ButtonGroup(); if (type == Stages.Battle) { GenerateNoteChoices(amount); @@ -40,12 +42,24 @@ private void Initialize(PlayerStats player, int amount, Stages type) } _acceptButton.Pressed += OnSelect; + _acceptButton.FocusEntered += () => ChangeDescription(_selection); _skipButton.Pressed += OnSkip; } public override void _Process(double delta) { - _acceptButton.Visible = (_nSelection != null) || (_rSelection != null); + _acceptButton.Visible = (_selection != null); + } + + private void AddButton(IDisplayable displayable) + { + var button = new DisplayButton(); + button.SetButtonGroup(_rewardGroup); + button.ToggleMode = true; + button.Display(displayable.Texture, displayable.Tooltip, displayable.Name); + button.Pressed += () => SetSelection(displayable); + button.FocusEntered += () => ChangeDescription(displayable); + ButtonContainer.AddChild(button); } private void GenerateRelicChoices(int amount = 1) @@ -56,10 +70,7 @@ private void GenerateRelicChoices(int amount = 1) foreach (var relic in _rChoices) { - var button = new DisplayButton(); - button.Display(relic.Texture, relic.Tooltip, relic.Name); - button.Pressed += () => OnRelicSelected(relic); - ButtonContainer.AddChild(button); + AddButton(relic); } ButtonContainer.GetChild