This commit is contained in:
RedisTKey 2026-01-06 11:58:41 +08:00
parent 6d248bdb88
commit e1de327991
33 changed files with 553 additions and 152 deletions

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,47 @@
[gd_scene load_steps=12 format=3 uid="uid://bj2318o3y68x2"]
[ext_resource type="Script" uid="uid://ds6jy3s0hhmwt" path="res://_game/DemoScript.gd" id="1_2tycc"]
[ext_resource type="PackedScene" uid="uid://cvqehvdjpoar4" path="res://_player/player_controller.tscn" id="2_gslp7"]
[ext_resource type="PackedScene" uid="uid://gwhff4qaouxy" path="res://_player/Avatar.tscn" id="3_6jw57"]
[ext_resource type="PackedScene" uid="uid://bt55vmoc83l6g" path="res://_game/scenes/l_1_s_1.tscn" id="4_6jw57"]
[ext_resource type="PackedScene" uid="uid://c6and5mqr3wv1" path="res://_game/scenes/l_1_s_2.tscn" id="5_2t6pm"]
[ext_resource type="PackedScene" uid="uid://0sivr6aig7gm" path="res://_game/scenes/l_1_s_3.tscn" id="6_xkd7q"]
[ext_resource type="Script" uid="uid://5e157vdk6175" path="res://addons/reedscene/scene/ReedScene.gd" id="6_xotud"]
[ext_resource type="Script" uid="uid://bh066o84byplh" path="res://addons/reedscene/scene/ReedSceneID.gd" id="7_2tycc"]
[ext_resource type="Script" uid="uid://dn0ksjoswquf5" path="res://addons/reedscene/scene/SceneManager.gd" id="8_3ihdv"]
[ext_resource type="Script" uid="uid://dsgl7lbyjsiif" path="res://addons/reedscene/act/ActManager.gd" id="9_hc6q0"]
[ext_resource type="Script" uid="uid://pxjf5vst08eo" path="res://addons/reedscene/prop/PropManager.gd" id="10_mwuv1"]
[node name="Game" type="Node2D"]
script = ExtResource("1_2tycc")
[node name="PlayerController" parent="." node_paths=PackedStringArray("auto_controlled_avatar") instance=ExtResource("2_gslp7")]
auto_controlled_avatar = NodePath("../Avatar")
[node name="Avatar" parent="." instance=ExtResource("3_6jw57")]
position = Vector2(283, 253)
collision_mask = 4
[node name="l1_s1" parent="." instance=ExtResource("4_6jw57")]
[node name="l1_s2" parent="." instance=ExtResource("5_2t6pm")]
debug_log = true
[node name="l1_s3" parent="." instance=ExtResource("6_xkd7q")]
debug_log = true
[node name="ReedScene" type="Node2D" parent="."]
script = ExtResource("6_xotud")
metadata/_custom_type_script = "uid://5e157vdk6175"
[node name="[Invalid!]" type="Node" parent="ReedScene"]
script = ExtResource("7_2tycc")
[node name="SceneManager" type="Node" parent="ReedScene"]
script = ExtResource("8_3ihdv")
[node name="ActManager" type="Node" parent="ReedScene"]
script = ExtResource("9_hc6q0")
[node name="Props" type="Node2D" parent="ReedScene"]
script = ExtResource("10_mwuv1")

View File

