1
1
mirror of https://github.com/Rundll86/Dog-Lynx-And-HCN.git synced 2026-05-28 06:51:54 +08:00

refactor(MathTool): 重命名随机数相关方法以提高可读性

将 randv2_range 重命名为 randomVector2In,randc_from 重命名为 randomChoiceFrom,randc_from_weights 重命名为 randChoiceWeightsFrom,并新增 randomRingPoint 方法
This commit is contained in:
2025-12-14 15:06:22 +08:00
parent 74d3e03fef
commit 2232c9148a
12 changed files with 30 additions and 28 deletions
+6 -6
View File
@@ -52,11 +52,11 @@ func attack(type):
if !is_instance_valid(currentFocusedBoss): return false
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)
bullet.position += MathTool.randomVector2In(50)
await TickTool.millseconds(50)
return false
elif type == 1:
await sprintTo(currentFocusedBoss.position - Vector2(MathTool.randc_from([-300, 300]), 300), 0.25)
await sprintTo(currentFocusedBoss.position - Vector2(MathTool.randomChoiceFrom([-300, 300]), 300), 0.25)
var count = randi_range(6, 8)
for i in range(count):
BulletBase.generate(ComponentManager.getBullet("SunDance"), self, weaponPos, deg_to_rad(360.0 / count * i))
@@ -66,7 +66,7 @@ func attack(type):
bullet.rotation = 360 / 13.0 * i
elif type == 3:
if !is_instance_valid(currentFocusedBoss): return false
await sprintTo(currentFocusedBoss.position - Vector2(MathTool.randc_from([500, -500]), 0), 0.25)
await sprintTo(currentFocusedBoss.position - Vector2(MathTool.randomChoiceFrom([500, -500]), 0), 0.25)
sprintParticle.emitting = true
canRunAi = false
currentInvinsible = true
@@ -76,7 +76,7 @@ func attack(type):
await trySprint()
sprintParticle.emitting = false
canRunAi = true
await sprintTo(currentFocusedBoss.position + MathTool.randv2_range(400), 0.25)
await sprintTo(currentFocusedBoss.position + MathTool.randomVector2In(400), 0.25)
currentInvinsible = false
return false
elif type == 4:
@@ -102,8 +102,8 @@ func attack(type):
for i in 16:
if !is_instance_valid(currentFocusedBoss): return false
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))
bullet.position += MathTool.randomVector2In(600)
bullet.look_at(currentFocusedBoss.position + MathTool.randomVector2In(50))
await TickTool.millseconds(100)
return false
elif type == 7:
+1 -1
View File
@@ -34,7 +34,7 @@ func attack(type):
if type == 0:
var weaponPos = findWeaponAnchor("normal")
for i in randi_range(7, 16):
BulletBase.generate(ComponentManager.getBullet("Diamond"), self, weaponPos + MathTool.randv2_range(20), rotation + deg_to_rad(randf_range(-90, 90)))
BulletBase.generate(ComponentManager.getBullet("Diamond"), self, weaponPos + MathTool.randomVector2In(20), rotation + deg_to_rad(randf_range(-90, 90)))
elif type == 1:
var laserCount = randi_range(2, 4)
for i in laserCount:
+1 -1
View File
@@ -34,7 +34,7 @@ func attack(type):
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(ComponentManager.getCharacter("KukeChild"), position + MathTool.randv2_range(500))
var child = EntityBase.generate(ComponentManager.getCharacter("KukeChild"), position + MathTool.randomVector2In(500))
child.currentFocusedBoss = currentFocusedBoss
child.masterMine = self
elif type == 2:
+1 -1
View File
@@ -18,5 +18,5 @@ func attack(type: int):
func sprint():
var target = BulletTool.findClosetBulletCanDamage(position, get_tree(), self)
if is_instance_valid(target):
var dir = (target.position - position).rotated(MathTool.randc_from([-1, 1]) * deg_to_rad(90))
var dir = (target.position - position).rotated(MathTool.randomChoiceFrom([-1, 1]) * deg_to_rad(90))
move(dir.normalized() * sprintMultiplier, true)