Game jam submission
This commit is contained in:
@@ -1,37 +1,30 @@
|
||||
extends Node
|
||||
extends Node3D
|
||||
|
||||
signal level_lost
|
||||
signal level_won(level_path : String)
|
||||
@warning_ignore("unused_signal")
|
||||
signal level_changed(level_path : String)
|
||||
|
||||
## Optional path to the next level if using an open world level system.
|
||||
@export_file("*.tscn") var next_level_path : String
|
||||
## The tether whose parting ends the run.
|
||||
@export var tether_path : NodePath = ^"Path3DRope"
|
||||
|
||||
var level_state : LevelState
|
||||
## Beat between the rope parting and the lost screen, in seconds, so the break
|
||||
## is actually seen instead of being covered by the menu on the same frame.
|
||||
@export var lose_delay := 0.5
|
||||
|
||||
func _on_lose_button_pressed() -> void:
|
||||
level_lost.emit()
|
||||
var _lost := false
|
||||
|
||||
func _on_win_button_pressed() -> void:
|
||||
level_won.emit(next_level_path)
|
||||
|
||||
func open_tutorials() -> void:
|
||||
%TutorialManager.open_tutorials()
|
||||
level_state.tutorial_read = true
|
||||
GlobalState.save()
|
||||
|
||||
func _ready() -> void:
|
||||
level_state = GameState.get_level_state(scene_file_path)
|
||||
%ColorPickerButton.color = level_state.color
|
||||
%BackgroundColor.color = level_state.color
|
||||
if not level_state.tutorial_read:
|
||||
open_tutorials()
|
||||
var tether := get_node_or_null(tether_path)
|
||||
if tether != null and tether.has_signal(&"snapped"):
|
||||
tether.snapped.connect(_on_tether_snapped)
|
||||
|
||||
func _on_color_picker_button_color_changed(color : Color) -> void:
|
||||
%BackgroundColor.color = color
|
||||
level_state.color = color
|
||||
GlobalState.save()
|
||||
|
||||
func _on_tutorial_button_pressed() -> void:
|
||||
open_tutorials()
|
||||
func _on_tether_snapped(_at_position : Vector3) -> void:
|
||||
if _lost:
|
||||
return
|
||||
_lost = true
|
||||
if lose_delay > 0.0:
|
||||
await get_tree().create_timer(lose_delay).timeout
|
||||
for player in get_tree().get_nodes_in_group(&"players"):
|
||||
if player is Player:
|
||||
(player as Player).controls_enabled = false
|
||||
level_lost.emit()
|
||||
|
||||
Reference in New Issue
Block a user