diff --git a/.gitignore b/.gitignore index b987736..625be0f 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,4 @@ shooter.iml src/main/resources/**/*.png src/main/resources/**/*.ogg src/main/resources/**/*.fnt + diff --git a/src/main/java/aunmag/shooter/game/ai/strategies/Strategy.java b/src/main/java/aunmag/shooter/game/ai/strategies/Strategy.java index 1e797b7..ced6032 100644 --- a/src/main/java/aunmag/shooter/game/ai/strategies/Strategy.java +++ b/src/main/java/aunmag/shooter/game/ai/strategies/Strategy.java @@ -85,7 +85,8 @@ public Enemy findEnemy() { } public boolean isEnemy(Actor actor) { - return (actor.type == ActorType.human || ai.actor.type == ActorType.human) + return (actor.type.genus == ActorType.Genus.HUMAN + || ai.actor.type.genus == ActorType.Genus.HUMAN) && actor != ai.actor && actor.isActive() && actor.isAlive(); diff --git a/src/main/java/aunmag/shooter/game/client/App.java b/src/main/java/aunmag/shooter/game/client/App.java index 8465496..60ad773 100644 --- a/src/main/java/aunmag/shooter/game/client/App.java +++ b/src/main/java/aunmag/shooter/game/client/App.java @@ -31,6 +31,7 @@ public void newGame() { setPause(false); } + @Override public void gameUpdate() { if (Input.keyboard.isKeyPressed(GLFW.GLFW_KEY_BACKSPACE)) { isDebug = !isDebug; @@ -43,6 +44,7 @@ public void gameUpdate() { } } + @Override public void gameRender() { if (isPause) { pause.render(); @@ -51,6 +53,7 @@ public void gameRender() { } } + @Override public void gameTerminate() { endGame(); } diff --git a/src/main/java/aunmag/shooter/game/client/states/Pause.java b/src/main/java/aunmag/shooter/game/client/states/Pause.java index a1bebd5..8fe4348 100644 --- a/src/main/java/aunmag/shooter/game/client/states/Pause.java +++ b/src/main/java/aunmag/shooter/game/client/states/Pause.java @@ -12,6 +12,8 @@ import aunmag.shooter.core.utilities.UtilsAudio; import aunmag.shooter.game.client.Constants; import aunmag.shooter.game.client.Context; +import aunmag.shooter.game.environment.actor.ActorType; +import aunmag.shooter.game.scenarios.ScenarioEncircling; import org.jetbrains.annotations.Nullable; import org.joml.Vector4f; @@ -46,19 +48,39 @@ private Page createPageMain() { version.setTextColour(new Vector4f(1, 1, 1, 0.75f)); - var onNewGame = (Runnable) () -> Context.main.application.newGame(); - var page = new Page(wallpaper); page.add(new Label(3, 3, 6, 1, Constants.TITLE)); page.add(version); page.add(buttonContinue); - page.add(new Button(4, 8, 4, 1, "New game", onNewGame)); + page.add(new Button(4, 8, 4, 1, "New game", + createCharacterSelectionPage()::open)); page.add(new Button(4, 9, 4, 1, "Help", createPageHelp()::open)); page.add(new Button(4, 10, 4, 1, "Exit", createPageExit()::open)); return page; } + private Page createCharacterSelectionPage() { + var wallpaper = Texture.manager + .asWallpaper() + .provide("images/wallpapers/main_menu"); + var page = new Page(wallpaper); + + page.add(new Label(3, 3, 6, 1, "Select your character")); + page.add(new Button(4, 7, 4, 1, "Soldier", () -> { + ScenarioEncircling.selectedActor = ActorType.soldier; + Context.main.application.newGame(); + Page.STACK.back(); + })); + page.add(new Button(4, 8, 4, 1, "Bandit", () -> { + ScenarioEncircling.selectedActor = ActorType.bandit; + Context.main.application.newGame(); + Page.STACK.back(); + })); + + return page; + } + private Page createPageHelp() { var wallpaper = Texture.manager.asWallpaper().provide("images/wallpapers/help"); var page = new Page(wallpaper); diff --git a/src/main/java/aunmag/shooter/game/environment/actor/Actor.java b/src/main/java/aunmag/shooter/game/environment/actor/Actor.java index fc894c4..ff474ff 100644 --- a/src/main/java/aunmag/shooter/game/environment/actor/Actor.java +++ b/src/main/java/aunmag/shooter/game/environment/actor/Actor.java @@ -272,7 +272,7 @@ public void render() { } private void soundHurt() { - if (type != ActorType.human) { + if (type != ActorType.soldier) { return; } diff --git a/src/main/java/aunmag/shooter/game/environment/actor/ActorType.java b/src/main/java/aunmag/shooter/game/environment/actor/ActorType.java index 0667670..6f32795 100644 --- a/src/main/java/aunmag/shooter/game/environment/actor/ActorType.java +++ b/src/main/java/aunmag/shooter/game/environment/actor/ActorType.java @@ -1,12 +1,15 @@ package aunmag.shooter.game.environment.actor; import aunmag.shooter.core.structures.Texture; +import aunmag.shooter.game.environment.weapon.WeaponType; +import org.jetbrains.annotations.Nullable; public class ActorType { public static final float STRENGTH_DEFAULT = 7500; public final String name; + public final Genus genus; public final float radius; public final float mass; public final float strength; @@ -15,10 +18,12 @@ public class ActorType { public final float velocityRotation; public final float damage; public final float reaction; + @Nullable public final WeaponType primaryWeapon; public final Texture texture; public ActorType( String name, + Genus genus, float radius, float mass, float strength, @@ -26,9 +31,11 @@ public ActorType( float velocityFactorSprint, float velocityRotation, float damage, - float reaction + float reaction, + @Nullable WeaponType primaryWeapon ) { this.name = name; + this.genus = genus; this.radius = radius; this.mass = mass; this.strength = strength; @@ -37,6 +44,7 @@ public ActorType( this.velocityRotation = velocityRotation; this.damage = damage; this.reaction = reaction; + this.primaryWeapon = primaryWeapon; var texture = Texture.manager.asSprite().provide("actors/" + name + "/image"); @@ -50,6 +58,7 @@ public ActorType( public static ActorType clone(ActorType type, float skill) { return new ActorType( type.name, + Genus.HUMAN, type.radius, type.mass, skill * type.strength, @@ -57,14 +66,16 @@ public static ActorType clone(ActorType type, float skill) { type.velocityFactorSprint, type.velocityRotation, type.damage, - type.reaction + type.reaction, + type.primaryWeapon ); } /* Types */ - public static final ActorType human = new ActorType( - "human", + public static final ActorType soldier = new ActorType( + "soldier", + Genus.HUMAN, 0.225f, 80_000, STRENGTH_DEFAULT, @@ -72,23 +83,41 @@ public static ActorType clone(ActorType type, float skill) { 2.76f, 8, STRENGTH_DEFAULT / 16f, - 0.06f + 0.06f, + WeaponType.pm ); + public static final ActorType bandit = new ActorType( + "bandit", + Genus.HUMAN, + soldier.radius * 1.1f, + soldier.mass * 1.1f, + soldier.strength * 0.8f, + soldier.velocity * 1.2f, + soldier.velocityFactorSprint * 1.2f, + soldier.velocityRotation * 1.2f, + soldier.damage * 0.8f, + soldier.reaction * 0.8f, + WeaponType.tt + ); + public static final ActorType zombie = new ActorType( "zombie", - human.radius, + Genus.ZOMBIE, + soldier.radius, 70_000, - 0.4f * human.strength, - 0.4f * human.velocity, - 0.4f * human.velocityFactorSprint, - 0.4f * human.velocityRotation, - human.strength / 8f, - 0.2f + 0.4f * soldier.strength, + 0.4f * soldier.velocity, + 0.4f * soldier.velocityFactorSprint, + 0.4f * soldier.velocityRotation, + soldier.strength / 8f, + 0.2f, + null ); public static final ActorType zombieAgile = new ActorType( "zombie agile", + Genus.ZOMBIE, 0.8f * zombie.radius, 40_000, 0.6f * zombie.strength, @@ -96,11 +125,13 @@ public static ActorType clone(ActorType type, float skill) { zombie.velocityFactorSprint, 2.5f * zombie.velocityRotation, 0.4f * zombie.damage, - 0.1f + 0.1f, + null ); public static final ActorType zombieHeavy = new ActorType( "zombie heavy", + Genus.ZOMBIE, 1.2f * zombie.radius, 120_000, 2.0f * zombie.strength, @@ -108,7 +139,13 @@ public static ActorType clone(ActorType type, float skill) { zombie.velocityFactorSprint, 0.7f * zombie.velocityRotation, 1.8f * zombie.damage, - 0.3f + 0.3f, + null ); + + public enum Genus { + HUMAN, + ZOMBIE + } } diff --git a/src/main/java/aunmag/shooter/game/environment/actor/Control.java b/src/main/java/aunmag/shooter/game/environment/actor/Control.java index b0602f8..f24b5d9 100644 --- a/src/main/java/aunmag/shooter/game/environment/actor/Control.java +++ b/src/main/java/aunmag/shooter/game/environment/actor/Control.java @@ -25,6 +25,8 @@ public void reset() { turningTo = null; } + /* Setters */ + public void walkForward() { isWalkingForward = true; } diff --git a/src/main/java/aunmag/shooter/game/environment/projectile/ProjectileType.java b/src/main/java/aunmag/shooter/game/environment/projectile/ProjectileType.java index 6fc3796..d9be7fc 100644 --- a/src/main/java/aunmag/shooter/game/environment/projectile/ProjectileType.java +++ b/src/main/java/aunmag/shooter/game/environment/projectile/ProjectileType.java @@ -68,4 +68,11 @@ protected ProjectileType( 0.08f ); + public static final ProjectileType _11_48x33mmR = new ProjectileType( + 1, + 15f, + 3f, + 0.1f + ); + } diff --git a/src/main/java/aunmag/shooter/game/environment/weapon/WeaponType.java b/src/main/java/aunmag/shooter/game/environment/weapon/WeaponType.java index 1994437..6b6255b 100644 --- a/src/main/java/aunmag/shooter/game/environment/weapon/WeaponType.java +++ b/src/main/java/aunmag/shooter/game/environment/weapon/WeaponType.java @@ -97,6 +97,17 @@ protected WeaponType( GRIP_OFFSET_SHORT ); + public static final WeaponType coltSingleActionArmy = new WeaponType( + "Colt SAA", + SEMI_AUTO_SHOTS_PER_MINUTE / 4, + 450, + 0.01f, + 80_000f, + false, + new MagazineType(ProjectileType._11_48x33mmR, true, 6, 3f), + GRIP_OFFSET_STEP + ); + public static final WeaponType mp43sawedOff = new WeaponType( "MP-43 sawed-off", SEMI_AUTO_SHOTS_PER_MINUTE, diff --git a/src/main/java/aunmag/shooter/game/scenarios/Scenario.java b/src/main/java/aunmag/shooter/game/scenarios/Scenario.java index 1bfcd9f..bd5273b 100644 --- a/src/main/java/aunmag/shooter/game/scenarios/Scenario.java +++ b/src/main/java/aunmag/shooter/game/scenarios/Scenario.java @@ -3,10 +3,12 @@ import aunmag.shooter.core.utilities.Operative; import aunmag.shooter.game.environment.World; import aunmag.shooter.game.environment.actor.Actor; +import aunmag.shooter.game.environment.actor.ActorType; import org.jetbrains.annotations.Nullable; public abstract class Scenario extends Operative { + public static ActorType selectedActor = null; public final World world; public Scenario(World world) { diff --git a/src/main/java/aunmag/shooter/game/scenarios/ScenarioEncircling.java b/src/main/java/aunmag/shooter/game/scenarios/ScenarioEncircling.java index db3f32a..1f8f22a 100644 --- a/src/main/java/aunmag/shooter/game/scenarios/ScenarioEncircling.java +++ b/src/main/java/aunmag/shooter/game/scenarios/ScenarioEncircling.java @@ -72,7 +72,8 @@ private void initializeBluffs() { @Override public Actor createPlayableActor() { - var actor = new Actor(ActorType.human, world, 0, 0, (float) -UtilsMath.PIx0_5); + var actor = new Actor( + selectedActor, world, 0, 0, (float) -UtilsMath.PIx0_5); actor.setWeapon(new Weapon(world, WeaponType.pm)); world.actors.all.add(actor); return actor; @@ -111,7 +112,7 @@ private boolean isWaveComplete() { waveCheckTimer.next(); for (var actor : world.actors.all) { - if (actor.type != ActorType.human) { + if (actor.type.genus != ActorType.Genus.HUMAN) { return false; } } @@ -153,7 +154,7 @@ private void startNextWave() { } if (wave > 1 && UtilsMath.chance(HUMAN_SPAWN_CHANCE)) { - spawnEnemy(ActorType.human); + spawnEnemy(ActorType.soldier); } } @@ -185,7 +186,7 @@ private void spawnEnemy(ActorType type) { world.actors.all.add(enemy); world.ais.all.add(new Ai(enemy)); - if (enemy.type == ActorType.human) { + if (enemy.type.genus == ActorType.Genus.HUMAN) { enemy.setWeapon(createRandomWeapon()); }