first
This commit is contained in:
36
script/minigames.gd
Normal file
36
script/minigames.gd
Normal file
@@ -0,0 +1,36 @@
|
||||
extends Control
|
||||
|
||||
#TODO: After Minigame is completed next Pausemenu only opens after pressing twice
|
||||
|
||||
var minigameActive: bool = false
|
||||
signal minigameCompleted
|
||||
var currentInitiator: MinigameInitiator
|
||||
|
||||
func _ready() -> void:
|
||||
pass
|
||||
|
||||
#func _process(_delta: float) -> void:
|
||||
#if Input.is_action_just_pressed("leaveMinigame"): endMinigame()
|
||||
|
||||
func spawnMinigame(minigameName: String, initiator: MinigameInitiator) -> void:
|
||||
if minigameActive: return
|
||||
|
||||
match minigameName:
|
||||
"wires":
|
||||
add_child(preload("res://Minigames/Minigames/Wires.tscn").instantiate())
|
||||
|
||||
minigameActive = true
|
||||
currentInitiator = initiator
|
||||
|
||||
|
||||
func endMinigame(outcome: bool) -> void:
|
||||
if !minigameActive: return
|
||||
|
||||
if outcome:
|
||||
currentInitiator.minigameCompleted = true
|
||||
minigameCompleted.emit()
|
||||
else:
|
||||
get_child(0).queue_free()
|
||||
minigameActive = false
|
||||
currentInitiator = null
|
||||
Multiplayer.thisPlayer.currentControlState = 0
|
||||
Reference in New Issue
Block a user