79 lines
3.1 KiB
GDScript
79 lines
3.1 KiB
GDScript
extends Node2D
|
|
|
|
##Onreadys
|
|
onready var levels = preload("res://maps/leveldata/levels.tres")
|
|
onready var title = $Title
|
|
onready var shard_title = $ShardTitle
|
|
onready var shard_arrow = $ShardArrow
|
|
onready var high_score = $HighScore
|
|
onready var golds = $Golds
|
|
onready var levelarrow_up = $LevelArrowUp
|
|
onready var levelarrow_down = $LevelArrowDown
|
|
#Shards
|
|
onready var shard0 = $ShardGraphics/Shard
|
|
onready var shard1 = $ShardGraphics/Shard2
|
|
onready var shard2 = $ShardGraphics/Shard3
|
|
onready var shard3 = $ShardGraphics/Shard4
|
|
onready var shard4 = $ShardGraphics/Shard5
|
|
onready var shard5 = $ShardGraphics/Shard6
|
|
onready var shard6 = $ShardGraphics/Shard7
|
|
onready var shard7 = $ShardGraphics/Shard8
|
|
onready var shard8 = $ShardGraphics/Shard9
|
|
onready var shard9 = $ShardGraphics/Shard10
|
|
##Runtime
|
|
var save = 0
|
|
var current_level = 0
|
|
var current_shard = 0
|
|
|
|
# Called when the node enters the scene tree for the first time.
|
|
func _ready():
|
|
pass
|
|
|
|
func _physics_process(delta):
|
|
if Input.is_action_just_pressed("ui_up"): change_current_level(-1)
|
|
if Input.is_action_just_pressed("ui_down"): change_current_level(1)
|
|
if Input.is_action_just_pressed("ui_left"): change_current_shard(-1)
|
|
if Input.is_action_just_pressed("ui_right"): change_current_shard(1)
|
|
#Draw level title
|
|
title.text = levels.level[current_level].level_title
|
|
#Draw Shard Title
|
|
shard_title.text = levels.level[current_level].shard_title[current_shard]
|
|
|
|
func change_current_shard(amount):
|
|
if current_shard + amount != -1 && current_shard + amount != 10: #Check if in range
|
|
current_shard += amount
|
|
shard_arrow.position.x += 15 * amount
|
|
|
|
func change_current_level(amount):
|
|
if current_level + amount != -1 && current_level + amount != levels.level.size(): #Check if in range
|
|
current_level += amount
|
|
#Show arrows or don't
|
|
if current_level == 0:
|
|
levelarrow_up.visible = false
|
|
levelarrow_down.visible = true
|
|
elif current_level == levels.level.size() - 1:
|
|
levelarrow_up.visible = true
|
|
levelarrow_down.visible = false
|
|
else:
|
|
levelarrow_down.visible = true
|
|
levelarrow_up.visible = true
|
|
#Return Shard select
|
|
current_shard = 0
|
|
shard_arrow.position.x = 61
|
|
#Load new data
|
|
var save = ConfigFile.new()
|
|
save.load(str("user://file") + str(Game.current_file) + str(".pr"))
|
|
#Draw score and golds
|
|
high_score.text = str("%06d" % save.get_value(str(current_level),"High Score",0))
|
|
golds.text = str("%02d" % save.get_value(str(current_level),"Golds",0))
|
|
#Draw shards collected
|
|
shard0.visible = save.get_value(str(current_level),"Shard0",false)
|
|
shard1.visible = save.get_value(str(current_level),"Shard1",false)
|
|
shard2.visible = save.get_value(str(current_level),"Shard2",false)
|
|
shard3.visible = save.get_value(str(current_level),"Shard3",false)
|
|
shard4.visible = save.get_value(str(current_level),"Shard4",false)
|
|
shard5.visible = save.get_value(str(current_level),"Shard5",false)
|
|
shard6.visible = save.get_value(str(current_level),"Shard6",false)
|
|
shard7.visible = save.get_value(str(current_level),"Shard7",false)
|
|
shard8.visible = save.get_value(str(current_level),"Shard8",false)
|
|
shard9.visible = save.get_value(str(current_level),"Shard9",false)
|