using System;
|
using System.Collections;
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
using UnityEngine.UI;
|
|
namespace vnxbqy.UI
|
{
|
public class RechargeWin : Window
|
{
|
[SerializeField] RechargeBehaviour[] m_Recharges;
|
[SerializeField] Text m_GoldValue;
|
[SerializeField] Button m_SpecialRechargeBtn;
|
[SerializeField] Transform cashObj;
|
[SerializeField] Text gameCashNum;
|
[SerializeField] Text timeGameCash; //限时代金券
|
|
|
VipModel m_Model;
|
VipModel model
|
{
|
get
|
{
|
return m_Model ?? (m_Model = ModelCenter.Instance.GetModel<VipModel>());
|
}
|
}
|
|
protected override void BindController()
|
{
|
|
}
|
|
protected override void AddListeners()
|
{
|
m_SpecialRechargeBtn.onClick.AddListener(SpecialRecharge);
|
}
|
|
protected override void OnPreClose()
|
{
|
PlayerDatas.Instance.playerDataRefreshEvent -= PlayerDataRefreshInfoEvent;
|
model.rechargeCountEvent -= RechargeCountEvent;
|
if (model.rechargeGiftRedpoint.state == RedPointState.Simple)
|
{
|
model.SetViewedRechargeGift();
|
}
|
}
|
|
protected override void OnPreOpen()
|
{
|
Display();
|
UpdateGoldValue();
|
PlayerDatas.Instance.playerDataRefreshEvent += PlayerDataRefreshInfoEvent;
|
model.rechargeCountEvent += RechargeCountEvent;
|
}
|
|
protected override void OnAfterClose()
|
{
|
|
}
|
|
protected override void OnAfterOpen()
|
{
|
|
}
|
|
private void PlayerDataRefreshInfoEvent(PlayerDataType _type)
|
{
|
switch (_type)
|
{
|
case PlayerDataType.Gold:
|
case PlayerDataType.default5:
|
case PlayerDataType.ExAttr11:
|
case PlayerDataType.default41:
|
UpdateGoldValue();
|
break;
|
}
|
}
|
|
void Display()
|
{
|
var _list = model.GetCTGConfigs(VersionConfig.Get().appId);
|
var _index = 0;
|
for (int i = 0; i < _list.Count; i++)
|
{
|
var config = CTGConfig.Get(_list[i]);
|
if (config == null || (config.PayType != 1 && config.PayType != 2))
|
{
|
continue;
|
}
|
if (_index >= m_Recharges.Length) break;
|
m_Recharges[_index].SetActive(true);
|
m_Recharges[_index].Display(_list[i]);
|
_index++;
|
}
|
for (int i = _index; i < m_Recharges.Length; i++)
|
{
|
m_Recharges[i].SetActive(false);
|
}
|
var _specialIndex = _list.FindIndex((x) =>
|
{
|
var config = CTGConfig.Get(x);
|
return config != null && config.PayType == 3;
|
});
|
m_SpecialRechargeBtn.SetActive(_specialIndex != -1 && PlayerDatas.Instance.baseData.VIPLv >= GeneralDefine.supremeRechargeVipLv);
|
|
}
|
|
private void SpecialRecharge()
|
{
|
var _list = model.GetCTGConfigs(VersionConfig.Get().appId);
|
var _specialIndex = _list.FindIndex((x) =>
|
{
|
var config = CTGConfig.Get(x);
|
return config != null && config.PayType == 3;
|
});
|
if (_specialIndex != -1)
|
{
|
WindowCenter.Instance.Open<SupremeRechargeWin>();
|
}
|
}
|
|
void UpdateGoldValue()
|
{
|
m_GoldValue.text = UIHelper.ReplaceLargeNum(UIHelper.GetMoneyCntEx(1));
|
var gameCash = UIHelper.GetAllVourcher()/100.0f;
|
//cashObj.SetActive(gameCash > 0);
|
gameCashNum.text = gameCash.ToString("0.##");// + Language.Get("GameCash");
|
timeGameCash.text = Language.Get("mr648tip3", (UIHelper.GetMoneyCnt(98) / 100.0f).ToString("0.##"));
|
}
|
|
private void RechargeCountEvent(int _id)
|
{
|
var config = CTGConfig.Get(_id);
|
if (config == null || (config.PayType != 1 && config.PayType != 2))
|
{
|
return;
|
}
|
for (int i = 0; i < m_Recharges.Length; i++)
|
{
|
if (m_Recharges[i].chargeId == _id)
|
{
|
m_Recharges[i].Display(_id);
|
break;
|
}
|
}
|
}
|
}
|
}
|
|