mirror of
https://github.com/Rundll86/Dog-Lynx-And-HCN.git
synced 2026-05-30 16:01:53 +08:00
refactor(Bullets): 优化子弹格挡逻辑并提取公共方法
重构Parrier.gd中的格挡逻辑,将重复代码提取为parryEffect和penerateEffect方法 调整FoxZhua子弹的追踪位置和场景配置 修改waveDebugConfig使用测试BOSS而非测试小怪
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
[gd_scene load_steps=11 format=3 uid="uid://btqtch0v58e7h"]
|
||||
[gd_scene format=3 uid="uid://btqtch0v58e7h"]
|
||||
|
||||
[ext_resource type="PackedScene" uid="uid://crtdkysmnkith" path="res://components/Abstracts/BulletBase.tscn" id="1_461id"]
|
||||
[ext_resource type="Texture2D" uid="uid://ddvmfyk2g4r1m" path="res://resources/bullets/fox-zhua/zhua.webp" id="2_45k2a"]
|
||||
@@ -192,33 +192,31 @@ _data = {
|
||||
radius = 91.0
|
||||
height = 290.0
|
||||
|
||||
[node name="FoxZhua" instance=ExtResource("1_461id")]
|
||||
[node name="FoxZhua" unique_id=1451377674 instance=ExtResource("1_461id")]
|
||||
script = ExtResource("2_rl21b")
|
||||
canTrace = true
|
||||
displayName = "爪"
|
||||
speed = 0.07
|
||||
motionType = 0
|
||||
penerate = 1.0
|
||||
indisDamage = true
|
||||
canDamageSelf = true
|
||||
autoSpawnAnimation = true
|
||||
freeAfterSpawn = true
|
||||
|
||||
[node name="texture" parent="." index="0"]
|
||||
[node name="texture" parent="." index="0" unique_id=162977358]
|
||||
modulate = Color(1, 1, 1, 0)
|
||||
position = Vector2(-400, 0)
|
||||
rotation = -0.7853982
|
||||
scale = Vector2(0.5, 0.5)
|
||||
sprite_frames = SubResource("SpriteFrames_rl21b")
|
||||
|
||||
[node name="animator" parent="texture" index="0"]
|
||||
libraries = {
|
||||
&"": SubResource("AnimationLibrary_45k2a")
|
||||
}
|
||||
[node name="animator" parent="texture" index="0" unique_id=1114087117]
|
||||
libraries/ = SubResource("AnimationLibrary_45k2a")
|
||||
|
||||
[node name="hand" type="Sprite2D" parent="texture" index="1"]
|
||||
[node name="hand" type="Sprite2D" parent="texture" index="1" unique_id=314757183]
|
||||
position = Vector2(50, 0)
|
||||
texture = ExtResource("2_45k2a")
|
||||
|
||||
[node name="hitbox" parent="." index="1"]
|
||||
position = Vector2(369, -1)
|
||||
[node name="hitbox" parent="." index="1" unique_id=175349408]
|
||||
shape = SubResource("CapsuleShape2D_45k2a")
|
||||
disabled = true
|
||||
|
||||
@@ -5,4 +5,4 @@ class_name FoxZhua
|
||||
|
||||
func ai():
|
||||
if canTrace:
|
||||
PresetBulletAI.lerpPosition(self, launcher.currentFocusedBoss.getTrackingAnchor() - Vector2(0, 200), speed)
|
||||
PresetBulletAI.lerpPosition(self , launcher.currentFocusedBoss.getTrackingAnchor(), speed)
|
||||
|
||||
@@ -9,6 +9,32 @@ var maxBallCount: int = 5
|
||||
var atk: float = 1
|
||||
var reflectRate: float = 1
|
||||
|
||||
func parryEffect(bullet: BulletBase):
|
||||
# 生成格挡特效
|
||||
parryiedTimes += 1
|
||||
var eff = EffectController.create(ComponentManager.getEffect("Parry"), position + (bullet.position - position).normalized() * 200) # 从子弹位置,面向其他子弹的方向前进150
|
||||
eff.modulate = bullet.modulate.blend(bullet.texture.modulate)
|
||||
eff.rotation = position.angle_to_point(bullet.position)
|
||||
eff.shot()
|
||||
launcher.impluse((position - bullet.position).normalized() * bullet.speed ** (1.0 / 2) * 250)
|
||||
func penerateEffect(entity: EntityBase):
|
||||
parryiedTimes += 1
|
||||
var eff = EffectController.create(ComponentManager.getEffect("ParryEntity"), position)
|
||||
eff.rotation = position.angle_to_point(position)
|
||||
eff.shot()
|
||||
entity.impluse((position - entity.position).normalized() * 450)
|
||||
func generateParryBall(targetBaseDamage: float):
|
||||
var cycler = launcher.getOrCreateCycleTimer("parry", 2000, 100)
|
||||
if len(cycler.bullets) < maxBallCount: # 玩家最多只能拥有多少气
|
||||
for b in BulletBase.generate(
|
||||
ComponentManager.getBullet("ParryBall"), # 生成气的子弹
|
||||
launcher,
|
||||
position,
|
||||
0
|
||||
):
|
||||
if b is ParryBallBullet:
|
||||
b.atk = atk * targetBaseDamage
|
||||
|
||||
func spawn():
|
||||
var varians = randi_range(0, 1)
|
||||
var inverts = [2]
|
||||
@@ -22,25 +48,17 @@ func spawn():
|
||||
eff.shot()
|
||||
func succeedToHit(_dmg: float, entity: EntityBase):
|
||||
if parryiedTimes < maxParryTimes && MathTool.rate(parryRate):
|
||||
parryiedTimes += 1
|
||||
var effSpawn = entity.texture.global_position
|
||||
var eff = EffectController.create(ComponentManager.getEffect("ParryEntity"), effSpawn)
|
||||
eff.rotation = position.angle_to_point(effSpawn)
|
||||
eff.shot()
|
||||
entity.impluse((effSpawn - position).normalized() * 450)
|
||||
penerateEffect(entity)
|
||||
func hitBullet(bullet: BulletBase): # 当前子弹与其他子弹相撞
|
||||
if !is_instance_valid(launcher): return
|
||||
if BulletTool.canDamage(bullet, launcher): # 其他子弹可以使当前子弹的发射者受伤吗?
|
||||
if parryiedTimes < maxParryTimes && MathTool.rate(parryRate): # 一个刀光最多格挡多少个敌方子弹?
|
||||
parryiedTimes += 1
|
||||
# 生成格挡特效
|
||||
var eff = EffectController.create(ComponentManager.getEffect("Parry"), position + (bullet.position - position).normalized() * 200) # 从子弹位置,面向其他子弹的方向前进150
|
||||
eff.modulate = bullet.modulate.blend(bullet.texture.modulate)
|
||||
eff.rotation = position.angle_to_point(bullet.position)
|
||||
eff.shot()
|
||||
launcher.impluse((position - bullet.position).normalized() * bullet.speed ** (1.0 / 2) * 250)
|
||||
var targetBaseDamage = bullet.baseDamage
|
||||
# 可以格挡 挥舞运动(近战攻击)、射弹运动(远程攻击)和猛冲运动 的子弹,射弹如果被弹反则不会产生气力
|
||||
# 魔法运动和召唤运动的子弹虽不能格挡,但是可以储能,吐息运动的子弹会对发射者产生击退
|
||||
if bullet.motionType == BulletBase.MotionType.PROJECTILE:
|
||||
# 无论如何都要生成格挡特效
|
||||
parryEffect(bullet)
|
||||
# 弹反 还是 格挡?
|
||||
if MathTool.rate(reflectRate):
|
||||
bullet.look_at(bullet.launcher.getTrackingAnchor())
|
||||
@@ -52,26 +70,24 @@ func hitBullet(bullet: BulletBase): # 当前子弹与其他子弹相撞
|
||||
bullet.animator.speed_scale *= 0.5
|
||||
else:
|
||||
bullet.tryDestroy()
|
||||
generateParryBall(targetBaseDamage)
|
||||
elif bullet.motionType == BulletBase.MotionType.SWING:
|
||||
parryEffect(bullet)
|
||||
bullet.hitbox.disabled = true
|
||||
generateParryBall(targetBaseDamage)
|
||||
elif bullet.motionType == BulletBase.MotionType.SPRINT:
|
||||
parryEffect(bullet)
|
||||
bullet.tryDestroy()
|
||||
bullet.launcher.velocity *= -0.1
|
||||
generateParryBall(targetBaseDamage)
|
||||
elif bullet.motionType == BulletBase.MotionType.BREATH:
|
||||
penerateEffect(bullet.launcher)
|
||||
bullet.hitbox.disable = true
|
||||
bullet.launcher.impluse(Vector2.from_angle(bullet.rotation) * -500)
|
||||
elif bullet.motionType == BulletBase.MotionType.SUMMON || bullet.motionType == BulletBase.MotionType.MAGIC:
|
||||
penerateEffect(bullet.launcher)
|
||||
launcher.storeEnergy(sqrt(bullet.baseDamage))
|
||||
var cycler = launcher.getOrCreateCycleTimer("parry", 2000, 100)
|
||||
if len(cycler.bullets) < maxBallCount: # 玩家最多只能拥有多少气
|
||||
for b in BulletBase.generate(
|
||||
ComponentManager.getBullet("ParryBall"), # 生成气的子弹
|
||||
launcher,
|
||||
position,
|
||||
0
|
||||
):
|
||||
if b is ParryBallBullet:
|
||||
b.atk = atk * targetBaseDamage
|
||||
|
||||
func refract(_newBullet: BulletBase, _entity: EntityBase, _index: int, _total: int, _lastBullet: float):
|
||||
return null
|
||||
func split(_newBullet: BulletBase, _index: int, _total: int, _lastBullet: float):
|
||||
|
||||
@@ -57,7 +57,7 @@ static var WAVE_TESTMOB = [
|
||||
]
|
||||
static var WAVE_EMPTY = []
|
||||
static var waveReleaseConfig = [WAVE_TESTBOSS, 1]
|
||||
static var waveDebugConfig = [WAVE_TESTMOB, 1]
|
||||
static var waveDebugConfig = [WAVE_TESTBOSS, 1]
|
||||
|
||||
static var current: int = startWith(waveReleaseConfig[1]) if WorldManager.isRelease() else startWith(waveDebugConfig[1])
|
||||
static var data = waveReleaseConfig[0] if WorldManager.isRelease() else waveDebugConfig[0]
|
||||
|
||||
Reference in New Issue
Block a user