Skip to content

Commit 979100a

Browse files
Merge pull request #106 from dcl-regenesislabs/NEW-RAGED-BAR
ft: new raged bar
2 parents f057fe7 + 28050eb commit 979100a

File tree

2 files changed

+41
-11
lines changed

2 files changed

+41
-11
lines changed

src/rageEffect.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* Weapons read getFireRateMultiplier() when deciding shoot interval.
44
*/
55

6-
const RAGE_DURATION_SEC = 10
6+
export const RAGE_DURATION_SEC = 10
77
let rageEndTime = 0
88

99
export function getFireRateMultiplier(): number {

src/ui.tsx

Lines changed: 40 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { getWaveUiState, getWaveCountdownLabel } from './waveManager'
55
import { getPlayerHp, isPlayerDead, MAX_HP, getRespawnAtMs, getRespawnDelay } from './playerHealth'
66
import { getZombieCoins } from './zombieCoins'
77
import { getGameTime } from './zombie'
8-
import { isRaging, getRageTimeLeft } from './rageEffect'
8+
import { isRaging, getRageTimeLeft, RAGE_DURATION_SEC } from './rageEffect'
99
import { getHealthPickupFeedback } from './potions'
1010
import {
1111
getCurrentWeapon,
@@ -98,6 +98,7 @@ export const uiMenu = () => {
9898
const localReadyForMatch = isLocalReadyForMatch()
9999
const showGameplayHud = inMatchContext && localReadyForMatch
100100
const showBackToLobbyButton = isInArenaRoster && localReadyForMatch
101+
const showPlayerHealthHud = showGameplayHud
101102
const timerNowMs = getServerTime()
102103
const arenaIntroSeconds =
103104
lobbyState?.arenaIntroEndTimeMs && lobbyState.arenaIntroEndTimeMs > timerNowMs
@@ -128,6 +129,13 @@ export const uiMenu = () => {
128129
const playerHpFillVisibleWidth = Math.max(0, Math.min(playerHpFillWidth, PLAYER_HP_FRAME_WIDTH - playerHpFillOffsetX))
129130
const playerHpFillVisibleHeight = Math.max(0, Math.min(playerHpFillHeight, PLAYER_HP_FRAME_HEIGHT - playerHpFillOffsetY))
130131
const playerHpFillCurrentWidth = Math.max(0, Math.round(playerHpFillVisibleWidth * playerHpRatio))
132+
const rageActive = showGameplayHud && isRaging()
133+
const rageFillRatio = rageActive ? Math.max(0, Math.min(1, getRageTimeLeft(getGameTime()) / RAGE_DURATION_SEC)) : 0
134+
const rageBarWidth = Math.max(0, Math.round((playerHpFillVisibleWidth - 90) * 1.178))
135+
const rageBarHeight = 6
136+
const rageBarCurrentWidth = Math.max(0, Math.round(rageBarWidth * rageFillRatio))
137+
const rageBarOffsetX = playerHpFillOffsetX + 10
138+
const rageBarOffsetTop = playerHpFillOffsetY + playerHpFillVisibleHeight + 1
131139

132140
return (
133141
<UiEntity
@@ -242,7 +250,7 @@ export const uiMenu = () => {
242250
</UiEntity>
243251
)}
244252

245-
{showGameplayHud && isRaging() && (
253+
{rageActive && (
246254
<UiEntity
247255
uiTransform={{
248256
position: { top: 186, left: 0 },
@@ -273,7 +281,7 @@ export const uiMenu = () => {
273281
</UiEntity>
274282
</UiEntity>
275283
)}
276-
{showZcCounter && (
284+
{showPlayerHealthHud && (
277285
<UiEntity
278286
uiTransform={{
279287
position: { left: 64, top: 206 },
@@ -283,13 +291,13 @@ export const uiMenu = () => {
283291
justifyContent: 'flex-start'
284292
}}
285293
>
286-
<UiEntity
287-
uiTransform={{
288-
width: PLAYER_HP_FRAME_WIDTH,
289-
height: PLAYER_HP_FRAME_HEIGHT,
290-
positionType: 'relative'
291-
}}
292-
>
294+
<UiEntity
295+
uiTransform={{
296+
width: PLAYER_HP_FRAME_WIDTH,
297+
height: PLAYER_HP_FRAME_HEIGHT + rageBarHeight + 4,
298+
positionType: 'relative'
299+
}}
300+
>
293301
<UiEntity
294302
uiTransform={{
295303
width: PLAYER_HP_FRAME_WIDTH,
@@ -326,6 +334,28 @@ export const uiMenu = () => {
326334
}}
327335
/>
328336
</UiEntity>
337+
{rageActive && (
338+
<UiEntity
339+
uiTransform={{
340+
width: rageBarWidth,
341+
height: rageBarHeight,
342+
positionType: 'absolute',
343+
position: { left: rageBarOffsetX, top: rageBarOffsetTop + 3 },
344+
flexDirection: 'row',
345+
alignItems: 'center',
346+
justifyContent: 'flex-start'
347+
}}
348+
uiBackground={{ color: Color4.create(0.16, 0.03, 0.05, 0.92) }}
349+
>
350+
<UiEntity
351+
uiTransform={{
352+
width: rageBarCurrentWidth,
353+
height: rageBarHeight
354+
}}
355+
uiBackground={{ color: Color4.create(0.5, 0.05, 0.12, 1) }}
356+
/>
357+
</UiEntity>
358+
)}
329359
</UiEntity>
330360
</UiEntity>
331361
)}

0 commit comments

Comments
 (0)