miduo_client/Assets/ManagedResources/~Lua/Modules/Harmony/View/HarmonyScrllow.lua

563 lines
19 KiB
Lua
Raw Normal View History

2021-02-20 16:55:28 +08:00
local this={}
2020-11-27 17:59:25 +08:00
this.tab=ConfigManager.GetConfig(ConfigName.Hongmeng)
2020-12-15 11:03:34 +08:00
local Gold =0;
local DemonCrystal = 0
local HeroList = {}
local tempData = nil
local TempItem = nil
local ItemList = {}
local Box = 0
local OpenBox = 0
2020-12-22 15:41:45 +08:00
local HeroCount
2020-12-15 11:03:34 +08:00
2021-01-04 15:27:19 +08:00
this.timerEffect = nil
2020-12-15 11:03:34 +08:00
function this:AwakeLength()
2020-12-22 15:41:45 +08:00
HeroCount = 0
2020-12-15 11:03:34 +08:00
Box = #HarmonyManager.hongmengHeroInfos;
OpenBox = #HarmonyManager.hongmengHeroInfos+2
2021-01-07 21:45:22 +08:00
--print(Box.."@@@@@@@@@"..OpenBox)
2020-12-15 11:03:34 +08:00
for i = 1, #HarmonyManager.hongmengHeroInfos do
-- body
if HarmonyManager.hongmengHeroInfos[i].heroId~="" then
-- body
HeroCount = HeroCount + 1
end
end
if self.stage == 1 then
-- body
this.NumText.text = string.format("%d/%d",HeroCount,Box)
else
local count = 0
2020-12-17 10:41:00 +08:00
for i = 1, #HarmonyManager.hongmengGuards do
2020-12-15 11:03:34 +08:00
-- body
2020-12-17 10:41:00 +08:00
if HarmonyManager.hongmengGuards[i].heroId ~= "" then
2020-12-15 11:03:34 +08:00
count = count + 1
-- body
end
end
2021-01-12 16:29:14 +08:00
2020-12-17 10:41:00 +08:00
this.NumText.text = string.format("%d/%d",HeroCount + count,Box + #HarmonyManager.hongmengGuards)
2020-12-15 11:03:34 +08:00
end
2020-11-27 17:59:25 +08:00
2020-12-15 11:03:34 +08:00
end
function this:InitComponent(gameObject,Golds,DemonCrystals,stage)
Gold = Golds
DemonCrystal = DemonCrystals
self.stage = stage
2020-11-27 17:59:25 +08:00
-- item预制件
this.item = Util.GetGameObject(gameObject , "HarmonyPanel/item")
--btn组件
this.addBtn = Util.GetGameObject(gameObject,"HarmonyPanel/AddBtn")
this.GongMingMsgBtn = Util.GetGameObject(gameObject,"HarmonyPanel/KnowGongMing")
2020-12-15 11:03:34 +08:00
2020-11-27 17:59:25 +08:00
this.scrollbar = Util.GetGameObject(gameObject,"HarmonyPanel/Scrollbar"):GetComponent("Scrollbar")
local scrollParent = Util.GetGameObject(gameObject, "HarmonyPanel/scroll"):GetComponent("RectTransform").rect
2020-12-15 11:03:34 +08:00
this.NumText = Util.GetGameObject(gameObject,"HarmonyPanel/itemNumText"):GetComponent("Text")
2020-11-27 17:59:25 +08:00
this.ScrollView=SubUIManager.Open(SubUIConfig.ScrollCycleView,Util.GetGameObject(gameObject,"HarmonyPanel/scroll").transform,
2021-01-11 11:03:06 +08:00
this.item,this.scrollbar,Vector2.New(-scrollParent.x*2,-scrollParent.y*2),1,5,Vector2.New(42,15))
2020-11-27 17:59:25 +08:00
this.ScrollView.moveTween.MomentumAmount = 1
this.ScrollView.moveTween.Strength = 1
-- for key, value in ConfigPairs(this.tab) do
-- print("key:",key,"value",value.Id)
-- end
this.BoxList=0;
2020-12-15 11:03:34 +08:00
this:AwakeLength()
2020-11-27 17:59:25 +08:00
this:InitBox()
2020-12-15 11:03:34 +08:00
--this.RunTimerFun()
2020-11-27 17:59:25 +08:00
end
2020-12-15 11:03:34 +08:00
local TextList = {}
local BoxList = {}
2020-11-27 17:59:25 +08:00
function this:InitBox()
2020-12-15 11:03:34 +08:00
--
2020-11-27 17:59:25 +08:00
local keys = GameDataBase.SheetBase.GetKeys(this.tab) --获取数据长度
2020-12-28 20:02:36 +08:00
2020-11-27 17:59:25 +08:00
this.ScrollView:SetData(keys,function (index, go)
local key = keys[index]
2021-01-15 19:40:47 +08:00
2020-12-15 11:03:34 +08:00
this.SingleBoxDataShow(go, this.tab[key], index)
2020-12-28 20:02:36 +08:00
2021-01-15 19:40:47 +08:00
end,false,false)
2020-12-30 14:50:38 +08:00
--print(LengthOfTable(ItemList))
2020-12-15 11:03:34 +08:00
2020-11-27 17:59:25 +08:00
end
2020-12-15 11:03:34 +08:00
function this.RunTimerFun()
local refreshFunc = function()
for key, value in pairs(ItemList) do
2020-12-30 14:50:38 +08:00
if value.index <= #HarmonyManager.hongmengHeroInfos then
2020-12-29 20:36:37 +08:00
--value.TimerText.text = "" value.index <= #HarmonyManager.hongmengHeroInfos and
2021-01-04 15:27:19 +08:00
-- print("倒计时开启 .."..#HarmonyManager.hongmengHeroInfos)
2020-12-28 20:02:36 +08:00
if value.TimerText ~=nil and value.Empty ~=nil then
-- body
if HarmonyManager.hongmengHeroInfos[value.index].time - GetTimeStamp() > 0 then
if value.Empty ~=nil then
-- body
2020-12-29 20:36:37 +08:00
--print(value.Empty," ")
2021-01-04 09:57:42 +08:00
-- if value.Empty.activeSelf == false then
-- -- body
-- value.Empty:SetActive(true)
-- end
2020-12-28 20:02:36 +08:00
end
2020-12-29 20:36:37 +08:00
2020-12-28 20:02:36 +08:00
local time_content = TimeToFelaxible(HarmonyManager.hongmengHeroInfos[value.index].time - GetTimeStamp())
2020-12-29 20:36:37 +08:00
--print(" ~~~~~ ",value.TimerText," xxxxx",time_content)
2021-03-04 15:16:23 +08:00
value.TimerText.text = string.format(Language[12204],time_content)
2020-12-28 20:02:36 +08:00
else
2020-12-29 20:36:37 +08:00
HarmonyManager.hongmengHeroInfos[value.index].time = 0
if value.TimerText then
-- body
value.TimerText.text = ""
2021-01-20 14:07:31 +08:00
if not value.AddImage.activeSelf then
-- body
value.AddImage:SetActive(true)
end
2020-12-29 20:36:37 +08:00
end
2020-12-15 11:03:34 +08:00
end
2020-12-28 20:02:36 +08:00
end
2020-12-28 14:12:17 +08:00
else
2020-12-15 11:03:34 +08:00
end
end
end
2021-01-04 15:27:19 +08:00
if this.timerEffect ==nil then
-- body
this.timerEffect = Timer.New(refreshFunc, 1, -1, true)
end
2020-12-15 11:03:34 +08:00
this.timerEffect:Start()
refreshFunc()
end
function this.SingleBoxDataShow(go,boxData,index)
2020-11-27 17:59:25 +08:00
-- body
2020-12-15 11:03:34 +08:00
local mask = Util.GetGameObject(go.transform,"Box/Empty/lock/mask");
local lock = Util.GetGameObject(go.transform,"Box/Empty/lock");
local Empty = Util.GetGameObject(go.transform,"Box/Empty")
2021-01-07 21:45:22 +08:00
local TimerText = Util.GetGameObject(go.transform,"Box/Empty/frame/Text"):GetComponent("Text")
local AddImage = Util.GetGameObject(go.transform,"Box/Empty/frame/AddImage")
2020-12-18 13:39:35 +08:00
local redPoint = Util.GetGameObject(go.transform,"Box/Empty/redPoint")
2021-02-27 19:30:23 +08:00
Util.GetGameObject(go.transform, "GameObject/proIcon"):GetComponent("Image").sprite = Util.LoadSprite("r_hero_huo 1_zh")
2020-12-29 20:36:37 +08:00
ItemList[go] ={}
ItemList[go].index = index
ItemList[go].TimerText = TimerText
ItemList[go].Empty = Empty
2021-01-20 14:07:31 +08:00
ItemList[go].AddImage = AddImage
2020-12-18 13:39:35 +08:00
2020-12-15 11:03:34 +08:00
Empty:SetActive(true)
mask:SetActive(true)
lock:SetActive(true)
2020-12-23 17:41:31 +08:00
redPoint:SetActive(false)
2020-12-17 10:41:00 +08:00
Util.SetGray(lock,true)
2020-12-15 11:03:34 +08:00
local gridData = HarmonyManager.hongmengHeroInfos[boxData.Id]
2020-12-28 20:02:36 +08:00
TimerText.text = ""
2020-12-15 11:03:34 +08:00
if gridData then
if gridData.gridId <= Box then
if gridData.heroId ~= "" then
Empty:SetActive(false)
local data = HeroManager.GetSingleHeroData(gridData.heroId)
if data then
this.SingleItemDataShow(go, data)
else
LogError("error: no hero data")
end
else
2021-01-20 14:07:31 +08:00
if gridData.time - GetTimeStamp() <= 0 then
2020-12-15 11:03:34 +08:00
-- body
2021-01-07 21:45:22 +08:00
2020-12-15 11:03:34 +08:00
TimerText.text = ""
2021-01-07 21:45:22 +08:00
AddImage:SetActive(true)
2020-12-15 11:03:34 +08:00
else
2021-01-07 21:45:22 +08:00
AddImage:SetActive(false)
2020-12-15 11:03:34 +08:00
end
Empty:SetActive(true)
mask:SetActive(false)
2020-11-27 17:59:25 +08:00
lock:SetActive(false)
2020-12-18 13:39:35 +08:00
redPoint:SetActive(false)
2020-12-23 17:41:31 +08:00
end
else
2020-11-27 17:59:25 +08:00
end
2020-12-15 11:03:34 +08:00
elseif index == Box + 1 then
mask:SetActive(false)
2020-12-17 10:41:00 +08:00
Util.SetGray(lock,false)
2020-12-23 17:41:31 +08:00
tempData = boxData
2020-12-18 13:39:35 +08:00
if HarmonyManager.RefreshOpenBoxPoint() then
-- body
2021-02-20 21:22:05 +08:00
Gold = BagManager.GetTotalItemNum(UpViewRechargeType.XuanHuangZhiQi)
2020-12-18 13:39:35 +08:00
CheckRedPointStatus(RedPointType.HongMeng_OpenBox)
2021-02-20 21:22:05 +08:00
-- print(Gold.."!@@@@@@"..boxData.PropPrice[2])
2021-01-12 16:29:14 +08:00
if Gold > boxData.PropPrice[2] then
2021-01-05 20:44:14 +08:00
-- body
redPoint:SetActive(true)
2021-01-12 16:29:14 +08:00
else
redPoint:SetActive(false)
2021-01-05 20:44:14 +08:00
end
2020-12-18 13:39:35 +08:00
else
2021-01-12 16:29:14 +08:00
redPoint:SetActive(false)
2020-12-18 13:39:35 +08:00
end
2020-12-23 17:41:31 +08:00
else
TimerText.text = ""
2020-12-15 11:03:34 +08:00
end
Util.AddOnceClick(go,function()
if gridData then
-- body
if gridData.heroId ~= "" then
-- body
TempItem = index
HarmonyManager:SetMingListIndexData(boxData.Id)
HarmonyManager.UnLoadGongMing = boxData.Id--发往服务器
UIManager.OpenPanel(UIName.HongMengUnLoadPanel)
else
if gridData.time == 0 then
-- body
2020-12-17 10:41:00 +08:00
UIManager.OpenPanel(UIName.HongMengChooseHeroPanel,false)
2020-12-15 11:03:34 +08:00
TempItem = index
HarmonyManager.GongMingBox = boxData.Id
2021-03-04 15:16:23 +08:00
print(Language[12205],HarmonyManager.GongMingBox)
2020-12-15 11:03:34 +08:00
else
local content = ""
2021-01-06 19:35:41 +08:00
--print((HarmonyManager.hongmengHeroInfos[boxData.Id].time - GetTimeStamp()) / 432)
2021-01-05 20:44:14 +08:00
local money = math.ceil((HarmonyManager.hongmengHeroInfos[boxData.Id].time - GetTimeStamp()) / 432)
2021-03-04 15:16:23 +08:00
content =string.format(Language[12189],money)
2020-12-15 11:03:34 +08:00
MsgPanel.ShowTwo(content,function ()
MsgPanel.Hide()
end,function ()
if DemonCrystal < money then
2021-03-02 16:53:12 +08:00
PopupTipPanel.ShowTip(Language[10846])
2020-12-15 11:03:34 +08:00
MsgPanel.Hide()
return
end
--向服务器 发消息
2020-12-18 13:39:35 +08:00
NetManager.UnlockGrid(boxData.Id,1,function ()
2020-12-15 11:03:34 +08:00
-- body
2020-12-18 13:39:35 +08:00
2020-12-15 11:03:34 +08:00
for i = 1, #HarmonyManager.hongmengHeroInfos do
-- body
2020-12-18 13:39:35 +08:00
if HarmonyManager.hongmengHeroInfos[i].gridId ==boxData.Id then
2020-12-15 11:03:34 +08:00
HarmonyManager.hongmengHeroInfos[i].time = 0
2021-03-04 15:16:23 +08:00
print(Language[12206])
2021-01-25 16:27:28 +08:00
break
2020-12-15 11:03:34 +08:00
end
end
2021-01-07 21:45:22 +08:00
AddImage:SetActive(true)
2020-12-18 13:39:35 +08:00
TimerText.text = ""
2021-01-25 16:27:28 +08:00
2021-03-02 16:53:12 +08:00
end,Language[10731],Language[11934])
2021-01-25 16:27:28 +08:00
this.RunTimerFun()
2020-12-15 11:03:34 +08:00
end)
end
end
2020-11-27 17:59:25 +08:00
else
2020-12-15 11:03:34 +08:00
if mask.activeSelf then
-- body
2021-03-04 15:16:23 +08:00
PopupTipPanel.ShowTip(Language[12207])
2020-12-15 11:03:34 +08:00
else
if lock.activeSelf then
-- body
this:AddBoxFun(boxData)
end
end
2020-11-27 17:59:25 +08:00
end
2020-12-15 11:03:34 +08:00
end)
end
--卸载刷新
function this:UpdateItemShow(go,boxData,msg)
2020-11-27 17:59:25 +08:00
2020-12-15 11:03:34 +08:00
end
function this:AddBoxFun(boxData)
local content = ""
2021-01-06 10:21:55 +08:00
Gold = BagManager.GetTotalItemNum(UpViewRechargeType.XuanHuangZhiQi)
DemonCrystal = BagManager.GetTotalItemNum(UpViewRechargeType.DemonCrystal)
2021-01-06 11:16:10 +08:00
local keys = GameDataBase.SheetBase.GetKeys(this.tab) --获取数据长度
if #HarmonyManager.hongmengHeroInfos >= #keys then
-- body
2021-03-04 15:16:23 +08:00
PopupTipPanel.ShowTip(Language[12208])
2021-01-06 11:16:10 +08:00
return
end
2021-01-06 19:35:41 +08:00
2020-12-23 17:41:31 +08:00
if Gold >= boxData.PropPrice[2] then
2021-03-04 15:16:23 +08:00
content =string.format(Language[12209],boxData.PropPrice[2])
2021-01-05 20:44:14 +08:00
elseif Gold < boxData.PropPrice[2] then
-- body and DemonCrystal >= boxData.MoneyPrice[2]
2021-03-04 15:16:23 +08:00
content=string.format(Language[12210],boxData.PropPrice[2],boxData.MoneyPrice[2])
2021-01-05 20:44:14 +08:00
2020-11-27 17:59:25 +08:00
end
2020-12-15 11:03:34 +08:00
MsgPanel.ShowTwo(content,function ()
end,function ()
if Gold < boxData.PropPrice[2] and DemonCrystal < boxData.MoneyPrice[2] then
2021-03-02 16:53:12 +08:00
PopupTipPanel.ShowTip(Language[10497])
2020-12-15 11:03:34 +08:00
return
2021-01-06 11:16:10 +08:00
end
if condition then
-- body
2020-12-15 11:03:34 +08:00
end
--向服务器请求消息
2020-12-18 13:39:35 +08:00
NetManager.HongMengRequset(boxData.Id,function()
2020-12-15 11:03:34 +08:00
--
Game.GlobalEvent:DispatchEvent(GameEvent.HongMeng.RereshNumText,boxData.Id)
end)
2021-03-02 16:53:12 +08:00
end,Language[10731],Language[11934])
2020-11-27 17:59:25 +08:00
end
function this:BindEvent()
2020-12-15 11:03:34 +08:00
end
2020-11-27 17:59:25 +08:00
2020-12-15 11:03:34 +08:00
function this:OnOpen()
this:AwakeLength()
2020-12-29 20:36:37 +08:00
ItemList = {}
2020-12-28 20:02:36 +08:00
this:InitBox()
2020-12-15 11:03:34 +08:00
this.RunTimerFun()
2020-12-29 20:36:37 +08:00
--this.timerEffect:Start()
2020-12-15 11:03:34 +08:00
end
function this.SingleItemDataShow(clone,Itemdata)
2020-12-28 10:44:31 +08:00
--LogGreen(clone.name.."||"..Itemdata.heroConfig.Id)
2020-12-26 15:07:51 +08:00
--Util.GetGameObject(clone.transform, "Box/Empty"):SetActive(false)
2020-12-15 11:03:34 +08:00
Util.GetGameObject(clone.transform, "GameObject/frame"):GetComponent("Image").sprite = Util.LoadSprite(GetHeroQuantityImageByquality(Itemdata.heroConfig.Quality,Itemdata.star))
Util.GetGameObject(clone.transform, "GameObject/lv/Text"):GetComponent("Text").text = string.format("<color=#0f0>%d</color>",Itemdata.lv)
Util.GetGameObject(clone.transform, "GameObject/icon"):GetComponent("Image").sprite = Util.LoadSprite(Itemdata.icon)
--Util.GetGameObject(clone.transform, "GameObject/posIcon"):SetActive(false)--:GetComponent("Image").sprite = Util.LoadSprite(heroData.professionIcon)
Util.GetGameObject(clone.transform, "GameObject/proIcon"):GetComponent("Image").sprite = Util.LoadSprite(GetProStrImageByProNum(Itemdata.heroConfig.PropertyName))
local starGrid = Util.GetGameObject(clone.transform, "GameObject/star")
SetHeroStars(starGrid, Itemdata.star,1,nil,nil,Vector2.New(0,1))
2020-11-27 17:59:25 +08:00
end
2020-12-15 11:03:34 +08:00
function this:Refesh(id)
-- body
Box = Box + 1
OpenBox = OpenBox + 1
2020-12-24 14:43:32 +08:00
Gold = BagManager.GetTotalItemNum(UpViewRechargeType.XuanHuangZhiQi)
DemonCrystal = BagManager.GetTotalItemNum(UpViewRechargeType.DemonCrystal)
2020-12-15 11:03:34 +08:00
if self.stage == 1 then
2020-12-22 15:41:45 +08:00
Game.GlobalEvent:DispatchEvent(GameEvent.HongMeng.OnlyRefeshText,{HeroCount,Box})
2020-12-15 11:03:34 +08:00
else
local count = 0
2020-12-17 10:41:00 +08:00
for i = 1, #HarmonyManager.hongmengGuards do
2020-12-15 11:03:34 +08:00
-- body
2020-12-17 10:41:00 +08:00
if HarmonyManager.hongmengGuards[i].heroId ~= "" then
2020-12-15 11:03:34 +08:00
count = count + 1
-- body
end
end
2020-12-22 15:41:45 +08:00
Game.GlobalEvent:DispatchEvent(GameEvent.HongMeng.OnlyRefeshText,{HeroCount + count,Box + #HarmonyManager.hongmengGuards})
2020-12-15 11:03:34 +08:00
end
2020-12-17 10:41:00 +08:00
LogGreen(Box)
2020-12-15 11:03:34 +08:00
local data = {}
data.gridId = id
data.heroId = ""
2020-12-17 10:41:00 +08:00
data.time = 0
2020-12-15 11:03:34 +08:00
table.insert(HarmonyManager.hongmengHeroInfos,data)
local keys = GameDataBase.SheetBase.GetKeys(this.tab) --获取数据长度
this.ScrollView:SetData(keys,function (index, go)
local key = keys[index]
2021-01-15 19:40:47 +08:00
this.SingleBoxDataShow(go, this.tab[key], index)
2020-12-28 20:02:36 +08:00
2021-01-15 19:40:47 +08:00
end,true,true)
2020-12-15 11:03:34 +08:00
end
function this:OpenBoxFun()
2020-12-28 20:02:36 +08:00
if tempData then
-- body
this:AddBoxFun(tempData)
2021-01-06 11:16:10 +08:00
else
2021-03-04 15:16:23 +08:00
PopupTipPanel.ShowTip(Language[12208])
2021-01-06 11:16:10 +08:00
return
2020-12-28 20:02:36 +08:00
end
2020-12-15 11:03:34 +08:00
end
2020-11-27 17:59:25 +08:00
2020-12-15 11:03:34 +08:00
function this:UpdateHero(Herodata)
2020-12-17 10:41:00 +08:00
2020-12-15 11:03:34 +08:00
for i = 1, #HarmonyManager.hongmengHeroInfos do
-- body
if HarmonyManager.GongMingBox ==HarmonyManager.hongmengHeroInfos[i].gridId then
-- body
HarmonyManager.hongmengHeroInfos[i].heroId = Herodata.dynamicId
HarmonyManager.hongmengHeroInfos[i].time = 0
2021-01-25 16:27:28 +08:00
2020-12-15 11:03:34 +08:00
break
2020-11-27 17:59:25 +08:00
end
end
2020-12-15 11:03:34 +08:00
HeroCount = HeroCount + 1
if self.stage == 1 then
-- body
Game.GlobalEvent:DispatchEvent(GameEvent.HongMeng.OnlyRefeshText,{HeroCount,Box})
else
local count = 0
2020-12-17 10:41:00 +08:00
for i = 1, #HarmonyManager.hongmengGuards do
2020-12-15 11:03:34 +08:00
-- body
2020-12-17 10:41:00 +08:00
if HarmonyManager.hongmengGuards[i].heroId~="" then
2020-12-15 11:03:34 +08:00
count = count + 1
-- body
end
end
2020-12-17 10:41:00 +08:00
Game.GlobalEvent:DispatchEvent(GameEvent.HongMeng.OnlyRefeshText,{HeroCount + count,Box + #HarmonyManager.hongmengGuards})
2020-12-15 11:03:34 +08:00
end
--Game.GlobalEvent:DispatchEvent(GameEvent.HongMeng.OnlyRefeshText,{HeroCount,Box, 1})
--this.NumText.text = string.format("%d/%d",HeroCount,Box)
local keys = GameDataBase.SheetBase.GetKeys(this.tab) --获取数据长度
--刷新选择英雄界面的 数据
HarmonyManager:SetInitList()
2020-11-27 17:59:25 +08:00
2020-12-15 11:03:34 +08:00
this.ScrollView:SetData(keys,function (index, go)
local key = keys[index]
2021-01-15 19:40:47 +08:00
this.SingleBoxDataShow(go, this.tab[key], index)
2020-12-28 20:02:36 +08:00
2021-01-15 19:40:47 +08:00
end,true,true)
2020-12-30 14:50:38 +08:00
this.RunTimerFun()
2020-11-27 17:59:25 +08:00
end
2021-01-12 16:29:14 +08:00
2020-11-27 17:59:25 +08:00
2020-12-15 11:03:34 +08:00
function this:UnLoadFun(msg)
HeroCount = HeroCount - 1
2020-11-27 17:59:25 +08:00
2020-12-15 11:03:34 +08:00
for key, value in pairs(ItemList) do
2020-12-29 20:36:37 +08:00
if value.index == TempItem then
2020-12-15 11:03:34 +08:00
-- body
2020-12-29 20:36:37 +08:00
HarmonyManager.hongmengHeroInfos[value.index].time = msg.leftTime + GetTimeStamp()
2020-12-15 11:03:34 +08:00
2020-12-29 20:36:37 +08:00
HarmonyManager.hongmengHeroInfos[value.index].heroId = ""
2020-12-15 11:03:34 +08:00
end
2020-11-27 17:59:25 +08:00
2020-12-15 11:03:34 +08:00
end
--刷新选择英雄界面的 数据
HarmonyManager:SetInitList()
if self.stage == 1 then
-- body
Game.GlobalEvent:DispatchEvent(GameEvent.HongMeng.OnlyRefeshText,{HeroCount,Box, 1})
else
local count = 0
2020-12-17 10:41:00 +08:00
for i = 1, #HarmonyManager.hongmengGuards do
2020-12-15 11:03:34 +08:00
-- body
2020-12-17 10:41:00 +08:00
if HarmonyManager.hongmengGuards[i].heroId ~= "" then
2020-12-15 11:03:34 +08:00
count = count + 1
-- body
end
end
2020-12-17 10:41:00 +08:00
Game.GlobalEvent:DispatchEvent(GameEvent.HongMeng.OnlyRefeshText,{HeroCount + count,Box + #HarmonyManager.hongmengGuards})
2020-12-15 11:03:34 +08:00
end
-- Game.GlobalEvent:DispatchEvent(GameEvent.HongMeng.OnlyRefeshText,{HeroCount,Box, 1})
--this.NumText.text = string.format("%d/%d",HeroCount,Box)
2020-11-27 17:59:25 +08:00
local keys = GameDataBase.SheetBase.GetKeys(this.tab) --获取数据长度
2020-12-15 11:03:34 +08:00
2020-12-30 14:50:38 +08:00
ItemList = {}
2020-11-27 17:59:25 +08:00
this.ScrollView:SetData(keys,function (index, go)
local key = keys[index]
2021-01-15 19:40:47 +08:00
this.SingleBoxDataShow(go, this.tab[key], index)
2020-12-28 20:02:36 +08:00
2021-01-15 19:40:47 +08:00
end,true,true)
2020-12-30 14:50:38 +08:00
this.RunTimerFun()
2020-11-27 17:59:25 +08:00
end
2020-12-29 20:36:37 +08:00
function this:OnlyRefeshHeroLv()
ItemList = {}
local keys = GameDataBase.SheetBase.GetKeys(this.tab) --获取数据长度
this.ScrollView:SetData(keys,function (index, go)
local key = keys[index]
2021-01-15 19:40:47 +08:00
this.SingleBoxDataShow(go, this.tab[key], index)
2020-12-29 20:36:37 +08:00
2021-01-15 19:40:47 +08:00
end,true,true)
2021-01-25 16:27:28 +08:00
2020-12-29 20:36:37 +08:00
end
2020-12-15 11:03:34 +08:00
--界面关闭时调用(用于子类重写)
function this:OnClose()
if this.timerEffect then
-- body
this.timerEffect:Stop()
end
end
2020-11-27 17:59:25 +08:00
function this:AddListener()
-- body
2020-12-15 11:03:34 +08:00
2020-11-27 17:59:25 +08:00
Game.GlobalEvent:AddEvent(GameEvent.HongMeng.RereshNumText,self.Refesh,self)
2020-12-15 11:03:34 +08:00
Game.GlobalEvent:AddEvent(GameEvent.HongMeng.OpenBoxTips,self.OpenBoxFun,self)
Game.GlobalEvent:AddEvent(GameEvent.HongMeng.ChooseData,self.UpdateHero,self)
Game.GlobalEvent:AddEvent(GameEvent.HongMeng.UnLoadData,self.UnLoadFun,self)
2021-01-12 16:29:14 +08:00
Game.GlobalEvent:AddEvent(GameEvent.Bag.BagGold,self.OnlyRefeshHeroLv,self)
2020-12-29 20:36:37 +08:00
Game.GlobalEvent:AddEvent(GameEvent.HongMeng.UpdateGongMingLv,self.OnlyRefeshHeroLv,self)
2020-11-27 17:59:25 +08:00
end
function this:RemoveListener()
-- body
2020-12-15 11:03:34 +08:00
Game.GlobalEvent:RemoveEvent(GameEvent.HongMeng.RereshNumText,self.Refesh,self)
Game.GlobalEvent:RemoveEvent(GameEvent.HongMeng.OpenBoxTips,self.OpenBoxFun,self)
Game.GlobalEvent:RemoveEvent(GameEvent.HongMeng.ChooseData,self.UpdateHero,self)
Game.GlobalEvent:RemoveEvent(GameEvent.HongMeng.UnLoadData,self.UnLoadFun,self)
2021-01-12 16:29:14 +08:00
Game.GlobalEvent:RemoveEvent(GameEvent.Bag.BagGold,self.OnlyRefeshHeroLv,self)
2020-12-29 20:36:37 +08:00
Game.GlobalEvent:RemoveEvent(GameEvent.HongMeng.UpdateGongMingLv,self.OnlyRefeshHeroLv,self)
2020-11-27 17:59:25 +08:00
end
function this:OnShow(...)
-- body
end
2020-12-15 11:03:34 +08:00
2020-11-27 17:59:25 +08:00
return this