Merge branch 'master' of github.com:unfa/jam-01 into master
commit
762f776a20
23
Game.gd
23
Game.gd
|
@ -1,9 +1,10 @@
|
||||||
extends Spatial
|
extends Node
|
||||||
|
|
||||||
export var SERVER_PORT = 9999 setget , get_port
|
export var SERVER_PORT = 80 setget , get_port
|
||||||
export(String, "172.28.162.191", "172.28.166.24", "127.0.0.1") var SERVER_IP = "172.28.162.191" setget , get_ip
|
export(String, "172.28.162.191", "172.28.166.24", "127.0.0.1") var SERVER_IP = "172.28.162.191" setget , get_ip
|
||||||
export var MAX_PLAYERS = 10
|
export var MAX_PLAYERS = 10
|
||||||
export (String, "MENU", "PLAYING") var GAME_MODE = "MENU"
|
export (String, "MENU", "PLAYING") var GAME_MODE = "MENU"
|
||||||
|
export var auto_host = false
|
||||||
|
|
||||||
var mouse_sensitivity_multiplier = 1.0
|
var mouse_sensitivity_multiplier = 1.0
|
||||||
|
|
||||||
|
@ -20,6 +21,10 @@ func _ready():
|
||||||
$MenuContainer/MainMenu/Destination/Port.set_text(str(SERVER_PORT))
|
$MenuContainer/MainMenu/Destination/Port.set_text(str(SERVER_PORT))
|
||||||
|
|
||||||
load_settings()
|
load_settings()
|
||||||
|
|
||||||
|
if auto_host:
|
||||||
|
initialize_server(false)
|
||||||
|
print("qwueyhgfiuyqwgaadsf")
|
||||||
|
|
||||||
func load_settings():
|
func load_settings():
|
||||||
var load_settings = File.new()
|
var load_settings = File.new()
|
||||||
|
@ -71,9 +76,10 @@ func open_menus():
|
||||||
$MenuContainer.show()
|
$MenuContainer.show()
|
||||||
|
|
||||||
func close_menus():
|
func close_menus():
|
||||||
GAME_MODE = "PLAYING"
|
if has_node("MenuContainer"):
|
||||||
Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)
|
GAME_MODE = "PLAYING"
|
||||||
$MenuContainer.hide()
|
Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)
|
||||||
|
$MenuContainer.hide()
|
||||||
|
|
||||||
func return_to_menu(type):
|
func return_to_menu(type):
|
||||||
for menu in $MenuContainer.get_children():
|
for menu in $MenuContainer.get_children():
|
||||||
|
@ -136,14 +142,15 @@ func get_ip():
|
||||||
func get_port():
|
func get_port():
|
||||||
return SERVER_PORT
|
return SERVER_PORT
|
||||||
|
|
||||||
func initialize_server():
|
func initialize_server(join=true):
|
||||||
var peer = NetworkedMultiplayerENet.new()
|
var peer = NetworkedMultiplayerENet.new()
|
||||||
peer.create_server(SERVER_PORT, MAX_PLAYERS)
|
peer.create_server(SERVER_PORT, MAX_PLAYERS)
|
||||||
get_tree().connect("network_peer_connected", self, "on_peer_connected")
|
get_tree().connect("network_peer_connected", self, "on_peer_connected")
|
||||||
get_tree().connect("network_peer_disconnected", self, "on_peer_disconnected")
|
get_tree().connect("network_peer_disconnected", self, "on_peer_disconnected")
|
||||||
get_tree().network_peer = peer
|
get_tree().network_peer = peer
|
||||||
close_menus()
|
close_menus()
|
||||||
add_player(1, false)
|
if join:
|
||||||
|
add_player(1, false)
|
||||||
|
|
||||||
func initialize_client():
|
func initialize_client():
|
||||||
var peer = NetworkedMultiplayerENet.new()
|
var peer = NetworkedMultiplayerENet.new()
|
||||||
|
|
19
Game.tscn
19
Game.tscn
|
@ -26,7 +26,7 @@ glow_blend_mode = 0
|
||||||
glow_hdr_threshold = 1.5
|
glow_hdr_threshold = 1.5
|
||||||
glow_bicubic_upscale = true
|
glow_bicubic_upscale = true
|
||||||
|
|
||||||
[node name="Game" type="Spatial"]
|
[node name="Game" type="Node"]
|
||||||
script = ExtResource( 2 )
|
script = ExtResource( 2 )
|
||||||
SERVER_IP = "127.0.0.1"
|
SERVER_IP = "127.0.0.1"
|
||||||
|
|
||||||
|
@ -36,7 +36,6 @@ environment = SubResource( 2 )
|
||||||
[node name="Level" parent="." instance=ExtResource( 3 )]
|
[node name="Level" parent="." instance=ExtResource( 3 )]
|
||||||
|
|
||||||
[node name="Players" type="Spatial" parent="."]
|
[node name="Players" type="Spatial" parent="."]
|
||||||
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 12.6315, 8.00684, -4.99273 )
|
|
||||||
|
|
||||||
[node name="MenuContainer" type="CenterContainer" parent="."]
|
[node name="MenuContainer" type="CenterContainer" parent="."]
|
||||||
anchor_right = 1.0
|
anchor_right = 1.0
|
||||||
|
@ -68,6 +67,8 @@ margin_bottom = 24.0
|
||||||
size_flags_horizontal = 3
|
size_flags_horizontal = 3
|
||||||
size_flags_stretch_ratio = 2.38
|
size_flags_stretch_ratio = 2.38
|
||||||
placeholder_text = "IP address"
|
placeholder_text = "IP address"
|
||||||
|
caret_blink = true
|
||||||
|
caret_blink_speed = 0.5
|
||||||
|
|
||||||
[node name="Port" type="LineEdit" parent="MenuContainer/MainMenu/Destination"]
|
[node name="Port" type="LineEdit" parent="MenuContainer/MainMenu/Destination"]
|
||||||
margin_left = 282.0
|
margin_left = 282.0
|
||||||
|
@ -75,6 +76,8 @@ margin_right = 400.0
|
||||||
margin_bottom = 24.0
|
margin_bottom = 24.0
|
||||||
size_flags_horizontal = 3
|
size_flags_horizontal = 3
|
||||||
placeholder_text = "port"
|
placeholder_text = "port"
|
||||||
|
caret_blink = true
|
||||||
|
caret_blink_speed = 0.5
|
||||||
|
|
||||||
[node name="NetworkType" type="HBoxContainer" parent="MenuContainer/MainMenu"]
|
[node name="NetworkType" type="HBoxContainer" parent="MenuContainer/MainMenu"]
|
||||||
margin_top = 52.0
|
margin_top = 52.0
|
||||||
|
@ -82,13 +85,20 @@ margin_right = 400.0
|
||||||
margin_bottom = 72.0
|
margin_bottom = 72.0
|
||||||
|
|
||||||
[node name="Host" type="Button" parent="MenuContainer/MainMenu/NetworkType"]
|
[node name="Host" type="Button" parent="MenuContainer/MainMenu/NetworkType"]
|
||||||
margin_right = 198.0
|
margin_right = 130.0
|
||||||
margin_bottom = 20.0
|
margin_bottom = 20.0
|
||||||
size_flags_horizontal = 3
|
size_flags_horizontal = 3
|
||||||
text = "Host"
|
text = "Host"
|
||||||
|
|
||||||
|
[node name="HostAsSpectator" type="Button" parent="MenuContainer/MainMenu/NetworkType"]
|
||||||
|
margin_left = 134.0
|
||||||
|
margin_right = 265.0
|
||||||
|
margin_bottom = 20.0
|
||||||
|
size_flags_horizontal = 3
|
||||||
|
text = "Host As Spectator"
|
||||||
|
|
||||||
[node name="Join" type="Button" parent="MenuContainer/MainMenu/NetworkType"]
|
[node name="Join" type="Button" parent="MenuContainer/MainMenu/NetworkType"]
|
||||||
margin_left = 202.0
|
margin_left = 269.0
|
||||||
margin_right = 400.0
|
margin_right = 400.0
|
||||||
margin_bottom = 20.0
|
margin_bottom = 20.0
|
||||||
size_flags_horizontal = 3
|
size_flags_horizontal = 3
|
||||||
|
@ -221,6 +231,7 @@ text = "Fullscreen"
|
||||||
[connection signal="pressed" from="MenuContainer/MainMenu/QuickJoin" to="." method="open_menu" binds= [ "QuickJoinMenu" ]]
|
[connection signal="pressed" from="MenuContainer/MainMenu/QuickJoin" to="." method="open_menu" binds= [ "QuickJoinMenu" ]]
|
||||||
[connection signal="text_changed" from="MenuContainer/MainMenu/Destination/IPAdress" to="." method="set_ip"]
|
[connection signal="text_changed" from="MenuContainer/MainMenu/Destination/IPAdress" to="." method="set_ip"]
|
||||||
[connection signal="pressed" from="MenuContainer/MainMenu/NetworkType/Host" to="." method="initialize_server"]
|
[connection signal="pressed" from="MenuContainer/MainMenu/NetworkType/Host" to="." method="initialize_server"]
|
||||||
|
[connection signal="pressed" from="MenuContainer/MainMenu/NetworkType/HostAsSpectator" to="." method="initialize_server" binds= [ false ]]
|
||||||
[connection signal="pressed" from="MenuContainer/MainMenu/NetworkType/Join" to="." method="initialize_client"]
|
[connection signal="pressed" from="MenuContainer/MainMenu/NetworkType/Join" to="." method="initialize_client"]
|
||||||
[connection signal="pressed" from="MenuContainer/MainMenu/Options" to="." method="open_menu" binds= [ "OptionsMenu" ]]
|
[connection signal="pressed" from="MenuContainer/MainMenu/Options" to="." method="open_menu" binds= [ "OptionsMenu" ]]
|
||||||
[connection signal="pressed" from="MenuContainer/MainMenu/Quit" to="." method="quit"]
|
[connection signal="pressed" from="MenuContainer/MainMenu/Quit" to="." method="quit"]
|
||||||
|
|
|
@ -0,0 +1,6 @@
|
||||||
|
[gd_scene load_steps=2 format=2]
|
||||||
|
|
||||||
|
[ext_resource path="res://Game.tscn" type="PackedScene" id=2]
|
||||||
|
|
||||||
|
[node name="Game" instance=ExtResource( 2 )]
|
||||||
|
auto_host = true
|
Reference in New Issue