feat: Implement UIManager for player action, playerboard, and power-up UI, and add initial lobby, main scenes, and PlayerboardManager.
This commit is contained in:
@@ -10,6 +10,12 @@ var selected_gridmap_position = Vector2i(-1, -1)
|
||||
var selected_playerboard_slot = -1
|
||||
var targeted_playerboard_slot = -1
|
||||
|
||||
# 0-based indices corresponding to User's 1-based request: 1,5,6,10,11,15,16,20,21,22,23,24,25
|
||||
const HIDDEN_SLOTS = [0, 4, 5, 9, 10, 14, 15, 19, 20, 21, 22, 23, 24]
|
||||
|
||||
func is_valid_playerboard_slot(slot_index: int) -> bool:
|
||||
return not (slot_index in HIDDEN_SLOTS)
|
||||
|
||||
func initialize(p_player: Node3D, p_gridmap: Node):
|
||||
player = p_player
|
||||
enhanced_gridmap = p_gridmap
|
||||
@@ -253,7 +259,13 @@ func bot_try_grab_item() -> bool:
|
||||
var item = enhanced_gridmap.get_cell_item(current_cell)
|
||||
|
||||
if item != -1:
|
||||
var empty_slot = player.playerboard.find(-1)
|
||||
# Find empty slot that is NOT hidden
|
||||
var empty_slot = -1
|
||||
for i in range(player.playerboard.size()):
|
||||
if player.playerboard[i] == -1 and not (i in HIDDEN_SLOTS):
|
||||
empty_slot = i
|
||||
break
|
||||
|
||||
if empty_slot != -1:
|
||||
if player.is_multiplayer_authority():
|
||||
# Convert Holo (11-14)
|
||||
@@ -281,7 +293,13 @@ func bot_try_grab_item() -> bool:
|
||||
var cell = Vector3i(neighbor.position.x, 1, neighbor.position.y)
|
||||
item = enhanced_gridmap.get_cell_item(cell)
|
||||
if item != -1:
|
||||
var empty_slot = player.playerboard.find(-1)
|
||||
# Find empty slot that is NOT hidden
|
||||
var empty_slot = -1
|
||||
for i in range(player.playerboard.size()):
|
||||
if player.playerboard[i] == -1 and not (i in HIDDEN_SLOTS):
|
||||
empty_slot = i
|
||||
break
|
||||
|
||||
if empty_slot != -1:
|
||||
if player.is_multiplayer_authority():
|
||||
player.playerboard[empty_slot] = item
|
||||
@@ -477,7 +495,7 @@ func handle_slot_clicked(slot_index: int):
|
||||
return
|
||||
|
||||
var adjacent_slots = get_adjacent_playerboard_slots(selected_playerboard_slot)
|
||||
if slot_index in adjacent_slots and player.playerboard[slot_index] == -1:
|
||||
if slot_index in adjacent_slots and player.playerboard[slot_index] == -1 and not (slot_index in HIDDEN_SLOTS):
|
||||
# Move item to empty target slot
|
||||
var selected_item = player.playerboard[selected_playerboard_slot]
|
||||
player.playerboard[slot_index] = selected_item
|
||||
@@ -526,11 +544,26 @@ func find_best_goal_slot_for_item(item: int) -> int:
|
||||
var board_row = i + 1 # offset to center in 5x5
|
||||
var board_col = j + 1
|
||||
var slot_index = board_row * 5 + board_col
|
||||
|
||||
# Ensure this slot is not hidden (though 3x3 center should be safe, best to check)
|
||||
if slot_index in HIDDEN_SLOTS:
|
||||
continue
|
||||
|
||||
if player.playerboard[slot_index] == -1: # only if empty
|
||||
return slot_index
|
||||
|
||||
# No ideal slot? Return any empty slot
|
||||
return player.playerboard.find(-1)
|
||||
# No ideal goal slot? Look for any empty slot that is NOT hidden AND NOT reserved for Goals
|
||||
# Goal slots are row 2-3, col 1-3 (indices: 11,12,13, 16,17,18) matching User request
|
||||
# Rows 1 (6,7,8) are now storage slots
|
||||
var reserved_goal_slots = [11, 12, 13, 16, 17, 18]
|
||||
|
||||
for i in range(player.playerboard.size()):
|
||||
if player.playerboard[i] == -1:
|
||||
if i in HIDDEN_SLOTS: continue
|
||||
if i in reserved_goal_slots: continue # Skip if it's a goal slot (reserved)
|
||||
return i
|
||||
|
||||
return -1
|
||||
|
||||
func find_best_put_candidate() -> Dictionary:
|
||||
# Convert goals to 2D (3x3)
|
||||
@@ -651,7 +684,11 @@ func has_items_in_playerboard() -> bool:
|
||||
return player.playerboard.any(func(item): return item != -1)
|
||||
|
||||
func playerboard_is_full() -> bool:
|
||||
return player.playerboard.find(-1) == -1
|
||||
# Check if any NON-HIDDEN slot is empty
|
||||
for i in range(player.playerboard.size()):
|
||||
if not (i in HIDDEN_SLOTS) and player.playerboard[i] == -1:
|
||||
return false
|
||||
return true
|
||||
|
||||
# Slot selection management
|
||||
func select_playerboard_slot(slot_index: int):
|
||||
|
||||
Reference in New Issue
Block a user