사망 시 사망 UI 출력
This commit is contained in:
@@ -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,10 +354,20 @@ public class NetworkPlayerController : NetworkBehaviour, ITeamMember, IDamageabl
|
||||
[ClientRpc]
|
||||
private void HidePlayerClientRpc()
|
||||
{
|
||||
// 로컬 플레이어만 입력 비활성화
|
||||
if (IsLocalPlayer && _inputActions != null)
|
||||
// 로컬 플레이어만 입력 비활성화 및 UI 표시
|
||||
if (IsLocalPlayer)
|
||||
{
|
||||
_inputActions.Disable();
|
||||
if (_inputActions != null)
|
||||
{
|
||||
_inputActions.Disable();
|
||||
}
|
||||
|
||||
// 리스폰 카운트다운 UI 표시
|
||||
if (_respawnCountdownUI != null)
|
||||
{
|
||||
double endServerTime = NetworkManager.Singleton.ServerTime.Time + respawnDelay;
|
||||
_respawnCountdownUI.Show(endServerTime, respawnDelay);
|
||||
}
|
||||
}
|
||||
|
||||
// CharacterController 비활성화 (이동 및 충돌 방지)
|
||||
@@ -367,10 +390,19 @@ public class NetworkPlayerController : NetworkBehaviour, ITeamMember, IDamageabl
|
||||
[ClientRpc]
|
||||
private void ShowPlayerClientRpc()
|
||||
{
|
||||
// 로컬 플레이어만 입력 활성화
|
||||
if (IsLocalPlayer && _inputActions != null)
|
||||
// 로컬 플레이어만 입력 활성화 및 UI 숨김
|
||||
if (IsLocalPlayer)
|
||||
{
|
||||
_inputActions.Enable();
|
||||
if (_inputActions != null)
|
||||
{
|
||||
_inputActions.Enable();
|
||||
}
|
||||
|
||||
// 리스폰 카운트다운 UI 숨김
|
||||
if (_respawnCountdownUI != null)
|
||||
{
|
||||
_respawnCountdownUI.Hide();
|
||||
}
|
||||
}
|
||||
|
||||
// CharacterController 활성화
|
||||
|
||||
@@ -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