From ac77e3d581677a7e58f1555ad8e865ff1dd76d1b 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, 24 Jan 2026 20:07:06 +0800 Subject: [PATCH] =?UTF-8?q?feat(UI):=20=E6=94=B9=E8=BF=9B=E6=8F=90?= =?UTF-8?q?=E7=A4=BA=E6=A1=86=E5=8A=9F=E8=83=BD=E5=B9=B6=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?Boss=E6=8F=90=E9=86=92?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 将TipBox的Label改为RichTextLabel以支持富文本 - 添加主题文件支持多种字体样式 - 修改showTip方法支持自定义显示时长 - 添加Boss波次提醒功能 - 调整TipBox场景的布局和样式 --- components/UI/TipBox.tscn | 12 ++++++++++-- scripts/Contents/Wave.gd | 23 ++++++++++++++++++++++- scripts/Statemachine/TipBox.gd | 2 +- scripts/Statemachine/UIState.gd | 6 +++--- themes/bigTextAndBold.tres | 4 ++++ 5 files changed, 40 insertions(+), 7 deletions(-) diff --git a/components/UI/TipBox.tscn b/components/UI/TipBox.tscn index 45dc32d..b11ccea 100644 --- a/components/UI/TipBox.tscn +++ b/components/UI/TipBox.tscn @@ -1,6 +1,7 @@ -[gd_scene load_steps=7 format=3 uid="uid://caogpc2fnlrin"] +[gd_scene load_steps=8 format=3 uid="uid://caogpc2fnlrin"] [ext_resource type="Script" uid="uid://c1gqcwr6say6f" path="res://scripts/Statemachine/TipBox.gd" id="1_7vuk3"] +[ext_resource type="Theme" uid="uid://bje5cd08dyok7" path="res://themes/bigTextAndBold.tres" id="2_5pngc"] [sub_resource type="StyleBoxFlat" id="StyleBoxFlat_nooq4"] content_margin_left = 10.0 @@ -101,13 +102,20 @@ _data = { } [node name="TipBox" type="PanelContainer"] +offset_right = 79.0 +offset_bottom = 34.0 +scale = Vector2(1, 2) theme_override_styles/panel = SubResource("StyleBoxFlat_nooq4") script = ExtResource("1_7vuk3") -[node name="label" type="Label" parent="."] +[node name="label" type="RichTextLabel" parent="."] unique_name_in_owner = true layout_mode = 2 +theme = ExtResource("2_5pngc") +bbcode_enabled = true text = "nothing" +fit_content = true +autowrap_mode = 0 [node name="animator" type="AnimationPlayer" parent="."] unique_name_in_owner = true diff --git a/scripts/Contents/Wave.gd b/scripts/Contents/Wave.gd index d965837..a9b0ef0 100644 --- a/scripts/Contents/Wave.gd +++ b/scripts/Contents/Wave.gd @@ -82,6 +82,18 @@ static func entityCountOf(wave: Wave) -> int: elif !hasBoss(): return randi_range(ceil(wave.minCount), floor(wave.maxCount * (1 + GameRule.entityCountBoostPerWave * current))) return 0 +static func getNextBossInfo() -> Array: + var nextBossName = "" + var minWavesLeft = INF + for wave in data: + if wave.isBoss: + var wavesLeft = wave.from - current + if wavesLeft > 0 and wavesLeft < minWavesLeft: + minWavesLeft = wavesLeft + nextBossName = ComponentManager.getCharacter(wave.entity).instantiate().displayName + if minWavesLeft < INF: + return [nextBossName, minWavesLeft] + return [] static func spawn(center: Vector2) -> Array: var result: Array = [] for i in range(len(data)): @@ -97,6 +109,15 @@ static func next(waves: Array): wave = instance_from_id(wave.get_instance_id()) EntityBase.generate(ComponentManager.getCharacter(wave.entity), wave.entityPosition, true, wave.isBoss) current += 1 - UIState.showTip("第%d波开始!" % current, true) + UIState.showTip("第%d波开始!" % current, 500) + showNextBossReminder() +static func showNextBossReminder(): + var nextBossInfo = getNextBossInfo() + if nextBossInfo: + var bossName = nextBossInfo[0] + var wavesLeft = nextBossInfo[1] + if wavesLeft > 0: + UIState.showTip("Boss [b]%s[/b] 将在[b]%d[/b]波后到来!" % [bossName, wavesLeft], 500) + static func startWith(wave: int): return wave - 1 diff --git a/scripts/Statemachine/TipBox.gd b/scripts/Statemachine/TipBox.gd index 0a219f8..11f943d 100644 --- a/scripts/Statemachine/TipBox.gd +++ b/scripts/Statemachine/TipBox.gd @@ -4,7 +4,7 @@ class_name TipBox @export var text: String = "nothing" -@onready var label: Label = $%label +@onready var label: RichTextLabel = $%label @onready var animator: AnimationPlayer = $%animator func _ready(): diff --git a/scripts/Statemachine/UIState.gd b/scripts/Statemachine/UIState.gd index 8954be2..7dcaf16 100644 --- a/scripts/Statemachine/UIState.gd +++ b/scripts/Statemachine/UIState.gd @@ -74,11 +74,11 @@ static func setPanel(targetName: String = "", args: Array = []): panel.hidePanel() static func closeCurrentPanel(): setPanel() -static func showTip(text: String, destroyAfter: bool = false): +static func showTip(text: String, destroyAfter: float = -1): var box = TipBox.create(text) tips.add_child(box) - if destroyAfter: - await TickTool.millseconds(len(text) * 500) + if destroyAfter > 0: + await TickTool.millseconds(destroyAfter * len(text)) box.destroy() else: return box diff --git a/themes/bigTextAndBold.tres b/themes/bigTextAndBold.tres index acfb898..65403da 100644 --- a/themes/bigTextAndBold.tres +++ b/themes/bigTextAndBold.tres @@ -2,3 +2,7 @@ [resource] RichTextLabel/font_sizes/bold_font_size = 18 +RichTextLabel/font_sizes/bold_italics_font_size = 18 +RichTextLabel/font_sizes/italics_font_size = 18 +RichTextLabel/font_sizes/mono_font_size = 18 +RichTextLabel/font_sizes/normal_font_size = 18