user progression
This commit is contained in:
@@ -0,0 +1,61 @@
|
||||
extends Resource
|
||||
class_name UserProgression
|
||||
|
||||
signal unlocks_changed()
|
||||
|
||||
enum Status{
|
||||
Locked,
|
||||
Unlocked,
|
||||
Completed,
|
||||
}
|
||||
|
||||
@export var version: = 1.0
|
||||
@export var difficulty: = 1
|
||||
@export var unlocks: = {}
|
||||
|
||||
|
||||
func _init() -> void:
|
||||
var number_of_lessons: = Database.get_lessons_count()
|
||||
|
||||
if unlocks.size() != number_of_lessons:
|
||||
for i in number_of_lessons:
|
||||
unlocks[i + 1] = {
|
||||
"look_and_learn": Status.Locked,
|
||||
"games": [
|
||||
Status.Locked,
|
||||
Status.Locked,
|
||||
Status.Locked,
|
||||
]
|
||||
}
|
||||
|
||||
unlocks[1]["look_and_learn"] = Status.Unlocked
|
||||
|
||||
|
||||
func get_max_unlocked_lesson() -> int:
|
||||
var max_unlocked_level: = 1
|
||||
for i in range(unlocks.size()):
|
||||
if unlocks[i + 1]["look_and_learn"] >= Status.Unlocked:
|
||||
max_unlocked_level = i
|
||||
|
||||
return max_unlocked_level
|
||||
|
||||
|
||||
func look_and_learn_completed(lesson_number: int) -> void:
|
||||
unlocks[lesson_number]["look_and_learn"] = Status.Completed
|
||||
|
||||
for i in range(3):
|
||||
unlocks[lesson_number]["games"][i] = Status.Unlocked
|
||||
|
||||
unlocks_changed.emit()
|
||||
|
||||
|
||||
func game_completed(lesson_number: int, game_number: int) -> void:
|
||||
unlocks[lesson_number]["games"][game_number] = Status.Completed
|
||||
|
||||
var all_completed: = true
|
||||
for i in range(3):
|
||||
all_completed &= unlocks[lesson_number]["games"] == Status.Completed
|
||||
|
||||
if all_completed and unlocks.has(lesson_number + 1):
|
||||
unlocks[lesson_number + 1] = Status.Unlocked
|
||||
unlocks_changed.emit()
|
||||
@@ -0,0 +1,28 @@
|
||||
extends Resource
|
||||
class_name UserSettings
|
||||
|
||||
@export var version: = 1.0
|
||||
|
||||
@export var master_volume: = 0.0 :
|
||||
set(volume):
|
||||
master_volume = volume
|
||||
var ind: = AudioServer.get_bus_index("Master")
|
||||
AudioServer.set_bus_volume_db(ind, volume)
|
||||
|
||||
@export var music_volume: = 0.0 :
|
||||
set(volume):
|
||||
music_volume = volume
|
||||
var ind: = AudioServer.get_bus_index("Music")
|
||||
AudioServer.set_bus_volume_db(ind, volume)
|
||||
|
||||
@export var voice_volume: = 0.0 :
|
||||
set(volume):
|
||||
voice_volume = volume
|
||||
var ind: = AudioServer.get_bus_index("Voice")
|
||||
AudioServer.set_bus_volume_db(ind, volume)
|
||||
|
||||
@export var effects_volume: = 0.0 :
|
||||
set(volume):
|
||||
effects_volume = volume
|
||||
var ind: = AudioServer.get_bus_index("Effects")
|
||||
AudioServer.set_bus_volume_db(ind, volume)
|
||||
Reference in New Issue
Block a user