정리 중
This commit is contained in:
@@ -33,6 +33,8 @@ public class RhinoObstacle : MonoBehaviour
|
||||
[SerializeField] private bool startAutomatically = true;
|
||||
[SerializeField] private bool loop = true;
|
||||
[SerializeField] private bool showDebugLog = true;
|
||||
[SerializeField] private bool showLifecycleDebugLog = false;
|
||||
[SerializeField] private bool showRoutineDebugLog = false;
|
||||
|
||||
private Coroutine routine;
|
||||
private bool isRunning;
|
||||
@@ -82,19 +84,25 @@ private void ResolveReferences()
|
||||
|
||||
public void StartRhino()
|
||||
{
|
||||
if (isRunning && routine != null)
|
||||
return;
|
||||
|
||||
if (routine != null)
|
||||
{
|
||||
StopCoroutine(routine);
|
||||
routine = null;
|
||||
}
|
||||
|
||||
isRunning = true;
|
||||
routine = StartCoroutine(RhinoRoutine());
|
||||
|
||||
Log("시작");
|
||||
Log("Start");
|
||||
}
|
||||
|
||||
public void StopRhino()
|
||||
{
|
||||
bool wasActive = isRunning || routine != null || isSurfaced;
|
||||
|
||||
isRunning = false;
|
||||
|
||||
if (routine != null)
|
||||
@@ -107,7 +115,10 @@ public void StopRhino()
|
||||
ForceIdleAnimation();
|
||||
MoveImmediatelyToUnderwater();
|
||||
|
||||
Log("정지");
|
||||
if (wasActive)
|
||||
{
|
||||
Log("Stop");
|
||||
}
|
||||
}
|
||||
|
||||
private IEnumerator RhinoRoutine()
|
||||
@@ -120,7 +131,7 @@ private IEnumerator RhinoRoutine()
|
||||
ForceIdleAnimation();
|
||||
|
||||
float hiddenWait = Random.Range(minHiddenTime, maxHiddenTime);
|
||||
Log($"물속 대기 {hiddenWait:0.0}초");
|
||||
LogRoutine($"물속 대기 {hiddenWait:0.0}초");
|
||||
|
||||
yield return new WaitForSeconds(hiddenWait);
|
||||
|
||||
@@ -128,7 +139,7 @@ private IEnumerator RhinoRoutine()
|
||||
break;
|
||||
|
||||
// 2. 수면 위로 떠오름
|
||||
Log("떠오름 시작");
|
||||
LogRoutine("떠오름 시작");
|
||||
yield return MoveToSurface();
|
||||
|
||||
if (!isRunning)
|
||||
@@ -139,7 +150,7 @@ private IEnumerator RhinoRoutine()
|
||||
SetDamageActive(true);
|
||||
ForceIdleAnimation();
|
||||
|
||||
Log("수면 위 도착 / 데미지 콜라이더 ON");
|
||||
LogRoutine("수면 위 도착 / 데미지 콜라이더 ON");
|
||||
|
||||
yield return new WaitForSeconds(surfaceIdleTime);
|
||||
|
||||
@@ -147,13 +158,13 @@ private IEnumerator RhinoRoutine()
|
||||
break;
|
||||
|
||||
// 4. 공격 실행
|
||||
Log("공격 시작");
|
||||
LogRoutine("공격 시작");
|
||||
PlayHitAnimation();
|
||||
|
||||
yield return new WaitForSeconds(attackStayTime);
|
||||
|
||||
// 5. 공격 종료 후 Idle 복귀
|
||||
Log("공격 종료 / Idle 복귀");
|
||||
LogRoutine("공격 종료 / Idle 복귀");
|
||||
ForceIdleAnimation();
|
||||
|
||||
if (!isRunning)
|
||||
@@ -163,7 +174,7 @@ private IEnumerator RhinoRoutine()
|
||||
isSurfaced = false;
|
||||
SetDamageActive(false);
|
||||
|
||||
Log("잠수 시작 / 데미지 콜라이더 OFF");
|
||||
LogRoutine("잠수 시작 / 데미지 콜라이더 OFF");
|
||||
yield return MoveToUnderwater();
|
||||
|
||||
if (!loop)
|
||||
@@ -228,7 +239,7 @@ private IEnumerator MoveToUnderwater()
|
||||
SetDamageActive(false);
|
||||
ForceIdleAnimation();
|
||||
|
||||
Log("잠수 완료");
|
||||
LogRoutine("잠수 완료");
|
||||
}
|
||||
|
||||
private void PlayHitAnimation()
|
||||
@@ -298,7 +309,13 @@ private float Smooth01(float t)
|
||||
|
||||
private void Log(string message)
|
||||
{
|
||||
if (showDebugLog)
|
||||
if (showDebugLog && showLifecycleDebugLog)
|
||||
Debug.Log($"[RhinoObstacle] {name} / {message}");
|
||||
}
|
||||
|
||||
private void LogRoutine(string message)
|
||||
{
|
||||
if (showDebugLog && showRoutineDebugLog)
|
||||
Debug.Log($"[RhinoObstacle] {name} / {message}");
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user