From 4d8969c47d5c597098d404d4f7a73ec3b2f8cda0 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: Sat, 6 Sep 2025 15:24:50 +0800 Subject: [PATCH] =?UTF-8?q?feat(UI):=20=E6=B7=BB=E5=8A=A0=E6=8A=80?= =?UTF-8?q?=E8=83=BD=E5=9B=BE=E6=A0=87=E6=98=BE=E7=A4=BA=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 在UI中添加技能图标容器,并为每个武器创建对应的技能图标 初始化武器冷却计时器,修复武器冷却时间未设置的问题 --- components/Scenes/UI.tscn | 21 ++++++++++++++++++++- scripts/Statemachine/EntityBase.gd | 4 ++++ scripts/Statemachine/SkillIcon.gd | 1 + scripts/Statemachine/UIState.gd | 2 ++ scripts/Structs/Weapon.gd | 5 +++-- 5 files changed, 30 insertions(+), 3 deletions(-) diff --git a/components/Scenes/UI.tscn b/components/Scenes/UI.tscn index 70364d7..e51d439 100644 --- a/components/Scenes/UI.tscn +++ b/components/Scenes/UI.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=19 format=3 uid="uid://dfwg750a47ggx"] +[gd_scene load_steps=20 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"] @@ -106,6 +106,9 @@ _data = { "show": SubResource("Animation_2xajo") } +[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_12otr"] +content_margin_right = 10.0 + [node name="UI" type="CanvasLayer"] process_mode = 3 script = ExtResource("1_f00a6") @@ -239,6 +242,22 @@ libraries = { "": SubResource("AnimationLibrary_37e4s") } +[node name="skills" type="PanelContainer" parent="root"] +layout_mode = 1 +anchors_preset = 6 +anchor_left = 1.0 +anchor_top = 0.5 +anchor_right = 1.0 +anchor_bottom = 0.5 +offset_left = -10.0 +grow_horizontal = 0 +grow_vertical = 2 +theme_override_styles/panel = SubResource("StyleBoxEmpty_12otr") + +[node name="skillContainer" type="VBoxContainer" parent="root/skills"] +unique_name_in_owner = true +layout_mode = 2 + [node name="itemCollect" type="VBoxContainer" parent="root"] unique_name_in_owner = true layout_mode = 1 diff --git a/scripts/Statemachine/EntityBase.gd b/scripts/Statemachine/EntityBase.gd index b1d0813..ad97296 100644 --- a/scripts/Statemachine/EntityBase.gd +++ b/scripts/Statemachine/EntityBase.gd @@ -111,6 +111,10 @@ func _ready(): else: UIState.energyPercent.setCurrent(newEnergy) ) + for i in weapons: + var icon: SkillIcon = preload("res://components/Abstracts/SkillIconBase.tscn").instantiate() + icon.weapon = i + UIState.skillIconContainer.add_child(icon) else: currentFocusedBoss = get_tree().get_nodes_in_group("players")[0] applyLevel() diff --git a/scripts/Statemachine/SkillIcon.gd b/scripts/Statemachine/SkillIcon.gd index 47a725b..36d6d8e 100644 --- a/scripts/Statemachine/SkillIcon.gd +++ b/scripts/Statemachine/SkillIcon.gd @@ -1,4 +1,5 @@ extends PanelContainer +class_name SkillIcon @export var weapon: Weapon = null; diff --git a/scripts/Statemachine/UIState.gd b/scripts/Statemachine/UIState.gd index bc0d852..f1021f5 100644 --- a/scripts/Statemachine/UIState.gd +++ b/scripts/Statemachine/UIState.gd @@ -13,12 +13,14 @@ static var currentPanel: FullscreenPanelBase = null static var panels: Control static var energyPercent: ColorBar static var itemCollect: VBoxContainer +static var skillIconContainer: VBoxContainer func _ready(): bossbar = $"%bossbar" panels = $"%panels" energyPercent = $"%percent" itemCollect = $"%itemCollect" + skillIconContainer = $"%skillContainer" func _process(_delta): bossbar.visible = !!bossbar.entity func _physics_process(_delta): diff --git a/scripts/Structs/Weapon.gd b/scripts/Structs/Weapon.gd index 0e7fe29..36fbf5e 100644 --- a/scripts/Structs/Weapon.gd +++ b/scripts/Structs/Weapon.gd @@ -27,16 +27,17 @@ class_name Weapon @onready var updateButton: Button = $"%updateBtn" @onready var sounds: Node2D = $"%sounds" -var cooldownTimer = CooldownTimer.new() +var cooldownTimer: CooldownTimer = null var originalStore: Dictionary = {} func _ready(): + cooldownTimer = CooldownTimer.new() + cooldownTimer.cooldown = cooldown originalStore = store updateButton.pressed.connect( func(): apply(UIState.player) ) - cooldownTimer.cooldown = cooldown for i in sounds.get_children(): i.process_mode = ProcessMode.PROCESS_MODE_ALWAYS rebuildInfo()