1
1
mirror of https://github.com/Rundll86/Dog-Lynx-And-HCN.git synced 2026-05-28 15:01:53 +08:00
Files
Dog-Lynx-And-HCN/scripts/Statemachine/CycleTimer.gd
T
fallingshrimp 238450bf11 feat(武器系统): 调整武器冷却时间并改进子弹轨迹效果
- 将Tree武器的冷却时间从500ms减少到200ms以提升攻击频率
- 修改CycleTimer子弹轨迹计算,增加垂直偏移和缩放效果
2026-03-18 06:49:11 +08:00

27 lines
770 B
GDScript

class_name CycleTimer
@export var period: float = 1
var startTime: float = 0
var running: bool = false
var distance: float = 200
var bullets: Array[BulletBase] = []
func start():
startTime = Time.get_ticks_msec()
running = true
func lifetime():
return Time.get_ticks_msec() - startTime
func periodPercent(count: int):
return lifetime() / period * deg_to_rad(360) - deg_to_rad(360.0 * count / len(bullets))
func apply():
bullets = bullets.filter(is_instance_valid)
for index in len(bullets):
var bullet = bullets[index]
var offset = Vector2.from_angle(periodPercent(index))
offset.y *= 0.5
bullet.position = bullet.launcher.position + offset * distance
bullet.scale = Vector2.ONE * (1 + offset.y)
func host(bullet: BulletBase):
bullets.append(bullet)