first lobby draft made, you can move a charcter around
This commit is contained in:
@@ -7,9 +7,11 @@ extends Resource
|
||||
@export var strength: float
|
||||
|
||||
|
||||
@warning_ignore("unused_parameter")
|
||||
func attach_to_tower(tower_stats: CardText) -> void:
|
||||
pass
|
||||
|
||||
|
||||
@warning_ignore("unused_parameter")
|
||||
func attach_to_weapon(weapon_stats: CardText) -> void:
|
||||
pass
|
||||
|
||||
@@ -278,6 +278,8 @@ func end_wave() -> void:
|
||||
Data.save_data.check_high_score(level_config.display_title, wave, starting_endless)
|
||||
for peer_id: int in connected_players_nodes:
|
||||
var player: Hero = connected_players_nodes[peer_id] as Hero
|
||||
if player.hud.enemy_count < 0:
|
||||
print(level_config.waves[wave - 2])
|
||||
player.hud.set_wave_count(wave)
|
||||
player.currency += ceili(pot / connected_players_nodes.size())
|
||||
player.currency += level_config.waves[wave - 2].bonus_cash
|
||||
|
||||
@@ -12,11 +12,13 @@ var loadout_editor: CharacterSelect = null
|
||||
var connected_players_profiles: Dictionary = {}
|
||||
var enet_peer: ENetMultiplayerPeer = ENetMultiplayerPeer.new()
|
||||
|
||||
|
||||
func setup_the_ui() -> void:
|
||||
chatbox = chatbox_scene.instantiate()
|
||||
game_manager.UILayer.add_child(chatbox)
|
||||
chatbox.set_visible(true)
|
||||
chatbox.game_manager = game_manager
|
||||
game_manager.chatbox = chatbox
|
||||
chatbox.anchor_bottom = 0.98
|
||||
chatbox.anchor_left = 0.02
|
||||
chatbox.anchor_top = 0.7
|
||||
|
||||
@@ -7,6 +7,9 @@ signal disconnected_from_server
|
||||
|
||||
@export var server_form: ServerForm
|
||||
|
||||
var player_ready_boxes: Dictionary[PlayerProfile, CheckBox]
|
||||
var player_character_selected_states: Dictionary[PlayerProfile, bool]
|
||||
|
||||
var alert_popup_scene: PackedScene = preload("res://Scenes/Menus/alert_popup.tscn")
|
||||
|
||||
|
||||
@@ -30,7 +33,10 @@ func _on_player_disconnected(peer_id: int) -> void:
|
||||
|
||||
|
||||
func _on_connection_succeeded() -> void:
|
||||
setup_game(multiplayer.get_unique_id())
|
||||
#setup_game(multiplayer.get_unique_id())
|
||||
connected_players_profiles[multiplayer.get_unique_id()] = Data.player_profile
|
||||
add_player_entry(Data.player_profile)
|
||||
$PanelContainer.visible = true
|
||||
|
||||
|
||||
func _on_connection_failed() -> void:
|
||||
@@ -48,22 +54,21 @@ func _on_server_disconnected() -> void:
|
||||
func create_server() -> void:
|
||||
enet_peer.create_server(server_form.port, server_form.max_players)
|
||||
multiplayer.multiplayer_peer = enet_peer
|
||||
setup_game(1)
|
||||
add_player_entry(Data.player_profile)
|
||||
connected_players_profiles[1] = Data.player_profile
|
||||
$PanelContainer.visible = true
|
||||
#setup_game(1)
|
||||
|
||||
|
||||
func setup_game(peer_id: int) -> void:
|
||||
func setup_game() -> void:
|
||||
loadout_editor = character_select_screen.instantiate() as CharacterSelect
|
||||
add_child(loadout_editor)
|
||||
player_disconnected.connect(game_manager.remove_player)
|
||||
#scoreboard.all_players_ready.connect(start_game)
|
||||
game_manager.chatbox = chatbox
|
||||
loadout_editor.hero_confirmed.connect(select_class)
|
||||
chatbox.username = Data.player_profile.display_name
|
||||
Data.player_profile.display_name_changed.connect(chatbox.change_username)
|
||||
loadout_editor.hero_selected.connect(Data.player_profile.set_preferred_class)
|
||||
loadout_editor.hero_selected.connect(edit_player_profile)
|
||||
connected_players_profiles[peer_id] = Data.player_profile
|
||||
player_connected.emit(peer_id, Data.player_profile)
|
||||
setup_the_ui()
|
||||
#loadout_editor.hero_selected.connect(Data.player_profile.set_preferred_class)
|
||||
#loadout_editor.hero_selected.connect(edit_player_profile)
|
||||
#player_connected.emit(peer_id, Data.player_profile)
|
||||
|
||||
|
||||
func connect_to_server() -> void:
|
||||
@@ -71,17 +76,70 @@ func connect_to_server() -> void:
|
||||
multiplayer.multiplayer_peer = enet_peer
|
||||
|
||||
|
||||
func ready_player() -> void:
|
||||
pass
|
||||
#var peer_id: int = multiplayer.get_unique_id()
|
||||
#networked_ready_player.rpc(peer_id)
|
||||
@rpc("any_peer", "reliable")
|
||||
func networked_ready_player(peer_id: int) -> void:
|
||||
player_ready_boxes[connected_players_profiles[peer_id]].button_pressed = true
|
||||
var start_game: bool = true
|
||||
for box: CheckBox in player_ready_boxes.values():
|
||||
if !box.button_pressed:
|
||||
start_game = false
|
||||
if start_game:
|
||||
setup_game()
|
||||
|
||||
|
||||
func ready_player(peer_id: int = multiplayer.get_unique_id()) -> void:
|
||||
networked_ready_player.rpc(peer_id)
|
||||
$PanelContainer/VBoxContainer/ReadyButton.visible = false
|
||||
player_ready_boxes[connected_players_profiles[peer_id]].button_pressed = true
|
||||
var start_game: bool = true
|
||||
for box: CheckBox in player_ready_boxes.values():
|
||||
if !box.button_pressed:
|
||||
start_game = false
|
||||
if start_game:
|
||||
setup_game()
|
||||
|
||||
|
||||
@rpc("any_peer", "reliable")
|
||||
func networked_select_class(peer_id: int) -> void:
|
||||
player_character_selected_states[connected_players_profiles[peer_id]] = true
|
||||
var start_game: bool = true
|
||||
for state: bool in player_character_selected_states.values():
|
||||
if !state:
|
||||
start_game = false
|
||||
if start_game:
|
||||
start_game()
|
||||
|
||||
|
||||
func select_class(peer_id: int = multiplayer.get_unique_id()) -> void:
|
||||
networked_select_class.rpc(peer_id)
|
||||
player_character_selected_states[connected_players_profiles[peer_id]] = true
|
||||
var start_game: bool = true
|
||||
for state: bool in player_character_selected_states.values():
|
||||
if !state:
|
||||
start_game = false
|
||||
if start_game:
|
||||
start_game()
|
||||
|
||||
|
||||
func start_game() -> void:
|
||||
enet_peer.refuse_new_connections = true
|
||||
visible = false
|
||||
super.start_game()
|
||||
|
||||
|
||||
func add_player_entry(profile: PlayerProfile) -> void:
|
||||
print("added player: " + str(profile.display_name))
|
||||
var entry: HBoxContainer = HBoxContainer.new()
|
||||
var label: Label = Label.new()
|
||||
var check: CheckBox = CheckBox.new()
|
||||
check.mouse_filter = Control.MOUSE_FILTER_IGNORE
|
||||
label.text = profile.display_name
|
||||
entry.add_child(label)
|
||||
entry.add_child(check)
|
||||
$PanelContainer/VBoxContainer.add_child(entry)
|
||||
player_ready_boxes[profile] = check
|
||||
|
||||
|
||||
#TODO: what the fuck is this doing lol
|
||||
func edit_player_profile(_argument: int) -> void:
|
||||
var profile_dict: Dictionary = Data.player_profile.to_dict()
|
||||
@@ -102,8 +160,4 @@ func add_player(new_player_profile_dict: Dictionary) -> void:
|
||||
chatbox.append_message("SERVER", Color.TOMATO, new_player_profile.display_name + " has connected!")
|
||||
connected_players_profiles[new_player_peer_id] = new_player_profile
|
||||
player_connected.emit(new_player_peer_id, new_player_profile)
|
||||
|
||||
|
||||
#@rpc("any_peer", "reliable", "call_local")
|
||||
#func networked_ready_player(peer_id: int) -> void:
|
||||
#scoreboard.set_player_ready_state(peer_id, true)
|
||||
add_player_entry(new_player_profile)
|
||||
|
||||
@@ -1,47 +0,0 @@
|
||||
class_name Scoreboard
|
||||
extends PanelContainer
|
||||
|
||||
signal all_players_ready()
|
||||
|
||||
var entry_scene: PackedScene = preload("res://UI/scoreboard_entry.tscn")
|
||||
var entries: Dictionary = {}
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
$VBoxContainer/DummyEntry1.queue_free()
|
||||
$VBoxContainer/DummyEntry2.queue_free()
|
||||
$VBoxContainer/DummyEntry3.queue_free()
|
||||
|
||||
|
||||
func get_player_entry(peer_id: int) -> ScoreboardEntry:
|
||||
return entries[peer_id]
|
||||
|
||||
|
||||
func set_player_ready_state(peer_id: int, state: bool) -> void:
|
||||
entries[peer_id].set_ready_state(state)
|
||||
for id: int in entries:
|
||||
if !entries[id].get_ready_state():
|
||||
return
|
||||
all_players_ready.emit()
|
||||
unready_all_players()
|
||||
|
||||
|
||||
func unready_all_players() -> void:
|
||||
for peer_id: int in entries:
|
||||
entries[peer_id].set_ready_state(false)
|
||||
|
||||
|
||||
func add_player(peer_id: int, player_profile: PlayerProfile) -> void:
|
||||
var entry: ScoreboardEntry = entry_scene.instantiate() as ScoreboardEntry
|
||||
entry.name = str(peer_id)
|
||||
entry.set_display_name("", player_profile.get_display_name())
|
||||
entry.set_character(0, player_profile.get_preferred_class())
|
||||
player_profile.display_name_changed.connect(entry.set_display_name)
|
||||
player_profile.preferred_class_changed.connect(entry.set_character)
|
||||
entries[peer_id] = entry
|
||||
$VBoxContainer.add_child(entry)
|
||||
|
||||
|
||||
func remove_player(peer_id: int) -> void:
|
||||
entries[peer_id].queue_free()
|
||||
entries.erase(peer_id)
|
||||
@@ -1 +0,0 @@
|
||||
uid://k0jvsnqw4766
|
||||
@@ -1,28 +0,0 @@
|
||||
class_name ScoreboardEntry
|
||||
extends HBoxContainer
|
||||
|
||||
var display_name: String
|
||||
var character: int
|
||||
var ready_state: bool
|
||||
|
||||
|
||||
func set_display_name(_old_name: String, new_name: String) -> void:
|
||||
display_name = new_name
|
||||
$DisplayName.text = new_name
|
||||
func get_display_name() -> String:
|
||||
return display_name
|
||||
|
||||
func set_character(_old_class: int, new_class: int) -> void:
|
||||
character = new_class
|
||||
$CharacterName.text = Data.characters[new_class].hero_name
|
||||
func get_character() -> int:
|
||||
return character
|
||||
|
||||
func set_ready_state(state: bool) -> void:
|
||||
ready_state = state
|
||||
if state:
|
||||
$TextureRect.texture.region = Rect2(32, 0, 32, 32)
|
||||
else:
|
||||
$TextureRect.texture.region = Rect2(0, 0, 32, 32)
|
||||
func get_ready_state() -> bool:
|
||||
return ready_state
|
||||
@@ -1 +0,0 @@
|
||||
uid://bmcym1lkp0j8f
|
||||
@@ -12,7 +12,6 @@ func setup_game() -> void:
|
||||
loadout_editor = character_select_screen.instantiate() as CharacterSelect
|
||||
loadout_editor.hero_confirmed.connect(start_game)
|
||||
add_child(loadout_editor)
|
||||
game_manager.chatbox = chatbox
|
||||
chatbox.username = Data.player_profile.display_name
|
||||
Data.player_profile.display_name_changed.connect(chatbox.change_username)
|
||||
loadout_editor.hero_selected.connect(Data.player_profile.set_preferred_class)
|
||||
|
||||
Reference in New Issue
Block a user