mirror of
https://github.com/Rundll86/Dog-Lynx-And-HCN.git
synced 2026-05-28 06:51:54 +08:00
refactor(CameraManager): 重构相机震动系统并添加强度参数
- 移除shaking布尔变量,改用shakeIntensity控制震动强度 - 修改shake方法接受强度参数,支持叠加震动效果 - 简化震动逻辑,移除调试打印语句 feat(ItemDropped): 添加物品自动收集功能 - 当物品与玩家距离小于60时自动收集并销毁 - 调用玩家collectItem方法处理收集逻辑 refactor(EntityBase): 重构物品收集逻辑 - 将物品收集逻辑从信号回调移至collectItem方法 - 移除itemCollected信号及相关UI更新代码 - 简化hurtbox连接逻辑 style(World): 调整动画资源顺序 - 交换两个动画资源的定义顺序
This commit is contained in:
@@ -6,6 +6,31 @@
|
||||
[ext_resource type="Script" path="res://scripts/Tools/CameraManager.gd" id="5_mk7bv"]
|
||||
[ext_resource type="Texture2D" uid="uid://ckk8kahhof06u" path="res://resources/maps/Castle 2.png" id="6_p0nkj"]
|
||||
|
||||
[sub_resource type="Animation" id="Animation_ykpvi"]
|
||||
length = 0.001
|
||||
tracks/0/type = "bezier"
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/path = NodePath(".:zoom:x")
|
||||
tracks/0/interp = 1
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/keys = {
|
||||
"handle_modes": PackedInt32Array(0),
|
||||
"points": PackedFloat32Array(1, -0.25, 0, 0.25, 0),
|
||||
"times": PackedFloat32Array(0)
|
||||
}
|
||||
tracks/1/type = "bezier"
|
||||
tracks/1/imported = false
|
||||
tracks/1/enabled = true
|
||||
tracks/1/path = NodePath(".:zoom:y")
|
||||
tracks/1/interp = 1
|
||||
tracks/1/loop_wrap = true
|
||||
tracks/1/keys = {
|
||||
"handle_modes": PackedInt32Array(0),
|
||||
"points": PackedFloat32Array(1, -0.25, 0, 0.25, 0),
|
||||
"times": PackedFloat32Array(0)
|
||||
}
|
||||
|
||||
[sub_resource type="Animation" id="Animation_kii8h"]
|
||||
resource_name = "bigLaser"
|
||||
length = 5.0
|
||||
@@ -33,31 +58,6 @@ tracks/1/keys = {
|
||||
"times": PackedFloat32Array(0, 0.5, 3)
|
||||
}
|
||||
|
||||
[sub_resource type="Animation" id="Animation_ykpvi"]
|
||||
length = 0.001
|
||||
tracks/0/type = "bezier"
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/path = NodePath(".:zoom:x")
|
||||
tracks/0/interp = 1
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/keys = {
|
||||
"handle_modes": PackedInt32Array(0),
|
||||
"points": PackedFloat32Array(1, -0.25, 0, 0.25, 0),
|
||||
"times": PackedFloat32Array(0)
|
||||
}
|
||||
tracks/1/type = "bezier"
|
||||
tracks/1/imported = false
|
||||
tracks/1/enabled = true
|
||||
tracks/1/path = NodePath(".:zoom:y")
|
||||
tracks/1/interp = 1
|
||||
tracks/1/loop_wrap = true
|
||||
tracks/1/keys = {
|
||||
"handle_modes": PackedInt32Array(0),
|
||||
"points": PackedFloat32Array(1, -0.25, 0, 0.25, 0),
|
||||
"times": PackedFloat32Array(0)
|
||||
}
|
||||
|
||||
[sub_resource type="AnimationLibrary" id="AnimationLibrary_44ixa"]
|
||||
_data = {
|
||||
"RESET": SubResource("Animation_ykpvi"),
|
||||
@@ -67,6 +67,7 @@ _data = {
|
||||
[node name="world" type="Node2D"]
|
||||
y_sort_enabled = true
|
||||
script = ExtResource("1_lxsxj")
|
||||
metadata/_edit_vertical_guides_ = [-1.0, 57.0]
|
||||
|
||||
[node name="UI" parent="." instance=ExtResource("2_04cdd")]
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ extends BulletBase
|
||||
class_name BigLaser
|
||||
|
||||
func spawn():
|
||||
CameraManager.shake(5000)
|
||||
CameraManager.shake(5000, 100)
|
||||
CameraManager.playAnimation("bigLaser")
|
||||
func ai():
|
||||
rotation = lerp_angle(rotation, ((get_global_mouse_position() - position).angle()), 0.1)
|
||||
|
||||
@@ -7,8 +7,6 @@ signal healthChanged(health: float)
|
||||
|
||||
signal energyChanged(energy: float)
|
||||
|
||||
signal itemCollected(itemType: ItemStore.ItemType, amount: int)
|
||||
|
||||
var fields = {
|
||||
FieldStore.Entity.MAX_HEALTH: 100,
|
||||
FieldStore.Entity.DAMAGE_MULTIPILER: 1,
|
||||
@@ -76,24 +74,11 @@ func _ready():
|
||||
if isPlayer():
|
||||
statebar.levelLabels.hide()
|
||||
UIState.player = self
|
||||
hurtbox.body_entered.connect(
|
||||
func(body):
|
||||
if body is ItemDropped:
|
||||
inventory[body.item] += body.stackCount
|
||||
playSound("collect")
|
||||
itemCollected.emit(body.item, body.stackCount)
|
||||
body.queue_free()
|
||||
)
|
||||
energyChanged.connect(
|
||||
func(newEnergy):
|
||||
UIState.energyPercent.maxValue = fields.get(FieldStore.Entity.MAX_ENERGY)
|
||||
UIState.energyPercent.setCurrent(newEnergy)
|
||||
)
|
||||
itemCollected.connect(
|
||||
func(itemType, amount):
|
||||
if MathTool.rate(GameRule.tipSpawnRateWhenGetDroppedItem):
|
||||
UIState.itemCollect.add_child(ItemShow.generate(itemType, amount, true))
|
||||
)
|
||||
else:
|
||||
currentFocusedBoss = get_tree().get_nodes_in_group("players")[0]
|
||||
applyLevel()
|
||||
@@ -166,6 +151,9 @@ func takeDamage(bullet: BulletBase, crit: bool):
|
||||
bullet.launcher.storeEnergy(energy * 0.35)
|
||||
bullet.launcher.setBoss(null)
|
||||
tryDie(bullet)
|
||||
func collectItem(itemType: ItemStore.ItemType, amount: int):
|
||||
inventory[itemType] += amount
|
||||
playSound("collect")
|
||||
func storeEnergy(value: float):
|
||||
energy += value * fields.get(FieldStore.Entity.ENERGY_MULTIPILER)
|
||||
energyChanged.emit(energy)
|
||||
|
||||
@@ -16,6 +16,9 @@ func _physics_process(_delta):
|
||||
targetPlayer = findPlayer()
|
||||
if is_instance_valid(targetPlayer):
|
||||
apply_central_force((targetPlayer.position - position).normalized() * 1000)
|
||||
if position.distance_to(targetPlayer.position) < 60:
|
||||
targetPlayer.collectItem(item, stackCount)
|
||||
queue_free()
|
||||
|
||||
func findPlayer() -> EntityBase:
|
||||
var result = null
|
||||
|
||||
@@ -2,11 +2,9 @@
|
||||
extends Camera2D
|
||||
class_name CameraManager
|
||||
|
||||
@export var shakeOffset: float = 100
|
||||
|
||||
@onready var animator: AnimationPlayer = $"%animator"
|
||||
|
||||
var shaking: bool = false
|
||||
var shakeIntensity: float = 0
|
||||
|
||||
static var instance: CameraManager = null
|
||||
|
||||
@@ -15,14 +13,11 @@ func _ready():
|
||||
func _physics_process(_delta):
|
||||
if is_instance_valid(UIState.player):
|
||||
position = UIState.player.position
|
||||
if shaking:
|
||||
position += MathTool.randv2_range(shakeOffset)
|
||||
position += MathTool.randv2_range(shakeIntensity)
|
||||
|
||||
static func shake(millseconds: int = 1000):
|
||||
print("shake start")
|
||||
instance.shaking = true
|
||||
static func shake(millseconds: int, intensity: float = 10):
|
||||
instance.shakeIntensity += intensity
|
||||
await TickTool.millseconds(millseconds)
|
||||
instance.shaking = false
|
||||
print("shake end")
|
||||
instance.shakeIntensity -= intensity
|
||||
static func playAnimation(animation: String):
|
||||
instance.animator.play(animation)
|
||||
|
||||
Reference in New Issue
Block a user