1
1
mirror of https://github.com/Rundll86/Dog-Lynx-And-HCN.git synced 2026-06-01 00:41:54 +08:00

refactor(Statemachine): 优化冷却计时器及攻击冷却管理

重构CooldownTimer类,添加初始化方法支持自定义冷却时间
将EntityBase中的单一冷却计时器改为基于攻击类型的映射管理
简化Wave类中的预设波次数据结构,移除未使用的测试波次
This commit is contained in:
2025-09-13 19:55:21 +08:00
parent 3171c39915
commit c5d21b68ba
3 changed files with 21 additions and 15 deletions
+7 -1
View File
@@ -48,6 +48,9 @@ var fields = {
var attackCooldownMap = {
0: 100
}
var attackCooldowner = {
0: CooldownTimer.new()
}
var inventory = {
ItemStore.ItemType.BASEBALL: 500,
ItemStore.ItemType.BASKETBALL: 500,
@@ -88,7 +91,6 @@ var trailing: bool = false
var lastDirection: int = 1
var currentFocusedBoss: EntityBase = null
var charginup: bool = false
var cooldownTimer = CooldownTimer.new()
var weapons: Array[Weapon] = []
func _ready():
@@ -228,6 +230,10 @@ func tryAttack(type: int, needChargeUp: bool = false):
if isPlayer():
state = true
else:
var cooldownTimer: CooldownTimer
if !attackCooldowner.has(type):
attackCooldowner[type] = CooldownTimer.new()
cooldownTimer = attackCooldowner[type]
cooldownTimer.cooldown = attackCooldownMap.get(type, defaultCooldownUnit)
state = cooldownTimer.start()
if state: