82 lines
2.7 KiB
GDScript
82 lines
2.7 KiB
GDScript
extends Control
|
|
|
|
func _ready():
|
|
get_node("SaveNode").LoadVars("Repeating Task", 0)
|
|
get_node("SaveNode").SaveVars("Repeating Task", 0)
|
|
|
|
get_node("Main/Shop Panel").visible = false
|
|
get_node("Main/MoneyArea/Label").text = str(get_node("SaveNode").MainVars["Money"])
|
|
|
|
# if we don't need set-up, go to the tasks!
|
|
if CanLoadMain():
|
|
get_node("Animation").play("MainShow")
|
|
else:
|
|
get_node("Animation").play("SetupShow")
|
|
|
|
# functions in the node "Set-Up"
|
|
|
|
var NewText = ""
|
|
|
|
func _on_input_text_changed(new_text: String):
|
|
get_node("Set-Up/Verify Answer/Text").text = "Alright! You will be repeating \"" + new_text + "\" for the day!"
|
|
NewText = new_text
|
|
if !get_node("Animation").is_playing():
|
|
get_node("Animation").play("GearTurn")
|
|
|
|
func _on_confirm_pressed():
|
|
var Verifytext = get_node("Set-Up/Verify Answer/Text").text
|
|
if Verifytext == "" || Verifytext == "Alright! You will be repeating \"\" for the day!":
|
|
return
|
|
|
|
get_node("SaveNode").MainVars["Repeating Task"] = NewText
|
|
get_node("SaveNode").MainVars["System Time"] = Time.get_datetime_dict_from_system().day
|
|
get_node("SaveNode").SaveVars("Repeating Task", 0)
|
|
get_node("Animation").play("FromSetupToMain")
|
|
|
|
CanLoadMain()
|
|
|
|
# functions in the node "Main"
|
|
|
|
func CanLoadMain():
|
|
if get_node("SaveNode").MainVars["Repeating Task"] != "" && get_node("SaveNode").MainVars["System Time"] == Time.get_datetime_dict_from_system().day:
|
|
get_node("Main/Panel/Label").text = "Hey! Your task is currently: \"" + get_node("SaveNode").MainVars["Repeating Task"] + "\". Good Luck! Tip: every five minutes, press done."
|
|
return true
|
|
return false
|
|
|
|
func _on_complete_pressed():
|
|
if !get_node("Animation").is_playing():
|
|
get_node("Animation").play("Win")
|
|
MoneyChange(10)
|
|
|
|
func _on_store_pressed():
|
|
if !get_node("Animation").is_playing():
|
|
if get_node("Main/Shop Panel").visible == false:
|
|
get_node("Animation").play("ShowShop")
|
|
else:
|
|
get_node("Animation").play("HideShop")
|
|
|
|
# Shop interface
|
|
|
|
func MoneyChange(amount: int = 0):
|
|
get_node("SaveNode").MainVars["Money"] += amount
|
|
get_node("SaveNode").SaveVars("Repeating Task", 0)
|
|
get_node("Main/MoneyArea/Label").text = str(get_node("SaveNode").MainVars["Money"])
|
|
|
|
func _on_buy_break_pressed():
|
|
if get_node("SaveNode").MainVars["Money"] >= 100:
|
|
MoneyChange(-100)
|
|
get_node("Animation").play("PurchaseAnimation")
|
|
|
|
func _on_buy_task_reset_pressed():
|
|
if get_node("SaveNode").MainVars["Money"] >= 150:
|
|
get_node("SaveNode").MainVars["Repeating Task"] = ""
|
|
MoneyChange(-150)
|
|
get_node("Animation").play("PurchaseAnimation")
|
|
|
|
func _on_buy_full_break_pressed():
|
|
if get_node("SaveNode").MainVars["Money"] >= 1000:
|
|
MoneyChange(-1000)
|
|
get_node("Animation").play("PurchaseAnimation")
|
|
|
|
func Animation_ExitGame():
|
|
get_tree().quit()
|