From 88330d16406538fe93e780580513bfb963a96e58 Mon Sep 17 00:00:00 2001 From: Martin Schmidt Date: Tue, 18 Jun 2024 11:36:33 +0200 Subject: [PATCH] chore: apply spotless --- .../main/de/dhbw/tinf22b6/UnderwatchGame.java | 2 -- .../de/dhbw/tinf22b6/gameobject/Player.java | 2 -- .../tinf22b6/gameobject/bullet/Bullet.java | 5 ---- .../tinf22b6/gameobject/bullet/MPBullet.java | 2 +- .../gameobject/bullet/PlayerBullet.java | 1 - .../gameobject/bullet/SniperBullet.java | 10 +++---- .../dhbw/tinf22b6/gameobject/enemy/Enemy.java | 3 -- .../gameobject/interaction/DamageBoost.java | 9 +++--- .../gameobject/interaction/WeaponBox.java | 2 +- .../de/dhbw/tinf22b6/util/EntitySystem.java | 2 -- .../dhbw/tinf22b6/util/PlayerStatistics.java | 3 +- .../src/main/de/dhbw/tinf22b6/weapon/M4.java | 5 +++- .../src/main/de/dhbw/tinf22b6/weapon/MP7.java | 25 ++++++++-------- .../main/de/dhbw/tinf22b6/weapon/Shotgun.java | 5 +++- .../main/de/dhbw/tinf22b6/weapon/Sniper.java | 29 +++++++++---------- .../main/de/dhbw/tinf22b6/weapon/Weapon.java | 5 ++-- .../dhbw/tinf22b6/world/WorldController.java | 10 +++---- 17 files changed, 55 insertions(+), 65 deletions(-) diff --git a/game/core/src/main/de/dhbw/tinf22b6/UnderwatchGame.java b/game/core/src/main/de/dhbw/tinf22b6/UnderwatchGame.java index 58b8a40..7116fb6 100644 --- a/game/core/src/main/de/dhbw/tinf22b6/UnderwatchGame.java +++ b/game/core/src/main/de/dhbw/tinf22b6/UnderwatchGame.java @@ -1,8 +1,6 @@ package de.dhbw.tinf22b6; -import com.badlogic.gdx.Application; import com.badlogic.gdx.Game; -import com.badlogic.gdx.Gdx; import com.badlogic.gdx.assets.AssetManager; import de.dhbw.tinf22b6.screen.MenuScreen; import de.dhbw.tinf22b6.util.Assets; diff --git a/game/core/src/main/de/dhbw/tinf22b6/gameobject/Player.java b/game/core/src/main/de/dhbw/tinf22b6/gameobject/Player.java index 3172e5d..df965a6 100644 --- a/game/core/src/main/de/dhbw/tinf22b6/gameobject/Player.java +++ b/game/core/src/main/de/dhbw/tinf22b6/gameobject/Player.java @@ -229,8 +229,6 @@ public void shoot() { PlayerStatistics.instance.getCurrentWeapon().shoot(); } - - public Vector2 getMotionVector() { return motionVector; } diff --git a/game/core/src/main/de/dhbw/tinf22b6/gameobject/bullet/Bullet.java b/game/core/src/main/de/dhbw/tinf22b6/gameobject/bullet/Bullet.java index 3c024dd..10a4805 100644 --- a/game/core/src/main/de/dhbw/tinf22b6/gameobject/bullet/Bullet.java +++ b/game/core/src/main/de/dhbw/tinf22b6/gameobject/bullet/Bullet.java @@ -5,14 +5,9 @@ import com.badlogic.gdx.graphics.g2d.Batch; import com.badlogic.gdx.math.Vector2; -import com.badlogic.gdx.physics.box2d.FixtureDef; -import com.badlogic.gdx.physics.box2d.PolygonShape; -import com.badlogic.gdx.physics.box2d.World; import de.dhbw.tinf22b6.gameobject.GameObject; import de.dhbw.tinf22b6.util.Constants; import de.dhbw.tinf22b6.util.EntitySystem; -import de.dhbw.tinf22b6.world.Box2dWorld; -import de.dhbw.tinf22b6.world.WorldParser; public abstract class Bullet extends GameObject { protected final int damage; diff --git a/game/core/src/main/de/dhbw/tinf22b6/gameobject/bullet/MPBullet.java b/game/core/src/main/de/dhbw/tinf22b6/gameobject/bullet/MPBullet.java index cf60c05..f09fba1 100644 --- a/game/core/src/main/de/dhbw/tinf22b6/gameobject/bullet/MPBullet.java +++ b/game/core/src/main/de/dhbw/tinf22b6/gameobject/bullet/MPBullet.java @@ -8,4 +8,4 @@ public MPBullet(Vector2 position, float angle, int damage, short mask) { this.speed = 3; this.range = 1.5f; } -} \ No newline at end of file +} diff --git a/game/core/src/main/de/dhbw/tinf22b6/gameobject/bullet/PlayerBullet.java b/game/core/src/main/de/dhbw/tinf22b6/gameobject/bullet/PlayerBullet.java index 68ce5d5..7d54405 100644 --- a/game/core/src/main/de/dhbw/tinf22b6/gameobject/bullet/PlayerBullet.java +++ b/game/core/src/main/de/dhbw/tinf22b6/gameobject/bullet/PlayerBullet.java @@ -7,5 +7,4 @@ public class PlayerBullet extends Bullet { public PlayerBullet(Vector2 position, float angle, int damage, short mask) { super("bullet7x13", position, angle, damage, mask); } - } diff --git a/game/core/src/main/de/dhbw/tinf22b6/gameobject/bullet/SniperBullet.java b/game/core/src/main/de/dhbw/tinf22b6/gameobject/bullet/SniperBullet.java index 25431fd..eb5384a 100644 --- a/game/core/src/main/de/dhbw/tinf22b6/gameobject/bullet/SniperBullet.java +++ b/game/core/src/main/de/dhbw/tinf22b6/gameobject/bullet/SniperBullet.java @@ -3,9 +3,9 @@ import com.badlogic.gdx.math.Vector2; public class SniperBullet extends Bullet { - public SniperBullet(Vector2 position, float angle, int damage, short mask) { - super("bullet7x13", position, angle, damage, mask); - this.speed = 10; - this.range = 5; - } + public SniperBullet(Vector2 position, float angle, int damage, short mask) { + super("bullet7x13", position, angle, damage, mask); + this.speed = 10; + this.range = 5; + } } diff --git a/game/core/src/main/de/dhbw/tinf22b6/gameobject/enemy/Enemy.java b/game/core/src/main/de/dhbw/tinf22b6/gameobject/enemy/Enemy.java index c40e1db..09e228f 100644 --- a/game/core/src/main/de/dhbw/tinf22b6/gameobject/enemy/Enemy.java +++ b/game/core/src/main/de/dhbw/tinf22b6/gameobject/enemy/Enemy.java @@ -15,7 +15,6 @@ import com.badlogic.gdx.graphics.Pixmap; import com.badlogic.gdx.graphics.Texture; import com.badlogic.gdx.graphics.g2d.Batch; -import com.badlogic.gdx.math.Rectangle; import com.badlogic.gdx.math.Vector2; import com.badlogic.gdx.physics.box2d.BodyDef; import com.badlogic.gdx.physics.box2d.FixtureDef; @@ -25,7 +24,6 @@ import de.dhbw.tinf22b6.ai.EnemySteeringBehaviour; import de.dhbw.tinf22b6.gameobject.Direction; import de.dhbw.tinf22b6.gameobject.Player; -import de.dhbw.tinf22b6.gameobject.interaction.AmmoBox; import de.dhbw.tinf22b6.util.Constants; import de.dhbw.tinf22b6.util.EntitySystem; import de.dhbw.tinf22b6.util.PlayerStatistics; @@ -37,7 +35,6 @@ import de.dhbw.tinf22b6.world.tiled.FlatTiledNode; import de.dhbw.tinf22b6.world.tiled.TiledMetricHeuristic; import de.dhbw.tinf22b6.world.tiled.TiledSmoothableGraphPath; -import java.util.concurrent.CompletableFuture; public abstract class Enemy extends MobGameObject implements Steerable { private static final String TAG = Enemy.class.getName(); diff --git a/game/core/src/main/de/dhbw/tinf22b6/gameobject/interaction/DamageBoost.java b/game/core/src/main/de/dhbw/tinf22b6/gameobject/interaction/DamageBoost.java index 53c63f7..06421c5 100644 --- a/game/core/src/main/de/dhbw/tinf22b6/gameobject/interaction/DamageBoost.java +++ b/game/core/src/main/de/dhbw/tinf22b6/gameobject/interaction/DamageBoost.java @@ -1,6 +1,5 @@ package de.dhbw.tinf22b6.gameobject.interaction; -import com.badlogic.gdx.Gdx; import com.badlogic.gdx.math.Rectangle; import com.badlogic.gdx.math.Vector2; import de.dhbw.tinf22b6.gameobject.Player; @@ -15,9 +14,9 @@ public DamageBoost(Vector2 position, Rectangle rectangle) { @Override public void activate() { super.activate(); -// Gdx.audio -// .newSound(Gdx.files.internal("sfx/damage_boost.mp3")) -// .play(Gdx.app.getPreferences("Controls").getFloat("sfx")); + // Gdx.audio + // .newSound(Gdx.files.internal("sfx/damage_boost.mp3")) + // .play(Gdx.app.getPreferences("Controls").getFloat("sfx")); } @Override @@ -25,4 +24,4 @@ public void interact(Player player) { PlayerStatistics.instance.addDamageModifier(0.2f); super.interact(player); } -} \ No newline at end of file +} diff --git a/game/core/src/main/de/dhbw/tinf22b6/gameobject/interaction/WeaponBox.java b/game/core/src/main/de/dhbw/tinf22b6/gameobject/interaction/WeaponBox.java index fc6455b..fd030c2 100644 --- a/game/core/src/main/de/dhbw/tinf22b6/gameobject/interaction/WeaponBox.java +++ b/game/core/src/main/de/dhbw/tinf22b6/gameobject/interaction/WeaponBox.java @@ -30,4 +30,4 @@ public void interact(Player player) { super.interact(player); } } -} \ No newline at end of file +} diff --git a/game/core/src/main/de/dhbw/tinf22b6/util/EntitySystem.java b/game/core/src/main/de/dhbw/tinf22b6/util/EntitySystem.java index 9241220..f7c27c1 100644 --- a/game/core/src/main/de/dhbw/tinf22b6/util/EntitySystem.java +++ b/game/core/src/main/de/dhbw/tinf22b6/util/EntitySystem.java @@ -5,7 +5,6 @@ import de.dhbw.tinf22b6.gameobject.GameObject; import de.dhbw.tinf22b6.gameobject.Player; import de.dhbw.tinf22b6.gameobject.bullet.Bullet; - import java.util.ArrayList; import java.util.Collections; import java.util.List; @@ -47,7 +46,6 @@ public List getSyncBulletsToBeCreated() { return syncBulletsToBeCreated; } - public void add(GameObject object) { this.gameObjects.add(object); } diff --git a/game/core/src/main/de/dhbw/tinf22b6/util/PlayerStatistics.java b/game/core/src/main/de/dhbw/tinf22b6/util/PlayerStatistics.java index ea49e9d..09f717f 100644 --- a/game/core/src/main/de/dhbw/tinf22b6/util/PlayerStatistics.java +++ b/game/core/src/main/de/dhbw/tinf22b6/util/PlayerStatistics.java @@ -3,7 +3,6 @@ import com.badlogic.gdx.Gdx; import com.badlogic.gdx.math.Vector2; import de.dhbw.tinf22b6.weapon.*; - import java.util.ArrayList; import java.util.List; @@ -152,9 +151,11 @@ public Vector2 getStartLocation() { public void setStartLocation(Vector2 startLocation) { this.startLocation = startLocation; } + public void addDamageModifier(float damageModifier) { this.damageModifier += damageModifier; } + public float getDamageModifier() { return damageModifier; } diff --git a/game/core/src/main/de/dhbw/tinf22b6/weapon/M4.java b/game/core/src/main/de/dhbw/tinf22b6/weapon/M4.java index eb3b283..375b4ec 100644 --- a/game/core/src/main/de/dhbw/tinf22b6/weapon/M4.java +++ b/game/core/src/main/de/dhbw/tinf22b6/weapon/M4.java @@ -22,7 +22,10 @@ public boolean shoot() { float angle = EntitySystem.instance.getPlayer().getAngle(); Vector2 pos = EntitySystem.instance.getPlayer().getPos(); EntitySystem.instance.add(new PlayerBullet( - new Vector2(pos.x + 15 / 2f, pos.y + 5), angle, this.getDamage(), Constants.WEAPON_BIT)); + new Vector2(pos.x + 15 / 2f, pos.y + 5), + angle, + this.getDamage(), + Constants.WEAPON_BIT)); } catch (InterruptedException e) { throw new RuntimeException(e); } diff --git a/game/core/src/main/de/dhbw/tinf22b6/weapon/MP7.java b/game/core/src/main/de/dhbw/tinf22b6/weapon/MP7.java index 3c8414a..2330994 100644 --- a/game/core/src/main/de/dhbw/tinf22b6/weapon/MP7.java +++ b/game/core/src/main/de/dhbw/tinf22b6/weapon/MP7.java @@ -3,7 +3,6 @@ import com.badlogic.gdx.graphics.g2d.Animation; import com.badlogic.gdx.math.Vector2; import de.dhbw.tinf22b6.gameobject.bullet.MPBullet; -import de.dhbw.tinf22b6.gameobject.bullet.PlayerBullet; import de.dhbw.tinf22b6.util.Assets; import de.dhbw.tinf22b6.util.Constants; import de.dhbw.tinf22b6.util.EntitySystem; @@ -18,19 +17,21 @@ public MP7() { public boolean shoot() { if (super.shoot()) { new Thread(() -> { - try { - Thread.sleep((long) (shootingAnimation.getAnimationDuration() * 1000)); - float angle = EntitySystem.instance.getPlayer().getAngle(); - Vector2 pos = EntitySystem.instance.getPlayer().getPos(); - EntitySystem.instance.add(new MPBullet( - new Vector2(pos.x + 15 / 2f, pos.y + 5), angle, this.getDamage(), Constants.WEAPON_BIT)); - } catch (InterruptedException e) { - throw new RuntimeException(e); - } - }) + try { + Thread.sleep((long) (shootingAnimation.getAnimationDuration() * 1000)); + float angle = EntitySystem.instance.getPlayer().getAngle(); + Vector2 pos = EntitySystem.instance.getPlayer().getPos(); + EntitySystem.instance.add(new MPBullet( + new Vector2(pos.x + 15 / 2f, pos.y + 5), + angle, + this.getDamage(), + Constants.WEAPON_BIT)); + } catch (InterruptedException e) { + throw new RuntimeException(e); + } + }) .start(); } return true; } } - diff --git a/game/core/src/main/de/dhbw/tinf22b6/weapon/Shotgun.java b/game/core/src/main/de/dhbw/tinf22b6/weapon/Shotgun.java index 029605d..ce7bde3 100644 --- a/game/core/src/main/de/dhbw/tinf22b6/weapon/Shotgun.java +++ b/game/core/src/main/de/dhbw/tinf22b6/weapon/Shotgun.java @@ -22,7 +22,10 @@ public boolean shoot() { angle += i; Vector2 pos = EntitySystem.instance.getPlayer().getPos(); EntitySystem.instance.add(new PlayerBullet( - new Vector2(pos.x + 15 / 2f, pos.y + 5), angle, this.getDamage(), Constants.WEAPON_BIT)); + new Vector2(pos.x + 15 / 2f, pos.y + 5), + angle, + this.getDamage(), + Constants.WEAPON_BIT)); } }) .start(); diff --git a/game/core/src/main/de/dhbw/tinf22b6/weapon/Sniper.java b/game/core/src/main/de/dhbw/tinf22b6/weapon/Sniper.java index 9fe02e5..9c19dcb 100644 --- a/game/core/src/main/de/dhbw/tinf22b6/weapon/Sniper.java +++ b/game/core/src/main/de/dhbw/tinf22b6/weapon/Sniper.java @@ -5,7 +5,6 @@ import com.badlogic.gdx.graphics.g2d.Animation; import com.badlogic.gdx.math.Vector2; -import de.dhbw.tinf22b6.gameobject.bullet.PlayerBullet; import de.dhbw.tinf22b6.gameobject.bullet.SniperBullet; import de.dhbw.tinf22b6.util.Assets; import de.dhbw.tinf22b6.util.Constants; @@ -21,20 +20,20 @@ public Sniper() { public boolean shoot() { if (super.shoot()) { new Thread(() -> { - try { - Thread.sleep((long) (shootingAnimation.getAnimationDuration() * 1000)); - float angle = EntitySystem.instance.getPlayer().getAngle(); - Vector2 pos = EntitySystem.instance.getPlayer().getPos(); - int r = 30; - EntitySystem.instance.add(new SniperBullet( - new Vector2(pos.x + r * cosDeg(angle), pos.y + 5 + r * sinDeg(angle)), - angle, - this.getDamage(), - Constants.WEAPON_BIT)); - } catch (InterruptedException e) { - throw new RuntimeException(e); - } - }) + try { + Thread.sleep((long) (shootingAnimation.getAnimationDuration() * 1000)); + float angle = EntitySystem.instance.getPlayer().getAngle(); + Vector2 pos = EntitySystem.instance.getPlayer().getPos(); + int r = 30; + EntitySystem.instance.add(new SniperBullet( + new Vector2(pos.x + r * cosDeg(angle), pos.y + 5 + r * sinDeg(angle)), + angle, + this.getDamage(), + Constants.WEAPON_BIT)); + } catch (InterruptedException e) { + throw new RuntimeException(e); + } + }) .start(); } return true; diff --git a/game/core/src/main/de/dhbw/tinf22b6/weapon/Weapon.java b/game/core/src/main/de/dhbw/tinf22b6/weapon/Weapon.java index 55bca77..fbe5cfb 100644 --- a/game/core/src/main/de/dhbw/tinf22b6/weapon/Weapon.java +++ b/game/core/src/main/de/dhbw/tinf22b6/weapon/Weapon.java @@ -31,8 +31,9 @@ public Weapon(String regionName, int ammo, float weaponCooldown, int damage) { } public int getDamage() { - return (int) (this.damage + Math.ceil(this.damage * PlayerStatistics.instance.getDamageModifier())); + return (int) (this.damage + Math.ceil(this.damage * PlayerStatistics.instance.getDamageModifier())); } + public boolean shoot() { if (this.ammo <= 0) { Gdx.audio @@ -47,7 +48,7 @@ public boolean shoot() { new Thread(() -> { try { Thread.sleep((long) (shootingAnimation.getAnimationDuration() * 1000)); - sound.play(Gdx.app.getPreferences("Controls").getFloat("sfx")*4); + sound.play(Gdx.app.getPreferences("Controls").getFloat("sfx") * 4); this.remainingWeaponCooldown = this.weaponCooldown; this.weaponStateTime = 0; this.isShooting = false; diff --git a/game/core/src/main/de/dhbw/tinf22b6/world/WorldController.java b/game/core/src/main/de/dhbw/tinf22b6/world/WorldController.java index b82a952..499521f 100644 --- a/game/core/src/main/de/dhbw/tinf22b6/world/WorldController.java +++ b/game/core/src/main/de/dhbw/tinf22b6/world/WorldController.java @@ -102,11 +102,8 @@ public void update(float deltaTime) { bullets.forEach(bullet -> { float width = 3; float height = 6; - bullet.setBody( - world.createBody( - WorldParser.getDynamicBodyDef( - bullet.getPos().x + width / 2, - bullet.getPos().y + height / 2))); + bullet.setBody(world.createBody( + WorldParser.getDynamicBodyDef(bullet.getPos().x + width / 2, bullet.getPos().y + height / 2))); PolygonShape polygonShape = new PolygonShape(); polygonShape.setAsBox(3 - 2, 3 - 2); @@ -125,7 +122,8 @@ public void update(float deltaTime) { List ammoBoxPosition = EntitySystem.instance.getSyncAmmoBoxesToBeCreated(); synchronized (ammoBoxPosition) { - ammoBoxPosition.forEach(ammoBox -> EntitySystem.instance.add(new AmmoBox(ammoBox, new Rectangle(3, 2, 10, 10)))); + ammoBoxPosition.forEach( + ammoBox -> EntitySystem.instance.add(new AmmoBox(ammoBox, new Rectangle(3, 2, 10, 10)))); ammoBoxPosition.clear(); }