| | |
| | |
|
| | | 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;
|
| | | //#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;
|
| | | //
|
| | | //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
|
| | | //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);
|
| | | //}
|
| | | //
|
| | | //protected override void OnPreOpen()
|
| | | //{
|
| | | // PlayerDatas.Instance.PlayerDataRefreshInfoEvent += RefreshInfo;
|
| | | // vipModel.OnVipTimeEvent += InitData;
|
| | | // if (model.TryGetDungeonRecord(model.currentDungeon.mapId, out dungeonRecord))
|
| | | // {
|
| | | // InitData();
|
| | | // }
|
| | | // else
|
| | | // {
|
| | | // CloseImmediately();
|
| | | // }
|
| | | //}
|
| | | //
|
| | | //private void RefreshInfo(PlayerDataRefresh refreshType)
|
| | | //{
|
| | | // switch (refreshType)
|
| | | // {
|
| | | // case PlayerDataRefresh.VIPLv:
|
| | | // {
|
| | | // InitData();
|
| | | // }
|
| | | // break;
|
| | | // }
|
| | | //}
|
| | | //
|
| | | //protected override void OnAfterOpen()
|
| | | //{
|
| | | //
|
| | | //}
|
| | | //
|
| | | //protected override void OnPreClose()
|
| | | //{
|
| | | // PlayerDatas.Instance.PlayerDataRefreshInfoEvent -= RefreshInfo;
|
| | | // vipModel.OnVipTimeEvent -= InitData;
|
| | | //}
|
| | | //
|
| | | //protected override void OnAfterClose()
|
| | | //{
|
| | | //}
|
| | | //#endregion
|
| | | //
|
| | | //public void InitData()
|
| | | //{
|
| | | // var _openTimeCfg = Config.Instance.Get<DungeonOpenTimeConfig>(model.currentDungeon.mapId);
|
| | | // var _dungeonCfg = Config.Instance.Get<DungeonConfig>(model.DungeonMap(model.currentDungeon.mapId, model.currentDungeon.lineId));
|
| | | //
|
| | | // m_PresentVipTxt.text = PlayerDatas.Instance.baseData.VIPLv.ToString();
|
| | | //
|
| | | // 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)
|
| | | // {
|
| | | // presentTimesText.text = UIHelper.ReplaceNewLine(Language.Get("FairyLand_Func21", StringUtility.Contact(
|
| | | // _surplusTimes > 0 ? "<color=#109d06>" : "<color=#FF0000>", _surplusTimes, "</color>"), _totalTimes));
|
| | | // }
|
| | | // else
|
| | | // {
|
| | | // presentTimesText.text = Language.Get("FairyLand_Func19", StringUtility.Contact(_totalTimes > 0 ? "<color=#109d06>" : "<color=#FF0000>", _totalTimes, "</color>"));
|
| | | // }
|
| | | // 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))
|
| | | // {
|
| | | // 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);
|
| | | // }
|
| | | // }
|
| | | //}
|
| | | //
|
| | | //private void OnBuyBtnClick()
|
| | | //{
|
| | | // if (!CheckSpecialDungeon())
|
| | | // {
|
| | | // return;
|
| | | // }
|
| | | // Equation.Instance.Clear();
|
| | | // Equation.Instance.AddKeyValue("hasBuyCnt", dungeonRecord.buyTimes);
|
| | | // int _cost = Equation.Instance.Eval<int>(dungeonBuyCntFormula);
|
| | | // if (PlayerDatas.Instance.baseData.GoldPaper + PlayerDatas.Instance.baseData.Gold >= _cost)
|
| | | // {
|
| | | // if (PlayerDatas.Instance.baseData.GoldPaper < _cost)
|
| | | // {
|
| | | // ConfirmCancel.ShowPopConfirm(Language.Get("Mail101"), Language.Get("FairyLand_Func13",
|
| | | // PlayerDatas.Instance.baseData.GoldPaper, _cost, _cost - PlayerDatas.Instance.baseData.GoldPaper), (bool isOk) =>
|
| | | // {
|
| | | // if (isOk)
|
| | | // {
|
| | | // model.SendBuyDungeonEnterCnt(model.currentDungeon.mapId);
|
| | | // CloseImmediately();
|
| | | // }
|
| | | // });
|
| | | // return;
|
| | | // }
|
| | | // else
|
| | | // {
|
| | | // model.SendBuyDungeonEnterCnt(model.currentDungeon.mapId);
|
| | | // }
|
| | | // }
|
| | | // else
|
| | | // {
|
| | | // if (VersionConfig.Get().isBanShu)
|
| | | // {
|
| | | // SysNotifyMgr.Instance.ShowTip("GoldErr");
|
| | | // return;
|
| | | // }
|
| | | // WindowCenter.Instance.Open<RechargeTipWin>();
|
| | | // }
|
| | | // CloseImmediately();
|
| | | //}
|
| | | //
|
| | | //private void GotoRecharge()
|
| | | //{
|
| | | // WindowJumpMgr.Instance.WindowJumpTo(JumpUIType.VipRechargeFunc1);
|
| | | //}
|
| | | //
|
| | | //private bool CheckSpecialDungeon()
|
| | | //{
|
| | | // if (DemonJarModel.DEMONJAR_MAPID == model.currentDungeon.mapId)
|
| | | // {
|
| | | // var _totalTimes = model.GetDungeonTotalTimes(DemonJarModel.DEMONJAR_MAPID);
|
| | | // var _enterTimes = model.GetDungeonEnterTimes(DemonJarModel.DEMONJAR_MAPID);
|
| | | // if ((_totalTimes - _enterTimes) >= DemonJarModel.TOTALTIME_LIMIT)
|
| | | // {
|
| | | // MessageWin.Inst.ShowFixedTip(Language.Get("DemonJar18"));
|
| | | // return false;
|
| | | // }
|
| | | // }
|
| | | // return true;
|
| | | //}
|
| | | [SerializeField] Button m_Close;
|
| | | [SerializeField] Text m_DungeonName;
|
| | | [SerializeField] Text m_TodayBuyTimes;
|
| | | [SerializeField] Text m_CostRemind;
|
| | | [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
|
| | | 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;
|
| | | if (model.TryGetDungeonRecord(model.currentDungeon.mapId, out dungeonRecord))
|
| | | {
|
| | | InitData();
|
| | | }
|
| | | else
|
| | | {
|
| | | CloseImmediately();
|
| | | }
|
| | | }
|
| | |
|
| | | private void RefreshInfo(PlayerDataRefresh refreshType)
|
| | | {
|
| | | switch (refreshType)
|
| | | {
|
| | | case PlayerDataRefresh.VIPLv:
|
| | | {
|
| | | InitData();
|
| | | }
|
| | | break;
|
| | | }
|
| | | }
|
| | |
|
| | | protected override void OnAfterOpen()
|
| | |
| | |
|
| | | protected override void OnPreClose()
|
| | | {
|
| | | PlayerDatas.Instance.PlayerDataRefreshInfoEvent -= RefreshInfo;
|
| | | vipModel.OnVipTimeEvent -= InitData;
|
| | |
|
| | | }
|
| | |
|
| | | protected override void OnAfterClose()
|
| | | {
|
| | | }
|
| | | #endregion
|
| | |
|
| | | public void InitData()
|
| | | void Display()
|
| | | {
|
| | | var _openTimeCfg = Config.Instance.Get<DungeonOpenTimeConfig>(model.currentDungeon.mapId);
|
| | | var _dungeonCfg = Config.Instance.Get<DungeonConfig>(model.DungeonMap(model.currentDungeon.mapId, model.currentDungeon.lineId));
|
| | |
|
| | | m_PresentVipTxt.text = PlayerDatas.Instance.baseData.VIPLv.ToString();
|
| | |
|
| | | 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)
|
| | | {
|
| | | presentTimesText.text = UIHelper.ReplaceNewLine(Language.Get("FairyLand_Func21", StringUtility.Contact(
|
| | | _surplusTimes > 0 ? "<color=#109d06>" : "<color=#FF0000>", _surplusTimes, "</color>"), _totalTimes));
|
| | | }
|
| | | else
|
| | | {
|
| | | presentTimesText.text = Language.Get("FairyLand_Func19", StringUtility.Contact(_totalTimes > 0 ? "<color=#109d06>" : "<color=#FF0000>", _totalTimes, "</color>"));
|
| | | }
|
| | | 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))
|
| | | {
|
| | | 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);
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | private void OnBuyBtnClick()
|
| | | private void BuyTimes()
|
| | | {
|
| | | if (!CheckSpecialDungeon())
|
| | | {
|
| | | return;
|
| | | }
|
| | | Equation.Instance.Clear();
|
| | | Equation.Instance.AddKeyValue("hasBuyCnt", dungeonRecord.buyTimes);
|
| | | int _cost = Equation.Instance.Eval<int>(dungeonBuyCntFormula);
|
| | | if (PlayerDatas.Instance.baseData.GoldPaper + PlayerDatas.Instance.baseData.Gold >= _cost)
|
| | | {
|
| | | if (PlayerDatas.Instance.baseData.GoldPaper < _cost)
|
| | | {
|
| | | ConfirmCancel.ShowPopConfirm(Language.Get("Mail101"), Language.Get("FairyLand_Func13",
|
| | | PlayerDatas.Instance.baseData.GoldPaper, _cost, _cost - PlayerDatas.Instance.baseData.GoldPaper), (bool isOk) =>
|
| | | {
|
| | | if (isOk)
|
| | | {
|
| | | model.SendBuyDungeonEnterCnt(model.currentDungeon.mapId);
|
| | | CloseImmediately();
|
| | | }
|
| | | });
|
| | | return;
|
| | | }
|
| | | else
|
| | | {
|
| | | model.SendBuyDungeonEnterCnt(model.currentDungeon.mapId);
|
| | | }
|
| | | }
|
| | | else
|
| | | {
|
| | | if (VersionConfig.Get().isBanShu)
|
| | | {
|
| | | SysNotifyMgr.Instance.ShowTip("GoldErr");
|
| | | return;
|
| | | }
|
| | | WindowCenter.Instance.Open<RechargeTipWin>();
|
| | | }
|
| | | CloseImmediately();
|
| | |
|
| | | }
|
| | |
|
| | | private void GotoRecharge()
|
| | | {
|
| | | WindowJumpMgr.Instance.WindowJumpTo(JumpUIType.VipRechargeFunc1);
|
| | | }
|
| | |
|
| | | private bool CheckSpecialDungeon()
|
| | | {
|
| | | if (DemonJarModel.DEMONJAR_MAPID == model.currentDungeon.mapId)
|
| | | {
|
| | | var _totalTimes = model.GetDungeonTotalTimes(DemonJarModel.DEMONJAR_MAPID);
|
| | | var _enterTimes = model.GetDungeonEnterTimes(DemonJarModel.DEMONJAR_MAPID);
|
| | | if ((_totalTimes - _enterTimes) >= DemonJarModel.TOTALTIME_LIMIT)
|
| | | {
|
| | | MessageWin.Inst.ShowFixedTip(Language.Get("DemonJar18"));
|
| | | return false;
|
| | | }
|
| | | }
|
| | | return true;
|
| | | }
|
| | | }
|
| | |
|