Adding Animal Animations
This commit is contained in:
@@ -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")
|
||||
|
||||
Reference in New Issue
Block a user