Skip to content
This repository has been archived by the owner on Sep 29, 2024. It is now read-only.

Commit

Permalink
chore: apply spotless
Browse files Browse the repository at this point in the history
  • Loading branch information
LPkkjHD committed Jun 18, 2024
1 parent d589a19 commit 88330d1
Show file tree
Hide file tree
Showing 17 changed files with 55 additions and 65 deletions.
2 changes: 0 additions & 2 deletions game/core/src/main/de/dhbw/tinf22b6/UnderwatchGame.java
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
2 changes: 0 additions & 2 deletions game/core/src/main/de/dhbw/tinf22b6/gameobject/Player.java
Original file line number Diff line number Diff line change
Expand Up @@ -229,8 +229,6 @@ public void shoot() {
PlayerStatistics.instance.getCurrentWeapon().shoot();
}



public Vector2 getMotionVector() {
return motionVector;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ public MPBullet(Vector2 position, float angle, int damage, short mask) {
this.speed = 3;
this.range = 1.5f;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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<Vector2> {
private static final String TAG = Enemy.class.getName();
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -15,14 +14,14 @@ 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
public void interact(Player player) {
PlayerStatistics.instance.addDamageModifier(0.2f);
super.interact(player);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,4 @@ public void interact(Player player) {
super.interact(player);
}
}
}
}
2 changes: 0 additions & 2 deletions game/core/src/main/de/dhbw/tinf22b6/util/EntitySystem.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -47,7 +46,6 @@ public List<Bullet> getSyncBulletsToBeCreated() {
return syncBulletsToBeCreated;
}


public void add(GameObject object) {
this.gameObjects.add(object);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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;
}
Expand Down
5 changes: 4 additions & 1 deletion game/core/src/main/de/dhbw/tinf22b6/weapon/M4.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
25 changes: 13 additions & 12 deletions game/core/src/main/de/dhbw/tinf22b6/weapon/MP7.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
}
}

5 changes: 4 additions & 1 deletion game/core/src/main/de/dhbw/tinf22b6/weapon/Shotgun.java
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
29 changes: 14 additions & 15 deletions game/core/src/main/de/dhbw/tinf22b6/weapon/Sniper.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down
5 changes: 3 additions & 2 deletions game/core/src/main/de/dhbw/tinf22b6/weapon/Weapon.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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;
Expand Down
10 changes: 4 additions & 6 deletions game/core/src/main/de/dhbw/tinf22b6/world/WorldController.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -125,7 +122,8 @@ public void update(float deltaTime) {
List<Vector2> 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();
}

Expand Down

0 comments on commit 88330d1

Please sign in to comment.