extends Area2D

export (int, "health", "energy", "time", "ammo") var type = 0
export var amount = 0
export (Color, RGB) var health_color
export (Color, RGB) var energy_color
export (Color, RGB) var time_color
export (Color, RGB) var ammo_color

var limit = 1000
var picked = false

onready var label_colors = ColorArray([health_color, energy_color, time_color, ammo_color])

func _ready():
	get_node("sprite").set_frame(type)
	var label = get_node("label/label")
	label.add_color_override("font_color", label_colors[type])
	label.set_text("+" + str(amount))

func _on_powerup_body_enter( body ):
	if body == Globals.get("PLAYER") and !picked and global.stats[type] < limit:
		picked = true
		global.apply_powerup(amount, type)
		get_node("anim").play("pickup")
		audio.play_sound("powerup")
		yield(get_node("anim"), "finished")
		queue_free()