From 7a4f3d4c59d01443157202d7bcd70c56677ac94f Mon Sep 17 00:00:00 2001 From: Kiskadee Date: Sun, 17 Oct 2021 05:10:15 +0100 Subject: [PATCH 1/2] Customer speech bubbles --- game/autoloads/OrderRepository.gd | 7 + game/customer/GenericCustomer.gd | 12 +- game/customer/GenericCustomer.tscn | 6 +- .../speech_bubble/Control_SpeechBubble.tscn | 121 ++++++++++++++++++ .../speech_bubble/SpatialSpeechBubble.gd | 79 ++++++++++++ .../speech_bubble/SpatialSpeechBubble.tscn | 37 ++++++ 6 files changed, 256 insertions(+), 6 deletions(-) create mode 100644 game/customer/speech_bubble/Control_SpeechBubble.tscn create mode 100644 game/customer/speech_bubble/SpatialSpeechBubble.gd create mode 100644 game/customer/speech_bubble/SpatialSpeechBubble.tscn diff --git a/game/autoloads/OrderRepository.gd b/game/autoloads/OrderRepository.gd index 5e7581c..53ea4b2 100644 --- a/game/autoloads/OrderRepository.gd +++ b/game/autoloads/OrderRepository.gd @@ -14,6 +14,13 @@ var translations:Dictionary = { possible_orders.coffee_cappuccino:"Cappuccino", } +var order_textures:Dictionary = { + possible_orders.coffee_americano:preload("res://art_assets/ui/logoCupAmericano.png"), + possible_orders.coffee_espresso:preload("res://art_assets/ui/logoCupEspresso.png"), + possible_orders.coffee_latte:preload("res://art_assets/ui/logoCupLatte.png"), + possible_orders.coffee_cappuccino:preload("res://art_assets/ui/logoCupCappuccino.png"), +} + func get_coffe_name(coffee_type: int) -> String: if coffee_type in translations.keys(): return translations[coffee_type] diff --git a/game/customer/GenericCustomer.gd b/game/customer/GenericCustomer.gd index f08a675..f437c88 100644 --- a/game/customer/GenericCustomer.gd +++ b/game/customer/GenericCustomer.gd @@ -41,10 +41,7 @@ onready var customer_generated_food_order = OrderRepository.generate_order(custo var allocated_spot:Spatial = null -var _current_position:Vector3 = Vector3() -var _last_frame_position:Vector3 = Vector3() -onready var customer_mesh:Spatial = $customer -onready var rotation_mesh:Spatial = $MeshInstance +onready var speech_bubble = $SpeechBubble var order_score = 0 @@ -86,13 +83,17 @@ func deliver_order_to_barista()->void: barista_took_order = true go_waiting_spot() OrderRepository.add_order(self, customer_generated_food_order) + speech_bubble.render_orders(customer_generated_food_order) + speech_bubble.show_bubble() func receive_order(received_item:int)->bool: #True = the delivered item is correct if received_item in customer_generated_food_order: customer_generated_food_order.erase(received_item) if customer_generated_food_order.empty(): needs_fullfilled() - return true + speech_bubble.hide_bubble() + return true + speech_bubble.render_orders(customer_generated_food_order) return false func go_ask_for_food_spot()->Spatial: @@ -174,6 +175,7 @@ func _physics_process(delta): order_score = OrderRepository.compare_order(OrderRepository.barista_prepared_order, OrderRepository.get_order(self)) print("The customer gave a rating to the food: ", order_score) OrderRepository.remove_order(self) + speech_bubble.hide_bubble() var will_stay_or_leave = rand_range(100, 105) if will_stay_or_leave < 10: leave_and_go_away() diff --git a/game/customer/GenericCustomer.tscn b/game/customer/GenericCustomer.tscn index 19f5554..262d74d 100644 --- a/game/customer/GenericCustomer.tscn +++ b/game/customer/GenericCustomer.tscn @@ -1,8 +1,9 @@ -[gd_scene load_steps=7 format=2] +[gd_scene load_steps=8 format=2] [ext_resource path="res://game/customer/GenericCustomer.gd" type="Script" id=1] [ext_resource path="res://art_assets/customer/customer.gltf" type="PackedScene" id=2] [ext_resource path="res://game/customer/CustomerClick.gd" type="Script" id=3] +[ext_resource path="res://game/customer/speech_bubble/SpatialSpeechBubble.tscn" type="PackedScene" id=4] [sub_resource type="CapsuleMesh" id=1] @@ -45,6 +46,9 @@ script = ExtResource( 3 ) transform = Transform( 1, 0, 0, 0, -4.37114e-08, -1, 0, 1, -4.37114e-08, 0, 0.321759, 0 ) shape = SubResource( 3 ) +[node name="SpeechBubble" parent="." instance=ExtResource( 4 )] +transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.68207, 0 ) + [connection signal="timeout" from="MaxWaitingTime" to="." method="_on_MaxWaitingTime_timeout"] [connection signal="input_event" from="Selection and stuff/AreaUserCustomerInteraction" to="Selection and stuff" method="_on_AreaUserCustomerInteraction_input_event"] [connection signal="mouse_entered" from="Selection and stuff/AreaUserCustomerInteraction" to="Selection and stuff" method="_on_AreaUserCustomerInteraction_mouse_entered"] diff --git a/game/customer/speech_bubble/Control_SpeechBubble.tscn b/game/customer/speech_bubble/Control_SpeechBubble.tscn new file mode 100644 index 0000000..bff7770 --- /dev/null +++ b/game/customer/speech_bubble/Control_SpeechBubble.tscn @@ -0,0 +1,121 @@ +[gd_scene load_steps=3 format=2] + +[ext_resource path="res://art_assets/ui/logoCupAmericano.png" type="Texture" id=1] +[ext_resource path="res://art_assets/ui/wordbubble.png" type="Texture" id=2] + +[node name="Control_SpeechBubble" type="Control"] +anchor_right = 1.0 +anchor_bottom = 1.0 +rect_min_size = Vector2( 20, 20 ) +input_pass_on_modal_close_click = false +size_flags_horizontal = 3 +size_flags_vertical = 3 +__meta__ = { +"_edit_use_anchors_": false +} + +[node name="CenterContainer" type="CenterContainer" parent="."] +anchor_right = 1.0 +anchor_bottom = 1.0 +margin_left = 3.96844 +margin_top = -9.52441 +margin_right = 3.96851 +margin_bottom = -9.52441 +size_flags_horizontal = 3 +size_flags_vertical = 3 +__meta__ = { +"_edit_use_anchors_": false +} + +[node name="MarginContainer1" type="MarginContainer" parent="CenterContainer"] +margin_left = 522.0 +margin_top = 325.0 +margin_right = 758.0 +margin_bottom = 395.0 +custom_constants/margin_right = 20 +custom_constants/margin_top = 0 +custom_constants/margin_left = 20 + +[node name="NinePatchRect" type="NinePatchRect" parent="CenterContainer/MarginContainer1"] +self_modulate = Color( 1, 1, 1, 0.537255 ) +margin_left = 20.0 +margin_right = 216.0 +margin_bottom = 70.0 +texture = ExtResource( 2 ) +patch_margin_left = 20 +patch_margin_top = 20 +patch_margin_right = 20 +patch_margin_bottom = 50 +__meta__ = { +"_edit_use_anchors_": false +} + +[node name="MarginContainer2" type="MarginContainer" parent="CenterContainer/MarginContainer1"] +margin_left = 20.0 +margin_right = 216.0 +margin_bottom = 70.0 +custom_constants/margin_right = 10 +custom_constants/margin_left = 10 + +[node name="CenterContainer" type="CenterContainer" parent="CenterContainer/MarginContainer1/MarginContainer2"] +margin_left = 10.0 +margin_right = 186.0 +margin_bottom = 70.0 + +[node name="HBoxContainer" type="HBoxContainer" parent="CenterContainer/MarginContainer1/MarginContainer2/CenterContainer"] +margin_top = 19.0 +margin_right = 176.0 +margin_bottom = 51.0 +size_flags_horizontal = 3 +size_flags_vertical = 3 +__meta__ = { +"_edit_use_anchors_": false +} + +[node name="TextureRect" type="TextureRect" parent="CenterContainer/MarginContainer1/MarginContainer2/CenterContainer/HBoxContainer"] +margin_right = 32.0 +margin_bottom = 32.0 +rect_min_size = Vector2( 32, 32 ) +size_flags_vertical = 0 +texture = ExtResource( 1 ) +expand = true + +[node name="TextureRect2" type="TextureRect" parent="CenterContainer/MarginContainer1/MarginContainer2/CenterContainer/HBoxContainer"] +margin_left = 36.0 +margin_right = 68.0 +margin_bottom = 32.0 +rect_min_size = Vector2( 32, 32 ) +size_flags_vertical = 0 +texture = ExtResource( 1 ) +expand = true +stretch_mode = 6 + +[node name="TextureRect3" type="TextureRect" parent="CenterContainer/MarginContainer1/MarginContainer2/CenterContainer/HBoxContainer"] +margin_left = 72.0 +margin_right = 104.0 +margin_bottom = 32.0 +rect_min_size = Vector2( 32, 32 ) +size_flags_vertical = 0 +texture = ExtResource( 1 ) +expand = true +stretch_mode = 6 + +[node name="TextureRect4" type="TextureRect" parent="CenterContainer/MarginContainer1/MarginContainer2/CenterContainer/HBoxContainer"] +margin_left = 108.0 +margin_right = 140.0 +margin_bottom = 32.0 +rect_min_size = Vector2( 32, 32 ) +size_flags_vertical = 0 +texture = ExtResource( 1 ) +expand = true +stretch_mode = 6 + +[node name="TextureRect5" type="TextureRect" parent="CenterContainer/MarginContainer1/MarginContainer2/CenterContainer/HBoxContainer"] +margin_left = 144.0 +margin_right = 176.0 +margin_bottom = 32.0 +rect_min_size = Vector2( 32, 32 ) +size_flags_vertical = 0 +texture = ExtResource( 1 ) +expand = true +stretch_mode = 6 diff --git a/game/customer/speech_bubble/SpatialSpeechBubble.gd b/game/customer/speech_bubble/SpatialSpeechBubble.gd new file mode 100644 index 0000000..b9cdc4a --- /dev/null +++ b/game/customer/speech_bubble/SpatialSpeechBubble.gd @@ -0,0 +1,79 @@ +extends Spatial + + +onready var hbox = $SpatialLabelSprite/Viewport/Control_SpeechBubble/CenterContainer/MarginContainer1/MarginContainer2/CenterContainer/HBoxContainer +onready var speechbubble = $SpatialLabelSprite/Viewport/Control_SpeechBubble + +export (Array, Texture) var order_textures + +var visibility_transition:bool = false +var show:bool = false + +#noderef:order_item +var sprites:Dictionary = { + +} + + +func add_item(sprite:Texture, order_id:int)->bool: + if sprite in sprites: + return false + if order_id > len(order_textures): + printerr("Order id is greater than the amount of images for the orders ", get_stack()) + return false + sprites[sprite] = order_id + var texture:TextureRect = TextureRect.new() + texture.expand = true + texture.stretch_mode = TextureRect.STRETCH_SCALE_ON_EXPAND + texture.rect_min_size = Vector2(32,32) + texture.rect_size = texture.rect_min_size + texture.size_flags_vertical = false + hbox.add_child(texture) + texture.texture = order_textures[order_id] + return true + +func remove_item(order_id:int)->bool: + for key in sprites: + if sprites[key] == order_id: + sprites.erase(key) + key.queue_free() + return true + return false + +func reset()->void: + for key in sprites: + sprites.erase(key) + key.queue_free() + +func render_orders(order_array:Array): + reset() + var childs = hbox.get_children() + for i in childs: + if not (i in sprites): + i.queue_free() + for order in order_array: + var texture:Texture = OrderRepository.order_textures[order] + add_item(texture, order) + + +func show_bubble(): + var current:Color = speechbubble.modulate + var tween = $Tween + tween.interpolate_property(speechbubble, "modulate", + current, Color.white, 2, + Tween.TRANS_LINEAR, Tween.EASE_IN_OUT) + tween.start() + + pass + speechbubble.modulate.a + +func hide_bubble(): + var current:Color = speechbubble.modulate + var tween = $Tween + tween.interpolate_property(speechbubble, "modulate", + current, Color.transparent, 2, + Tween.TRANS_LINEAR, Tween.EASE_IN_OUT) + tween.start() + +func _ready(): + speechbubble.modulate = Color.transparent diff --git a/game/customer/speech_bubble/SpatialSpeechBubble.tscn b/game/customer/speech_bubble/SpatialSpeechBubble.tscn new file mode 100644 index 0000000..4b71e4c --- /dev/null +++ b/game/customer/speech_bubble/SpatialSpeechBubble.tscn @@ -0,0 +1,37 @@ +[gd_scene load_steps=8 format=2] + +[ext_resource path="res://game/customer/speech_bubble/SpatialSpeechBubble.gd" type="Script" id=1] +[ext_resource path="res://art_assets/ui/logoCupEspresso.png" type="Texture" id=2] +[ext_resource path="res://art_assets/ui/logoCupCappuccino.png" type="Texture" id=3] +[ext_resource path="res://art_assets/ui/logoCupLatte.png" type="Texture" id=4] +[ext_resource path="res://art_assets/ui/logoCupAmericano.png" type="Texture" id=5] +[ext_resource path="res://game/customer/speech_bubble/Control_SpeechBubble.tscn" type="PackedScene" id=6] + +[sub_resource type="ViewportTexture" id=1] +flags = 4 +viewport_path = NodePath("SpatialLabelSprite/Viewport") + +[node name="SpatialHbox" type="Spatial"] +script = ExtResource( 1 ) +order_textures = [ ExtResource( 5 ), ExtResource( 2 ), ExtResource( 4 ), ExtResource( 3 ) ] + +[node name="SpatialLabelSprite" type="Spatial" parent="."] + +[node name="Viewport" type="Viewport" parent="SpatialLabelSprite"] +size = Vector2( 640, 640 ) +transparent_bg = true +handle_input_locally = false +hdr = false +usage = 0 +render_target_v_flip = true +gui_disable_input = true + +[node name="Control_SpeechBubble" parent="SpatialLabelSprite/Viewport" instance=ExtResource( 6 )] + +[node name="Sprite3D" type="Sprite3D" parent="SpatialLabelSprite"] +cast_shadow = 0 +generate_lightmap = false +billboard = 1 +texture = SubResource( 1 ) + +[node name="Tween" type="Tween" parent="."] From a8411d2c5cf00bc17318e8bfacbcbbf5f7025ac3 Mon Sep 17 00:00:00 2001 From: outfrost Date: Sun, 17 Oct 2021 06:46:56 +0200 Subject: [PATCH 2/2] Move clock --- level/Cafe.tscn | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/level/Cafe.tscn b/level/Cafe.tscn index 2de3707..6f660d2 100644 --- a/level/Cafe.tscn +++ b/level/Cafe.tscn @@ -618,7 +618,7 @@ transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 3.5, 3, 0 ) transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, -3.5, 3, 0 ) [node name="landscape" parent="LevelStatics/Decorations" instance=ExtResource( 22 )] -transform = Transform( -2, 0, -3.01992e-07, 0, 2, 0, 3.01992e-07, 0, -2, -3.01, 1.9, -5.51 ) +transform = Transform( -2, 0, -3.01992e-07, 0, 2, 0, 3.01992e-07, 0, -2, -3.41, 1.9, -5.51 ) [node name="winter" parent="LevelStatics/Decorations" instance=ExtResource( 36 )] transform = Transform( 3.89414e-07, 0, -2, 0, 2, 0, 2, 0, 3.89414e-07, -5.51, 1.9, 1.5 ) @@ -636,7 +636,7 @@ transform = Transform( -8.74228e-08, 0, -2, 0, 2, 0, 2, 0, -8.74228e-08, -5.5, 1 transform = Transform( 0.707107, 0, 0.707107, 0, 1, 0, -0.707107, 0, 0.707107, 5.32, 1.8, 2.64 ) [node name="calendar2" parent="LevelStatics/Decorations" instance=ExtResource( 37 )] -transform = Transform( -2, 0, -3.01992e-07, 0, 2, 0, 3.01992e-07, 0, -2, -1.11, 1.8, -5.5 ) +transform = Transform( -2, 0, -3.01992e-07, 0, 2, 0, 3.01992e-07, 0, -2, -0.51, 1.8, -5.5 ) [node name="poster-1" parent="LevelStatics/Decorations" instance=ExtResource( 27 )] transform = Transform( -1, 0, 8.74228e-08, 0, 1, 0, -8.74228e-08, 0, -1, 4.69, 1.8, -5.5 ) @@ -1216,4 +1216,4 @@ transform = Transform( -4.37114e-08, 0, 1, 0, 1, 0, -1, 0, -4.37114e-08, 0.325, transform = Transform( -4.37114e-08, 0, 1, 0, 1, 0, -1, 0, -4.37114e-08, -4.075, 0, 5.15 ) [node name="Clock" parent="LevelStatics" instance=ExtResource( 58 )] -transform = Transform( -4.37114e-08, 0, 1, 0, 1, 0, -1, 0, -4.37114e-08, -5.475, 2.6, 0.2 ) +transform = Transform( 1, 0, 1.06581e-14, 0, 1, 0, -1.06581e-14, 0, 1, -1.61, 2.4, -5.475 )