using System;
|
using System.Collections;
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
using LitJson;
|
using System.Linq;
|
|
namespace Snxxz.UI
|
{
|
[XLua.LuaCallCSharp]
|
public class VipModel : Model, IBeforePlayerDataInitialize, IPlayerLoginOk
|
{
|
private Dictionary<int, VipGiftData> vipGiftDics = new Dictionary<int, VipGiftData>();
|
private Dictionary<int, int> vipExpDic = null;
|
private Dictionary<int, VipCardData> vipCardDic = null;
|
private Dictionary<int, int> vipTitleDic = null;
|
private Dictionary<int, int> m_VipCardMapItemDict = null;
|
private Dictionary<string, List<int>> m_CTGConfigDict = new Dictionary<string, List<int>>();
|
|
public event Action OnVipGiftEvent;
|
public event Action OnVipExpEvent;
|
|
public event Action OnVipTimeEvent;
|
public event Action OnVipOpenPayWinEvent;
|
|
public event Action firstChargeRewardEvent;
|
public event Action<int> rechargeCountEvent;
|
|
private bool serverInited = false;
|
|
private bool waitingJump = false;
|
|
PlayerDeadModel deadModel { get { return ModelCenter.Instance.GetModel<PlayerDeadModel>(); } }
|
PackModel packModel { get { return ModelCenter.Instance.GetModel<PackModel>(); } }
|
|
public override void Init()
|
{
|
ParseConfig();
|
ParseVipGift();
|
ParseVipExp();
|
ParseVipCard();
|
ParseVipTitle();
|
ParseVipTime();
|
ParseCTGConfig();
|
ParseFirstCharge();
|
PlayerDatas.Instance.playerDataRefreshEvent += PlayerDataRefreshInfoEvent;
|
SDKUtility.Instance.onFreePlatformPayCancel += OnChargeFail;
|
SDKUtility.Instance.onFreePlatformPayFail += OnChargeFail;
|
SDKUtility.Instance.onFreePlatformPayOk += OnChargeComplete;
|
WindowCenter.Instance.windowAfterOpenEvent += WindowAfterOpenEvent;
|
TimeUtility.OnServerOpenDayRefresh += OnServerOpenDayRefresh;
|
TreasureNewGotWin.CloseTreasureNewGotWinEvent += CloseTreasureNewGotWinEvent;
|
NewBieCenter.Instance.guideCompletedEvent += GuideCompletedEvent;
|
packModel.refreshItemCountEvent += RefreshItemCountAct;
|
StageLoad.Instance.onStageLoadFinish += OnStageLoadFinish;
|
}
|
|
public override void UnInit()
|
{
|
PlayerDatas.Instance.playerDataRefreshEvent -= PlayerDataRefreshInfoEvent;
|
SDKUtility.Instance.onFreePlatformPayCancel -= OnChargeFail;
|
SDKUtility.Instance.onFreePlatformPayFail -= OnChargeFail;
|
SDKUtility.Instance.onFreePlatformPayOk -= OnChargeComplete;
|
WindowCenter.Instance.windowAfterOpenEvent -= WindowAfterOpenEvent;
|
TimeUtility.OnServerOpenDayRefresh -= OnServerOpenDayRefresh;
|
TreasureNewGotWin.CloseTreasureNewGotWinEvent -= CloseTreasureNewGotWinEvent;
|
NewBieCenter.Instance.guideCompletedEvent -= GuideCompletedEvent;
|
packModel.refreshItemCountEvent -= RefreshItemCountAct;
|
StageLoad.Instance.onStageLoadFinish -= OnStageLoadFinish;
|
}
|
|
public void OnBeforePlayerDataInitialize()
|
{
|
TimeMgr.Instance.UnRegister(TimeMgr.SyntonyType.VipExperirnceOverdue);
|
m_VipExperienceTime = 0;
|
if (WindowCenter.Instance.IsOpen<GotoChargeWin>())
|
{
|
WindowCenter.Instance.Close<GotoChargeWin>();
|
}
|
m_RechargeCountDict.Clear();
|
m_ChargeReset = true;
|
serverInited = false;
|
firstRechargeOpen = false;
|
waitingJump = false;
|
}
|
|
private void PlayerDataRefreshInfoEvent(PlayerDataType _type)
|
{
|
if (_type == PlayerDataType.ChangeCoinPointTotal)
|
{
|
if (serverInited && PlayerDatas.Instance.baseData.coinPointTotal > 0
|
&& !beforeRecharge)
|
{
|
firstRechargeOpen = true;
|
}
|
m_ChargeReset = true;
|
UpdateFirstRechargeRedpoint();
|
UpdateRedpoint();
|
}
|
else if (_type == PlayerDataType.VIPLv)
|
{
|
if (serverInited)
|
{
|
if (PlayerDatas.Instance.baseData.VIPLv > beforeVipLv)
|
{
|
if (!NewBieCenter.Instance.inGuiding && !deadModel.playerIsDie)
|
{
|
if (!waitingJump)
|
{
|
waitingJump = true;
|
SnxxzGame.Instance.StartCoroutine(Co_JumpVip());
|
}
|
}
|
}
|
}
|
beforeVipLv = PlayerDatas.Instance.baseData.VIPLv;
|
UpdateGiftRedpoint();
|
}
|
else if (_type == PlayerDataType.Gold)
|
{
|
UpdateGiftRedpoint();
|
}
|
else if (_type == PlayerDataType.LV)
|
{
|
UpdateFirstRechargeRedpoint();
|
}
|
}
|
|
IEnumerator Co_JumpVip()
|
{
|
yield return WaitingForSecondConst.WaitMS1000;
|
waitingJump = false;
|
if (!NewBieCenter.Instance.inGuiding && !WindowCenter.Instance.IsOpen<LoadingWin>()
|
&& StageLoad.Instance.stageType == Stage.E_StageType.Dungeon && !deadModel.playerIsDie)
|
{
|
if (!WindowCenter.Instance.IsOpen<VipRechargeWin>())
|
{
|
WindowJumpMgr.Instance.ClearJumpData();
|
WindowCenter.Instance.CloseAll(WindowCenter.CloseAllIgnoreType.BaseAndCustom);
|
}
|
gotoVipLv = PlayerDatas.Instance.baseData.VIPLv;
|
OpenVipPayUI(VipWinType.Vip);
|
}
|
}
|
|
private void OnChargeComplete()
|
{
|
m_ChargeReset = true;
|
if (WindowCenter.Instance.IsOpen<RechargeBoxWin>())
|
{
|
WindowCenter.Instance.Close<RechargeBoxWin>();
|
}
|
if (WindowCenter.Instance.IsOpen<SupremeRechargeWin>())
|
{
|
WindowCenter.Instance.Close<SupremeRechargeWin>();
|
}
|
if (WindowCenter.Instance.IsOpen<FirstRechargeWin>())
|
{
|
WindowCenter.Instance.Close<FirstRechargeWin>();
|
WindowCenter.Instance.Open<MainInterfaceWin>();
|
}
|
}
|
|
private void OnChargeFail()
|
{
|
m_ChargeReset = true;
|
}
|
|
private int m_VipExp = 0;
|
public int vipExp {
|
get { return Mathf.Max(0, m_VipExp - GetVipPreExp(PlayerDatas.Instance.baseData.VIPLv)); }
|
}
|
|
public int vipTotalExp {
|
get { return m_VipExp; }
|
}
|
|
private uint m_VipExperienceTime = 0;
|
public uint vipExperienceTime {
|
get { return m_VipExperienceTime; }
|
}
|
|
private DateTime m_VipExperienceOverdue = TimeUtility.ServerNow;
|
public DateTime vipExperienceOverdue {
|
get {
|
if (m_VipExperienceTime == 0) return TimeUtility.ServerNow;
|
return m_VipExperienceOverdue;
|
}
|
}
|
|
public uint vipMaxLv {
|
get; private set;
|
}
|
|
public uint vipDayLimit {
|
get; private set;
|
}
|
|
public uint vipExpDay {
|
get; private set;
|
}
|
|
public int vipExpMoney {
|
get; private set;
|
}
|
|
public int vipExperienceItemId { get; private set; }
|
|
public int gotoVipLv { get; set; }
|
|
private bool m_ChargeReset = true;
|
|
public int presentSelectVip = 1;
|
#region 配置
|
private Dictionary<int, int> m_VipExperienceDic = null;
|
public Dictionary<int, List<string>> m_VipPrivilegeDict = new Dictionary<int, List<string>>();
|
private static string[] lineSplit = new string[] { "</r>" };
|
private int m_CTGDelayTime = 60;
|
private void ParseConfig()
|
{
|
var cfg = FuncConfigConfig.Get("VIPExperience");
|
m_VipExperienceDic = ConfigParse.GetDic<int, int>(cfg.Numerical1);
|
cfg = FuncConfigConfig.Get("PayRMB");
|
vipExpMoney = int.Parse(cfg.Numerical1);
|
cfg = FuncConfigConfig.Get("VIPExperienceCard");
|
vipExperienceItemId = int.Parse(cfg.Numerical1);
|
}
|
|
private void ParseVipGift()
|
{
|
foreach (var cfg in VIPAwardConfig.GetValues())
|
{
|
if (!vipGiftDics.ContainsKey(cfg.VIPLV))
|
{
|
VipGiftData data = new VipGiftData(cfg.GiftPrice, cfg.OldPrice);
|
ImpactRankModel.RankAwardItem _item = new ImpactRankModel.RankAwardItem();
|
JsonData _jsonData = JsonMapper.ToObject(cfg.VIPgift);
|
foreach (string _key in _jsonData.Keys)
|
{
|
var _job = int.Parse(_key);
|
var _itemArray = LitJson.JsonMapper.ToObject<int[][]>(_jsonData[_key].ToJson());
|
for (int j = 0; j < _itemArray.Length; j++)
|
{
|
_item.Add(_job, new Item(_itemArray[j][0], _itemArray[j][1]));
|
}
|
}
|
data.giftItems = _item;
|
vipGiftDics.Add(cfg.VIPLV, data);
|
}
|
}
|
}
|
|
public VipGiftData GetVipGift(int vipLv)
|
{
|
VipGiftData data = null;
|
vipGiftDics.TryGetValue(vipLv, out data);
|
return data;
|
}
|
|
private void ParseVipExp()
|
{
|
FuncConfigConfig cfg = FuncConfigConfig.Get("VIPLV");
|
if (cfg != null)
|
{
|
vipExpDic = ConfigParse.GetDic<int, int>(cfg.Numerical1);
|
vipExpDay = uint.Parse(cfg.Numerical2);
|
}
|
vipMaxLv = (uint)vipExpDic.Count;
|
|
for (int i = 1; i <= vipMaxLv; i++)
|
{
|
List<string> _list = null;
|
if (!m_VipPrivilegeDict.TryGetValue(i, out _list))
|
{
|
_list = new List<string>();
|
m_VipPrivilegeDict.Add(i, _list);
|
}
|
_list.AddRange(Language.Get(StringUtility.Contact("VipPrivilegeDesc", i)).Split(lineSplit, StringSplitOptions.None));
|
giftRedpoints.Add(new Redpoint(3503, 350300 + i));
|
}
|
}
|
public int GetVipLevelUpExp(int vipLv)
|
{
|
if (vipExpDic != null && vipExpDic.ContainsKey(vipLv + 1))
|
{
|
int _exp = vipExpDic[vipLv + 1];
|
if (vipExpDic.ContainsKey(vipLv))
|
{
|
_exp -= vipExpDic[vipLv];
|
}
|
return _exp;
|
}
|
return 0;
|
}
|
|
public int GetVipPreExp(int vipLv)
|
{
|
int _exp = 0;
|
if (vipExpDic.ContainsKey(vipLv))
|
{
|
_exp = vipExpDic[vipLv];
|
}
|
return _exp;
|
}
|
|
private void ParseVipCard()
|
{
|
FuncConfigConfig cfg = FuncConfigConfig.Get("VIPPrice");
|
if (cfg != null)
|
{
|
vipCardDic = new Dictionary<int, VipCardData>();
|
Dictionary<int, int> _idDic = ConfigParse.GetDic<int, int>(cfg.Numerical1);
|
Dictionary<int, int> _timeDic = ConfigParse.GetDic<int, int>(cfg.Numerical2);
|
Dictionary<int, string> _titleDic = ConfigParse.GetDic<int, string>(cfg.Numerical3);
|
Dictionary<int, string> _descDic = ConfigParse.GetDic<int, string>(cfg.Numerical4);
|
Dictionary<int, string> _iconDic = ConfigParse.GetDic<int, string>(cfg.Numerical5);
|
foreach (var id in _idDic.Keys)
|
{
|
VipCardData data = new VipCardData();
|
data.id = id;
|
data.price = _idDic[id];
|
data.hour = _timeDic[id];
|
data.icon = _iconDic[id];
|
data.title = _titleDic[id];
|
data.desc = _descDic[id];
|
vipCardDic.Add(id, data);
|
}
|
}
|
cfg = FuncConfigConfig.Get("VIPCard");
|
m_VipCardMapItemDict = ConfigParse.GetDic<int, int>(cfg.Numerical1);
|
}
|
public Dictionary<int, VipCardData> GetVipCardDic()
|
{
|
return vipCardDic;
|
}
|
public VipCardData GetVipCard(int _id)
|
{
|
VipCardData data = null;
|
vipCardDic.TryGetValue(_id, out data);
|
return data;
|
}
|
|
private void ParseVipTitle()
|
{
|
FuncConfigConfig cfg = FuncConfigConfig.Get("VIPTitle");
|
if (cfg != null)
|
{
|
vipTitleDic = ConfigParse.GetDic<int, int>(cfg.Numerical1);
|
}
|
}
|
public DienstgradConfig GetVipTitle(int vipLv)
|
{
|
if (vipTitleDic.ContainsKey(vipLv))
|
{
|
DienstgradConfig title = DienstgradConfig.Get(vipTitleDic[vipLv]);
|
return title;
|
}
|
return null;
|
}
|
|
Dictionary<int, int> fightPowerDict = new Dictionary<int, int>();
|
public int GetTitlePower(int vipLv)
|
{
|
int[] propertys = DienstgradConfig.GetTitleAttrType(vipTitleDic[vipLv]);
|
int[] values = DienstgradConfig.GetTitleAttrValue(vipTitleDic[vipLv]);
|
fightPowerDict.Clear();
|
for (int i = 0; i < propertys.Length; i++)
|
{
|
fightPowerDict.Add(propertys[i], values[i]);
|
}
|
return (int)UIHelper.GetFightPower(fightPowerDict);
|
}
|
|
private void ParseVipTime()
|
{
|
FuncConfigConfig cfg = FuncConfigConfig.Get("VIPLimit");
|
if (cfg != null)
|
{
|
vipDayLimit = uint.Parse(cfg.Numerical1);
|
}
|
}
|
|
private void ParseCTGConfig()
|
{
|
var configs = OrderInfoConfig.GetValues();
|
m_RechargeGainItemDict = new Dictionary<int, List<Item>>();
|
for (int i = 0; i < configs.Count; i++)
|
{
|
List<OrderInfoConfig> list;
|
if (!m_OrderInfoDict.TryGetValue(configs[i].AppId, out list))
|
{
|
list = new List<OrderInfoConfig>();
|
m_OrderInfoDict.Add(configs[i].AppId, list);
|
}
|
list.Add(configs[i]);
|
if (configs[i].CTGID == 0)
|
{
|
continue;
|
}
|
List<int> _list = null;
|
if (!m_CTGConfigDict.TryGetValue(configs[i].AppId, out _list))
|
{
|
_list = new List<int>();
|
m_CTGConfigDict.Add(configs[i].AppId, _list);
|
}
|
_list.Add(configs[i].CTGID);
|
if (!m_RechargeGainItemDict.ContainsKey(configs[i].CTGID))
|
{
|
var ctg = CTGConfig.Get(configs[i].CTGID);
|
var _itemArray = LitJson.JsonMapper.ToObject<int[][]>(ctg.GainItemList);
|
if (_itemArray != null && _itemArray.Length > 0)
|
{
|
var _itemList = new List<Item>();
|
m_RechargeGainItemDict.Add(configs[i].CTGID, _itemList);
|
for (int k = 0; k < _itemArray.Length; k++)
|
{
|
Item _item = new Item(_itemArray[k][0], _itemArray[k][1]);
|
_itemList.Add(_item);
|
}
|
}
|
}
|
}
|
var _funcConfig = FuncConfigConfig.Get("ChargeDelayTime");
|
m_CTGDelayTime = int.Parse(_funcConfig.Numerical1);
|
_funcConfig = FuncConfigConfig.Get("FirstGoldMobs");
|
firstRechargeWeapon = ConfigParse.GetDic<int, int>(_funcConfig.Numerical1);
|
}
|
|
public List<int> GetCTGConfigs(string _appid)
|
{
|
if (m_CTGConfigDict.ContainsKey(_appid))
|
{
|
return m_CTGConfigDict[_appid];
|
}
|
return m_CTGConfigDict.Values.Last();
|
}
|
|
public bool TryGetRechargeItem(int id, out List<Item> list)
|
{
|
return m_RechargeGainItemDict.TryGetValue(id, out list);
|
}
|
|
private Dictionary<int, List<Item>> m_FirstChargeItemDict = new Dictionary<int, List<Item>>();
|
private Dictionary<int, int> m_FirstChargeWorthDict = new Dictionary<int, int>();
|
private void ParseFirstCharge()
|
{
|
var _funcCfg = FuncConfigConfig.Get("FirstGold");
|
var _itemJson = LitJson.JsonMapper.ToObject(_funcCfg.Numerical1);
|
var _worthJson = LitJson.JsonMapper.ToObject(_funcCfg.Numerical2);
|
foreach (var _key in _itemJson.Keys)
|
{
|
var _job = int.Parse(_key);
|
List<Item> _list = null;
|
if (!m_FirstChargeItemDict.TryGetValue(_job, out _list))
|
{
|
_list = new List<Item>();
|
m_FirstChargeItemDict.Add(_job, _list);
|
}
|
m_FirstChargeWorthDict.Add(_job, int.Parse(_worthJson[_key].ToJson()));
|
var _itemArray = JsonMapper.ToObject<int[][]>(_itemJson[_key].ToJson());
|
for (int i = 0; i < _itemArray.Length; i++)
|
{
|
Item _item = new Item(_itemArray[i][0], _itemArray[i][1]);
|
_list.Add(_item);
|
}
|
}
|
}
|
|
public bool TryGetFirstReward(int _job, out List<Item> _list)
|
{
|
return m_FirstChargeItemDict.TryGetValue(_job, out _list);
|
}
|
|
#endregion
|
|
public void UpdateVipGift(int vipLv, bool _isbuy)
|
{
|
VipGiftData data = GetVipGift(vipLv);
|
if (data != null)
|
{
|
data.hasBuy = _isbuy;
|
if (serverInited)
|
{
|
ResetGiftRedpoint = true;
|
UpdateGiftRedpoint();
|
}
|
}
|
}
|
|
public void UpdateVipGift(uint awardMsg)
|
{
|
for (int i = 0; i < vipMaxLv; i++)
|
{
|
int k = 1 << (i + 1);
|
if (((int)awardMsg & k) == k)
|
{
|
UpdateVipGift(i + 1, true);
|
}
|
else
|
{
|
UpdateVipGift(i + 1, false);
|
}
|
}
|
if (OnVipGiftEvent != null) OnVipGiftEvent();
|
}
|
|
public void UpdateVipExp(uint _vipexp)
|
{
|
m_VipExp = (int)_vipexp;
|
if (OnVipExpEvent != null) OnVipExpEvent();
|
}
|
|
public void UpdateVipTime(uint _vipTime, uint _experienceTime)
|
{
|
m_VipExperienceTime = _experienceTime;
|
m_VipExperienceOverdue = TimeUtility.ServerNow.AddTicks(_experienceTime * TimeSpan.TicksPerSecond);
|
|
if (_experienceTime > 0)
|
{
|
TimeMgr.Instance.Register(TimeMgr.SyntonyType.VipExperirnceOverdue, _experienceTime);
|
if (serverInited)
|
{
|
popExperienceWindow = true;
|
CheckAutoPopExperienceWin();
|
}
|
}
|
if (OnVipTimeEvent != null)
|
{
|
OnVipTimeEvent();
|
}
|
}
|
|
public bool IsVipActive()
|
{
|
return PlayerDatas.Instance.baseData.VIPLv > 0;
|
}
|
|
public bool IsVipExperience()
|
{
|
int surplusTime = Mathf.Max(0, (int)(vipExperienceOverdue - TimeUtility.ServerNow).TotalSeconds);
|
return surplusTime > 0;
|
}
|
|
#region 自动弹出Vip体验界面
|
bool popExperienceWindow = false;
|
public void CheckAutoPopExperienceWin()
|
{
|
if (!popExperienceWindow)
|
{
|
return;
|
}
|
if (!(StageLoad.Instance.stageType == Stage.E_StageType.Dungeon))
|
{
|
return;
|
}
|
if (!WindowCenter.Instance.IsOpen<MainInterfaceWin>()
|
|| WindowCenter.Instance.ExistAnyFullScreenOrMaskWin()
|
|| NewBieCenter.Instance.inGuiding
|
|| WindowCenter.Instance.IsOpen<VipExperienceWin>())
|
{
|
return;
|
}
|
popExperienceWindow = false;
|
WindowCenter.Instance.Open<VipExperienceWin>();
|
}
|
|
private void RefreshItemCountAct(PackType packType, int _index, int itemId)
|
{
|
if (serverInited && itemId == vipExperienceItemId)
|
{
|
CheckUseVipExperienceCard();
|
}
|
}
|
|
private void CheckUseVipExperienceCard()
|
{
|
if (PlayerDatas.Instance.baseData.VIPLv > 0)
|
{
|
return;
|
}
|
if (IsVipExperience())
|
{
|
return;
|
}
|
var singlepack = packModel.GetSinglePack(PackType.Item);
|
if (singlepack != null)
|
{
|
var list = singlepack.GetItemsById(vipExperienceItemId);
|
if (list.Count > 0 && singlepack.GetCountById(vipExperienceItemId) > 0)
|
{
|
var itemModel = list[0];
|
CA323_tagCMUseItems pak = new CA323_tagCMUseItems();
|
pak.ItemIndex = (byte)itemModel.gridIndex;
|
pak.UseCnt = 1;
|
pak.ExData = 0;
|
GameNetSystem.Instance.SendInfo(pak);
|
}
|
}
|
}
|
#endregion
|
|
#region 打开Vip界面
|
public void OpenVipPayUI(VipWinType type)
|
{
|
vipWinType = type;
|
var _order = (int)vipWinType;
|
if (!WindowCenter.Instance.IsOpen<VipRechargeWin>())
|
{
|
WindowCenter.Instance.Open<VipRechargeWin>(false, _order);
|
}
|
else
|
{
|
if (OnVipOpenPayWinEvent != null)
|
{
|
OnVipOpenPayWinEvent();
|
}
|
}
|
}
|
|
public enum VipWinType
|
{
|
Pay = 0,
|
Vip = 1,
|
VipInverst = 2,
|
MonthInvest = 3,
|
}
|
|
public VipWinType vipWinType = VipWinType.Vip;
|
#endregion
|
|
public void SendBuyVipGift(int vipLv)
|
{
|
if (PlayerDatas.Instance.baseData.VIPLv < vipLv)
|
{
|
SysNotifyMgr.Instance.ShowTip("VipLevel");
|
return;
|
}
|
VipGiftData data = GetVipGift(vipLv);
|
if (PlayerDatas.Instance.baseData.diamond < data.giftNowPrice)
|
{
|
if (VersionConfig.Get().isBanShu)
|
{
|
SysNotifyMgr.Instance.ShowTip("GoldErr");
|
return;
|
}
|
WindowCenter.Instance.Open<RechargeTipWin>();
|
return;
|
}
|
ConfirmCancel.ShowPopConfirm(Language.Get("Mail101"), Language.Get("SurePay"), (bool isOk) =>
|
{
|
if (isOk)
|
{
|
CA804_tagCMBuyVIPItem buygiftpack = new CA804_tagCMBuyVIPItem();
|
buygiftpack.VIPLV = (byte)vipLv;
|
GameNetSystem.Instance.SendInfo(buygiftpack);
|
}
|
});
|
}
|
|
public int GetVipPrivilegeCnt(VipPrivilegeType type)
|
{
|
if (VersionConfig.Get().isBanShu)
|
{
|
return VipPrivilegeConfig.GetVipPrivilegeData(type, 0);
|
}
|
if (PlayerDatas.Instance.baseData.VIPLv == 0)
|
{
|
if (IsVipExperience() && m_VipExperienceDic.ContainsKey((int)type))
|
{
|
return m_VipExperienceDic[(int)type];
|
}
|
}
|
return VipPrivilegeConfig.GetVipPrivilegeData(type, PlayerDatas.Instance.baseData.VIPLv);
|
}
|
|
public int GetPrivilegeVipLv(VipPrivilegeType type, int val = 0)
|
{
|
for (int i = 0; i <= vipMaxLv; i++)
|
{
|
if (VipPrivilegeConfig.GetVipPrivilegeData(type, i) > val)
|
{
|
return i;
|
}
|
}
|
return -1;
|
}
|
|
#region 充值
|
public Dictionary<int, int> firstRechargeWeapon { get; private set; }
|
public Dictionary<int, List<Item>> m_RechargeGainItemDict { get; private set; }
|
private Dictionary<int, RechargeCount> m_RechargeCountDict = new Dictionary<int, RechargeCount>();
|
Dictionary<string, List<OrderInfoConfig>> m_OrderInfoDict = new Dictionary<string, List<OrderInfoConfig>>();
|
public int presentSelectRechargeId { get; private set; }
|
public bool beforeRecharge { get; private set; }
|
private int beforeVipLv { get; set; }
|
private DateTime beforeCTGTime = DateTime.Now;
|
private Redpoint rechargeRedpoint = new Redpoint(21);
|
public Redpoint firstRechargeRedpoint = new Redpoint(210000);//首充领取红点
|
public Redpoint rechargeFuncRedpoint = new Redpoint(21, 2101);
|
public Redpoint rechargeGiftRedpoint = new Redpoint(2101, 210101);//18元礼包
|
|
public bool TryGetOrderInfo(int _id, out OrderInfoConfig config)
|
{
|
config = null;
|
if (_id == 0)
|
{
|
return false;
|
}
|
List<OrderInfoConfig> list;
|
if (m_OrderInfoDict.TryGetValue(VersionConfig.Get().appId, out list))
|
{
|
for (int i = 0; i < list.Count; i++)
|
{
|
if (list[i].CTGID == _id)
|
{
|
config = list[i];
|
return true;
|
}
|
}
|
}
|
return false;
|
}
|
|
public float GetPayRmb(int _id)
|
{
|
var appid = VersionConfig.Get().appId;
|
appid = m_CTGConfigDict.ContainsKey(appid) ? appid : m_CTGConfigDict.Keys.Last();
|
var configs = OrderInfoConfig.GetValues();
|
for (int i = 0; i < configs.Count; i++)
|
{
|
if (configs[i].AppId.Equals(appid)
|
&& configs[i].CTGID == _id)
|
{
|
return configs[i].PayRMBNum;
|
}
|
}
|
return 0;
|
}
|
|
public void CTG(int _id)
|
{
|
OrderInfoConfig orderInfo = null;
|
if (TryGetOrderInfo(_id, out orderInfo))
|
{
|
CTG(orderInfo);
|
}
|
}
|
|
public void CTG(OrderInfoConfig config)
|
{
|
if (config == null)
|
{
|
return;
|
}
|
var ctgconfig = CTGConfig.Get(config.CTGID);
|
if (!VersionConfig.Get().appId.Equals(config.AppId))
|
{
|
return;
|
}
|
if (!FuncOpen.Instance.IsFuncOpen((int)FuncOpenEnum.Recharge))
|
{
|
FuncOpen.Instance.ProcessorFuncErrorTip((int)FuncOpenEnum.Recharge);
|
return;
|
}
|
|
if ((DateTime.Now - beforeCTGTime).TotalSeconds < m_CTGDelayTime && !m_ChargeReset)
|
{
|
ScrollTip.ShowTip(Language.Get("RechargeTimesLimit"));
|
return;
|
}
|
if (m_RechargeCountDict.ContainsKey(config.CTGID))
|
{
|
if (ctgconfig != null)
|
{
|
if (ctgconfig.DailyBuyCount > 0 &&
|
ctgconfig.DailyBuyCount <= m_RechargeCountDict[config.CTGID].todayCount)
|
{
|
ScrollTip.ShowTip(Language.Get("RechargeCountsLimit"));
|
return;
|
}
|
}
|
}
|
m_ChargeReset = false;
|
beforeCTGTime = DateTime.Now;
|
if (!WindowCenter.Instance.IsOpen<GotoChargeWin>())
|
{
|
WindowCenter.Instance.Open<GotoChargeWin>(true);
|
}
|
SDKUtility.Instance.FreePlatformPay(ctgconfig == null ? string.Empty : ctgconfig.Title, config.PayRMBNum, config.OrderInfo);
|
}
|
|
public event Action<string> OnCTGStageChange;
|
public void SetCTGDisplay(string _display)
|
{
|
if (OnCTGStageChange != null)
|
{
|
OnCTGStageChange(_display);
|
}
|
}
|
|
public void ShowRechargeBox(int _rechargeId)
|
{
|
presentSelectRechargeId = _rechargeId;
|
if (rechargeGiftRedpoint.state == RedPointState.Simple)
|
{
|
SetViewedRechargeGift();
|
}
|
if (!WindowCenter.Instance.IsOpen<RechargeBoxWin>())
|
{
|
WindowCenter.Instance.Open<RechargeBoxWin>();
|
}
|
}
|
|
public void UpdateRechargeCount(HA110_tagMCCoinToGoldCountInfo package)
|
{
|
for (int i = 0; i < package.RecordCount; i++)
|
{
|
var _data = package.CTGCountInfoList[i];
|
m_RechargeCountDict[_data.RecordID] = new RechargeCount()
|
{
|
todayCount = _data.TodayPayCount,
|
totalCount = (int)_data.TotalPayCount,
|
};
|
if (rechargeCountEvent != null)
|
{
|
rechargeCountEvent(_data.RecordID);
|
}
|
}
|
UpdateRedpoint();
|
}
|
|
public bool TryGetRechargeCount(int _rechargeId, out RechargeCount _rechargeCount)
|
{
|
return m_RechargeCountDict.TryGetValue(_rechargeId, out _rechargeCount);
|
}
|
|
private bool firstRechargeOpen {
|
get;
|
set;
|
}
|
|
public void AreadyGetFirstRecharge()
|
{
|
if (firstChargeRewardGet)
|
{
|
SysNotifyMgr.Instance.ShowTip("FirstPayAlreadyGet");
|
}
|
}
|
|
private void WindowAfterOpenEvent(Window _win)
|
{
|
if (_win is MainInterfaceWin)
|
{
|
if (!firstChargeRewardGet || popExperienceWindow)
|
{
|
SnxxzGame.Instance.StartCoroutine(Co_Load());
|
}
|
}
|
}
|
|
private void OnStageLoadFinish()
|
{
|
if (!(StageLoad.Instance.stageType == Stage.E_StageType.Dungeon))
|
{
|
popExperienceWindow = false;
|
}
|
}
|
|
private void GuideCompletedEvent(int _id)
|
{
|
if (popExperienceWindow)
|
{
|
SnxxzGame.Instance.StartCoroutine(Co_CheckPopExperienceWin());
|
}
|
}
|
|
private void CloseTreasureNewGotWinEvent()
|
{
|
if (!firstChargeRewardGet && PlayerDatas.Instance.baseData.coinPointTotal > 0)
|
{
|
SnxxzGame.Instance.StartCoroutine(Co_Load());
|
}
|
}
|
|
public List<int> GetFrontCharges()
|
{
|
List<int> list = new List<int>();
|
var configs = GetCTGConfigs(VersionConfig.Get().appId);
|
var index = 0;
|
for (int i = 0; i < configs.Count; i++)
|
{
|
var config = CTGConfig.Get(configs[i]);
|
if (config.PayType == 2 && index != 3)
|
{
|
list.Add(configs[i]);
|
}
|
index++;
|
if (list.Count >= 3)
|
{
|
break;
|
}
|
}
|
return list;
|
}
|
|
public bool RequireLoginAd()
|
{
|
var configs = GetCTGConfigs(VersionConfig.Get().appId);
|
var existAnyFirstRecharge = false;
|
for (int i = 0; i < configs.Count; i++)
|
{
|
var config = CTGConfig.Get(configs[i]);
|
if (config.FirstGoldPaperPrize > 0)
|
{
|
existAnyFirstRecharge = true;
|
}
|
RechargeCount rechargeCount;
|
if (TryGetRechargeCount(config.RecordID, out rechargeCount))
|
{
|
if (config.FirstGoldPaperPrize > 0 && rechargeCount.totalCount > 0)
|
{
|
return false;
|
}
|
}
|
}
|
return existAnyFirstRecharge;
|
}
|
|
IEnumerator Co_Load()
|
{
|
yield return WaitingForSecondConst.WaitMS500;
|
if (!firstChargeRewardGet)
|
{
|
CheckOpenFirstRechargeWin();
|
}
|
if (popExperienceWindow)
|
{
|
CheckAutoPopExperienceWin();
|
}
|
}
|
|
IEnumerator Co_CheckPopExperienceWin()
|
{
|
yield return WaitingForSecondConst.WaitMS500;
|
if (popExperienceWindow)
|
{
|
CheckAutoPopExperienceWin();
|
}
|
}
|
|
private void CheckOpenFirstRechargeWin()
|
{
|
if (WindowCenter.Instance.IsOpen<TreasureNewGotWin>())
|
{
|
return;
|
}
|
if (!NewBieCenter.Instance.inGuiding && WindowCenter.Instance.IsOpen<MainInterfaceWin>() && !waitingJump)
|
{
|
if (PlayerDatas.Instance.baseData.coinPointTotal > 0 && !firstChargeRewardGet
|
&& firstRechargeOpen && !WindowCenter.Instance.ExistAnyFullScreenOrMaskWin())
|
{
|
firstRechargeOpen = false;
|
WindowCenter.Instance.Close<MainInterfaceWin>();
|
WindowCenter.Instance.Open<FirstRechargeWin>(true);
|
}
|
}
|
if (firstRechargeOpen)
|
{
|
firstRechargeOpen = false;
|
}
|
}
|
|
public struct RechargeCount
|
{
|
public int todayCount;
|
public int totalCount;
|
}
|
|
bool m_FirstChargeRewardGet = false;
|
public bool firstChargeRewardGet {
|
get { return m_FirstChargeRewardGet; }
|
set {
|
m_FirstChargeRewardGet = value;
|
if (firstChargeRewardEvent != null)
|
{
|
firstChargeRewardEvent();
|
}
|
}
|
}
|
|
public void UpdateFirstChargeReward(HAA02_tagMCFirstGoldInfo package)
|
{
|
firstChargeRewardGet = package.FirstGoldRewardState == 1;
|
UpdateFirstRechargeRedpoint();
|
UpdateRedpoint();
|
}
|
|
private void UpdateFirstRechargeRedpoint()
|
{
|
firstRechargeRedpoint.state = RedPointState.None;
|
if (PlayerDatas.Instance.baseData.coinPointTotal == 0)
|
{
|
if (PlayerDatas.Instance.baseData.LV <= GeneralDefine.rechargeRedpointLv
|
&& PlayerDatas.Instance.baseData.LV >= GeneralDefine.rechargeRedpointMinLv)
|
{
|
firstRechargeRedpoint.state = RedPointState.Quantity;
|
}
|
return;
|
}
|
firstRechargeRedpoint.state = firstChargeRewardGet ? RedPointState.None : RedPointState.Simple;
|
}
|
|
public Redpoint vipRedpoint = new Redpoint(35, 3503);
|
public List<Redpoint> giftRedpoints = new List<Redpoint>();
|
public event Action giftRedpointStateEvent;
|
|
public bool ResetGiftRedpoint {
|
get { return LocalSave.GetBool(StringUtility.Contact(PlayerDatas.Instance.PlayerId, "_ResetVipGiftRedpoint"), true); }
|
set { LocalSave.SetBool(StringUtility.Contact(PlayerDatas.Instance.PlayerId, "_ResetVipGiftRedpoint"), value); }
|
}
|
|
public void UpdateGiftRedpoint()
|
{
|
for (int i = 0; i < giftRedpoints.Count; i++)
|
{
|
giftRedpoints[i].state = RedPointState.None;
|
}
|
var _vipLv = PlayerDatas.Instance.baseData.VIPLv;
|
if (_vipLv > 0)
|
{
|
for (int i = 1; i <= vipMaxLv; i++)
|
{
|
var data = GetVipGift(i);
|
if (_vipLv < i || data.hasBuy || !ResetGiftRedpoint)
|
{
|
continue;
|
}
|
if (PlayerDatas.Instance.baseData.diamond >= data.giftNowPrice)
|
{
|
giftRedpoints[i - 1].state = RedPointState.Simple;
|
break;
|
}
|
}
|
}
|
if (giftRedpointStateEvent != null)
|
{
|
giftRedpointStateEvent();
|
}
|
}
|
|
public int IsGiftRedpointActive(int _vipLv)
|
{
|
for (int i = 1; i <= vipMaxLv; i++)
|
{
|
if (giftRedpoints[i - 1].state == RedPointState.Simple)
|
{
|
return i == _vipLv ? 0 : i < _vipLv ? -1 : 1;
|
}
|
}
|
return -10;
|
}
|
|
public int IsVipGiftRedpoint()
|
{
|
for (int i = 1; i <= vipMaxLv; i++)
|
{
|
if (giftRedpoints[i - 1].state == RedPointState.Simple)
|
{
|
return i;
|
}
|
}
|
return 0;
|
}
|
|
public int VipGiftMinLevel()
|
{
|
for (int i = 1; i <= vipMaxLv; i++)
|
{
|
VipGiftData data = GetVipGift(i);
|
if (data != null && PlayerDatas.Instance.baseData.VIPLv >= i &&
|
!data.hasBuy && PlayerDatas.Instance.baseData.diamond >= data.giftNowPrice)
|
{
|
return i;
|
}
|
}
|
return 0;
|
}
|
|
private void UpdateRedpoint()
|
{
|
rechargeGiftRedpoint.state = RedPointState.None;
|
if (!FuncOpen.Instance.IsFuncOpen((int)FuncOpenEnum.Recharge))
|
{
|
return;
|
}
|
if (PlayerDatas.Instance.baseData.coinPointTotal <= 0 || !firstChargeRewardGet)
|
{
|
return;
|
}
|
var list = GetCTGConfigs(VersionConfig.Get().appId);
|
var config = CTGConfig.Get(list[0]);
|
if (m_RechargeCountDict.ContainsKey(config.RecordID))
|
{
|
if (config.DailyBuyCount > 0 &&
|
config.DailyBuyCount <= m_RechargeCountDict[config.RecordID].todayCount)
|
{
|
return;
|
}
|
}
|
if (DayRemind.Instance.GetDayRemind(DayRemind.RECHARGE_GIFT_TIP))
|
{
|
return;
|
}
|
rechargeGiftRedpoint.state = RedPointState.Simple;
|
}
|
|
public void SetViewedRechargeGift()
|
{
|
if (DayRemind.Instance.GetDayRemind(DayRemind.RECHARGE_GIFT_TIP))
|
{
|
return;
|
}
|
DayRemind.Instance.SetDayRemind(DayRemind.RECHARGE_GIFT_TIP, true);
|
UpdateRedpoint();
|
}
|
|
private void OnServerOpenDayRefresh()
|
{
|
UpdateRedpoint();
|
}
|
|
public void OnPlayerLoginOk()
|
{
|
UpdateFirstRechargeRedpoint();
|
UpdateRedpoint();
|
serverInited = true;
|
beforeRecharge = PlayerDatas.Instance.baseData.coinPointTotal > 0;
|
beforeVipLv = PlayerDatas.Instance.baseData.VIPLv;
|
if (!DayRemind.Instance.GetDayRemind(DayRemind.VIP_GIFT_REDPOINT))
|
{
|
ResetGiftRedpoint = true;
|
}
|
UpdateGiftRedpoint();
|
CheckUseVipExperienceCard();
|
}
|
#endregion
|
}
|
}
|
|
|