mirror of
https://github.com/Rundll86/Dog-Lynx-And-HCN.git
synced 2026-05-29 23:41:54 +08:00
feat(战斗系统): 添加KukeMC召唤机制及子实体管理
为KukeMC添加召唤子实体KukeChild的功能,并在血量低于25%时自动清除所有子实体并恢复血量 在EntityBase中添加tryKill方法统一处理实体销毁逻辑 在EntityTool中添加按类查找实体的工具方法
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
extends EntityBase
|
||||
class_name KukeChild
|
||||
|
||||
var masterMine: KukeMC
|
||||
|
||||
@@ -12,11 +13,12 @@ func ai():
|
||||
tryAttack(0)
|
||||
tryAttack(1)
|
||||
if timeLived() > 10000:
|
||||
masterMine.tryHeal(100)
|
||||
tryDie(null)
|
||||
tryKill()
|
||||
func attack(type):
|
||||
if type == 0:
|
||||
BulletBase.generate(preload("res://components/Bullets/PurpleCrystalSmall.tscn"), self, findWeaponAnchor("normal"), position.angle_to_point(currentFocusedBoss.position))
|
||||
await TickTool.millseconds(randi_range(5, 25))
|
||||
elif type == 1:
|
||||
BulletBase.generate(preload("res://components/Bullets/BossAttack/KukeMC/HeavyCrystal.tscn"), self, findWeaponAnchor("normal"), position.angle_to_point(currentFocusedBoss.position))
|
||||
func kill():
|
||||
masterMine.tryHeal(100)
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
extends EntityBase
|
||||
class_name KukeMC
|
||||
|
||||
var canSummon: bool = true
|
||||
|
||||
func register():
|
||||
fields[FieldStore.Entity.MAX_HEALTH] = 3000
|
||||
fields[FieldStore.Entity.MOVEMENT_SPEED] = 0.5
|
||||
@@ -9,6 +11,15 @@ func register():
|
||||
attackCooldownMap[2] = 20000
|
||||
attackCooldownMap[3] = 2000
|
||||
inventory[ItemStore.ItemType.APPLE] = INF
|
||||
healthChanged.connect(
|
||||
func(h):
|
||||
if h < fields[FieldStore.Entity.MAX_HEALTH] * 0.25:
|
||||
canSummon = false
|
||||
for child in EntityTool.findEntityByClass("KukeChild", get_tree()):
|
||||
if child.masterMine == self:
|
||||
child.tryKill()
|
||||
tryHeal(200)
|
||||
)
|
||||
func ai():
|
||||
PresetEntityAI.follow(self, currentFocusedBoss, 500)
|
||||
for bullet in get_tree().get_nodes_in_group("bullets"):
|
||||
@@ -25,7 +36,7 @@ func attack(type):
|
||||
fields[FieldStore.Entity.OFFSET_SHOOT] = 25
|
||||
BulletBase.generate(preload("res://components/Bullets/PurpleCrystal.tscn"), self, findWeaponAnchor("normal"), position.angle_to_point(currentFocusedBoss.position))
|
||||
await TickTool.millseconds(randi_range(10, 50))
|
||||
elif type == 1 and health < fields[FieldStore.Entity.MAX_HEALTH] * 0.5:
|
||||
elif type == 1 and health < fields[FieldStore.Entity.MAX_HEALTH] * 0.5 and canSummon:
|
||||
for i in randi_range(1, 2):
|
||||
var child = EntityBase.generate(preload("res://components/Characters/KukeChild.tscn"), position + MathTool.randv2_range(500))
|
||||
child.currentFocusedBoss = currentFocusedBoss
|
||||
|
||||
@@ -344,6 +344,9 @@ func playSound(type: String):
|
||||
cloned.play()
|
||||
await cloned.finished
|
||||
cloned.queue_free()
|
||||
func tryKill():
|
||||
kill()
|
||||
await tryDie()
|
||||
|
||||
func getTrackingAnchor() -> Vector2:
|
||||
return hurtbox.get_node("hitbox").global_position
|
||||
@@ -376,6 +379,8 @@ func exitStage(_stage: int):
|
||||
pass
|
||||
func enterStage(_stage: int):
|
||||
pass
|
||||
func kill():
|
||||
pass
|
||||
|
||||
static func generate(
|
||||
entity: PackedScene,
|
||||
|
||||
@@ -24,3 +24,10 @@ static func findClosetEntity(to: Vector2, fromTree: SceneTree, player: bool = fa
|
||||
return result
|
||||
static func findClosetPlayer(to: Vector2, fromTree: SceneTree, excludes: Array[EntityBase] = []) -> EntityBase:
|
||||
return findClosetEntity(to, fromTree, true, false, excludes)
|
||||
static func findEntityByClass(cls: String, fromTree: SceneTree) -> Array[EntityBase]:
|
||||
var results: Array[EntityBase] = []
|
||||
var nodes = fromTree.get_nodes_in_group("mobs") + fromTree.get_nodes_in_group("players")
|
||||
for entity in nodes:
|
||||
if entity.get_class() == cls:
|
||||
results.append(entity)
|
||||
return results
|
||||
|
||||
Reference in New Issue
Block a user