mirror of
https://github.com/Rundll86/Dog-Lynx-And-HCN.git
synced 2026-05-28 06:51:54 +08:00
feat: 添加游戏控制和管理功能
- 新增GameControl节点用于统一处理游戏重启和退出 - 添加GameBusManager管理游戏重启时的资源清理 - 修改Pause和GameOver面板使用新的GameControl - 为EffectController和ItemDropped添加分组管理 - 统一使用WorldManager管理游戏时间
This commit is contained in:
@@ -7,6 +7,7 @@ class_name CameraManager
|
||||
@onready var animator: AnimationPlayer = $"%animator"
|
||||
|
||||
var shakeIntensity: float = 0
|
||||
var shaking: bool = false
|
||||
|
||||
static var instance: CameraManager = null
|
||||
|
||||
@@ -25,8 +26,11 @@ static func shake(millseconds: float, intensity: float = 10, steper: Callable =
|
||||
await TickTool.until(
|
||||
func():
|
||||
instance.shakeIntensity = steper.call(instance.shakeIntensity, intensity, 1 - (WorldManager.getTime() - startTime) / millseconds)
|
||||
return 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)
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
class_name GameBusManager
|
||||
|
||||
static func restart(tree: SceneTree):
|
||||
for bullet in tree.get_nodes_in_group("bullets"):
|
||||
bullet.queue_free()
|
||||
for entity in tree.get_nodes_in_group("entities"):
|
||||
entity.queue_free()
|
||||
for effect in tree.get_nodes_in_group("effects"):
|
||||
effect.queue_free()
|
||||
for item in tree.get_nodes_in_group("items"):
|
||||
item.queue_free()
|
||||
CameraManager.shakeStop()
|
||||
WorldManager.timeRestart()
|
||||
UIState.setPanel("Starter")
|
||||
@@ -0,0 +1 @@
|
||||
uid://cf1agt55tt4pu
|
||||
@@ -38,6 +38,8 @@ func spawn(node: Node):
|
||||
func justReturn(data):
|
||||
return ArrayTool.parseEncodedObject(data)[0]
|
||||
|
||||
static func timeRestart():
|
||||
runningTime = 0
|
||||
static func getTime():
|
||||
return runningTime
|
||||
static func spawnNode(node: Node):
|
||||
|
||||
Reference in New Issue
Block a user