diff --git a/house.tscn b/house.tscn index fb8a675..68a77b5 100644 --- a/house.tscn +++ b/house.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=129 format=2] +[gd_scene load_steps=131 format=2] [ext_resource path="res://baked_light_maps/LightMap13.png" type="Texture" id=1] [ext_resource path="res://baked_light_maps/LightMap23.png" type="Texture" id=2] @@ -93,6 +93,7 @@ [ext_resource path="res://baked_light_maps/LightMap35.png" type="Texture" id=91] [ext_resource path="res://baked_light_maps/LightMap15.png" type="Texture" id=92] [ext_resource path="res://scripts/Counter.gd" type="Script" id=93] +[ext_resource path="res://scripts/Cup.gd" type="Script" id=94] [sub_resource type="BakedLightmapData" id=1] bounds = AABB( -15.4245, -6.32598, -10.8367, 30.8491, 12.652, 21.6735 ) @@ -209,38 +210,41 @@ extents = Vector3( 8.21697, 5.09508, 2.57927 ) [sub_resource type="BoxShape" id=25] extents = Vector3( 1.05268, 4.61627, 2.55698 ) -[sub_resource type="SpatialMaterial" id=26] +[sub_resource type="BoxShape" id=26] +extents = Vector3( 0.307867, 0.292225, 0.228886 ) + +[sub_resource type="SpatialMaterial" id=27] albedo_color = Color( 0.411765, 0.411765, 0.411765, 1 ) -[sub_resource type="PlaneMesh" id=27] -material = SubResource( 26 ) +[sub_resource type="PlaneMesh" id=28] +material = SubResource( 27 ) size = Vector2( 30, 25 ) -[sub_resource type="PhysicsMaterial" id=28] +[sub_resource type="PhysicsMaterial" id=29] -[sub_resource type="BoxShape" id=29] +[sub_resource type="BoxShape" id=30] extents = Vector3( 1.92531, 63.5722, 132.438 ) -[sub_resource type="BoxShape" id=30] +[sub_resource type="BoxShape" id=31] extents = Vector3( 6.72167, 6.64167, 0.811614 ) -[sub_resource type="BoxShape" id=31] +[sub_resource type="BoxShape" id=32] extents = Vector3( 0.195678, 6.28887, 13.5598 ) -[sub_resource type="BoxShape" id=32] +[sub_resource type="BoxShape" id=33] extents = Vector3( 15.4606, 1, 0.721973 ) -[sub_resource type="BoxShape" id=33] +[sub_resource type="BoxShape" id=34] extents = Vector3( 15.0346, 1, 0.241463 ) -[sub_resource type="SpatialMaterial" id=34] +[sub_resource type="SpatialMaterial" id=35] emission_enabled = true emission = Color( 1, 1, 1, 1 ) emission_energy = 0.5 emission_operator = 0 emission_on_uv2 = false -[sub_resource type="CapsuleMesh" id=35] +[sub_resource type="CapsuleMesh" id=36] [node name="Level" type="Spatial"] script = ExtResource( 71 ) @@ -467,10 +471,24 @@ use_in_baked_light = true mesh = ExtResource( 29 ) material/0 = null +[node name="Cup" type="StaticBody" parent="House/Interactive"] +transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, -10.128, 8.613, -12.91 ) +script = ExtResource( 94 ) + +[node name="cup" type="MeshInstance" parent="House/Interactive/Cup"] +transform = Transform( -4.37114e-09, -0.1, 4.37114e-09, 0, -4.37114e-09, -0.1, 0.1, -4.37114e-09, 1.91069e-16, 0, 0, 0 ) +use_in_baked_light = true +mesh = ExtResource( 50 ) +material/0 = null + +[node name="CollisionShape" type="CollisionShape" parent="House/Interactive/Cup"] +transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, -0.245941, 0, 0 ) +shape = SubResource( 26 ) + [node name="Floor" type="MeshInstance" parent="House"] transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, -5.02677, 0, -8.42726 ) use_in_baked_light = true -mesh = SubResource( 27 ) +mesh = SubResource( 28 ) material/0 = null [node name="Objects" type="Spatial" parent="House"] @@ -523,12 +541,6 @@ use_in_baked_light = true mesh = ExtResource( 50 ) material/0 = null -[node name="cup4" type="MeshInstance" parent="House/Objects"] -transform = Transform( -4.37114e-09, -0.1, 4.37114e-09, 0, -4.37114e-09, -0.1, 0.1, -4.37114e-09, 1.91069e-16, -10.129, 8.62064, -12.8909 ) -use_in_baked_light = true -mesh = ExtResource( 50 ) -material/0 = null - [node name="estante" type="MeshInstance" parent="House/Objects"] transform = Transform( -4.37114e-09, 0, -0.1, 0, 0.1, 0, 0.1, 0, -4.37114e-09, -11.7643, 8.2627, -12.8918 ) use_in_baked_light = true @@ -640,11 +652,11 @@ material/0 = null [node name="wall_left" type="StaticBody" parent="House/Walls"] transform = Transform( 0.1, 0, 0, 0, 0.1, 0, 0, 0, 0.1, -19.897, 0, 0.217551 ) input_ray_pickable = false -physics_material_override = SubResource( 28 ) +physics_material_override = SubResource( 29 ) [node name="CollisionShape" type="CollisionShape" parent="House/Walls/wall_left"] transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, -1.13116, 62.3193, -86.7871 ) -shape = SubResource( 29 ) +shape = SubResource( 30 ) [node name="wall_deco" type="MeshInstance" parent="House/Walls/wall_left"] transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, -1.03, 0, -91.9755 ) @@ -687,11 +699,11 @@ material/0 = null [node name="CollisionShape" type="CollisionShape" parent="House/Walls/wall_to_hall"] transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 4.90353, 6.35394, -13.5157 ) -shape = SubResource( 30 ) +shape = SubResource( 31 ) [node name="CollisionShape2" type="CollisionShape" parent="House/Walls/wall_to_hall"] transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, -12.9399, 6.35394, -13.5157 ) -shape = SubResource( 30 ) +shape = SubResource( 31 ) [node name="wall_deco4" type="MeshInstance" parent="House/Walls/wall_to_hall"] transform = Transform( -4.37114e-09, 0, -0.1, 0, 0.1, 0, 0.1, 0, -4.37114e-09, 5.06242, 0, -13.7643 ) @@ -724,7 +736,7 @@ material/0 = null [node name="CollisionShape" type="CollisionShape" parent="House/Walls/wall_right"] transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 9.97591, 6.27322, -9.15217 ) -shape = SubResource( 31 ) +shape = SubResource( 32 ) [node name="wall_hall" type="StaticBody" parent="House/Walls"] input_ray_pickable = false @@ -752,14 +764,14 @@ material/0 = null [node name="CollisionShape" type="CollisionShape" parent="House/Walls/wall_hall"] transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, -4.89446, 0, -18.2286 ) -shape = SubResource( 32 ) +shape = SubResource( 33 ) [node name="4th_wall" type="StaticBody" parent="House/Walls"] input_ray_pickable = false [node name="CollisionShape" type="CollisionShape" parent="House/Walls/4th_wall"] transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, -5.03856, 0, 2.63837 ) -shape = SubResource( 33 ) +shape = SubResource( 34 ) [node name="light_bulb" type="MeshInstance" parent="House"] transform = Transform( 0.1, 0, 0, 0, 0.1, 0, 0, 0, 0.1, -5.34679, 9.9391, -4.33002 ) @@ -770,7 +782,7 @@ material/0 = null [node name="light_glow" type="MeshInstance" parent="House/light_bulb"] transform = Transform( 3.5, 0, 0, 0, 3.5, 0, 0, 0, 2.5, -0.0281982, 1.99683, 0.000198364 ) -material_override = SubResource( 34 ) +material_override = SubResource( 35 ) cast_shadow = 0 -mesh = SubResource( 35 ) +mesh = SubResource( 36 ) material/0 = null diff --git a/scripts/Level.gd b/scripts/Level.gd index b70d1ec..e7e6ec8 100644 --- a/scripts/Level.gd +++ b/scripts/Level.gd @@ -10,6 +10,9 @@ onready var label = get_node('Cursor Label') var mouse_position var obj_under_mouse +# What we want to avoid when pointing, it is loaded in the ready function +var avoid + # For showing the label of objects under mouse var mouse_offset = Vector2(8, 8) @@ -30,19 +33,19 @@ var current_click_action = WALK # For debugging var DEBUG = false - +func _ready(): + avoid = get_node('House/Walls').get_children() + avoid.append($Cole) + func can_perform_current_action_on(obj): return obj and obj.get(properties_needed[current_click_action]) - func get_object_under_mouse(mouse_pos): # Function to retrieve which object is under the mouse... var RAY_LENGTH = 100 var from = camera.project_ray_origin(mouse_pos) var to = from + camera.project_ray_normal(mouse_pos) * RAY_LENGTH - var avoid = get_node('House/Walls').get_children() - var selection = world.direct_space_state.intersect_ray(from, to, avoid) # If the ray hits something, then selection has a dictionary, with a @@ -69,12 +72,15 @@ func point(): # or maybe display a menu... or something label.rect_position = mouse_position + mouse_offset label.text = action_label[current_click_action] + " " - - if can_perform_current_action_on(obj_under_mouse): - label.set("custom_colors/default_color", Color(.1, .9, .1, 1)) - label.text += str(obj_under_mouse.name) - else: - label.set("custom_colors/default_color", Color(.9, .1, .1, 1)) + label.set("custom_colors/default_color", Color(1, 1, 1, 0)) + + if obj_under_mouse: + label.text += str(obj_under_mouse.name).to_lower() + + if can_perform_current_action_on(obj_under_mouse): + label.set("custom_colors/default_color", Color(1, 1, 1, 1)) + else: + label.set("custom_colors/default_color", Color(.6, .6, .6, .9)) func click():