-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDice.pde
63 lines (52 loc) · 1.56 KB
/
Dice.pde
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
public class Dice extends UISquare implements Showable{
private int value;
private DiceTray tray;
private int type;
public Dice(DiceTray new_tray, int new_type) {
super(new_tray.get_corner(), new_tray.get_side(), stat_cols[new_type]);
active_dice.add(this);
value = int(random(1, 7));
tray = new_tray;
type = new_type;
}
public Dice(DiceTray new_tray, int new_type, int new_value) {
this(new_tray, new_type);
value = new_value;
}
public int get_value() {
return value;
}
public DiceTray get_tray() {
return tray;
}
public void set_tray(DiceTray new_tray) {
assert(new_tray != null);
tray = new_tray;
set_side(new_tray.get_side());
}
public float get_side() {
return tray.get_side();
}
public int get_type() {
return type;
}
@Override
public void show() {
if (this == held_dice) {
super.show(color(red(get_color()) * 0.9, green(get_color()) * 0.9, blue(get_color()) * 0.9));
} else if (held_dice != null && get_tray().is_swappable(held_dice.get_tray()) && get_tray().is_touched()) {
super.show(color(red(get_color()) * 0.7, green(get_color()) * 0.7, blue(get_color()) * 0.7));
} else {
super.show();
}
float leading_scalar = 5f / 3;
float horizontal_scalar = 2f / 3;
float vertical_scalar = 2f / 3;
new TextBox(this, Integer.toString(get_value()), color(0)).show(leading_scalar, horizontal_scalar, vertical_scalar);
}
@Override
public void cleanup() {
cleanup_dice.add(this);
get_tray().set_dice(null);
}
}