mirror of
https://github.com/Rundll86/Dog-Lynx-And-HCN.git
synced 2026-05-28 06:51:54 +08:00
2a551d4720
修复相机偏移计算中clampf的范围限制错误,从(0,100)改为(-100,100) 调整红水晶武器的攻击力从60降至45,冷却时间从2000ms降至1000ms,并更新描述文本
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(-100, 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)
|