사망 시 사망 UI 출력
This commit is contained in:
@@ -93,6 +93,7 @@ MonoBehaviour:
|
||||
deathEffectPrefab: {fileID: 5642766282230003982, guid: b5c8ca7ed10b61e499cce8ec3b6e2e4c, type: 3}
|
||||
resourcePickupPrefab: {fileID: 1627676033990080135, guid: 8c45964a69bf8fa4ba461ed217bc052f, type: 3}
|
||||
respawnDelay: 10
|
||||
respawnPanelPrefab: {fileID: 5112555873318329611, guid: 9257920ba4a6256499ad89eeb7d7098a, type: 3}
|
||||
showHealthBar: 1
|
||||
healthBarPrefab: {fileID: 100000, guid: 8e7a5b12c9f8a4a5ba3c8d1f2e5a7b9c, type: 3}
|
||||
--- !u!143 &3007098678582223509
|
||||
|
||||
@@ -52,6 +52,7 @@ public class NetworkPlayerController : NetworkBehaviour, ITeamMember, IDamageabl
|
||||
private NetworkAnimator _networkAnimator;
|
||||
private PlayerStats _playerStats;
|
||||
private UnitHealthBar _healthBar;
|
||||
private RespawnCountdownUI _respawnCountdownUI;
|
||||
|
||||
// 이 플레이어가 로컬 플레이어인지 확인
|
||||
|
||||
@@ -93,6 +94,12 @@ public class NetworkPlayerController : NetworkBehaviour, ITeamMember, IDamageabl
|
||||
_currentHealth.OnValueChanged += OnHealthChanged;
|
||||
_ownerPlayerId.OnValueChanged += OnOwnerPlayerIdChanged;
|
||||
|
||||
// 로컬 플레이어만 씬에서 리스폰 UI 찾기
|
||||
if (IsLocalPlayer)
|
||||
{
|
||||
_respawnCountdownUI = FindFirstObjectByType<RespawnCountdownUI>();
|
||||
}
|
||||
|
||||
// 체력바 생성
|
||||
if (showHealthBar && healthBarPrefab != null)
|
||||
{
|
||||
@@ -107,6 +114,12 @@ public class NetworkPlayerController : NetworkBehaviour, ITeamMember, IDamageabl
|
||||
{
|
||||
OnOwnerChanged?.Invoke(newValue);
|
||||
TryInitializeLocalPlayer();
|
||||
|
||||
// 로컬 플레이어가 되면 리스폰 UI 참조 가져오기
|
||||
if (IsLocalPlayer && _respawnCountdownUI == null)
|
||||
{
|
||||
_respawnCountdownUI = FindFirstObjectByType<RespawnCountdownUI>();
|
||||
}
|
||||
}
|
||||
|
||||
private void TryInitializeLocalPlayer()
|
||||
@@ -341,12 +354,22 @@ public class NetworkPlayerController : NetworkBehaviour, ITeamMember, IDamageabl
|
||||
[ClientRpc]
|
||||
private void HidePlayerClientRpc()
|
||||
{
|
||||
// 로컬 플레이어만 입력 비활성화
|
||||
if (IsLocalPlayer && _inputActions != null)
|
||||
// 로컬 플레이어만 입력 비활성화 및 UI 표시
|
||||
if (IsLocalPlayer)
|
||||
{
|
||||
if (_inputActions != null)
|
||||
{
|
||||
_inputActions.Disable();
|
||||
}
|
||||
|
||||
// 리스폰 카운트다운 UI 표시
|
||||
if (_respawnCountdownUI != null)
|
||||
{
|
||||
double endServerTime = NetworkManager.Singleton.ServerTime.Time + respawnDelay;
|
||||
_respawnCountdownUI.Show(endServerTime, respawnDelay);
|
||||
}
|
||||
}
|
||||
|
||||
// CharacterController 비활성화 (이동 및 충돌 방지)
|
||||
if (_controller != null)
|
||||
{
|
||||
@@ -367,12 +390,21 @@ public class NetworkPlayerController : NetworkBehaviour, ITeamMember, IDamageabl
|
||||
[ClientRpc]
|
||||
private void ShowPlayerClientRpc()
|
||||
{
|
||||
// 로컬 플레이어만 입력 활성화
|
||||
if (IsLocalPlayer && _inputActions != null)
|
||||
// 로컬 플레이어만 입력 활성화 및 UI 숨김
|
||||
if (IsLocalPlayer)
|
||||
{
|
||||
if (_inputActions != null)
|
||||
{
|
||||
_inputActions.Enable();
|
||||
}
|
||||
|
||||
// 리스폰 카운트다운 UI 숨김
|
||||
if (_respawnCountdownUI != null)
|
||||
{
|
||||
_respawnCountdownUI.Hide();
|
||||
}
|
||||
}
|
||||
|
||||
// CharacterController 활성화
|
||||
if (_controller != null)
|
||||
{
|
||||
|
||||
@@ -18,6 +18,25 @@ public class RespawnCountdownUI : MonoBehaviour
|
||||
private double _endServerTime;
|
||||
private float _duration;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
// 시작할 때는 UI 숨김 (root가 자신이 아닌 경우만)
|
||||
if (root != null && root != gameObject)
|
||||
{
|
||||
root.SetActive(false);
|
||||
}
|
||||
else if (root == gameObject)
|
||||
{
|
||||
// root가 자신인 경우, 자식인 Panel을 사용
|
||||
Transform panelTransform = transform.Find("Panel");
|
||||
if (panelTransform != null)
|
||||
{
|
||||
root = panelTransform.gameObject;
|
||||
root.SetActive(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 외부에서 호출: 사망 시 UI 시작
|
||||
public void Show(double respawnEndServerTime, float durationSeconds)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user