타이머에 처음 시작 시간 추가
적 포탈 위치 조정
This commit is contained in:
@@ -15,10 +15,12 @@ namespace Northbound
|
||||
public float cycleLength = 60f; // 한 주기 길이 (초)
|
||||
public bool autoStart = true;
|
||||
public bool pauseOnZero = false; // 0에 도달하면 일시정지
|
||||
public float exceptionalFirstCycleLength = 0;
|
||||
|
||||
[Header("Debug")]
|
||||
public bool showDebugLogs = false;
|
||||
|
||||
|
||||
// 현재 타이머 값 (초)
|
||||
private NetworkVariable<float> _currentTime = new NetworkVariable<float>(
|
||||
0f,
|
||||
@@ -47,6 +49,7 @@ namespace Northbound
|
||||
public event Action<float> OnHalfwayPoint; // 사이클 중간 지점
|
||||
|
||||
private bool _hasReachedHalfway;
|
||||
private bool _isFirstTime = true;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
@@ -56,6 +59,8 @@ namespace Northbound
|
||||
return;
|
||||
}
|
||||
Instance = this;
|
||||
|
||||
_isFirstTime = exceptionalFirstCycleLength > 0 ? true : false;
|
||||
}
|
||||
|
||||
public override void OnNetworkSpawn()
|
||||
@@ -83,23 +88,33 @@ namespace Northbound
|
||||
|
||||
_currentTime.Value -= Time.deltaTime;
|
||||
|
||||
// 중간 지점 체크
|
||||
if (!_hasReachedHalfway && _currentTime.Value <= cycleLength / 2f)
|
||||
if (_isFirstTime)
|
||||
{
|
||||
_hasReachedHalfway = true;
|
||||
OnHalfwayPoint?.Invoke(cycleLength / 2f);
|
||||
NotifyHalfwayClientRpc();
|
||||
|
||||
if (showDebugLogs)
|
||||
Debug.Log($"<color=yellow>[GlobalTimer] 사이클 중간 지점 도달</color>");
|
||||
if (_currentTime.Value + exceptionalFirstCycleLength < cycleLength)
|
||||
{
|
||||
_isFirstTime = false;
|
||||
CompleteCycle();
|
||||
}
|
||||
}
|
||||
|
||||
// 사이클 완료
|
||||
if (_currentTime.Value <= 0f)
|
||||
else
|
||||
{
|
||||
CompleteCycle();
|
||||
}
|
||||
// 중간 지점 체크
|
||||
if (!_hasReachedHalfway && _currentTime.Value <= cycleLength / 2f)
|
||||
{
|
||||
_hasReachedHalfway = true;
|
||||
OnHalfwayPoint?.Invoke(cycleLength / 2f);
|
||||
NotifyHalfwayClientRpc();
|
||||
|
||||
if (showDebugLogs)
|
||||
Debug.Log($"<color=yellow>[GlobalTimer] 사이클 중간 지점 도달</color>");
|
||||
}
|
||||
|
||||
// 사이클 완료
|
||||
if (_currentTime.Value <= 0f)
|
||||
{
|
||||
CompleteCycle();
|
||||
}
|
||||
}
|
||||
OnTimerTick?.Invoke(_currentTime.Value);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user