@ -0,0 +1,47 @@
[gd_scene load_steps=12 format=3 uid="uid://bj2318o3y68x2"]
[ext_resource type="Script" uid="uid://ds6jy3s0hhmwt" path="res://_game/DemoScript.gd" id="1_2tycc"]
[ext_resource type="PackedScene" uid="uid://cvqehvdjpoar4" path="res://_player/player_controller.tscn" id="2_gslp7"]
[ext_resource type="PackedScene" uid="uid://gwhff4qaouxy" path="res://_player/Avatar.tscn" id="3_6jw57"]
[ext_resource type="PackedScene" uid="uid://bt55vmoc83l6g" path="res://_game/scenes/l_1_s_1.tscn" id="4_6jw57"]
[ext_resource type="PackedScene" uid="uid://c6and5mqr3wv1" path="res://_game/scenes/l_1_s_2.tscn" id="5_2t6pm"]
[ext_resource type="PackedScene" uid="uid://0sivr6aig7gm" path="res://_game/scenes/l_1_s_3.tscn" id="6_xkd7q"]
[ext_resource type="Script" uid="uid://5e157vdk6175" path="res://addons/reedscene/scene/ReedScene.gd" id="6_xotud"]
[ext_resource type="Script" uid="uid://bh066o84byplh" path="res://addons/reedscene/scene/ReedSceneID.gd" id="7_2tycc"]
[ext_resource type="Script" uid="uid://dn0ksjoswquf5" path="res://addons/reedscene/scene/SceneManager.gd" id="8_3ihdv"]
[ext_resource type="Script" uid="uid://dsgl7lbyjsiif" path="res://addons/reedscene/act/ActManager.gd" id="9_hc6q0"]
[ext_resource type="Script" uid="uid://pxjf5vst08eo" path="res://addons/reedscene/prop/PropManager.gd" id="10_mwuv1"]
[node name="Game" type="Node2D"]
script = ExtResource("1_2tycc")
[node name="PlayerController" parent="." node_paths=PackedStringArray("auto_controlled_avatar") instance=ExtResource("2_gslp7")]
auto_controlled_avatar = NodePath("../Avatar")
[node name="Avatar" parent="." instance=ExtResource("3_6jw57")]
position = Vector2(283, 253)
collision_mask = 4
[node name="l1_s1" parent="." instance=ExtResource("4_6jw57")]
[node name="l1_s2" parent="." instance=ExtResource("5_2t6pm")]
debug_log = true
[node name="l1_s3" parent="." instance=ExtResource("6_xkd7q")]
debug_log = true
[node name="ReedScene" type="Node2D" parent="."]
script = ExtResource("6_xotud")
metadata/_custom_type_script = "uid://5e157vdk6175"
[node name="[Invalid!]" type="Node" parent="ReedScene"]
script = ExtResource("7_2tycc")
[node name="SceneManager" type="Node" parent="ReedScene"]
script = ExtResource("8_3ihdv")
[node name="ActManager" type="Node" parent="ReedScene"]
script = ExtResource("9_hc6q0")
[node name="Props" type="Node2D" parent="ReedScene"]
script = ExtResource("10_mwuv1")

View File

@ -0,0 +1,47 @@
[gd_scene load_steps=12 format=3 uid="uid://bj2318o3y68x2"]
[ext_resource type="Script" uid="uid://ds6jy3s0hhmwt" path="res://_game/DemoScript.gd" id="1_2tycc"]
[ext_resource type="PackedScene" uid="uid://cvqehvdjpoar4" path="res://_player/player_controller.tscn" id="2_gslp7"]
[ext_resource type="PackedScene" uid="uid://gwhff4qaouxy" path="res://_player/Avatar.tscn" id="3_6jw57"]
[ext_resource type="PackedScene" uid="uid://bt55vmoc83l6g" path="res://_game/scenes/l_1_s_1.tscn" id="4_6jw57"]
[ext_resource type="PackedScene" uid="uid://c6and5mqr3wv1" path="res://_game/scenes/l_1_s_2.tscn" id="5_2t6pm"]
[ext_resource type="PackedScene" uid="uid://0sivr6aig7gm" path="res://_game/scenes/l_1_s_3.tscn" id="6_xkd7q"]
[ext_resource type="Script" uid="uid://5e157vdk6175" path="res://addons/reedscene/scene/ReedScene.gd" id="6_xotud"]
[ext_resource type="Script" uid="uid://bh066o84byplh" path="res://addons/reedscene/scene/ReedSceneID.gd" id="7_2tycc"]
[ext_resource type="Script" uid="uid://dn0ksjoswquf5" path="res://addons/reedscene/scene/SceneManager.gd" id="8_3ihdv"]
[ext_resource type="Script" uid="uid://dsgl7lbyjsiif" path="res://addons/reedscene/act/ActManager.gd" id="9_hc6q0"]
[ext_resource type="Script" uid="uid://pxjf5vst08eo" path="res://addons/reedscene/prop/PropManager.gd" id="10_mwuv1"]
[node name="Game" type="Node2D"]
script = ExtResource("1_2tycc")
[node name="PlayerController" parent="." node_paths=PackedStringArray("auto_controlled_avatar") instance=ExtResource("2_gslp7")]
auto_controlled_avatar = NodePath("../Avatar")
[node name="Avatar" parent="." instance=ExtResource("3_6jw57")]
position = Vector2(283, 253)
collision_mask = 4
[node name="l1_s1" parent="." instance=ExtResource("4_6jw57")]
[node name="l1_s2" parent="." instance=ExtResource("5_2t6pm")]
debug_log = true
[node name="l1_s3" parent="." instance=ExtResource("6_xkd7q")]
debug_log = true
[node name="ReedScene" type="Node2D" parent="."]
script = ExtResource("6_xotud")
metadata/_custom_type_script = "uid://5e157vdk6175"
[node name="[Invalid!]" type="Node" parent="ReedScene"]
script = ExtResource("7_2tycc")
[node name="SceneManager" type="Node" parent="ReedScene"]
script = ExtResource("8_3ihdv")
[node name="ActManager" type="Node" parent="ReedScene"]
script = ExtResource("9_hc6q0")
[node name="Props" type="Node2D" parent="ReedScene"]
script = ExtResource("10_mwuv1")

