-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Additional changes for second Playtest
- Loading branch information
Andus
committed
Aug 31, 2024
1 parent
cdc73cc
commit 70e69cc
Showing
12 changed files
with
180 additions
and
160 deletions.
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
src/main/java/dev/celestialfox/spectrumsurvival/game/phases/PhaseBossBar.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package dev.celestialfox.spectrumsurvival.game.phases; | ||
|
||
import dev.celestialfox.spectrumsurvival.game.classes.GameLobby; | ||
import dev.celestialfox.spectrumsurvival.utils.Misc; | ||
import net.kyori.adventure.bossbar.BossBar; | ||
import net.kyori.adventure.text.Component; | ||
import net.kyori.adventure.text.format.NamedTextColor; | ||
|
||
public class PhaseBossBar { | ||
public static void updateBossBar(GameLobby game, BossBar nextPhaseBossBar, int phaseDuration) { | ||
long currentTime = System.currentTimeMillis(); | ||
long elapsedMillis = currentTime - game.getPhaseStartTime(); | ||
long elapsedSeconds = elapsedMillis / 1000; | ||
float progress = 1.0f - (float) elapsedSeconds / phaseDuration; | ||
nextPhaseBossBar.progress(Math.max(progress, 0.0f)); | ||
long remainingSeconds = phaseDuration - elapsedSeconds; | ||
String remainingTime = String.format("%d seconds until next phase", Math.max(remainingSeconds, 0)); | ||
nextPhaseBossBar.name(Component.text(remainingTime, NamedTextColor.WHITE)); | ||
} | ||
|
||
public static void resetBossBarProgress(BossBar nextPhaseBossBar) { | ||
nextPhaseBossBar.progress(1.0f); | ||
} | ||
|
||
public static void removeBossBar(GameLobby game, BossBar nextPhaseBossBar) { | ||
game.getPlayers().forEach(uuid -> Misc.getPlayer(uuid).hideBossBar(nextPhaseBossBar)); | ||
} | ||
} |
Oops, something went wrong.