-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathTimer.java
More file actions
97 lines (83 loc) · 3.15 KB
/
Copy pathTimer.java
File metadata and controls
97 lines (83 loc) · 3.15 KB
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
//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by Fernflower decompiler)
//
import greenfoot.Actor;
import greenfoot.Greenfoot;
import greenfoot.GreenfootImage;
import java.awt.Color;
public class Timer extends Actor {
public long millisElapsed;
long lastTime;
public int rtime = 15;
int tstart = 15;
public boolean auton = true;
public boolean ts = true;
public Timer() {
this.setImage(new GreenfootImage("15", 26, Color.BLACK, (Color)null));
}
public void start() {
this.millisElapsed = 0L;
this.lastTime = 0L;
}
public void gamePaused() {
this.lastTime = 0L;
}
public void act() {
long time = System.currentTimeMillis();
if(this.lastTime != 0L) {
long diff = time - this.lastTime;
this.millisElapsed += diff;
}
this.lastTime = time;
this.rtime = (int)((long)this.tstart - this.millisElapsed / 1000L);
this.setImage(new GreenfootImage("" + this.rtime, 26, Color.BLACK, (Color)null));
if(this.rtime <= 30 && this.ts && !this.auton) {
if(Title.sounds) {
Greenfoot.playSound("Whistle.wav");
}
this.ts = false;
}
if(this.rtime <= 0) {
if(this.auton) {
this.tstart = 135;
this.millisElapsed = 0L;
this.rtime = 135;
this.auton = false;
TopAirship red = (TopAirship)this.getWorld().getObjects(TopAirship.class).get(0);
TopAirship blue = (TopAirship)this.getWorld().getObjects(TopAirship.class).get(1);
++red.gears;
++blue.gears;
if(Title.sounds) {
Greenfoot.playSound("three-bells.wav");
}
} else {
RedScore red = (RedScore)this.getWorld().getObjects(RedScore.class).get(0);
BlueScore blue = (BlueScore)this.getWorld().getObjects(BlueScore.class).get(0);
if(Title.sounds) {
Greenfoot.playSound("buzzer.wav");
}
Greenfoot.setWorld(new End(blue.score, red.score, blue.mobility, blue.fscore, blue.rscore, blue.cscore, blue.bscore, BlueScore.fouls, red.mobility, red.fscore, red.rscore, red.cscore, red.bscore, RedScore.fouls));
}
}
}
public void abortMatch() {
if(Title.sounds) {
Greenfoot.playSound("foghorn.wav");
}
MyWorld.music.stop();
RedScore red = (RedScore)this.getWorld().getObjects(RedScore.class).get(0);
BlueScore blue = (BlueScore)this.getWorld().getObjects(BlueScore.class).get(0);
Greenfoot.setWorld(new End(blue.score, red.score, blue.mobility, blue.fscore, blue.rscore, blue.cscore, blue.bscore, BlueScore.fouls, red.mobility, red.fscore, red.rscore, red.cscore, red.bscore, RedScore.fouls));
}
public void end() {
this.millisElapsed = 134000L;
this.tstart = 135;
this.auton = false;
}
public void climb() {
this.millisElapsed = 104000L;
this.tstart = 135;
this.auton = false;
}
}