1
1
mirror of https://github.com/Rundll86/Dog-Lynx-And-HCN.git synced 2026-06-08 04:37:13 +08:00

feat(角色): 添加熊boss的新攻击方式和音效

添加熊boss的四种攻击方式:
1. 箭雨攻击(ArrowSeven)
2. 太阳舞攻击(SunDance)
3. 永恒彩虹攻击(ForeverRainbow)
4. 冲刺攻击(BearSprint)

新增对应攻击音效资源
调整子弹追踪和伤害计算逻辑
添加冲刺粒子特效
This commit is contained in:
2025-09-13 19:55:51 +08:00
parent c5d21b68ba
commit 97ec81f05e
19 changed files with 426 additions and 54 deletions
@@ -27,10 +27,10 @@ func ai():
if timeLived() <= forwardTime:
speed = 10 * ((forwardTime - timeLived()) / forwardTime)
elif forwarded:
if timeLived() < forwardTime + 1000:
if timeLived() < forwardTime + 2000:
speed = clamp((timeLived() - forwardTime) / 75, 0, 30)
if is_instance_valid(tracer):
PresetBulletAI.trace(self, tracer.position, 0.1)
PresetBulletAI.trace(self, tracer.position, 0.03)
else:
forwarded = true
@@ -0,0 +1,20 @@
extends BulletBase
@export var allColor: GradientTexture1D = null
var myColor: Color
func register():
damage = 5
penerate = 1
func spawn():
myColor = allColor.gradient.sample(randf())
setColor(myColor)
func ai():
speed = (11000 - timeLived()) / 11000 * initialSpeed
rotation_degrees += speed / 10
PresetBulletAI.forward(self, rotation)
func setColor(color: Color):
texture.modulate = color
+2 -2
View File
@@ -5,10 +5,10 @@ func register():
speed = 0
penerate = 1
func ai():
damage = launcher.velocity.length()
damage = launcher.velocity.length() / 300
PresetBulletAI.lockLauncher(self, launcher, true)
if !launcher.sprinting:
tryDestroy()
func destroy(beacuseMap: bool):
if beacuseMap:
launcher.takeDamage(self, 0.5)
launcher.takeDamage(self, MathTool.rate(0.5))
+30 -8
View File
@@ -1,23 +1,45 @@
extends EntityBase
class_name Bear # 攻击方式模仿泰拉瑞亚光之女皇
@onready var sprintParticle: GPUParticles2D = $"%sprintParticle"
func register():
fields[FieldStore.Entity.MAX_HEALTH] = 2000
fields[FieldStore.Entity.MOVEMENT_SPEED] = 0.25
attackCooldownMap[0] = 100
attackCooldownMap[1] = 100
attackCooldownMap[0] = 3000
attackCooldownMap[1] = 10000
attackCooldownMap[2] = 8000
attackCooldownMap[3] = 13000
sprintMultiplier = 120
func spawn():
texture.play("walk")
func ai():
PresetEntityAI.follow(self, currentFocusedBoss, 0)
tryAttack(0)
tryAttack(1)
for i in range(4):
tryAttack(i)
func attack(type):
var weaponPos = findWeaponAnchor("normal")
if type == 0:
for bullet in BulletBase.generate(preload("res://components/Bullets/BossAttack/Bear/ArrowSeven.tscn"), self, weaponPos, deg_to_rad(randf_range(0, 360))):
bullet.tracer = currentFocusedBoss
for i in range(20):
for bullet in BulletBase.generate(preload("res://components/Bullets/BossAttack/Bear/ArrowSeven.tscn"), self, weaponPos, deg_to_rad(randf_range(0, 360))):
bullet.tracer = currentFocusedBoss
elif type == 1:
for bullet in BulletBase.generate(preload("res://components/Bullets/BossAttack/Bear/SunDance.tscn"), self, weaponPos, deg_to_rad(randf_range(0, 360))):
bullet.damage = 1
await sprintTo(currentFocusedBoss.position - Vector2(200, 200), 0.25)
for i in range(6):
BulletBase.generate(preload("res://components/Bullets/BossAttack/Bear/SunDance.tscn"), self, weaponPos, deg_to_rad(randf_range(0, 360)))
elif type == 2:
for i in range(13):
for bullet in BulletBase.generate(preload("res://components/Bullets/BossAttack/Bear/ForeverRainbow.tscn"), self, weaponPos, 0):
bullet.rotation = 360 / 13.0 * i
elif type == 3:
await sprintTo(currentFocusedBoss.position - Vector2(500, 0), 0.25)
sprintParticle.emitting = true
canRunAi = false
await TickTool.millseconds(1500)
BulletBase.generate(preload("res://components/Bullets/BearSprint.tscn"), self, weaponPos, 0)
await trySprint()
sprintParticle.emitting = false
canRunAi = true
return true
func sprint():
move((currentFocusedBoss.position - position).normalized() * sprintMultiplier * Vector2(1, 0), true)
+2
View File
@@ -26,8 +26,10 @@ var spawnInWhere: Vector2 = Vector2.ZERO
var destroying: bool = false
var isChildSplit: bool = false
var isChildRefract: bool = false
var initialSpeed: float = 0
func _ready():
initialSpeed = speed
register()
area_entered.connect(hit)
spawnInWhen = WorldManager.getTime()
+12 -4
View File
@@ -92,6 +92,7 @@ var lastDirection: int = 1
var currentFocusedBoss: EntityBase = null
var charginup: bool = false
var weapons: Array[Weapon] = []
var canRunAi: bool = true
func _ready():
register()
@@ -155,7 +156,7 @@ func _physics_process(_delta: float) -> void:
sprinting = false
else:
velocity = Vector2.ZERO
if (isPlayer() or is_instance_valid(currentFocusedBoss)) and not charginup:
if (isPlayer() or is_instance_valid(currentFocusedBoss)) and not charginup and canRunAi:
ai()
move_and_slide()
storeEnergy(randf_range(0.01, 0.1) * fields.get(FieldStore.Entity.ENERGY_REGENERATION), true)
@@ -242,11 +243,11 @@ func tryAttack(type: int, needChargeUp: bool = false):
await EffectController.create(preload("res://components/Effects/AttackStar.tscn"), damageAnchor.global_position).shot()
charginup = false
if isPlayer():
if weapon.tryAttack(self):
if await weapon.tryAttack(self):
weapon.playSound("attack")
else:
if attack(type):
playSound("attack" + str(type))
attack(type)
playSound("attack" + str(type))
return state
func trySprint():
trailing = true
@@ -255,6 +256,13 @@ func trySprint():
sprinting = true
await TickTool.until(func(): return !sprinting)
trailing = false
func sprintTo(target: Vector2, speed: float):
await TickTool.until(
func():
position += (target - position) * speed
return position.distance_to(target) < 10
)
position = target
func tryDie(by: BulletBase):
if is_queued_for_deletion(): return
for drop in range(min(len(drops), len(dropCounts))):
+1 -1
View File
@@ -100,7 +100,7 @@ func playSound(sound: String):
func tryAttack(entity: EntityBase):
if cooldownTimer.start():
if entity.useEnergy(needEnergy):
return attack(entity)
return await attack(entity)
# 抽象
func update(_to: int, origin: Dictionary, _entity: EntityBase):