Renamed all room folders to use 2 digits.
This commit is contained in:
60
game/rooms/room08/puzzle/10_buttons_puzzle.gd
Normal file
60
game/rooms/room08/puzzle/10_buttons_puzzle.gd
Normal 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.globals_manager.set_global("r8_m_door_open", true)
|
||||
escoria.object_manager.get_object("r8_m_door").set_state("door_open")
|
||||
|
||||
|
||||
func _on_quit_pressed():
|
||||
escoria.main.current_scene.game.show_ui()
|
||||
escoria.main.current_scene.show()
|
||||
queue_free()
|
||||
160
game/rooms/room08/puzzle/10_buttons_puzzle.tscn
Normal file
160
game/rooms/room08/puzzle/10_buttons_puzzle.tscn
Normal 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/room08/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"]
|
||||
Reference in New Issue
Block a user