2022-05-23 13:39:59 +00:00
|
|
|
|
using System;
|
|
|
|
|
|
using System.Collections;
|
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
|
|
|
|
|
public class PlayerData : StorageBase<PlayerData>
|
|
|
|
|
|
{
|
2022-09-09 14:35:49 +00:00
|
|
|
|
public bool IsMMOUser
|
|
|
|
|
|
{
|
|
|
|
|
|
get => mIsMMOUser;
|
|
|
|
|
|
set
|
|
|
|
|
|
{
|
|
|
|
|
|
mIsMMOUser = value;
|
|
|
|
|
|
Save();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2022-07-04 11:17:39 +00:00
|
|
|
|
[SerializeField] bool mIsMMOUser = false;
|
|
|
|
|
|
|
2022-10-10 08:20:54 +00:00
|
|
|
|
public bool IsIPShow
|
|
|
|
|
|
{
|
|
|
|
|
|
get => mIsIPShow;
|
|
|
|
|
|
set
|
|
|
|
|
|
{
|
|
|
|
|
|
mIsIPShow = value;
|
|
|
|
|
|
Save();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
[SerializeField] bool mIsIPShow = false;
|
|
|
|
|
|
|
2022-05-23 13:39:59 +00:00
|
|
|
|
public int CurrentLevel
|
|
|
|
|
|
{
|
|
|
|
|
|
get => mCurrentLevel;
|
|
|
|
|
|
set
|
|
|
|
|
|
{
|
|
|
|
|
|
mCurrentLevel = value;
|
|
|
|
|
|
Save();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
[SerializeField] int mCurrentLevel = 1;
|
|
|
|
|
|
|
|
|
|
|
|
public int CurrentLevelID
|
|
|
|
|
|
{
|
|
|
|
|
|
get => mCurrentLevel - 1;//GameConfig.Instance.LevelList[(mCurrentLevel - 1) % GameConfig.Instance.LevelList.Count];
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2022-06-08 13:23:44 +00:00
|
|
|
|
[SerializeField] private Dictionary<int, string> mAutoLevelDic = new Dictionary<int, string>();
|
|
|
|
|
|
|
2022-07-04 11:17:39 +00:00
|
|
|
|
public DataLevel CurrentLevelData
|
2022-06-08 13:23:44 +00:00
|
|
|
|
{
|
2022-09-09 14:35:49 +00:00
|
|
|
|
get => TableLevel.Instance.GetData(CurrentLevel);
|
2022-06-08 13:23:44 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
2022-07-04 11:17:39 +00:00
|
|
|
|
public DataLevel NextLevelData
|
2022-06-08 13:23:44 +00:00
|
|
|
|
{
|
2022-09-09 14:35:49 +00:00
|
|
|
|
get => TableLevel.Instance.GetData((CurrentLevel + 1));
|
2022-06-08 13:23:44 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
2022-07-04 11:17:39 +00:00
|
|
|
|
public int Diamond
|
|
|
|
|
|
{
|
|
|
|
|
|
get => mDiamond;
|
|
|
|
|
|
set
|
|
|
|
|
|
{
|
|
|
|
|
|
mDiamond = value;
|
|
|
|
|
|
Save();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
[SerializeField] int mDiamond = 0;
|
|
|
|
|
|
|
2022-05-23 13:39:59 +00:00
|
|
|
|
public int Coin
|
|
|
|
|
|
{
|
|
|
|
|
|
get => mCoin;
|
|
|
|
|
|
set
|
|
|
|
|
|
{
|
|
|
|
|
|
mCoin = value;
|
|
|
|
|
|
Save();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
[SerializeField] int mCoin = 0;
|
|
|
|
|
|
|
2022-06-08 13:23:44 +00:00
|
|
|
|
public int CurrentWinCoin => NextLevelData.FirstNum * (HumanPrice + MonsterPrice) / 2 + NextLevelData.FirstNum * (NextLevelData.FirstNum - 1) * 100;
|
|
|
|
|
|
public int CurrentLoseCoin
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
int tBaseN = NextLevelData.RetryTotal == 0 ? NextLevelData.FirstNum / 2 : NextLevelData.RetryTotal;
|
|
|
|
|
|
|
|
|
|
|
|
return tBaseN * (HumanPrice + MonsterPrice) / 2 + tBaseN * (tBaseN - 1) * 100;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2022-05-23 13:39:59 +00:00
|
|
|
|
public string ArmyStr
|
|
|
|
|
|
{
|
|
|
|
|
|
get => mArmyStr;
|
|
|
|
|
|
set
|
|
|
|
|
|
{
|
|
|
|
|
|
mArmyStr = value;
|
|
|
|
|
|
Save();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2022-07-04 11:17:39 +00:00
|
|
|
|
[SerializeField] string mArmyStr = "12_1_1";
|
2022-05-23 13:39:59 +00:00
|
|
|
|
|
|
|
|
|
|
public bool IsArmyFull
|
|
|
|
|
|
{
|
|
|
|
|
|
get => mArmyStr.Split(';').Length >= 15;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2022-07-04 11:17:39 +00:00
|
|
|
|
public int CurrentPetID => mCurrentPetID;
|
|
|
|
|
|
[SerializeField] int mCurrentPetID = 1;
|
|
|
|
|
|
|
|
|
|
|
|
public int CurrentFloorID => mCurrentFloorID;
|
|
|
|
|
|
[SerializeField] int mCurrentFloorID = -1;
|
|
|
|
|
|
|
|
|
|
|
|
[SerializeField] Dictionary<int, int> mPetProgressDic = new Dictionary<int, int>();
|
|
|
|
|
|
[SerializeField] Dictionary<int, int> mFloorProgressDic = new Dictionary<int, int>();
|
|
|
|
|
|
|
2022-05-23 13:39:59 +00:00
|
|
|
|
[SerializeField] List<string> mOwnedCardIDs = new List<string>() { "Human_01", "Monster_01"};
|
2022-09-09 14:35:49 +00:00
|
|
|
|
[SerializeField] List<int> mOwnedPetIDs = new List<int>();
|
2022-07-04 11:17:39 +00:00
|
|
|
|
[SerializeField] List<int> mOwnedFloorIDs = new List<int>();
|
2022-05-23 13:39:59 +00:00
|
|
|
|
|
|
|
|
|
|
public int LoginCount => mLoginCount;
|
|
|
|
|
|
[SerializeField] long mRegisterTimestamp = 0;
|
|
|
|
|
|
[SerializeField] bool mHasRegister = false;
|
|
|
|
|
|
[SerializeField] int mLoginCount = 0;
|
|
|
|
|
|
|
2022-06-08 13:23:44 +00:00
|
|
|
|
public int HumanPrice
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
if (GameConfig.Instance.IsAutoLevel)
|
|
|
|
|
|
{
|
|
|
|
|
|
return 200 * mHumanBoughtCount + (mHumanBoughtCount - 1) * 200;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return (200 * (mHumanBoughtCount / 64 + 1)) * mHumanBoughtCount;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2022-05-23 13:39:59 +00:00
|
|
|
|
[SerializeField] private int mHumanBoughtCount = 0;
|
|
|
|
|
|
|
2022-06-08 13:23:44 +00:00
|
|
|
|
public int MonsterPrice
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
if (GameConfig.Instance.IsAutoLevel)
|
|
|
|
|
|
{
|
|
|
|
|
|
return 200 * mMonsterBoughtCount + (mMonsterBoughtCount - 1) * 200;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return (200 * (mMonsterBoughtCount / 64 + 1)) * mMonsterBoughtCount;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2022-05-23 13:39:59 +00:00
|
|
|
|
[SerializeField] private int mMonsterBoughtCount = 0;
|
|
|
|
|
|
|
2022-06-08 13:23:44 +00:00
|
|
|
|
public int CurrentSellBase
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
if (GameConfig.Instance.IsAutoLevel)
|
|
|
|
|
|
{
|
|
|
|
|
|
return Mathf.Min(200 * (mHumanBoughtCount - 1) + (mHumanBoughtCount - 2) * 200, 200 * (mMonsterBoughtCount - 1) + (mMonsterBoughtCount - 2) * 200);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return Mathf.Min((200 * ((mHumanBoughtCount - 1) / 64 + 1)) * (mHumanBoughtCount - 1), (200 * ((mMonsterBoughtCount - 1) / 64 + 1)) * (mMonsterBoughtCount - 1)); ;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2022-09-09 14:35:49 +00:00
|
|
|
|
public bool IsAutoMergeEnabled => mCurrentLevel > TKGSDKManager.Instance.GetConfigInt(TKGParamKey.AutoMergeOpenLv);
|
2022-06-08 13:23:44 +00:00
|
|
|
|
public int AutoMergeCount
|
|
|
|
|
|
{
|
|
|
|
|
|
get => mAutoMergeCount;
|
|
|
|
|
|
set
|
|
|
|
|
|
{
|
|
|
|
|
|
mAutoMergeCount = value;
|
|
|
|
|
|
Save();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
[SerializeField] private int mAutoMergeCount = 10;
|
|
|
|
|
|
|
2022-05-23 13:39:59 +00:00
|
|
|
|
[SerializeField] private List<int> mFinishedGuideIndex = new List<int>();
|
|
|
|
|
|
|
|
|
|
|
|
public bool IsNoAds
|
|
|
|
|
|
{
|
|
|
|
|
|
get => mIsNoAds;
|
|
|
|
|
|
set
|
|
|
|
|
|
{
|
|
|
|
|
|
mIsNoAds = value;
|
2022-09-09 14:35:49 +00:00
|
|
|
|
TKGSDKManager.Instance.IsRemoveAds = mIsNoAds || mIsVIP;
|
2022-05-23 13:39:59 +00:00
|
|
|
|
Save();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
[SerializeField] bool mIsNoAds = false;
|
|
|
|
|
|
|
2022-07-04 11:17:39 +00:00
|
|
|
|
public bool IsVIP
|
|
|
|
|
|
{
|
|
|
|
|
|
get => mIsVIP;
|
|
|
|
|
|
set
|
|
|
|
|
|
{
|
|
|
|
|
|
mIsVIP = value;
|
2022-09-09 14:35:49 +00:00
|
|
|
|
TKGSDKManager.Instance.IsRemoveAds = mIsNoAds || mIsVIP;
|
2022-07-04 11:17:39 +00:00
|
|
|
|
Save();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
[SerializeField] bool mIsVIP = false;
|
|
|
|
|
|
|
2022-05-23 13:39:59 +00:00
|
|
|
|
public void Login()
|
|
|
|
|
|
{
|
|
|
|
|
|
if (!mHasRegister)
|
|
|
|
|
|
{
|
|
|
|
|
|
mHasRegister = true;
|
|
|
|
|
|
mRegisterTimestamp = Utils.DateToTimestamp(DateTime.Now);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
mLoginCount++;
|
|
|
|
|
|
Save();
|
2022-07-04 11:17:39 +00:00
|
|
|
|
|
2022-09-09 14:35:49 +00:00
|
|
|
|
if (!GameConfig.Instance.IsDebug)
|
2022-07-04 11:17:39 +00:00
|
|
|
|
{
|
2022-10-10 08:20:54 +00:00
|
|
|
|
List<Touka.FunctionType> tFuncs = new List<Touka.FunctionType>() { Touka.FunctionType.Function_wangz, Touka.FunctionType.Function_IP };
|
2022-09-26 09:00:57 +00:00
|
|
|
|
TKGSDKManager.Instance.SetFunctionSwitchListener(tFuncs, OnUserSource);
|
2022-07-04 11:17:39 +00:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2022-09-26 09:00:57 +00:00
|
|
|
|
private void OnUserSource(Touka.FunctionType pFuncType, bool pOn)
|
2022-07-04 11:17:39 +00:00
|
|
|
|
{
|
2022-10-10 08:20:54 +00:00
|
|
|
|
switch (pFuncType)
|
|
|
|
|
|
{
|
|
|
|
|
|
case Touka.FunctionType.Function_wangz:
|
|
|
|
|
|
IsMMOUser = pOn;
|
|
|
|
|
|
Debug.Log("Usersource is mmo :" + IsMMOUser);
|
|
|
|
|
|
break;
|
|
|
|
|
|
case Touka.FunctionType.Function_IP:
|
|
|
|
|
|
IsIPShow = pOn;
|
|
|
|
|
|
Debug.Log("Usersource is IP show :" + IsIPShow);
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
2022-07-04 11:17:39 +00:00
|
|
|
|
|
2022-09-26 09:00:57 +00:00
|
|
|
|
Debug.Log("【ToukaGame】回调:func:" + pFuncType + "result:" + pOn);
|
2022-05-23 13:39:59 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#region card
|
|
|
|
|
|
public bool HasCard(string pCardID)
|
|
|
|
|
|
{
|
|
|
|
|
|
return mOwnedCardIDs.Contains(pCardID);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void GetCard(string pCard)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (!mOwnedCardIDs.Contains(pCard))
|
|
|
|
|
|
{
|
|
|
|
|
|
mOwnedCardIDs.Add(pCard);
|
|
|
|
|
|
Save();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void BuyHuman()
|
|
|
|
|
|
{
|
|
|
|
|
|
mHumanBoughtCount++;
|
|
|
|
|
|
Save();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void BuyMonster()
|
|
|
|
|
|
{
|
|
|
|
|
|
mMonsterBoughtCount++;
|
|
|
|
|
|
Save();
|
|
|
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
2022-07-04 11:17:39 +00:00
|
|
|
|
#region skin
|
|
|
|
|
|
public int AddPetProgress(int pPetID)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (!mPetProgressDic.ContainsKey(pPetID))
|
|
|
|
|
|
{
|
|
|
|
|
|
mPetProgressDic[pPetID] = 0;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
mPetProgressDic[pPetID]++;
|
|
|
|
|
|
Save();
|
|
|
|
|
|
|
|
|
|
|
|
return mPetProgressDic[pPetID];
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public int GetPetProgress(int pPetID)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (!mPetProgressDic.ContainsKey(pPetID))
|
|
|
|
|
|
{
|
|
|
|
|
|
mPetProgressDic[pPetID] = 0;
|
|
|
|
|
|
Save();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return mPetProgressDic[pPetID];
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public bool HasPet(int pPetID)
|
|
|
|
|
|
{
|
|
|
|
|
|
return mOwnedPetIDs.Contains(pPetID);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void GetPet(int pPetID)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (!mOwnedPetIDs.Contains(pPetID))
|
|
|
|
|
|
{
|
|
|
|
|
|
mOwnedPetIDs.Add(pPetID);
|
|
|
|
|
|
Save();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void UsePet(int pPetID)
|
|
|
|
|
|
{
|
|
|
|
|
|
mCurrentPetID = pPetID;
|
|
|
|
|
|
Save();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public int AddFloorProgress(int pFloorID)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (!mFloorProgressDic.ContainsKey(pFloorID))
|
|
|
|
|
|
{
|
|
|
|
|
|
mFloorProgressDic[pFloorID] = 0;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
mFloorProgressDic[pFloorID]++;
|
|
|
|
|
|
Save();
|
|
|
|
|
|
|
|
|
|
|
|
return mFloorProgressDic[pFloorID];
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public int GetFloorProgress(int pFloorID)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (!mFloorProgressDic.ContainsKey(pFloorID))
|
|
|
|
|
|
{
|
|
|
|
|
|
mFloorProgressDic[pFloorID] = 0;
|
|
|
|
|
|
Save();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return mFloorProgressDic[pFloorID];
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public bool HasFloor(int pFloorID)
|
|
|
|
|
|
{
|
|
|
|
|
|
return mOwnedFloorIDs.Contains(pFloorID);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void GetFloor(int pFloorID)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (!mOwnedFloorIDs.Contains(pFloorID))
|
|
|
|
|
|
{
|
|
|
|
|
|
mOwnedFloorIDs.Add(pFloorID);
|
|
|
|
|
|
Save();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void UseFloor(int pFloorID)
|
|
|
|
|
|
{
|
|
|
|
|
|
mCurrentFloorID = pFloorID;
|
|
|
|
|
|
Save();
|
|
|
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
2022-06-08 13:23:44 +00:00
|
|
|
|
#region auto level
|
|
|
|
|
|
public string GetAutoLevel()
|
|
|
|
|
|
{
|
|
|
|
|
|
if (mAutoLevelDic.ContainsKey(mCurrentLevel))
|
|
|
|
|
|
{
|
|
|
|
|
|
return mAutoLevelDic[mCurrentLevel];
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return "";
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void SaveAutoLevel(string pLevelStr)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (!mAutoLevelDic.ContainsKey(mCurrentLevel))
|
|
|
|
|
|
{
|
|
|
|
|
|
mAutoLevelDic[mCurrentLevel] = pLevelStr;
|
|
|
|
|
|
Save();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
2022-05-23 13:39:59 +00:00
|
|
|
|
#region guide
|
|
|
|
|
|
public bool CheckGuide(int pIndex)
|
|
|
|
|
|
{
|
2022-09-09 14:35:49 +00:00
|
|
|
|
if (GameConfig.Instance.IsFakeMode || mLoginCount > 1 || mCurrentLevel > 1)
|
2022-08-31 11:45:55 +00:00
|
|
|
|
return true;
|
|
|
|
|
|
|
2022-05-23 13:39:59 +00:00
|
|
|
|
return mFinishedGuideIndex.Contains(pIndex);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void FinishGuide(int pIndex)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (!mFinishedGuideIndex.Contains(pIndex))
|
|
|
|
|
|
{
|
|
|
|
|
|
mFinishedGuideIndex.Add(pIndex);
|
|
|
|
|
|
Save();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
}
|