View File

@ -0,0 +1,47 @@
[gd_scene load_steps=12 format=3 uid="uid://bj2318o3y68x2"]
[ext_resource type="Script" uid="uid://ds6jy3s0hhmwt" path="res://_game/DemoScript.gd" id="1_2tycc"]
[ext_resource type="PackedScene" uid="uid://cvqehvdjpoar4" path="res://_player/player_controller.tscn" id="2_gslp7"]
[ext_resource type="PackedScene" uid="uid://gwhff4qaouxy" path="res://_player/Avatar.tscn" id="3_6jw57"]
[ext_resource type="PackedScene" uid="uid://bt55vmoc83l6g" path="res://_game/scenes/l_1_s_1.tscn" id="4_6jw57"]
[ext_resource type="PackedScene" uid="uid://c6and5mqr3wv1" path="res://_game/scenes/l_1_s_2.tscn" id="5_2t6pm"]
[ext_resource type="PackedScene" uid="uid://0sivr6aig7gm" path="res://_game/scenes/l_1_s_3.tscn" id="6_xkd7q"]
[ext_resource type="Script" uid="uid://5e157vdk6175" path="res://addons/reedscene/scene/ReedScene.gd" id="6_xotud"]
[ext_resource type="Script" uid="uid://bh066o84byplh" path="res://addons/reedscene/scene/ReedSceneID.gd" id="7_2tycc"]
[ext_resource type="Script" uid="uid://dn0ksjoswquf5" path="res://addons/reedscene/scene/SceneManager.gd" id="8_3ihdv"]
[ext_resource type="Script" uid="uid://dsgl7lbyjsiif" path="res://addons/reedscene/act/ActManager.gd" id="9_hc6q0"]
[ext_resource type="Script" uid="uid://pxjf5vst08eo" path="res://addons/reedscene/prop/PropManager.gd" id="10_mwuv1"]
[node name="Game" type="Node2D"]
script = ExtResource("1_2tycc")
[node name="PlayerController" parent="." node_paths=PackedStringArray("auto_controlled_avatar") instance=ExtResource("2_gslp7")]
auto_controlled_avatar = NodePath("../Avatar")
[node name="Avatar" parent="." instance=ExtResource("3_6jw57")]
position = Vector2(283, 253)
collision_mask = 4
[node name="l1_s1" parent="." instance=ExtResource("4_6jw57")]
[node name="l1_s2" parent="." instance=ExtResource("5_2t6pm")]
debug_log = true
[node name="l1_s3" parent="." instance=ExtResource("6_xkd7q")]
debug_log = true
[node name="ReedScene" type="Node2D" parent="."]
script = ExtResource("6_xotud")
metadata/_custom_type_script = "uid://5e157vdk6175"
[node name="[Invalid!]" type="Node" parent="ReedScene"]
script = ExtResource("7_2tycc")
[node name="SceneManager" type="Node" parent="ReedScene"]
script = ExtResource("8_3ihdv")
[node name="ActManager" type="Node" parent="ReedScene"]
script = ExtResource("9_hc6q0")
[node name="Props" type="Node2D" parent="ReedScene"]
script = ExtResource("10_mwuv1")

View File

