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 GameGUI gui;
|
||||||
private float overheatTimer = 0f;
|
private float overheatTimer = 0f;
|
||||||
private float cooldownTimer = 0f;
|
private float cooldownTimer = 0f;
|
||||||
private boolean wasOverheat = false;
|
private boolean isOverheat = false;
|
||||||
private boolean isShooting = false;
|
private boolean isShooting = false;
|
||||||
|
|
||||||
public PlayerShootControl(InputManager inputmanager, GameGUI gui) {
|
public PlayerShootControl(InputManager inputmanager, GameGUI gui) {
|
||||||
@ -57,10 +57,10 @@ public class PlayerShootControl extends BaseControl implements ActionListener {
|
|||||||
if (isShooting) {
|
if (isShooting) {
|
||||||
overheatTimer += tpf;
|
overheatTimer += tpf;
|
||||||
if (overheatTimer >= MAX_TIME_TO_OVERHEAT) {
|
if (overheatTimer >= MAX_TIME_TO_OVERHEAT) {
|
||||||
|
isOverheat = true;
|
||||||
setShooting(false);
|
setShooting(false);
|
||||||
overheatTimer = MAX_TIME_TO_OVERHEAT;
|
overheatTimer = MAX_TIME_TO_OVERHEAT;
|
||||||
cooldownTimer = MAX_COOLDOWN;
|
cooldownTimer = MAX_COOLDOWN;
|
||||||
wasOverheat = true;
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (cooldownTimer > 0f) {
|
if (cooldownTimer > 0f) {
|
||||||
@ -70,7 +70,7 @@ public class PlayerShootControl extends BaseControl implements ActionListener {
|
|||||||
overheatTimer -= tpf * COOLDOWN_FACTOR;
|
overheatTimer -= tpf * COOLDOWN_FACTOR;
|
||||||
} else {
|
} else {
|
||||||
overheatTimer = 0f;
|
overheatTimer = 0f;
|
||||||
wasOverheat = false;
|
isOverheat = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -79,10 +79,8 @@ public class PlayerShootControl extends BaseControl implements ActionListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void setShooting(boolean isShooting) {
|
private void setShooting(boolean isShooting) {
|
||||||
if (!(wasOverheat && overheatTimer > 0f)) {
|
this.isShooting = isShooting;
|
||||||
this.isShooting = isShooting;
|
spatial.setUserData(UserDataKeys.SHOOTING, isShooting);
|
||||||
spatial.setUserData(UserDataKeys.SHOOTING, isShooting);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -98,7 +96,9 @@ public class PlayerShootControl extends BaseControl implements ActionListener {
|
|||||||
|
|
||||||
public void onAction(String name, boolean isPressed, float tpf) {
|
public void onAction(String name, boolean isPressed, float tpf) {
|
||||||
if (name.equals(MAPPING_PLAYER_MOUSE_LEFT_CLICK) && (Boolean) spatial.getUserData(UserDataKeys.RUNNING)) {
|
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 GameSettings settings;
|
||||||
private AudioDataManager audioDataManager;
|
private AudioDataManager audioDataManager;
|
||||||
private StarManager starManager;
|
private StarManager starManager;
|
||||||
private final MediaPlayerFactory mediaPlayerFactory;
|
private MediaPlayerFactory mediaPlayerFactory;
|
||||||
private DirectMediaPlayer mediaPlayer;
|
private DirectMediaPlayer mediaPlayer;
|
||||||
private Node rootNode;
|
private Node rootNode;
|
||||||
private GameGUI gui;
|
private GameGUI gui;
|
||||||
@ -94,14 +94,6 @@ public class GameState extends AbstractAppState implements GameListener, ActionL
|
|||||||
this.viewPort = viewPort;
|
this.viewPort = viewPort;
|
||||||
this.optionSettings = optionSettings;
|
this.optionSettings = optionSettings;
|
||||||
this.highscoreManager = highscoreManager;
|
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;
|
this.settings = settings;
|
||||||
|
|
||||||
Particles.setParticleDensity(optionSettings.getParticleDensity());
|
Particles.setParticleDensity(optionSettings.getParticleDensity());
|
||||||
@ -115,7 +107,12 @@ public class GameState extends AbstractAppState implements GameListener, ActionL
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void initMediaPlayer() throws Exception {
|
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(),
|
mediaPlayer = mediaPlayerFactory.newDirectMediaPlayer(settings.getVideoFormat(),
|
||||||
settings.getVideoWidth(), settings.getVideoHeight(),
|
settings.getVideoWidth(), settings.getVideoHeight(),
|
||||||
settings.getVideoWidth() * settings.getVideoDepth(), cinema);
|
settings.getVideoWidth() * settings.getVideoDepth(), cinema);
|
||||||
@ -176,8 +173,6 @@ public class GameState extends AbstractAppState implements GameListener, ActionL
|
|||||||
rootNode.detachChild(player);
|
rootNode.detachChild(player);
|
||||||
rootNode.detachChild(ground);
|
rootNode.detachChild(ground);
|
||||||
rootNode.detachChild(cinema);
|
rootNode.detachChild(cinema);
|
||||||
mediaPlayer.release();
|
|
||||||
mediaPlayerFactory.release();
|
|
||||||
inputManager.setCursorVisible(true);
|
inputManager.setCursorVisible(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -204,6 +199,7 @@ public class GameState extends AbstractAppState implements GameListener, ActionL
|
|||||||
mediaPlayer.release();
|
mediaPlayer.release();
|
||||||
mediaPlayerFactory.release();
|
mediaPlayerFactory.release();
|
||||||
mediaPlayer = null;
|
mediaPlayer = null;
|
||||||
|
mediaPlayerFactory = null;
|
||||||
player = null;
|
player = null;
|
||||||
ground = null;
|
ground = null;
|
||||||
cinema = null;
|
cinema = null;
|
||||||
|
|||||||
@ -51,6 +51,7 @@ public class HighscoreState extends AbstractAppState implements HighscoreListene
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void stateAttached(AppStateManager stateManager) {
|
public void stateAttached(AppStateManager stateManager) {
|
||||||
|
gui.refresh();
|
||||||
gui.attach();
|
gui.attach();
|
||||||
music.play();
|
music.play();
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user