From e4c25a1ca5147be00539c311ad657c630cb7d5c0 Mon Sep 17 00:00:00 2001 From: Rendo Date: Wed, 23 Jul 2025 16:07:55 +0500 Subject: [PATCH] Plants flash and shovel alt --- assets/GenericFlashMaterial.tres | 10 ++ assets/ZombieMaterial.tres | 10 ++ assets/shaders/canvas_group_flash.gdshader | 24 ++++ .../shaders/canvas_group_flash.gdshader.uid | 1 + assets/shaders/generic_flash.gdshader | 19 +++ assets/shaders/generic_flash.gdshader.uid | 1 + scenes/entities/Zombies/bucket_zombie.tscn | 52 +++----- scenes/entities/Zombies/cone_zombie.tscn | 99 +++++++------- scenes/entities/Zombies/hobo.tscn | 91 ++++++++++--- scenes/entities/Zombies/zombie.tscn | 67 +++++----- scenes/entities/plants/sunflower.tscn | 1 + scenes/gui/shovel_button.tscn | 11 +- scenes/templates/plant_template.tscn | 12 +- scripts/entities/Armor.cs | 12 +- scripts/entities/ArmorHPObserver.cs | 8 +- scripts/entities/DegradingSprite.cs | 4 +- scripts/entities/Entity.cs | 6 +- scripts/entities/FlashComponent.cs | 36 ------ scripts/entities/FlashComponent.cs.uid | 1 - scripts/entities/FlashShaderController.cs | 51 ++++++++ scripts/entities/FlashShaderController.cs.uid | 1 + scripts/entities/zombies/RuntimeZombieData.cs | 7 +- scripts/gui/ShovelButton.cs | 122 ++++++++++++++++-- 23 files changed, 451 insertions(+), 195 deletions(-) create mode 100644 assets/GenericFlashMaterial.tres create mode 100644 assets/ZombieMaterial.tres create mode 100644 assets/shaders/canvas_group_flash.gdshader create mode 100644 assets/shaders/canvas_group_flash.gdshader.uid create mode 100644 assets/shaders/generic_flash.gdshader create mode 100644 assets/shaders/generic_flash.gdshader.uid delete mode 100644 scripts/entities/FlashComponent.cs delete mode 100644 scripts/entities/FlashComponent.cs.uid create mode 100644 scripts/entities/FlashShaderController.cs create mode 100644 scripts/entities/FlashShaderController.cs.uid diff --git a/assets/GenericFlashMaterial.tres b/assets/GenericFlashMaterial.tres new file mode 100644 index 0000000..b86626b --- /dev/null +++ b/assets/GenericFlashMaterial.tres @@ -0,0 +1,10 @@ +[gd_resource type="ShaderMaterial" load_steps=2 format=3 uid="uid://cn7ac4meka1hc"] + +[ext_resource type="Shader" uid="uid://cgc7spjkhsx7c" path="res://assets/shaders/generic_flash.gdshader" id="1_38cc4"] + +[resource] +resource_local_to_scene = true +shader = ExtResource("1_38cc4") +shader_parameter/FLASH_COLOR = Color(1, 0.709804, 0.439216, 0.5) +shader_parameter/selected = false +shader_parameter/blend = 0.0 diff --git a/assets/ZombieMaterial.tres b/assets/ZombieMaterial.tres new file mode 100644 index 0000000..c907f1d --- /dev/null +++ b/assets/ZombieMaterial.tres @@ -0,0 +1,10 @@ +[gd_resource type="ShaderMaterial" load_steps=2 format=3 uid="uid://jr0vpg030jqv"] + +[ext_resource type="Shader" uid="uid://btf4xhu31ln6n" path="res://assets/shaders/canvas_group_flash.gdshader" id="1_fsu5r"] + +[resource] +resource_local_to_scene = true +shader = ExtResource("1_fsu5r") +shader_parameter/FLASH_COLOR = Color(1, 0.709804, 0.439216, 0.5) +shader_parameter/blend = 0.0 +shader_parameter/selected = false diff --git a/assets/shaders/canvas_group_flash.gdshader b/assets/shaders/canvas_group_flash.gdshader new file mode 100644 index 0000000..27c05ae --- /dev/null +++ b/assets/shaders/canvas_group_flash.gdshader @@ -0,0 +1,24 @@ +shader_type canvas_item; +render_mode unshaded; + +uniform vec4 FLASH_COLOR : source_color = vec4(1,0.709803921,0.43921568,0.5); +uniform sampler2D screen_texture : hint_screen_texture, repeat_disable, filter_nearest; +uniform float blend : hint_range(0,1,0.01); +uniform bool selected = false; + +void fragment() { + vec4 text = textureLod(screen_texture, SCREEN_UV, 0.0); + + if (text.a > 0.0001) { + text.rgb /= text.a; + } + + if (selected) + { + COLOR = vec4(mix(text.rgb,FLASH_COLOR.rgb,FLASH_COLOR.a),text.a); + } + else + { + COLOR = vec4(mix(text.rgb,FLASH_COLOR.rgb,FLASH_COLOR.a*blend),text.a); + } +} \ No newline at end of file diff --git a/assets/shaders/canvas_group_flash.gdshader.uid b/assets/shaders/canvas_group_flash.gdshader.uid new file mode 100644 index 0000000..b3e6995 --- /dev/null +++ b/assets/shaders/canvas_group_flash.gdshader.uid @@ -0,0 +1 @@ +uid://btf4xhu31ln6n diff --git a/assets/shaders/generic_flash.gdshader b/assets/shaders/generic_flash.gdshader new file mode 100644 index 0000000..2ef7d15 --- /dev/null +++ b/assets/shaders/generic_flash.gdshader @@ -0,0 +1,19 @@ +shader_type canvas_item; + +uniform vec4 FLASH_COLOR : source_color = vec4(1,0.709803921,0.43921568,0.5); +uniform bool selected = false; +uniform float blend : hint_range(0.0, 1.0, 0.01); + +void fragment() { + vec4 text = texture(TEXTURE,UV); + + if (selected) + { + COLOR = vec4(mix(text.rgb,FLASH_COLOR.rgb,FLASH_COLOR.a),text.a); + } + else + { + COLOR = vec4(mix(text.rgb,FLASH_COLOR.rgb,FLASH_COLOR.a*blend),text.a); + } + +} \ No newline at end of file diff --git a/assets/shaders/generic_flash.gdshader.uid b/assets/shaders/generic_flash.gdshader.uid new file mode 100644 index 0000000..bfb6ecf --- /dev/null +++ b/assets/shaders/generic_flash.gdshader.uid @@ -0,0 +1 @@ +uid://cgc7spjkhsx7c diff --git a/scenes/entities/Zombies/bucket_zombie.tscn b/scenes/entities/Zombies/bucket_zombie.tscn index 59f9922..8768e5a 100644 --- a/scenes/entities/Zombies/bucket_zombie.tscn +++ b/scenes/entities/Zombies/bucket_zombie.tscn @@ -1,7 +1,6 @@ -[gd_scene load_steps=15 format=3 uid="uid://xu4i6tmkv00a"] +[gd_scene load_steps=13 format=3 uid="uid://xu4i6tmkv00a"] [ext_resource type="PackedScene" uid="uid://hhjbqkjqpt7x" path="res://scenes/entities/Zombies/cone_zombie.tscn" id="1_mwqpo"] -[ext_resource type="Shader" uid="uid://d0eo5uuj222c4" path="res://assets/shaders/CG_color_blender.gdshader" id="2_3mrqj"] [ext_resource type="Texture2D" uid="uid://ce04l60l6mhfk" path="res://assets/sprites/bucket1.tres" id="3_0nlp0"] [ext_resource type="Script" uid="uid://c3cfnrmnnuqms" path="res://addons/floatmodifiers/FloatModifiers.cs" id="4_1s2fn"] [ext_resource type="Texture2D" uid="uid://ikk4jp7mvm3s" path="res://assets/sprites/bucket2.tres" id="4_xx7fu"] @@ -10,12 +9,6 @@ [ext_resource type="AudioStream" uid="uid://w0qfwds4o3ti" path="res://assets/audio/sfx/hit_generic.tres" id="6_kedip"] [ext_resource type="Texture2D" uid="uid://dacgbwohpmeed" path="res://assets/sprites/zombies/basic.png" id="6_lea3a"] -[sub_resource type="ShaderMaterial" id="ShaderMaterial_wdi07"] -resource_local_to_scene = true -shader = ExtResource("2_3mrqj") -shader_parameter/blend_color = Color(1, 1, 1, 1) -shader_parameter/amount = 0.0 - [sub_resource type="AtlasTexture" id="AtlasTexture_wfem3"] atlas = ExtResource("6_lea3a") region = Rect2(24, 2, 9, 9) @@ -40,9 +33,6 @@ mult_value = 1.0 [node name="BucketZombie" instance=ExtResource("1_mwqpo")] -[node name="CanvasGroup" parent="." index="0"] -material = SubResource("ShaderMaterial_wdi07") - [node name="Zombie" parent="CanvasGroup/basic_zombie_walk" index="0"] use_parent_material = false @@ -58,37 +48,37 @@ use_parent_material = false scale = Vector2(0.999836, 0.999836) [node name="RightLowerLeg" parent="CanvasGroup/basic_zombie_walk/Zombie/Butt/RightUpperLeg" index="1"] -scale = Vector2(0.999833, 0.999833) +scale = Vector2(0.999831, 0.999831) [node name="RightFoot" parent="CanvasGroup/basic_zombie_walk/Zombie/Butt/RightUpperLeg/RightLowerLeg" index="0"] -scale = Vector2(0.999834, 0.999834) +scale = Vector2(0.999833, 0.999833) [node name="LeftUpperLeg" parent="CanvasGroup/basic_zombie_walk/Zombie/Butt" index="2"] use_parent_material = false +scale = Vector2(0.999831, 0.999831) [node name="LeftLowerLeg" parent="CanvasGroup/basic_zombie_walk/Zombie/Butt/LeftUpperLeg" index="1"] scale = Vector2(0.999833, 0.999833) [node name="LeftFoot" parent="CanvasGroup/basic_zombie_walk/Zombie/Butt/LeftUpperLeg/LeftLowerLeg" index="1"] -scale = Vector2(0.999831, 0.999831) +scale = Vector2(0.999832, 0.999832) [node name="Body" parent="CanvasGroup/basic_zombie_walk/Zombie/Butt" index="3"] use_parent_material = false -scale = Vector2(0.999827, 0.999827) +scale = Vector2(0.999826, 0.999826) [node name="RightUpperArm" parent="CanvasGroup/basic_zombie_walk/Zombie/Butt/Body" index="0"] use_parent_material = false -scale = Vector2(0.999826, 0.999826) +scale = Vector2(0.99983, 0.99983) [node name="RightLowerArm" parent="CanvasGroup/basic_zombie_walk/Zombie/Butt/Body/RightUpperArm" index="1"] -scale = Vector2(0.999826, 0.999826) +scale = Vector2(0.999828, 0.999828) [node name="RightHand" parent="CanvasGroup/basic_zombie_walk/Zombie/Butt/Body/RightUpperArm/RightLowerArm" index="0"] scale = Vector2(0.999828, 0.999828) [node name="Tie" parent="CanvasGroup/basic_zombie_walk/Zombie/Butt/Body" index="2"] -rotation = -0.0952629 -skew = -0.000141501 +rotation = 0.0612749 [node name="Head" parent="CanvasGroup/basic_zombie_walk/Zombie/Butt/Body" index="3"] scale = Vector2(0.999828, 0.999828) @@ -100,12 +90,12 @@ position = Vector2(-16, -8) position = Vector2(-4, -9) [node name="Jaw" parent="CanvasGroup/basic_zombie_walk/Zombie/Butt/Body/Head/HeadParticle/Head" index="2"] -position = Vector2(-2.88169, 2.71447) -rotation = -0.0665417 -scale = Vector2(0.999829, 0.999829) +position = Vector2(-2.82709, 2.57856) +rotation = 0.0226432 +scale = Vector2(0.999827, 0.999827) [node name="Jaw" parent="CanvasGroup/basic_zombie_walk/Zombie/Butt/Body/Head" index="1"] -scale = Vector2(0.999829, 0.999829) +scale = Vector2(0.999827, 0.999827) [node name="Hat" parent="CanvasGroup/basic_zombie_walk/Zombie/Butt/Body/Head" index="4"] position = Vector2(-6, -8) @@ -116,23 +106,23 @@ texture = ExtResource("3_0nlp0") degradationStages = Array[Texture]([ExtResource("3_0nlp0"), ExtResource("4_xx7fu"), ExtResource("5_v1iwd")]) [node name="LeftUpperArm" parent="CanvasGroup/basic_zombie_walk/Zombie/Butt/Body" index="4"] -scale = Vector2(0.999829, 0.999829) +scale = Vector2(0.999828, 0.999828) [node name="Left_Lower_Arm" parent="CanvasGroup/basic_zombie_walk/Zombie/Butt/Body/LeftUpperArm/HandProjectile" index="0"] -rotation = -0.10097 -scale = Vector2(0.999997, 0.999997) +rotation = 0.132621 +scale = Vector2(0.999996, 0.999996) [node name="Left_Hand" parent="CanvasGroup/basic_zombie_walk/Zombie/Butt/Body/LeftUpperArm/HandProjectile/Left_Lower_Arm" index="0"] show_behind_parent = false position = Vector2(-0.99983, 12.9978) -rotation = -0.0832296 -scale = Vector2(0.999659, 0.999659) +rotation = -0.0968181 +scale = Vector2(0.999658, 0.999658) [node name="LeftLowerArm" parent="CanvasGroup/basic_zombie_walk/Zombie/Butt/Body/LeftUpperArm" index="2"] -scale = Vector2(0.999827, 0.999827) +scale = Vector2(0.999826, 0.999826) [node name="LeftHand" parent="CanvasGroup/basic_zombie_walk/Zombie/Butt/Body/LeftUpperArm/LeftLowerArm" index="0"] -scale = Vector2(0.999829, 0.999829) +scale = Vector2(0.999828, 0.999828) [node name="Left_Hand" type="Sprite2D" parent="CanvasGroup/basic_zombie_walk/Zombie/Butt/Body/LeftUpperArm/LeftLowerArm/LeftHand" index="0"] texture = SubResource("AtlasTexture_wfem3") @@ -151,7 +141,7 @@ _damage = SubResource("Resource_lea3a") [node name="Mover" parent="." index="4"] _speed = SubResource("Resource_v1iwd") -_speedControlMult = 0.345736 +_speedControlMult = 2.25202 [node name="HitPlayer" parent="." index="5"] playlist = Array[AudioStream]([ExtResource("5_lt6ps"), ExtResource("6_kedip")]) diff --git a/scenes/entities/Zombies/cone_zombie.tscn b/scenes/entities/Zombies/cone_zombie.tscn index 4d4f2ef..c5adc24 100644 --- a/scenes/entities/Zombies/cone_zombie.tscn +++ b/scenes/entities/Zombies/cone_zombie.tscn @@ -1,8 +1,8 @@ [gd_scene load_steps=16 format=3 uid="uid://hhjbqkjqpt7x"] [ext_resource type="PackedScene" uid="uid://co11v3w8hbwgf" path="res://scenes/entities/Zombies/zombie.tscn" id="1_3dq4c"] -[ext_resource type="Shader" uid="uid://d0eo5uuj222c4" path="res://assets/shaders/CG_color_blender.gdshader" id="2_2dq8e"] [ext_resource type="Script" uid="uid://fd4im1fmwc5n" path="res://scripts/entities/Armor.cs" id="3_5s7in"] +[ext_resource type="Material" uid="uid://cn7ac4meka1hc" path="res://assets/GenericFlashMaterial.tres" id="3_b8kja"] [ext_resource type="Script" uid="uid://dt5uj25u0g6y3" path="res://scripts/particles/FallParticle.cs" id="3_w70im"] [ext_resource type="Texture2D" uid="uid://ceqvdmude7cgg" path="res://assets/sprites/cone1.tres" id="4_qdhik"] [ext_resource type="Script" uid="uid://c3cfnrmnnuqms" path="res://addons/floatmodifiers/FloatModifiers.cs" id="4_qof5v"] @@ -11,12 +11,7 @@ [ext_resource type="AudioStream" uid="uid://bmupd3v3gvsca" path="res://assets/audio/sfx/plastichit_generic.tres" id="7_0amn8"] [ext_resource type="Texture2D" uid="uid://cnn81r1y0xwod" path="res://assets/sprites/cone3.tres" id="7_011r0"] [ext_resource type="AudioStream" uid="uid://w0qfwds4o3ti" path="res://assets/audio/sfx/hit_generic.tres" id="7_67t4t"] - -[sub_resource type="ShaderMaterial" id="ShaderMaterial_sat5k"] -resource_local_to_scene = true -shader = ExtResource("2_2dq8e") -shader_parameter/blend_color = Color(1, 1, 1, 1) -shader_parameter/amount = 0.0 +[ext_resource type="Script" uid="uid://30pbgasu64aw" path="res://scripts/entities/FlashShaderController.cs" id="13_7fceb"] [sub_resource type="CircleShape2D" id="CircleShape2D_67t4t"] @@ -37,53 +32,57 @@ mult_value = 1.0 [node name="ConeZombie" node_paths=PackedStringArray("_armor") instance=ExtResource("1_3dq4c")] _armor = NodePath("Armor") -[node name="CanvasGroup" parent="." index="0"] -material = SubResource("ShaderMaterial_sat5k") - [node name="RightUpperLeg" parent="CanvasGroup/basic_zombie_walk/Zombie/Butt" index="1"] -scale = Vector2(0.999835, 0.999835) - -[node name="LeftUpperLeg" parent="CanvasGroup/basic_zombie_walk/Zombie/Butt" index="2"] -scale = Vector2(0.999829, 0.999829) - -[node name="LeftLowerLeg" parent="CanvasGroup/basic_zombie_walk/Zombie/Butt/LeftUpperLeg" index="1"] scale = Vector2(0.999834, 0.999834) -[node name="LeftFoot" parent="CanvasGroup/basic_zombie_walk/Zombie/Butt/LeftUpperLeg/LeftLowerLeg" index="1"] -scale = Vector2(0.999826, 0.999826) +[node name="RightLowerLeg" parent="CanvasGroup/basic_zombie_walk/Zombie/Butt/RightUpperLeg" index="1"] +scale = Vector2(0.999832, 0.999832) -[node name="Body" parent="CanvasGroup/basic_zombie_walk/Zombie/Butt" index="3"] -scale = Vector2(0.999828, 0.999828) - -[node name="RightUpperArm" parent="CanvasGroup/basic_zombie_walk/Zombie/Butt/Body" index="0"] -scale = Vector2(0.999829, 0.999829) - -[node name="RightLowerArm" parent="CanvasGroup/basic_zombie_walk/Zombie/Butt/Body/RightUpperArm" index="1"] -scale = Vector2(0.999826, 0.999826) - -[node name="RightHand" parent="CanvasGroup/basic_zombie_walk/Zombie/Butt/Body/RightUpperArm/RightLowerArm" index="0"] +[node name="RightFoot" parent="CanvasGroup/basic_zombie_walk/Zombie/Butt/RightUpperLeg/RightLowerLeg" index="0"] scale = Vector2(0.999831, 0.999831) +[node name="LeftUpperLeg" parent="CanvasGroup/basic_zombie_walk/Zombie/Butt" index="2"] +scale = Vector2(0.999832, 0.999832) + +[node name="LeftLowerLeg" parent="CanvasGroup/basic_zombie_walk/Zombie/Butt/LeftUpperLeg" index="1"] +scale = Vector2(0.999832, 0.999832) + +[node name="LeftFoot" parent="CanvasGroup/basic_zombie_walk/Zombie/Butt/LeftUpperLeg/LeftLowerLeg" index="1"] +scale = Vector2(0.99983, 0.99983) + +[node name="Body" parent="CanvasGroup/basic_zombie_walk/Zombie/Butt" index="3"] +scale = Vector2(0.999829, 0.999829) + +[node name="RightUpperArm" parent="CanvasGroup/basic_zombie_walk/Zombie/Butt/Body" index="0"] +scale = Vector2(0.99983, 0.99983) + +[node name="RightLowerArm" parent="CanvasGroup/basic_zombie_walk/Zombie/Butt/Body/RightUpperArm" index="1"] +scale = Vector2(0.999825, 0.999825) + +[node name="RightHand" parent="CanvasGroup/basic_zombie_walk/Zombie/Butt/Body/RightUpperArm/RightLowerArm" index="0"] +scale = Vector2(0.99983, 0.99983) + [node name="Tie" parent="CanvasGroup/basic_zombie_walk/Zombie/Butt/Body" index="2"] -rotation = 0.134918 -skew = -0.000136733 +rotation = 0.116614 +skew = -0.000146031 [node name="Head" parent="CanvasGroup/basic_zombie_walk/Zombie/Butt/Body" index="3"] -scale = Vector2(0.999823, 0.999823) +scale = Vector2(0.999828, 0.999828) [node name="Right_Eye" parent="CanvasGroup/basic_zombie_walk/Zombie/Butt/Body/Head/HeadParticle/Head" index="0"] -position = Vector2(-16, -7.99999) +position = Vector2(-16, -8) +scale = Vector2(1, 1) [node name="Left_Eye" parent="CanvasGroup/basic_zombie_walk/Zombie/Butt/Body/Head/HeadParticle/Head" index="1"] -position = Vector2(-4, -8.99999) +scale = Vector2(1, 1) [node name="Jaw" parent="CanvasGroup/basic_zombie_walk/Zombie/Butt/Body/Head/HeadParticle/Head" index="2"] -position = Vector2(-3.00166, 2.9972) -rotation = 0.0130933 -scale = Vector2(0.999837, 0.999837) +position = Vector2(-3.00143, 2.99758) +rotation = 0.011317 +scale = Vector2(0.999829, 0.999829) [node name="Jaw" parent="CanvasGroup/basic_zombie_walk/Zombie/Butt/Body/Head" index="1"] -scale = Vector2(0.999837, 0.999837) +scale = Vector2(0.999829, 0.999829) [node name="Hat" type="RigidBody2D" parent="CanvasGroup/basic_zombie_walk/Zombie/Butt/Body/Head" index="4" node_paths=PackedStringArray("data")] position = Vector2(-2.5, -13.5) @@ -100,6 +99,7 @@ maxTorque = 45.0 Impulse = 100.0 [node name="Sprite" type="Sprite2D" parent="CanvasGroup/basic_zombie_walk/Zombie/Butt/Body/Head/Hat" index="0" node_paths=PackedStringArray("armor")] +material = ExtResource("3_b8kja") position = Vector2(-1, -12) texture = ExtResource("4_qdhik") script = ExtResource("5_ickyd") @@ -112,24 +112,29 @@ position = Vector2(1, -6) shape = SubResource("CircleShape2D_67t4t") [node name="LeftUpperArm" parent="CanvasGroup/basic_zombie_walk/Zombie/Butt/Body" index="4"] -scale = Vector2(0.999825, 0.999825) +scale = Vector2(0.999828, 0.999828) [node name="Left_Lower_Arm" parent="CanvasGroup/basic_zombie_walk/Zombie/Butt/Body/LeftUpperArm/HandProjectile" index="0"] -rotation = 0.126852 +rotation = 0.109643 +scale = Vector2(0.999998, 0.999998) [node name="Left_Hand" parent="CanvasGroup/basic_zombie_walk/Zombie/Butt/Body/LeftUpperArm/HandProjectile/Left_Lower_Arm" index="0"] -rotation = -0.0559848 -scale = Vector2(0.999655, 0.999655) +position = Vector2(-0.99983, 12.9978) +rotation = -0.0483896 +scale = Vector2(0.999657, 0.999657) + +[node name="LeftLowerArm" parent="CanvasGroup/basic_zombie_walk/Zombie/Butt/Body/LeftUpperArm" index="2"] +scale = Vector2(0.999828, 0.999828) [node name="LeftHand" parent="CanvasGroup/basic_zombie_walk/Zombie/Butt/Body/LeftUpperArm/LeftLowerArm" index="0"] -scale = Vector2(0.999825, 0.999825) +scale = Vector2(0.999827, 0.999827) [node name="Eatbox" parent="." index="2"] _damage = SubResource("Resource_011r0") [node name="Mover" parent="." index="4"] _speed = SubResource("Resource_b6mal") -_speedControlMult = 0.918428 +_speedControlMult = 0.670374 [node name="HitPlayer" parent="." index="5"] playlist = Array[AudioStream]([ExtResource("7_0amn8"), ExtResource("7_67t4t")]) @@ -139,6 +144,12 @@ channels = Array[String](["plastic_hit", "hit"]) script = ExtResource("3_5s7in") MaxHP = 135.0 -[connection signal="ArmorDamaged" from="Armor" to="." method="HPChangedMixedInvoker"] +[node name="FlashController" type="Node" parent="Armor" index="0"] +script = ExtResource("13_7fceb") +shaderMaterial = ExtResource("3_b8kja") + [connection signal="ArmorLost" from="Armor" to="HitPlayer" method="Next"] [connection signal="ArmorLost" from="Armor" to="CanvasGroup/basic_zombie_walk/Zombie/Butt/Body/Head/Hat" method="FallOff"] +[connection signal="Damaged" from="Armor" to="HitPlayer" method="Play"] +[connection signal="Damaged" from="Armor" to="Armor/FlashController" method="DamageFlash"] +[connection signal="HpChanged" from="Armor" to="." method="HPChangedMixedInvoker"] diff --git a/scenes/entities/Zombies/hobo.tscn b/scenes/entities/Zombies/hobo.tscn index 4cef8ab..e546aad 100644 --- a/scenes/entities/Zombies/hobo.tscn +++ b/scenes/entities/Zombies/hobo.tscn @@ -1,7 +1,8 @@ -[gd_scene load_steps=63 format=3 uid="uid://bgqmwsb6ynm81"] +[gd_scene load_steps=71 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_n380g"] [ext_resource type="Resource" uid="uid://dsg1vjx76ifgu" path="res://assets/effects/GarlicEffect.tres" id="3_b583s"] [ext_resource type="Script" uid="uid://dt5uj25u0g6y3" path="res://scripts/particles/FallParticle.cs" id="3_tu6af"] [ext_resource type="Script" uid="uid://c5v2og85t7s6j" path="res://scripts/entities/zombies/behaviours/HoboBehaviour.cs" id="4_5selg"] @@ -10,6 +11,7 @@ [ext_resource type="Texture2D" uid="uid://dri70dxyks7xh" path="res://assets/sprites/zombies/hobo.png" id="5_b583s"] [ext_resource type="Script" uid="uid://bbw848msxb4re" path="res://scripts/entities/DegradingSprite.cs" id="5_ndwp0"] [ext_resource type="Texture2D" uid="uid://8h5vg1pk32b2" path="res://assets/sprites/garbage_can1.tres" id="6_i6nje"] +[ext_resource type="Shader" uid="uid://cgc7spjkhsx7c" path="res://assets/shaders/generic_flash.gdshader" id="7_nlwsb"] [ext_resource type="Texture2D" uid="uid://cogfbn4re3kob" path="res://assets/sprites/garbage_can2.tres" id="7_txjqc"] [ext_resource type="AnimationLibrary" uid="uid://ceb3khu7rwgy8" path="res://assets/animations/zombies/basic.res" id="7_vn3j1"] [ext_resource type="AudioStream" uid="uid://bu1egfsyplpx4" path="res://assets/audio/sfx/metalhit_generic.tres" id="8_4248q"] @@ -19,6 +21,8 @@ [ext_resource type="Script" uid="uid://c36bj8u7jghc7" path="res://scripts/audio/ChannelPlayer.cs" id="11_7jlle"] [ext_resource type="Script" uid="uid://d3l8e8ko5r5i3" path="res://scripts/entities/ArmorHPObserver.cs" id="12_vn3j1"] [ext_resource type="AudioStream" uid="uid://ch55p7qbaawtp" path="res://assets/audio/sfx/argh.tres" id="12_w1b1s"] +[ext_resource type="Script" uid="uid://30pbgasu64aw" path="res://scripts/entities/FlashShaderController.cs" id="19_8y6c0"] +[ext_resource type="Shader" uid="uid://btf4xhu31ln6n" path="res://assets/shaders/canvas_group_flash.gdshader" id="23_nc6p3"] [sub_resource type="ShaderMaterial" id="ShaderMaterial_w8pya"] resource_local_to_scene = true @@ -70,6 +74,18 @@ region = Rect2(91, 32, 9, 15) atlas = ExtResource("5_b583s") region = Rect2(137, 19, 29, 39) +[sub_resource type="ShaderMaterial" id="ShaderMaterial_y0p2l"] +resource_local_to_scene = true +shader = ExtResource("7_nlwsb") +shader_parameter/selected = false +shader_parameter/blend = 0.0 + +[sub_resource type="ShaderMaterial" id="ShaderMaterial_op0h6"] +resource_local_to_scene = true +shader = ExtResource("7_nlwsb") +shader_parameter/selected = false +shader_parameter/blend = 0.0 + [sub_resource type="AtlasTexture" id="AtlasTexture_5selg"] atlas = ExtResource("5_b583s") region = Rect2(0, 29, 35, 11) @@ -86,6 +102,12 @@ region = Rect2(80, 0, 32, 30) atlas = ExtResource("5_b583s") region = Rect2(38, 22, 22, 13) +[sub_resource type="ShaderMaterial" id="ShaderMaterial_0s5wm"] +resource_local_to_scene = true +shader = ExtResource("7_nlwsb") +shader_parameter/selected = false +shader_parameter/blend = 0.0 + [sub_resource type="AtlasTexture" id="AtlasTexture_n380g"] atlas = ExtResource("5_b583s") region = Rect2(34, 38, 45, 27) @@ -753,10 +775,16 @@ flat_value = 0.4 percentage_value = 0.0 mult_value = 1.0 +[sub_resource type="ShaderMaterial" id="ShaderMaterial_pjhfy"] +resource_local_to_scene = true +shader = ExtResource("23_nc6p3") +shader_parameter/blend = 0.0 +shader_parameter/selected = false + [node name="Hobo" node_paths=PackedStringArray("_armor") instance=ExtResource("1_fnu7s")] _armor = NodePath("CanArmor") MaxHP = 130.0 -_effectImmunities = [ExtResource("3_b583s")] +_effectImmunities = Array[ExtResource("2_n380g")]([ExtResource("3_b583s")]) [node name="CanvasGroup" parent="." index="0"] material = SubResource("ShaderMaterial_w8pya") @@ -768,16 +796,16 @@ scale = Vector2(0.999902, 0.999902) texture = SubResource("AtlasTexture_txjqc") [node name="RightUpperLeg" parent="CanvasGroup/basic_zombie_walk/Zombie/Butt" index="1"] -scale = Vector2(0.999828, 0.999828) +scale = Vector2(0.99982, 0.99982) [node name="Right_Upper_Leg" parent="CanvasGroup/basic_zombie_walk/Zombie/Butt/RightUpperLeg" index="0"] texture = SubResource("AtlasTexture_b583s") [node name="RightLowerLeg" parent="CanvasGroup/basic_zombie_walk/Zombie/Butt/RightUpperLeg" index="1"] -scale = Vector2(0.99983, 0.99983) +scale = Vector2(0.999826, 0.999826) [node name="RightFoot" parent="CanvasGroup/basic_zombie_walk/Zombie/Butt/RightUpperLeg/RightLowerLeg" index="0"] -scale = Vector2(0.999828, 0.999828) +scale = Vector2(0.999826, 0.999826) [node name="Right_Foot" parent="CanvasGroup/basic_zombie_walk/Zombie/Butt/RightUpperLeg/RightLowerLeg/RightFoot" index="0"] texture = SubResource("AtlasTexture_uoit3") @@ -786,31 +814,34 @@ texture = SubResource("AtlasTexture_uoit3") texture = SubResource("AtlasTexture_vn3j1") [node name="LeftUpperLeg" parent="CanvasGroup/basic_zombie_walk/Zombie/Butt" index="2"] -scale = Vector2(0.999827, 0.999827) +scale = Vector2(0.999823, 0.999823) [node name="Left_Upper_Leg" parent="CanvasGroup/basic_zombie_walk/Zombie/Butt/LeftUpperLeg" index="0"] texture = SubResource("AtlasTexture_yb81c") [node name="LeftLowerLeg" parent="CanvasGroup/basic_zombie_walk/Zombie/Butt/LeftUpperLeg" index="1"] -scale = Vector2(0.999831, 0.999831) +scale = Vector2(0.999829, 0.999829) [node name="Left_Lower_Leg" parent="CanvasGroup/basic_zombie_walk/Zombie/Butt/LeftUpperLeg/LeftLowerLeg" index="0"] texture = SubResource("AtlasTexture_nlwsb") [node name="LeftFoot" parent="CanvasGroup/basic_zombie_walk/Zombie/Butt/LeftUpperLeg/LeftLowerLeg" index="1"] -scale = Vector2(0.999816, 0.999816) +scale = Vector2(0.999822, 0.999822) [node name="Left_Foot" parent="CanvasGroup/basic_zombie_walk/Zombie/Butt/LeftUpperLeg/LeftLowerLeg/LeftFoot" index="0"] texture = SubResource("AtlasTexture_8y6c0") +[node name="Body" parent="CanvasGroup/basic_zombie_walk/Zombie/Butt" index="3"] +scale = Vector2(0.999825, 0.999825) + [node name="RightUpperArm" parent="CanvasGroup/basic_zombie_walk/Zombie/Butt/Body" index="0"] -scale = Vector2(0.999829, 0.999829) +scale = Vector2(0.999828, 0.999828) [node name="Right_Upper_Arm" parent="CanvasGroup/basic_zombie_walk/Zombie/Butt/Body/RightUpperArm" index="0"] texture = SubResource("AtlasTexture_nc6p3") [node name="RightLowerArm" parent="CanvasGroup/basic_zombie_walk/Zombie/Butt/Body/RightUpperArm" index="1"] -scale = Vector2(0.999816, 0.999816) +scale = Vector2(0.999811, 0.999811) [node name="Right_Hand" parent="CanvasGroup/basic_zombie_walk/Zombie/Butt/Body/RightUpperArm/RightLowerArm/RightHand" index="0"] texture = SubResource("AtlasTexture_y0p2l") @@ -822,7 +853,7 @@ texture = SubResource("AtlasTexture_op0h6") texture = SubResource("AtlasTexture_0s5wm") [node name="Tie" parent="CanvasGroup/basic_zombie_walk/Zombie/Butt/Body" index="2"] -rotation = 0.050955 +rotation = 0.0327417 scale = Vector2(1e-05, 1e-05) [node name="Tie" parent="CanvasGroup/basic_zombie_walk/Zombie/Butt/Body/Tie" index="0"] @@ -841,6 +872,7 @@ maxTorque = 45.0 Impulse = 100.0 [node name="Sprite2D" type="Sprite2D" parent="CanvasGroup/basic_zombie_walk/Zombie/Butt/Body/Can" index="0" node_paths=PackedStringArray("armor")] +material = SubResource("ShaderMaterial_y0p2l") position = Vector2(-5.9999, -4.5002) texture = ExtResource("6_i6nje") script = ExtResource("5_ndwp0") @@ -850,6 +882,7 @@ thresholdPercentage = Array[float]([1.0, 0.667, 0.333]) [node name="Sprite2D2" type="Sprite2D" parent="CanvasGroup/basic_zombie_walk/Zombie/Butt/Body/Can" index="1"] z_index = -1 +material = SubResource("ShaderMaterial_op0h6") position = Vector2(-7.4999, -27.5002) texture = SubResource("AtlasTexture_5selg") @@ -863,10 +896,16 @@ scale = Vector2(0.999827, 0.999827) [node name="Head" parent="CanvasGroup/basic_zombie_walk/Zombie/Butt/Body/Head/HeadParticle" index="0"] texture = SubResource("AtlasTexture_pjhfy") +[node name="Right_Eye" parent="CanvasGroup/basic_zombie_walk/Zombie/Butt/Body/Head/HeadParticle/Head" index="0"] +position = Vector2(-16, -8) + +[node name="Left_Eye" parent="CanvasGroup/basic_zombie_walk/Zombie/Butt/Body/Head/HeadParticle/Head" index="1"] +position = Vector2(-4, -9) + [node name="Jaw" parent="CanvasGroup/basic_zombie_walk/Zombie/Butt/Body/Head/HeadParticle/Head" index="2"] position = Vector2(-3, 3) -rotation = -0.082875 -scale = Vector2(0.999827, 0.999827) +rotation = -0.0532523 +scale = Vector2(0.999828, 0.999828) texture = SubResource("AtlasTexture_7cvmi") offset = Vector2(-14, -2) @@ -881,7 +920,9 @@ data = NodePath("../../../../../../../../..") [node name="Trashcan_lid" type="Sprite2D" parent="CanvasGroup/basic_zombie_walk/Zombie/Butt/Body/Head/HeadParticle/Head/TrashcanLid" index="0"] z_index = -1 +material = SubResource("ShaderMaterial_0s5wm") position = Vector2(2.99822, -20.0166) +scale = Vector2(1, 1) texture = SubResource("AtlasTexture_n380g") offset = Vector2(-0.5, -0.5) metadata/_edit_lock_ = true @@ -896,7 +937,7 @@ _threshold = 0.333 _observedArmor = NodePath("../../../../../../../../../../CanArmor") [node name="Jaw" parent="CanvasGroup/basic_zombie_walk/Zombie/Butt/Body/Head" index="1"] -scale = Vector2(0.999827, 0.999827) +scale = Vector2(0.999828, 0.999828) [node name="TrashcanLid" type="Bone2D" parent="CanvasGroup/basic_zombie_walk/Zombie/Butt/Body/Head" index="4"] position = Vector2(-0.0022974, -17.0131) @@ -911,23 +952,24 @@ editor_settings/show_bone_gizmo = false remote_path = NodePath("../../HeadParticle/Head/TrashcanLid/Trashcan_lid") [node name="LeftUpperArm" parent="CanvasGroup/basic_zombie_walk/Zombie/Butt/Body" index="5"] -scale = Vector2(0.999828, 0.999828) +scale = Vector2(0.99981, 0.99981) [node name="Left_Upper_Arm" parent="CanvasGroup/basic_zombie_walk/Zombie/Butt/Body/LeftUpperArm" index="0"] texture = SubResource("AtlasTexture_tebih") [node name="Left_Lower_Arm" parent="CanvasGroup/basic_zombie_walk/Zombie/Butt/Body/LeftUpperArm/HandProjectile" index="0"] -rotation = 0.0459656 -scale = Vector2(0.999997, 0.999997) +rotation = 0.0295357 +scale = Vector2(0.999991, 0.999991) texture = SubResource("AtlasTexture_auxav") [node name="Left_Hand" parent="CanvasGroup/basic_zombie_walk/Zombie/Butt/Body/LeftUpperArm/HandProjectile/Left_Lower_Arm" index="0"] -rotation = -3.72659e-09 +position = Vector2(-0.99983, 12.9978) +rotation = 0.0 scale = Vector2(0.999652, 0.999652) texture = SubResource("AtlasTexture_dntsa") [node name="LeftLowerArm" parent="CanvasGroup/basic_zombie_walk/Zombie/Butt/Body/LeftUpperArm" index="2"] -scale = Vector2(0.999827, 0.999827) +scale = Vector2(0.999821, 0.999821) [node name="LeftHand" parent="CanvasGroup/basic_zombie_walk/Zombie/Butt/Body/LeftUpperArm/LeftLowerArm" index="0"] scale = Vector2(0.999822, 0.999822) @@ -948,7 +990,6 @@ advance_expression_base_node = NodePath("../Behaviour") [node name="Mover" parent="." index="4"] _speed = SubResource("Resource_4248q") -_speedControlMult = 0.0 [node name="HitPlayer" parent="." index="5"] playlist = Array[AudioStream]([ExtResource("8_4248q"), ExtResource("9_tu6af")]) @@ -959,6 +1000,10 @@ script = ExtResource("4_w8pya") MaxHP = 385.0 metadata/_custom_type_script = "uid://fd4im1fmwc5n" +[node name="FlashController" type="Node" parent="CanArmor" index="0"] +script = ExtResource("19_8y6c0") +shaderMaterial = SubResource("ShaderMaterial_0s5wm") + [node name="Behaviour" type="Node" parent="." index="8" node_paths=PackedStringArray("_eatBox", "_animationTree")] script = ExtResource("4_5selg") _eatBox = NodePath("../Eatbox") @@ -970,9 +1015,13 @@ audioStream = ExtResource("12_w1b1s") channel = "anger" metadata/_custom_type_script = "uid://c36bj8u7jghc7" +[node name="FlashController" parent="." index="12"] +shaderMaterial = SubResource("ShaderMaterial_pjhfy") + [connection signal="ThresholdReached" from="CanvasGroup/basic_zombie_walk/Zombie/Butt/Body/Head/HeadParticle/Head/TrashcanLid/Observer" to="CanvasGroup/basic_zombie_walk/Zombie/Butt/Body/Head/HeadParticle/Head/TrashcanLid" method="FallOff"] [connection signal="ThresholdReached" from="CanvasGroup/basic_zombie_walk/Zombie/Butt/Body/Head/HeadParticle/Head/TrashcanLid/Observer" to="CanvasGroup/basic_zombie_walk/Zombie/Butt/Body/Head/TrashcanLid/RemoteTransform2D" method="queue_free"] -[connection signal="ArmorDamaged" from="CanArmor" to="." method="HPChangedMixedInvoker"] [connection signal="ArmorLost" from="CanArmor" to="HitPlayer" method="Next"] [connection signal="ArmorLost" from="CanArmor" to="CanvasGroup/basic_zombie_walk/Zombie/Butt/Body/Can" method="FallOff"] [connection signal="ArmorLost" from="CanArmor" to="Behaviour" method="Trashed"] +[connection signal="Damaged" from="CanArmor" to="HitPlayer" method="Play"] +[connection signal="Damaged" from="CanArmor" to="CanArmor/FlashController" method="DamageFlash"] diff --git a/scenes/entities/Zombies/zombie.tscn b/scenes/entities/Zombies/zombie.tscn index 0ba50d0..efdb166 100644 --- a/scenes/entities/Zombies/zombie.tscn +++ b/scenes/entities/Zombies/zombie.tscn @@ -1,11 +1,10 @@ -[gd_scene load_steps=61 format=3 uid="uid://co11v3w8hbwgf"] +[gd_scene load_steps=60 format=3 uid="uid://co11v3w8hbwgf"] [ext_resource type="Script" uid="uid://dildme6epx8l4" path="res://scripts/entities/zombies/RuntimeZombieData.cs" id="1_qq3f1"] +[ext_resource type="Material" uid="uid://jr0vpg030jqv" path="res://assets/ZombieMaterial.tres" id="2_b51fx"] [ext_resource type="AudioStream" uid="uid://dt13iugnnx4op" path="res://assets/audio/sfx/yuck_generic.tres" id="2_hh4qh"] -[ext_resource type="Shader" uid="uid://d0eo5uuj222c4" path="res://assets/shaders/CG_color_blender.gdshader" id="2_srwwe"] [ext_resource type="Script" uid="uid://dqyony6jxt2p0" path="res://scripts/entities/zombies/EatBox.cs" id="3_2aulo"] [ext_resource type="AudioStream" uid="uid://bjotp63arocci" path="res://assets/audio/sfx/frozen.mp3" id="3_ltj46"] -[ext_resource type="Script" uid="uid://c5vfccegyy01t" path="res://scripts/entities/FlashComponent.cs" id="3_rao3m"] [ext_resource type="Script" uid="uid://7hdj2k14lfe4" path="res://scripts/entities/zombies/ZombieMover.cs" id="4_u5syx"] [ext_resource type="Texture2D" uid="uid://dacgbwohpmeed" path="res://assets/sprites/zombies/basic.png" id="6_xnora"] [ext_resource type="Script" uid="uid://c3cfnrmnnuqms" path="res://addons/floatmodifiers/FloatModifiers.cs" id="7_b3p4o"] @@ -24,12 +23,7 @@ [ext_resource type="Resource" uid="uid://7uj0oe656jfx" path="res://assets/effects/SnowSlow.tres" id="19_ccrjo"] [ext_resource type="Script" uid="uid://c1x4n4nqyq72f" path="res://scripts/audio/ChannelSettings.cs" id="21_xnora"] [ext_resource type="Script" uid="uid://dk32ln8c2574d" path="res://scripts/entities/zombies/ZombieKillHandler.cs" id="23_mc1kl"] - -[sub_resource type="ShaderMaterial" id="ShaderMaterial_63ls2"] -resource_local_to_scene = true -shader = ExtResource("2_srwwe") -shader_parameter/blend_color = Color(0.73, 0.73, 0.73, 1) -shader_parameter/amount = 0.0 +[ext_resource type="Script" uid="uid://30pbgasu64aw" path="res://scripts/entities/FlashShaderController.cs" id="24_b51fx"] [sub_resource type="SkeletonModification2DCCDIK" id="SkeletonModification2DCCDIK_wn68q"] tip_nodepath = NodePath("Butt/Body/LeftUpperArm/LeftLowerArm/LeftHand") @@ -753,7 +747,7 @@ _data = { } [sub_resource type="RectangleShape2D" id="RectangleShape2D_hxyad"] -size = Vector2(9, 48) +size = Vector2(26, 48) [sub_resource type="Resource" id="Resource_ruqsf"] resource_local_to_scene = true @@ -795,8 +789,7 @@ _tree = NodePath("AnimationTree") metadata/_edit_vertical_guides_ = [-159.0] [node name="CanvasGroup" type="CanvasGroup" parent="."] -material = SubResource("ShaderMaterial_63ls2") -script = ExtResource("3_rao3m") +material = ExtResource("2_b51fx") [node name="basic_zombie_walk" type="Node2D" parent="CanvasGroup"] @@ -821,7 +814,7 @@ metadata/_edit_lock_ = true [node name="RightUpperLeg" type="Bone2D" parent="CanvasGroup/basic_zombie_walk/Zombie/Butt"] use_parent_material = true position = Vector2(-6, 3) -scale = Vector2(0.999832, 0.999832) +scale = Vector2(0.999834, 0.999834) rest = Transform2D(1, 0, 0, 1, -6, 3) editor_settings/show_bone_gizmo = false @@ -833,13 +826,13 @@ metadata/_edit_lock_ = true [node name="RightLowerLeg" type="Bone2D" parent="CanvasGroup/basic_zombie_walk/Zombie/Butt/RightUpperLeg"] position = Vector2(-2, 12) -scale = Vector2(0.999836, 0.999836) +scale = Vector2(0.999834, 0.999834) rest = Transform2D(1, 0, 0, 1, -2, 12) editor_settings/show_bone_gizmo = false [node name="RightFoot" type="Bone2D" parent="CanvasGroup/basic_zombie_walk/Zombie/Butt/RightUpperLeg/RightLowerLeg"] position = Vector2(-2, 14) -scale = Vector2(0.999833, 0.999833) +scale = Vector2(0.999832, 0.999832) rest = Transform2D(1, 0, 0, 1, -2, 14) auto_calculate_length_and_angle = false length = 12.0 @@ -862,7 +855,7 @@ metadata/_edit_lock_ = true [node name="LeftUpperLeg" type="Bone2D" parent="CanvasGroup/basic_zombie_walk/Zombie/Butt"] use_parent_material = true position = Vector2(6, 4) -scale = Vector2(0.999832, 0.999832) +scale = Vector2(0.999835, 0.999835) rest = Transform2D(1, 0, 0, 1, 6, 4) editor_settings/show_bone_gizmo = false @@ -886,7 +879,7 @@ metadata/_edit_lock_ = true [node name="LeftFoot" type="Bone2D" parent="CanvasGroup/basic_zombie_walk/Zombie/Butt/LeftUpperLeg/LeftLowerLeg"] position = Vector2(6, 10) -scale = Vector2(0.999829, 0.999829) +scale = Vector2(0.999831, 0.999831) rest = Transform2D(1, 0, 0, 1, 6, 10) auto_calculate_length_and_angle = false length = 12.0 @@ -910,7 +903,7 @@ editor_settings/show_bone_gizmo = false z_index = -1 use_parent_material = true position = Vector2(-14, -23) -scale = Vector2(0.999829, 0.999829) +scale = Vector2(0.999827, 0.999827) rest = Transform2D(1, 0, 0, 1, -14, -23) editor_settings/show_bone_gizmo = false @@ -922,7 +915,7 @@ metadata/_edit_lock_ = true [node name="RightLowerArm" type="Bone2D" parent="CanvasGroup/basic_zombie_walk/Zombie/Butt/Body/RightUpperArm"] position = Vector2(-2, 15) -scale = Vector2(0.999827, 0.999827) +scale = Vector2(0.999828, 0.999828) rest = Transform2D(1, 0, 0, 1, -2, 15) editor_settings/show_bone_gizmo = false @@ -956,8 +949,8 @@ metadata/_edit_lock_ = true [node name="Tie" type="Bone2D" parent="CanvasGroup/basic_zombie_walk/Zombie/Butt/Body"] position = Vector2(-9, -21) -rotation = 0.0155712 -skew = -0.00043869 +rotation = -0.134944 +skew = -0.000461102 rest = Transform2D(1, 0, 0, 1, -9, -21) auto_calculate_length_and_angle = false length = 24.0 @@ -972,7 +965,7 @@ metadata/_edit_lock_ = true [node name="Head" type="Bone2D" parent="CanvasGroup/basic_zombie_walk/Zombie/Butt/Body"] position = Vector2(-10, -25) -scale = Vector2(0.999822, 0.999822) +scale = Vector2(0.999828, 0.999828) rest = Transform2D(1, 0, 0, 1, -10, -25) editor_settings/show_bone_gizmo = false @@ -995,7 +988,6 @@ metadata/_edit_lock_ = true [node name="Right_Eye" type="Sprite2D" parent="CanvasGroup/basic_zombie_walk/Zombie/Butt/Body/Head/HeadParticle/Head"] position = Vector2(-16, -8) -scale = Vector2(1, 1) texture = SubResource("AtlasTexture_vcc72") centered = false offset = Vector2(-2, -2) @@ -1003,16 +995,15 @@ metadata/_edit_lock_ = true [node name="Left_Eye" type="Sprite2D" parent="CanvasGroup/basic_zombie_walk/Zombie/Butt/Body/Head/HeadParticle/Head"] position = Vector2(-4, -9) -scale = Vector2(1, 1) texture = SubResource("AtlasTexture_kto0i") centered = false offset = Vector2(-2, -2) metadata/_edit_lock_ = true [node name="Jaw" type="Sprite2D" parent="CanvasGroup/basic_zombie_walk/Zombie/Butt/Body/Head/HeadParticle/Head"] -position = Vector2(-2.75527, 2.40711) -rotation = 0.0250584 -scale = Vector2(0.999813, 0.999813) +position = Vector2(-2.83241, 2.59553) +rotation = -0.0942595 +scale = Vector2(0.999826, 0.999826) texture = SubResource("AtlasTexture_x5uj2") centered = false offset = Vector2(-12, -2) @@ -1029,7 +1020,7 @@ _observedEntity = NodePath("../../../../../../../..") [node name="Jaw" type="Bone2D" parent="CanvasGroup/basic_zombie_walk/Zombie/Butt/Body/Head"] position = Vector2(-3, 3) -scale = Vector2(0.999813, 0.999813) +scale = Vector2(0.999826, 0.999826) rest = Transform2D(1, 0, 0, 1, -3, 3) auto_calculate_length_and_angle = false length = 11.0 @@ -1063,7 +1054,7 @@ remote_path = NodePath("../../HeadParticle/Head/Left_Eye") [node name="LeftUpperArm" type="Bone2D" parent="CanvasGroup/basic_zombie_walk/Zombie/Butt/Body"] position = Vector2(-1, -20) -scale = Vector2(0.999828, 0.999828) +scale = Vector2(0.999827, 0.999827) rest = Transform2D(1, 0, 0, 1, -1, -20) editor_settings/show_bone_gizmo = false @@ -1085,7 +1076,7 @@ minTorque = -45.0 maxTorque = 45.0 [node name="Left_Lower_Arm" type="Sprite2D" parent="CanvasGroup/basic_zombie_walk/Zombie/Butt/Body/LeftUpperArm/HandProjectile"] -rotation = 0.120426 +rotation = -0.143029 scale = Vector2(0.999994, 0.999994) texture = SubResource("AtlasTexture_auqeq") centered = false @@ -1095,8 +1086,8 @@ metadata/_edit_lock_ = true [node name="Left_Hand" type="Sprite2D" parent="CanvasGroup/basic_zombie_walk/Zombie/Butt/Body/LeftUpperArm/HandProjectile/Left_Lower_Arm"] show_behind_parent = true position = Vector2(-0.99983, 12.9978) -rotation = -0.107145 -scale = Vector2(0.999655, 0.999655) +rotation = -0.117899 +scale = Vector2(0.999658, 0.999658) texture = SubResource("AtlasTexture_vlvtp") centered = false offset = Vector2(-4, -1) @@ -1118,7 +1109,7 @@ editor_settings/show_bone_gizmo = false [node name="LeftHand" type="Bone2D" parent="CanvasGroup/basic_zombie_walk/Zombie/Butt/Body/LeftUpperArm/LeftLowerArm"] position = Vector2(-1, 13) -scale = Vector2(0.999825, 0.999825) +scale = Vector2(0.999828, 0.999828) rest = Transform2D(1, 0, 0, 1, -1, 13) auto_calculate_length_and_angle = false length = 6.0 @@ -1143,7 +1134,7 @@ collision_layer = 8 collision_mask = 0 [node name="CollisionShape2D" type="CollisionShape2D" parent="Hitbox"] -position = Vector2(-1.5, -24) +position = Vector2(4, -24) shape = SubResource("RectangleShape2D_hxyad") [node name="Eatbox" type="Area2D" parent="."] @@ -1168,7 +1159,7 @@ entity = NodePath("..") [node name="Mover" type="Node" parent="."] script = ExtResource("4_u5syx") _speed = SubResource("Resource_ckb7n") -_speedControlMult = 2.5893 +_speedControlMult = 0.77483 [node name="HitPlayer" type="Node" parent="."] script = ExtResource("12_he8da") @@ -1201,9 +1192,13 @@ script = ExtResource("23_mc1kl") _tree = NodePath("../AnimationTree") _collider = NodePath("../Hitbox/CollisionShape2D") +[node name="FlashController" type="Node" parent="."] +script = ExtResource("24_b51fx") +shaderMaterial = ExtResource("2_b51fx") + [connection signal="HasBeenKilled" from="." to="DeathHandler" method="OnKilled"] [connection signal="OnDamaged" from="." to="HitPlayer" method="Play"] -[connection signal="OnHPChanged" from="." to="CanvasGroup" method="DamageFlash"] +[connection signal="OnDamaged" from="." to="FlashController" method="DamageFlash"] [connection signal="ThresholdReached" from="CanvasGroup/basic_zombie_walk/Zombie/Butt/Body/Head/HeadParticle/Observer" to="CanvasGroup/basic_zombie_walk/Zombie/Butt/Body/Head/HeadParticle" method="FallOff"] [connection signal="ThresholdReached" from="CanvasGroup/basic_zombie_walk/Zombie/Butt/Body/Head/HeadParticle/Observer" to="CanvasGroup/basic_zombie_walk/Zombie/Butt/Body/Head/Jaw/RemoteTransform2D" method="queue_free"] [connection signal="ThresholdReached" from="CanvasGroup/basic_zombie_walk/Zombie/Butt/Body/Head/HeadParticle/Observer" to="CanvasGroup/basic_zombie_walk/Zombie/Butt/Body/Head/RightEye/RemoteTransform2D" method="queue_free"] diff --git a/scenes/entities/plants/sunflower.tscn b/scenes/entities/plants/sunflower.tscn index 1acc1d0..650c6be 100644 --- a/scenes/entities/plants/sunflower.tscn +++ b/scenes/entities/plants/sunflower.tscn @@ -73,6 +73,7 @@ MaxHP = 30.0 texture = ExtResource("2_fwcda") hframes = 9 vframes = 2 +frame = 1 [node name="AnimationPlayer" parent="." index="1"] libraries = { diff --git a/scenes/gui/shovel_button.tscn b/scenes/gui/shovel_button.tscn index 9f81c76..19f8e4a 100644 --- a/scenes/gui/shovel_button.tscn +++ b/scenes/gui/shovel_button.tscn @@ -4,7 +4,7 @@ [ext_resource type="Texture2D" uid="uid://fd6drk2su0df" path="res://assets/sprites/gui/EmptyShovel.tres" id="2_pw2pj"] [ext_resource type="Script" uid="uid://d4dbg0us5ngxy" path="res://scripts/gui/ShovelButton.cs" id="3_u6gir"] -[node name="ShovelButton" type="TextureButton"] +[node name="ShovelButton" type="TextureButton" node_paths=PackedStringArray("raycast")] anchors_preset = -1 anchor_right = 0.085 anchor_bottom = 0.117 @@ -18,5 +18,14 @@ texture_normal = ExtResource("1_46afk") texture_pressed = ExtResource("2_pw2pj") stretch_mode = 0 script = ExtResource("3_u6gir") +raycast = NodePath("RayCast2D") + +[node name="RayCast2D" type="RayCast2D" parent="."] +exclude_parent = false +target_position = Vector2(0, 0) +collision_mask = 24 +hit_from_inside = true +collide_with_areas = true +collide_with_bodies = false [connection signal="focus_exited" from="." to="." method="OnFocusExited"] diff --git a/scenes/templates/plant_template.tscn b/scenes/templates/plant_template.tscn index d8ac777..158bd36 100644 --- a/scenes/templates/plant_template.tscn +++ b/scenes/templates/plant_template.tscn @@ -1,7 +1,9 @@ -[gd_scene load_steps=3 format=3 uid="uid://b1hjjbdwf1rtc"] +[gd_scene load_steps=5 format=3 uid="uid://b1hjjbdwf1rtc"] [ext_resource type="Script" uid="uid://dli2i6albvugt" path="res://scripts/entities/plants/RuntimePlantData.cs" id="1_324sd"] +[ext_resource type="Material" uid="uid://cn7ac4meka1hc" path="res://assets/GenericFlashMaterial.tres" id="2_3uws4"] [ext_resource type="Script" uid="uid://dwlwi42smgxkb" path="res://scripts/TimeScalableAnimationTree.cs" id="2_e75pf"] +[ext_resource type="Script" uid="uid://30pbgasu64aw" path="res://scripts/entities/FlashShaderController.cs" id="4_3uws4"] [node name="PlantTemplate" type="Node2D" node_paths=PackedStringArray("_player", "_tree")] script = ExtResource("1_324sd") @@ -9,7 +11,7 @@ _player = NodePath("AnimationPlayer") _tree = NodePath("AnimationTree") [node name="Sprite2D" type="Sprite2D" parent="."] -use_parent_material = true +material = ExtResource("2_3uws4") [node name="AnimationPlayer" type="AnimationPlayer" parent="."] @@ -21,3 +23,9 @@ entity = NodePath("..") [node name="Hitbox" type="Area2D" parent="."] collision_layer = 2 collision_mask = 0 + +[node name="FlashController" type="Node" parent="."] +script = ExtResource("4_3uws4") +shaderMaterial = ExtResource("2_3uws4") + +[connection signal="OnDamaged" from="." to="FlashController" method="DamageFlash"] diff --git a/scripts/entities/Armor.cs b/scripts/entities/Armor.cs index 37371a6..96b4a89 100644 --- a/scripts/entities/Armor.cs +++ b/scripts/entities/Armor.cs @@ -6,7 +6,9 @@ namespace Newlon.Components; public partial class Armor : Node { [Signal] - public delegate void ArmorDamagedEventHandler(float hp); + public delegate void DamagedEventHandler(); + [Signal] + public delegate void HpChangedEventHandler(float hp); [Signal] public delegate void ArmorLostEventHandler(); @@ -32,14 +34,16 @@ public partial class Armor : Node { var delta = _hp; _hp = 0; - EmitSignal(SignalName.ArmorDamaged, delta); + EmitSignal(SignalName.HpChanged, -delta); + EmitSignal(SignalName.Damaged); EmitSignal(SignalName.ArmorLost); _lost = true; } else { _hp -= damage; - EmitSignal(SignalName.ArmorDamaged, damage); + EmitSignal(SignalName.HpChanged, -damage); + EmitSignal(SignalName.Damaged); } return returnAmount; } @@ -55,7 +59,7 @@ public partial class Armor : Node returnAmount = _hp-MaxHP; _hp = MaxHP; } - EmitSignal(SignalName.ArmorDamaged,_hp); + EmitSignal(SignalName.HpChanged,_hp); return returnAmount; } } diff --git a/scripts/entities/ArmorHPObserver.cs b/scripts/entities/ArmorHPObserver.cs index 59d1445..c5de7ef 100644 --- a/scripts/entities/ArmorHPObserver.cs +++ b/scripts/entities/ArmorHPObserver.cs @@ -11,21 +11,21 @@ public partial class ArmorHPObserver : Node public override void _Ready() { - _observedArmor.ArmorDamaged += OnHPChanged; + _observedArmor.Damaged += OnDamaged; } - private void OnHPChanged(float delta) + private void OnDamaged() { if (_setGreater == false && _observedArmor._hp / _observedArmor.MaxHP < _threshold) { EmitSignal(SignalName.ThresholdReached); - _observedArmor.ArmorDamaged -= OnHPChanged; + _observedArmor.Damaged -= OnDamaged; QueueFree(); } else if (_setGreater && _observedArmor._hp / _observedArmor.MaxHP > _threshold) { EmitSignal(SignalName.ThresholdReached); - _observedArmor.ArmorDamaged -= OnHPChanged; + _observedArmor.Damaged -= OnDamaged; QueueFree(); } } diff --git a/scripts/entities/DegradingSprite.cs b/scripts/entities/DegradingSprite.cs index a3df2d1..a32a97c 100644 --- a/scripts/entities/DegradingSprite.cs +++ b/scripts/entities/DegradingSprite.cs @@ -11,10 +11,10 @@ public partial class DegradingSprite : Sprite2D public override void _Ready() { - armor.ArmorDamaged += OnArmorHPChanged; + armor.Damaged += OnDamaged; } - private void OnArmorHPChanged(float hp) + private void OnDamaged() { float percent = armor._hp / armor.MaxHP; for (int i = 0; i < degradationStages.Count; i++) diff --git a/scripts/entities/Entity.cs b/scripts/entities/Entity.cs index 131d265..ad73497 100644 --- a/scripts/entities/Entity.cs +++ b/scripts/entities/Entity.cs @@ -10,13 +10,15 @@ public partial class Entity : Node2D { #region Health points [Export] public float MaxHP; - public float HP; + [Export]public float HP; [Signal] public delegate void OnHPChangedEventHandler(EntitySignalContext context); [Signal] public delegate void OnDamagedEventHandler(); public virtual void TakeDamage(float amount, Node origin) { - EmitSignal(SignalName.OnDamaged); + if(amount > 0) + EmitSignal(SignalName.OnDamaged); + var context = new EntitySignalContext() { target = this, diff --git a/scripts/entities/FlashComponent.cs b/scripts/entities/FlashComponent.cs deleted file mode 100644 index 109c479..0000000 --- a/scripts/entities/FlashComponent.cs +++ /dev/null @@ -1,36 +0,0 @@ -using Godot; -using System; - -namespace Newlon.Components; - -public partial class FlashComponent : CanvasGroup -{ - [Export] private float _flashDuration = 0.1f; - private Tween _tween; - private ShaderMaterial _shaderMaterial; - - public override void _Ready() - { - _shaderMaterial = Material as ShaderMaterial; - } - - public void DamageFlash(EntitySignalContext context) - { - Flash(); - } - - - public void Flash() - { - _tween?.Kill(); - _tween = CreateTween(); - - Action action = SetAmount; - _tween.TweenMethod(Callable.From(action),0.8f,0.0f,_flashDuration); - } - - private void SetAmount(float amount) - { - _shaderMaterial.SetShaderParameter("amount",amount); - } -} diff --git a/scripts/entities/FlashComponent.cs.uid b/scripts/entities/FlashComponent.cs.uid deleted file mode 100644 index c0f482d..0000000 --- a/scripts/entities/FlashComponent.cs.uid +++ /dev/null @@ -1 +0,0 @@ -uid://c5vfccegyy01t diff --git a/scripts/entities/FlashShaderController.cs b/scripts/entities/FlashShaderController.cs new file mode 100644 index 0000000..cf06d73 --- /dev/null +++ b/scripts/entities/FlashShaderController.cs @@ -0,0 +1,51 @@ +using Godot; +using Newlon.Components; + +public partial class FlashShaderController : Node +{ + [Export] public float flashTime = 0.5f; + [Export] + private ShaderMaterial shaderMaterial; + private uint toggleStack = 0; + private Tween flashTween; + public void DamageFlash() + { + Flash(); + } + public void Flash(float customFlashTime = 0) + { + if (flashTween != null) + flashTween.Kill(); + var time = flashTime; + if (customFlashTime > 0) + time = customFlashTime; + + flashTween = CreateTween(); + flashTween.TweenMethod(Callable.From(SetBlend), 1.0, 0.0, time); + } + public void Select() + { + toggleStack++; + UpdateSelected(); + } + public void Deselect() + { + toggleStack--; + UpdateSelected(); + } + private void SetBlend(float blend) + { + shaderMaterial.SetShaderParameter("blend", blend); + } + private void UpdateSelected() + { + if (toggleStack > 0) + { + shaderMaterial.SetShaderParameter("selected", true); + } + else + { + shaderMaterial.SetShaderParameter("selected", false); + } + } +} diff --git a/scripts/entities/FlashShaderController.cs.uid b/scripts/entities/FlashShaderController.cs.uid new file mode 100644 index 0000000..0e43889 --- /dev/null +++ b/scripts/entities/FlashShaderController.cs.uid @@ -0,0 +1 @@ +uid://30pbgasu64aw diff --git a/scripts/entities/zombies/RuntimeZombieData.cs b/scripts/entities/zombies/RuntimeZombieData.cs index ab146f9..915ceaf 100644 --- a/scripts/entities/zombies/RuntimeZombieData.cs +++ b/scripts/entities/zombies/RuntimeZombieData.cs @@ -49,15 +49,18 @@ public partial class RuntimeZombieData : Entity damage = _armor.RecieveDamage(amount); } - EmitSignal(SignalName.OnDamaged); var context = new EntitySignalContext() { source = origin, target = this, actionAmount = amount }; + if(damage > 0) + EmitSignal(SignalName.OnDamaged); + if (HP - damage <= 0) { + var delta = -HP; HP = 0; EmitSignal(SignalName.OnHPChanged, context); @@ -80,7 +83,7 @@ public partial class RuntimeZombieData : Entity EmitSignal(SignalName.HPChangedMixed, new EntitySignalContext() { - deltaHP = -delta, + deltaHP = delta, source = null, target = this, actionAmount = delta diff --git a/scripts/gui/ShovelButton.cs b/scripts/gui/ShovelButton.cs index deae0a4..cb47ce7 100644 --- a/scripts/gui/ShovelButton.cs +++ b/scripts/gui/ShovelButton.cs @@ -1,16 +1,26 @@ using Godot; using Newlon.Components.Plants; using Newlon.Components.Level; +using Newlon.Components.Zombies; namespace Newlon.Components.GUI; public partial class ShovelButton : TextureButton { [Export] private PackedScene particles; + private Entity hoveredEntity; + private bool Selected => hoveredEntity != null; + [Export] + private RayCast2D raycast; private void OnFocusExited() { ButtonPressed = false; } + public override void _Ready() + { + raycast.Reparent(PoolContainer.Instance); + } + public override void _Toggled(bool toggledOn) { Cursor.Instance.shovel = toggledOn; @@ -22,24 +32,118 @@ public partial class ShovelButton : TextureButton if (@event.IsActionPressed("primary_action") && ButtonPressed) { - var checkedPosition = (PoolContainer.Instance.Plants.GetGlobalMousePosition() / FieldParams.Tile).Ceil() * FieldParams.Tile - new Vector2(20, 14); - - for (int i = FieldParams.LayersCount - 1; i >= 0; i--) + if (hoveredEntity != null) { - if (PoolContainer.Instance.EntityField[i].TryGetValue(checkedPosition, out var entity) && entity is RuntimePlantData plantData) + if (hoveredEntity is RuntimePlantData hoveredPlant) { - plantData.Kill(); - - PoolContainer.Instance.SpawnParticles(particles, plantData.GlobalPosition + Vector2.Down * FieldParams.TileHeight / 2.0f); - - break; + hoveredPlant.Kill(); + PoolContainer.Instance.SpawnParticles(particles, hoveredPlant.GlobalPosition + Vector2.Down * FieldParams.TileHeight / 2.0f); + } + else + { + hoveredEntity.TakeDamage(205, null); } } + hoveredEntity?.GetNode("FlashController").Deselect(); + hoveredEntity = null; ButtonPressed = false; } if (@event.IsActionPressed("cancel_plant") && ButtonPressed) { + hoveredEntity?.GetNode("FlashController").Deselect(); + hoveredEntity = null; ButtonPressed = false; } } + public override void _Process(double delta) + { + + if (ButtonPressed) + { + var gridEntity = GetTile(PoolContainer.Instance.Plants.GetGlobalMousePosition()); + if (TrySetGridEntity(gridEntity)) return; + if (TrySetDynEntity()) return; + + else + { + if (Selected) + { + hoveredEntity.GetNode("FlashController").Deselect(); + hoveredEntity = null; + return; + } + } + } + else + { + if (Selected) + { + hoveredEntity.GetNode("FlashController").Deselect(); + hoveredEntity = null; + } + } + } + private Entity GetTile(Vector2 position) + { + var checkedPosition = (position / FieldParams.Tile).Ceil() * FieldParams.Tile - new Vector2(20, 14); + for (int i = FieldParams.LayersCount - 1; i >= 0; i--) + { + if (PoolContainer.Instance.EntityField[i].TryGetValue(checkedPosition, out var entity) && entity is RuntimePlantData plantData) + { + return plantData; + } + } + return null; + } + private bool TrySetGridEntity(Entity chosenEntity) + { + if (chosenEntity != null && Selected == false) + { + hoveredEntity = chosenEntity; + hoveredEntity.GetNode("FlashController").Select(); + return true; + } + if (chosenEntity == null && Selected && hoveredEntity is RuntimePlantData) + { + hoveredEntity.GetNode("FlashController").Deselect(); + hoveredEntity = null; + return true; + } + if (hoveredEntity == null || chosenEntity == null) return false; + if (chosenEntity != hoveredEntity && Selected) + { + hoveredEntity.GetNode("FlashController").Deselect(); + hoveredEntity = chosenEntity; + hoveredEntity.GetNode("FlashController").Select(); + return true; + } + return hoveredEntity != null && hoveredEntity is RuntimeZombieData == false; + } + private bool TrySetDynEntity() + { + raycast.GlobalPosition = PoolContainer.Instance.GetGlobalMousePosition(); + + if (raycast.IsColliding()) + { + var entity = ((Area2D)raycast.GetCollider()).GetParent() as Entity; + + if (entity == null) return false; + + if (Selected == false) + { + hoveredEntity = entity; + hoveredEntity.GetNode("FlashController").Select(); + return true; + } + if (hoveredEntity == null) return false; + if (Selected && hoveredEntity != entity) + { + hoveredEntity.GetNode("FlashController").Deselect(); + entity.GetNode("FlashController").Select(); + hoveredEntity = entity; + return true; + } + } + return hoveredEntity != null && hoveredEntity is RuntimeZombieData; + } }