2020-03-01 23:18:15 +00:00
|
|
|
extends Spatial
|
|
|
|
|
|
|
|
|
|
|
|
var players = {} # keys are String, values are Players
|
|
|
|
const Player = preload("res://Scenes/Player.tscn")
|
2021-05-14 10:26:04 +00:00
|
|
|
var winner_name = null # String or null
|
2020-03-01 23:18:15 +00:00
|
|
|
|
|
|
|
remote func place_player(player_id : int, position : Vector3, rotation : Vector3) -> void:
|
|
|
|
get_parent().console_print('Placing player with id: ' + String(player_id))
|
|
|
|
var player = Player.instance()
|
2020-08-16 12:10:31 +00:00
|
|
|
player.set_name('player' + String(player_id))
|
2020-03-01 23:18:15 +00:00
|
|
|
add_child(player)
|
2020-08-16 12:10:31 +00:00
|
|
|
player.set_translation(position)
|
|
|
|
player.set_rotation(rotation)
|
|
|
|
get_parent().console_print('Player Coords: ' + String(player.translation) + String(player.rotation))
|
2020-03-01 23:18:15 +00:00
|
|
|
players[player_id] = player
|
2020-04-18 17:26:09 +00:00
|
|
|
if player_id == get_tree().get_network_unique_id():
|
|
|
|
player.is_local = true
|
|
|
|
get_parent().console_print('Setting player with id (' + String(player_id) + ') as local')
|
2020-09-27 15:08:20 +00:00
|
|
|
player.init(player_id, get_parent().color_dict[player_id])
|
|
|
|
$Camera.register_player(player)
|
2021-05-14 10:26:04 +00:00
|
|
|
$WinnerPanel.visible = false
|
2020-03-01 23:18:15 +00:00
|
|
|
|
|
|
|
func init():
|
|
|
|
get_parent().arena_ready()
|
2020-08-16 12:10:31 +00:00
|
|
|
|
|
|
|
func play_full_plans():
|
|
|
|
for player in players.values():
|
|
|
|
player.play_full_plan()
|
2020-09-27 15:08:20 +00:00
|
|
|
|
|
|
|
func mouse_enter(player_obj : RigidBody):
|
|
|
|
players[get_tree().get_network_unique_id()].display_data(player_obj)
|
|
|
|
|
|
|
|
func mouse_exit(player_obj : RigidBody):
|
|
|
|
players[get_tree().get_network_unique_id()].clear_info_panel()
|
|
|
|
|
2021-05-14 10:26:04 +00:00
|
|
|
remote func declare_winner(name : String) -> void:
|
|
|
|
winner_name = "Victor: " + name
|
|
|
|
$WinnerPanel/WinnerLabel.text = winner_name
|
|
|
|
|
|
|
|
|
|
|
|
func show_winner() -> void:
|
|
|
|
if winner_name != null:
|
|
|
|
$WinnerPanel.visible = true
|
|
|
|
|
|
|
|
|
|
|
|
func _on_RematchButton_pressed():
|
|
|
|
$WinnerPanel/RematchButton.disabled = true
|
|
|
|
$Camera.clear_register()
|
|
|
|
for player_id in players.keys():
|
|
|
|
players[player_id].queue_free()
|
|
|
|
players.clear()
|
|
|
|
winner_name = null
|
|
|
|
rpc_id(1, "request_rematch", get_tree().get_network_unique_id())
|
|
|
|
|
|
|
|
|
|
|
|
func _on_ExitButton_pressed():
|
|
|
|
get_parent().exit_button_pressed()
|
|
|
|
|
|
|
|
|
|
|
|
|