diff --git a/Phase2/Networking/Client/.import/.gdignore b/Phase2/Networking/Client/.import/.gdignore new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/Phase2/Networking/Client/.import/.gdignore @@ -0,0 +1 @@ + diff --git a/Phase2/Networking/Client/.import/icon.png-487276ed1e3a0c39cad0279d744ee560.md5 b/Phase2/Networking/Client/.import/icon.png-487276ed1e3a0c39cad0279d744ee560.md5 new file mode 100644 index 0000000..5328bc7 --- /dev/null +++ b/Phase2/Networking/Client/.import/icon.png-487276ed1e3a0c39cad0279d744ee560.md5 @@ -0,0 +1,3 @@ +source_md5="47313fa4c47a9963fddd764e1ec6e4a8" +dest_md5="26ea799ea0a3da9e753b3ebe822e0570" + diff --git a/Phase2/Networking/Client/.import/icon.png-487276ed1e3a0c39cad0279d744ee560.stex b/Phase2/Networking/Client/.import/icon.png-487276ed1e3a0c39cad0279d744ee560.stex new file mode 100644 index 0000000..71f6913 Binary files /dev/null and b/Phase2/Networking/Client/.import/icon.png-487276ed1e3a0c39cad0279d744ee560.stex differ diff --git a/Phase2/Networking/Client/Lobby/Lobby.gd b/Phase2/Networking/Client/Lobby/Lobby.gd new file mode 100644 index 0000000..14904b9 --- /dev/null +++ b/Phase2/Networking/Client/Lobby/Lobby.gd @@ -0,0 +1,5 @@ +extends Control + + +func _on_Button_pressed(): + Server._connect_to_server() diff --git a/Phase2/Networking/Client/Lobby/Lobby.tscn b/Phase2/Networking/Client/Lobby/Lobby.tscn new file mode 100644 index 0000000..7033fbc --- /dev/null +++ b/Phase2/Networking/Client/Lobby/Lobby.tscn @@ -0,0 +1,21 @@ +[gd_scene load_steps=2 format=2] + +[ext_resource path="res://Lobby/Lobby.gd" type="Script" id=1] + +[node name="Control" type="Control"] +anchor_right = 1.0 +anchor_bottom = 1.0 +script = ExtResource( 1 ) + +[node name="CenterContainer" type="CenterContainer" parent="."] +anchor_right = 1.0 +anchor_bottom = 1.0 + +[node name="Button" type="Button" parent="CenterContainer"] +margin_left = 468.0 +margin_top = 290.0 +margin_right = 556.0 +margin_bottom = 310.0 +text = "Join Session" + +[connection signal="pressed" from="CenterContainer/Button" to="." method="_on_Button_pressed"] diff --git a/Phase2/Networking/Client/Server/Server.gd b/Phase2/Networking/Client/Server/Server.gd new file mode 100644 index 0000000..a11e01e --- /dev/null +++ b/Phase2/Networking/Client/Server/Server.gd @@ -0,0 +1,38 @@ +extends Node + +const DEFAULT_IP = "127.0.0.1" +const DEFAULT_PORT = 8080 + +var network = NetworkedMultiplayerENet.new() +var selected_IP +var selected_port + +var local_player_id = 0 +sync var players = {} +sync var player_data = {} + +func _ready(): + get_tree().connect("network_peer_connected", self, "_player_connected") + get_tree().connect("network_peer_disconnected", self, "_player_disconnected") + get_tree().connect("connection_failed", self, "_connected_fail") + get_tree().connect("server_disconnected", self, "_server_disconnected") + +func _connect_to_server(): + get_tree().connect("connected_to_server", self, "_connected_ok") + network.create_client(DEFAULT_IP, DEFAULT_PORT) + get_tree().set_network_peer(network) + +func _player_connected(id): + print("Player: " + str(id) + " Connected") + +func _player_disconnected(id): + print("Player: " + str(id) + " Disconnected") + +func _connected_ok(): + print("Successfully connected to server") + +func _connected_fail(): + print("Failed to connect") + +func _server_disconnected(): + print("Server Disconnected") diff --git a/Phase2/Networking/Client/default_env.tres b/Phase2/Networking/Client/default_env.tres new file mode 100644 index 0000000..20207a4 --- /dev/null +++ b/Phase2/Networking/Client/default_env.tres @@ -0,0 +1,7 @@ +[gd_resource type="Environment" load_steps=2 format=2] + +[sub_resource type="ProceduralSky" id=1] + +[resource] +background_mode = 2 +background_sky = SubResource( 1 ) diff --git a/Phase2/Networking/Client/icon.png b/Phase2/Networking/Client/icon.png new file mode 100644 index 0000000..c98fbb6 Binary files /dev/null and b/Phase2/Networking/Client/icon.png differ diff --git a/Phase2/Networking/Client/icon.png.import b/Phase2/Networking/Client/icon.png.import new file mode 100644 index 0000000..a4c02e6 --- /dev/null +++ b/Phase2/Networking/Client/icon.png.import @@ -0,0 +1,35 @@ +[remap] + +importer="texture" +type="StreamTexture" +path="res://.import/icon.png-487276ed1e3a0c39cad0279d744ee560.stex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://icon.png" +dest_files=[ "res://.import/icon.png-487276ed1e3a0c39cad0279d744ee560.stex" ] + +[params] + +compress/mode=0 +compress/lossy_quality=0.7 +compress/hdr_mode=0 +compress/bptc_ldr=0 +compress/normal_map=0 +flags/repeat=0 +flags/filter=true +flags/mipmaps=false +flags/anisotropic=false +flags/srgb=2 +process/fix_alpha_border=true +process/premult_alpha=false +process/HDR_as_SRGB=false +process/invert_color=false +process/normal_map_invert_y=false +stream=false +size_limit=0 +detect_3d=true +svg/scale=1.0 diff --git a/Phase2/Networking/Client/project.godot b/Phase2/Networking/Client/project.godot new file mode 100644 index 0000000..fa1373a --- /dev/null +++ b/Phase2/Networking/Client/project.godot @@ -0,0 +1,34 @@ +; Engine configuration file. +; It's best edited using the editor UI and not directly, +; since the parameters that go here are not all obvious. +; +; Format: +; [section] ; section goes between [] +; param=value ; assign values to parameters + +config_version=4 + +[application] + +config/name="ClientDemo" +run/main_scene="res://Lobby/Lobby.tscn" +config/icon="res://icon.png" + +[autoload] + +Server="*res://Server/Server.gd" + +[gui] + +common/drop_mouse_on_gui_input_disabled=true + +[physics] + +common/enable_pause_aware_picking=true + +[rendering] + +quality/driver/driver_name="GLES2" +vram_compression/import_etc=true +vram_compression/import_etc2=false +environment/default_environment="res://default_env.tres" diff --git a/Phase2/Networking/Server/.import/.gdignore b/Phase2/Networking/Server/.import/.gdignore new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/Phase2/Networking/Server/.import/.gdignore @@ -0,0 +1 @@ + diff --git a/Phase2/Networking/Server/.import/icon.png-487276ed1e3a0c39cad0279d744ee560.md5 b/Phase2/Networking/Server/.import/icon.png-487276ed1e3a0c39cad0279d744ee560.md5 new file mode 100644 index 0000000..5328bc7 --- /dev/null +++ b/Phase2/Networking/Server/.import/icon.png-487276ed1e3a0c39cad0279d744ee560.md5 @@ -0,0 +1,3 @@ +source_md5="47313fa4c47a9963fddd764e1ec6e4a8" +dest_md5="26ea799ea0a3da9e753b3ebe822e0570" + diff --git a/Phase2/Networking/Server/.import/icon.png-487276ed1e3a0c39cad0279d744ee560.stex b/Phase2/Networking/Server/.import/icon.png-487276ed1e3a0c39cad0279d744ee560.stex new file mode 100644 index 0000000..71f6913 Binary files /dev/null and b/Phase2/Networking/Server/.import/icon.png-487276ed1e3a0c39cad0279d744ee560.stex differ diff --git a/Phase2/Networking/Server/Server/Server.gd b/Phase2/Networking/Server/Server/Server.gd new file mode 100644 index 0000000..3bb7296 --- /dev/null +++ b/Phase2/Networking/Server/Server/Server.gd @@ -0,0 +1,23 @@ +extends Node + +var network = NetworkedMultiplayerENet.new() +var port = 8080 +var max_players = 4 + +func _ready(): + start_server() + +func start_server(): + network.create_server(port, max_players) + get_tree().set_network_peer(network) + network.connect("peer_connected", self, "_player_connected") + network.connect("peer_disconnected", self, "_player_disconnected") + + print("Server Started") + +func _player_connected(player_id): + print("Player: " + str(player_id) + " Connected") + +func _player_disconnected(player_id): + print("Player: " + str(player_id) + " Disconnected") + diff --git a/Phase2/Networking/Server/Server/Server.tscn b/Phase2/Networking/Server/Server/Server.tscn new file mode 100644 index 0000000..ea7e9ff --- /dev/null +++ b/Phase2/Networking/Server/Server/Server.tscn @@ -0,0 +1,6 @@ +[gd_scene load_steps=2 format=2] + +[ext_resource path="res://Server/Server.gd" type="Script" id=1] + +[node name="Server" type="Node"] +script = ExtResource( 1 ) diff --git a/Phase2/Networking/Server/default_env.tres b/Phase2/Networking/Server/default_env.tres new file mode 100644 index 0000000..20207a4 --- /dev/null +++ b/Phase2/Networking/Server/default_env.tres @@ -0,0 +1,7 @@ +[gd_resource type="Environment" load_steps=2 format=2] + +[sub_resource type="ProceduralSky" id=1] + +[resource] +background_mode = 2 +background_sky = SubResource( 1 ) diff --git a/Phase2/Networking/Server/icon.png b/Phase2/Networking/Server/icon.png new file mode 100644 index 0000000..c98fbb6 Binary files /dev/null and b/Phase2/Networking/Server/icon.png differ diff --git a/Phase2/Networking/Server/icon.png.import b/Phase2/Networking/Server/icon.png.import new file mode 100644 index 0000000..a4c02e6 --- /dev/null +++ b/Phase2/Networking/Server/icon.png.import @@ -0,0 +1,35 @@ +[remap] + +importer="texture" +type="StreamTexture" +path="res://.import/icon.png-487276ed1e3a0c39cad0279d744ee560.stex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://icon.png" +dest_files=[ "res://.import/icon.png-487276ed1e3a0c39cad0279d744ee560.stex" ] + +[params] + +compress/mode=0 +compress/lossy_quality=0.7 +compress/hdr_mode=0 +compress/bptc_ldr=0 +compress/normal_map=0 +flags/repeat=0 +flags/filter=true +flags/mipmaps=false +flags/anisotropic=false +flags/srgb=2 +process/fix_alpha_border=true +process/premult_alpha=false +process/HDR_as_SRGB=false +process/invert_color=false +process/normal_map_invert_y=false +stream=false +size_limit=0 +detect_3d=true +svg/scale=1.0 diff --git a/Phase2/Networking/Server/project.godot b/Phase2/Networking/Server/project.godot new file mode 100644 index 0000000..3b45ac8 --- /dev/null +++ b/Phase2/Networking/Server/project.godot @@ -0,0 +1,30 @@ +; Engine configuration file. +; It's best edited using the editor UI and not directly, +; since the parameters that go here are not all obvious. +; +; Format: +; [section] ; section goes between [] +; param=value ; assign values to parameters + +config_version=4 + +[application] + +config/name="ServerDemo" +run/main_scene="res://Server/Server.tscn" +config/icon="res://icon.png" + +[gui] + +common/drop_mouse_on_gui_input_disabled=true + +[physics] + +common/enable_pause_aware_picking=true + +[rendering] + +quality/driver/driver_name="GLES2" +vram_compression/import_etc=true +vram_compression/import_etc2=false +environment/default_environment="res://default_env.tres"