-
Notifications
You must be signed in to change notification settings - Fork 1
/
OSCView.pde
190 lines (186 loc) · 9 KB
/
OSCView.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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
class OSCView extends BasicView {
public OSCView() {
LEDsetup();
}
public void display() {
while (true) {
int fc = frameCount;
int i = 0;
int j = 0;
// int t1 = millis();
BasicPlayer[] _players = battleSystem.players;
for (BasicPlayer player : _players) {
String playerColor = i == 1 ? "blue" : "red";
for (BasicWeapon weapon : player.weapons) {
switch (battleSystem.getState()) {
case PRE_SKILLTEST :
patterns.get("flameString").c1 = colors.get("white");
patterns.get("flameString").c2 = colors.get("orange");
patterns.get("flameString").doPattern(weapon.ledCount, player, weapon.address, fc, battleSystem);
break;
case SKILLTEST_INTRO :
patterns.get("fadeInOut").c1 = colors.get("white");
patterns.get("fadeInOut").doPattern(weapon.ledCount, player, weapon.address, fc, battleSystem);
break;
case SKILLTEST :
patterns.get("skillPower").c1 = colors.get("white");
patterns.get("skillPower").doPattern(weapon.ledCount, player, weapon.address, fc, battleSystem);
break;
case PRE_WPSEL :
patterns.get("skillPower").c1 = colors.get("white");
patterns.get("skillPower").doPattern(weapon.ledCount, player, weapon.address, fc, battleSystem);
break;
case WPSEL:
if (!weapon.isUseable()) {
patterns.get("solid").c1 = colors.get("red");
patterns.get("solid").doPattern(weapon.ledCount, player, weapon.address, fc, battleSystem);
} else {
String anim;
// println(player.getSelectedWeapon());
if ((player.getSelectedWeapon() != null) && (player.getSelectedWeapon().name == weapon.name)) {
anim = "fadeInOut";
} else {
anim = "solid";
}
switch (weapon.useCount) {
case 1:
patterns.get(anim).c1 = colors.get("orange");
patterns.get(anim).c2 = colors.get(player.mainColor);
patterns.get(anim).doPattern(weapon.ledCount, player, weapon.address, fc, battleSystem);
break;
case 0:
patterns.get(anim).c1 = colors.get("green");
patterns.get(anim).c2 = colors.get(player.mainColor);
patterns.get(anim).doPattern(weapon.ledCount, player, weapon.address, fc, battleSystem);
break;
}
}
break;
case BATTLE :
patterns.get("solid").c1 = colors.get("white");
patterns.get("solid").doPattern(weapon.ledCount, player, weapon.address, fc, battleSystem);
break;
case SP_ANIMATION :
if ( i == 0 && battleSystem.battleResult[3] == 1) {
patterns.get("specialPower").c1 = colors.get("white");
patterns.get("specialPower").doPattern(weapon.ledCount, player, weapon.address, fc, battleSystem);
} else if ( i == 1 && battleSystem.battleResult[4] == 1) {
patterns.get("specialPower").c1 = colors.get("white");
patterns.get("specialPower").doPattern(weapon.ledCount, player, weapon.address, fc, battleSystem);
} else {
patterns.get("solid").c1 = colors.get("nocolor");
patterns.get("solid").doPattern(weapon.ledCount, player, weapon.address, fc, battleSystem);
}
break;
case BATTLE_ANIMATION :
if ( i == battleSystem.battleResult[0] && battleSystem.battleResult[i + 1] == weapon.address) {
patterns.get("fadeInOutString").c1 = colors.get(playerColor);
patterns.get("fadeInOutString").doPattern(weapon.ledCount, player, weapon.address, fc, battleSystem);
} else if ( i != battleSystem.battleResult[0] && battleSystem.battleResult[i + 1] == weapon.address) {
patterns.get("fadeInOutEven").c1 = colors.get(playerColor);
patterns.get("fadeInOutEven").doPattern(weapon.ledCount, player, weapon.address, fc, battleSystem);
} else {
patterns.get("solid").c1 = colors.get("nocolor");
patterns.get("solid").doPattern(weapon.ledCount, player, weapon.address, fc, battleSystem);
}
break;
case BATTLE_RESULT :
if (battleSystem.roundEndsGame) {
if (i == battleSystem.winner) {
patterns.get("specialPower").c1 = colors.get(playerColor);
patterns.get("specialPower").doPattern(weapon.ledCount, player, weapon.address, fc, battleSystem);
} else {
patterns.get("solid").c1 = colors.get("nocolor");
patterns.get("solid").doPattern(weapon.ledCount, player, weapon.address, fc, battleSystem);
}
} else if ( i == battleSystem.battleResult[0] && battleSystem.battleResult[i + 1] == weapon.address && battleSystem.battleResult[5] == 1) {
//Attacker success
patterns.get("attackOK").c1 = colors.get(playerColor);
patterns.get("attackOK").doPattern(weapon.ledCount, player, weapon.address, fc, battleSystem);
} else if ( i == battleSystem.battleResult[0] && battleSystem.battleResult[i + 1] == weapon.address && battleSystem.battleResult[5] == 0) {
//Attacker fail
patterns.get("fadeOut").c1 = colors.get(playerColor);
patterns.get("fadeOut").doPattern(weapon.ledCount, player, weapon.address, fc, battleSystem);
} else if ( i != battleSystem.battleResult[0] && battleSystem.battleResult[i + 1] == weapon.address && battleSystem.battleResult[5] == 1) {
//Defender fail
patterns.get("fadeOut").c1 = colors.get(playerColor);
patterns.get("fadeOut").doPattern(weapon.ledCount, player, weapon.address, fc, battleSystem);
} else if ( i != battleSystem.battleResult[0] && battleSystem.battleResult[i + 1] == weapon.address && battleSystem.battleResult[5] == 0) {
//Defender success
patterns.get("attackOK").c1 = colors.get(playerColor);
patterns.get("attackOK").doPattern(weapon.ledCount, player, weapon.address, fc, battleSystem);
} else {
patterns.get("solid").c1 = colors.get("nocolor");
patterns.get("solid").doPattern(weapon.ledCount, player, weapon.address, fc, battleSystem);
}
// if(battleSystem.battleResult[5] == 0){//Attack Fail
// if(i == battleSystem.battleResult[0]){//Player is attacker
// if (battleSystem.battleResult[1] == j+1){//Is selected weapon
// patterns.get("fadeOut").c1 = colors.get(playerColor);
// patterns.get("fadeOut").doPattern(weapon.ledCount, player, weapon.address, fc, battleSystem);
// }else{
// patterns.get("solid").c1 = colors.get("nocolor");
// patterns.get("solid").doPattern(weapon.ledCount, player, weapon.address, fc, battleSystem);
// }
// }else if (i != battleSystem.battleResult[0]) {//Player is defender
// if (battleSystem.battleResult[2] == j+1){//Is selected weapon
// patterns.get("solid").c1 = colors.get(playerColor);
// patterns.get("solid").doPattern(weapon.ledCount, player, weapon.address, fc, battleSystem);
// }else{
// patterns.get("solid").c1 = colors.get("nocolor");
// patterns.get("solid").doPattern(weapon.ledCount, player, weapon.address, fc, battleSystem);
// }
// }
// }else if (battleSystem.battleResult[5] == 1) {//Attack success
// if(i == battleSystem.battleResult[0]){//Player is attacker
// if (battleSystem.battleResult[1] == j+1){//Is selected weapon
// patterns.get("solid").c1 = colors.get(playerColor);
// patterns.get("solid").doPattern(weapon.ledCount, player, weapon.address, fc, battleSystem);
// }else{
// patterns.get("solid").c1 = colors.get("nocolor");
// patterns.get("solid").doPattern(weapon.ledCount, player, weapon.address, fc, battleSystem);
// }
// }else if (i != battleSystem.battleResult[0]) {//Player is defender
// if (battleSystem.battleResult[2] == j+1){//Is selected weapon
// patterns.get("fadeOut").c1 = colors.get(playerColor);
// patterns.get("fadeOut").doPattern(weapon.ledCount, player, weapon.address, fc, battleSystem);
// }else{
// patterns.get("solid").c1 = colors.get("nocolor");
// patterns.get("solid").doPattern(weapon.ledCount, player, weapon.address, fc, battleSystem);
// }
// }
// }
break;
case NULL_STATE :
patterns.get("solid").c1 = colors.get("nocolor");
patterns.get("solid").doPattern(weapon.ledCount, player, weapon.address, fc, battleSystem);
break;
default:
patterns.get("solid").c1 = colors.get("nocolor");
patterns.get("solid").doPattern(weapon.ledCount, player, weapon.address, fc, battleSystem);
break;
}
delay(5);
j++;
}
// Hp - 10
patterns.get("healthBar").c1 = colors.get("purple");
patterns.get("healthBar").doPattern(10, player, 5, fc, battleSystem);
delay(5);
// Att - 5
patterns.get("weaponAttack").c1 = colors.get("red");
patterns.get("weaponAttack").doPattern(5, player, 6, fc, battleSystem);
delay(5);
// Def - 5
patterns.get("weaponDefense").c1 = colors.get("blue");
patterns.get("weaponDefense").doPattern(5, player, 7, fc, battleSystem);
delay(5);
//GSR is 16
patterns.get("GSR").c1 = colors.get("white");
patterns.get("GSR").doPattern(16, player, 8, fc, battleSystem);
delay(5);
i++;
}
}
}
}