mirror of
https://github.com/Rundll86/Dog-Lynx-And-HCN.git
synced 2026-06-02 09:21:54 +08:00
feat(战斗系统): 添加招架球子弹和循环计时器功能
实现新的招架球子弹类型(ParryBallBullet)及其相关行为 新增CycleTimer类用于管理子弹的周期性运动 在EntityBase中添加计时器管理功能,支持创建和应用周期计时器 添加招架球子弹的资源文件和相关配置
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
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)
|
||||
Reference in New Issue
Block a user