diff --git a/assets/audio/sfx/yuck.mp3.import b/assets/audio/sfx/yuck.mp3.import index 65416f2..196eea0 100644 --- a/assets/audio/sfx/yuck.mp3.import +++ b/assets/audio/sfx/yuck.mp3.import @@ -13,7 +13,7 @@ dest_files=["res://.godot/imported/yuck.mp3-300336a3ee536c8e6db69a73706c7ea5.mp3 [params] loop=false -loop_offset=0 -bpm=0 +loop_offset=0.0 +bpm=0.0 beat_count=0 bar_beats=4 diff --git a/assets/sprites/zombies/basic.png b/assets/sprites/zombies/basic.png new file mode 100644 index 0000000..e25856a Binary files /dev/null and b/assets/sprites/zombies/basic.png differ diff --git a/assets/sprites/zombies/basic.png.import b/assets/sprites/zombies/basic.png.import new file mode 100644 index 0000000..6f1c698 --- /dev/null +++ b/assets/sprites/zombies/basic.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://dacgbwohpmeed" +path="res://.godot/imported/basic.png-205c58c8e7a1c883499253aaac0827ad.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://assets/sprites/zombies/basic.png" +dest_files=["res://.godot/imported/basic.png-205c58c8e7a1c883499253aaac0827ad.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/assets/sprites/zombies/basic_fem.png b/assets/sprites/zombies/basic_fem.png new file mode 100644 index 0000000..9109ef4 Binary files /dev/null and b/assets/sprites/zombies/basic_fem.png differ diff --git a/assets/sprites/zombies/basic_fem.png.import b/assets/sprites/zombies/basic_fem.png.import new file mode 100644 index 0000000..1f1dd84 --- /dev/null +++ b/assets/sprites/zombies/basic_fem.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://vmtirasfeqx2" +path="res://.godot/imported/basic_fem.png-127aa80fcab40abe52a558e5d27d9b50.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://assets/sprites/zombies/basic_fem.png" +dest_files=["res://.godot/imported/basic_fem.png-127aa80fcab40abe52a558e5d27d9b50.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/assets/sprites/zombies/hobo.png b/assets/sprites/zombies/hobo.png new file mode 100644 index 0000000..be8c292 Binary files /dev/null and b/assets/sprites/zombies/hobo.png differ diff --git a/assets/sprites/zombies/hobo.png.import b/assets/sprites/zombies/hobo.png.import new file mode 100644 index 0000000..d7617a3 --- /dev/null +++ b/assets/sprites/zombies/hobo.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://dri70dxyks7xh" +path="res://.godot/imported/hobo.png-3a16a8c443698b434e4066b4d1a9eb45.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://assets/sprites/zombies/hobo.png" +dest_files=["res://.godot/imported/hobo.png-3a16a8c443698b434e4066b4d1a9eb45.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/assets/sprites/zombies/polevaulter.png b/assets/sprites/zombies/polevaulter.png new file mode 100644 index 0000000..7379901 Binary files /dev/null and b/assets/sprites/zombies/polevaulter.png differ diff --git a/assets/sprites/zombies/polevaulter.png.import b/assets/sprites/zombies/polevaulter.png.import new file mode 100644 index 0000000..efbadd8 --- /dev/null +++ b/assets/sprites/zombies/polevaulter.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://b2p72b08as365" +path="res://.godot/imported/polevaulter.png-1daef60b20e89deaa51a84148fdba268.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://assets/sprites/zombies/polevaulter.png" +dest_files=["res://.godot/imported/polevaulter.png-1daef60b20e89deaa51a84148fdba268.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/assets/sprites/zombies/screendoor.png b/assets/sprites/zombies/screendoor.png new file mode 100644 index 0000000..c39eb10 Binary files /dev/null and b/assets/sprites/zombies/screendoor.png differ diff --git a/assets/sprites/zombies/screendoor.png.import b/assets/sprites/zombies/screendoor.png.import new file mode 100644 index 0000000..602dd11 --- /dev/null +++ b/assets/sprites/zombies/screendoor.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://cxbudhukl268p" +path="res://.godot/imported/screendoor.png-215bb197239ee5db1b25f8a23e7c9f3f.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://assets/sprites/zombies/screendoor.png" +dest_files=["res://.godot/imported/screendoor.png-215bb197239ee5db1b25f8a23e7c9f3f.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/assets/sprites/zombies/screendoor_fem.png b/assets/sprites/zombies/screendoor_fem.png new file mode 100644 index 0000000..f21eae2 Binary files /dev/null and b/assets/sprites/zombies/screendoor_fem.png differ diff --git a/assets/sprites/zombies/screendoor_fem.png.import b/assets/sprites/zombies/screendoor_fem.png.import new file mode 100644 index 0000000..07e1ed6 --- /dev/null +++ b/assets/sprites/zombies/screendoor_fem.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://c5arkk8bthwbk" +path="res://.godot/imported/screendoor_fem.png-2ee7b01445eb11951dbc02e1dc4a467d.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://assets/sprites/zombies/screendoor_fem.png" +dest_files=["res://.godot/imported/screendoor_fem.png-2ee7b01445eb11951dbc02e1dc4a467d.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/assets/sprites/zombies/Зондби.png b/assets/sprites/zombies/Зондби.png new file mode 100644 index 0000000..30d9fae Binary files /dev/null and b/assets/sprites/zombies/Зондби.png differ diff --git a/assets/sprites/zombies/Зондби.png.import b/assets/sprites/zombies/Зондби.png.import new file mode 100644 index 0000000..8769469 --- /dev/null +++ b/assets/sprites/zombies/Зондби.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://dunlsp8tx7a4w" +path="res://.godot/imported/Зондби.png-232f73fd1fdda4bd055015133aa6210e.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://assets/sprites/zombies/Зондби.png" +dest_files=["res://.godot/imported/Зондби.png-232f73fd1fdda4bd055015133aa6210e.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/project.godot b/project.godot index 2e08b3e..e6bfbe8 100644 --- a/project.godot +++ b/project.godot @@ -22,7 +22,7 @@ config/windows_native_icon="res://icon.ico" LevelController="*res://scripts/LevelController.cs" Cursor="*res://scripts/Cursor.cs" GameRegistry="*res://scripts/systems/GameRegistry.cs" -Cheats="res://scripts/debug/Cheats.cs" +Cheats="*res://scripts/debug/Cheats.cs" AudioSequencer="*res://scenes/audio_sequencer.tscn" [display] diff --git a/resources/animations/plants/sunflower.res b/resources/animations/plants/sunflower.res index 1f15a38..107ee29 100644 Binary files a/resources/animations/plants/sunflower.res and b/resources/animations/plants/sunflower.res differ diff --git a/resources/animations/zombies/basic_zombie_eating.res b/resources/animations/zombies/basic_zombie_eating.res new file mode 100644 index 0000000..24448b1 Binary files /dev/null and b/resources/animations/zombies/basic_zombie_eating.res differ diff --git a/resources/animations/zombies/basic_zombie_stand.res b/resources/animations/zombies/basic_zombie_stand.res new file mode 100644 index 0000000..a678c41 Binary files /dev/null and b/resources/animations/zombies/basic_zombie_stand.res differ diff --git a/resources/animations/zombies/basic_zombie_walk.res b/resources/animations/zombies/basic_zombie_walk.res new file mode 100644 index 0000000..0f6d641 Binary files /dev/null and b/resources/animations/zombies/basic_zombie_walk.res differ diff --git a/resources/effects/GarlicEffect.tres b/resources/effects/GarlicEffect.tres index 374c2cd..5c9f170 100644 --- a/resources/effects/GarlicEffect.tres +++ b/resources/effects/GarlicEffect.tres @@ -5,4 +5,4 @@ [resource] script = ExtResource("1_rfumy") Duration = 0.25 -Slot = 3 +Slot = "garlic" diff --git a/resources/effects/SnowSlow.tres b/resources/effects/SnowSlow.tres index 5851046..5a62fd5 100644 --- a/resources/effects/SnowSlow.tres +++ b/resources/effects/SnowSlow.tres @@ -1,10 +1,10 @@ [gd_resource type="Resource" load_steps=2 format=3 uid="uid://7uj0oe656jfx"] -[ext_resource type="Script" path="res://scripts/systems/effects/SlownessEffect.cs" id="1_8md01"] +[ext_resource type="Script" uid="uid://dyc7fc5bfkdii" path="res://scripts/systems/effects/SlownessEffect.cs" id="1_8md01"] [resource] script = ExtResource("1_8md01") ColorOverride = Color(0, 1, 1, 1) Multiplier = 0.75 Duration = 3.25 -Slot = 0 +Slot = "freeze_slow" diff --git a/scenes/entities/Zombies/hobo.tscn b/scenes/entities/Zombies/hobo.tscn index 5cb2e5f..8751989 100644 --- a/scenes/entities/Zombies/hobo.tscn +++ b/scenes/entities/Zombies/hobo.tscn @@ -1,8 +1,10 @@ -[gd_scene load_steps=44 format=3 uid="uid://bgqmwsb6ynm81"] +[gd_scene load_steps=48 format=3 uid="uid://bgqmwsb6ynm81"] [ext_resource type="PackedScene" uid="uid://co11v3w8hbwgf" path="res://scenes/entities/Zombies/zombie.tscn" id="1_fnu7s"] [ext_resource type="Shader" uid="uid://d0eo5uuj222c4" path="res://assets/shaders/CG_color_blender.gdshader" id="2_6qr4h"] +[ext_resource type="Script" uid="uid://bcc7skl7ts6sh" path="res://scripts/systems/effects/Effect.cs" id="2_txjqc"] [ext_resource type="Texture2D" uid="uid://cse1504ao4g8e" path="res://assets/sprites/atlases/zombies/hobo.png" id="3_6qr4h"] +[ext_resource type="Resource" uid="uid://dsg1vjx76ifgu" path="res://resources/effects/GarlicEffect.tres" id="3_b583s"] [ext_resource type="Script" uid="uid://dt5uj25u0g6y3" path="res://scripts/components/particles/FallParticle.cs" id="3_tu6af"] [ext_resource type="AnimationLibrary" uid="uid://cuh2kyb21hmkm" path="res://resources/animations/zombies/basic_zombie.res" id="4_02fim"] [ext_resource type="Script" uid="uid://c5v2og85t7s6j" path="res://scripts/components/zombies/behaviours/HoboBehaviour.cs" id="4_5selg"] @@ -150,6 +152,8 @@ _data = { &"run": SubResource("Animation_5selg") } +[sub_resource type="AnimationNodeTimeScale" id="AnimationNodeTimeScale_2q05d"] + [sub_resource type="AnimationNodeAnimation" id="AnimationNodeAnimation_h0rfo"] animation = &"basic_zombie/eat" @@ -217,7 +221,15 @@ states/hobo_zombie_can_destroy/position = Vector2(368, 206) states/hobo_zombie_run/node = SubResource("AnimationNodeAnimation_c1y3b") states/hobo_zombie_run/position = Vector2(866, 89) transitions = ["Start", "basic_zombie_idle", SubResource("AnimationNodeStateMachineTransition_vxhht"), "basic_zombie_idle", "basic_zombie_eat", SubResource("AnimationNodeStateMachineTransition_y2ivb"), "basic_zombie_walk", "basic_zombie_eat", SubResource("AnimationNodeStateMachineTransition_7d3k4"), "basic_zombie_idle", "basic_zombie_walk", SubResource("AnimationNodeStateMachineTransition_qg8rq"), "basic_zombie_idle", "hobo_zombie_run", SubResource("AnimationNodeStateMachineTransition_4248q"), "hobo_zombie_run", "basic_zombie_eat", SubResource("AnimationNodeStateMachineTransition_tu6af"), "basic_zombie_eat", "hobo_zombie_run", SubResource("AnimationNodeStateMachineTransition_yalvk"), "hobo_zombie_can_destroy", "basic_zombie_idle", SubResource("AnimationNodeStateMachineTransition_7jlle"), "basic_zombie_eat", "basic_zombie_walk", SubResource("AnimationNodeStateMachineTransition_w1b1s"), "basic_zombie_walk", "hobo_zombie_run", SubResource("AnimationNodeStateMachineTransition_02fim")] -graph_offset = Vector2(55, -28) +graph_offset = Vector2(210, 91) + +[sub_resource type="AnimationNodeBlendTree" id="AnimationNodeBlendTree_txjqc"] +graph_offset = Vector2(-447, 53) +nodes/TimeScale/node = SubResource("AnimationNodeTimeScale_2q05d") +nodes/TimeScale/position = Vector2(60, 120) +nodes/Tree/node = SubResource("AnimationNodeStateMachine_xg3p6") +nodes/Tree/position = Vector2(-220, 120) +node_connections = [&"TimeScale", 0, &"Tree", &"output", 0, &"TimeScale"] [sub_resource type="Resource" id="Resource_4248q"] resource_local_to_scene = true @@ -227,8 +239,9 @@ percentage_value = 0.0 mult_value = 1.0 [node name="Hobo" node_paths=PackedStringArray("_armor") instance=ExtResource("1_fnu7s")] -_maxHP = 130 _armor = NodePath("CanArmor") +MaxHP = 130.0 +_effectImmunities = Array[ExtResource("2_txjqc")]([ExtResource("3_b583s")]) [node name="CanvasGroup" parent="." index="0"] material = SubResource("ShaderMaterial_w8pya") @@ -274,7 +287,7 @@ autoplay = "baisc_zombie/walk" speed_scale = 3.0 [node name="AnimationTree" parent="." index="4"] -tree_root = SubResource("AnimationNodeStateMachine_xg3p6") +tree_root = SubResource("AnimationNodeBlendTree_txjqc") advance_expression_base_node = NodePath("../Behaviour") [node name="Mover" parent="." index="5"] @@ -282,7 +295,7 @@ _speed = SubResource("Resource_4248q") [node name="CanArmor" type="Node" parent="." index="7"] script = ExtResource("4_w8pya") -MaxHP = 385 +MaxHP = 385.0 metadata/_custom_type_script = "uid://fd4im1fmwc5n" [node name="Behaviour" type="Node" parent="." index="8" node_paths=PackedStringArray("_eatBox", "_animationTree")] diff --git a/scenes/entities/Zombies/zombie.tscn b/scenes/entities/Zombies/zombie.tscn index 82685a4..60dabed 100644 --- a/scenes/entities/Zombies/zombie.tscn +++ b/scenes/entities/Zombies/zombie.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=24 format=3 uid="uid://co11v3w8hbwgf"] +[gd_scene load_steps=32 format=3 uid="uid://co11v3w8hbwgf"] [ext_resource type="Script" uid="uid://dildme6epx8l4" path="res://scripts/components/zombies/RuntimeZombieData.cs" id="1_qq3f1"] [ext_resource type="Texture2D" uid="uid://bwdqbrnn7ygtr" path="res://assets/sprites/atlases/zombies/Зондби.png" id="2_4pdxh"] @@ -12,10 +12,15 @@ [ext_resource type="Script" uid="uid://c3cfnrmnnuqms" path="res://addons/floatmodifiers/FloatModifiers.cs" id="7_b3p4o"] [ext_resource type="AnimationNodeStateMachine" uid="uid://dj0blope85bg7" path="res://resources/animations/zombies/basic_zombie_tree.tres" id="8_ckb7n"] [ext_resource type="Script" uid="uid://c36bj8u7jghc7" path="res://scripts/audio/ChannelPlayer.cs" id="10_ruqsf"] +[ext_resource type="Script" uid="uid://dwlwi42smgxkb" path="res://scripts/components/TimeScalableAnimationTree.cs" id="11_ccrjo"] [ext_resource type="AudioStream" uid="uid://dyid55nhflwyn" path="res://assets/audio/sfx/chomp_generic.tres" id="11_vjrlo"] [ext_resource type="AudioStream" uid="uid://bg76miyscfvhu" path="res://assets/audio/sfx/groan.tres" id="12_ad42i"] [ext_resource type="Script" uid="uid://cnn0ymuhypdff" path="res://scripts/audio/ChannelPlaylist.cs" id="12_he8da"] [ext_resource type="AudioStream" uid="uid://w0qfwds4o3ti" path="res://assets/audio/sfx/hit_generic.tres" id="12_vjrlo"] +[ext_resource type="Script" uid="uid://b8r6fxsfjdo3a" path="res://scripts/audio/EffectBasedPlayer.cs" id="17_ltj46"] +[ext_resource type="Resource" uid="uid://dsg1vjx76ifgu" path="res://resources/effects/GarlicEffect.tres" id="18_2q05d"] +[ext_resource type="Resource" uid="uid://7uj0oe656jfx" path="res://resources/effects/SnowSlow.tres" id="19_ccrjo"] +[ext_resource type="Script" uid="uid://c1x4n4nqyq72f" path="res://scripts/audio/ChannelSettings.cs" id="21_xnora"] [sub_resource type="ShaderMaterial" id="ShaderMaterial_63ls2"] resource_local_to_scene = true @@ -56,6 +61,15 @@ _data = { &"RESET": SubResource("Animation_qv5y7") } +[sub_resource type="AnimationNodeTimeScale" id="AnimationNodeTimeScale_2q05d"] + +[sub_resource type="AnimationNodeBlendTree" id="AnimationNodeBlendTree_ccrjo"] +nodes/TimeScale/node = SubResource("AnimationNodeTimeScale_2q05d") +nodes/TimeScale/position = Vector2(60, 120) +nodes/Tree/node = ExtResource("8_ckb7n") +nodes/Tree/position = Vector2(-240, 120) +node_connections = [&"TimeScale", 0, &"Tree", &"output", 0, &"TimeScale"] + [sub_resource type="Resource" id="Resource_ckb7n"] resource_local_to_scene = true script = ExtResource("7_b3p4o") @@ -63,12 +77,17 @@ flat_value = 0.2 percentage_value = 0.0 mult_value = 1.0 +[sub_resource type="Resource" id="Resource_dn8ha"] +script = ExtResource("21_xnora") +restartTreshold = -1.0 +metadata/_custom_type_script = "uid://c1x4n4nqyq72f" + [node name="Zombie" type="Node2D"] y_sort_enabled = true script = ExtResource("1_qq3f1") -_maxHP = 70 garlicSound = ExtResource("2_hh4qh") freezeSound = ExtResource("3_ltj46") +MaxHP = 70.0 [node name="CanvasGroup" type="CanvasGroup" parent="."] material = SubResource("ShaderMaterial_63ls2") @@ -102,10 +121,13 @@ libraries = { &"basic_zombie": ExtResource("6_ckb7n") } -[node name="AnimationTree" type="AnimationTree" parent="."] -tree_root = ExtResource("8_ckb7n") +[node name="AnimationTree" type="AnimationTree" parent="." node_paths=PackedStringArray("entity")] +tree_root = SubResource("AnimationNodeBlendTree_ccrjo") advance_expression_base_node = NodePath("../Eatbox") anim_player = NodePath("../AnimationPlayer") +parameters/TimeScale/scale = 1.0 +script = ExtResource("11_ccrjo") +entity = NodePath("..") [node name="Mover" type="Node" parent="."] script = ExtResource("4_u5syx") @@ -137,6 +159,12 @@ wait_time = 5.0 one_shot = true autostart = true +[node name="EffectPlayer" type="Node" parent="."] +script = ExtResource("17_ltj46") +effectsToMap = Array[Resource]([ExtResource("18_2q05d"), ExtResource("19_ccrjo")]) +streamsToMapTo = Array[AudioStream]([ExtResource("2_hh4qh"), ExtResource("3_ltj46")]) +streamSettings = Array[Object]([null, SubResource("Resource_dn8ha")]) + [connection signal="OnDamaged" from="." to="HitPlayer" method="Play"] [connection signal="OnHPChanged" from="." to="CanvasGroup" method="DamageFlash"] [connection signal="area_entered" from="Eatbox" to="Eatbox" method="OnAreaEntered"] diff --git a/scenes/entities/plants/aloe.tscn b/scenes/entities/plants/aloe.tscn index c4c75a4..4aeb856 100644 --- a/scenes/entities/plants/aloe.tscn +++ b/scenes/entities/plants/aloe.tscn @@ -1,9 +1,10 @@ -[gd_scene load_steps=18 format=3 uid="uid://bw1w8jp0yeypy"] +[gd_scene load_steps=21 format=3 uid="uid://bw1w8jp0yeypy"] [ext_resource type="PackedScene" uid="uid://b1hjjbdwf1rtc" path="res://scenes/templates/plant_template.tscn" id="1_n25yi"] [ext_resource type="Texture2D" uid="uid://b6tyoa5htapir" path="res://assets/sprites/atlases/plants/aloe.png" id="2_iup5p"] [ext_resource type="AnimationLibrary" uid="uid://bgutjc3ruq27s" path="res://resources/animations/plants/aloe.res" id="3_3sp3b"] [ext_resource type="Script" uid="uid://cljytsmqac0w7" path="res://scripts/components/plants/behaviours/AloeBehaviour.cs" id="4_55asm"] +[ext_resource type="Script" uid="uid://c4jy0cnbnx33h" path="res://scripts/components/TimeScalableTimer.cs" id="5_gfy6j"] [sub_resource type="Animation" id="Animation_vknky"] length = 0.001 @@ -22,7 +23,7 @@ tracks/0/keys = { tracks/1/type = "value" tracks/1/imported = false tracks/1/enabled = true -tracks/1/path = NodePath("AnimationTree:parameters/conditions/heal") +tracks/1/path = NodePath("AnimationTree:parameters/Tree/conditions/heal") tracks/1/interp = 1 tracks/1/loop_wrap = true tracks/1/keys = { @@ -37,6 +38,8 @@ _data = { &"RESET": SubResource("Animation_vknky") } +[sub_resource type="AnimationNodeTimeScale" id="AnimationNodeTimeScale_qtb3p"] + [sub_resource type="AnimationNodeAnimation" id="AnimationNodeAnimation_c25ew"] animation = &"aloe/heal" @@ -80,10 +83,19 @@ states/aloe_recharge/position = Vector2(530, 171) transitions = ["Start", "aloe_idle", SubResource("AnimationNodeStateMachineTransition_gi6e0"), "aloe_heal", "aloe_idle_used", SubResource("AnimationNodeStateMachineTransition_l1t7h"), "aloe_recharge", "aloe_idle", SubResource("AnimationNodeStateMachineTransition_cut4s"), "aloe_idle", "aloe_heal", SubResource("AnimationNodeStateMachineTransition_um4ov"), "aloe_idle_used", "aloe_recharge", SubResource("AnimationNodeStateMachineTransition_4kdc0")] graph_offset = Vector2(-78.082, -71.7578) +[sub_resource type="AnimationNodeBlendTree" id="AnimationNodeBlendTree_gfy6j"] +graph_offset = Vector2(-383, 84) +nodes/TimeScale/node = SubResource("AnimationNodeTimeScale_qtb3p") +nodes/TimeScale/position = Vector2(120, 120) +nodes/Tree/node = SubResource("AnimationNodeStateMachine_bldox") +nodes/Tree/position = Vector2(-140, 160) +node_connections = [&"TimeScale", 0, &"Tree", &"output", 0, &"TimeScale"] + [sub_resource type="RectangleShape2D" id="RectangleShape2D_oe0dc"] size = Vector2(22, 32) [node name="Aloe" instance=ExtResource("1_n25yi")] +MaxHP = 30.0 [node name="Sprite2D" parent="." index="0"] position = Vector2(9, -14) @@ -98,17 +110,20 @@ libraries = { } [node name="AnimationTree" parent="." index="2"] -tree_root = SubResource("AnimationNodeStateMachine_bldox") -parameters/conditions/charged = false -parameters/conditions/heal = false +tree_root = SubResource("AnimationNodeBlendTree_gfy6j") +parameters/TimeScale/scale = 1.0 +parameters/Tree/conditions/charged = false +parameters/Tree/conditions/heal = false [node name="Behaviour" type="Node" parent="." index="3"] script = ExtResource("4_55asm") _hpTreshold = 0.33 -[node name="Timer" type="Timer" parent="Behaviour" index="0"] +[node name="Timer" type="Timer" parent="Behaviour" index="0" node_paths=PackedStringArray("entity")] wait_time = 20.0 one_shot = true +script = ExtResource("5_gfy6j") +entity = NodePath("../..") [node name="CollisionShape2D" type="CollisionShape2D" parent="Hitbox" index="0"] shape = SubResource("RectangleShape2D_oe0dc") diff --git a/scenes/entities/plants/garlic.tscn b/scenes/entities/plants/garlic.tscn index 67c316e..46bea8a 100644 --- a/scenes/entities/plants/garlic.tscn +++ b/scenes/entities/plants/garlic.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=14 format=3 uid="uid://qq0cw8xtcoj3"] +[gd_scene load_steps=16 format=3 uid="uid://qq0cw8xtcoj3"] [ext_resource type="PackedScene" uid="uid://b1hjjbdwf1rtc" path="res://scenes/templates/plant_template.tscn" id="1_5i0e6"] [ext_resource type="Texture2D" uid="uid://dff73m8ahamaa" path="res://assets/sprites/atlases/plants/garlic.png" id="2_w2jbi"] @@ -27,6 +27,8 @@ _data = { &"RESET": SubResource("Animation_k0cex") } +[sub_resource type="AnimationNodeTimeScale" id="AnimationNodeTimeScale_2d3xk"] + [sub_resource type="AnimationNodeAnimation" id="AnimationNodeAnimation_mdv0r"] animation = &"garlic/full_hp" @@ -46,11 +48,19 @@ blend_point_2/pos = 0.3 min_space = 0.0 blend_mode = 1 +[sub_resource type="AnimationNodeBlendTree" id="AnimationNodeBlendTree_2o7sr"] +graph_offset = Vector2(-397, 76) +nodes/TimeScale/node = SubResource("AnimationNodeTimeScale_2d3xk") +nodes/TimeScale/position = Vector2(100, 160) +nodes/Tree/node = SubResource("AnimationNodeBlendSpace1D_8mvpm") +nodes/Tree/position = Vector2(-160, 200) +node_connections = [&"TimeScale", 0, &"Tree", &"output", 0, &"TimeScale"] + [sub_resource type="RectangleShape2D" id="RectangleShape2D_thlvs"] size = Vector2(32, 29) [node name="Garlic" instance=ExtResource("1_5i0e6")] -_maxHP = 200 +MaxHP = 200.0 [node name="Sprite2D" parent="." index="0"] texture = ExtResource("2_w2jbi") @@ -64,8 +74,9 @@ libraries = { } [node name="AnimationTree" parent="." index="2"] -tree_root = SubResource("AnimationNodeBlendSpace1D_8mvpm") -parameters/blend_position = 1.0 +tree_root = SubResource("AnimationNodeBlendTree_2o7sr") +parameters/TimeScale/scale = 1.0 +parameters/Tree/blend_position = 1.0 [node name="CollisionShape2D" type="CollisionShape2D" parent="Hitbox" index="0"] position = Vector2(1, 11.5) diff --git a/scenes/entities/plants/peashooter.tscn b/scenes/entities/plants/peashooter.tscn index 7ba01a0..853fb21 100644 --- a/scenes/entities/plants/peashooter.tscn +++ b/scenes/entities/plants/peashooter.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=21 format=3 uid="uid://dy41q1kxray5t"] +[gd_scene load_steps=24 format=3 uid="uid://dy41q1kxray5t"] [ext_resource type="PackedScene" uid="uid://b1hjjbdwf1rtc" path="res://scenes/templates/plant_template.tscn" id="1_pyk3o"] [ext_resource type="Texture2D" uid="uid://cksryh4w5dbbx" path="res://assets/sprites/atlases/plants/peashooter.png" id="2_14qlx"] @@ -6,6 +6,7 @@ [ext_resource type="Script" uid="uid://ceprqkraw3v6m" path="res://scripts/components/plants/Shooter.cs" id="3_a4ew1"] [ext_resource type="PackedScene" uid="uid://b2hrv0aqbui7u" path="res://scenes/projectiles/pea.tscn" id="4_saxds"] [ext_resource type="Script" uid="uid://bdk5iqtw4xbkl" path="res://scripts/components/plants/behaviours/PeashooterBehaviour.cs" id="5_7qiua"] +[ext_resource type="Script" uid="uid://c4jy0cnbnx33h" path="res://scripts/components/TimeScalableTimer.cs" id="6_q58jr"] [ext_resource type="Script" uid="uid://dn53jvpjyg63l" path="res://scripts/components/plants/Eyesight.cs" id="7_2bki8"] [ext_resource type="Script" uid="uid://hccb0aee0x0o" path="res://scripts/components/plants/PlantEyesightLimiter.cs" id="8_nl4jc"] [ext_resource type="Script" uid="uid://c36bj8u7jghc7" path="res://scripts/audio/ChannelPlayer.cs" id="9_mbbd7"] @@ -31,6 +32,8 @@ _data = { &"RESET": SubResource("Animation_a2y0j") } +[sub_resource type="AnimationNodeTimeScale" id="AnimationNodeTimeScale_mbbd7"] + [sub_resource type="AnimationNodeAnimation" id="AnimationNodeAnimation_34v85"] animation = &"peashooter/idle" @@ -55,6 +58,14 @@ states/peashooter_shoot/node = SubResource("AnimationNodeAnimation_u4o2k") states/peashooter_shoot/position = Vector2(674, 82) transitions = ["Start", "peashooter_idle", SubResource("AnimationNodeStateMachineTransition_70n3m"), "peashooter_idle", "peashooter_shoot", SubResource("AnimationNodeStateMachineTransition_2lwpg"), "peashooter_shoot", "peashooter_idle", SubResource("AnimationNodeStateMachineTransition_k61yr")] +[sub_resource type="AnimationNodeBlendTree" id="AnimationNodeBlendTree_q58jr"] +graph_offset = Vector2(-518.8, 27.8) +nodes/TimeScale/node = SubResource("AnimationNodeTimeScale_mbbd7") +nodes/TimeScale/position = Vector2(0, 120) +nodes/Tree/node = SubResource("AnimationNodeStateMachine_13o7y") +nodes/Tree/position = Vector2(-300, 120) +node_connections = [&"TimeScale", 0, &"Tree", &"output", 0, &"TimeScale"] + [sub_resource type="SegmentShape2D" id="SegmentShape2D_8iovl"] resource_local_to_scene = true @@ -62,6 +73,7 @@ resource_local_to_scene = true size = Vector2(20, 44) [node name="Peashooter" instance=ExtResource("1_pyk3o")] +MaxHP = 30.0 [node name="Sprite2D" parent="." index="0"] texture = ExtResource("2_14qlx") @@ -76,8 +88,9 @@ libraries = { autoplay = "peashooter/idle" [node name="AnimationTree" parent="." index="2"] -tree_root = SubResource("AnimationNodeStateMachine_13o7y") -parameters/conditions/ready = false +tree_root = SubResource("AnimationNodeBlendTree_q58jr") +parameters/TimeScale/scale = 1.0 +parameters/Tree/conditions/ready = false [node name="Shooter" type="Marker2D" parent="." index="3" node_paths=PackedStringArray("_timer")] position = Vector2(12, -4) @@ -85,9 +98,11 @@ script = ExtResource("3_a4ew1") _projectile = ExtResource("4_saxds") _timer = NodePath("Timer") -[node name="Timer" type="Timer" parent="Shooter" index="0"] +[node name="Timer" type="Timer" parent="Shooter" index="0" node_paths=PackedStringArray("entity")] wait_time = 1.5 one_shot = true +script = ExtResource("6_q58jr") +entity = NodePath("../..") [node name="Behaviour" type="Node" parent="." index="4" node_paths=PackedStringArray("_shootTimer", "_sight")] script = ExtResource("5_7qiua") diff --git a/scenes/entities/plants/potato_mine.tscn b/scenes/entities/plants/potato_mine.tscn index 03dee1e..c3cf489 100644 --- a/scenes/entities/plants/potato_mine.tscn +++ b/scenes/entities/plants/potato_mine.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=24 format=3 uid="uid://b5x35v3w2u8dx"] +[gd_scene load_steps=27 format=3 uid="uid://b5x35v3w2u8dx"] [ext_resource type="PackedScene" uid="uid://b1hjjbdwf1rtc" path="res://scenes/templates/plant_template.tscn" id="1_dj7ul"] [ext_resource type="Texture2D" uid="uid://c77o6ba0mw7a3" path="res://assets/sprites/atlases/plants/potato_mine.png" id="2_sneas"] @@ -8,8 +8,11 @@ [ext_resource type="PackedScene" uid="uid://ckanq33rao1ur" path="res://scenes/particles/potato_explosion.tscn" id="5_px4r0"] [ext_resource type="Script" uid="uid://c36bj8u7jghc7" path="res://scripts/audio/ChannelPlayer.cs" id="7_b1j2f"] [ext_resource type="AudioStream" uid="uid://dltjtpyfr1so0" path="res://assets/audio/sfx/potato_mine.mp3" id="8_3vqdc"] +[ext_resource type="Script" uid="uid://c4jy0cnbnx33h" path="res://scripts/components/TimeScalableTimer.cs" id="8_824aq"] [ext_resource type="AudioStream" uid="uid://b27om1bw1x04e" path="res://assets/audio/sfx/dirt_rise.mp3" id="9_3vqdc"] +[sub_resource type="AnimationNodeTimeScale" id="AnimationNodeTimeScale_3vqdc"] + [sub_resource type="AnimationNodeAnimation" id="AnimationNodeAnimation_6uutc"] animation = &"potato_mine/explode" @@ -55,6 +58,13 @@ states/potato_mine_prime/position = Vector2(490.656, 75.168) transitions = ["Start", "potato_mine_idle_unprimed", SubResource("AnimationNodeStateMachineTransition_ttnxb"), "potato_mine_idle_unprimed", "potato_mine_prime", SubResource("AnimationNodeStateMachineTransition_8nvnf"), "potato_mine_explode", "End", SubResource("AnimationNodeStateMachineTransition_q0arb"), "potato_mine_prime", "potato_mine_idle_primed", SubResource("AnimationNodeStateMachineTransition_dikhn"), "potato_mine_idle_primed", "potato_mine_explode", SubResource("AnimationNodeStateMachineTransition_lqd1d")] graph_offset = Vector2(-16.3438, -67.832) +[sub_resource type="AnimationNodeBlendTree" id="AnimationNodeBlendTree_824aq"] +nodes/TimeScale/node = SubResource("AnimationNodeTimeScale_3vqdc") +nodes/TimeScale/position = Vector2(100, 120) +nodes/Tree/node = SubResource("AnimationNodeStateMachine_nfn7b") +nodes/Tree/position = Vector2(-260, 140) +node_connections = [&"TimeScale", 0, &"Tree", &"output", 0, &"TimeScale"] + [sub_resource type="CircleShape2D" id="CircleShape2D_v0g5b"] radius = 19.0263 @@ -68,7 +78,7 @@ size = Vector2(15, 27) size = Vector2(34, 19) [node name="Potato mine" instance=ExtResource("1_dj7ul")] -_maxHP = 20 +MaxHP = 20.0 [node name="Sprite2D" parent="." index="0"] texture = ExtResource("2_sneas") @@ -83,9 +93,10 @@ libraries = { autoplay = "idle_unprimed" [node name="AnimationTree" parent="." index="2"] -tree_root = SubResource("AnimationNodeStateMachine_nfn7b") -parameters/conditions/explode = false -parameters/conditions/primed = false +tree_root = SubResource("AnimationNodeBlendTree_824aq") +parameters/TimeScale/scale = 1.0 +parameters/Tree/conditions/explode = false +parameters/Tree/conditions/primed = false [node name="Detectionbox" type="Area2D" parent="." index="3"] collision_layer = 0 @@ -112,10 +123,12 @@ audioStream = ExtResource("8_3vqdc") channel = "explosion" metadata/_custom_type_script = "uid://c36bj8u7jghc7" -[node name="PrimeTimer" type="Timer" parent="." index="5"] +[node name="PrimeTimer" type="Timer" parent="." index="5" node_paths=PackedStringArray("entity")] wait_time = 15.0 one_shot = true autostart = true +script = ExtResource("8_824aq") +entity = NodePath("..") [node name="Behaviour" type="Node" parent="." index="6" node_paths=PackedStringArray("_hitbox", "_unprimedShape", "_primedShape")] script = ExtResource("4_twx65") diff --git a/scenes/entities/plants/snowpea.tscn b/scenes/entities/plants/snowpea.tscn index eb784f2..97fd65c 100644 --- a/scenes/entities/plants/snowpea.tscn +++ b/scenes/entities/plants/snowpea.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=14 format=3 uid="uid://b7innrovtmf5u"] +[gd_scene load_steps=16 format=3 uid="uid://b7innrovtmf5u"] [ext_resource type="PackedScene" uid="uid://dy41q1kxray5t" path="res://scenes/entities/plants/peashooter.tscn" id="1_lp85e"] [ext_resource type="Texture2D" uid="uid://cu0651pvvkmvm" path="res://assets/sprites/atlases/plants/snow_pea.png" id="2_ytrm0"] @@ -25,6 +25,8 @@ _data = { &"RESET": SubResource("Animation_pephc") } +[sub_resource type="AnimationNodeTimeScale" id="AnimationNodeTimeScale_mbbd7"] + [sub_resource type="AnimationNodeAnimation" id="AnimationNodeAnimation_dv2ad"] animation = &"snowpea/idle" @@ -49,6 +51,14 @@ states/snowpea_shoot/node = SubResource("AnimationNodeAnimation_ptach") states/snowpea_shoot/position = Vector2(682, 100) transitions = ["snowpea_shoot", "snowpea_idle", SubResource("AnimationNodeStateMachineTransition_8spty"), "Start", "snowpea_idle", SubResource("AnimationNodeStateMachineTransition_lshcr"), "snowpea_idle", "snowpea_shoot", SubResource("AnimationNodeStateMachineTransition_ihul0")] +[sub_resource type="AnimationNodeBlendTree" id="AnimationNodeBlendTree_3oyhk"] +graph_offset = Vector2(-518.8, 27.8) +nodes/TimeScale/node = SubResource("AnimationNodeTimeScale_mbbd7") +nodes/TimeScale/position = Vector2(0, 120) +nodes/Tree/node = SubResource("AnimationNodeStateMachine_qdmro") +nodes/Tree/position = Vector2(-320, 100) +node_connections = [&"TimeScale", 0, &"Tree", &"output", 0, &"TimeScale"] + [sub_resource type="SegmentShape2D" id="SegmentShape2D_3oyhk"] resource_local_to_scene = true @@ -65,7 +75,7 @@ libraries = { autoplay = "snowpea/idle" [node name="AnimationTree" parent="." index="2"] -tree_root = SubResource("AnimationNodeStateMachine_qdmro") +tree_root = SubResource("AnimationNodeBlendTree_3oyhk") [node name="Shooter" parent="." index="3"] _projectile = ExtResource("5_bv86m") diff --git a/scenes/entities/plants/spikeweed.tscn b/scenes/entities/plants/spikeweed.tscn index 9b96cff..6c669a8 100644 --- a/scenes/entities/plants/spikeweed.tscn +++ b/scenes/entities/plants/spikeweed.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=10 format=3 uid="uid://bdhod5c6o53ha"] +[gd_scene load_steps=12 format=3 uid="uid://bdhod5c6o53ha"] [ext_resource type="PackedScene" uid="uid://b1hjjbdwf1rtc" path="res://scenes/templates/plant_template.tscn" id="1_vmbvr"] [ext_resource type="Texture2D" uid="uid://coafh3mjharxo" path="res://assets/sprites/atlases/plants/spikeweed.png" id="2_ffrjr"] @@ -6,6 +6,8 @@ [ext_resource type="AnimationLibrary" uid="uid://cen6ku4y01dyg" path="res://resources/animations/plants/spikeweed.res" id="3_nwshn"] [ext_resource type="Script" uid="uid://dqquodxaijmem" path="res://scripts/components/plants/behaviours/SpikeweedBehaviour.cs" id="3_uhpn7"] +[sub_resource type="AnimationNodeTimeScale" id="AnimationNodeTimeScale_jleqa"] + [sub_resource type="AnimationNodeAnimation" id="AnimationNodeAnimation_lmfqg"] animation = &"spikeweed/idle" @@ -22,10 +24,19 @@ snap = 1.0 value_label = "attack" blend_mode = 1 +[sub_resource type="AnimationNodeBlendTree" id="AnimationNodeBlendTree_63okc"] +graph_offset = Vector2(-318, 108) +nodes/TimeScale/node = SubResource("AnimationNodeTimeScale_jleqa") +nodes/TimeScale/position = Vector2(140, 140) +nodes/Tree/node = SubResource("AnimationNodeBlendSpace1D_1y7y3") +nodes/Tree/position = Vector2(-120, 180) +node_connections = [&"TimeScale", 0, &"Tree", &"output", 0, &"TimeScale"] + [sub_resource type="RectangleShape2D" id="RectangleShape2D_1di76"] size = Vector2(49, 38) [node name="Spikeweed" instance=ExtResource("1_vmbvr")] +MaxHP = 30.0 [node name="Sprite2D" parent="." index="0"] texture = ExtResource("2_ffrjr") @@ -39,8 +50,9 @@ libraries = { } [node name="AnimationTree" parent="." index="2"] -tree_root = SubResource("AnimationNodeBlendSpace1D_1y7y3") -parameters/blend_position = 0.0 +tree_root = SubResource("AnimationNodeBlendTree_63okc") +parameters/TimeScale/scale = 1.0 +parameters/Tree/blend_position = 0 [node name="Behaviour" type="Node" parent="." index="3" node_paths=PackedStringArray("_tree")] script = ExtResource("3_uhpn7") diff --git a/scenes/entities/plants/sunflower.tscn b/scenes/entities/plants/sunflower.tscn index 2f23a96..967f77c 100644 --- a/scenes/entities/plants/sunflower.tscn +++ b/scenes/entities/plants/sunflower.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=16 format=3 uid="uid://bg7lomiorxo2c"] +[gd_scene load_steps=19 format=3 uid="uid://bg7lomiorxo2c"] [ext_resource type="PackedScene" uid="uid://b1hjjbdwf1rtc" path="res://scenes/templates/plant_template.tscn" id="1_bikjn"] [ext_resource type="Texture2D" uid="uid://b3tuidu8dag8u" path="res://assets/sprites/atlases/plants/sunflower.png" id="2_fwcda"] @@ -6,13 +6,14 @@ [ext_resource type="Script" uid="uid://b71gebny84s81" path="res://scripts/components/plants/PlantSunSpawner.cs" id="3_te0pl"] [ext_resource type="PackedScene" uid="uid://bpekho7leatr5" path="res://scenes/sun.tscn" id="4_b8hls"] [ext_resource type="Script" uid="uid://bth7gah4tn7uj" path="res://scripts/components/plants/behaviours/SunflowerBehaviour.cs" id="5_26je0"] +[ext_resource type="Script" uid="uid://c4jy0cnbnx33h" path="res://scripts/components/TimeScalableTimer.cs" id="7_rlkb7"] [sub_resource type="Animation" id="Animation_bfx6v"] length = 0.001 tracks/0/type = "value" tracks/0/imported = false tracks/0/enabled = true -tracks/0/path = NodePath("AnimationTree:parameters/conditions/produce") +tracks/0/path = NodePath("AnimationTree:parameters/Tree/conditions/produce") tracks/0/interp = 1 tracks/0/loop_wrap = true tracks/0/keys = { @@ -27,6 +28,8 @@ _data = { &"RESET": SubResource("Animation_bfx6v") } +[sub_resource type="AnimationNodeTimeScale" id="AnimationNodeTimeScale_811ah"] + [sub_resource type="AnimationNodeAnimation" id="AnimationNodeAnimation_lkpmx"] animation = &"sunflower/idle" @@ -51,17 +54,24 @@ states/sunflower_produce/node = SubResource("AnimationNodeAnimation_hc6hn") states/sunflower_produce/position = Vector2(624, 99) transitions = ["Start", "sunflower_idle", SubResource("AnimationNodeStateMachineTransition_26fia"), "sunflower_idle", "sunflower_produce", SubResource("AnimationNodeStateMachineTransition_d2akw"), "sunflower_produce", "sunflower_idle", SubResource("AnimationNodeStateMachineTransition_sww40")] +[sub_resource type="AnimationNodeBlendTree" id="AnimationNodeBlendTree_rlkb7"] +graph_offset = Vector2(-437, 84) +nodes/TimeScale/node = SubResource("AnimationNodeTimeScale_811ah") +nodes/TimeScale/position = Vector2(100, 140) +nodes/Tree/node = SubResource("AnimationNodeStateMachine_enpal") +nodes/Tree/position = Vector2(-160, 180) +node_connections = [&"TimeScale", 0, &"Tree", &"output", 0, &"TimeScale"] + [sub_resource type="RectangleShape2D" id="RectangleShape2D_4xs4g"] size = Vector2(26, 48) [node name="Sunflower" instance=ExtResource("1_bikjn")] -_maxHP = 30 +MaxHP = 30.0 [node name="Sprite2D" parent="." index="0"] texture = ExtResource("2_fwcda") hframes = 9 vframes = 2 -frame = 1 [node name="AnimationPlayer" parent="." index="1"] libraries = { @@ -70,8 +80,9 @@ libraries = { } [node name="AnimationTree" parent="." index="2"] -tree_root = SubResource("AnimationNodeStateMachine_enpal") -parameters/conditions/produce = false +tree_root = SubResource("AnimationNodeBlendTree_rlkb7") +parameters/TimeScale/scale = 1.0 +parameters/Tree/conditions/produce = false [node name="PlantSunSpawner" type="Node2D" parent="." index="3"] position = Vector2(-2, 0) @@ -82,13 +93,17 @@ _amountPerSun = 25 [node name="Behaviour" type="Node" parent="." index="4"] script = ExtResource("5_26je0") -[node name="Timer" type="Timer" parent="Behaviour" index="0"] +[node name="Timer" type="Timer" parent="Behaviour" index="0" node_paths=PackedStringArray("entity")] wait_time = 24.25 +script = ExtResource("7_rlkb7") +entity = NodePath("../..") -[node name="StartTimer" type="Timer" parent="Behaviour" index="1"] +[node name="StartTimer" type="Timer" parent="Behaviour" index="1" node_paths=PackedStringArray("entity")] wait_time = 12.0 one_shot = true autostart = true +script = ExtResource("7_rlkb7") +entity = NodePath("../..") [node name="CollisionShape2D" type="CollisionShape2D" parent="Hitbox" index="0"] position = Vector2(0, 4) diff --git a/scenes/entities/plants/threepeater.tscn b/scenes/entities/plants/threepeater.tscn index f9fedb5..bae2cac 100644 --- a/scenes/entities/plants/threepeater.tscn +++ b/scenes/entities/plants/threepeater.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=18 format=3 uid="uid://eegv1qihfv2q"] +[gd_scene load_steps=20 format=3 uid="uid://eegv1qihfv2q"] [ext_resource type="PackedScene" uid="uid://dy41q1kxray5t" path="res://scenes/entities/plants/peashooter.tscn" id="1_muntu"] [ext_resource type="Script" uid="uid://djpc0kvagpadv" path="res://scripts/components/plants/ThreepeaterShooter.cs" id="2_ieami"] @@ -94,6 +94,8 @@ _data = { &"shoot": SubResource("Animation_7kfrv") } +[sub_resource type="AnimationNodeTimeScale" id="AnimationNodeTimeScale_mbbd7"] + [sub_resource type="AnimationNodeAnimation" id="AnimationNodeAnimation_j7h7q"] animation = &"threepeater/idle" @@ -118,6 +120,14 @@ states/threepeater_shoot/node = SubResource("AnimationNodeAnimation_pqbws") states/threepeater_shoot/position = Vector2(633, 91) transitions = ["Start", "threepeater_idle", SubResource("AnimationNodeStateMachineTransition_7kfrv"), "threepeater_idle", "threepeater_shoot", SubResource("AnimationNodeStateMachineTransition_o2obw"), "threepeater_shoot", "threepeater_idle", SubResource("AnimationNodeStateMachineTransition_wiys2")] +[sub_resource type="AnimationNodeBlendTree" id="AnimationNodeBlendTree_j7h7q"] +graph_offset = Vector2(-518.8, 27.8) +nodes/TimeScale/node = SubResource("AnimationNodeTimeScale_mbbd7") +nodes/TimeScale/position = Vector2(0, 120) +nodes/Tree/node = SubResource("AnimationNodeStateMachine_wiys2") +nodes/Tree/position = Vector2(-320, 100) +node_connections = [&"TimeScale", 0, &"Tree", &"output", 0, &"TimeScale"] + [sub_resource type="SegmentShape2D" id="SegmentShape2D_j7h7q"] resource_local_to_scene = true @@ -138,7 +148,7 @@ libraries = { } [node name="AnimationTree" parent="." index="2"] -tree_root = SubResource("AnimationNodeStateMachine_wiys2") +tree_root = SubResource("AnimationNodeBlendTree_j7h7q") [node name="Shooter" parent="." index="3"] position = Vector2(20, -9) diff --git a/scenes/entities/plants/wallnut.tscn b/scenes/entities/plants/wallnut.tscn index 84a0d9e..76e6f40 100644 --- a/scenes/entities/plants/wallnut.tscn +++ b/scenes/entities/plants/wallnut.tscn @@ -1,10 +1,12 @@ -[gd_scene load_steps=10 format=3 uid="uid://bq7imkpr2yqyr"] +[gd_scene load_steps=12 format=3 uid="uid://bq7imkpr2yqyr"] [ext_resource type="PackedScene" uid="uid://b1hjjbdwf1rtc" path="res://scenes/templates/plant_template.tscn" id="1_fluxn"] [ext_resource type="Texture2D" uid="uid://dstqh1wc5dvmo" path="res://assets/sprites/atlases/plants/wallnut.png" id="2_o5tda"] [ext_resource type="AnimationLibrary" uid="uid://0bdesb8j2mbo" path="res://resources/animations/plants/wallnut.res" id="3_xl65q"] [ext_resource type="Script" uid="uid://btkmd86pn828y" path="res://scripts/components/plants/behaviours/HpBasedBehaviour.cs" id="4_cjtyy"] +[sub_resource type="AnimationNodeTimeScale" id="AnimationNodeTimeScale_y3tlf"] + [sub_resource type="AnimationNodeAnimation" id="AnimationNodeAnimation_ds5ry"] animation = &"wallnut/idle_full" @@ -24,11 +26,19 @@ blend_point_2/pos = 0.3 min_space = 0.0 blend_mode = 1 +[sub_resource type="AnimationNodeBlendTree" id="AnimationNodeBlendTree_bi7an"] +graph_offset = Vector2(-498, 95) +nodes/TimeScale/node = SubResource("AnimationNodeTimeScale_y3tlf") +nodes/TimeScale/position = Vector2(60, 140) +nodes/Tree/node = SubResource("AnimationNodeBlendSpace1D_nij8v") +nodes/Tree/position = Vector2(-180, 180) +node_connections = [&"TimeScale", 0, &"Tree", &"output", 0, &"TimeScale"] + [sub_resource type="RectangleShape2D" id="RectangleShape2D_khltr"] size = Vector2(33, 46) [node name="Wallnut" instance=ExtResource("1_fluxn")] -_maxHP = 600 +MaxHP = 600.0 [node name="Sprite2D" parent="." index="0"] texture = ExtResource("2_o5tda") @@ -41,8 +51,9 @@ libraries = { } [node name="AnimationTree" parent="." index="2"] -tree_root = SubResource("AnimationNodeBlendSpace1D_nij8v") -parameters/blend_position = 1.0 +tree_root = SubResource("AnimationNodeBlendTree_bi7an") +parameters/TimeScale/scale = 1.0 +parameters/Tree/blend_position = 1.0 [node name="CollisionShape2D" type="CollisionShape2D" parent="Hitbox" index="0"] position = Vector2(3.5, 5) diff --git a/scenes/projectiles/snowpea_projectile.tscn b/scenes/projectiles/snowpea_projectile.tscn index 001c48a..bfde097 100644 --- a/scenes/projectiles/snowpea_projectile.tscn +++ b/scenes/projectiles/snowpea_projectile.tscn @@ -18,7 +18,6 @@ script = ExtResource("1_fkydi") _speed = 3.0 _damage = 10 _impactEffect = ExtResource("2_fn62x") -_damageType = 1 particles = ExtResource("3_t6hp0") [node name="Sprite" type="Sprite2D" parent="."] diff --git a/scenes/templates/plant_template.tscn b/scenes/templates/plant_template.tscn index 2266c6a..6404adc 100644 --- a/scenes/templates/plant_template.tscn +++ b/scenes/templates/plant_template.tscn @@ -1,18 +1,20 @@ -[gd_scene load_steps=2 format=3 uid="uid://b1hjjbdwf1rtc"] +[gd_scene load_steps=3 format=3 uid="uid://b1hjjbdwf1rtc"] [ext_resource type="Script" uid="uid://dli2i6albvugt" path="res://scripts/components/plants/RuntimePlantData.cs" id="1_324sd"] +[ext_resource type="Script" uid="uid://dwlwi42smgxkb" path="res://scripts/components/TimeScalableAnimationTree.cs" id="2_e75pf"] [node name="PlantTemplate" type="Node2D"] script = ExtResource("1_324sd") -_maxHP = 30 [node name="Sprite2D" type="Sprite2D" parent="."] use_parent_material = true [node name="AnimationPlayer" type="AnimationPlayer" parent="."] -[node name="AnimationTree" type="AnimationTree" parent="."] +[node name="AnimationTree" type="AnimationTree" parent="." node_paths=PackedStringArray("entity")] anim_player = NodePath("../AnimationPlayer") +script = ExtResource("2_e75pf") +entity = NodePath("..") [node name="Hitbox" type="Area2D" parent="."] collision_layer = 2 diff --git a/scripts/audio/EffectBasedPlayer.cs b/scripts/audio/EffectBasedPlayer.cs new file mode 100644 index 0000000..786d853 --- /dev/null +++ b/scripts/audio/EffectBasedPlayer.cs @@ -0,0 +1,29 @@ +using Godot; +using Godot.Collections; +using System.Collections.Generic; +using Newlon.Components; +using Newlon.Systems.Effects; + +public partial class EffectBasedPlayer : Node +{ + [Export] public Array effectsToMap; + [Export] public Array streamsToMapTo; + [Export] public Array streamSettings; + private System.Collections.Generic.Dictionary effectToAudioMap = new(); + public override void _Ready() + { + GetParent().EffectStarted += OnEffectStarted; + + for (int i = 0; i < effectsToMap.Count; i++) + { + effectToAudioMap.Add(effectsToMap[i], (streamsToMapTo[i],streamSettings[i])); + } + } + + public void OnEffectStarted(Effect what) + { + if (effectToAudioMap.ContainsKey(what) == false) return; + AudioSequencer.Play(what.Slot, effectToAudioMap[what].Item1); + AudioSequencer.ChangeSettings(what.Slot, effectToAudioMap[what].Item2); + } +} diff --git a/scripts/audio/EffectBasedPlayer.cs.uid b/scripts/audio/EffectBasedPlayer.cs.uid new file mode 100644 index 0000000..ed55549 --- /dev/null +++ b/scripts/audio/EffectBasedPlayer.cs.uid @@ -0,0 +1 @@ +uid://b8r6fxsfjdo3a diff --git a/scripts/components/Armor.cs b/scripts/components/Armor.cs index 4326ff0..7e8ba22 100644 --- a/scripts/components/Armor.cs +++ b/scripts/components/Armor.cs @@ -6,13 +6,13 @@ namespace Newlon.Components; public partial class Armor : Node { [Signal] - public delegate void ArmorDamagedEventHandler(int hp); + public delegate void ArmorDamagedEventHandler(float hp); [Signal] public delegate void ArmorLostEventHandler(); [Export] - public int MaxHP { get; private set; } - private int _hp; + public float MaxHP { get; private set; } + private float _hp; private bool _lost = false; public override void _Ready() @@ -20,11 +20,11 @@ public partial class Armor : Node _hp = MaxHP; } - public int RecieveDamage(int damage) + public float RecieveDamage(float damage) { if(_lost) return damage; - int returnAmount = 0; + float returnAmount = 0; _hp -= damage; if(_hp <= 0) { @@ -37,11 +37,11 @@ public partial class Armor : Node return returnAmount; } - public int Heal(int amount) + public float Heal(float amount) { if(_lost) return amount; - int returnAmount = 0; + float returnAmount = 0; _hp += amount; if (_hp >= MaxHP) { diff --git a/scripts/components/DegradingSprite.cs b/scripts/components/DegradingSprite.cs index baa5e8f..3c28adc 100644 --- a/scripts/components/DegradingSprite.cs +++ b/scripts/components/DegradingSprite.cs @@ -14,9 +14,9 @@ public partial class DegradingSprite : Sprite2D armor.ArmorDamaged += OnZombieHPChanged; } - private void OnZombieHPChanged(int hp) + private void OnZombieHPChanged(float hp) { - float percent = (float)hp / (float)armor.MaxHP; + float percent = hp / armor.MaxHP; for (int i = 0; i < degradationStages.Count; i++) { if (percent <= thresholdPercentage[i]) diff --git a/scripts/components/Entity.cs b/scripts/components/Entity.cs new file mode 100644 index 0000000..01e4254 --- /dev/null +++ b/scripts/components/Entity.cs @@ -0,0 +1,156 @@ +using Godot; +using Godot.Collections; +using Newlon.Systems.Effects; + +namespace Newlon.Components; + +[GlobalClass] +public partial class Entity : Node2D +{ + #region Health points + [Export] public float MaxHP; + public float HP; + [Signal] public delegate void OnHPChangedEventHandler(int deltaHP, Node origin); + [Signal] public delegate void OnDamagedEventHandler(); + + public virtual void TakeDamage(float amount, Node origin) + { + HP -= amount; + EmitSignal(SignalName.OnHPChanged, -amount, origin); + EmitSignal(SignalName.OnDamaged); + if (HP <= 0) + { + KillByDamage(); + } + } + + public virtual void Heal(float amount, Node origin) + { + EmitSignal(SignalName.OnHPChanged, amount, origin); + HP += amount; + } + + public virtual void KillByDamage() + { + Kill(); + } + + public virtual void Kill() + { + QueueFree(); + } + + + #endregion + #region Brain + public virtual void DisableBrain() + { + GetNode("AnimationPlayer").ProcessMode = ProcessModeEnum.Always; + GetNode("AnimationTree").ProcessMode = ProcessModeEnum.Always; + ProcessMode = ProcessModeEnum.Disabled; + } + + public virtual void EnableBrain() + { + GetNode("AnimationPlayer").ProcessMode = ProcessModeEnum.Inherit; + GetNode("AnimationTree").ProcessMode = ProcessModeEnum.Inherit; + ProcessMode = ProcessModeEnum.Inherit; + } + #endregion + #region Effects + [Export] private Array _effectImmunities = new(); + private readonly Dictionary _activeEffectSlots = new(); + private readonly Dictionary _effectSlotTimers = new(); + + [Signal] public delegate void EffectStartedEventHandler(Effect what); + [Signal] public delegate void EffectEndedEventHandler(Effect what); + [Signal] public delegate void EffectContinuedEventHandler(Effect what); + + + public virtual void GiveEffect(Effect what) + { + if (_effectImmunities.Contains(what)) + { + return; + } + + string slot = what.Slot; + if (_activeEffectSlots.ContainsKey(slot) == false) + { + InitSlot(slot); + } + + if (what == _activeEffectSlots[slot]) + { + EmitSignal(SignalName.EffectContinued, what); + } + else + { + EmitSignal(SignalName.EffectStarted, what); + } + + if (_activeEffectSlots[slot] != null) + { + _effectSlotTimers[slot].Stop(); + _activeEffectSlots[slot].Exit(this); + } + _effectSlotTimers[slot].WaitTime = what.Duration; + _effectSlotTimers[slot].Start(); + + what.Enter(this); + _activeEffectSlots[slot] = what; + + } + + private void InitSlot(string key) + { + _activeEffectSlots.Add(key, null); + + var timer = new Timer() { Autostart = false, OneShot = true }; + AddChild(timer); + timer.Timeout += () => { EndEffectAtSlot(key); }; + + _effectSlotTimers.Add(key, timer); + + } + + public void EndEffect(Effect what) + { + EndEffectAtSlot(what.Slot); + } + + public void ProcessEffects() + { + foreach (string key in _activeEffectSlots.Keys) + _activeEffectSlots[key]?.Process(this); + } + + private void EndEffectAtSlot(string slot) + { + _activeEffectSlots[slot].Exit(this); + _activeEffectSlots[slot] = null; + + EmitSignal(SignalName.EffectEnded, _activeEffectSlots[slot]); + + } + #endregion + #region LocalTimescale + private float _localTimescale = 1.0f; + [Signal] public delegate void OnLocalTimescaleChangedEventHandler(float scale); + public float LocalTimescale + { + get => _localTimescale; + set + { + _localTimescale = value; + EmitSignal(SignalName.OnLocalTimescaleChanged, _localTimescale); + } + } + #endregion + #region Godot overrides + public override void _Ready() + { + HP = MaxHP; + } + #endregion +} diff --git a/scripts/components/Entity.cs.uid b/scripts/components/Entity.cs.uid new file mode 100644 index 0000000..c9ca417 --- /dev/null +++ b/scripts/components/Entity.cs.uid @@ -0,0 +1 @@ +uid://3tw88wj1nrj1 diff --git a/scripts/components/IEntity.cs b/scripts/components/IEntity.cs deleted file mode 100644 index 7446c70..0000000 --- a/scripts/components/IEntity.cs +++ /dev/null @@ -1,17 +0,0 @@ -using Godot; - -namespace Newlon.Components; - -// -// Base interface for entities -// -public interface IEntity -{ - public int Hp { get; } - public int MaxHp { get; } - public void TakeDamage(int amount, Node origin, Utility.DamageTypes damageType = Utility.DamageTypes.PHYSICAL); - public void Heal(int amount, Node origin); - public void DisableBrain(); - public void EnableBrain(); -} - \ No newline at end of file diff --git a/scripts/components/IEntity.cs.uid b/scripts/components/IEntity.cs.uid deleted file mode 100644 index c16d5f4..0000000 --- a/scripts/components/IEntity.cs.uid +++ /dev/null @@ -1 +0,0 @@ -uid://cjdeq452vk2ll diff --git a/scripts/components/ILocalTimescale.cs b/scripts/components/ILocalTimescale.cs deleted file mode 100644 index e60865a..0000000 --- a/scripts/components/ILocalTimescale.cs +++ /dev/null @@ -1,6 +0,0 @@ -namespace Newlon.Components; - -public interface ILocalTimescale -{ - public float LocalTimescale { get; set; } -} \ No newline at end of file diff --git a/scripts/components/ILocalTimescale.cs.uid b/scripts/components/ILocalTimescale.cs.uid deleted file mode 100644 index 48a6d9b..0000000 --- a/scripts/components/ILocalTimescale.cs.uid +++ /dev/null @@ -1 +0,0 @@ -uid://bxu6ljkmmlgd5 diff --git a/scripts/components/LinearProjectile.cs b/scripts/components/LinearProjectile.cs index 156c486..f9ad5c0 100644 --- a/scripts/components/LinearProjectile.cs +++ b/scripts/components/LinearProjectile.cs @@ -17,8 +17,6 @@ public partial class LinearProjectile : Area2D, IProjectile [Export] private Effect _impactEffect; [Export] - private Utility.DamageTypes _damageType = Utility.DamageTypes.PHYSICAL; - [Export] private PackedScene particles; private int _line; private bool used = false; @@ -33,13 +31,13 @@ public partial class LinearProjectile : Area2D, IProjectile public void OnAreaEntered(Area2D area) { if (used == true) return; - var entity = area.GetParent(); + var entity = area.GetParent(); if (entity != null) { - entity.TakeDamage(_damage,this,_damageType); + entity.TakeDamage(_damage,this); used = true; - if (entity is IEffectHandler effectHandler && _impactEffect != null) - effectHandler.GiveEffect(_impactEffect); + if (_impactEffect != null) + entity.GiveEffect(_impactEffect); PoolContainer.Instance.SpawnParticles(particles, GlobalPosition); diff --git a/scripts/components/TimeScalableAnimationTree.cs b/scripts/components/TimeScalableAnimationTree.cs new file mode 100644 index 0000000..e7206cd --- /dev/null +++ b/scripts/components/TimeScalableAnimationTree.cs @@ -0,0 +1,17 @@ +using Godot; + +namespace Newlon.Components; + +public partial class TimeScalableAnimationTree : AnimationTree +{ + [Export] private Entity entity; + public override void _Ready() + { + entity.OnLocalTimescaleChanged += OnTimescaleChanged; + } + + private void OnTimescaleChanged(float timescale) + { + Set("parameters/TimeScale/scale", timescale); + } +} diff --git a/scripts/components/TimeScalableAnimationTree.cs.uid b/scripts/components/TimeScalableAnimationTree.cs.uid new file mode 100644 index 0000000..f44c2c0 --- /dev/null +++ b/scripts/components/TimeScalableAnimationTree.cs.uid @@ -0,0 +1 @@ +uid://dwlwi42smgxkb diff --git a/scripts/components/TimeScalableTimer.cs b/scripts/components/TimeScalableTimer.cs new file mode 100644 index 0000000..a6e5c51 --- /dev/null +++ b/scripts/components/TimeScalableTimer.cs @@ -0,0 +1,21 @@ +using Godot; + +namespace Newlon.Components; + +public partial class TimeScalableTimer : Timer +{ + [Export] private Entity entity; + + private float internal_timescale; + public override void _Ready() + { + internal_timescale = entity.LocalTimescale; + entity.OnLocalTimescaleChanged += OnTimescaleChanged; + } + + private void OnTimescaleChanged(float timescale) + { + WaitTime *= internal_timescale / timescale; + internal_timescale = timescale; + } +} diff --git a/scripts/components/TimeScalableTimer.cs.uid b/scripts/components/TimeScalableTimer.cs.uid new file mode 100644 index 0000000..5e713e2 --- /dev/null +++ b/scripts/components/TimeScalableTimer.cs.uid @@ -0,0 +1 @@ +uid://c4jy0cnbnx33h diff --git a/scripts/components/gui/choose_your_seeds/Previewport.cs b/scripts/components/gui/choose_your_seeds/Previewport.cs index bb90799..71a1709 100644 --- a/scripts/components/gui/choose_your_seeds/Previewport.cs +++ b/scripts/components/gui/choose_your_seeds/Previewport.cs @@ -44,7 +44,7 @@ public partial class Previewport : SubViewport title.Text = Tr(resource.name_key); description.Text = Tr(resource.description_key); AddChild(current_display); - if (current_display is IEntity entity) + if (current_display is Entity entity) entity.DisableBrain(); } diff --git a/scripts/components/level/PoolContainer.cs b/scripts/components/level/PoolContainer.cs index 2714860..b5765fd 100644 --- a/scripts/components/level/PoolContainer.cs +++ b/scripts/components/level/PoolContainer.cs @@ -23,12 +23,12 @@ public partial class PoolContainer : Node2D public static PoolContainer Instance { get; private set; } - public Dictionary[] EntityField = { new(), new(), new() }; + public Dictionary[] EntityField = { new(), new(), new() }; public override void _Ready() { Instance = this; } - public bool TryGetEntity(Vector2 key, out IEntity result, int layer = 1) + public bool TryGetEntity(Vector2 key, out Entity result, int layer = 1) { if (EntityField[layer].ContainsKey(key)) { diff --git a/scripts/components/plants/Eyesight.cs b/scripts/components/plants/Eyesight.cs index 7922358..2480476 100644 --- a/scripts/components/plants/Eyesight.cs +++ b/scripts/components/plants/Eyesight.cs @@ -7,7 +7,7 @@ public partial class Eyesight : Area2D { private bool _enemyDetected; public bool EnemyDetected => _enemyDetected; - private readonly List _detectedEntities = new List(); + private readonly List _detectedEntities = new List(); private RuntimePlantData _plantData; public override void _Ready() @@ -19,7 +19,7 @@ public partial class Eyesight : Area2D public void OnAreaEntered(Area2D area) { - var entity = area.GetParent(); + var entity = area.GetParent(); if (entity != null) { _detectedEntities.Add(entity); @@ -30,7 +30,7 @@ public partial class Eyesight : Area2D public void OnAreaExited(Area2D area) { - var entity = area.GetParent(); + var entity = area.GetParent(); if (entity != null) { if (_detectedEntities.Contains(entity)) diff --git a/scripts/components/plants/LoseZone.cs b/scripts/components/plants/LoseZone.cs index 53e71fa..18ab886 100644 --- a/scripts/components/plants/LoseZone.cs +++ b/scripts/components/plants/LoseZone.cs @@ -4,10 +4,11 @@ namespace Newlon.Components.Plants; public partial class LoseZone : RuntimePlantData { - public override void TakeDamage(int amount, Node origin, Utility.DamageTypes damageType = Utility.DamageTypes.PHYSICAL) - { + public override void TakeDamage(float amount, Node origin) + { + + } - } public override void Kill() { diff --git a/scripts/components/plants/ReturnEffect.cs b/scripts/components/plants/ReturnEffect.cs index 149e8b5..c481de1 100644 --- a/scripts/components/plants/ReturnEffect.cs +++ b/scripts/components/plants/ReturnEffect.cs @@ -11,6 +11,7 @@ public partial class ReturnEffect : Node public void OnDamageRecieved(int delta,Node origin) { + if (delta >= 0) return; if (origin is RuntimeZombieData zombie) { zombie.GiveEffect(_effectToReturn); diff --git a/scripts/components/plants/RuntimePlantData.cs b/scripts/components/plants/RuntimePlantData.cs index ce189c5..6968e5d 100644 --- a/scripts/components/plants/RuntimePlantData.cs +++ b/scripts/components/plants/RuntimePlantData.cs @@ -7,64 +7,19 @@ namespace Newlon.Components.Plants; // Data that plant stores during runtime // -public partial class RuntimePlantData : Node2D, IEntity +public partial class RuntimePlantData : Entity { - [Export] - private int _maxHP; - private int _hp; - public int Hp => _hp; - public int MaxHp => _maxHP; public int Line { get; set; } public PlantResource Resource; - - private AudioStream eatenSound; - - [Signal] - public delegate void OnHPChangedEventHandler(int amount, Node origin); - - public override void _Ready() + private AudioStream eatenSound = ResourceLoader.Load("res://assets/audio/sfx/gulp.mp3"); + public override void KillByDamage() { - _hp = _maxHP; - eatenSound = ResourceLoader.Load("res://assets/audio/sfx/gulp.mp3"); + AudioSequencer.Play("plant_eaten", eatenSound); + base.KillByDamage(); } - - public virtual void Heal(int amount, Node origin) - { - _hp += amount; - - EmitSignal(SignalName.OnHPChanged, amount, origin); - - if (MaxHp > 0) - { - _hp = MaxHp; - } - } - - public virtual void TakeDamage(int amount, Node origin, Utility.DamageTypes damageType = Utility.DamageTypes.PHYSICAL) - { - _hp -= amount; - - EmitSignal(SignalName.OnHPChanged, -amount, origin); - - if (_hp <= 0) - { - Kill(); - AudioSequencer.Play("plant_eaten", eatenSound); - } - } - public virtual void Kill() + public override void Kill() { PoolContainer.Instance.EntityField[Resource.Layer].Remove(GlobalPosition); QueueFree(); } - - public virtual void DisableBrain() - { - GetNode("Behaviour").ProcessMode = ProcessModeEnum.Disabled; - } - - public virtual void EnableBrain() - { - GetNode("Behaviour").ProcessMode = ProcessModeEnum.Inherit; - } } diff --git a/scripts/components/plants/behaviours/AloeBehaviour.cs b/scripts/components/plants/behaviours/AloeBehaviour.cs index 323f8ab..3186709 100644 --- a/scripts/components/plants/behaviours/AloeBehaviour.cs +++ b/scripts/components/plants/behaviours/AloeBehaviour.cs @@ -17,15 +17,15 @@ public partial class AloeBehaviour : BaseBehaviour public override void _Process(double delta) { - _tree.Set("parameters/conditions/charged",_charge); + _tree.Set("parameters/Tree/conditions/charged",_charge); var checkPos = GetParent().GlobalPosition + Vector2.Right * Utility.TileWidth; if(_charge && PoolContainer.Instance.TryGetEntity(checkPos, out RuntimePlantData plantData)) { - if((float)plantData.Hp / (float)plantData.MaxHp < _hpTreshold) + if((float)plantData.HP / (float)plantData.MaxHP < _hpTreshold) { _charge = false; - _tree.Set("parameters/conditions/heal",true); + _tree.Set("parameters/Tree/conditions/heal",true); _timer.Start(); } } @@ -36,7 +36,7 @@ public partial class AloeBehaviour : BaseBehaviour var checkPos = GetParent().GlobalPosition + Vector2.Right * Utility.TileWidth; if (PoolContainer.Instance.TryGetEntity(checkPos, out RuntimePlantData plantData)) { - plantData.Heal(3000 + 25 * plantData.MaxHp, GetParent()); + plantData.Heal(3000 + 25 * plantData.MaxHP, GetParent()); } } diff --git a/scripts/components/plants/behaviours/HpBasedBehaviour.cs b/scripts/components/plants/behaviours/HpBasedBehaviour.cs index d49af31..4c7fe1e 100644 --- a/scripts/components/plants/behaviours/HpBasedBehaviour.cs +++ b/scripts/components/plants/behaviours/HpBasedBehaviour.cs @@ -13,6 +13,6 @@ public partial class HpBasedBehaviour : BaseBehaviour public void OnHPChanged(int amount,Node origin) { - _tree.Set("parameters/blend_position",(float)_data.Hp/_data.MaxHp); + _tree.Set("parameters/Tree/blend_position",(float)_data.HP/_data.MaxHP); } } diff --git a/scripts/components/plants/behaviours/PeashooterBehaviour.cs b/scripts/components/plants/behaviours/PeashooterBehaviour.cs index be36c8e..71d0568 100644 --- a/scripts/components/plants/behaviours/PeashooterBehaviour.cs +++ b/scripts/components/plants/behaviours/PeashooterBehaviour.cs @@ -11,6 +11,6 @@ public partial class PeashooterBehaviour : BaseBehaviour { bool readyToShoot = _sight.EnemyDetected && _shootTimer.TimeLeft <= 0; - _tree.Set("parameters/conditions/ready",readyToShoot); + _tree.Set("parameters/Tree/conditions/ready",readyToShoot); } } diff --git a/scripts/components/plants/behaviours/PotatomineBehaviour.cs b/scripts/components/plants/behaviours/PotatomineBehaviour.cs index 75c38c3..8f16553 100644 --- a/scripts/components/plants/behaviours/PotatomineBehaviour.cs +++ b/scripts/components/plants/behaviours/PotatomineBehaviour.cs @@ -10,7 +10,7 @@ public partial class PotatomineBehaviour : BaseBehaviour private bool _primed = false; public void Prime() { - _tree.Set("parameters/conditions/primed",true); + _tree.Set("parameters/Tree/conditions/primed",true); _hitbox.Monitorable = false; @@ -22,7 +22,7 @@ public partial class PotatomineBehaviour : BaseBehaviour public void OnAreaEntered(Area2D area) { if (_primed == false) return; - _tree.Set("parameters/conditions/explode",true); + _tree.Set("parameters/Tree/conditions/explode",true); _primed = false; } } diff --git a/scripts/components/plants/behaviours/SpikeweedBehaviour.cs b/scripts/components/plants/behaviours/SpikeweedBehaviour.cs index 7e4d3e6..2569966 100644 --- a/scripts/components/plants/behaviours/SpikeweedBehaviour.cs +++ b/scripts/components/plants/behaviours/SpikeweedBehaviour.cs @@ -2,20 +2,18 @@ using Godot; namespace Newlon.Components.Plants.Behaviours; -public partial class SpikeweedBehaviour : Node +public partial class SpikeweedBehaviour : BaseBehaviour { - [Export] private AnimationTree _tree; - private int _inCount = 0; public void OnHitboxEntered(Area2D _area) { if (_inCount++ == 0) - _tree.Set("parameters/blend_position",1); + _tree.Set("parameters/Tree/blend_position",1); } public void OnHitboxExited(Area2D _area) { if (--_inCount == 0) - _tree.Set("parameters/blend_position",0); + _tree.Set("parameters/Tree/blend_position",0); } } diff --git a/scripts/components/plants/behaviours/SunflowerBehaviour.cs b/scripts/components/plants/behaviours/SunflowerBehaviour.cs index 8672ac9..b01d703 100644 --- a/scripts/components/plants/behaviours/SunflowerBehaviour.cs +++ b/scripts/components/plants/behaviours/SunflowerBehaviour.cs @@ -2,18 +2,11 @@ using Godot; namespace Newlon.Components.Plants.Behaviours; -public partial class SunflowerBehaviour : Node +public partial class SunflowerBehaviour : BaseBehaviour { - private AnimationTree _tree; - - public override void _Ready() - { - _tree = GetNode("../AnimationTree"); - } - public void Timeout() { - _tree.Set("parameters/conditions/produce", true); + _tree.Set("parameters/Tree/conditions/produce", true); } } diff --git a/scripts/components/zombies/RuntimeZombieData.cs b/scripts/components/zombies/RuntimeZombieData.cs index e0fcef0..bf4a64a 100644 --- a/scripts/components/zombies/RuntimeZombieData.cs +++ b/scripts/components/zombies/RuntimeZombieData.cs @@ -1,162 +1,48 @@ -using System.Collections.Generic; using Godot; -using Newlon.Systems.Effects; namespace Newlon.Components.Zombies; -public partial class RuntimeZombieData : Node2D, IEntity, ILocalTimescale, IEffectHandler +public partial class RuntimeZombieData : Entity { - [Signal] - public delegate void OnHPChangedEventHandler(int deltaHP, Node origin); - [Signal] - public delegate void OnDamagedEventHandler(); - - [Signal] - public delegate void OnLocalTimescaleChangedEventHandler(int currentTimescale); - - [Export] - private int _hp; - [Export] - private int _maxHP; [Export] private Armor _armor; - [Export] private AudioStream garlicSound; [Export] private AudioStream freezeSound; - - - private float _localTimescale = 1.0f; - public int Hp => _hp; - - public int MaxHp => _maxHP; - public bool AbleToEat = true; - public float LocalTimescale - { - get => _localTimescale; - set - { - _localTimescale = value; - EmitSignal(SignalName.OnLocalTimescaleChanged,_localTimescale); - } - } - - public override void _Ready() - { - _hp = _maxHP; - - // Effect timers setup - for(int i = 0; i < Utility.EffectSlotCount; i++) - { - var timer = new Timer() {Autostart = false, OneShot = true}; - _effectSlotTimers[i] = timer; - AddChild(timer); - int current_index = i; - timer.Timeout += () => {EndEffectAtSlot(current_index);}; - } - } - - public void Heal(int amount,Node origin) - { - if(_armor != null) - { - _hp += _armor.Heal(amount); - } - else - _hp += amount; - EmitSignal(SignalName.OnHPChanged,amount,origin); - - if (MaxHp > 0) - { - _hp = MaxHp; - } - } - - public void TakeDamage(int amount, Node origin, Utility.DamageTypes damageType = Utility.DamageTypes.PHYSICAL) + public override void Heal(float amount, Node origin) { if (_armor != null) { - _hp -= _armor.RecieveDamage(amount); + HP += _armor.Heal(amount); } else - _hp -= amount; - EmitSignal(SignalName.OnHPChanged,-amount, origin); + HP += amount; + EmitSignal(SignalName.OnHPChanged, amount, origin); + + if (HP > MaxHP) + { + HP = MaxHP; + } + } + + public override void TakeDamage(float amount, Node origin) + { + if (_armor != null) + { + HP -= _armor.RecieveDamage(amount); + } + else + HP -= amount; + EmitSignal(SignalName.OnHPChanged, -amount, origin); EmitSignal(SignalName.OnDamaged); - if (_hp <= 0) + if (HP <= 0) { - QueueFree(); + KillByDamage(); } } - #region Effects system - private readonly Effect[] _activeEffectSlots = new Effect[Utility.EffectSlotCount]; - private readonly Timer[] _effectSlotTimers = new Timer[Utility.EffectSlotCount]; - - // Effect handling - - public void GiveEffect(Effect what) - { - int slot = (int)what.Slot; - if (_activeEffectSlots[slot] == null) - { - switch (what.Slot) - { - case Utility.EffectSlots.FREEZE: - AudioSequencer.Play("zombie_freeze", freezeSound); - var settings = new ChannelSettings(); - settings.restartTreshold = -1; - AudioSequencer.ChangeSettings("zombie_freeze",settings); - break; - case Utility.EffectSlots.GARLIC: - AudioSequencer.Play("zombie_garlic", garlicSound); - - break; - } - } - if (_activeEffectSlots[slot] != null) - { - _effectSlotTimers[slot].Stop(); - _activeEffectSlots[slot].Exit(this); - } - _effectSlotTimers[slot].WaitTime = what.Duration; - _effectSlotTimers[slot].Start(); - - what.Enter(this); - _activeEffectSlots[slot] = what; - } - - public void EndEffect(Effect what) - { - what.Exit(this); - _activeEffectSlots[(int)what.Slot] = null; - } - - public void ProcessEffects() - { - for(int i = 0; i < Utility.EffectSlotCount; i++) - _activeEffectSlots[i]?.Process(this); - } - - private void EndEffectAtSlot(int slot) - { - _activeEffectSlots[slot].Exit(this); - _activeEffectSlots[slot] = null; - } - - public void DisableBrain() - { - GetNode("AnimationPlayer").ProcessMode = ProcessModeEnum.Pausable; - ProcessMode = ProcessModeEnum.Disabled; - } - - public void EnableBrain() - { - GetNode("AnimationPlayer").ProcessMode = ProcessModeEnum.Inherit; - ProcessMode = ProcessModeEnum.Inherit; - } - #endregion } diff --git a/scripts/components/zombies/behaviours/HoboBehaviour.cs b/scripts/components/zombies/behaviours/HoboBehaviour.cs index 86cc9a6..dd0dd8d 100644 --- a/scripts/components/zombies/behaviours/HoboBehaviour.cs +++ b/scripts/components/zombies/behaviours/HoboBehaviour.cs @@ -11,8 +11,7 @@ public partial class HoboBehaviour : Node public void Trashed() { canDestroyed = true; - ((AnimationNodeStateMachinePlayback)_animationTree.Get("parameters/playback")).Travel("hobo_zombie_can_destroy"); - _animationTree.Set("parameters/eat_Tree/blend/blend_amount", 1.0); + ((AnimationNodeStateMachinePlayback)_animationTree.Get("parameters/Tree/playback")).Travel("hobo_zombie_can_destroy"); _eatBox._damage.SetMult(3.0f); } } diff --git a/scripts/systems/effects/Effect.cs b/scripts/systems/effects/Effect.cs index 43d6e0e..aa80f70 100644 --- a/scripts/systems/effects/Effect.cs +++ b/scripts/systems/effects/Effect.cs @@ -5,7 +5,7 @@ namespace Newlon.Systems.Effects; public abstract partial class Effect : Resource { [Export] public float Duration; - [Export] public Utility.EffectSlots Slot; + [Export] public string Slot; public abstract void Enter(Node target); public abstract void Process(Node target); public abstract void Exit(Node target); diff --git a/scripts/systems/effects/IEffectHandler.cs b/scripts/systems/effects/IEffectHandler.cs deleted file mode 100644 index 6c9b758..0000000 --- a/scripts/systems/effects/IEffectHandler.cs +++ /dev/null @@ -1,8 +0,0 @@ -namespace Newlon.Systems.Effects; - -public interface IEffectHandler -{ - void GiveEffect(Effect what); - void EndEffect(Effect what); - void ProcessEffects(); -} \ No newline at end of file diff --git a/scripts/systems/effects/IEffectHandler.cs.uid b/scripts/systems/effects/IEffectHandler.cs.uid deleted file mode 100644 index 8c581ef..0000000 --- a/scripts/systems/effects/IEffectHandler.cs.uid +++ /dev/null @@ -1 +0,0 @@ -uid://eeqk3fvjwg31 diff --git a/scripts/systems/effects/SlownessEffect.cs b/scripts/systems/effects/SlownessEffect.cs index 1491a2c..19d7a4e 100644 --- a/scripts/systems/effects/SlownessEffect.cs +++ b/scripts/systems/effects/SlownessEffect.cs @@ -11,21 +11,20 @@ public partial class SlownessEffect : Effect public override void Enter(Node target) { - if (target is IEffectHandler handler) + if (target is Entity entity) { - if (target is ILocalTimescale timescalable) - timescalable.LocalTimescale *= Multiplier; - if (target is CanvasItem canvasItem) - canvasItem.Modulate = ColorOverride; + entity.LocalTimescale *= Multiplier; + entity.Modulate = ColorOverride; } } public override void Exit(Node target) { - if(target is ILocalTimescale timescalable) - timescalable.LocalTimescale /= Multiplier; - if(target is CanvasItem canvasItem) - canvasItem.Modulate = Colors.White; + if (target is Entity entity) + { + entity.LocalTimescale /= Multiplier; + entity.Modulate = Colors.White; + } } public override void Process(Node target) diff --git a/translations/zombies.csv b/translations/zombies.csv index fda31d7..0e3d7eb 100644 --- a/translations/zombies.csv +++ b/translations/zombies.csv @@ -34,13 +34,15 @@ Attack damage: [color=darkred]1 bite[/color]. ","Бронированная ве Скорость атаки: [color=darkred]1 Гц[/color]. Урон от атаки: [color=darkred]1 укус[/color]." hobo,Trash can zombie,Зомби в мусорке -hobo_desc,"Some time in the past he met a great conqueror. Hates to live without his can. Equivalent of ~8 zombies. +hobo_desc,"Some time in the past he met a great conqueror. Hates to live without his can. Equivalent of ~8 zombies. +[color=darkgreen]He is immune to garlic-like effects. [/color] Health points: [color=darkred]13 peas[/color]. Armour points: [color=darkred]39 peas[/color]. Walk speed: [color=darkred]0.2 tiles/second[/color]. Run speed: [color=darkred]0.6 tiles/second[/color]. Attack speed: [color=darkred]1 Hz[/color]. Attack damage: [color=darkred]1 bite[/color]. ","Однажды повстречал великого полководца. Ненавидит жить без своего ведра. Равен примерно 8 зомби. +[color=darkgreen]Имеет иммунитет к эффектам как у чеснока. [/color] Очки здоровья: [color=darkred]13 горошин[/color]. Armour points: [color=darkred]39 горошин[/color]. Скорость ходьбы: [color=darkred]0.2 клеток/сек[/color]. diff --git a/translations/zombies.en.translation b/translations/zombies.en.translation index 45f31c8..184a456 100644 Binary files a/translations/zombies.en.translation and b/translations/zombies.en.translation differ diff --git a/translations/zombies.ru.translation b/translations/zombies.ru.translation index aa9df63..6189382 100644 Binary files a/translations/zombies.ru.translation and b/translations/zombies.ru.translation differ