1
1
mirror of https://github.com/Rundll86/Dog-Lynx-And-HCN.git synced 2026-05-27 22:41:56 +08:00

feat(武器系统): 增强武器描述模板功能并添加调试选项

为武器系统添加数据类型支持,包括数值、百分比和角度显示格式
添加debugRebuild选项用于编辑器调试
移除调试用的print语句
更新LGBT武器的场景配置和描述显示
This commit is contained in:
2025-09-06 08:17:10 +08:00
parent f2287d6ee7
commit 6c7778309d
5 changed files with 23 additions and 6 deletions
+2 -1
View File
@@ -18,6 +18,7 @@ store = {
"power": 0.3,
"trace": 2.0
}
storeType = Array[int]([0, 0, 1, 0])
descriptionTemplate = "发射$count条可追踪$trace秒,效率为$power的带状彩虹,每条造成$atk点伤害。"
needEnergy = 150.0
@@ -33,5 +34,5 @@ quality = 4
[node name="description" parent="container" index="2"]
size_flags_vertical = 3
text = "[center]发射[color=cyan]7.0[/color]条可追踪[color=cyan]2.0[/color]秒,效率为[color=cyan]0.3[/color]的带状彩虹,每条造成[color=cyan]20.0[/color]点伤害。[/center]"
text = "[center]发射[color=cyan]7.0[/color]条可追踪[color=cyan]2.0[/color]秒,效率为[color=cyan]30.0%[/color]的带状彩虹,每条造成[color=cyan]20.0[/color]点伤害。[/center]"
autowrap_mode = 2
+1
View File
@@ -1,3 +1,4 @@
@tool
extends Weapon
class_name LGBTWeapon
@@ -7,5 +7,4 @@ func update(to: int, origin: Dictionary, _entity: EntityBase):
func attack(entity: EntityBase):
var weaponPos = entity.findWeaponAnchor("normal")
BulletBase.generate(preload("res://components/Bullets/PurpleCrystal.tscn"), entity, weaponPos, (get_global_mouse_position() - weaponPos).angle())
print("test2")
return true
-1
View File
@@ -211,7 +211,6 @@ func tryAttack(type: int, needChargeUp: bool = false):
var done
if isPlayer():
done = weapon.attack(self)
print("test", done, weapon.name)
else:
done = attack(type)
if done:
+20 -3
View File
@@ -13,9 +13,13 @@ signal selected(applied: bool)
@export var store: Dictionary = {
"atk": 10
}
@export var storeType: Array[FieldStore.DataType] = [
FieldStore.DataType.VALUE
]
@export var descriptionTemplate: String = "造成$atk点伤害。"
@export var needEnergy: float = 0
@export var cooldown: float = 100
@export var debugRebuild: bool = false
@onready var avatarRect: TextureRect = $"%avatar"
@onready var nameLabel: WeaponName = $"%name"
@@ -33,8 +37,10 @@ func _ready():
)
cooldownTimer.cooldown = cooldown
rebuildInfo()
func _physics_process(_delta: float):
descriptionLabel.text = buildDescription()
debugRebuild = false # 只能在编辑器里打开
func _physics_process(_delta):
if debugRebuild:
rebuildInfo()
func allHad(entity: EntityBase) -> bool:
var allHave = true
@@ -66,6 +72,7 @@ func rebuildInfo():
nameLabel.quality = quality
nameLabel.typeTopic = typeTopic
energyLabel.text = "%.1f" % needEnergy
descriptionLabel.text = buildDescription()
for i in costsBox.get_children():
i.queue_free()
for i in range(min(costs.size(), costCounts.size())):
@@ -77,8 +84,18 @@ func rebuildInfo():
costsBox.add_child(costShow)
func buildDescription():
var result = descriptionTemplate
var i = 0
for key in store.keys():
result = result.replace("$" + key, "[color=cyan]%.1f[/color]" % readStore(key))
var data = store[key]
var type = storeType[i]
if type == FieldStore.DataType.VALUE:
data = "%.1f" % data
elif type == FieldStore.DataType.PERCENT:
data = ("%.1f" % (data * 100)) + "%"
elif type == FieldStore.DataType.ANGLE:
data = "%.1f°" % data
result = result.replace("$" + key, "[color=cyan]%s[/color]" % data)
i += 1
return "[center]%s[/center]" % result
func readStore(key: String, default: Variant = null):
return store.get(key, default)