34 lines
824 B
GDScript3
34 lines
824 B
GDScript3
|
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
|