mirror of
https://github.com/Rundll86/Dog-Lynx-And-HCN.git
synced 2026-05-28 06:51:54 +08:00
ac643e426b
实现新的招架球子弹类型(ParryBallBullet)及其相关行为 新增CycleTimer类用于管理子弹的周期性运动 在EntityBase中添加计时器管理功能,支持创建和应用周期计时器 添加招架球子弹的资源文件和相关配置
24 lines
684 B
GDScript
24 lines
684 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]
|
|
bullet.position = bullet.launcher.position + Vector2.from_angle(periodPercent(index)) * distance
|
|
func host(bullet: BulletBase):
|
|
bullets.append(bullet)
|