Adding Animal Animations

This commit is contained in:
2024-09-01 23:10:04 +02:00
parent e1b43a0de9
commit 40a71daba8
6 changed files with 570 additions and 209 deletions

View File

@@ -7,6 +7,10 @@ signal liberated
var is_liberated := false
var current_plants := 0
func _ready():
$AnimationPlayer.play("Closed")
update_count()
func _on_area_2d_area_entered(area: Area2D) -> void:
var plant = area.get_parent()
if plant is Plant and not liberated:
@@ -19,13 +23,21 @@ func tracked_plant_grew():
current_plants += 1
if current_plants == n_plant_needed:
liberate()
update_count()
func tracked_plant_died():
if liberated:
return
current_plants -= 1
update_count()
func update_count():
$PlantsCount.text = str(roundf((float(current_plants)/n_plant_needed)*100)) + "%"
func liberate():
is_liberated = true
print("Liberated !!")
liberated.emit()
$PlantsCount.visible = false
$AnimationPlayer.play("Finished")
await $AnimationPlayer.animation_finished
$AnimationPlayer.play("Open")