extends Label

onready var Dirt = get_parent().get_parent().get_node("Dirt") #get_node("/root/Main/Level/Dirt")
var total
var current
var percent
var WinPlayed = 0

func _ready():
	total = Dirt.get_child_count()

func _physics_process(_delta):
	current = Dirt.get_child_count()
	var cleaned = total - current
	percent = (cleaned * 100 ) / total
	text = String(percent) + "% CLEANED"
	if (percent == 100):
		get_parent().get_node("Time").stoptimer()
		get_parent().get_node("WIN").visible = true
		if (WinPlayed == 0):
			get_parent().get_node("WinSound").play()
			WinPlayed = 1
