mirror of
https://github.com/Rundll86/Dog-Lynx-And-HCN.git
synced 2026-05-28 06:51:54 +08:00
feat: 添加新的子弹类型和相关逻辑,更新角色攻击方式,增加无差别伤害选项
This commit is contained in:
@@ -2,6 +2,8 @@ extends BulletBase
|
||||
class_name Diamond
|
||||
|
||||
func ai():
|
||||
if Time.get_ticks_msec() - spawnInWhen < 500: # 生成的前0.5秒可以追踪
|
||||
var tracing = Time.get_ticks_msec() - spawnInWhen < 1000
|
||||
if tracing:
|
||||
rotation = lerp_angle(rotation, position.angle_to_point(launcher.currentFocusedBoss.position), 0.1)
|
||||
canDamageSelf = !tracing
|
||||
forward(Vector2.from_angle(rotation))
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
extends BulletBase
|
||||
class_name Laser
|
||||
|
||||
func ai():
|
||||
rotation_degrees += 2
|
||||
position = launcher.texture.global_position
|
||||
@@ -3,6 +3,8 @@ class_name Chick
|
||||
|
||||
@onready var firepot = $"%firepot"
|
||||
|
||||
const laserCount = 4
|
||||
|
||||
func _ready():
|
||||
fields[FieldStore.Entity.MAX_HEALTH] = 1000
|
||||
fields[FieldStore.Entity.MOVEMENT_SPEED] = 0.1
|
||||
@@ -10,23 +12,23 @@ func _ready():
|
||||
|
||||
func ai():
|
||||
move(currentFocusedBoss.position - position)
|
||||
if currentFocusedBoss.position.distance_to(position) < 300:
|
||||
if currentFocusedBoss.position.distance_to(position) < 200:
|
||||
tryAttack(2)
|
||||
elif currentFocusedBoss.position.distance_to(position) < 400:
|
||||
tryAttack(1)
|
||||
else:
|
||||
tryAttack(0)
|
||||
func attack(type):
|
||||
if type == 0:
|
||||
var weaponPos = findWeaponAnchor("normal")
|
||||
BulletBase.generate(preload("res://components/Bullets/Diamond.tscn"), self, weaponPos, rotation + deg_to_rad(MathTool.randc_from([-90, 90])))
|
||||
for i in randi_range(10, 20):
|
||||
BulletBase.generate(preload("res://components/Bullets/Diamond.tscn"), self, weaponPos + MathTool.randv2_range(20), rotation + deg_to_rad(randf_range(-90, 90)))
|
||||
elif type == 1:
|
||||
for i in range(laserCount):
|
||||
BulletBase.generate(preload("res://components/Bullets/Laser.tscn"), self, texture.global_position, deg_to_rad(90 * i))
|
||||
elif type == 2:
|
||||
var weaponPos = findWeaponAnchor("normal")
|
||||
var target = weaponPos.angle_to_point(currentFocusedBoss.position)
|
||||
firepot.global_rotation = target
|
||||
firepot.shot()
|
||||
BulletBase.generate(preload("res://components/Bullets/FireScan.tscn"), self, weaponPos, target)
|
||||
# elif type == 2:
|
||||
# var weaponPos = findWeaponAnchor("normal")
|
||||
# var target = weaponPos.angle_to_point(currentFocusedBoss.position)
|
||||
# firepot.global_rotation = target
|
||||
# firepot.shot()
|
||||
BulletBase.generate(preload("res://components/Bullets/Laser.tscn"), self, weaponPos, target)
|
||||
|
||||
@@ -8,6 +8,8 @@ class_name BulletBase
|
||||
}
|
||||
@export var lifeDistance: float = -1 # -1表示无限距离
|
||||
@export var lifeTime: float = -1 # -1表示无限时间
|
||||
@export var indisDamage: bool = false # 是否无差别伤害(不区分敌我)
|
||||
@export var canDamageSelf: bool = false # 是否可以伤害发射者
|
||||
|
||||
var launcher: EntityBase = null
|
||||
var spawnInWhen: float = 0
|
||||
@@ -31,8 +33,8 @@ func _physics_process(_delta: float) -> void:
|
||||
func hit(target: Node):
|
||||
var entity: EntityBase = EntityTool.fromHurtbox(target)
|
||||
if !entity || !launcher: return
|
||||
if entity == launcher: return
|
||||
if !GameRule.allowFriendlyFire:
|
||||
if !canDamageSelf && entity == launcher: return
|
||||
if !indisDamage && !GameRule.allowFriendlyFire:
|
||||
if entity.isPlayer() == launcher.isPlayer(): return
|
||||
entity.takeDamage(self, MathTool.rate(launcher.fields.get(FieldStore.Entity.CRIT_RATE)))
|
||||
if !MathTool.rate(fullPenerate()):
|
||||
|
||||
@@ -83,7 +83,7 @@ func takeDamage(bullet: BulletBase, crit: bool):
|
||||
playSound("hurt")
|
||||
health -= damage
|
||||
DamageLabel.create(damage, crit, $"%damageAnchor".global_position + MathTool.randv2_range(GameRule.damageLabelSpawnOffset))
|
||||
if isBoss:
|
||||
if isBoss and bullet.launcher.isPlayer():
|
||||
bullet.launcher.setBoss(self)
|
||||
if health <= 0:
|
||||
if isBoss:
|
||||
|
||||
Reference in New Issue
Block a user