remove some redundant files
This commit is contained in:
@@ -1,14 +0,0 @@
|
||||
package netwerkprog.game.server.controllers.game;
|
||||
|
||||
import netwerkprog.game.util.Controller;
|
||||
|
||||
public class CharacterController extends Controller {
|
||||
public CharacterController() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,37 +0,0 @@
|
||||
package netwerkprog.game.server.controllers.game;
|
||||
|
||||
import netwerkprog.game.util.Controller;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
public class GameController extends Controller {
|
||||
private int score;
|
||||
private Timer timer;
|
||||
private final CharacterController characterController;
|
||||
private final ObjectController objectController;
|
||||
private HashMap<String, Objective> objectives;
|
||||
|
||||
private final int id;
|
||||
|
||||
public GameController(int id) {
|
||||
this.characterController = new CharacterController();
|
||||
this.objectController = new ObjectController();
|
||||
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
boolean running = true;
|
||||
while (running) {
|
||||
System.out.println("game thread " + id + "active");
|
||||
try {
|
||||
Thread.sleep(1000);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
package netwerkprog.game.server.controllers.game;
|
||||
|
||||
import netwerkprog.game.util.Controller;
|
||||
|
||||
public class ObjectController extends Controller {
|
||||
public ObjectController() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,4 +0,0 @@
|
||||
package netwerkprog.game.server.controllers.game;
|
||||
|
||||
public class Objective {
|
||||
}
|
||||
@@ -1,104 +0,0 @@
|
||||
package netwerkprog.game.server.controllers.game;
|
||||
|
||||
import netwerkprog.game.util.Updatable;
|
||||
|
||||
public class Timer implements Updatable {
|
||||
private double wait;
|
||||
private double time;
|
||||
private boolean loop;
|
||||
private int timeout;
|
||||
|
||||
/**
|
||||
* makes a new timer that doesnt start automatically and doesnt loop
|
||||
* @param wait the time in ms to wait
|
||||
*/
|
||||
public Timer(double wait) {
|
||||
this(wait, false, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* makes a new timer with the given parameters
|
||||
* @param wait the wait time in ms
|
||||
* @param autoStart whether the timer should start automatically
|
||||
*/
|
||||
public Timer(double wait, boolean autoStart) {
|
||||
this(wait, autoStart, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* makes a new timer with the given parameters
|
||||
* @param wait the wait time in ms
|
||||
* @param autoStart wether the timer should start automatically
|
||||
* @param loop if this timer should loop
|
||||
*/
|
||||
public Timer(double wait, boolean autoStart, boolean loop) {
|
||||
this.wait = wait;
|
||||
this.loop = loop;
|
||||
this.time = 0.0;
|
||||
this.timeout = autoStart ? 0 : -1;
|
||||
}
|
||||
|
||||
public void start() {
|
||||
this.timeout = 0;
|
||||
}
|
||||
|
||||
public void stop() {
|
||||
this.timeout = -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get whether the timer has timed out.
|
||||
* Timeouts will stack and will not be reset when this method has been called,
|
||||
* instead the timeout will decrease by one.
|
||||
*
|
||||
* @return timeout occurred
|
||||
*/
|
||||
public boolean timeout() {
|
||||
if (this.timeout == -1) {
|
||||
// timeout has occurred and is not looped
|
||||
return false;
|
||||
}
|
||||
|
||||
if (this.timeout - 1 < 0) {
|
||||
// timeout has not occurred
|
||||
this.timeout = 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (this.loop) {
|
||||
// when looped, decrease by one
|
||||
this.timeout -= 1;
|
||||
} else {
|
||||
// else abort the timer
|
||||
this.timeout = -1;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* sets the time until the timeout.
|
||||
* @param wait the new timeout time
|
||||
*/
|
||||
public void setWait(double wait) {
|
||||
this.wait = wait;
|
||||
}
|
||||
|
||||
|
||||
public double getWait() {
|
||||
return this.wait;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(double deltaTime) {
|
||||
if (this.timeout != -1) {
|
||||
// Only update when timer is not aborted
|
||||
this.time += deltaTime;
|
||||
if (this.time >= this.wait) {
|
||||
// timeout occurred
|
||||
this.time -= this.wait;
|
||||
this.timeout++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user