fixed highscore refresh, tried to fix the weird shooting bug
This commit is contained in:
parent
3d54919d10
commit
856eb882ba
@ -42,7 +42,7 @@ public class PlayerShootControl extends BaseControl implements ActionListener {
|
||||
private GameGUI gui;
|
||||
private float overheatTimer = 0f;
|
||||
private float cooldownTimer = 0f;
|
||||
private boolean wasOverheat = false;
|
||||
private boolean isOverheat = false;
|
||||
private boolean isShooting = false;
|
||||
|
||||
public PlayerShootControl(InputManager inputmanager, GameGUI gui) {
|
||||
@ -57,10 +57,10 @@ public class PlayerShootControl extends BaseControl implements ActionListener {
|
||||
if (isShooting) {
|
||||
overheatTimer += tpf;
|
||||
if (overheatTimer >= MAX_TIME_TO_OVERHEAT) {
|
||||
isOverheat = true;
|
||||
setShooting(false);
|
||||
overheatTimer = MAX_TIME_TO_OVERHEAT;
|
||||
cooldownTimer = MAX_COOLDOWN;
|
||||
wasOverheat = true;
|
||||
}
|
||||
} else {
|
||||
if (cooldownTimer > 0f) {
|
||||
@ -70,7 +70,7 @@ public class PlayerShootControl extends BaseControl implements ActionListener {
|
||||
overheatTimer -= tpf * COOLDOWN_FACTOR;
|
||||
} else {
|
||||
overheatTimer = 0f;
|
||||
wasOverheat = false;
|
||||
isOverheat = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -79,10 +79,8 @@ public class PlayerShootControl extends BaseControl implements ActionListener {
|
||||
}
|
||||
|
||||
private void setShooting(boolean isShooting) {
|
||||
if (!(wasOverheat && overheatTimer > 0f)) {
|
||||
this.isShooting = isShooting;
|
||||
spatial.setUserData(UserDataKeys.SHOOTING, isShooting);
|
||||
}
|
||||
this.isShooting = isShooting;
|
||||
spatial.setUserData(UserDataKeys.SHOOTING, isShooting);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -98,7 +96,9 @@ public class PlayerShootControl extends BaseControl implements ActionListener {
|
||||
|
||||
public void onAction(String name, boolean isPressed, float tpf) {
|
||||
if (name.equals(MAPPING_PLAYER_MOUSE_LEFT_CLICK) && (Boolean) spatial.getUserData(UserDataKeys.RUNNING)) {
|
||||
setShooting(isPressed);
|
||||
if (!isOverheat) {
|
||||
setShooting(isPressed);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -64,7 +64,7 @@ public class GameState extends AbstractAppState implements GameListener, ActionL
|
||||
private GameSettings settings;
|
||||
private AudioDataManager audioDataManager;
|
||||
private StarManager starManager;
|
||||
private final MediaPlayerFactory mediaPlayerFactory;
|
||||
private MediaPlayerFactory mediaPlayerFactory;
|
||||
private DirectMediaPlayer mediaPlayer;
|
||||
private Node rootNode;
|
||||
private GameGUI gui;
|
||||
@ -94,14 +94,6 @@ public class GameState extends AbstractAppState implements GameListener, ActionL
|
||||
this.viewPort = viewPort;
|
||||
this.optionSettings = optionSettings;
|
||||
this.highscoreManager = highscoreManager;
|
||||
|
||||
if (settings.useVideo() || !optionSettings.isAudioVisualizationEnabled()) {
|
||||
mediaPlayerFactory = new MediaPlayerFactory("--no-video-title-show", "--quiet");
|
||||
} else {
|
||||
mediaPlayerFactory = new MediaPlayerFactory("--no-video-title-show", "--quiet",
|
||||
"--audio-visual=visual", "--effect-list=scope");
|
||||
}
|
||||
|
||||
this.settings = settings;
|
||||
|
||||
Particles.setParticleDensity(optionSettings.getParticleDensity());
|
||||
@ -115,7 +107,12 @@ public class GameState extends AbstractAppState implements GameListener, ActionL
|
||||
}
|
||||
|
||||
public void initMediaPlayer() throws Exception {
|
||||
System.out.println("create");
|
||||
if (settings.useVideo() || !optionSettings.isAudioVisualizationEnabled()) {
|
||||
mediaPlayerFactory = new MediaPlayerFactory("--no-video-title-show", "--quiet");
|
||||
} else {
|
||||
mediaPlayerFactory = new MediaPlayerFactory("--no-video-title-show", "--quiet",
|
||||
"--audio-visual=visual", "--effect-list=scope");
|
||||
}
|
||||
mediaPlayer = mediaPlayerFactory.newDirectMediaPlayer(settings.getVideoFormat(),
|
||||
settings.getVideoWidth(), settings.getVideoHeight(),
|
||||
settings.getVideoWidth() * settings.getVideoDepth(), cinema);
|
||||
@ -176,8 +173,6 @@ public class GameState extends AbstractAppState implements GameListener, ActionL
|
||||
rootNode.detachChild(player);
|
||||
rootNode.detachChild(ground);
|
||||
rootNode.detachChild(cinema);
|
||||
mediaPlayer.release();
|
||||
mediaPlayerFactory.release();
|
||||
inputManager.setCursorVisible(true);
|
||||
}
|
||||
|
||||
@ -204,6 +199,7 @@ public class GameState extends AbstractAppState implements GameListener, ActionL
|
||||
mediaPlayer.release();
|
||||
mediaPlayerFactory.release();
|
||||
mediaPlayer = null;
|
||||
mediaPlayerFactory = null;
|
||||
player = null;
|
||||
ground = null;
|
||||
cinema = null;
|
||||
|
||||
@ -51,6 +51,7 @@ public class HighscoreState extends AbstractAppState implements HighscoreListene
|
||||
|
||||
@Override
|
||||
public void stateAttached(AppStateManager stateManager) {
|
||||
gui.refresh();
|
||||
gui.attach();
|
||||
music.play();
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user