2022-07-16 21:33:47 +01:00
|
|
|
tool
|
|
|
|
extends Control
|
|
|
|
|
|
|
|
const dice_image_string = "res://Assets/Dice/Dice%s.png"
|
2022-07-17 14:25:56 +01:00
|
|
|
const selected_shader = preload("res://UI/RainbowOutline.tres")
|
2022-07-16 21:33:47 +01:00
|
|
|
|
2022-07-17 15:53:56 +01:00
|
|
|
export (int, 0, 6) var dice_value : int = 0
|
2022-07-17 14:25:56 +01:00
|
|
|
export var selected : bool setget _set_selected
|
|
|
|
|
|
|
|
|
|
|
|
func _set_selected(new_value):
|
|
|
|
selected = new_value
|
|
|
|
if selected:
|
|
|
|
self.material = selected_shader
|
|
|
|
else:
|
|
|
|
self.material = null
|
|
|
|
|
2022-07-16 21:33:47 +01:00
|
|
|
|
2022-07-17 15:53:56 +01:00
|
|
|
func _physics_process(delta):
|
|
|
|
self.texture = load(dice_image_string % dice_value)
|
2022-07-16 21:33:47 +01:00
|
|
|
|
|
|
|
|
|
|
|
func _ready():
|
|
|
|
randomize()
|
|
|
|
|
2022-07-17 15:53:56 +01:00
|
|
|
if dice_value == 0:
|
|
|
|
self.dice_value = int(round(rand_range(0.5, 6.49999999)))
|
|
|
|
|
|
|
|
_physics_process(0)
|
2022-07-17 14:25:56 +01:00
|
|
|
|
|
|
|
|