329 lines
15 KiB
Lua
329 lines
15 KiB
Lua
require("Base/BasePanel")
|
||
GMMingWangPanel = Inherit(BasePanel)
|
||
local this=GMMingWangPanel
|
||
local prestigeConfigList=ConfigManager.TryGetAllConfigsDataByKey(ConfigName.PrestigeConfig,"Type",2)
|
||
local GameSetting = ConfigManager.GetConfig(ConfigName.GameSetting)
|
||
local curLv
|
||
local curSelectLv
|
||
local isEnough --道具是否足够
|
||
local isBuy --是否已购买
|
||
local storeConfig --商店数据
|
||
function this:InitComponent()
|
||
this.spLoader = SpriteLoader.New()
|
||
this.backBtn=Util.GetGameObject(self.gameObject, "backBtn")
|
||
this.grow = Util.GetGameObject(self.gameObject,"Content")
|
||
this.tip = Util.GetGameObject(self.grow,"Tip"):GetComponent("Text")
|
||
this.icon = Util.GetGameObject(self.grow,"Icon"):GetComponent("Image")
|
||
this.name = Util.GetGameObject(self.grow,"Name"):GetComponent("Image")
|
||
this.name.sprite=this.spLoader:LoadSprite("gm_mingwang_title")
|
||
this.progress = Util.GetGameObject(self.grow,"Progress/Image")
|
||
this.value = Util.GetGameObject(self.grow,"Progress/Text"):GetComponent("Text")
|
||
this.reward = Util.GetGameObject(self.grow,"Reward")
|
||
this.btnLeft = Util.GetGameObject(self.grow,"btnLeft")
|
||
this.btnRight = Util.GetGameObject(self.grow,"btnRight")
|
||
this.btnGet = Util.GetGameObject(self.grow,"btnGet")
|
||
this.price = Util.GetGameObject(self.btnGet,"cost/Text"):GetComponent("Text")
|
||
this.cost = Util.GetGameObject(self.btnGet,"cost")
|
||
this.btnText = Util.GetGameObject(self.btnGet,"Text")
|
||
this.btnRed = Util.GetGameObject(self.btnGet,"red")
|
||
this.leftRed = Util.GetGameObject(self.btnLeft,"Red")
|
||
this.rightRed = Util.GetGameObject(self.btnRight,"Red")
|
||
|
||
this.tabGrid=Util.GetGameObject(self.gameObject, "layout/tabScroll/grid")
|
||
this.tabBtnPre=Util.GetGameObject(self.gameObject, "layout/tabBtnPre")
|
||
this.selectBtn=Util.GetGameObject(self.gameObject, "layout/tabSelectBtn")
|
||
this.selectBtnText=Util.GetGameObject(self.gameObject, "layout/tabSelectBtn/Text"):GetComponent("Text")
|
||
this.privilegeAddText=Util.GetGameObject(self.gameObject, "layout/privilegeAddScroll/Text"):GetComponent("Text")
|
||
for i = 2, #prestigeConfigList do
|
||
local tabBtn = newObjToParent(this.tabBtnPre, this.tabGrid)
|
||
Util.GetGameObject(tabBtn, "Text"):GetComponent("Text").text=string.format("名望%s",prestigeConfigList[i].Level)
|
||
Util.AddClick(tabBtn,function ()
|
||
this.TabBtnOnClick(prestigeConfigList[i].Level)
|
||
end)
|
||
end
|
||
this.infoTxt=Util.GetGameObject(self.gameObject, "layout/infoTxt"):GetComponent("Text")
|
||
this.infoTxt.text="使用GM额度兑换GM修改器中的礼包、基金、神充等,也可获得等额的名望经验,兑换免费充值无法获得名望经验"
|
||
this.List1 = {}
|
||
-- 显示货币
|
||
this.UpView = SubUIManager.Open(SubUIConfig.UpView, self.gameObject.transform)
|
||
end
|
||
|
||
function this:BindEvent()
|
||
Util.AddClick(this.backBtn,function ()
|
||
self:ClosePanel()
|
||
end)
|
||
Util.AddClick(this.exchangeBtn,function ()
|
||
UIManager.OpenPanel(UIName.NewShenZunExpExchangePopup)
|
||
end)
|
||
|
||
end
|
||
|
||
function this:OnOpen(data)
|
||
this.UpView:OnOpen({ showType = UpViewOpenType.ShowLeft, panelType = PanelType.ShenZun})
|
||
--this.UpdateTopInfo()
|
||
end
|
||
|
||
function this:OnShow()
|
||
this.SetGrowGift()
|
||
this.TabBtnOnClick(curLv)
|
||
end
|
||
|
||
|
||
--添加事件监听(用于子类重写)
|
||
function this:AddListener()
|
||
Game.GlobalEvent:AddEvent(GameEvent.Activity.UpdateShenzunLv, this.UpdateTopInfo)
|
||
Game.GlobalEvent:AddEvent(GameEvent.MoneyPay.OnPayResultSuccess,self.SetGrowGift,self)
|
||
end
|
||
|
||
--移除事件监听(用于子类重写)
|
||
function this:RemoveListener()
|
||
Game.GlobalEvent:RemoveEvent(GameEvent.Activity.UpdateShenzunLv, this.UpdateTopInfo)
|
||
Game.GlobalEvent:RemoveEvent(GameEvent.MoneyPay.OnPayResultSuccess,self.SetGrowGift,self)
|
||
end
|
||
|
||
function this.UpdateTopInfo()
|
||
|
||
end
|
||
|
||
function this.TabBtnOnClick(_privilegeLv)
|
||
local _level=_privilegeLv>0 and _privilegeLv or 1
|
||
local clickBtn=this.tabGrid.transform:GetChild(_level-1)
|
||
this.selectBtn.transform:SetParent(clickBtn)
|
||
this.selectBtn.transform.localScale = Vector3.one
|
||
this.selectBtn.transform.localPosition = Vector3.zero
|
||
this.selectBtnText.text=string.format("名望%s",_level)
|
||
this.UpdateLayout(_level)
|
||
end
|
||
|
||
function this.UpdateLayout(_privilegeLv)
|
||
curSelectLv=_privilegeLv
|
||
local curAddData= PrivilegeManager.GetMingWangAddByLv(_privilegeLv)
|
||
local privilegeAddText =""
|
||
for _, privilegeInfo in ipairs(curAddData) do
|
||
|
||
if privilegeInfo.value == ""
|
||
or (privilegeInfo.IfFloat == 1 and privilegeInfo.value > 0)
|
||
or (privilegeInfo.IfFloat == 2 and privilegeInfo.value ~= 0)
|
||
then
|
||
local colorStr = "<color=#f46363><size=35>%s</size></color>"
|
||
local formatStr
|
||
if privilegeInfo.IfFloat == 2 and privilegeInfo.value > 1 then --特权关卡挂机加成百分比
|
||
formatStr = string.format(colorStr, (privilegeInfo.value*100-100).."%")
|
||
elseif privilegeInfo.IfFloat == 2 and privilegeInfo.value <= 0 then
|
||
formatStr = string.format(colorStr, ((privilegeInfo.value+1)*10).."")
|
||
else
|
||
formatStr = string.format(colorStr, privilegeInfo.value)
|
||
end
|
||
|
||
if privilegeInfo.id == PRIVILEGE_TYPE.HANG_ON_TIME then
|
||
-- 挂机时长特权特殊显示处理
|
||
privilegeAddText = privilegeAddText.."\n·"..string.format(privilegeInfo.content, string.format(colorStr, privilegeInfo.value + GameSetting[1].AdventureOffline), formatStr)
|
||
else
|
||
privilegeAddText = privilegeAddText.."\n·"..string.format(privilegeInfo.content, formatStr)
|
||
end
|
||
end
|
||
end
|
||
this.privilegeAddText.text=privilegeAddText
|
||
|
||
end
|
||
local growData
|
||
--==============================成长礼包部分==========================(rechargeViewNew和EveryDayGiftNew中有完全相同的部分,复制过去)
|
||
function this.SetGrowGift()
|
||
growData = DynamicActivityManager.GetGiftDataByType({{2,95}})
|
||
local rechargeNum = BagManager.GetItemCountById(1351) --VipManager.GetChargedNum()--已经充值的金额
|
||
table.sort(growData,function (a,b)
|
||
return a.data.shopItemData.BuyRule[2] < b.data.shopItemData.BuyRule[2]
|
||
end)
|
||
LogError("rechargenum=="..rechargeNum)
|
||
--计算当前声望等级
|
||
if DynamicActivityManager.curLevel == 0 then
|
||
for i = 1, #growData do
|
||
local lv=growData[i].data.shopItemData.BuyRule[2]
|
||
|
||
if rechargeNum < DynamicActivityManager.GetMingWangLv(lv) then
|
||
if rechargeNum ~= 0 then
|
||
LogError("lv======"..lv.." i=="..i)
|
||
DynamicActivityManager.curLevel = i
|
||
if DynamicActivityManager.Index == 0 then
|
||
DynamicActivityManager.Index = DynamicActivityManager.curLevel
|
||
end
|
||
break
|
||
else
|
||
DynamicActivityManager.curLevel = 1
|
||
DynamicActivityManager.Index = 1
|
||
end
|
||
end
|
||
end
|
||
end
|
||
--如果所有都没有,说明超范围了
|
||
if DynamicActivityManager.curLevel == 0 then
|
||
DynamicActivityManager.curLevel = #growData
|
||
if DynamicActivityManager.Index == 0 then
|
||
DynamicActivityManager.Index = DynamicActivityManager.curLevel
|
||
end
|
||
end
|
||
LogError("DynamicActivityManager.Index=="..DynamicActivityManager.Index)
|
||
--Log("当前声望Level:"..tostring(DynamicActivityManager.curLevel).." Index:"..tostring(DynamicActivityManager.Index))
|
||
--如果有当前声望数据,就显示,没有就显示上一档位
|
||
--local data = not not growData[DynamicActivityManager.Index] and growData[DynamicActivityManager.Index] or growData[DynamicActivityManager.Index-1]
|
||
local data=growData[DynamicActivityManager.Index]
|
||
curLv=DynamicActivityManager.Index
|
||
this.RefreshReward(data)
|
||
|
||
Util.AddOnceClick(this.btnLeft,function ()
|
||
if growData[DynamicActivityManager.Index - 1] then
|
||
DynamicActivityManager.Index = DynamicActivityManager.Index - 1
|
||
this.RefreshReward(growData[DynamicActivityManager.Index])
|
||
this.TabBtnOnClick(DynamicActivityManager.Index)
|
||
end
|
||
end)
|
||
Util.AddOnceClick(this.btnRight,function ()
|
||
if growData[DynamicActivityManager.Index + 1] then
|
||
DynamicActivityManager.Index = DynamicActivityManager.Index + 1
|
||
this.RefreshReward(growData[DynamicActivityManager.Index])
|
||
this.TabBtnOnClick(DynamicActivityManager.Index)
|
||
end
|
||
end)
|
||
end
|
||
--刷新奖励、按钮显示
|
||
function this.RefreshReward(Data)
|
||
local rechargeNum = BagManager.GetItemCountById(1351) --VipManager.GetChargedNum()--已经充值的金额
|
||
this.btnLeft:SetActive(not not growData[DynamicActivityManager.Index - 1])--左按钮显示
|
||
this.btnRight:SetActive(not not growData[DynamicActivityManager.Index + 1])--右按钮显示
|
||
-- LogPink(DynamicActivityManager.Index.." 金额:"..tostring(Data.data.shopItemData.BuyRule[2]).." 限购:"..tostring(Data.data.limitNum).." 已购:"..tostring(Data.data.boughtNum).." rechargeNum:"..tostring(rechargeNum))
|
||
local text = 1
|
||
local num = 0
|
||
LogError("#groupdata len=="..#growData.." DynamicActivityManager.Index=="..DynamicActivityManager.Index)
|
||
if DynamicActivityManager.Index < 2 then
|
||
num = growData[1].data.shopItemData.BuyRule[2]
|
||
elseif DynamicActivityManager.Index + 1 > #growData then
|
||
text = #growData
|
||
num = growData[#growData].data.shopItemData.BuyRule[2]
|
||
else
|
||
text = DynamicActivityManager.Index
|
||
num = growData[DynamicActivityManager.Index].data.shopItemData.BuyRule[2]
|
||
end
|
||
LogError("num=================="..num)
|
||
num=DynamicActivityManager.GetMingWangLv(num)
|
||
local aaa=growData[DynamicActivityManager.curLevel].data.shopItemData.BuyRule[2]
|
||
if DynamicActivityManager.curLevel <= 2 then
|
||
--this.tip.text = string.format("再获得%s积分升至名望1",num - rechargeNum)
|
||
elseif DynamicActivityManager.curLevel >= #growData and rechargeNum >= DynamicActivityManager.GetMingWangLv(aaa) then
|
||
--this.tip.text = ""
|
||
else
|
||
-- this.tip.text = string.format("再获得%s积分升至名望%s",DynamicActivityManager.GetMingWangLv(aaa) - rechargeNum,DynamicActivityManager.curLevel+1)
|
||
end
|
||
this.tip.text="每充值1元可以获得10点名望经验"
|
||
local size = rechargeNum/num
|
||
size = size > 1 and 1 or size
|
||
-- LogRed(DynamicActivityManager.Index.." #growData:"..tostring(#growData).." text:"..tostring(text))
|
||
this.icon.sprite = this.spLoader:LoadSprite("t_tequan_vip"..text)
|
||
this.progress:GetComponent("RectTransform").sizeDelta = Vector3.New(483*size,12,0)
|
||
this.value.text = string.format("%s/%s",rechargeNum,num)
|
||
this.price.text = Data.data.price
|
||
this.btnRed:SetActive(false)
|
||
local needNum=DynamicActivityManager.GetMingWangLv(Data.data.shopItemData.BuyRule[2]-1)
|
||
if Data.data.limitNum - Data.data.boughtNum > 0 then
|
||
this.btnText:SetActive(false)
|
||
this.cost:SetActive(true)
|
||
this.btnGet:GetComponent("Button").interactable = true
|
||
Util.SetGray(this.btnGet, false)
|
||
--LogError("rechargenum=="..rechargeNum.." neednum=="..needNum)
|
||
if rechargeNum >= needNum then
|
||
this.btnGet:GetComponent("Image").sprite = this.spLoader:LoadSprite("Btn_hz_cheng_01")
|
||
if BagManager.GetTotalItemNum(Data.data.costId) >= Data.data.price then
|
||
this.btnRed:SetActive(true)
|
||
end
|
||
else
|
||
this.btnGet:GetComponent("Image").sprite = this.spLoader:LoadSprite("Btn_hz_cheng_01")
|
||
end
|
||
else
|
||
this.btnText:SetActive(true)
|
||
this.cost:SetActive(false)
|
||
this.btnGet:GetComponent("Button").interactable = false
|
||
Util.SetGray(this.btnGet, true)
|
||
end
|
||
|
||
Util.AddOnceClick(this.btnGet,function ()
|
||
-- LogGreen(tostring(Data.data.limitNum).." "..tostring(Data.data.boughtNum))
|
||
if Data.data.limitNum - Data.data.boughtNum > 0 then
|
||
-- LogYellow(tostring(rechargeNum).." "..tostring(Data.data.shopItemData.BuyRule[2]))
|
||
if rechargeNum >= needNum then
|
||
-- LogPink(tostring(BagManager.GetItemCountById(Data.data.costId)).." "..tostring(Data.data.price))
|
||
if BagManager.GetItemCountById(Data.data.costId) >= Data.data.price then
|
||
-- LogBlue(tostring(Data.data.shopItemData.buyType).." "..tostring(Data.data.shopData.id))
|
||
ShopManager.RequestBuyShopItem(Data.buyType, Data.data.shopData.id, 1, function()
|
||
this.SetGrowGift()
|
||
CheckRedPointStatus(RedPointType.DailyGift)
|
||
CheckRedPointStatus(RedPointType.GrowthPackage)
|
||
end)
|
||
else
|
||
NotEnoughPopup:Show(Data.data.costId)
|
||
end
|
||
else
|
||
PopupTipPanel.ShowTip(string.format("名望等级不足,请升至%s级后才可购买!",DynamicActivityManager.Index))
|
||
end
|
||
end
|
||
end)
|
||
|
||
|
||
if not this.ItemList then
|
||
this.ItemList = {}
|
||
end
|
||
for i = 1, #this.ItemList do
|
||
this.ItemList[i].gameObject:SetActive(false)
|
||
end
|
||
for i = 1, #Data.data.shows do
|
||
if not this.ItemList[i] then
|
||
this.ItemList[i] = SubUIManager.Open(SubUIConfig.ItemView,this.reward.transform)
|
||
end
|
||
this.ItemList[i]:OnOpen(false, {Data.data.shows[i][1],Data.data.shows[i][2],Data.data.shows[i][3]}, 0.9,false,false,false,this.sortingOrder)
|
||
this.ItemList[i].gameObject:SetActive(true)
|
||
end
|
||
|
||
--左右按钮红点检测
|
||
if growData[DynamicActivityManager.Index - 1] then
|
||
for i = DynamicActivityManager.Index - 1, 1,-1 do
|
||
local curData = growData[i]
|
||
if curData.data.limitNum - curData.data.boughtNum > 0 and
|
||
BagManager.GetTotalItemNum(curData.data.costId) >= curData.data.price and
|
||
rechargeNum >=DynamicActivityManager.GetMingWangLv(curData.data.shopItemData.BuyRule[2]-1) then
|
||
this.leftRed:SetActive(true)
|
||
break
|
||
else
|
||
this.leftRed:SetActive(false)
|
||
end
|
||
end
|
||
end
|
||
if growData[DynamicActivityManager.Index + 1] then
|
||
for i = DynamicActivityManager.Index + 1, 20 do
|
||
local curData = growData[i]
|
||
if curData and curData.data.limitNum - curData.data.boughtNum > 0 and
|
||
BagManager.GetTotalItemNum(curData.data.costId) >= curData.data.price and
|
||
rechargeNum >= DynamicActivityManager.GetMingWangLv(curData.data.shopItemData.BuyRule[2]-1) then
|
||
this.rightRed:SetActive(true)
|
||
break
|
||
else
|
||
this.rightRed:SetActive(false)
|
||
end
|
||
end
|
||
end
|
||
end
|
||
|
||
|
||
|
||
|
||
|
||
--界面关闭时调用(用于子类重写)
|
||
function this:OnClose()
|
||
CheckRedPointStatus(RedPointType.MingWangPri)
|
||
end
|
||
|
||
function this:OnDestroy()
|
||
this.spLoader:Destroy()
|
||
for k,v in pairs(self.ItemList) do
|
||
SubUIManager.Close(v)
|
||
end
|
||
self.ItemList = {}
|
||
end
|
||
return this |