Hellswipers/game/arrow/arrow.gd

34 lines
824 B
GDScript3
Raw Normal View History

2024-03-14 17:39:20 +00:00
extends Polygon2D
class_name Arrow
@onready var inner := $Inner
@onready var player := $AnimationPlayer
@export_color_no_alpha var normal_color: Color = Color.WHITE
@export_color_no_alpha var done_color: Color = Color.KHAKI
var dir: Global.DIRS = Global.DIRS.RIGHT :
get:
return dir
set(v):
match v:
Global.DIRS.LEFT: rotation = PI
Global.DIRS.RIGHT: rotation = 0
Global.DIRS.UP: rotation = 3*PI/2
Global.DIRS.DOWN: rotation = PI/2
dir = v
var state: Global.ARROW_STATE = Global.ARROW_STATE.NORMAL :
get:
return state
set(v):
match v:
Global.ARROW_STATE.NORMAL:
if state == Global.ARROW_STATE.DONE:
player.play('done-error')
else:
inner.color = normal_color
Global.ARROW_STATE.DONE: inner.color = done_color
Global.ARROW_STATE.ERROR: player.play('error')
state = v