2021-05-28 10:36:55 +08:00
|
|
|
|
|
|
|
|
|
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
|
2021-05-29 15:35:52 +08:00
|
|
|
|
local isYaojing=false
|
2021-05-28 10:36:55 +08:00
|
|
|
|
--初始化组件(用于子类重写)
|
|
|
|
|
function TimeLimitUpHero:InitComponent()
|
|
|
|
|
self.spLoader = SpriteLoader.New()
|
|
|
|
|
self.helpBtn = Util.GetGameObject(self.gameObject,"help")
|
|
|
|
|
self.helpPosition=self.helpBtn:GetComponent("RectTransform").localPosition
|
|
|
|
|
|
|
|
|
|
self.btnActivity = Util.GetGameObject(self.gameObject,"btngroup/btnActivity")
|
2021-05-28 16:54:40 +08:00
|
|
|
|
self.btnActivity:GetComponent("Image").sprite=self.spLoader:LoadSprite("r_shilian-jiangli_zh")
|
2021-05-28 10:36:55 +08:00
|
|
|
|
self.btnRewardBtn = Util.GetGameObject(self.gameObject,"btngroup/btnRewardBtn")
|
|
|
|
|
self.btnRewardBtn:SetActive(false)
|
2021-05-29 15:35:52 +08:00
|
|
|
|
|
2021-05-28 10:36:55 +08:00
|
|
|
|
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.recruitTimeUpdate = Util.GetGameObject(self.gameObject,"recruitTimesUpdate/Text1") :GetComponent("Text") --活动剩余时间
|
|
|
|
|
self.recruitTimesUpdate = Util.GetGameObject(self.gameObject,"recruitTimesUpdate/Text") :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.heroPar=Util.GetGameObject(self.gameObject,"Bg2/curObj")
|
|
|
|
|
self.dragView=Util.GetGameObject(self.gameObject,"Bg2/dragView")
|
|
|
|
|
self.btn_hero=Util.GetGameObject(self.gameObject,"btn_hero")
|
|
|
|
|
self.heroIcon=Util.GetGameObject(self.gameObject,"btn_hero/Icon"):GetComponent("Image")
|
|
|
|
|
self.textInfo1=Util.GetGameObject(self.gameObject,"btn_hero/Text"):GetComponent("Text")
|
|
|
|
|
self.textInfo1.text="选择神将"
|
|
|
|
|
self.titleImg=Util.GetGameObject(self.gameObject,"Bg2/Image (3)"):GetComponent("Image")
|
|
|
|
|
self.callTimeImg=Util.GetGameObject(self.gameObject,"callTimeImg"):GetComponent("Image")
|
|
|
|
|
self.callTimeImg.sprite=self.spLoader:LoadSprite("x_xinjiangzhaohuan_28zi")
|
|
|
|
|
self.callTimeTxt=Util.GetGameObject(self.gameObject,"callTimeImg/Text"):GetComponent("Text")
|
|
|
|
|
self.heroNameTxt=Util.GetGameObject(self.gameObject,"Bg2/PreviewBtn/di/Name/Text"):GetComponent("Text")
|
|
|
|
|
self.heroProImg=Util.GetGameObject(self.gameObject,"Bg2/PreviewBtn/di/Image"):GetComponent("Image")
|
|
|
|
|
self.starPar=Util.GetGameObject(self.gameObject,"Bg2/PreviewBtn/di/Image"):GetComponent("Image")
|
2021-05-28 16:54:40 +08:00
|
|
|
|
self.gailvImg=Util.GetGameObject(self.gameObject,"btn_hero/InfoImg2"):GetComponent("Image")
|
|
|
|
|
self.changeImg=Util.GetGameObject(self.gameObject,"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")
|
2021-05-28 10:36:55 +08:00
|
|
|
|
Util.AddClick(self.btn_hero.gameObject, function()
|
|
|
|
|
UIManager.OpenPanel(UIName.GeneralPopup,GENERAL_POPUP_TYPE.ChooseUpHero,self.actId,curHeroId)
|
|
|
|
|
end)
|
|
|
|
|
Util.AddClick(self.dragView.gameObject, function()
|
|
|
|
|
local SkeletonGraphic = heroLiveObj:GetComponent("SkeletonGraphic")
|
|
|
|
|
SkeletonGraphic.AnimationState:SetAnimation(0, "touch", false)
|
|
|
|
|
end)
|
2021-05-29 15:35:52 +08:00
|
|
|
|
|
2021-05-28 10:36:55 +08:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--绑定事件(用于子类重写)
|
|
|
|
|
function TimeLimitUpHero:BindEvent()
|
|
|
|
|
Util.AddOnceClick(self.helpBtn, function()
|
2021-05-28 15:09:18 +08:00
|
|
|
|
UIManager.OpenPanel(UIName.HelpPopup,Setting.QAId,self.helpPosition.x,self.helpPosition.y)
|
2021-05-28 10:36:55 +08:00
|
|
|
|
end)
|
|
|
|
|
|
|
|
|
|
Util.AddOnceClick(self.btnActivity, function()
|
2021-05-28 15:09:18 +08:00
|
|
|
|
UIManager.OpenPanel(UIName.GeneralBigPopup,GENERAL_POPUP_TYPE.RecrutDetail,Setting.QAId,20003,PRE_REWARD_POOL_TYPE.TIME_LIMITED_UP,PRE_REWARD_POOL_TYPE.TIME_LIMITED,curHeroId,self.actId)
|
2021-05-28 10:36:55 +08:00
|
|
|
|
end)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--添加事件监听(用于子类重写)
|
|
|
|
|
function TimeLimitUpHero:AddListener()
|
2021-05-28 15:09:18 +08:00
|
|
|
|
Game.GlobalEvent:AddEvent(GameEvent.Activity.TimeLimitUpHeroChange,self.OnUPHeroChange,self)
|
2021-05-28 10:36:55 +08:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--移除事件监听(用于子类重写)
|
|
|
|
|
function TimeLimitUpHero:RemoveListener()
|
2021-05-28 15:09:18 +08:00
|
|
|
|
Game.GlobalEvent:RemoveEvent(GameEvent.Activity.TimeLimitUpHeroChange,self.OnUPHeroChange,self)
|
2021-05-28 10:36:55 +08:00
|
|
|
|
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:OnShow(_sortingOrder)
|
|
|
|
|
self.gameObject:SetActive(true)
|
|
|
|
|
sortingOrder = _sortingOrder
|
|
|
|
|
|
|
|
|
|
self.actId = self.actConfig.ActId
|
|
|
|
|
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
|
2021-06-01 11:46:00 +08:00
|
|
|
|
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
|
2021-05-28 10:36:55 +08:00
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
for k,v in ipairs(self.bgs) do
|
|
|
|
|
v.bg.gameObject:SetActive(false)
|
|
|
|
|
end
|
2021-06-01 14:41:28 +08:00
|
|
|
|
LogError(" actid===="..self.actId)
|
2021-05-28 10:36:55 +08:00
|
|
|
|
wishConfig=ConfigManager.GetConfigDataByKey(ConfigName.WishActivityUp,"ActivityId",self.actId)
|
|
|
|
|
self.titleImg.sprite=self.spLoader:LoadSprite(self.actConfig.Icon[3])
|
|
|
|
|
Setting= ConfigManager.GetConfigData(ConfigName.WishActivitySetting,1)
|
|
|
|
|
self.freeTimesId=Setting.FreeTimes
|
|
|
|
|
self.maxtimesId=Setting.MaxTimes
|
|
|
|
|
self.yaojingMaxTimeId =Setting.DiamondMaxTimes
|
|
|
|
|
activityData=ActivityGiftManager.GetActivityInfoByType(self.actId)
|
|
|
|
|
curHeroId=activityData.choiceRewardId
|
2021-05-29 15:35:52 +08:00
|
|
|
|
local curTimes = PrivilegeManager.GetPrivilegeUsedTimes(self.maxtimesId)
|
|
|
|
|
self.upper.text= "今日召唤上限:"..curTimes.."/"..privilegeConfig[self.maxtimesId].Condition[1][2]--特权上限
|
2021-05-28 10:36:55 +08:00
|
|
|
|
LogError("活动数据英雄id: "..activityData.choiceRewardId)
|
|
|
|
|
self:RefreshHeroData()
|
|
|
|
|
self:RefreshGetHeroTimes()
|
|
|
|
|
self:TimeCountDown()
|
|
|
|
|
self:RefreshNextLevelReward()
|
|
|
|
|
end
|
|
|
|
|
local lastLiveName
|
|
|
|
|
function TimeLimitUpHero:RefreshHeroData()
|
|
|
|
|
curConfig=ConfigManager.GetConfigData(ConfigName.HeroConfig,curHeroId)
|
|
|
|
|
self.heroIcon.sprite=self.spLoader:LoadSprite(artResourcesConfig[curConfig.Icon].Name)
|
|
|
|
|
self.heroNameTxt.text=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)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
end
|
|
|
|
|
local freeTime = 0
|
|
|
|
|
--刷新剩余次数
|
|
|
|
|
function TimeLimitUpHero:RefreshGetHeroTimes()
|
2021-05-29 15:35:52 +08:00
|
|
|
|
|
2021-05-28 10:36:55 +08:00
|
|
|
|
self.timeupdate.gameObject:SetActive(true)
|
|
|
|
|
if self.freeTimesId and self.freeTimesId > 0 then
|
|
|
|
|
freeTime = PrivilegeManager.GetPrivilegeRemainValue(self.freeTimesId)
|
|
|
|
|
RecruitManager.freeUseTimeList[self.freeTimesId]=freeTime
|
|
|
|
|
end
|
|
|
|
|
--按钮赋值
|
2021-05-29 15:35:52 +08:00
|
|
|
|
local num=PrivilegeManager.GetPrivilegeRemainValue(Setting.DiamondMaxTimes)
|
|
|
|
|
self.recruitTimesUpdate.text = string.format("今日剩余妖晶召唤次数:<color=#F27D0F>%s</color>",num)
|
2021-05-28 10:36:55 +08:00
|
|
|
|
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 = "1次"
|
|
|
|
|
else
|
|
|
|
|
type = Setting.CostItemMul
|
|
|
|
|
m.info.text = "10次"
|
|
|
|
|
end
|
|
|
|
|
local d = {}
|
|
|
|
|
if isFree then
|
|
|
|
|
self.timeupdate.gameObject:SetActive(false)
|
|
|
|
|
m.info.text="免费抽取"
|
|
|
|
|
else
|
2021-05-29 15:35:52 +08:00
|
|
|
|
local d = RecruitManager.GetExpendDataByCostItem(type,n,num)
|
2021-05-28 10:36:55 +08:00
|
|
|
|
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= tostring(itemNum)
|
|
|
|
|
end
|
|
|
|
|
local sureFunc=function()
|
2021-05-29 15:35:52 +08:00
|
|
|
|
local isFree = PrivilegeManager.GetPrivilegeRemainValue(self.freeTimesId)>= 1 and n == 1
|
2021-05-28 10:36:55 +08:00
|
|
|
|
if not isFree then
|
2021-05-29 15:35:52 +08:00
|
|
|
|
local count=PrivilegeManager.GetPrivilegeRemainValue(Setting.DiamondMaxTimes)
|
|
|
|
|
local d = RecruitManager.GetExpendDataByCostItem(type,n,count)
|
|
|
|
|
itemId=d[1]
|
|
|
|
|
if BagManager.GetItemCountById(itemId)<d[2] then
|
2021-05-28 10:36:55 +08:00
|
|
|
|
PopupTipPanel.ShowTip(itemConfig[itemId].Name.."数量不足!")
|
|
|
|
|
return
|
|
|
|
|
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()
|
2021-05-29 15:35:52 +08:00
|
|
|
|
self:Recruit(self.actId,n,itemId)
|
2021-05-28 10:36:55 +08:00
|
|
|
|
end,n)
|
|
|
|
|
else
|
2021-05-29 15:35:52 +08:00
|
|
|
|
self:Recruit(self.actId,n,itemId)
|
2021-05-28 10:36:55 +08:00
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
if n==1 then
|
|
|
|
|
oneFunc=sureFunc
|
|
|
|
|
oneFunc2=sureFunc
|
|
|
|
|
else
|
|
|
|
|
tenFunc=sureFunc
|
|
|
|
|
end
|
|
|
|
|
Util.AddOnceClick(m.btn,sureFunc)
|
|
|
|
|
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 = totalTimes
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
self.callTimeTxt.text=reMaintimes
|
|
|
|
|
end
|
|
|
|
|
|
2021-05-29 15:35:52 +08:00
|
|
|
|
function TimeLimitUpHero:Recruit(actId,type,itemId)
|
2021-05-28 10:36:55 +08:00
|
|
|
|
local recrutType =type==1 and 1 or 10
|
|
|
|
|
if PrivilegeManager.GetPrivilegeUsedTimes(self.maxtimesId)+recrutType>privilegeConfig[self.maxtimesId].Condition[1][2] then
|
|
|
|
|
PopupTipPanel.ShowTip("无法超出每日召唤次数上限!")
|
|
|
|
|
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)--记录抽卡次数
|
|
|
|
|
|
|
|
|
|
--记录妖晶抽卡
|
2021-05-29 15:35:52 +08:00
|
|
|
|
if itemId==16 then
|
2021-05-28 10:36:55 +08:00
|
|
|
|
PrivilegeManager.RefreshPrivilegeUsedTimes(self.yaojingMaxTimeId,recrutType)--记录妖晶抽卡次数
|
|
|
|
|
end
|
|
|
|
|
if type == 1 then
|
|
|
|
|
UIManager.OpenPanel(UIName.QianKunBoxBuyOnePanel, msg.drop,actId,{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,actId,{RecruitType.PrayerSingle,RecruitType.PrayerTen},tenFunc)
|
|
|
|
|
end
|
|
|
|
|
if msg.drop.Hero[1] then
|
2021-06-01 14:41:28 +08:00
|
|
|
|
UIManager.OpenPanel(UIName.SingleRecruitPanel, msg.drop.Hero[1],actId,1,{RecruitType.PrayerSingle,RecruitType.PrayerTen},oneFunc2)
|
2021-05-28 10:36:55 +08:00
|
|
|
|
end
|
|
|
|
|
CheckRedPointStatus(RedPointType.TimeLimited)
|
|
|
|
|
end,self.freeTimesId)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--刷新时间
|
|
|
|
|
function TimeLimitUpHero:TimeCountDown()
|
|
|
|
|
if self.timer then
|
|
|
|
|
self.timer:Stop()
|
|
|
|
|
self.timer = nil
|
|
|
|
|
end
|
|
|
|
|
local timeDown=CalculateSecondsNowTo_N_OClock(0)--ActivityGiftManager.GetTaskRemainTime(ActivityTypeDef.FindFairy)
|
|
|
|
|
local endTime = ActivityGiftManager.GetTaskEndTime(self.actType) - PlayerManager.serverTime
|
|
|
|
|
self.recruitTimeUpdate.text = string.format("活动剩余时间:"..self:TimeToDHMS(endTime))
|
|
|
|
|
self.timeupdate.text = TimeToHMS(timeDown).."后刷新"
|
|
|
|
|
self.timer = Timer.New(function()
|
|
|
|
|
if timeDown < 1 then
|
|
|
|
|
self:RefreshGetHeroTimes()
|
|
|
|
|
return
|
|
|
|
|
else
|
|
|
|
|
self.timeupdate.text = TimeToHMS(timeDown).."后刷新"
|
|
|
|
|
end
|
|
|
|
|
if endTime < 1 then
|
|
|
|
|
self.timer:Stop()
|
|
|
|
|
self.timer = nil
|
|
|
|
|
self:OnShow(sortingOrder)
|
|
|
|
|
return
|
|
|
|
|
else
|
|
|
|
|
self.recruitTimeUpdate.text = string.format("活动剩余时间:"..self:TimeToDHMS(endTime))
|
|
|
|
|
end
|
|
|
|
|
endTime = endTime - 1
|
|
|
|
|
timeDown = timeDown - 1
|
|
|
|
|
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="奖励可领取"
|
|
|
|
|
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
|
|
|
|
|
Util.GetGameObject(self.slider.gameObject,"Text"):GetComponent("Text").text="300/300"
|
|
|
|
|
self.sliderText.text="奖励已全部领取"
|
|
|
|
|
Util.AddOnceClick(self.getBtn,function()
|
2021-05-29 18:27:03 +08:00
|
|
|
|
UIManager.OpenPanel(UIName.GeneralPopup,GENERAL_POPUP_TYPE.RecrutReward,self.actType,self.actId,curHeroId)
|
2021-05-28 10:36:55 +08:00
|
|
|
|
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="下一阶段:"..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("%s分%s秒",minute, sec)
|
|
|
|
|
else
|
|
|
|
|
return string.format("%s天%s小时",day, hour)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--界面关闭时调用(用于子类重写)
|
|
|
|
|
function TimeLimitUpHero:OnClose()
|
|
|
|
|
self.gameObject:SetActive(false)
|
|
|
|
|
if self.timer then
|
|
|
|
|
self.timer:Stop()
|
|
|
|
|
self.timer = nil
|
|
|
|
|
end
|
2021-05-31 11:31:15 +08:00
|
|
|
|
|
|
|
|
|
if UIManager.IsOpen(UIName.GeneralPopup) then
|
|
|
|
|
UIManager.ClosePanel(UIName.GeneralPopup)
|
|
|
|
|
end
|
2021-05-28 10:36:55 +08:00
|
|
|
|
end
|
|
|
|
|
--界面销毁时调用(用于子类重写)
|
|
|
|
|
function TimeLimitUpHero:OnDestroy()
|
|
|
|
|
self.spLoader:Destroy()
|
|
|
|
|
self.btns = {}
|
|
|
|
|
--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
|