diff --git a/components/Weapons/LGBT.tscn b/components/Weapons/LGBT.tscn index 57d2c6a..2af53cd 100644 --- a/components/Weapons/LGBT.tscn +++ b/components/Weapons/LGBT.tscn @@ -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 diff --git a/scripts/Contents/Weapons/LGBTWeapon.gd b/scripts/Contents/Weapons/LGBTWeapon.gd index 0665395..b52f1f2 100644 --- a/scripts/Contents/Weapons/LGBTWeapon.gd +++ b/scripts/Contents/Weapons/LGBTWeapon.gd @@ -1,3 +1,4 @@ +@tool extends Weapon class_name LGBTWeapon diff --git a/scripts/Contents/Weapons/PurpleCrystal.gd b/scripts/Contents/Weapons/PurpleCrystal.gd index 472e9ba..692e2f1 100644 --- a/scripts/Contents/Weapons/PurpleCrystal.gd +++ b/scripts/Contents/Weapons/PurpleCrystal.gd @@ -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 diff --git a/scripts/Statemachine/EntityBase.gd b/scripts/Statemachine/EntityBase.gd index aa55a99..db0867d 100644 --- a/scripts/Statemachine/EntityBase.gd +++ b/scripts/Statemachine/EntityBase.gd @@ -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: diff --git a/scripts/Structs/Weapon.gd b/scripts/Structs/Weapon.gd index 49217d7..df9d194 100644 --- a/scripts/Structs/Weapon.gd +++ b/scripts/Structs/Weapon.gd @@ -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)