miduo_client/Assets/ManagedResources/~Lua/Modules/Operating/GMChangePanel.lua

310 lines
12 KiB
Lua
Raw Normal View History

2022-09-20 17:04:48 +08:00
require("Base/BasePanel")
GMChangePanel = Inherit(BasePanel)
local this= GMChangePanel
local GMInfo=ConfigManager.GetConfig(ConfigName.GMInfo)
local GMMaster=ConfigManager.GetConfig(ConfigName.GMMaster)
local itemConfig=ConfigManager.GetConfig(ConfigName.ItemConfig)
local rechargeCommodityConfig=ConfigManager.GetConfig(ConfigName.RechargeCommodityConfig)
2024-02-22 15:17:44 +08:00
local icons={"普通特权","超级特权","神级特权","无上特权"}
2022-09-20 17:04:48 +08:00
local sortingOrder = 0
2022-11-07 14:38:55 +08:00
local isFirst=true
local curBtn=nil
local curConfig=nil
2022-09-20 17:04:48 +08:00
--初始化组件(用于子类重写)
function GMChangePanel:InitComponent()
this.spLoader = SpriteLoader.New()
--定义头部文字和按钮
this.curTxt=Util.GetGameObject(self.gameObject, "layout/top/value1"):GetComponent("Text")
this.addTxt=Util.GetGameObject(self.gameObject, "layout/top/value2"):GetComponent("Text")
this.btn_add=Util.GetGameObject(self.gameObject, "layout/top/btn_chong")
2022-09-23 15:24:10 +08:00
this.gmIcon=Util.GetGameObject(self.gameObject, "layout/top/Image"):GetComponent("Image")
2024-02-22 15:17:44 +08:00
this.gmTxt=Util.GetGameObject(self.gameObject, "layout/top/Image/Image/Text"):GetComponent("Text")
2022-09-20 17:04:48 +08:00
this.btn_up=Util.GetGameObject(self.gameObject, "layout/top/btn_up")
2022-09-23 15:24:10 +08:00
this.progress=Util.GetGameObject(self.gameObject, "layout/top/progress")
2022-09-20 17:04:48 +08:00
this.progressTxt=Util.GetGameObject(self.gameObject, "layout/top/progress/value"):GetComponent("Text")
this.progressBar=Util.GetGameObject(self.gameObject, "layout/top/progress/progressBar"):GetComponent("Image")
this.progressBar.fillAmount=0
--滚动条和预设
--self.scrollItem = Util.GetGameObject(self.gameObject, "rzyBg/scrollItem")
this.itemPre = Util.GetGameObject(self.gameObject, "layout/tabBtnPre")
this.grid = Util.GetGameObject(self.gameObject, "layout/tabScroll/grid")
this.btn_close=Util.GetGameObject(self.gameObject, "layout/backBtn")
this.selectBtn=Util.GetGameObject(self.gameObject, "layout/tabSelectBtn")
this.selectBtnText=Util.GetGameObject(self.gameObject, "layout/tabSelectBtn/Text"):GetComponent("Text")
this.shopItemPre=Util.GetGameObject(self.gameObject, "layout/shopItemPre")
this.scroll=Util.GetGameObject(self.gameObject, "layout/scroll")
this.hint=Util.GetGameObject(self.gameObject, "layout/hint"):GetComponent("Text")
2022-09-23 15:24:10 +08:00
this.info=Util.GetGameObject(self.gameObject, "layout/top/Text (1)"):GetComponent("Text")
2022-09-20 17:04:48 +08:00
--设置滚动条
local rootHight = this.scroll.transform.rect.height
local width = this.scroll.transform.rect.width
this.scrollView = SubUIManager.Open(SubUIConfig.ScrollCycleView, this.scroll.transform,
this.shopItemPre, nil, Vector2.New(width, rootHight), 1, 1, Vector2.New(0, 5),false)
this.scrollView.moveTween.MomentumAmount = 1
this.scrollView.moveTween.Strength = 2
2022-11-07 14:38:55 +08:00
2022-09-20 17:04:48 +08:00
for k, v in ConfigPairs(GMInfo) do
if v.IsOpen==1 then
local tabBtn = newObjToParent(this.itemPre,this.grid)
Util.GetGameObject(tabBtn, "Text"):GetComponent("Text").text=v.Name
Util.AddClick(tabBtn,function ()
this.TabBtnOnClick(tabBtn,v)
end)
if isFirst then
2022-11-07 14:38:55 +08:00
--this.TabBtnOnClick(tabBtn,v)
curBtn=tabBtn
curConfig=v
2022-09-20 17:04:48 +08:00
isFirst=false
end
end
end
end
--绑定事件(用于子类重写)
function GMChangePanel:BindEvent()
Util.AddClick(this.btn_close, function()
self:ClosePanel()
end)
Util.AddClick(this.btn_add, function()
UIManager.OpenPanel(UIName.RewardItemSingleShowPopup,1342)
end)
Util.AddClick(this.btn_up, function()
2022-11-04 17:18:11 +08:00
UIManager.OpenPanel(UIName.GMShuaChongTeQuan)
2022-09-20 17:04:48 +08:00
end)
end
--添加事件监听(用于子类重写)
function GMChangePanel:AddListener()
end
--移除事件监听(用于子类重写)
function GMChangePanel:RemoveListener()
end
--界面打开时调用(用于子类重写)
function GMChangePanel:OnOpen(activityId)
this:ShowTopInfo()
end
2022-09-23 15:24:10 +08:00
function GMChangePanel:OnFocus()
this:ShowTopInfo()
end
2022-09-20 17:04:48 +08:00
function GMChangePanel:ShowTopInfo()
local num=BagManager.GetItemCountById(1367)
2022-09-23 15:24:10 +08:00
this.info.text="使用1元直充卡可增加余额今日还可存入"
local allTimes = PrivilegeManager.GetPrivilegeNumber(PRIVILEGE_TYPE.GM_YI_YUAN_UP_TIME)
local useTime=PrivilegeManager.GetPrivilegeUsedTimes(PRIVILEGE_TYPE.GM_YI_YUAN_UP_TIME)
local leftTimes = PrivilegeManager.GetPrivilegeRemainValue(PRIVILEGE_TYPE.GM_YI_YUAN_UP_TIME)
LogError("allTimes=="..allTimes.." leftTimes=="..leftTimes.." useTime"..useTime)
2022-09-20 17:04:48 +08:00
this.curTxt.text=num..""
2022-09-23 15:24:10 +08:00
local maxnum=100
local missions=ActivityGiftManager.GetActivityInfoByType(ActivityTypeDef.shuaChongTeQuan).mission
local index=1
if missions then
2024-02-22 15:17:44 +08:00
LogError("#missions=========================="..#missions)
2022-09-23 15:24:10 +08:00
for i = 1, #missions do
if missions[i].state~=0 then
index=i
end
end
end
2024-02-22 15:01:18 +08:00
--this.gmIcon.sprite=this.spLoader:LoadSprite(icons[index])
2024-02-22 15:17:44 +08:00
this.gmTxt.text=icons[index]
2022-09-23 15:24:10 +08:00
local privile=ConfigManager.GetConfigData(ConfigName.PrivilegeTypeConfig,2101)
if privile then
2022-10-27 15:32:13 +08:00
maxnum=privile.Condition[index][2]
2022-09-23 15:24:10 +08:00
if maxnum~=-1 then
this.progress:SetActive(true)
this.addTxt.text=maxnum-useTime..""
this.progressBar.fillAmount=useTime/maxnum
this.progressTxt.text=useTime.."/"..maxnum
else
this.progress:SetActive(false)
this.addTxt.text="不限"
end
end
2022-09-20 17:04:48 +08:00
end
function this.TabBtnOnClick(btn,config)
2022-11-07 14:38:55 +08:00
curBtn=btn
curConfig=config
2022-09-20 17:04:48 +08:00
--local _level=_privilegeLv>0 and _privilegeLv or 1
--local clickBtn=this.tabGrid.transform:GetChild(_level-1)
this.selectBtn.transform:SetParent(btn.gameObject.transform)
this.selectBtn.transform.localScale = Vector3.one
this.selectBtn.transform.localPosition = Vector3.zero
this.selectBtnText.text=config.Name
--this.UpdateLayout(_level)
local dataList={}
local aa=config.Unlock[1]
local isOpen,tip=CheckGMIsOpen(aa[1],aa[2])
2022-12-07 15:39:35 +08:00
--if isOpen then
2022-09-20 17:04:48 +08:00
this.hint.gameObject:SetActive(false)
this.scroll:SetActive(true)
for k, v in ConfigPairs(GMMaster) do
if v.Type==config.Type then
table.insert(dataList,v)
end
end
this.scrollView:SetData(dataList,function(index, rewardItem)
2022-12-07 15:39:35 +08:00
this:SingleTask(rewardItem, dataList[index],isOpen,tip)
2022-09-20 17:04:48 +08:00
end,not false,not false)
2022-12-07 15:39:35 +08:00
-- else
-- this.hint.gameObject:SetActive(true)
-- this.hint.text=tip
-- this.scroll:SetActive(false)
-- end
2022-09-20 17:04:48 +08:00
end
2022-12-07 15:39:35 +08:00
function GMChangePanel:SingleTask(go,data,isOpen,tip)
2022-09-20 17:04:48 +08:00
local name=Util.GetGameObject(go, "name"):GetComponent("Text")
local num=Util.GetGameObject(go, "num"):GetComponent("Text")
local itemDes=Util.GetGameObject(go, "item"):GetComponent("Text")
local btn=Util.GetGameObject(go, "btn")
local btnTxt=Util.GetGameObject(go, "btn/Text"):GetComponent("Text")
2022-12-07 15:39:35 +08:00
local priceTxt=Util.GetGameObject(go, "price"):GetComponent("Text")
local limitTxt=Util.GetGameObject(go, "limit"):GetComponent("Text")
2022-09-20 17:04:48 +08:00
local recharge=rechargeCommodityConfig[data.PackID]
2022-11-30 18:36:50 +08:00
local scale=1
2022-12-07 15:39:35 +08:00
btn:SetActive(true)
limitTxt.gameObject:SetActive(false)
priceTxt.gameObject:SetActive(true)
2022-12-01 18:03:52 +08:00
if data.PackID~=0 and recharge then
2022-11-30 18:36:50 +08:00
name.text=recharge.Name
2022-12-07 15:39:35 +08:00
priceTxt.gameObject:SetActive(isOpen)
limitTxt.gameObject:SetActive(not isOpen)
btn:SetActive(isOpen)
limitTxt.text=tip
2022-11-30 18:36:50 +08:00
--LogError("type=="..recharge.Type.." id=="..recharge.Id)
local leftBuyTime=OperatingManager.GetLeftBuyTime(recharge.Type,recharge.Id)
if leftBuyTime==-1 then
num.text=""
else
num.text="("..leftBuyTime.."/"..recharge.Limit..")"
end
btn:GetComponent("Button").interactable = leftBuyTime==-1 or leftBuyTime>0
Util.SetGray(btn,leftBuyTime==0)
2022-12-07 15:39:35 +08:00
if data.Type==7 or data.Type==8 then
btnTxt.text="前往"
else
btnTxt.text="兑换"
end
2022-12-07 16:07:15 +08:00
if isOpen and leftBuyTime>0 then
priceTxt.gameObject:SetActive(true)
else
priceTxt.gameObject:SetActive(false)
end
2022-12-07 15:39:35 +08:00
priceTxt.text=data.Price[1][2]..""
2022-11-04 17:49:27 +08:00
else
2022-11-30 18:36:50 +08:00
name.text=data.Name
2022-12-07 15:39:35 +08:00
priceTxt.gameObject:SetActive(false)
2022-12-01 18:03:52 +08:00
btn:GetComponent("Button").interactable = true
Util.SetGray(btn,false)
2022-11-30 18:36:50 +08:00
if data.Id==45 then
scale = BattleManager.GetTimeScale()
scale = math.floor(scale*10 + 0.5)/10
if scale == BATTLE_TIME_SCALE_ONE then
btnTxt.text="一键破解"
else
btnTxt.text="暂停"
end
else
btnTxt.text="前往"
end
2022-11-04 17:49:27 +08:00
end
2022-11-30 18:36:50 +08:00
--LogError("data.id=="..data.Id.." data.name=="..data.Type)
2022-09-20 17:04:48 +08:00
local des=""
2022-12-01 16:03:19 +08:00
-- for i = 1, #data.Price do
-- if itemConfig[data.Price[i][1]] then
-- des=des.." "..itemConfig[data.Price[i][1]].Name.." *"..data.Price[i][2]
-- end
-- end
des=data.DisplayReward
2022-09-20 17:04:48 +08:00
itemDes.text=des
2022-11-30 18:36:50 +08:00
Util.AddOnceClick(btn, function()
if data.PackID==0 then
if data.Id==45 then
scale = BattleManager.GetTimeScale()
scale = math.floor(scale*10 + 0.5)/10
--LogError("scale========="..scale)
if scale == BATTLE_TIME_SCALE_ONE then
BattleManager.SetTimeScale(BATTLE_TIME_SCALE_TWO)
btnTxt.text="暂停"
2022-11-08 13:58:54 +08:00
else
2022-11-30 18:36:50 +08:00
BattleManager.SetTimeScale(BATTLE_TIME_SCALE_ONE)
btnTxt.text="一键破解"
2022-11-08 13:58:54 +08:00
end
2022-11-30 18:36:50 +08:00
scale = BattleManager.GetTimeScale()
scale = math.floor(scale*10 + 0.5)/10
else
JumpManager.GoJump(data.Jump)
end
return
else
2022-12-07 15:39:35 +08:00
if data.Type==7 or data.Type==8 then
JumpManager.GoJump(data.Jump)
return
end
2022-11-30 18:36:50 +08:00
local sureFunc=function()
NetManager.SendGmBuyGoodRequest(data.PackID,function()
if data.Jump~=0 then
self:ClosePanel()
JumpManager.GoJump(data.Jump)
return
end
local leftBuyTime=OperatingManager.GetLeftBuyTime(recharge.Type,recharge.Id)
if leftBuyTime==-1 then
num.text=""
else
num.text="("..leftBuyTime.."/"..recharge.Limit..")"
end
Util.SetGray(btn,leftBuyTime==0)
btn:GetComponent("Button").interactable = leftBuyTime==-1 or leftBuyTime>0
this:ShowTopInfo()
end)
end
local args={}
args[1]="是否兑换?"
args[2]="兑换"
args[3]="取消"
args[4]=sureFunc
UIManager.OpenPanel(UIName.GMCommonConfirmPanel,args)
2022-09-20 17:04:48 +08:00
end
2022-11-30 18:36:50 +08:00
2022-09-20 17:04:48 +08:00
end)
2022-11-30 18:36:50 +08:00
2022-09-20 17:04:48 +08:00
end
function GMChangePanel:OnSortingOrderChange()
end
-- 打开,重新打开时回调
function GMChangePanel:OnShow(_sortingOrder)
2022-11-07 14:38:55 +08:00
this:ShowTopInfo()
this.TabBtnOnClick(curBtn,curConfig)
2022-09-20 17:04:48 +08:00
end
--界面关闭时调用(用于子类重写)
function GMChangePanel:OnClose()
2022-11-07 14:38:55 +08:00
isFirst=true
2022-09-20 17:04:48 +08:00
end
--界面销毁时调用(用于子类重写)
function GMChangePanel:OnDestroy()
this.spLoader:Destroy()
end
return GMChangePanel