forked from team-sg/hero-mark-2
44 lines
1.2 KiB
GDScript
44 lines
1.2 KiB
GDScript
tool
|
|
extends Node2D
|
|
|
|
enum StarColor {RED, YELLOW, GREEN, BLUE, MAGENTA}
|
|
|
|
const COLORS = [
|
|
preload("res://graphics/collectibles/pal_star_red.png"),
|
|
preload("res://graphics/collectibles/pal_star_yellow.png"),
|
|
preload("res://graphics/collectibles/pal_star_green.png"),
|
|
preload("res://graphics/collectibles/pal_star_blue.png"),
|
|
preload("res://graphics/collectibles/pal_star_magenta.png")
|
|
]
|
|
|
|
export(StarColor) var color setget _set_color
|
|
export var value = 1
|
|
export (Array, Color) var particle_colors := []
|
|
onready var sprite = $AnimatedSprite
|
|
|
|
func _ready():
|
|
#Sync all coinframes
|
|
sprite.play()
|
|
#Change color
|
|
_set_color(color)
|
|
|
|
func _set_color(new_color):
|
|
color = new_color
|
|
if is_inside_tree():
|
|
sprite.material.set_shader_param("palette", COLORS[color])
|
|
$Sparkles.color = particle_colors[color]
|
|
|
|
func _on_Area2D_body_entered(body):
|
|
#Collect
|
|
if body.is_in_group("player"):
|
|
Audio.play_sound(Audio.a_star,Audio.ac_collectible)
|
|
Game.score += 100
|
|
Game.stars_collected[color] = true
|
|
#5 Star reward
|
|
if Game.stars == 5:
|
|
Audio.play_shard_sound()
|
|
Game.shards_collected[4] = true
|
|
if Game._get_shards() >= 5 && Game.keys == 50:
|
|
Audio.great_job()
|
|
Game.score += 500
|
|
queue_free()
|