Skip to content

Commit

Permalink
Merge pull request #112 from TheSecondReal0/map-system-2-electric-boo…
Browse files Browse the repository at this point in the history
…galoo

Add lobby and improve map system
  • Loading branch information
monban authored Oct 19, 2020
2 parents 90567d0 + cd8bb04 commit 7435457
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 19 deletions.
4 changes: 3 additions & 1 deletion src/assets/main/main.gd
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ var player_scene = load(player_s)
var players = {}
#!!!THIS IS IMPORTANT!!!
#INCREASE THIS VARIABLE BY ONE EVERY COMMIT TO PREVENT OLD CLIENTS FROM TRYING TO CONNECT TO SERVERS!!!
var version = 3
var version = 4
var intruders = 0
var errdc = false
onready var config = ConfigFile.new()
Expand Down Expand Up @@ -134,8 +134,10 @@ func _on_startgamebutton_gamestartpressed():
intruders = intruders + 1
rpc_id(other_id,"startgame",isintruder)
isintruder = false
$maps.switchMap("test")
emit_signal("clientstartgame")
get_tree().set_refuse_new_network_connections(true)

remote func startgame(areweanintruder):
if areweanintruder:
print("we are the intruder!")
Expand Down
8 changes: 4 additions & 4 deletions src/assets/main/main.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,10 @@ margin_right = -247.972
margin_bottom = -13.1382

[node name="startgamebutton" type="Button" parent="players/Player/Camera2D/CanvasLayer"]
margin_left = 1.77539
margin_top = 571.249
margin_right = 95.7754
margin_bottom = 599.249
anchor_top = 1.0
anchor_bottom = 1.0
margin_top = -28.0
margin_right = 94.0
text = "Start Game"
script = ExtResource( 7 )
__meta__ = {
Expand Down
14 changes: 10 additions & 4 deletions src/assets/main/maps.gd
Original file line number Diff line number Diff line change
@@ -1,17 +1,23 @@
extends Node2D

var maps: Dictionary = {"test": preload("res://assets/maps/test/test.tscn")}
var maps: Dictionary = {"lobby": preload("res://assets/maps/lobby/lobby.tscn"), "test": preload("res://assets/maps/test/test.tscn")}

var currentMap: String = "test"
var currentMap: String = "lobby"

func _ready():
switchMap("test")
set_network_master(1)
switchMap(currentMap)

func switchMap(newMap: String):
puppet func switchMap(newMap: String):
#if the func is not remotely called rpc sender id will be 0, if server sent it will be 1, negative should be impossible
if not get_tree().get_rpc_sender_id() < 2:
return
if GameManager.ingame:
return
if not maps.keys().has(newMap):
return
if get_tree().is_network_server():
rpc("switchMap", newMap)
for i in get_children():
i.queue_free()
currentMap = newMap
Expand Down
11 changes: 11 additions & 0 deletions src/assets/maps/lobby/lobby.tscn
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[gd_scene format=2]

[node name="lobby" type="Node2D"]

[node name="Label" type="Label" parent="."]
margin_right = 40.0
margin_bottom = 22.0
text = "LOBBY"
__meta__ = {
"_edit_use_anchors_": false
}
22 changes: 12 additions & 10 deletions src/assets/ui/mainmenu/playgame/playgame.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ __meta__ = {

[node name="CreateGameMenu" type="VBoxContainer" parent="."]
visible = false
margin_right = 640.0
margin_bottom = 64.0
anchor_right = 1.0
size_flags_horizontal = 3
size_flags_vertical = 3
custom_constants/separation = 8
alignment = 1

[node name="PortLine" type="HBoxContainer" parent="CreateGameMenu"]
margin_right = 640.0
Expand All @@ -42,9 +42,11 @@ caret_blink = true
caret_blink_speed = 0.5

[node name="Name" type="HBoxContainer" parent="CreateGameMenu"]
anchor_right = 1.0
margin_top = 38.0
margin_right = 640.0
margin_bottom = 68.0
alignment = 1

[node name="Name" type="Label" parent="CreateGameMenu/Name"]
margin_top = 4.0
Expand Down Expand Up @@ -72,11 +74,11 @@ text = "BACK"

[node name="JoinGameMenu" type="VBoxContainer" parent="."]
visible = false
margin_right = 640.0
margin_bottom = 100.0
anchor_right = 1.0
size_flags_horizontal = 3
size_flags_vertical = 3
custom_constants/separation = 8
alignment = 1
__meta__ = {
"_edit_use_anchors_": false
}
Expand Down Expand Up @@ -150,36 +152,36 @@ margin_bottom = 190.0
text = "BACK"

[node name="PlayGameMenu" type="VBoxContainer" parent="."]
margin_right = 640.0
margin_bottom = 124.0
anchor_right = 1.0
size_flags_horizontal = 3
size_flags_vertical = 3
custom_constants/separation = 8
alignment = 1

[node name="Tutorial" type="Button" parent="PlayGameMenu"]
margin_right = 640.0
margin_right = 1024.0
margin_bottom = 34.0
disabled = true
text = "TUTORIAL"
flat = true

[node name="JoinGame" type="Button" parent="PlayGameMenu"]
margin_top = 42.0
margin_right = 640.0
margin_right = 1024.0
margin_bottom = 76.0
text = "JOIN GAME"
flat = true

[node name="CreateGame" type="Button" parent="PlayGameMenu"]
margin_top = 84.0
margin_right = 640.0
margin_right = 1024.0
margin_bottom = 118.0
text = "CREATE GAME"
flat = true

[node name="Back" type="Button" parent="PlayGameMenu"]
margin_top = 126.0
margin_right = 640.0
margin_right = 1024.0
margin_bottom = 160.0
text = "BACK"
flat = true
Expand Down
1 change: 1 addition & 0 deletions src/export_presets.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ binary_format/embed_pck=true
custom_template/release=""
custom_template/debug=""
codesign/enable=false
codesign/identity_type=0
codesign/identity=""
codesign/password=""
codesign/timestamp=true
Expand Down

0 comments on commit 7435457

Please sign in to comment.