mirror of
https://github.com/Rundll86/Dog-Lynx-And-HCN.git
synced 2026-05-29 23:41:54 +08:00
fix(EffectController): 修复oneShot效果后未释放自身的问题
feat(EntityBase): 添加获取生命值百分比的方法 refactor(BulletBase): 重命名scene变量为parentScene以提高可读性 fix(BlueCrystal): 修正弹道追踪旋转计算错误 style(EffectBase): 调整场景文件格式和属性顺序
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
[gd_scene load_steps=3 format=3 uid="uid://bcvuuy2m0pke0"]
|
||||
|
||||
[ext_resource type="Script" path="res://scripts/Statemachine/EffectController.gd" id="1_pt2rk"]
|
||||
[ext_resource type="Script" uid="uid://0iwnvhdh645p" path="res://scripts/Statemachine/EffectController.gd" id="1_pt2rk"]
|
||||
|
||||
[sub_resource type="ShaderMaterial" id="ShaderMaterial_7cv4k"]
|
||||
|
||||
@@ -16,8 +16,8 @@ unique_name_in_owner = true
|
||||
[node name="particles" type="GPUParticles2D" parent="."]
|
||||
unique_name_in_owner = true
|
||||
amount = 30
|
||||
process_material = SubResource("ShaderMaterial_7cv4k")
|
||||
explosiveness = 1.0
|
||||
process_material = SubResource("ShaderMaterial_7cv4k")
|
||||
|
||||
[node name="stage" type="ColorRect" parent="."]
|
||||
unique_name_in_owner = true
|
||||
|
||||
@@ -8,7 +8,7 @@ func ai():
|
||||
if is_instance_valid(tracer):
|
||||
var tracker = tracer.getTrackingAnchor()
|
||||
var targetAngle = position.angle_to_point(tracker)
|
||||
trail.rotation = - Vector2.from_angle(rotation).angle_to(Vector2.from_angle(targetAngle)) * 0.75 / (speed / initialSpeed)
|
||||
trail.rotation = - Vector2.from_angle(rotation).angle_to(Vector2.from_angle(targetAngle)) / (speed / initialSpeed)
|
||||
PresetBulletAI.trace(self, tracker, 0.07)
|
||||
else:
|
||||
trail.rotation = 0
|
||||
|
||||
@@ -35,7 +35,7 @@ var isChildRefract: bool = false
|
||||
var initialSpeed: float = 0
|
||||
var initialDamage: float = 0
|
||||
var speedScale: float = 1
|
||||
var scene: PackedScene = null
|
||||
var parentScene: PackedScene = null
|
||||
|
||||
func _ready():
|
||||
initialSpeed = speed
|
||||
@@ -146,8 +146,8 @@ func trySplit():
|
||||
func tryRefract():
|
||||
if is_instance_valid(launcher) and !isChildRefract:
|
||||
var value = launcher.fields.get(FieldStore.Entity.BULLET_REFRACTION)
|
||||
var entity = EntityTool.findClosetEntity(position, get_tree(), !launcher.isPlayer(), launcher.isPlayer())
|
||||
for i in range(MathTool.shrimpRate(value)):
|
||||
var entity = EntityTool.findClosetEntity(position, get_tree(), !launcher.isPlayer(), launcher.isPlayer(), [launcher])
|
||||
if is_instance_valid(entity):
|
||||
refract(entity, i, value, value - floor(value))
|
||||
|
||||
@@ -166,7 +166,7 @@ func register():
|
||||
pass
|
||||
func split(index: int, total: int, _lastBullet: float):
|
||||
BulletBase.generate(
|
||||
scene,
|
||||
parentScene,
|
||||
launcher,
|
||||
position,
|
||||
rotation + deg_to_rad(360.0 / total * index),
|
||||
@@ -175,7 +175,7 @@ func split(index: int, total: int, _lastBullet: float):
|
||||
)
|
||||
func refract(entity: EntityBase, _index: int, _total: int, _lastBullet: float):
|
||||
BulletBase.generate(
|
||||
scene,
|
||||
parentScene,
|
||||
launcher,
|
||||
position,
|
||||
position.angle_to_point(entity.position) if is_instance_valid(entity) else randf_range(0, deg_to_rad(360)),
|
||||
@@ -202,7 +202,7 @@ static func generate(
|
||||
instance.isChildRefract = asChildRefract
|
||||
instance.launcher = launchBy
|
||||
instance.position = spawnPosition
|
||||
instance.scene = bullet
|
||||
instance.parentScene = bullet
|
||||
instance.rotation = spawnRotation + deg_to_rad(launchBy.fields.get(FieldStore.Entity.OFFSET_SHOOT) * randf_range(-1, 1) * int(!ignoreOffset))
|
||||
if addToWorld:
|
||||
WorldManager.rootNode.call_deferred("add_child", instance)
|
||||
|
||||
@@ -24,6 +24,7 @@ func shot():
|
||||
if oneShot:
|
||||
await cloned.finished
|
||||
cloned.queue_free()
|
||||
queue_free()
|
||||
|
||||
static func create(scene: PackedScene, spawnPosition: Vector2, parent: Node2D = null) -> EffectController:
|
||||
var cloned = scene.instantiate() as EffectController
|
||||
|
||||
@@ -400,6 +400,8 @@ func useItem(items: Dictionary):
|
||||
func getItem(items: Dictionary):
|
||||
for item in items:
|
||||
inventory[item] = clamp(inventory[item] + items[item], 0, inventoryMax[item])
|
||||
func getHealthPercent():
|
||||
return health / fields[FieldStore.Entity.MAX_HEALTH]
|
||||
func getMySummons() -> Array[SummonBase]:
|
||||
var result: Array[SummonBase] = []
|
||||
for entity in get_tree().get_nodes_in_group("players" if isPlayer() else "mobs"):
|
||||
|
||||
Reference in New Issue
Block a user