diff --git a/src/components/level_system/PatternGen.gd b/src/components/level_system/PatternGen.gd index 326f7f5..7a91682 100644 --- a/src/components/level_system/PatternGen.gd +++ b/src/components/level_system/PatternGen.gd @@ -1,25 +1,49 @@ extends Node class_name PatternGen -var level_queue: LevelQueue +var level_queue := LevelQueue.new() var patterns_struct: Dictionary = {} const MAX_LEVEL := 10 -var level := 0: - set(val): - level = clamp(0, MAX_LEVEL, val) - +var level := 0: set = set_level func _ready(): + initialize_patterns() add_pattern() +func set_level(val): + level = clamp(0, MAX_LEVEL, val) + update_patterns_based_on_level() + func upgrade_level(): level += 1 + update_patterns_based_on_level() func downgrade_level(): level -= 1 - -func next_pattern(): - return + update_patterns_based_on_level() + +func next_pattern() -> Dictionary: + return level_queue.next_item() + +func initialize_patterns(): + # Example initialization of patterns_struct + patterns_struct = { + 1: [ {name: "Easy Pattern", difficulty: 1}], + 2: [ {name: "Medium Pattern", difficulty: 2}, {name: "Another Medium Pattern", difficulty: 2}], + # Add more levels and patterns as needed + } + +func add_pattern(): + var current_level_patterns = patterns_struct[level] + if current_level_patterns != null: + for pattern in current_level_patterns: + level_queue.add_item(pattern) + +func update_patterns_based_on_level(): + # Clear the queue to avoid mixing patterns from different levels + level_queue.items_queue.clear() + # Add patterns corresponding to the current level + add_pattern() diff --git a/src/components/level_system/PatternList.gd b/src/components/level_system/PatternList.gd new file mode 100644 index 0000000..d266444 --- /dev/null +++ b/src/components/level_system/PatternList.gd @@ -0,0 +1,10 @@ +extends RefCounted +class_name PatternList + +var _name: String +var _patterns: Array[int] + + +func _init(name: String, patterns: Array[int]): + _name = name + _patterns = patterns diff --git a/src/components/level_system/PatternStruct.gd b/src/components/level_system/PatternStruct.gd new file mode 100644 index 0000000..b27288e --- /dev/null +++ b/src/components/level_system/PatternStruct.gd @@ -0,0 +1,18 @@ +extends RefCounted + +var l1 := [ + d0, + d1, + +] + +var d0 := [ + PatternList.new("tutorial", [0, 1, 2, 3]), + PatternList.new("tutorial1", [1, 1, 1]), + PatternList.new("tutorial2", [0, 0, 0, 0, 0, ]), +] +var d1 := [ + PatternList.new("a", [0, 1, 2, 3]), + PatternList.new("a1", [1, 1, 1]), + PatternList.new("a2", [0, 0, 0, 0, 0, ]), +]