mirror of
https://github.com/Rundll86/Dog-Lynx-And-HCN.git
synced 2026-05-27 22:41:56 +08:00
feat(UI): 改进提示框功能并添加Boss提醒
- 将TipBox的Label改为RichTextLabel以支持富文本 - 添加主题文件支持多种字体样式 - 修改showTip方法支持自定义显示时长 - 添加Boss波次提醒功能 - 调整TipBox场景的布局和样式
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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():
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user