2021-05-08 20:38:16 +02:00
|
|
|
extends Spatial
|
|
|
|
|
|
2021-05-12 13:51:34 +02:00
|
|
|
const time_max = 3000 # msec
|
|
|
|
|
|
|
|
|
|
onready var meshes = {
|
|
|
|
|
"dagger": {
|
2021-05-13 18:57:12 +02:00
|
|
|
"mesh": $"Hidden Objects Items/dagger",
|
2021-05-12 13:51:34 +02:00
|
|
|
"value": 0.0,
|
|
|
|
|
"label": "Dagger",
|
|
|
|
|
"lock": false,
|
|
|
|
|
"tick_reference": null
|
2021-05-13 18:57:12 +02:00
|
|
|
},
|
|
|
|
|
"fiole1": {
|
|
|
|
|
"mesh": $"Hidden Objects Items/Fioles x3/sm_fiole1",
|
|
|
|
|
"value": 0.0,
|
|
|
|
|
"label": "Fiole",
|
|
|
|
|
"lock": false,
|
|
|
|
|
"tick_reference": null
|
|
|
|
|
},
|
|
|
|
|
"fiole2": {
|
|
|
|
|
"mesh": $"Hidden Objects Items/Fioles x3/sm_fiole2",
|
|
|
|
|
"value": 0.0,
|
|
|
|
|
"label": "Fiole",
|
|
|
|
|
"lock": false,
|
|
|
|
|
"tick_reference": null
|
|
|
|
|
},
|
|
|
|
|
"fiole3": {
|
|
|
|
|
"mesh": $"Hidden Objects Items/Fioles x3/sm_fiole_socle/sm_fiole3",
|
|
|
|
|
"value": 0.0,
|
|
|
|
|
"label": "Fiole",
|
|
|
|
|
"lock": false,
|
|
|
|
|
"tick_reference": null
|
|
|
|
|
},
|
|
|
|
|
"spyglass": {
|
|
|
|
|
"mesh": $"Hidden Objects Items/sm_spyglass",
|
|
|
|
|
"value": 0.0,
|
|
|
|
|
"label": "Spyglass",
|
|
|
|
|
"lock": false,
|
|
|
|
|
"tick_reference": null
|
|
|
|
|
},
|
|
|
|
|
"coin1": {
|
|
|
|
|
"mesh": $"Hidden Objects Items/golds/sm_stackgold_1",
|
|
|
|
|
"value": 0.0,
|
|
|
|
|
"label": "Coins",
|
|
|
|
|
"lock": false,
|
|
|
|
|
"tick_reference": null
|
|
|
|
|
},
|
|
|
|
|
"coin2": {
|
|
|
|
|
"mesh": $"Hidden Objects Items/golds/sm_stackgold_2",
|
|
|
|
|
"value": 0.0,
|
|
|
|
|
"label": "Coins",
|
|
|
|
|
"lock": false,
|
|
|
|
|
"tick_reference": null
|
|
|
|
|
},
|
|
|
|
|
"coin3": {
|
|
|
|
|
"mesh": $"Hidden Objects Items/golds/sm_stackgold_3",
|
|
|
|
|
"value": 0.0,
|
|
|
|
|
"label": "Coins",
|
|
|
|
|
"lock": false,
|
|
|
|
|
"tick_reference": null
|
|
|
|
|
},
|
|
|
|
|
"weapon": {
|
|
|
|
|
"mesh": $"Hidden Objects Items/sm_weapon_gun",
|
|
|
|
|
"value": 0.0,
|
|
|
|
|
"label": "Weapon Gun",
|
|
|
|
|
"lock": false,
|
|
|
|
|
"tick_reference": null
|
|
|
|
|
},
|
|
|
|
|
"beer": {
|
|
|
|
|
"mesh": $"Hidden Objects Items/sm_pinte_beer",
|
|
|
|
|
"value": 0.0,
|
|
|
|
|
"label": "Beer Pinte",
|
|
|
|
|
"lock": false,
|
|
|
|
|
"tick_reference": null
|
|
|
|
|
},
|
|
|
|
|
"apple1": {
|
|
|
|
|
"mesh": $"Hidden Objects Items/apples/sm_apple_1",
|
|
|
|
|
"value": 0.0,
|
|
|
|
|
"label": "Apple",
|
|
|
|
|
"lock": false,
|
|
|
|
|
"tick_reference": null
|
|
|
|
|
},
|
|
|
|
|
"apple2": {
|
|
|
|
|
"mesh": $"Hidden Objects Items/apples/sm_apple_2",
|
|
|
|
|
"value": 0.0,
|
|
|
|
|
"label": "Apple",
|
|
|
|
|
"lock": false,
|
|
|
|
|
"tick_reference": null
|
|
|
|
|
},
|
|
|
|
|
"apple3": {
|
|
|
|
|
"mesh": $"Hidden Objects Items/apples/sm_apple_3",
|
|
|
|
|
"value": 0.0,
|
|
|
|
|
"label": "Apple",
|
|
|
|
|
"lock": false,
|
|
|
|
|
"tick_reference": null
|
|
|
|
|
},
|
|
|
|
|
"apple4": {
|
|
|
|
|
"mesh": $"Hidden Objects Items/apples/sm_apple_4",
|
|
|
|
|
"value": 0.0,
|
|
|
|
|
"label": "Apple",
|
|
|
|
|
"lock": false,
|
|
|
|
|
"tick_reference": null
|
2021-05-12 13:51:34 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func _ready():
|
|
|
|
|
$Dialog/ConfirmEscape.set_title("Quit ?")
|
|
|
|
|
$Dialog/ConfirmEscape.set_text("Voulez vous vraiment quitté ?")
|
|
|
|
|
|
2021-05-09 17:10:40 +02:00
|
|
|
func _process(_delta):
|
|
|
|
|
# Event key "escape" and "godot event" ui_end
|
|
|
|
|
if Input.is_action_just_pressed("ui_end"):
|
2021-05-09 22:03:42 +02:00
|
|
|
_confirm_before_quit()
|
2021-05-12 13:51:34 +02:00
|
|
|
|
|
|
|
|
# Event dissolve in object searched by gamer
|
|
|
|
|
for mesh in meshes:
|
|
|
|
|
if meshes[mesh]["lock"] == true and meshes[mesh]["mesh"] != null:
|
|
|
|
|
if meshes[mesh]["tick_reference"] == null:
|
|
|
|
|
meshes[mesh]["tick_reference"] = OS.get_ticks_msec()
|
|
|
|
|
|
|
|
|
|
if OS.get_ticks_msec() < meshes[mesh]["tick_reference"] + time_max:
|
|
|
|
|
meshes[mesh]["value"] += 0.01
|
|
|
|
|
meshes[mesh]["mesh"].get_surface_material(0).set("shader_param/dissolve_amount", meshes[mesh]["value"])
|
|
|
|
|
else:
|
|
|
|
|
meshes[mesh]["mesh"].call_deferred("free")
|
|
|
|
|
meshes[mesh]["mesh"] = null
|
2021-05-08 20:38:16 +02:00
|
|
|
|
|
|
|
|
func _notification(what):
|
2021-05-09 17:10:40 +02:00
|
|
|
# Notification for android back action
|
2021-05-08 20:38:16 +02:00
|
|
|
if what == MainLoop.NOTIFICATION_WM_GO_BACK_REQUEST:
|
2021-05-09 22:03:42 +02:00
|
|
|
_confirm_before_quit()
|
|
|
|
|
|
|
|
|
|
func _confirm_before_quit():
|
2021-05-12 13:51:34 +02:00
|
|
|
$Dialog/ConfirmEscape.popup()
|
2021-05-09 17:10:40 +02:00
|
|
|
|
|
|
|
|
# Back to main scene
|
|
|
|
|
func _quit_to_menu():
|
|
|
|
|
Global.goto_scene("res://scenes/main.tscn")
|
2021-05-12 13:51:34 +02:00
|
|
|
|
2021-05-13 18:57:12 +02:00
|
|
|
func _initialize_mesh_ref(meshInstance, event):
|
|
|
|
|
if meshes[meshInstance]["lock"] == false and (event is InputEventMouseButton or event is InputEventScreenTouch):
|
|
|
|
|
meshes[meshInstance]["lock"] = true
|
|
|
|
|
|
2021-05-12 13:51:34 +02:00
|
|
|
# Event when user click/touch dagger
|
|
|
|
|
func _on_dagger_input_event(camera, event, click_position, click_normal, shape_idx):
|
|
|
|
|
_initialize_mesh_ref("dagger", event)
|
|
|
|
|
|
2021-05-13 18:57:12 +02:00
|
|
|
func _on_fiole1_input_event(camera, event, click_position, click_normal, shape_idx):
|
|
|
|
|
_initialize_mesh_ref("fiole1", event)
|
|
|
|
|
|
|
|
|
|
func _on_fiole2_input_event(camera, event, click_position, click_normal, shape_idx):
|
|
|
|
|
_initialize_mesh_ref("fiole2", event)
|
|
|
|
|
|
|
|
|
|
func _on_fiole3_input_event(camera, event, click_position, click_normal, shape_idx):
|
|
|
|
|
_initialize_mesh_ref("fiole3", event)
|
|
|
|
|
|
|
|
|
|
func _on_spyglass_input_event(camera, event, click_position, click_normal, shape_idx):
|
|
|
|
|
_initialize_mesh_ref("spyglass", event)
|
|
|
|
|
|
|
|
|
|
func _on_pinte_beer_input_event(camera, event, click_position, click_normal, shape_idx):
|
|
|
|
|
_initialize_mesh_ref("beer", event)
|
|
|
|
|
|
|
|
|
|
func _on_weapon_gun_input_event(camera, event, click_position, click_normal, shape_idx):
|
|
|
|
|
_initialize_mesh_ref("weapon", event)
|
|
|
|
|
|
|
|
|
|
func _on_apple_1_input_event(camera, event, click_position, click_normal, shape_idx):
|
|
|
|
|
_initialize_mesh_ref("apple1", event)
|
|
|
|
|
|
|
|
|
|
func _on_apple_2_input_event(camera, event, click_position, click_normal, shape_idx):
|
|
|
|
|
_initialize_mesh_ref("apple2", event)
|
|
|
|
|
|
|
|
|
|
func _on_apple_3_input_event(camera, event, click_position, click_normal, shape_idx):
|
|
|
|
|
_initialize_mesh_ref("apple3", event)
|
|
|
|
|
|
|
|
|
|
func _on_apple_4_input_event(camera, event, click_position, click_normal, shape_idx):
|
|
|
|
|
_initialize_mesh_ref("apple4", event)
|
|
|
|
|
|
|
|
|
|
func _on_gold_1_input_event(camera, event, click_position, click_normal, shape_idx):
|
|
|
|
|
_initialize_mesh_ref("coin1", event)
|
|
|
|
|
|
|
|
|
|
func _on_gold_2_input_event(camera, event, click_position, click_normal, shape_idx):
|
|
|
|
|
_initialize_mesh_ref("coin2", event)
|
|
|
|
|
|
|
|
|
|
func _on_gold_3_input_event(camera, event, click_position, click_normal, shape_idx):
|
|
|
|
|
_initialize_mesh_ref("coin3", event)
|
2021-05-12 13:51:34 +02:00
|
|
|
|
|
|
|
|
func _on_ConfirmEscape_confirmed():
|
|
|
|
|
_quit_to_menu()
|