Added next-level button for emergency situations.
This commit is contained in:
parent
e9270efbc6
commit
e27cfc71b6
38
core/src/com/saltosion/gladiator/input/IRNextLevel.java
Normal file
38
core/src/com/saltosion/gladiator/input/IRNextLevel.java
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
/**
|
||||||
|
* GladiatorBrawler is a 2D swordfighting game.
|
||||||
|
* Copyright (C) 2015 Jeasonfire/Allexit
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
package com.saltosion.gladiator.input;
|
||||||
|
|
||||||
|
import com.saltosion.gladiator.GladiatorBrawler;
|
||||||
|
import com.saltosion.gladiator.state.InGameState;
|
||||||
|
|
||||||
|
public class IRNextLevel implements InputReceiver {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean pressed() {
|
||||||
|
if (GladiatorBrawler.currentState instanceof InGameState) {
|
||||||
|
((InGameState) GladiatorBrawler.currentState).nextLevel();
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean released() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -49,6 +49,7 @@ public class InputHandler implements InputProcessor {
|
|||||||
addInput(Keys.DOWN, Name.SWING_DOWN, false);
|
addInput(Keys.DOWN, Name.SWING_DOWN, false);
|
||||||
addInput(Keys.F2, Name.DEBUG, true);
|
addInput(Keys.F2, Name.DEBUG, true);
|
||||||
addInput(Keys.ESCAPE, Name.SKIP_INTRO, false);
|
addInput(Keys.ESCAPE, Name.SKIP_INTRO, false);
|
||||||
|
addInput(Keys.F3, Name.NEXT_LEVEL, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addInput(int key, String action, boolean activated) {
|
private void addInput(int key, String action, boolean activated) {
|
||||||
|
@ -36,6 +36,7 @@ public class InputReceivers {
|
|||||||
inputreceivers.put(Name.SWING_DOWN, new IRSwing(Direction.DOWN));
|
inputreceivers.put(Name.SWING_DOWN, new IRSwing(Direction.DOWN));
|
||||||
inputreceivers.put(Name.DEBUG, new IRDebugToggle());
|
inputreceivers.put(Name.DEBUG, new IRDebugToggle());
|
||||||
inputreceivers.put(Name.SKIP_INTRO, new IRSkipIntros());
|
inputreceivers.put(Name.SKIP_INTRO, new IRSkipIntros());
|
||||||
|
inputreceivers.put(Name.NEXT_LEVEL, new IRNextLevel());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static InputReceiver getReceiver(String key) {
|
public static InputReceiver getReceiver(String key) {
|
||||||
|
@ -81,6 +81,7 @@ public class InGameState extends BaseState {
|
|||||||
AppUtil.inputHandler.setInputEnabled(Name.SWING_LEFT, true);
|
AppUtil.inputHandler.setInputEnabled(Name.SWING_LEFT, true);
|
||||||
AppUtil.inputHandler.setInputEnabled(Name.SWING_RIGHT, true);
|
AppUtil.inputHandler.setInputEnabled(Name.SWING_RIGHT, true);
|
||||||
AppUtil.inputHandler.setInputEnabled(Name.SWING_UP, true);
|
AppUtil.inputHandler.setInputEnabled(Name.SWING_UP, true);
|
||||||
|
AppUtil.inputHandler.setInputEnabled(Name.NEXT_LEVEL, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -100,13 +101,8 @@ public class InGameState extends BaseState {
|
|||||||
if (level.levelCleared()) {
|
if (level.levelCleared()) {
|
||||||
timeSinceLevelWon += deltaTime;
|
timeSinceLevelWon += deltaTime;
|
||||||
if (timeSinceLevelWon > levelWonDelay) {
|
if (timeSinceLevelWon > levelWonDelay) {
|
||||||
currentLevel++;
|
|
||||||
timeSinceLevelWon = 0;
|
timeSinceLevelWon = 0;
|
||||||
if (currentLevel >= levels.length) {
|
nextLevel();
|
||||||
setState(new WinState());
|
|
||||||
} else {
|
|
||||||
changeLevel(levels[currentLevel]);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -118,6 +114,15 @@ public class InGameState extends BaseState {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void nextLevel() {
|
||||||
|
currentLevel++;
|
||||||
|
if (currentLevel >= levels.length) {
|
||||||
|
setState(new WinState());
|
||||||
|
} else {
|
||||||
|
changeLevel(levels[currentLevel]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void changeLevel(Level level) {
|
public void changeLevel(Level level) {
|
||||||
AppUtil.engine.removeAllEntities();
|
AppUtil.engine.removeAllEntities();
|
||||||
this.level = level;
|
this.level = level;
|
||||||
@ -136,6 +141,7 @@ public class InGameState extends BaseState {
|
|||||||
AppUtil.inputHandler.setInputEnabled(Name.SWING_LEFT, false);
|
AppUtil.inputHandler.setInputEnabled(Name.SWING_LEFT, false);
|
||||||
AppUtil.inputHandler.setInputEnabled(Name.SWING_RIGHT, false);
|
AppUtil.inputHandler.setInputEnabled(Name.SWING_RIGHT, false);
|
||||||
AppUtil.inputHandler.setInputEnabled(Name.SWING_UP, false);
|
AppUtil.inputHandler.setInputEnabled(Name.SWING_UP, false);
|
||||||
|
AppUtil.inputHandler.setInputEnabled(Name.NEXT_LEVEL, false);
|
||||||
|
|
||||||
// Clear all entities that are left as they are no longer needed
|
// Clear all entities that are left as they are no longer needed
|
||||||
AppUtil.engine.removeAllEntities();
|
AppUtil.engine.removeAllEntities();
|
||||||
|
@ -51,6 +51,7 @@ public class Name {
|
|||||||
public static final String SWING_UP = "SWING_UP";
|
public static final String SWING_UP = "SWING_UP";
|
||||||
public static final String SWING_DOWN = "SWING_DOWN";
|
public static final String SWING_DOWN = "SWING_DOWN";
|
||||||
public static final String SKIP_INTRO = "SKIP_INTRO";
|
public static final String SKIP_INTRO = "SKIP_INTRO";
|
||||||
|
public static final String NEXT_LEVEL = "NEXT_LEVEL";
|
||||||
public static final String DEBUG = "DEBUG";
|
public static final String DEBUG = "DEBUG";
|
||||||
|
|
||||||
public static final String MUSIC_THEME = "MUSIC_THEME";
|
public static final String MUSIC_THEME = "MUSIC_THEME";
|
||||||
|
Loading…
Reference in New Issue
Block a user