mirror of
https://github.com/Rundll86/Dog-Lynx-And-HCN.git
synced 2026-05-28 06:51:54 +08:00
refactor: 使用ComponentManager统一管理资源加载
将所有直接使用`load("res://components/...")`加载资源的代码替换为通过`ComponentManager`统一管理的方式,提高代码的可维护性和资源管理的统一性
This commit is contained in:
@@ -39,7 +39,7 @@ func attack(type):
|
||||
playSound("attack0")
|
||||
for i in randi_range(20, 30):
|
||||
if !is_instance_valid(currentFocusedBoss): return false
|
||||
for bullet in BulletBase.generate(load("res://components/Bullets/BossAttack/Bear/ArrowSeven.tscn"), self, findWeaponAnchor("normal"), deg_to_rad(randf_range(0, 360))):
|
||||
for bullet in BulletBase.generate(ComponentManager.getBullet("ArrowSeven"), self, findWeaponAnchor("normal"), deg_to_rad(randf_range(0, 360))):
|
||||
bullet.tracer = currentFocusedBoss
|
||||
bullet.position += MathTool.randv2_range(50)
|
||||
await TickTool.millseconds(50)
|
||||
@@ -48,10 +48,10 @@ func attack(type):
|
||||
await sprintTo(currentFocusedBoss.position - Vector2(MathTool.randc_from([-300, 300]), 300), 0.25)
|
||||
var count = randi_range(6, 8)
|
||||
for i in range(count):
|
||||
BulletBase.generate(load("res://components/Bullets/BossAttack/Bear/SunDance.tscn"), self, weaponPos, deg_to_rad(360.0 / count * i))
|
||||
BulletBase.generate(ComponentManager.getBullet("SunDance"), self, weaponPos, deg_to_rad(360.0 / count * i))
|
||||
elif type == 2:
|
||||
for i in range(13):
|
||||
for bullet in BulletBase.generate(load("res://components/Bullets/BossAttack/Bear/ForeverRainbow.tscn"), self, weaponPos, 0):
|
||||
for bullet in BulletBase.generate(ComponentManager.getBullet("ForeverRainbow"), self, weaponPos, 0):
|
||||
bullet.rotation = 360 / 13.0 * i
|
||||
elif type == 3:
|
||||
if !is_instance_valid(currentFocusedBoss): return false
|
||||
@@ -61,7 +61,7 @@ func attack(type):
|
||||
currentInvinsible = true
|
||||
playSound("attack3")
|
||||
await TickTool.millseconds(500)
|
||||
BulletBase.generate(load("res://components/Bullets/BearSprint.tscn"), self, weaponPos, 0)
|
||||
BulletBase.generate(ComponentManager.getBullet("BearSprint"), self, weaponPos, 0)
|
||||
await trySprint()
|
||||
sprintParticle.emitting = false
|
||||
canRunAi = true
|
||||
@@ -73,7 +73,7 @@ func attack(type):
|
||||
var count = randi_range(8, 12)
|
||||
for i in range(count):
|
||||
if !is_instance_valid(currentFocusedBoss): return false
|
||||
for bullet in BulletBase.generate(load("res://components/Bullets/BossAttack/Bear/ArrowSeven.tscn"), self, findWeaponAnchor("normal"), deg_to_rad(360.0 / count * i)):
|
||||
for bullet in BulletBase.generate(ComponentManager.getBullet("ArrowSeven"), self, findWeaponAnchor("normal"), deg_to_rad(360.0 / count * i)):
|
||||
bullet.tracer = currentFocusedBoss
|
||||
await TickTool.millseconds(830.0 / count)
|
||||
return false
|
||||
@@ -82,7 +82,7 @@ func attack(type):
|
||||
var count = randi_range(20, 30)
|
||||
for i in range(count):
|
||||
if !is_instance_valid(currentFocusedBoss): return false
|
||||
for bullet in BulletBase.generate(load("res://components/Bullets/BossAttack/Bear/LightGun.tscn"), self, currentFocusedBoss.position, 0):
|
||||
for bullet in BulletBase.generate(ComponentManager.getBullet("LightGun"), self, currentFocusedBoss.position, 0):
|
||||
bullet.rotation = deg_to_rad(360.0 / count * i)
|
||||
await TickTool.millseconds(1670.0 / count)
|
||||
return false
|
||||
@@ -90,7 +90,7 @@ func attack(type):
|
||||
playSound("attack6")
|
||||
for i in 16:
|
||||
if !is_instance_valid(currentFocusedBoss): return false
|
||||
for bullet in BulletBase.generate(load("res://components/Bullets/BossAttack/Bear/LightGun.tscn"), self, currentFocusedBoss.position, 0):
|
||||
for bullet in BulletBase.generate(ComponentManager.getBullet("LightGun"), self, currentFocusedBoss.position, 0):
|
||||
bullet.position += MathTool.randv2_range(600)
|
||||
bullet.look_at(currentFocusedBoss.position + MathTool.randv2_range(50))
|
||||
await TickTool.millseconds(100)
|
||||
@@ -102,7 +102,7 @@ func attack(type):
|
||||
if !is_instance_valid(currentFocusedBoss): return false
|
||||
playSound("attack7")
|
||||
for i in 16:
|
||||
for bullet in BulletBase.generate(load("res://components/Bullets/BossAttack/Bear/LightGun.tscn"), self, currentFocusedBoss.position, 0):
|
||||
for bullet in BulletBase.generate(ComponentManager.getBullet("LightGun"), self, currentFocusedBoss.position, 0):
|
||||
bullet.rotation_degrees += initAngle
|
||||
bullet.rotation -= angle / 2
|
||||
bullet.rotation += angle / 16 * i
|
||||
|
||||
@@ -26,19 +26,19 @@ func attack(type):
|
||||
if type == 0:
|
||||
var weaponPos = findWeaponAnchor("normal")
|
||||
for i in randi_range(10, 20):
|
||||
BulletBase.generate(load("res://components/Bullets/Diamond.tscn"), self, weaponPos + MathTool.randv2_range(20), rotation + deg_to_rad(randf_range(-90, 90)))
|
||||
BulletBase.generate(ComponentManager.getBullet("Diamond"), self, weaponPos + MathTool.randv2_range(20), rotation + deg_to_rad(randf_range(-90, 90)))
|
||||
elif type == 1:
|
||||
var laserCount = randi_range(2, 4)
|
||||
for i in laserCount:
|
||||
BulletBase.generate(load("res://components/Bullets/ChickLaser.tscn"), self, texture.global_position, deg_to_rad(360.0 / laserCount * i))
|
||||
BulletBase.generate(ComponentManager.getBullet("ChickLaser"), self, texture.global_position, deg_to_rad(360.0 / laserCount * i))
|
||||
elif type == 2:
|
||||
var weaponPos = findWeaponAnchor("normal")
|
||||
var target = weaponPos.angle_to_point(currentFocusedBoss.position)
|
||||
firepot.global_rotation = target
|
||||
firepot.shot()
|
||||
BulletBase.generate(load("res://components/Bullets/FireScan.tscn"), self, weaponPos, target)
|
||||
BulletBase.generate(ComponentManager.getBullet("FireScan"), self, weaponPos, target)
|
||||
elif type == 3:
|
||||
BulletBase.generate(load("res://components/Bullets/ChickSprint.tscn"), self, position, 0)
|
||||
BulletBase.generate(ComponentManager.getBullet("ChickSprint"), self, position, 0)
|
||||
trySprint()
|
||||
return true
|
||||
func sprint():
|
||||
|
||||
@@ -14,5 +14,5 @@ func attack(type):
|
||||
if type == 0:
|
||||
var weaponPos = findWeaponAnchor("normal")
|
||||
for i in randi_range(1, 4):
|
||||
BulletBase.generate(load("res://components/Bullets/Star.tscn"), self, weaponPos, (currentFocusedBoss.position - position).angle())
|
||||
BulletBase.generate(ComponentManager.getBullet("Star"), self, weaponPos, (currentFocusedBoss.position - position).angle())
|
||||
return true
|
||||
|
||||
@@ -16,9 +16,9 @@ func ai():
|
||||
tryKill()
|
||||
func attack(type):
|
||||
if type == 0:
|
||||
BulletBase.generate(load("res://components/Bullets/PurpleCrystalSmall.tscn"), self, findWeaponAnchor("normal"), position.angle_to_point(currentFocusedBoss.position))
|
||||
BulletBase.generate(ComponentManager.getBullet("PurpleCrystalSmall"), self, findWeaponAnchor("normal"), position.angle_to_point(currentFocusedBoss.position))
|
||||
await TickTool.millseconds(randi_range(5, 25))
|
||||
elif type == 1:
|
||||
BulletBase.generate(load("res://components/Bullets/BossAttack/KukeMC/HeavyCrystal.tscn"), self, findWeaponAnchor("normal"), position.angle_to_point(currentFocusedBoss.position))
|
||||
BulletBase.generate(ComponentManager.getBullet("HeavyCrystal"), self, findWeaponAnchor("normal"), position.angle_to_point(currentFocusedBoss.position))
|
||||
func kill():
|
||||
masterMine.tryHeal(100)
|
||||
|
||||
@@ -34,11 +34,11 @@ func attack(type):
|
||||
if type == 0:
|
||||
for i in randi_range(8, 16):
|
||||
fields[FieldStore.Entity.OFFSET_SHOOT] = 25
|
||||
BulletBase.generate(load("res://components/Bullets/PurpleCrystal.tscn"), self, findWeaponAnchor("normal"), position.angle_to_point(currentFocusedBoss.position))
|
||||
BulletBase.generate(ComponentManager.getBullet("PurpleCrystal"), 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 and canSummon:
|
||||
for i in randi_range(1, 2):
|
||||
var child = EntityBase.generate(load("res://components/Characters/KukeChild.tscn"), position + MathTool.randv2_range(500))
|
||||
var child = EntityBase.generate(ComponentManager.getCharacter("KukeChild"), position + MathTool.randv2_range(500))
|
||||
child.currentFocusedBoss = currentFocusedBoss
|
||||
child.masterMine = self
|
||||
elif type == 2:
|
||||
@@ -47,7 +47,7 @@ func attack(type):
|
||||
for bulletIndex in countOfBullet:
|
||||
for branchIndex in countOfBranch:
|
||||
fields[FieldStore.Entity.OFFSET_SHOOT] = 0
|
||||
BulletBase.generate(load("res://components/Bullets/PurpleCrystal.tscn"), self, findWeaponAnchor("normal"), deg_to_rad(360.0 / countOfBullet * bulletIndex + 360.0 / countOfBranch * branchIndex))
|
||||
BulletBase.generate(ComponentManager.getBullet("PurpleCrystal"), self, findWeaponAnchor("normal"), deg_to_rad(360.0 / countOfBullet * bulletIndex + 360.0 / countOfBranch * branchIndex))
|
||||
await TickTool.millseconds(100)
|
||||
elif type == 3:
|
||||
BulletBase.generate(load("res://components/Bullets/BossAttack/KukeMC/HeavyCrystal.tscn"), self, findWeaponAnchor("normal"), position.angle_to_point(currentFocusedBoss.position))
|
||||
BulletBase.generate(ComponentManager.getBullet("HeavyCrystal"), self, findWeaponAnchor("normal"), position.angle_to_point(currentFocusedBoss.position))
|
||||
|
||||
Reference in New Issue
Block a user