DEG-165[Fix] 스크립트 적용
This commit is contained in:
parent
7becedc9d5
commit
acb756880d
@ -5,6 +5,7 @@ using System.Runtime.CompilerServices;
|
||||
using UnityEditor.TextCore.Text;
|
||||
using UnityEngine;
|
||||
using UnityEngine.SceneManagement;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public enum PlayerState { None, Idle, Move, Win, Hit, Dead }
|
||||
|
||||
@ -17,6 +18,7 @@ public class PlayerController : CharacterBase, IObserver<GameObject>
|
||||
[SerializeField] private GameObject normalModel; // char_body : 일상복
|
||||
[SerializeField] private GameObject battleModel; // warrior_1 : 전투복
|
||||
[SerializeField] private Transform dashEffectAnchor; // 대시 이펙트 위치
|
||||
[SerializeField] private Image dashCooldownFillImage; //대시 쿨다운 이미지
|
||||
|
||||
// 내부에서만 사용하는 변수
|
||||
private PlayerHitEffectController hitEffectController;
|
||||
@ -108,7 +110,16 @@ public class PlayerController : CharacterBase, IObserver<GameObject>
|
||||
|
||||
//대시 쿨타임 진행
|
||||
if (dashCooldownTimer > 0f)
|
||||
{
|
||||
dashCooldownTimer -= Time.deltaTime;
|
||||
if(dashCooldownFillImage != null)
|
||||
dashCooldownFillImage.fillAmount = DashCooldownRatio;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(dashCooldownFillImage != null)
|
||||
dashCooldownFillImage.fillAmount = 0f;
|
||||
}
|
||||
|
||||
// Hit 상태거나 게임 끝났을 땐 땐 입력 무시
|
||||
if (CurrentState == PlayerState.Hit || CurrentState == PlayerState.Dead || CurrentState == PlayerState.Win)
|
||||
|
@ -15,6 +15,9 @@ public class DungeonSave
|
||||
// 현재 진행 중인 스테이지
|
||||
public int stageLevel = 0;
|
||||
|
||||
// 스테이지 도전 횟수
|
||||
public int tryStageCount = 999;
|
||||
|
||||
//병합을 위한 메서드
|
||||
public void MergeWith(DungeonSave other)
|
||||
{
|
||||
@ -26,6 +29,7 @@ public class DungeonSave
|
||||
if (other.moveSpeedLevel != 0) moveSpeedLevel = other.moveSpeedLevel;
|
||||
if (other.dashCoolDownLevel != 0) dashCoolDownLevel = other.dashCoolDownLevel;
|
||||
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 bool hasShownBubbleToday = false;
|
||||
public bool hasShownBubbleTodaySet = false;
|
||||
|
||||
public bool hasCheckedAbsenceToday;
|
||||
public bool hasCheckedAbsenceTodaySet = false;
|
||||
|
||||
//튜토리얼 여부
|
||||
public bool hasTutorial = false;
|
||||
public bool hasTutorialSet = false;
|
||||
|
||||
//병합을 위한 메서드
|
||||
public void MergeWith(HomeSave other)
|
||||
{
|
||||
@ -55,6 +69,12 @@ public class HomeSave
|
||||
if (other.health < 999) health = other.health;
|
||||
if (other.reputation < 999) reputation = other.reputation;
|
||||
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 DungeonSave dungeonSave;
|
||||
|
||||
//초기 값 반환
|
||||
public Save InitSave()
|
||||
{
|
||||
return new Save
|
||||
@ -75,7 +96,10 @@ public class Save
|
||||
time = 8.0f,
|
||||
health = 8.0f,
|
||||
reputation = 2.0f,
|
||||
mealCount = 0
|
||||
mealCount = 0,
|
||||
hasShownBubbleToday = false,
|
||||
hasCheckedAbsenceToday = false,
|
||||
hasTutorial = false
|
||||
},
|
||||
dungeonSave = new DungeonSave
|
||||
{
|
||||
@ -84,7 +108,8 @@ public class Save
|
||||
heartLevel = 1,
|
||||
moveSpeedLevel = 1,
|
||||
dashCoolDownLevel = 1,
|
||||
stageLevel = 1
|
||||
stageLevel = 1,
|
||||
tryStageCount = 0
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@ -46,9 +46,6 @@ public class SaveManager : Singleton<SaveManager>
|
||||
backupSave = LoadBackup();
|
||||
|
||||
saveDataController.ApplySaveData(mainSave);
|
||||
|
||||
Debug.Log("메인 로드" + mainSave.homeSave.reputation); //임시 코드
|
||||
Debug.Log("백업 로드" + backupSave.homeSave.reputation); //임시 코드
|
||||
}
|
||||
|
||||
private void UpdateSaveInfo()
|
||||
@ -187,7 +184,7 @@ public class SaveManager : Singleton<SaveManager>
|
||||
backupSave = fresh.InitSave();
|
||||
SaveMain();
|
||||
SaveBackup();
|
||||
saveDataController.ApplySaveData(fresh);
|
||||
saveDataController.ApplySaveData(mainSave);
|
||||
}
|
||||
|
||||
|
||||
|
@ -30,6 +30,8 @@ public class UpgradeManager : Singleton<UpgradeManager>
|
||||
|
||||
private RectTransform backgroundRectTransform;
|
||||
private List<Button> cards = new List<Button>();
|
||||
|
||||
private bool isHome = false;
|
||||
|
||||
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>
|
||||
/// 중복되지 않는 랜덤한 스탯 번호 뽑기
|
||||
@ -130,13 +162,15 @@ public class UpgradeManager : Singleton<UpgradeManager>
|
||||
public void DestroyUpgradeCard()
|
||||
{
|
||||
// 카드 비활성화
|
||||
if (stats.Count == 0)
|
||||
if (stats.Count == 0|| isHome)
|
||||
{
|
||||
StartCoroutine(CoFade(cards[0].gameObject, 1f,0f,0.4f,() =>
|
||||
{
|
||||
cards[0].gameObject.SetActive(false);
|
||||
backgroundRectTransform.gameObject.SetActive(false);
|
||||
}));
|
||||
|
||||
isHome = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -189,7 +223,7 @@ public class UpgradeManager : Singleton<UpgradeManager>
|
||||
|
||||
if (canvasGroup == null && image == null)
|
||||
{
|
||||
Debug.LogError("CanvasGroup도 Image도 없습니다!");
|
||||
Debug.LogError("CanvasGroup도 Image도 없습니다");
|
||||
yield break;
|
||||
}
|
||||
|
||||
|
@ -87,7 +87,6 @@ public class UpgradeStat : MonoBehaviour, ISaveable
|
||||
/// <returns></returns>
|
||||
public Save ExtractSaveData()
|
||||
{
|
||||
Debug.Log("UpgradeStat extracting save data");
|
||||
return new Save
|
||||
{
|
||||
dungeonSave = new DungeonSave
|
||||
|
@ -46,7 +46,7 @@ public class DungeonPanelController : MonoBehaviour
|
||||
// out of index error 방지
|
||||
if (_countHealth >= visibleHeartCount) return false;
|
||||
|
||||
_playerHealthImages[_countHealth].color = Color.black;
|
||||
_playerHealthImages[visibleHeartCount-(_countHealth+1)].color = Color.black;
|
||||
_countHealth++;
|
||||
return _countHealth < visibleHeartCount;
|
||||
}
|
||||
|
@ -416,6 +416,11 @@ public class PlayerStats : MonoBehaviour,ISaveable
|
||||
HealthStat = Mathf.Clamp(save.homeSave.health, 0, _gameConstants.maxHealth);
|
||||
ReputationStat = Mathf.Clamp(save.homeSave.reputation, 0, _gameConstants.maxReputation);
|
||||
_mealCount = Mathf.Clamp(save.homeSave.mealCount, 0, 2);
|
||||
_hasCheckedAbsenceToday = save.homeSave.hasCheckedAbsenceToday;
|
||||
_hasShownBubbleToday = save.homeSave.hasShownBubbleToday;
|
||||
|
||||
//UI적용
|
||||
OnStatsChanged?.Invoke(new StatsChangeData(TimeStat, HealthStat, ReputationStat));
|
||||
}
|
||||
}
|
||||
|
||||
@ -428,7 +433,13 @@ public class PlayerStats : MonoBehaviour,ISaveable
|
||||
time = Mathf.Clamp(this.TimeStat,0,_gameConstants.maxTime),
|
||||
health = Mathf.Clamp(this.HealthStat,0,_gameConstants.maxHealth),
|
||||
reputation = Mathf.Clamp(this.ReputationStat,0,_gameConstants.maxReputation),
|
||||
mealCount = Mathf.Clamp(this._mealCount,0,2)
|
||||
mealCount = Mathf.Clamp(this._mealCount,0,2),
|
||||
|
||||
hasCheckedAbsenceTodaySet = true,
|
||||
hasCheckedAbsenceToday = this._hasCheckedAbsenceToday,
|
||||
|
||||
hasShownBubbleTodaySet = true,
|
||||
hasShownBubbleToday = this._hasShownBubbleToday,
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@ -5,6 +5,7 @@ using System.Text;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using Random = UnityEngine.Random;
|
||||
|
||||
public class InteractionAnimationPanelController : MonoBehaviour
|
||||
{
|
||||
@ -108,6 +109,16 @@ public class InteractionAnimationPanelController : MonoBehaviour
|
||||
//패널 닫고 애니메이션 null처리
|
||||
HidePanel();
|
||||
_autoHideCoroutine = null;
|
||||
|
||||
if (actionType == ActionType.Housework)
|
||||
{
|
||||
var chance = 0.7f;
|
||||
|
||||
if (Random.value < chance)
|
||||
{
|
||||
UpgradeManager.Instance.StartUpgradeInHome();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void HidePanel()
|
||||
|
@ -133,6 +133,7 @@ public partial class GameManager : Singleton<GameManager>,ISaveable
|
||||
if (save?.dungeonSave != null)
|
||||
{
|
||||
stageLevel = Mathf.Clamp(save.dungeonSave.stageLevel,1,2);
|
||||
tryStageCount = Mathf.Clamp(save.dungeonSave.tryStageCount,0,3);
|
||||
}
|
||||
|
||||
if (save?.homeSave != null)
|
||||
@ -148,6 +149,7 @@ public partial class GameManager : Singleton<GameManager>,ISaveable
|
||||
dungeonSave = new DungeonSave()
|
||||
{
|
||||
stageLevel = Mathf.Clamp(this.stageLevel,1,2),
|
||||
tryStageCount = Mathf.Clamp(this.tryStageCount,0,3),
|
||||
},
|
||||
|
||||
homeSave = new HomeSave
|
||||
|
@ -23,11 +23,17 @@ public partial class GameManager
|
||||
private void ZeroReputationEnd() // 평판 0 엔딩
|
||||
{
|
||||
StartNPCDialogue(GamePhase.ZeroEnd);
|
||||
|
||||
//세이브 초기화
|
||||
SaveManager.Instance.ResetSave();
|
||||
}
|
||||
|
||||
private void FailEnd() // 같은 스테이지 3회 도전 실패 엔딩
|
||||
{
|
||||
StartNPCDialogue(GamePhase.FailEnd);
|
||||
|
||||
//세이브 초기화
|
||||
SaveManager.Instance.ResetSave();
|
||||
}
|
||||
|
||||
// 회고 엔딩. 7일차에 실행
|
||||
@ -35,5 +41,8 @@ public partial class GameManager
|
||||
{
|
||||
// npc와의 마지막 대화 출력
|
||||
StartNPCDialogue(GamePhase.End);
|
||||
|
||||
//세이브 초기화
|
||||
SaveManager.Instance.ResetSave();
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user