Commit 22686a7e authored by Julia Santos's avatar Julia Santos

Commented parts of the energy and event handler

parent e73e38b6
extends Control
#UI elements
onready var dialogue
onready var energy_bar
#ingredients
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
for ing in ingredients:
get_parent().get_node(ing).queue_free()
ingredients.clear()
......
......@@ -14,6 +14,7 @@ onready var kitchen = get_parent().get_node("Kitchen")
onready var laundryBasket = get_parent().get_node("Laundry basket")
onready var laundryArea = get_parent().get_node("Laundry area")
onready var fridge = get_parent().get_node("Fridge")
#functioning stuff
onready var quests = notepad.get_node("Quests")
......@@ -27,61 +28,55 @@ func _ready():
get_node(item).passEvent(self)
connect_stools()
func zoom_in():
func zoom_in(): # for close up perspectives without some UI
moxie.hide()
inventory.hide()
left.hide()
right.hide()
deselect.hide()
func zoom_out():
func zoom_out(): # for returning from close up perspectives
moxie.show()
inventory.show()
get_parent().get_node("UI/Movement Handler").check_arrows()
get_parent().get_node("UI/Movement Handler").check_arrows() # show arrows depending on situation
deselect.show()
func _get_notebook():
func _get_notebook(): # when To Do list is retrieved for the first time
notepad.show()
right.show()
_return_laundry()
quests.add("Eat")
quests.add("Put away groceries")
func _laundry_basket():
func _laundry_basket(): # looking at the laundry basket view
bedroom.hide()
laundryBasket.show()
zoom_in()
func _return_laundry():
func _return_laundry(): # returning from laundry basket view
laundryBasket.hide()
bedroom.show()
zoom_out()
func _return_fridge():
fridge.hide()
kitchen.show()
zoom_out()
notepad.show()
func _open_fridge():
func _open_fridge(): # looking into the fridge
kitchen.hide()
fridge.show()
zoom_in()
notepad.hide()
func connect_stools():
func _return_fridge(): # returning from fridge view
fridge.hide()
kitchen.show()
zoom_out()
notepad.show()
func connect_stools(): # connecting the two instances of the stool so that one disappears when the other is retrieved
get_parent().get_node("Laundry area/Stool").giveStool(get_parent().get_node("Kitchen/Stool"))
get_parent().get_node("Kitchen/Stool").giveStool(get_parent().get_node("Laundry area/Stool"))
func _groceries_put_away():
func _groceries_put_away(): # when the groceries are put away
fridge.get_node("Granola bar").show()
laundryArea.get_node("Laundry door").flavorText = "Open sesame!"
func give_energy_bar():
func give_energy_bar(): # returns energy bar node
return energy
# Called every frame. 'delta' is the elapsed time since the previous frame.
#func _process(delta):
# pass
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment