Bomb game automatic action and summary ready.
This commit is contained in:
@@ -24,6 +24,7 @@ import ve.ucv.ciens.ccg.nxtar.network.SensorReportThread;
|
|||||||
import ve.ucv.ciens.ccg.nxtar.network.ServiceDiscoveryThread;
|
import ve.ucv.ciens.ccg.nxtar.network.ServiceDiscoveryThread;
|
||||||
import ve.ucv.ciens.ccg.nxtar.network.VideoStreamingThread;
|
import ve.ucv.ciens.ccg.nxtar.network.VideoStreamingThread;
|
||||||
import ve.ucv.ciens.ccg.nxtar.states.AutomaticActionState;
|
import ve.ucv.ciens.ccg.nxtar.states.AutomaticActionState;
|
||||||
|
import ve.ucv.ciens.ccg.nxtar.states.AutomaticActionSummaryState;
|
||||||
import ve.ucv.ciens.ccg.nxtar.states.BaseState;
|
import ve.ucv.ciens.ccg.nxtar.states.BaseState;
|
||||||
import ve.ucv.ciens.ccg.nxtar.states.CameraCalibrationState;
|
import ve.ucv.ciens.ccg.nxtar.states.CameraCalibrationState;
|
||||||
import ve.ucv.ciens.ccg.nxtar.states.InGameState;
|
import ve.ucv.ciens.ccg.nxtar.states.InGameState;
|
||||||
@@ -75,7 +76,7 @@ public class NxtARCore extends Game implements ApplicationEventsListener{
|
|||||||
* Valid game states.
|
* Valid game states.
|
||||||
*/
|
*/
|
||||||
public enum game_states_t {
|
public enum game_states_t {
|
||||||
MAIN_MENU(0), IN_GAME(1), CALIBRATION(2), AUTOMATIC_ACTION(3);
|
MAIN_MENU(0), IN_GAME(1), CALIBRATION(2), AUTOMATIC_ACTION(3), SUMMARY(4);
|
||||||
|
|
||||||
private int value;
|
private int value;
|
||||||
|
|
||||||
@@ -88,7 +89,7 @@ public class NxtARCore extends Game implements ApplicationEventsListener{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static int getNumStates(){
|
public static int getNumStates(){
|
||||||
return 4;
|
return 5;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -256,25 +257,35 @@ public class NxtARCore extends Game implements ApplicationEventsListener{
|
|||||||
|
|
||||||
// Create the state objects.
|
// Create the state objects.
|
||||||
states = new BaseState[game_states_t.getNumStates()];
|
states = new BaseState[game_states_t.getNumStates()];
|
||||||
if(Ouya.runningOnOuya)
|
|
||||||
states[game_states_t.MAIN_MENU.getValue()] = new OuyaMainMenuState(this);
|
|
||||||
else
|
|
||||||
states[game_states_t.MAIN_MENU.getValue()] = new TabletMainMenuState(this);
|
|
||||||
|
|
||||||
try{
|
try{
|
||||||
states[game_states_t.IN_GAME.getValue()] = new InGameState(this);
|
if(Ouya.runningOnOuya)
|
||||||
}catch(IllegalStateException e){
|
states[game_states_t.MAIN_MENU.getValue()] = new OuyaMainMenuState(this);
|
||||||
Gdx.app.error(TAG, CLASS_NAME + ".create(): Illegal state in IN_GAME_STATE: " + e.getMessage());
|
else
|
||||||
Gdx.app.exit();
|
states[game_states_t.MAIN_MENU.getValue()] = new TabletMainMenuState(this);
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
states[game_states_t.CALIBRATION.getValue()] = new CameraCalibrationState(this);
|
try{
|
||||||
|
states[game_states_t.IN_GAME.getValue()] = new InGameState(this);
|
||||||
|
}catch(IllegalStateException e){
|
||||||
|
Gdx.app.error(TAG, CLASS_NAME + ".create(): Illegal state in IN_GAME_STATE: ", e);
|
||||||
|
Gdx.app.exit();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
try{
|
states[game_states_t.CALIBRATION.getValue()] = new CameraCalibrationState(this);
|
||||||
states[game_states_t.AUTOMATIC_ACTION.getValue()] = new AutomaticActionState(this);
|
|
||||||
}catch(IllegalStateException e){
|
try{
|
||||||
Gdx.app.error(TAG, CLASS_NAME + ".create(): Illegal state in AUTOMATIC_ACTION_STATE: " + e.getMessage());
|
states[game_states_t.AUTOMATIC_ACTION.getValue()] = new AutomaticActionState(this);
|
||||||
|
}catch(IllegalStateException e){
|
||||||
|
Gdx.app.error(TAG, CLASS_NAME + ".create(): Illegal state in AUTOMATIC_ACTION_STATE: ", e);
|
||||||
|
Gdx.app.exit();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
states[game_states_t.SUMMARY.getValue()] = new AutomaticActionSummaryState(this);
|
||||||
|
|
||||||
|
}catch(IllegalArgumentException e){
|
||||||
|
Gdx.app.error(TAG, CLASS_NAME + ".create(): Illegal argument caught creating states: ", e);
|
||||||
Gdx.app.exit();
|
Gdx.app.exit();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -285,8 +296,8 @@ public class NxtARCore extends Game implements ApplicationEventsListener{
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Set up the overlay font.
|
// Set up the overlay font.
|
||||||
overlayX = -(Utils.getScreenWidth() / 2) + 10;
|
overlayX = -(Utils.getScreenWidthWithOverscan() / 2) + 10;
|
||||||
overlayY = (Utils.getScreenHeight() / 2) - 10;
|
overlayY = (Utils.getScreenHeightWithOverscan() / 2) - 10;
|
||||||
|
|
||||||
font = new BitmapFont();
|
font = new BitmapFont();
|
||||||
font.setColor(1.0f, 1.0f, 0.0f, 1.0f);
|
font.setColor(1.0f, 1.0f, 0.0f, 1.0f);
|
||||||
@@ -428,21 +439,23 @@ public class NxtARCore extends Game implements ApplicationEventsListener{
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>Pause a currently running thread. Pausing an already paused thread is a
|
* <p>Pauses the video streaming and the current state.</p>
|
||||||
* no op.</p>
|
|
||||||
*/
|
*/
|
||||||
public void pause(){
|
public void pause(){
|
||||||
if(videoThread != null)
|
if(videoThread != null)
|
||||||
videoThread.pause();
|
videoThread.pause();
|
||||||
|
|
||||||
|
states[currState.getValue()].pause();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>Resume a currently paused thread. Resuming an already resumed thread is a
|
* <p>Resumes the video streaming and the current state.</p>
|
||||||
* no op.</p>
|
|
||||||
*/
|
*/
|
||||||
public void resume(){
|
public void resume(){
|
||||||
if(videoThread != null)
|
if(videoThread != null)
|
||||||
videoThread.play();
|
videoThread.play();
|
||||||
|
|
||||||
|
states[currState.getValue()].resume();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -473,7 +486,7 @@ public class NxtARCore extends Game implements ApplicationEventsListener{
|
|||||||
batch.dispose();
|
batch.dispose();
|
||||||
font.dispose();
|
font.dispose();
|
||||||
|
|
||||||
GameGlobals.clearGameSettings();
|
GameGlobals.dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
/*;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
|
|||||||
@@ -18,6 +18,10 @@ package ve.ucv.ciens.ccg.nxtar.game;
|
|||||||
import ve.ucv.ciens.ccg.nxtar.interfaces.ImageProcessor.MarkerData;
|
import ve.ucv.ciens.ccg.nxtar.interfaces.ImageProcessor.MarkerData;
|
||||||
|
|
||||||
public abstract class AutomaticActionPerformerBase {
|
public abstract class AutomaticActionPerformerBase {
|
||||||
|
public abstract class AutomaticActionSummary{
|
||||||
|
public abstract void reset();
|
||||||
|
}
|
||||||
|
|
||||||
public enum automatic_action_t{
|
public enum automatic_action_t{
|
||||||
NO_ACTION,
|
NO_ACTION,
|
||||||
GO_FORWARD,
|
GO_FORWARD,
|
||||||
@@ -34,6 +38,8 @@ public abstract class AutomaticActionPerformerBase {
|
|||||||
STOP_LOOKING;
|
STOP_LOOKING;
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract boolean performAutomaticAction(int lightSensorReading, MarkerData markers);
|
public abstract boolean performAutomaticAction(int lightSensorReading, MarkerData markers);
|
||||||
public abstract automatic_action_t getNextAction();
|
public abstract automatic_action_t getNextAction();
|
||||||
|
public abstract AutomaticActionSummary getSummary();
|
||||||
|
public abstract void reset();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,33 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2014 Miguel Angel Astor Romero
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
package ve.ucv.ciens.ccg.nxtar.game;
|
||||||
|
|
||||||
|
import ve.ucv.ciens.ccg.nxtar.game.AutomaticActionPerformerBase.AutomaticActionSummary;
|
||||||
|
|
||||||
|
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
|
||||||
|
import com.badlogic.gdx.utils.Disposable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>Base class for summary screens. Just renders a summary overlay.</p>
|
||||||
|
*/
|
||||||
|
public abstract class AutomaticActionSummaryOverlayBase implements Disposable{
|
||||||
|
/**
|
||||||
|
* <p>Renders the overlay.</p>
|
||||||
|
*
|
||||||
|
* @param batch The {@link SpriteBatch} to use for rendering.
|
||||||
|
*/
|
||||||
|
public abstract void render(SpriteBatch batch, AutomaticActionSummary summary);
|
||||||
|
}
|
||||||
@@ -36,11 +36,12 @@ import com.badlogic.gdx.graphics.g3d.ModelBatch;
|
|||||||
import com.badlogic.gdx.utils.Disposable;
|
import com.badlogic.gdx.utils.Disposable;
|
||||||
|
|
||||||
public abstract class GameGlobals{
|
public abstract class GameGlobals{
|
||||||
private static EntityCreatorBase entityCreator = null;
|
private static EntityCreatorBase entityCreator = null;
|
||||||
private static GameLogicSystemBase gameLogicSystem = null;
|
private static GameLogicSystemBase gameLogicSystem = null;
|
||||||
private static World gameWorld = null;
|
private static World gameWorld = null;
|
||||||
private static ModelBatch modelBatch = null;
|
private static ModelBatch modelBatch = null;
|
||||||
private static AutomaticActionPerformerBase automaticActionPerformer = null;
|
private static AutomaticActionPerformerBase automaticActionPerformer = null;
|
||||||
|
private static AutomaticActionSummaryOverlayBase automaticActionSummaryOverlay = null;
|
||||||
|
|
||||||
public static void initGameSettings(NxtARCore core) throws IllegalArgumentException, InstantiationException, IllegalAccessException{
|
public static void initGameSettings(NxtARCore core) throws IllegalArgumentException, InstantiationException, IllegalAccessException{
|
||||||
if(core == null)
|
if(core == null)
|
||||||
@@ -49,12 +50,12 @@ public abstract class GameGlobals{
|
|||||||
if(modelBatch == null)
|
if(modelBatch == null)
|
||||||
modelBatch = new ModelBatch();
|
modelBatch = new ModelBatch();
|
||||||
|
|
||||||
if(getGameWorld() == null){
|
if(gameWorld == null){
|
||||||
gameWorld = new World();
|
gameWorld = new World();
|
||||||
gameWorld.setManager(new GroupManager());
|
gameWorld.setManager(new GroupManager());
|
||||||
}
|
}
|
||||||
|
|
||||||
if(getEntityCreator() == null){
|
if(entityCreator == null){
|
||||||
try {
|
try {
|
||||||
entityCreator = (EntityCreatorBase) ScenarioImplementation.entityCreatorClass.newInstance();
|
entityCreator = (EntityCreatorBase) ScenarioImplementation.entityCreatorClass.newInstance();
|
||||||
} catch (InstantiationException e) {
|
} catch (InstantiationException e) {
|
||||||
@@ -68,7 +69,7 @@ public abstract class GameGlobals{
|
|||||||
entityCreator.setCore(core);
|
entityCreator.setCore(core);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(getGameLogicSystem() == null){
|
if(gameLogicSystem == null){
|
||||||
try {
|
try {
|
||||||
gameLogicSystem = (GameLogicSystemBase) ScenarioImplementation.gameLogicSystemClass.newInstance();
|
gameLogicSystem = (GameLogicSystemBase) ScenarioImplementation.gameLogicSystemClass.newInstance();
|
||||||
} catch (InstantiationException e) {
|
} catch (InstantiationException e) {
|
||||||
@@ -92,6 +93,18 @@ public abstract class GameGlobals{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(automaticActionSummaryOverlay == null){
|
||||||
|
try {
|
||||||
|
automaticActionSummaryOverlay = (AutomaticActionSummaryOverlayBase) ScenarioImplementation.automaticActionSummaryScreen.newInstance();
|
||||||
|
} catch (InstantiationException e) {
|
||||||
|
System.out.println("Error instantiating automatic action performer.");
|
||||||
|
throw e;
|
||||||
|
} catch (IllegalAccessException e) {
|
||||||
|
System.out.println("Error accessing automatic action performer.");
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
gameWorld.setSystem(new MarkerPositioningSystem());
|
gameWorld.setSystem(new MarkerPositioningSystem());
|
||||||
gameWorld.setSystem(new RobotArmPositioningSystem(), Ouya.runningOnOuya);
|
gameWorld.setSystem(new RobotArmPositioningSystem(), Ouya.runningOnOuya);
|
||||||
gameWorld.setSystem(new GeometrySystem());
|
gameWorld.setSystem(new GeometrySystem());
|
||||||
@@ -106,8 +119,13 @@ public abstract class GameGlobals{
|
|||||||
gameWorld.initialize();
|
gameWorld.initialize();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void clearGameSettings(){
|
public static void dispose() throws IllegalStateException{
|
||||||
ImmutableBag<EntitySystem> systems = gameWorld.getSystems();
|
ImmutableBag<EntitySystem> systems;
|
||||||
|
|
||||||
|
if(entityCreator == null || gameWorld == null || gameLogicSystem == null || automaticActionPerformer == null || automaticActionSummaryOverlay == null)
|
||||||
|
throw new IllegalStateException("Calling dispose before init or after previous dispose.");
|
||||||
|
|
||||||
|
systems = gameWorld.getSystems();
|
||||||
|
|
||||||
for(int i = 0; i < systems.size(); i++){
|
for(int i = 0; i < systems.size(); i++){
|
||||||
if(systems.get(i) instanceof Disposable){
|
if(systems.get(i) instanceof Disposable){
|
||||||
@@ -115,38 +133,64 @@ public abstract class GameGlobals{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
automaticActionSummaryOverlay.dispose();
|
||||||
entityCreator.dispose();
|
entityCreator.dispose();
|
||||||
entityCreator = null;
|
|
||||||
gameLogicSystem = null;
|
entityCreator = null;
|
||||||
gameWorld = null;
|
gameLogicSystem = null;
|
||||||
|
gameWorld = null;
|
||||||
|
automaticActionPerformer = null;
|
||||||
|
automaticActionSummaryOverlay = null;
|
||||||
System.gc();
|
System.gc();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the entityCreator
|
* @return the entityCreator
|
||||||
*/
|
*/
|
||||||
public static EntityCreatorBase getEntityCreator() {
|
public static EntityCreatorBase getEntityCreator() throws IllegalStateException{
|
||||||
|
if(entityCreator == null)
|
||||||
|
throw new IllegalStateException("Calling getEntityCreator() before init.");
|
||||||
|
|
||||||
return entityCreator;
|
return entityCreator;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the gameLogicSystem
|
* @return the gameLogicSystem
|
||||||
*/
|
*/
|
||||||
public static GameLogicSystemBase getGameLogicSystem() {
|
public static GameLogicSystemBase getGameLogicSystem() throws IllegalStateException{
|
||||||
|
if(gameLogicSystem == null)
|
||||||
|
throw new IllegalStateException("Calling getGameLogicSystem() before init.");
|
||||||
|
|
||||||
return gameLogicSystem;
|
return gameLogicSystem;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the gameWorld
|
* @return the gameWorld
|
||||||
*/
|
*/
|
||||||
public static World getGameWorld() {
|
public static World getGameWorld() throws IllegalStateException{
|
||||||
|
if(gameWorld == null)
|
||||||
|
throw new IllegalStateException("Calling getGameWorld() before init.");
|
||||||
|
|
||||||
return gameWorld;
|
return gameWorld;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the automaticActionPerformer
|
* @return the automaticActionPerformer
|
||||||
*/
|
*/
|
||||||
public static AutomaticActionPerformerBase getAutomaticActionPerformer() {
|
public static AutomaticActionPerformerBase getAutomaticActionPerformer() throws IllegalStateException{
|
||||||
|
if(automaticActionPerformer == null)
|
||||||
|
throw new IllegalStateException("Calling getAutomaticActionPerformer() before init.");
|
||||||
|
|
||||||
return automaticActionPerformer;
|
return automaticActionPerformer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the automaticActionSummaryScreen
|
||||||
|
*/
|
||||||
|
public static AutomaticActionSummaryOverlayBase getAutomaticActionSummaryOverlay() throws IllegalStateException{
|
||||||
|
if(automaticActionSummaryOverlay == null)
|
||||||
|
throw new IllegalStateException("Calling getAutomaticActionSummaryOverlay() before init.");
|
||||||
|
|
||||||
|
return automaticActionSummaryOverlay;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,6 +16,7 @@
|
|||||||
package ve.ucv.ciens.ccg.nxtar.game;
|
package ve.ucv.ciens.ccg.nxtar.game;
|
||||||
|
|
||||||
import ve.ucv.ciens.ccg.nxtar.game.bombgame.BombGameAutomaticActionPerformer;
|
import ve.ucv.ciens.ccg.nxtar.game.bombgame.BombGameAutomaticActionPerformer;
|
||||||
|
import ve.ucv.ciens.ccg.nxtar.game.bombgame.BombGameAutomaticActionSummaryOverlay;
|
||||||
import ve.ucv.ciens.ccg.nxtar.game.bombgame.BombGameEntityCreator;
|
import ve.ucv.ciens.ccg.nxtar.game.bombgame.BombGameEntityCreator;
|
||||||
import ve.ucv.ciens.ccg.nxtar.game.bombgame.BombGameLogicSystem;
|
import ve.ucv.ciens.ccg.nxtar.game.bombgame.BombGameLogicSystem;
|
||||||
|
|
||||||
@@ -24,6 +25,7 @@ public final class ScenarioImplementation{
|
|||||||
public static Class gameLogicSystemClass = BombGameLogicSystem.class;
|
public static Class gameLogicSystemClass = BombGameLogicSystem.class;
|
||||||
public static Class entityCreatorClass = BombGameEntityCreator.class;
|
public static Class entityCreatorClass = BombGameEntityCreator.class;
|
||||||
public static Class automaticActionPerformerClass = BombGameAutomaticActionPerformer.class;
|
public static Class automaticActionPerformerClass = BombGameAutomaticActionPerformer.class;
|
||||||
|
public static Class automaticActionSummaryScreen = BombGameAutomaticActionSummaryOverlay.class;
|
||||||
|
|
||||||
private ScenarioImplementation(){}
|
private ScenarioImplementation(){}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,58 +18,132 @@ package ve.ucv.ciens.ccg.nxtar.game.bombgame;
|
|||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import com.badlogic.gdx.Gdx;
|
|
||||||
|
|
||||||
import ve.ucv.ciens.ccg.nxtar.game.AutomaticActionPerformerBase;
|
import ve.ucv.ciens.ccg.nxtar.game.AutomaticActionPerformerBase;
|
||||||
|
import ve.ucv.ciens.ccg.nxtar.game.GameGlobals;
|
||||||
import ve.ucv.ciens.ccg.nxtar.interfaces.ImageProcessor.MarkerData;
|
import ve.ucv.ciens.ccg.nxtar.interfaces.ImageProcessor.MarkerData;
|
||||||
import ve.ucv.ciens.ccg.nxtar.utils.ProjectConstants;
|
import ve.ucv.ciens.ccg.nxtar.utils.ProjectConstants;
|
||||||
|
|
||||||
|
import com.artemis.Entity;
|
||||||
|
import com.artemis.World;
|
||||||
|
import com.artemis.managers.GroupManager;
|
||||||
|
import com.artemis.utils.ImmutableBag;
|
||||||
|
import com.badlogic.gdx.Gdx;
|
||||||
|
|
||||||
public class BombGameAutomaticActionPerformer extends AutomaticActionPerformerBase {
|
public class BombGameAutomaticActionPerformer extends AutomaticActionPerformerBase {
|
||||||
private static final int GOAL_FLOOR_MIN_LUMINANCE = 85;
|
private static final String TAG = "BOMB_GAME_AUTO_PERFORMER";
|
||||||
private static final int MARKER_NEARBY_FLOOR_MIN_LUMINANCE = 45;
|
private static final String CLASS_NAME = BombGameAutomaticActionPerformer.class.getSimpleName();
|
||||||
|
private static final int GOAL_FLOOR_MIN_LUMINANCE = 75;
|
||||||
|
private static final int MARKER_NEARBY_FLOOR_MIN_LUMINANCE = 45;
|
||||||
|
|
||||||
private enum action_state_t{
|
private enum action_state_t{
|
||||||
START, WALK_FORWARD, DETECT_MARKER, FINISHING, END;
|
START, WALK_FORWARD, DETECT_MARKER, FINISHING, END;
|
||||||
}
|
}
|
||||||
|
|
||||||
private automatic_action_t nextAction;
|
public class BombGameAutomaticActionSummary extends AutomaticActionSummary{
|
||||||
private action_state_t state;
|
private int numCombinationBombs;
|
||||||
private List<Integer> detectedMarkers;
|
private int numInclinationBombs;
|
||||||
private float then;
|
private int numWireBombs;
|
||||||
|
|
||||||
|
public BombGameAutomaticActionSummary(){
|
||||||
|
reset();
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getNumCombinationBombs() {
|
||||||
|
return numCombinationBombs;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getNumInclinationBombs() {
|
||||||
|
return numInclinationBombs;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getNumWireBombs() {
|
||||||
|
return numWireBombs;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addCombinationBomb(){
|
||||||
|
numCombinationBombs++;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addInclinationBomb(){
|
||||||
|
numInclinationBombs++;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addWireBomb(){
|
||||||
|
numWireBombs++;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void reset() {
|
||||||
|
this.numCombinationBombs = 0;
|
||||||
|
this.numInclinationBombs = 0;
|
||||||
|
this.numWireBombs = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private automatic_action_t nextAction;
|
||||||
|
private action_state_t state;
|
||||||
|
private List<Integer> detectedMarkers;
|
||||||
|
private float then;
|
||||||
|
private float now;
|
||||||
|
private GroupManager manager;
|
||||||
|
private BombGameAutomaticActionSummary summary;
|
||||||
|
|
||||||
public BombGameAutomaticActionPerformer(){
|
public BombGameAutomaticActionPerformer(){
|
||||||
nextAction = automatic_action_t.NO_ACTION;
|
nextAction = automatic_action_t.NO_ACTION;
|
||||||
state = action_state_t.START;
|
state = action_state_t.START;
|
||||||
detectedMarkers = new LinkedList<Integer>();
|
detectedMarkers = new LinkedList<Integer>();
|
||||||
then = 0.0f;
|
then = 0.0f;
|
||||||
|
now = 0.0f;
|
||||||
|
manager = null;
|
||||||
|
summary = new BombGameAutomaticActionSummary();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean performAutomaticAction(int lightSensorReading, MarkerData markers) throws IllegalStateException, IllegalArgumentException{
|
public boolean performAutomaticAction(int lightSensorReading, MarkerData markers) throws IllegalStateException, IllegalArgumentException{
|
||||||
boolean finish = false;
|
BombComponent bomb;
|
||||||
int detectedCode = -1;
|
boolean finish = false;
|
||||||
float now, deltaT;
|
boolean markerDetected = false;
|
||||||
|
int detectedCode = -1;
|
||||||
|
ImmutableBag<Entity> entities = null;
|
||||||
|
float deltaT;
|
||||||
|
World world;
|
||||||
|
|
||||||
|
if(manager == null){
|
||||||
|
world = GameGlobals.getGameWorld();
|
||||||
|
if(world == null)
|
||||||
|
throw new IllegalStateException("World is null after getGameWorld().");
|
||||||
|
|
||||||
|
manager = world.getManager(GroupManager.class);
|
||||||
|
if(manager == null)
|
||||||
|
throw new IllegalStateException("World has no group managers.");
|
||||||
|
}
|
||||||
|
|
||||||
if(markers == null)
|
if(markers == null)
|
||||||
throw new IllegalArgumentException("Markers is null");
|
throw new IllegalArgumentException("Markers is null");
|
||||||
|
|
||||||
switch(state){
|
switch(state){
|
||||||
case START:
|
case START:
|
||||||
|
Gdx.app.log(TAG, CLASS_NAME + ".performAutomaticAction(): State is START.");
|
||||||
|
summary.reset();
|
||||||
nextAction = automatic_action_t.ROTATE_90;
|
nextAction = automatic_action_t.ROTATE_90;
|
||||||
state = action_state_t.WALK_FORWARD;
|
state = action_state_t.WALK_FORWARD;
|
||||||
finish = false;
|
finish = false;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WALK_FORWARD:
|
case WALK_FORWARD:
|
||||||
|
Gdx.app.log(TAG, CLASS_NAME + ".performAutomaticAction(): State is WALK_FORWARD.");
|
||||||
if(lightSensorReading >= GOAL_FLOOR_MIN_LUMINANCE){
|
if(lightSensorReading >= GOAL_FLOOR_MIN_LUMINANCE){
|
||||||
|
Gdx.app.log(TAG, CLASS_NAME + ".performAutomaticAction(): Found goal.");
|
||||||
nextAction = automatic_action_t.STOP;
|
nextAction = automatic_action_t.STOP;
|
||||||
state = action_state_t.END;
|
state = action_state_t.FINISHING;
|
||||||
}else{
|
}else{
|
||||||
if(lightSensorReading >= MARKER_NEARBY_FLOOR_MIN_LUMINANCE && lightSensorReading < GOAL_FLOOR_MIN_LUMINANCE){
|
if(lightSensorReading >= MARKER_NEARBY_FLOOR_MIN_LUMINANCE && lightSensorReading < GOAL_FLOOR_MIN_LUMINANCE){
|
||||||
|
Gdx.app.log(TAG, CLASS_NAME + ".performAutomaticAction(): There is a marker nearby.");
|
||||||
nextAction = automatic_action_t.STOP;
|
nextAction = automatic_action_t.STOP;
|
||||||
state = action_state_t.DETECT_MARKER;
|
state = action_state_t.DETECT_MARKER;
|
||||||
then = Gdx.graphics.getDeltaTime();
|
then = Gdx.graphics.getDeltaTime();
|
||||||
}else{
|
}else{
|
||||||
|
Gdx.app.log(TAG, CLASS_NAME + ".performAutomaticAction(): Walking.");
|
||||||
nextAction = automatic_action_t.GO_FORWARD;
|
nextAction = automatic_action_t.GO_FORWARD;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -77,35 +151,68 @@ public class BombGameAutomaticActionPerformer extends AutomaticActionPerformerBa
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case DETECT_MARKER:
|
case DETECT_MARKER:
|
||||||
for(int i = 0; i < ProjectConstants.MAXIMUM_NUMBER_OF_MARKERS; i++){
|
Gdx.app.log(TAG, CLASS_NAME + ".performAutomaticAction(): State is DETECT_MARKER.");
|
||||||
|
for(int i = 0; !markerDetected && i < ProjectConstants.MAXIMUM_NUMBER_OF_MARKERS; i++){
|
||||||
// Check if this marker has not been detected already.
|
// Check if this marker has not been detected already.
|
||||||
for(Integer code : detectedMarkers){
|
for(Integer code : detectedMarkers){
|
||||||
if(markers.markerCodes[i] == code){
|
if(markers.markerCodes[i] == code){
|
||||||
i = ProjectConstants.MAXIMUM_NUMBER_OF_MARKERS;
|
Gdx.app.log(TAG, CLASS_NAME + ".performAutomaticAction(): Marker already detected.");
|
||||||
|
markerDetected = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// If the marker has not been detected before then examine it.
|
// If the marker has not been detected before then examine it.
|
||||||
if(i < ProjectConstants.MAXIMUM_NUMBER_OF_MARKERS){
|
if(!markerDetected){
|
||||||
|
Gdx.app.log(TAG, CLASS_NAME + ".performAutomaticAction(): New marker detected.");
|
||||||
detectedCode = markers.markerCodes[i];
|
detectedCode = markers.markerCodes[i];
|
||||||
// TODO: If marker is a bomb then add it to the summary.
|
entities = manager.getEntities(Integer.toString(detectedCode));
|
||||||
|
|
||||||
|
for(int e = 0; entities != null && e < entities.size() && entities.get(e) != null; e++){
|
||||||
|
bomb = entities.get(e).getComponent(BombComponent.class);
|
||||||
|
|
||||||
|
if(bomb == null){
|
||||||
|
Gdx.app.log(TAG, CLASS_NAME + ".performAutomaticAction(): Entity has no bomb component. Skipping.");
|
||||||
|
}else{
|
||||||
|
Gdx.app.log(TAG, CLASS_NAME + ".performAutomaticAction(): Adding bomb.");
|
||||||
|
switch(bomb.bombType){
|
||||||
|
case COMBINATION:
|
||||||
|
summary.addCombinationBomb();
|
||||||
|
break;
|
||||||
|
case INCLINATION:
|
||||||
|
summary.addInclinationBomb();
|
||||||
|
break;
|
||||||
|
case WIRES:
|
||||||
|
summary.addWireBomb();
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
throw new IllegalStateException("Unrecognized bomb type.");
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(detectedCode == -1)
|
if(!markerDetected && detectedCode != -1)
|
||||||
detectedMarkers.add(detectedCode);
|
detectedMarkers.add(detectedCode);
|
||||||
|
|
||||||
if(lightSensorReading < MARKER_NEARBY_FLOOR_MIN_LUMINANCE){
|
if(lightSensorReading < MARKER_NEARBY_FLOOR_MIN_LUMINANCE){
|
||||||
|
Gdx.app.log(TAG, CLASS_NAME + ".performAutomaticAction(): Switching to WALK_FORWARD.");
|
||||||
state = action_state_t.WALK_FORWARD;
|
state = action_state_t.WALK_FORWARD;
|
||||||
nextAction = automatic_action_t.STOP;
|
nextAction = automatic_action_t.STOP;
|
||||||
then = 0.0f;
|
then = 0.0f;
|
||||||
|
now = 0.0f;
|
||||||
}else{
|
}else{
|
||||||
now = Gdx.graphics.getDeltaTime();
|
Gdx.app.log(TAG, CLASS_NAME + ".performAutomaticAction(): Clearing MARKER_NEARBY_FLOOR.");
|
||||||
deltaT = now - then;
|
now += Gdx.graphics.getDeltaTime();
|
||||||
|
deltaT = now - then;
|
||||||
if(deltaT >= 2.0f){
|
if(deltaT >= 2.0f){
|
||||||
nextAction = automatic_action_t.GO_FORWARD;
|
nextAction = automatic_action_t.GO_FORWARD;
|
||||||
then = Gdx.graphics.getDeltaTime();
|
then = Gdx.graphics.getDeltaTime();
|
||||||
|
now = 0.0f;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -114,16 +221,20 @@ public class BombGameAutomaticActionPerformer extends AutomaticActionPerformerBa
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case FINISHING:
|
case FINISHING:
|
||||||
detectedMarkers.clear();
|
Gdx.app.log(TAG, CLASS_NAME + ".performAutomaticAction(): State is FINISHING.");
|
||||||
state = action_state_t.END;
|
state = action_state_t.END;
|
||||||
nextAction = automatic_action_t.RECENTER;
|
nextAction = automatic_action_t.RECENTER;
|
||||||
finish = false;
|
finish = false;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case END:
|
case END:
|
||||||
state = action_state_t.START;
|
Gdx.app.log(TAG, CLASS_NAME + ".performAutomaticAction(): State is END.");
|
||||||
nextAction = automatic_action_t.NO_ACTION;
|
nextAction = automatic_action_t.NO_ACTION;
|
||||||
finish = true;
|
state = action_state_t.START;
|
||||||
|
finish = true;
|
||||||
|
now = 0.0f;
|
||||||
|
then = 0.0f;
|
||||||
|
detectedMarkers.clear();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@@ -151,4 +262,19 @@ public class BombGameAutomaticActionPerformer extends AutomaticActionPerformerBa
|
|||||||
return automatic_action_t.RECENTER;
|
return automatic_action_t.RECENTER;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public AutomaticActionSummary getSummary() {
|
||||||
|
return (AutomaticActionSummary)summary;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void reset() {
|
||||||
|
Gdx.app.log(TAG, CLASS_NAME + ".reset(): Reset requested.");
|
||||||
|
detectedMarkers.clear();
|
||||||
|
summary.reset();
|
||||||
|
state = action_state_t.START;
|
||||||
|
nextAction = automatic_action_t.NO_ACTION;
|
||||||
|
then = 0.0f;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,127 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2014 Miguel Angel Astor Romero
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
package ve.ucv.ciens.ccg.nxtar.game.bombgame;
|
||||||
|
|
||||||
|
import ve.ucv.ciens.ccg.nxtar.game.AutomaticActionPerformerBase.AutomaticActionSummary;
|
||||||
|
import ve.ucv.ciens.ccg.nxtar.game.AutomaticActionSummaryOverlayBase;
|
||||||
|
import ve.ucv.ciens.ccg.nxtar.game.bombgame.BombGameAutomaticActionPerformer.BombGameAutomaticActionSummary;
|
||||||
|
import ve.ucv.ciens.ccg.nxtar.utils.ProjectConstants;
|
||||||
|
import ve.ucv.ciens.ccg.nxtar.utils.Utils;
|
||||||
|
|
||||||
|
import com.badlogic.gdx.Gdx;
|
||||||
|
import com.badlogic.gdx.graphics.Color;
|
||||||
|
import com.badlogic.gdx.graphics.Texture;
|
||||||
|
import com.badlogic.gdx.graphics.g2d.BitmapFont;
|
||||||
|
import com.badlogic.gdx.graphics.g2d.Sprite;
|
||||||
|
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
|
||||||
|
import com.badlogic.gdx.graphics.g2d.freetype.FreeTypeFontGenerator;
|
||||||
|
import com.badlogic.gdx.graphics.g2d.freetype.FreeTypeFontGenerator.FreeTypeFontParameter;
|
||||||
|
|
||||||
|
public class BombGameAutomaticActionSummaryOverlay extends AutomaticActionSummaryOverlayBase{
|
||||||
|
private static final float CANNONICAL_SCREEN_WIDTH = 800.0f;
|
||||||
|
|
||||||
|
private Texture inclinationBombTexture;
|
||||||
|
private Texture combinationBombTexture;
|
||||||
|
private Texture wireBombTexture;
|
||||||
|
private BitmapFont font;
|
||||||
|
private BitmapFont titleFont;
|
||||||
|
private Sprite inclinationBomb;
|
||||||
|
private Sprite combinationBomb;
|
||||||
|
private Sprite wireBomb;
|
||||||
|
private float inclinationX;
|
||||||
|
private float combinationX;
|
||||||
|
private float wireX;
|
||||||
|
private float inclinationY;
|
||||||
|
private float combinationY;
|
||||||
|
private float wireY;
|
||||||
|
private float titleWidth;
|
||||||
|
private float titleHeight;
|
||||||
|
|
||||||
|
public BombGameAutomaticActionSummaryOverlay(){
|
||||||
|
FreeTypeFontGenerator fontGenerator;
|
||||||
|
FreeTypeFontParameter fontParameters;
|
||||||
|
|
||||||
|
inclinationBombTexture = new Texture(Gdx.files.internal("data/gfx/bomb_game/incl_bomb.png"));
|
||||||
|
combinationBombTexture = new Texture(Gdx.files.internal("data/gfx/bomb_game/comb_bomb.png"));
|
||||||
|
wireBombTexture = new Texture(Gdx.files.internal("data/gfx/bomb_game/wire_bomb.png"));
|
||||||
|
|
||||||
|
inclinationBomb = new Sprite(inclinationBombTexture);
|
||||||
|
combinationBomb = new Sprite(combinationBombTexture);
|
||||||
|
wireBomb = new Sprite(wireBombTexture);
|
||||||
|
|
||||||
|
inclinationBomb.setSize(inclinationBomb.getWidth() * 0.5f, inclinationBomb.getHeight() * 0.5f);
|
||||||
|
combinationBomb.setSize(combinationBomb.getWidth() * 0.5f, combinationBomb.getHeight() * 0.5f);
|
||||||
|
wireBomb.setSize(wireBomb.getWidth() * 0.5f, wireBomb.getHeight() * 0.5f);
|
||||||
|
|
||||||
|
combinationBomb.setPosition(-(Utils.getScreenWidthWithOverscan() / 4.0f) - combinationBomb.getWidth(), -(combinationBomb.getHeight() / 2.0f));
|
||||||
|
inclinationBomb.setPosition(-(Utils.getScreenWidthWithOverscan() / 4.0f) - inclinationBomb.getWidth(), combinationBomb.getY() + combinationBomb.getHeight() + 10.0f);
|
||||||
|
wireBomb.setPosition(-(Utils.getScreenWidthWithOverscan() / 4.0f) - wireBomb.getWidth(), combinationBomb.getY() - wireBomb.getHeight() - 10.0f);
|
||||||
|
|
||||||
|
fontParameters = new FreeTypeFontParameter();
|
||||||
|
fontParameters.characters = ProjectConstants.FONT_CHARS;
|
||||||
|
fontParameters.size = (int)((float)ProjectConstants.MENU_BUTTON_FONT_SIZE * ((float)Gdx.graphics.getWidth() / CANNONICAL_SCREEN_WIDTH));
|
||||||
|
fontParameters.flip = false;
|
||||||
|
fontGenerator = new FreeTypeFontGenerator(Gdx.files.internal("data/fonts/d-puntillas-B-to-tiptoe.ttf"));
|
||||||
|
|
||||||
|
font = fontGenerator.generateFont(fontParameters);
|
||||||
|
font.setColor(Color.YELLOW);
|
||||||
|
|
||||||
|
fontParameters.size = (int)(90.0f * ((float)Gdx.graphics.getWidth() / CANNONICAL_SCREEN_WIDTH));
|
||||||
|
titleFont = fontGenerator.generateFont(fontParameters);
|
||||||
|
|
||||||
|
fontGenerator.dispose();
|
||||||
|
|
||||||
|
inclinationX = inclinationBomb.getX() + inclinationBomb.getWidth() + 15.0f;
|
||||||
|
combinationX = combinationBomb.getX() + combinationBomb.getWidth() + 15.0f;
|
||||||
|
wireX = wireBomb.getX() + wireBomb.getWidth() + 15.0f;
|
||||||
|
|
||||||
|
inclinationY = inclinationBomb.getY() + (inclinationBomb.getWidth() / 2.0f) - (font.getCapHeight() / 2.0f);
|
||||||
|
combinationY = combinationBomb.getY() + (combinationBomb.getWidth() / 2.0f) - (font.getCapHeight() / 2.0f);
|
||||||
|
wireY = wireBomb.getY() + (wireBomb.getWidth() / 2.0f) - (font.getCapHeight() / 2.0f);
|
||||||
|
|
||||||
|
titleWidth = titleFont.getBounds("Summary").width;
|
||||||
|
titleHeight = titleFont.getBounds("Summary").height;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void dispose() {
|
||||||
|
inclinationBombTexture.dispose();
|
||||||
|
combinationBombTexture.dispose();
|
||||||
|
wireBombTexture.dispose();
|
||||||
|
font.dispose();
|
||||||
|
titleFont.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void render(SpriteBatch batch, AutomaticActionSummary summary) throws ClassCastException{
|
||||||
|
BombGameAutomaticActionSummary bombGameSummary;
|
||||||
|
|
||||||
|
if(!(summary instanceof BombGameAutomaticActionSummary))
|
||||||
|
throw new ClassCastException("Summary is not a bomb game summary.");
|
||||||
|
|
||||||
|
bombGameSummary = (BombGameAutomaticActionSummary)summary;
|
||||||
|
|
||||||
|
inclinationBomb.draw(batch);
|
||||||
|
combinationBomb.draw(batch);
|
||||||
|
wireBomb.draw(batch);
|
||||||
|
|
||||||
|
font.draw(batch, String.format("Inclination bombs: %d", bombGameSummary.getNumInclinationBombs()), inclinationX, inclinationY);
|
||||||
|
font.draw(batch, String.format("Combination bombs: %d", bombGameSummary.getNumCombinationBombs()), combinationX, combinationY);
|
||||||
|
font.draw(batch, String.format("Wire bombs: %d", bombGameSummary.getNumWireBombs()), wireX, wireY);
|
||||||
|
|
||||||
|
titleFont.draw(batch, "Summary", -(titleWidth / 2), (Utils.getScreenHeightWithOverscan() / 2) - titleHeight - 10);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -269,7 +269,6 @@ public class BombGameEntityCreator extends EntityCreatorBase{
|
|||||||
|
|
||||||
private void addBomb(EntityParameters parameters, bomb_type_t type) throws IllegalArgumentException{
|
private void addBomb(EntityParameters parameters, bomb_type_t type) throws IllegalArgumentException{
|
||||||
Entity bomb;
|
Entity bomb;
|
||||||
BombComponent bombComponent = new BombComponent(currentBombId, type);
|
|
||||||
|
|
||||||
// Create a bomb entity and add it's generic components.
|
// Create a bomb entity and add it's generic components.
|
||||||
bomb = world.createEntity();
|
bomb = world.createEntity();
|
||||||
@@ -277,54 +276,54 @@ public class BombGameEntityCreator extends EntityCreatorBase{
|
|||||||
bomb.addComponent(new EnvironmentComponent(parameters.environment));
|
bomb.addComponent(new EnvironmentComponent(parameters.environment));
|
||||||
bomb.addComponent(new ShaderComponent(parameters.shader));
|
bomb.addComponent(new ShaderComponent(parameters.shader));
|
||||||
bomb.addComponent(new MarkerCodeComponent(parameters.markerCode));
|
bomb.addComponent(new MarkerCodeComponent(parameters.markerCode));
|
||||||
bomb.addComponent(bombComponent);
|
bomb.addComponent(new BombComponent(currentBombId, type));
|
||||||
bomb.addComponent(new VisibilityComponent());
|
bomb.addComponent(new VisibilityComponent());
|
||||||
|
|
||||||
// Add the collision and render models depending on the bomb type.
|
// Add the collision and render models depending on the bomb type.
|
||||||
if(type == bomb_type_t.COMBINATION){
|
if(type == bomb_type_t.COMBINATION){
|
||||||
bomb.addComponent(new RenderModelComponent(combinationBombModel));
|
bomb.addComponent(new RenderModelComponent(combinationBombModel));
|
||||||
bomb.addComponent(new CollisionModelComponent(combinationBombCollisionModel));
|
bomb.addComponent(new CollisionModelComponent(combinationBombCollisionModel));
|
||||||
addBombCombinationButtons(parameters, bombComponent);
|
addBombCombinationButtons(parameters);
|
||||||
if(DEBUG_RENDER_BOMB_COLLISION_MODELS)
|
if(DEBUG_RENDER_BOMB_COLLISION_MODELS)
|
||||||
addDebugCollisionModelRenderingEntity(combinationBombCollisionModel, parameters, false);
|
addDebugCollisionModelRenderingEntity(combinationBombCollisionModel, parameters, false);
|
||||||
|
|
||||||
}else if(type == bomb_type_t.INCLINATION){
|
}else if(type == bomb_type_t.INCLINATION){
|
||||||
bomb.addComponent(new RenderModelComponent(inclinationBombModel));
|
bomb.addComponent(new RenderModelComponent(inclinationBombModel));
|
||||||
bomb.addComponent(new CollisionModelComponent(inclinationBombCollisionModel));
|
bomb.addComponent(new CollisionModelComponent(inclinationBombCollisionModel));
|
||||||
addBombInclinationButton(parameters, bombComponent);
|
addBombInclinationButton(parameters);
|
||||||
if(DEBUG_RENDER_BOMB_COLLISION_MODELS)
|
if(DEBUG_RENDER_BOMB_COLLISION_MODELS)
|
||||||
addDebugCollisionModelRenderingEntity(inclinationBombCollisionModel, parameters, false);
|
addDebugCollisionModelRenderingEntity(inclinationBombCollisionModel, parameters, false);
|
||||||
|
|
||||||
}else if(type == bomb_type_t.WIRES){
|
}else if(type == bomb_type_t.WIRES){
|
||||||
bomb.addComponent(new RenderModelComponent(wiresBombModel));
|
bomb.addComponent(new RenderModelComponent(wiresBombModel));
|
||||||
bomb.addComponent(new CollisionModelComponent(wiresBombCollisionModel));
|
bomb.addComponent(new CollisionModelComponent(wiresBombCollisionModel));
|
||||||
addBombWires(parameters, bombComponent);
|
addBombWires(parameters);
|
||||||
if(DEBUG_RENDER_BOMB_COLLISION_MODELS)
|
if(DEBUG_RENDER_BOMB_COLLISION_MODELS)
|
||||||
addDebugCollisionModelRenderingEntity(wiresBombCollisionModel, parameters, false);
|
addDebugCollisionModelRenderingEntity(wiresBombCollisionModel, parameters, false);
|
||||||
|
|
||||||
}else
|
}else
|
||||||
throw new IllegalArgumentException("Unrecognized bomb type: " + Integer.toString(type.getValue()));
|
throw new IllegalArgumentException("Unrecognized bomb type: " + Integer.toString(type.getValue()));
|
||||||
|
|
||||||
// Add the bomb and increase the id for the next one.
|
// Add the bomb to the world and the respective marker group. Then increase the id for the next bomb.
|
||||||
//groupManager.add(bomb, CollisionDetectionSystem.COLLIDABLE_OBJECT);
|
groupManager.add(bomb, Integer.toString(parameters.markerCode));
|
||||||
bomb.addToWorld();
|
bomb.addToWorld();
|
||||||
entities.add(bomb);
|
entities.add(bomb);
|
||||||
currentBombId++;
|
currentBombId++;
|
||||||
NUM_BOMBS++;
|
NUM_BOMBS++;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addBombCombinationButtons(EntityParameters parameters, BombComponent bomb){
|
private void addBombCombinationButtons(EntityParameters parameters){
|
||||||
Entity button1, button2, button3, button4;
|
Entity button1, button2, button3, button4;
|
||||||
|
|
||||||
button1 = addBombParaphernalia(combinationButton1Model, combinationButton1CollisionModel, bomb, parameters);
|
button1 = addBombParaphernalia(combinationButton1Model, combinationButton1CollisionModel, parameters);
|
||||||
button2 = addBombParaphernalia(combinationButton2Model, combinationButton2CollisionModel, bomb, parameters);
|
button2 = addBombParaphernalia(combinationButton2Model, combinationButton2CollisionModel, parameters);
|
||||||
button3 = addBombParaphernalia(combinationButton3Model, combinationButton3CollisionModel, bomb, parameters);
|
button3 = addBombParaphernalia(combinationButton3Model, combinationButton3CollisionModel, parameters);
|
||||||
button4 = addBombParaphernalia(combinationButton4Model, combinationButton4CollisionModel, bomb, parameters);
|
button4 = addBombParaphernalia(combinationButton4Model, combinationButton4CollisionModel, parameters);
|
||||||
|
|
||||||
button1.addComponent(new BombGameObjectTypeComponent(BombGameObjectTypeComponent.COM_BUTTON_1));
|
button1.addComponent(new BombGameEntityTypeComponent(BombGameEntityTypeComponent.COM_BUTTON_1));
|
||||||
button2.addComponent(new BombGameObjectTypeComponent(BombGameObjectTypeComponent.COM_BUTTON_2));
|
button2.addComponent(new BombGameEntityTypeComponent(BombGameEntityTypeComponent.COM_BUTTON_2));
|
||||||
button3.addComponent(new BombGameObjectTypeComponent(BombGameObjectTypeComponent.COM_BUTTON_3));
|
button3.addComponent(new BombGameEntityTypeComponent(BombGameEntityTypeComponent.COM_BUTTON_3));
|
||||||
button4.addComponent(new BombGameObjectTypeComponent(BombGameObjectTypeComponent.COM_BUTTON_4));
|
button4.addComponent(new BombGameEntityTypeComponent(BombGameEntityTypeComponent.COM_BUTTON_4));
|
||||||
|
|
||||||
button1.addToWorld();
|
button1.addToWorld();
|
||||||
button2.addToWorld();
|
button2.addToWorld();
|
||||||
@@ -332,31 +331,31 @@ public class BombGameEntityCreator extends EntityCreatorBase{
|
|||||||
button4.addToWorld();
|
button4.addToWorld();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addBombInclinationButton(EntityParameters parameters, BombComponent bomb){
|
private void addBombInclinationButton(EntityParameters parameters){
|
||||||
Entity button;
|
Entity button;
|
||||||
|
|
||||||
button = addBombParaphernalia(inclinationBombButtonModel, inclinationBombButtonCollisionModel, bomb, parameters);
|
button = addBombParaphernalia(inclinationBombButtonModel, inclinationBombButtonCollisionModel, parameters);
|
||||||
button.addComponent(new BombGameObjectTypeComponent(BombGameObjectTypeComponent.BIG_BUTTON));
|
button.addComponent(new BombGameEntityTypeComponent(BombGameEntityTypeComponent.BIG_BUTTON));
|
||||||
button.addToWorld();
|
button.addToWorld();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addBombWires(EntityParameters parameters, BombComponent bomb){
|
private void addBombWires(EntityParameters parameters){
|
||||||
Entity wire1, wire2, wire3;
|
Entity wire1, wire2, wire3;
|
||||||
|
|
||||||
wire1 = addBombParaphernalia(wiresBombModelWire1, wiresBombCollisionModelWire1, bomb, parameters);
|
wire1 = addBombParaphernalia(wiresBombModelWire1, wiresBombCollisionModelWire1, parameters);
|
||||||
wire2 = addBombParaphernalia(wiresBombModelWire2, wiresBombCollisionModelWire2, bomb, parameters);
|
wire2 = addBombParaphernalia(wiresBombModelWire2, wiresBombCollisionModelWire2, parameters);
|
||||||
wire3 = addBombParaphernalia(wiresBombModelWire3, wiresBombCollisionModelWire3, bomb, parameters);
|
wire3 = addBombParaphernalia(wiresBombModelWire3, wiresBombCollisionModelWire3, parameters);
|
||||||
|
|
||||||
wire1.addComponent(new BombGameObjectTypeComponent(BombGameObjectTypeComponent.BOMB_WIRE_1));
|
wire1.addComponent(new BombGameEntityTypeComponent(BombGameEntityTypeComponent.BOMB_WIRE_1));
|
||||||
wire2.addComponent(new BombGameObjectTypeComponent(BombGameObjectTypeComponent.BOMB_WIRE_2));
|
wire2.addComponent(new BombGameEntityTypeComponent(BombGameEntityTypeComponent.BOMB_WIRE_2));
|
||||||
wire3.addComponent(new BombGameObjectTypeComponent(BombGameObjectTypeComponent.BOMB_WIRE_3));
|
wire3.addComponent(new BombGameEntityTypeComponent(BombGameEntityTypeComponent.BOMB_WIRE_3));
|
||||||
|
|
||||||
wire1.addToWorld();
|
wire1.addToWorld();
|
||||||
wire2.addToWorld();
|
wire2.addToWorld();
|
||||||
wire3.addToWorld();
|
wire3.addToWorld();
|
||||||
}
|
}
|
||||||
|
|
||||||
private Entity addBombParaphernalia(Model renderModel, Model collisionModel, BombComponent bomb, EntityParameters parameters){
|
private Entity addBombParaphernalia(Model renderModel, Model collisionModel, EntityParameters parameters){
|
||||||
Entity thing;
|
Entity thing;
|
||||||
|
|
||||||
thing = world.createEntity();
|
thing = world.createEntity();
|
||||||
@@ -365,7 +364,6 @@ public class BombGameEntityCreator extends EntityCreatorBase{
|
|||||||
thing.addComponent(new ShaderComponent(parameters.shader));
|
thing.addComponent(new ShaderComponent(parameters.shader));
|
||||||
thing.addComponent(new RenderModelComponent(renderModel));
|
thing.addComponent(new RenderModelComponent(renderModel));
|
||||||
thing.addComponent(new CollisionModelComponent(collisionModel));
|
thing.addComponent(new CollisionModelComponent(collisionModel));
|
||||||
thing.addComponent(new BombComponent(bomb));
|
|
||||||
thing.addComponent(new VisibilityComponent());
|
thing.addComponent(new VisibilityComponent());
|
||||||
thing.addComponent(new MarkerCodeComponent(parameters.markerCode));
|
thing.addComponent(new MarkerCodeComponent(parameters.markerCode));
|
||||||
thing.addComponent(new CollisionDetectionComponent());
|
thing.addComponent(new CollisionDetectionComponent());
|
||||||
@@ -393,7 +391,7 @@ public class BombGameEntityCreator extends EntityCreatorBase{
|
|||||||
frame.addComponent(new ShaderComponent(parameters.shader));
|
frame.addComponent(new ShaderComponent(parameters.shader));
|
||||||
frame.addComponent(new VisibilityComponent());
|
frame.addComponent(new VisibilityComponent());
|
||||||
frame.addComponent(new MarkerCodeComponent(parameters.markerCode));
|
frame.addComponent(new MarkerCodeComponent(parameters.markerCode));
|
||||||
frame.addComponent(new BombGameObjectTypeComponent(BombGameObjectTypeComponent.DOOR_FRAME));
|
frame.addComponent(new BombGameEntityTypeComponent(BombGameEntityTypeComponent.DOOR_FRAME));
|
||||||
groupManager.add(frame, Integer.toString(parameters.markerCode));
|
groupManager.add(frame, Integer.toString(parameters.markerCode));
|
||||||
frame.addToWorld();
|
frame.addToWorld();
|
||||||
|
|
||||||
@@ -409,7 +407,7 @@ public class BombGameEntityCreator extends EntityCreatorBase{
|
|||||||
doorColInstance = door.getComponent(CollisionModelComponent.class).instance;
|
doorColInstance = door.getComponent(CollisionModelComponent.class).instance;
|
||||||
door.addComponent(new AnimationComponent(doorInstance, parameters.nextAnimation, parameters.loopAnimation, doorColInstance));
|
door.addComponent(new AnimationComponent(doorInstance, parameters.nextAnimation, parameters.loopAnimation, doorColInstance));
|
||||||
door.addComponent(new CollisionDetectionComponent());
|
door.addComponent(new CollisionDetectionComponent());
|
||||||
door.addComponent(new BombGameObjectTypeComponent(BombGameObjectTypeComponent.DOOR));
|
door.addComponent(new BombGameEntityTypeComponent(BombGameEntityTypeComponent.DOOR));
|
||||||
groupManager.add(door, CollisionDetectionSystem.COLLIDABLE_OBJECTS_GROUP);
|
groupManager.add(door, CollisionDetectionSystem.COLLIDABLE_OBJECTS_GROUP);
|
||||||
groupManager.add(door, Integer.toString(parameters.markerCode));
|
groupManager.add(door, Integer.toString(parameters.markerCode));
|
||||||
groupManager.add(door, DOORS_GROUP);
|
groupManager.add(door, DOORS_GROUP);
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ package ve.ucv.ciens.ccg.nxtar.game.bombgame;
|
|||||||
|
|
||||||
import com.artemis.Component;
|
import com.artemis.Component;
|
||||||
|
|
||||||
public class BombGameObjectTypeComponent extends Component {
|
public class BombGameEntityTypeComponent extends Component {
|
||||||
public static final int BOMB_WIRE_1 = 10;
|
public static final int BOMB_WIRE_1 = 10;
|
||||||
public static final int BOMB_WIRE_2 = 11;
|
public static final int BOMB_WIRE_2 = 11;
|
||||||
public static final int BOMB_WIRE_3 = 12;
|
public static final int BOMB_WIRE_3 = 12;
|
||||||
@@ -32,7 +32,7 @@ public class BombGameObjectTypeComponent extends Component {
|
|||||||
|
|
||||||
public int type;
|
public int type;
|
||||||
|
|
||||||
public BombGameObjectTypeComponent(int type){
|
public BombGameEntityTypeComponent(int type){
|
||||||
this.type = type;
|
this.type = type;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -53,7 +53,7 @@ public class BombGameLogicSystem extends GameLogicSystemBase {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Mapper ComponentMapper<BombGameObjectTypeComponent> typeMapper;
|
@Mapper ComponentMapper<BombGameEntityTypeComponent> typeMapper;
|
||||||
@Mapper ComponentMapper<AnimationComponent> animationMapper;
|
@Mapper ComponentMapper<AnimationComponent> animationMapper;
|
||||||
@Mapper ComponentMapper<VisibilityComponent> visibilityMapper;
|
@Mapper ComponentMapper<VisibilityComponent> visibilityMapper;
|
||||||
@Mapper ComponentMapper<MarkerCodeComponent> markerMapper;
|
@Mapper ComponentMapper<MarkerCodeComponent> markerMapper;
|
||||||
@@ -61,20 +61,20 @@ public class BombGameLogicSystem extends GameLogicSystemBase {
|
|||||||
@Mapper ComponentMapper<FadeEffectComponent> fadeMapper;
|
@Mapper ComponentMapper<FadeEffectComponent> fadeMapper;
|
||||||
|
|
||||||
private MarkerCodeComponent tempMarker;
|
private MarkerCodeComponent tempMarker;
|
||||||
private BombGameObjectTypeComponent tempType;
|
private BombGameEntityTypeComponent tempType;
|
||||||
private GroupManager manager;
|
private GroupManager manager;
|
||||||
private int then;
|
private int then;
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public BombGameLogicSystem(){
|
public BombGameLogicSystem(){
|
||||||
super(Aspect.getAspectForAll(BombGameObjectTypeComponent.class));
|
super(Aspect.getAspectForAll(BombGameEntityTypeComponent.class));
|
||||||
manager = null;
|
manager = null;
|
||||||
then = 0;
|
then = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void process(Entity e){
|
protected void process(Entity e){
|
||||||
BombGameObjectTypeComponent typeComponent;
|
BombGameEntityTypeComponent typeComponent;
|
||||||
|
|
||||||
if(manager == null)
|
if(manager == null)
|
||||||
manager = world.getManager(GroupManager.class);
|
manager = world.getManager(GroupManager.class);
|
||||||
@@ -82,28 +82,28 @@ public class BombGameLogicSystem extends GameLogicSystemBase {
|
|||||||
typeComponent = typeMapper.get(e);
|
typeComponent = typeMapper.get(e);
|
||||||
|
|
||||||
switch(typeComponent.type){
|
switch(typeComponent.type){
|
||||||
case BombGameObjectTypeComponent.BOMB_WIRE_1:
|
case BombGameEntityTypeComponent.BOMB_WIRE_1:
|
||||||
case BombGameObjectTypeComponent.BOMB_WIRE_2:
|
case BombGameEntityTypeComponent.BOMB_WIRE_2:
|
||||||
case BombGameObjectTypeComponent.BOMB_WIRE_3:
|
case BombGameEntityTypeComponent.BOMB_WIRE_3:
|
||||||
processWireBomb(e);
|
processWireBomb(e);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case BombGameObjectTypeComponent.BIG_BUTTON:
|
case BombGameEntityTypeComponent.BIG_BUTTON:
|
||||||
processInclinationBomb(e);
|
processInclinationBomb(e);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case BombGameObjectTypeComponent.COM_BUTTON_1:
|
case BombGameEntityTypeComponent.COM_BUTTON_1:
|
||||||
case BombGameObjectTypeComponent.COM_BUTTON_2:
|
case BombGameEntityTypeComponent.COM_BUTTON_2:
|
||||||
case BombGameObjectTypeComponent.COM_BUTTON_3:
|
case BombGameEntityTypeComponent.COM_BUTTON_3:
|
||||||
case BombGameObjectTypeComponent.COM_BUTTON_4:
|
case BombGameEntityTypeComponent.COM_BUTTON_4:
|
||||||
processCombinationBomb(e);
|
processCombinationBomb(e);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case BombGameObjectTypeComponent.DOOR:
|
case BombGameEntityTypeComponent.DOOR:
|
||||||
processDoor(e);
|
processDoor(e);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case BombGameObjectTypeComponent.FADE_EFFECT:
|
case BombGameEntityTypeComponent.FADE_EFFECT:
|
||||||
processFade(e);
|
processFade(e);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -120,7 +120,7 @@ public class BombGameLogicSystem extends GameLogicSystemBase {
|
|||||||
private void processWireBomb(Entity b){
|
private void processWireBomb(Entity b){
|
||||||
CollisionDetectionComponent collision;
|
CollisionDetectionComponent collision;
|
||||||
MarkerCodeComponent marker;
|
MarkerCodeComponent marker;
|
||||||
BombGameObjectTypeComponent wireType;
|
BombGameEntityTypeComponent wireType;
|
||||||
|
|
||||||
// Get this wire's parameters.
|
// Get this wire's parameters.
|
||||||
collision = collisionMapper.getSafe(b);
|
collision = collisionMapper.getSafe(b);
|
||||||
@@ -140,7 +140,7 @@ public class BombGameLogicSystem extends GameLogicSystemBase {
|
|||||||
manager.remove(b, Integer.toString(marker.code));
|
manager.remove(b, Integer.toString(marker.code));
|
||||||
b.deleteFromWorld();
|
b.deleteFromWorld();
|
||||||
|
|
||||||
if(wireType.type != BombGameObjectTypeComponent.BOMB_WIRE_1){
|
if(wireType.type != BombGameEntityTypeComponent.BOMB_WIRE_1){
|
||||||
Gdx.app.log(TAG, CLASS_NAME + ".processWireBomb(): Wire bomb exploded.");
|
Gdx.app.log(TAG, CLASS_NAME + ".processWireBomb(): Wire bomb exploded.");
|
||||||
createFadeOutEffect();
|
createFadeOutEffect();
|
||||||
reducePlayerLivesByOne();
|
reducePlayerLivesByOne();
|
||||||
@@ -163,7 +163,7 @@ public class BombGameLogicSystem extends GameLogicSystemBase {
|
|||||||
combination_button_state_t state;
|
combination_button_state_t state;
|
||||||
CollisionDetectionComponent collision;
|
CollisionDetectionComponent collision;
|
||||||
MarkerCodeComponent marker;
|
MarkerCodeComponent marker;
|
||||||
BombGameObjectTypeComponent buttonType;
|
BombGameEntityTypeComponent buttonType;
|
||||||
|
|
||||||
// Get this wire's parameters.
|
// Get this wire's parameters.
|
||||||
collision = collisionMapper.getSafe(b);
|
collision = collisionMapper.getSafe(b);
|
||||||
@@ -360,10 +360,10 @@ public class BombGameLogicSystem extends GameLogicSystemBase {
|
|||||||
// Enable collisions with the corresponding door frame entity. Disable collisions with other related entities.
|
// Enable collisions with the corresponding door frame entity. Disable collisions with other related entities.
|
||||||
if(tempMarker != null) tempMarker.enabled = false;
|
if(tempMarker != null) tempMarker.enabled = false;
|
||||||
if(tempType != null){
|
if(tempType != null){
|
||||||
if(tempType.type != BombGameObjectTypeComponent.DOOR_FRAME && tempType.type != BombGameObjectTypeComponent.DOOR){
|
if(tempType.type != BombGameEntityTypeComponent.DOOR_FRAME && tempType.type != BombGameEntityTypeComponent.DOOR){
|
||||||
manager.remove(related.get(i), CollisionDetectionSystem.COLLIDABLE_OBJECTS_GROUP);
|
manager.remove(related.get(i), CollisionDetectionSystem.COLLIDABLE_OBJECTS_GROUP);
|
||||||
manager.remove(related.get(i), Integer.toString(markerCode));
|
manager.remove(related.get(i), Integer.toString(markerCode));
|
||||||
}else if(tempType.type != BombGameObjectTypeComponent.DOOR_FRAME){
|
}else if(tempType.type != BombGameEntityTypeComponent.DOOR_FRAME){
|
||||||
manager.add(related.get(i), CollisionDetectionSystem.COLLIDABLE_OBJECTS_GROUP);
|
manager.add(related.get(i), CollisionDetectionSystem.COLLIDABLE_OBJECTS_GROUP);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -373,7 +373,7 @@ public class BombGameLogicSystem extends GameLogicSystemBase {
|
|||||||
/**
|
/**
|
||||||
* <p>Checks if a combination bomb is being disabled in the correct sequence.</p>
|
* <p>Checks if a combination bomb is being disabled in the correct sequence.</p>
|
||||||
*
|
*
|
||||||
* @param buttonType A number between {@link BombGameObjectTypeComponent.COM_BUTTON_1} and {@link BombGameObjectTypeComponent.COM_BUTTON_4}.
|
* @param buttonType A number between {@link BombGameEntityTypeComponent.COM_BUTTON_1} and {@link BombGameEntityTypeComponent.COM_BUTTON_4}.
|
||||||
* @param markerCode A marker code between [0, 1023], inclusive.
|
* @param markerCode A marker code between [0, 1023], inclusive.
|
||||||
* @return The current state of the bomb.
|
* @return The current state of the bomb.
|
||||||
* @throws IllegalArgumentException If marker code is not in range or if buttonType is not valid.
|
* @throws IllegalArgumentException If marker code is not in range or if buttonType is not valid.
|
||||||
@@ -384,7 +384,7 @@ public class BombGameLogicSystem extends GameLogicSystemBase {
|
|||||||
int remainingButtons = 0;
|
int remainingButtons = 0;
|
||||||
ImmutableBag<Entity> related;
|
ImmutableBag<Entity> related;
|
||||||
|
|
||||||
if(buttonType < BombGameObjectTypeComponent.COM_BUTTON_1 || buttonType > BombGameObjectTypeComponent.COM_BUTTON_4)
|
if(buttonType < BombGameEntityTypeComponent.COM_BUTTON_1 || buttonType > BombGameEntityTypeComponent.COM_BUTTON_4)
|
||||||
throw new IllegalArgumentException("Button is not a valid combination bomb button: " + Integer.toString(buttonType));
|
throw new IllegalArgumentException("Button is not a valid combination bomb button: " + Integer.toString(buttonType));
|
||||||
|
|
||||||
if(markerCode < 0 || markerCode > 1023)
|
if(markerCode < 0 || markerCode > 1023)
|
||||||
@@ -398,7 +398,7 @@ public class BombGameLogicSystem extends GameLogicSystemBase {
|
|||||||
|
|
||||||
if(tempType == null) continue;
|
if(tempType == null) continue;
|
||||||
|
|
||||||
if(tempType.type >= BombGameObjectTypeComponent.COM_BUTTON_1 && tempType.type <= BombGameObjectTypeComponent.COM_BUTTON_4){
|
if(tempType.type >= BombGameEntityTypeComponent.COM_BUTTON_1 && tempType.type <= BombGameEntityTypeComponent.COM_BUTTON_4){
|
||||||
if(tempType.type >= buttonType){
|
if(tempType.type >= buttonType){
|
||||||
// If this remaining button is a correct one then skip it.
|
// If this remaining button is a correct one then skip it.
|
||||||
remainingButtons++;
|
remainingButtons++;
|
||||||
@@ -427,7 +427,7 @@ public class BombGameLogicSystem extends GameLogicSystemBase {
|
|||||||
*/
|
*/
|
||||||
private void createFadeOutEffect(){
|
private void createFadeOutEffect(){
|
||||||
Entity effect = world.createEntity();
|
Entity effect = world.createEntity();
|
||||||
effect.addComponent(new BombGameObjectTypeComponent(BombGameObjectTypeComponent.FADE_EFFECT));
|
effect.addComponent(new BombGameEntityTypeComponent(BombGameEntityTypeComponent.FADE_EFFECT));
|
||||||
effect.addComponent(new FadeEffectComponent());
|
effect.addComponent(new FadeEffectComponent());
|
||||||
effect.addToWorld();
|
effect.addToWorld();
|
||||||
}
|
}
|
||||||
@@ -437,7 +437,7 @@ public class BombGameLogicSystem extends GameLogicSystemBase {
|
|||||||
*/
|
*/
|
||||||
private void createFadeInEffect(){
|
private void createFadeInEffect(){
|
||||||
Entity effect = world.createEntity();
|
Entity effect = world.createEntity();
|
||||||
effect.addComponent(new BombGameObjectTypeComponent(BombGameObjectTypeComponent.FADE_EFFECT));
|
effect.addComponent(new BombGameEntityTypeComponent(BombGameEntityTypeComponent.FADE_EFFECT));
|
||||||
effect.addComponent(new FadeEffectComponent(true));
|
effect.addComponent(new FadeEffectComponent(true));
|
||||||
effect.addToWorld();
|
effect.addToWorld();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ import com.badlogic.gdx.graphics.g2d.SpriteBatch;
|
|||||||
import com.badlogic.gdx.utils.Disposable;
|
import com.badlogic.gdx.utils.Disposable;
|
||||||
|
|
||||||
public class BombGamePlayerSystem extends PlayerSystemBase implements Disposable{
|
public class BombGamePlayerSystem extends PlayerSystemBase implements Disposable{
|
||||||
private static final float HEART_Y_POS = (Utils.getScreenHeight() / 2) - 69;
|
private static final float HEART_Y_POS = (Utils.getScreenHeightWithOverscan() / 2) - 69;
|
||||||
@Mapper ComponentMapper<BombGamePlayerComponent> playerMapper;
|
@Mapper ComponentMapper<BombGamePlayerComponent> playerMapper;
|
||||||
|
|
||||||
private SpriteBatch batch;
|
private SpriteBatch batch;
|
||||||
@@ -50,7 +50,7 @@ public class BombGamePlayerSystem extends PlayerSystemBase implements Disposable
|
|||||||
BombGamePlayerComponent player = playerMapper.get(e);
|
BombGamePlayerComponent player = playerMapper.get(e);
|
||||||
|
|
||||||
// Render remaining lives.
|
// Render remaining lives.
|
||||||
heartXPos = -(Utils.getScreenWidth() / 2) + 5;
|
heartXPos = -(Utils.getScreenWidthWithOverscan() / 2) + 5;
|
||||||
for(int i = 0; i < player.lives; ++i){
|
for(int i = 0; i < player.lives; ++i){
|
||||||
heart.setPosition(heartXPos, HEART_Y_POS);
|
heart.setPosition(heartXPos, HEART_Y_POS);
|
||||||
heart.draw(batch);
|
heart.draw(batch);
|
||||||
|
|||||||
@@ -85,6 +85,7 @@ public class AutomaticActionState extends BaseState{
|
|||||||
private boolean ignoreBackKey;
|
private boolean ignoreBackKey;
|
||||||
private boolean automaticActionEnabled;
|
private boolean automaticActionEnabled;
|
||||||
private AutomaticActionPerformerBase automaticActionPerformer;
|
private AutomaticActionPerformerBase automaticActionPerformer;
|
||||||
|
private automatic_action_t previousAction;
|
||||||
|
|
||||||
// Cameras.
|
// Cameras.
|
||||||
private OrthographicCamera unitaryOrthographicCamera;
|
private OrthographicCamera unitaryOrthographicCamera;
|
||||||
@@ -136,6 +137,7 @@ public class AutomaticActionState extends BaseState{
|
|||||||
automaticActionEnabled = false;
|
automaticActionEnabled = false;
|
||||||
startButtonPressed = false;
|
startButtonPressed = false;
|
||||||
automaticActionPerformer = GameGlobals.getAutomaticActionPerformer();
|
automaticActionPerformer = GameGlobals.getAutomaticActionPerformer();
|
||||||
|
previousAction = automatic_action_t.NO_ACTION;
|
||||||
|
|
||||||
// Set up the cameras.
|
// Set up the cameras.
|
||||||
pixelPerfectOrthographicCamera = new OrthographicCamera(Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
|
pixelPerfectOrthographicCamera = new OrthographicCamera(Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
|
||||||
@@ -306,11 +308,11 @@ public class AutomaticActionState extends BaseState{
|
|||||||
frameBufferSprite.translate(-frameBufferSprite.getWidth() / 2, 0.5f - frameBufferSprite.getHeight());
|
frameBufferSprite.translate(-frameBufferSprite.getWidth() / 2, 0.5f - frameBufferSprite.getHeight());
|
||||||
}else{
|
}else{
|
||||||
float xSize = Gdx.graphics.getHeight() * (w / h);
|
float xSize = Gdx.graphics.getHeight() * (w / h);
|
||||||
renderableVideoFrame.setSize(xSize * ProjectConstants.OVERSCAN, Utils.getScreenHeight());
|
renderableVideoFrame.setSize(xSize * ProjectConstants.OVERSCAN, Utils.getScreenHeightWithOverscan());
|
||||||
renderableVideoFrame.rotate90(true);
|
renderableVideoFrame.rotate90(true);
|
||||||
renderableVideoFrame.translate(-renderableVideoFrame.getWidth() / 2, -renderableVideoFrame.getHeight() / 2);
|
renderableVideoFrame.translate(-renderableVideoFrame.getWidth() / 2, -renderableVideoFrame.getHeight() / 2);
|
||||||
|
|
||||||
frameBufferSprite.setSize(xSize * ProjectConstants.OVERSCAN, Utils.getScreenHeight());
|
frameBufferSprite.setSize(xSize * ProjectConstants.OVERSCAN, Utils.getScreenHeightWithOverscan());
|
||||||
frameBufferSprite.rotate90(true);
|
frameBufferSprite.rotate90(true);
|
||||||
frameBufferSprite.translate(-frameBufferSprite.getWidth() / 2, -frameBufferSprite.getHeight() / 2);
|
frameBufferSprite.translate(-frameBufferSprite.getWidth() / 2, -frameBufferSprite.getHeight() / 2);
|
||||||
}
|
}
|
||||||
@@ -342,6 +344,14 @@ public class AutomaticActionState extends BaseState{
|
|||||||
data = null;
|
data = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void pause(){
|
||||||
|
automaticActionPerformer.reset();
|
||||||
|
startButton.setDisabled(false);
|
||||||
|
ignoreBackKey = false;
|
||||||
|
automaticActionEnabled = false;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void dispose(){
|
public void dispose(){
|
||||||
SensorReportThread.freeInstance();
|
SensorReportThread.freeInstance();
|
||||||
@@ -457,104 +467,109 @@ public class AutomaticActionState extends BaseState{
|
|||||||
if(!automaticActionPerformer.performAutomaticAction(sensorThread.getLightSensorReading(), data)){
|
if(!automaticActionPerformer.performAutomaticAction(sensorThread.getLightSensorReading(), data)){
|
||||||
nextAction = automaticActionPerformer.getNextAction();
|
nextAction = automaticActionPerformer.getNextAction();
|
||||||
|
|
||||||
switch(nextAction){
|
if(nextAction != previousAction){
|
||||||
case GO_BACKWARDS:
|
switch(nextAction){
|
||||||
event1 = new MotorEvent();
|
case GO_BACKWARDS:
|
||||||
event2 = new MotorEvent();
|
event1 = new MotorEvent();
|
||||||
event1.setMotor(motor_t.MOTOR_A);
|
event2 = new MotorEvent();
|
||||||
event1.setPower((byte)-100);
|
event1.setMotor(motor_t.MOTOR_A);
|
||||||
event2.setMotor(motor_t.MOTOR_C);
|
event1.setPower((byte)-20);
|
||||||
event2.setPower((byte)-100);
|
event2.setMotor(motor_t.MOTOR_C);
|
||||||
break;
|
event2.setPower((byte)-20);
|
||||||
|
break;
|
||||||
|
|
||||||
case GO_FORWARD:
|
case GO_FORWARD:
|
||||||
event1 = new MotorEvent();
|
event1 = new MotorEvent();
|
||||||
event2 = new MotorEvent();
|
event2 = new MotorEvent();
|
||||||
event1.setMotor(motor_t.MOTOR_A);
|
event1.setMotor(motor_t.MOTOR_A);
|
||||||
event1.setPower((byte)100);
|
event1.setPower((byte)20);
|
||||||
event2.setMotor(motor_t.MOTOR_C);
|
event2.setMotor(motor_t.MOTOR_C);
|
||||||
event2.setPower((byte)100);
|
event2.setPower((byte)20);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case STOP:
|
case STOP:
|
||||||
event1 = new MotorEvent();
|
event1 = new MotorEvent();
|
||||||
event2 = new MotorEvent();
|
event2 = new MotorEvent();
|
||||||
event1.setMotor(motor_t.MOTOR_A);
|
event1.setMotor(motor_t.MOTOR_A);
|
||||||
event1.setPower((byte)0);
|
event1.setPower((byte)0);
|
||||||
event2.setMotor(motor_t.MOTOR_C);
|
event2.setMotor(motor_t.MOTOR_C);
|
||||||
event2.setPower((byte)0);
|
event2.setPower((byte)0);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ROTATE_90:
|
case ROTATE_90:
|
||||||
event1 = new MotorEvent();
|
event1 = new MotorEvent();
|
||||||
event1.setMotor(motor_t.ROTATE_90);
|
event1.setMotor(motor_t.ROTATE_90);
|
||||||
event1.setPower((byte)100);
|
event1.setPower((byte)20);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case RECENTER:
|
case RECENTER:
|
||||||
event1 = new MotorEvent();
|
event1 = new MotorEvent();
|
||||||
event1.setMotor(motor_t.RECENTER);
|
event1.setMotor(motor_t.RECENTER);
|
||||||
event1.setPower((byte)100);
|
event1.setPower((byte)20);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TURN_LEFT:
|
case TURN_LEFT:
|
||||||
event1 = new MotorEvent();
|
event1 = new MotorEvent();
|
||||||
event1.setMotor(motor_t.MOTOR_A);
|
event1.setMotor(motor_t.MOTOR_A);
|
||||||
event1.setPower((byte)100);
|
event1.setPower((byte)20);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TURN_RIGHT:
|
case TURN_RIGHT:
|
||||||
event1 = new MotorEvent();
|
event1 = new MotorEvent();
|
||||||
event1.setMotor(motor_t.MOTOR_C);
|
event1.setMotor(motor_t.MOTOR_C);
|
||||||
event1.setPower((byte)100);
|
event1.setPower((byte)20);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case BACKWARDS_LEFT:
|
case BACKWARDS_LEFT:
|
||||||
event1 = new MotorEvent();
|
event1 = new MotorEvent();
|
||||||
event1.setMotor(motor_t.MOTOR_C);
|
event1.setMotor(motor_t.MOTOR_C);
|
||||||
event1.setPower((byte)-100);
|
event1.setPower((byte)-20);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case BACKWARDS_RIGHT:
|
case BACKWARDS_RIGHT:
|
||||||
event1 = new MotorEvent();
|
event1 = new MotorEvent();
|
||||||
event1.setMotor(motor_t.MOTOR_A);
|
event1.setMotor(motor_t.MOTOR_A);
|
||||||
event1.setPower((byte)-100);
|
event1.setPower((byte)-20);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case LOOK_RIGHT:
|
case LOOK_RIGHT:
|
||||||
event1 = new MotorEvent();
|
event1 = new MotorEvent();
|
||||||
event1.setMotor(motor_t.MOTOR_B);
|
event1.setMotor(motor_t.MOTOR_B);
|
||||||
event1.setPower((byte)25);
|
event1.setPower((byte)25);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case LOOK_LEFT:
|
case LOOK_LEFT:
|
||||||
event1 = new MotorEvent();
|
event1 = new MotorEvent();
|
||||||
event1.setMotor(motor_t.MOTOR_B);
|
event1.setMotor(motor_t.MOTOR_B);
|
||||||
event1.setPower((byte)-25);
|
event1.setPower((byte)-25);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case STOP_LOOKING:
|
case STOP_LOOKING:
|
||||||
event1 = new MotorEvent();
|
event1 = new MotorEvent();
|
||||||
event1.setMotor(motor_t.MOTOR_B);
|
event1.setMotor(motor_t.MOTOR_B);
|
||||||
event1.setPower((byte)0);
|
event1.setPower((byte)0);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case NO_ACTION:
|
case NO_ACTION:
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(event1 != null)
|
||||||
|
queue.addEvent(event1);
|
||||||
|
if(event2 != null)
|
||||||
|
queue.addEvent(event2);
|
||||||
|
|
||||||
|
previousAction = nextAction;
|
||||||
|
}else{
|
||||||
|
Gdx.app.log(TAG, CLASS_NAME + ".performAutomaticAction(): Skipping repeated action.");
|
||||||
}
|
}
|
||||||
|
|
||||||
if(event1 != null)
|
|
||||||
queue.addEvent(event1);
|
|
||||||
if(event2 != null)
|
|
||||||
queue.addEvent(event2);
|
|
||||||
|
|
||||||
}else{
|
}else{
|
||||||
// TODO: Go to summary screen.
|
|
||||||
startButton.setDisabled(false);
|
startButton.setDisabled(false);
|
||||||
ignoreBackKey = false;
|
ignoreBackKey = false;
|
||||||
automaticActionEnabled = false;
|
automaticActionEnabled = false;
|
||||||
core.nextState = game_states_t.MAIN_MENU;
|
core.nextState = game_states_t.SUMMARY;
|
||||||
}
|
}
|
||||||
|
|
||||||
}catch(IllegalArgumentException e){
|
}catch(IllegalArgumentException e){
|
||||||
|
|||||||
@@ -0,0 +1,330 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2014 Miguel Angel Astor Romero
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
package ve.ucv.ciens.ccg.nxtar.states;
|
||||||
|
|
||||||
|
import ve.ucv.ciens.ccg.nxtar.NxtARCore;
|
||||||
|
import ve.ucv.ciens.ccg.nxtar.NxtARCore.game_states_t;
|
||||||
|
import ve.ucv.ciens.ccg.nxtar.game.AutomaticActionPerformerBase;
|
||||||
|
import ve.ucv.ciens.ccg.nxtar.game.AutomaticActionSummaryOverlayBase;
|
||||||
|
import ve.ucv.ciens.ccg.nxtar.game.GameGlobals;
|
||||||
|
import ve.ucv.ciens.ccg.nxtar.utils.ProjectConstants;
|
||||||
|
import ve.ucv.ciens.ccg.nxtar.utils.Utils;
|
||||||
|
|
||||||
|
import com.badlogic.gdx.Gdx;
|
||||||
|
import com.badlogic.gdx.Input;
|
||||||
|
import com.badlogic.gdx.controllers.Controller;
|
||||||
|
import com.badlogic.gdx.controllers.mappings.Ouya;
|
||||||
|
import com.badlogic.gdx.graphics.Color;
|
||||||
|
import com.badlogic.gdx.graphics.GL20;
|
||||||
|
import com.badlogic.gdx.graphics.OrthographicCamera;
|
||||||
|
import com.badlogic.gdx.graphics.Texture;
|
||||||
|
import com.badlogic.gdx.graphics.Texture.TextureFilter;
|
||||||
|
import com.badlogic.gdx.graphics.Texture.TextureWrap;
|
||||||
|
import com.badlogic.gdx.graphics.g2d.BitmapFont;
|
||||||
|
import com.badlogic.gdx.graphics.g2d.NinePatch;
|
||||||
|
import com.badlogic.gdx.graphics.g2d.Sprite;
|
||||||
|
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
|
||||||
|
import com.badlogic.gdx.graphics.g2d.TextureRegion;
|
||||||
|
import com.badlogic.gdx.graphics.g2d.freetype.FreeTypeFontGenerator;
|
||||||
|
import com.badlogic.gdx.graphics.g2d.freetype.FreeTypeFontGenerator.FreeTypeFontParameter;
|
||||||
|
import com.badlogic.gdx.graphics.glutils.ShaderProgram;
|
||||||
|
import com.badlogic.gdx.math.Rectangle;
|
||||||
|
import com.badlogic.gdx.math.Vector2;
|
||||||
|
import com.badlogic.gdx.math.Vector3;
|
||||||
|
import com.badlogic.gdx.scenes.scene2d.ui.TextButton;
|
||||||
|
import com.badlogic.gdx.scenes.scene2d.ui.TextButton.TextButtonStyle;
|
||||||
|
import com.badlogic.gdx.scenes.scene2d.utils.NinePatchDrawable;
|
||||||
|
|
||||||
|
public class AutomaticActionSummaryState extends BaseState{
|
||||||
|
private static final String TAG = "AUTO_SUMMARY";
|
||||||
|
private static final String CLASS_NAME = AutomaticActionSummaryState.class.getSimpleName();
|
||||||
|
private static final String SHADER_PATH = "shaders/movingBckg/movingBckg";
|
||||||
|
|
||||||
|
// Helper fields.
|
||||||
|
private float u_scaling[];
|
||||||
|
private float u_displacement;
|
||||||
|
|
||||||
|
// Buttons and other gui components.
|
||||||
|
private TextButton continueButton;
|
||||||
|
private Rectangle continueButtonBBox;
|
||||||
|
private Sprite background;
|
||||||
|
private Texture backgroundTexture;
|
||||||
|
private ShaderProgram backgroundShader;
|
||||||
|
private Texture ouyaOButtonTexture;
|
||||||
|
private Sprite ouyaOButton;
|
||||||
|
private boolean oButtonPressed;
|
||||||
|
|
||||||
|
// Graphic data for the start button.
|
||||||
|
private Texture buttonEnabledTexture;
|
||||||
|
private Texture buttonDisabledTexture;
|
||||||
|
private Texture buttonPressedTexture;
|
||||||
|
private NinePatch buttonEnabled9p;
|
||||||
|
private NinePatch buttonDisabled9p;
|
||||||
|
private NinePatch buttonPressed9p;
|
||||||
|
private BitmapFont font;
|
||||||
|
|
||||||
|
// Summary overlay related fields.
|
||||||
|
AutomaticActionPerformerBase automaticActionPerformer;
|
||||||
|
AutomaticActionSummaryOverlayBase summaryOverlay;
|
||||||
|
|
||||||
|
// Button touch helper fields.
|
||||||
|
private boolean continueButtonTouched;
|
||||||
|
private int continueButtonTouchPointer;
|
||||||
|
|
||||||
|
public AutomaticActionSummaryState(NxtARCore core) throws IllegalArgumentException{
|
||||||
|
TextButtonStyle textButtonStyle;
|
||||||
|
FreeTypeFontGenerator fontGenerator;
|
||||||
|
FreeTypeFontParameter fontParameters;
|
||||||
|
|
||||||
|
if(core == null)
|
||||||
|
throw new IllegalArgumentException(CLASS_NAME + ": Core is null.");
|
||||||
|
|
||||||
|
this.core = core;
|
||||||
|
this.pixelPerfectCamera = new OrthographicCamera(Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
|
||||||
|
oButtonPressed = false;
|
||||||
|
automaticActionPerformer = GameGlobals.getAutomaticActionPerformer();
|
||||||
|
summaryOverlay = GameGlobals.getAutomaticActionSummaryOverlay();
|
||||||
|
|
||||||
|
// Create the start button background.
|
||||||
|
buttonEnabledTexture = new Texture(Gdx.files.internal("data/gfx/gui/Anonymous_Pill_Button_Yellow.png"));
|
||||||
|
buttonEnabled9p = new NinePatch(new TextureRegion(buttonEnabledTexture, 0, 0, buttonEnabledTexture.getWidth(), buttonEnabledTexture.getHeight()), 49, 49, 45, 45);
|
||||||
|
buttonDisabledTexture = new Texture(Gdx.files.internal("data/gfx/gui/Anonymous_Pill_Button_Cyan.png"));
|
||||||
|
buttonDisabled9p = new NinePatch(new TextureRegion(buttonDisabledTexture, 0, 0, buttonDisabledTexture.getWidth(), buttonDisabledTexture.getHeight()), 49, 49, 45, 45);
|
||||||
|
buttonPressedTexture = new Texture(Gdx.files.internal("data/gfx/gui/Anonymous_Pill_Button_Blue.png"));
|
||||||
|
buttonPressed9p = new NinePatch(new TextureRegion(buttonPressedTexture, 0, 0, buttonPressedTexture.getWidth(), buttonPressedTexture.getHeight()), 49, 49, 45, 45);
|
||||||
|
|
||||||
|
// Create the start button font.
|
||||||
|
fontParameters = new FreeTypeFontParameter();
|
||||||
|
fontParameters.characters = ProjectConstants.FONT_CHARS;
|
||||||
|
fontParameters.size = ProjectConstants.MENU_BUTTON_FONT_SIZE;
|
||||||
|
fontParameters.flip = false;
|
||||||
|
fontGenerator = new FreeTypeFontGenerator(Gdx.files.internal("data/fonts/d-puntillas-B-to-tiptoe.ttf"));
|
||||||
|
font = fontGenerator.generateFont(fontParameters);
|
||||||
|
fontGenerator.dispose();
|
||||||
|
|
||||||
|
// Create the contine button.
|
||||||
|
textButtonStyle = new TextButtonStyle();
|
||||||
|
textButtonStyle.font = font;
|
||||||
|
textButtonStyle.up = new NinePatchDrawable(buttonEnabled9p);
|
||||||
|
textButtonStyle.checked = new NinePatchDrawable(buttonPressed9p);
|
||||||
|
textButtonStyle.disabled = new NinePatchDrawable(buttonDisabled9p);
|
||||||
|
textButtonStyle.fontColor = new Color(Color.BLACK);
|
||||||
|
textButtonStyle.downFontColor = new Color(Color.WHITE);
|
||||||
|
textButtonStyle.disabledFontColor = new Color(Color.BLACK);
|
||||||
|
|
||||||
|
continueButton = new TextButton("Continue", textButtonStyle);
|
||||||
|
continueButton.setText("Continue");
|
||||||
|
continueButton.setPosition(-(continueButton.getWidth() / 2), -(Utils.getScreenHeightWithOverscan() / 2) + 10);
|
||||||
|
continueButtonBBox = new Rectangle(0, 0, continueButton.getWidth(), continueButton.getHeight());
|
||||||
|
continueButtonBBox.setPosition(continueButton.getX(), continueButton.getY());
|
||||||
|
|
||||||
|
// Set OUYA's O button.
|
||||||
|
if(Ouya.runningOnOuya){
|
||||||
|
ouyaOButtonTexture = new Texture("data/gfx/gui/OUYA_O.png");
|
||||||
|
ouyaOButton = new Sprite(ouyaOButtonTexture);
|
||||||
|
ouyaOButton.setSize(ouyaOButton.getWidth() * 0.6f, ouyaOButton.getHeight() * 0.6f);
|
||||||
|
oButtonPressed = false;
|
||||||
|
}else{
|
||||||
|
ouyaOButtonTexture = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set up the background.
|
||||||
|
backgroundTexture = new Texture(Gdx.files.internal("data/gfx/textures/tile_aqua.png"));
|
||||||
|
backgroundTexture.setWrap(TextureWrap.Repeat, TextureWrap.Repeat);
|
||||||
|
backgroundTexture.setFilter(TextureFilter.Linear, TextureFilter.Linear);
|
||||||
|
background = new Sprite(backgroundTexture);
|
||||||
|
background.setSize(Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
|
||||||
|
background.setPosition(-(Gdx.graphics.getWidth() / 2), -(Gdx.graphics.getHeight() / 2));
|
||||||
|
|
||||||
|
backgroundShader = new ShaderProgram(Gdx.files.internal(SHADER_PATH + "_vert.glsl"), Gdx.files.internal(SHADER_PATH + "_frag.glsl"));
|
||||||
|
if(!backgroundShader.isCompiled()){
|
||||||
|
Gdx.app.error(TAG, CLASS_NAME + ".MainMenuStateBase() :: Failed to compile the background shader.");
|
||||||
|
Gdx.app.error(TAG, CLASS_NAME + backgroundShader.getLog());
|
||||||
|
backgroundShader = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
u_scaling = new float[2];
|
||||||
|
u_scaling[0] = Gdx.graphics.getWidth() > Gdx.graphics.getHeight() ? 16.0f : 9.0f;
|
||||||
|
u_scaling[1] = Gdx.graphics.getHeight() > Gdx.graphics.getWidth() ? 16.0f : 9.0f;
|
||||||
|
|
||||||
|
u_displacement = 1.0f;
|
||||||
|
|
||||||
|
win2world = new Vector3(0.0f, 0.0f, 0.0f);
|
||||||
|
touchPointWorldCoords = new Vector2();
|
||||||
|
continueButtonTouched = false;
|
||||||
|
continueButtonTouchPointer = -1;
|
||||||
|
stateActive = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void render(float delta){
|
||||||
|
Gdx.gl.glClearColor(1, 1, 1, 1);
|
||||||
|
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
|
||||||
|
|
||||||
|
core.batch.setProjectionMatrix(pixelPerfectCamera.combined);
|
||||||
|
core.batch.begin();{
|
||||||
|
|
||||||
|
// Render background.
|
||||||
|
core.batch.disableBlending();
|
||||||
|
drawBackground(core.batch);
|
||||||
|
core.batch.enableBlending();
|
||||||
|
|
||||||
|
summaryOverlay.render(core.batch, automaticActionPerformer.getSummary());
|
||||||
|
|
||||||
|
// Render buttons.
|
||||||
|
continueButton.draw(core.batch, 1.0f);
|
||||||
|
if(Ouya.runningOnOuya)
|
||||||
|
ouyaOButton.draw(core.batch);
|
||||||
|
|
||||||
|
}core.batch.end();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void dispose(){
|
||||||
|
buttonEnabledTexture.dispose();
|
||||||
|
buttonDisabledTexture.dispose();
|
||||||
|
buttonPressedTexture.dispose();
|
||||||
|
if(ouyaOButtonTexture != null)
|
||||||
|
ouyaOButtonTexture.dispose();
|
||||||
|
backgroundTexture.dispose();
|
||||||
|
if(backgroundShader != null) backgroundShader.dispose();
|
||||||
|
font.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void drawBackground(SpriteBatch batch){
|
||||||
|
if(backgroundShader != null){
|
||||||
|
batch.setShader(backgroundShader);
|
||||||
|
backgroundShader.setUniform2fv("u_scaling", u_scaling, 0, 2);
|
||||||
|
backgroundShader.setUniformf("u_displacement", u_displacement);
|
||||||
|
}
|
||||||
|
background.draw(batch);
|
||||||
|
if(backgroundShader != null) batch.setShader(null);
|
||||||
|
u_displacement = u_displacement < 0.0f ? 1.0f : u_displacement - 0.0005f;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onStateSet(){
|
||||||
|
stateActive = true;
|
||||||
|
Gdx.input.setInputProcessor(this);
|
||||||
|
Gdx.input.setCatchBackKey(true);
|
||||||
|
Gdx.input.setCatchMenuKey(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onStateUnset(){
|
||||||
|
stateActive = false;
|
||||||
|
Gdx.input.setInputProcessor(null);
|
||||||
|
Gdx.input.setCatchBackKey(false);
|
||||||
|
Gdx.input.setCatchMenuKey(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
|
; INPUT LISTENER METHODS ;
|
||||||
|
;;;;;;;;;;;;;;;;;;;;;;;;;;*/
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean touchDown(int screenX, int screenY, int pointer, int button){
|
||||||
|
unprojectTouch(screenX, screenY);
|
||||||
|
|
||||||
|
Gdx.app.log(TAG, CLASS_NAME + String.format(".touchDown(%d, %d, %d, %d)", screenX, screenY, pointer, button));
|
||||||
|
Gdx.app.log(TAG, CLASS_NAME + String.format(".touchDown() :: Unprojected touch point: (%f, %f)", touchPointWorldCoords.x, touchPointWorldCoords.y));
|
||||||
|
|
||||||
|
if(!continueButton.isDisabled() && continueButtonBBox.contains(touchPointWorldCoords)){
|
||||||
|
continueButton.setChecked(true);
|
||||||
|
continueButtonTouched = true;
|
||||||
|
continueButtonTouchPointer = pointer;
|
||||||
|
Gdx.app.log(TAG, CLASS_NAME + ".touchDown() :: Start button pressed.");
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean touchUp(int screenX, int screenY, int pointer, int button){
|
||||||
|
unprojectTouch(screenX, screenY);
|
||||||
|
|
||||||
|
Gdx.app.log(TAG, CLASS_NAME + String.format(".touchUp(%d, %d, %d, %d)", screenX, screenY, pointer, button));
|
||||||
|
Gdx.app.log(TAG, CLASS_NAME + String.format(".touchUp() :: Unprojected touch point: (%f, %f)", touchPointWorldCoords.x, touchPointWorldCoords.y));
|
||||||
|
|
||||||
|
if(!continueButton.isDisabled() && continueButtonBBox.contains(touchPointWorldCoords) && continueButtonTouched){
|
||||||
|
continueButton.setChecked(false);
|
||||||
|
continueButtonTouched = false;
|
||||||
|
continueButtonTouchPointer = -1;
|
||||||
|
core.nextState = game_states_t.MAIN_MENU;
|
||||||
|
Gdx.app.log(TAG, CLASS_NAME + ".touchDown() :: Start button released.");
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean touchDragged(int screenX, int screenY, int pointer){
|
||||||
|
unprojectTouch(screenX, screenY);
|
||||||
|
|
||||||
|
if(!continueButton.isDisabled() && continueButtonTouched && pointer == continueButtonTouchPointer && !continueButtonBBox.contains(touchPointWorldCoords)){
|
||||||
|
continueButtonTouchPointer = -1;
|
||||||
|
continueButtonTouched = false;
|
||||||
|
continueButton.setChecked(false);
|
||||||
|
Gdx.app.log(TAG, CLASS_NAME + ".touchDragged() :: Start button released.");
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean keyDown(int keycode){
|
||||||
|
if(keycode == Input.Keys.BACK){
|
||||||
|
core.nextState = game_states_t.MAIN_MENU;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
|
; CONTROLLER LISTENER METHODS ;
|
||||||
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;*/
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean buttonDown(Controller controller, int buttonCode){
|
||||||
|
if(stateActive){
|
||||||
|
if(buttonCode == Ouya.BUTTON_O && !continueButton.isDisabled()){
|
||||||
|
Gdx.app.log(TAG, CLASS_NAME + ".buttonDown(): O button pressed.");
|
||||||
|
oButtonPressed = true;
|
||||||
|
continueButton.setChecked(true);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}else{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean buttonUp(Controller controller, int buttonCode){
|
||||||
|
if(stateActive){
|
||||||
|
if(buttonCode == Ouya.BUTTON_O){
|
||||||
|
Gdx.app.log(TAG, CLASS_NAME + ".buttonDown(): O button released.");
|
||||||
|
if(oButtonPressed){
|
||||||
|
oButtonPressed = false;
|
||||||
|
continueButton.setChecked(false);
|
||||||
|
core.nextState = game_states_t.MAIN_MENU;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}else{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -246,8 +246,8 @@ public class InGameState extends BaseState{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void render(float delta){
|
public void render(float delta){
|
||||||
final float MIN_SLIDER_X = correctAngleLedOnSprite != null ? -(Utils.getScreenWidth() / 2) + 5 + correctAngleLedOnSprite.getWidth() : -(Utils.getScreenWidth() / 2) + 5;
|
final float MIN_SLIDER_X = correctAngleLedOnSprite != null ? -(Utils.getScreenWidthWithOverscan() / 2) + 5 + correctAngleLedOnSprite.getWidth() : -(Utils.getScreenWidthWithOverscan() / 2) + 5;
|
||||||
final float MAX_SLIDER_X = correctAngleLedOnSprite != null ? (Utils.getScreenWidth() / 2) - 5 - correctAngleLedOnSprite.getWidth(): (Utils.getScreenWidth() / 2) - 5;
|
final float MAX_SLIDER_X = correctAngleLedOnSprite != null ? (Utils.getScreenWidthWithOverscan() / 2) - 5 - correctAngleLedOnSprite.getWidth(): (Utils.getScreenWidthWithOverscan() / 2) - 5;
|
||||||
int w, h;
|
int w, h;
|
||||||
float t, xSliderPos;
|
float t, xSliderPos;
|
||||||
byte[] frame;
|
byte[] frame;
|
||||||
@@ -362,11 +362,11 @@ public class InGameState extends BaseState{
|
|||||||
|
|
||||||
}else{
|
}else{
|
||||||
float xSize = Gdx.graphics.getHeight() * (w / h);
|
float xSize = Gdx.graphics.getHeight() * (w / h);
|
||||||
renderableVideoFrame.setSize(xSize * ProjectConstants.OVERSCAN, Utils.getScreenHeight());
|
renderableVideoFrame.setSize(xSize * ProjectConstants.OVERSCAN, Utils.getScreenHeightWithOverscan());
|
||||||
renderableVideoFrame.rotate90(true);
|
renderableVideoFrame.rotate90(true);
|
||||||
renderableVideoFrame.translate(-renderableVideoFrame.getWidth() / 2, -renderableVideoFrame.getHeight() / 2);
|
renderableVideoFrame.translate(-renderableVideoFrame.getWidth() / 2, -renderableVideoFrame.getHeight() / 2);
|
||||||
|
|
||||||
frameBufferSprite.setSize(xSize * ProjectConstants.OVERSCAN, Utils.getScreenHeight());
|
frameBufferSprite.setSize(xSize * ProjectConstants.OVERSCAN, Utils.getScreenHeightWithOverscan());
|
||||||
frameBufferSprite.rotate90(true);
|
frameBufferSprite.rotate90(true);
|
||||||
frameBufferSprite.translate(-frameBufferSprite.getWidth() / 2, -frameBufferSprite.getHeight() / 2);
|
frameBufferSprite.translate(-frameBufferSprite.getWidth() / 2, -frameBufferSprite.getHeight() / 2);
|
||||||
}
|
}
|
||||||
@@ -595,7 +595,7 @@ public class InGameState extends BaseState{
|
|||||||
orientationSliderTexture = new Texture(Gdx.files.internal("data/gfx/gui/slider_black.png"));
|
orientationSliderTexture = new Texture(Gdx.files.internal("data/gfx/gui/slider_black.png"));
|
||||||
orientationSlider = new Sprite(orientationSliderTexture);
|
orientationSlider = new Sprite(orientationSliderTexture);
|
||||||
orientationSlider.setSize(orientationSlider.getWidth() * 0.25f, orientationSlider.getHeight() * 0.25f);
|
orientationSlider.setSize(orientationSlider.getWidth() * 0.25f, orientationSlider.getHeight() * 0.25f);
|
||||||
orientationSlider.setPosition(-(orientationSlider.getWidth() / 2), (Utils.getScreenHeight() / 2) - orientationSlider.getHeight() - 5);
|
orientationSlider.setPosition(-(orientationSlider.getWidth() / 2), (Utils.getScreenHeightWithOverscan() / 2) - orientationSlider.getHeight() - 5);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
/*;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
|
|||||||
@@ -65,8 +65,7 @@ public abstract class MainMenuStateBase extends BaseState{
|
|||||||
protected Sprite cameraCalibratedLedOff;
|
protected Sprite cameraCalibratedLedOff;
|
||||||
protected Sprite assetsLoadedLedOn;
|
protected Sprite assetsLoadedLedOn;
|
||||||
protected Sprite assetsLoadedLedOff;
|
protected Sprite assetsLoadedLedOff;
|
||||||
|
protected Sprite background;
|
||||||
protected Sprite background;
|
|
||||||
|
|
||||||
// Graphic data for the start button.
|
// Graphic data for the start button.
|
||||||
private Texture menuButtonEnabledTexture;
|
private Texture menuButtonEnabledTexture;
|
||||||
@@ -102,10 +101,8 @@ public abstract class MainMenuStateBase extends BaseState{
|
|||||||
// Create the start button background.
|
// Create the start button background.
|
||||||
menuButtonEnabledTexture = new Texture(Gdx.files.internal("data/gfx/gui/Anonymous_Pill_Button_Yellow.png"));
|
menuButtonEnabledTexture = new Texture(Gdx.files.internal("data/gfx/gui/Anonymous_Pill_Button_Yellow.png"));
|
||||||
menuButtonEnabled9p = new NinePatch(new TextureRegion(menuButtonEnabledTexture, 0, 0, menuButtonEnabledTexture.getWidth(), menuButtonEnabledTexture.getHeight()), 49, 49, 45, 45);
|
menuButtonEnabled9p = new NinePatch(new TextureRegion(menuButtonEnabledTexture, 0, 0, menuButtonEnabledTexture.getWidth(), menuButtonEnabledTexture.getHeight()), 49, 49, 45, 45);
|
||||||
|
|
||||||
menuButtonDisabledTexture = new Texture(Gdx.files.internal("data/gfx/gui/Anonymous_Pill_Button_Cyan.png"));
|
menuButtonDisabledTexture = new Texture(Gdx.files.internal("data/gfx/gui/Anonymous_Pill_Button_Cyan.png"));
|
||||||
menuButtonDisabled9p = new NinePatch(new TextureRegion(menuButtonDisabledTexture, 0, 0, menuButtonDisabledTexture.getWidth(), menuButtonDisabledTexture.getHeight()), 49, 49, 45, 45);
|
menuButtonDisabled9p = new NinePatch(new TextureRegion(menuButtonDisabledTexture, 0, 0, menuButtonDisabledTexture.getWidth(), menuButtonDisabledTexture.getHeight()), 49, 49, 45, 45);
|
||||||
|
|
||||||
menuButtonPressedTexture = new Texture(Gdx.files.internal("data/gfx/gui/Anonymous_Pill_Button_Blue.png"));
|
menuButtonPressedTexture = new Texture(Gdx.files.internal("data/gfx/gui/Anonymous_Pill_Button_Blue.png"));
|
||||||
menuButtonPressed9p = new NinePatch(new TextureRegion(menuButtonPressedTexture, 0, 0, menuButtonPressedTexture.getWidth(), menuButtonPressedTexture.getHeight()), 49, 49, 45, 45);
|
menuButtonPressed9p = new NinePatch(new TextureRegion(menuButtonPressedTexture, 0, 0, menuButtonPressedTexture.getWidth(), menuButtonPressedTexture.getHeight()), 49, 49, 45, 45);
|
||||||
|
|
||||||
@@ -118,7 +115,7 @@ public abstract class MainMenuStateBase extends BaseState{
|
|||||||
font = fontGenerator.generateFont(fontParameters);
|
font = fontGenerator.generateFont(fontParameters);
|
||||||
fontGenerator.dispose();
|
fontGenerator.dispose();
|
||||||
|
|
||||||
// Create the start button.
|
// Create the buttons.
|
||||||
textButtonStyle = new TextButtonStyle();
|
textButtonStyle = new TextButtonStyle();
|
||||||
textButtonStyle.font = font;
|
textButtonStyle.font = font;
|
||||||
textButtonStyle.up = new NinePatchDrawable(menuButtonEnabled9p);
|
textButtonStyle.up = new NinePatchDrawable(menuButtonEnabled9p);
|
||||||
@@ -133,7 +130,6 @@ public abstract class MainMenuStateBase extends BaseState{
|
|||||||
startButton.setDisabled(true);
|
startButton.setDisabled(true);
|
||||||
startButtonBBox = new Rectangle(0, 0, startButton.getWidth(), startButton.getHeight());
|
startButtonBBox = new Rectangle(0, 0, startButton.getWidth(), startButton.getHeight());
|
||||||
|
|
||||||
// Create the calibration button.
|
|
||||||
calibrationButton = new TextButton("Calibrate camera", textButtonStyle);
|
calibrationButton = new TextButton("Calibrate camera", textButtonStyle);
|
||||||
calibrationButton.setText("Calibrate camera");
|
calibrationButton.setText("Calibrate camera");
|
||||||
calibrationButton.setDisabled(true);
|
calibrationButton.setDisabled(true);
|
||||||
@@ -150,13 +146,10 @@ public abstract class MainMenuStateBase extends BaseState{
|
|||||||
|
|
||||||
region = new TextureRegion(ledOnTexture);
|
region = new TextureRegion(ledOnTexture);
|
||||||
cameraCalibratedLedOn = new Sprite(region);
|
cameraCalibratedLedOn = new Sprite(region);
|
||||||
|
|
||||||
region = new TextureRegion(ledOffTexture);
|
region = new TextureRegion(ledOffTexture);
|
||||||
cameraCalibratedLedOff = new Sprite(region);
|
cameraCalibratedLedOff = new Sprite(region);
|
||||||
|
|
||||||
region = new TextureRegion(ledOnTexture);
|
region = new TextureRegion(ledOnTexture);
|
||||||
assetsLoadedLedOn = new Sprite(region);
|
assetsLoadedLedOn = new Sprite(region);
|
||||||
|
|
||||||
region = new TextureRegion(ledOffTexture);
|
region = new TextureRegion(ledOffTexture);
|
||||||
assetsLoadedLedOff = new Sprite(region);
|
assetsLoadedLedOff = new Sprite(region);
|
||||||
|
|
||||||
|
|||||||
@@ -36,9 +36,12 @@ public class OuyaMainMenuState extends MainMenuStateBase{
|
|||||||
private int oButtonSelection;
|
private int oButtonSelection;
|
||||||
private float ledYPos;
|
private float ledYPos;
|
||||||
|
|
||||||
public OuyaMainMenuState(final NxtARCore core){
|
public OuyaMainMenuState(final NxtARCore core) throws IllegalArgumentException{
|
||||||
super();
|
super();
|
||||||
|
|
||||||
|
if(core == null)
|
||||||
|
throw new IllegalArgumentException(CLASS_NAME + ": Core is null.");
|
||||||
|
|
||||||
this.core = core;
|
this.core = core;
|
||||||
|
|
||||||
// Set buttons.
|
// Set buttons.
|
||||||
@@ -50,7 +53,7 @@ public class OuyaMainMenuState extends MainMenuStateBase{
|
|||||||
autoButtonBBox.setPosition(autoButton.getX(), autoButton.getY());
|
autoButtonBBox.setPosition(autoButton.getX(), autoButton.getY());
|
||||||
|
|
||||||
//Set leds.
|
//Set leds.
|
||||||
ledYPos = -(Utils.getScreenHeight() / 2) + 10;
|
ledYPos = -(Utils.getScreenHeightWithOverscan() / 2) + 10;
|
||||||
cameraCalibratedLedOn.setSize(cameraCalibratedLedOn.getWidth() * 0.5f, cameraCalibratedLedOn.getHeight() * 0.5f);
|
cameraCalibratedLedOn.setSize(cameraCalibratedLedOn.getWidth() * 0.5f, cameraCalibratedLedOn.getHeight() * 0.5f);
|
||||||
cameraCalibratedLedOn.setPosition(-cameraCalibratedLedOn.getWidth() - 5, ledYPos);
|
cameraCalibratedLedOn.setPosition(-cameraCalibratedLedOn.getWidth() - 5, ledYPos);
|
||||||
cameraCalibratedLedOff.setSize(cameraCalibratedLedOff.getWidth() * 0.5f, cameraCalibratedLedOff.getHeight() * 0.5f);
|
cameraCalibratedLedOff.setSize(cameraCalibratedLedOff.getWidth() * 0.5f, cameraCalibratedLedOff.getHeight() * 0.5f);
|
||||||
@@ -111,9 +114,9 @@ public class OuyaMainMenuState extends MainMenuStateBase{
|
|||||||
ouyaOButtonTexture.dispose();
|
ouyaOButtonTexture.dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
/*;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
; BEGIN CONTROLLER LISTENER METHODS ;
|
; CONTROLLER LISTENER METHODS ;
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;*/
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;*/
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean buttonDown(Controller controller, int buttonCode){
|
public boolean buttonDown(Controller controller, int buttonCode){
|
||||||
|
|||||||
@@ -22,11 +22,16 @@ import com.badlogic.gdx.Gdx;
|
|||||||
import com.badlogic.gdx.graphics.GL20;
|
import com.badlogic.gdx.graphics.GL20;
|
||||||
|
|
||||||
public class TabletMainMenuState extends MainMenuStateBase{
|
public class TabletMainMenuState extends MainMenuStateBase{
|
||||||
|
private static final String CLASS_NAME = TabletMainMenuState.class.getSimpleName();
|
||||||
|
|
||||||
private float ledYPos;
|
private float ledYPos;
|
||||||
|
|
||||||
public TabletMainMenuState(final NxtARCore core){
|
public TabletMainMenuState(final NxtARCore core) throws IllegalArgumentException{
|
||||||
super();
|
super();
|
||||||
|
|
||||||
|
if(core == null)
|
||||||
|
throw new IllegalArgumentException(CLASS_NAME + ": Core is null.");
|
||||||
|
|
||||||
this.core = core;
|
this.core = core;
|
||||||
|
|
||||||
// Set buttons.
|
// Set buttons.
|
||||||
@@ -38,7 +43,7 @@ public class TabletMainMenuState extends MainMenuStateBase{
|
|||||||
autoButtonBBox.setPosition(autoButton.getX(), autoButton.getY());
|
autoButtonBBox.setPosition(autoButton.getX(), autoButton.getY());
|
||||||
|
|
||||||
// Set leds.
|
// Set leds.
|
||||||
ledYPos = -(Utils.getScreenHeight() / 2) + 10;
|
ledYPos = -(Utils.getScreenHeightWithOverscan() / 2) + 10;
|
||||||
cameraCalibratedLedOn.setSize(cameraCalibratedLedOn.getWidth() * 0.5f, cameraCalibratedLedOn.getHeight() * 0.5f);
|
cameraCalibratedLedOn.setSize(cameraCalibratedLedOn.getWidth() * 0.5f, cameraCalibratedLedOn.getHeight() * 0.5f);
|
||||||
cameraCalibratedLedOn.setPosition(-cameraCalibratedLedOn.getWidth() - 5, ledYPos);
|
cameraCalibratedLedOn.setPosition(-cameraCalibratedLedOn.getWidth() - 5, ledYPos);
|
||||||
cameraCalibratedLedOff.setSize(cameraCalibratedLedOff.getWidth() * 0.5f, cameraCalibratedLedOff.getHeight() * 0.5f);
|
cameraCalibratedLedOff.setSize(cameraCalibratedLedOff.getWidth() * 0.5f, cameraCalibratedLedOff.getHeight() * 0.5f);
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ public abstract class ProjectConstants{
|
|||||||
|
|
||||||
public static final float OVERSCAN;
|
public static final float OVERSCAN;
|
||||||
public static final int MENU_BUTTON_FONT_SIZE;
|
public static final int MENU_BUTTON_FONT_SIZE;
|
||||||
public static final String FONT_CHARS = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890";
|
public static final String FONT_CHARS = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890:";
|
||||||
|
|
||||||
public static final int MAXIMUM_NUMBER_OF_MARKERS = 5;
|
public static final int MAXIMUM_NUMBER_OF_MARKERS = 5;
|
||||||
public static final int CALIBRATION_PATTERN_POINTS = 54;
|
public static final int CALIBRATION_PATTERN_POINTS = 54;
|
||||||
|
|||||||
@@ -41,14 +41,14 @@ public abstract class Utils{
|
|||||||
/**
|
/**
|
||||||
* @return The width of the screen accounting for screen overscan.
|
* @return The width of the screen accounting for screen overscan.
|
||||||
*/
|
*/
|
||||||
public static int getScreenWidth(){
|
public static int getScreenWidthWithOverscan(){
|
||||||
return (int)(Gdx.graphics.getWidth() * ProjectConstants.OVERSCAN);
|
return (int)(Gdx.graphics.getWidth() * ProjectConstants.OVERSCAN);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return The height of the screen accounting for screen overscan.
|
* @return The height of the screen accounting for screen overscan.
|
||||||
*/
|
*/
|
||||||
public static int getScreenHeight(){
|
public static int getScreenHeightWithOverscan(){
|
||||||
return (int)(Gdx.graphics.getHeight() * ProjectConstants.OVERSCAN);
|
return (int)(Gdx.graphics.getHeight() * ProjectConstants.OVERSCAN);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user