@ -0,0 +1,47 @@
[gd_scene load_steps=12 format=3 uid="uid://bj2318o3y68x2"]
[ext_resource type="Script" uid="uid://ds6jy3s0hhmwt" path="res://_game/DemoScript.gd" id="1_2tycc"]
[ext_resource type="PackedScene" uid="uid://cvqehvdjpoar4" path="res://_player/player_controller.tscn" id="2_gslp7"]
[ext_resource type="PackedScene" uid="uid://gwhff4qaouxy" path="res://_player/Avatar.tscn" id="3_6jw57"]
[ext_resource type="PackedScene" uid="uid://bt55vmoc83l6g" path="res://_game/scenes/l_1_s_1.tscn" id="4_6jw57"]
[ext_resource type="PackedScene" uid="uid://c6and5mqr3wv1" path="res://_game/scenes/l_1_s_2.tscn" id="5_2t6pm"]
[ext_resource type="PackedScene" uid="uid://0sivr6aig7gm" path="res://_game/scenes/l_1_s_3.tscn" id="6_xkd7q"]
[ext_resource type="Script" uid="uid://5e157vdk6175" path="res://addons/reedscene/scene/ReedScene.gd" id="6_xotud"]
[ext_resource type="Script" uid="uid://bh066o84byplh" path="res://addons/reedscene/scene/ReedSceneID.gd" id="7_2tycc"]
[ext_resource type="Script" uid="uid://dn0ksjoswquf5" path="res://addons/reedscene/scene/SceneManager.gd" id="8_3ihdv"]
[ext_resource type="Script" uid="uid://dsgl7lbyjsiif" path="res://addons/reedscene/act/ActManager.gd" id="9_hc6q0"]
[ext_resource type="Script" uid="uid://pxjf5vst08eo" path="res://addons/reedscene/prop/PropManager.gd" id="10_mwuv1"]
[node name="Game" type="Node2D"]
script = ExtResource("1_2tycc")
[node name="PlayerController" parent="." node_paths=PackedStringArray("auto_controlled_avatar") instance=ExtResource("2_gslp7")]
auto_controlled_avatar = NodePath("../Avatar")
[node name="Avatar" parent="." instance=ExtResource("3_6jw57")]
position = Vector2(283, 253)
collision_mask = 4
[node name="l1_s1" parent="." instance=ExtResource("4_6jw57")]
[node name="l1_s2" parent="." instance=ExtResource("5_2t6pm")]
debug_log = true
[node name="l1_s3" parent="." instance=ExtResource("6_xkd7q")]
debug_log = true
[node name="ReedScene" type="Node2D" parent="."]
script = ExtResource("6_xotud")
metadata/_custom_type_script = "uid://5e157vdk6175"
[node name="[Invalid!]" type="Node" parent="ReedScene"]
script = ExtResource("7_2tycc")
[node name="SceneManager" type="Node" parent="ReedScene"]
script = ExtResource("8_3ihdv")
[node name="ActManager" type="Node" parent="ReedScene"]
script = ExtResource("9_hc6q0")
[node name="Props" type="Node2D" parent="ReedScene"]
script = ExtResource("10_mwuv1")

4
_game/game.gd Normal file
View File

@ -0,0 +1,4 @@
extends Node2D
func _ready() -> void:
CameraSystem.register_player_camera(self)

1
_game/game.gd.uid Normal file
View File

@ -0,0 +1 @@
uid://crgac4manhoud

View File

@ -1,4 +1,4 @@
[gd_scene load_steps=41 format=3 uid="uid://gwhff4qaouxy"] [gd_scene load_steps=43 format=3 uid="uid://gwhff4qaouxy"]
[ext_resource type="Script" uid="uid://dq1g1qp66chwy" path="res://_player/avatar.gd" id="1_rkqpu"] [ext_resource type="Script" uid="uid://dq1g1qp66chwy" path="res://_player/avatar.gd" id="1_rkqpu"]
[ext_resource type="Script" uid="uid://isu8onknb75o" path="res://_player/states/character_state_machine.gd" id="1_wvs5h"] [ext_resource type="Script" uid="uid://isu8onknb75o" path="res://_player/states/character_state_machine.gd" id="1_wvs5h"]
@ -33,8 +33,10 @@
[ext_resource type="Resource" uid="uid://do0bnwse614jw" path="res://_player/effect_binding/land_dust.tres" id="26_s5egm"] [ext_resource type="Resource" uid="uid://do0bnwse614jw" path="res://_player/effect_binding/land_dust.tres" id="26_s5egm"]
[ext_resource type="Script" uid="uid://bijoqygv6tncj" path="res://addons/reedcomponent/SingleComponentRemotor.gd" id="28_mxt3b"] [ext_resource type="Script" uid="uid://bijoqygv6tncj" path="res://addons/reedcomponent/SingleComponentRemotor.gd" id="28_mxt3b"]
[ext_resource type="Resource" uid="uid://bdad4yjv1q0uu" path="res://_player/effect_binding/jump_dust.tres" id="30_hquoe"] [ext_resource type="Resource" uid="uid://bdad4yjv1q0uu" path="res://_player/effect_binding/jump_dust.tres" id="30_hquoe"]
[ext_resource type="Script" uid="uid://bhd4nuiu23e7l" path="res://addons/phantom_camera/scripts/phantom_camera/phantom_camera_noise_emitter_2d.gd" id="32_ciuu3"]
[ext_resource type="Script" uid="uid://bhexx6mj1xv3q" path="res://addons/phantom_camera/scripts/phantom_camera/phantom_camera_2d.gd" id="32_u7cua"] [ext_resource type="Script" uid="uid://bhexx6mj1xv3q" path="res://addons/phantom_camera/scripts/phantom_camera/phantom_camera_2d.gd" id="32_u7cua"]
[ext_resource type="Script" uid="uid://bueehfgv5vnc0" path="res://_player/extra/camera_priority_locker.gd" id="34_1a1t3"] [ext_resource type="Script" uid="uid://bueehfgv5vnc0" path="res://_player/extra/camera_priority_locker.gd" id="34_1a1t3"]
[ext_resource type="Resource" uid="uid://dy1hsviasxfu0" path="res://_shared/camera/camera_shake/base_noise.tres" id="34_01uoa"]
[sub_resource type="CircleShape2D" id="CircleShape2D_1a1t3"] [sub_resource type="CircleShape2D" id="CircleShape2D_1a1t3"]
radius = 3.0 radius = 3.0
@ -195,11 +197,20 @@ script = ExtResource("24_mwlgv")
bindings = Array[ExtResource("25_s5egm")]([ExtResource("26_s5egm"), ExtResource("30_hquoe")]) bindings = Array[ExtResource("25_s5egm")]([ExtResource("26_s5egm"), ExtResource("30_hquoe")])
metadata/_custom_type_script = "uid://ta2r2bc1nrwe" metadata/_custom_type_script = "uid://ta2r2bc1nrwe"
[node name="PhantomCameraNoiseEmitter2D" type="Node2D" parent="."]
unique_name_in_owner = true
script = ExtResource("32_ciuu3")
noise = ExtResource("34_01uoa")
duration = 0.2
noise_emitter_layer = 0
metadata/_custom_type_script = "uid://bhd4nuiu23e7l"
[node name="PhantomCamera2D" type="Node2D" parent="."] [node name="PhantomCamera2D" type="Node2D" parent="."]
position = Vector2(50, -75) position = Vector2(50, -75)
script = ExtResource("32_u7cua") script = ExtResource("32_u7cua")
tween_resource = SubResource("Resource_1a1t3") tween_resource = SubResource("Resource_1a1t3")
draw_limits = true draw_limits = true
noise = ExtResource("34_01uoa")
metadata/_custom_type_script = "uid://bhexx6mj1xv3q" metadata/_custom_type_script = "uid://bhexx6mj1xv3q"
[node name="Locker" type="Node" parent="PhantomCamera2D" node_paths=PackedStringArray("target_camera")] [node name="Locker" type="Node" parent="PhantomCamera2D" node_paths=PackedStringArray("target_camera")]

View File

@ -9,6 +9,9 @@ class_name Player extends CharacterBody2D
@onready var foot_pos_marker: Marker2D = %FootPosMarker @onready var foot_pos_marker: Marker2D = %FootPosMarker
@onready var ground_companion: Area2D = %GroundCompanion @onready var ground_companion: Area2D = %GroundCompanion
@onready var phantom_camera_noise_emitter_2d: PhantomCameraNoiseEmitter2D = %PhantomCameraNoiseEmitter2D
enum Direction{LEFT,RIGHT} enum Direction{LEFT,RIGHT}
var direction: Direction = Direction.RIGHT: set = _player_direction_changed var direction: Direction = Direction.RIGHT: set = _player_direction_changed
@ -58,7 +61,6 @@ func _draw() -> void:
func _process(delta: float) -> void: func _process(delta: float) -> void:
queue_redraw() queue_redraw()
print(self.is_on_floor())
func set_move_input(dir: Vector2) -> void: func set_move_input(dir: Vector2) -> void:

View File

@ -24,6 +24,8 @@ func _enter() -> void:
tween.tween_interval(.12) tween.tween_interval(.12)
tween.tween_property(Engine, "time_scale", 1.0, .06) tween.tween_property(Engine, "time_scale", 1.0, .06)
agent.phantom_camera_noise_emitter_2d.emit()
if root.grap_hook_state._jump_grace_timer > 0: if root.grap_hook_state._jump_grace_timer > 0:
_hook_to_jump() _hook_to_jump()

19
_shared/CameraAnchor.gd Normal file
View File

@ -0,0 +1,19 @@
@tool
class_name CameraAnchor extends Node2D
@export var priority: int = 0
@export var enabled: bool = true
@export var blend_time: float = 0.3
@export var zoom: Vector2 = Vector2.ONE
@export var offset: Vector2 = Vector2.ZERO
func _enter_tree() -> void:
if Engine.is_editor_hint():
return
CameraSystem.register_anchor(self)
func _exit_tree() -> void:
if Engine.is_editor_hint():
return
CameraSystem.unregister_anchor(self)

