mirror of
https://github.com/Rundll86/Dog-Lynx-And-HCN.git
synced 2026-05-28 06:51:54 +08:00
feat(武器系统): 增强武器描述模板功能并添加调试选项
为武器系统添加数据类型支持,包括数值、百分比和角度显示格式 添加debugRebuild选项用于编辑器调试 移除调试用的print语句 更新LGBT武器的场景配置和描述显示
This commit is contained in:
@@ -18,6 +18,7 @@ store = {
|
|||||||
"power": 0.3,
|
"power": 0.3,
|
||||||
"trace": 2.0
|
"trace": 2.0
|
||||||
}
|
}
|
||||||
|
storeType = Array[int]([0, 0, 1, 0])
|
||||||
descriptionTemplate = "发射$count条可追踪$trace秒,效率为$power的带状彩虹,每条造成$atk点伤害。"
|
descriptionTemplate = "发射$count条可追踪$trace秒,效率为$power的带状彩虹,每条造成$atk点伤害。"
|
||||||
needEnergy = 150.0
|
needEnergy = 150.0
|
||||||
|
|
||||||
@@ -33,5 +34,5 @@ quality = 4
|
|||||||
|
|
||||||
[node name="description" parent="container" index="2"]
|
[node name="description" parent="container" index="2"]
|
||||||
size_flags_vertical = 3
|
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
|
autowrap_mode = 2
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
@tool
|
||||||
extends Weapon
|
extends Weapon
|
||||||
class_name LGBTWeapon
|
class_name LGBTWeapon
|
||||||
|
|
||||||
|
|||||||
@@ -7,5 +7,4 @@ func update(to: int, origin: Dictionary, _entity: EntityBase):
|
|||||||
func attack(entity: EntityBase):
|
func attack(entity: EntityBase):
|
||||||
var weaponPos = entity.findWeaponAnchor("normal")
|
var weaponPos = entity.findWeaponAnchor("normal")
|
||||||
BulletBase.generate(preload("res://components/Bullets/PurpleCrystal.tscn"), entity, weaponPos, (get_global_mouse_position() - weaponPos).angle())
|
BulletBase.generate(preload("res://components/Bullets/PurpleCrystal.tscn"), entity, weaponPos, (get_global_mouse_position() - weaponPos).angle())
|
||||||
print("test2")
|
|
||||||
return true
|
return true
|
||||||
|
|||||||
@@ -211,7 +211,6 @@ func tryAttack(type: int, needChargeUp: bool = false):
|
|||||||
var done
|
var done
|
||||||
if isPlayer():
|
if isPlayer():
|
||||||
done = weapon.attack(self)
|
done = weapon.attack(self)
|
||||||
print("test", done, weapon.name)
|
|
||||||
else:
|
else:
|
||||||
done = attack(type)
|
done = attack(type)
|
||||||
if done:
|
if done:
|
||||||
|
|||||||
@@ -13,9 +13,13 @@ signal selected(applied: bool)
|
|||||||
@export var store: Dictionary = {
|
@export var store: Dictionary = {
|
||||||
"atk": 10
|
"atk": 10
|
||||||
}
|
}
|
||||||
|
@export var storeType: Array[FieldStore.DataType] = [
|
||||||
|
FieldStore.DataType.VALUE
|
||||||
|
]
|
||||||
@export var descriptionTemplate: String = "造成$atk点伤害。"
|
@export var descriptionTemplate: String = "造成$atk点伤害。"
|
||||||
@export var needEnergy: float = 0
|
@export var needEnergy: float = 0
|
||||||
@export var cooldown: float = 100
|
@export var cooldown: float = 100
|
||||||
|
@export var debugRebuild: bool = false
|
||||||
|
|
||||||
@onready var avatarRect: TextureRect = $"%avatar"
|
@onready var avatarRect: TextureRect = $"%avatar"
|
||||||
@onready var nameLabel: WeaponName = $"%name"
|
@onready var nameLabel: WeaponName = $"%name"
|
||||||
@@ -33,8 +37,10 @@ func _ready():
|
|||||||
)
|
)
|
||||||
cooldownTimer.cooldown = cooldown
|
cooldownTimer.cooldown = cooldown
|
||||||
rebuildInfo()
|
rebuildInfo()
|
||||||
func _physics_process(_delta: float):
|
debugRebuild = false # 只能在编辑器里打开
|
||||||
descriptionLabel.text = buildDescription()
|
func _physics_process(_delta):
|
||||||
|
if debugRebuild:
|
||||||
|
rebuildInfo()
|
||||||
|
|
||||||
func allHad(entity: EntityBase) -> bool:
|
func allHad(entity: EntityBase) -> bool:
|
||||||
var allHave = true
|
var allHave = true
|
||||||
@@ -66,6 +72,7 @@ func rebuildInfo():
|
|||||||
nameLabel.quality = quality
|
nameLabel.quality = quality
|
||||||
nameLabel.typeTopic = typeTopic
|
nameLabel.typeTopic = typeTopic
|
||||||
energyLabel.text = "%.1f" % needEnergy
|
energyLabel.text = "%.1f" % needEnergy
|
||||||
|
descriptionLabel.text = buildDescription()
|
||||||
for i in costsBox.get_children():
|
for i in costsBox.get_children():
|
||||||
i.queue_free()
|
i.queue_free()
|
||||||
for i in range(min(costs.size(), costCounts.size())):
|
for i in range(min(costs.size(), costCounts.size())):
|
||||||
@@ -77,8 +84,18 @@ func rebuildInfo():
|
|||||||
costsBox.add_child(costShow)
|
costsBox.add_child(costShow)
|
||||||
func buildDescription():
|
func buildDescription():
|
||||||
var result = descriptionTemplate
|
var result = descriptionTemplate
|
||||||
|
var i = 0
|
||||||
for key in store.keys():
|
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
|
return "[center]%s[/center]" % result
|
||||||
func readStore(key: String, default: Variant = null):
|
func readStore(key: String, default: Variant = null):
|
||||||
return store.get(key, default)
|
return store.get(key, default)
|
||||||
|
|||||||
Reference in New Issue
Block a user