1234567891011121314151617181920212223242526272829303132333435 |
- extends Node
- const MAX_LEVEL = 3
- var current_scene = null
- var level = 1
- var spell_level = 1
- var learn_spell = [true, false, false, false, false, false, false, false]
- func _ready():
- var root = get_tree().get_root()
- current_scene = root.get_child(root.get_child_count() -1)
- func goto_scene(scene):
- var s = ResourceLoader.load(scene)
- print("Going from \"" + current_scene.get_filename() + "\"")
- print(" to \"" + scene + "\"")
- current_scene.queue_free()
- current_scene = s.instance()
- get_tree().get_root().add_child(current_scene)
- func next_level():
- if learn_spell[level - 1]:
- spell_level += 1
- level += 1
- var next_scene = ""
- if level <= MAX_LEVEL:
- next_scene = "res://Scenes/levels/level_" + str(level) + ".xscn"
- print("You beat the level!")
- else:
- next_scene = "res://Scenes/main_menu.xscn"
- print("You won the game!")
- goto_scene(next_scene)
|