View File

@ -0,0 +1 @@
uid://dyxrydokgy0qs

View File

@ -0,0 +1,6 @@
[gd_scene load_steps=2 format=3 uid="uid://bflwr7cryd2l0"]
[ext_resource type="Script" uid="uid://dyxrydokgy0qs" path="res://_shared/CameraAnchor.gd" id="1_dhu66"]
[node name="CameraAnchor" type="Node2D"]
script = ExtResource("1_dhu66")

View File

@ -1,15 +0,0 @@
[gd_scene load_steps=3 format=3 uid="uid://b8pv5wtbo0y20"]
[ext_resource type="Script" uid="uid://bd046eokvcnu2" path="res://addons/phantom_camera/scripts/phantom_camera_host/phantom_camera_host.gd" id="1_tvldw"]
[ext_resource type="Script" uid="uid://lpenhftmjj4o" path="res://_shared/camera_system.gd" id="1_vo3bs"]
[node name="CameraSystem" type="Node"]
script = ExtResource("1_vo3bs")
[node name="Camera2D" type="Camera2D" parent="."]
[node name="PhantomCameraHost" type="Node" parent="Camera2D"]
process_priority = 300
process_physics_priority = 300
script = ExtResource("1_tvldw")
metadata/_custom_type_script = "uid://bd046eokvcnu2"

View File

@ -0,0 +1,19 @@
extends Node
var _cached_player_camera: GlobalCamera
const PLAYER_CAMERA_SCENE:= preload("res://_shared/camera/PlayerStaticCamera.tscn")
## 注册玩家相机
func register_player_camera(owner: Node) -> GlobalCamera:
if not _cached_player_camera:
_cached_player_camera = PLAYER_CAMERA_SCENE.instantiate() as GlobalCamera
if _cached_player_camera:
owner.add_child(_cached_player_camera)
return _cached_player_camera
## 外部获取玩家全局相机
func get_cached_camera() -> GlobalCamera:
return _cached_player_camera

View File

@ -0,0 +1 @@
uid://04mchxkp161a

View File

@ -0,0 +1,4 @@
class_name GlobalCamera extends Node2D
@onready var phantom_camera_2d: PhantomCamera2D = %PhantomCamera2D
@onready var phantom_camera_noise_emitter_2d: PhantomCameraNoiseEmitter2D = %PhantomCameraNoiseEmitter2D

View File

@ -0,0 +1 @@
uid://52tgslofxoi2

View File

@ -0,0 +1,21 @@
[gd_scene load_steps=4 format=3 uid="uid://d1w8ftfhxycfy"]
[ext_resource type="Script" uid="uid://52tgslofxoi2" path="res://_shared/camera/GlobalCamera.gd" id="1_fixiw"]
[ext_resource type="Script" uid="uid://bhexx6mj1xv3q" path="res://addons/phantom_camera/scripts/phantom_camera/phantom_camera_2d.gd" id="1_llsih"]
[ext_resource type="Script" uid="uid://bhd4nuiu23e7l" path="res://addons/phantom_camera/scripts/phantom_camera/phantom_camera_noise_emitter_2d.gd" id="3_0bl5s"]
[node name="PlayerStaticCamera" type="Node2D"]
script = ExtResource("1_fixiw")
[node name="PhantomCamera2D" type="Node2D" parent="."]
unique_name_in_owner = true
script = ExtResource("1_llsih")
priority = 1000
tween_on_load = false
draw_limits = true
metadata/_custom_type_script = "uid://bhexx6mj1xv3q"
[node name="PhantomCameraNoiseEmitter2D" type="Node2D" parent="PhantomCamera2D"]
unique_name_in_owner = true
script = ExtResource("3_0bl5s")
metadata/_custom_type_script = "uid://bhd4nuiu23e7l"

View File

