onready var bread = get_parent().get_node("Bread")
onready var egg = get_parent().get_node("Egg")
onready var granola = get_parent().get_node("Granola bar")
onready var vienna = get_parent().get_node("Vienna sausage")
onready var eat = get_parent().get_node("Eat")
onready var cook = get_parent().get_node("Cook")
onready var energy_bar
onready var sandwich = 0
onready var cookables = 0 # number of selected ingredients that can be cooked by itself
onready var ingredient_number = 0
# an array containing all of the selected ingredients
onready var ingredients = []
# Called when the node enters the scene tree for the first time.
func _ready():
pass # Replace with function body.
func giveUI(dia):
func giveUI(dia): #passes dialogue box node
dialogue = dia
func passEvent(handler):
func passEvent(handler): # retrieves energy bar from event handler
energy_bar = handler.give_energy_bar()
func _selected_ing(ingredient):
ingredients.append(ingredient)
print(ingredients)
func _selected_ing(ingredient): # when an ingredient is selected
ingredients.append(ingredient)
print(ingredients.size())
print(ingredients)
updateUI()
func _unselected_ing(ingredient):
func _unselected_ing(ingredient): # when an ingredient is unselected
ingredients.erase(ingredient)
print(ingredients.size())
if ingredients.size() == 0:
if ingredients.size() == 0: # reset flavor text
dialogue.text = ""
updateUI()
print(ingredients.size())
print(ingredients)
updateUI()
func updateUI():
if ingredients.size() >= 1 and ingredients[0] != "Granola bar":
func updateUI(): # whenever there's a change in selections
if ingredients.size() >= 1 and ingredients[0] != "Granola bar": # if anything aside from the granola bar is selected, as it can't be cooked in a recipe
granola.interactable = false
granola.modulate = Color("#616161")
granola.modulate = Color("#616161") # turn grey
eat.hide()
match ingredients.size():
0:
0: # reset if none is selected
granola.interactable = true
granola.modulate = Color("#ffffff")
eat.hide()
cook.hide()
1:
1: # flavor text and options for singular ingredients
if ingredients[0] != "Egg":
eat.show()
var flavor = get_parent().get_node(ingredients[0]).flavorText
...
...
@@ -60,7 +61,7 @@ func updateUI():
cook.hide()
"Egg", "Vienna sausage":
cook.show()
2:
2: # variations on sandwich, or a non-recipe
if ingredients.has("Bread"):
if ingredients.has("Egg"):
dialogue.text = "An egg sandwich. Requires 15 energy and gives 34 energy."
...
...
@@ -70,12 +71,11 @@ func updateUI():
else:
dialogue.text = "I don't think this makes a meal together."
cook.hide()
3:
3: # a full sandwich
dialogue.text = "An egg and sausage sandwich. Requires 20 energy and gives 40 energy."
cook.show()
func clearFridge():
func clearFridge(): # clear out the consumed ingredients