Commit e73e38b6 authored by Julia Santos's avatar Julia Santos

Implemented energy system, included aspect of grocery puzzle

parent fc6a18c3
extends Control extends Control
onready var dialogue
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
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):
dialogue = dia
func passEvent(handler):
energy_bar = handler.give_energy_bar()
func _selected_ing(ingredient):
ingredients.append(ingredient)
print(ingredients)
print(ingredients.size())
updateUI()
func _unselected_ing(ingredient):
ingredients.erase(ingredient)
print(ingredients.size())
if ingredients.size() == 0:
dialogue.text = ""
updateUI()
print(ingredients)
func updateUI():
if ingredients.size() >= 1 and ingredients[0] != "Granola bar":
granola.interactable = false
granola.modulate = Color("#616161")
eat.hide()
match ingredients.size():
0:
granola.interactable = true
granola.modulate = Color("#ffffff")
eat.hide()
cook.hide()
1:
if ingredients[0] != "Egg":
eat.show()
var flavor = get_parent().get_node(ingredients[0]).flavorText
dialogue.text = flavor
match ingredients[0]:
"Bread", "Granola bar":
cook.hide()
"Egg", "Vienna sausage":
cook.show()
2:
if ingredients.has("Bread"):
if ingredients.has("Egg"):
dialogue.text = "An egg sandwich. Requires 15 energy and gives 34 energy."
elif ingredients.has("Vienna sausage"):
dialogue.text = "A sausage sandwich. Requires 12 energy and gives 30 energy."
cook.show()
else:
dialogue.text = "I don't think this makes a meal together."
cook.hide()
3:
dialogue.text = "An egg and sausage sandwich. Requires 20 energy and gives 40 energy."
cook.show()
func clearFridge():
for ing in ingredients:
get_parent().get_node(ing).queue_free()
ingredients.clear()
updateUI()
dialogue.text = "Delicious!"
func cook():
match ingredients.size():
1:
match ingredients[0]:
"Egg":
energy_bar.value += 12
"Vienna sausage":
energy_bar.value += 10
2:
if ingredients.has("Bread"):
if ingredients.has("Egg"):
energy_bar.value += 17
elif ingredients.has("Vienna sausage"):
energy_bar.value += 14
3:
energy_bar.value += 20
clearFridge()
cook.hide()
func eat():
match ingredients[0]:
"Vienna sausage":
energy_bar.value += 12
"Bread":
energy_bar.value += 8
"Granola bar":
energy_bar.value += 10
clearFridge()
...@@ -6,11 +6,13 @@ onready var left = get_parent().get_node("UI/Left") ...@@ -6,11 +6,13 @@ onready var left = get_parent().get_node("UI/Left")
onready var right = get_parent().get_node("UI/Right") onready var right = get_parent().get_node("UI/Right")
onready var inventory = get_parent().get_node("UI/Inventory") onready var inventory = get_parent().get_node("UI/Inventory")
onready var deselect = get_parent().get_node("UI/Button") onready var deselect = get_parent().get_node("UI/Button")
onready var energy = get_parent().get_node("UI/Energy bar")
#rooms #rooms
onready var bedroom = get_parent().get_node("Bedroom") onready var bedroom = get_parent().get_node("Bedroom")
onready var kitchen = get_parent().get_node("Kitchen") 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 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")
...@@ -61,6 +63,7 @@ func _return_fridge(): ...@@ -61,6 +63,7 @@ func _return_fridge():
fridge.hide() fridge.hide()
kitchen.show() kitchen.show()
zoom_out() zoom_out()
notepad.show()
func _open_fridge(): func _open_fridge():
kitchen.hide() kitchen.hide()
...@@ -72,6 +75,13 @@ func connect_stools(): ...@@ -72,6 +75,13 @@ func connect_stools():
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():
fridge.get_node("Granola bar").show()
laundryArea.get_node("Laundry door").flavorText = "Open sesame!"
func give_energy_bar():
return energy
# Called every frame. 'delta' is the elapsed time since the previous frame. # Called every frame. 'delta' is the elapsed time since the previous frame.
#func _process(delta): #func _process(delta):
# pass # pass
extends "res://Item.gd"
onready var number = 0
signal selected_ing
signal unselected_ing
signal cook
signal eat
# booleans
onready var bread
onready var egg
onready var granola
onready var sausage
# Called when the node enters the scene tree for the first time.
func _ready():
connect("selected_ing", get_parent().get_node("Energy handler"), "_selected_ing")
connect("unselected_ing", get_parent().get_node("Energy handler"), "_unselected_ing")
connect("cook", get_parent().get_node("Energy handler"), "cook")
connect("eat", get_parent().get_node("Energy handler"), "eat")
func passUI(inv, dia, que):
.passUI(inv, dia, que)
get_parent().get_node("Energy handler").giveUI(dia)
func mouseInteraction():
match get_name():
"Bread":
if bread:
modulate = Color("#ffffff")
emit_signal("unselected_ing", get_name())
bread = false
else:
.mouseInteraction()
modulate = Color("#00ed2b")
emit_signal("selected_ing", get_name())
bread = true
"Egg":
if egg:
modulate = Color("#ffffff")
emit_signal("unselected_ing", get_name())
egg = false
else:
.mouseInteraction()
modulate = Color("#00ed2b")
emit_signal("selected_ing", get_name())
egg= true
"Granola bar":
if granola:
modulate = Color("#ffffff")
emit_signal("unselected_ing", get_name())
granola = false
else:
.mouseInteraction()
modulate = Color("#00ed2b")
emit_signal("selected_ing", get_name())
granola = true
"Vienna sausage":
if sausage:
modulate = Color("#ffffff")
emit_signal("unselected_ing", get_name())
sausage = false
else:
.mouseInteraction()
modulate = Color("#00ed2b")
emit_signal("selected_ing", get_name())
sausage = true
"Eat":
emit_signal("eat")
"Cook":
emit_signal("cook")
[gd_scene load_steps=14 format=2] [gd_scene load_steps=17 format=2]
[ext_resource path="res://assets/Thesis Clickables/bread.png" type="Texture" id=1] [ext_resource path="res://assets/Thesis Clickables/bread.png" type="Texture" id=1]
[ext_resource path="res://assets/Thesis Clickables/eggs.png" type="Texture" id=2] [ext_resource path="res://assets/Thesis Clickables/eggs.png" type="Texture" id=2]
[ext_resource path="res://assets/Placeholder BGs/ref inside.png" type="Texture" id=3] [ext_resource path="res://assets/Placeholder BGs/ref inside.png" type="Texture" id=3]
[ext_resource path="res://Item.gd" type="Script" id=4]
[ext_resource path="res://assets/Thesis Clickables/Vienna sausage.png" type="Texture" id=5] [ext_resource path="res://assets/Thesis Clickables/Vienna sausage.png" type="Texture" id=5]
[ext_resource path="res://assets/Thesis Clickables/Granola bar.png" type="Texture" id=6] [ext_resource path="res://assets/Thesis Clickables/Granola bar.png" type="Texture" id=6]
[ext_resource path="res://Return_fridge.gd" type="Script" id=7] [ext_resource path="res://Return_fridge.gd" type="Script" id=7]
[ext_resource path="res://Energy handler.gd" type="Script" id=8] [ext_resource path="res://Energy handler.gd" type="Script" id=8]
[ext_resource path="res://Food.gd" type="Script" id=9]
[ext_resource path="res://assets/Thesis Clickables/eat button.png" type="Texture" id=10]
[ext_resource path="res://assets/Thesis Clickables/cook button.png" type="Texture" id=11]
[sub_resource type="RectangleShape2D" id=1] [sub_resource type="RectangleShape2D" id=1]
extents = Vector2( 14.2862, 14.7497 ) extents = Vector2( 14.2862, 14.7497 )
...@@ -25,6 +27,9 @@ extents = Vector2( 17.4279, 15.7667 ) ...@@ -25,6 +27,9 @@ extents = Vector2( 17.4279, 15.7667 )
flags = 4 flags = 4
load_path = "res://.import/return arrow.png-ba7c2fea6c5a220a249845f29bbe9177.stex" load_path = "res://.import/return arrow.png-ba7c2fea6c5a220a249845f29bbe9177.stex"
[sub_resource type="RectangleShape2D" id=6]
extents = Vector2( 15.0752, 12.5446 )
[node name="Fridge" type="Node2D"] [node name="Fridge" type="Node2D"]
[node name="ref inside" type="Sprite" parent="."] [node name="ref inside" type="Sprite" parent="."]
...@@ -55,7 +60,7 @@ __meta__ = { ...@@ -55,7 +60,7 @@ __meta__ = {
[node name="Bread" type="StaticBody2D" parent="."] [node name="Bread" type="StaticBody2D" parent="."]
position = Vector2( 902.817, 254.199 ) position = Vector2( 902.817, 254.199 )
input_pickable = true input_pickable = true
script = ExtResource( 4 ) script = ExtResource( 9 )
__meta__ = { __meta__ = {
"_edit_group_": true "_edit_group_": true
} }
...@@ -75,7 +80,7 @@ texture = ExtResource( 1 ) ...@@ -75,7 +80,7 @@ texture = ExtResource( 1 )
[node name="Egg" type="StaticBody2D" parent="."] [node name="Egg" type="StaticBody2D" parent="."]
position = Vector2( 649.603, 329.114 ) position = Vector2( 649.603, 329.114 )
input_pickable = true input_pickable = true
script = ExtResource( 4 ) script = ExtResource( 9 )
__meta__ = { __meta__ = {
"_edit_group_": true "_edit_group_": true
} }
...@@ -93,9 +98,10 @@ scale = Vector2( 0.0381084, 0.0381084 ) ...@@ -93,9 +98,10 @@ scale = Vector2( 0.0381084, 0.0381084 )
texture = ExtResource( 2 ) texture = ExtResource( 2 )
[node name="Granola bar" type="StaticBody2D" parent="."] [node name="Granola bar" type="StaticBody2D" parent="."]
visible = false
position = Vector2( 489.284, 336.606 ) position = Vector2( 489.284, 336.606 )
input_pickable = true input_pickable = true
script = ExtResource( 4 ) script = ExtResource( 9 )
__meta__ = { __meta__ = {
"_edit_group_": true "_edit_group_": true
} }
...@@ -115,7 +121,7 @@ texture = ExtResource( 6 ) ...@@ -115,7 +121,7 @@ texture = ExtResource( 6 )
[node name="Vienna sausage" type="StaticBody2D" parent="."] [node name="Vienna sausage" type="StaticBody2D" parent="."]
position = Vector2( 349.941, 321.623 ) position = Vector2( 349.941, 321.623 )
input_pickable = true input_pickable = true
script = ExtResource( 4 ) script = ExtResource( 9 )
__meta__ = { __meta__ = {
"_edit_group_": true "_edit_group_": true
} }
...@@ -151,3 +157,45 @@ shape = SubResource( 4 ) ...@@ -151,3 +157,45 @@ shape = SubResource( 4 )
position = Vector2( -0.670166, 0.427979 ) position = Vector2( -0.670166, 0.427979 )
scale = Vector2( 0.0395079, 0.0395079 ) scale = Vector2( 0.0395079, 0.0395079 )
texture = SubResource( 5 ) texture = SubResource( 5 )
[node name="Cook" type="StaticBody2D" parent="."]
visible = false
position = Vector2( 445.529, 475.172 )
scale = Vector2( 0.8, 0.8 )
input_pickable = true
script = ExtResource( 9 )
__meta__ = {
"_edit_group_": true
}
interactable = true
[node name="CollisionShape2D" type="CollisionShape2D" parent="Cook"]
position = Vector2( -14.9377, -2.05679 )
scale = Vector2( 5, 5 )
shape = SubResource( 6 )
[node name="Sprite" type="Sprite" parent="Cook/CollisionShape2D"]
position = Vector2( 0.732666, -0.413818 )
scale = Vector2( 0.0395079, 0.0395079 )
texture = ExtResource( 11 )
[node name="Eat" type="StaticBody2D" parent="."]
visible = false
position = Vector2( 608.286, 478.539 )
scale = Vector2( 0.8, 0.8 )
input_pickable = true
script = ExtResource( 9 )
__meta__ = {
"_edit_group_": true
}
interactable = true
[node name="CollisionShape2D" type="CollisionShape2D" parent="Eat"]
position = Vector2( -14.9377, -2.05679 )
scale = Vector2( 5, 5 )
shape = SubResource( 6 )
[node name="Sprite" type="Sprite" parent="Eat/CollisionShape2D"]
position = Vector2( 0.732666, -0.413818 )
scale = Vector2( 0.0395079, 0.0395079 )
texture = ExtResource( 10 )
...@@ -20,4 +20,69 @@ extends Node ...@@ -20,4 +20,69 @@ extends Node
func _ready(): func _ready():
pass # Replace with function body. pass # Replace with function body.
#selected
#match ingredient:
# "Bread":
# eat.show()
# ingredient_number += 1
# sandwich += 1
# "Egg":
# eat.show()
# ingredient_number += 1
# sandwich += 1
# cookables += 1
# "Vienna sausage":
# eat.show()
# ingredient_number += 1
# sandwich += 1
# cookables += 1
#
# if ingredient_number > 0:
# granola.interactable = false
# granola.modulate = Color("#616161")
#
# if ingredient_number > 1:
# eat.hide()
# elif cookables > 1:
# cook.show()
# if cookables == 2: #2 cookables and bread
# if ingredient_number == 3:
# dialogue.text = "An egg and sausage sandwich. Requires 20 energy and gives 40 energy."
# cook.show()
# elif bread.visible and ingredient_number > 1: # bread and only 1 other ingredient
# cook.show()
# if egg.visible:
# dialogue.text = "An egg sandwich. Requires 15 energy and gives 35 energy."
# else:
# dialogue.text = "A sausage sandwich. Requires 15 energy and gives 35 energy."
# else:
# cook.hide()
#unselected
#match ingredient:
# "Bread":
# ingredient_number -= 1
# sandwich -= 1
# "Egg":
# ingredient_number -= 1
# cookables -= 1
# sandwich -= 1
# "Vienna sausage":
# ingredient_number -= 1
# cookables -= 1
# sandwich -= 1
#
# if ingredient_number == 1 and cookables == 1:
# cook.show()
# else:
# cook.hide()
#
# if !eat.visible:
# eat.show()
#
# if ingredient_number == 0:
# eat.hide()
# cook.hide()
# granola.interactable = true
# granola.modulate = Color("#ffffff")
# sandwich = 0
extends "res://Item.gd"
signal groceries_put_away
# Called when the node enters the scene tree for the first time.
func _ready():
pass # Replace with function body.
func objInteraction(selected): # when an object is used on it
var flavor = control.interaction(inventory.get_item_text(selected), self.get_name())
if typeof(flavor) != 0: #checks if there's coded flavor text for this interaction
dialogueBox.text = flavor
else:
dialogueBox.text = "No flavor text found" #can replace this later!
inventory.unselect_all()
if inventory.get_item_text(selected)=="Stool":
inventory.remove_item(selected)
emit_signal("groceries_put_away")
queue_free()
func passEvent(handler):
connect("groceries_put_away", handler,"_groceries_put_away")
pass
[gd_scene load_steps=11 format=2] [gd_scene load_steps=12 format=2]
[ext_resource path="res://assets/Placeholder BGs/laundry area.png" type="Texture" id=1] [ext_resource path="res://assets/Placeholder BGs/laundry area.png" type="Texture" id=1]
[ext_resource path="res://Item.gd" type="Script" id=2] [ext_resource path="res://Item.gd" type="Script" id=2]
[ext_resource path="res://assets/Thesis Clickables/stool.png" type="Texture" id=3] [ext_resource path="res://assets/Thesis Clickables/stool.png" type="Texture" id=3]
[ext_resource path="res://Stool.gd" type="Script" id=4] [ext_resource path="res://Stool.gd" type="Script" id=4]
[ext_resource path="res://Dialogue control - Laundry area.gd" type="Script" id=5] [ext_resource path="res://Dialogue control - Laundry area.gd" type="Script" id=5]
[ext_resource path="res://Groceries.gd" type="Script" id=6]
[sub_resource type="RectangleShape2D" id=1] [sub_resource type="RectangleShape2D" id=1]
extents = Vector2( 32.8504, 37.878 ) extents = Vector2( 32.8504, 37.878 )
...@@ -77,12 +78,12 @@ __meta__ = { ...@@ -77,12 +78,12 @@ __meta__ = {
position = Vector2( 335.711, 460.475 ) position = Vector2( 335.711, 460.475 )
scale = Vector2( 0.829244, 0.829244 ) scale = Vector2( 0.829244, 0.829244 )
input_pickable = true input_pickable = true
script = ExtResource( 2 ) script = ExtResource( 6 )
__meta__ = { __meta__ = {
"_edit_group_": true "_edit_group_": true
} }
interactable = true interactable = true
flavorText = "Might trip on these. But legs... Too short... Can't reach pantry shelves... Why did I put them so high up anyway?" flavorText = "Gotta put these away before they go bad or I trip on them. But legs... Too short... Can't reach pantry shelves... Why did I put them so high up anyway?"
[node name="CollisionShape2D" type="CollisionShape2D" parent="Groceries"] [node name="CollisionShape2D" type="CollisionShape2D" parent="Groceries"]
position = Vector2( 4.11099, 2.53656 ) position = Vector2( 4.11099, 2.53656 )
......
...@@ -55,12 +55,12 @@ items = [ NodePath("Laundry door"), NodePath("Groceries"), NodePath("Stool") ] ...@@ -55,12 +55,12 @@ items = [ NodePath("Laundry door"), NodePath("Groceries"), NodePath("Stool") ]
[node name="Fridge" parent="." instance=ExtResource( 17 )] [node name="Fridge" parent="." instance=ExtResource( 17 )]
visible = false visible = false
script = ExtResource( 4 ) script = ExtResource( 4 )
items = [ NodePath("Bread"), NodePath("Egg"), NodePath("Granola bar"), NodePath("Vienna sausage"), NodePath("Return") ] items = [ NodePath("Bread"), NodePath("Egg"), NodePath("Granola bar"), NodePath("Vienna sausage"), NodePath("Return"), NodePath("Cook"), NodePath("Eat") ]
[node name="Event Handler" type="Node2D" parent="."] [node name="Event Handler" type="Node2D" parent="."]
position = Vector2( 460.602, 18.6417 ) position = Vector2( 460.602, 18.6417 )
script = ExtResource( 12 ) script = ExtResource( 12 )
eventItems = [ NodePath("../Laundry basket/To do list"), NodePath("../Bedroom/Laundry basket"), NodePath("../Laundry basket/Return"), NodePath("../Fridge/Return"), NodePath("../Kitchen/Fridge") ] eventItems = [ NodePath("../Laundry basket/To do list"), NodePath("../Bedroom/Laundry basket"), NodePath("../Laundry basket/Return"), NodePath("../Fridge/Return"), NodePath("../Kitchen/Fridge"), NodePath("../Laundry area/Groceries"), NodePath("../Fridge/Energy handler") ]
[node name="Moxie" type="Sprite" parent="."] [node name="Moxie" type="Sprite" parent="."]
position = Vector2( 214.135, 386.725 ) position = Vector2( 214.135, 386.725 )
...@@ -209,14 +209,14 @@ __meta__ = { ...@@ -209,14 +209,14 @@ __meta__ = {
"_edit_use_anchors_": false "_edit_use_anchors_": false
} }
[node name="ProgressBar" type="ProgressBar" parent="UI"] [node name="Energy bar" type="ProgressBar" parent="UI"]
margin_left = -197.122 margin_left = -197.122
margin_top = -367.765 margin_top = -367.765
margin_right = 235.878 margin_right = 235.878
margin_bottom = -325.765 margin_bottom = -325.765
custom_styles/fg = SubResource( 3 ) custom_styles/fg = SubResource( 3 )
custom_styles/bg = SubResource( 4 ) custom_styles/bg = SubResource( 4 )
value = 80.0 value = 50.0
percent_visible = false percent_visible = false
__meta__ = { __meta__ = {
"_edit_use_anchors_": false "_edit_use_anchors_": false
......
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