feat: Add dynamic camera context manager, initial main scene setup with gridmap and UI, and player script.
This commit is contained in:
@@ -19,6 +19,8 @@ var camera_setups = [
|
||||
]
|
||||
|
||||
var unique_id: int
|
||||
var current_row_setup: int = -1
|
||||
var current_col_setup: int = -1
|
||||
|
||||
func initialize(p_camera: Camera3D, _p_shake_manager: Node):
|
||||
camera = p_camera
|
||||
@@ -58,18 +60,79 @@ func _update_camera_target():
|
||||
# Player current_position is Vector2i(grid_x, grid_y)
|
||||
|
||||
var current_row = player.current_position.y
|
||||
var target_pos = Vector3.ZERO
|
||||
var current_col = player.current_position.x
|
||||
|
||||
for i in range(camera_setups.size()):
|
||||
var setup = camera_setups[i]
|
||||
if current_row <= setup.max_row:
|
||||
target_pos = setup.position
|
||||
break
|
||||
# --- ROW LOGIC (Z/Y) ---
|
||||
# Zone 1 (Top): 0-4
|
||||
# Zone 2 (Mid): 5-9
|
||||
# Zone 3 (Bot): 10-13
|
||||
|
||||
# Initialize if needed
|
||||
if current_row_setup == -1:
|
||||
if current_row <= 4: current_row_setup = 0
|
||||
elif current_row <= 9: current_row_setup = 1
|
||||
else: current_row_setup = 2
|
||||
|
||||
# Row Hysteresis
|
||||
match current_row_setup:
|
||||
0: # Top
|
||||
if current_row >= 6: current_row_setup = 1 # Move to Mid
|
||||
1: # Mid
|
||||
if current_row <= 3: current_row_setup = 0 # Move to Top
|
||||
elif current_row >= 11: current_row_setup = 2 # Move to Bot
|
||||
2: # Bot
|
||||
if current_row <= 8: current_row_setup = 1 # Move to Mid
|
||||
|
||||
# --- COLUMN LOGIC (X) ---
|
||||
# Zone 1 (Left): 0-4
|
||||
# Zone 2 (Center): 5-9
|
||||
# Zone 3 (Right): 10-13
|
||||
|
||||
# Initialize if needed
|
||||
if current_col_setup == -1:
|
||||
if current_col <= 4: current_col_setup = 0
|
||||
elif current_col <= 9: current_col_setup = 1
|
||||
else: current_col_setup = 2
|
||||
|
||||
# Col Hysteresis
|
||||
match current_col_setup:
|
||||
0: # Left
|
||||
if current_col >= 6: current_col_setup = 1 # Move to Center
|
||||
1: # Center
|
||||
if current_col <= 3: current_col_setup = 0 # Move to Left
|
||||
elif current_col >= 11: current_col_setup = 2 # Move to Right
|
||||
2: # Right
|
||||
if current_col <= 8: current_col_setup = 1 # Move to Center
|
||||
|
||||
# --- TARGET CALCULATION ---
|
||||
var target_z = 0.0
|
||||
var target_y = 0.0
|
||||
var target_x = 7.0
|
||||
|
||||
# Apply Row Targets
|
||||
match current_row_setup:
|
||||
0: # Top
|
||||
target_z = 15.0
|
||||
target_y = 19.636
|
||||
1: # Mid
|
||||
target_z = 19.0
|
||||
target_y = 19.636
|
||||
2: # Bot
|
||||
target_z = 22.5
|
||||
target_y = 19.22636
|
||||
|
||||
# Apply Col Targets
|
||||
match current_col_setup:
|
||||
0: # Left
|
||||
target_x = 5.0
|
||||
1: # Center
|
||||
target_x = 7.0
|
||||
2: # Right
|
||||
target_x = 9.0
|
||||
|
||||
var target_pos = Vector3(target_x, target_y, target_z)
|
||||
|
||||
# print("[CameraContextManager] Player Row: %d -> Selected Setup: %d (Target: %s)" % [current_row, setup_index, target_pos])
|
||||
|
||||
# Update ScreenShakeManager's target
|
||||
# Update Camera Position directly with Tween
|
||||
if camera.position != target_pos:
|
||||
var tween = create_tween()
|
||||
tween.tween_property(camera, "position", target_pos, 1.0).set_trans(Tween.TRANS_SINE).set_ease(Tween.EASE_IN_OUT)
|
||||
tween.tween_property(camera, "position", target_pos, 0.4).set_trans(Tween.TRANS_SINE).set_ease(Tween.EASE_IN_OUT)
|
||||
|
||||
Reference in New Issue
Block a user