feature/list-object-counter (#60)

Co-authored-by: VAILLANT Jeremy <vaillant.jeremy@dev-crea.com>
Reviewed-on: Athena/game-source#60
Co-authored-by: darknight <vaillant.jeremy@dev-crea.com>
Co-committed-by: darknight <vaillant.jeremy@dev-crea.com>
This commit is contained in:
darknight
2021-05-29 21:09:10 +02:00
parent 80890cbdce
commit ed20465f39
22 changed files with 475 additions and 165 deletions
+26 -13
View File
@@ -11,20 +11,31 @@ onready var table = Global.database.get_table_by_name("scenes")
onready var meshes = {}
onready var from = null
onready var to = null
onready var mlevel = load("res://db/MLevel.gd")
onready var mscene = load("res://db/MScene.gd")
onready var victory_condition = 0
onready var victory_progress = 0
func _ready():
_load_translations()
_load_meshes()
_prepare_victory_condition()
func _prepare_victory_condition():
var level = mlevel.new(Global.current_scene_int)
victory_condition = level.object_to_find()
victory_progress = level.object_finding()
func _process(_delta):
_check_dissolve_mesh()
_check_change_angle_camera()
_check_victory_condition()
func _check_dissolve_mesh():
# Event dissolve in object searched by gamer
for key in meshes:
if meshes[key].lock() == true and meshes[key].mesh() != null:
if bool(meshes[key].lock()) == true and meshes[key].mesh() != null:
if meshes[key].tick_reference() == 0:
meshes[key].set_tick_reference(OS.get_ticks_msec())
@@ -32,15 +43,10 @@ func _check_dissolve_mesh():
meshes[key].set_value(meshes[key].value() + 0.01)
_node_to_mesh(key).get_surface_material(0).set("shader_param/dissolve_amount", meshes[key].value())
else:
victory_progress = mlevel.new(Global.current_scene_int).object_finding()
_node_to_mesh(key).call_deferred("free")
meshes[key].set_mesh(null)
func _node_to_mesh(key):
return get_node(meshes[key].mesh())
func _node_to_area(key):
return get_node(meshes[key].mesh()+"/Area")
func _check_change_angle_camera():
var camera = $"Main Camera"
var gyroscope = Input.get_gyroscope()
@@ -104,12 +110,22 @@ func _gyroscope_changed_up(gyroscope):
gyroscope.x < gyroscope_value_old.x
func _start_dissolve(key):
if meshes[key].lock() == false:
meshes[key].set_lock(true)
if bool(meshes[key].lock()) == false:
meshes[key].set_lock(int(true))
$ObjectFind.stream = meshes[key].audio_sound()
$ObjectFind.play()
## PRIVATE
func _check_victory_condition():
if victory_condition == victory_progress:
print("[levels#_check_victory_condition] \\o/")
Global.goto_scene("res://scenes/UI/ending.tscn")
func _node_to_mesh(key):
return get_node(meshes[key].mesh())
func _node_to_area(key):
return get_node(meshes[key].mesh()+"/Area")
func _load_translations():
pass
@@ -122,9 +138,6 @@ func _load_meshes():
if scene_detail.key() != null:
meshes[scene_detail.key()] = scene_detail
for key in meshes:
meshes[key].search_keys()
func _input(event):
if event is InputEventMouseButton or event is InputEventScreenTouch:
var camera = $"Main Camera"