2026.06.25 Fishing scene
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using UnityEngine;
|
||||
using UnityEngine.InputSystem;
|
||||
@@ -11,12 +12,29 @@ public enum ResultType
|
||||
Miss
|
||||
}
|
||||
|
||||
[Header("Auto Bind")]
|
||||
[Tooltip("현재 만든 Prefab 구조 기준으로 비어 있는 참조를 자동 연결합니다.")]
|
||||
[SerializeField] private bool autoBindMissingReferences = true;
|
||||
|
||||
[Header("References")]
|
||||
[Tooltip("낚시 UI 전체 루트입니다. UI를 자동으로 켜고 끄고 싶을 때만 연결하세요.")]
|
||||
[SerializeField] private GameObject uiRoot;
|
||||
|
||||
[SerializeField] private FishingGaugeUI ui;
|
||||
[SerializeField] private FishingRewardSystem rewardSystem;
|
||||
[SerializeField] private FishingHapticManager haptic;
|
||||
[SerializeField] private RotateUI centerIconRotate;
|
||||
|
||||
[Header("XR Controller Input")]
|
||||
[Tooltip("낚시 판정을 실행할 컨트롤러 입력입니다. 예: XRI Right Interaction / Select")]
|
||||
[SerializeField] private InputActionReference submitAction;
|
||||
|
||||
[Tooltip("낚시를 다시 시작할 컨트롤러 입력입니다. 필요 없으면 비워둬도 됩니다.")]
|
||||
[SerializeField] private InputActionReference resetAction;
|
||||
|
||||
[Tooltip("씬에 Input Action Manager가 없거나 액션이 자동 활성화되지 않으면 켜두세요.")]
|
||||
[SerializeField] private bool enableInputActionsManually = true;
|
||||
|
||||
[Header("Pointer")]
|
||||
[SerializeField] private float pointerAngle;
|
||||
[SerializeField] private float pointerSpeed = 180f;
|
||||
@@ -30,29 +48,97 @@ public enum ResultType
|
||||
[SerializeField] private float maxZoneSize = 120f;
|
||||
[SerializeField] private float zoneCenter;
|
||||
|
||||
[Header("Rules")]
|
||||
[Header("Catch Rules")]
|
||||
[Tooltip("아이템 1개를 낚기 위해 필요한 성공 횟수입니다.")]
|
||||
[SerializeField] private int requiredSuccesses = 3;
|
||||
|
||||
[Tooltip("아이템 1개를 낚는 동안 허용되는 실패 횟수입니다. 초과하면 낚싯줄이 끊어진 것으로 처리합니다.")]
|
||||
[SerializeField] private int allowedFails = 3;
|
||||
|
||||
[Header("Pond Cleanup Rules")]
|
||||
[Tooltip("연못을 맑게 만들기 위해 필요한 쓰레기성 아이템 수입니다. 쓰레기, 병, 봉지가 여기에 포함됩니다.")]
|
||||
[SerializeField] private int requiredCleanupItems = 3;
|
||||
|
||||
[Tooltip("연못이 맑아진 뒤 다음 성공 낚시에서 기억의 조각을 확정으로 낚습니다.")]
|
||||
[SerializeField] private bool guaranteeMemoryPieceAfterCleaned = true;
|
||||
|
||||
[Tooltip("StartFishing을 호출할 때 쓰레기 수거/연못 상태를 초기화합니다.")]
|
||||
[SerializeField] private bool resetPondStateOnStart = true;
|
||||
|
||||
[Header("Round Settings")]
|
||||
[SerializeField] private float nextRoundDelay = 0.35f;
|
||||
[SerializeField] private float nextCatchDelay = 2.0f;
|
||||
[SerializeField] private bool randomDirectionEachRound = true;
|
||||
[SerializeField] private bool resetDifficultyEachCatch = true;
|
||||
[SerializeField] private bool startOnAwake = true;
|
||||
|
||||
[Header("Final Result Settings")]
|
||||
[Tooltip("최종 결과를 잠깐 보여준 뒤 uiRoot를 자동으로 끕니다. uiRoot가 비어 있으면 동작하지 않습니다.")]
|
||||
[SerializeField] private bool hideUIRootAfterFinalResult = false;
|
||||
|
||||
[SerializeField] private float finalResultShowTime = 1.5f;
|
||||
|
||||
[Header("Debug")]
|
||||
[SerializeField] private bool showDebugLog = true;
|
||||
|
||||
private int successCount;
|
||||
private int failCount;
|
||||
private int cleanupItemCount;
|
||||
private int totalCaughtItems;
|
||||
|
||||
// 임시 낚시 세션 카운트입니다. 나중에 공용 인벤토리와 연결할 때는 저장용으로 쓰지 말고 UI 표시용으로만 쓰세요.
|
||||
private int sessionFishCount;
|
||||
private int sessionTrashCount;
|
||||
private int sessionMemoryPieceCount;
|
||||
private int sessionCompassCount;
|
||||
|
||||
private bool clockwise = true;
|
||||
private bool activeGame;
|
||||
private bool inputLocked;
|
||||
private bool pondCleaned;
|
||||
private bool memoryPieceCollected;
|
||||
|
||||
private bool submitActionWasEnabled;
|
||||
private bool resetActionWasEnabled;
|
||||
|
||||
private Coroutine nextRoundRoutine;
|
||||
private Coroutine nextCatchRoutine;
|
||||
private Coroutine finalResultRoutine;
|
||||
|
||||
public bool IsActiveGame => activeGame;
|
||||
public bool IsPondCleaned => pondCleaned;
|
||||
public bool IsMemoryPieceCollected => memoryPieceCollected;
|
||||
public int SuccessCount => successCount;
|
||||
public int FailCount => failCount;
|
||||
public int CleanupItemCount => cleanupItemCount;
|
||||
public int RequiredCleanupItems => requiredCleanupItems;
|
||||
public int TotalCaughtItems => totalCaughtItems;
|
||||
public int SessionFishCount => sessionFishCount;
|
||||
public int SessionTrashCount => sessionTrashCount;
|
||||
public int SessionMemoryPieceCount => sessionMemoryPieceCount;
|
||||
public int SessionCompassCount => sessionCompassCount;
|
||||
|
||||
public event Action<FishingItemType, int> ItemCaught;
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
RegisterInputAction(submitAction, OnSubmitAction, ref submitActionWasEnabled);
|
||||
RegisterInputAction(resetAction, OnResetAction, ref resetActionWasEnabled);
|
||||
}
|
||||
|
||||
private void OnDisable()
|
||||
{
|
||||
UnregisterInputAction(submitAction, OnSubmitAction, submitActionWasEnabled);
|
||||
UnregisterInputAction(resetAction, OnResetAction, resetActionWasEnabled);
|
||||
}
|
||||
|
||||
private void Start()
|
||||
{
|
||||
if (autoBindMissingReferences)
|
||||
AutoBindMissingReferences();
|
||||
|
||||
ValidateRuntimeSettings();
|
||||
|
||||
if (startOnAwake)
|
||||
{
|
||||
StartFishing();
|
||||
@@ -74,13 +160,137 @@ private void Update()
|
||||
RotatePointer();
|
||||
}
|
||||
|
||||
private void OnValidate()
|
||||
{
|
||||
ValidateRuntimeSettings();
|
||||
}
|
||||
|
||||
|
||||
|
||||
[ContextMenu("Auto Bind Fishing References")]
|
||||
public void AutoBindMissingReferences()
|
||||
{
|
||||
Transform searchRoot = GetSearchRoot();
|
||||
|
||||
if (uiRoot == null)
|
||||
{
|
||||
Transform canvasTransform = FindTransformRecursive(searchRoot, "FishingCanvas");
|
||||
if (canvasTransform != null)
|
||||
uiRoot = canvasTransform.gameObject;
|
||||
}
|
||||
|
||||
if (ui == null)
|
||||
ui = searchRoot != null ? searchRoot.GetComponentInChildren<FishingGaugeUI>(true) : GetComponentInChildren<FishingGaugeUI>(true);
|
||||
|
||||
if (rewardSystem == null)
|
||||
rewardSystem = searchRoot != null ? searchRoot.GetComponentInChildren<FishingRewardSystem>(true) : GetComponentInChildren<FishingRewardSystem>(true);
|
||||
|
||||
if (haptic == null)
|
||||
haptic = searchRoot != null ? searchRoot.GetComponentInChildren<FishingHapticManager>(true) : GetComponentInChildren<FishingHapticManager>(true);
|
||||
|
||||
if (centerIconRotate == null)
|
||||
{
|
||||
Transform centerIconTransform = FindTransformRecursive(searchRoot, "CenterIcon");
|
||||
if (centerIconTransform != null)
|
||||
centerIconRotate = centerIconTransform.GetComponent<RotateUI>();
|
||||
|
||||
if (centerIconRotate == null && searchRoot != null)
|
||||
centerIconRotate = searchRoot.GetComponentInChildren<RotateUI>(true);
|
||||
}
|
||||
}
|
||||
|
||||
private Transform GetSearchRoot()
|
||||
{
|
||||
Transform current = transform;
|
||||
|
||||
while (current.parent != null)
|
||||
current = current.parent;
|
||||
|
||||
return current;
|
||||
}
|
||||
|
||||
private Transform FindTransformRecursive(Transform current, string targetName)
|
||||
{
|
||||
if (current == null || string.IsNullOrEmpty(targetName))
|
||||
return null;
|
||||
|
||||
if (NormalizeName(current.name) == NormalizeName(targetName))
|
||||
return current;
|
||||
|
||||
for (int i = 0; i < current.childCount; i++)
|
||||
{
|
||||
Transform found = FindTransformRecursive(current.GetChild(i), targetName);
|
||||
if (found != null)
|
||||
return found;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private string NormalizeName(string value)
|
||||
{
|
||||
return value.Replace(" ", string.Empty)
|
||||
.Replace("_", string.Empty)
|
||||
.Replace("-", string.Empty)
|
||||
.ToLowerInvariant();
|
||||
}
|
||||
|
||||
private void RegisterInputAction(InputActionReference actionReference, System.Action<InputAction.CallbackContext> callback, ref bool wasEnabled)
|
||||
{
|
||||
if (actionReference == null || actionReference.action == null)
|
||||
return;
|
||||
|
||||
wasEnabled = actionReference.action.enabled;
|
||||
actionReference.action.performed += callback;
|
||||
|
||||
if (enableInputActionsManually && !wasEnabled)
|
||||
actionReference.action.Enable();
|
||||
}
|
||||
|
||||
private void UnregisterInputAction(InputActionReference actionReference, System.Action<InputAction.CallbackContext> callback, bool wasEnabled)
|
||||
{
|
||||
if (actionReference == null || actionReference.action == null)
|
||||
return;
|
||||
|
||||
actionReference.action.performed -= callback;
|
||||
|
||||
if (enableInputActionsManually && !wasEnabled)
|
||||
actionReference.action.Disable();
|
||||
}
|
||||
|
||||
private void ValidateRuntimeSettings()
|
||||
{
|
||||
requiredSuccesses = Mathf.Max(1, requiredSuccesses);
|
||||
allowedFails = Mathf.Max(1, allowedFails);
|
||||
requiredCleanupItems = Mathf.Max(1, requiredCleanupItems);
|
||||
|
||||
minSpeed = Mathf.Max(1f, minSpeed);
|
||||
maxSpeed = Mathf.Max(minSpeed, maxSpeed);
|
||||
pointerSpeed = Mathf.Clamp(pointerSpeed, minSpeed, maxSpeed);
|
||||
|
||||
minZoneSize = Mathf.Clamp(minZoneSize, 1f, 360f);
|
||||
maxZoneSize = Mathf.Clamp(maxZoneSize, minZoneSize, 360f);
|
||||
startZoneSize = Mathf.Clamp(startZoneSize, minZoneSize, maxZoneSize);
|
||||
zoneSize = Mathf.Clamp(zoneSize, minZoneSize, maxZoneSize);
|
||||
|
||||
nextRoundDelay = Mathf.Max(0f, nextRoundDelay);
|
||||
nextCatchDelay = Mathf.Max(0f, nextCatchDelay);
|
||||
finalResultShowTime = Mathf.Max(0f, finalResultShowTime);
|
||||
|
||||
pointerAngle = Normalize(pointerAngle);
|
||||
zoneCenter = Normalize(zoneCenter);
|
||||
cleanupItemCount = Mathf.Max(0, cleanupItemCount);
|
||||
totalCaughtItems = Mathf.Max(0, totalCaughtItems);
|
||||
}
|
||||
|
||||
private void InitializeIdleUI()
|
||||
{
|
||||
if (ui != null)
|
||||
{
|
||||
ui.HideRoundResult();
|
||||
ui.HideFinalResult();
|
||||
ui.InitializeFishingUI();
|
||||
ui.UpdateCounter(0, requiredSuccesses, 0, allowedFails);
|
||||
ui.UpdateFishingProgress(cleanupItemCount, requiredCleanupItems, pondCleaned, memoryPieceCollected, totalCaughtItems);
|
||||
ui.UpdateInventoryUI(sessionFishCount, sessionTrashCount, sessionMemoryPieceCount, sessionCompassCount);
|
||||
ui.SetPointerRotation(0f);
|
||||
ui.SetZone(0f, startZoneSize);
|
||||
}
|
||||
@@ -91,30 +301,73 @@ private void InitializeIdleUI()
|
||||
|
||||
public void StartFishing()
|
||||
{
|
||||
if (nextRoundRoutine != null)
|
||||
{
|
||||
StopCoroutine(nextRoundRoutine);
|
||||
nextRoundRoutine = null;
|
||||
}
|
||||
ValidateRuntimeSettings();
|
||||
StopRunningRoutines();
|
||||
|
||||
successCount = 0;
|
||||
failCount = 0;
|
||||
if (uiRoot != null)
|
||||
uiRoot.SetActive(true);
|
||||
|
||||
pointerAngle = 0f;
|
||||
pointerSpeed = minSpeed;
|
||||
zoneSize = startZoneSize;
|
||||
|
||||
activeGame = true;
|
||||
inputLocked = false;
|
||||
|
||||
clockwise = Random.value > 0.5f;
|
||||
if (resetPondStateOnStart)
|
||||
ResetPondState();
|
||||
|
||||
if (ui != null)
|
||||
ui.InitializeFishingUI();
|
||||
|
||||
StartNewCatchAttempt();
|
||||
|
||||
if (showDebugLog)
|
||||
Debug.Log("기묘한 낚시터 시작");
|
||||
}
|
||||
|
||||
public void StopFishing(bool hideUI = false)
|
||||
{
|
||||
StopRunningRoutines();
|
||||
|
||||
activeGame = false;
|
||||
inputLocked = true;
|
||||
|
||||
if (centerIconRotate != null)
|
||||
centerIconRotate.StopRotate();
|
||||
|
||||
if (hideUI && uiRoot != null)
|
||||
uiRoot.SetActive(false);
|
||||
}
|
||||
|
||||
public void ResetFishing()
|
||||
{
|
||||
StartFishing();
|
||||
}
|
||||
|
||||
public void ResetPondState()
|
||||
{
|
||||
successCount = 0;
|
||||
failCount = 0;
|
||||
cleanupItemCount = 0;
|
||||
totalCaughtItems = 0;
|
||||
sessionFishCount = 0;
|
||||
sessionTrashCount = 0;
|
||||
sessionMemoryPieceCount = 0;
|
||||
sessionCompassCount = 0;
|
||||
pondCleaned = false;
|
||||
memoryPieceCollected = false;
|
||||
}
|
||||
|
||||
private void StartNewCatchAttempt()
|
||||
{
|
||||
successCount = 0;
|
||||
failCount = 0;
|
||||
inputLocked = false;
|
||||
activeGame = true;
|
||||
|
||||
if (resetDifficultyEachCatch)
|
||||
{
|
||||
ui.HideRoundResult();
|
||||
ui.HideFinalResult();
|
||||
pointerAngle = 0f;
|
||||
pointerSpeed = minSpeed;
|
||||
zoneSize = startZoneSize;
|
||||
}
|
||||
|
||||
clockwise = UnityEngine.Random.value > 0.5f;
|
||||
|
||||
if (centerIconRotate != null)
|
||||
{
|
||||
centerIconRotate.ResetRotation();
|
||||
@@ -123,9 +376,27 @@ public void StartFishing()
|
||||
|
||||
RandomizeZone();
|
||||
UpdateUI();
|
||||
}
|
||||
|
||||
if (showDebugLog)
|
||||
Debug.Log("낚시 시작");
|
||||
private void StopRunningRoutines()
|
||||
{
|
||||
if (nextRoundRoutine != null)
|
||||
{
|
||||
StopCoroutine(nextRoundRoutine);
|
||||
nextRoundRoutine = null;
|
||||
}
|
||||
|
||||
if (nextCatchRoutine != null)
|
||||
{
|
||||
StopCoroutine(nextCatchRoutine);
|
||||
nextCatchRoutine = null;
|
||||
}
|
||||
|
||||
if (finalResultRoutine != null)
|
||||
{
|
||||
StopCoroutine(finalResultRoutine);
|
||||
finalResultRoutine = null;
|
||||
}
|
||||
}
|
||||
|
||||
private void RotatePointer()
|
||||
@@ -149,8 +420,17 @@ public void SubmitAttempt()
|
||||
|
||||
inputLocked = true;
|
||||
|
||||
if (ui != null)
|
||||
ui.HideControllerGuide();
|
||||
|
||||
ResultType result = EvaluateResult();
|
||||
|
||||
if (ui != null)
|
||||
{
|
||||
ui.ShowResultForType(result);
|
||||
ui.FlashFeedbackForType(result);
|
||||
}
|
||||
|
||||
switch (result)
|
||||
{
|
||||
case ResultType.Perfect:
|
||||
@@ -168,7 +448,7 @@ public void SubmitAttempt()
|
||||
|
||||
if (successCount >= requiredSuccesses)
|
||||
{
|
||||
FishingSuccess();
|
||||
CatchItemSuccess();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -207,11 +487,8 @@ private void OnPerfect()
|
||||
if (haptic != null)
|
||||
haptic.Perfect();
|
||||
|
||||
if (ui != null)
|
||||
ui.ShowResult("완벽!");
|
||||
|
||||
if (showDebugLog)
|
||||
Debug.Log("낚시 판정: Perfect");
|
||||
Debug.Log("낚시 판정: Perfect");
|
||||
|
||||
ClampDifficulty();
|
||||
UpdateUI();
|
||||
@@ -227,11 +504,8 @@ private void OnGood()
|
||||
if (haptic != null)
|
||||
haptic.Good();
|
||||
|
||||
if (ui != null)
|
||||
ui.ShowResult("성공!");
|
||||
|
||||
if (showDebugLog)
|
||||
Debug.Log("낚시 판정: Good");
|
||||
Debug.Log("낚시 판정: Good");
|
||||
|
||||
ClampDifficulty();
|
||||
UpdateUI();
|
||||
@@ -247,11 +521,8 @@ private void OnMiss()
|
||||
if (haptic != null)
|
||||
haptic.Miss();
|
||||
|
||||
if (ui != null)
|
||||
ui.ShowResult("실패!");
|
||||
|
||||
if (showDebugLog)
|
||||
Debug.Log("낚시 판정: Miss");
|
||||
Debug.Log("낚시 판정: Miss");
|
||||
|
||||
ClampDifficulty();
|
||||
UpdateUI();
|
||||
@@ -262,10 +533,13 @@ private IEnumerator NextRoundRoutine()
|
||||
yield return new WaitForSeconds(nextRoundDelay);
|
||||
|
||||
if (!activeGame)
|
||||
{
|
||||
nextRoundRoutine = null;
|
||||
yield break;
|
||||
}
|
||||
|
||||
if (randomDirectionEachRound)
|
||||
clockwise = Random.value > 0.5f;
|
||||
clockwise = UnityEngine.Random.value > 0.5f;
|
||||
|
||||
RandomizeZone();
|
||||
UpdateUI();
|
||||
@@ -274,6 +548,122 @@ private IEnumerator NextRoundRoutine()
|
||||
nextRoundRoutine = null;
|
||||
}
|
||||
|
||||
private void CatchItemSuccess()
|
||||
{
|
||||
activeGame = false;
|
||||
inputLocked = true;
|
||||
|
||||
if (centerIconRotate != null)
|
||||
centerIconRotate.StopRotate();
|
||||
|
||||
bool forceMemoryPiece = pondCleaned && guaranteeMemoryPieceAfterCleaned && !memoryPieceCollected;
|
||||
|
||||
FishingRewardSystem.CatchResult catchResult;
|
||||
|
||||
if (rewardSystem != null)
|
||||
catchResult = rewardSystem.RollCatch(pondCleaned, forceMemoryPiece);
|
||||
else
|
||||
catchResult = new FishingRewardSystem.CatchResult(FishingItemType.Fish, "생선", false, false);
|
||||
|
||||
ApplyCatchResult(catchResult);
|
||||
}
|
||||
|
||||
private void ApplyCatchResult(FishingRewardSystem.CatchResult catchResult)
|
||||
{
|
||||
totalCaughtItems++;
|
||||
|
||||
AddToSessionCounts(catchResult.ItemType);
|
||||
ItemCaught?.Invoke(catchResult.ItemType, 1);
|
||||
|
||||
bool pondJustCleaned = false;
|
||||
string extraHint = string.Empty;
|
||||
|
||||
if (catchResult.CountsAsCleanupItem)
|
||||
{
|
||||
cleanupItemCount = Mathf.Min(cleanupItemCount + 1, requiredCleanupItems);
|
||||
extraHint = $"연못 정화 {cleanupItemCount}/{requiredCleanupItems}";
|
||||
|
||||
if (!pondCleaned && cleanupItemCount >= requiredCleanupItems)
|
||||
{
|
||||
pondCleaned = true;
|
||||
pondJustCleaned = true;
|
||||
extraHint = "연못이 맑아졌다. 기억의 조각이 모습을 드러낸다.";
|
||||
}
|
||||
}
|
||||
|
||||
if (catchResult.IsMemoryPiece)
|
||||
{
|
||||
memoryPieceCollected = true;
|
||||
extraHint = "잃어버린 기억의 일부다.";
|
||||
}
|
||||
|
||||
UpdateUI();
|
||||
|
||||
if (ui != null)
|
||||
{
|
||||
ui.HighlightSlotForItem(catchResult.ItemType);
|
||||
|
||||
if (!catchResult.IsMemoryPiece)
|
||||
ui.ShowCaughtItem(catchResult.ItemType, catchResult.DisplayName, catchResult.CountsAsCleanupItem, extraHint);
|
||||
|
||||
if (pondJustCleaned)
|
||||
ui.ShowNotice("연못이 맑아졌다!\n기억의 조각이 모습을 드러냈다!");
|
||||
|
||||
// 기억의 조각 획득은 FinalResultPanel에서 크게 보여줍니다.
|
||||
// NoticePanel까지 동시에 띄우면 ShowFinalResult에서 바로 숨겨져 연출이 겹칠 수 있습니다.
|
||||
}
|
||||
|
||||
if (showDebugLog)
|
||||
Debug.Log($"{catchResult.DisplayName}을(를) 낚았다!");
|
||||
|
||||
if (catchResult.IsMemoryPiece)
|
||||
{
|
||||
FishingSuccess();
|
||||
return;
|
||||
}
|
||||
|
||||
nextCatchRoutine = StartCoroutine(NextCatchRoutine());
|
||||
}
|
||||
|
||||
private IEnumerator NextCatchRoutine()
|
||||
{
|
||||
yield return new WaitForSeconds(nextCatchDelay);
|
||||
|
||||
if (memoryPieceCollected)
|
||||
{
|
||||
nextCatchRoutine = null;
|
||||
yield break;
|
||||
}
|
||||
|
||||
StartNewCatchAttempt();
|
||||
nextCatchRoutine = null;
|
||||
}
|
||||
|
||||
|
||||
private void AddToSessionCounts(FishingItemType itemType)
|
||||
{
|
||||
switch (itemType)
|
||||
{
|
||||
case FishingItemType.Fish:
|
||||
sessionFishCount++;
|
||||
break;
|
||||
|
||||
case FishingItemType.Trash:
|
||||
case FishingItemType.Bottle:
|
||||
case FishingItemType.PlasticBag:
|
||||
sessionTrashCount++;
|
||||
break;
|
||||
|
||||
case FishingItemType.MemoryPiece:
|
||||
sessionMemoryPieceCount++;
|
||||
break;
|
||||
|
||||
case FishingItemType.OldCompass:
|
||||
sessionCompassCount++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void ClampDifficulty()
|
||||
{
|
||||
zoneSize = Mathf.Clamp(zoneSize, minZoneSize, maxZoneSize);
|
||||
@@ -282,7 +672,7 @@ private void ClampDifficulty()
|
||||
|
||||
private void RandomizeZone()
|
||||
{
|
||||
zoneCenter = Random.Range(0f, 360f);
|
||||
zoneCenter = UnityEngine.Random.Range(0f, 360f);
|
||||
}
|
||||
|
||||
private void UpdateUI()
|
||||
@@ -292,6 +682,8 @@ private void UpdateUI()
|
||||
|
||||
ui.SetZone(zoneCenter, zoneSize);
|
||||
ui.UpdateCounter(successCount, requiredSuccesses, failCount, allowedFails);
|
||||
ui.UpdateFishingProgress(cleanupItemCount, requiredCleanupItems, pondCleaned, memoryPieceCollected, totalCaughtItems);
|
||||
ui.UpdateInventoryUI(sessionFishCount, sessionTrashCount, sessionMemoryPieceCount, sessionCompassCount);
|
||||
}
|
||||
|
||||
private void FishingSuccess()
|
||||
@@ -302,14 +694,15 @@ private void FishingSuccess()
|
||||
if (centerIconRotate != null)
|
||||
centerIconRotate.StopRotate();
|
||||
|
||||
if (ui != null)
|
||||
ui.ShowFinalResult("낚시 성공!");
|
||||
UpdateUI();
|
||||
|
||||
if (rewardSystem != null)
|
||||
rewardSystem.GiveReward();
|
||||
if (ui != null)
|
||||
ui.ShowFinalResult("기억의 조각 획득!\n기묘한 낚시터 클리어!");
|
||||
|
||||
if (showDebugLog)
|
||||
Debug.Log("낚시 최종 성공");
|
||||
Debug.Log("기묘한 낚시터 클리어");
|
||||
|
||||
BeginFinalResultRoutineIfNeeded();
|
||||
}
|
||||
|
||||
private void FishingFail()
|
||||
@@ -321,15 +714,33 @@ private void FishingFail()
|
||||
centerIconRotate.StopRotate();
|
||||
|
||||
if (ui != null)
|
||||
ui.ShowFinalResult("낚시 실패!");
|
||||
ui.ShowFinalResult("낚싯줄이 끊어졌다!\n다시 천천히 낚아보자.");
|
||||
|
||||
if (showDebugLog)
|
||||
Debug.Log("낚시 최종 실패");
|
||||
Debug.Log("낚시 실패: 낚싯줄 끊어짐");
|
||||
|
||||
BeginFinalResultRoutineIfNeeded();
|
||||
}
|
||||
|
||||
public void ResetFishing()
|
||||
private void BeginFinalResultRoutineIfNeeded()
|
||||
{
|
||||
StartFishing();
|
||||
if (!hideUIRootAfterFinalResult || uiRoot == null)
|
||||
return;
|
||||
|
||||
if (finalResultRoutine != null)
|
||||
StopCoroutine(finalResultRoutine);
|
||||
|
||||
finalResultRoutine = StartCoroutine(HideUIRootAfterFinalResultRoutine());
|
||||
}
|
||||
|
||||
private IEnumerator HideUIRootAfterFinalResultRoutine()
|
||||
{
|
||||
yield return new WaitForSeconds(finalResultShowTime);
|
||||
|
||||
if (uiRoot != null)
|
||||
uiRoot.SetActive(false);
|
||||
|
||||
finalResultRoutine = null;
|
||||
}
|
||||
|
||||
private float Normalize(float angle)
|
||||
@@ -342,17 +753,13 @@ private float Normalize(float angle)
|
||||
return angle;
|
||||
}
|
||||
|
||||
// XR Input Action의 Select / Trigger 버튼에 연결
|
||||
public void OnSubmit(InputValue value)
|
||||
private void OnSubmitAction(InputAction.CallbackContext context)
|
||||
{
|
||||
if (value.isPressed)
|
||||
SubmitAttempt();
|
||||
SubmitAttempt();
|
||||
}
|
||||
|
||||
// Reset 버튼에 연결 가능
|
||||
public void OnReset(InputValue value)
|
||||
private void OnResetAction(InputAction.CallbackContext context)
|
||||
{
|
||||
if (value.isPressed)
|
||||
ResetFishing();
|
||||
ResetFishing();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user