-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
42 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,45 +1,37 @@ | ||
extends Node | ||
class_name PatternGen | ||
|
||
var level_queue := LevelQueue.new() | ||
|
||
const MAX_LEVEL := 10 | ||
|
||
enum SpawnMode {TUTORIAL, DEBUG, QUEUE} | ||
|
||
@export var level := 0: | ||
@export var level: int = G.settings.DEFAULT_LEVEL: | ||
set(val): | ||
level = clamp(0, MAX_LEVEL, val) | ||
|
||
var level_queue := LevelQueue.new() | ||
|
||
func _ready(): | ||
G.level_changed.connect(_on_level_changed) | ||
add_patterns() | ||
|
||
func upgrade_level(): | ||
level += 1 | ||
|
||
func downgrade_level(): | ||
level -= 1 | ||
func _on_level_changed(new_level: int): | ||
level = new_level | ||
|
||
func next_pattern() -> int: | ||
if level_queue.length <= 0: | ||
add_patterns() | ||
return level_queue.next_item() | ||
|
||
|
||
func add_patterns(): | ||
var current_level: Dictionary = LevelPatterns.levels[level] | ||
if current_level.get("random"): | ||
var p: int = current_level.level_patterns.pick_random() | ||
for i in LevelPatterns.patterns[p]: | ||
level_queue.add_item(i) | ||
else: | ||
for pattern in current_level.level_patterns: | ||
for type in LevelPatterns.patterns[pattern]: | ||
level_queue.add_item(type) | ||
|
||
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_patterns() | ||
var random_pattern: int = current_level.level_patterns.pick_random() | ||
queue_pattern(random_pattern) | ||
return | ||
|
||
for pattern in current_level.level_patterns: | ||
queue_pattern(pattern) | ||
|
||
func queue_pattern(pattern: int): | ||
for type in LevelPatterns.patterns[pattern]: | ||
level_queue.add_item(type) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters