Moved speeds to LevelManager
This commit is contained in:
@ -11,6 +11,7 @@ import se.urmo.game.graphics.SpriteSheetManager;
|
||||
import se.urmo.game.main.Game;
|
||||
import se.urmo.game.map.GameMap;
|
||||
import se.urmo.game.state.GhostManager;
|
||||
import se.urmo.game.state.LevelManager;
|
||||
import se.urmo.game.util.Direction;
|
||||
import se.urmo.game.util.MiscUtil;
|
||||
import se.urmo.game.util.MyPoint;
|
||||
@ -27,11 +28,8 @@ import java.util.stream.Collectors;
|
||||
public class Ghost extends BaseAnimated {
|
||||
private static final double BASE_SPEED = 0.40;
|
||||
private static final int WARNING_THRESHOLD = 180; // 3 seconds of warning
|
||||
private static final int COLLISION_BOX_SIZE = 16;
|
||||
public static final int GHOST_SIZE = 32;
|
||||
private static final int ANIMATION_UPDATE_FREQUENCY = 25;
|
||||
private static final int COLLISION_BOX_OFFSET = COLLISION_BOX_SIZE / 2;
|
||||
private static final BufferedImage COLLISION_BOX = MiscUtil.createOutlinedBox(COLLISION_BOX_SIZE, COLLISION_BOX_SIZE, Color.black, 2);
|
||||
private static final int FRIGHTENED_DURATION_TICKS = 10 * Game.UPS_SET;
|
||||
|
||||
private final GhostCollisionChecker collisionChecker;
|
||||
@ -39,6 +37,7 @@ public class Ghost extends BaseAnimated {
|
||||
private final MyPoint startPos;
|
||||
private final BufferedImage[] fearAnimation;
|
||||
private final BufferedImage[] baseAnimation;
|
||||
private final LevelManager levelManager;
|
||||
private MyPoint position;
|
||||
|
||||
private final GhostStrategy scaterStrategy;
|
||||
@ -52,7 +51,7 @@ public class Ghost extends BaseAnimated {
|
||||
private boolean isBlinking = false;
|
||||
|
||||
|
||||
public Ghost(GhostCollisionChecker collisionChecker, GhostStrategy strategy, GhostStrategy scaterStrategy, int animation) {
|
||||
public Ghost(GhostCollisionChecker collisionChecker, GhostStrategy strategy, GhostStrategy scaterStrategy, int animation, LevelManager levelManager) {
|
||||
super(ANIMATION_UPDATE_FREQUENCY, GhostManager.MAX_SPRITE_FRAMES);
|
||||
this.collisionChecker = collisionChecker;
|
||||
this.chaseStrategy = strategy;
|
||||
@ -66,6 +65,7 @@ public class Ghost extends BaseAnimated {
|
||||
startPos = position;
|
||||
this.currentStrategy = chaseStrategy;
|
||||
this.animation = baseAnimation;
|
||||
this.levelManager = levelManager;
|
||||
}
|
||||
|
||||
public void draw(Graphics g) {
|
||||
@ -123,7 +123,7 @@ public class Ghost extends BaseAnimated {
|
||||
}
|
||||
|
||||
private double getSpeed() {
|
||||
return BASE_SPEED * 0.75;
|
||||
return BASE_SPEED * levelManager.getGhostSpeed();
|
||||
}
|
||||
|
||||
private void moveTo(MyPoint newPosition) {
|
||||
@ -190,20 +190,6 @@ public class Ghost extends BaseAnimated {
|
||||
return best;
|
||||
}
|
||||
|
||||
// private void updateAnimationTick() {
|
||||
// if (moving) {
|
||||
// aniTick++;
|
||||
// if (aniTick >= ANIMATION_UPDATE_FREQUENCY) {
|
||||
// aniTick = 0;
|
||||
// aniIndex++;
|
||||
// if (aniIndex >= GhostManager.MAX_SPRITE_FRAMES) {
|
||||
// aniIndex = 0;
|
||||
// }
|
||||
//
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
public void setMode(GhostMode mode) {
|
||||
this.mode = mode;
|
||||
switch (mode) {
|
||||
|
||||
Reference in New Issue
Block a user