396 lines
9.2 KiB
C#
396 lines
9.2 KiB
C#
using System;
|
||
using System.Collections;
|
||
using System.Collections.Generic;
|
||
using UnityEngine;
|
||
|
||
public class PlayerData : StorageBase<PlayerData>
|
||
{
|
||
public bool IsMMOUser
|
||
{
|
||
get => mIsMMOUser;
|
||
set
|
||
{
|
||
mIsMMOUser = value;
|
||
Save();
|
||
}
|
||
}
|
||
[SerializeField] bool mIsMMOUser = false;
|
||
|
||
public bool IsIPShow
|
||
{
|
||
get => mIsIPShow;
|
||
set
|
||
{
|
||
mIsIPShow = value;
|
||
Save();
|
||
}
|
||
}
|
||
[SerializeField] bool mIsIPShow = false;
|
||
|
||
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];
|
||
}
|
||
|
||
[SerializeField] private Dictionary<int, string> mAutoLevelDic = new Dictionary<int, string>();
|
||
|
||
public DataLevel CurrentLevelData
|
||
{
|
||
get => TableLevel.Instance.GetData(CurrentLevel);
|
||
}
|
||
|
||
public DataLevel NextLevelData
|
||
{
|
||
get => TableLevel.Instance.GetData((CurrentLevel + 1));
|
||
}
|
||
|
||
public int Diamond
|
||
{
|
||
get => mDiamond;
|
||
set
|
||
{
|
||
mDiamond = value;
|
||
Save();
|
||
}
|
||
}
|
||
[SerializeField] int mDiamond = 0;
|
||
|
||
public int Coin
|
||
{
|
||
get => mCoin;
|
||
set
|
||
{
|
||
mCoin = value;
|
||
Save();
|
||
}
|
||
}
|
||
[SerializeField] int mCoin = 0;
|
||
|
||
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;
|
||
}
|
||
}
|
||
|
||
public string ArmyStr
|
||
{
|
||
get => mArmyStr;
|
||
set
|
||
{
|
||
mArmyStr = value;
|
||
Save();
|
||
}
|
||
}
|
||
[SerializeField] string mArmyStr = "12_1_1";
|
||
|
||
public bool IsArmyFull
|
||
{
|
||
get => mArmyStr.Split(';').Length >= 15;
|
||
}
|
||
|
||
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>();
|
||
|
||
[SerializeField] List<string> mOwnedCardIDs = new List<string>() { "Human_01", "Monster_01"};
|
||
[SerializeField] List<int> mOwnedPetIDs = new List<int>();
|
||
[SerializeField] List<int> mOwnedFloorIDs = new List<int>();
|
||
|
||
public int LoginCount => mLoginCount;
|
||
[SerializeField] long mRegisterTimestamp = 0;
|
||
[SerializeField] bool mHasRegister = false;
|
||
[SerializeField] int mLoginCount = 0;
|
||
|
||
public int HumanPrice
|
||
{
|
||
get
|
||
{
|
||
if (GameConfig.Instance.IsAutoLevel)
|
||
{
|
||
return 200 * mHumanBoughtCount + (mHumanBoughtCount - 1) * 200;
|
||
}
|
||
|
||
return (200 * (mHumanBoughtCount / 64 + 1)) * mHumanBoughtCount;
|
||
}
|
||
}
|
||
[SerializeField] private int mHumanBoughtCount = 0;
|
||
|
||
public int MonsterPrice
|
||
{
|
||
get
|
||
{
|
||
if (GameConfig.Instance.IsAutoLevel)
|
||
{
|
||
return 200 * mMonsterBoughtCount + (mMonsterBoughtCount - 1) * 200;
|
||
}
|
||
|
||
return (200 * (mMonsterBoughtCount / 64 + 1)) * mMonsterBoughtCount;
|
||
}
|
||
}
|
||
[SerializeField] private int mMonsterBoughtCount = 0;
|
||
|
||
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)); ;
|
||
}
|
||
}
|
||
|
||
public bool IsAutoMergeEnabled => mCurrentLevel > TKGSDKManager.Instance.GetConfigInt(TKGParamKey.AutoMergeOpenLv);
|
||
public int AutoMergeCount
|
||
{
|
||
get => mAutoMergeCount;
|
||
set
|
||
{
|
||
mAutoMergeCount = value;
|
||
Save();
|
||
}
|
||
}
|
||
[SerializeField] private int mAutoMergeCount = 10;
|
||
|
||
[SerializeField] private List<int> mFinishedGuideIndex = new List<int>();
|
||
|
||
public bool IsNoAds
|
||
{
|
||
get => mIsNoAds;
|
||
set
|
||
{
|
||
mIsNoAds = value;
|
||
TKGSDKManager.Instance.IsRemoveAds = mIsNoAds || mIsVIP;
|
||
Save();
|
||
}
|
||
}
|
||
[SerializeField] bool mIsNoAds = false;
|
||
|
||
public bool IsVIP
|
||
{
|
||
get => mIsVIP;
|
||
set
|
||
{
|
||
mIsVIP = value;
|
||
TKGSDKManager.Instance.IsRemoveAds = mIsNoAds || mIsVIP;
|
||
Save();
|
||
}
|
||
}
|
||
[SerializeField] bool mIsVIP = false;
|
||
|
||
public void Login()
|
||
{
|
||
if (!mHasRegister)
|
||
{
|
||
mHasRegister = true;
|
||
mRegisterTimestamp = Utils.DateToTimestamp(DateTime.Now);
|
||
}
|
||
|
||
mLoginCount++;
|
||
Save();
|
||
|
||
if (!GameConfig.Instance.IsDebug)
|
||
{
|
||
List<Touka.FunctionType> tFuncs = new List<Touka.FunctionType>() { Touka.FunctionType.Function_wangz, Touka.FunctionType.Function_IP };
|
||
TKGSDKManager.Instance.SetFunctionSwitchListener(tFuncs, OnUserSource);
|
||
}
|
||
}
|
||
|
||
private void OnUserSource(Touka.FunctionType pFuncType, bool pOn)
|
||
{
|
||
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;
|
||
}
|
||
|
||
Debug.Log("【ToukaGame】回调:func:" + pFuncType + "result:" + pOn);
|
||
}
|
||
|
||
#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
|
||
|
||
#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
|
||
|
||
#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
|
||
|
||
#region guide
|
||
public bool CheckGuide(int pIndex)
|
||
{
|
||
if (GameConfig.Instance.IsFakeMode || mLoginCount > 1 || mCurrentLevel > 1)
|
||
return true;
|
||
|
||
return mFinishedGuideIndex.Contains(pIndex);
|
||
}
|
||
|
||
public void FinishGuide(int pIndex)
|
||
{
|
||
if (!mFinishedGuideIndex.Contains(pIndex))
|
||
{
|
||
mFinishedGuideIndex.Add(pIndex);
|
||
Save();
|
||
}
|
||
}
|
||
#endregion
|
||
} |