1
1
mirror of https://github.com/Rundll86/Dog-Lynx-And-HCN.git synced 2026-05-27 22:41:56 +08:00

feat(武器系统): 添加魔法导弹武器及配套子弹逻辑

实现魔法导弹武器系统,包括:
1. 新增HOLD_LOOP发射类型武器
2. 添加魔法导弹子弹类实现追踪和分裂逻辑
3. 修改武器基类支持循环攻击模式
4. 更新角色控制器支持新武器类型
5. 添加相关资源文件和配置
This commit is contained in:
2026-04-18 08:12:27 +08:00
parent 6129902a78
commit 2dd47a4f3e
11 changed files with 196 additions and 34 deletions
+30 -7
View File
@@ -6,7 +6,7 @@ enum EmitType {
HOLD_SHOOT,
CLICK_SHOOT,
CHARGE,
HOLD_ONCE
HOLD_LOOP
}
@export var avatarTexture: Texture2D = null
@@ -49,6 +49,7 @@ var cooldownTimer: CooldownTimer = null
var originalStore: Dictionary = {}
var chargedTime: float = 0
var attackSpeed: float = 1
var looping: bool = false
func _ready():
cooldownTimer = CooldownTimer.new()
@@ -188,19 +189,41 @@ func canAttackBy(entity: EntityBase):
cooldownTimer.speedScale = entity.fields.get(FieldStore.Entity.ATTACK_SPEED) * attackSpeed
return cooldownTimer.isCooldowned() and entity.isEnergyEnough(needEnergy) and checkAttack(entity)
func tryAttack(entity: EntityBase):
if canAttackBy(entity):
var result = await attack(entity)
if result:
cooldownTimer.start()
entity.useEnergy(needEnergy)
return result
if looping:
if checkAttack(entity):
return await attack(entity)
else:
exitLoop(entity)
else:
if canAttackBy(entity):
if emitType == EmitType.HOLD_LOOP:
var result = await loopStart(entity)
if result:
looping = true
cooldownTimer.start()
entity.useEnergy(needEnergy)
return result
else:
var result = await attack(entity)
if result:
cooldownTimer.start()
entity.useEnergy(needEnergy)
return result
func charged(base: float, percent: float):
return base * sqrt(1 + chargedTime / 15 * percent)
func exitLoop(entity: EntityBase):
if !looping: return
looping = false
loopExit(entity)
# 抽象
func update(_to: int, origin: Dictionary, _entity: EntityBase):
return origin
func loopStart(_entity: EntityBase):
pass
func checkAttack(_entity: EntityBase) -> bool:
return true
func attack(_entity: EntityBase):
pass
func loopExit(_entity: EntityBase):
pass