mirror of
https://github.com/Rundll86/Dog-Lynx-And-HCN.git
synced 2026-06-26 13:32:29 +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"]
|
[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"]
|
[sub_resource type="ShaderMaterial" id="ShaderMaterial_7cv4k"]
|
||||||
|
|
||||||
@@ -16,8 +16,8 @@ unique_name_in_owner = true
|
|||||||
[node name="particles" type="GPUParticles2D" parent="."]
|
[node name="particles" type="GPUParticles2D" parent="."]
|
||||||
unique_name_in_owner = true
|
unique_name_in_owner = true
|
||||||
amount = 30
|
amount = 30
|
||||||
process_material = SubResource("ShaderMaterial_7cv4k")
|
|
||||||
explosiveness = 1.0
|
explosiveness = 1.0
|
||||||
|
process_material = SubResource("ShaderMaterial_7cv4k")
|
||||||
|
|
||||||
[node name="stage" type="ColorRect" parent="."]
|
[node name="stage" type="ColorRect" parent="."]
|
||||||
unique_name_in_owner = true
|
unique_name_in_owner = true
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ func ai():
|
|||||||
if is_instance_valid(tracer):
|
if is_instance_valid(tracer):
|
||||||
var tracker = tracer.getTrackingAnchor()
|
var tracker = tracer.getTrackingAnchor()
|
||||||
var targetAngle = position.angle_to_point(tracker)
|
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)
|
PresetBulletAI.trace(self, tracker, 0.07)
|
||||||
else:
|
else:
|
||||||
trail.rotation = 0
|
trail.rotation = 0
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ var isChildRefract: bool = false
|
|||||||
var initialSpeed: float = 0
|
var initialSpeed: float = 0
|
||||||
var initialDamage: float = 0
|
var initialDamage: float = 0
|
||||||
var speedScale: float = 1
|
var speedScale: float = 1
|
||||||
var scene: PackedScene = null
|
var parentScene: PackedScene = null
|
||||||
|
|
||||||
func _ready():
|
func _ready():
|
||||||
initialSpeed = speed
|
initialSpeed = speed
|
||||||
@@ -146,8 +146,8 @@ func trySplit():
|
|||||||
func tryRefract():
|
func tryRefract():
|
||||||
if is_instance_valid(launcher) and !isChildRefract:
|
if is_instance_valid(launcher) and !isChildRefract:
|
||||||
var value = launcher.fields.get(FieldStore.Entity.BULLET_REFRACTION)
|
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)):
|
for i in range(MathTool.shrimpRate(value)):
|
||||||
|
var entity = EntityTool.findClosetEntity(position, get_tree(), !launcher.isPlayer(), launcher.isPlayer(), [launcher])
|
||||||
if is_instance_valid(entity):
|
if is_instance_valid(entity):
|
||||||
refract(entity, i, value, value - floor(value))
|
refract(entity, i, value, value - floor(value))
|
||||||
|
|
||||||
@@ -166,7 +166,7 @@ func register():
|
|||||||
pass
|
pass
|
||||||
func split(index: int, total: int, _lastBullet: float):
|
func split(index: int, total: int, _lastBullet: float):
|
||||||
BulletBase.generate(
|
BulletBase.generate(
|
||||||
scene,
|
parentScene,
|
||||||
launcher,
|
launcher,
|
||||||
position,
|
position,
|
||||||
rotation + deg_to_rad(360.0 / total * index),
|
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):
|
func refract(entity: EntityBase, _index: int, _total: int, _lastBullet: float):
|
||||||
BulletBase.generate(
|
BulletBase.generate(
|
||||||
scene,
|
parentScene,
|
||||||
launcher,
|
launcher,
|
||||||
position,
|
position,
|
||||||
position.angle_to_point(entity.position) if is_instance_valid(entity) else randf_range(0, deg_to_rad(360)),
|
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.isChildRefract = asChildRefract
|
||||||
instance.launcher = launchBy
|
instance.launcher = launchBy
|
||||||
instance.position = spawnPosition
|
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))
|
instance.rotation = spawnRotation + deg_to_rad(launchBy.fields.get(FieldStore.Entity.OFFSET_SHOOT) * randf_range(-1, 1) * int(!ignoreOffset))
|
||||||
if addToWorld:
|
if addToWorld:
|
||||||
WorldManager.rootNode.call_deferred("add_child", instance)
|
WorldManager.rootNode.call_deferred("add_child", instance)
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ func shot():
|
|||||||
if oneShot:
|
if oneShot:
|
||||||
await cloned.finished
|
await cloned.finished
|
||||||
cloned.queue_free()
|
cloned.queue_free()
|
||||||
|
queue_free()
|
||||||
|
|
||||||
static func create(scene: PackedScene, spawnPosition: Vector2, parent: Node2D = null) -> EffectController:
|
static func create(scene: PackedScene, spawnPosition: Vector2, parent: Node2D = null) -> EffectController:
|
||||||
var cloned = scene.instantiate() as EffectController
|
var cloned = scene.instantiate() as EffectController
|
||||||
|
|||||||
@@ -400,6 +400,8 @@ func useItem(items: Dictionary):
|
|||||||
func getItem(items: Dictionary):
|
func getItem(items: Dictionary):
|
||||||
for item in items:
|
for item in items:
|
||||||
inventory[item] = clamp(inventory[item] + items[item], 0, inventoryMax[item])
|
inventory[item] = clamp(inventory[item] + items[item], 0, inventoryMax[item])
|
||||||
|
func getHealthPercent():
|
||||||
|
return health / fields[FieldStore.Entity.MAX_HEALTH]
|
||||||
func getMySummons() -> Array[SummonBase]:
|
func getMySummons() -> Array[SummonBase]:
|
||||||
var result: Array[SummonBase] = []
|
var result: Array[SummonBase] = []
|
||||||
for entity in get_tree().get_nodes_in_group("players" if isPlayer() else "mobs"):
|
for entity in get_tree().get_nodes_in_group("players" if isPlayer() else "mobs"):
|
||||||
|
|||||||
Reference in New Issue
Block a user