forked from DeadPigeonGames/Arcanum-Fortuna
-
Notifications
You must be signed in to change notification settings - Fork 0
/
health_card.gd
59 lines (43 loc) · 1.1 KB
/
health_card.gd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
extends Card
var data: CardData
var isHovered := false
var selected := false
var value := 0
signal clicked
func _ready():
mouse_entered.connect(mouse_entered_event)
mouse_exited.connect(mouse_exited_event)
func set_value(amount):
value = amount
func _process(delta):
if isHovered:
scale = scale.lerp(Vector2.ONE * 1.1, 0.2)
elif selected:
scale = scale.lerp(Vector2.ONE * 1.05, 0.2)
else:
scale = scale.lerp(Vector2.ONE, 0.2)
func reveal():
var tween = create_tween()
tween.tween_property(self, "size", Vector2(0, 1), 1)
tween.play()
await tween.finished
$value.text = str(value)
$value.horizontal_alignment = HORIZONTAL_ALIGNMENT_CENTER
$value.size = Vector2(-1, 1)
tween.kill()
tween = null
tween = create_tween()
tween.play()
tween.tween_property(self, "size", Vector2(-1, 1) * -1, 1)
await tween.finished
func initialise(_data: CardData):
data = _data
func mouse_entered_event():
isHovered = true
$HoverSound.play()
func mouse_exited_event():
isHovered = false
func _input(event):
if isHovered and event.is_action_pressed("pickUpCard"):
$ClickSound.play()
clicked.emit(self)