49 lines
1.4 KiB
GDScript
49 lines
1.4 KiB
GDScript
extends Node3D
|
|
|
|
var sequence
|
|
var sequence_guess = []
|
|
var i = 0
|
|
|
|
func _ready():
|
|
sequence = $".."/Painting.sequence
|
|
var bmat = StandardMaterial3D.new()
|
|
bmat.emission_enabled = true
|
|
bmat.albedo_color = Color.LIGHT_SLATE_GRAY
|
|
bmat.emission = Color.LIGHT_BLUE
|
|
$ButtonUp.set_surface_override_material(0, bmat)
|
|
$ButtonLeft.set_surface_override_material(0, bmat)
|
|
$ButtonDown.set_surface_override_material(0, bmat)
|
|
$ButtonRight.set_surface_override_material(0, bmat)
|
|
|
|
func add_sequence_guess(dir):
|
|
if sequence[i] == dir:
|
|
print(".")
|
|
i += 1
|
|
if (i == sequence.size()):
|
|
print("yay")
|
|
$Door.visible = false
|
|
$ButtonUp.visible = false
|
|
$ButtonDown.visible = false
|
|
$ButtonLeft.visible = false
|
|
$ButtonRight.visible = false
|
|
i = 0
|
|
else:
|
|
print("x")
|
|
i = 0
|
|
|
|
func _on_up_input_event(camera, event, position, normal, shape_idx):
|
|
if event is InputEventMouseButton and event.is_action_pressed("interact"):
|
|
add_sequence_guess(0)
|
|
|
|
func _on_left_input_event(camera, event, position, normal, shape_idx):
|
|
if event is InputEventMouseButton and event.is_action_pressed("interact"):
|
|
add_sequence_guess(3)
|
|
|
|
func _on_down_input_event(camera, event, position, normal, shape_idx):
|
|
if event is InputEventMouseButton and event.is_action_pressed("interact"):
|
|
add_sequence_guess(2)
|
|
|
|
func _on_right_input_event(camera, event, position, normal, shape_idx):
|
|
if event is InputEventMouseButton and event.is_action_pressed("interact"):
|
|
add_sequence_guess(1)
|