From a7d126483026fdf307a8700a1e15418596f7717c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=A8=E8=90=BD=E5=9F=BA=E5=9B=B4=E8=99=BE?= <3161880837@qq.com> Date: Tue, 9 Sep 2025 22:26:16 +0800 Subject: [PATCH] =?UTF-8?q?feat(UI):=20=E9=87=8D=E6=9E=84=E8=83=BD?= =?UTF-8?q?=E9=87=8F=E6=9D=A1=E4=B8=BA=E5=9E=82=E7=9B=B4=E6=A0=B7=E5=BC=8F?= =?UTF-8?q?=E5=B9=B6=E8=B0=83=E6=95=B4UI=E5=B8=83=E5=B1=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit refactor: 修改能量恢复随机范围从0.01-0.15调整为0.01-0.1 style: 更新着色器进度范围提示从0.0-2.0改为-0.0-2.0 feat: 新增垂直颜色条组件和样式资源 chore: 恢复测试波次为普通模式 --- components/Scenes/UI.tscn | 67 ++++++++++--------- components/UI/Variants/VerticalColorBar.tscn | 41 ++++++++++++ scripts/Contents/Wave.gd | 6 +- scripts/Statemachine/EntityBase.gd | 2 +- scripts/Statemachine/UIState.gd | 6 -- .../Statemachine/Variants/VerticalColorBar.gd | 8 +++ shaders/CooldownProgress.gdshader | 2 +- shaders/LightScan.gdshader | 15 +++++ styleboxes/centerRight.tres | 15 +++++ 9 files changed, 120 insertions(+), 42 deletions(-) create mode 100644 components/UI/Variants/VerticalColorBar.tscn create mode 100644 scripts/Statemachine/Variants/VerticalColorBar.gd create mode 100644 shaders/LightScan.gdshader create mode 100644 styleboxes/centerRight.tres diff --git a/components/Scenes/UI.tscn b/components/Scenes/UI.tscn index dad25e2..bc766eb 100644 --- a/components/Scenes/UI.tscn +++ b/components/Scenes/UI.tscn @@ -1,20 +1,31 @@ -[gd_scene load_steps=21 format=3 uid="uid://dfwg750a47ggx"] +[gd_scene load_steps=24 format=3 uid="uid://dfwg750a47ggx"] [ext_resource type="PackedScene" uid="uid://ofpg5s3j7esv" path="res://components/UI/BossBar.tscn" id="1_2pe58"] [ext_resource type="Script" path="res://scripts/Statemachine/UIState.gd" id="1_f00a6"] [ext_resource type="StyleBox" uid="uid://dx0udq8nv2ec0" path="res://styleboxes/topPanel.tres" id="3_kep0k"] [ext_resource type="PackedScene" uid="uid://bbm8l3hr4ihar" path="res://components/UI/ItemShow.tscn" id="3_o2oi4"] [ext_resource type="PackedScene" uid="uid://1n28ji5sl6bx" path="res://components/Scenes/FullscreenPanels/MakeFeed.tscn" id="4_kkki3"] -[ext_resource type="Theme" uid="uid://b6nox1qqh50ub" path="res://themes/smallText.tres" id="5_widd7"] -[ext_resource type="StyleBox" uid="uid://bsv1daadkv4eq" path="res://styleboxes/topLeftPanel.tres" id="6_8m0pt"] +[ext_resource type="StyleBox" uid="uid://8pg3ry3y5wjv" path="res://styleboxes/centerRight.tres" id="5_3hym1"] [ext_resource type="PackedScene" uid="uid://beo6s1kudbbve" path="res://components/Scenes/FullscreenPanels/GameOver.tscn" id="6_10ay6"] [ext_resource type="Texture2D" uid="uid://k13cte17httt" path="res://resources/items/energy.svg" id="7_2om12"] -[ext_resource type="PackedScene" uid="uid://d1ulrvupa76ap" path="res://components/UI/ColorBar.tscn" id="9_44nw8"] +[ext_resource type="PackedScene" uid="uid://b07gqo6df0r5y" path="res://components/UI/Variants/VerticalColorBar.tscn" id="8_f4j2b"] [ext_resource type="StyleBox" uid="uid://ddnjus87wwlm8" path="res://styleboxes/leftPanel.tres" id="11_67ghp"] [ext_resource type="PackedScene" uid="uid://cksonrrx38k36" path="res://components/Scenes/FullscreenPanels/Pause.tscn" id="12_jkm6o"] [ext_resource type="PackedScene" uid="uid://dekcqdhrjs07u" path="res://components/Scenes/FullscreenPanels/Weapon.tscn" id="13_bmc24"] [ext_resource type="PackedScene" uid="uid://w2o3klbsssq3" path="res://components/Scenes/FullscreenPanels/Thanks.tscn" id="14_gp8lx"] +[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_kp2r0"] +bg_color = Color(0, 0, 0, 0.5) + +[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_kgnwf"] +bg_color = Color(1, 0, 0, 0.5) + +[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_egr4c"] +bg_color = Color(0, 1, 0, 0.5) + +[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_1xshu"] +bg_color = Color(1, 1, 1, 1) + [sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_ri8gw"] content_margin_left = 20.0 content_margin_top = 20.0 @@ -169,20 +180,28 @@ type = 3 [node name="energy" type="PanelContainer" parent="root"] z_index = 1 z_as_relative = false -custom_minimum_size = Vector2(300, 0) layout_mode = 1 anchors_preset = -1 -offset_left = -3.0 -offset_top = -3.0 -offset_right = 97.0 -offset_bottom = 14.0 -theme_override_styles/panel = ExtResource("6_8m0pt") +anchor_left = 1.0 +anchor_top = 0.4 +anchor_right = 1.0 +anchor_bottom = 0.6 +offset_left = -33.0 +offset_top = -70.0 +offset_right = 3.0 +offset_bottom = 70.0 +grow_horizontal = 0 +grow_vertical = 2 +theme_override_styles/panel = ExtResource("5_3hym1") [node name="container" type="VBoxContainer" parent="root/energy"] layout_mode = 2 +theme_override_constants/separation = 10 +alignment = 1 [node name="energy" type="HBoxContainer" parent="root/energy/container"] layout_mode = 2 +alignment = 1 [node name="icon" type="TextureRect" parent="root/energy/container/energy"] custom_minimum_size = Vector2(16, 16) @@ -192,27 +211,14 @@ size_flags_vertical = 4 texture = ExtResource("7_2om12") expand_mode = 1 -[node name="energy" type="Label" parent="root/energy/container/energy"] +[node name="percent" parent="root/energy/container" instance=ExtResource("8_f4j2b")] unique_name_in_owner = true layout_mode = 2 -theme = ExtResource("5_widd7") -text = "%current%" - -[node name="sep" type="Label" parent="root/energy/container/energy"] -layout_mode = 2 -theme = ExtResource("5_widd7") -text = "/" - -[node name="energyMax" type="Label" parent="root/energy/container/energy"] -unique_name_in_owner = true -layout_mode = 2 -theme = ExtResource("5_widd7") -text = "%max%" - -[node name="percent" parent="root/energy/container" instance=ExtResource("9_44nw8")] -unique_name_in_owner = true -custom_minimum_size = Vector2(0, 5) -layout_mode = 2 +size_flags_vertical = 3 +backBox = SubResource("StyleBoxFlat_kp2r0") +middleBox1 = SubResource("StyleBoxFlat_kgnwf") +middleBox2 = SubResource("StyleBoxFlat_egr4c") +frontBox = SubResource("StyleBoxFlat_1xshu") [node name="fields" type="PanelContainer" parent="root"] modulate = Color(1, 1, 1, 0) @@ -292,9 +298,8 @@ offset_top = 0.0 offset_bottom = 0.0 [node name="GameOver" parent="root/panels" instance=ExtResource("6_10ay6")] +visible = false layout_mode = 1 -offset_top = 0.0 -offset_bottom = 0.0 [node name="Pause" parent="root/panels" instance=ExtResource("12_jkm6o")] visible = false diff --git a/components/UI/Variants/VerticalColorBar.tscn b/components/UI/Variants/VerticalColorBar.tscn new file mode 100644 index 0000000..a5d6284 --- /dev/null +++ b/components/UI/Variants/VerticalColorBar.tscn @@ -0,0 +1,41 @@ +[gd_scene load_steps=7 format=3 uid="uid://b07gqo6df0r5y"] + +[ext_resource type="PackedScene" uid="uid://d1ulrvupa76ap" path="res://components/UI/ColorBar.tscn" id="1_345g7"] +[ext_resource type="Script" path="res://scripts/Statemachine/Variants/VerticalColorBar.gd" id="2_25su1"] + +[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_b46aq"] +bg_color = Color(0, 0, 0, 0.5) +corner_radius_top_left = 5 +corner_radius_top_right = 5 +corner_radius_bottom_right = 5 +corner_radius_bottom_left = 5 + +[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_jm5oe"] +bg_color = Color(1, 0, 0, 0.5) +corner_radius_top_left = 5 +corner_radius_top_right = 5 +corner_radius_bottom_right = 5 +corner_radius_bottom_left = 5 + +[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_w7upt"] +bg_color = Color(0, 1, 0, 0.5) +corner_radius_top_left = 5 +corner_radius_top_right = 5 +corner_radius_bottom_right = 5 +corner_radius_bottom_left = 5 + +[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_l12vy"] +bg_color = Color(1, 1, 1, 1) +corner_radius_top_left = 5 +corner_radius_top_right = 5 +corner_radius_bottom_right = 5 +corner_radius_bottom_left = 5 + +[node name="VerticalColorBar" instance=ExtResource("1_345g7")] +offset_right = 10.0 +offset_bottom = 100.0 +script = ExtResource("2_25su1") +backBox = SubResource("StyleBoxFlat_b46aq") +middleBox1 = SubResource("StyleBoxFlat_jm5oe") +middleBox2 = SubResource("StyleBoxFlat_w7upt") +frontBox = SubResource("StyleBoxFlat_l12vy") diff --git a/scripts/Contents/Wave.gd b/scripts/Contents/Wave.gd index c583997..22e4b56 100644 --- a/scripts/Contents/Wave.gd +++ b/scripts/Contents/Wave.gd @@ -17,12 +17,12 @@ static var presetWaves = { create(preload("res://components/Characters/Bear.tscn"), 0, 0, true, 19, INF, 10), ], "testBoss": [ - # create(preload("res://components/Characters/Chick.tscn"), 1, 1, true, 0, INF, 1), - # create(preload("res://components/Characters/Bear.tscn"), 1, 1, true, 0, INF, 1), + create(preload("res://components/Characters/Chick.tscn"), 1, 1, true, 0, INF, 1), + create(preload("res://components/Characters/Bear.tscn"), 1, 1, true, 0, INF, 1), create(preload("res://components/Characters/KukeMC.tscn"), 1, 1, true, 0, INF, 1), ] } -static var data = presetWaves["testBoss"] +static var data = presetWaves["normal"] static func create( entity_: PackedScene, diff --git a/scripts/Statemachine/EntityBase.gd b/scripts/Statemachine/EntityBase.gd index 678aca6..08ca07f 100644 --- a/scripts/Statemachine/EntityBase.gd +++ b/scripts/Statemachine/EntityBase.gd @@ -156,7 +156,7 @@ func _physics_process(_delta: float) -> void: if (isPlayer() or is_instance_valid(currentFocusedBoss)) and not charginup: ai() move_and_slide() - storeEnergy(randf_range(0.01, 0.15) * fields.get(FieldStore.Entity.ENERGY_REGENERATION), true) + storeEnergy(randf_range(0.01, 0.1) * fields.get(FieldStore.Entity.ENERGY_REGENERATION), true) trailParticle.emitting = trailing # 通用方法 diff --git a/scripts/Statemachine/UIState.gd b/scripts/Statemachine/UIState.gd index 8147420..c84ebac 100644 --- a/scripts/Statemachine/UIState.gd +++ b/scripts/Statemachine/UIState.gd @@ -2,8 +2,6 @@ extends CanvasLayer class_name UIState @onready var items = $"%items" -@onready var energyLabel: Label = $"%energy" -@onready var energyMaxLabel: Label = $"%energyMax" @onready var fields: VBoxContainer = $"%fields" @onready var fieldsAnimator: AnimationPlayer = $"%fieldsAnimator" @@ -21,14 +19,10 @@ func _ready(): energyPercent = $"%percent" itemCollect = $"%itemCollect" skillIconContainer = $"%skillContainer" - # for i in FieldStore.entityMap: - # print(FieldStore.entityMap[i]) func _process(_delta): bossbar.visible = !!bossbar.entity func _physics_process(_delta): if is_instance_valid(player): - energyLabel.text = "%.2f" % clamp(player.energy, 0, player.fields.get(FieldStore.Entity.MAX_ENERGY)) - energyMaxLabel.text = "%.1f" % player.fields.get(FieldStore.Entity.MAX_ENERGY) for i in items.get_children(): var item = i as ItemShow item.count = player.inventory.get(item.type) diff --git a/scripts/Statemachine/Variants/VerticalColorBar.gd b/scripts/Statemachine/Variants/VerticalColorBar.gd new file mode 100644 index 0000000..5c0ab56 --- /dev/null +++ b/scripts/Statemachine/Variants/VerticalColorBar.gd @@ -0,0 +1,8 @@ +@tool +extends ColorBar +class_name VerticalColorBar + +func _draw(): + draw_style_box(backBox, Rect2(0, 0, size.x, size.y)) + draw_style_box(middleBox2 if forwardDirection > 0 else middleBox1, Rect2(0, size.y * (1 - getPercent(middleValue)), size.x, size.y * getPercent(middleValue))) + draw_style_box(frontBox, Rect2(0, size.y * (1 - getPercent(frontValue)), size.x, size.y * getPercent(frontValue))) diff --git a/shaders/CooldownProgress.gdshader b/shaders/CooldownProgress.gdshader index 17c0c5a..71af89a 100644 --- a/shaders/CooldownProgress.gdshader +++ b/shaders/CooldownProgress.gdshader @@ -1,5 +1,5 @@ shader_type canvas_item; -uniform float progress:hint_range(0.0, 2.0, 0.01)=0.5; +uniform float progress:hint_range(-0.0, 2.0, 0.01)=0.5; uniform float backAlpha:hint_range(0.0, 1.0, 0.01)=0.25; 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; diff --git a/shaders/LightScan.gdshader b/shaders/LightScan.gdshader new file mode 100644 index 0000000..71af89a --- /dev/null +++ b/shaders/LightScan.gdshader @@ -0,0 +1,15 @@ +shader_type canvas_item; +uniform float progress:hint_range(-0.0, 2.0, 0.01)=0.5; +uniform float backAlpha:hint_range(0.0, 1.0, 0.01)=0.25; +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)