Improve equipment window

This commit is contained in:
2022-08-25 20:05:15 +02:00
parent a8a12a022a
commit 2c1fc56a5f
13 changed files with 287 additions and 39 deletions

View File

@@ -13,15 +13,17 @@ import lombok.Getter;
import lombok.NonNull;
import org.joml.Vector2i;
import java.util.Random;
public class MeleeWeapon extends IconDelegate implements Weapon {
private final Context context;
private final DiceRoller roller;
private final AnimationRunner animation;
private final String sound;
@Getter
private final String name;
@Getter
private final DiceRoller dmgRoller;
@Getter
private final int cooldown;
@@ -34,7 +36,7 @@ public class MeleeWeapon extends IconDelegate implements Weapon {
this.context = ContextHolder.INSTANCE.getContext();
this.name = template.getName();
this.roller = DiceRoller.of(template.getDamage());
this.dmgRoller = DiceRoller.of(template.getDamage());
this.cooldown = template.getCooldown();
this.animation = new RandomAnimationsRunner(2).nRange(0, 2f).nScale(0.2f, 0.15f).uAnimationSpeed(0.5f, 1f).nRotation(0, 10).offset(0, -10).uDelay(250, 500).with(A.animations.get(template.getAnimation()).uid);
this.sound = A.sounds.get(template.getSound()).uid;
@@ -45,7 +47,7 @@ public class MeleeWeapon extends IconDelegate implements Weapon {
var facingNeighbour = attacker.getCoordinates().add(attacker.getFaceDirection().vector, new Vector2i());
for (var entity : attacker.getLayer().getEntities()) {
if (entity.getCoordinates().equals(facingNeighbour) && entity.isBlocking() && entity instanceof Creature character) {
var damage = roller.roll();
var damage = dmgRoller.roll();
character.hit(attacker, damage);
animation.run(context, character.getLayer(), character);
context.playSound(sound);

View File

@@ -18,16 +18,22 @@ import lombok.NonNull;
public class RangedWeapon extends IconDelegate implements Weapon {
private final Context context;
private final DiceRoller dmgRoller;
private final DiceRoller rangeRoller;
private final BulletAnimationRunner animation;
private final String sound;
private final AnimationRunner punchAnimation;
private final String punchSound;
private final AnimationRunner missAnimation;
private final String missSound;
@Getter
private final String name;
@Getter
private final DiceRoller dmgRoller;
@Getter
private final DiceRoller rangeRoller;
@Getter
private final int cooldown;