diff --git a/assets/GenericFlashMaterial.tres b/assets/GenericFlashMaterial.tres index b86626b..3cd7eb3 100644 --- a/assets/GenericFlashMaterial.tres +++ b/assets/GenericFlashMaterial.tres @@ -5,6 +5,7 @@ [resource] resource_local_to_scene = true shader = ExtResource("1_38cc4") -shader_parameter/FLASH_COLOR = Color(1, 0.709804, 0.439216, 0.5) +shader_parameter/FLASH_COLOR = Color(0.78, 0.78, 0.78, 0.501961) +shader_parameter/HIGHLIGHT_COLOR = Color(0.69, 0, 0, 0.282353) shader_parameter/selected = false shader_parameter/blend = 0.0 diff --git a/assets/ZombieMaterial.tres b/assets/ZombieMaterial.tres index c907f1d..341585e 100644 --- a/assets/ZombieMaterial.tres +++ b/assets/ZombieMaterial.tres @@ -5,6 +5,7 @@ [resource] resource_local_to_scene = true shader = ExtResource("1_fsu5r") -shader_parameter/FLASH_COLOR = Color(1, 0.709804, 0.439216, 0.5) +shader_parameter/FLASH_COLOR = Color(0.78, 0.78, 0.78, 0.501961) +shader_parameter/HIGHLIGHT_COLOR = Color(0.69, 0, 0, 0.282353) 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 index 27c05ae..df21cff 100644 --- a/assets/shaders/canvas_group_flash.gdshader +++ b/assets/shaders/canvas_group_flash.gdshader @@ -2,6 +2,7 @@ shader_type canvas_item; render_mode unshaded; uniform vec4 FLASH_COLOR : source_color = vec4(1,0.709803921,0.43921568,0.5); +uniform vec4 HIGHLIGHT_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; @@ -15,7 +16,7 @@ void fragment() { if (selected) { - COLOR = vec4(mix(text.rgb,FLASH_COLOR.rgb,FLASH_COLOR.a),text.a); + COLOR = vec4(mix(text.rgb,HIGHLIGHT_COLOR.rgb,HIGHLIGHT_COLOR.a),text.a); } else { diff --git a/assets/shaders/generic_flash.gdshader b/assets/shaders/generic_flash.gdshader index 2ef7d15..0970742 100644 --- a/assets/shaders/generic_flash.gdshader +++ b/assets/shaders/generic_flash.gdshader @@ -1,6 +1,7 @@ shader_type canvas_item; uniform vec4 FLASH_COLOR : source_color = vec4(1,0.709803921,0.43921568,0.5); +uniform vec4 HIGHLIGHT_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); @@ -9,7 +10,7 @@ void fragment() { if (selected) { - COLOR = vec4(mix(text.rgb,FLASH_COLOR.rgb,FLASH_COLOR.a),text.a); + COLOR = vec4(mix(text.rgb,HIGHLIGHT_COLOR.rgb,HIGHLIGHT_COLOR.a),text.a); } else { diff --git a/assets/shaders/radial_progress.gdshader b/assets/shaders/radial_progress.gdshader index ec7a2c6..b7ed32a 100644 --- a/assets/shaders/radial_progress.gdshader +++ b/assets/shaders/radial_progress.gdshader @@ -1,7 +1,20 @@ shader_type canvas_item; +uniform vec4 region_rect; +uniform float progress; + void fragment() { - //vec4 text = texture(TEXTURE,UV); - vec3 argg = vec3(distance(vec2(0.5),UV)); - COLOR = vec4(argg,1); + if (progress > 0.9999) + { + vec4 text = texture(TEXTURE,UV); + COLOR = text; + } + vec2 c = vec2(0.5)-UV; + float d = atan(c.x,c.y)+PI; + if (d > progress*TAU) + { + discard; + } + vec4 text = texture(TEXTURE,UV); + COLOR = text; } diff --git a/assets/sprites/gui/EmptyShovel.tres b/assets/sprites/gui/EmptyShovel.tres index 0fee8b1..710ae9c 100644 --- a/assets/sprites/gui/EmptyShovel.tres +++ b/assets/sprites/gui/EmptyShovel.tres @@ -5,3 +5,4 @@ [resource] atlas = ExtResource("1_i8m7w") region = Rect2(0, 174, 46, 46) +filter_clip = true diff --git a/assets/sprites/gui/Shovel.tres b/assets/sprites/gui/Shovel.tres index 8c78421..2ddfd29 100644 --- a/assets/sprites/gui/Shovel.tres +++ b/assets/sprites/gui/Shovel.tres @@ -5,3 +5,4 @@ [resource] atlas = ExtResource("1_s2rs0") region = Rect2(46, 174, 51, 47) +filter_clip = true diff --git a/assets/sprites/gui/shovel_button.png b/assets/sprites/gui/shovel_button.png new file mode 100644 index 0000000..bc6df22 Binary files /dev/null and b/assets/sprites/gui/shovel_button.png differ diff --git a/assets/sprites/gui/shovel_button.png.import b/assets/sprites/gui/shovel_button.png.import new file mode 100644 index 0000000..8328bbe --- /dev/null +++ b/assets/sprites/gui/shovel_button.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://b0jta6xgl7mvc" +path="res://.godot/imported/shovel_button.png-c2f09bdee84da389a849b137a44654ee.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://assets/sprites/gui/shovel_button.png" +dest_files=["res://.godot/imported/shovel_button.png-c2f09bdee84da389a849b137a44654ee.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/scenes/entities/plants/wallnut.tscn b/scenes/entities/plants/wallnut.tscn index c18e095..ce6d938 100644 --- a/scenes/entities/plants/wallnut.tscn +++ b/scenes/entities/plants/wallnut.tscn @@ -1,10 +1,19 @@ -[gd_scene load_steps=12 format=3 uid="uid://bq7imkpr2yqyr"] +[gd_scene load_steps=14 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="Shader" uid="uid://cgc7spjkhsx7c" path="res://assets/shaders/generic_flash.gdshader" id="2_bi7an"] [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://assets/animations/plants/wallnut.res" id="3_xl65q"] [ext_resource type="Script" uid="uid://btkmd86pn828y" path="res://scripts/entities/plants/behaviours/HpBasedBehaviour.cs" id="4_cjtyy"] +[sub_resource type="ShaderMaterial" id="ShaderMaterial_ladjs"] +resource_local_to_scene = true +shader = ExtResource("2_bi7an") +shader_parameter/FLASH_COLOR = Color(1, 0.709804, 0.439216, 0.5) +shader_parameter/HIGHLIGHT_COLOR = Color(1, 0.709804, 0.439216, 0.5) +shader_parameter/selected = false +shader_parameter/blend = 0.0 + [sub_resource type="AnimationNodeTimeScale" id="AnimationNodeTimeScale_y3tlf"] [sub_resource type="AnimationNodeAnimation" id="AnimationNodeAnimation_ds5ry"] @@ -42,10 +51,10 @@ internal_id = "wallnut" MaxHP = 600.0 [node name="Sprite2D" parent="." index="0"] +material = SubResource("ShaderMaterial_ladjs") texture = ExtResource("2_o5tda") hframes = 12 vframes = 3 -frame = 10 [node name="AnimationPlayer" parent="." index="1"] libraries = { @@ -65,4 +74,7 @@ shape = SubResource("RectangleShape2D_khltr") script = ExtResource("4_cjtyy") parameters = Array[String](["parameters/Tree/blend_position"]) +[node name="FlashController" parent="." index="5"] +shaderMaterial = SubResource("ShaderMaterial_ladjs") + [connection signal="OnHPChanged" from="." to="Behaviour" method="OnHPChanged"] diff --git a/scenes/gui/shovel_button.tscn b/scenes/gui/shovel_button.tscn index a48ea39..b9288ee 100644 --- a/scenes/gui/shovel_button.tscn +++ b/scenes/gui/shovel_button.tscn @@ -1,14 +1,16 @@ [gd_scene load_steps=6 format=3 uid="uid://t0vpmycj6c8j"] -[ext_resource type="Texture2D" uid="uid://cw73vihkrfenc" path="res://assets/sprites/gui/Shovel.tres" id="1_46afk"] [ext_resource type="Shader" uid="uid://c5kv2gwtme1dk" path="res://assets/shaders/radial_progress.gdshader" id="1_jj4sa"] +[ext_resource type="Texture2D" uid="uid://b0jta6xgl7mvc" path="res://assets/sprites/gui/shovel_button.png" id="2_jj4sa"] [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"] [sub_resource type="ShaderMaterial" id="ShaderMaterial_grw26"] shader = ExtResource("1_jj4sa") +shader_parameter/region_rect = Vector4(46, 174, 51, 47) +shader_parameter/progress = 1.0 -[node name="ShovelButton" type="TextureButton" node_paths=PackedStringArray("raycast")] +[node name="ShovelButton" type="TextureButton" node_paths=PackedStringArray("raycast", "timer")] material = SubResource("ShaderMaterial_grw26") anchors_preset = -1 anchor_right = 0.085 @@ -19,11 +21,12 @@ size_flags_horizontal = 4 size_flags_vertical = 0 mouse_default_cursor_shape = 2 toggle_mode = true -texture_normal = ExtResource("1_46afk") +texture_normal = ExtResource("2_jj4sa") texture_pressed = ExtResource("2_pw2pj") -stretch_mode = 0 +stretch_mode = 5 script = ExtResource("3_u6gir") raycast = NodePath("RayCast2D") +timer = NodePath("Timer") [node name="RayCast2D" type="RayCast2D" parent="."] exclude_parent = false @@ -32,3 +35,7 @@ collision_mask = 24 hit_from_inside = true collide_with_areas = true collide_with_bodies = false + +[node name="Timer" type="Timer" parent="."] +wait_time = 90.0 +one_shot = true diff --git a/scripts/gui/ShovelButton.cs b/scripts/gui/ShovelButton.cs index 3c72f02..be9dc6a 100644 --- a/scripts/gui/ShovelButton.cs +++ b/scripts/gui/ShovelButton.cs @@ -7,11 +7,14 @@ namespace Newlon.Components.GUI; public partial class ShovelButton : TextureButton { + const float CONE_HEALTH = 295.0f; [Export] private PackedScene particles; private Entity hoveredEntity; private bool Selected => hoveredEntity != null; [Export] private RayCast2D raycast; + [Export] + private Timer timer; private void OnFocusExited() { ButtonPressed = false; @@ -20,6 +23,7 @@ public partial class ShovelButton : TextureButton { raycast.Reparent(PoolContainer.Instance); FocusExited += OnFocusExited; + timer.Timeout += OnTimerTimeout; } public override void _Toggled(bool toggledOn) @@ -42,7 +46,9 @@ public partial class ShovelButton : TextureButton } else { - hoveredEntity.TakeDamage(205, null); + hoveredEntity.TakeDamage(CONE_HEALTH, null); + timer.Start(); + Disabled = true; } } hoveredEntity?.GetNode("FlashController").Deselect(); @@ -58,6 +64,7 @@ public partial class ShovelButton : TextureButton } public override void _Process(double delta) { + UpdateTimer(); if (ButtonPressed) { @@ -145,6 +152,20 @@ public partial class ShovelButton : TextureButton return true; } } + else + { + hoveredEntity?.GetNode("FlashController").Deselect(); + hoveredEntity = null; + return false; + } return hoveredEntity != null && hoveredEntity is RuntimeZombieData; } + private void UpdateTimer() + { + ((ShaderMaterial)Material).SetShaderParameter("progress", 1.0-timer.TimeLeft/timer.WaitTime); + } + private void OnTimerTimeout() + { + Disabled = false; + } }