From c6cee88ab2623859e2296e3dbcb005a33b21ef8e Mon Sep 17 00:00:00 2001 From: Nathan Chapman Date: Sun, 18 May 2025 14:16:18 -0600 Subject: [PATCH] Add damage indicator --- .../textures/terrain/sand_albedo_height.png | 3 + .../terrain/sand_albedo_height.png.import | 35 +++ .../terrain/sand_normal_roughness.png | 3 + .../terrain/sand_normal_roughness.png.import | 35 +++ project.godot | 4 + .../terrain_data/terrain3d-01-01.res | Bin 0 -> 5853 bytes .../terrain_data/terrain3d-01_00.res | Bin 0 -> 5854 bytes .../terrain_data/terrain3d_00-01.res | Bin 0 -> 5857 bytes .../terrain_data/terrain3d_00_00.res | Bin 0 -> 5859 bytes src/scenes/autoload/vfx_manager.tscn | 6 + src/scenes/characters/enemy.tscn | 209 ++++++++++-------- src/scenes/characters/player.tscn | 148 ++++++++++--- src/scenes/levels/level.tscn | 155 ++++++++++--- src/scenes/structures/lamp.tscn | 1 + src/scenes/ui/damage_number.tscn | 95 ++++++++ src/scripts/autoload/vfx_manager.gd | 8 + src/scripts/autoload/vfx_manager.gd.uid | 1 + src/scripts/characters/health_component.gd | 7 +- src/scripts/ui/damage_number.gd | 15 ++ src/scripts/ui/damage_number.gd.uid | 1 + 20 files changed, 564 insertions(+), 162 deletions(-) create mode 100644 assets/textures/terrain/sand_albedo_height.png create mode 100644 assets/textures/terrain/sand_albedo_height.png.import create mode 100644 assets/textures/terrain/sand_normal_roughness.png create mode 100644 assets/textures/terrain/sand_normal_roughness.png.import create mode 100644 src/resources/terrain_data/terrain3d-01-01.res create mode 100644 src/resources/terrain_data/terrain3d-01_00.res create mode 100644 src/resources/terrain_data/terrain3d_00-01.res create mode 100644 src/resources/terrain_data/terrain3d_00_00.res create mode 100644 src/scenes/autoload/vfx_manager.tscn create mode 100644 src/scenes/ui/damage_number.tscn create mode 100644 src/scripts/autoload/vfx_manager.gd create mode 100644 src/scripts/autoload/vfx_manager.gd.uid create mode 100644 src/scripts/ui/damage_number.gd create mode 100644 src/scripts/ui/damage_number.gd.uid diff --git a/assets/textures/terrain/sand_albedo_height.png b/assets/textures/terrain/sand_albedo_height.png new file mode 100644 index 0000000..67697f1 --- /dev/null +++ b/assets/textures/terrain/sand_albedo_height.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:3d357cfb42013184ba7f9119c59f8a9c37a692ee68dd8dfb204086ba21f8a3a2 +size 7860151 diff --git a/assets/textures/terrain/sand_albedo_height.png.import b/assets/textures/terrain/sand_albedo_height.png.import new file mode 100644 index 0000000..5baf2b5 --- /dev/null +++ b/assets/textures/terrain/sand_albedo_height.png.import @@ -0,0 +1,35 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://bpamrp14tk2cp" +path.s3tc="res://.godot/imported/sand_albedo_height.png-568aa75c142f091bd9b6cfa9077b95da.s3tc.ctex" +metadata={ +"imported_formats": ["s3tc_bptc"], +"vram_texture": true +} + +[deps] + +source_file="res://assets/textures/terrain/sand_albedo_height.png" +dest_files=["res://.godot/imported/sand_albedo_height.png-568aa75c142f091bd9b6cfa9077b95da.s3tc.ctex"] + +[params] + +compress/mode=2 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=2 +compress/channel_pack=0 +mipmaps/generate=true +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/assets/textures/terrain/sand_normal_roughness.png b/assets/textures/terrain/sand_normal_roughness.png new file mode 100644 index 0000000..dade20f --- /dev/null +++ b/assets/textures/terrain/sand_normal_roughness.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:bdc14ad786e1d8a60be00d673f955f64e397ed1d1a49ee98da92f41f8b8955eb +size 10106707 diff --git a/assets/textures/terrain/sand_normal_roughness.png.import b/assets/textures/terrain/sand_normal_roughness.png.import new file mode 100644 index 0000000..36ee7f5 --- /dev/null +++ b/assets/textures/terrain/sand_normal_roughness.png.import @@ -0,0 +1,35 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://dpq5k4rlimus8" +path.s3tc="res://.godot/imported/sand_normal_roughness.png-a161f64e16b4203ed6531156209a09bd.s3tc.ctex" +metadata={ +"imported_formats": ["s3tc_bptc"], +"vram_texture": true +} + +[deps] + +source_file="res://assets/textures/terrain/sand_normal_roughness.png" +dest_files=["res://.godot/imported/sand_normal_roughness.png-a161f64e16b4203ed6531156209a09bd.s3tc.ctex"] + +[params] + +compress/mode=2 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=2 +compress/channel_pack=0 +mipmaps/generate=true +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/project.godot b/project.godot index 731f163..b064d50 100644 --- a/project.godot +++ b/project.godot @@ -15,6 +15,10 @@ run/main_scene="uid://dw0lbkh31rofd" config/features=PackedStringArray("4.4", "Forward Plus") config/icon="res://icon.svg" +[autoload] + +VFXManager="*res://src/scenes/autoload/vfx_manager.tscn" + [editor_plugins] enabled=PackedStringArray("res://addons/sky_3d/plugin.cfg", "res://addons/terrain_3d/plugin.cfg") diff --git a/src/resources/terrain_data/terrain3d-01-01.res b/src/resources/terrain_data/terrain3d-01-01.res new file mode 100644 index 0000000000000000000000000000000000000000..aeaaa9932cedbc357e821c50bd7356f40746ad45 GIT binary patch literal 5853 zcmWFvc6MfB00IF9hWtoghDb&R24Ns~q~d&_-$h3-ZXCgWr&YY?0K-&ctNz~v2L4(u zhHDor3=?uMNf_`jPgn7rB+$&@UUQ_@c$4{`{fhCMP76wl=Q~ATJ92i5mgl!Z*PgpR zH||DpX)>rY=rZ^kSwt@74agQ~bL!tpzR?OFj1c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ox=e^yi)F&Eb*b@M4Xn_zF_wWr0aPL|GW@(>?lLOKKN=vTiD5J& z0NbOZ838RL>}6(n!U8HQnc0A?cF)|z^i&35|5yshVJ**0Dal|5vNBRL(=$ra@{4j4 zOM={;94$D2g1MOmxrqhEj46pFi45{UfsjyE24MTXo}c09j?dg5mpRs)xx8LS<*L}+ zW?RV>Q3+ZX7dSDje0%G?u-@+Sr<;(9WuT`27-jXSAX?=$8X%(q0`63U3bE0|Fq#-f z6T^_m2>BeM%nTwdpd8B#tR{g2&Y;0(hLF^vqQuNRW0#=R^vwJ`22e%IQZ15a&kAI4 zF*GoMDp?62W@6yv3JMN#=3%H-u+TctbGO6!jEQ(pi}D{y$IynAO#CP0EWgPL1_4L5 E0U{B(9smFU literal 0 HcmV?d00001 diff --git a/src/resources/terrain_data/terrain3d_00-01.res b/src/resources/terrain_data/terrain3d_00-01.res new file mode 100644 index 0000000000000000000000000000000000000000..34c3f23112087469b9bf73a1f489cb7c04f28de1 GIT binary patch literal 5857 zcmWFvc6MfB00IF9hWtoghFC@h24Ns~q~d&_-$h3-ZXCgWr&YY?0K-&ctNz~v2L8ER z4A(AL8YSdjk}%+5J}w~OD8Q0f-p03kyYkK1E4K3fESm1NWku$-wZDE(w7en|a^7%m zo_X2!X-rxS>J0h}zD5?2OL@a`qIn#5esup~8lU3kBxc~^@b47=u1s5@InPawt^L9K zulp(UI?IpX?9KDbEn(O2P{oo z7~;O;>V=jR&Myv?8|GeF)UoJXy~1|exu14&tZv{s_A_Dk6`_jd%O|pO>FaOROFx)( z$oOiP0kiSUS(6_BXjz^UxarP~2OAP^G(ef^lSJT{@jsW&{%jj zRA9YS%k-I^L9Q1qZ%l4n#kx$0SBquBuXU;MS`DzWF_wWr0Tc|33_tIeyFg3FQNhsw z8BGkpX4z;)7|jUqjIfuP;Ry?Vh9mvW^%}mcI zNy{(FO)Lp=cXG7g01D=27UU)t6f>qImLxLB0|i1tSsDKS|6k9~aCFCK?vKkHYtCF= zucLBRY;LoySt&0ns7*@W$^H0z%ggg_%lODYEe;QW}dN2P-=Q+ejWp;qGhQT z$+Kq#GPoET7(kV*1Q0VZaB>9&2RZXFR4Z6$9q75+;e5tKyr)I^kECO0!%8Op6LOZ{ KWCeqOgWCWQCA2~S literal 0 HcmV?d00001 diff --git a/src/resources/terrain_data/terrain3d_00_00.res b/src/resources/terrain_data/terrain3d_00_00.res new file mode 100644 index 0000000000000000000000000000000000000000..fe74c30d66327983bd1c372583d6b6c1409af897 GIT binary patch literal 5859 zcmWFvc6MfB00IF9hWtoghImE>24Ns~q~d&_-$h3-ZXCgWr&YY?0K-&ctNz~v2L82N z495hlObU*ACja^W`ip(||JAX7xo-Kcy}L>9X0_%mmB75;s)_9CM?@FpT|dFNVuDa( z{o$PKH+j0OS`6w8dJMVYb6#&0yMIZ|yfE}1Pra(qfuM$lqsH(XOFO2sV$BB z!?j=K6XWD3CBOKmEy!MT>*~ds8`uhVYiUpY96WF8%(@B*O@a!us;B$% z7c7}^>)6fETC>AUm1>%*{W85jl|0hGzwRVx|J=v^d8zh2m?@eC7vErUD>+7c{|8nf8<^0n7l!a{rGOQe0WBl!WoCH70xBz+*?>)V&)mfHR0d!tSqjKuEze9T$zTVvGEy_s zGfL9(i*gf7g4~@PEjWOJxtRsIi3P=sDTyVC4DvvMkWf~J|NsBj^D`XX@tOPMGRK-T zm)Gm4Tos$!Y%94UDnaYw0w;!*Z*RR9*4thFbQ4ms4Ak@=qpThkM60|;17tKnz&&eF zAvT&AMiawmVi*z`A)iB(nL&gFlw+BJ)g*A#88iaT5RzI{l$e=k>=Klko|&J=0IFzN zszvhbS%C~Lh6V;uB`X2MObnb{LBT=JJPg$e7Fq{-?shnzF%j=+QT`+87}~IsiT{M0 M void: + var number = DAMAGE_NUMBER.instantiate() + number.setup(damage, position_in, is_critical) + add_child(number) diff --git a/src/scripts/autoload/vfx_manager.gd.uid b/src/scripts/autoload/vfx_manager.gd.uid new file mode 100644 index 0000000..134ef07 --- /dev/null +++ b/src/scripts/autoload/vfx_manager.gd.uid @@ -0,0 +1 @@ +uid://cfrxuprulebec diff --git a/src/scripts/characters/health_component.gd b/src/scripts/characters/health_component.gd index 6fe9648..86da214 100644 --- a/src/scripts/characters/health_component.gd +++ b/src/scripts/characters/health_component.gd @@ -1,9 +1,10 @@ -extends Node -class_name HealthComponent +class_name HealthComponent extends Node signal defeat() signal health_changed() +@export var body: PhysicsBody3D + var max_health: float var current_health: float: set(value): @@ -20,5 +21,5 @@ func take_damage(damage_in: float, is_critical: bool) -> void: var damage = damage_in if is_critical: damage *= 2.0 - print("Is critical hit") current_health -= damage + VFXManager.spawn_damage_number(damage, body.global_position, is_critical) diff --git a/src/scripts/ui/damage_number.gd b/src/scripts/ui/damage_number.gd new file mode 100644 index 0000000..c2137d2 --- /dev/null +++ b/src/scripts/ui/damage_number.gd @@ -0,0 +1,15 @@ +extends Node3D + +@onready var label: Label3D = $Label3D + +func setup(damage: int, position_in: Vector3, is_critical: bool) -> void: + if not is_inside_tree(): + await ready + + var color = Color.GOLD + if is_critical: + color = Color.RED + label.text = "-" + str(damage) + label.modulate = color + global_position = position_in + diff --git a/src/scripts/ui/damage_number.gd.uid b/src/scripts/ui/damage_number.gd.uid new file mode 100644 index 0000000..07106b5 --- /dev/null +++ b/src/scripts/ui/damage_number.gd.uid @@ -0,0 +1 @@ +uid://cjiuw6wud2e3m