initial commit
This commit is contained in:
commit
a3549d357b
@ -0,0 +1,3 @@
|
|||||||
|
source_md5="73d4e8af5731d88b8d9ed188fd16bd86"
|
||||||
|
dest_md5="548af57ffd919fd4b0880e4ca16c47ad"
|
||||||
|
|
BIN
Client/.import/hex.dae-11b3e3e61b7f8c01f8672d854a6a4c26.scn
Normal file
BIN
Client/.import/hex.dae-11b3e3e61b7f8c01f8672d854a6a4c26.scn
Normal file
Binary file not shown.
@ -0,0 +1,3 @@
|
|||||||
|
source_md5="47313fa4c47a9963fddd764e1ec6e4a8"
|
||||||
|
dest_md5="2ded9e7f9060e2b530aab678b135fc5b"
|
||||||
|
|
BIN
Client/.import/icon.png-487276ed1e3a0c39cad0279d744ee560.stex
Normal file
BIN
Client/.import/icon.png-487276ed1e3a0c39cad0279d744ee560.stex
Normal file
Binary file not shown.
66
Client/Material/hex.dae
Normal file
66
Client/Material/hex.dae
Normal file
@ -0,0 +1,66 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<COLLADA xmlns="http://www.collada.org/2005/11/COLLADASchema" version="1.4.1">
|
||||||
|
<asset>
|
||||||
|
<contributor>
|
||||||
|
<author>Anonymous</author>
|
||||||
|
<authoring_tool>Collada Exporter for Blender 2.6+, by Juan Linietsky (juan@codenix.com)</authoring_tool>
|
||||||
|
</contributor>
|
||||||
|
<created>2020-02-27T18:22:18Z</created>
|
||||||
|
<modified>2020-02-27T18:22:18Z</modified>
|
||||||
|
<unit meter="1.0" name="meter"/>
|
||||||
|
<up_axis>Z_UP</up_axis>
|
||||||
|
</asset>
|
||||||
|
<library_geometries>
|
||||||
|
<geometry id="id-mesh-2" name="Cylinder">
|
||||||
|
<mesh>
|
||||||
|
<source id="id-mesh-2-positions">
|
||||||
|
<float_array id="id-mesh-2-positions-array" count="108"> 0.0 1.0 -1.0 0.0 1.0 1.0 0.9922332167625427 0.4999999701976776 1.0 0.9922332167625427 0.4999999701976776 -1.0 0.9922332167625427 0.4999999701976776 -1.0 0.9922332167625427 0.4999999701976776 1.0 0.992233157157898 -0.5000000596046448 1.0 0.992233157157898 -0.5000000596046448 -1.0 0.992233157157898 -0.5000000596046448 -1.0 0.992233157157898 -0.5000000596046448 1.0 -1.001630849373214e-07 -1.0 1.0 -1.001630849373214e-07 -1.0 -1.0 -1.001630849373214e-07 -1.0 -1.0 -1.001630849373214e-07 -1.0 1.0 -0.9922332167625427 -0.49999991059303284 1.0 -0.9922332167625427 -0.49999991059303284 -1.0 0.9922332167625427 0.4999999701976776 1.0 0.0 1.0 1.0 -0.9922332167625427 0.49999991059303284 1.0 -0.9922332167625427 -0.49999991059303284 1.0 -1.001630849373214e-07 -1.0 1.0 0.992233157157898 -0.5000000596046448 1.0 -0.9922332167625427 -0.49999991059303284 -1.0 -0.9922332167625427 -0.49999991059303284 1.0 -0.9922332167625427 0.49999991059303284 1.0 -0.9922332167625427 0.49999991059303284 -1.0 -0.9922332167625427 0.49999991059303284 -1.0 -0.9922332167625427 0.49999991059303284 1.0 0.0 1.0 1.0 0.0 1.0 -1.0 0.0 1.0 -1.0 0.9922332167625427 0.4999999701976776 -1.0 0.992233157157898 -0.5000000596046448 -1.0 -1.001630849373214e-07 -1.0 -1.0 -0.9922332167625427 -0.49999991059303284 -1.0 -0.9922332167625427 0.49999991059303284 -1.0</float_array>
|
||||||
|
<technique_common>
|
||||||
|
<accessor source="#id-mesh-2-positions-array" count="36" stride="3">
|
||||||
|
<param name="X" type="float"/>
|
||||||
|
<param name="Y" type="float"/>
|
||||||
|
<param name="Z" type="float"/>
|
||||||
|
</accessor>
|
||||||
|
</technique_common>
|
||||||
|
</source>
|
||||||
|
<source id="id-mesh-2-normals">
|
||||||
|
<float_array id="id-mesh-2-normals-array" count="108"> 0.45000749826431274 0.8930248022079468 0.0 0.45000749826431274 0.8930248022079468 0.0 0.45000749826431274 0.8930248022079468 0.0 0.45000749826431274 0.8930248022079468 0.0 1.0 -5.960464477539063e-08 0.0 1.0 -5.960464477539063e-08 0.0 1.0 -5.960464477539063e-08 0.0 1.0 -5.960464477539063e-08 0.0 0.4500074088573456 -0.893024742603302 0.0 0.4500074088573456 -0.893024742603302 0.0 0.4500074088573456 -0.893024742603302 0.0 0.4500074088573456 -0.893024742603302 0.0 -0.4500076174736023 -0.8930246829986572 0.0 -0.4500076174736023 -0.8930246829986572 0.0 -0.4500076174736023 -0.8930246829986572 0.0 -0.4500076174736023 -0.8930246829986572 0.0 4.004747466979097e-08 0.0 1.0 4.004747466979097e-08 0.0 1.0 4.004747466979097e-08 0.0 1.0 4.004747466979097e-08 0.0 1.0 4.004747466979097e-08 0.0 1.0 4.004747466979097e-08 0.0 1.0 -1.0 0.0 0.0 -1.0 0.0 0.0 -1.0 0.0 0.0 -1.0 0.0 0.0 -0.4500075876712799 0.893024742603302 0.0 -0.4500075876712799 0.893024742603302 0.0 -0.4500075876712799 0.893024742603302 0.0 -0.4500075876712799 0.893024742603302 0.0 6.007121555740014e-08 0.0 -1.0 6.007121555740014e-08 0.0 -1.0 6.007121555740014e-08 0.0 -1.0 6.007121555740014e-08 0.0 -1.0 6.007121555740014e-08 0.0 -1.0 6.007121555740014e-08 0.0 -1.0</float_array>
|
||||||
|
<technique_common>
|
||||||
|
<accessor source="#id-mesh-2-normals-array" count="36" stride="3">
|
||||||
|
<param name="X" type="float"/>
|
||||||
|
<param name="Y" type="float"/>
|
||||||
|
<param name="Z" type="float"/>
|
||||||
|
</accessor>
|
||||||
|
</technique_common>
|
||||||
|
</source>
|
||||||
|
<vertices id="id-mesh-2-vertices">
|
||||||
|
<input semantic="POSITION" source="#id-mesh-2-positions"/>
|
||||||
|
</vertices>
|
||||||
|
<polygons count="8">
|
||||||
|
<input semantic="VERTEX" source="#id-mesh-2-vertices" offset="0"/>
|
||||||
|
<input semantic="NORMAL" source="#id-mesh-2-normals" offset="0"/>
|
||||||
|
<p> 0 1 2 3 </p>
|
||||||
|
<p> 4 5 6 7 </p>
|
||||||
|
<p> 8 9 10 11 </p>
|
||||||
|
<p> 12 13 14 15 </p>
|
||||||
|
<p> 16 17 18 19 20 21 </p>
|
||||||
|
<p> 22 23 24 25 </p>
|
||||||
|
<p> 26 27 28 29 </p>
|
||||||
|
<p> 30 31 32 33 34 35 </p>
|
||||||
|
</polygons>
|
||||||
|
</mesh>
|
||||||
|
</geometry>
|
||||||
|
</library_geometries>
|
||||||
|
<library_visual_scenes>
|
||||||
|
<visual_scene id="id-scene-1" name="scene">
|
||||||
|
<node id="Cylinder" name="Cylinder" type="NODE">
|
||||||
|
<matrix sid="transform"> 1.0 0.0 0.0 0.0 0.0 1.0 0.0 0.0 0.0 0.0 0.10000002384185791 0.0 0.0 0.0 0.0 1.0 </matrix>
|
||||||
|
<instance_geometry url="#id-mesh-2">
|
||||||
|
</instance_geometry>
|
||||||
|
</node>
|
||||||
|
</visual_scene>
|
||||||
|
</library_visual_scenes>
|
||||||
|
<scene>
|
||||||
|
<instance_visual_scene url="#id-scene-1" />
|
||||||
|
</scene>
|
||||||
|
</COLLADA>
|
1063
Client/Material/hex.dae.import
Normal file
1063
Client/Material/hex.dae.import
Normal file
File diff suppressed because it is too large
Load Diff
45
Client/Scenes/Matchmaking/Client/Network_connection.gd
Normal file
45
Client/Scenes/Matchmaking/Client/Network_connection.gd
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
extends Node
|
||||||
|
|
||||||
|
const SERVER_IP = "willipink.eu"
|
||||||
|
const SERVER_PORT = 14600
|
||||||
|
|
||||||
|
onready var _start_button = get_node("Start_button")
|
||||||
|
onready var _disconnect_button = get_node("Disconnect_button")
|
||||||
|
var _connected = false
|
||||||
|
|
||||||
|
func _ready():
|
||||||
|
get_tree().connect("connected_to_server", self, "_connected_ok")
|
||||||
|
initialize_connection()
|
||||||
|
|
||||||
|
func initialize_connection():
|
||||||
|
$Try_to_connect_to_server_timer.start()
|
||||||
|
connect_to_server()
|
||||||
|
_start_button.text = "Connecting..."
|
||||||
|
|
||||||
|
func connect_to_server():
|
||||||
|
print("Try to join the server.")
|
||||||
|
var peer = NetworkedMultiplayerENet.new()
|
||||||
|
peer.create_client(SERVER_IP, SERVER_PORT)
|
||||||
|
get_tree().set_network_peer(peer)
|
||||||
|
|
||||||
|
func _connected_ok():
|
||||||
|
$Try_to_connect_to_server_timer.stop()
|
||||||
|
Player.set_player_id(get_tree().get_network_unique_id())
|
||||||
|
_connected = true
|
||||||
|
_start_button.text = "Start"
|
||||||
|
_start_button.disabled = false
|
||||||
|
_disconnect_button.text = "Disconnect"
|
||||||
|
|
||||||
|
func _on_Try_to_connect_to_server_timer_timeout():
|
||||||
|
if !_connected:
|
||||||
|
connect_to_server()
|
||||||
|
|
||||||
|
func disconnect_from_server():
|
||||||
|
get_tree().set_network_peer(null)
|
||||||
|
|
||||||
|
func _on_Start_button_pressed():
|
||||||
|
get_tree().change_scene("res://Scenes/Matchmaking/Lobby/Lobby.tscn")
|
||||||
|
|
||||||
|
func _on_Disconnect_button_pressed():
|
||||||
|
disconnect_from_server()
|
||||||
|
get_tree().change_scene("res://Scenes/Matchmaking/Menu/Menu.tscn")
|
51
Client/Scenes/Matchmaking/Client/Network_connection.tscn
Normal file
51
Client/Scenes/Matchmaking/Client/Network_connection.tscn
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
[gd_scene load_steps=3 format=2]
|
||||||
|
|
||||||
|
[ext_resource path="res://icon.png" type="Texture" id=1]
|
||||||
|
[ext_resource path="res://Scenes/Matchmaking/Client/Network_connection.gd" type="Script" id=2]
|
||||||
|
|
||||||
|
[node name="Network_connection" type="Node"]
|
||||||
|
script = ExtResource( 2 )
|
||||||
|
|
||||||
|
[node name="Background_image" type="TextureRect" parent="."]
|
||||||
|
anchor_right = 1.0
|
||||||
|
anchor_bottom = 1.0
|
||||||
|
texture = ExtResource( 1 )
|
||||||
|
stretch_mode = 2
|
||||||
|
__meta__ = {
|
||||||
|
"_edit_use_anchors_": false
|
||||||
|
}
|
||||||
|
|
||||||
|
[node name="Start_button" type="Button" parent="."]
|
||||||
|
anchor_left = 0.5
|
||||||
|
anchor_top = 0.5
|
||||||
|
anchor_right = 0.5
|
||||||
|
anchor_bottom = 0.5
|
||||||
|
margin_left = -188.5
|
||||||
|
margin_top = -70.0
|
||||||
|
margin_right = 188.5
|
||||||
|
margin_bottom = 70.0
|
||||||
|
disabled = true
|
||||||
|
text = "Connecting..."
|
||||||
|
__meta__ = {
|
||||||
|
"_edit_use_anchors_": false
|
||||||
|
}
|
||||||
|
|
||||||
|
[node name="Disconnect_button" type="Button" parent="."]
|
||||||
|
anchor_left = 0.5
|
||||||
|
anchor_top = 0.5
|
||||||
|
anchor_right = 0.5
|
||||||
|
anchor_bottom = 0.5
|
||||||
|
margin_left = -188.5
|
||||||
|
margin_top = 103.958
|
||||||
|
margin_right = 188.5
|
||||||
|
margin_bottom = 243.958
|
||||||
|
text = "Cancel"
|
||||||
|
__meta__ = {
|
||||||
|
"_edit_use_anchors_": false
|
||||||
|
}
|
||||||
|
|
||||||
|
[node name="Try_to_connect_to_server_timer" type="Timer" parent="."]
|
||||||
|
wait_time = 2.0
|
||||||
|
[connection signal="pressed" from="Start_button" to="." method="_on_Start_button_pressed"]
|
||||||
|
[connection signal="pressed" from="Disconnect_button" to="." method="_on_Disconnect_button_pressed"]
|
||||||
|
[connection signal="timeout" from="Try_to_connect_to_server_timer" to="." method="_on_Try_to_connect_to_server_timer_timeout"]
|
@ -0,0 +1,36 @@
|
|||||||
|
extends Spatial
|
||||||
|
|
||||||
|
const MOVE_MARGIN = 20
|
||||||
|
const MOVE_SPEED = 15
|
||||||
|
|
||||||
|
const X_BORDER_LIMIT = 8
|
||||||
|
const X_MAP_OFFSET = 2
|
||||||
|
|
||||||
|
const Z_BORDER_LIMIT = 3
|
||||||
|
const Z_MAP_OFFSET = 1
|
||||||
|
|
||||||
|
onready var cam = $Camera
|
||||||
|
|
||||||
|
func _process(delta):
|
||||||
|
var mouse_position = get_viewport().get_mouse_position()
|
||||||
|
calc_move(mouse_position, delta)
|
||||||
|
|
||||||
|
func calc_move(mouse_position, delta):
|
||||||
|
var screen_size = get_viewport().size
|
||||||
|
var position = translation
|
||||||
|
|
||||||
|
if mouse_position.x < MOVE_MARGIN:
|
||||||
|
position.x -= MOVE_SPEED * delta
|
||||||
|
|
||||||
|
if mouse_position.y < MOVE_MARGIN:
|
||||||
|
position.z -= MOVE_SPEED * delta
|
||||||
|
|
||||||
|
if mouse_position.x > screen_size.x - MOVE_MARGIN:
|
||||||
|
position.x += MOVE_SPEED * delta
|
||||||
|
|
||||||
|
if mouse_position.y > screen_size.y - MOVE_MARGIN:
|
||||||
|
position.z += MOVE_SPEED * delta
|
||||||
|
|
||||||
|
position.x = clamp(position.x, -X_BORDER_LIMIT, X_BORDER_LIMIT + X_MAP_OFFSET)
|
||||||
|
position.z = clamp(position.z, -Z_BORDER_LIMIT - Z_MAP_OFFSET, Z_BORDER_LIMIT - Z_MAP_OFFSET)
|
||||||
|
translation = position
|
178
Client/Scenes/Matchmaking/Game/Game_manager.gd
Normal file
178
Client/Scenes/Matchmaking/Game/Game_manager.gd
Normal file
@ -0,0 +1,178 @@
|
|||||||
|
extends Spatial
|
||||||
|
|
||||||
|
var _current_player_index
|
||||||
|
|
||||||
|
var _turn_number
|
||||||
|
|
||||||
|
var _round_counter = 0
|
||||||
|
|
||||||
|
var _other_players = []
|
||||||
|
|
||||||
|
var _map
|
||||||
|
|
||||||
|
var _game_started = false
|
||||||
|
|
||||||
|
var _ability_left = false
|
||||||
|
|
||||||
|
var _previous_hex = null
|
||||||
|
|
||||||
|
func _ready():
|
||||||
|
$GUI/Player_name_panel/HBoxContainer/Player_name.text = Player.get_player_name()
|
||||||
|
_other_players = NetworkingSync._player_in_same_game_room_list.duplicate()
|
||||||
|
_other_players.erase([Player.get_player_id(), Player.get_player_name()])
|
||||||
|
init_game()
|
||||||
|
fill_player_list()
|
||||||
|
|
||||||
|
if Player.is_host():
|
||||||
|
init_game_state()
|
||||||
|
|
||||||
|
NetworkingSync.send_ready_signal()
|
||||||
|
|
||||||
|
func init_game():
|
||||||
|
create_map()
|
||||||
|
_turn_number = 1
|
||||||
|
$GUI/Bottom_left_panel/VBoxContainer/HBoxContainer/Turn_indicator.text = str(_turn_number)
|
||||||
|
|
||||||
|
func fill_player_list():
|
||||||
|
for player in _other_players:
|
||||||
|
add_other_players_to_list(player[1])
|
||||||
|
|
||||||
|
func update_player_list():
|
||||||
|
for child in $GUI/Player_info/VBoxContainer/Player_list.get_children():
|
||||||
|
child.queue_free()
|
||||||
|
|
||||||
|
fill_player_list()
|
||||||
|
|
||||||
|
func add_other_players_to_list(player_name):
|
||||||
|
var player = load("res://Scenes/Matchmaking/Game_room/Player_entry.tscn").instance()
|
||||||
|
player.set_player_name(player_name)
|
||||||
|
$GUI/Player_info/VBoxContainer/Player_list.add_child(player)
|
||||||
|
|
||||||
|
func create_map():
|
||||||
|
_map = load("res://Scenes/Matchmaking/Game/Map/Map.tscn").instance()
|
||||||
|
add_child(_map)
|
||||||
|
|
||||||
|
func init_game_state():
|
||||||
|
yield(NetworkingSync, "all_ready")
|
||||||
|
var starting_player_index = calculate_stating_player_index()
|
||||||
|
|
||||||
|
set_starting_player(starting_player_index)
|
||||||
|
for player in _other_players:
|
||||||
|
rpc_id(player[0], "set_starting_player", starting_player_index)
|
||||||
|
|
||||||
|
func is_my_turn():
|
||||||
|
return NetworkingSync._player_in_same_game_room_list[_current_player_index][0] == Player.get_player_id()
|
||||||
|
|
||||||
|
func calculate_stating_player_index():
|
||||||
|
return int(rand_range(0, len(NetworkingSync._player_in_same_game_room_list)))
|
||||||
|
|
||||||
|
remote func set_starting_player(starting_player_index):
|
||||||
|
_current_player_index = starting_player_index
|
||||||
|
$GUI/Top_panel/Top_panel_container/Player_indicator.text = str(NetworkingSync._player_in_same_game_room_list[_current_player_index][1])
|
||||||
|
update_current_player()
|
||||||
|
|
||||||
|
|
||||||
|
func update_current_player():
|
||||||
|
if is_my_turn():
|
||||||
|
_ability_left = true
|
||||||
|
_round_counter = 0
|
||||||
|
_previous_hex = null
|
||||||
|
$GUI/Bottom_left_panel/VBoxContainer/Next_turn_button.disabled = false
|
||||||
|
else:
|
||||||
|
$GUI/Bottom_left_panel/VBoxContainer/Next_turn_button.disabled = true
|
||||||
|
|
||||||
|
func _on_Next_turn_button_pressed():
|
||||||
|
next_turn()
|
||||||
|
|
||||||
|
func next_turn():
|
||||||
|
next_player()
|
||||||
|
for player in _other_players:
|
||||||
|
rpc_id(player[0], "next_player")
|
||||||
|
_turn_number += 1
|
||||||
|
$GUI/Bottom_left_panel/VBoxContainer/HBoxContainer/Turn_indicator.text = str(_turn_number)
|
||||||
|
|
||||||
|
remote func next_player():
|
||||||
|
_current_player_index = (_current_player_index + 1) % len(NetworkingSync._player_in_same_game_room_list)
|
||||||
|
$GUI/Top_panel/Top_panel_container/Player_indicator.text = str(NetworkingSync._player_in_same_game_room_list[_current_player_index][1])
|
||||||
|
update_current_player()
|
||||||
|
|
||||||
|
func game_started():
|
||||||
|
return _game_started
|
||||||
|
|
||||||
|
func color_the_hex(hex_node):
|
||||||
|
for player in _other_players:
|
||||||
|
rpc_id(player[0], "color_the_hex_to_player_color", hex_node._x, hex_node._y)
|
||||||
|
color_the_hex_to_player_color(hex_node._x, hex_node._y)
|
||||||
|
|
||||||
|
remote func color_the_hex_to_player_color(hex_x, hex_y):
|
||||||
|
_map._hexes[hex_x][hex_y].set_color(_current_player_index)
|
||||||
|
|
||||||
|
func ability_left():
|
||||||
|
return _ability_left
|
||||||
|
|
||||||
|
func get_previous_hex():
|
||||||
|
return _previous_hex
|
||||||
|
|
||||||
|
func try_to_occupy_hex(hex_node):
|
||||||
|
color_the_hex(hex_node)
|
||||||
|
occupy_hex(hex_node._x, hex_node._y)
|
||||||
|
for player in _other_players:
|
||||||
|
rpc_id(player[0], "occupy_hex", hex_node._x, hex_node._y)
|
||||||
|
|
||||||
|
_previous_hex = hex_node
|
||||||
|
_round_counter += 1
|
||||||
|
|
||||||
|
if _round_counter >= _turn_number:
|
||||||
|
next_turn()
|
||||||
|
else:
|
||||||
|
if !hex_node.is_any_neighbour_free():
|
||||||
|
left_game()
|
||||||
|
|
||||||
|
remote func occupy_hex(hex_x, hex_y):
|
||||||
|
_map._hexes[hex_x][hex_y].occupy_hex()
|
||||||
|
|
||||||
|
#func _process(delta):
|
||||||
|
# if len(_other_players) <= 0 and _game_started:
|
||||||
|
# end_game(true)
|
||||||
|
|
||||||
|
func left_game():
|
||||||
|
for player in _other_players:
|
||||||
|
rpc_id(player[0], "player_left", Player.get_player_id(), Player.get_player_name())
|
||||||
|
end_game(false)
|
||||||
|
|
||||||
|
func end_game(is_winning):
|
||||||
|
if is_winning:
|
||||||
|
$End_game_panel/Label.text = "You won."
|
||||||
|
$GUI.visible = false
|
||||||
|
$End_game_panel.visible = true
|
||||||
|
|
||||||
|
remote func player_left(player_id, player_name):
|
||||||
|
print("Player: " + str(player_id) + " left.")
|
||||||
|
_other_players.erase([player_id, player_name])
|
||||||
|
NetworkingSync._player_in_same_game_room_list.erase([player_id, player_name])
|
||||||
|
update_player_list()
|
||||||
|
check_for_win()
|
||||||
|
next_player()
|
||||||
|
|
||||||
|
func check_for_win():
|
||||||
|
if len(_other_players) <= 0:
|
||||||
|
end_game(true)
|
||||||
|
|
||||||
|
func back_to_lobby():
|
||||||
|
get_tree().change_scene("res://Scenes/Matchmaking/Lobby/Lobby.tscn")
|
||||||
|
|
||||||
|
func _on_Back_to_lobby_button_pressed():
|
||||||
|
back_to_lobby()
|
||||||
|
|
||||||
|
func _on_Surrender_button_pressed():
|
||||||
|
$Menu_panel.visible = false
|
||||||
|
left_game()
|
||||||
|
|
||||||
|
func _input(event):
|
||||||
|
if Input.is_key_pressed(KEY_ESCAPE) and $Menu_panel.visible:
|
||||||
|
$Menu_panel.visible = false
|
||||||
|
elif Input.is_key_pressed(KEY_ESCAPE) and !$Menu_panel.visible:
|
||||||
|
$Menu_panel.visible = true
|
||||||
|
|
||||||
|
func _on_Close_pressed():
|
||||||
|
$Menu_panel.visible = false
|
303
Client/Scenes/Matchmaking/Game/Game_manager.tscn
Normal file
303
Client/Scenes/Matchmaking/Game/Game_manager.tscn
Normal file
@ -0,0 +1,303 @@
|
|||||||
|
[gd_scene load_steps=4 format=2]
|
||||||
|
|
||||||
|
[ext_resource path="res://Scenes/Matchmaking/Game/Camera_controller/Camera_controller.gd" type="Script" id=2]
|
||||||
|
[ext_resource path="res://Scenes/Matchmaking/Game/Game_manager.gd" type="Script" id=3]
|
||||||
|
[ext_resource path="res://Scenes/Matchmaking/Game/Mouse_controller/Mouse_controller.gd" type="Script" id=4]
|
||||||
|
|
||||||
|
[node name="Game_manager" type="Spatial"]
|
||||||
|
script = ExtResource( 3 )
|
||||||
|
|
||||||
|
[node name="End_game_panel" type="Control" parent="."]
|
||||||
|
visible = false
|
||||||
|
anchor_right = 1.0
|
||||||
|
anchor_bottom = 1.0
|
||||||
|
__meta__ = {
|
||||||
|
"_edit_use_anchors_": false
|
||||||
|
}
|
||||||
|
|
||||||
|
[node name="ColorRect" type="ColorRect" parent="End_game_panel"]
|
||||||
|
anchor_right = 1.0
|
||||||
|
anchor_bottom = 1.0
|
||||||
|
margin_left = 1.22772
|
||||||
|
margin_right = 1.22778
|
||||||
|
color = Color( 0.156863, 0.611765, 0.160784, 0.392157 )
|
||||||
|
|
||||||
|
[node name="Label" type="Label" parent="End_game_panel"]
|
||||||
|
anchor_left = 0.5
|
||||||
|
anchor_top = 0.5
|
||||||
|
anchor_right = 0.5
|
||||||
|
anchor_bottom = 0.5
|
||||||
|
margin_left = -223.5
|
||||||
|
margin_top = -89.0
|
||||||
|
margin_right = 223.5
|
||||||
|
margin_bottom = 89.0
|
||||||
|
text = "You lose"
|
||||||
|
align = 1
|
||||||
|
valign = 1
|
||||||
|
__meta__ = {
|
||||||
|
"_edit_use_anchors_": false
|
||||||
|
}
|
||||||
|
|
||||||
|
[node name="ColorRect2" type="ColorRect" parent="End_game_panel/Label"]
|
||||||
|
anchor_right = 1.0
|
||||||
|
anchor_bottom = 1.0
|
||||||
|
color = Color( 0, 1, 1, 0.235294 )
|
||||||
|
__meta__ = {
|
||||||
|
"_edit_use_anchors_": false
|
||||||
|
}
|
||||||
|
|
||||||
|
[node name="Back_to_lobby_button" type="Button" parent="End_game_panel"]
|
||||||
|
anchor_left = 0.5
|
||||||
|
anchor_top = 0.5
|
||||||
|
anchor_right = 0.5
|
||||||
|
anchor_bottom = 0.5
|
||||||
|
margin_left = -183.0
|
||||||
|
margin_top = 135.815
|
||||||
|
margin_right = 183.0
|
||||||
|
margin_bottom = 313.815
|
||||||
|
text = "Back to lobby"
|
||||||
|
|
||||||
|
[node name="GUI" type="Control" parent="."]
|
||||||
|
anchor_right = 1.0
|
||||||
|
anchor_bottom = 1.0
|
||||||
|
mouse_filter = 2
|
||||||
|
__meta__ = {
|
||||||
|
"_edit_use_anchors_": false
|
||||||
|
}
|
||||||
|
|
||||||
|
[node name="Player_info" type="Control" parent="GUI"]
|
||||||
|
margin_left = 1650.14
|
||||||
|
margin_top = 68.4775
|
||||||
|
margin_right = 1910.14
|
||||||
|
margin_bottom = 283.477
|
||||||
|
__meta__ = {
|
||||||
|
"_edit_use_anchors_": false
|
||||||
|
}
|
||||||
|
|
||||||
|
[node name="ColorRect" type="ColorRect" parent="GUI/Player_info"]
|
||||||
|
anchor_right = 1.0
|
||||||
|
anchor_bottom = 1.0
|
||||||
|
color = Color( 0.831373, 0, 0, 0.137255 )
|
||||||
|
|
||||||
|
[node name="VBoxContainer" type="VBoxContainer" parent="GUI/Player_info"]
|
||||||
|
anchor_right = 1.0
|
||||||
|
anchor_bottom = 1.0
|
||||||
|
__meta__ = {
|
||||||
|
"_edit_use_anchors_": false
|
||||||
|
}
|
||||||
|
|
||||||
|
[node name="Label" type="Label" parent="GUI/Player_info/VBoxContainer"]
|
||||||
|
margin_right = 260.0
|
||||||
|
margin_bottom = 14.0
|
||||||
|
size_flags_horizontal = 3
|
||||||
|
size_flags_vertical = 1
|
||||||
|
text = "Oponents left:"
|
||||||
|
align = 1
|
||||||
|
valign = 1
|
||||||
|
|
||||||
|
[node name="Player_list" type="VBoxContainer" parent="GUI/Player_info/VBoxContainer"]
|
||||||
|
margin_top = 18.0
|
||||||
|
margin_right = 260.0
|
||||||
|
margin_bottom = 214.0
|
||||||
|
size_flags_horizontal = 3
|
||||||
|
size_flags_vertical = 3
|
||||||
|
__meta__ = {
|
||||||
|
"_edit_use_anchors_": false
|
||||||
|
}
|
||||||
|
|
||||||
|
[node name="Player_name_panel" type="Control" parent="GUI"]
|
||||||
|
margin_right = 306.0
|
||||||
|
margin_bottom = 40.0
|
||||||
|
__meta__ = {
|
||||||
|
"_edit_use_anchors_": false
|
||||||
|
}
|
||||||
|
|
||||||
|
[node name="HBoxContainer" type="HBoxContainer" parent="GUI/Player_name_panel"]
|
||||||
|
anchor_right = 1.0
|
||||||
|
anchor_bottom = 1.0
|
||||||
|
__meta__ = {
|
||||||
|
"_edit_use_anchors_": false
|
||||||
|
}
|
||||||
|
|
||||||
|
[node name="Player_name_info_laabel" type="Label" parent="GUI/Player_name_panel/HBoxContainer"]
|
||||||
|
margin_right = 47.0
|
||||||
|
margin_bottom = 40.0
|
||||||
|
size_flags_vertical = 3
|
||||||
|
text = "Player: "
|
||||||
|
align = 1
|
||||||
|
valign = 1
|
||||||
|
__meta__ = {
|
||||||
|
"_edit_use_anchors_": false
|
||||||
|
}
|
||||||
|
|
||||||
|
[node name="Player_name" type="Label" parent="GUI/Player_name_panel/HBoxContainer"]
|
||||||
|
margin_left = 51.0
|
||||||
|
margin_right = 306.0
|
||||||
|
margin_bottom = 40.0
|
||||||
|
size_flags_horizontal = 3
|
||||||
|
size_flags_vertical = 3
|
||||||
|
text = "Bob"
|
||||||
|
valign = 1
|
||||||
|
__meta__ = {
|
||||||
|
"_edit_use_anchors_": false
|
||||||
|
}
|
||||||
|
|
||||||
|
[node name="Top_panel" type="Control" parent="GUI"]
|
||||||
|
anchor_left = 0.5
|
||||||
|
anchor_right = 0.5
|
||||||
|
margin_left = -960.0
|
||||||
|
margin_right = 960.0
|
||||||
|
margin_bottom = 50.0
|
||||||
|
__meta__ = {
|
||||||
|
"_edit_use_anchors_": false
|
||||||
|
}
|
||||||
|
|
||||||
|
[node name="Top_panel_container" type="HBoxContainer" parent="GUI/Top_panel"]
|
||||||
|
anchor_right = 1.0
|
||||||
|
anchor_bottom = 1.0
|
||||||
|
size_flags_horizontal = 0
|
||||||
|
size_flags_vertical = 0
|
||||||
|
__meta__ = {
|
||||||
|
"_edit_use_anchors_": false
|
||||||
|
}
|
||||||
|
|
||||||
|
[node name="Player_label" type="Label" parent="GUI/Top_panel/Top_panel_container"]
|
||||||
|
margin_right = 958.0
|
||||||
|
margin_bottom = 50.0
|
||||||
|
size_flags_horizontal = 3
|
||||||
|
size_flags_vertical = 3
|
||||||
|
text = "Turn of:"
|
||||||
|
align = 2
|
||||||
|
valign = 1
|
||||||
|
__meta__ = {
|
||||||
|
"_edit_use_anchors_": true
|
||||||
|
}
|
||||||
|
|
||||||
|
[node name="Player_indicator" type="Label" parent="GUI/Top_panel/Top_panel_container"]
|
||||||
|
margin_left = 962.0
|
||||||
|
margin_right = 1920.0
|
||||||
|
margin_bottom = 50.0
|
||||||
|
size_flags_horizontal = 3
|
||||||
|
size_flags_vertical = 3
|
||||||
|
text = "Player 1"
|
||||||
|
valign = 1
|
||||||
|
__meta__ = {
|
||||||
|
"_edit_use_anchors_": true
|
||||||
|
}
|
||||||
|
|
||||||
|
[node name="Bottom_left_panel" type="Control" parent="GUI"]
|
||||||
|
anchor_top = 0.924074
|
||||||
|
anchor_right = 0.233333
|
||||||
|
anchor_bottom = 1.0
|
||||||
|
__meta__ = {
|
||||||
|
"_edit_use_anchors_": true
|
||||||
|
}
|
||||||
|
|
||||||
|
[node name="VBoxContainer" type="VBoxContainer" parent="GUI/Bottom_left_panel"]
|
||||||
|
anchor_right = 1.0
|
||||||
|
anchor_bottom = 1.0
|
||||||
|
size_flags_horizontal = 3
|
||||||
|
size_flags_vertical = 3
|
||||||
|
__meta__ = {
|
||||||
|
"_edit_use_anchors_": false
|
||||||
|
}
|
||||||
|
|
||||||
|
[node name="Next_turn_button" type="Button" parent="GUI/Bottom_left_panel/VBoxContainer"]
|
||||||
|
visible = false
|
||||||
|
margin_right = 447.0
|
||||||
|
margin_bottom = 39.0
|
||||||
|
size_flags_horizontal = 3
|
||||||
|
size_flags_vertical = 3
|
||||||
|
disabled = true
|
||||||
|
text = "Next turn"
|
||||||
|
__meta__ = {
|
||||||
|
"_edit_use_anchors_": false
|
||||||
|
}
|
||||||
|
|
||||||
|
[node name="HBoxContainer" type="HBoxContainer" parent="GUI/Bottom_left_panel/VBoxContainer"]
|
||||||
|
margin_right = 447.0
|
||||||
|
margin_bottom = 82.0
|
||||||
|
size_flags_horizontal = 3
|
||||||
|
size_flags_vertical = 3
|
||||||
|
|
||||||
|
[node name="Turn_label" type="Label" parent="GUI/Bottom_left_panel/VBoxContainer/HBoxContainer"]
|
||||||
|
margin_right = 221.0
|
||||||
|
margin_bottom = 82.0
|
||||||
|
size_flags_horizontal = 3
|
||||||
|
size_flags_vertical = 7
|
||||||
|
text = "Turn:"
|
||||||
|
align = 2
|
||||||
|
valign = 1
|
||||||
|
|
||||||
|
[node name="Turn_indicator" type="Label" parent="GUI/Bottom_left_panel/VBoxContainer/HBoxContainer"]
|
||||||
|
margin_left = 225.0
|
||||||
|
margin_right = 447.0
|
||||||
|
margin_bottom = 82.0
|
||||||
|
size_flags_horizontal = 3
|
||||||
|
size_flags_vertical = 3
|
||||||
|
text = "1"
|
||||||
|
valign = 1
|
||||||
|
|
||||||
|
[node name="Menu_panel" type="Control" parent="."]
|
||||||
|
visible = false
|
||||||
|
anchor_left = 0.5
|
||||||
|
anchor_top = 0.5
|
||||||
|
anchor_right = 0.5
|
||||||
|
anchor_bottom = 0.5
|
||||||
|
margin_left = -382.5
|
||||||
|
margin_top = -186.0
|
||||||
|
margin_right = 382.5
|
||||||
|
margin_bottom = 186.0
|
||||||
|
__meta__ = {
|
||||||
|
"_edit_use_anchors_": false
|
||||||
|
}
|
||||||
|
|
||||||
|
[node name="Background" type="ColorRect" parent="Menu_panel"]
|
||||||
|
anchor_right = 1.0
|
||||||
|
anchor_bottom = 1.0
|
||||||
|
color = Color( 0.235294, 0.219608, 0.301961, 1 )
|
||||||
|
__meta__ = {
|
||||||
|
"_edit_use_anchors_": false
|
||||||
|
}
|
||||||
|
|
||||||
|
[node name="Surrender_button" type="Button" parent="Menu_panel"]
|
||||||
|
anchor_left = 0.5
|
||||||
|
anchor_top = 0.5
|
||||||
|
anchor_right = 0.5
|
||||||
|
anchor_bottom = 0.5
|
||||||
|
margin_left = -112.5
|
||||||
|
margin_top = -77.5851
|
||||||
|
margin_right = 112.5
|
||||||
|
margin_bottom = -23.5851
|
||||||
|
text = "Surrender"
|
||||||
|
__meta__ = {
|
||||||
|
"_edit_use_anchors_": false
|
||||||
|
}
|
||||||
|
|
||||||
|
[node name="Close" type="Button" parent="Menu_panel"]
|
||||||
|
anchor_left = 0.5
|
||||||
|
anchor_top = 0.5
|
||||||
|
anchor_right = 0.5
|
||||||
|
anchor_bottom = 0.5
|
||||||
|
margin_left = -112.5
|
||||||
|
margin_top = 35.5883
|
||||||
|
margin_right = 112.5
|
||||||
|
margin_bottom = 89.5883
|
||||||
|
text = "Close"
|
||||||
|
__meta__ = {
|
||||||
|
"_edit_use_anchors_": false
|
||||||
|
}
|
||||||
|
|
||||||
|
[node name="Camera_base" type="Spatial" parent="."]
|
||||||
|
script = ExtResource( 2 )
|
||||||
|
|
||||||
|
[node name="Camera" type="Camera" parent="Camera_base"]
|
||||||
|
transform = Transform( 1, 0, 0, 0, 0.422618, 0.906308, 0, -0.906308, 0.422618, 12, 12, 12 )
|
||||||
|
|
||||||
|
[node name="Mouse_controller" type="Spatial" parent="."]
|
||||||
|
script = ExtResource( 4 )
|
||||||
|
[connection signal="tree_exited" from="." to="." method="_on_Game_manager_tree_exited"]
|
||||||
|
[connection signal="pressed" from="End_game_panel/Back_to_lobby_button" to="." method="_on_Back_to_lobby_button_pressed"]
|
||||||
|
[connection signal="pressed" from="GUI/Bottom_left_panel/VBoxContainer/Next_turn_button" to="." method="_on_Next_turn_button_pressed"]
|
||||||
|
[connection signal="pressed" from="Menu_panel/Surrender_button" to="." method="_on_Surrender_button_pressed"]
|
||||||
|
[connection signal="pressed" from="Menu_panel/Close" to="." method="_on_Close_pressed"]
|
94
Client/Scenes/Matchmaking/Game/Map/Hex.gd
Normal file
94
Client/Scenes/Matchmaking/Game/Map/Hex.gd
Normal file
@ -0,0 +1,94 @@
|
|||||||
|
extends Spatial
|
||||||
|
|
||||||
|
var _is_free
|
||||||
|
var _x
|
||||||
|
var _y
|
||||||
|
|
||||||
|
var _neighbours
|
||||||
|
|
||||||
|
var _map
|
||||||
|
|
||||||
|
func _ready():
|
||||||
|
_is_free = true
|
||||||
|
_map = get_node("/root/Game_manager/Map")
|
||||||
|
|
||||||
|
func set_coordinates(x, y):
|
||||||
|
_x = x
|
||||||
|
_y = y
|
||||||
|
|
||||||
|
func _on_Area_input_event(camera, event, click_position, click_normal, shape_idx):
|
||||||
|
if event is InputEventMouseButton:
|
||||||
|
if event.button_index == BUTTON_LEFT and event.pressed:
|
||||||
|
get_node("/root/Game_manager/Mouse_controller").left_click_on_hex(self)
|
||||||
|
|
||||||
|
if event.button_index == BUTTON_RIGHT and event.pressed:
|
||||||
|
get_node("/root/Game_manager/Mouse_controller").right_click_on_hex(self)
|
||||||
|
|
||||||
|
func set_color(color_id):
|
||||||
|
# TODO: make color better?
|
||||||
|
var material = SpatialMaterial.new()
|
||||||
|
material.albedo_color = Color(1, 0, 1)
|
||||||
|
$Cylinder.set_surface_material(0, material)
|
||||||
|
|
||||||
|
func occupy_hex():
|
||||||
|
_is_free = false
|
||||||
|
|
||||||
|
func is_free():
|
||||||
|
return _is_free
|
||||||
|
|
||||||
|
func is_any_neighbour_free():
|
||||||
|
var is_free = false
|
||||||
|
for neighbour in get_neighbours():
|
||||||
|
if neighbour.is_free():
|
||||||
|
is_free = true
|
||||||
|
continue
|
||||||
|
return is_free
|
||||||
|
|
||||||
|
func get_neighbours():
|
||||||
|
if _neighbours == null:
|
||||||
|
_neighbours = []
|
||||||
|
|
||||||
|
# left neighbour
|
||||||
|
if _x > 0:
|
||||||
|
_neighbours.append(_map.get_hex_at(_x - 1, _y))
|
||||||
|
|
||||||
|
# odd-row, starting below
|
||||||
|
##########
|
||||||
|
if _y % 2 == 0:
|
||||||
|
# top left neighbour if(y%2)
|
||||||
|
if _x > 0 && _y < _map._map_height - 1:
|
||||||
|
_neighbours.append(_map.get_hex_at(_x - 1, _y + 1))
|
||||||
|
|
||||||
|
# top right neighbour if(y%2)
|
||||||
|
if _y < _map._map_height - 1:
|
||||||
|
_neighbours.append(_map.get_hex_at(_x, _y + 1))
|
||||||
|
|
||||||
|
# bottom right neighbour if(y%2)
|
||||||
|
if _y > 0:
|
||||||
|
_neighbours.append(_map.get_hex_at(_x, _y - 1));
|
||||||
|
# bottom left neighbour if(y%2)
|
||||||
|
if _x > 0 && _y > 0:
|
||||||
|
_neighbours.append(_map.get_hex_at(_x - 1, _y - 1));
|
||||||
|
##########
|
||||||
|
else:
|
||||||
|
# top left neighbour
|
||||||
|
if _y < _map._map_height - 1:
|
||||||
|
_neighbours.append(_map.get_hex_at(_x, _y + 1));
|
||||||
|
|
||||||
|
# top right neighbour
|
||||||
|
if _x < _map._map_width - 1 && _y < _map._map_height - 1:
|
||||||
|
_neighbours.append(_map.get_hex_at(_x + 1, _y + 1))
|
||||||
|
# bottom right neighbour
|
||||||
|
if _x < _map._map_width - 1 && _y > 0:
|
||||||
|
_neighbours.append(_map.get_hex_at(_x + 1, _y - 1))
|
||||||
|
|
||||||
|
# bottom left neighbour
|
||||||
|
if _y > 0:
|
||||||
|
_neighbours.append(_map.get_hex_at(_x, _y - 1))
|
||||||
|
|
||||||
|
##########
|
||||||
|
## right neighbour
|
||||||
|
if _x < _map._map_width - 1:
|
||||||
|
_neighbours.append(_map.get_hex_at(_x + 1, _y))
|
||||||
|
|
||||||
|
return _neighbours
|
22
Client/Scenes/Matchmaking/Game/Map/Hex.tscn
Normal file
22
Client/Scenes/Matchmaking/Game/Map/Hex.tscn
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
[gd_scene load_steps=5 format=2]
|
||||||
|
|
||||||
|
[ext_resource path="res://Material/hex.dae" type="PackedScene" id=1]
|
||||||
|
[ext_resource path="res://Scenes/Matchmaking/Game/Map/Hex.gd" type="Script" id=2]
|
||||||
|
|
||||||
|
[sub_resource type="SpatialMaterial" id=1]
|
||||||
|
albedo_color = Color( 0, 0.27451, 1, 1 )
|
||||||
|
|
||||||
|
[sub_resource type="CylinderShape" id=2]
|
||||||
|
radius = 0.986306
|
||||||
|
|
||||||
|
[node name="Hex" instance=ExtResource( 1 )]
|
||||||
|
script = ExtResource( 2 )
|
||||||
|
|
||||||
|
[node name="Cylinder" parent="." index="0"]
|
||||||
|
material/0 = SubResource( 1 )
|
||||||
|
|
||||||
|
[node name="Area" type="Area" parent="Cylinder" index="0"]
|
||||||
|
|
||||||
|
[node name="CollisionShape" type="CollisionShape" parent="Cylinder/Area" index="0"]
|
||||||
|
shape = SubResource( 2 )
|
||||||
|
[connection signal="input_event" from="Cylinder/Area" to="." method="_on_Area_input_event"]
|
49
Client/Scenes/Matchmaking/Game/Map/Map.gd
Normal file
49
Client/Scenes/Matchmaking/Game/Map/Map.gd
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
extends Spatial
|
||||||
|
|
||||||
|
export var _map_width = 12
|
||||||
|
export var _map_height = 8
|
||||||
|
|
||||||
|
var _width_offset = 2.0
|
||||||
|
var _height_offset = 2.0 * 0.75
|
||||||
|
var gap = 0.1
|
||||||
|
|
||||||
|
var _hexes = []
|
||||||
|
|
||||||
|
func _ready():
|
||||||
|
add_gap_between_hexes()
|
||||||
|
generate_map()
|
||||||
|
|
||||||
|
func calculate_world_position(grid_position):
|
||||||
|
var offset = 0
|
||||||
|
|
||||||
|
if int(grid_position.y) % 2 != 0:
|
||||||
|
offset = _width_offset / 2
|
||||||
|
|
||||||
|
var x = grid_position.x * _width_offset + offset
|
||||||
|
var z = grid_position.y * _height_offset
|
||||||
|
|
||||||
|
return Vector3(x, 0, z)
|
||||||
|
|
||||||
|
func add_gap_between_hexes():
|
||||||
|
_width_offset += _width_offset * gap
|
||||||
|
_height_offset += _height_offset * gap
|
||||||
|
|
||||||
|
func generate_map():
|
||||||
|
for x in range(0, _map_width):
|
||||||
|
_hexes.append([])
|
||||||
|
_hexes[x].resize(_map_height)
|
||||||
|
|
||||||
|
for y in range(0, _map_height):
|
||||||
|
var hex_node = load("res://Scenes/Matchmaking/Game/Map/Hex.tscn").instance()
|
||||||
|
hex_node.set_coordinates(x, y)
|
||||||
|
|
||||||
|
var position = (calculate_world_position(Vector2(x,y)))
|
||||||
|
|
||||||
|
hex_node.name = "hex_%d_%d" % [x, y]
|
||||||
|
hex_node.translation = position
|
||||||
|
|
||||||
|
add_child(hex_node)
|
||||||
|
_hexes[x][y] = hex_node
|
||||||
|
|
||||||
|
func get_hex_at(x, y):
|
||||||
|
return _hexes[x][y]
|
6
Client/Scenes/Matchmaking/Game/Map/Map.tscn
Normal file
6
Client/Scenes/Matchmaking/Game/Map/Map.tscn
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
[gd_scene load_steps=2 format=2]
|
||||||
|
|
||||||
|
[ext_resource path="res://Scenes/Matchmaking/Game/Map/Map.gd" type="Script" id=1]
|
||||||
|
|
||||||
|
[node name="Map" type="Spatial"]
|
||||||
|
script = ExtResource( 1 )
|
@ -0,0 +1,25 @@
|
|||||||
|
extends Spatial
|
||||||
|
|
||||||
|
var _game_manager
|
||||||
|
|
||||||
|
func _ready():
|
||||||
|
_game_manager = get_node("/root/Game_manager")
|
||||||
|
|
||||||
|
func left_click_on_hex(hex_node):
|
||||||
|
if _game_manager.is_my_turn():
|
||||||
|
|
||||||
|
if _game_manager.ability_left():
|
||||||
|
|
||||||
|
if hex_node.is_free():
|
||||||
|
|
||||||
|
if _game_manager.get_previous_hex() != null:
|
||||||
|
print("try to occupy")
|
||||||
|
|
||||||
|
if hex_node in _game_manager.get_previous_hex().get_neighbours():
|
||||||
|
print("Yea")
|
||||||
|
_game_manager.try_to_occupy_hex(hex_node)
|
||||||
|
else:
|
||||||
|
_game_manager.try_to_occupy_hex(hex_node)
|
||||||
|
|
||||||
|
func right_click_on_hex(hex_node):
|
||||||
|
print("Right click")
|
66
Client/Scenes/Matchmaking/Game_room/Game_room.gd
Normal file
66
Client/Scenes/Matchmaking/Game_room/Game_room.gd
Normal file
@ -0,0 +1,66 @@
|
|||||||
|
extends Control
|
||||||
|
|
||||||
|
func _ready():
|
||||||
|
for player_id in NetworkingSync._open_games[Player.get_game_id()][3]:
|
||||||
|
if player_id != Player.get_player_id():
|
||||||
|
rpc_id(player_id, "update_game_room_player_list")
|
||||||
|
|
||||||
|
update_game_room_player_list()
|
||||||
|
|
||||||
|
remote func update_game_room_player_list():
|
||||||
|
NetworkingSync.send_open_games_request_to_server()
|
||||||
|
yield(NetworkingSync, "updated_games")
|
||||||
|
|
||||||
|
for child in $Player_list/ScrollContainer/Player_list_container.get_children():
|
||||||
|
child.queue_free()
|
||||||
|
|
||||||
|
NetworkingSync._player_in_same_game_room_list = []
|
||||||
|
|
||||||
|
for player_id in NetworkingSync._open_games[Player.get_game_id()][3]:
|
||||||
|
add_player_entry_to_list(player_id)
|
||||||
|
|
||||||
|
func add_player_entry_to_list(player_id):
|
||||||
|
var player = load("res://Scenes/Matchmaking/Game_room/Player_entry.tscn").instance()
|
||||||
|
var player_name = str(NetworkingSync._open_games[Player.get_game_id()][3][player_id][0])
|
||||||
|
player.set_player_name(player_name)
|
||||||
|
$Player_list/ScrollContainer/Player_list_container.add_child(player)
|
||||||
|
var player_info = [player_id, player_name]
|
||||||
|
NetworkingSync._player_in_same_game_room_list.append(player_info)
|
||||||
|
|
||||||
|
func _on_Game_room_tree_entered():
|
||||||
|
if Player._is_host:
|
||||||
|
$Start_button.show()
|
||||||
|
$Ready_button.hide()
|
||||||
|
else:
|
||||||
|
$Start_button.hide()
|
||||||
|
$Ready_button.hide() # TODO: change this to .show(), if ready-feature is implemented.
|
||||||
|
|
||||||
|
func _on_Start_button_pressed():
|
||||||
|
NetworkingSync._players_ready = []
|
||||||
|
NetworkingSync.close_game()
|
||||||
|
|
||||||
|
if len(NetworkingSync._player_in_same_game_room_list) >= 2:
|
||||||
|
for player_id in NetworkingSync._player_in_same_game_room_list:
|
||||||
|
if player_id[0] != Player.get_player_id():
|
||||||
|
rpc_id(player_id[0], "start_game")
|
||||||
|
start_game()
|
||||||
|
rpc_id(1, "remove_game_from_game_list", Player.get_game_id())
|
||||||
|
|
||||||
|
remote func start_game():
|
||||||
|
get_tree().change_scene("res://Scenes/Matchmaking/Game/Game_manager.tscn")
|
||||||
|
|
||||||
|
func _on_Leave_button_pressed():
|
||||||
|
if Player.is_host():
|
||||||
|
#TODO: kick everyone out of the game
|
||||||
|
NetworkingSync.close_game()
|
||||||
|
|
||||||
|
else:
|
||||||
|
NetworkingSync.left_game()
|
||||||
|
yield(NetworkingSync, "updated_games")
|
||||||
|
for player in NetworkingSync._open_games[Player.get_game_id()][3]:
|
||||||
|
print(player)
|
||||||
|
if player != Player.get_player_id():
|
||||||
|
rpc_id(player, "update_game_room_player_list")
|
||||||
|
|
||||||
|
Player.set_game_id(0)
|
||||||
|
get_tree().change_scene("res://Scenes/Matchmaking/Lobby/Lobby.tscn")
|
88
Client/Scenes/Matchmaking/Game_room/Game_room.tscn
Normal file
88
Client/Scenes/Matchmaking/Game_room/Game_room.tscn
Normal file
@ -0,0 +1,88 @@
|
|||||||
|
[gd_scene load_steps=3 format=2]
|
||||||
|
|
||||||
|
[ext_resource path="res://icon.png" type="Texture" id=1]
|
||||||
|
[ext_resource path="res://Scenes/Matchmaking/Game_room/Game_room.gd" type="Script" id=2]
|
||||||
|
|
||||||
|
[node name="Game_room" type="Control"]
|
||||||
|
anchor_right = 1.0
|
||||||
|
anchor_bottom = 1.0
|
||||||
|
script = ExtResource( 2 )
|
||||||
|
__meta__ = {
|
||||||
|
"_edit_use_anchors_": false
|
||||||
|
}
|
||||||
|
|
||||||
|
[node name="Background" type="TextureRect" parent="."]
|
||||||
|
anchor_right = 1.0
|
||||||
|
anchor_bottom = 1.0
|
||||||
|
texture = ExtResource( 1 )
|
||||||
|
expand = true
|
||||||
|
stretch_mode = 2
|
||||||
|
__meta__ = {
|
||||||
|
"_edit_use_anchors_": false
|
||||||
|
}
|
||||||
|
|
||||||
|
[node name="Start_button" type="Button" parent="."]
|
||||||
|
margin_left = 185.965
|
||||||
|
margin_top = 324.728
|
||||||
|
margin_right = 522.965
|
||||||
|
margin_bottom = 502.728
|
||||||
|
text = "Start"
|
||||||
|
__meta__ = {
|
||||||
|
"_edit_use_anchors_": false
|
||||||
|
}
|
||||||
|
|
||||||
|
[node name="Ready_button" type="Button" parent="."]
|
||||||
|
visible = false
|
||||||
|
margin_left = 185.965
|
||||||
|
margin_top = 324.728
|
||||||
|
margin_right = 522.965
|
||||||
|
margin_bottom = 502.728
|
||||||
|
text = "Ready"
|
||||||
|
__meta__ = {
|
||||||
|
"_edit_use_anchors_": false
|
||||||
|
}
|
||||||
|
|
||||||
|
[node name="Leave_button" type="Button" parent="."]
|
||||||
|
margin_left = 179.497
|
||||||
|
margin_top = 615.335
|
||||||
|
margin_right = 526.497
|
||||||
|
margin_bottom = 810.335
|
||||||
|
text = "Leave"
|
||||||
|
__meta__ = {
|
||||||
|
"_edit_use_anchors_": false
|
||||||
|
}
|
||||||
|
|
||||||
|
[node name="Player_list" type="Control" parent="."]
|
||||||
|
anchor_left = 0.314583
|
||||||
|
anchor_top = 0.266667
|
||||||
|
anchor_right = 0.939583
|
||||||
|
anchor_bottom = 0.822222
|
||||||
|
margin_left = -3.99939
|
||||||
|
margin_top = 1.99963
|
||||||
|
margin_right = -3.99939
|
||||||
|
margin_bottom = 2.00024
|
||||||
|
__meta__ = {
|
||||||
|
"_edit_use_anchors_": true
|
||||||
|
}
|
||||||
|
|
||||||
|
[node name="ColorRect" type="ColorRect" parent="Player_list"]
|
||||||
|
anchor_right = 1.0
|
||||||
|
anchor_bottom = 1.0
|
||||||
|
color = Color( 0.282353, 0.0235294, 0.0235294, 0.823529 )
|
||||||
|
__meta__ = {
|
||||||
|
"_edit_use_anchors_": false
|
||||||
|
}
|
||||||
|
|
||||||
|
[node name="ScrollContainer" type="ScrollContainer" parent="Player_list"]
|
||||||
|
anchor_right = 1.0
|
||||||
|
anchor_bottom = 1.0
|
||||||
|
__meta__ = {
|
||||||
|
"_edit_use_anchors_": false
|
||||||
|
}
|
||||||
|
|
||||||
|
[node name="Player_list_container" type="VBoxContainer" parent="Player_list/ScrollContainer"]
|
||||||
|
margin_right = 1200.0
|
||||||
|
size_flags_horizontal = 3
|
||||||
|
[connection signal="tree_entered" from="." to="." method="_on_Game_room_tree_entered"]
|
||||||
|
[connection signal="pressed" from="Start_button" to="." method="_on_Start_button_pressed"]
|
||||||
|
[connection signal="pressed" from="Leave_button" to="." method="_on_Leave_button_pressed"]
|
4
Client/Scenes/Matchmaking/Game_room/Player_entry.gd
Normal file
4
Client/Scenes/Matchmaking/Game_room/Player_entry.gd
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
extends HBoxContainer
|
||||||
|
|
||||||
|
func set_player_name(player_name):
|
||||||
|
$Player_name_label.text = player_name
|
19
Client/Scenes/Matchmaking/Game_room/Player_entry.tscn
Normal file
19
Client/Scenes/Matchmaking/Game_room/Player_entry.tscn
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
[gd_scene load_steps=2 format=2]
|
||||||
|
|
||||||
|
[ext_resource path="res://Scenes/Matchmaking/Game_room/Player_entry.gd" type="Script" id=1]
|
||||||
|
|
||||||
|
[node name="Player_entry" type="HBoxContainer"]
|
||||||
|
margin_right = 800.0
|
||||||
|
margin_bottom = 40.0
|
||||||
|
script = ExtResource( 1 )
|
||||||
|
__meta__ = {
|
||||||
|
"_edit_use_anchors_": false
|
||||||
|
}
|
||||||
|
|
||||||
|
[node name="Player_name_label" type="Label" parent="."]
|
||||||
|
margin_right = 800.0
|
||||||
|
margin_bottom = 40.0
|
||||||
|
size_flags_horizontal = 3
|
||||||
|
size_flags_vertical = 3
|
||||||
|
text = "Player 1"
|
||||||
|
valign = 1
|
33
Client/Scenes/Matchmaking/Lobby/Game_information.gd
Normal file
33
Client/Scenes/Matchmaking/Lobby/Game_information.gd
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
extends Node
|
||||||
|
|
||||||
|
var _game_id
|
||||||
|
var _game_name
|
||||||
|
var _max_players
|
||||||
|
var _player_list
|
||||||
|
|
||||||
|
func _init(game_id, game_name, max_players):
|
||||||
|
_game_id = game_id
|
||||||
|
_game_name = game_name
|
||||||
|
_max_players = max_players
|
||||||
|
_player_list = {}
|
||||||
|
|
||||||
|
func get_parsable_game_information():
|
||||||
|
return [_game_id, _game_name, _max_players, _player_list]
|
||||||
|
|
||||||
|
func add_player_to_game(player):
|
||||||
|
_player_list.append(player)
|
||||||
|
|
||||||
|
func remove_player_from_game():
|
||||||
|
pass
|
||||||
|
|
||||||
|
func set_game_id(game_id):
|
||||||
|
_game_id = game_id
|
||||||
|
|
||||||
|
func set_game_name(game_name):
|
||||||
|
_game_name = game_name
|
||||||
|
|
||||||
|
func set_max_players(max_players):
|
||||||
|
_max_players = max_players
|
||||||
|
|
||||||
|
func is_full():
|
||||||
|
return _max_players <= len(_player_list)
|
28
Client/Scenes/Matchmaking/Lobby/Games_entry.gd
Normal file
28
Client/Scenes/Matchmaking/Lobby/Games_entry.gd
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
extends Button
|
||||||
|
|
||||||
|
var _game_name
|
||||||
|
var _max_players
|
||||||
|
var _game_id
|
||||||
|
|
||||||
|
func set_game_id(game_id):
|
||||||
|
_game_id = game_id
|
||||||
|
|
||||||
|
func set_game_name(game_name):
|
||||||
|
_game_name = game_name
|
||||||
|
|
||||||
|
func set_max_players(max_players):
|
||||||
|
_max_players = max_players
|
||||||
|
|
||||||
|
func update_gui():
|
||||||
|
$HBoxContainer/Game_name.text = _game_name
|
||||||
|
$HBoxContainer/Number_of_player.text = str(len(NetworkingSync._open_games[_game_id][3])) + "/" + str(_max_players)
|
||||||
|
|
||||||
|
func _on_Games_entry_pressed():
|
||||||
|
NetworkingSync.send_open_games_request_to_server()
|
||||||
|
yield(NetworkingSync, "updated_games")
|
||||||
|
if _game_id in NetworkingSync._open_games and !is_full():
|
||||||
|
NetworkingSync.join_game(_game_id)
|
||||||
|
|
||||||
|
func is_full():
|
||||||
|
var number_of_players = len(NetworkingSync._open_games[_game_id][3])
|
||||||
|
return number_of_players >= _max_players
|
36
Client/Scenes/Matchmaking/Lobby/Games_entry.tscn
Normal file
36
Client/Scenes/Matchmaking/Lobby/Games_entry.tscn
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
[gd_scene load_steps=2 format=2]
|
||||||
|
|
||||||
|
[ext_resource path="res://Scenes/Matchmaking/Lobby/Games_entry.gd" type="Script" id=1]
|
||||||
|
|
||||||
|
[node name="Games_entry" type="Button"]
|
||||||
|
margin_right = 661.0
|
||||||
|
margin_bottom = 77.0
|
||||||
|
script = ExtResource( 1 )
|
||||||
|
__meta__ = {
|
||||||
|
"_edit_use_anchors_": false
|
||||||
|
}
|
||||||
|
|
||||||
|
[node name="HBoxContainer" type="HBoxContainer" parent="."]
|
||||||
|
anchor_right = 1.0
|
||||||
|
anchor_bottom = 1.0
|
||||||
|
__meta__ = {
|
||||||
|
"_edit_use_anchors_": false
|
||||||
|
}
|
||||||
|
|
||||||
|
[node name="Game_name" type="Label" parent="HBoxContainer"]
|
||||||
|
margin_right = 80.0
|
||||||
|
margin_bottom = 77.0
|
||||||
|
size_flags_vertical = 1
|
||||||
|
text = "Game_name"
|
||||||
|
valign = 1
|
||||||
|
|
||||||
|
[node name="Number_of_player" type="Label" parent="HBoxContainer"]
|
||||||
|
margin_left = 84.0
|
||||||
|
margin_right = 661.0
|
||||||
|
margin_bottom = 77.0
|
||||||
|
size_flags_horizontal = 3
|
||||||
|
size_flags_vertical = 3
|
||||||
|
text = "2/2"
|
||||||
|
align = 2
|
||||||
|
valign = 1
|
||||||
|
[connection signal="pressed" from="." to="." method="_on_Games_entry_pressed"]
|
80
Client/Scenes/Matchmaking/Lobby/Lobby.gd
Normal file
80
Client/Scenes/Matchmaking/Lobby/Lobby.gd
Normal file
@ -0,0 +1,80 @@
|
|||||||
|
extends Control
|
||||||
|
|
||||||
|
const MIN_PLAYERS = 2
|
||||||
|
const MAX_PLAYERS = 8
|
||||||
|
const MIN_GAME_NAME_LENGTH = 1
|
||||||
|
const MAX_GAME_NAME_LENGTH = 20
|
||||||
|
|
||||||
|
func _on_Refresh_button_pressed():
|
||||||
|
refresh_game_list()
|
||||||
|
|
||||||
|
func refresh_game_list():
|
||||||
|
NetworkingSync.send_open_games_request_to_server()
|
||||||
|
yield(NetworkingSync, "updated_games")
|
||||||
|
for child in $Lobby/Games_list/Open_games/VBoxContainer.get_children():
|
||||||
|
child.queue_free()
|
||||||
|
|
||||||
|
for game in NetworkingSync.get_open_games().values():
|
||||||
|
add_entry_to_lobby(game[0], game[1], game[2])
|
||||||
|
|
||||||
|
func add_entry_to_lobby(game_id, game_name, max_players):
|
||||||
|
var new_game = load("res://Scenes/Matchmaking/Lobby/Games_entry.tscn").instance()
|
||||||
|
new_game.set_game_id(game_id)
|
||||||
|
new_game.set_game_name(game_name)
|
||||||
|
new_game.set_max_players(max_players)
|
||||||
|
new_game.name = "Game_entry_" + game_name
|
||||||
|
new_game.update_gui()
|
||||||
|
$Lobby/Games_list/Open_games/VBoxContainer.add_child(new_game)
|
||||||
|
|
||||||
|
func _on_Create_game_button_pressed():
|
||||||
|
$Lobby.hide()
|
||||||
|
$Lobby_game_creation_panel.show()
|
||||||
|
|
||||||
|
func _on_Ok_button_pressed():
|
||||||
|
create_game_room()
|
||||||
|
|
||||||
|
func _on_Cancel_button_pressed():
|
||||||
|
$Lobby_game_creation_panel.hide()
|
||||||
|
$Lobby.show()
|
||||||
|
|
||||||
|
func _on_Exit_button_pressed():
|
||||||
|
get_tree().change_scene("res://Scenes/Matchmaking/Menu/Menu.tscn")
|
||||||
|
|
||||||
|
func _on_Lobby_controller_tree_entered():
|
||||||
|
refresh_game_list()
|
||||||
|
|
||||||
|
func _on_Game_name_line_edit_text_changed(new_text):
|
||||||
|
check_input_fields()
|
||||||
|
|
||||||
|
func _on_Number_of_players_line_edit_text_changed(new_text):
|
||||||
|
check_input_fields()
|
||||||
|
|
||||||
|
func is_number_of_players_text_field_ok():
|
||||||
|
var result = false
|
||||||
|
var text_field = $Lobby_game_creation_panel/HBoxContainer2/Number_of_players_line_edit.text
|
||||||
|
if int(text_field) >= MIN_PLAYERS and int(text_field) <= MAX_PLAYERS:
|
||||||
|
result = true
|
||||||
|
return result
|
||||||
|
|
||||||
|
func is_game_name_text_field_ok():
|
||||||
|
var result = false
|
||||||
|
var text_field = $Lobby_game_creation_panel/HBoxContainer/Game_name_line_edit.text
|
||||||
|
if len(text_field) <= MAX_GAME_NAME_LENGTH and len(text_field) >= MIN_GAME_NAME_LENGTH:
|
||||||
|
result = true
|
||||||
|
return result
|
||||||
|
|
||||||
|
func check_input_fields():
|
||||||
|
if is_number_of_players_text_field_ok() and is_game_name_text_field_ok():
|
||||||
|
$Lobby_game_creation_panel/Ok_button.disabled = false
|
||||||
|
else:
|
||||||
|
$Lobby_game_creation_panel/Ok_button.disabled = true
|
||||||
|
|
||||||
|
func _input(ev):
|
||||||
|
if Input.is_key_pressed(KEY_ENTER) and not $Lobby_game_creation_panel/Ok_button.disabled:
|
||||||
|
create_game_room()
|
||||||
|
|
||||||
|
func create_game_room():
|
||||||
|
var game_name = $Lobby_game_creation_panel/HBoxContainer/Game_name_line_edit.text
|
||||||
|
var max_players = int($Lobby_game_creation_panel/HBoxContainer2/Number_of_players_line_edit.text)
|
||||||
|
var game_id = get_tree().get_network_unique_id()
|
||||||
|
NetworkingSync.create_game([game_id, game_name, max_players, {}], Player)
|
221
Client/Scenes/Matchmaking/Lobby/Lobby.tscn
Normal file
221
Client/Scenes/Matchmaking/Lobby/Lobby.tscn
Normal file
@ -0,0 +1,221 @@
|
|||||||
|
[gd_scene load_steps=3 format=2]
|
||||||
|
|
||||||
|
[ext_resource path="res://Scenes/Matchmaking/Lobby/Lobby.gd" type="Script" id=1]
|
||||||
|
[ext_resource path="res://icon.png" type="Texture" id=2]
|
||||||
|
|
||||||
|
[node name="Lobby_controller" type="Control"]
|
||||||
|
anchor_right = 1.0
|
||||||
|
anchor_bottom = 1.0
|
||||||
|
script = ExtResource( 1 )
|
||||||
|
__meta__ = {
|
||||||
|
"_edit_use_anchors_": false
|
||||||
|
}
|
||||||
|
|
||||||
|
[node name="Lobby_background" type="TextureRect" parent="."]
|
||||||
|
anchor_right = 1.0
|
||||||
|
anchor_bottom = 1.0
|
||||||
|
texture = ExtResource( 2 )
|
||||||
|
stretch_mode = 2
|
||||||
|
__meta__ = {
|
||||||
|
"_edit_use_anchors_": false
|
||||||
|
}
|
||||||
|
|
||||||
|
[node name="Lobby" type="Control" parent="."]
|
||||||
|
anchor_right = 1.0
|
||||||
|
anchor_bottom = 1.0
|
||||||
|
__meta__ = {
|
||||||
|
"_edit_use_anchors_": false
|
||||||
|
}
|
||||||
|
|
||||||
|
[node name="Games_list" type="Control" parent="Lobby"]
|
||||||
|
anchor_left = 0.31283
|
||||||
|
anchor_top = 0.147956
|
||||||
|
anchor_right = 0.965434
|
||||||
|
anchor_bottom = 0.834067
|
||||||
|
__meta__ = {
|
||||||
|
"_edit_use_anchors_": true
|
||||||
|
}
|
||||||
|
|
||||||
|
[node name="Background" type="ColorRect" parent="Lobby/Games_list"]
|
||||||
|
anchor_right = 1.0
|
||||||
|
anchor_bottom = 1.0
|
||||||
|
color = Color( 0.196078, 0.254902, 0.352941, 0.843137 )
|
||||||
|
__meta__ = {
|
||||||
|
"_edit_use_anchors_": false
|
||||||
|
}
|
||||||
|
|
||||||
|
[node name="Open_games" type="ScrollContainer" parent="Lobby/Games_list"]
|
||||||
|
anchor_right = 1.0
|
||||||
|
anchor_bottom = 1.0
|
||||||
|
__meta__ = {
|
||||||
|
"_edit_use_anchors_": false
|
||||||
|
}
|
||||||
|
|
||||||
|
[node name="VBoxContainer" type="VBoxContainer" parent="Lobby/Games_list/Open_games"]
|
||||||
|
margin_right = 1253.0
|
||||||
|
size_flags_horizontal = 3
|
||||||
|
|
||||||
|
[node name="Lobby_buttons" type="Control" parent="Lobby"]
|
||||||
|
anchor_left = 0.0234375
|
||||||
|
anchor_top = 0.407407
|
||||||
|
anchor_right = 0.283854
|
||||||
|
anchor_bottom = 0.796296
|
||||||
|
__meta__ = {
|
||||||
|
"_edit_use_anchors_": true
|
||||||
|
}
|
||||||
|
|
||||||
|
[node name="Background" type="ColorRect" parent="Lobby/Lobby_buttons"]
|
||||||
|
anchor_right = 1.0
|
||||||
|
anchor_bottom = 1.0
|
||||||
|
margin_right = -3.05176e-05
|
||||||
|
margin_bottom = -20.0
|
||||||
|
color = Color( 0.196078, 0.254902, 0.352941, 0.843137 )
|
||||||
|
__meta__ = {
|
||||||
|
"_edit_use_anchors_": true
|
||||||
|
}
|
||||||
|
|
||||||
|
[node name="Create_game_button" type="Button" parent="Lobby/Lobby_buttons"]
|
||||||
|
margin_left = 20.0
|
||||||
|
margin_top = 20.0
|
||||||
|
margin_right = 480.0
|
||||||
|
margin_bottom = 80.0
|
||||||
|
text = "Create Game"
|
||||||
|
__meta__ = {
|
||||||
|
"_edit_use_anchors_": false
|
||||||
|
}
|
||||||
|
|
||||||
|
[node name="Search_game_button" type="Button" parent="Lobby/Lobby_buttons"]
|
||||||
|
margin_left = 20.0
|
||||||
|
margin_top = 120.0
|
||||||
|
margin_right = 480.0
|
||||||
|
margin_bottom = 180.0
|
||||||
|
disabled = true
|
||||||
|
text = "Search Game"
|
||||||
|
__meta__ = {
|
||||||
|
"_edit_use_anchors_": false
|
||||||
|
}
|
||||||
|
|
||||||
|
[node name="Refresh_button" type="Button" parent="Lobby/Lobby_buttons"]
|
||||||
|
margin_left = 20.0
|
||||||
|
margin_top = 220.0
|
||||||
|
margin_right = 480.0
|
||||||
|
margin_bottom = 280.0
|
||||||
|
text = "Refresh"
|
||||||
|
__meta__ = {
|
||||||
|
"_edit_use_anchors_": false
|
||||||
|
}
|
||||||
|
|
||||||
|
[node name="Exit_button" type="Button" parent="Lobby/Lobby_buttons"]
|
||||||
|
margin_left = 20.0
|
||||||
|
margin_top = 320.0
|
||||||
|
margin_right = 480.0
|
||||||
|
margin_bottom = 380.0
|
||||||
|
text = "Exit"
|
||||||
|
__meta__ = {
|
||||||
|
"_edit_use_anchors_": false
|
||||||
|
}
|
||||||
|
|
||||||
|
[node name="Auto_refresh_timer" type="Timer" parent="Lobby"]
|
||||||
|
|
||||||
|
[node name="Lobby_game_creation_panel" type="Control" parent="."]
|
||||||
|
visible = false
|
||||||
|
anchor_left = 0.183854
|
||||||
|
anchor_top = 0.200463
|
||||||
|
anchor_right = 0.816146
|
||||||
|
anchor_bottom = 0.799537
|
||||||
|
__meta__ = {
|
||||||
|
"_edit_use_anchors_": true
|
||||||
|
}
|
||||||
|
|
||||||
|
[node name="Background" type="ColorRect" parent="Lobby_game_creation_panel"]
|
||||||
|
anchor_right = 1.0
|
||||||
|
anchor_bottom = 1.0
|
||||||
|
margin_top = 1.75809
|
||||||
|
margin_bottom = 1.75806
|
||||||
|
color = Color( 0.360784, 0.360784, 0.360784, 0.823529 )
|
||||||
|
__meta__ = {
|
||||||
|
"_edit_use_anchors_": false
|
||||||
|
}
|
||||||
|
|
||||||
|
[node name="HBoxContainer" type="HBoxContainer" parent="Lobby_game_creation_panel"]
|
||||||
|
anchor_left = 0.0881384
|
||||||
|
anchor_top = 0.0772798
|
||||||
|
anchor_right = 0.911862
|
||||||
|
anchor_bottom = 0.200927
|
||||||
|
margin_bottom = -40.0
|
||||||
|
__meta__ = {
|
||||||
|
"_edit_use_anchors_": true
|
||||||
|
}
|
||||||
|
|
||||||
|
[node name="Game_name_label" type="Label" parent="Lobby_game_creation_panel/HBoxContainer"]
|
||||||
|
margin_right = 78.0
|
||||||
|
margin_bottom = 39.0
|
||||||
|
size_flags_vertical = 3
|
||||||
|
text = "Gamename:"
|
||||||
|
valign = 1
|
||||||
|
|
||||||
|
[node name="Game_name_line_edit" type="LineEdit" parent="Lobby_game_creation_panel/HBoxContainer"]
|
||||||
|
margin_left = 82.0
|
||||||
|
margin_right = 1000.0
|
||||||
|
margin_bottom = 39.0
|
||||||
|
size_flags_horizontal = 3
|
||||||
|
|
||||||
|
[node name="HBoxContainer2" type="HBoxContainer" parent="Lobby_game_creation_panel"]
|
||||||
|
anchor_left = 0.0881384
|
||||||
|
anchor_top = 0.278207
|
||||||
|
anchor_right = 0.911862
|
||||||
|
anchor_bottom = 0.401855
|
||||||
|
margin_bottom = -40.0
|
||||||
|
__meta__ = {
|
||||||
|
"_edit_use_anchors_": true
|
||||||
|
}
|
||||||
|
|
||||||
|
[node name="Max_player_label" type="Label" parent="Lobby_game_creation_panel/HBoxContainer2"]
|
||||||
|
margin_right = 80.0
|
||||||
|
margin_bottom = 40.0
|
||||||
|
size_flags_vertical = 3
|
||||||
|
text = "Max Players:"
|
||||||
|
valign = 1
|
||||||
|
|
||||||
|
[node name="Number_of_players_line_edit" type="LineEdit" parent="Lobby_game_creation_panel/HBoxContainer2"]
|
||||||
|
margin_left = 84.0
|
||||||
|
margin_right = 1000.0
|
||||||
|
margin_bottom = 40.0
|
||||||
|
size_flags_horizontal = 3
|
||||||
|
|
||||||
|
[node name="Ok_button" type="Button" parent="Lobby_game_creation_panel"]
|
||||||
|
anchor_left = 0.5
|
||||||
|
anchor_top = 1.0
|
||||||
|
anchor_right = 0.5
|
||||||
|
anchor_bottom = 1.0
|
||||||
|
margin_left = -457.0
|
||||||
|
margin_top = -247.0
|
||||||
|
margin_right = -57.0
|
||||||
|
margin_bottom = -147.0
|
||||||
|
disabled = true
|
||||||
|
text = "Ok"
|
||||||
|
__meta__ = {
|
||||||
|
"_edit_use_anchors_": false
|
||||||
|
}
|
||||||
|
|
||||||
|
[node name="Cancel_button" type="Button" parent="Lobby_game_creation_panel"]
|
||||||
|
anchor_left = 0.5
|
||||||
|
anchor_top = 1.0
|
||||||
|
anchor_right = 0.5
|
||||||
|
anchor_bottom = 1.0
|
||||||
|
margin_left = 43.0001
|
||||||
|
margin_top = -247.0
|
||||||
|
margin_right = 443.0
|
||||||
|
margin_bottom = -147.0
|
||||||
|
text = "Cancel"
|
||||||
|
__meta__ = {
|
||||||
|
"_edit_use_anchors_": false
|
||||||
|
}
|
||||||
|
[connection signal="tree_entered" from="." to="." method="_on_Lobby_controller_tree_entered"]
|
||||||
|
[connection signal="pressed" from="Lobby/Lobby_buttons/Create_game_button" to="." method="_on_Create_game_button_pressed"]
|
||||||
|
[connection signal="pressed" from="Lobby/Lobby_buttons/Refresh_button" to="." method="_on_Refresh_button_pressed"]
|
||||||
|
[connection signal="pressed" from="Lobby/Lobby_buttons/Exit_button" to="." method="_on_Exit_button_pressed"]
|
||||||
|
[connection signal="text_changed" from="Lobby_game_creation_panel/HBoxContainer/Game_name_line_edit" to="." method="_on_Game_name_line_edit_text_changed"]
|
||||||
|
[connection signal="text_changed" from="Lobby_game_creation_panel/HBoxContainer2/Number_of_players_line_edit" to="." method="_on_Number_of_players_line_edit_text_changed"]
|
||||||
|
[connection signal="pressed" from="Lobby_game_creation_panel/Ok_button" to="." method="_on_Ok_button_pressed"]
|
||||||
|
[connection signal="pressed" from="Lobby_game_creation_panel/Cancel_button" to="." method="_on_Cancel_button_pressed"]
|
22
Client/Scenes/Matchmaking/Menu/Menu.gd
Normal file
22
Client/Scenes/Matchmaking/Menu/Menu.gd
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
extends Node
|
||||||
|
|
||||||
|
func _on_Button_pressed():
|
||||||
|
connect_to_server()
|
||||||
|
|
||||||
|
|
||||||
|
func _on_LineEdit_text_changed(new_text):
|
||||||
|
if len(new_text) <= 0 or len(new_text) >= 20:
|
||||||
|
$GUI/Start_button.disabled = true
|
||||||
|
else:
|
||||||
|
$GUI/Start_button.disabled = false
|
||||||
|
|
||||||
|
func _input(ev):
|
||||||
|
if Input.is_key_pressed(KEY_ENTER) and not $GUI/Start_button.disabled:
|
||||||
|
connect_to_server()
|
||||||
|
|
||||||
|
func connect_to_server():
|
||||||
|
Player.set_player_name($GUI/LineEdit.text)
|
||||||
|
get_tree().change_scene("res://Scenes/Matchmaking/Client/Network_connection.tscn")
|
||||||
|
|
||||||
|
func _on_Exit_button_pressed():
|
||||||
|
get_tree().quit()
|
59
Client/Scenes/Matchmaking/Menu/Menu.tscn
Normal file
59
Client/Scenes/Matchmaking/Menu/Menu.tscn
Normal file
@ -0,0 +1,59 @@
|
|||||||
|
[gd_scene load_steps=2 format=2]
|
||||||
|
|
||||||
|
[ext_resource path="res://Scenes/Matchmaking/Menu/Menu.gd" type="Script" id=1]
|
||||||
|
|
||||||
|
[node name="Menu" type="Node"]
|
||||||
|
script = ExtResource( 1 )
|
||||||
|
|
||||||
|
[node name="GUI" type="Control" parent="."]
|
||||||
|
anchor_right = 1.0
|
||||||
|
anchor_bottom = 1.0
|
||||||
|
__meta__ = {
|
||||||
|
"_edit_use_anchors_": false
|
||||||
|
}
|
||||||
|
|
||||||
|
[node name="Start_button" type="Button" parent="GUI"]
|
||||||
|
anchor_left = 0.5
|
||||||
|
anchor_top = 0.5
|
||||||
|
anchor_right = 0.5
|
||||||
|
anchor_bottom = 0.5
|
||||||
|
margin_left = -134.5
|
||||||
|
margin_top = 91.7361
|
||||||
|
margin_right = 134.5
|
||||||
|
margin_bottom = 162.736
|
||||||
|
disabled = true
|
||||||
|
text = "Connect to Server"
|
||||||
|
__meta__ = {
|
||||||
|
"_edit_use_anchors_": false
|
||||||
|
}
|
||||||
|
|
||||||
|
[node name="Exit_button" type="Button" parent="GUI"]
|
||||||
|
anchor_left = 0.5
|
||||||
|
anchor_top = 0.5
|
||||||
|
anchor_right = 0.5
|
||||||
|
anchor_bottom = 0.5
|
||||||
|
margin_left = -134.5
|
||||||
|
margin_top = 193.832
|
||||||
|
margin_right = 134.5
|
||||||
|
margin_bottom = 264.832
|
||||||
|
text = "Exit"
|
||||||
|
__meta__ = {
|
||||||
|
"_edit_use_anchors_": false
|
||||||
|
}
|
||||||
|
|
||||||
|
[node name="LineEdit" type="LineEdit" parent="GUI"]
|
||||||
|
anchor_left = 0.5
|
||||||
|
anchor_top = 0.5
|
||||||
|
anchor_right = 0.5
|
||||||
|
anchor_bottom = 0.5
|
||||||
|
margin_left = -300.0
|
||||||
|
margin_top = -15.0
|
||||||
|
margin_right = 300.0
|
||||||
|
margin_bottom = 15.0
|
||||||
|
placeholder_text = "Playername..."
|
||||||
|
__meta__ = {
|
||||||
|
"_edit_use_anchors_": false
|
||||||
|
}
|
||||||
|
[connection signal="pressed" from="GUI/Start_button" to="." method="_on_Button_pressed"]
|
||||||
|
[connection signal="pressed" from="GUI/Exit_button" to="." method="_on_Exit_button_pressed"]
|
||||||
|
[connection signal="text_changed" from="GUI/LineEdit" to="." method="_on_LineEdit_text_changed"]
|
53
Client/Scenes/Matchmaking/Networking/Networking_sync.gd
Normal file
53
Client/Scenes/Matchmaking/Networking/Networking_sync.gd
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
extends Node
|
||||||
|
|
||||||
|
signal updated_games
|
||||||
|
signal all_ready
|
||||||
|
|
||||||
|
var _open_games = {}
|
||||||
|
var _player_in_same_game_room_list = []
|
||||||
|
var _players_ready = []
|
||||||
|
|
||||||
|
func send_open_games_request_to_server():
|
||||||
|
rpc_id(1, "get_open_games_from_server", get_tree().get_network_unique_id())
|
||||||
|
|
||||||
|
remote func update_open_games(open_games):
|
||||||
|
_open_games = open_games
|
||||||
|
emit_signal("updated_games")
|
||||||
|
|
||||||
|
func get_open_games():
|
||||||
|
return _open_games
|
||||||
|
|
||||||
|
func create_game(game_information, host_player):
|
||||||
|
Player.set_game_id(host_player.get_player_id())
|
||||||
|
Player.set_host(true)
|
||||||
|
rpc_id(1, "add_game_to_game_list", host_player.get_player_id(), game_information, host_player.get_parsable_player())
|
||||||
|
yield(NetworkingSync, "updated_games")
|
||||||
|
get_tree().change_scene("res://Scenes/Matchmaking/Game_room/Game_room.tscn")
|
||||||
|
|
||||||
|
func join_game(game_id):
|
||||||
|
Player.set_game_id(game_id)
|
||||||
|
Player.set_host(false)
|
||||||
|
rpc_id(1, "join_open_game", game_id, Player.get_parsable_player())
|
||||||
|
get_tree().change_scene("res://Scenes/Matchmaking/Game_room/Game_room.tscn")
|
||||||
|
|
||||||
|
func left_game():
|
||||||
|
rpc_id(1, "remove_player_from_open_game", Player.get_game_id(), Player.get_player_id())
|
||||||
|
send_open_games_request_to_server()
|
||||||
|
|
||||||
|
func _on_Server_is_reachable_timeout():
|
||||||
|
print("Server is reachable.")
|
||||||
|
# TODO: check if connection still exists.
|
||||||
|
|
||||||
|
func close_game():
|
||||||
|
rpc_id(1, "remove_game_from_game_list", Player.get_game_id())
|
||||||
|
|
||||||
|
func send_ready_signal():
|
||||||
|
if Player.is_host():
|
||||||
|
send_host_ready_signal(Player.get_player_id())
|
||||||
|
else:
|
||||||
|
rpc_id(Player.get_game_id(), "send_host_ready_signal", Player.get_player_id())
|
||||||
|
|
||||||
|
remote func send_host_ready_signal(id):
|
||||||
|
_players_ready.append(id)
|
||||||
|
if len(_players_ready) == len(_player_in_same_game_room_list):
|
||||||
|
emit_signal("all_ready")
|
@ -0,0 +1,9 @@
|
|||||||
|
[gd_scene load_steps=2 format=2]
|
||||||
|
|
||||||
|
[ext_resource path="res://Scenes/Matchmaking/Networking/Networking_sync.gd" type="Script" id=1]
|
||||||
|
|
||||||
|
[node name="Networking" type="Node"]
|
||||||
|
script = ExtResource( 1 )
|
||||||
|
|
||||||
|
[node name="Server_is_reachable_timer" type="Timer" parent="."]
|
||||||
|
[connection signal="timeout" from="Server_is_reachable_timer" to="." method="_on_Server_is_reachable_timeout"]
|
33
Client/Scenes/Matchmaking/Player/Player.gd
Normal file
33
Client/Scenes/Matchmaking/Player/Player.gd
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
extends Node
|
||||||
|
|
||||||
|
var _player_id
|
||||||
|
var _player_name
|
||||||
|
var _game_id
|
||||||
|
var _is_host
|
||||||
|
|
||||||
|
func set_player_name(player_name):
|
||||||
|
_player_name = player_name
|
||||||
|
|
||||||
|
func set_player_id(player_id):
|
||||||
|
_player_id = player_id
|
||||||
|
|
||||||
|
func set_host(is_host):
|
||||||
|
_is_host = is_host
|
||||||
|
|
||||||
|
func is_host():
|
||||||
|
return _is_host
|
||||||
|
|
||||||
|
func get_player_name():
|
||||||
|
return _player_name
|
||||||
|
|
||||||
|
func get_player_id():
|
||||||
|
return _player_id
|
||||||
|
|
||||||
|
func set_game_id(game_id):
|
||||||
|
_game_id = game_id
|
||||||
|
|
||||||
|
func get_game_id():
|
||||||
|
return _game_id
|
||||||
|
|
||||||
|
func get_parsable_player():
|
||||||
|
return [_player_name, _player_id, _game_id, _is_host]
|
6
Client/Scenes/Matchmaking/Player/Player.tscn
Normal file
6
Client/Scenes/Matchmaking/Player/Player.tscn
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
[gd_scene load_steps=2 format=2]
|
||||||
|
|
||||||
|
[ext_resource path="res://Scenes/Matchmaking/Player/Player.gd" type="Script" id=1]
|
||||||
|
|
||||||
|
[node name="Player" type="Node"]
|
||||||
|
script = ExtResource( 1 )
|
67
Client/export_presets.cfg
Normal file
67
Client/export_presets.cfg
Normal file
@ -0,0 +1,67 @@
|
|||||||
|
[preset.0]
|
||||||
|
|
||||||
|
name="Linux/X11"
|
||||||
|
platform="Linux/X11"
|
||||||
|
runnable=true
|
||||||
|
custom_features=""
|
||||||
|
export_filter="all_resources"
|
||||||
|
include_filter=""
|
||||||
|
exclude_filter=""
|
||||||
|
export_path="../../Godot_Executables/Client.x86_64"
|
||||||
|
patch_list=PoolStringArray( )
|
||||||
|
script_export_mode=1
|
||||||
|
script_encryption_key=""
|
||||||
|
|
||||||
|
[preset.0.options]
|
||||||
|
|
||||||
|
texture_format/bptc=false
|
||||||
|
texture_format/s3tc=true
|
||||||
|
texture_format/etc=false
|
||||||
|
texture_format/etc2=false
|
||||||
|
texture_format/no_bptc_fallbacks=true
|
||||||
|
binary_format/64_bits=true
|
||||||
|
binary_format/embed_pck=false
|
||||||
|
custom_template/release=""
|
||||||
|
custom_template/debug=""
|
||||||
|
|
||||||
|
[preset.1]
|
||||||
|
|
||||||
|
name="Windows Desktop"
|
||||||
|
platform="Windows Desktop"
|
||||||
|
runnable=true
|
||||||
|
custom_features=""
|
||||||
|
export_filter="all_resources"
|
||||||
|
include_filter=""
|
||||||
|
exclude_filter=""
|
||||||
|
export_path="../../Godot_Executables/Client.exe"
|
||||||
|
patch_list=PoolStringArray( )
|
||||||
|
script_export_mode=1
|
||||||
|
script_encryption_key=""
|
||||||
|
|
||||||
|
[preset.1.options]
|
||||||
|
|
||||||
|
texture_format/bptc=false
|
||||||
|
texture_format/s3tc=true
|
||||||
|
texture_format/etc=false
|
||||||
|
texture_format/etc2=false
|
||||||
|
texture_format/no_bptc_fallbacks=true
|
||||||
|
binary_format/64_bits=true
|
||||||
|
binary_format/embed_pck=false
|
||||||
|
custom_template/release=""
|
||||||
|
custom_template/debug=""
|
||||||
|
codesign/enable=false
|
||||||
|
codesign/identity=""
|
||||||
|
codesign/password=""
|
||||||
|
codesign/timestamp=true
|
||||||
|
codesign/timestamp_server_url=""
|
||||||
|
codesign/digest_algorithm=1
|
||||||
|
codesign/description=""
|
||||||
|
codesign/custom_options=PoolStringArray( )
|
||||||
|
application/icon=""
|
||||||
|
application/file_version=""
|
||||||
|
application/product_version=""
|
||||||
|
application/company_name=""
|
||||||
|
application/product_name=""
|
||||||
|
application/file_description=""
|
||||||
|
application/copyright=""
|
||||||
|
application/trademarks=""
|
BIN
Client/icon.png
Normal file
BIN
Client/icon.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.2 KiB |
34
Client/icon.png.import
Normal file
34
Client/icon.png.import
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
[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
|
||||||
|
stream=false
|
||||||
|
size_limit=0
|
||||||
|
detect_3d=true
|
||||||
|
svg/scale=1.0
|
30
Client/project.godot
Normal file
30
Client/project.godot
Normal file
@ -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
|
||||||
|
|
||||||
|
_global_script_classes=[ ]
|
||||||
|
_global_script_class_icons={
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
[application]
|
||||||
|
|
||||||
|
config/name="Client_project"
|
||||||
|
run/main_scene="res://Scenes/Matchmaking/Menu/Menu.tscn"
|
||||||
|
config/icon="res://icon.png"
|
||||||
|
|
||||||
|
[autoload]
|
||||||
|
|
||||||
|
Player="*res://Scenes/Matchmaking/Player/Player.tscn"
|
||||||
|
NetworkingSync="*res://Scenes/Matchmaking/Networking/Networking_sync.tscn"
|
||||||
|
|
||||||
|
[display]
|
||||||
|
|
||||||
|
window/size/width=1920
|
||||||
|
window/size/height=1080
|
21
LICENSE
Normal file
21
LICENSE
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
MIT License
|
||||||
|
|
||||||
|
Copyright (c) 2020 twille00
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
SOFTWARE.
|
@ -0,0 +1,3 @@
|
|||||||
|
source_md5="47313fa4c47a9963fddd764e1ec6e4a8"
|
||||||
|
dest_md5="2ded9e7f9060e2b530aab678b135fc5b"
|
||||||
|
|
BIN
Server/.import/icon.png-487276ed1e3a0c39cad0279d744ee560.stex
Normal file
BIN
Server/.import/icon.png-487276ed1e3a0c39cad0279d744ee560.stex
Normal file
Binary file not shown.
26
Server/Scenes/Matchmaking/Networking/Networking_sync.gd
Normal file
26
Server/Scenes/Matchmaking/Networking/Networking_sync.gd
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
extends Node
|
||||||
|
# {game_id:[_game_id, _game_name, _max_players, _player_list]} # player_list is a dict
|
||||||
|
# {game_id:[_game_id, _game_name, _max_players, {player_id:[_player_name, _player_id, _game_id, _is_host]}]}
|
||||||
|
var _open_games = {}
|
||||||
|
|
||||||
|
var _players_online = []
|
||||||
|
|
||||||
|
remote func get_open_games_from_server(id):
|
||||||
|
rpc_id(id, "update_open_games", _open_games)
|
||||||
|
|
||||||
|
remote func add_game_to_game_list(game_id, game_information, host_player):
|
||||||
|
_open_games[game_id] = game_information
|
||||||
|
add_player_to_open_game(game_id, host_player)
|
||||||
|
get_open_games_from_server(game_id)
|
||||||
|
|
||||||
|
remote func join_open_game(game_id, player_information):
|
||||||
|
add_player_to_open_game(game_id, player_information)
|
||||||
|
|
||||||
|
func add_player_to_open_game(game_id, player_information):
|
||||||
|
_open_games[game_id][3][player_information[1]] = player_information
|
||||||
|
|
||||||
|
remote func remove_player_from_open_game(game_id, player_id):
|
||||||
|
_open_games[game_id][3].erase(player_id)
|
||||||
|
|
||||||
|
remote func remove_game_from_game_list(game_id):
|
||||||
|
_open_games.erase(game_id)
|
@ -0,0 +1,6 @@
|
|||||||
|
[gd_scene load_steps=2 format=2]
|
||||||
|
|
||||||
|
[ext_resource path="res://Scenes/Matchmaking/Networking/Networking_sync.gd" type="Script" id=1]
|
||||||
|
|
||||||
|
[node name="Networking" type="Node"]
|
||||||
|
script = ExtResource( 1 )
|
32
Server/Scenes/Matchmaking/Server/Server.gd
Normal file
32
Server/Scenes/Matchmaking/Server/Server.gd
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
extends Node
|
||||||
|
|
||||||
|
const SERVER_PORT = 14600
|
||||||
|
const MAX_PLAYERS = 1000
|
||||||
|
|
||||||
|
func _ready():
|
||||||
|
get_tree().connect("network_peer_connected", self, "_player_connected")
|
||||||
|
get_tree().connect("network_peer_disconnected", self, "_player_disconnected")
|
||||||
|
start_server()
|
||||||
|
|
||||||
|
func start_server():
|
||||||
|
print("Try to start the server.")
|
||||||
|
var peer = NetworkedMultiplayerENet.new()
|
||||||
|
var result = peer.create_server(SERVER_PORT, MAX_PLAYERS)
|
||||||
|
|
||||||
|
if result != OK:
|
||||||
|
print("Failed creating the server.")
|
||||||
|
return
|
||||||
|
else:
|
||||||
|
print("Created the server.")
|
||||||
|
|
||||||
|
get_tree().set_network_peer(peer)
|
||||||
|
|
||||||
|
func _player_connected(id):
|
||||||
|
print(str(id) + " connected to server.")
|
||||||
|
NetworkingSync._players_online.append(id)
|
||||||
|
|
||||||
|
func _player_disconnected(id):
|
||||||
|
print(str(id) + " left the game.")
|
||||||
|
NetworkingSync._players_online.erase(id)
|
||||||
|
if id in NetworkingSync._open_games:
|
||||||
|
NetworkingSync.remove_game_from_game_list(id)
|
6
Server/Scenes/Matchmaking/Server/Server.tscn
Normal file
6
Server/Scenes/Matchmaking/Server/Server.tscn
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
[gd_scene load_steps=2 format=2]
|
||||||
|
|
||||||
|
[ext_resource path="res://Scenes/Matchmaking/Server/Server.gd" type="Script" id=1]
|
||||||
|
|
||||||
|
[node name="Server" type="Node"]
|
||||||
|
script = ExtResource( 1 )
|
67
Server/export_presets.cfg
Normal file
67
Server/export_presets.cfg
Normal file
@ -0,0 +1,67 @@
|
|||||||
|
[preset.0]
|
||||||
|
|
||||||
|
name="Linux/X11"
|
||||||
|
platform="Linux/X11"
|
||||||
|
runnable=true
|
||||||
|
custom_features=""
|
||||||
|
export_filter="all_resources"
|
||||||
|
include_filter=""
|
||||||
|
exclude_filter=""
|
||||||
|
export_path="../../Godot_Executables/Server.x86_64"
|
||||||
|
patch_list=PoolStringArray( )
|
||||||
|
script_export_mode=1
|
||||||
|
script_encryption_key=""
|
||||||
|
|
||||||
|
[preset.0.options]
|
||||||
|
|
||||||
|
texture_format/bptc=false
|
||||||
|
texture_format/s3tc=true
|
||||||
|
texture_format/etc=false
|
||||||
|
texture_format/etc2=false
|
||||||
|
texture_format/no_bptc_fallbacks=true
|
||||||
|
binary_format/64_bits=true
|
||||||
|
binary_format/embed_pck=false
|
||||||
|
custom_template/release=""
|
||||||
|
custom_template/debug=""
|
||||||
|
|
||||||
|
[preset.1]
|
||||||
|
|
||||||
|
name="Windows Desktop"
|
||||||
|
platform="Windows Desktop"
|
||||||
|
runnable=true
|
||||||
|
custom_features=""
|
||||||
|
export_filter="all_resources"
|
||||||
|
include_filter=""
|
||||||
|
exclude_filter=""
|
||||||
|
export_path=""
|
||||||
|
patch_list=PoolStringArray( )
|
||||||
|
script_export_mode=1
|
||||||
|
script_encryption_key=""
|
||||||
|
|
||||||
|
[preset.1.options]
|
||||||
|
|
||||||
|
texture_format/bptc=false
|
||||||
|
texture_format/s3tc=true
|
||||||
|
texture_format/etc=false
|
||||||
|
texture_format/etc2=false
|
||||||
|
texture_format/no_bptc_fallbacks=true
|
||||||
|
binary_format/64_bits=true
|
||||||
|
binary_format/embed_pck=false
|
||||||
|
custom_template/release=""
|
||||||
|
custom_template/debug=""
|
||||||
|
codesign/enable=false
|
||||||
|
codesign/identity=""
|
||||||
|
codesign/password=""
|
||||||
|
codesign/timestamp=true
|
||||||
|
codesign/timestamp_server_url=""
|
||||||
|
codesign/digest_algorithm=1
|
||||||
|
codesign/description=""
|
||||||
|
codesign/custom_options=PoolStringArray( )
|
||||||
|
application/icon=""
|
||||||
|
application/file_version=""
|
||||||
|
application/product_version=""
|
||||||
|
application/company_name=""
|
||||||
|
application/product_name=""
|
||||||
|
application/file_description=""
|
||||||
|
application/copyright=""
|
||||||
|
application/trademarks=""
|
BIN
Server/icon.png
Normal file
BIN
Server/icon.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.2 KiB |
34
Server/icon.png.import
Normal file
34
Server/icon.png.import
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
[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
|
||||||
|
stream=false
|
||||||
|
size_limit=0
|
||||||
|
detect_3d=true
|
||||||
|
svg/scale=1.0
|
24
Server/project.godot
Normal file
24
Server/project.godot
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
; 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
|
||||||
|
|
||||||
|
_global_script_classes=[ ]
|
||||||
|
_global_script_class_icons={
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
[application]
|
||||||
|
|
||||||
|
config/name="Server_project"
|
||||||
|
run/main_scene="res://Scenes/Matchmaking/Server/Server.tscn"
|
||||||
|
config/icon="res://icon.png"
|
||||||
|
|
||||||
|
[autoload]
|
||||||
|
|
||||||
|
NetworkingSync="*res://Scenes/Matchmaking/Networking/Networking_sync.tscn"
|
Reference in New Issue
Block a user