feat: Introduce Stop N Go game mode manager handling phase transitions, missions, arena setup, and a new camera context manager.
This commit is contained in:
@@ -55,84 +55,114 @@ func _update_camera_target():
|
|||||||
if not player or not camera:
|
if not player or not camera:
|
||||||
return
|
return
|
||||||
|
|
||||||
# Get player row (Z coordinate in 3D world / Y in GridMap)
|
|
||||||
# In this game: Grid Y maps to World Z.
|
|
||||||
# Player current_position is Vector2i(grid_x, grid_y)
|
|
||||||
|
|
||||||
var current_row = player.current_position.y
|
var current_row = player.current_position.y
|
||||||
var current_col = player.current_position.x
|
var current_col = player.current_position.x
|
||||||
|
|
||||||
# --- ROW LOGIC (Z/Y) ---
|
if LobbyManager.game_mode == "Stop n Go":
|
||||||
# Zone 1 (Top): 0-4
|
_update_stop_n_go_camera(current_row, current_col)
|
||||||
# Zone 2 (Mid): 5-9
|
else:
|
||||||
# Zone 3 (Bot): 10-13
|
_update_freemode_camera(current_row, current_col)
|
||||||
|
|
||||||
|
func _update_stop_n_go_camera(current_row: int, current_col: int):
|
||||||
|
# --- STOP N GO: 4 Columns (X), 2 Rows (Y/Z) ---
|
||||||
|
# Columns: 0-5, 6-10, 11-15, 16-21
|
||||||
|
# Rows: 0-4, 5-9
|
||||||
|
|
||||||
# Initialize if needed
|
# 1. Column Logic (4 Zones)
|
||||||
|
if current_col_setup == -1:
|
||||||
|
if current_col <= 5: current_col_setup = 0
|
||||||
|
elif current_col <= 10: current_col_setup = 1
|
||||||
|
elif current_col <= 15: current_col_setup = 2
|
||||||
|
else: current_col_setup = 3
|
||||||
|
|
||||||
|
match current_col_setup:
|
||||||
|
0: # Leftmost
|
||||||
|
if current_col >= 7: current_col_setup = 1
|
||||||
|
1: # Mid-Left
|
||||||
|
if current_col <= 4: current_col_setup = 0
|
||||||
|
elif current_col >= 12: current_col_setup = 2
|
||||||
|
2: # Mid-Right
|
||||||
|
if current_col <= 9: current_col_setup = 1
|
||||||
|
elif current_col >= 17: current_col_setup = 3
|
||||||
|
3: # Rightmost
|
||||||
|
if current_col <= 14: current_col_setup = 2
|
||||||
|
|
||||||
|
# 2. Row Logic (2 Zones)
|
||||||
|
if current_row_setup == -1:
|
||||||
|
if current_row <= 4: current_row_setup = 0
|
||||||
|
else: current_row_setup = 1
|
||||||
|
|
||||||
|
match current_row_setup:
|
||||||
|
0: # Top
|
||||||
|
if current_row >= 6: current_row_setup = 1
|
||||||
|
1: # Bottom
|
||||||
|
if current_row <= 3: current_row_setup = 0
|
||||||
|
|
||||||
|
# 3. Target Calculation
|
||||||
|
var target_x = 3.0 + (current_col_setup * 5.0) # approx centers for 4 zones in 22 cols
|
||||||
|
var target_y = 19.636
|
||||||
|
var target_z = 15.0 if current_row_setup == 0 else 19.5
|
||||||
|
|
||||||
|
# Adjust specific X centers for the 22-col field
|
||||||
|
match current_col_setup:
|
||||||
|
0: target_x = 3.0
|
||||||
|
1: target_x = 8.5
|
||||||
|
2: target_x = 13.5
|
||||||
|
3: target_x = 18.5
|
||||||
|
|
||||||
|
_apply_camera_tween(Vector3(target_x, target_y, target_z))
|
||||||
|
|
||||||
|
func _update_freemode_camera(current_row: int, current_col: int):
|
||||||
|
# --- FREEMODE: 3x3 Grid ---
|
||||||
|
# Zone thresholds 4, 9
|
||||||
|
|
||||||
|
# Row Hysteresis
|
||||||
if current_row_setup == -1:
|
if current_row_setup == -1:
|
||||||
if current_row <= 4: current_row_setup = 0
|
if current_row <= 4: current_row_setup = 0
|
||||||
elif current_row <= 9: current_row_setup = 1
|
elif current_row <= 9: current_row_setup = 1
|
||||||
else: current_row_setup = 2
|
else: current_row_setup = 2
|
||||||
|
|
||||||
# Row Hysteresis
|
|
||||||
match current_row_setup:
|
match current_row_setup:
|
||||||
0: # Top
|
0: # Top
|
||||||
if current_row >= 6: current_row_setup = 1 # Move to Mid
|
if current_row >= 6: current_row_setup = 1
|
||||||
1: # Mid
|
1: # Mid
|
||||||
if current_row <= 3: current_row_setup = 0 # Move to Top
|
if current_row <= 3: current_row_setup = 0
|
||||||
elif current_row >= 11: current_row_setup = 2 # Move to Bot
|
elif current_row >= 11: current_row_setup = 2
|
||||||
2: # Bot
|
2: # Bot
|
||||||
if current_row <= 8: current_row_setup = 1 # Move to Mid
|
if current_row <= 8: current_row_setup = 1
|
||||||
|
|
||||||
# --- COLUMN LOGIC (X) ---
|
# Col Hysteresis
|
||||||
# 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_setup == -1:
|
||||||
if current_col <= 4: current_col_setup = 0
|
if current_col <= 4: current_col_setup = 0
|
||||||
elif current_col <= 9: current_col_setup = 1
|
elif current_col <= 9: current_col_setup = 1
|
||||||
else: current_col_setup = 2
|
else: current_col_setup = 2
|
||||||
|
|
||||||
# Col Hysteresis
|
|
||||||
match current_col_setup:
|
match current_col_setup:
|
||||||
0: # Left
|
0: # Left
|
||||||
if current_col >= 6: current_col_setup = 1 # Move to Center
|
if current_col >= 6: current_col_setup = 1
|
||||||
1: # Center
|
1: # Center
|
||||||
if current_col <= 3: current_col_setup = 0 # Move to Left
|
if current_col <= 3: current_col_setup = 0
|
||||||
elif current_col >= 11: current_col_setup = 2 # Move to Right
|
elif current_col >= 11: current_col_setup = 2
|
||||||
2: # Right
|
2: # Right
|
||||||
if current_col <= 8: current_col_setup = 1 # Move to Center
|
if current_col <= 8: current_col_setup = 1
|
||||||
|
|
||||||
# --- TARGET CALCULATION ---
|
var target_z = 15.0
|
||||||
var target_z = 0.0
|
var target_y = 19.636
|
||||||
var target_y = 0.0
|
|
||||||
var target_x = 7.0
|
var target_x = 7.0
|
||||||
|
|
||||||
# Apply Row Targets
|
|
||||||
match current_row_setup:
|
match current_row_setup:
|
||||||
0: # Top
|
0: target_z = 15.0
|
||||||
target_z = 15.0
|
1: target_z = 19.0
|
||||||
target_y = 19.636
|
2: target_z = 22.5; target_y = 19.22636
|
||||||
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:
|
match current_col_setup:
|
||||||
0: # Left
|
0: target_x = 5.0
|
||||||
target_x = 5.0
|
1: target_x = 7.0
|
||||||
1: # Center
|
2: target_x = 9.0
|
||||||
target_x = 7.0
|
|
||||||
2: # Right
|
|
||||||
target_x = 9.0
|
|
||||||
|
|
||||||
var target_pos = Vector3(target_x, target_y, target_z)
|
_apply_camera_tween(Vector3(target_x, target_y, target_z))
|
||||||
|
|
||||||
# Update Camera Position directly with Tween
|
func _apply_camera_tween(target_pos: Vector3):
|
||||||
if camera.position != target_pos:
|
if camera.position != target_pos:
|
||||||
var tween = create_tween()
|
var tween = create_tween()
|
||||||
tween.tween_property(camera, "position", target_pos, 0.4).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)
|
||||||
|
|||||||
@@ -297,7 +297,7 @@ func _assign_missions():
|
|||||||
"current": 0
|
"current": 0
|
||||||
}
|
}
|
||||||
idx += 1
|
idx += 1
|
||||||
|
|
||||||
if can_rpc():
|
if can_rpc():
|
||||||
rpc("sync_missions", player_missions)
|
rpc("sync_missions", player_missions)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user