Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4,165 changes: 1,930 additions & 2,235 deletions GGJ26/Assets/00. Scenes/DeathMatchGameScene.unity

Large diffs are not rendered by default.

225 changes: 187 additions & 38 deletions GGJ26/Assets/00. Scenes/GameScene.unity

Large diffs are not rendered by default.

16 changes: 16 additions & 0 deletions GGJ26/Assets/00. Scenes/Lobby.unity
Original file line number Diff line number Diff line change
Expand Up @@ -4504,6 +4504,22 @@ PrefabInstance:
propertyPath: 'm_fontSharedMaterials.Array.data[0]'
value:
objectReference: {fileID: 1893403078}
- target: {fileID: 1559650123334622070, guid: d8790d17699e6614db16a6c30df9c4bf, type: 3}
propertyPath: m_fontColor.b
value: 0.7226415
objectReference: {fileID: 0}
- target: {fileID: 1559650123334622070, guid: d8790d17699e6614db16a6c30df9c4bf, type: 3}
propertyPath: m_fontColor.g
value: 0.9793531
objectReference: {fileID: 0}
- target: {fileID: 1559650123334622070, guid: d8790d17699e6614db16a6c30df9c4bf, type: 3}
propertyPath: m_fontColor.r
value: 1
objectReference: {fileID: 0}
- target: {fileID: 1559650123334622070, guid: d8790d17699e6614db16a6c30df9c4bf, type: 3}
propertyPath: m_fontColor32.rgba
value: 4290312959
objectReference: {fileID: 0}
- target: {fileID: 1906092115782938955, guid: d8790d17699e6614db16a6c30df9c4bf, type: 3}
propertyPath: clickSfxClip
value:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,29 @@ private sealed class DeathmatchRuntimeState
public bool IsEnabled => GameModeRuntime.IsDeathmatch;
public Vector3 SafeZoneCenter => safeZoneCenter;

public bool TryGetLives(PlayerRef player, out int lives)
{
lives = 3;
if (states.TryGetValue(player.RawEncoded, out var state) == false)
{
return false;
}

lives = Mathf.Clamp(state.Lives, 0, 3);
return true;
}

public bool TryGetLocalPlayerLives(out int lives)
{
lives = 3;
if (Runner == null || Runner.IsRunning == false)
{
return false;
}

return TryGetLives(Runner.LocalPlayer, out lives);
}

public override void Spawned()
{
if (GameModeRuntime.IsDeathmatch == false)
Expand Down Expand Up @@ -315,16 +338,10 @@ private void TryResolveWinner()
return;
}

if (aliveCount > 1)
if (aliveCount <= 0)
{
if (NetRemainingSeconds <= 0f)
{
ResolveTieBreakerAtTimeout();
}
return;
ResolveTieBreakerAtTimeout();
}

ResolveTieBreakerAtTimeout();
}

private void ResolveTieBreakerAtTimeout()
Expand Down
166 changes: 166 additions & 0 deletions GGJ26/Assets/01. Scripts/UI/DeathmatchLivesUI.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,166 @@
using System.Collections.Generic;
using Fusion;
using UnityEngine;
using UnityEngine.UI;

public class DeathmatchLivesUI : MonoBehaviour
{
[Header("References")]
[SerializeField] private DeathmatchMatchController deathmatchController;
[SerializeField] private Transform livesRoot;

[Header("Settings")]
[SerializeField] private int maxLives = 3;
[SerializeField] private bool hideWhenNotDeathmatch = true;

private readonly List<GameObject> lifeIcons = new List<GameObject>();
private int lastAppliedLives = -1;

private void Awake()
{
ResolveReferences();
CacheLifeIcons();
}

private void OnEnable()
{
lastAppliedLives = -1;
RefreshNow();
}

private void Update()
{
RefreshNow();
}

private void ResolveReferences()
{
if (deathmatchController == null)
{
deathmatchController = FindFirstObjectByType<DeathmatchMatchController>();
}

if (livesRoot != null)
{
return;
}

var allTransforms = FindObjectsByType<Transform>(FindObjectsInactive.Include, FindObjectsSortMode.None);
for (int i = 0; i < allTransforms.Length; i++)
{
var t = allTransforms[i];
if (t == null || t.name != "Lifes")
{
continue;
}

livesRoot = t;
break;
}
}

private void CacheLifeIcons()
{
lifeIcons.Clear();
if (livesRoot == null)
{
return;
}

for (int i = 0; i < livesRoot.childCount; i++)
{
var child = livesRoot.GetChild(i);
if (child == null)
{
continue;
}

// Treat direct children as life icons; supports Image objects and wrappers.
lifeIcons.Add(child.gameObject);
}
}

private void RefreshNow()
{
if (livesRoot == null)
{
ResolveReferences();
CacheLifeIcons();
if (livesRoot == null)
{
return;
}
}

if (hideWhenNotDeathmatch && GameModeRuntime.IsDeathmatch == false)
{
if (livesRoot.gameObject.activeSelf)
{
livesRoot.gameObject.SetActive(false);
}

return;
}

if (livesRoot.gameObject.activeSelf == false)
{
livesRoot.gameObject.SetActive(true);
}

int lives = maxLives;
if (TryReadLocalLives(out var syncedLives))
{
lives = syncedLives;
}

lives = Mathf.Clamp(lives, 0, Mathf.Max(0, maxLives));
if (lives == lastAppliedLives)
{
return;
}

lastAppliedLives = lives;
ApplyLives(lives);
}

private bool TryReadLocalLives(out int lives)
{
lives = maxLives;
if (deathmatchController == null)
{
return false;
}

if (deathmatchController.TryGetLocalPlayerLives(out lives))
{
return true;
}

NetworkRunner runner = deathmatchController.Runner;
if (runner != null && runner.IsRunning)
{
return deathmatchController.TryGetLives(runner.LocalPlayer, out lives);
}

return false;
}

private void ApplyLives(int lives)
{
int iconCount = lifeIcons.Count;
if (iconCount == 0)
{
return;
}

for (int i = 0; i < iconCount; i++)
{
bool visible = i < lives;
GameObject icon = lifeIcons[i];
if (icon != null && icon.activeSelf != visible)
{
icon.SetActive(visible);
}
}
}
}
2 changes: 2 additions & 0 deletions GGJ26/Assets/01. Scripts/UI/DeathmatchLivesUI.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

29 changes: 0 additions & 29 deletions GGJ26/Assets/01. Scripts/UI/GameManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -554,35 +554,6 @@ private bool IsGameplayScene(Scene scene)
private void OnGroupDanceActive(bool isActive)
{
isGroupDanceActive = isActive;

if (uiCanvasManager == null || playerStateManager == null)
{
return;
}

if (playerStateManager.TryGetLocalPlayer(out var localState) == false)
{
return;
}

if (localState.IsDead)
{
return;
}

if (localState.IsSeeker)
{
return;
}

if (isActive)
{
uiCanvasManager.SetHiderCanvasVisible(false);
}
else
{
uiCanvasManager.EnableHiderCanvas();
}
}

private void ResetRoundUI()
Expand Down
8 changes: 0 additions & 8 deletions GGJ26/Assets/01. Scripts/UI/UICanvasManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,4 @@ public void EnableHiderCanvas()

Debug.Log("Hider canvas enabled");
}

public void SetHiderCanvasVisible(bool visible)
{
if (hiderCanvas != null)
{
hiderCanvas.enabled = visible;
}
}
}
Loading
Loading