@ -0,0 +1,133 @@
[gd_scene load_steps=3 format=3 uid="uid://b8pv5wtbo0y20"]
[ext_resource type="Script" uid="uid://bd046eokvcnu2" path="res://addons/phantom_camera/scripts/phantom_camera_host/phantom_camera_host.gd" id="2_s84x6"]
[sub_resource type="GDScript" id="GDScript_3tsvq"]
script/source = "'''全局的相机管理器
======= 外部调用函数 =======
'''
extends Node
var _cached_player_camera: GlobalCamera
var _cached_anchors: Array[CameraAnchor] = []
var _current_anchor: CameraAnchor
var _switch_tween: Tween
## 玩家关卡内静态相机
const PLAYER_CAMERA_SCENE:= preload(\"res://_shared/camera/PlayerStaticCamera.tscn\")
## 注册玩家相机
func register_player_camera(owner: Node) -> GlobalCamera:
if not _cached_player_camera:
_cached_player_camera = PLAYER_CAMERA_SCENE.instantiate() as GlobalCamera
if _cached_player_camera:
owner.add_child(_cached_player_camera)
return _cached_player_camera
## 外部获取玩家全局相机
func get_cached_camera() -> GlobalCamera:
return _cached_player_camera
## 注册一个相机锚点
func register_anchor(anchor: CameraAnchor) -> void:
if anchor in _cached_anchors:
return
_cached_anchors.append(anchor)
_sort_anchors()
_try_auto_switch()
## 注销一个相机锚点
func unregister_anchor(anchor: CameraAnchor) -> void:
_cached_anchors.erase(anchor)
if _current_anchor == anchor:
_current_anchor = null
_try_auto_switch()
## 排序已有的锚点
func _sort_anchors() -> void:
_cached_anchors.sort_custom(func(a, b):
return a.priority > b.priority
)
## 尝试自切换
func _try_auto_switch() -> void:
for a in _cached_anchors:
if a.enabled:
switch_anchor(a)
return
## 重置所有的Camera的priority
func reset_all_camera_priority() -> void:
for a in _cached_anchors:
a.priority = 0
## 切换相机
func switch_anchor(target_anchor: CameraAnchor) -> void:
if target_anchor == null:
return
if target_anchor == _current_anchor:
return
if not is_instance_valid(_cached_player_camera):
return
# 中断旧 Tween
if _switch_tween and _switch_tween.is_running():
_switch_tween.kill()
_switch_tween = null
var camera := _cached_player_camera
var blend_time : float = max(target_anchor.blend_time, 0.001)
# 创建 Tween关键ignore time scale
_switch_tween = get_tree().create_tween()
_switch_tween.set_ignore_time_scale(true)
_switch_tween.set_trans(Tween.TRANS_SINE)
_switch_tween.set_ease(Tween.EASE_OUT)
# ===== 位置 =====
_switch_tween.tween_property(
camera,
\"global_position\",
target_anchor.global_position,
blend_time
)
# ===== Zoom =====
_switch_tween.tween_property(
camera,
\"zoom\",
target_anchor.zoom,
blend_time
)
# ===== Offset =====
_switch_tween.tween_property(
camera,
\"offset\",
target_anchor.offset,
blend_time
)
# 完成回调
_switch_tween.finished.connect(func():
_current_anchor = target_anchor
)
_current_anchor = target_anchor
"
[node name="CameraSystem" type="Node"]
script = SubResource("GDScript_3tsvq")
[node name="Camera2D" type="Camera2D" parent="."]
[node name="PhantomCameraHost" type="Node" parent="Camera2D"]
process_priority = 300
process_physics_priority = 300
script = ExtResource("2_s84x6")
metadata/_custom_type_script = "uid://bd046eokvcnu2"

View File

@ -0,0 +1,12 @@
[gd_resource type="Resource" script_class="PhantomCameraNoise2D" load_steps=2 format=3 uid="uid://dy1hsviasxfu0"]
[ext_resource type="Script" uid="uid://dimvdouy8g0sv" path="res://addons/phantom_camera/scripts/resources/phantom_camera_noise_2d.gd" id="1_oi7x7"]
[resource]
script = ExtResource("1_oi7x7")
amplitude = 8.0
frequency = 15.0
randomize_noise_seed = 1
noise_seed = 896
positional_multiplier_y = 2.0
metadata/_custom_type_script = "uid://dimvdouy8g0sv"

View File

@ -1,35 +0,0 @@
class_name CameraRoom extends Node2D
@onready var phantom_camera2d: PhantomCamera2D = $PhantomCamera2D
@onready var default_start_point: Node2D = $PlayerStartPoint
@export var _room_id : int = -1
func _ready() -> void:
#room_entrance.body_entered.connect(_handle_body_enter_room)
RoomSystem.room_changed.connect(_handle_global_room_changed)
##绑定一个Room下面的room entrance到进入这个房间
for r in self.get_children():
if r is RoomEntrance:
r.body_entered.connect(_handle_body_enter_room)
r.init_room_entrance(self)
self.get_process_delta_time()
func _handle_body_enter_room(body: Node2D) -> void:
if RoomSystem.current_room_id == self._room_id:
return
if body != null:
RoomSystem.update_current_room_id(self._room_id)
return
func _handle_global_room_changed(room_id: int) -> void:
if room_id == self._room_id:
_update_room_to_self()
func reset_priority() -> void:
phantom_camera2d.priority = 0
func _update_room_to_self() -> void:
phantom_camera2d.priority = 99

View File

@ -1 +0,0 @@
uid://c7fditim2t1c1

View File

@ -1,11 +0,0 @@
'''全局的相机管理器
======= =======
force_change_camera(camera : ReedCamera)
func camera_room_enterd(camear : ReedCamera) Camera Room
func camera_room_exited(camera_room : ReedCameraRoom) Camera Room
'''
extends Node

View File

@ -1 +0,0 @@
uid://lpenhftmjj4o

View File

@ -1,21 +0,0 @@
[gd_scene load_steps=5 format=3 uid="uid://byf5lgbkjk52y"]
[ext_resource type="Script" uid="uid://c7fditim2t1c1" path="res://_shared/camera_room.gd" id="1_yrcw7"]
[ext_resource type="Script" uid="uid://bhexx6mj1xv3q" path="res://addons/phantom_camera/scripts/phantom_camera/phantom_camera_2d.gd" id="2_bdhnx"]
[ext_resource type="Script" uid="uid://8umksf8e80fw" path="res://addons/phantom_camera/scripts/resources/tween_resource.gd" id="3_p25y8"]
[sub_resource type="Resource" id="Resource_y58mf"]
script = ExtResource("3_p25y8")
[node name="Room" type="Node2D" groups=["ROOM"]]
script = ExtResource("1_yrcw7")
_room_id = 10001
[node name="PhantomCamera2D" type="Node2D" parent="."]
script = ExtResource("2_bdhnx")
zoom = Vector2(0.8, 0.8)
tween_resource = SubResource("Resource_y58mf")
tween_on_load = false
metadata/_custom_type_script = "uid://bhexx6mj1xv3q"
[node name="PlayerStartPoint" type="Marker2D" parent="."]

View File

@ -1,9 +0,0 @@
@tool
class_name RoomEntrance extends Area2D
@export var restart_node: Node2D
##如果没有手动绑定Start节点则自动绑定到Room的default
func init_room_entrance(room: CameraRoom) -> void:
if restart_node == null:
restart_node = room.default_start_point

View File

@ -1 +0,0 @@
uid://ir0fur783tru

View File

@ -1,6 +0,0 @@
[gd_scene load_steps=2 format=3 uid="uid://d1mnkm2uv857q"]
[ext_resource type="Script" uid="uid://ir0fur783tru" path="res://_shared/room_entrance.gd" id="1_nlirq"]
[node name="RoomEntrance" type="Area2D"]
script = ExtResource("1_nlirq")

View File

@ -1,35 +0,0 @@
extends Node
var current_room_id: int = 0
var defalut_room_id: int = 10001
signal room_changed(room_id: int)
func _ready() -> void:
init_room()
##更新房间id
func update_current_room_id(room_id: int) -> bool:
if room_id == current_room_id:
return false
reset_all_room_camera_property()
current_room_id = room_id
room_changed.emit(room_id)
return true
##重置所有房间的room property
func reset_all_room_camera_property() -> void:
get_tree().call_group(&"ROOM",&"reset_priority")
##初始化相机房间
func init_room() -> void:
for r in get_tree().get_nodes_in_group(&"ROOM"):
if r._room_id == defalut_room_id:
if r.is_node_ready():
update_current_room_id(defalut_room_id)
break
else:
await r.ready
update_current_room_id(defalut_room_id)
break

View File

@ -1 +0,0 @@
uid://bnl485emckxmh

View File

@ -18,8 +18,7 @@ config/icon="res://icon.svg"
[autoload] [autoload]
PhantomCameraManager="*res://addons/phantom_camera/scripts/managers/phantom_camera_manager.gd" PhantomCameraManager="*res://addons/phantom_camera/scripts/managers/phantom_camera_manager.gd"
CameraSystem="*res://_shared/CameraSystem.tscn" CameraSystem="*res://_shared/camera/camera_shake/CameraSystem.tscn"
RoomSystem="*res://_shared/room_system.gd"
GlobalEvent="*res://_shared/global_event.gd" GlobalEvent="*res://_shared/global_event.gd"
ReedVFX="*res://addons/reedfx/vfx/ReedVFXSystem.tscn" ReedVFX="*res://addons/reedfx/vfx/ReedVFXSystem.tscn"
ReedSceneRegistry="*res://addons/reedscene/scene/SceneRegistry.gd" ReedSceneRegistry="*res://addons/reedscene/scene/SceneRegistry.gd"