DEG-165 [Fix] 세이브 매니저, 업그레이드 매니저 수정

This commit is contained in:
99jamin 2025-05-14 18:09:05 +09:00
parent 901e81aaf6
commit 62ab81bba2
4 changed files with 64 additions and 9 deletions

View File

@ -15,6 +15,9 @@ public class DungeonSave
// 현재 진행 중인 스테이지 // 현재 진행 중인 스테이지
public int stageLevel = 0; public int stageLevel = 0;
// 스테이지 도전 횟수
public int tryStageCount = 999;
//병합을 위한 메서드 //병합을 위한 메서드
public void MergeWith(DungeonSave other) public void MergeWith(DungeonSave other)
{ {
@ -26,6 +29,7 @@ public class DungeonSave
if (other.moveSpeedLevel != 0) moveSpeedLevel = other.moveSpeedLevel; if (other.moveSpeedLevel != 0) moveSpeedLevel = other.moveSpeedLevel;
if (other.dashCoolDownLevel != 0) dashCoolDownLevel = other.dashCoolDownLevel; if (other.dashCoolDownLevel != 0) dashCoolDownLevel = other.dashCoolDownLevel;
if (other.stageLevel != 0) stageLevel = other.stageLevel; if (other.stageLevel != 0) stageLevel = other.stageLevel;
if (other.tryStageCount < 999) tryStageCount = other.tryStageCount;
} }
} }
@ -45,6 +49,16 @@ public class HomeSave
//이벤트 //이벤트
public int mealCount = 999; public int mealCount = 999;
public bool hasShownBubbleToday = false;
public bool hasShownBubbleTodaySet = false;
public bool hasCheckedAbsenceToday;
public bool hasCheckedAbsenceTodaySet = false;
//튜토리얼 여부
public bool hasTutorial;
public bool hasTutorialSet;
//병합을 위한 메서드 //병합을 위한 메서드
public void MergeWith(HomeSave other) public void MergeWith(HomeSave other)
{ {
@ -55,6 +69,12 @@ public class HomeSave
if (other.health < 999) health = other.health; if (other.health < 999) health = other.health;
if (other.reputation < 999) reputation = other.reputation; if (other.reputation < 999) reputation = other.reputation;
if (other.mealCount < 999) mealCount = other.mealCount; if (other.mealCount < 999) mealCount = other.mealCount;
if (other.hasShownBubbleTodaySet) hasShownBubbleToday = other.hasShownBubbleToday;
if (other.hasCheckedAbsenceTodaySet) hasCheckedAbsenceToday = other.hasCheckedAbsenceToday;
if (other.hasTutorialSet) hasTutorial = other.hasTutorial;
} }
} }
@ -65,6 +85,7 @@ public class Save
public HomeSave homeSave; public HomeSave homeSave;
public DungeonSave dungeonSave; public DungeonSave dungeonSave;
//초기 값 반환
public Save InitSave() public Save InitSave()
{ {
return new Save return new Save
@ -75,7 +96,10 @@ public class Save
time = 8.0f, time = 8.0f,
health = 8.0f, health = 8.0f,
reputation = 2.0f, reputation = 2.0f,
mealCount = 0 mealCount = 0,
hasShownBubbleToday = false,
hasCheckedAbsenceToday = false,
hasTutorial = false
}, },
dungeonSave = new DungeonSave dungeonSave = new DungeonSave
{ {
@ -84,7 +108,8 @@ public class Save
heartLevel = 1, heartLevel = 1,
moveSpeedLevel = 1, moveSpeedLevel = 1,
dashCoolDownLevel = 1, dashCoolDownLevel = 1,
stageLevel = 1 stageLevel = 1,
tryStageCount = 0
} }
}; };
} }

View File

@ -46,9 +46,6 @@ public class SaveManager : Singleton<SaveManager>
backupSave = LoadBackup(); backupSave = LoadBackup();
saveDataController.ApplySaveData(mainSave); saveDataController.ApplySaveData(mainSave);
Debug.Log("메인 로드" + mainSave.homeSave.reputation); //임시 코드
Debug.Log("백업 로드" + backupSave.homeSave.reputation); //임시 코드
} }
private void UpdateSaveInfo() private void UpdateSaveInfo()
@ -187,7 +184,7 @@ public class SaveManager : Singleton<SaveManager>
backupSave = fresh.InitSave(); backupSave = fresh.InitSave();
SaveMain(); SaveMain();
SaveBackup(); SaveBackup();
saveDataController.ApplySaveData(fresh); saveDataController.ApplySaveData(mainSave);
} }

View File

@ -30,6 +30,8 @@ public class UpgradeManager : Singleton<UpgradeManager>
private RectTransform backgroundRectTransform; private RectTransform backgroundRectTransform;
private List<Button> cards = new List<Button>(); private List<Button> cards = new List<Button>();
private bool isHome = false;
public void Start() public void Start()
{ {
@ -83,6 +85,36 @@ public class UpgradeManager : Singleton<UpgradeManager>
} }
} }
/// <summary>
/// 랜덤한 강화 카드 1장
/// </summary>
public void StartUpgradeInHome()
{
isHome = true;
DrawStatNumber();
//배경 패널 생성
if(backgroundRectTransform == null)
backgroundRectTransform = Instantiate(backgroundPanel,canvas.transform).GetComponent<RectTransform>();
//배경 패널 애니메이션 적용
backgroundRectTransform.gameObject.SetActive(true);
StartCoroutine(CoFade(backgroundRectTransform.gameObject, 0f,0.7f,0.2f));
EnsureCardListSize(3);
if(cards[0] == null)
cards[0] = Instantiate(upgradeButton, backgroundRectTransform);
cards[0].gameObject.SetActive(true);
cards[0].GetComponent<UpgradeCard>().Init((StatType)stats[0]);
StartCoroutine(CoFade(cards[0].gameObject, 0f,1f,0.4f, () =>
{
cards[0].GetComponent<CanvasGroup>().interactable = true;
}));
}
/// <summary> /// <summary>
/// 중복되지 않는 랜덤한 스탯 번호 뽑기 /// 중복되지 않는 랜덤한 스탯 번호 뽑기
@ -130,13 +162,15 @@ public class UpgradeManager : Singleton<UpgradeManager>
public void DestroyUpgradeCard() public void DestroyUpgradeCard()
{ {
// 카드 비활성화 // 카드 비활성화
if (stats.Count == 0) if (stats.Count == 0|| isHome)
{ {
StartCoroutine(CoFade(cards[0].gameObject, 1f,0f,0.4f,() => StartCoroutine(CoFade(cards[0].gameObject, 1f,0f,0.4f,() =>
{ {
cards[0].gameObject.SetActive(false); cards[0].gameObject.SetActive(false);
backgroundRectTransform.gameObject.SetActive(false); backgroundRectTransform.gameObject.SetActive(false);
})); }));
isHome = false;
} }
else else
{ {
@ -189,7 +223,7 @@ public class UpgradeManager : Singleton<UpgradeManager>
if (canvasGroup == null && image == null) if (canvasGroup == null && image == null)
{ {
Debug.LogError("CanvasGroup도 Image도 없습니다!"); Debug.LogError("CanvasGroup도 Image도 없습니다");
yield break; yield break;
} }

View File

@ -87,7 +87,6 @@ public class UpgradeStat : MonoBehaviour, ISaveable
/// <returns></returns> /// <returns></returns>
public Save ExtractSaveData() public Save ExtractSaveData()
{ {
Debug.Log("UpgradeStat extracting save data");
return new Save return new Save
{ {
dungeonSave = new DungeonSave dungeonSave = new DungeonSave