feat: Establish initial game structure including lobby, UI, and core gameplay managers.

This commit is contained in:
Yogi Wiguna
2026-02-02 15:01:30 +08:00
parent 9201c99d42
commit 66d34d0d29
21 changed files with 1688 additions and 1475 deletions
+49 -4
View File
@@ -11,6 +11,7 @@ var virtual_joystick: Control
var grab_button: Button
var put_button: Button
var special_button: Button
var spawn_boost_button: Button
var settings_button: Button
# Settings - persisted to config file
@@ -23,7 +24,8 @@ var joystick_position: Vector2 = Vector2(120, -120) # Relative to bottom-left
var button_positions: Dictionary = {
"grab": Vector2(-200, -240), # Relative to bottom-right
"put": Vector2(-120, -160),
"special": Vector2(-200, -80)
"special": Vector2(-200, -80),
"spawn_boost": Vector2(-120, -80)
}
var button_scale: float = 1.0
@@ -93,6 +95,7 @@ func _create_touch_ui():
grab_button = _find_or_create_action_button(container, "Grab", "👋", button_positions.grab)
put_button = _find_or_create_action_button(container, "Put", "📦", button_positions.put)
special_button = _find_or_create_action_button(container, "Special", "", button_positions.special)
spawn_boost_button = _find_or_create_action_button(container, "SpawnBoost", "🚀", button_positions.spawn_boost)
# Create settings button (top-right corner)
settings_button = container.get_node_or_null("SettingsBtn")
@@ -203,6 +206,7 @@ func _on_button_pressed(button_name: String):
"Grab": btn = grab_button
"Put": btn = put_button
"Special": btn = special_button
"SpawnBoost": btn = spawn_boost_button
if btn:
var tween = create_tween()
@@ -221,8 +225,32 @@ func _on_button_pressed(button_name: String):
"Special":
emit_signal("special_pressed")
var powerup_mgr = local_player.get_node_or_null("PowerUpManager")
if powerup_mgr and powerup_mgr.has_method("use_special_effect"):
powerup_mgr.use_special_effect()
if powerup_mgr:
# Require Full Boost to Activate (User Request: "Connect to boost bar")
var can_use = powerup_mgr.can_use_special()
var boost_val = powerup_mgr.current_boost
print("[TouchControls] Special Pressed. Boost: %s, CanUse: %s" % [boost_val, can_use])
if can_use:
powerup_mgr.use_special_effect() # Sets is_attack_mode=true, Does NOT consume boost yet
else:
# Optional feedback for not ready?
pass
else:
print("[TouchControls] PowerUpManager missing on player")
"SpawnBoost":
var powerup_mgr = local_player.get_node_or_null("PowerUpManager")
if powerup_mgr:
var can_use = powerup_mgr.can_use_special()
var boost_val = powerup_mgr.current_boost
print("[TouchControls] SpawnBoost Pressed. Boost: %s, CanUse: %s" % [boost_val, can_use])
if can_use: # Check if boost is full
if local_player.special_tiles_manager and local_player.special_tiles_manager.has_method("spawn_powerups_around"):
local_player.special_tiles_manager.spawn_powerups_around(local_player.current_position)
powerup_mgr.reset_boost() # Consume the boost manually since we bypassed use_special_effect
else:
print("[TouchControls] PowerUpManager missing on player")
func _on_button_released(button_name: String):
var btn: Button
@@ -230,6 +258,7 @@ func _on_button_released(button_name: String):
"Grab": btn = grab_button
"Put": btn = put_button
"Special": btn = special_button
"SpawnBoost": btn = spawn_boost_button
if btn:
var tween = create_tween()
@@ -268,7 +297,8 @@ func _load_settings():
var grab_pos = config.get_value("touch_controls", "grab_position", Vector2(-200, -240))
var put_pos = config.get_value("touch_controls", "put_position", Vector2(-120, -160))
var special_pos = config.get_value("touch_controls", "special_position", Vector2(-200, -80))
button_positions = {"grab": grab_pos, "put": put_pos, "special": special_pos}
var spawn_boost_pos = config.get_value("touch_controls", "spawn_boost_position", Vector2(-120, -80))
button_positions = {"grab": grab_pos, "put": put_pos, "special": special_pos, "spawn_boost": spawn_boost_pos}
# Apply loaded settings
_apply_settings()
@@ -286,6 +316,7 @@ func _save_settings():
config.set_value("touch_controls", "grab_position", button_positions.grab)
config.set_value("touch_controls", "put_position", button_positions.put)
config.set_value("touch_controls", "special_position", button_positions.special)
config.set_value("touch_controls", "spawn_boost_position", button_positions.spawn_boost)
var err = config.save(CONFIG_PATH)
if err != OK:
@@ -331,6 +362,14 @@ func _apply_settings():
special_button.offset_right = button_positions.special.x + button_size
special_button.offset_bottom = button_positions.special.y + button_size
if spawn_boost_button:
spawn_boost_button.visible = buttons_visible
spawn_boost_button.scale = Vector2(button_scale, button_scale)
spawn_boost_button.offset_left = button_positions.spawn_boost.x
spawn_boost_button.offset_top = button_positions.spawn_boost.y
spawn_boost_button.offset_right = button_positions.spawn_boost.x + button_size
spawn_boost_button.offset_bottom = button_positions.spawn_boost.y + button_size
# Force layer update
visible = true
@@ -375,6 +414,12 @@ func set_button_position(button_name: String, new_position: Vector2):
special_button.offset_top = new_position.y
special_button.offset_right = new_position.x + button_size
special_button.offset_bottom = new_position.y + button_size
"spawn_boost":
if spawn_boost_button:
spawn_boost_button.offset_left = new_position.x
spawn_boost_button.offset_top = new_position.y
spawn_boost_button.offset_right = new_position.x + button_size
spawn_boost_button.offset_bottom = new_position.y + button_size
func get_button_positions() -> Dictionary:
"""Get current button positions for settings UI."""