Added new room demonstrating a puzzle scene superposed on top of the room.

Need ESC commands to hide escoria.main.current_room and escoria.main.game.ui.*
This commit is contained in:
Julian Murgia
2021-01-22 14:00:57 +01:00
parent 6890d927f5
commit 9fd1d6738d
15 changed files with 606 additions and 107 deletions

View File

@@ -39,7 +39,7 @@ tracks/0/keys = {
"values": [ Color( 0.0313726, 0.996078, 0, 1 ) ]
}
[sub_resource type="Animation" id=9]
[sub_resource type="Animation" id=6]
resource_name = "red"
tracks/0/type = "value"
tracks/0/path = NodePath("Polygon2D:color")
@@ -69,7 +69,7 @@ tracks/0/keys = {
"values": [ Color( 0.0313726, 0.996078, 0, 1 ) ]
}
[sub_resource type="Animation" id=10]
[sub_resource type="Animation" id=8]
resource_name = "red"
tracks/0/type = "value"
tracks/0/path = NodePath("Polygon2D:color")
@@ -162,7 +162,6 @@ __meta__ = {
global_id = "r7_r_exit"
esc_script = "res://game/rooms/room7/esc/right_exit.esc"
is_exit = true
is_interactive = false
interaction_direction = 1
tooltip_name = "Exit"
dialog_color = Color( 1, 1, 1, 1 )
@@ -207,7 +206,7 @@ __meta__ = {
global_id = "r7_object2"
dialog_color = Color( 1, 1, 1, 1 )
interact_positions = {
"default": Vector2( 1600.63, 1358.99 )
"default": Vector2( 1770.63, 1358.99 )
}
[node name="CollisionPolygon2D" type="CollisionPolygon2D" parent="Hotspots/object2"]
@@ -260,7 +259,7 @@ position = Vector2( -167.43, 1463.23 )
global_id = "r7_button_push"
esc_script = "res://game/rooms/room7/esc/button_push.esc"
interact_positions = {
"default": Vector2( 279.618, 1763.84 )
"default": Vector2( 175.618, 1763.84 )
}
[node name="Position2D" type="Position2D" parent="Hotspots/button_camera_push"]
@@ -285,7 +284,7 @@ position = Vector2( 9.393, 1464.03 )
global_id = "r7_button_push"
esc_script = "res://game/rooms/room7/esc/button_shift.esc"
interact_positions = {
"default": Vector2( 463.651, 1765.65 )
"default": Vector2( 359.651, 1765.65 )
}
[node name="Position2D" type="Position2D" parent="Hotspots/button_camera_shift"]
@@ -307,7 +306,7 @@ position = Vector2( 172.527, 1464.03 )
global_id = "r7_button_follow"
esc_script = "res://game/rooms/room7/esc/button_follow.esc"
interact_positions = {
"default": Vector2( 463.651, 1765.65 )
"default": Vector2( 522.785, 1765.65 )
}
[node name="Position2D" type="Position2D" parent="Hotspots/button_camera_follow"]
@@ -329,7 +328,7 @@ position = Vector2( 332.527, 1464.03 )
global_id = "r7_button_zoom"
esc_script = "res://game/rooms/room7/esc/button_zoom.esc"
interact_positions = {
"default": Vector2( 522.785, 1765.65 )
"default": Vector2( 682.785, 1765.65 )
}
[node name="Position2D" type="Position2D" parent="Hotspots/button_camera_zoom"]
@@ -356,7 +355,7 @@ is_interactive = false
player_orients_on_arrival = false
dialog_color = Color( 1, 1, 1, 1 )
interact_positions = {
"default": null
"default": Vector2( 406, 0 )
}
[node name="CollisionPolygon2D" type="CollisionPolygon2D" parent="Hotspots/trigger_left"]
@@ -384,7 +383,7 @@ is_interactive = false
player_orients_on_arrival = false
dialog_color = Color( 1, 1, 1, 1 )
interact_positions = {
"default": null
"default": Vector2( 592.68, 4.12805 )
}
[node name="CollisionPolygon2D" type="CollisionPolygon2D" parent="Hotspots/trigger_right"]
@@ -410,7 +409,7 @@ global_id = "r7_light_left"
is_interactive = false
dialog_color = Color( 1, 1, 1, 1 )
interact_positions = {
"default": null
"default": Vector2( 1154.19, 1518.8 )
}
[node name="Polygon2D" type="Polygon2D" parent="Hotspots/light_left"]
@@ -423,7 +422,7 @@ shape = SubResource( 4 )
[node name="AnimationPlayer" type="AnimationPlayer" parent="Hotspots/light_left"]
anims/green = SubResource( 5 )
anims/red = SubResource( 9 )
anims/red = SubResource( 6 )
[node name="light_right" type="Area2D" parent="Hotspots"]
position = Vector2( 613.333, -1.13 )
@@ -432,7 +431,7 @@ global_id = "r7_light_right"
is_interactive = false
dialog_color = Color( 1, 1, 1, 1 )
interact_positions = {
"default": Vector2( 742.194, 1518.8 )
"default": Vector2( 1355.53, 1517.67 )
}
[node name="Polygon2D" type="Polygon2D" parent="Hotspots/light_right"]
@@ -445,7 +444,7 @@ shape = SubResource( 4 )
[node name="AnimationPlayer" type="AnimationPlayer" parent="Hotspots/light_right"]
anims/green = SubResource( 7 )
anims/red = SubResource( 10 )
anims/red = SubResource( 8 )
[node name="player_start" type="Position2D" parent="."]
position = Vector2( 76.7617, 1847.24 )

View File

@@ -0,0 +1,9 @@
:look
say player "That must be the command to open the door."
:use
> [!r8_m_door_open]
superpose_scene "res://game/rooms/room8/puzzle/10_buttons_puzzle.tscn"
> [r8_m_door_open]
say player "The door is already open."

View File

@@ -0,0 +1,6 @@
:look
say player "That must be the command to open the door."
:use
set_global r8_m_door_open false
set_state r8_m_door door_close

View File

@@ -0,0 +1,2 @@
:exit_scene
change_scene "res://game/rooms/room7/room7.tscn"

View File

@@ -0,0 +1,2 @@
:exit_scene
#change_scene "res://game/rooms/room9/room9.tscn"

View File

@@ -0,0 +1,60 @@
extends Panel
var numbers_array : Array
var next_to_be_pressed : int = 1
func _ready():
randomize()
initialize()
reset()
for button in $GridContainer.get_children():
button.connect("pressed", self, "_button_pressed", [button])
escoria.main.current_scene.game.hide_ui()
escoria.main.current_scene.hide()
func initialize():
numbers_array = range(1, 11)
numbers_array.shuffle()
func reset():
$win_label.hide()
next_to_be_pressed = 1
var i = 0
for button in $GridContainer.get_children():
var number = numbers_array[i]
button.text = str(number)
button.pressed = false
button.disabled = false
i += 1
func _button_pressed(button : Button):
var number : String= button.text
if int(number) != next_to_be_pressed:
reset()
else:
button.disabled = true
next_to_be_pressed += 1
if next_to_be_pressed == 11:
win()
func win():
$win_label.show()
yield(get_tree().create_timer(2), "timeout")
hide()
escoria.main.current_scene.game.show_ui()
escoria.main.current_scene.show()
escoria.esc_runner.set_global("r8_m_door_open", "true")
escoria.esc_runner.set_state("r8_m_door", ["door_open"])
func _on_quit_pressed():
escoria.main.current_scene.game.show_ui()
escoria.main.current_scene.show()
queue_free()

View File

@@ -0,0 +1,160 @@
[gd_scene load_steps=7 format=2]
[ext_resource path="res://game/ui/commons/fonts/caslonantique.tres" type="DynamicFont" id=1]
[ext_resource path="res://game/rooms/room8/puzzle/10_buttons_puzzle.gd" type="Script" id=2]
[ext_resource path="res://addons/escoria-core/game/assets/fonts/efmi/efmi.TTF" type="DynamicFontData" id=3]
[sub_resource type="DynamicFont" id=1]
size = 50
font_data = ExtResource( 3 )
[sub_resource type="DynamicFont" id=2]
size = 50
font_data = ExtResource( 3 )
[sub_resource type="DynamicFont" id=3]
size = 50
font_data = ExtResource( 3 )
[node name="10_buttons_puzzle" type="Panel"]
anchor_right = 1.0
anchor_bottom = 1.0
script = ExtResource( 2 )
__meta__ = {
"_edit_lock_": true
}
[node name="Label" type="Label" parent="."]
margin_left = 174.813
margin_top = 79.6769
margin_right = 899.813
margin_bottom = 126.677
custom_fonts/font = SubResource( 1 )
text = "Click the buttons in the increasing order"
__meta__ = {
"_edit_use_anchors_": false
}
[node name="win_label" type="Label" parent="."]
margin_left = 558.177
margin_top = 674.983
margin_right = 719.177
margin_bottom = 721.983
custom_fonts/font = SubResource( 2 )
text = "Well done!"
__meta__ = {
"_edit_use_anchors_": false
}
[node name="GridContainer" type="GridContainer" parent="."]
margin_left = 149.0
margin_top = 190.0
margin_right = 1122.0
margin_bottom = 622.0
columns = 5
__meta__ = {
"_edit_use_anchors_": false
}
[node name="Button" type="Button" parent="GridContainer"]
margin_right = 191.0
margin_bottom = 214.0
size_flags_horizontal = 3
size_flags_vertical = 3
custom_fonts/font = SubResource( 3 )
toggle_mode = true
[node name="Button2" type="Button" parent="GridContainer"]
margin_left = 195.0
margin_right = 386.0
margin_bottom = 214.0
size_flags_horizontal = 3
size_flags_vertical = 3
custom_fonts/font = SubResource( 3 )
toggle_mode = true
[node name="Button3" type="Button" parent="GridContainer"]
margin_left = 390.0
margin_right = 581.0
margin_bottom = 214.0
size_flags_horizontal = 3
size_flags_vertical = 3
custom_fonts/font = SubResource( 3 )
toggle_mode = true
[node name="Button4" type="Button" parent="GridContainer"]
margin_left = 585.0
margin_right = 776.0
margin_bottom = 214.0
size_flags_horizontal = 3
size_flags_vertical = 3
custom_fonts/font = SubResource( 3 )
toggle_mode = true
[node name="Button5" type="Button" parent="GridContainer"]
margin_left = 780.0
margin_right = 971.0
margin_bottom = 214.0
size_flags_horizontal = 3
size_flags_vertical = 3
custom_fonts/font = SubResource( 3 )
toggle_mode = true
[node name="Button6" type="Button" parent="GridContainer"]
margin_top = 218.0
margin_right = 191.0
margin_bottom = 432.0
size_flags_horizontal = 3
size_flags_vertical = 3
custom_fonts/font = SubResource( 3 )
toggle_mode = true
[node name="Button7" type="Button" parent="GridContainer"]
margin_left = 195.0
margin_top = 218.0
margin_right = 386.0
margin_bottom = 432.0
size_flags_horizontal = 3
size_flags_vertical = 3
custom_fonts/font = SubResource( 3 )
toggle_mode = true
[node name="Button8" type="Button" parent="GridContainer"]
margin_left = 390.0
margin_top = 218.0
margin_right = 581.0
margin_bottom = 432.0
size_flags_horizontal = 3
size_flags_vertical = 3
custom_fonts/font = SubResource( 3 )
toggle_mode = true
[node name="Button9" type="Button" parent="GridContainer"]
margin_left = 585.0
margin_top = 218.0
margin_right = 776.0
margin_bottom = 432.0
size_flags_horizontal = 3
size_flags_vertical = 3
custom_fonts/font = SubResource( 3 )
toggle_mode = true
[node name="Button10" type="Button" parent="GridContainer"]
margin_left = 780.0
margin_top = 218.0
margin_right = 971.0
margin_bottom = 432.0
size_flags_horizontal = 3
size_flags_vertical = 3
custom_fonts/font = SubResource( 3 )
toggle_mode = true
[node name="quit" type="Button" parent="."]
margin_left = 1148.0
margin_top = 56.0
margin_right = 1193.0
margin_bottom = 109.0
custom_fonts/font = ExtResource( 1 )
text = "X"
[connection signal="pressed" from="quit" to="." method="_on_quit_pressed"]

245
game/rooms/room8/room8.tscn Normal file
View File

@@ -0,0 +1,245 @@
[gd_scene load_steps=11 format=2]
[ext_resource path="res://addons/escoria-core/game/core-scripts/escterrain.gd" type="Script" id=1]
[ext_resource path="res://addons/escoria-core/game/core-scripts/escbackground.gd" type="Script" id=2]
[ext_resource path="res://game/ui/commons/fonts/caslonantique.tres" type="DynamicFont" id=3]
[ext_resource path="res://game/characters/mark/mark.tscn" type="PackedScene" id=4]
[ext_resource path="res://addons/escoria-core/game/core-scripts/escitem.gd" type="Script" id=5]
[ext_resource path="res://addons/escoria-core/game/core-scripts/escroom.gd" type="Script" id=6]
[sub_resource type="NavigationPolygon" id=1]
vertices = PoolVector2Array( 1143.08, 613.35, 1267.68, 669.029, 1275.03, 799.721, -9.16094, 803.802, -6.44019, 711.297, 84.5821, 654.06, 742.298, 623.672, 581.028, 613.592, 583.548, 574.535, 707.02, 574.535, 714.58, 611.072, 3.15687, 646.051, 59.2201, 628.698, 129.634, 615.792, 530.631, 612.332, 550.79, 623.672, 783.875, 609.812 )
polygons = [ PoolIntArray( 0, 1, 2, 3, 4, 5, 6 ), PoolIntArray( 7, 8, 9, 10 ), PoolIntArray( 4, 11, 12, 5 ), PoolIntArray( 5, 13, 14, 15 ), PoolIntArray( 7, 10, 6, 15 ), PoolIntArray( 6, 16, 0 ), PoolIntArray( 6, 5, 15 ) ]
outlines = [ PoolVector2Array( -6.44019, 711.297, 3.15687, 646.051, 59.2201, 628.698, 84.5821, 654.06, 129.634, 615.792, 530.631, 612.332, 550.79, 623.672, 581.028, 613.592, 583.548, 574.535, 707.02, 574.535, 714.58, 611.072, 742.298, 623.672, 783.875, 609.812, 1143.08, 613.35, 1267.68, 669.029, 1275.03, 799.721, -9.16094, 803.802 ) ]
[sub_resource type="Animation" id=3]
resource_name = "door_close"
tracks/0/type = "value"
tracks/0/path = NodePath("door:polygon")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/keys = {
"times": PoolRealArray( 0, 0.5 ),
"transitions": PoolRealArray( 1, 1 ),
"update": 0,
"values": [ PoolVector2Array( 557.104, 45.8, 743.623, 45.8, 744.482, 48.9414, 555.602, 48.274 ), PoolVector2Array( 557.104, 45.8, 743.623, 45.8, 746.798, 345.025, 557.898, 347.406 ) ]
}
tracks/1/type = "value"
tracks/1/path = NodePath(".:is_exit")
tracks/1/interp = 1
tracks/1/loop_wrap = true
tracks/1/imported = false
tracks/1/enabled = true
tracks/1/keys = {
"times": PoolRealArray( 0.6 ),
"transitions": PoolRealArray( 1 ),
"update": 1,
"values": [ false ]
}
[sub_resource type="Animation" id=4]
resource_name = "door_open"
tracks/0/type = "value"
tracks/0/path = NodePath("door:polygon")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/keys = {
"times": PoolRealArray( 0, 0.5 ),
"transitions": PoolRealArray( 1, 1 ),
"update": 0,
"values": [ PoolVector2Array( 557.104, 45.8, 743.623, 45.8, 746.798, 345.025, 557.898, 347.406 ), PoolVector2Array( 557.104, 45.8, 743.623, 45.8, 744.482, 48.9414, 555.602, 48.274 ) ]
}
tracks/1/type = "value"
tracks/1/path = NodePath(".:is_exit")
tracks/1/interp = 1
tracks/1/loop_wrap = true
tracks/1/imported = false
tracks/1/enabled = true
tracks/1/keys = {
"times": PoolRealArray( 0, 0.6 ),
"transitions": PoolRealArray( 1, 1 ),
"update": 1,
"values": [ false, true ]
}
[sub_resource type="RectangleShape2D" id=2]
extents = Vector2( 20.3273, 18.0047 )
[node name="room8" type="Node2D"]
script = ExtResource( 6 )
__meta__ = {
"_edit_vertical_guides_": [ ]
}
global_id = "room8"
esc_script = "res://game/rooms/room1/esc/room1.esc"
player_scene = ExtResource( 4 )
camera_limits = [ Rect2( 0, 0, 1289, 555 ) ]
[node name="background" type="TextureRect" parent="."]
margin_right = 1289.0
margin_bottom = 555.0
mouse_filter = 2
script = ExtResource( 2 )
__meta__ = {
"_edit_lock_": true,
"_edit_use_anchors_": false
}
[node name="l_platform" type="Line2D" parent="background"]
position = Vector2( 2, -266 )
points = PoolVector2Array( -2.96298, 712.01, 129.973, 614.429, 1167.5, 612.894, 1274.59, 669.705, 1273.25, 812.694, 2.36697, 811.043, 2.36697, 713.389 )
[node name="l_door" type="Line2D" parent="background"]
position = Vector2( 0, -266 )
points = PoolVector2Array( 6.61201, 704.409, 6.61203, 389.558, 87.755, 339.775, 87.5463, 649.784 )
__meta__ = {
"_editor_description_": ""
}
[node name="m_door" type="Line2D" parent="background"]
position = Vector2( 0, -267.828 )
points = PoolVector2Array( 555.952, 615.32, 554.538, 311.267, 744.043, 312.679, 746.871, 615.32, 557.367, 616.734 )
[node name="Label" type="Label" parent="background"]
margin_right = 48.0
margin_bottom = 16.0
custom_fonts/font = ExtResource( 3 )
text = "Room 8"
__meta__ = {
"_edit_use_anchors_": false
}
[node name="walkable_area" type="Navigation2D" parent="."]
script = ExtResource( 1 )
[node name="platform" type="NavigationPolygonInstance" parent="walkable_area"]
position = Vector2( 6.73163, -264.779 )
navpoly = SubResource( 1 )
__meta__ = {
"_editor_description_": ""
}
[node name="Hotspots" type="Node2D" parent="."]
[node name="l_door" type="Area2D" parent="Hotspots"]
script = ExtResource( 5 )
__meta__ = {
"_editor_description_": ""
}
global_id = "r8_l_exit"
esc_script = "res://game/rooms/room8/esc/left_exit.esc"
is_exit = true
tooltip_name = "Exit"
dialog_color = Color( 1, 1, 1, 1 )
interact_positions = {
"default": Vector2( 45.47, 383.99 )
}
[node name="CollisionPolygon2D" type="CollisionPolygon2D" parent="Hotspots/l_door"]
polygon = PoolVector2Array( 2.93237, 447.051, 2.93237, 127.051, 88.9324, 71.0505, 90.9324, 379.051 )
[node name="Position2D" type="Position2D" parent="Hotspots/l_door"]
position = Vector2( 45.47, 383.99 )
[node name="m_door" type="Area2D" parent="Hotspots"]
script = ExtResource( 5 )
__meta__ = {
"_editor_description_": ""
}
global_id = "r8_m_door"
esc_script = "res://game/rooms/room8/esc/middle_exit.esc"
tooltip_name = "Exit"
dialog_color = Color( 1, 1, 1, 1 )
interact_positions = {
"default": Vector2( 1225.47, 353.99 )
}
[node name="CollisionPolygon2D" type="CollisionPolygon2D" parent="Hotspots/m_door"]
polygon = PoolVector2Array( 557.522, 348.813, 551.222, 42.6524, 743.99, 43.9123, 750.289, 345.033 )
[node name="Position2D" type="Position2D" parent="Hotspots/m_door"]
position = Vector2( 653.466, 366.589 )
[node name="door" type="Polygon2D" parent="Hotspots/m_door"]
color = Color( 0.4, 0.501961, 1, 1 )
polygon = PoolVector2Array( 557.104, 45.8, 743.623, 45.8, 746.798, 345.025, 557.898, 347.406 )
[node name="AnimationPlayer" type="AnimationPlayer" parent="Hotspots/m_door"]
anims/door_close = SubResource( 3 )
anims/door_open = SubResource( 4 )
[node name="r8_mini_puzzle_button" type="Area2D" parent="Hotspots"]
script = ExtResource( 5 )
global_id = "r8_button_puzzle"
esc_script = "res://game/rooms/room8/esc/button_puzzle.esc"
tooltip_name = "Button"
default_action = "use"
dialog_color = Color( 1, 1, 1, 1 )
interact_positions = {
"default": null
}
[node name="button" type="Line2D" parent="Hotspots/r8_mini_puzzle_button"]
position = Vector2( -588.313, 5.65686 )
points = PoolVector2Array( 1048.39, 178.619, 1048.39, 208.814, 1076.99, 208.814, 1078.05, 183.387, 1052.09, 183.916 )
default_color = Color( 0.4, 0.501961, 1, 1 )
[node name="CollisionShape2D" type="CollisionShape2D" parent="Hotspots/r8_mini_puzzle_button"]
position = Vector2( 474.343, 201.414 )
shape = SubResource( 2 )
[node name="Position2D" type="Position2D" parent="Hotspots/r8_mini_puzzle_button"]
position = Vector2( 474.801, 369.29 )
[node name="button_puzzle" type="Label" parent="Hotspots/r8_mini_puzzle_button"]
margin_left = 445.617
margin_top = 166.124
margin_right = 508.617
margin_bottom = 182.124
custom_fonts/font = ExtResource( 3 )
text = "Run puzzle"
__meta__ = {
"_edit_use_anchors_": false
}
[node name="r8_reset_puzzle_button" type="Area2D" parent="Hotspots"]
position = Vector2( -139.185, 0 )
script = ExtResource( 5 )
global_id = "r8_button_reset_puzzle"
esc_script = "res://game/rooms/room8/esc/button_reset_puzzle.esc"
tooltip_name = "Button"
default_action = "use"
dialog_color = Color( 1, 1, 1, 1 )
interact_positions = {
"default": Vector2( 474.801, 369.29 )
}
[node name="button" type="Line2D" parent="Hotspots/r8_reset_puzzle_button"]
position = Vector2( -588.313, 5.65686 )
points = PoolVector2Array( 1048.39, 178.619, 1048.39, 208.814, 1076.99, 208.814, 1078.05, 183.387, 1052.09, 183.916 )
default_color = Color( 0.4, 0.501961, 1, 1 )
[node name="CollisionShape2D" type="CollisionShape2D" parent="Hotspots/r8_reset_puzzle_button"]
position = Vector2( 474.343, 201.414 )
shape = SubResource( 2 )
[node name="Position2D" type="Position2D" parent="Hotspots/r8_reset_puzzle_button"]
position = Vector2( 474.801, 369.29 )
[node name="reset_puzzle" type="Label" parent="Hotspots/r8_reset_puzzle_button"]
margin_left = 441.128
margin_top = 166.124
margin_right = 512.128
margin_bottom = 182.124
custom_fonts/font = ExtResource( 3 )
text = "Reset puzzle"
__meta__ = {
"_edit_use_anchors_": false
}
[node name="player_start" type="Position2D" parent="."]
position = Vector2( 76.7617, 437.649 )

View File

@@ -20,5 +20,7 @@
# 7/ long room with camera shift to object 2 if look on object 1
# and stairs with camera shift too
change_scene res://game/rooms/room7/room7.tscn
#change_scene res://game/rooms/room7/room7.tscn
# 8/ puzzle in superposed scene
change_scene res://game/rooms/room8/room8.tscn

View File

@@ -112,3 +112,15 @@ func close_inventory():
func mousewheel_action(direction : int):
pass
func hide_ui():
$ui/panel_down.hide()
$ui/verbs_layer/verbs_menu.hide()
$ui/inventory_layer/inventory_ui.hide()
$ui/tooltip_layer/tooltip.hide()
func show_ui():
$ui/panel_down.show()
$ui/verbs_layer/verbs_menu.show()
$ui/inventory_layer/inventory_ui.show()
$ui/tooltip_layer/tooltip.show()