feat: Implement initial main scene with player input management and touch controls, including new graphics assets.
This commit is contained in:
@@ -131,14 +131,19 @@ func handle_unhandled_input(event):
|
||||
player.powerup_manager.use_special_effect()
|
||||
KEY_G:
|
||||
if player.is_carrying_tekton:
|
||||
player.throw_tekton()
|
||||
if player.powerup_manager and player.powerup_manager.can_use_special():
|
||||
player.throw_tekton()
|
||||
player.powerup_manager.reset_boost()
|
||||
else:
|
||||
player.grab_tekton()
|
||||
KEY_B:
|
||||
if player.has_method("enter_knock_mode"):
|
||||
player.enter_knock_mode()
|
||||
else:
|
||||
player.knock_tekton()
|
||||
if player.powerup_manager and player.powerup_manager.can_use_special():
|
||||
if player.has_method("enter_knock_mode"):
|
||||
player.enter_knock_mode()
|
||||
player.powerup_manager.reset_boost()
|
||||
else:
|
||||
player.knock_tekton()
|
||||
player.powerup_manager.reset_boost()
|
||||
|
||||
# Handle spawn point selection if not yet selected
|
||||
|
||||
|
||||
@@ -14,6 +14,8 @@ var put_button: Button
|
||||
var attack_mode_button: Button # Renamed from special_button
|
||||
var spawn_boost_button: Button
|
||||
var settings_button: Button
|
||||
var tekton_knock_button: Button
|
||||
var tekton_throw_button: Button
|
||||
|
||||
# Settings - persisted to config file
|
||||
const CONFIG_PATH = "user://touch_controls_settings.cfg"
|
||||
@@ -131,10 +133,15 @@ func _create_touch_ui():
|
||||
grab_button = _find_or_create_action_button(actions_container, "Grab", "👋", button_positions.grab)
|
||||
put_button = _find_or_create_action_button(actions_container, "Put", "📦", button_positions.put)
|
||||
|
||||
tekton_knock_button = _find_or_create_action_button(actions_container, "TektonKnock", "👊", Vector2(-280, -160))
|
||||
tekton_throw_button = _find_or_create_action_button(actions_container, "TektonThrow", "🎯", Vector2(-280, -80))
|
||||
|
||||
# Order: AttackMode, SpawnBoost, Grab
|
||||
if attack_mode_button: actions_container.move_child(attack_mode_button, 0)
|
||||
if spawn_boost_button: actions_container.move_child(spawn_boost_button, 1)
|
||||
if grab_button: actions_container.move_child(grab_button, 2)
|
||||
if tekton_knock_button: actions_container.move_child(tekton_knock_button, 3)
|
||||
if tekton_throw_button: actions_container.move_child(tekton_throw_button, 4)
|
||||
|
||||
# Hide Put Button
|
||||
if put_button:
|
||||
@@ -252,15 +259,24 @@ func _ensure_shortcut_label(btn: Button, button_name: String):
|
||||
"Put": existing_lbl.text = ""
|
||||
"AttackMode": existing_lbl.text = "Q" if is_sng else ""
|
||||
"SpawnBoost": existing_lbl.text = "E" if is_sng else ""
|
||||
"TektonKnock": existing_lbl.text = "B"
|
||||
"TektonThrow": existing_lbl.text = "G"
|
||||
|
||||
# Ensure correct placement (Top Right)
|
||||
existing_lbl.horizontal_alignment = HORIZONTAL_ALIGNMENT_RIGHT
|
||||
existing_lbl.vertical_alignment = VERTICAL_ALIGNMENT_TOP
|
||||
existing_lbl.offset_top = -5 # Closer to top
|
||||
existing_lbl.offset_right = 0 # Aligned with right edge
|
||||
return
|
||||
|
||||
# Add Keyboard Shortcut Label
|
||||
var shortcut_lbl = Label.new()
|
||||
shortcut_lbl.name = "ShortcutLabel"
|
||||
shortcut_lbl.set_anchors_preset(Control.PRESET_FULL_RECT)
|
||||
shortcut_lbl.horizontal_alignment = HORIZONTAL_ALIGNMENT_CENTER
|
||||
shortcut_lbl.vertical_alignment = VERTICAL_ALIGNMENT_BOTTOM
|
||||
shortcut_lbl.offset_bottom = 20 # Below button
|
||||
shortcut_lbl.horizontal_alignment = HORIZONTAL_ALIGNMENT_RIGHT
|
||||
shortcut_lbl.vertical_alignment = VERTICAL_ALIGNMENT_TOP
|
||||
shortcut_lbl.offset_top = -5 # Closer to top
|
||||
shortcut_lbl.offset_right = 0 # Aligned with right edge
|
||||
shortcut_lbl.add_theme_font_size_override("font_size", 16)
|
||||
shortcut_lbl.add_theme_color_override("font_outline_color", Color.BLACK)
|
||||
shortcut_lbl.add_theme_constant_override("outline_size", 4)
|
||||
@@ -270,6 +286,8 @@ func _ensure_shortcut_label(btn: Button, button_name: String):
|
||||
"Put": shortcut_lbl.text = "" # Disabled shortcut
|
||||
"AttackMode": shortcut_lbl.text = "Q"
|
||||
"SpawnBoost": shortcut_lbl.text = "E"
|
||||
"TektonKnock": shortcut_lbl.text = "B"
|
||||
"TektonThrow": shortcut_lbl.text = "G"
|
||||
|
||||
btn.add_child(shortcut_lbl)
|
||||
|
||||
@@ -289,6 +307,8 @@ func _on_button_pressed(button_name: String):
|
||||
"Put": btn = put_button
|
||||
"AttackMode": btn = attack_mode_button
|
||||
"SpawnBoost": btn = spawn_boost_button
|
||||
"TektonKnock": btn = tekton_knock_button
|
||||
"TektonThrow": btn = tekton_throw_button
|
||||
|
||||
if btn:
|
||||
var tween = create_tween()
|
||||
@@ -305,11 +325,9 @@ func _on_button_pressed(button_name: String):
|
||||
if local_player.has_method("auto_put_item"):
|
||||
local_player.auto_put_item()
|
||||
"AttackMode":
|
||||
emit_signal("attack_mode_pressed") # Also special?
|
||||
# emit_signal("special_pressed") # Keep legacy signal?
|
||||
emit_signal("attack_mode_pressed")
|
||||
var powerup_mgr = local_player.get_node_or_null("PowerUpManager")
|
||||
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] AttackMode Pressed. Boost: %s, CanUse: %s" % [boost_val, can_use])
|
||||
@@ -317,24 +335,30 @@ func _on_button_pressed(button_name: String):
|
||||
if can_use:
|
||||
powerup_mgr.use_special_effect() # Sets is_attack_mode=true
|
||||
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
|
||||
# Same usage logic, but specific action
|
||||
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
|
||||
else:
|
||||
print("[TouchControls] PowerUpManager missing on player")
|
||||
if powerup_mgr and powerup_mgr.can_use_special():
|
||||
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()
|
||||
"TektonKnock":
|
||||
var powerup_mgr = local_player.get_node_or_null("PowerUpManager")
|
||||
if powerup_mgr and powerup_mgr.can_use_special():
|
||||
if local_player.has_method("enter_knock_mode"):
|
||||
local_player.enter_knock_mode()
|
||||
powerup_mgr.reset_boost()
|
||||
elif local_player.has_method("knock_tekton"):
|
||||
local_player.knock_tekton()
|
||||
powerup_mgr.reset_boost()
|
||||
"TektonThrow":
|
||||
var powerup_mgr = local_player.get_node_or_null("PowerUpManager")
|
||||
if powerup_mgr and powerup_mgr.can_use_special():
|
||||
if local_player.has_method("throw_tekton"):
|
||||
local_player.throw_tekton()
|
||||
powerup_mgr.reset_boost()
|
||||
|
||||
func _on_button_released(button_name: String):
|
||||
var btn: Button
|
||||
@@ -343,6 +367,8 @@ func _on_button_released(button_name: String):
|
||||
"Put": btn = put_button
|
||||
"AttackMode": btn = attack_mode_button
|
||||
"SpawnBoost": btn = spawn_boost_button
|
||||
"TektonKnock": btn = tekton_knock_button
|
||||
"TektonThrow": btn = tekton_throw_button
|
||||
|
||||
if btn:
|
||||
var tween = create_tween()
|
||||
@@ -512,6 +538,8 @@ func _on_boost_points_changed(current_points: int, max_points: int):
|
||||
|
||||
_update_boost_button_state(attack_mode_button, is_full)
|
||||
_update_boost_button_state(spawn_boost_button, is_full)
|
||||
_update_boost_button_state(tekton_knock_button, is_full)
|
||||
_update_boost_button_state(tekton_throw_button, is_full)
|
||||
|
||||
func _update_boost_button_state(btn: Button, is_enabled: bool):
|
||||
if not btn: return
|
||||
|
||||
Reference in New Issue
Block a user