using System.Collections; using System.Collections.Generic; using UnityEngine; public class PlayerData : StorageBase { public int CurrentLevel { get { return mCurrentLevel; } set { mCurrentLevel = Mathf.Clamp(value, 1, GameConfig.Instance.LevelSort.Count); Save(); } } [SerializeField]private int mCurrentLevel = 1; public int UnlockedLevel { get { return mUnlockedLevel; } } [SerializeField] private int mUnlockedLevel = 1; public int CurrentLevelID { get { return GameConfig.Instance.LevelSort[mCurrentLevel - 1]; } } [SerializeField] private Dictionary> mEndingDic = new Dictionary>(); [SerializeField] private Dictionary> mEndingAdTipDic = new Dictionary>(); public void UnlockNewLevel() { if (mCurrentLevel == mUnlockedLevel && mUnlockedLevel < GameConfig.Instance.LevelSort.Count) { mUnlockedLevel++; } } public bool HasUnlockedAllLevel() { return mUnlockedLevel == GameConfig.Instance.LevelSort.Count; } public bool AddEnding(int pLevelID, int pEndingID) { if (!mEndingDic.ContainsKey(pLevelID)) { mEndingDic[pLevelID] = new List(); } if (!mEndingDic[pLevelID].Contains(pEndingID)) { mEndingDic[pLevelID].Add(pEndingID); Save(); return true; } return false; } public int EndingCountOfLevel(int pLevelID) { if (mEndingDic.ContainsKey(pLevelID)) { return mEndingDic[pLevelID].Count; } return 0; } public bool HasUnlockedEnding(int pLevelID, int pEndingID) { return mEndingDic.ContainsKey(pLevelID) && mEndingDic[pLevelID].Contains(pEndingID); } public void AddEndingAdTip(int pLevelID, int pEndingID) { if (!mEndingAdTipDic.ContainsKey(pLevelID)) { mEndingAdTipDic[pLevelID] = new List(); } if (!mEndingAdTipDic[pLevelID].Contains(pEndingID)) { mEndingAdTipDic[pLevelID].Add(pEndingID); Save(); } } public bool HasWatchedEndingAdTip(int pLevelID, int pEndingID) { return mEndingAdTipDic.ContainsKey(pLevelID) && mEndingAdTipDic[pLevelID].Contains(pEndingID); } }