546 lines
23 KiB
Lua
546 lines
23 KiB
Lua
local TimeLimitUpHero = {}
|
||
local sortingOrder = 0
|
||
local globalActive = ConfigManager.GetConfig(ConfigName.GlobalActivity)
|
||
local lotterySetting = ConfigManager.GetConfig(ConfigName.LotterySetting)
|
||
local privilegeConfig = ConfigManager.GetConfig(ConfigName.PrivilegeTypeConfig)
|
||
local artResourcesConfig = ConfigManager.GetConfig(ConfigName.ArtResourcesConfig)
|
||
local itemConfig = ConfigManager.GetConfig(ConfigName.ItemConfig)
|
||
local heroConfig = ConfigManager.GetConfig(ConfigName.HeroConfig)
|
||
local wishConfig = nil
|
||
local heroLiveObj = nil
|
||
local curConfig = nil
|
||
local curHeroId = 0
|
||
local activityData = nil
|
||
function TimeLimitUpHero:New(gameObject)
|
||
local b = {}
|
||
b.gameObject = gameObject
|
||
b.transform = gameObject.transform
|
||
setmetatable(b, { __index = TimeLimitUpHero })
|
||
return b
|
||
end
|
||
|
||
local Setting = nil
|
||
local oneFunc = nil
|
||
local tenFunc = nil
|
||
local oneFunc2 = nil
|
||
local isYaojing = false
|
||
--初始化组件(用于子类重写)
|
||
function TimeLimitUpHero:InitComponent()
|
||
self.spLoader = SpriteLoader.New()
|
||
self.helpBtn = Util.GetGameObject(self.gameObject, "help")
|
||
self.helpPosition = self.helpBtn:GetComponent("RectTransform").localPosition
|
||
self.titleImg = Util.GetGameObject(self.gameObject, "title"):GetComponent("Image")
|
||
self.btnActivity = Util.GetGameObject(self.gameObject, "btngroup/btnActivity")
|
||
self.btnStore = Util.GetGameObject(self.gameObject, "btngroup/store")
|
||
self.btnStore:SetActive(false)
|
||
self.btnActivity:GetComponent("Image").sprite = self.spLoader:LoadSprite("r_shilian-jiangli_zh")
|
||
|
||
self.btns = {}
|
||
self.bgs = {}
|
||
for i = 1, 2 do
|
||
self.btns[i] = {}
|
||
self.btns[i].btn = Util.GetGameObject(self.gameObject, "btngroup/btn" .. i)
|
||
self.btns[i].red = Util.GetGameObject(self.btns[i].btn.gameObject, "redPoint")
|
||
self.btns[i].info = Util.GetGameObject(self.btns[i].btn.gameObject, "layout/Text"):GetComponent("Text")
|
||
self.btns[i].icon = Util.GetGameObject(self.btns[i].btn.gameObject, "layout/icon"):GetComponent("Image")
|
||
self.btns[i].num = Util.GetGameObject(self.btns[i].btn.gameObject, "layout/num"):GetComponent("Text")
|
||
end
|
||
|
||
self.timeupdate = Util.GetGameObject(self.gameObject, "timeupdate"):GetComponent("Text") --免费次数剩余刷新时间
|
||
self.upper = Util.GetGameObject(self.gameObject, "maxtimes/times"):GetComponent("Text") ---召唤上限
|
||
self.recruitTimesUpdate = Util.GetGameObject(self.gameObject, "recruitTimesUpdate/recruitTime"):GetComponent("Text") --保底剩余次数
|
||
|
||
self.getBtn = Util.GetGameObject(self.gameObject, "nextlevel")
|
||
self.slider = Util.GetGameObject(self.getBtn, "Slider"):GetComponent("Slider")
|
||
self.sliderText = Util.GetGameObject(self.getBtn, "Text"):GetComponent("Text")
|
||
self.sliderText2 = Util.GetGameObject(self.slider.gameObject, "Text"):GetComponent("Text")
|
||
self.nextReward = Util.GetGameObject(self.getBtn, "reward")
|
||
self.effect = Util.GetGameObject(self.nextReward, "juneng_chenggong")
|
||
|
||
self.Bg = Util.GetGameObject(self.gameObject, "Bg2"):GetComponent("Image")
|
||
self.mask1 = Util.GetGameObject(self.gameObject, "Bg2/mask")
|
||
self.heroPar = Util.GetGameObject(self.mask1, "curObj")
|
||
self.dragView = Util.GetGameObject(self.mask1, "dragView")
|
||
self.btn_hero = Util.GetGameObject(self.gameObject, "btngroup/btn_hero")
|
||
self.lsth = Util.GetGameObject(self.gameObject, "btngroup/zqbg")
|
||
--self.lsth.gameObject:SetActive(false)
|
||
self.zqbgRed = Util.GetGameObject(self.gameObject, "btngroup/zqbg/red")
|
||
self.zqbgEffect = Util.GetGameObject(self.gameObject, "btngroup/zqbg/Fx_Circle 1")
|
||
BindRedPointObject(RedPointType.TimeLimitWishStore, self.zqbgRed)
|
||
self.heroIcon = Util.GetGameObject(self.btn_hero, "Icon"):GetComponent("Image")
|
||
self.callTimeImg = Util.GetGameObject(self.gameObject, "callTimeImg"):GetComponent("Image")
|
||
self.callTimeTxt = Util.GetGameObject(self.gameObject, "callTimeImg/Text"):GetComponent("Text")
|
||
|
||
self.previewBtn = Util.GetGameObject(self.mask1, "PreviewBtn")
|
||
self.heroNameTxt = Util.GetGameObject(self.previewBtn, "di/Name/Text"):GetComponent("Text")
|
||
self.heroProImg = Util.GetGameObject(self.previewBtn, "di/Image"):GetComponent("Image")
|
||
self.starPar = Util.GetGameObject(self.previewBtn, "di/Image"):GetComponent("Image")
|
||
self.gailvImg = Util.GetGameObject(self.btn_hero, "InfoImg2"):GetComponent("Image")
|
||
self.changeImg = Util.GetGameObject(self.btn_hero, "InfoImg"):GetComponent("Image")
|
||
-- self.changeImg.sprite=self.spLoader:LoadSprite("x_xinjiangzhaohuan_icondi_ghwj_zh")
|
||
self.gailvImg.sprite = self.spLoader:LoadSprite("x_xinjiangzhaohuan_gailv_zh")
|
||
|
||
self.mask2 = Util.GetGameObject(self.gameObject, "Bg2/mask2")
|
||
self.mask2Img = Util.GetGameObject(self.mask2, "curObj/Image"):GetComponent("Image")
|
||
end
|
||
|
||
--绑定事件(用于子类重写)
|
||
function TimeLimitUpHero:BindEvent()
|
||
Util.AddClick(self.btn_hero.gameObject, function()
|
||
-- 制作数据
|
||
local upConfig = ConfigManager.GetConfigDataByKey(ConfigName.WishActivityUp, "ActivityId", self.actId)
|
||
if not upConfig then
|
||
return
|
||
end
|
||
local str = upConfig.UpList
|
||
local heros = {}
|
||
for i = 1, #str do
|
||
table.insert(heros, { str[i][1], str[i][5], str[i][2] })
|
||
end
|
||
-- 打开选择界面
|
||
UIManager.OpenPanel(UIName.GeneralBigPopup, GENERAL_POPUP_TYPE.ChooseUpHero, heros, curHeroId, function(chooseId)
|
||
NetManager.ChoiceHeroRewardRequest(self.actId, chooseId, function()
|
||
ActivityGiftManager.SetActivityInfoRewardId(self.actId, chooseId)
|
||
Game.GlobalEvent:DispatchEvent(GameEvent.Activity.TimeLimitUpHeroChange, chooseId)
|
||
end)
|
||
end)
|
||
end)
|
||
Util.AddClick(self.dragView.gameObject, function()
|
||
local SkeletonGraphic = heroLiveObj:GetComponent("SkeletonGraphic")
|
||
SkeletonGraphic.AnimationState:SetAnimation(0, "touch", false)
|
||
end)
|
||
Util.AddOnceClick(self.helpBtn, function()
|
||
UIManager.OpenPanel(UIName.HelpPopup, Setting.QAId, self.helpPosition.x, self.helpPosition.y)
|
||
end)
|
||
|
||
Util.AddOnceClick(self.btnActivity, function()
|
||
UIManager.OpenPanel(UIName.GeneralBigPopup, GENERAL_POPUP_TYPE.RecrutDetail, Setting.QAId,
|
||
ActivityTypeDef.LimitUpHero, PRE_REWARD_POOL_TYPE.TIME_LIMITED_NEW, PRE_REWARD_POOL_TYPE.TIME_LIMITED_NEW_UP,
|
||
curHeroId, self.actId)
|
||
end)
|
||
Util.AddOnceClick(self.btnStore, function()
|
||
JumpManager.GoJump(40068)
|
||
end)
|
||
Util.AddOnceClick(self.lsth, function()
|
||
local isOpen = CheckFunctionOpenClient(FUNCTION_OPEN_TYPE.ChouJiangRukou)
|
||
local tip = GetFunctionOpenTipClient(FUNCTION_OPEN_TYPE.ChouJiangRukou)
|
||
if isOpen == false then
|
||
PopupTipPanel.ShowTip(tip)
|
||
return
|
||
end
|
||
JumpManager.GoJump(40071)
|
||
end)
|
||
end
|
||
|
||
--添加事件监听(用于子类重写)
|
||
function TimeLimitUpHero:AddListener()
|
||
Game.GlobalEvent:AddEvent(GameEvent.Activity.TimeLimitUpHeroChange, self.OnUPHeroChange, self)
|
||
end
|
||
|
||
--移除事件监听(用于子类重写)
|
||
function TimeLimitUpHero:RemoveListener()
|
||
Game.GlobalEvent:RemoveEvent(GameEvent.Activity.TimeLimitUpHeroChange, self.OnUPHeroChange, self)
|
||
end
|
||
|
||
--up的英雄改变
|
||
function TimeLimitUpHero:OnUPHeroChange(id)
|
||
curHeroId = id
|
||
self:RefreshHeroData()
|
||
self:RefreshNextLevelReward()
|
||
end
|
||
|
||
--界面打开时调用(用于子类重写)
|
||
function TimeLimitUpHero:OnOpen(_activityConfig, _index, parent)
|
||
self.actConfig = _activityConfig
|
||
self.pageIndex = _index
|
||
self.parent = parent
|
||
end
|
||
|
||
function TimeLimitUpHero:OnSortingOrderChange(layer)
|
||
sortingOrder = layer
|
||
SetParticleSortLayer(self.effect, layer)
|
||
SetParticleSortLayer(self.zqbgEffect, layer)
|
||
end
|
||
|
||
-- 打开,重新打开时回调
|
||
function TimeLimitUpHero:OnShow(_sortingOrder)
|
||
self.gameObject:SetActive(true)
|
||
sortingOrder = _sortingOrder
|
||
self.titleImg.sprite = self.spLoader:LoadSprite("gm_chouka_xxzm_title_zh")
|
||
Util.SetParticleSortLayer(self.effect, sortingOrder + 1)
|
||
Util.SetParticleSortLayer(self.zqbgEffect, sortingOrder + 1)
|
||
self.actId = self.actConfig.ActId
|
||
LogError("self.actId====" ..
|
||
self.actId ..
|
||
" self.actConfig.ActiveType==" ..
|
||
self.actConfig.ActiveType .. " self.actConfig.FunType== " .. self.actConfig.FunType)
|
||
self.actType = self.actConfig.ActiveType > 0 and self.actConfig.ActiveType or self.actConfig.FunType
|
||
if self.actConfig.IfBack == 1 then
|
||
if self.actConfig.ActiveType > 0 then
|
||
local id = ActivityGiftManager.IsActivityTypeOpen(self.actConfig.ActiveType)
|
||
if id and id > 0 then
|
||
self.actId = id
|
||
local actConfig = ConfigManager.TryGetConfigDataByThreeKey(ConfigName.ActivityGroups, "ActId",
|
||
globalActive[id].ShowArt, "PageType", self.actConfig.PageType, "ActiveType",
|
||
self.actConfig.ActiveType)
|
||
if not actConfig then
|
||
actConfig = ConfigManager.TryGetConfigDataByThreeKey(ConfigName.ActivityGroups, "ActId", id,
|
||
"PageType", self.actConfig.PageType, "ActiveType", self.actConfig.ActiveType)
|
||
end
|
||
if actConfig then
|
||
self.actConfig = actConfig
|
||
end
|
||
end
|
||
end
|
||
end
|
||
|
||
for k, v in ipairs(self.bgs) do
|
||
v.bg.gameObject:SetActive(false)
|
||
end
|
||
--
|
||
wishConfig = ConfigManager.TryGetConfigDataByKey(ConfigName.WishActivityUp, "ActivityId", self.actId)
|
||
Setting = ConfigManager.GetConfigData(ConfigName.WishActivitySetting, 1)
|
||
self.freeTimesId = Setting.FreeTimes
|
||
self.maxtimesId = Setting.MaxTimes
|
||
self.yaojingMaxTimeId = Setting.DiamondMaxTimes
|
||
activityData = ActivityGiftManager.GetActivityInfoByType(self.actId)
|
||
if activityData == nil then
|
||
LogError(" actid====" .. self.actId .. " 没有活动======")
|
||
return
|
||
end
|
||
curHeroId = activityData.choiceRewardId
|
||
local curTimes = PrivilegeManager.GetPrivilegeUsedTimes(self.maxtimesId)
|
||
self.upper.text = Language[10596] .. curTimes .. "/" .. privilegeConfig[self.maxtimesId].Condition[1][2] --特权上限
|
||
-- LogError("活动数据英雄id: "..activityData.choiceRewardId)
|
||
self:RefreshHeroData()
|
||
self:RefreshGetHeroTimes()
|
||
self:TimeCountDown()
|
||
self:RefreshNextLevelReward()
|
||
CheckRedPointStatus(RedPointType.TimeLimitWishStore)
|
||
end
|
||
|
||
local lastLiveName
|
||
function TimeLimitUpHero:RefreshHeroData()
|
||
Log("curHeroId:" .. tostring(curHeroId))
|
||
local id = curHeroId
|
||
if itemConfig[curHeroId] and itemConfig[curHeroId].RewardGroup then
|
||
local rewardConfig = ConfigManager.TryGetConfigData(ConfigName.RewardGroup, itemConfig[curHeroId].RewardGroup[1])
|
||
if rewardConfig and rewardConfig.ShowItem then
|
||
id = rewardConfig.ShowItem[1][1]
|
||
LogError("curHeroId==" .. id)
|
||
end
|
||
end
|
||
local bool = not not heroConfig[id] --判断是神将还是什么
|
||
curConfig = bool and heroConfig[id] or itemConfig[id]
|
||
self.mask1:SetActive(bool)
|
||
self.mask2:SetActive(not bool)
|
||
if bool then --是神将
|
||
self.heroIcon.sprite = self.spLoader:LoadSprite(artResourcesConfig[curConfig.Icon].Name)
|
||
self.heroNameTxt.text = GetLanguageStrById(curConfig.ReadingName)
|
||
self.heroProImg.sprite = self.spLoader:LoadSprite(GetProStrImageByProNum(curConfig.PropertyName))
|
||
if heroLiveObj then
|
||
poolManager:UnLoadLive(lastLiveName, heroLiveObj)
|
||
end
|
||
lastLiveName = GetResourcePath(curConfig.Live)
|
||
heroLiveObj = HeroManager.LoadHerolive1(curConfig, self.heroPar)
|
||
SetHEeroLiveToward(heroLiveObj, curConfig.Toward, curConfig.Position)
|
||
self.Bg.sprite = self.spLoader:LoadSprite("x_xinjiangzhaohuan_beijin")
|
||
self.callTimeImg.sprite = self.spLoader:LoadSprite("x_xinjiangzhaohuan_28zi_zh")
|
||
else --不是神将
|
||
self.heroIcon.sprite = self.spLoader:LoadSprite(artResourcesConfig[curConfig.ResourceID].Name)
|
||
self.Bg.sprite = self.spLoader:LoadSprite("f_feishengshi_beijing")
|
||
self.mask2Img.sprite = self.spLoader:LoadSprite("f_feishengshi_daicon")
|
||
self.callTimeImg.sprite = self.spLoader:LoadSprite("x_xinjiangzhaohuan_feishengshi")
|
||
end
|
||
|
||
|
||
local reMaintimes = ActivityGiftManager.GetActivityValueInfo(self.actId)
|
||
local totalTimes = 0
|
||
for i = 1, #wishConfig.UpList do
|
||
if wishConfig.UpList[i][1] == curHeroId then
|
||
totalTimes = wishConfig.UpList[i][4]
|
||
end
|
||
end
|
||
reMaintimes = totalTimes - reMaintimes
|
||
if reMaintimes <= 0 then
|
||
reMaintimes = 1
|
||
end
|
||
|
||
self.callTimeTxt.text = reMaintimes
|
||
end
|
||
|
||
local freeTime = 0
|
||
--刷新剩余次数
|
||
function TimeLimitUpHero:RefreshGetHeroTimes()
|
||
self.timeupdate.gameObject:SetActive(true)
|
||
if self.freeTimesId and self.freeTimesId > 0 then
|
||
freeTime = PrivilegeManager.GetPrivilegeRemainValue(self.freeTimesId)
|
||
RecruitManager.freeUseTimeList[self.freeTimesId] = freeTime
|
||
end
|
||
--按钮赋值
|
||
local num = PrivilegeManager.GetPrivilegeRemainValue(Setting.DiamondMaxTimes)
|
||
self.recruitTimesUpdate.text = string.format(Language[10614], num)
|
||
for n, m in ipairs(self.btns) do
|
||
--存在免费次数 并且 免费>=1 并且是1按钮
|
||
local isFree = freeTime >= 1 and n == 1
|
||
m.red.gameObject:SetActive(isFree)
|
||
m.icon.gameObject:SetActive(not isFree)
|
||
m.num.gameObject:SetActive(not isFree)
|
||
local itemId = 0
|
||
local itemNum = 0
|
||
local type = 0
|
||
if n == 1 then
|
||
type = Setting.CostItemSingle
|
||
m.info.text = Language[10577]
|
||
else
|
||
type = Setting.CostItemMul
|
||
m.info.text = Language[10578]
|
||
end
|
||
local d = {}
|
||
if isFree then
|
||
self.timeupdate.gameObject:SetActive(false)
|
||
m.info.text = Language[10583]
|
||
else
|
||
local d = RecruitManager.GetExpendDataByCostItem(type, n, num)
|
||
itemId = d[1]
|
||
if itemId == 16 then
|
||
isYaojing = true
|
||
end
|
||
itemNum = d[2]
|
||
m.icon.sprite = self.spLoader:LoadSprite(artResourcesConfig[itemConfig[itemId].ResourceID].Name)
|
||
m.num.text = PrintWanNum2(itemNum)
|
||
end
|
||
local sureFunc = function()
|
||
local isOpen = CheckFunctionOpenClient(FUNCTION_OPEN_TYPE.ChouJiangRukou)
|
||
local tip = GetFunctionOpenTipClient(FUNCTION_OPEN_TYPE.ChouJiangRukou)
|
||
if isOpen == false then
|
||
PopupTipPanel.ShowTip(tip)
|
||
return
|
||
end
|
||
local isFree = PrivilegeManager.GetPrivilegeRemainValue(self.freeTimesId) >= 1 and n == 1
|
||
if not isFree then
|
||
local count = PrivilegeManager.GetPrivilegeRemainValue(Setting.DiamondMaxTimes)
|
||
local d = RecruitManager.GetExpendDataByCostItem(type, n, count)
|
||
itemId = d[1]
|
||
if BagManager.GetItemCountById(itemId) < d[2] then
|
||
PopupTipPanel.ShowTip(GetLanguageStrById(itemConfig[itemId].Name) .. Language[10584])
|
||
--只在不足提示的时候返回,用以判断特效是否显示
|
||
return true
|
||
end
|
||
end
|
||
local state = PlayerPrefs.GetInt(PlayerManager.uid .. "GeneralPopup_RecruitConfirm" .. RecruitType.PrayerTen)
|
||
--local recrutId = n == 1 and self.singleRecruit.Id or self.tenRecruit.Id
|
||
local recrutNum = n == 1 and 1 or 10
|
||
if state == 0 and itemId == 16 and not isFree then
|
||
UIManager.OpenPanel(UIName.GeneralPopup, GENERAL_POPUP_TYPE.RecruitConfirm, "timeLimitHero", function()
|
||
self:Recruit(self.actId, n, itemId)
|
||
end, n)
|
||
else
|
||
self:Recruit(self.actId, n, itemId)
|
||
end
|
||
end
|
||
if n == 1 then
|
||
oneFunc = sureFunc
|
||
oneFunc2 = sureFunc
|
||
else
|
||
tenFunc = sureFunc
|
||
end
|
||
Util.AddOnceClick(m.btn, sureFunc)
|
||
end
|
||
end
|
||
|
||
function TimeLimitUpHero:OnFocus()
|
||
CheckRedPointStatus(RedPointType.TimeLimitWishStore)
|
||
end
|
||
|
||
function TimeLimitUpHero:Recruit(actId, type, itemId)
|
||
local recrutType = type == 1 and 1 or 10
|
||
if PrivilegeManager.GetPrivilegeUsedTimes(self.maxtimesId) + recrutType > privilegeConfig[self.maxtimesId].Condition[1][2] then
|
||
PopupTipPanel.ShowTip(Language[10587])
|
||
return
|
||
end
|
||
NetManager.ChoiceDrawCardRequest(actId, type, function(msg)
|
||
if freeTime >= 1 and type == 1 then
|
||
PrivilegeManager.RefreshPrivilegeUsedTimes(self.freeTimesId, recrutType) --记录抽卡次数
|
||
end
|
||
PrivilegeManager.RefreshPrivilegeUsedTimes(self.maxtimesId, recrutType) --记录抽卡次数
|
||
|
||
--记录妖晶抽卡
|
||
if itemId == 16 then
|
||
PrivilegeManager.RefreshPrivilegeUsedTimes(self.yaojingMaxTimeId, recrutType) --记录妖晶抽卡次数
|
||
end
|
||
if type == 1 then
|
||
UIManager.OpenPanel(UIName.QianKunBoxBuyOnePanel, msg.drop, RecruitType.PrayerSingle,
|
||
{ RecruitType.PrayerSingle, RecruitType.PrayerTen }, oneFunc)
|
||
else
|
||
--UIManager.OpenPanel(UIName.SingleRecruitPanel, msg.drop.Hero,actId,type,{RecruitType.TimeLimitSingle,RecruitType.TimeLimitTen})
|
||
UIManager.OpenPanel(UIName.QianKunBoxBuyTenPanel, msg.drop, RecruitType.PrayerTen,
|
||
{ RecruitType.PrayerSingle, RecruitType.PrayerTen }, tenFunc)
|
||
end
|
||
-- if msg.drop.Hero[1] then
|
||
-- UIManager.OpenPanel(UIName.SingleRecruitPanel, msg.drop.Hero[1],actId,1,{RecruitType.PrayerSingle,RecruitType.PrayerTen},oneFunc2)
|
||
-- end
|
||
CheckRedPointStatus(RedPointType.TimeLimitWish)
|
||
end, self.freeTimesId)
|
||
end
|
||
|
||
--刷新时间
|
||
function TimeLimitUpHero:TimeCountDown()
|
||
if self.timer then
|
||
self.timer:Stop()
|
||
self.timer = nil
|
||
end
|
||
local timeDown = CalculateSecondsNowTo_N_OClock(0)
|
||
self.timeupdate.text = TimeToHMS(timeDown) .. Language[10585]
|
||
self.timer = Timer.New(function()
|
||
self.timeupdate.text = TimeToHMS(timeDown) .. Language[10585]
|
||
timeDown = timeDown - 1
|
||
if timeDown <= 0 then
|
||
self:RefreshGetHeroTimes()
|
||
return
|
||
end
|
||
end, 1, -1, true)
|
||
self.timer:Start()
|
||
end
|
||
|
||
function TimeLimitUpHero:RefreshNextLevelReward()
|
||
-- 0 无法领取 1已领取 2可领取 -1 全部领取完
|
||
local curState = 0
|
||
local data1 = ConfigManager.GetAllConfigsDataByKey(ConfigName.ActivityRewardConfig, "ActivityId", self.actId) --通过活动id获取阶段任务
|
||
local rewardItem = nil
|
||
local mission = nil
|
||
|
||
local reward = nil
|
||
for i = 1, #wishConfig.UpList do
|
||
if wishConfig.UpList[i][1] == curHeroId then
|
||
reward = wishConfig.RewardList[i]
|
||
end
|
||
end
|
||
--替换奖励数据
|
||
for i = 1, #data1 do
|
||
data1[i].Reward[1][1] = reward[i]
|
||
end
|
||
for n, m in ipairs(data1) do
|
||
mission = ActivityGiftManager.GetActivityInfo(self.actId, m.Id)
|
||
if (mission.progress >= m.Values[1][1]) then
|
||
if mission.state == 0 then
|
||
rewardItem = m
|
||
curState = 2
|
||
break
|
||
end
|
||
else
|
||
curState = 0
|
||
rewardItem = m
|
||
break
|
||
end
|
||
end
|
||
|
||
--所有任务都已完成
|
||
if not rewardItem then
|
||
curState = -1
|
||
rewardItem = data1[#data1]
|
||
end
|
||
|
||
OperatingManager.TimeLimitedTimes = mission.progress
|
||
|
||
if not self.itemView then
|
||
self.itemView = SubUIManager.Open(SubUIConfig.ItemView, self.nextReward.transform)
|
||
end
|
||
self.itemView:OnOpen(false, { rewardItem.Reward[1][1], rewardItem.Reward[1][2] }, 0.73, false)
|
||
self.itemView.gameObject:SetActive(true)
|
||
Util.GetGameObject(self.itemView.gameObject, "item/frame"):GetComponent("Button").enabled = false
|
||
|
||
if (curState == 2) then
|
||
local temp = mission.progress <= rewardItem.Values[1][1] and mission.progress or rewardItem.Values[1][1]
|
||
self.sliderText2.text = temp .. "/" .. rewardItem.Values[1][1]
|
||
self.slider.value = temp / rewardItem.Values[1][1]
|
||
local vec = self.sliderText.transform:GetComponent("RectTransform").anchoredPosition3D
|
||
vec.y = 22.4
|
||
self.sliderText.transform:GetComponent("RectTransform").anchoredPosition3D = vec
|
||
self.sliderText.text = Language[10609]
|
||
self.sliderText.fontSize = 26
|
||
Util.AddOnceClick(self.getBtn, function()
|
||
NetManager.GetActivityRewardRequest(mission.missionId, self.actId,
|
||
function(respond)
|
||
UIManager.OpenPanel(UIName.RewardItemPopup, respond, 1)
|
||
ActivityGiftManager.SetActivityInfo(self.actId, mission.missionId, 1)
|
||
self:RefreshGetHeroTimes()
|
||
self:RefreshNextLevelReward()
|
||
end)
|
||
end)
|
||
self.effect.gameObject:SetActive(true)
|
||
elseif (curState == -1) then
|
||
self.slider.value = 1
|
||
self.sliderText2.text = rewardItem.Values[1][1] .. "/" .. rewardItem.Values[1][1]
|
||
self.sliderText.text = Language[10612]
|
||
Util.AddOnceClick(self.getBtn, function()
|
||
UIManager.OpenPanel(UIName.GeneralPopup, GENERAL_POPUP_TYPE.RecrutReward, self.actType, self.actId, curHeroId)
|
||
end)
|
||
else
|
||
self.slider.gameObject:SetActive(true)
|
||
Util.GetGameObject(self.slider.gameObject, "Text"):GetComponent("Text").text = mission.progress ..
|
||
"/" .. rewardItem.Values[1][1]
|
||
local vec = self.sliderText.transform:GetComponent("RectTransform").anchoredPosition3D
|
||
vec.y = 22.4
|
||
self.sliderText.transform:GetComponent("RectTransform").anchoredPosition3D = vec
|
||
self.sliderText.text = Language[10613] .. mission.progress .. "/" .. rewardItem.Values[1][1]
|
||
self.sliderText.fontSize = 26
|
||
self.slider.value = mission.progress / rewardItem.Values[1][1]
|
||
self.effect.gameObject:SetActive(false)
|
||
Util.AddOnceClick(self.getBtn, function()
|
||
UIManager.OpenPanel(UIName.GeneralPopup, GENERAL_POPUP_TYPE.RecrutReward, self.actType, self.actId, curHeroId)
|
||
end)
|
||
end
|
||
end
|
||
|
||
--- 将一段时间转换为天时分秒
|
||
function TimeLimitUpHero:TimeToDHMS(second)
|
||
local day = math.floor(second / (24 * 3600))
|
||
local minute = math.floor(second / 60) % 60
|
||
local sec = math.floor(second % 60)
|
||
local hour = math.floor(math.floor(second - day * 24 * 3600 - sec - minute * 60) / 3600)
|
||
if day <= 0 and hour <= 0 then
|
||
return string.format(Language[10571], minute, sec)
|
||
else
|
||
return string.format(Language[10572], day, hour)
|
||
end
|
||
end
|
||
|
||
--
|
||
function TimeLimitUpHero:ShowGuideGo()
|
||
JumpManager.ShowGuide(UIName.ActivityMainPanel, self.btn_hero)
|
||
end
|
||
|
||
--界面关闭时调用(用于子类重写)
|
||
function TimeLimitUpHero:OnClose()
|
||
self.gameObject:SetActive(false)
|
||
if self.timer then
|
||
self.timer:Stop()
|
||
self.timer = nil
|
||
end
|
||
|
||
if UIManager.IsOpen(UIName.GeneralPopup) then
|
||
UIManager.ClosePanel(UIName.GeneralPopup)
|
||
end
|
||
end
|
||
|
||
--界面销毁时调用(用于子类重写)
|
||
function TimeLimitUpHero:OnDestroy()
|
||
self.spLoader:Destroy()
|
||
self.btns = {}
|
||
ClearRedPointObject(RedPointType.TimeLimitWishStore, self.zqbgRed)
|
||
--SubUIManager.Close(self.itemView)
|
||
self.itemView = nil
|
||
heroLiveObj = nil
|
||
lastLiveName = nil
|
||
curHeroId = 0
|
||
if oneFunc then
|
||
oneFunc = nil
|
||
end
|
||
if tenFunc then
|
||
tenFunc = nil
|
||
end
|
||
end
|
||
|
||
return TimeLimitUpHero
|