diff --git a/components/Abstracts/SkillIconBase.tscn b/components/Abstracts/SkillIconBase.tscn index 7002344..4c27b12 100644 --- a/components/Abstracts/SkillIconBase.tscn +++ b/components/Abstracts/SkillIconBase.tscn @@ -4,6 +4,14 @@ [ext_resource type="Script" path="res://scripts/Statemachine/SkillIcon.gd" id="1_l7say"] [ext_resource type="Texture2D" uid="uid://cp4ypuarjoshp" path="res://resources/skillIcons/purple-crystal.png" id="2_hh1bl"] +[sub_resource type="ShaderMaterial" id="ShaderMaterial_3fyf3"] +shader = ExtResource("1_jaivk") +shader_parameter/progress = 0.55 +shader_parameter/backAlpha = 0.25 +shader_parameter/edgeHeight = 0.05 +shader_parameter/trailHeight = 0.3 +shader_parameter/trailAlpha = 0.5 + [sub_resource type="StyleBoxFlat" id="StyleBoxFlat_a60wd"] content_margin_left = 5.0 content_margin_top = 5.0 @@ -15,14 +23,8 @@ corner_radius_top_right = 20 corner_radius_bottom_right = 20 corner_radius_bottom_left = 20 -[sub_resource type="ShaderMaterial" id="ShaderMaterial_ew32n"] -shader = ExtResource("1_jaivk") -shader_parameter/progress = 0.5 -shader_parameter/backAlpha = 0.25 -shader_parameter/edgeHeight = 0.05 -shader_parameter/trailHeight = 0.3 - [node name="SkillIconBase" type="PanelContainer"] +material = SubResource("ShaderMaterial_3fyf3") custom_minimum_size = Vector2(40, 40) offset_right = 30.0 offset_bottom = 30.0 @@ -31,7 +33,7 @@ script = ExtResource("1_l7say") [node name="texture" type="TextureRect" parent="."] unique_name_in_owner = true -material = SubResource("ShaderMaterial_ew32n") +z_index = -1 layout_mode = 2 texture = ExtResource("2_hh1bl") expand_mode = 1 diff --git a/components/Scenes/UI.tscn b/components/Scenes/UI.tscn index bc766eb..f5acb76 100644 --- a/components/Scenes/UI.tscn +++ b/components/Scenes/UI.tscn @@ -119,7 +119,6 @@ _data = { } [sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_12otr"] -content_margin_right = 10.0 [node name="UI" type="CanvasLayer"] process_mode = 3 @@ -252,12 +251,13 @@ libraries = { [node name="skills" type="PanelContainer" parent="root"] layout_mode = 1 -anchors_preset = 6 -anchor_left = 1.0 +anchors_preset = -1 +anchor_left = 0.97 anchor_top = 0.5 -anchor_right = 1.0 +anchor_right = 0.97 anchor_bottom = 0.5 -offset_left = -10.0 +offset_left = 0.399902 +offset_right = 0.399902 grow_horizontal = 0 grow_vertical = 2 theme_override_styles/panel = SubResource("StyleBoxEmpty_12otr") diff --git a/scripts/Statemachine/SkillIcon.gd b/scripts/Statemachine/SkillIcon.gd index e162739..218796e 100644 --- a/scripts/Statemachine/SkillIcon.gd +++ b/scripts/Statemachine/SkillIcon.gd @@ -4,11 +4,10 @@ class_name SkillIcon @export var weapon: Weapon = null; @onready var textureRect: TextureRect = $"%texture" - func _ready(): - textureRect.material = textureRect.material.duplicate() + material = material.duplicate() func _physics_process(_delta): if is_instance_valid(weapon): textureRect.texture = weapon.avatarTexture var progress = min(weapon.cooldownTimer.timeSinceLastStart() / weapon.cooldownTimer.cooldown, UIState.player.energy / weapon.needEnergy) - textureRect.material.set_shader_parameter("progress", progress) + material.set_shader_parameter("progress", progress) diff --git a/shaders/CooldownProgress.gdshader b/shaders/CooldownProgress.gdshader index 71af89a..55b0c03 100644 --- a/shaders/CooldownProgress.gdshader +++ b/shaders/CooldownProgress.gdshader @@ -5,11 +5,15 @@ uniform float edgeHeight:hint_range(0.0, 1.0, 0.01)=0.05; uniform float trailHeight:hint_range(0.0, 1.0, 0.01)=0.3; uniform float trailAlpha:hint_range(0.0, 1.0, 0.01)=0.5; void fragment() { - if(UV.y>=progress){ - COLOR.a*=backAlpha; - }else if(distance(UV.y,progress)=1.0-progress){ + if(1.0-progress+trailHeight-UV.y>0.0){ + float dist=distance(UV.y,1.0-progress); + COLOR=vec4(1); + COLOR.a=(trailHeight-dist)/trailHeight*trailAlpha; + }else{ + COLOR.a*=backAlpha; + } + }else if(distance(UV.y,1.0-progress)