Added the player entity and it's logic to the world.
This commit is contained in:
@@ -29,6 +29,7 @@ import ve.ucv.ciens.ccg.nxtar.components.CollisionModelComponent;
|
|||||||
import ve.ucv.ciens.ccg.nxtar.components.EnvironmentComponent;
|
import ve.ucv.ciens.ccg.nxtar.components.EnvironmentComponent;
|
||||||
import ve.ucv.ciens.ccg.nxtar.components.GeometryComponent;
|
import ve.ucv.ciens.ccg.nxtar.components.GeometryComponent;
|
||||||
import ve.ucv.ciens.ccg.nxtar.components.MarkerCodeComponent;
|
import ve.ucv.ciens.ccg.nxtar.components.MarkerCodeComponent;
|
||||||
|
import ve.ucv.ciens.ccg.nxtar.components.PlayerComponentBase;
|
||||||
import ve.ucv.ciens.ccg.nxtar.components.RenderModelComponent;
|
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;
|
||||||
@@ -222,6 +223,7 @@ public class BombGameEntityCreator extends EntityCreatorBase{
|
|||||||
if(player == null){
|
if(player == null){
|
||||||
player = world.createEntity();
|
player = world.createEntity();
|
||||||
player.addComponent(new BombGamePlayerComponent(3));
|
player.addComponent(new BombGamePlayerComponent(3));
|
||||||
|
groupManager.add(player, PlayerComponentBase.PLAYER_GROUP);
|
||||||
player.addToWorld();
|
player.addToWorld();
|
||||||
}else{
|
}else{
|
||||||
player.getComponent(BombGamePlayerComponent.class).reset();
|
player.getComponent(BombGamePlayerComponent.class).reset();
|
||||||
|
|||||||
@@ -17,9 +17,11 @@ package ve.ucv.ciens.ccg.nxtar.systems;
|
|||||||
|
|
||||||
import ve.ucv.ciens.ccg.nxtar.components.AnimationComponent;
|
import ve.ucv.ciens.ccg.nxtar.components.AnimationComponent;
|
||||||
import ve.ucv.ciens.ccg.nxtar.components.BombGameObjectTypeComponent;
|
import ve.ucv.ciens.ccg.nxtar.components.BombGameObjectTypeComponent;
|
||||||
|
import ve.ucv.ciens.ccg.nxtar.components.BombGamePlayerComponent;
|
||||||
import ve.ucv.ciens.ccg.nxtar.components.CollisionDetectionComponent;
|
import ve.ucv.ciens.ccg.nxtar.components.CollisionDetectionComponent;
|
||||||
import ve.ucv.ciens.ccg.nxtar.components.FadeEffectComponent;
|
import ve.ucv.ciens.ccg.nxtar.components.FadeEffectComponent;
|
||||||
import ve.ucv.ciens.ccg.nxtar.components.MarkerCodeComponent;
|
import ve.ucv.ciens.ccg.nxtar.components.MarkerCodeComponent;
|
||||||
|
import ve.ucv.ciens.ccg.nxtar.components.PlayerComponentBase;
|
||||||
import ve.ucv.ciens.ccg.nxtar.components.VisibilityComponent;
|
import ve.ucv.ciens.ccg.nxtar.components.VisibilityComponent;
|
||||||
import ve.ucv.ciens.ccg.nxtar.entities.BombGameEntityCreator;
|
import ve.ucv.ciens.ccg.nxtar.entities.BombGameEntityCreator;
|
||||||
import ve.ucv.ciens.ccg.nxtar.utils.ProjectConstants;
|
import ve.ucv.ciens.ccg.nxtar.utils.ProjectConstants;
|
||||||
@@ -142,6 +144,7 @@ public class BombGameLogicSystem extends GameLogicSystemBase {
|
|||||||
if(wireType.type != BombGameObjectTypeComponent.BOMB_WIRE_1){
|
if(wireType.type != BombGameObjectTypeComponent.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();
|
||||||
}
|
}
|
||||||
|
|
||||||
disableBomb(marker.code);
|
disableBomb(marker.code);
|
||||||
@@ -189,6 +192,7 @@ public class BombGameLogicSystem extends GameLogicSystemBase {
|
|||||||
Gdx.app.log(TAG, CLASS_NAME + ".processCombinationBomb(): Combination bomb exploded.");
|
Gdx.app.log(TAG, CLASS_NAME + ".processCombinationBomb(): Combination bomb exploded.");
|
||||||
createFadeOutEffect();
|
createFadeOutEffect();
|
||||||
disableBomb(marker.code);
|
disableBomb(marker.code);
|
||||||
|
reducePlayerLivesByOne();
|
||||||
}else if(state.getValue() == combination_button_state_t.DISABLED.getValue()){
|
}else if(state.getValue() == combination_button_state_t.DISABLED.getValue()){
|
||||||
Gdx.app.log(TAG, CLASS_NAME + ".processCombinationBomb(): Combination bomb disabled.");
|
Gdx.app.log(TAG, CLASS_NAME + ".processCombinationBomb(): Combination bomb disabled.");
|
||||||
disableBomb(marker.code);
|
disableBomb(marker.code);
|
||||||
@@ -227,6 +231,7 @@ public class BombGameLogicSystem extends GameLogicSystemBase {
|
|||||||
if(Utils.isDeviceRollValid() && Math.abs(Gdx.input.getRoll()) > ProjectConstants.MAX_ABS_ROLL){
|
if(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();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Disable all related entities.
|
// Disable all related entities.
|
||||||
@@ -312,6 +317,30 @@ public class BombGameLogicSystem extends GameLogicSystemBase {
|
|||||||
return doorOpen;
|
return doorOpen;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>Updates the player's lives count.</p>
|
||||||
|
*/
|
||||||
|
private void reducePlayerLivesByOne(){
|
||||||
|
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.lives -= 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>
|
||||||
*
|
*
|
||||||
@@ -400,7 +429,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 BombGameObjectTypeComponent(BombGameObjectTypeComponent.FADE_EFFECT));
|
||||||
effect.addComponent(new FadeEffectComponent(false));
|
effect.addComponent(new FadeEffectComponent());
|
||||||
effect.addToWorld();
|
effect.addToWorld();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user