Add ready lobby and reconnect support
This commit is contained in:
1 parent
19b1a67773
commit
32594c7f81
8 files changed
+215
-36
No files matched your search
@@ -137,6 +137,7 @@ var friend_match_button := Rect2(475, 665, 300, 64)
|
||||
var private_match_button := Rect2(825, 665, 300, 64)
|
||||
var ai_match_button := Rect2(1175, 665, 300, 64)
|
||||
var cancel_search_button := Rect2(625, 650, 350, 64)
|
||||
var lobby_ready_button := Rect2(625, 580, 350, 58)
|
||||
var room_code_input_rect := Rect2(510, 340, 580, 90)
|
||||
var join_room_button := Rect2(625, 525, 350, 64)
|
||||
var coop_side_button := Rect2(920, 18, 140, 54)
|
||||
@@ -444,7 +445,9 @@ func _handle_pointer(position: Vector2, is_touch := false) -> void:
|
||||
queue_redraw()
|
||||
return
|
||||
if game_mode == "matchmaking":
|
||||
if cancel_search_button.has_point(position) or multiplayer_back_button.has_point(position):
|
||||
if lobby_ready_button.has_point(position) and multiplayer_manager.matchmaking_state in ["hosting", "matched", "lobby", "reconnected"]:
|
||||
multiplayer_manager.toggle_lobby_ready()
|
||||
elif cancel_search_button.has_point(position) or multiplayer_back_button.has_point(position):
|
||||
multiplayer_manager.cancel_search()
|
||||
game_mode = "multiplayer_menu"
|
||||
queue_redraw()
|
||||
@@ -1068,6 +1071,8 @@ func _apply_online_snapshot(snapshot: Dictionary) -> void:
|
||||
if not coop_online_mode or snapshot.is_empty():
|
||||
return
|
||||
selected_difficulty = clampi(int(snapshot.get("difficulty", selected_difficulty)), 0, DIFFICULTY_DATA.size() - 1)
|
||||
if bool(snapshot.get("connection_interrupted", false)):
|
||||
_show_status("MITPILOT GETRENNT • WIEDERBEITRITT %d S" % int(snapshot.get("reconnect_seconds", 0)))
|
||||
reactor_lives = int(snapshot.get("reactor_lives", reactor_lives))
|
||||
wave = int(snapshot.get("wave", wave))
|
||||
wave_active = bool(snapshot.get("wave_active", false))
|
||||
@@ -1467,7 +1472,7 @@ func _draw_menu() -> void:
|
||||
_draw_button(start_button, "MISSION STARTEN", false, Color("18556f"))
|
||||
_draw_button(multiplayer_button, "MULTIPLAYER", false, Color("254f75"))
|
||||
draw_string(font, Vector2(0, 792), "BESTE WELLE %02d • KERNKRISTALLE %04d • KARTENBONUS %d" % [best_wave, core_crystals, int(_difficulty().crystals)], HORIZONTAL_ALIGNMENT_CENTER, 1600, 17, Color("86c8d8"))
|
||||
draw_string(font, Vector2(0, 860), "VERSION 0.20 • GERGAMES-ONLINEKONTO • GLOBALE BESTENLISTEN", HORIZONTAL_ALIGNMENT_CENTER, 1600, 14, Color("688293"))
|
||||
draw_string(font, Vector2(0, 860), "VERSION 0.21 • GERGAMES-ONLINEKONTO • GLOBALE BESTENLISTEN", HORIZONTAL_ALIGNMENT_CENTER, 1600, 14, Color("688293"))
|
||||
|
||||
|
||||
func _draw_multiplayer_menu() -> void:
|
||||
@@ -1535,14 +1540,20 @@ func _draw_matchmaking() -> void:
|
||||
_draw_button(multiplayer_back_button, "< ZURÜCK", false, Color("26394a"))
|
||||
var private_mode: bool = multiplayer_manager.matchmaking_mode in ["private_host", "private_join"]
|
||||
draw_string(font, Vector2(0, 210), "PRIVATER KOOP-RAUM" if private_mode else "MITSPIELERSUCHE", HORIZONTAL_ALIGNMENT_CENTER, 1600, 46, Color("c7f5ff"))
|
||||
var pulse := 56.0 + sin(elapsed * 3.0) * 8.0
|
||||
draw_arc(Vector2(800, 390), pulse, -PI * 0.2, PI * 1.45, 52, Color("65eaff"), 5.0)
|
||||
draw_circle(Vector2(800, 390), 22.0, Color("8ffaff"))
|
||||
var in_lobby: bool = multiplayer_manager.player_slot >= 0 and multiplayer_manager.matchmaking_state in ["hosting", "matched", "lobby", "reconnected"]
|
||||
if in_lobby:
|
||||
_draw_online_lobby_players(font)
|
||||
else:
|
||||
var pulse := 56.0 + sin(elapsed * 3.0) * 8.0
|
||||
draw_arc(Vector2(800, 390), pulse, -PI * 0.2, PI * 1.45, 52, Color("65eaff"), 5.0)
|
||||
draw_circle(Vector2(800, 390), 22.0, Color("8ffaff"))
|
||||
var mode_labels := {"quick": "SCHNELLES SPIEL", "private_host": "RAUM ERSTELLEN", "private_join": "RAUM BEITRETEN"}
|
||||
var mode_text: String = mode_labels.get(multiplayer_manager.matchmaking_mode, "KOOP-SPIEL")
|
||||
if not multiplayer_manager.private_room_code.is_empty():
|
||||
mode_text = "RAUMCODE %s" % " ".join(multiplayer_manager.private_room_code.split(""))
|
||||
draw_string(font, Vector2(0, 500), mode_text, HORIZONTAL_ALIGNMENT_CENTER, 1600, 23, Color.WHITE)
|
||||
if in_lobby:
|
||||
_draw_button(lobby_ready_button, "NICHT BEREIT" if multiplayer_manager.local_ready else "BEREIT", multiplayer_manager.local_ready, Color("8b6330") if multiplayer_manager.local_ready else Color("185f68"))
|
||||
_draw_button(cancel_search_button, "ZURÜCK" if multiplayer_manager.matchmaking_state == "room_not_found" else "SUCHE ABBRECHEN", false, Color("5c3342"))
|
||||
var online_text := "ONLINE • SUCHE NACH EINEM MITPILOTEN"
|
||||
var online_color := Color("83ffc8")
|
||||
@@ -1553,8 +1564,17 @@ func _draw_matchmaking() -> void:
|
||||
online_text = "SERVER NOCH NICHT ERREICHBAR • BITTE SPÄTER ERNEUT VERSUCHEN"
|
||||
online_color = Color("ff8e8e")
|
||||
elif multiplayer_manager.matchmaking_state == "matched":
|
||||
online_text = "MITPILOT GEFUNDEN • KOOP-SITZUNG BEREIT"
|
||||
online_text = "MITPILOT GEFUNDEN • WÄHLE BEREIT"
|
||||
online_color = Color("8ffaff")
|
||||
elif multiplayer_manager.matchmaking_state in ["lobby", "reconnected"]:
|
||||
online_text = "BEIDE SPIELER MÜSSEN BEREIT SEIN"
|
||||
online_color = Color("8ffaff")
|
||||
elif multiplayer_manager.matchmaking_state == "reconnecting":
|
||||
online_text = "VERBINDUNG WIRD WIEDERHERGESTELLT ."
|
||||
online_color = Color("ffcf7a")
|
||||
elif multiplayer_manager.matchmaking_state == "connection_lost":
|
||||
online_text = "VERBINDUNG VERLOREN • BITTE ZURÜCKKEHREN"
|
||||
online_color = Color("ff8e8e")
|
||||
elif multiplayer_manager.matchmaking_state == "creating_room":
|
||||
online_text = "PRIVATER RAUM WIRD ERSTELLT ."
|
||||
online_color = Color("ffcf7a")
|
||||
@@ -1571,6 +1591,24 @@ func _draw_matchmaking() -> void:
|
||||
draw_string(font, Vector2(0, 548), online_text, HORIZONTAL_ALIGNMENT_CENTER, 1600, 16, online_color)
|
||||
|
||||
|
||||
func _draw_online_lobby_players(font: Font) -> void:
|
||||
for slot in 2:
|
||||
var rect := Rect2(270 + slot * 560, 285, 500, 130)
|
||||
var player = multiplayer_manager.lobby_players[slot] if slot < multiplayer_manager.lobby_players.size() else null
|
||||
var occupied: bool = player is Dictionary
|
||||
var connected: bool = occupied and bool(player.get("connected", false))
|
||||
var ready: bool = occupied and bool(player.get("ready", false))
|
||||
var border := Color("5de8a8") if ready else (Color("65eaff") if connected else Color("425567"))
|
||||
draw_rect(rect, Color(0.012, 0.035, 0.065, 0.96), true)
|
||||
draw_rect(rect, border, false, 3.0)
|
||||
var name := String(player.get("name", "PILOT")) if occupied else "WARTE AUF MITPILOTEN"
|
||||
var side := "LINKE VERTEIDIGUNG" if slot == 0 else "RECHTE VERTEIDIGUNG"
|
||||
var state := "BEREIT" if ready else ("NICHT BEREIT" if connected else "NICHT VERBUNDEN")
|
||||
draw_string(font, Vector2(rect.position.x + 24, rect.position.y + 43), name.to_upper(), HORIZONTAL_ALIGNMENT_LEFT, rect.size.x - 48, 24, Color("e8fbff"))
|
||||
draw_string(font, Vector2(rect.position.x + 24, rect.position.y + 78), side, HORIZONTAL_ALIGNMENT_LEFT, rect.size.x - 48, 14, Color("8fcddd"))
|
||||
draw_string(font, Vector2(rect.position.x + 24, rect.position.y + 108), state, HORIZONTAL_ALIGNMENT_LEFT, rect.size.x - 48, 16, border)
|
||||
|
||||
|
||||
func _draw_profile() -> void:
|
||||
var font := ThemeDB.fallback_font
|
||||
draw_rect(Rect2(Vector2.ZERO, SCREEN), Color(0.005, 0.015, 0.035, 0.76))
|
||||
|
||||
Reference in new issue
Block a user