| 
									
										
										
										
											2022-02-09 08:35:01 +00:00
										 |  |  |  | using System.Collections; | 
					
						
							|  |  |  |  | using System.Collections.Generic; | 
					
						
							|  |  |  |  | using UnityEngine; | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | public class PlayerData : StorageBase<PlayerData> | 
					
						
							|  |  |  |  | { | 
					
						
							|  |  |  |  |     public int CurrentLevel | 
					
						
							|  |  |  |  |     { | 
					
						
							|  |  |  |  |         get | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             return mCurrentLevel; | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  |         set | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             mCurrentLevel = Mathf.Clamp(value, 1, GameConfig.Instance.LevelSort.Count); | 
					
						
							|  |  |  |  |             Save(); | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  |     } | 
					
						
							|  |  |  |  |     [SerializeField]private int mCurrentLevel = 1; | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-02-09 12:28:20 +00:00
										 |  |  |  |     public int UnlockedLevel | 
					
						
							|  |  |  |  |     { | 
					
						
							|  |  |  |  |         get | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             return mUnlockedLevel; | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  |     } | 
					
						
							|  |  |  |  |     [SerializeField] private int mUnlockedLevel = 1; | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-02-09 08:35:01 +00:00
										 |  |  |  |     public int CurrentLevelID | 
					
						
							|  |  |  |  |     { | 
					
						
							|  |  |  |  |         get | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             return GameConfig.Instance.LevelSort[mCurrentLevel - 1]; | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  |     } | 
					
						
							| 
									
										
										
										
											2022-02-09 12:07:40 +00:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-02-16 11:41:50 +00:00
										 |  |  |  |     public bool HasShowedReview | 
					
						
							|  |  |  |  |     { | 
					
						
							|  |  |  |  |         get | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             return mHasShowedReview; | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  |     } | 
					
						
							|  |  |  |  |     [SerializeField] private bool mHasShowedReview = false; | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-02-09 12:07:40 +00:00
										 |  |  |  |     [SerializeField] private Dictionary<int, List<int>> mEndingDic = new Dictionary<int, List<int>>(); | 
					
						
							| 
									
										
										
										
											2022-02-10 04:26:52 +00:00
										 |  |  |  |     [SerializeField] private Dictionary<int, List<int>> mEndingAdTipDic = new Dictionary<int, List<int>>(); | 
					
						
							| 
									
										
										
										
											2022-02-09 12:07:40 +00:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-02-09 12:28:20 +00:00
										 |  |  |  |     public void UnlockNewLevel() | 
					
						
							|  |  |  |  |     { | 
					
						
							| 
									
										
										
										
											2022-02-10 10:17:22 +00:00
										 |  |  |  |         if (mCurrentLevel == mUnlockedLevel && mUnlockedLevel < GameConfig.Instance.LevelSort.Count) | 
					
						
							| 
									
										
										
										
											2022-02-09 12:28:20 +00:00
										 |  |  |  |         { | 
					
						
							|  |  |  |  |             mUnlockedLevel++; | 
					
						
							| 
									
										
										
										
											2022-02-14 10:38:47 +00:00
										 |  |  |  |             Save(); | 
					
						
							| 
									
										
										
										
											2022-02-09 12:28:20 +00:00
										 |  |  |  |         } | 
					
						
							|  |  |  |  |     } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-02-15 04:29:41 +00:00
										 |  |  |  |     public void UnlockAllLevel()//for debug | 
					
						
							|  |  |  |  |     { | 
					
						
							|  |  |  |  |         mUnlockedLevel = GameConfig.Instance.LevelSort.Count; | 
					
						
							|  |  |  |  |         Save(); | 
					
						
							|  |  |  |  |     } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-02-10 10:17:22 +00:00
										 |  |  |  |     public bool HasUnlockedAllLevel() | 
					
						
							|  |  |  |  |     { | 
					
						
							|  |  |  |  |         return mUnlockedLevel == GameConfig.Instance.LevelSort.Count; | 
					
						
							|  |  |  |  |     } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-02-11 13:04:38 +00:00
										 |  |  |  |     public bool IsNextLevelPassed() | 
					
						
							|  |  |  |  |     { | 
					
						
							|  |  |  |  |         if (mCurrentLevel == GameConfig.Instance.LevelSort.Count) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             return true; | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         int tNextLvID = GameConfig.Instance.LevelSort[mCurrentLevel];//+1 - 1 | 
					
						
							|  |  |  |  |         return LevelReachGoodEnding(tNextLvID); | 
					
						
							|  |  |  |  |     } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-02-09 12:07:40 +00:00
										 |  |  |  |     public bool AddEnding(int pLevelID, int pEndingID) | 
					
						
							|  |  |  |  |     { | 
					
						
							|  |  |  |  |         if (!mEndingDic.ContainsKey(pLevelID)) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             mEndingDic[pLevelID] = new List<int>(); | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         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; | 
					
						
							|  |  |  |  |     } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-02-11 13:04:38 +00:00
										 |  |  |  |     public bool LevelReachGoodEnding(int pLevelID) | 
					
						
							|  |  |  |  |     { | 
					
						
							|  |  |  |  |         if (mEndingDic.ContainsKey(pLevelID)) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             LevelData tLvData = GameConfig.Instance.GetLevelData(pLevelID); | 
					
						
							|  |  |  |  |             for (int i = 0; i < tLvData.Endings.Count; i++) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 if (tLvData.Endings[i].IsGoodEnding && mEndingDic[pLevelID].Contains(i)) | 
					
						
							|  |  |  |  |                 { | 
					
						
							|  |  |  |  |                     return true; | 
					
						
							|  |  |  |  |                 } | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         return false; | 
					
						
							|  |  |  |  |     } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-02-09 12:07:40 +00:00
										 |  |  |  |     public bool HasUnlockedEnding(int pLevelID, int pEndingID) | 
					
						
							|  |  |  |  |     { | 
					
						
							| 
									
										
										
										
											2022-02-10 04:26:52 +00:00
										 |  |  |  |         return mEndingDic.ContainsKey(pLevelID) && mEndingDic[pLevelID].Contains(pEndingID); | 
					
						
							|  |  |  |  |     } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |     public void AddEndingAdTip(int pLevelID, int pEndingID) | 
					
						
							|  |  |  |  |     { | 
					
						
							|  |  |  |  |         if (!mEndingAdTipDic.ContainsKey(pLevelID)) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             mEndingAdTipDic[pLevelID] = new List<int>(); | 
					
						
							|  |  |  |  |         } | 
					
						
							| 
									
										
										
										
											2022-02-09 12:07:40 +00:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-02-10 04:26:52 +00:00
										 |  |  |  |         if (!mEndingAdTipDic[pLevelID].Contains(pEndingID)) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             mEndingAdTipDic[pLevelID].Add(pEndingID); | 
					
						
							|  |  |  |  |             Save(); | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  |     } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-02-16 11:41:50 +00:00
										 |  |  |  |     public int EndingAdTipCountOfLevel(int pLevelID) | 
					
						
							|  |  |  |  |     { | 
					
						
							|  |  |  |  |         if (mEndingAdTipDic.ContainsKey(pLevelID)) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             return mEndingAdTipDic[pLevelID].Count; | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         return 0; | 
					
						
							|  |  |  |  |     } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-02-10 04:26:52 +00:00
										 |  |  |  |     public bool HasWatchedEndingAdTip(int pLevelID, int pEndingID) | 
					
						
							|  |  |  |  |     { | 
					
						
							|  |  |  |  |         return mEndingAdTipDic.ContainsKey(pLevelID) && mEndingAdTipDic[pLevelID].Contains(pEndingID); | 
					
						
							| 
									
										
										
										
											2022-02-09 12:07:40 +00:00
										 |  |  |  |     } | 
					
						
							| 
									
										
										
										
											2022-02-16 11:41:50 +00:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  |     public void MarkReviewShowed() | 
					
						
							|  |  |  |  |     { | 
					
						
							|  |  |  |  |         mHasShowedReview = true; | 
					
						
							|  |  |  |  |     } | 
					
						
							| 
									
										
										
										
											2022-02-09 08:35:01 +00:00
										 |  |  |  | } |