added a main menu scene/script added a network manager script added the network script to be autoloaded added an exportmaster
parent
57840ab860
commit
e9354f1d93
@ -0,0 +1,364 @@
|
||||
[gd_scene load_steps=2 format=2]
|
||||
|
||||
[ext_resource path="res://scripts/MainMenu.gd" type="Script" id=1]
|
||||
|
||||
[node name="MainMenu" type="Container" index="0"]
|
||||
|
||||
anchor_left = 0.0
|
||||
anchor_top = 0.0
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
rect_pivot_offset = Vector2( 0, 0 )
|
||||
rect_clip_content = false
|
||||
mouse_filter = 0
|
||||
mouse_default_cursor_shape = 0
|
||||
size_flags_horizontal = 1
|
||||
size_flags_vertical = 1
|
||||
script = ExtResource( 1 )
|
||||
|
||||
[node name="ConnectOptions" type="VBoxContainer" parent="." index="0"]
|
||||
|
||||
anchor_left = 0.5
|
||||
anchor_top = 0.5
|
||||
anchor_right = 0.5
|
||||
anchor_bottom = 0.5
|
||||
margin_left = -280.0
|
||||
margin_top = -221.0
|
||||
margin_right = 280.0
|
||||
margin_bottom = 221.0
|
||||
rect_pivot_offset = Vector2( 0, 0 )
|
||||
rect_clip_content = false
|
||||
mouse_filter = 1
|
||||
mouse_default_cursor_shape = 0
|
||||
size_flags_horizontal = 1
|
||||
size_flags_vertical = 1
|
||||
alignment = 0
|
||||
|
||||
[node name="Label" type="Label" parent="ConnectOptions" index="0"]
|
||||
|
||||
anchor_left = 0.0
|
||||
anchor_top = 0.0
|
||||
anchor_right = 0.0
|
||||
anchor_bottom = 0.0
|
||||
margin_right = 560.0
|
||||
margin_bottom = 14.0
|
||||
rect_pivot_offset = Vector2( 0, 0 )
|
||||
rect_clip_content = false
|
||||
mouse_filter = 2
|
||||
mouse_default_cursor_shape = 0
|
||||
size_flags_horizontal = 1
|
||||
size_flags_vertical = 4
|
||||
text = "choose your weapon"
|
||||
align = 1
|
||||
percent_visible = 1.0
|
||||
lines_skipped = 0
|
||||
max_lines_visible = -1
|
||||
|
||||
[node name="HBoxContainer" type="HBoxContainer" parent="ConnectOptions" index="1"]
|
||||
|
||||
editor/display_folded = true
|
||||
anchor_left = 0.0
|
||||
anchor_top = 0.0
|
||||
anchor_right = 0.0
|
||||
anchor_bottom = 0.0
|
||||
margin_top = 18.0
|
||||
margin_right = 560.0
|
||||
margin_bottom = 42.0
|
||||
rect_pivot_offset = Vector2( 0, 0 )
|
||||
rect_clip_content = false
|
||||
mouse_filter = 1
|
||||
mouse_default_cursor_shape = 0
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 1
|
||||
alignment = 1
|
||||
|
||||
[node name="Label" type="Label" parent="ConnectOptions/HBoxContainer" index="0"]
|
||||
|
||||
anchor_left = 0.0
|
||||
anchor_top = 0.0
|
||||
anchor_right = 0.0
|
||||
anchor_bottom = 0.0
|
||||
margin_top = 5.0
|
||||
margin_right = 17.0
|
||||
margin_bottom = 19.0
|
||||
rect_pivot_offset = Vector2( 0, 0 )
|
||||
rect_clip_content = false
|
||||
mouse_filter = 2
|
||||
mouse_default_cursor_shape = 0
|
||||
size_flags_horizontal = 1
|
||||
size_flags_vertical = 4
|
||||
text = "IP:"
|
||||
percent_visible = 1.0
|
||||
lines_skipped = 0
|
||||
max_lines_visible = -1
|
||||
|
||||
[node name="LineEdit2" type="LineEdit" parent="ConnectOptions/HBoxContainer" index="1"]
|
||||
|
||||
anchor_left = 0.0
|
||||
anchor_top = 0.0
|
||||
anchor_right = 0.0
|
||||
anchor_bottom = 0.0
|
||||
margin_left = 21.0
|
||||
margin_right = 271.0
|
||||
margin_bottom = 24.0
|
||||
rect_pivot_offset = Vector2( 0, 0 )
|
||||
rect_clip_content = false
|
||||
focus_mode = 2
|
||||
mouse_filter = 0
|
||||
mouse_default_cursor_shape = 1
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 1
|
||||
focus_mode = 2
|
||||
context_menu_enabled = true
|
||||
placeholder_text = "127.0.0.1"
|
||||
placeholder_alpha = 0.6
|
||||
caret_blink = false
|
||||
caret_blink_speed = 0.65
|
||||
caret_position = 0
|
||||
_sections_unfolded = [ "Placeholder" ]
|
||||
|
||||
[node name="Label2" type="Label" parent="ConnectOptions/HBoxContainer" index="2"]
|
||||
|
||||
anchor_left = 0.0
|
||||
anchor_top = 0.0
|
||||
anchor_right = 0.0
|
||||
anchor_bottom = 0.0
|
||||
margin_left = 275.0
|
||||
margin_top = 5.0
|
||||
margin_right = 305.0
|
||||
margin_bottom = 19.0
|
||||
rect_pivot_offset = Vector2( 0, 0 )
|
||||
rect_clip_content = false
|
||||
mouse_filter = 2
|
||||
mouse_default_cursor_shape = 0
|
||||
size_flags_horizontal = 1
|
||||
size_flags_vertical = 4
|
||||
text = "Port:"
|
||||
percent_visible = 1.0
|
||||
lines_skipped = 0
|
||||
max_lines_visible = -1
|
||||
|
||||
[node name="LineEdit" type="LineEdit" parent="ConnectOptions/HBoxContainer" index="3"]
|
||||
|
||||
anchor_left = 0.0
|
||||
anchor_top = 0.0
|
||||
anchor_right = 0.0
|
||||
anchor_bottom = 0.0
|
||||
margin_left = 309.0
|
||||
margin_right = 560.0
|
||||
margin_bottom = 24.0
|
||||
rect_pivot_offset = Vector2( 0, 0 )
|
||||
rect_clip_content = false
|
||||
focus_mode = 2
|
||||
mouse_filter = 0
|
||||
mouse_default_cursor_shape = 1
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 1
|
||||
focus_mode = 2
|
||||
context_menu_enabled = true
|
||||
placeholder_text = "31400"
|
||||
placeholder_alpha = 0.6
|
||||
caret_blink = false
|
||||
caret_blink_speed = 0.65
|
||||
caret_position = 0
|
||||
_sections_unfolded = [ "Placeholder" ]
|
||||
|
||||
[node name="HBoxContainer2" type="HBoxContainer" parent="ConnectOptions" index="2"]
|
||||
|
||||
anchor_left = 0.0
|
||||
anchor_top = 0.0
|
||||
anchor_right = 0.0
|
||||
anchor_bottom = 0.0
|
||||
margin_top = 46.0
|
||||
margin_right = 560.0
|
||||
margin_bottom = 66.0
|
||||
rect_pivot_offset = Vector2( 0, 0 )
|
||||
rect_clip_content = false
|
||||
mouse_filter = 1
|
||||
mouse_default_cursor_shape = 0
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 1
|
||||
custom_constants/separation = 44
|
||||
alignment = 1
|
||||
_sections_unfolded = [ "custom_constants" ]
|
||||
|
||||
[node name="Button" type="Button" parent="ConnectOptions/HBoxContainer2" index="0"]
|
||||
|
||||
anchor_left = 0.0
|
||||
anchor_top = 0.0
|
||||
anchor_right = 0.0
|
||||
anchor_bottom = 0.0
|
||||
margin_left = 214.0
|
||||
margin_right = 249.0
|
||||
margin_bottom = 20.0
|
||||
rect_pivot_offset = Vector2( 0, 0 )
|
||||
rect_clip_content = false
|
||||
focus_mode = 2
|
||||
mouse_filter = 0
|
||||
mouse_default_cursor_shape = 0
|
||||
size_flags_horizontal = 1
|
||||
size_flags_vertical = 1
|
||||
toggle_mode = false
|
||||
enabled_focus_mode = 2
|
||||
shortcut = null
|
||||
group = null
|
||||
text = "Join"
|
||||
flat = false
|
||||
align = 1
|
||||
|
||||
[node name="Button2" type="Button" parent="ConnectOptions/HBoxContainer2" index="1"]
|
||||
|
||||
anchor_left = 0.0
|
||||
anchor_top = 0.0
|
||||
anchor_right = 0.0
|
||||
anchor_bottom = 0.0
|
||||
margin_left = 293.0
|
||||
margin_right = 346.0
|
||||
margin_bottom = 20.0
|
||||
rect_pivot_offset = Vector2( 0, 0 )
|
||||
rect_clip_content = false
|
||||
focus_mode = 2
|
||||
mouse_filter = 0
|
||||
mouse_default_cursor_shape = 0
|
||||
size_flags_horizontal = 1
|
||||
size_flags_vertical = 1
|
||||
toggle_mode = false
|
||||
enabled_focus_mode = 2
|
||||
shortcut = null
|
||||
group = null
|
||||
text = "Create"
|
||||
flat = false
|
||||
align = 1
|
||||
|
||||
[node name="PlayOptions" type="VBoxContainer" parent="." index="1"]
|
||||
|
||||
editor/display_folded = true
|
||||
anchor_left = 0.5
|
||||
anchor_top = 0.5
|
||||
anchor_right = 0.5
|
||||
anchor_bottom = 0.5
|
||||
margin_left = -280.0
|
||||
margin_top = -75.0
|
||||
margin_right = 280.0
|
||||
margin_bottom = 221.0
|
||||
rect_pivot_offset = Vector2( 0, 0 )
|
||||
rect_clip_content = false
|
||||
mouse_filter = 1
|
||||
mouse_default_cursor_shape = 0
|
||||
size_flags_horizontal = 1
|
||||
size_flags_vertical = 1
|
||||
alignment = 0
|
||||
|
||||
[node name="Label" type="Label" parent="PlayOptions" index="0"]
|
||||
|
||||
anchor_left = 0.0
|
||||
anchor_top = 0.0
|
||||
anchor_right = 0.0
|
||||
anchor_bottom = 0.0
|
||||
margin_right = 560.0
|
||||
margin_bottom = 14.0
|
||||
rect_pivot_offset = Vector2( 0, 0 )
|
||||
rect_clip_content = false
|
||||
mouse_filter = 2
|
||||
mouse_default_cursor_shape = 0
|
||||
size_flags_horizontal = 1
|
||||
size_flags_vertical = 4
|
||||
text = "choose your weapon"
|
||||
align = 1
|
||||
percent_visible = 1.0
|
||||
lines_skipped = 0
|
||||
max_lines_visible = -1
|
||||
|
||||
[node name="HBoxContainer" type="HBoxContainer" parent="PlayOptions" index="1"]
|
||||
|
||||
anchor_left = 0.0
|
||||
anchor_top = 0.0
|
||||
anchor_right = 0.0
|
||||
anchor_bottom = 0.0
|
||||
margin_top = 18.0
|
||||
margin_right = 560.0
|
||||
margin_bottom = 38.0
|
||||
rect_pivot_offset = Vector2( 0, 0 )
|
||||
rect_clip_content = false
|
||||
mouse_filter = 1
|
||||
mouse_default_cursor_shape = 0
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 1
|
||||
alignment = 1
|
||||
|
||||
[node name="Button" type="Button" parent="PlayOptions/HBoxContainer" index="0"]
|
||||
|
||||
anchor_left = 0.0
|
||||
anchor_top = 0.0
|
||||
anchor_right = 0.0
|
||||
anchor_bottom = 0.0
|
||||
margin_right = 184.0
|
||||
margin_bottom = 20.0
|
||||
rect_pivot_offset = Vector2( 0, 0 )
|
||||
rect_clip_content = false
|
||||
focus_mode = 2
|
||||
mouse_filter = 0
|
||||
mouse_default_cursor_shape = 0
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 1
|
||||
toggle_mode = true
|
||||
enabled_focus_mode = 2
|
||||
shortcut = null
|
||||
group = null
|
||||
text = "Player"
|
||||
flat = false
|
||||
align = 1
|
||||
|
||||
[node name="Button2" type="Button" parent="PlayOptions/HBoxContainer" index="1"]
|
||||
|
||||
anchor_left = 0.0
|
||||
anchor_top = 0.0
|
||||
anchor_right = 0.0
|
||||
anchor_bottom = 0.0
|
||||
margin_left = 188.0
|
||||
margin_right = 372.0
|
||||
margin_bottom = 20.0
|
||||
rect_pivot_offset = Vector2( 0, 0 )
|
||||
rect_clip_content = false
|
||||
focus_mode = 2
|
||||
mouse_filter = 0
|
||||
mouse_default_cursor_shape = 0
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 1
|
||||
toggle_mode = true
|
||||
enabled_focus_mode = 2
|
||||
shortcut = null
|
||||
group = null
|
||||
text = "Camera"
|
||||
flat = false
|
||||
align = 1
|
||||
|
||||
[node name="Button3" type="Button" parent="PlayOptions/HBoxContainer" index="2"]
|
||||
|
||||
anchor_left = 0.0
|
||||
anchor_top = 0.0
|
||||
anchor_right = 0.0
|
||||
anchor_bottom = 0.0
|
||||
margin_left = 376.0
|
||||
margin_right = 560.0
|
||||
margin_bottom = 20.0
|
||||
rect_pivot_offset = Vector2( 0, 0 )
|
||||
rect_clip_content = false
|
||||
focus_mode = 2
|
||||
mouse_filter = 0
|
||||
mouse_default_cursor_shape = 0
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 1
|
||||
toggle_mode = true
|
||||
enabled_focus_mode = 2
|
||||
shortcut = null
|
||||
group = null
|
||||
text = "Enemus"
|
||||
flat = false
|
||||
align = 1
|
||||
|
||||
[connection signal="pressed" from="ConnectOptions/HBoxContainer2/Button" to="." method="_on_Join_pressed"]
|
||||
|
||||
[connection signal="pressed" from="ConnectOptions/HBoxContainer2/Button2" to="." method="_on_Create_pressed"]
|
||||
|
||||
|
@ -0,0 +1,22 @@
|
||||
extends Container
|
||||
|
||||
onready var roles = [
|
||||
$"PlayOptions/HBoxContainer/Button",
|
||||
$"PlayOptions/HBoxContainer/Button2",
|
||||
$"PlayOptions/HBoxContainer/Button3"
|
||||
]
|
||||
|
||||
var avaliable = 7
|
||||
|
||||
func _ready():
|
||||
pass
|
||||
|
||||
|
||||
|
||||
func _on_Create_pressed():
|
||||
var ip =
|
||||
NetworkManager.create_server()
|
||||
|
||||
|
||||
func _on_Join_pressed():
|
||||
pass # replace with function body
|
@ -0,0 +1,33 @@
|
||||
extends Node
|
||||
|
||||
const DEFAULT_IP = '127.0.0.1'
|
||||
const DEFAULT_PORT = 31400
|
||||
const MAX_PLAYERS = 3
|
||||
|
||||
var players = {}
|
||||
var self_data = { role = 0, position = Vector3(), rotation = Vector3() }
|
||||
|
||||
func _ready():
|
||||
get_tree().connect('network_peer_disconnected', self, '_player_disconnect')
|
||||
|
||||
func create_server(ip = DEFAULT_IP, port = DEFAULT_PORT):
|
||||
players[1] = self_data
|
||||
var peer = NetworkedMultiplayerENet.new()
|
||||
peer.create_server(ip, port)
|
||||
get_tree().set_network_peer(peer)
|
||||
|
||||
func connect_to_server(ip = DEFAULT_IP, port = DEFAULT_PORT):
|
||||
get_tree().connect('connected_to_server', self, '_connected')
|
||||
var peer = NetworkedMultiplayerENet.new()
|
||||
peer.create_client(ip, port)
|
||||
get_tree().set_network_peer(peer)
|
||||
|
||||
func _connected():
|
||||
players[get_tree().get_network_unique_id()] = self_data
|
||||
rpc('_send_player_info', get_tree().get_network_unique_id(), self_data)
|
||||
|
||||
func _player_disconnect(id):
|
||||
players.erase(id)
|
||||
|
||||
remote func _send_player_info(id, data):
|
||||
|
Loading…
Reference in new issue