chicken_dy/Assets/Scripts/Storage/PlayerData.cs

81 lines
1.8 KiB
C#
Raw Normal View History

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
[SerializeField] private Dictionary<int, List<int>> mEndingDic = new Dictionary<int, List<int>>();
2022-02-09 12:28:20 +00:00
public void UnlockNewLevel()
{
if (mUnlockedLevel < GameConfig.Instance.LevelSort.Count)
{
mUnlockedLevel++;
}
}
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;
}
public bool HasUnlockedEnding(int pLevelID, int pEndingID)
{
bool tUnlocked = mEndingDic.ContainsKey(pLevelID) && mEndingDic[pLevelID].Contains(pEndingID);
return tUnlocked;
}
2022-02-09 08:35:01 +00:00
}