-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPiece.gd
66 lines (50 loc) · 1.62 KB
/
Piece.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
60
61
62
63
64
65
66
extends Node2D
enum COLOUR {
RED = 1,
BLUE = 2
}
onready var rotationArrows = null #REMEMBER TO INITIALIZE THIS IF YOU WANT ROTATION ARROWS
var selected = false
export(String) var board_coords
export(COLOUR) var team_colour
signal selected(self_node)
signal deselected(self_node)
signal piece_rotating_right(self_node)
signal piece_rotating_left(self_node)
signal mouse_over_piece(self_node)
signal mouse_off_piece(self_node)
func toggle_selected():
if is_network_master():
selected = !selected
if (selected):
#$ClickBox/selectSprite.show()
if rotationArrows != null:
rotationArrows.enabled = selected
emit_signal("selected", self)
else:
#$ClickBox/selectSprite.hide()
if rotationArrows != null:
rotationArrows.enabled = selected
emit_signal("deselected", self)
func set_selected(newSelected):
if (newSelected):
$ClickBox/selectSprite.show()
if rotationArrows != null:
rotationArrows.enabled = newSelected
else:
$ClickBox/selectSprite.hide()
if rotationArrows != null:
rotationArrows.enabled = newSelected
selected = newSelected
remotesync func rotate_right():
print(self.name, " rotating right - UNIMPLEMENTED ROTATION - Piece should override this function")
remotesync func rotate_left():
print(self.name, " rotating left - UNIMPLEMENTED ROTATION - Piece should override this function")
func _on_RotationArrows_clicked_left():
emit_signal("piece_rotating_right", self)
func _on_RotationArrows_clicked_right():
emit_signal("piece_rotating_left", self)
func _on_Piece_Hovered():
emit_signal("mouse_over_piece", self)
func _on_Piece_Off_Hovered():
emit_signal("mouse_off_piece", self)