Quest
모든 퀘스트 상태와 진행도를 관리
퀘스트별 진행도는 questId 기준으로 Dictionary에 저장
Dictionary<int, QuestProgress> questProgress;
Dictionary<int, QuestState> questStates;
퀘스트마다 현재 진행도 / 목표치 보관
class QuestProgress
{
public int Current;
public int Target;
}
QuestTrackerUI
UI는 숫자만 보여주는 역할
퀘스트 로직을 전혀 모르게 설계 (책임 분리)
public void SetProgress(int current, int required)
{
progressText.text = $"진행도 ( {current} / {required} )";
}
문제는 퀘스트가 여러 개 동시에 진행될 때였다.
메인 퀘스트: 고블린 처치
서브 퀘스트: 버섯 수집
해결책
HUD는 항상 하나의 퀘스트만 추적한다.
private int trackedQuestId = -1;
진행도 자체는 모든 퀘스트가 각각 증가
progress.Current += amount;
하지만 HUD 갱신은 조건을 만족할 때만
if (questId == trackedQuestId && condition == trackedCondition)
{
trackerUI.SetProgress(progress.Current, progress.Target);
}
이렇게 해서:
데이터는 정상적으로 각각 증가
HUD는 선택한 퀘스트만 표시
QuestItemUI (퀘스트 목록 아이템)
퀘스트를 클릭하면:
상세 UI 표시
동시에 HUD 추적 퀘스트 변경
public void OnClick()
{
QuestUIController.Instance.ShowQuestDetail(questData);
QuestManager.Instance.SetTrackedQuest(questData.QuestID);
}
진행도가 섞이지 않는지 확인하기 위해
값이 증가하는 지점에 Debug 로그를 추가했다.
Debug.Log(
$"[QuestProgress] questId={questId}, " +
$"questName={quest.QuestName}, " +
$"current={progress.Current}/{progress.Target}"
);
버섯 수집 시 → 버섯 퀘스트만 증가
고블린 처치 시 → 메인 퀘스트만 증가
메인/서브 퀘스트 진행도 완전히 분리
HUD는 항상 선택한 퀘스트만 표시
퀘스트 수가 늘어나도 확장 가능한 구조
UI / 로직 / 데이터 책임 분리 완료