Merge branch 'master' of github.com:unfa/jam-01 into master
This commit is contained in:
commit
5554104503
8 changed files with 128 additions and 64 deletions
|
@ -2,16 +2,16 @@
|
|||
|
||||
[ext_resource path="res://Fonts/Roboto_Condensed/RobotoCondensed-Regular-dynamic.tres" type="DynamicFont" id=1]
|
||||
|
||||
[sub_resource type="StyleBoxFlat" id=2]
|
||||
[sub_resource type="StyleBoxFlat" id=1]
|
||||
|
||||
[sub_resource type="StyleBoxFlat" id=3]
|
||||
[sub_resource type="StyleBoxFlat" id=2]
|
||||
bg_color = Color( 0.113725, 0.0784314, 0.0392157, 0.513726 )
|
||||
corner_radius_top_left = 5
|
||||
corner_radius_top_right = 5
|
||||
corner_radius_bottom_right = 5
|
||||
corner_radius_bottom_left = 5
|
||||
|
||||
[sub_resource type="StyleBoxFlat" id=1]
|
||||
[sub_resource type="StyleBoxFlat" id=3]
|
||||
bg_color = Color( 0.172549, 0.109804, 0.109804, 0.372549 )
|
||||
border_width_left = 5
|
||||
border_width_top = 5
|
||||
|
@ -57,10 +57,11 @@ Button/colors/font_color_pressed = Color( 1, 1, 1, 1 )
|
|||
Button/constants/hseparation = 2
|
||||
Button/fonts/font = null
|
||||
Button/styles/disabled = null
|
||||
Button/styles/focus = SubResource( 2 )
|
||||
Button/styles/hover = SubResource( 3 )
|
||||
Button/styles/normal = SubResource( 1 )
|
||||
Button/styles/focus = SubResource( 1 )
|
||||
Button/styles/hover = SubResource( 2 )
|
||||
Button/styles/normal = SubResource( 3 )
|
||||
Button/styles/pressed = SubResource( 4 )
|
||||
LineEdit/colors/Test = Color( 0, 0, 0, 1 )
|
||||
LineEdit/colors/clear_button_color = Color( 0.88, 0.88, 0.88, 1 )
|
||||
LineEdit/colors/clear_button_color_pressed = Color( 1, 1, 1, 1 )
|
||||
LineEdit/colors/cursor_color = Color( 0.94, 0.94, 0.94, 1 )
|
||||
|
|
75
Game.gd
75
Game.gd
|
@ -19,6 +19,10 @@ var settingmap = {
|
|||
onready var peer = NetworkedMultiplayerENet.new()
|
||||
var local_player = null setget set_local_player
|
||||
|
||||
func set_local_player(player):
|
||||
local_player = player
|
||||
player.set_local_player()
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready():
|
||||
$MenuContainer/ConnectMenu/Destination/IPAdress.set_text(SERVER_IP)
|
||||
|
@ -29,11 +33,6 @@ func _ready():
|
|||
if auto_host:
|
||||
initialize_server(false)
|
||||
|
||||
func set_local_player(player):
|
||||
local_player = player
|
||||
player.set_local_player()
|
||||
player.rpc("set_nickname", $MenuContainer/MainMenu/Name.text)
|
||||
|
||||
func load_settings():
|
||||
var load_settings = File.new()
|
||||
load_settings.open("user://settings.save", File.READ)
|
||||
|
@ -75,8 +74,13 @@ func _input(event):
|
|||
var buttons = child.get_children()
|
||||
for button in buttons:
|
||||
if button.name == "Back":
|
||||
print(child.name)
|
||||
button.emit_signal("pressed")
|
||||
|
||||
if event.is_action_pressed("ShowPlayerList") and !$MenuContainer.visible:
|
||||
$PlayerListContainer.show()
|
||||
|
||||
if event.is_action_released("ShowPlayerList"):
|
||||
$PlayerListContainer.hide()
|
||||
|
||||
func open_menus():
|
||||
GAME_MODE = "MENU"
|
||||
|
@ -107,8 +111,8 @@ func join_test_server():
|
|||
SERVER_IP = "unfa.xyz"
|
||||
initialize_client()
|
||||
|
||||
sync func set_player_name(player, name):
|
||||
print(name)
|
||||
#sync func set_player_name(player, name):
|
||||
# print(name)
|
||||
|
||||
func join_home():
|
||||
SERVER_IP = "127.0.0.1"
|
||||
|
@ -167,11 +171,13 @@ func initialize_server(join=true):
|
|||
peer.create_server(SERVER_PORT, MAX_PLAYERS)
|
||||
get_tree().connect("network_peer_connected", self, "on_peer_connected")
|
||||
get_tree().connect("network_peer_disconnected", self, "on_peer_disconnected")
|
||||
get_tree().network_peer = peer
|
||||
|
||||
initialize()
|
||||
|
||||
if join:
|
||||
add_player(1, false)
|
||||
join_game()
|
||||
#add_player(peer.get_unique_id(), false)
|
||||
|
||||
func initialize_client():
|
||||
peer.create_client(SERVER_IP, SERVER_PORT)
|
||||
|
@ -188,7 +194,6 @@ func initialize():
|
|||
$MenuContainer/MainMenu/Disconnect.show()
|
||||
|
||||
close_menus()
|
||||
set_nickname($MenuContainer/MainMenu/Name.text)
|
||||
|
||||
func free_client():
|
||||
$MenuContainer/MainMenu/Connect.show()
|
||||
|
@ -197,6 +202,9 @@ func free_client():
|
|||
for player in $Players.get_children():
|
||||
player.queue_free()
|
||||
|
||||
for player_list_item in $PlayerListContainer/Panel/PlayerList.get_children():
|
||||
player_list_item.queue_free()
|
||||
|
||||
peer.close_connection()
|
||||
|
||||
func quit():
|
||||
|
@ -220,6 +228,7 @@ sync func check_players(player_data):
|
|||
var player = player_scene.instance()
|
||||
|
||||
player.name = player_name
|
||||
player.set_network_master(int(player_name))
|
||||
|
||||
$Players.add_child(player)
|
||||
player.translation += Vector3(0.0, 3.0, 0.0)
|
||||
|
@ -227,36 +236,54 @@ sync func check_players(player_data):
|
|||
var data = player_data[player_name]
|
||||
player.set_nickname(data["nickname"])
|
||||
|
||||
if player_name == str(get_tree().get_network_unique_id()):
|
||||
set_local_player(player)
|
||||
on_player_added(player)
|
||||
|
||||
func add_player(id, check=true):
|
||||
func join_game():
|
||||
var player = player_scene.instance()
|
||||
var id = peer.get_unique_id()
|
||||
|
||||
player.name = str(id)
|
||||
$Players.add_child(player)
|
||||
player.set_network_master(id)
|
||||
player.translation += Vector3(0.0, 0.0, 0.0)
|
||||
|
||||
if check:
|
||||
var player_data = get_player_data()
|
||||
rpc("check_players", player_data)
|
||||
else:
|
||||
set_local_player(player)
|
||||
|
||||
$Players.add_child(player)
|
||||
set_local_player(player)
|
||||
|
||||
var nickname = $MenuContainer/MainMenu/Name.text
|
||||
set_nickname(nickname)
|
||||
player.set_nickname(nickname)
|
||||
on_player_added(player)
|
||||
|
||||
var player_data = get_player_data()
|
||||
|
||||
rpc("set_player_data", player_data)
|
||||
|
||||
func on_player_added(player):
|
||||
var player_list_item = preload("res://PlayerListItem.tscn").instance()
|
||||
$PlayerListContainer/Panel/PlayerList.add_child(player_list_item)
|
||||
player_list_item.player = player
|
||||
|
||||
sync func remove_player(id):
|
||||
for player_list_item in $PlayerListContainer/Panel/PlayerList.get_children():
|
||||
if player_list_item.network_id == str(id):
|
||||
player_list_item.queue_free()
|
||||
|
||||
for player in $Players.get_children():
|
||||
if player.name == str(id):
|
||||
$Players.remove_child(player)
|
||||
player.queue_free()
|
||||
|
||||
func get_spawn_point():
|
||||
return $Level/SpawnPoint
|
||||
|
||||
func on_peer_connected(id):
|
||||
print("Peer connected with id ", id)
|
||||
|
||||
master func set_player_data(player_data):
|
||||
check_players(player_data)
|
||||
var new_player_data = get_player_data()
|
||||
|
||||
add_player(id)
|
||||
print(new_player_data)
|
||||
|
||||
rpc("check_players", new_player_data)
|
||||
|
||||
func on_peer_disconnected(id):
|
||||
print("Peer disconnected with id ", id)
|
||||
|
@ -264,7 +291,7 @@ func on_peer_disconnected(id):
|
|||
rpc("remove_player", id)
|
||||
|
||||
func on_connection_established():
|
||||
print("Connection has been established")
|
||||
join_game()
|
||||
|
||||
func on_connection_failed():
|
||||
print("Connection has failed")
|
||||
|
|
19
Game.tscn
19
Game.tscn
|
@ -264,6 +264,25 @@ margin_top = 24.0
|
|||
margin_right = 300.0
|
||||
margin_bottom = 64.0
|
||||
text = "Fullscreen"
|
||||
|
||||
[node name="PlayerListContainer" type="CenterContainer" parent="."]
|
||||
visible = false
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
theme = ExtResource( 1 )
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="Panel" type="Panel" parent="PlayerListContainer"]
|
||||
margin_left = 262.0
|
||||
margin_top = 49.0
|
||||
margin_right = 762.0
|
||||
margin_bottom = 549.0
|
||||
rect_min_size = Vector2( 500, 500 )
|
||||
|
||||
[node name="PlayerList" type="VBoxContainer" parent="PlayerListContainer/Panel"]
|
||||
alignment = 1
|
||||
[connection signal="pressed" from="MenuContainer/MainMenu/QuickConnect" to="." method="join_test_server"]
|
||||
[connection signal="pressed" from="MenuContainer/MainMenu/Connect" to="." method="open_menu" binds= [ "ConnectMenu" ]]
|
||||
[connection signal="pressed" from="MenuContainer/MainMenu/Disconnect" to="." method="free_client"]
|
||||
|
|
52
Level.tscn
52
Level.tscn
|
@ -1,27 +1,23 @@
|
|||
[gd_scene load_steps=14 format=2]
|
||||
[gd_scene load_steps=12 format=2]
|
||||
|
||||
[ext_resource path="res://LevelComponents/Killfloor.tscn" type="PackedScene" id=1]
|
||||
[ext_resource path="res://LevelComponents/SpawnPoint.tscn" type="PackedScene" id=2]
|
||||
[ext_resource path="res://LevelComponents/LevelGeometry.gd" type="Script" id=3]
|
||||
|
||||
[sub_resource type="BoxShape" id=1]
|
||||
|
||||
[sub_resource type="CubeMesh" id=2]
|
||||
|
||||
[sub_resource type="VisualShaderNodeTextureUniformTriplanar" id=3]
|
||||
[sub_resource type="VisualShaderNodeTextureUniformTriplanar" id=1]
|
||||
output_port_for_preview = 0
|
||||
uniform_name = "BaseTexture"
|
||||
texture_type = 1
|
||||
|
||||
[sub_resource type="VisualShaderNodeTextureUniformTriplanar" id=4]
|
||||
[sub_resource type="VisualShaderNodeTextureUniformTriplanar" id=2]
|
||||
output_port_for_preview = 0
|
||||
uniform_name = "BaseTextureNormal"
|
||||
texture_type = 2
|
||||
|
||||
[sub_resource type="VisualShaderNodeScalarUniform" id=5]
|
||||
[sub_resource type="VisualShaderNodeScalarUniform" id=3]
|
||||
uniform_name = "ScalarUniform"
|
||||
|
||||
[sub_resource type="VisualShader" id=6]
|
||||
[sub_resource type="VisualShader" id=4]
|
||||
code = "shader_type spatial;
|
||||
render_mode specular_schlick_ggx, world_vertex_coords;
|
||||
|
||||
|
@ -93,59 +89,49 @@ void light() {
|
|||
graph_offset = Vector2( -531, 641.5 )
|
||||
flags/world_vertex_coords = true
|
||||
nodes/fragment/0/position = Vector2( 220, 100 )
|
||||
nodes/fragment/3/node = SubResource( 3 )
|
||||
nodes/fragment/3/node = SubResource( 1 )
|
||||
nodes/fragment/3/position = Vector2( -640, 20 )
|
||||
nodes/fragment/5/node = SubResource( 4 )
|
||||
nodes/fragment/5/node = SubResource( 2 )
|
||||
nodes/fragment/5/position = Vector2( -280, 500 )
|
||||
nodes/fragment/6/node = SubResource( 5 )
|
||||
nodes/fragment/6/node = SubResource( 3 )
|
||||
nodes/fragment/6/position = Vector2( -140, 200 )
|
||||
nodes/fragment/connections = PoolIntArray( 3, 0, 0, 0, 5, 0, 0, 8, 6, 0, 0, 3 )
|
||||
|
||||
[sub_resource type="OpenSimplexNoise" id=7]
|
||||
[sub_resource type="OpenSimplexNoise" id=5]
|
||||
octaves = 7
|
||||
period = 256.0
|
||||
persistence = 0.859
|
||||
lacunarity = 4.0
|
||||
|
||||
[sub_resource type="NoiseTexture" id=8]
|
||||
[sub_resource type="NoiseTexture" id=6]
|
||||
seamless = true
|
||||
noise = SubResource( 7 )
|
||||
noise = SubResource( 5 )
|
||||
|
||||
[sub_resource type="NoiseTexture" id=9]
|
||||
[sub_resource type="NoiseTexture" id=7]
|
||||
seamless = true
|
||||
as_normalmap = true
|
||||
bump_strength = 4.0
|
||||
noise = SubResource( 7 )
|
||||
noise = SubResource( 5 )
|
||||
|
||||
[sub_resource type="ShaderMaterial" id=10]
|
||||
shader = SubResource( 6 )
|
||||
[sub_resource type="ShaderMaterial" id=8]
|
||||
shader = SubResource( 4 )
|
||||
shader_param/ScalarUniform = 0.4
|
||||
shader_param/triplanar_scale = Vector3( 0.1, 0.1, 0.1 )
|
||||
shader_param/triplanar_offset = null
|
||||
shader_param/triplanar_sharpness = 0.5
|
||||
shader_param/BaseTexture = SubResource( 8 )
|
||||
shader_param/BaseTextureNormal = SubResource( 9 )
|
||||
shader_param/BaseTexture = SubResource( 6 )
|
||||
shader_param/BaseTextureNormal = SubResource( 7 )
|
||||
|
||||
[node name="Level" type="Spatial"]
|
||||
|
||||
[node name="Node" type="Node" parent="."]
|
||||
|
||||
[node name="DirectionalLight" type="DirectionalLight" parent="Node"]
|
||||
transform = Transform( 1, 0, 0, 0, 0.707107, 0.707107, 0, -0.707107, 0.707107, 0, 24.5477, 7 )
|
||||
transform = Transform( 0.41961, 0.641844, -0.641844, 0, 0.707107, 0.707107, 0.907704, -0.296709, 0.296709, 0, 24.5477, 7 )
|
||||
shadow_enabled = true
|
||||
|
||||
[node name="RigidBody" type="RigidBody" parent="."]
|
||||
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 4.22547, 0 )
|
||||
|
||||
[node name="CollisionShape" type="CollisionShape" parent="RigidBody"]
|
||||
shape = SubResource( 1 )
|
||||
|
||||
[node name="MeshInstance" type="MeshInstance" parent="RigidBody"]
|
||||
mesh = SubResource( 2 )
|
||||
material/0 = null
|
||||
|
||||
[node name="CSGCombiner" type="CSGCombiner" parent="."]
|
||||
material_override = SubResource( 10 )
|
||||
material_override = SubResource( 8 )
|
||||
use_collision = true
|
||||
script = ExtResource( 3 )
|
||||
|
||||
|
|
|
@ -57,10 +57,13 @@ func set_health(value):
|
|||
$Billboard.rpc("set_health", value)
|
||||
#$Billboard.set_health(value)
|
||||
|
||||
sync func set_nickname(_nickname):
|
||||
func set_nickname(_nickname):
|
||||
$Billboard.set_nickname(_nickname)
|
||||
nickname = _nickname
|
||||
|
||||
remote func set_player_data(player):
|
||||
nickname = player.nickname
|
||||
|
||||
func gravity():
|
||||
if not is_on_floor():
|
||||
self.velocity.y -= GRAVITY
|
||||
|
|
8
PlayerListItem.gd
Normal file
8
PlayerListItem.gd
Normal file
|
@ -0,0 +1,8 @@
|
|||
extends HBoxContainer
|
||||
|
||||
var player setget set_player
|
||||
var network_id
|
||||
|
||||
func set_player(player):
|
||||
$Nickname.text = player.nickname
|
||||
network_id = player.name
|
15
PlayerListItem.tscn
Normal file
15
PlayerListItem.tscn
Normal file
|
@ -0,0 +1,15 @@
|
|||
[gd_scene load_steps=2 format=2]
|
||||
|
||||
[ext_resource path="res://PlayerListItem.gd" type="Script" id=1]
|
||||
|
||||
[node name="Player" type="HBoxContainer"]
|
||||
margin_bottom = 14.0
|
||||
script = ExtResource( 1 )
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="Nickname" type="Label" parent="."]
|
||||
margin_right = 28.0
|
||||
margin_bottom = 14.0
|
||||
text = "TEST"
|
|
@ -75,6 +75,11 @@ ToggleMenu={
|
|||
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777217,"unicode":0,"echo":false,"script":null)
|
||||
]
|
||||
}
|
||||
ShowPlayerList={
|
||||
"deadzone": 0.5,
|
||||
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777218,"unicode":0,"echo":false,"script":null)
|
||||
]
|
||||
}
|
||||
|
||||
[rendering]
|
||||
|
||||
|
|
Reference in a new issue