mirror of
https://github.com/Rundll86/Dog-Lynx-And-HCN.git
synced 2026-05-28 06:51:54 +08:00
49172a0088
- 新增完美闪避判定逻辑,当移动速度达到阈值时触发 - 添加黄色字体颜色用于显示完美闪避文本 - 完美闪避时获得双倍能量奖励并显示"PERFECT MISS" - 普通闪避仍显示"MISS"并给予基础能量奖励
43 lines
1.3 KiB
GDScript
43 lines
1.3 KiB
GDScript
extends Node2D
|
|
class_name DamageLabel
|
|
|
|
@export var damage: float = 0
|
|
@export var crit: bool = false
|
|
@export var color1: Color = Color(1, 0, 0, 1)
|
|
@export var color2: Color = Color(0, 1, 0, 1)
|
|
@export var color3: Color = Color(0.5, 0.5, 0.5, 1)
|
|
@export var color4: Color = Color.YELLOW
|
|
|
|
@onready var label: Label = $"%label"
|
|
@onready var animator: AnimationPlayer = $"%animator"
|
|
|
|
func _ready():
|
|
label.label_settings = label.label_settings.duplicate()
|
|
var damageValue = round(abs(damage))
|
|
var damageSign = sign(damage)
|
|
if damageSign > 0:
|
|
label.label_settings.font_color = color1
|
|
label.text = "%s%s" % [damageValue, "!!!" if crit else ""]
|
|
elif damageSign < 0:
|
|
label.label_settings.font_color = color2
|
|
label.text = "+%s%s" % [damageValue, "!!!" if crit else ""]
|
|
else:
|
|
if crit:
|
|
label.label_settings.font_color = color4
|
|
label.text = "PERFECT MISS"
|
|
else:
|
|
label.label_settings.font_color = color3
|
|
label.text = "MISS"
|
|
animator.play("show")
|
|
await animator.animation_finished
|
|
queue_free()
|
|
|
|
static func create(spawnDamage: float, spawnCrit: bool, spawnPosition: Vector2, addToWorld: bool = true) -> DamageLabel:
|
|
var instance = preload("res://components/UI/DamageLabel.tscn").instantiate()
|
|
instance.damage = spawnDamage
|
|
instance.crit = spawnCrit
|
|
instance.position = spawnPosition
|
|
if addToWorld:
|
|
WorldManager.rootNode.add_child(instance)
|
|
return instance
|