mirror of
https://github.com/Rundll86/Dog-Lynx-And-HCN.git
synced 2026-05-28 06:51:54 +08:00
30527a18a8
- 新增GameControl节点用于统一处理游戏重启和退出 - 添加GameBusManager管理游戏重启时的资源清理 - 修改Pause和GameOver面板使用新的GameControl - 为EffectController和ItemDropped添加分组管理 - 统一使用WorldManager管理游戏时间
37 lines
1.2 KiB
GDScript
37 lines
1.2 KiB
GDScript
@tool
|
|
extends Camera2D
|
|
class_name CameraManager
|
|
|
|
@export var constantOffset: Vector2 = Vector2.ZERO
|
|
|
|
@onready var animator: AnimationPlayer = $"%animator"
|
|
|
|
var shakeIntensity: float = 0
|
|
var shaking: bool = false
|
|
|
|
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.sampleInCircle(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):
|
|
if StarterPanel.buildingShader: return
|
|
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.shaking
|
|
)
|
|
instance.shakeIntensity = 0
|
|
static func shakeStop():
|
|
instance.shaking = false
|
|
instance.shakeIntensity = 0
|
|
static func playAnimation(animation: String):
|
|
instance.animator.play(animation)
|