feat: Add initial player character, movement, network synchronization, bot AI, and game managers.

This commit is contained in:
Yogi Wiguna
2026-02-24 16:54:45 +08:00
parent aa6d6dcec2
commit e31973dfab
7 changed files with 367 additions and 127 deletions
+16 -13
View File
@@ -11,7 +11,7 @@ enum Phase {GO, STOP}
const GO_DURATION: float = 8.0
const STOP_DURATION: float = 4.0
const REQUIRED_GOALS: int = 2
const REQUIRED_GOALS: int = 5
var current_phase: Phase = Phase.GO
var phase_timer: float = GO_DURATION
@@ -416,12 +416,7 @@ func sync_mission_progress(_player_id: int, _mission_index: int, _current: int):
# Deprecated
pass
func check_win_condition(player_id: int, position: Vector2i) -> bool:
# 1. Must reach the finish line (Column 21)
if position.x < finish_line_x:
return false
# 2. Must have enough Goal Completions (tracked by GoalsCycleManager)
func is_mission_complete(player_id: int) -> bool:
var main = get_node_or_null("/root/Main")
if not main: return false
@@ -429,15 +424,23 @@ func check_win_condition(player_id: int, position: Vector2i) -> bool:
if not goals_cycle_manager: return false
var completed_count = goals_cycle_manager.player_goal_counts.get(player_id, 0)
if completed_count >= REQUIRED_GOALS:
print("[StopNGo] Player %d REACHED FINISH with %d goals complete!" % [player_id, completed_count])
return completed_count >= REQUIRED_GOALS
func check_win_condition(player_id: int, position: Vector2i) -> bool:
# 1. Must reach the finish line (Column 21)
if position.x < finish_line_x:
return false
# 2. Must have enough Goal Completions
if is_mission_complete(player_id):
print("[StopNGo] Player %d REACHED FINISH with goals complete!" % player_id)
return true
else:
# Inform the player locally if they reach the end without goals
var player_node = main.get_node_or_null(str(player_id))
var main = get_node_or_null("/root/Main")
var player_node = main.get_node_or_null(str(player_id)) if main else null
if player_node:
NotificationManager.send_message(player_node, "Incomplete! Achieve %d goals (x%d) to win!" % [REQUIRED_GOALS, REQUIRED_GOALS], NotificationManager.MessageType.WARNING)
NotificationManager.send_message(player_node, "Incomplete! Achieve %d goals to win!" % REQUIRED_GOALS, NotificationManager.MessageType.WARNING)
print("[StopNGo] Player %d reached finish but goal count too low: %d/%d" % [player_id, completed_count, REQUIRED_GOALS])
print("[StopNGo] Player %d reached finish but goals incomplete." % player_id)
return false