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