A team game with an emphasis on movement (with no shooting), inspired by Overwatch and Zineth
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

58 lines
1.6 KiB

[WIP] Split up lobby -> menu, lobby, custom_game lobby.gd had gotten big, bloated, ugly, and hard to read. It needed a refactor. The first thing I did is split up the *GUI* into the logical steps it should be. So the new flow is: - Start the game - Click "Quick Play" - Matchmaking begins on my dedicated server - Start the game - Click "Custom Game" - *Only now* am I presented with server / client options - Start the game - Click "Singleplayer" - Singleplayer NOW, and only now, and NO MATTER WHAT PATH I TAKE, I am taken to the *lobby*, which now is where I: - Choose my name - Choose hero - See list of players - Get my team assigned - Anything else that I might like to put in The point here is that this has *nothing* to do with handshaking / matchmaking / etc! This is just part of the game! At this point I have *already been connected* to the server. I've already been aquainted with my other players. The game has begun. I put the things that don't belong in any of these flows in networking.gd, a sort of model-view sorta thing. All of these flows use some sort of networking thing like `init_server` that tbh should be *completely* abstracted from the UI. It's totally a WIP!!! Above is the IDEA, but below is what I've actually *done*: - Made the scenes, made a passable UI for each one that at least indicates ~what they'll do - Made the corresponding scripts, and split up the lobby script into ABOUT where I think it'll end up, but no promises It still errors all over the place, and it's nowhere near properly organized. PLUS, I'd also like to rewrite a lot of the code / rename things as part of the initial refactor goal of making me able to actually think about networking.
7 years ago
  1. extends Control
  2. var port = null # Defined by command-line argument with default
  3. onready var hero_select = get_node("HeroSelect/Hero")
  4. func _ready():
  5. if get_tree().is_network_server():
  6. get_node("LevelSelect").show()
  7. get_node("Username").connect("text_changed", self, "_send_name")
  8. get_node("StartGame").connect("pressed", self, "_start_game")
  9. var spectating = util.args.get_value("-silent")
  10. get_node("Spectating").pressed = spectating
  11. #
  12. get_node("Spectating").connect("toggled", networking, "set_spectating") # TODO
  13. # get_node("CustomGame/LevelSelect").connect("item_selected", self, "select_level") TODO
  14. # _send_name()
  15. # hero_select.set_hero(0)
  16. networking.connect("info_updated", self, "render_player_list")
  17. get_tree().connect("connected_to_server", self, "_send_settings")
  18. if get_tree().is_network_server():
  19. _send_settings()
  20. func _send_settings():
  21. print("sending")
  22. _send_name()
  23. hero_select.random_hero()
  24. sync func set_hero(peer, hero):
  25. networking.players[peer].hero = hero
  26. render_player_list()
  27. func _send_name():
  28. var name = get_node("Username").text
  29. networking.set_info("username", name)
  30. func render_player_list():
  31. print(JSON.print(networking.players))
  32. var list = ""
  33. var hero_names = hero_select.hero_names
  34. for p in networking.players:
  35. list += "%-15s" % networking.players[p].username
  36. list += "%-20s" % hero_names[networking.players[p].hero]
  37. if networking.players[p].is_right_team:
  38. list += "Right Team"
  39. else:
  40. list += "Left Team"
  41. list += "\n"
  42. get_node("PlayerList").set_text(list)
  43. func _start_game():
  44. _collect_info()
  45. var level = 2 # TODO
  46. networking.rpc_id(1, "start_game", level)