feat: Implement Stop N Go game mode with a new manager script and associated gridmap assets within the MeshLibrary.

This commit is contained in:
Yogi Wiguna
2026-02-24 10:43:00 +08:00
parent a536e060c9
commit ea49eb2e4a
6 changed files with 59 additions and 16 deletions
+16 -15
View File
@@ -22,7 +22,8 @@ var finish_line_x: int = 21 # Right side of the map for win condition
# Tile IDs
const TILE_WALKABLE = 0
const TILE_START = 2 # Start Line
const TILE_START = 3 # Start Line
const TILE_FINISH = 3 # Finish Line
const TILE_SAFE = 2 # Green Safe Zone
const TILE_OBSTACLE = 4 # Wall
@@ -143,7 +144,7 @@ func _update_stop_timer_visuals():
var hbox = stop_timer_node.get_node_or_null("HBox")
if hbox:
stop_segments.clear()
for i in range(4):
for i in range(3):
var seg = hbox.get_node_or_null("Segment%d" % i)
if seg: stop_segments.append(seg)
@@ -173,9 +174,9 @@ func _update_stop_timer_visuals():
stop_timer_node.visible = true
if current_phase == Phase.GO:
# GO Phase: All dim unless in last 4 seconds
# GO Phase: All dim unless in last 3 seconds
for i in range(stop_segments.size()):
var threshold = 4.0 - i
var threshold = 3.0 - i
if phase_timer <= threshold:
stop_segments[i].add_theme_stylebox_override("panel", lit_style)
else:
@@ -277,6 +278,8 @@ func _apply_arena_setup():
var tile_id = TILE_WALKABLE
if x == 0:
tile_id = TILE_START
elif x == gridmap.columns - 1:
tile_id = TILE_FINISH
elif x in safe_columns:
tile_id = TILE_SAFE
@@ -352,16 +355,14 @@ func _spawn_mission_tiles():
if base_tile == TILE_OBSTACLE:
continue
# Randomly populate other floors with goal tiles
# 30% chance to have a tile to avoid overcrowding
if randf() < 0.3:
var tile_type = goal_items[randi() % goal_items.size()]
gridmap.set_cell_item(Vector3i(x, 1, z), tile_type)
# Sync to clients
var main = get_node("/root/Main")
if main:
main.rpc("sync_grid_item", x, 1, z, tile_type)
# Spawn tiles on all floors (100% density)
var tile_type = goal_items[randi() % goal_items.size()]
gridmap.set_cell_item(Vector3i(x, 1, z), tile_type)
# Sync to clients
var main = get_node("/root/Main")
if main:
main.rpc("sync_grid_item", x, 1, z, tile_type)
func _assign_missions():
# NO-OP: Missions are now achievement-based (Complete 3 Goals)
@@ -384,7 +385,7 @@ func check_movement_violation(player_id: int, from: Vector2i, to: Vector2i) -> b
# Usually implies checking if you ARE in a safe zone.
var tile_from = gridmap.get_cell_item(Vector3i(from.x, 0, from.y))
if tile_from != TILE_SAFE:
if tile_from != TILE_SAFE and tile_from != TILE_START and tile_from != TILE_FINISH:
_penalize_player(player_id)
return true
return false