Finished implementing bomb game.
This commit is contained in:
@@ -15,7 +15,6 @@
|
|||||||
*/
|
*/
|
||||||
package ve.ucv.ciens.ccg.nxtar;
|
package ve.ucv.ciens.ccg.nxtar;
|
||||||
|
|
||||||
import ve.ucv.ciens.ccg.nxtar.game.GameGlobals;
|
|
||||||
import ve.ucv.ciens.ccg.nxtar.interfaces.ActionResolver;
|
import ve.ucv.ciens.ccg.nxtar.interfaces.ActionResolver;
|
||||||
import ve.ucv.ciens.ccg.nxtar.interfaces.ApplicationEventsListener;
|
import ve.ucv.ciens.ccg.nxtar.interfaces.ApplicationEventsListener;
|
||||||
import ve.ucv.ciens.ccg.nxtar.interfaces.ImageProcessor;
|
import ve.ucv.ciens.ccg.nxtar.interfaces.ImageProcessor;
|
||||||
@@ -23,6 +22,7 @@ import ve.ucv.ciens.ccg.nxtar.network.RobotControlThread;
|
|||||||
import ve.ucv.ciens.ccg.nxtar.network.SensorReportThread;
|
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.scenarios.ScenarioGlobals;
|
||||||
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.AutomaticActionSummaryState;
|
||||||
import ve.ucv.ciens.ccg.nxtar.states.BaseState;
|
import ve.ucv.ciens.ccg.nxtar.states.BaseState;
|
||||||
@@ -30,6 +30,7 @@ import ve.ucv.ciens.ccg.nxtar.states.CameraCalibrationState;
|
|||||||
import ve.ucv.ciens.ccg.nxtar.states.InGameState;
|
import ve.ucv.ciens.ccg.nxtar.states.InGameState;
|
||||||
import ve.ucv.ciens.ccg.nxtar.states.MainMenuStateBase;
|
import ve.ucv.ciens.ccg.nxtar.states.MainMenuStateBase;
|
||||||
import ve.ucv.ciens.ccg.nxtar.states.OuyaMainMenuState;
|
import ve.ucv.ciens.ccg.nxtar.states.OuyaMainMenuState;
|
||||||
|
import ve.ucv.ciens.ccg.nxtar.states.ScenarioEndSummaryState;
|
||||||
import ve.ucv.ciens.ccg.nxtar.states.TabletMainMenuState;
|
import ve.ucv.ciens.ccg.nxtar.states.TabletMainMenuState;
|
||||||
import ve.ucv.ciens.ccg.nxtar.utils.ProjectConstants;
|
import ve.ucv.ciens.ccg.nxtar.utils.ProjectConstants;
|
||||||
import ve.ucv.ciens.ccg.nxtar.utils.Utils;
|
import ve.ucv.ciens.ccg.nxtar.utils.Utils;
|
||||||
@@ -76,7 +77,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), SUMMARY(4);
|
MAIN_MENU(0), IN_GAME(1), CALIBRATION(2), AUTOMATIC_ACTION(3), AUTOMATIC_ACTION_SUMMARY(4), SCENARIO_END_SUMMARY(5);
|
||||||
|
|
||||||
private int value;
|
private int value;
|
||||||
|
|
||||||
@@ -89,7 +90,7 @@ public class NxtARCore extends Game implements ApplicationEventsListener{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static int getNumStates(){
|
public static int getNumStates(){
|
||||||
return 5;
|
return 6;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -233,18 +234,18 @@ public class NxtARCore extends Game implements ApplicationEventsListener{
|
|||||||
*/
|
*/
|
||||||
public void create(){
|
public void create(){
|
||||||
try {
|
try {
|
||||||
GameGlobals.initGameSettings(this);
|
ScenarioGlobals.init(this);
|
||||||
} catch (IllegalArgumentException e) {
|
} catch (IllegalArgumentException e) {
|
||||||
Gdx.app.log(TAG, CLASS_NAME + ".create(): Illegal argument initializing globals: ", e);
|
Gdx.app.error(TAG, CLASS_NAME + ".create(): Illegal argument initializing globals: ", e);
|
||||||
Gdx.app.exit();
|
System.exit(1);
|
||||||
return;
|
return;
|
||||||
} catch (InstantiationException e) {
|
} catch (InstantiationException e) {
|
||||||
Gdx.app.log(TAG, CLASS_NAME + ".create(): Instantiation exception initializing globals: ", e);
|
Gdx.app.error(TAG, CLASS_NAME + ".create(): Instantiation exception initializing globals: ", e);
|
||||||
Gdx.app.exit();
|
System.exit(1);
|
||||||
return;
|
return;
|
||||||
} catch (IllegalAccessException e) {
|
} catch (IllegalAccessException e) {
|
||||||
Gdx.app.log(TAG, CLASS_NAME + ".create(): Illegal access exception initializing globals: ", e);
|
Gdx.app.error(TAG, CLASS_NAME + ".create(): Illegal access exception initializing globals: ", e);
|
||||||
Gdx.app.exit();
|
System.exit(1);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -268,7 +269,7 @@ public class NxtARCore extends Game implements ApplicationEventsListener{
|
|||||||
states[game_states_t.IN_GAME.getValue()] = new InGameState(this);
|
states[game_states_t.IN_GAME.getValue()] = new InGameState(this);
|
||||||
}catch(IllegalStateException e){
|
}catch(IllegalStateException e){
|
||||||
Gdx.app.error(TAG, CLASS_NAME + ".create(): Illegal state in IN_GAME_STATE: ", e);
|
Gdx.app.error(TAG, CLASS_NAME + ".create(): Illegal state in IN_GAME_STATE: ", e);
|
||||||
Gdx.app.exit();
|
System.exit(1);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -278,15 +279,16 @@ public class NxtARCore extends Game implements ApplicationEventsListener{
|
|||||||
states[game_states_t.AUTOMATIC_ACTION.getValue()] = new AutomaticActionState(this);
|
states[game_states_t.AUTOMATIC_ACTION.getValue()] = new AutomaticActionState(this);
|
||||||
}catch(IllegalStateException e){
|
}catch(IllegalStateException e){
|
||||||
Gdx.app.error(TAG, CLASS_NAME + ".create(): Illegal state in AUTOMATIC_ACTION_STATE: ", e);
|
Gdx.app.error(TAG, CLASS_NAME + ".create(): Illegal state in AUTOMATIC_ACTION_STATE: ", e);
|
||||||
Gdx.app.exit();
|
System.exit(1);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
states[game_states_t.SUMMARY.getValue()] = new AutomaticActionSummaryState(this);
|
states[game_states_t.AUTOMATIC_ACTION_SUMMARY.getValue()] = new AutomaticActionSummaryState(this);
|
||||||
|
states[game_states_t.SCENARIO_END_SUMMARY.getValue()] = new ScenarioEndSummaryState(this);
|
||||||
|
|
||||||
}catch(IllegalArgumentException e){
|
}catch(IllegalArgumentException e){
|
||||||
Gdx.app.error(TAG, CLASS_NAME + ".create(): Illegal argument caught creating states: ", e);
|
Gdx.app.error(TAG, CLASS_NAME + ".create(): Illegal argument caught creating states: ", e);
|
||||||
Gdx.app.exit();
|
System.exit(1);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -342,11 +344,10 @@ public class NxtARCore extends Game implements ApplicationEventsListener{
|
|||||||
fadeTexture = new Texture(pixmap);
|
fadeTexture = new Texture(pixmap);
|
||||||
pixmap.dispose();
|
pixmap.dispose();
|
||||||
|
|
||||||
alpha = new MutableFloat(0.0f);
|
alpha = new MutableFloat(0.0f);
|
||||||
fadeOut = Tween.to(alpha, 0, 0.5f).target(1.0f).ease(TweenEquations.easeInQuint);
|
fadeOut = Tween.to(alpha, 0, 0.5f).target(1.0f).ease(TweenEquations.easeInQuint);
|
||||||
fadeIn = Tween.to(alpha, 0, 0.5f).target(0.0f).ease(TweenEquations.easeInQuint);
|
fadeIn = Tween.to(alpha, 0, 0.5f).target(0.0f).ease(TweenEquations.easeInQuint);
|
||||||
|
fading = false;
|
||||||
fading = false;
|
|
||||||
|
|
||||||
// Set initial input handlers.
|
// Set initial input handlers.
|
||||||
Gdx.input.setInputProcessor(states[currState.getValue()]);
|
Gdx.input.setInputProcessor(states[currState.getValue()]);
|
||||||
@@ -368,8 +369,8 @@ public class NxtARCore extends Game implements ApplicationEventsListener{
|
|||||||
super.render();
|
super.render();
|
||||||
|
|
||||||
// Load the assets.
|
// Load the assets.
|
||||||
if(!GameGlobals.getEntityCreator().areEntitiesCreated())
|
if(!ScenarioGlobals.getEntityCreator().areEntitiesCreated())
|
||||||
GameGlobals.getEntityCreator().updateAssetManager();
|
ScenarioGlobals.getEntityCreator().updateAssetManager();
|
||||||
|
|
||||||
// If the current state set a value for nextState then switch to that state.
|
// If the current state set a value for nextState then switch to that state.
|
||||||
if(nextState != null){
|
if(nextState != null){
|
||||||
@@ -486,7 +487,7 @@ public class NxtARCore extends Game implements ApplicationEventsListener{
|
|||||||
batch.dispose();
|
batch.dispose();
|
||||||
font.dispose();
|
font.dispose();
|
||||||
|
|
||||||
GameGlobals.dispose();
|
ScenarioGlobals.dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
/*;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
|
@@ -1,32 +0,0 @@
|
|||||||
/*
|
|
||||||
* 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.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.BombGameLogicSystem;
|
|
||||||
|
|
||||||
@SuppressWarnings("rawtypes")
|
|
||||||
public final class ScenarioImplementation{
|
|
||||||
public static Class gameLogicSystemClass = BombGameLogicSystem.class;
|
|
||||||
public static Class entityCreatorClass = BombGameEntityCreator.class;
|
|
||||||
public static Class automaticActionPerformerClass = BombGameAutomaticActionPerformer.class;
|
|
||||||
public static Class automaticActionSummaryScreen = BombGameAutomaticActionSummaryOverlay.class;
|
|
||||||
// TODO: Add player processing system.
|
|
||||||
|
|
||||||
private ScenarioImplementation(){}
|
|
||||||
}
|
|
@@ -1,82 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2013 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.NxtARCore;
|
|
||||||
import ve.ucv.ciens.ccg.nxtar.systems.PlayerSystemBase;
|
|
||||||
import ve.ucv.ciens.ccg.nxtar.utils.Utils;
|
|
||||||
|
|
||||||
import com.artemis.ComponentMapper;
|
|
||||||
import com.artemis.Entity;
|
|
||||||
import com.artemis.annotations.Mapper;
|
|
||||||
import com.badlogic.gdx.Gdx;
|
|
||||||
import com.badlogic.gdx.graphics.Texture;
|
|
||||||
import com.badlogic.gdx.graphics.g2d.Sprite;
|
|
||||||
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
|
|
||||||
import com.badlogic.gdx.utils.Disposable;
|
|
||||||
|
|
||||||
public class BombGamePlayerSystem extends PlayerSystemBase implements Disposable{
|
|
||||||
private static final float HEART_Y_POS = (Utils.getScreenHeightWithOverscan() / 2) - 69;
|
|
||||||
@Mapper ComponentMapper<BombGamePlayerComponent> playerMapper;
|
|
||||||
|
|
||||||
private SpriteBatch batch;
|
|
||||||
private Texture heartTexture;
|
|
||||||
private Sprite heart;
|
|
||||||
|
|
||||||
public BombGamePlayerSystem(NxtARCore core){
|
|
||||||
super(BombGamePlayerComponent.class, core);
|
|
||||||
batch = new SpriteBatch();
|
|
||||||
heartTexture = new Texture(Gdx.files.internal("data/gfx/gui/Anonymous_heart_1.png"));
|
|
||||||
heart = new Sprite(heartTexture);
|
|
||||||
heart.setSize(heart.getWidth() * 0.5f, heart.getHeight() * 0.5f);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void process(Entity e) {
|
|
||||||
float heartXPos;
|
|
||||||
BombGamePlayerComponent player = playerMapper.get(e);
|
|
||||||
|
|
||||||
// Render remaining lives.
|
|
||||||
heartXPos = -(Utils.getScreenWidthWithOverscan() / 2) + 5;
|
|
||||||
for(int i = 0; i < player.lives; ++i){
|
|
||||||
heart.setPosition(heartXPos, HEART_Y_POS);
|
|
||||||
heart.draw(batch);
|
|
||||||
heartXPos += heart.getWidth() + 5;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check ending conditions.
|
|
||||||
if(player.lives == 0){
|
|
||||||
player.gameFinished = true;
|
|
||||||
player.victory = false;
|
|
||||||
}else if(player.disabledBombs == BombGameEntityCreator.NUM_BOMBS){
|
|
||||||
player.gameFinished = true;
|
|
||||||
player.victory = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// If met ending conditions then end the game.
|
|
||||||
if(player.gameFinished)
|
|
||||||
finishGame(player.victory);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void dispose() {
|
|
||||||
if(batch != null)
|
|
||||||
batch.dispose();
|
|
||||||
|
|
||||||
if(heartTexture != null)
|
|
||||||
heartTexture.dispose();
|
|
||||||
}
|
|
||||||
}
|
|
@@ -13,15 +13,11 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package ve.ucv.ciens.ccg.nxtar.game;
|
package ve.ucv.ciens.ccg.nxtar.scenarios;
|
||||||
|
|
||||||
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,
|
||||||
@@ -40,6 +36,6 @@ public abstract class AutomaticActionPerformerBase {
|
|||||||
|
|
||||||
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 SummaryBase getSummary();
|
||||||
public abstract void reset();
|
public abstract void reset();
|
||||||
}
|
}
|
@@ -13,7 +13,7 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package ve.ucv.ciens.ccg.nxtar.game;
|
package ve.ucv.ciens.ccg.nxtar.scenarios;
|
||||||
|
|
||||||
import ve.ucv.ciens.ccg.nxtar.NxtARCore;
|
import ve.ucv.ciens.ccg.nxtar.NxtARCore;
|
||||||
import ve.ucv.ciens.ccg.nxtar.entities.EntityCreatorBase;
|
import ve.ucv.ciens.ccg.nxtar.entities.EntityCreatorBase;
|
||||||
@@ -25,6 +25,7 @@ import ve.ucv.ciens.ccg.nxtar.systems.GeometrySystem;
|
|||||||
import ve.ucv.ciens.ccg.nxtar.systems.MarkerPositioningSystem;
|
import ve.ucv.ciens.ccg.nxtar.systems.MarkerPositioningSystem;
|
||||||
import ve.ucv.ciens.ccg.nxtar.systems.MarkerRenderingSystem;
|
import ve.ucv.ciens.ccg.nxtar.systems.MarkerRenderingSystem;
|
||||||
import ve.ucv.ciens.ccg.nxtar.systems.ObjectRenderingSystem;
|
import ve.ucv.ciens.ccg.nxtar.systems.ObjectRenderingSystem;
|
||||||
|
import ve.ucv.ciens.ccg.nxtar.systems.PlayerSystemBase;
|
||||||
import ve.ucv.ciens.ccg.nxtar.systems.RobotArmPositioningSystem;
|
import ve.ucv.ciens.ccg.nxtar.systems.RobotArmPositioningSystem;
|
||||||
|
|
||||||
import com.artemis.EntitySystem;
|
import com.artemis.EntitySystem;
|
||||||
@@ -35,15 +36,17 @@ import com.badlogic.gdx.controllers.mappings.Ouya;
|
|||||||
import com.badlogic.gdx.graphics.g3d.ModelBatch;
|
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 ScenarioGlobals{
|
||||||
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;
|
private static SummaryOverlayBase automaticActionSummaryOverlay = null;
|
||||||
|
private static PlayerSystemBase playerSystem = null;
|
||||||
|
private static SummaryOverlayBase scenarioSummaryOverlay = null;
|
||||||
|
|
||||||
public static void initGameSettings(NxtARCore core) throws IllegalArgumentException, InstantiationException, IllegalAccessException{
|
public static void init(NxtARCore core) throws IllegalArgumentException, InstantiationException, IllegalAccessException{
|
||||||
if(core == null)
|
if(core == null)
|
||||||
throw new IllegalArgumentException("Core is null.");
|
throw new IllegalArgumentException("Core is null.");
|
||||||
|
|
||||||
@@ -95,17 +98,41 @@ public abstract class GameGlobals{
|
|||||||
|
|
||||||
if(automaticActionSummaryOverlay == null){
|
if(automaticActionSummaryOverlay == null){
|
||||||
try {
|
try {
|
||||||
automaticActionSummaryOverlay = (AutomaticActionSummaryOverlayBase) ScenarioImplementation.automaticActionSummaryScreen.newInstance();
|
automaticActionSummaryOverlay = (SummaryOverlayBase) ScenarioImplementation.automaticActionSummaryOverlay.newInstance();
|
||||||
} catch (InstantiationException e) {
|
} catch (InstantiationException e) {
|
||||||
System.out.println("Error instantiating automatic action performer.");
|
System.out.println("Error instantiating automatic action summary overlay");
|
||||||
throw e;
|
throw e;
|
||||||
} catch (IllegalAccessException e) {
|
} catch (IllegalAccessException e) {
|
||||||
System.out.println("Error accessing automatic action performer.");
|
System.out.println("Error accessing automatic action summary overlay.");
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Create player processing system.
|
if(playerSystem == null){
|
||||||
|
try {
|
||||||
|
playerSystem = (PlayerSystemBase) ScenarioImplementation.playerSystemClass.newInstance();
|
||||||
|
} catch (InstantiationException e) {
|
||||||
|
System.out.println("Error instantiating player system.");
|
||||||
|
throw e;
|
||||||
|
} catch (IllegalAccessException e) {
|
||||||
|
System.out.println("Error accessing player system.");
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(scenarioSummaryOverlay == null){
|
||||||
|
try {
|
||||||
|
scenarioSummaryOverlay = (SummaryOverlayBase) ScenarioImplementation.scenarioSummaryOverlayClass.newInstance();
|
||||||
|
} catch (InstantiationException e) {
|
||||||
|
System.out.println("Error instantiating scenario summary overlay.");
|
||||||
|
throw e;
|
||||||
|
} catch (IllegalAccessException e) {
|
||||||
|
System.out.println("Error accessing scenario summary overlay.");
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
playerSystem.setCore(core);
|
||||||
|
|
||||||
gameWorld.setSystem(new MarkerPositioningSystem());
|
gameWorld.setSystem(new MarkerPositioningSystem());
|
||||||
gameWorld.setSystem(new RobotArmPositioningSystem(), Ouya.runningOnOuya);
|
gameWorld.setSystem(new RobotArmPositioningSystem(), Ouya.runningOnOuya);
|
||||||
@@ -113,7 +140,7 @@ public abstract class GameGlobals{
|
|||||||
gameWorld.setSystem(new AnimationSystem());
|
gameWorld.setSystem(new AnimationSystem());
|
||||||
gameWorld.setSystem(new CollisionDetectionSystem());
|
gameWorld.setSystem(new CollisionDetectionSystem());
|
||||||
gameWorld.setSystem(gameLogicSystem);
|
gameWorld.setSystem(gameLogicSystem);
|
||||||
// TODO: Add player processing system.
|
gameWorld.setSystem(playerSystem, true);
|
||||||
gameWorld.setSystem(new MarkerRenderingSystem(modelBatch), true);
|
gameWorld.setSystem(new MarkerRenderingSystem(modelBatch), true);
|
||||||
gameWorld.setSystem(new ObjectRenderingSystem(modelBatch), true);
|
gameWorld.setSystem(new ObjectRenderingSystem(modelBatch), true);
|
||||||
gameWorld.setSystem(new FadeEffectRenderingSystem(), true);
|
gameWorld.setSystem(new FadeEffectRenderingSystem(), true);
|
||||||
@@ -135,6 +162,7 @@ public abstract class GameGlobals{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
scenarioSummaryOverlay.dispose();
|
||||||
automaticActionSummaryOverlay.dispose();
|
automaticActionSummaryOverlay.dispose();
|
||||||
entityCreator.dispose();
|
entityCreator.dispose();
|
||||||
|
|
||||||
@@ -143,12 +171,12 @@ public abstract class GameGlobals{
|
|||||||
gameWorld = null;
|
gameWorld = null;
|
||||||
automaticActionPerformer = null;
|
automaticActionPerformer = null;
|
||||||
automaticActionSummaryOverlay = null;
|
automaticActionSummaryOverlay = null;
|
||||||
|
playerSystem = null;
|
||||||
|
scenarioSummaryOverlay = null;
|
||||||
|
|
||||||
System.gc();
|
System.gc();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the entityCreator
|
|
||||||
*/
|
|
||||||
public static EntityCreatorBase getEntityCreator() throws IllegalStateException{
|
public static EntityCreatorBase getEntityCreator() throws IllegalStateException{
|
||||||
if(entityCreator == null)
|
if(entityCreator == null)
|
||||||
throw new IllegalStateException("Calling getEntityCreator() before init.");
|
throw new IllegalStateException("Calling getEntityCreator() before init.");
|
||||||
@@ -156,9 +184,6 @@ public abstract class GameGlobals{
|
|||||||
return entityCreator;
|
return entityCreator;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the gameLogicSystem
|
|
||||||
*/
|
|
||||||
public static GameLogicSystemBase getGameLogicSystem() throws IllegalStateException{
|
public static GameLogicSystemBase getGameLogicSystem() throws IllegalStateException{
|
||||||
if(gameLogicSystem == null)
|
if(gameLogicSystem == null)
|
||||||
throw new IllegalStateException("Calling getGameLogicSystem() before init.");
|
throw new IllegalStateException("Calling getGameLogicSystem() before init.");
|
||||||
@@ -166,9 +191,6 @@ public abstract class GameGlobals{
|
|||||||
return gameLogicSystem;
|
return gameLogicSystem;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the gameWorld
|
|
||||||
*/
|
|
||||||
public static World getGameWorld() throws IllegalStateException{
|
public static World getGameWorld() throws IllegalStateException{
|
||||||
if(gameWorld == null)
|
if(gameWorld == null)
|
||||||
throw new IllegalStateException("Calling getGameWorld() before init.");
|
throw new IllegalStateException("Calling getGameWorld() before init.");
|
||||||
@@ -176,9 +198,6 @@ public abstract class GameGlobals{
|
|||||||
return gameWorld;
|
return gameWorld;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the automaticActionPerformer
|
|
||||||
*/
|
|
||||||
public static AutomaticActionPerformerBase getAutomaticActionPerformer() throws IllegalStateException{
|
public static AutomaticActionPerformerBase getAutomaticActionPerformer() throws IllegalStateException{
|
||||||
if(automaticActionPerformer == null)
|
if(automaticActionPerformer == null)
|
||||||
throw new IllegalStateException("Calling getAutomaticActionPerformer() before init.");
|
throw new IllegalStateException("Calling getAutomaticActionPerformer() before init.");
|
||||||
@@ -186,13 +205,24 @@ public abstract class GameGlobals{
|
|||||||
return automaticActionPerformer;
|
return automaticActionPerformer;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public static SummaryOverlayBase getAutomaticActionSummaryOverlay() throws IllegalStateException{
|
||||||
* @return the automaticActionSummaryScreen
|
|
||||||
*/
|
|
||||||
public static AutomaticActionSummaryOverlayBase getAutomaticActionSummaryOverlay() throws IllegalStateException{
|
|
||||||
if(automaticActionSummaryOverlay == null)
|
if(automaticActionSummaryOverlay == null)
|
||||||
throw new IllegalStateException("Calling getAutomaticActionSummaryOverlay() before init.");
|
throw new IllegalStateException("Calling getAutomaticActionSummaryOverlay() before init.");
|
||||||
|
|
||||||
return automaticActionSummaryOverlay;
|
return automaticActionSummaryOverlay;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static PlayerSystemBase getPlayerSystem() throws IllegalStateException{
|
||||||
|
if(playerSystem == null)
|
||||||
|
throw new IllegalStateException("Calling getPlayerSystem() before init.");
|
||||||
|
|
||||||
|
return playerSystem;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static SummaryOverlayBase getScenarioSummaryOverlay() throws IllegalStateException{
|
||||||
|
if(scenarioSummaryOverlay == null)
|
||||||
|
throw new IllegalStateException("Calling getScenarioSummaryOverlay() before init.");
|
||||||
|
|
||||||
|
return scenarioSummaryOverlay;
|
||||||
|
}
|
||||||
}
|
}
|
@@ -0,0 +1,35 @@
|
|||||||
|
/*
|
||||||
|
* 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.scenarios;
|
||||||
|
|
||||||
|
import ve.ucv.ciens.ccg.nxtar.scenarios.bombgame.BombGameAutomaticActionPerformer;
|
||||||
|
import ve.ucv.ciens.ccg.nxtar.scenarios.bombgame.BombGameAutomaticActionSummaryOverlay;
|
||||||
|
import ve.ucv.ciens.ccg.nxtar.scenarios.bombgame.BombGameEntityCreator;
|
||||||
|
import ve.ucv.ciens.ccg.nxtar.scenarios.bombgame.BombGameLogicSystem;
|
||||||
|
import ve.ucv.ciens.ccg.nxtar.scenarios.bombgame.BombGamePlayerSystem;
|
||||||
|
import ve.ucv.ciens.ccg.nxtar.scenarios.bombgame.BombGameScenarioEndingOverlay;
|
||||||
|
|
||||||
|
@SuppressWarnings("rawtypes")
|
||||||
|
public final class ScenarioImplementation{
|
||||||
|
public static final Class gameLogicSystemClass = BombGameLogicSystem.class;
|
||||||
|
public static final Class entityCreatorClass = BombGameEntityCreator.class;
|
||||||
|
public static final Class automaticActionPerformerClass = BombGameAutomaticActionPerformer.class;
|
||||||
|
public static final Class automaticActionSummaryOverlay = BombGameAutomaticActionSummaryOverlay.class;
|
||||||
|
public static final Class playerSystemClass = BombGamePlayerSystem.class;
|
||||||
|
public static final Class scenarioSummaryOverlayClass = BombGameScenarioEndingOverlay.class;
|
||||||
|
|
||||||
|
private ScenarioImplementation(){}
|
||||||
|
}
|
20
src/ve/ucv/ciens/ccg/nxtar/scenarios/SummaryBase.java
Normal file
20
src/ve/ucv/ciens/ccg/nxtar/scenarios/SummaryBase.java
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
/*
|
||||||
|
* 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.scenarios;
|
||||||
|
|
||||||
|
public abstract class SummaryBase{
|
||||||
|
public abstract void reset();
|
||||||
|
}
|
@@ -13,9 +13,7 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package ve.ucv.ciens.ccg.nxtar.game;
|
package ve.ucv.ciens.ccg.nxtar.scenarios;
|
||||||
|
|
||||||
import ve.ucv.ciens.ccg.nxtar.game.AutomaticActionPerformerBase.AutomaticActionSummary;
|
|
||||||
|
|
||||||
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
|
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
|
||||||
import com.badlogic.gdx.utils.Disposable;
|
import com.badlogic.gdx.utils.Disposable;
|
||||||
@@ -23,11 +21,11 @@ import com.badlogic.gdx.utils.Disposable;
|
|||||||
/**
|
/**
|
||||||
* <p>Base class for summary screens. Just renders a summary overlay.</p>
|
* <p>Base class for summary screens. Just renders a summary overlay.</p>
|
||||||
*/
|
*/
|
||||||
public abstract class AutomaticActionSummaryOverlayBase implements Disposable{
|
public abstract class SummaryOverlayBase implements Disposable{
|
||||||
/**
|
/**
|
||||||
* <p>Renders the overlay.</p>
|
* <p>Renders the overlay.</p>
|
||||||
*
|
*
|
||||||
* @param batch The {@link SpriteBatch} to use for rendering.
|
* @param batch The {@link SpriteBatch} to use for rendering.
|
||||||
*/
|
*/
|
||||||
public abstract void render(SpriteBatch batch, AutomaticActionSummary summary);
|
public abstract void render(SpriteBatch batch, SummaryBase summary);
|
||||||
}
|
}
|
@@ -13,7 +13,7 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package ve.ucv.ciens.ccg.nxtar.game.bombgame;
|
package ve.ucv.ciens.ccg.nxtar.scenarios.bombgame;
|
||||||
|
|
||||||
import com.artemis.Component;
|
import com.artemis.Component;
|
||||||
|
|
@@ -13,14 +13,15 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package ve.ucv.ciens.ccg.nxtar.game.bombgame;
|
package ve.ucv.ciens.ccg.nxtar.scenarios.bombgame;
|
||||||
|
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
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.scenarios.AutomaticActionPerformerBase;
|
||||||
|
import ve.ucv.ciens.ccg.nxtar.scenarios.ScenarioGlobals;
|
||||||
|
import ve.ucv.ciens.ccg.nxtar.scenarios.SummaryBase;
|
||||||
import ve.ucv.ciens.ccg.nxtar.utils.ProjectConstants;
|
import ve.ucv.ciens.ccg.nxtar.utils.ProjectConstants;
|
||||||
|
|
||||||
import com.artemis.Entity;
|
import com.artemis.Entity;
|
||||||
@@ -39,7 +40,7 @@ public class BombGameAutomaticActionPerformer extends AutomaticActionPerformerBa
|
|||||||
START, WALK_FORWARD, DETECT_MARKER, FINISHING, END;
|
START, WALK_FORWARD, DETECT_MARKER, FINISHING, END;
|
||||||
}
|
}
|
||||||
|
|
||||||
public class BombGameAutomaticActionSummary extends AutomaticActionSummary{
|
public class BombGameAutomaticActionSummary extends SummaryBase{
|
||||||
private int numCombinationBombs;
|
private int numCombinationBombs;
|
||||||
private int numInclinationBombs;
|
private int numInclinationBombs;
|
||||||
private int numWireBombs;
|
private int numWireBombs;
|
||||||
@@ -109,7 +110,7 @@ public class BombGameAutomaticActionPerformer extends AutomaticActionPerformerBa
|
|||||||
World world;
|
World world;
|
||||||
|
|
||||||
if(manager == null){
|
if(manager == null){
|
||||||
world = GameGlobals.getGameWorld();
|
world = ScenarioGlobals.getGameWorld();
|
||||||
if(world == null)
|
if(world == null)
|
||||||
throw new IllegalStateException("World is null after getGameWorld().");
|
throw new IllegalStateException("World is null after getGameWorld().");
|
||||||
|
|
||||||
@@ -264,8 +265,8 @@ public class BombGameAutomaticActionPerformer extends AutomaticActionPerformerBa
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public AutomaticActionSummary getSummary() {
|
public SummaryBase getSummary() {
|
||||||
return (AutomaticActionSummary)summary;
|
return (SummaryBase)summary;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
@@ -13,11 +13,11 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package ve.ucv.ciens.ccg.nxtar.game.bombgame;
|
package ve.ucv.ciens.ccg.nxtar.scenarios.bombgame;
|
||||||
|
|
||||||
import ve.ucv.ciens.ccg.nxtar.game.AutomaticActionPerformerBase.AutomaticActionSummary;
|
import ve.ucv.ciens.ccg.nxtar.scenarios.SummaryBase;
|
||||||
import ve.ucv.ciens.ccg.nxtar.game.AutomaticActionSummaryOverlayBase;
|
import ve.ucv.ciens.ccg.nxtar.scenarios.SummaryOverlayBase;
|
||||||
import ve.ucv.ciens.ccg.nxtar.game.bombgame.BombGameAutomaticActionPerformer.BombGameAutomaticActionSummary;
|
import ve.ucv.ciens.ccg.nxtar.scenarios.bombgame.BombGameAutomaticActionPerformer.BombGameAutomaticActionSummary;
|
||||||
import ve.ucv.ciens.ccg.nxtar.utils.ProjectConstants;
|
import ve.ucv.ciens.ccg.nxtar.utils.ProjectConstants;
|
||||||
import ve.ucv.ciens.ccg.nxtar.utils.Utils;
|
import ve.ucv.ciens.ccg.nxtar.utils.Utils;
|
||||||
|
|
||||||
@@ -30,7 +30,7 @@ import com.badlogic.gdx.graphics.g2d.SpriteBatch;
|
|||||||
import com.badlogic.gdx.graphics.g2d.freetype.FreeTypeFontGenerator;
|
import com.badlogic.gdx.graphics.g2d.freetype.FreeTypeFontGenerator;
|
||||||
import com.badlogic.gdx.graphics.g2d.freetype.FreeTypeFontGenerator.FreeTypeFontParameter;
|
import com.badlogic.gdx.graphics.g2d.freetype.FreeTypeFontGenerator.FreeTypeFontParameter;
|
||||||
|
|
||||||
public class BombGameAutomaticActionSummaryOverlay extends AutomaticActionSummaryOverlayBase{
|
public class BombGameAutomaticActionSummaryOverlay extends SummaryOverlayBase{
|
||||||
private static final float CANNONICAL_SCREEN_WIDTH = 800.0f;
|
private static final float CANNONICAL_SCREEN_WIDTH = 800.0f;
|
||||||
|
|
||||||
private Texture inclinationBombTexture;
|
private Texture inclinationBombTexture;
|
||||||
@@ -106,7 +106,7 @@ public class BombGameAutomaticActionSummaryOverlay extends AutomaticActionSummar
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void render(SpriteBatch batch, AutomaticActionSummary summary) throws ClassCastException{
|
public void render(SpriteBatch batch, SummaryBase summary) throws ClassCastException{
|
||||||
BombGameAutomaticActionSummary bombGameSummary;
|
BombGameAutomaticActionSummary bombGameSummary;
|
||||||
|
|
||||||
if(!(summary instanceof BombGameAutomaticActionSummary))
|
if(!(summary instanceof BombGameAutomaticActionSummary))
|
@@ -13,7 +13,7 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package ve.ucv.ciens.ccg.nxtar.game.bombgame;
|
package ve.ucv.ciens.ccg.nxtar.scenarios.bombgame;
|
||||||
|
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -30,8 +30,8 @@ import ve.ucv.ciens.ccg.nxtar.components.RenderModelComponent;
|
|||||||
import ve.ucv.ciens.ccg.nxtar.components.ShaderComponent;
|
import ve.ucv.ciens.ccg.nxtar.components.ShaderComponent;
|
||||||
import ve.ucv.ciens.ccg.nxtar.components.VisibilityComponent;
|
import ve.ucv.ciens.ccg.nxtar.components.VisibilityComponent;
|
||||||
import ve.ucv.ciens.ccg.nxtar.entities.EntityCreatorBase;
|
import ve.ucv.ciens.ccg.nxtar.entities.EntityCreatorBase;
|
||||||
import ve.ucv.ciens.ccg.nxtar.game.bombgame.BombComponent.bomb_type_t;
|
|
||||||
import ve.ucv.ciens.ccg.nxtar.graphics.shaders.DirectionalLightPerPixelShader;
|
import ve.ucv.ciens.ccg.nxtar.graphics.shaders.DirectionalLightPerPixelShader;
|
||||||
|
import ve.ucv.ciens.ccg.nxtar.scenarios.bombgame.BombComponent.bomb_type_t;
|
||||||
import ve.ucv.ciens.ccg.nxtar.systems.AnimationSystem;
|
import ve.ucv.ciens.ccg.nxtar.systems.AnimationSystem;
|
||||||
import ve.ucv.ciens.ccg.nxtar.systems.CollisionDetectionSystem;
|
import ve.ucv.ciens.ccg.nxtar.systems.CollisionDetectionSystem;
|
||||||
|
|
@@ -13,7 +13,7 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package ve.ucv.ciens.ccg.nxtar.game.bombgame;
|
package ve.ucv.ciens.ccg.nxtar.scenarios.bombgame;
|
||||||
|
|
||||||
import com.artemis.Component;
|
import com.artemis.Component;
|
||||||
|
|
@@ -13,7 +13,7 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package ve.ucv.ciens.ccg.nxtar.game.bombgame;
|
package ve.ucv.ciens.ccg.nxtar.scenarios.bombgame;
|
||||||
|
|
||||||
import ve.ucv.ciens.ccg.nxtar.components.AnimationComponent;
|
import ve.ucv.ciens.ccg.nxtar.components.AnimationComponent;
|
||||||
import ve.ucv.ciens.ccg.nxtar.components.CollisionDetectionComponent;
|
import ve.ucv.ciens.ccg.nxtar.components.CollisionDetectionComponent;
|
||||||
@@ -227,7 +227,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(Utils.isDeviceRollValid() && Math.abs(Gdx.input.getRoll()) > ProjectConstants.MAX_ABS_ROLL){
|
if(!Utils.isDeviceRollValid() || (Utils.isDeviceRollValid() && Math.abs(Gdx.input.getRoll()) > ProjectConstants.MAX_ABS_ROLL)){
|
||||||
Gdx.app.log(TAG, CLASS_NAME + ".processInclinationBomb(): Inclination bomb exploded.");
|
Gdx.app.log(TAG, CLASS_NAME + ".processInclinationBomb(): Inclination bomb exploded.");
|
||||||
createFadeOutEffect();
|
createFadeOutEffect();
|
||||||
reducePlayerLivesByOne();
|
reducePlayerLivesByOne();
|
||||||
@@ -326,7 +326,7 @@ public class BombGameLogicSystem extends GameLogicSystemBase {
|
|||||||
|
|
||||||
players = manager.getEntities(PlayerComponentBase.PLAYER_GROUP);
|
players = manager.getEntities(PlayerComponentBase.PLAYER_GROUP);
|
||||||
if(players != null && players.size() > 0 && players.get(0) != null){
|
if(players != null && players.size() > 0 && players.get(0) != null){
|
||||||
player = players.get(0);
|
player = players.get(0);
|
||||||
playerComponent = player.getComponent(BombGamePlayerComponent.class);
|
playerComponent = player.getComponent(BombGamePlayerComponent.class);
|
||||||
|
|
||||||
if(playerComponent != null){
|
if(playerComponent != null){
|
||||||
@@ -340,6 +340,30 @@ public class BombGameLogicSystem extends GameLogicSystemBase {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>Updates the player's disabled bombs count.</p>
|
||||||
|
*/
|
||||||
|
private void increasePlayerDisabledBombsByOne(){
|
||||||
|
Entity player;
|
||||||
|
BombGamePlayerComponent playerComponent;
|
||||||
|
ImmutableBag<Entity> players;
|
||||||
|
|
||||||
|
players = manager.getEntities(PlayerComponentBase.PLAYER_GROUP);
|
||||||
|
if(players != null && players.size() > 0 && players.get(0) != null){
|
||||||
|
player = players.get(0);
|
||||||
|
playerComponent = player.getComponent(BombGamePlayerComponent.class);
|
||||||
|
|
||||||
|
if(playerComponent != null){
|
||||||
|
playerComponent.disabledBombs += 1;
|
||||||
|
}else{
|
||||||
|
Gdx.app.log(TAG, CLASS_NAME + ".reducePlayerLivesByOne(): Players is missing required components.");
|
||||||
|
}
|
||||||
|
|
||||||
|
}else{
|
||||||
|
Gdx.app.log(TAG, CLASS_NAME + ".reducePlayerLivesByOne(): No players found.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>Disables all entities associated with the corresponding marker code.</p>
|
* <p>Disables all entities associated with the corresponding marker code.</p>
|
||||||
*
|
*
|
||||||
@@ -368,6 +392,8 @@ public class BombGameLogicSystem extends GameLogicSystemBase {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
increasePlayerDisabledBombsByOne();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
@@ -13,7 +13,7 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package ve.ucv.ciens.ccg.nxtar.game.bombgame;
|
package ve.ucv.ciens.ccg.nxtar.scenarios.bombgame;
|
||||||
|
|
||||||
import ve.ucv.ciens.ccg.nxtar.components.PlayerComponentBase;
|
import ve.ucv.ciens.ccg.nxtar.components.PlayerComponentBase;
|
||||||
|
|
||||||
@@ -21,9 +21,9 @@ public class BombGamePlayerComponent extends PlayerComponentBase {
|
|||||||
public static final int MIN_LIVES = 1;
|
public static final int MIN_LIVES = 1;
|
||||||
public static final int MAX_LIVES = 5;
|
public static final int MAX_LIVES = 5;
|
||||||
|
|
||||||
private int startingLives;
|
public int startingLives;
|
||||||
public int lives;
|
public int lives;
|
||||||
public int disabledBombs;
|
public int disabledBombs;
|
||||||
|
|
||||||
public BombGamePlayerComponent(int lives) throws IllegalArgumentException{
|
public BombGamePlayerComponent(int lives) throws IllegalArgumentException{
|
||||||
super();
|
super();
|
||||||
@@ -38,7 +38,7 @@ public class BombGamePlayerComponent extends PlayerComponentBase {
|
|||||||
public BombGamePlayerComponent(){
|
public BombGamePlayerComponent(){
|
||||||
this(3);
|
this(3);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void reset(){
|
public void reset(){
|
||||||
super.reset();
|
super.reset();
|
@@ -0,0 +1,118 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2013 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.scenarios.bombgame;
|
||||||
|
|
||||||
|
import ve.ucv.ciens.ccg.nxtar.scenarios.SummaryBase;
|
||||||
|
import ve.ucv.ciens.ccg.nxtar.systems.PlayerSystemBase;
|
||||||
|
import ve.ucv.ciens.ccg.nxtar.utils.Utils;
|
||||||
|
|
||||||
|
import com.artemis.ComponentMapper;
|
||||||
|
import com.artemis.Entity;
|
||||||
|
import com.artemis.annotations.Mapper;
|
||||||
|
import com.badlogic.gdx.Gdx;
|
||||||
|
import com.badlogic.gdx.graphics.OrthographicCamera;
|
||||||
|
import com.badlogic.gdx.graphics.Texture;
|
||||||
|
import com.badlogic.gdx.graphics.g2d.Sprite;
|
||||||
|
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
|
||||||
|
|
||||||
|
public class BombGamePlayerSystem extends PlayerSystemBase{
|
||||||
|
public final class BombGamePlayerSummary extends SummaryBase{
|
||||||
|
public int livesLeft;
|
||||||
|
public int disabledBombs;
|
||||||
|
public int detonatedBombs;
|
||||||
|
public boolean victory;
|
||||||
|
|
||||||
|
public BombGamePlayerSummary(){
|
||||||
|
reset();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void reset() {
|
||||||
|
this.livesLeft = 0;
|
||||||
|
this.disabledBombs = 0;
|
||||||
|
this.detonatedBombs = 0;
|
||||||
|
this.victory = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Mapper ComponentMapper<BombGamePlayerComponent> playerMapper;
|
||||||
|
|
||||||
|
private SpriteBatch batch;
|
||||||
|
private Texture heartTexture;
|
||||||
|
private Sprite heart;
|
||||||
|
private OrthographicCamera camera;
|
||||||
|
private BombGamePlayerSummary summary;
|
||||||
|
private float heartYPos;
|
||||||
|
|
||||||
|
public BombGamePlayerSystem(){
|
||||||
|
super(BombGamePlayerComponent.class);
|
||||||
|
camera = new OrthographicCamera(Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
|
||||||
|
batch = new SpriteBatch();
|
||||||
|
heartTexture = new Texture(Gdx.files.internal("data/gfx/bomb_game/Anonymous_heart_1.png"));
|
||||||
|
summary = new BombGamePlayerSummary();
|
||||||
|
heart = new Sprite(heartTexture);
|
||||||
|
heart.setSize(heart.getWidth() * 0.25f, heart.getHeight() * 0.25f);
|
||||||
|
heartYPos = (Utils.getScreenHeightWithOverscan() / 2) - heart.getHeight() - 64 - 5;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void process(Entity e){
|
||||||
|
float heartXPos;
|
||||||
|
BombGamePlayerComponent player = playerMapper.get(e);
|
||||||
|
|
||||||
|
// Render remaining lives.
|
||||||
|
batch.setProjectionMatrix(camera.combined);
|
||||||
|
batch.begin();{
|
||||||
|
heartXPos = -(Utils.getScreenWidthWithOverscan() / 2) + 5;
|
||||||
|
for(int i = 0; i < player.lives; ++i){
|
||||||
|
heart.setPosition(heartXPos, heartYPos);
|
||||||
|
heart.draw(batch);
|
||||||
|
heartXPos += heart.getWidth() + 5;
|
||||||
|
}
|
||||||
|
}batch.end();
|
||||||
|
|
||||||
|
// Check ending conditions.
|
||||||
|
if(player.lives <= 0){
|
||||||
|
player.gameFinished = true;
|
||||||
|
player.victory = false;
|
||||||
|
}else if(player.disabledBombs >= BombGameEntityCreator.NUM_BOMBS){
|
||||||
|
player.gameFinished = true;
|
||||||
|
player.victory = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(player.gameFinished){
|
||||||
|
summary.victory = player.victory;
|
||||||
|
summary.livesLeft = player.lives;
|
||||||
|
summary.disabledBombs = BombGameEntityCreator.NUM_BOMBS - (player.startingLives - player.lives);
|
||||||
|
summary.detonatedBombs = player.startingLives - player.lives;
|
||||||
|
finishGame(player.victory);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void dispose() {
|
||||||
|
if(batch != null)
|
||||||
|
batch.dispose();
|
||||||
|
|
||||||
|
if(heartTexture != null)
|
||||||
|
heartTexture.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public SummaryBase getPlayerSummary() {
|
||||||
|
return summary;
|
||||||
|
}
|
||||||
|
}
|
@@ -0,0 +1,101 @@
|
|||||||
|
/*
|
||||||
|
* 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.scenarios.bombgame;
|
||||||
|
|
||||||
|
import ve.ucv.ciens.ccg.nxtar.scenarios.SummaryBase;
|
||||||
|
import ve.ucv.ciens.ccg.nxtar.scenarios.SummaryOverlayBase;
|
||||||
|
import ve.ucv.ciens.ccg.nxtar.scenarios.bombgame.BombGamePlayerSystem.BombGamePlayerSummary;
|
||||||
|
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.g2d.BitmapFont;
|
||||||
|
import com.badlogic.gdx.graphics.g2d.BitmapFont.TextBounds;
|
||||||
|
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 BombGameScenarioEndingOverlay extends SummaryOverlayBase {
|
||||||
|
private static final float CANNONICAL_SCREEN_WIDTH = 800.0f;
|
||||||
|
|
||||||
|
private BitmapFont font;
|
||||||
|
private BitmapFont titleFont;
|
||||||
|
private float textX;
|
||||||
|
private float baseTextY;
|
||||||
|
private TextBounds titleBounds;
|
||||||
|
|
||||||
|
public BombGameScenarioEndingOverlay(){
|
||||||
|
FreeTypeFontGenerator fontGenerator;
|
||||||
|
FreeTypeFontParameter fontParameters;
|
||||||
|
|
||||||
|
fontParameters = new FreeTypeFontParameter();
|
||||||
|
fontParameters.characters = ProjectConstants.FONT_CHARS;
|
||||||
|
fontParameters.size = (int)(65.0f * ((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();
|
||||||
|
|
||||||
|
textX = -(Utils.getScreenWidthWithOverscan() / 7.0f);
|
||||||
|
baseTextY = -(font.getCapHeight() / 2.0f);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void dispose(){
|
||||||
|
font.dispose();
|
||||||
|
titleFont.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void render(SpriteBatch batch, SummaryBase summary) throws ClassCastException{
|
||||||
|
BombGamePlayerSummary bombGamePlayerSummary;
|
||||||
|
String title;
|
||||||
|
String text;
|
||||||
|
|
||||||
|
// Get the player's summary.
|
||||||
|
if(!(summary instanceof BombGamePlayerSummary))
|
||||||
|
throw new ClassCastException("Summary is not a bomb game summary.");
|
||||||
|
bombGamePlayerSummary = (BombGamePlayerSummary)summary;
|
||||||
|
|
||||||
|
// Render the summary.
|
||||||
|
text = String.format("Lives left: %d", bombGamePlayerSummary.livesLeft);
|
||||||
|
textX = -(font.getBounds(text).width / 2);
|
||||||
|
font.draw(batch, text, textX, baseTextY + font.getCapHeight() + 15);
|
||||||
|
|
||||||
|
text = String.format("Bombs defused: %d", bombGamePlayerSummary.disabledBombs);
|
||||||
|
textX = -(font.getBounds(text).width / 2);
|
||||||
|
font.draw(batch, text, textX, baseTextY);
|
||||||
|
|
||||||
|
text = String.format("Bombs detonated: %d", bombGamePlayerSummary.detonatedBombs);
|
||||||
|
textX = -(font.getBounds(text).width / 2);
|
||||||
|
font.draw(batch, text, textX, baseTextY - font.getCapHeight() - 15);
|
||||||
|
|
||||||
|
// Render the title.
|
||||||
|
if(bombGamePlayerSummary.victory)
|
||||||
|
title = "Victory!";
|
||||||
|
else
|
||||||
|
title = "Game Over";
|
||||||
|
titleBounds = titleFont.getBounds(title);
|
||||||
|
titleFont.draw(batch, title, -(titleBounds.width / 2), (Utils.getScreenHeightWithOverscan() / 2) - titleBounds.height - 10);
|
||||||
|
}
|
||||||
|
}
|
@@ -19,14 +19,14 @@ import ve.ucv.ciens.ccg.networkdata.MotorEvent;
|
|||||||
import ve.ucv.ciens.ccg.networkdata.MotorEvent.motor_t;
|
import ve.ucv.ciens.ccg.networkdata.MotorEvent.motor_t;
|
||||||
import ve.ucv.ciens.ccg.nxtar.NxtARCore;
|
import ve.ucv.ciens.ccg.nxtar.NxtARCore;
|
||||||
import ve.ucv.ciens.ccg.nxtar.NxtARCore.game_states_t;
|
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.AutomaticActionPerformerBase.automatic_action_t;
|
|
||||||
import ve.ucv.ciens.ccg.nxtar.game.GameGlobals;
|
|
||||||
import ve.ucv.ciens.ccg.nxtar.graphics.CustomPerspectiveCamera;
|
import ve.ucv.ciens.ccg.nxtar.graphics.CustomPerspectiveCamera;
|
||||||
import ve.ucv.ciens.ccg.nxtar.interfaces.ImageProcessor.MarkerData;
|
import ve.ucv.ciens.ccg.nxtar.interfaces.ImageProcessor.MarkerData;
|
||||||
import ve.ucv.ciens.ccg.nxtar.network.SensorReportThread;
|
import ve.ucv.ciens.ccg.nxtar.network.SensorReportThread;
|
||||||
import ve.ucv.ciens.ccg.nxtar.network.monitors.MotorEventQueue;
|
import ve.ucv.ciens.ccg.nxtar.network.monitors.MotorEventQueue;
|
||||||
import ve.ucv.ciens.ccg.nxtar.network.monitors.VideoFrameMonitor;
|
import ve.ucv.ciens.ccg.nxtar.network.monitors.VideoFrameMonitor;
|
||||||
|
import ve.ucv.ciens.ccg.nxtar.scenarios.AutomaticActionPerformerBase;
|
||||||
|
import ve.ucv.ciens.ccg.nxtar.scenarios.ScenarioGlobals;
|
||||||
|
import ve.ucv.ciens.ccg.nxtar.scenarios.AutomaticActionPerformerBase.automatic_action_t;
|
||||||
import ve.ucv.ciens.ccg.nxtar.systems.CollisionDetectionSystem;
|
import ve.ucv.ciens.ccg.nxtar.systems.CollisionDetectionSystem;
|
||||||
import ve.ucv.ciens.ccg.nxtar.systems.MarkerPositioningSystem;
|
import ve.ucv.ciens.ccg.nxtar.systems.MarkerPositioningSystem;
|
||||||
import ve.ucv.ciens.ccg.nxtar.systems.MarkerRenderingSystem;
|
import ve.ucv.ciens.ccg.nxtar.systems.MarkerRenderingSystem;
|
||||||
@@ -137,7 +137,7 @@ public class AutomaticActionState extends BaseState{
|
|||||||
aButtonPressed = false;
|
aButtonPressed = false;
|
||||||
automaticActionEnabled = false;
|
automaticActionEnabled = false;
|
||||||
startButtonPressed = false;
|
startButtonPressed = false;
|
||||||
automaticActionPerformer = GameGlobals.getAutomaticActionPerformer();
|
automaticActionPerformer = ScenarioGlobals.getAutomaticActionPerformer();
|
||||||
previousAction = automatic_action_t.NO_ACTION;
|
previousAction = automatic_action_t.NO_ACTION;
|
||||||
|
|
||||||
// Set up the cameras.
|
// Set up the cameras.
|
||||||
@@ -187,7 +187,7 @@ public class AutomaticActionState extends BaseState{
|
|||||||
setUpButton();
|
setUpButton();
|
||||||
|
|
||||||
// Set up the game world.
|
// Set up the game world.
|
||||||
gameWorld = GameGlobals.getGameWorld();
|
gameWorld = ScenarioGlobals.getGameWorld();
|
||||||
markerRenderingSystem = gameWorld.getSystem(MarkerRenderingSystem.class);
|
markerRenderingSystem = gameWorld.getSystem(MarkerRenderingSystem.class);
|
||||||
|
|
||||||
if(markerRenderingSystem == null)
|
if(markerRenderingSystem == null)
|
||||||
@@ -571,7 +571,7 @@ public class AutomaticActionState extends BaseState{
|
|||||||
startButton.setDisabled(false);
|
startButton.setDisabled(false);
|
||||||
ignoreBackKey = false;
|
ignoreBackKey = false;
|
||||||
automaticActionEnabled = false;
|
automaticActionEnabled = false;
|
||||||
core.nextState = game_states_t.SUMMARY;
|
core.nextState = game_states_t.AUTOMATIC_ACTION_SUMMARY;
|
||||||
}
|
}
|
||||||
|
|
||||||
}catch(IllegalArgumentException e){
|
}catch(IllegalArgumentException e){
|
||||||
|
@@ -17,9 +17,9 @@ package ve.ucv.ciens.ccg.nxtar.states;
|
|||||||
|
|
||||||
import ve.ucv.ciens.ccg.nxtar.NxtARCore;
|
import ve.ucv.ciens.ccg.nxtar.NxtARCore;
|
||||||
import ve.ucv.ciens.ccg.nxtar.NxtARCore.game_states_t;
|
import ve.ucv.ciens.ccg.nxtar.NxtARCore.game_states_t;
|
||||||
import ve.ucv.ciens.ccg.nxtar.game.AutomaticActionPerformerBase;
|
import ve.ucv.ciens.ccg.nxtar.scenarios.AutomaticActionPerformerBase;
|
||||||
import ve.ucv.ciens.ccg.nxtar.game.AutomaticActionSummaryOverlayBase;
|
import ve.ucv.ciens.ccg.nxtar.scenarios.ScenarioGlobals;
|
||||||
import ve.ucv.ciens.ccg.nxtar.game.GameGlobals;
|
import ve.ucv.ciens.ccg.nxtar.scenarios.SummaryOverlayBase;
|
||||||
import ve.ucv.ciens.ccg.nxtar.utils.ProjectConstants;
|
import ve.ucv.ciens.ccg.nxtar.utils.ProjectConstants;
|
||||||
import ve.ucv.ciens.ccg.nxtar.utils.Utils;
|
import ve.ucv.ciens.ccg.nxtar.utils.Utils;
|
||||||
|
|
||||||
@@ -71,14 +71,11 @@ public class AutomaticActionSummaryState extends BaseState{
|
|||||||
private Texture buttonEnabledTexture;
|
private Texture buttonEnabledTexture;
|
||||||
private Texture buttonDisabledTexture;
|
private Texture buttonDisabledTexture;
|
||||||
private Texture buttonPressedTexture;
|
private Texture buttonPressedTexture;
|
||||||
private NinePatch buttonEnabled9p;
|
|
||||||
private NinePatch buttonDisabled9p;
|
|
||||||
private NinePatch buttonPressed9p;
|
|
||||||
private BitmapFont font;
|
private BitmapFont font;
|
||||||
|
|
||||||
// Summary overlay related fields.
|
// Summary overlay related fields.
|
||||||
AutomaticActionPerformerBase automaticActionPerformer;
|
AutomaticActionPerformerBase automaticActionPerformer;
|
||||||
AutomaticActionSummaryOverlayBase summaryOverlay;
|
SummaryOverlayBase summaryOverlay;
|
||||||
|
|
||||||
// Button touch helper fields.
|
// Button touch helper fields.
|
||||||
private boolean continueButtonTouched;
|
private boolean continueButtonTouched;
|
||||||
@@ -88,6 +85,9 @@ public class AutomaticActionSummaryState extends BaseState{
|
|||||||
TextButtonStyle textButtonStyle;
|
TextButtonStyle textButtonStyle;
|
||||||
FreeTypeFontGenerator fontGenerator;
|
FreeTypeFontGenerator fontGenerator;
|
||||||
FreeTypeFontParameter fontParameters;
|
FreeTypeFontParameter fontParameters;
|
||||||
|
NinePatch buttonEnabled9p;
|
||||||
|
NinePatch buttonDisabled9p;
|
||||||
|
NinePatch buttonPressed9p;
|
||||||
|
|
||||||
if(core == null)
|
if(core == null)
|
||||||
throw new IllegalArgumentException(CLASS_NAME + ": Core is null.");
|
throw new IllegalArgumentException(CLASS_NAME + ": Core is null.");
|
||||||
@@ -95,34 +95,34 @@ public class AutomaticActionSummaryState extends BaseState{
|
|||||||
this.core = core;
|
this.core = core;
|
||||||
this.pixelPerfectCamera = new OrthographicCamera(Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
|
this.pixelPerfectCamera = new OrthographicCamera(Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
|
||||||
oButtonPressed = false;
|
oButtonPressed = false;
|
||||||
automaticActionPerformer = GameGlobals.getAutomaticActionPerformer();
|
automaticActionPerformer = ScenarioGlobals.getAutomaticActionPerformer();
|
||||||
summaryOverlay = GameGlobals.getAutomaticActionSummaryOverlay();
|
summaryOverlay = ScenarioGlobals.getAutomaticActionSummaryOverlay();
|
||||||
|
|
||||||
// Create the start button background.
|
// Create the start button background.
|
||||||
buttonEnabledTexture = new Texture(Gdx.files.internal("data/gfx/gui/Anonymous_Pill_Button_Yellow.png"));
|
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);
|
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"));
|
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);
|
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"));
|
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);
|
buttonPressed9p = new NinePatch(new TextureRegion(buttonPressedTexture, 0, 0, buttonPressedTexture.getWidth(), buttonPressedTexture.getHeight()), 49, 49, 45, 45);
|
||||||
|
|
||||||
// Create the start button font.
|
// Create the start button font.
|
||||||
fontParameters = new FreeTypeFontParameter();
|
fontParameters = new FreeTypeFontParameter();
|
||||||
fontParameters.characters = ProjectConstants.FONT_CHARS;
|
fontParameters.characters = ProjectConstants.FONT_CHARS;
|
||||||
fontParameters.size = ProjectConstants.MENU_BUTTON_FONT_SIZE;
|
fontParameters.size = ProjectConstants.MENU_BUTTON_FONT_SIZE;
|
||||||
fontParameters.flip = false;
|
fontParameters.flip = false;
|
||||||
fontGenerator = new FreeTypeFontGenerator(Gdx.files.internal("data/fonts/d-puntillas-B-to-tiptoe.ttf"));
|
fontGenerator = new FreeTypeFontGenerator(Gdx.files.internal("data/fonts/d-puntillas-B-to-tiptoe.ttf"));
|
||||||
font = fontGenerator.generateFont(fontParameters);
|
font = fontGenerator.generateFont(fontParameters);
|
||||||
fontGenerator.dispose();
|
fontGenerator.dispose();
|
||||||
|
|
||||||
// Create the contine button.
|
// Create the contine button.
|
||||||
textButtonStyle = new TextButtonStyle();
|
textButtonStyle = new TextButtonStyle();
|
||||||
textButtonStyle.font = font;
|
textButtonStyle.font = font;
|
||||||
textButtonStyle.up = new NinePatchDrawable(buttonEnabled9p);
|
textButtonStyle.up = new NinePatchDrawable(buttonEnabled9p);
|
||||||
textButtonStyle.checked = new NinePatchDrawable(buttonPressed9p);
|
textButtonStyle.checked = new NinePatchDrawable(buttonPressed9p);
|
||||||
textButtonStyle.disabled = new NinePatchDrawable(buttonDisabled9p);
|
textButtonStyle.disabled = new NinePatchDrawable(buttonDisabled9p);
|
||||||
textButtonStyle.fontColor = new Color(Color.BLACK);
|
textButtonStyle.fontColor = new Color(Color.BLACK);
|
||||||
textButtonStyle.downFontColor = new Color(Color.WHITE);
|
textButtonStyle.downFontColor = new Color(Color.WHITE);
|
||||||
textButtonStyle.disabledFontColor = new Color(Color.BLACK);
|
textButtonStyle.disabledFontColor = new Color(Color.BLACK);
|
||||||
|
|
||||||
continueButton = new TextButton("Continue", textButtonStyle);
|
continueButton = new TextButton("Continue", textButtonStyle);
|
||||||
@@ -156,17 +156,16 @@ public class AutomaticActionSummaryState extends BaseState{
|
|||||||
backgroundShader = null;
|
backgroundShader = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
u_scaling = new float[2];
|
u_scaling = new float[2];
|
||||||
u_scaling[0] = Gdx.graphics.getWidth() > Gdx.graphics.getHeight() ? 16.0f : 9.0f;
|
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_scaling[1] = Gdx.graphics.getHeight() > Gdx.graphics.getWidth() ? 16.0f : 9.0f;
|
||||||
|
|
||||||
u_displacement = 1.0f;
|
u_displacement = 1.0f;
|
||||||
|
|
||||||
win2world = new Vector3(0.0f, 0.0f, 0.0f);
|
win2world = new Vector3(0.0f, 0.0f, 0.0f);
|
||||||
touchPointWorldCoords = new Vector2();
|
touchPointWorldCoords = new Vector2();
|
||||||
continueButtonTouched = false;
|
continueButtonTouched = false;
|
||||||
continueButtonTouchPointer = -1;
|
continueButtonTouchPointer = -1;
|
||||||
stateActive = false;
|
stateActive = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@@ -19,7 +19,6 @@ import ve.ucv.ciens.ccg.networkdata.MotorEvent;
|
|||||||
import ve.ucv.ciens.ccg.networkdata.MotorEvent.motor_t;
|
import ve.ucv.ciens.ccg.networkdata.MotorEvent.motor_t;
|
||||||
import ve.ucv.ciens.ccg.nxtar.NxtARCore;
|
import ve.ucv.ciens.ccg.nxtar.NxtARCore;
|
||||||
import ve.ucv.ciens.ccg.nxtar.NxtARCore.game_states_t;
|
import ve.ucv.ciens.ccg.nxtar.NxtARCore.game_states_t;
|
||||||
import ve.ucv.ciens.ccg.nxtar.game.GameGlobals;
|
|
||||||
import ve.ucv.ciens.ccg.nxtar.graphics.CustomPerspectiveCamera;
|
import ve.ucv.ciens.ccg.nxtar.graphics.CustomPerspectiveCamera;
|
||||||
import ve.ucv.ciens.ccg.nxtar.input.GamepadUserInput;
|
import ve.ucv.ciens.ccg.nxtar.input.GamepadUserInput;
|
||||||
import ve.ucv.ciens.ccg.nxtar.input.KeyboardUserInput;
|
import ve.ucv.ciens.ccg.nxtar.input.KeyboardUserInput;
|
||||||
@@ -28,11 +27,13 @@ import ve.ucv.ciens.ccg.nxtar.input.UserInput;
|
|||||||
import ve.ucv.ciens.ccg.nxtar.interfaces.ImageProcessor.MarkerData;
|
import ve.ucv.ciens.ccg.nxtar.interfaces.ImageProcessor.MarkerData;
|
||||||
import ve.ucv.ciens.ccg.nxtar.network.monitors.MotorEventQueue;
|
import ve.ucv.ciens.ccg.nxtar.network.monitors.MotorEventQueue;
|
||||||
import ve.ucv.ciens.ccg.nxtar.network.monitors.VideoFrameMonitor;
|
import ve.ucv.ciens.ccg.nxtar.network.monitors.VideoFrameMonitor;
|
||||||
|
import ve.ucv.ciens.ccg.nxtar.scenarios.ScenarioGlobals;
|
||||||
import ve.ucv.ciens.ccg.nxtar.systems.CollisionDetectionSystem;
|
import ve.ucv.ciens.ccg.nxtar.systems.CollisionDetectionSystem;
|
||||||
import ve.ucv.ciens.ccg.nxtar.systems.FadeEffectRenderingSystem;
|
import ve.ucv.ciens.ccg.nxtar.systems.FadeEffectRenderingSystem;
|
||||||
import ve.ucv.ciens.ccg.nxtar.systems.MarkerPositioningSystem;
|
import ve.ucv.ciens.ccg.nxtar.systems.MarkerPositioningSystem;
|
||||||
import ve.ucv.ciens.ccg.nxtar.systems.MarkerRenderingSystem;
|
import ve.ucv.ciens.ccg.nxtar.systems.MarkerRenderingSystem;
|
||||||
import ve.ucv.ciens.ccg.nxtar.systems.ObjectRenderingSystem;
|
import ve.ucv.ciens.ccg.nxtar.systems.ObjectRenderingSystem;
|
||||||
|
import ve.ucv.ciens.ccg.nxtar.systems.PlayerSystemBase;
|
||||||
import ve.ucv.ciens.ccg.nxtar.systems.RobotArmPositioningSystem;
|
import ve.ucv.ciens.ccg.nxtar.systems.RobotArmPositioningSystem;
|
||||||
import ve.ucv.ciens.ccg.nxtar.utils.ProjectConstants;
|
import ve.ucv.ciens.ccg.nxtar.utils.ProjectConstants;
|
||||||
import ve.ucv.ciens.ccg.nxtar.utils.Utils;
|
import ve.ucv.ciens.ccg.nxtar.utils.Utils;
|
||||||
@@ -99,6 +100,7 @@ public class InGameState extends BaseState{
|
|||||||
private ObjectRenderingSystem objectRenderingSystem;
|
private ObjectRenderingSystem objectRenderingSystem;
|
||||||
private RobotArmPositioningSystem robotArmPositioningSystem;
|
private RobotArmPositioningSystem robotArmPositioningSystem;
|
||||||
private FadeEffectRenderingSystem fadeEffectRenderingSystem;
|
private FadeEffectRenderingSystem fadeEffectRenderingSystem;
|
||||||
|
private PlayerSystemBase playerSystem;
|
||||||
private robot_control_mode_t controlMode;
|
private robot_control_mode_t controlMode;
|
||||||
|
|
||||||
// Cameras.
|
// Cameras.
|
||||||
@@ -215,13 +217,13 @@ public class InGameState extends BaseState{
|
|||||||
backgroundShader = null;
|
backgroundShader = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
uScaling = new float[2];
|
uScaling = new float[2];
|
||||||
uScaling[0] = Gdx.graphics.getWidth() > Gdx.graphics.getHeight() ? 16.0f : 9.0f;
|
uScaling[0] = Gdx.graphics.getWidth() > Gdx.graphics.getHeight() ? 16.0f : 9.0f;
|
||||||
uScaling[1] = Gdx.graphics.getHeight() > Gdx.graphics.getWidth() ? 16.0f : 9.0f;
|
uScaling[1] = Gdx.graphics.getHeight() > Gdx.graphics.getWidth() ? 16.0f : 9.0f;
|
||||||
|
|
||||||
// Set up the 3D rendering.
|
// Set up the 3D rendering.
|
||||||
modelBatch = new ModelBatch();
|
modelBatch = new ModelBatch();
|
||||||
frameBuffer = null;
|
frameBuffer = null;
|
||||||
perspectiveCamera = null;
|
perspectiveCamera = null;
|
||||||
frameBufferSprite = null;
|
frameBufferSprite = null;
|
||||||
|
|
||||||
@@ -230,12 +232,13 @@ public class InGameState extends BaseState{
|
|||||||
setUpButtons();
|
setUpButtons();
|
||||||
|
|
||||||
// Set up the game world.
|
// Set up the game world.
|
||||||
gameWorld = GameGlobals.getGameWorld();
|
gameWorld = ScenarioGlobals.getGameWorld();
|
||||||
|
|
||||||
robotArmPositioningSystem = gameWorld.getSystem(RobotArmPositioningSystem.class);
|
robotArmPositioningSystem = gameWorld.getSystem(RobotArmPositioningSystem.class);
|
||||||
markerRenderingSystem = gameWorld.getSystem(MarkerRenderingSystem.class);
|
markerRenderingSystem = gameWorld.getSystem(MarkerRenderingSystem.class);
|
||||||
objectRenderingSystem = gameWorld.getSystem(ObjectRenderingSystem.class);
|
objectRenderingSystem = gameWorld.getSystem(ObjectRenderingSystem.class);
|
||||||
fadeEffectRenderingSystem = gameWorld.getSystem(FadeEffectRenderingSystem.class);
|
fadeEffectRenderingSystem = gameWorld.getSystem(FadeEffectRenderingSystem.class);
|
||||||
|
playerSystem = ScenarioGlobals.getPlayerSystem();
|
||||||
|
|
||||||
if(robotArmPositioningSystem == null || markerRenderingSystem == null || objectRenderingSystem == null || fadeEffectRenderingSystem == null)
|
if(robotArmPositioningSystem == null || markerRenderingSystem == null || objectRenderingSystem == null || fadeEffectRenderingSystem == null)
|
||||||
throw new IllegalStateException("One or more essential systems are null.");
|
throw new IllegalStateException("One or more essential systems are null.");
|
||||||
@@ -303,6 +306,11 @@ public class InGameState extends BaseState{
|
|||||||
perspectiveCamera.update(perspectiveCamera.projection);
|
perspectiveCamera.update(perspectiveCamera.projection);
|
||||||
|
|
||||||
// Update the game state.
|
// Update the game state.
|
||||||
|
if(controlMode == robot_control_mode_t.ARM_CONTROL)
|
||||||
|
gameWorld.getSystem(CollisionDetectionSystem.class).enableCollisions();
|
||||||
|
else
|
||||||
|
gameWorld.getSystem(CollisionDetectionSystem.class).disableCollisions();
|
||||||
|
|
||||||
gameWorld.setDelta(Gdx.graphics.getDeltaTime() * 1000);
|
gameWorld.setDelta(Gdx.graphics.getDeltaTime() * 1000);
|
||||||
gameWorld.getSystem(MarkerPositioningSystem.class).setMarkerData(data);
|
gameWorld.getSystem(MarkerPositioningSystem.class).setMarkerData(data);
|
||||||
gameWorld.process();
|
gameWorld.process();
|
||||||
@@ -436,6 +444,7 @@ public class InGameState extends BaseState{
|
|||||||
}
|
}
|
||||||
|
|
||||||
fadeEffectRenderingSystem.process();
|
fadeEffectRenderingSystem.process();
|
||||||
|
playerSystem.process();
|
||||||
|
|
||||||
data = null;
|
data = null;
|
||||||
}
|
}
|
||||||
@@ -494,7 +503,6 @@ public class InGameState extends BaseState{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onStateSet(){
|
public void onStateSet(){
|
||||||
gameWorld.getSystem(CollisionDetectionSystem.class).enableCollisions();
|
|
||||||
stateActive = true;
|
stateActive = true;
|
||||||
Gdx.input.setInputProcessor(this);
|
Gdx.input.setInputProcessor(this);
|
||||||
Gdx.input.setCatchBackKey(true);
|
Gdx.input.setCatchBackKey(true);
|
||||||
|
329
src/ve/ucv/ciens/ccg/nxtar/states/ScenarioEndSummaryState.java
Normal file
329
src/ve/ucv/ciens/ccg/nxtar/states/ScenarioEndSummaryState.java
Normal file
@@ -0,0 +1,329 @@
|
|||||||
|
/*
|
||||||
|
* 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.scenarios.ScenarioGlobals;
|
||||||
|
import ve.ucv.ciens.ccg.nxtar.scenarios.SummaryOverlayBase;
|
||||||
|
import ve.ucv.ciens.ccg.nxtar.systems.PlayerSystemBase;
|
||||||
|
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 ScenarioEndSummaryState 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 BitmapFont font;
|
||||||
|
|
||||||
|
// Summary overlay related fields.
|
||||||
|
PlayerSystemBase playerSystem;
|
||||||
|
SummaryOverlayBase summaryOverlay;
|
||||||
|
|
||||||
|
// Button touch helper fields.
|
||||||
|
private boolean continueButtonTouched;
|
||||||
|
private int continueButtonTouchPointer;
|
||||||
|
|
||||||
|
public ScenarioEndSummaryState(NxtARCore core) throws IllegalArgumentException{
|
||||||
|
TextButtonStyle textButtonStyle;
|
||||||
|
FreeTypeFontGenerator fontGenerator;
|
||||||
|
FreeTypeFontParameter fontParameters;
|
||||||
|
NinePatch buttonEnabled9p;
|
||||||
|
NinePatch buttonDisabled9p;
|
||||||
|
NinePatch buttonPressed9p;
|
||||||
|
|
||||||
|
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;
|
||||||
|
playerSystem = ScenarioGlobals.getPlayerSystem();
|
||||||
|
summaryOverlay = ScenarioGlobals.getScenarioSummaryOverlay();
|
||||||
|
|
||||||
|
// 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, playerSystem.getPlayerSummary());
|
||||||
|
|
||||||
|
// 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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@@ -17,36 +17,35 @@ package ve.ucv.ciens.ccg.nxtar.systems;
|
|||||||
|
|
||||||
import ve.ucv.ciens.ccg.nxtar.NxtARCore;
|
import ve.ucv.ciens.ccg.nxtar.NxtARCore;
|
||||||
import ve.ucv.ciens.ccg.nxtar.components.PlayerComponentBase;
|
import ve.ucv.ciens.ccg.nxtar.components.PlayerComponentBase;
|
||||||
import ve.ucv.ciens.ccg.nxtar.game.GameGlobals;
|
import ve.ucv.ciens.ccg.nxtar.scenarios.ScenarioGlobals;
|
||||||
|
import ve.ucv.ciens.ccg.nxtar.scenarios.SummaryBase;
|
||||||
|
|
||||||
import com.artemis.Aspect;
|
import com.artemis.Aspect;
|
||||||
import com.artemis.Entity;
|
|
||||||
import com.artemis.systems.EntityProcessingSystem;
|
import com.artemis.systems.EntityProcessingSystem;
|
||||||
|
import com.badlogic.gdx.utils.Disposable;
|
||||||
|
|
||||||
public abstract class PlayerSystemBase extends EntityProcessingSystem {
|
public abstract class PlayerSystemBase extends EntityProcessingSystem implements Disposable{
|
||||||
protected NxtARCore core;
|
protected NxtARCore core;
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public PlayerSystemBase(Class<? extends PlayerComponentBase> component, NxtARCore core){
|
public PlayerSystemBase(Class<? extends PlayerComponentBase> component){
|
||||||
super(Aspect.getAspectForAll(component));
|
super(Aspect.getAspectForAll(component));
|
||||||
|
}
|
||||||
|
|
||||||
if(component == null)
|
public abstract SummaryBase getPlayerSummary();
|
||||||
throw new IllegalArgumentException("Component is null.");
|
|
||||||
|
|
||||||
|
public final void setCore(NxtARCore core) throws IllegalArgumentException{
|
||||||
if(core == null)
|
if(core == null)
|
||||||
throw new IllegalArgumentException("Core is null.");
|
throw new IllegalArgumentException("Core is null.");
|
||||||
|
|
||||||
this.core = core;
|
this.core = core;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected final void finishGame(boolean victory){
|
protected final void finishGame(boolean victory) throws IllegalStateException{
|
||||||
// TODO: Switch to game over state.
|
if(core == null)
|
||||||
// TODO: Set game over state parameters.
|
throw new IllegalStateException("Core is null.");
|
||||||
GameGlobals.getEntityCreator().resetAllEntities();
|
|
||||||
core.nextState = NxtARCore.game_states_t.MAIN_MENU;
|
ScenarioGlobals.getEntityCreator().resetAllEntities();
|
||||||
|
core.nextState = NxtARCore.game_states_t.SCENARIO_END_SUMMARY;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected abstract void process(Entity e);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user