diff --git a/build.gradle b/build.gradle index c6f9945..db8b0e4 100644 --- a/build.gradle +++ b/build.gradle @@ -95,7 +95,7 @@ project(":core") { implementation 'commons-io:commons-io:2.8.0' api 'org.apache.commons:commons-lang3:3.13.0' api 'ch.qos.logback:logback-classic:1.4.12' - api "com.github.beverly-hills-money-gangster.Daikombat-server:net-client:15.0.0" + api "com.github.beverly-hills-money-gangster.Daikombat-server:net-client:16.0.0" api 'commons-validator:commons-validator:1.7' api 'org.apache.commons:commons-math3:3.6.1' compileOnly 'org.projectlombok:lombok:1.18.30' diff --git a/core/src/com/beverly/hills/money/gang/Configs.java b/core/src/com/beverly/hills/money/gang/Configs.java index 9498752..9881544 100644 --- a/core/src/com/beverly/hills/money/gang/Configs.java +++ b/core/src/com/beverly/hills/money/gang/Configs.java @@ -22,4 +22,6 @@ public interface Configs { int MAX_RECONNECTIONS = NumberUtils.toInt( System.getenv("DESKTOP_MAX_RECONNECTIONS"), 5); + int SPEED_BOOST = NumberUtils.toInt(System.getenv("DESKTOP_SPEED_BOOST"), 1); + } diff --git a/core/src/com/beverly/hills/money/gang/entities/enemies/EnemyPlayer.java b/core/src/com/beverly/hills/money/gang/entities/enemies/EnemyPlayer.java index 23380c7..b1c28c9 100644 --- a/core/src/com/beverly/hills/money/gang/entities/enemies/EnemyPlayer.java +++ b/core/src/com/beverly/hills/money/gang/entities/enemies/EnemyPlayer.java @@ -44,6 +44,13 @@ public class EnemyPlayer extends Enemy { @Getter private final String name; + @Getter + private final String enemyClass; + + @Getter + @Setter + private int hp; + private long movingAnimationUntil; private long shootingAnimationUntil; @@ -66,9 +73,13 @@ public EnemyPlayer(final Player player, final String name, final TexturesRegistry enemyTextureRegistry, final EnemyListeners enemyListeners, - final int speed) { + final int speed, + final int hp, + final String enemyClass) { super(position, screen, player, enemyListeners); + this.hp = hp; + this.enemyClass = enemyClass; this.enemyPlayerId = enemyPlayerId; lastDirection = direction; enemyTextures = new EnemyTextures(screen.getGame().getAssMan(), enemyTextureRegistry); diff --git a/core/src/com/beverly/hills/money/gang/entities/player/Player.java b/core/src/com/beverly/hills/money/gang/entities/player/Player.java index 01c3222..1bcf7a4 100644 --- a/core/src/com/beverly/hills/money/gang/entities/player/Player.java +++ b/core/src/com/beverly/hills/money/gang/entities/player/Player.java @@ -1,5 +1,7 @@ package com.beverly.hills.money.gang.entities.player; +import static com.beverly.hills.money.gang.Configs.SPEED_BOOST; + import com.badlogic.gdx.Gdx; import com.badlogic.gdx.Input; import com.badlogic.gdx.Input.Buttons; @@ -90,7 +92,7 @@ public Player(final GameScreen screen, final int speed, final Map weaponStats) { super(screen); - this.speed = speed; + this.speed = speed * SPEED_BOOST; screenWeapon = new ScreenWeapon(screen.getGame().getAssMan(), weaponStats); this.onMovementListener = onMovementListener; this.onAttackListener = onAttackListener; diff --git a/core/src/com/beverly/hills/money/gang/entities/player/PlayerFactory.java b/core/src/com/beverly/hills/money/gang/entities/player/PlayerFactory.java index 12c9c75..9ee9e4f 100644 --- a/core/src/com/beverly/hills/money/gang/entities/player/PlayerFactory.java +++ b/core/src/com/beverly/hills/money/gang/entities/player/PlayerFactory.java @@ -5,9 +5,11 @@ import com.beverly.hills.money.gang.network.LoadBalancedGameConnection; import com.beverly.hills.money.gang.proto.PushGameEventCommand; import com.beverly.hills.money.gang.proto.PushGameEventCommand.GameEventType; -import com.beverly.hills.money.gang.proto.PushGameEventCommand.WeaponType; +import com.beverly.hills.money.gang.proto.Vector; +import com.beverly.hills.money.gang.proto.WeaponType; import com.beverly.hills.money.gang.screens.PlayScreen; import com.beverly.hills.money.gang.screens.data.PlayerConnectionContextData; +import com.beverly.hills.money.gang.screens.ui.EnemyAim; import java.util.Optional; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -27,8 +29,8 @@ public static Player create( LOG.warn("Can't shoot while being teleported"); return; } - PushGameEventCommand.WeaponType weaponType = switch (playerWeapon.getWeapon()) { - case GAUNTLET -> PushGameEventCommand.WeaponType.PUNCH; + WeaponType weaponType = switch (playerWeapon.getWeapon()) { + case GAUNTLET -> WeaponType.PUNCH; case SHOTGUN -> WeaponType.SHOTGUN; case RAILGUN -> WeaponType.RAILGUN; case MINIGUN -> WeaponType.MINIGUN; @@ -46,10 +48,10 @@ public static Player create( .setPlayerId(playerConnectionContextData.getPlayerId()) .setSequence(screen.getActionSequence().incrementAndGet()) .setDirection( - PushGameEventCommand.Vector.newBuilder().setX(direction.x).setY(direction.y) + Vector.newBuilder().setX(direction.x).setY(direction.y) .build()) .setPosition( - PushGameEventCommand.Vector.newBuilder().setX(position.x).setY(position.y) + Vector.newBuilder().setX(position.x).setY(position.y) .build()) .setAffectedPlayerId(enemy.getEnemyPlayerId()) .setEventType(GameEventType.ATTACK) @@ -66,10 +68,10 @@ public static Player create( .orElse(0)) .setPlayerId(playerConnectionContextData.getPlayerId()) .setDirection( - PushGameEventCommand.Vector.newBuilder().setX(direction.x).setY(direction.y) + Vector.newBuilder().setX(direction.x).setY(direction.y) .build()) .setPosition( - PushGameEventCommand.Vector.newBuilder().setX(position.x).setY(position.y) + Vector.newBuilder().setX(position.x).setY(position.y) .build()) .setWeaponType(weaponType) .setEventType(GameEventType.ATTACK) @@ -78,7 +80,10 @@ public static Player create( }, enemy -> { if (!enemy.getEnemyEffects().isPowerUpActive(PowerUpType.INVISIBILITY)) { - screen.setEnemyAimName(enemy.getName()); + screen.setEnemyAim( + EnemyAim.builder().name(enemy.getName()).hp(enemy.getHp()) + .playerClass(enemy.getEnemyClass()) + .build()); } }, player -> { diff --git a/core/src/com/beverly/hills/money/gang/handler/PlayScreenGameConnectionHandler.java b/core/src/com/beverly/hills/money/gang/handler/PlayScreenGameConnectionHandler.java index 5b72314..62a8338 100644 --- a/core/src/com/beverly/hills/money/gang/handler/PlayScreenGameConnectionHandler.java +++ b/core/src/com/beverly/hills/money/gang/handler/PlayScreenGameConnectionHandler.java @@ -1,6 +1,7 @@ package com.beverly.hills.money.gang.handler; import static com.beverly.hills.money.gang.Constants.DEFAULT_ENEMY_Y; +import static com.beverly.hills.money.gang.proto.WeaponType.PUNCH; import com.badlogic.gdx.math.Vector2; import com.badlogic.gdx.math.Vector3; @@ -17,13 +18,16 @@ import com.beverly.hills.money.gang.entities.enemies.EnemyPlayerActionType; import com.beverly.hills.money.gang.entities.item.PowerUpType; import com.beverly.hills.money.gang.entities.ui.UILeaderBoard; +import com.beverly.hills.money.gang.proto.PlayerClass; +import com.beverly.hills.money.gang.proto.PlayerSkinColor; import com.beverly.hills.money.gang.proto.ServerResponse; import com.beverly.hills.money.gang.proto.ServerResponse.GameEvent.GameEventType; -import com.beverly.hills.money.gang.proto.ServerResponse.GameEvent.WeaponType; import com.beverly.hills.money.gang.proto.ServerResponse.GamePowerUp; import com.beverly.hills.money.gang.proto.ServerResponse.GamePowerUpType; +import com.beverly.hills.money.gang.proto.Vector; import com.beverly.hills.money.gang.registry.EnemiesRegistry; import com.beverly.hills.money.gang.screens.PlayScreen; +import com.beverly.hills.money.gang.screens.ui.selection.PlayerClassUISelection; import com.beverly.hills.money.gang.screens.ui.weapon.WeaponMapper; import com.beverly.hills.money.gang.utils.Converter; import java.util.Optional; @@ -157,7 +161,9 @@ private void handleSpawn(ServerResponse.GameEvent gameEvent) { createVector(gameEvent.getPlayer().getDirection()), playScreen, gameEvent.getPlayer().getPlayerName(), getEnemyTexture(gameEvent.getPlayer().getSkinColor()), createEnemyListeners(), - playScreen.getPlayerConnectionContextData().getSpeed()); + playScreen.getPlayerConnectionContextData().getSpeed(), + gameEvent.getPlayer().getHealth(), + createPlayerClass(gameEvent.getPlayer().getPlayerClass()).toString()); gameEvent.getPlayer().getActivePowerUpsList().forEach( gamePowerUp -> activateEnemyPowerUpOnSpawn( enemyPlayer, getPowerUpType(gamePowerUp.getType()), gamePowerUp.getLastsForMls())); @@ -188,13 +194,23 @@ private void handleSpawn(ServerResponse.GameEvent gameEvent) { } } + private PlayerClassUISelection createPlayerClass(PlayerClass playerClass) { + return switch (playerClass) { + case COMMONER -> PlayerClassUISelection.COMMONER; + case DRACULA_BERSERK -> PlayerClassUISelection.DRACULA_BERSERK; + case DEMON_TANK -> PlayerClassUISelection.DEMON_TANK; + case BEAST_WARRIOR -> PlayerClassUISelection.BEAST_WARRIOR; + default -> throw new IllegalArgumentException("Not supported class " + playerClass.name()); + }; + } + private void activateEnemyPowerUpOnSpawn(EnemyPlayer enemyPlayer, PowerUpType powerUpType, int lastsForMls) { enemyPlayer.getEnemyEffects().activatePowerUp(powerUpType, lastsForMls); playScreen.removePowerUp(powerUpType); } - private TexturesRegistry getEnemyTexture(ServerResponse.PlayerSkinColor playerSkinColor) { + private TexturesRegistry getEnemyTexture(PlayerSkinColor playerSkinColor) { return switch (playerSkinColor) { case BLUE -> TexturesRegistry.ENEMY_PLAYER_SPRITES_BLUE; case PURPLE -> TexturesRegistry.ENEMY_PLAYER_SPRITES_PURPLE; @@ -300,7 +316,7 @@ private void handleAttackMiss(ServerResponse.GameEvent gameEvent) { .enemyPlayerActionType(enemyPlayerActionType) .direction(Converter.convertToVector2(gameEvent.getPlayer().getDirection())) .onComplete(() -> { - if (gameEvent.getWeaponType() == WeaponType.PUNCH) { + if (gameEvent.getWeaponType() == PUNCH) { new TimeLimitedSound( playScreen.getGame().getAssMan() .getUserSettingSound(SoundRegistry.ENEMY_PUNCH_THROWN)) @@ -315,14 +331,17 @@ private void handleAttackMiss(ServerResponse.GameEvent gameEvent) { private void handleGetHit(ServerResponse.GameEvent gameEvent) { EnemyPlayerActionType enemyPlayerActionType = EnemyPlayerActionType.ATTACK; - // if I hit somebody, then do nothing. the animation is played one client immediately - - // if I get hit - if (gameEvent.getAffectedPlayer().getPlayerId() == playScreen.getPlayerConnectionContextData() + // if I hit somebody + if (gameEvent.getPlayer().getPlayerId() == playScreen.getPlayerConnectionContextData() .getPlayerId()) { - + enemiesRegistry.getEnemy(gameEvent.getAffectedPlayer().getPlayerId()) + .ifPresent(enemyPlayer -> enemyPlayer.setHp(gameEvent.getAffectedPlayer().getHealth())); + } else if (gameEvent.getAffectedPlayer().getPlayerId() + == playScreen.getPlayerConnectionContextData().getPlayerId()) { + // if I get hit enemiesRegistry.getEnemy(gameEvent.getPlayer().getPlayerId()) .ifPresent(enemyPlayer -> { + enemyPlayer.setHp(gameEvent.getPlayer().getHealth()); enemyPlayer.queueAction(EnemyPlayerAction.builder() .eventSequenceId(gameEvent.getSequence()) .enemyPlayerActionType(enemyPlayerActionType) @@ -338,23 +357,26 @@ private void handleGetHit(ServerResponse.GameEvent gameEvent) { }) .build()); }); - } else if (gameEvent.getPlayer().getPlayerId() != playScreen.getPlayerConnectionContextData() - .getPlayerId()) { - + } else { // enemies hitting each other enemiesRegistry.getEnemy(gameEvent.getPlayer().getPlayerId()) - .ifPresent(enemyPlayer -> enemyPlayer.queueAction(EnemyPlayerAction.builder() - .eventSequenceId(gameEvent.getSequence()) - .enemyPlayerActionType(enemyPlayerActionType) - .direction(Converter.convertToVector2(gameEvent.getPlayer().getDirection())) - .route(Converter.convertToVector2(gameEvent.getPlayer().getPosition())) - .onComplete( - () -> { - enemyPlayer.attack(WeaponMapper.getWeapon(gameEvent.getWeaponType()), false); - enemiesRegistry.getEnemy(gameEvent.getAffectedPlayer().getPlayerId()) - .ifPresent(EnemyPlayer::getHit); - }) - .build())); + .ifPresent(enemyPlayer -> { + enemyPlayer.setHp(gameEvent.getPlayer().getHealth()); + enemyPlayer.queueAction(EnemyPlayerAction.builder() + .eventSequenceId(gameEvent.getSequence()) + .enemyPlayerActionType(enemyPlayerActionType) + .direction(Converter.convertToVector2(gameEvent.getPlayer().getDirection())) + .route(Converter.convertToVector2(gameEvent.getPlayer().getPosition())) + .onComplete( + () -> { + enemyPlayer.attack(WeaponMapper.getWeapon(gameEvent.getWeaponType()), false); + enemiesRegistry.getEnemy(gameEvent.getAffectedPlayer().getPlayerId()) + .ifPresent(EnemyPlayer::getHit); + }) + .build()); + }); + enemiesRegistry.getEnemy(gameEvent.getAffectedPlayer().getPlayerId()) + .ifPresent(enemyPlayer -> enemyPlayer.setHp(gameEvent.getAffectedPlayer().getHealth())); } } @@ -474,7 +496,7 @@ private Enemy.EnemyListeners createEnemyListeners() { ).build(); } - private static Vector2 createVector(ServerResponse.Vector serverVector) { + private static Vector2 createVector(Vector serverVector) { return new Vector2(serverVector.getX(), serverVector.getY()); } } \ No newline at end of file diff --git a/core/src/com/beverly/hills/money/gang/screens/JoinGameScreen.java b/core/src/com/beverly/hills/money/gang/screens/JoinGameScreen.java index 554daba..6f89532 100644 --- a/core/src/com/beverly/hills/money/gang/screens/JoinGameScreen.java +++ b/core/src/com/beverly/hills/money/gang/screens/JoinGameScreen.java @@ -7,8 +7,8 @@ import com.beverly.hills.money.gang.proto.JoinGameCommand; import com.beverly.hills.money.gang.proto.MergeConnectionCommand; import com.beverly.hills.money.gang.proto.PlayerClass; +import com.beverly.hills.money.gang.proto.PlayerSkinColor; import com.beverly.hills.money.gang.proto.ServerResponse; -import com.beverly.hills.money.gang.proto.SkinColorSelection; import com.beverly.hills.money.gang.screens.data.ConnectGameData; import com.beverly.hills.money.gang.screens.data.PlayerConnectionContextData; import com.beverly.hills.money.gang.screens.ui.selection.PlayerClassUISelection; @@ -52,7 +52,7 @@ public void show() { var joinGameRequestBuilder = JoinGameCommand.newBuilder() .setVersion(ClientConfig.VERSION) .setGameId(Configs.GAME_ID) - .setSkin(creatSkinColorSelection(connectGameData.getSkinUISelection())) + .setSkin(createSkinColorSelection(connectGameData.getSkinUISelection())) .setPlayerClass(createPlayerClass(connectGameData.getPlayerClassUISelection())) .setPlayerName(connectGameData.getPlayerName()); Optional.ofNullable(connectGameData.getPlayerIdToRecover()) @@ -62,14 +62,14 @@ public void show() { } - private SkinColorSelection creatSkinColorSelection(SkinUISelection skinUISelection) { + private PlayerSkinColor createSkinColorSelection(SkinUISelection skinUISelection) { return switch (skinUISelection) { - case BLUE -> SkinColorSelection.BLUE; - case YELLOW -> SkinColorSelection.YELLOW; - case ORANGE -> SkinColorSelection.ORANGE; - case GREEN -> SkinColorSelection.GREEN; - case PINK -> SkinColorSelection.PINK; - case PURPLE -> SkinColorSelection.PURPLE; + case BLUE -> PlayerSkinColor.BLUE; + case YELLOW -> PlayerSkinColor.YELLOW; + case ORANGE -> PlayerSkinColor.ORANGE; + case GREEN -> PlayerSkinColor.GREEN; + case PINK -> PlayerSkinColor.PINK; + case PURPLE -> PlayerSkinColor.PURPLE; }; } diff --git a/core/src/com/beverly/hills/money/gang/screens/MainMenuScreen.java b/core/src/com/beverly/hills/money/gang/screens/MainMenuScreen.java index 9a7df2c..b33b9a4 100644 --- a/core/src/com/beverly/hills/money/gang/screens/MainMenuScreen.java +++ b/core/src/com/beverly/hills/money/gang/screens/MainMenuScreen.java @@ -51,7 +51,8 @@ public void handleInput(final float delta) { } } else if (Gdx.input.isKeyJustPressed(Input.Keys.ESCAPE)) { - Gdx.app.exit(); + removeAllEntities(); + getGame().setScreen(new SureExitScreen(getGame())); } else if (Gdx.input.isKeyJustPressed(Input.Keys.UP)) { menuSelection.next(); dingSound1.play(Constants.DEFAULT_SFX_VOLUME); diff --git a/core/src/com/beverly/hills/money/gang/screens/PlayScreen.java b/core/src/com/beverly/hills/money/gang/screens/PlayScreen.java index b8fd7ee..58e3e2a 100644 --- a/core/src/com/beverly/hills/money/gang/screens/PlayScreen.java +++ b/core/src/com/beverly/hills/money/gang/screens/PlayScreen.java @@ -36,7 +36,9 @@ import com.beverly.hills.money.gang.proto.PushChatEventCommand; import com.beverly.hills.money.gang.proto.PushGameEventCommand; import com.beverly.hills.money.gang.proto.PushGameEventCommand.GameEventType; +import com.beverly.hills.money.gang.proto.Vector; import com.beverly.hills.money.gang.screens.data.PlayerConnectionContextData; +import com.beverly.hills.money.gang.screens.ui.EnemyAim; import com.beverly.hills.money.gang.screens.ui.selection.ActivePlayUISelection; import com.beverly.hills.money.gang.screens.ui.selection.DeadPlayUISelection; import com.beverly.hills.money.gang.screens.ui.selection.UISelection; @@ -52,6 +54,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; +// TODO make killer log message 64 @Getter public class PlayScreen extends GameScreen { @@ -66,7 +69,7 @@ public class PlayScreen extends GameScreen { private static final float BLOOD_OVERLAY_ALPHA_SWITCH = 0.5f; private final TextureRegion texRegBloodOverlay, texRegBlackOverlay; private final Environment env; - private String enemyAimName; + private EnemyAim enemyAim; private final TextInputProcessor chatTextInputProcessor; private final BitmapFont guiFont64; private final BitmapFont guiFont32; @@ -224,9 +227,9 @@ public void spawnTeleport(int teleportId, Vector2 position) { .orElse(0)) .setPlayerId(playerConnectionContextData.getPlayerId()) .setEventType(GameEventType.TELEPORT) - .setPosition(PushGameEventCommand.Vector.newBuilder() + .setPosition(Vector.newBuilder() .setX(currentPosition.x).setY(currentPosition.y).build()) - .setDirection(PushGameEventCommand.Vector.newBuilder() + .setDirection(Vector.newBuilder() .setX(currentDirection.x).setY(currentDirection.y).build()) .setGameId(Configs.GAME_ID) .setTeleportId(teleportId) @@ -256,9 +259,9 @@ public void spawnPowerUp(PowerUpType powerUpType, Vector2 position) { .setPlayerId(playerConnectionContextData.getPlayerId()) .setEventType(powerUpType.getPickType()) .setGameId(Configs.GAME_ID) - .setPosition(PushGameEventCommand.Vector.newBuilder() + .setPosition(Vector.newBuilder() .setX(currentPosition.x).setY(currentPosition.y).build()) - .setDirection(PushGameEventCommand.Vector.newBuilder() + .setDirection(Vector.newBuilder() .setX(currentDirection.x).setY(currentDirection.y).build()) .build()); removePowerUp(powerUpType); @@ -405,9 +408,9 @@ public void sendCurrentPlayerPosition() { .setPlayerId(playerConnectionContextData.getPlayerId()) .setEventType(PushGameEventCommand.GameEventType.MOVE) .setGameId(Configs.GAME_ID) - .setPosition(PushGameEventCommand.Vector.newBuilder() + .setPosition(Vector.newBuilder() .setX(currentPosition.x).setY(currentPosition.y).build()) - .setDirection(PushGameEventCommand.Vector.newBuilder() + .setDirection(Vector.newBuilder() .setX(currentDirection.x).setY(currentDirection.y).build()) .build()); setTimeToSendMoves(); @@ -458,7 +461,7 @@ public void render(final float delta) { powerUpEffect(Color.SKY, PowerUpType.QUAD_DAMAGE); } else if (getPlayer().getPlayerEffects().isPowerUpActive(PowerUpType.DEFENCE)) { powerUpEffect(Color.LIME, PowerUpType.DEFENCE); - } else if (getPlayer().getPlayerEffects().isPowerUpActive(PowerUpType.INVISIBILITY)) { + } else if (getPlayer().getPlayerEffects().isPowerUpActive(PowerUpType.INVISIBILITY)) { powerUpEffect(Color.WHITE, PowerUpType.INVISIBILITY); } } @@ -479,8 +482,8 @@ public void render(final float delta) { if (!getPlayer().isDead()) { if (myPlayerKillLog.hasKillerMessage()) { String killerMessage = myPlayerKillLog.getKillerMessage(); - GlyphLayout glyphLayoutKillerMessage = new GlyphLayout(guiFont32, killerMessage); - guiFont32.draw(getGame().getBatch(), killerMessage, + GlyphLayout glyphLayoutKillerMessage = new GlyphLayout(guiFont64, killerMessage); + guiFont64.draw(getGame().getBatch(), killerMessage, getViewport().getWorldWidth() / 2f - glyphLayoutKillerMessage.width / 2f, getViewport().getWorldHeight() / 2f - glyphLayoutKillerMessage.height / 2f + 128); } @@ -502,19 +505,35 @@ public void render(final float delta) { 128 - 32 + 64 + glyphLayoutChatLog.height); } - if (enemyAimName != null) { - GlyphLayout enemyNameGlyph = new GlyphLayout(guiFont32, enemyAimName); + if (enemyAim != null) { + guiFont32.setColor(1, 1, 1, 0.8f); - guiFont32.draw(getGame().getBatch(), enemyAimName, - getViewport().getWorldWidth() / 2f - enemyNameGlyph.width / 2f, - getViewport().getWorldHeight() / 2f - (enemyNameGlyph.height / 2f) + 32); - enemyAimName = null; + guiFont64.setColor(1, 1, 1, 0.8f); + + GlyphLayout glyphName = new GlyphLayout(guiFont64, enemyAim.getName()); + guiFont64.draw(getGame().getBatch(), enemyAim.getName(), + getViewport().getWorldWidth() / 2f - glyphName.width / 2f, + getViewport().getWorldHeight() / 2f - (glyphName.height / 2f) + 64); + GlyphLayout glyphClass = new GlyphLayout(guiFont32, enemyAim.getPlayerClass()); + guiFont32.draw(getGame().getBatch(), enemyAim.getPlayerClass(), + getViewport().getWorldWidth() / 2f - glyphClass.width / 2f, + getViewport().getWorldHeight() / 2f - (glyphClass.height / 2f) + 64 - 32); + GlyphLayout glyphHP = new GlyphLayout(guiFont32, enemyAim.getHp()); + guiFont32.draw(getGame().getBatch(), enemyAim.getHp(), + getViewport().getWorldWidth() / 2f - glyphHP.width / 2f, + getViewport().getWorldHeight() / 2f - (glyphHP.height / 2f) + 64 - 32 - 16); + + enemyAim = null; guiFont32.setColor(1, 1, 1, 1); + guiFont64.setColor(1, 1, 1, 1); } getGame().getBatch().setColor(1, 1, 1, 1); // Never cover HUD in blood. if (!getPlayer().isDead()) { - guiFont64.draw(getGame().getBatch(), getPlayer().getCurrentHP() + " HP", 32, 128 - 32); + guiFont64.draw(getGame().getBatch(), + getPlayer().getCurrentHP() + " HP | " + playerConnectionContextData.getConnectGameData() + .getPlayerName() + " | " + playerConnectionContextData.getConnectGameData() + .getPlayerClassUISelection().toString(), 32, 128 - 32); guiFont64.draw(getGame().getBatch(), "+", getViewport().getWorldWidth() / 2f - glyphLayoutAim.width / 2f, getViewport().getWorldHeight() / 2f - glyphLayoutAim.height / 2f); @@ -665,7 +684,7 @@ public void dispose() { gameConnection.disconnect(); } - public void setEnemyAimName(String name) { - this.enemyAimName = name; + public void setEnemyAim(EnemyAim enemyAim) { + this.enemyAim = enemyAim; } } diff --git a/core/src/com/beverly/hills/money/gang/screens/SureExitScreen.java b/core/src/com/beverly/hills/money/gang/screens/SureExitScreen.java new file mode 100644 index 0000000..2e924c9 --- /dev/null +++ b/core/src/com/beverly/hills/money/gang/screens/SureExitScreen.java @@ -0,0 +1,74 @@ +package com.beverly.hills.money.gang.screens; + +import com.badlogic.gdx.Gdx; +import com.badlogic.gdx.Input; +import com.badlogic.gdx.graphics.g2d.BitmapFont; +import com.badlogic.gdx.graphics.g2d.GlyphLayout; +import com.beverly.hills.money.gang.Constants; +import com.beverly.hills.money.gang.DaiKombatGame; +import com.beverly.hills.money.gang.assets.managers.registry.FontRegistry; +import com.beverly.hills.money.gang.assets.managers.registry.SoundRegistry; +import com.beverly.hills.money.gang.assets.managers.sound.UserSettingSound; +import com.beverly.hills.money.gang.screens.ui.selection.SureExitUISelection; +import com.beverly.hills.money.gang.screens.ui.selection.UISelection; + +public class SureExitScreen extends AbstractMainMenuScreen { + + private final BitmapFont guiFont64; + private final UserSettingSound boomSound1; + private final UserSettingSound dingSound1; + + private static final String SURE_EXIT_MSG = "SURE WANT TO QUIT?"; + private final UISelection selection = new UISelection<>( + SureExitUISelection.values()); + + + public SureExitScreen(final DaiKombatGame game) { + super(game); + guiFont64 = game.getAssMan().getFont(FontRegistry.FONT_64); + + boomSound1 = game.getAssMan().getUserSettingSound(SoundRegistry.BOOM_1); + dingSound1 = game.getAssMan().getUserSettingSound(SoundRegistry.DING_1); + showLogo = false; + } + + @Override + public void handleInput(final float delta) { + + if (Gdx.input.isKeyJustPressed(Input.Keys.ENTER)) { + boomSound1.play(Constants.DEFAULT_SFX_VOLUME); + switch (selection.getSelectedOption()) { + case YES -> Gdx.app.exit(); + case NO -> { + removeAllEntities(); + getGame().setScreen(new MainMenuScreen(getGame())); + } + } + } else if (Gdx.input.isKeyJustPressed(Input.Keys.ESCAPE)) { + Gdx.app.exit(); + } else if (Gdx.input.isKeyJustPressed(Input.Keys.UP)) { + selection.next(); + dingSound1.play(Constants.DEFAULT_SFX_VOLUME); + } else if (Gdx.input.isKeyJustPressed(Input.Keys.DOWN)) { + selection.prev(); + dingSound1.play(Constants.DEFAULT_SFX_VOLUME); + } + } + + + @Override + public void render(final float delta) { + super.render(delta); + getGame().getBatch().begin(); + + GlyphLayout glyphLayoutEnterYourClass = new GlyphLayout(guiFont64, SURE_EXIT_MSG); + guiFont64.draw(getGame().getBatch(), SURE_EXIT_MSG, + getViewport().getWorldWidth() / 2f - glyphLayoutEnterYourClass.width / 2f, + getViewport().getWorldHeight() / 2f - glyphLayoutEnterYourClass.height / 2f + - Constants.LOGO_INDENT + 64); + + selection.render(guiFont64, this, Constants.LOGO_INDENT); + getGame().getBatch().end(); + } + +} diff --git a/core/src/com/beverly/hills/money/gang/screens/ui/EnemyAim.java b/core/src/com/beverly/hills/money/gang/screens/ui/EnemyAim.java new file mode 100644 index 0000000..590b38f --- /dev/null +++ b/core/src/com/beverly/hills/money/gang/screens/ui/EnemyAim.java @@ -0,0 +1,21 @@ +package com.beverly.hills.money.gang.screens.ui; + + +import lombok.Builder; +import lombok.Getter; + +@Builder + +public class EnemyAim { + + @Getter + private final String name; + @Getter + private final String playerClass; + private final int hp; + + public String getHp() { + return hp + " HP"; + } + +} diff --git a/core/src/com/beverly/hills/money/gang/screens/ui/selection/SureExitUISelection.java b/core/src/com/beverly/hills/money/gang/screens/ui/selection/SureExitUISelection.java new file mode 100644 index 0000000..444ab13 --- /dev/null +++ b/core/src/com/beverly/hills/money/gang/screens/ui/selection/SureExitUISelection.java @@ -0,0 +1,21 @@ +package com.beverly.hills.money.gang.screens.ui.selection; + +import lombok.Getter; + +public enum SureExitUISelection { + YES("YES, QUIT"), NO("NO, KEEP GAMING"); + + @Getter + private final String title; + + SureExitUISelection(String title) { + this.title = title; + } + + + @Override + public String toString() { + return this.title; + } + +} diff --git a/core/src/com/beverly/hills/money/gang/screens/ui/weapon/WeaponMapper.java b/core/src/com/beverly/hills/money/gang/screens/ui/weapon/WeaponMapper.java index 472d4fa..2313781 100644 --- a/core/src/com/beverly/hills/money/gang/screens/ui/weapon/WeaponMapper.java +++ b/core/src/com/beverly/hills/money/gang/screens/ui/weapon/WeaponMapper.java @@ -1,10 +1,10 @@ package com.beverly.hills.money.gang.screens.ui.weapon; -import com.beverly.hills.money.gang.proto.ServerResponse.GameEvent; +import com.beverly.hills.money.gang.proto.WeaponType; public interface WeaponMapper { - static Weapon getWeapon(GameEvent.WeaponType weaponType) { + static Weapon getWeapon(WeaponType weaponType) { return switch (weaponType) { case PUNCH -> Weapon.GAUNTLET; case SHOTGUN -> Weapon.SHOTGUN; diff --git a/core/src/com/beverly/hills/money/gang/utils/Converter.java b/core/src/com/beverly/hills/money/gang/utils/Converter.java index b054d0c..a14c250 100644 --- a/core/src/com/beverly/hills/money/gang/utils/Converter.java +++ b/core/src/com/beverly/hills/money/gang/utils/Converter.java @@ -2,11 +2,12 @@ import com.badlogic.gdx.math.Vector2; import com.beverly.hills.money.gang.proto.ServerResponse; +import com.beverly.hills.money.gang.proto.Vector; public interface Converter { - static Vector2 convertToVector2(ServerResponse.Vector vector) { + static Vector2 convertToVector2(Vector vector) { return new Vector2(vector.getX(), vector.getY()); } } diff --git a/manual-testing-cases.html b/manual-testing-cases.html index 9a9659b..b621bd5 100644 --- a/manual-testing-cases.html +++ b/manual-testing-cases.html @@ -175,6 +175,13 @@

All tests must be performed against a remote gamer server

+ + Play screen + Player join the game with a 5x speed boost (DESKTOP_SPEED_BOOST=5). After running on the + map, the player is disconnected from the server for cheating. + + + Play screen 2 players join the game. Player 1 kills player 2 three times. After that, player 2 kills