Skip to content

Commit

Permalink
Add various in-game sounds
Browse files Browse the repository at this point in the history
  • Loading branch information
ellieisjelly committed Oct 15, 2024
1 parent c18fc9b commit f9fd0f0
Showing 1 changed file with 26 additions and 5 deletions.
31 changes: 26 additions & 5 deletions src/main/java/me/ellieis/Sabotage/game/phase/SabotageActive.java
Original file line number Diff line number Diff line change
Expand Up @@ -227,10 +227,7 @@ public void pickRoles() {
// need to make a new list from .toList to make it mutable
List<ServerPlayerEntity> plrList = new ArrayList<>(plrs.stream().toList());
Collections.shuffle(plrList);
int sabCount = playerCount / 3;
if (sabCount < 1) {
sabCount = 1;
}
int sabCount = Math.max(playerCount / 3, 1);
int detCount = playerCount / 8;
for (ServerPlayerEntity plr : plrList) {
if (detCount >= 1) {
Expand Down Expand Up @@ -370,26 +367,45 @@ public boolean testEntity(ServerPlayerEntity plr, Vec3d pos) {
}
world.playSound(null, plr.getBlockPos(), SoundEvents.BLOCK_IRON_DOOR_OPEN, SoundCategory.BLOCKS, 1, 0.5f);
};

// sounds for testing
for (int i = 1; i <= 20; i++) {
int finalI = i;
taskScheduler.addTask(new Task((int) (world.getTime() + (10 * i)), (gameSpace) -> {
world.playSound(null,
pos.getX(),
pos.getY(),
pos.getZ(),
SoundEvents.BLOCK_NOTE_BLOCK_BASS.value(),
SoundCategory.BLOCKS,
1.0f,
(float) Math.min((0.5 + (0.05 * finalI)), 1.4));
}));
}
taskScheduler.addTask(new Task(revealTime - 100, reminder));
taskScheduler.addTask(new Task(revealTime, reveal));
}
return true;
}
private void awardPlayerKill(ServerPlayerEntity attacker, ServerPlayerEntity plr, Roles plrRole, int innocentKarma, int detectiveKarma, int saboteurKarma) {
// attacker is confirmed innocent or detective
// 0.9 -> 1.05
switch(plrRole) {
case INNOCENT -> {
karmaManager.decrementKarma(attacker, innocentKarma);
attacker.playSound(SoundEvents.BLOCK_TRIAL_SPAWNER_DETECT_PLAYER, SoundCategory.RECORDS, 1, 1);
attacker.sendMessage(createAttackerKillMessage(plr, -innocentKarma));
}

case DETECTIVE -> {
karmaManager.decrementKarma(attacker, detectiveKarma);
attacker.playSound(SoundEvents.BLOCK_TRIAL_SPAWNER_DETECT_PLAYER, SoundCategory.RECORDS, 1, 1);
attacker.sendMessage(createAttackerKillMessage(plr, -detectiveKarma));
}

case SABOTEUR -> {
karmaManager.incrementKarma(attacker, saboteurKarma);
attacker.playSound(SoundEvents.BLOCK_TRIAL_SPAWNER_OPEN_SHUTTER, SoundCategory.RECORDS, 1, 1f);
attacker.sendMessage(createAttackerKillMessage(plr, saboteurKarma));
}
}
Expand Down Expand Up @@ -430,6 +446,7 @@ public void End(EndReason endReason) {
} else if (endReason == EndReason.TIMEOUT) {
plrs.sendMessage(Text.translatable("sabotage.game_end.none"));
}
gameSpace.getPlayers().playSound(SoundEvents.ENTITY_PLAYER_LEVELUP);
}
public static void Open(GameSpace gameSpace, ServerWorld world, SabotageMap map, SabotageConfig config) {
gameSpace.setActivity(activity -> {
Expand Down Expand Up @@ -486,7 +503,7 @@ private ActionResult onDeath(ServerPlayerEntity plr, DamageSource damageSource)
Entity entityAttacker = damageSource.getAttacker();
Roles plrRole = getPlayerRole(plr);
plr.changeGameMode(GameMode.SPECTATOR);

plr.playSound(SoundEvents.ENTITY_COW_DEATH, SoundCategory.PLAYERS, 1, 0.7f);
if (gameState != GameStates.ACTIVE) {
return ActionResult.FAIL;
}
Expand All @@ -501,16 +518,20 @@ private ActionResult onDeath(ServerPlayerEntity plr, DamageSource damageSource)
switch(plrRole) {
case INNOCENT -> {
karmaManager.incrementKarma(attacker, config.innocentKarmaAward());
attacker.playSound(SoundEvents.BLOCK_TRIAL_SPAWNER_OPEN_SHUTTER, SoundCategory.RECORDS, 1, 1f);
attacker.sendMessage(createAttackerKillMessage(plr, config.innocentKarmaAward()));
}

case DETECTIVE -> {
karmaManager.incrementKarma(attacker, config.detectiveKarmaAward());
attacker.playSound(SoundEvents.BLOCK_TRIAL_SPAWNER_OPEN_SHUTTER, SoundCategory.RECORDS, 1, 1f);
attacker.playSound(SoundEvents.BLOCK_TRIAL_SPAWNER_DETECT_PLAYER, SoundCategory.RECORDS, 0.5f, 1f);
attacker.sendMessage(createAttackerKillMessage(plr, config.detectiveKarmaAward()));
}

case SABOTEUR -> {
karmaManager.decrementKarma(attacker, config.saboteurKarmaPenalty());
attacker.playSound(SoundEvents.BLOCK_TRIAL_SPAWNER_DETECT_PLAYER, SoundCategory.RECORDS, 1, 1f);
attacker.sendMessage(createAttackerKillMessage(plr, -config.saboteurKarmaPenalty()));
}
}
Expand Down

0 comments on commit f9fd0f0

Please sign in to comment.