| | |
| | |
|
| | | public class DungeonBuyTimesWin : Window
|
| | | {
|
| | | #region 组件
|
| | | [SerializeField] Text remindText;
|
| | | [SerializeField] Text presentTimesText;
|
| | | [SerializeField] Image presentVipImg;
|
| | | [SerializeField] Transform fullTimesContainer;
|
| | | [SerializeField] Transform noFullTimesContainer;
|
| | | [SerializeField] Image nextVipImg;
|
| | | [SerializeField] Text nextTimesText;
|
| | | [SerializeField] Button buyBtn;
|
| | | [SerializeField] Button m_CloseBtn;
|
| | | [SerializeField] Text m_PresentVipTxt;
|
| | | [SerializeField] Text m_NextVipTxt;
|
| | | [SerializeField] Text m_BuyBtnTxt;
|
| | | [SerializeField] Button m_GotoRechargeBtn;
|
| | | [SerializeField] Button m_Close;
|
| | | [SerializeField] Text m_DungeonName;
|
| | | [SerializeField] Text m_TodayBuyTimes;
|
| | | [SerializeField] Text m_CostRemind;
|
| | | [SerializeField] RectTransform m_ContainerVipUp;
|
| | | [SerializeField] Text m_VipUpRemind;
|
| | | [SerializeField] RectTransform m_ContainerBuylimit;
|
| | | [SerializeField] Button m_BuyTimes;
|
| | | [SerializeField] Button m_GotoRecharge;
|
| | |
|
| | | private Color m_CacheBuyTxtCol;
|
| | | #endregion
|
| | | DungeonModel m_Model;
|
| | | DungeonModel model
|
| | | {
|
| | | get
|
| | | {
|
| | | return m_Model ?? (m_Model = ModelCenter.Instance.GetModel<DungeonModel>());
|
| | | }
|
| | | }
|
| | | VipModel m_VipModel;
|
| | | VipModel vipModel
|
| | | {
|
| | | get
|
| | | {
|
| | | return m_VipModel ?? (m_VipModel = ModelCenter.Instance.GetModel<VipModel>());
|
| | | }
|
| | | }
|
| | | DungeonRecord dungeonRecord;
|
| | | private string dungeonBuyCntFormula = string.Empty;
|
| | | #region Built-in
|
| | | string costFormula = string.Empty;
|
| | |
|
| | | DungeonModel model { get { return ModelCenter.Instance.GetModel<DungeonModel>(); } }
|
| | | VipModel vipModel { get { return ModelCenter.Instance.GetModel<VipModel>(); } }
|
| | |
|
| | | protected override void BindController()
|
| | | {
|
| | | m_CacheBuyTxtCol = m_BuyBtnTxt.color;
|
| | |
|
| | | }
|
| | |
|
| | | protected override void AddListeners()
|
| | | {
|
| | | buyBtn.onClick.AddListener(OnBuyBtnClick);
|
| | | m_CloseBtn.onClick.AddListener(CloseClick);
|
| | | m_GotoRechargeBtn.onClick.AddListener(GotoRecharge);
|
| | | m_Close.onClick.AddListener(CloseClick);
|
| | | m_BuyTimes.onClick.AddListener(BuyTimes);
|
| | | m_GotoRecharge.onClick.AddListener(GotoRecharge);
|
| | | }
|
| | |
|
| | | protected override void OnPreOpen()
|
| | | {
|
| | | PlayerDatas.Instance.PlayerDataRefreshInfoEvent += RefreshInfo;
|
| | | vipModel.OnVipTimeEvent += InitData;
|
| | | PlayerDatas.Instance.PlayerDataRefreshInfoEvent += PlayerDataRefreshInfoEvent;
|
| | | vipModel.OnVipTimeEvent += OnVipTimeEvent;
|
| | | model.updateDungeonBuyCnt += UpdateDungeonBuyCnt;
|
| | | if (model.TryGetDungeonRecord(model.currentDungeon.mapId, out dungeonRecord))
|
| | | {
|
| | | InitData();
|
| | | Display();
|
| | | }
|
| | | else
|
| | | {
|
| | | CloseImmediately();
|
| | | }
|
| | | }
|
| | |
|
| | | private void RefreshInfo(PlayerDataRefresh refreshType)
|
| | | {
|
| | | switch (refreshType)
|
| | | {
|
| | | case PlayerDataRefresh.VIPLv:
|
| | | {
|
| | | InitData();
|
| | | }
|
| | | break;
|
| | | }
|
| | | }
|
| | |
|
| | |
| | |
|
| | | protected override void OnPreClose()
|
| | | {
|
| | | PlayerDatas.Instance.PlayerDataRefreshInfoEvent -= RefreshInfo;
|
| | | vipModel.OnVipTimeEvent -= InitData;
|
| | | PlayerDatas.Instance.PlayerDataRefreshInfoEvent -= PlayerDataRefreshInfoEvent;
|
| | | vipModel.OnVipTimeEvent -= OnVipTimeEvent;
|
| | | model.updateDungeonBuyCnt -= UpdateDungeonBuyCnt;
|
| | | }
|
| | |
|
| | | protected override void OnAfterClose()
|
| | | {
|
| | | }
|
| | | #endregion
|
| | |
|
| | | public void InitData()
|
| | | private void OnVipTimeEvent()
|
| | | {
|
| | | var _openTimeCfg = Config.Instance.Get<DungeonOpenTimeConfig>(model.currentDungeon.mapId);
|
| | | var _dungeonCfg = Config.Instance.Get<DungeonConfig>(model.DungeonMap(model.currentDungeon.mapId, model.currentDungeon.lineId));
|
| | | Display();
|
| | | }
|
| | |
|
| | | m_PresentVipTxt.text = PlayerDatas.Instance.baseData.VIPLv.ToString();
|
| | | private void PlayerDataRefreshInfoEvent(PlayerDataRefresh refreshType)
|
| | | {
|
| | | if (refreshType == PlayerDataRefresh.VIPLv)
|
| | | {
|
| | | Display();
|
| | | }
|
| | | }
|
| | |
|
| | | int _defaultTimes = VipPrivilegeConfig.GetVipPrivilegeData((VipPrivilegeType)_openTimeCfg.BuyTimesID, 0);
|
| | | int _vipBuyTimes = vipModel.GetVipPrivilegeCnt((VipPrivilegeType)_openTimeCfg.BuyTimesID) - _defaultTimes;
|
| | | var _totalTimes = _defaultTimes + _vipBuyTimes;
|
| | | var _surplusTimes = _totalTimes - dungeonRecord.buyTimes;
|
| | | var _canBuyTimes = _defaultTimes > dungeonRecord.buyTimes || _surplusTimes > 0;
|
| | | buyBtn.SetEnable(m_BuyBtnTxt, _canBuyTimes);
|
| | | buyBtn.gameObject.SetActive(_canBuyTimes);
|
| | | //buyBtn.interactable = _canBuyTimes;
|
| | | //m_BuyBtnTxt.color = _canBuyTimes ? m_CacheBuyTxtCol : Color.gray;
|
| | | if (_totalTimes > 0)
|
| | | private void UpdateDungeonBuyCnt()
|
| | | {
|
| | | presentTimesText.text = UIHelper.ReplaceNewLine(Language.Get("FairyLand_Func21", StringUtility.Contact(
|
| | | _surplusTimes > 0 ? "<color=#109d06>" : "<color=#FF0000>", _surplusTimes, "</color>"), _totalTimes));
|
| | | Display();
|
| | | }
|
| | | else
|
| | |
|
| | | void Display()
|
| | | {
|
| | | presentTimesText.text = Language.Get("FairyLand_Func19", StringUtility.Contact(_totalTimes > 0 ? "<color=#109d06>" : "<color=#FF0000>", _totalTimes, "</color>"));
|
| | | var openTimeConfig = Config.Instance.Get<DungeonOpenTimeConfig>(model.currentDungeon.mapId);
|
| | | var dungeonConfig = Config.Instance.Get<DungeonConfig>(model.DungeonMap(model.currentDungeon.mapId, model.currentDungeon.lineId));
|
| | |
|
| | | m_DungeonName.text = dungeonConfig.FBName;
|
| | |
|
| | | int defaultTimes = VipPrivilegeConfig.GetVipPrivilegeData((VipPrivilegeType)openTimeConfig.BuyTimesID, 0);
|
| | | int vipBuyTimes = vipModel.GetVipPrivilegeCnt((VipPrivilegeType)openTimeConfig.BuyTimesID) - defaultTimes;
|
| | | var totalTimes = defaultTimes + vipBuyTimes;
|
| | | var surplusTimes = totalTimes - dungeonRecord.buyTimes;
|
| | | var canBuyTimes = defaultTimes > dungeonRecord.buyTimes || surplusTimes > 0;
|
| | |
|
| | | var surplusTimeDisplay = UIHelper.GetTextColorByItemColor(surplusTimes > 0 ? TextColType.Green : TextColType.Red, surplusTimes.ToString(), true);
|
| | |
|
| | | m_TodayBuyTimes.text = Language.Get("TimesBuyLanguage1", surplusTimeDisplay, totalTimes);
|
| | | int nextVipLv = vipModel.GetPrivilegeVipLv((VipPrivilegeType)openTimeConfig.BuyTimesID, totalTimes);
|
| | |
|
| | | m_ContainerVipUp.gameObject.SetActive(nextVipLv != -1);
|
| | | m_GotoRecharge.gameObject.SetActive(nextVipLv != -1 && !canBuyTimes);
|
| | |
|
| | | if (nextVipLv != -1)
|
| | | {
|
| | | var _buyTimes = VipPrivilegeConfig.GetVipPrivilegeData((VipPrivilegeType)openTimeConfig.BuyTimesID, nextVipLv);
|
| | | var upTimes = _buyTimes - totalTimes;
|
| | | m_VipUpRemind.text = Language.Get("TimesBuyLanguage2", nextVipLv, upTimes);
|
| | | }
|
| | | int _nextVip = vipModel.GetPrivilegeVipLv((VipPrivilegeType)_openTimeCfg.BuyTimesID, _totalTimes);
|
| | | fullTimesContainer.gameObject.SetActive(_nextVip == -1);
|
| | | noFullTimesContainer.gameObject.SetActive(_nextVip != -1);
|
| | | nextTimesText.gameObject.SetActive(_nextVip != -1);
|
| | | m_GotoRechargeBtn.gameObject.SetActive(_nextVip != -1 && !_canBuyTimes);
|
| | | if (_nextVip != -1)
|
| | | {
|
| | | var _buyTimes = VipPrivilegeConfig.GetVipPrivilegeData((VipPrivilegeType)_openTimeCfg.BuyTimesID, _nextVip);
|
| | | nextTimesText.text = Language.Get("FairyLand_Func19", StringUtility.Contact(_buyTimes > 0 ?
|
| | | "<color=#109d06>" : "<color=#FF0000>", _buyTimes, "</color>"));
|
| | | m_NextVipTxt.text = _nextVip.ToString();
|
| | | }
|
| | | if (_canBuyTimes)
|
| | | {
|
| | | if (model.TryGetDungeonBuyCntCost(model.currentDungeon.mapId, out dungeonBuyCntFormula))
|
| | | if (model.TryGetDungeonBuyCntCost(model.currentDungeon.mapId, out costFormula))
|
| | | {
|
| | | Equation.Instance.Clear();
|
| | | Equation.Instance.AddKeyValue("hasBuyCnt", dungeonRecord.buyTimes);
|
| | | int _cost = Equation.Instance.Eval<int>(dungeonBuyCntFormula);
|
| | | remindText.text = UIHelper.ReplaceNewLine(Language.Get("FairyLand_Func17", _cost, _dungeonCfg.FBName));
|
| | | }
|
| | | }
|
| | | else if(PlayerDatas.Instance.baseData.VIPLv == 0)
|
| | | {
|
| | | remindText.text = Language.Get("FairyLand_Func20");
|
| | | }
|
| | | else if (PlayerDatas.Instance.baseData.VIPLv >= vipModel.vipMaxLv)
|
| | | {
|
| | | remindText.text = Language.Get("FairyLand_Func16");
|
| | | }
|
| | | else
|
| | | {
|
| | | if (_nextVip == -1)
|
| | | {
|
| | | remindText.text = Language.Get("FairyLand_Func15");
|
| | | }
|
| | | else
|
| | | {
|
| | | remindText.text = Language.Get("FairyLand_Func14", _nextVip);
|
| | | }
|
| | | }
|
| | | int _cost = Equation.Instance.Eval<int>(costFormula);
|
| | | m_CostRemind.text = Language.Get("TimesBuyLanguage3", _cost);
|
| | | }
|
| | |
|
| | | private void OnBuyBtnClick()
|
| | | m_BuyTimes.gameObject.SetActive(canBuyTimes);
|
| | | m_GotoRecharge.gameObject.SetActive(!canBuyTimes && nextVipLv != -1);
|
| | | m_ContainerBuylimit.gameObject.SetActive(!canBuyTimes && nextVipLv == -1);
|
| | | }
|
| | |
|
| | | private void BuyTimes()
|
| | | {
|
| | | if (!CheckSpecialDungeon())
|
| | | {
|
| | |
| | | }
|
| | | Equation.Instance.Clear();
|
| | | Equation.Instance.AddKeyValue("hasBuyCnt", dungeonRecord.buyTimes);
|
| | | int _cost = Equation.Instance.Eval<int>(dungeonBuyCntFormula);
|
| | | model.TryGetDungeonBuyCntCost(model.currentDungeon.mapId, out costFormula);
|
| | | int _cost = Equation.Instance.Eval<int>(costFormula);
|
| | | if (PlayerDatas.Instance.baseData.GoldPaper + PlayerDatas.Instance.baseData.Gold >= _cost)
|
| | | {
|
| | | if (PlayerDatas.Instance.baseData.GoldPaper < _cost)
|
| | |
| | | }
|
| | | WindowCenter.Instance.Open<RechargeTipWin>();
|
| | | }
|
| | | CloseImmediately();
|
| | | }
|
| | |
|
| | | private void GotoRecharge()
|
| | | {
|
| | | WindowJumpMgr.Instance.WindowJumpTo(JumpUIType.VipRechargeFunc1);
|
| | | //CloseImmediately();
|
| | | }
|
| | |
|
| | | private bool CheckSpecialDungeon()
|
| | |
| | | }
|
| | | return true;
|
| | | }
|
| | |
|
| | | private void GotoRecharge()
|
| | | {
|
| | | WindowJumpMgr.Instance.WindowJumpTo(JumpUIType.VipRechargeFunc1);
|
| | | }
|
| | | }
|
| | |
|
| | | }
|