1
1
mirror of https://github.com/Rundll86/Dog-Lynx-And-HCN.git synced 2026-07-10 03:52:53 +08:00

feat(UI): 添加波次开始提示并优化提示框功能

- 在Wave.gd中添加波次开始时的UI提示
- 调整UI.tscn中提示框的布局和位置
- 修复TipBox.gd中实例化组件的错误
- 修改UIState.gd中提示框的显示逻辑,支持自动销毁
This commit is contained in:
2026-01-24 15:54:42 +08:00
parent 6be95a5658
commit a6ece59c71
4 changed files with 19 additions and 14 deletions
+2 -1
View File
@@ -286,9 +286,10 @@ theme_override_constants/separation = 10
[node name="tips" type="VBoxContainer" parent="root"] [node name="tips" type="VBoxContainer" parent="root"]
unique_name_in_owner = true unique_name_in_owner = true
layout_mode = 1 layout_mode = 1
anchors_preset = 2 anchors_preset = -1
anchor_top = 1.0 anchor_top = 1.0
anchor_bottom = 1.0 anchor_bottom = 1.0
offset_bottom = -100.0
grow_vertical = 0 grow_vertical = 0
[node name="panels" type="Control" parent="root"] [node name="panels" type="Control" parent="root"]
+1
View File
@@ -97,5 +97,6 @@ static func next(waves: Array):
wave = instance_from_id(wave.get_instance_id()) wave = instance_from_id(wave.get_instance_id())
EntityBase.generate(ComponentManager.getCharacter(wave.entity), wave.entityPosition, true, wave.isBoss) EntityBase.generate(ComponentManager.getCharacter(wave.entity), wave.entityPosition, true, wave.isBoss)
current += 1 current += 1
UIState.showTip("%d波开始!" % current, true)
static func startWith(wave: int): static func startWith(wave: int):
return wave - 1 return wave - 1
+9 -9
View File
@@ -8,17 +8,17 @@ class_name TipBox
@onready var animator: AnimationPlayer = $%animator @onready var animator: AnimationPlayer = $%animator
func _ready(): func _ready():
label.text = text label.text = text
animator.play("show") animator.play("show")
func _process(_delta): func _process(_delta):
label.text = text label.text = text
func destroy(): func destroy():
animator.play("hide") animator.play("hide")
await animator.animation_finished await animator.animation_finished
queue_free() queue_free()
static func create(applyText: String) -> TipBox: static func create(applyText: String) -> TipBox:
var box = ComponentManager.getUIComponent("TipBox") var box = ComponentManager.getUIComponent("TipBox").instantiate()
box.text = applyText box.text = applyText
return box return box
+7 -4
View File
@@ -1,7 +1,7 @@
extends CanvasLayer extends CanvasLayer
class_name UIState class_name UIState
static var items: PanelContainer static var items: HBoxContainer
static var fields: VBoxContainer static var fields: VBoxContainer
static var fieldsAnimator: AnimationPlayer static var fieldsAnimator: AnimationPlayer
static var player: EntityBase static var player: EntityBase
@@ -20,6 +20,9 @@ func _ready():
itemCollect = $%itemCollect itemCollect = $%itemCollect
skillIconContainer = $%skillContainer skillIconContainer = $%skillContainer
tips = $%tips tips = $%tips
items = $%items
fields = $%fields
fieldsAnimator = $%fieldsAnimator
setPanel("Starter") setPanel("Starter")
func _process(_delta): func _process(_delta):
bossbar.visible = !!bossbar.entity bossbar.visible = !!bossbar.entity
@@ -71,11 +74,11 @@ static func setPanel(targetName: String = "", args: Array = []):
panel.hidePanel() panel.hidePanel()
static func closeCurrentPanel(): static func closeCurrentPanel():
setPanel() setPanel()
static func showTip(text: String, destroyAfter: float = -1): static func showTip(text: String, destroyAfter: bool = false):
var box = TipBox.create(text) var box = TipBox.create(text)
tips.add_child(box) tips.add_child(box)
if destroyAfter > 0: if destroyAfter:
await TickTool.millseconds(destroyAfter * 1000) await TickTool.millseconds(len(text) * 500)
box.destroy() box.destroy()
else: else:
return box return box