fixed portal pairing
This commit is contained in:
parent
a412ab90e6
commit
b4a7cf00d6
1 changed files with 39 additions and 39 deletions
|
|
@ -76,7 +76,7 @@ func clear_tiles() -> void:
|
|||
remove_tile(location)
|
||||
|
||||
# Function to place random game tiles at the start of each match
|
||||
func place_random_game_tiles(num_tiles: int = 6) -> void:
|
||||
func place_random_game_tiles(num_tiles: int = 8) -> void:
|
||||
if !board_flow:
|
||||
push_error("TileManager not initialized with board_flow")
|
||||
return
|
||||
|
|
@ -89,8 +89,11 @@ func place_random_game_tiles(num_tiles: int = 6) -> void:
|
|||
|
||||
available_positions.shuffle()
|
||||
|
||||
|
||||
var skipNext = false;
|
||||
for i in range(min(num_tiles, available_positions.size())):
|
||||
if skipNext:
|
||||
skipNext = false
|
||||
continue
|
||||
var pos = available_positions[i]
|
||||
var container = board_flow.get_node(pos) as PieceContainer
|
||||
if !container:
|
||||
|
|
@ -116,6 +119,34 @@ func place_random_game_tiles(num_tiles: int = 6) -> void:
|
|||
2: # Portal pair
|
||||
# Only create portal pair if this isn't the last tile
|
||||
if i < available_positions.size() - 1:
|
||||
var next_pos = available_positions[i + 1]
|
||||
var next_container = board_flow.get_node(next_pos) as PieceContainer
|
||||
if next_container:
|
||||
# var next_is_white = (int(next_pos.split("-")[0]) + int(next_pos.split("-")[1])) % 2 == 0
|
||||
|
||||
# # Create portal pair with alternating blue/orange colors
|
||||
# # var portal_color = Color.ORANGE if (i % 2 == 0) else Color.BLUE
|
||||
# var portals = PortalTile.create_portal_pair(
|
||||
# container, is_white,
|
||||
# next_container, next_is_white,
|
||||
# -1, # permanent duration
|
||||
# i, # pair id
|
||||
# Color.ORANGE,
|
||||
# Color.BLUE
|
||||
# )
|
||||
|
||||
# # Add both portals
|
||||
# add_tile(pos, portals[0])
|
||||
# add_tile(next_pos, portals[1])
|
||||
place_portal_pair(pos, i, available_positions, container, is_white)
|
||||
# Skip the next position since we used it for the portal pair
|
||||
skipNext = true
|
||||
else:
|
||||
# If we can't make a pair, fall back to a wall tile
|
||||
tile = WallTile.new(container, is_white, -1)
|
||||
add_tile(pos, tile)
|
||||
|
||||
func place_portal_pair(pos: String = "", i: int = 0, available_positions: Array = [], container: PieceContainer = null, is_white: bool = false) -> void:
|
||||
var next_pos = available_positions[i + 1]
|
||||
var next_container = board_flow.get_node(next_pos) as PieceContainer
|
||||
if next_container:
|
||||
|
|
@ -135,34 +166,3 @@ func place_random_game_tiles(num_tiles: int = 6) -> void:
|
|||
# Add both portals
|
||||
add_tile(pos, portals[0])
|
||||
add_tile(next_pos, portals[1])
|
||||
|
||||
# Skip the next position since we used it for the portal pair
|
||||
i += 1
|
||||
else:
|
||||
# If we can't make a pair, fall back to a wall tile
|
||||
tile = WallTile.new(container, is_white, -1)
|
||||
add_tile(pos, tile)
|
||||
|
||||
# func place_portal_pair(location1: String, location2: String, duration: int = -1) -> void:
|
||||
# var container1 = board_flow.get_node(location1) as PieceContainer
|
||||
# var container2 = board_flow.get_node(location2) as PieceContainer
|
||||
|
||||
# if container1 && container2:
|
||||
# var is_white1 = (int(location1.split("-")[0]) + int(location1.split("-")[1])) % 2 == 0
|
||||
# var is_white2 = (int(location2.split("-")[0]) + int(location2.split("-")[1])) % 2 == 0
|
||||
|
||||
# # Generate a unique color for this pair
|
||||
# var portal_color = Color(randf(), randf(), 1.0) # Blue-ish random color
|
||||
|
||||
# # Create portal pair
|
||||
# var portals = PortalTile.create_portal_pair(
|
||||
# container1, is_white1,
|
||||
# container2, is_white2,
|
||||
# duration,
|
||||
# active_tiles.size(), # Use current size as unique pair ID
|
||||
# portal_color
|
||||
# )
|
||||
|
||||
# # Add both portals to active tiles
|
||||
# add_tile(location1, portals[0])
|
||||
# add_tile(location2, portals[1])
|
||||
|
|
|
|||
Loading…
Reference in a new issue