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

Commented parts of the energy and event handler

parent e73e38b6
extends Control extends Control
#UI elements
onready var dialogue onready var dialogue
onready var energy_bar
#ingredients
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
func clearFridge():
for ing in ingredients: for ing in ingredients:
get_parent().get_node(ing).queue_free() get_parent().get_node(ing).queue_free()
ingredients.clear() ingredients.clear()
......
...@@ -14,6 +14,7 @@ onready var kitchen = get_parent().get_node("Kitchen") ...@@ -14,6 +14,7 @@ onready var kitchen = get_parent().get_node("Kitchen")
onready var laundryBasket = get_parent().get_node("Laundry basket") onready var laundryBasket = get_parent().get_node("Laundry basket")
onready var laundryArea = get_parent().get_node("Laundry area") onready var laundryArea = get_parent().get_node("Laundry area")
onready var fridge = get_parent().get_node("Fridge") onready var fridge = get_parent().get_node("Fridge")
#functioning stuff #functioning stuff
onready var quests = notepad.get_node("Quests") onready var quests = notepad.get_node("Quests")
...@@ -27,61 +28,55 @@ func _ready(): ...@@ -27,61 +28,55 @@ func _ready():
get_node(item).passEvent(self) get_node(item).passEvent(self)
connect_stools() connect_stools()
func zoom_in(): func zoom_in(): # for close up perspectives without some UI
moxie.hide() moxie.hide()
inventory.hide() inventory.hide()
left.hide() left.hide()
right.hide() right.hide()
deselect.hide() deselect.hide()
func zoom_out(): func zoom_out(): # for returning from close up perspectives
moxie.show() moxie.show()
inventory.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() deselect.show()
func _get_notebook(): # when To Do list is retrieved for the first time
func _get_notebook():
notepad.show() notepad.show()
right.show() right.show()
_return_laundry() _return_laundry()
quests.add("Eat") quests.add("Eat")
quests.add("Put away groceries") quests.add("Put away groceries")
func _laundry_basket(): # looking at the laundry basket view
func _laundry_basket():
bedroom.hide() bedroom.hide()
laundryBasket.show() laundryBasket.show()
zoom_in() zoom_in()
func _return_laundry(): func _return_laundry(): # returning from laundry basket view
laundryBasket.hide() laundryBasket.hide()
bedroom.show() bedroom.show()
zoom_out() zoom_out()
func _return_fridge(): func _open_fridge(): # looking into the fridge
fridge.hide()
kitchen.show()
zoom_out()
notepad.show()
func _open_fridge():
kitchen.hide() kitchen.hide()
fridge.show() fridge.show()
zoom_in() zoom_in()
notepad.hide() 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("Laundry area/Stool").giveStool(get_parent().get_node("Kitchen/Stool"))
get_parent().get_node("Kitchen/Stool").giveStool(get_parent().get_node("Laundry area/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() fridge.get_node("Granola bar").show()
laundryArea.get_node("Laundry door").flavorText = "Open sesame!" laundryArea.get_node("Laundry door").flavorText = "Open sesame!"
func give_energy_bar(): func give_energy_bar(): # returns energy bar node
return energy 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