using vnxbqy.UI;
|
using System;
|
using System.Collections.Generic;
|
using System.Linq;
|
using System.Text;
|
using System.Threading.Tasks;
|
using UnityEngine;
|
using UnityEngine.UI;
|
|
class BossHomeBuyTimesWin : ILWindow
|
{
|
|
RectTransform noneVipContainer;
|
Text noneVipTip;
|
Button viewVipButton;
|
Text vipLevel;
|
RectTransform normalVipContainer;
|
Text todayBuyTimesText;
|
Text priceText;
|
Text nextTip;
|
Button buyButton;
|
Button rechargeButton;
|
Text maxPrivilegeText;
|
Button closeButton;
|
|
int killTimePrice;
|
|
BossHomeModel bossHomeModel;
|
VipModel vipModel;
|
|
protected override void BindController()
|
{
|
base.BindController();
|
bossHomeModel = ModelCenter.Instance.GetModelEx<BossHomeModel>();
|
vipModel = ModelCenter.Instance.GetModelEx<VipModel>();
|
|
noneVipContainer = proxy.GetWidgtEx<RectTransform>("noneVipContainer");
|
noneVipTip = proxy.GetWidgtEx<Text>("noneVipTip");
|
viewVipButton = proxy.GetWidgtEx<Button>("viewVipButton");
|
vipLevel = proxy.GetWidgtEx<Text>("vipLevel");
|
normalVipContainer = proxy.GetWidgtEx<RectTransform>("normalVipContainer");
|
todayBuyTimesText = proxy.GetWidgtEx<Text>("todayBuyTimesText");
|
priceText = proxy.GetWidgtEx<Text>("priceText");
|
nextTip = proxy.GetWidgtEx<Text>("nextTip");
|
buyButton = proxy.GetWidgtEx<Button>("buyButton");
|
rechargeButton = proxy.GetWidgtEx<Button>("rechargeButton");
|
maxPrivilegeText = proxy.GetWidgtEx<Text>("maxPrivilegeText");
|
closeButton = proxy.GetWidgtEx<Button>("closeButton");
|
|
var content = FuncConfigConfig.Get("KillBossCntLimit1").Numerical2;
|
|
Int2 int2;
|
if (Int2.TryParse(content, out int2))
|
this.killTimePrice = int2.y;
|
}
|
|
protected override void AddListeners()
|
{
|
base.AddListeners();
|
this.viewVipButton.AddListener(() =>
|
{
|
WindowCenter.Instance.CloseIL<BossHomeBuyTimesWin>();
|
WindowJumpMgr.Instance.WindowJumpTo(JumpUIType.VipRechargeVip4);
|
});
|
this.buyButton.AddListener(() =>
|
{
|
BuyTimes();
|
});
|
this.rechargeButton.AddListener(() =>
|
{
|
WindowCenter.Instance.CloseIL<BossHomeBuyTimesWin>();
|
WindowJumpMgr.Instance.WindowJumpTo(JumpUIType.VipRechargeFunc1);
|
});
|
this.closeButton.SetListener(() =>
|
{
|
WindowCenter.Instance.CloseIL<BossHomeBuyTimesWin>();
|
});
|
}
|
|
protected override void OnPreOpen()
|
{
|
base.OnPreOpen();
|
Display();
|
bossHomeModel.boughtTimeChangeEvent += Display;
|
}
|
|
protected override void OnPreClose()
|
{
|
base.OnPreClose();
|
bossHomeModel.boughtTimeChangeEvent -= Display;
|
}
|
|
void Display()
|
{
|
var vipLevel = PlayerDatas.Instance.baseData.VIPLv;
|
var privilege = VipPrivilegeConfig.GetVipPrivilegeData(37, vipLevel);
|
if (privilege > 0)
|
DisplayNormalVip();
|
else
|
DisplayNoneVip();
|
}
|
|
void DisplayNormalVip()
|
{
|
this.noneVipContainer.SetActiveIL(false);
|
this.normalVipContainer.SetActiveIL(true);
|
var vipLevel = PlayerDatas.Instance.baseData.VIPLv;
|
var privilege = VipPrivilegeConfig.GetVipPrivilegeData(37, vipLevel);
|
var absolutelyPrivilege = VipPrivilegeConfig.GetVipPrivilegeData(37, 15);
|
var boughtTimes = this.bossHomeModel.boughtTimes;
|
|
this.priceText.text = Language.Get("TimesBuyLanguage3", this.killTimePrice);
|
string description = "";
|
if (boughtTimes >= privilege)
|
description = UIHelper.AppendColor(TextColType.Red, (privilege - boughtTimes).ToString(), true);
|
else
|
description = UIHelper.AppendColor(TextColType.Green, (privilege - boughtTimes).ToString(), true);
|
|
this.todayBuyTimesText.text = Language.Get("TimesBuyLanguage1", description, privilege);
|
this.nextTip.SetActiveIL(privilege < absolutelyPrivilege);
|
|
if (privilege < absolutelyPrivilege)
|
{
|
var nextVipLevel = 0;
|
var timesDif = 0;
|
for (int i = 1; i <= VipPrivilegeConfig.MAX_VIP_LEVEL; i++)
|
{
|
var tempTime = VipPrivilegeConfig.GetVipPrivilegeData(37, i);
|
if (tempTime > privilege)
|
{
|
nextVipLevel = i;
|
timesDif = tempTime - privilege;
|
break;
|
}
|
}
|
this.nextTip.text = Language.Get("TimesBuyLanguage2", nextVipLevel, timesDif);
|
}
|
|
this.buyButton.SetActiveIL(boughtTimes < privilege);
|
this.maxPrivilegeText.SetActiveIL(privilege >= absolutelyPrivilege && boughtTimes >= privilege);
|
this.rechargeButton.SetActiveIL(privilege < absolutelyPrivilege && boughtTimes >= privilege);
|
}
|
|
|
void DisplayNoneVip()
|
{
|
this.noneVipContainer.SetActiveIL(true);
|
this.normalVipContainer.SetActiveIL(false);
|
var vipLevel = 0;
|
var buyTimes = 0;
|
for (int i = 1; i <= VipPrivilegeConfig.MAX_VIP_LEVEL; i++)
|
{
|
var privilege = VipPrivilegeConfig.GetVipPrivilegeData(37, i);
|
if (privilege > 0)
|
{
|
vipLevel = i;
|
buyTimes = privilege;
|
break;
|
}
|
}
|
|
this.vipLevel.text = vipLevel.ToString();
|
var rechargeCount = vipModel.GetVipPreExp(vipLevel) - this.vipModel.vipTotalExp;
|
this.noneVipTip.text = Language.Get("BossHomeLack1", rechargeCount, vipLevel, buyTimes);
|
}
|
|
|
void BuyTimes()
|
{
|
var myDiamond = PlayerDatas.Instance.baseData.diamond;
|
var remindTimes = this.bossHomeModel.remindTimes;
|
var timesLimit = this.vipModel.GetVipPrivilegeCnt(VipPrivilegeType.BossHomeAwardLimit);
|
if (remindTimes >= timesLimit)
|
SysNotifyMgr.Instance.ShowTip("BossHomeBuyLimit");
|
else if (myDiamond < this.killTimePrice)
|
WindowCenter.Instance.OpenEx<RechargeTipWin>();
|
else
|
{
|
var data = new CA50A_tagCMBuyKillBossCnt();
|
data.KillBossMark = 1;
|
GameNetSystem.Instance.SendInfo(data);
|
}
|
}
|
|
}
|