diff --git a/scenes/main.tscn b/scenes/main.tscn index 185ef88..389ff7a 100644 --- a/scenes/main.tscn +++ b/scenes/main.tscn @@ -15,6 +15,7 @@ [ext_resource type="Texture2D" uid="uid://dasaeaytvhll0" path="res://assets/models/pboard/AdjacentRect.tres" id="9_aspsw"] [ext_resource type="FontFile" uid="uid://xnjx058n4tsw" path="res://assets/fonts/Nougat-ExtraBlack.ttf" id="13_j8jky"] [ext_resource type="Theme" uid="uid://0dhxl4ohyxh8" path="res://assets/graphics/game_setting/setting_theme.tres" id="18_pm3ni"] +[ext_resource type="PackedScene" uid="uid://dqp3e6q3orers" path="res://scenes/arena/stop_n_go.scn" id="24_y6deb"] [ext_resource type="Texture2D" uid="uid://ba80xnybpixw2" path="res://assets/graphics/touch_control/take_tile.png" id="25_qkpxi"] [ext_resource type="Texture2D" uid="uid://bsgqrjx2ity4c" path="res://assets/graphics/touch_control/speed.png" id="26_2f3dj"] [ext_resource type="Texture2D" uid="uid://pwxo4lb87yi" path="res://assets/graphics/touch_control/put_tile.png" id="26_5q0nq"] @@ -1730,6 +1731,8 @@ custom_minimum_size = Vector2(0, 40) layout_mode = 2 text = "Back" +[node name="StopNGo" parent="." unique_id=1986641660 instance=ExtResource("24_y6deb")] + [connection signal="text_submitted" from="MessageInput" to="." method="_on_message_input_text_submitted"] [connection signal="pressed" from="PauseMenu/Panel/VBox/ResumeBtn" to="." method="_on_resume_pressed"] [connection signal="pressed" from="PauseMenu/Panel/VBox/HowToPlayBtn" to="." method="_on_how_to_play_pressed"] diff --git a/scripts/managers/stop_n_go_manager.gd b/scripts/managers/stop_n_go_manager.gd index c897e36..99ce3dc 100644 --- a/scripts/managers/stop_n_go_manager.gd +++ b/scripts/managers/stop_n_go_manager.gd @@ -42,6 +42,7 @@ const TILE_FINISH = 3 # Finish Line const TILE_SAFE = 2 # Green Safe Zone const TILE_OBSTACLE = 4 # Wall const TILE_LIGHTNING_STONE = 15 # Ancient Rock with Lightning Symbol +const TILE_SAFE_WALL = 16 # Safe Zone Wall var hud_layer: CanvasLayer var mission_label: Label @@ -354,14 +355,117 @@ func _apply_arena_setup(): gridmap.set_cell_item(Vector3i(x, 0, z), tile_id) gridmap.set_cell_item(Vector3i(x, 1, z), -1) - # Dynamic Safe Zones are procedural and spawn during GO phase - - # Note: Specific obstacles removed as per user request to replace with random ones. - # MISSION TILES: Moved to start_game_mode() to ensure they spawn AFTER walls. + # Create rooms (Option B: hollow inside, walls around edges) + # Room 1: (7,6) to (11,9) - 5x4 Area. Boundaries: X[7..11], Z[6..9] + var r1_entrances = [Vector2i(7, 8), Vector2i(9, 6), Vector2i(9, 9), Vector2i(11, 8)] + _create_room_with_edge_walls(gridmap, 7, 6, 11, 9, r1_entrances) + # Non-walkable obstacle inside Room 1 + gridmap.set_cell_item(Vector3i(9, 1, 8), TILE_OBSTACLE) + + # Room 2: (15,1) to (19,5) - 5x5 Area. Boundaries: X[15..19], Z[1..5] + var r2_entrances = [Vector2i(15, 2), Vector2i(17, 1), Vector2i(19, 2), Vector2i(18, 5)] + _create_room_with_edge_walls(gridmap, 15, 1, 19, 5, r2_entrances) + gridmap.update_grid_data() gridmap.initialize_astar() + +func _create_room_with_edge_walls(gridmap: GridMap, x_start: int, z_start: int, x_end: int, z_end: int, entrances: Array): + for x in range(x_start, x_end + 1): + for z in range(z_start, z_end + 1): + var is_north = (z == z_start) + var is_south = (z == z_end) + var is_west = (x == x_start) + var is_east = (x == x_end) + + if is_north or is_south or is_west or is_east: + if not Vector2i(x, z) in entrances: + # We NO LONGER set TILE_OBSTACLE here so you can walk near the walls + # gridmap.set_cell_item(Vector3i(x, 1, z), TILE_OBSTACLE) + + # Determine placement SIDE and rotation + if is_north: _instantiate_safe_zone_wall(gridmap, x, z, "NORTH") + if is_south: _instantiate_safe_zone_wall(gridmap, x, z, "SOUTH") + if is_west: _instantiate_safe_zone_wall(gridmap, x, z, "WEST") + if is_east: _instantiate_safe_zone_wall(gridmap, x, z, "EAST") + + # Ensure ground is floor + var current_f0 = gridmap.get_cell_item(Vector3i(x, 0, z)) + if current_f0 == -1: + gridmap.set_cell_item(Vector3i(x, 0, z), TILE_WALKABLE) + +func _disconnect_astar_across_walls(gridmap: Node): + if not gridmap or not gridmap.get("astar"): return + var astar = gridmap.astar + # We re-calculate the edges and disconnect + var rooms = [ + {"start": Vector2i(7, 6), "end": Vector2i(11, 9), "entrances": [Vector2i(7, 8), Vector2i(9, 6), Vector2i(9, 10), Vector2i(11, 8)]}, + {"start": Vector2i(15, 1), "end": Vector2i(19, 5), "entrances": [Vector2i(15, 2), Vector2i(17, 1), Vector2i(19, 2), Vector2i(18, 5)]} + ] + + for room in rooms: + for x in range(room.start.x, room.end.x + 1): + for z in range(room.start.y, room.end.y + 1): + var pos = Vector2i(x, z) + var is_north = (z == room.start.y) + var is_south = (z == room.end.y) + var is_west = (x == room.start.x) + var is_east = (x == room.end.x) + + if is_north or is_south or is_west or is_east: + if pos in room.entrances: continue + + var current_id = gridmap.get_point_id(Vector3i(x, 0, z)) + + if is_north: + var n_id = gridmap.get_point_id(Vector3i(x, 0, z - 1)) + if astar.has_point(current_id) and astar.has_point(n_id): + astar.disconnect_points(current_id, n_id) + if is_south: + var s_id = gridmap.get_point_id(Vector3i(x, 0, z + 1)) + if astar.has_point(current_id) and astar.has_point(s_id): + astar.disconnect_points(current_id, s_id) + if is_west: + var w_id = gridmap.get_point_id(Vector3i(x - 1, 0, z)) + if astar.has_point(current_id) and astar.has_point(w_id): + astar.disconnect_points(current_id, w_id) + if is_east: + var e_id = gridmap.get_point_id(Vector3i(x + 1, 0, z)) + if astar.has_point(current_id) and astar.has_point(e_id): + astar.disconnect_points(current_id, e_id) + +func _instantiate_safe_zone_wall(gridmap: GridMap, x: int, z: int, side: String): + var wall_scene = load("res://scenes/safe_zone_wall.tscn") + if not wall_scene: return + + var wall = wall_scene.instantiate() + gridmap.add_child(wall) + + var pos = Vector3( + x * gridmap.cell_size.x + gridmap.cell_size.x/2, + 0.5, + z * gridmap.cell_size.z + gridmap.cell_size.z/2 + ) + + # Adjust position to the LINE between tiles based on side + match side: + "NORTH": + pos.z = z * gridmap.cell_size.z # Top edge of cell + wall.rotation_degrees.y = 0 + "SOUTH": + pos.z = (z + 1) * gridmap.cell_size.z # Bottom edge + wall.rotation_degrees.y = 0 + "WEST": + pos.x = x * gridmap.cell_size.x # Left edge + wall.rotation_degrees.y = 90 + "EAST": + pos.x = (x + 1) * gridmap.cell_size.x # Right edge + wall.rotation_degrees.y = 90 + + wall.add_to_group("SafeZoneWalls") + wall.global_position = pos + func setup_mission_tiles(): """Public wrapper to trigger mission tile spawning before game start.""" if multiplayer.is_server():