1
1
mirror of https://github.com/Rundll86/Dog-Lynx-And-HCN.git synced 2026-05-30 16:01:53 +08:00
Files
Dog-Lynx-And-HCN/scripts/Contents/Characters/KukeMC.gd
T
fallingshrimp 895f468a4a refactor: 优化子弹生成逻辑中的变量命名和循环结构
使用更具描述性的变量名 countOfBullet 和 countOfBranch 替换原 count 和 count1
将嵌套循环的迭代变量改为更有意义的 bulletIndex 和 branchIndex
保持原有功能不变,提高代码可读性
2025-09-18 06:48:07 +08:00

43 lines
1.8 KiB
GDScript

extends EntityBase
class_name KukeMC
func register():
fields[FieldStore.Entity.MAX_HEALTH] = 2500
fields[FieldStore.Entity.MOVEMENT_SPEED] = 0.5
attackCooldownMap[0] = 2000
attackCooldownMap[1] = 5000
attackCooldownMap[2] = 6000
attackCooldownMap[3] = 2000
inventory[ItemStore.ItemType.APPLE] = INF
func ai():
PresetEntityAI.follow(self, currentFocusedBoss, 500)
for bullet in get_tree().get_nodes_in_group("bullets"):
if (
bullet is LGBTBullet and
bullet.position.distance_to(self.position) < 200
):
bullet.tryDestroy()
for i in len(attackCooldownMap.keys()):
tryAttack(i)
func attack(type):
if type == 0:
for i in randi_range(8, 16):
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:
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
child.masterMine = self
elif type == 2:
var countOfBullet = randi_range(40, 50)
var countOfBranch = randi_range(2, 4)
for bulletIndex in countOfBullet:
for branchIndex in countOfBranch:
fields[FieldStore.Entity.OFFSET_SHOOT] = 0
BulletBase.generate(preload("res://components/Bullets/PurpleCrystal.tscn"), self, findWeaponAnchor("normal"), deg_to_rad(360.0 / countOfBullet * bulletIndex + 360.0 / countOfBranch * branchIndex))
await TickTool.millseconds(100)
elif type == 3:
BulletBase.generate(preload("res://components/Bullets/BossAttack/KukeMC/HeavyCrystal.tscn"), self, findWeaponAnchor("normal"), position.angle_to_point(currentFocusedBoss.position))