Game Settings resource, directly launch game now.
This commit is contained in:
parent
76e7f5ef19
commit
42035d7907
|
|
@ -1,10 +1,11 @@
|
||||||
[gd_scene load_steps=11 format=2]
|
[gd_scene load_steps=12 format=2]
|
||||||
|
|
||||||
[ext_resource path="res://src/classes/camera_guide.gd" type="Script" id=1]
|
[ext_resource path="res://src/classes/camera_guide.gd" type="Script" id=1]
|
||||||
[ext_resource path="res://src/Camera2D.gd" type="Script" id=2]
|
[ext_resource path="res://src/Camera2D.gd" type="Script" id=2]
|
||||||
[ext_resource path="res://src/levels/TestBox.tscn" type="PackedScene" id=3]
|
[ext_resource path="res://src/levels/TestBox.tscn" type="PackedScene" id=3]
|
||||||
[ext_resource path="res://src/ui/scene_transition.tscn" type="PackedScene" id=4]
|
[ext_resource path="res://src/ui/scene_transition.tscn" type="PackedScene" id=4]
|
||||||
[ext_resource path="res://src/ui/HUD.tscn" type="PackedScene" id=5]
|
[ext_resource path="res://src/ui/HUD.tscn" type="PackedScene" id=5]
|
||||||
|
[ext_resource path="res://settings.tres" type="Resource" id=6]
|
||||||
[ext_resource path="res://src/Main.gd" type="Script" id=7]
|
[ext_resource path="res://src/Main.gd" type="Script" id=7]
|
||||||
[ext_resource path="res://src/ui/lobby.tscn" type="PackedScene" id=9]
|
[ext_resource path="res://src/ui/lobby.tscn" type="PackedScene" id=9]
|
||||||
|
|
||||||
|
|
@ -28,6 +29,7 @@ extents = Vector2( 160, 90 )
|
||||||
script = ExtResource( 7 )
|
script = ExtResource( 7 )
|
||||||
starting_level = ExtResource( 3 )
|
starting_level = ExtResource( 3 )
|
||||||
player_hud = ExtResource( 5 )
|
player_hud = ExtResource( 5 )
|
||||||
|
game_settings = ExtResource( 6 )
|
||||||
|
|
||||||
[node name="MusicPlayer" type="AudioStreamPlayer" parent="."]
|
[node name="MusicPlayer" type="AudioStreamPlayer" parent="."]
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -34,6 +34,11 @@ _global_script_classes=[ {
|
||||||
"language": "GDScript",
|
"language": "GDScript",
|
||||||
"path": "res://lib/classes/collision_shape2D_state_receiver.gd"
|
"path": "res://lib/classes/collision_shape2D_state_receiver.gd"
|
||||||
}, {
|
}, {
|
||||||
|
"base": "Resource",
|
||||||
|
"class": "GameSettings",
|
||||||
|
"language": "GDScript",
|
||||||
|
"path": "res://src/game_settings.gd"
|
||||||
|
}, {
|
||||||
"base": "Node",
|
"base": "Node",
|
||||||
"class": "HealthComponent",
|
"class": "HealthComponent",
|
||||||
"language": "GDScript",
|
"language": "GDScript",
|
||||||
|
|
@ -175,6 +180,7 @@ _global_script_class_icons={
|
||||||
"AudioStreamPlayer_StateReceiver": "",
|
"AudioStreamPlayer_StateReceiver": "",
|
||||||
"CameraGuide": "",
|
"CameraGuide": "",
|
||||||
"CollisionShape2D_StateReceiver": "",
|
"CollisionShape2D_StateReceiver": "",
|
||||||
|
"GameSettings": "",
|
||||||
"HealthComponent": "",
|
"HealthComponent": "",
|
||||||
"HealthPickup": "",
|
"HealthPickup": "",
|
||||||
"Interactable": "",
|
"Interactable": "",
|
||||||
|
|
|
||||||
7
settings.tres
Normal file
7
settings.tres
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
[gd_resource type="Resource" load_steps=2 format=2]
|
||||||
|
|
||||||
|
[ext_resource path="res://src/game_settings.gd" type="Script" id=1]
|
||||||
|
|
||||||
|
[resource]
|
||||||
|
script = ExtResource( 1 )
|
||||||
|
multiplayer_enabled = false
|
||||||
|
|
@ -12,6 +12,8 @@ export var starting_level: PackedScene
|
||||||
export var player_hud: PackedScene
|
export var player_hud: PackedScene
|
||||||
export var start_screen: PackedScene
|
export var start_screen: PackedScene
|
||||||
|
|
||||||
|
export var game_settings :Resource
|
||||||
|
|
||||||
onready var viewport_container = $ViewportContainer
|
onready var viewport_container = $ViewportContainer
|
||||||
onready var viewport = $"%Viewport"
|
onready var viewport = $"%Viewport"
|
||||||
onready var lobby = $ViewportContainer/Viewport/Lobby
|
onready var lobby = $ViewportContainer/Viewport/Lobby
|
||||||
|
|
@ -24,6 +26,7 @@ onready var window_scale :float
|
||||||
|
|
||||||
# Called when the node enters the scene tree for the first time.
|
# Called when the node enters the scene tree for the first time.
|
||||||
func _ready():
|
func _ready():
|
||||||
|
assert(game_settings is GameSettings, "Incorrect resource or no settings resource specified.")
|
||||||
game_size = viewport.size
|
game_size = viewport.size
|
||||||
window_scale = (OS.window_size / game_size).x
|
window_scale = (OS.window_size / game_size).x
|
||||||
assert(starting_level != null, "Main: starting level not specified.")
|
assert(starting_level != null, "Main: starting level not specified.")
|
||||||
|
|
@ -32,7 +35,13 @@ func _ready():
|
||||||
|
|
||||||
##TODO: Once a start screen is there, go there instead of lobby UI.
|
##TODO: Once a start screen is there, go there instead of lobby UI.
|
||||||
# Or shift this over to UIManager singleton
|
# Or shift this over to UIManager singleton
|
||||||
|
if game_settings is GameSettings:
|
||||||
if is_instance_valid(start_screen) == false:
|
if is_instance_valid(start_screen) == false:
|
||||||
|
if game_settings.multiplayer_enabled == false:
|
||||||
|
lobby.visible = false
|
||||||
|
NetworkManager.host_game('DISABLED')
|
||||||
|
NetworkManager.begin_game()
|
||||||
|
else:
|
||||||
lobby.visible = true
|
lobby.visible = true
|
||||||
|
|
||||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||||
|
|
|
||||||
6
src/game_settings.gd
Normal file
6
src/game_settings.gd
Normal file
|
|
@ -0,0 +1,6 @@
|
||||||
|
class_name GameSettings
|
||||||
|
extends Resource
|
||||||
|
|
||||||
|
|
||||||
|
export var multiplayer_enabled :bool = false
|
||||||
|
|
||||||
Loading…
Reference in New Issue
Block a user