mirror of
https://github.com/Rundll86/Dog-Lynx-And-HCN.git
synced 2026-05-28 15:01:53 +08:00
11aee1f370
- 将相机偏移从offset改为constantOffset属性 - 添加鼠标位置对相机偏移的影响 - 为Rooster角色添加脚步粒子效果 - 调整红水晶武器的攻击力从40提升到60 - 移除调试相关的debugRebuild属性
32 lines
1.1 KiB
GDScript
32 lines
1.1 KiB
GDScript
@tool
|
|
extends Camera2D
|
|
class_name CameraManager
|
|
|
|
@export var constantOffset: Vector2 = Vector2.ZERO
|
|
|
|
@onready var animator: AnimationPlayer = $"%animator"
|
|
|
|
var shakeIntensity: float = 0
|
|
|
|
static var instance: CameraManager = null
|
|
|
|
func _ready():
|
|
instance = self
|
|
func _physics_process(_delta):
|
|
if is_instance_valid(UIState.player):
|
|
position = UIState.player.position + constantOffset
|
|
position += MathTool.randomVector2In(shakeIntensity)
|
|
offset += ((get_global_mouse_position() - UIState.player.position).clampf(0, 100) - offset) * 0.15
|
|
|
|
static func shake(millseconds: float, intensity: float = 10, steper: Callable = func(currentValue, _totalValue, _restPercent): return currentValue):
|
|
var startTime = WorldManager.getTime()
|
|
instance.shakeIntensity = intensity
|
|
await TickTool.until(
|
|
func():
|
|
instance.shakeIntensity = steper.call(instance.shakeIntensity, intensity, 1 - (WorldManager.getTime() - startTime) / millseconds)
|
|
return WorldManager.getTime() - startTime >= millseconds
|
|
)
|
|
instance.shakeIntensity = 0
|
|
static func playAnimation(animation: String):
|
|
instance.animator.play(animation)
|