| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558 |
- local UIGuildHuntView = require("UIGuild/UIGuildHuntView_Generate")
- local PreviewSystem = require("PreviewSystem")
- function UIGuildHuntView:OnAwake(data)
- self.controller = require("UIGuild/UIGuildHuntCtr"):new()
- self.controller:Init(self)
- self.controller:SetData(data)
- end
- function UIGuildHuntView:AddEventListener()
- ManagerContainer.LuaEventMgr:RegisterUIEvent(self.uiData.name, UIEventNames.GUILD_DISBAND_SUCCESS, self, self.OnGuildDisBandSuccess)
- ManagerContainer.LuaEventMgr:RegisterUIEvent(self.uiData.name, UIEventNames.GUILD_QUIT_SUCCESS, self, self.OnGuildQuitSuccess)
- ManagerContainer.LuaEventMgr:RegisterUIEvent(self.uiData.name, UIEventNames.GUILD_KICKOUT_SUCCESS, self, self.OnGuildKickoutSuccess)
- ManagerContainer.LuaEventMgr:RegisterUIEvent(self.uiData.name, UIEventNames.GUILD_HUNT_BOSS_LIST_CHANGED, self, self.OnGuildHuntBossListChanged)
- ManagerContainer.LuaEventMgr:RegisterUIEvent(self.uiData.name, UIEventNames.GUILD_HUNT_BOSS_SUMMON_CHANGED, self, self.OnGuildHuntBossSummonChanged)
- ManagerContainer.LuaEventMgr:RegisterUIEvent(self.uiData.name, UIEventNames.VIP_LV_CHANGED, self, self.OnVipLvChanged)
- end
- function UIGuildHuntView:FillContent(data, uiBase)
- self.uiBase = uiBase
- local gameObject = self.uiBase:GetRoot()
- if gameObject ~= nil then
- self.gameObject = gameObject
- self.transform = gameObject.transform
- end
- self:InitGenerate(self.transform, data)
- self:Init()
- end
- function UIGuildHuntView:Init()
- ManagerContainer.LuaEventMgr:Dispatch(UIEventNames.RED_POINT_MGR_NOTICE, Enum.RPNotifyType.GuildHuntBoss, false)
- if not self.previewSystem then
- self.previewSystem = PreviewSystem:new('GuildHuntPreview')
- self.previewSystem:SetView(Vector3(0, 1.93, 4.75), Quaternion.Euler(0, 180, 0))
- else
- self.previewSystem:RemoveAllGo()
- end
- self.bossImg.rawImage.texture = self.previewSystem:GetRenderTexture()
- self:RefreshModel()
- self:RefreshView()
- self.controller:SendGuildHuntBossListInfoReq()
- end
- function UIGuildHuntView:RemoveEventListener()
- ManagerContainer.LuaEventMgr:Unregister(self.uiData.name)
- end
- function UIGuildHuntView:AddUIEventListener()
- self.uiBase:AddButtonUniqueEventListener(self.btnPlayRule.button, self, self.OnClickPlayRuleBtn)
- self.uiBase:AddButtonUniqueEventListener(self.btnAward.button, self, self.OnClickAwardBtn)
- self.uiBase:AddButtonUniqueEventListener(self.btnLeft.button, self, self.OnClickLeftBtn)
- self.uiBase:AddButtonUniqueEventListener(self.btnRight.button, self, self.OnClickRightBtn)
- self.uiBase:AddButtonUniqueEventListener(self.btnBack.button, self, self.OnClickBackBtn)
- self.uiBase:AddButtonUniqueEventListener(self.btnLog.button, self, self.OnClickLogBtn)
- self.uiBase:AddButtonUniqueEventListener(self.btnChallenge.button, self, self.OnClickChallengeBtn)
- self.uiBase:AddButtonUniqueEventListener(self.btnSummon.button, self, self.OnClickSummonBtn)
- end
- function UIGuildHuntView:OnHide()
- end
- function UIGuildHuntView:OnShow(data)
- self.controller:SetData(data)
- end
- function UIGuildHuntView:OnClose()
- end
- function UIGuildHuntView:OnDispose()
- self:DisposeModel()
- if self.previewSystem then
- self.previewSystem:Dispose()
- self.previewSystem = nil
- end
- self:DisposeRefreshTimer()
- self:DisposeRefreshInfoTimer()
- self.controller:OnDispose()
- end
- function UIGuildHuntView:OnGuildDisBandSuccess()
- self.uiBase.MSourceUIID = 0
- ManagerContainer.LuaUIMgr:OpenSourceUI(self)
- end
- function UIGuildHuntView:OnGuildQuitSuccess()
- self.uiBase.MSourceUIID = 0
- ManagerContainer.LuaUIMgr:OpenSourceUI(self)
- end
- function UIGuildHuntView:OnGuildKickoutSuccess()
- self.uiBase.MSourceUIID = 0
- ManagerContainer.LuaUIMgr:OpenSourceUI(self)
- end
- function UIGuildHuntView:OnGuildHuntBossListChanged()
- self.controller:RefreshBossList()
- self:RefreshModel()
- self:RefreshView()
- self:StartRefreshInfoTimer()
- end
- function UIGuildHuntView:OnGuildHuntBossSummonChanged(bossId)
- if not self.controller:ContainBoss(bossId) then
- self.controller:RefreshBossList()
- self:RefreshModel()
- end
- self:RefreshView()
- end
- function UIGuildHuntView:OnVipLvChanged()
- self:RefreshView()
- end
- function UIGuildHuntView:OnClickPlayRuleBtn()
- ManagerContainer.LuaUIMgr:Open(Enum.UIPageName.UIPlayRule, {'PlayExplainTitle', 'GuildBossPlayExplain'})
- end
- function UIGuildHuntView:OnClickAwardBtn()
- local bossId = self.controller:GetCurBossId()
- if not bossId then
- return
- end
- ManagerContainer.LuaUIMgr:Open(Enum.UIPageName.UIGuildHuntMasterReward, bossId)
- end
- function UIGuildHuntView:OnClickLeftBtn()
- if not self.controller:ChangeBoss(false) then
- return
- end
- self:RefreshModel()
- self:RefreshView()
- end
- function UIGuildHuntView:OnClickRightBtn()
- if not self.controller:ChangeBoss(true) then
- return
- end
- self:RefreshModel()
- self:RefreshView()
- end
- function UIGuildHuntView:OnClickBackBtn()
- ManagerContainer.LuaUIMgr:OpenSourceUI(self)
- end
- function UIGuildHuntView:OnClickChallengeBtn()
- local data = self.controller:GetBossInfoList()
- if not data then
- ManagerContainer.LuaUIMgr:ErrorNoticeDisplay(587)
- return
- end
- local bossCfgData, bossData = self.controller:GetCurBossInfo()
- if not bossCfgData or not bossData then
- ManagerContainer.LuaUIMgr:ErrorNoticeDisplay(587)
- return
- end
- local maxNum = bossCfgData.Challenge or 0
- if bossCfgData.BossType == Enum.GuildHuntBossType.Normal then
- maxNum = maxNum + self.controller:ExtraChallengeNum() + self.controller:ExtraBoliVipChallengeNum()
- end
- local remainNum = bossData.remainNum or 0
- if remainNum >= maxNum then
- ManagerContainer.LuaUIMgr:ErrorNoticeDisplay(587)
- return
- end
- if bossCfgData.BossType ~= Enum.GuildHuntBossType.Normal then
- local cd = self.controller:GetHuntBossCd()
- if cd then
- local remainTime = ManagerContainer.LuaTimerMgr:GetRemainSecondsWithUInt64(cd)
- if remainTime > 0 then
- ManagerContainer.LuaUIMgr:ErrorNoticeDisplayWithParam('GuildTips_045', DateTimeUtil.convertSeconds2TimeStr1(remainTime, true, true, true))
- return
- end
- end
- end
- self.controller:ChallengeBoss()
- end
- function UIGuildHuntView:OnClickSummonBtn()
- local errorCode = self.controller:SendGuildHuntBossSummonReq()
- if errorCode ~= 0 then
- ManagerContainer.LuaUIMgr:ErrorNoticeDisplay(errorCode)
- end
- end
- function UIGuildHuntView:OnClickLogBtn()
- local bossId = self.controller:GetCurBossId()
- if not bossId then
- return
- end
- ManagerContainer.LuaUIMgr:Open(Enum.UIPageName.UIGuildHuntLog, bossId)
- end
- function UIGuildHuntView:OnClickSkillItem(_, params)
- local skillId = params[0]
- local skillLv = params[1]
- ManagerContainer.LuaUIMgr:OpenTips({tipsType = Enum.UITipsType.Skill, cfgId = skillId, num = skillLv})
- end
- function UIGuildHuntView:OnClickIconItem(_, params)
- local data = params[0]
- ManagerContainer.LuaUIMgr:OpenTips(data)
- end
- function UIGuildHuntView:RefreshView()
- local data = self.controller:GetBossInfoList()
- if not data then
- self.bossName:SetActive(false)
- self.timer:SetActive(false)
- self.btnAward:SetActive(false)
- self.btnLeft:SetActive(false)
- self.btnRight:SetActive(false)
- self.skillList:SetActive(false)
- self.awardScrollView:SetActive(false)
- self.btnChallenge:SetActive(false)
- self.btnSummon:SetActive(false)
- self.costBox:SetActive(false)
- self.condBox:SetActive(false)
- self.btnLog:SetActive(false)
- return
- end
- local canLeft, canRight = self.controller:CanMove()
- self.btnLeft:SetActive(canLeft)
- self.btnRight:SetActive(canRight)
- local bossCfgData, bossData = self.controller:GetCurBossInfo()
- if not bossCfgData or not bossData then
- self.bossName:SetActive(false)
- self.timer:SetActive(false)
- self.btnAward:SetActive(false)
- self.skillList:SetActive(false)
- self.awardScrollView:SetActive(false)
- self.btnChallenge:SetActive(false)
- self.btnSummon:SetActive(false)
- self.costBox:SetActive(false)
- self.condBox:SetActive(false)
- self.btnLog:SetActive(false)
- self:StopRefreshTimer()
- return
- end
- self.bossName:SetActive(true)
- self.btnAward:SetActive((bossCfgData.BossType == Enum.GuildHuntBossType.Normal and bossCfgData.MasterReward and #bossCfgData.MasterReward > 0))
- self.skillList:SetActive(true)
- self.btnLog:SetActive(true)
- local post = self.controller:GetGuildMinePost()
- local summonAuth = IsTableHasValue(bossCfgData.SummonLimit, post)
- if bossCfgData.UnlockCond > self.controller:GetGuildLv() then
- self.timer:SetActive(false)
- self:StopRefreshTimer()
- self.costBox:SetActive(false)
- self.condBox:SetActive(true)
- self.condBox.condTxt.text.text = string.formatbykey('GuildInfo_035', tostring(bossCfgData.UnlockCond))
- if summonAuth then
- self.btnChallenge:SetActive(false)
- self.btnSummon:SetActive(true)
- self.btnSummon.button.interactable = false
- else
- self.btnChallenge:SetActive(true)
- self.btnChallenge.button.interactable = false
- self.btnSummon:SetActive(false)
- end
- elseif bossData.fightTime and bossData.fightTime > 0 then
- self.timer:SetActive(true)
- local remainTime = ManagerContainer.LuaTimerMgr:GetRemainSecondsWithUInt64(bossData.fightTime)
- self.timeTxt.text.text = string.formatbykey('OutTime1', DateTimeUtil.convertSeconds2TimeStr1(remainTime, true, true, false))
- self:StartRefreshTimer()
- local maxNum = bossCfgData.Challenge or 0
- if bossCfgData.BossType == Enum.GuildHuntBossType.Normal then
- --LogError("=============BossType================="..self.controller:ExtraChallengeNum())
- maxNum = maxNum + self.controller:ExtraChallengeNum() + self.controller:ExtraBoliVipChallengeNum()
- end
- local remainNum = bossData.remainNum or 0
- self.costBox:SetActive(false)
- self.condBox:SetActive(true)
- self.condBox.condTxt.text.text = string.formatbykey('GuildInfo_034', tostring(maxNum - remainNum))
- self.btnChallenge:SetActive(true)
- self.btnChallenge.button.interactable = true
- self.btnSummon:SetActive(false)
- -- elseif bossData.fightCdTime and bossData.fightCdTime > 0 then
- -- local remainTime = ManagerContainer.LuaTimerMgr:GetRemainSecondsWithUInt64(bossData.fightCdTime)
- -- -- self.timeTxt.text.text = string.formatbykey('InTime1', DateTimeUtil.convertSeconds2TimeStr1(remainTime, true, true, false))
- -- -- self:StartRefreshTimer()
- -- -- self.btnChallenge:SetActive(false)
- -- -- self.btnSummon:SetActive(false)
- -- self.timer:SetActive(false)
- -- self:StopRefreshTimer()
- -- if bossCfgData.BossType == Enum.GuildHuntBossType.Normal or not summonAuth then
- -- self.btnChallenge:SetActive(true)
- -- self.btnChallenge.button.interactable = true
- -- self.btnSummon:SetActive(false)
- -- self.costBox:SetActive(true)
- -- local maxNum = bossCfgData.Challenge or 0
- -- local remainNum = bossData.remainNum or 0
- -- self.costBox.number.text.text = string.formatbykey('GuildInfo_034', tostring(maxNum - remainNum))
- -- self.condBox:SetActive(false)
- -- else
- -- self.btnChallenge:SetActive(false)
- -- self.btnSummon:SetActive(true)
- -- self.btnSummon.button.interactable = false
- -- end
- else
- if bossData.fightCdTime and bossData.fightCdTime > 0 then
- local remainTime = ManagerContainer.LuaTimerMgr:GetRemainSecondsWithUInt64(bossData.fightCdTime)
- self.timeTxt.text.text = string.formatbykey('GuildInfo_039', DateTimeUtil.convertSeconds2TimeStr1(remainTime, true, true, false))
- self.timer:SetActive(true)
- self:StartRefreshTimer()
- else
- self.timer:SetActive(false)
- self:StopRefreshTimer()
- end
- if bossCfgData.BossType == Enum.GuildHuntBossType.Normal or not summonAuth then
- self.btnChallenge:SetActive(true)
- self.btnChallenge.button.interactable = false
- self.btnSummon:SetActive(false)
- self.costBox:SetActive(false)
- self.condBox:SetActive(true)
- self.condBox.condTxt.text.text = string.formatbykey('GuildInfo_036')
- else
- self.btnChallenge:SetActive(false)
- self.btnSummon:SetActive(true)
- self.costBox:SetActive(true)
- local active = self.controller:GetCurGuildActive()
- if (bossCfgData.Consume > active) then
- self.btnSummon.button.interactable = false
- self.costBox.number.text.text = string.format(Constant.RedColorText, (tostring(active) .. '/' .. tostring(bossCfgData.Consume)))
- else
- self.btnSummon.button.interactable = true
- self.costBox.number.text.text = string.format(Constant.GreenColorText, (tostring(active) .. '/' .. tostring(bossCfgData.Consume)))
- end
- self.condBox:SetActive(false)
- end
- end
- local npcId = bossCfgData.SummonId
- local npcCfgData = ManagerContainer.CfgMgr:GetNpcCfgById(npcId)
- local skillInfos = nil
- if npcCfgData then
- skillInfos = npcCfgData.SkillIds
- self.bossName.text.text = string.formatbykey(npcCfgData.Name)
- else
- self.bossName.text.text = ''
- end
- for i = 1, 4 do
- local skillItem = self['skillItem' .. i]
- if skillItem then
- local skillInfo = skillInfos and skillInfos[i] or nil
- if not skillInfo then
- skillItem:SetActive(false)
- else
- skillItem:SetActive(true)
- local skillId = skillInfo[1]
- local skillLv = skillInfo[2]
- local skillCfgData = ManagerContainer.CfgMgr:GetSkillCfgByType(Enum.SkillType.Active, skillId, skillLv)
- if skillCfgData then
- skillItem.icon.image.enabled = false
- skillItem.icon.image.sprite = nil
- CommonUtil.LoadIcon(self, skillCfgData.Icon, function (sprite)
- skillItem.icon.image.enabled = true
- skillItem.icon.image.sprite = sprite
- end, skillItem, "SkillIconAsyncIdx")
- self.uiBase:AddButtonUniqueEventListener(skillItem.icon.button, self, self.OnClickSkillItem, skillId, skillLv)
- else
- skillItem.icon.image.enabled = false
- skillItem.icon.image.sprite = nil
- skillItem.icon.button:RemoveAllListeners()
- end
- skillItem.num.text.text = (I18N.SetLanguageValue('Lv') .. tostring(skillLv)) or ''
- end
- end
- end
- local awards = bossCfgData.ReviewAwards
- if not awards then
- self.awardScrollView:SetActive(false)
- return
- end
- self.awardScrollView:SetActive(true)
- CommonUtil.LoopGridViewEleCreateNew(self, self.awardScrollView.loopHorizontalScrollRect, nil, awards, 0, self, self.UpdateAwardItem)
- end
- function UIGuildHuntView:UpdateAwardItem(itemLua, idx, itemData)
- if not itemLua or not itemData then return end
- CommonUtil.UpdateItemPrefab(self, itemLua, {cfgId = itemData, num = 0}, Enum.ItemIEnterType.Bag, self, self.OnClickIconItem)
- end
- function UIGuildHuntView:RefreshModel()
- self:DisposeModel()
- local data = self.controller:GetBossInfoList()
- if not data then
- return
- end
- local bossCfgData, bossData = self.controller:GetCurBossInfo()
- if not bossCfgData or not bossData then
- return
- end
- local npcCfgData = ManagerContainer.CfgMgr:GetNpcCfgById(bossCfgData.SummonId)
- if not npcCfgData then
- return
- end
- local avatarCfgData = ManagerContainer.CfgMgr:GetAvatarCfgById(npcCfgData.AvatarId)
- if not avatarCfgData then
- return
- end
- self.modelPath = avatarCfgData.AvatarPrefab
- self.modelPos = CommonUtil.TableToVector3(bossCfgData.ShowPos)
- self.modelRot = CommonUtil.TableToQuaternion(bossCfgData.ShowRot)
- self.seqId = ManagerContainer.ResMgr:LuaLoadAssets(Enum.ResourceType.GameObject, Constants.ModelPath, {self.modelPath}, self, self.ShowModel)
- end
- function UIGuildHuntView:ShowModel()
- self.modelGo = ManagerContainer.ResMgr:GetGoFromPool(Constants.ModelPath, self.modelPath)
- if self.previewSystem then
- self.previewSystem:AddGo(self.modelGo)
- end
- if ManagerContainer.LuaModelMgr and ManagerContainer.LuaModelMgr.ModelRoot then
- self.modelGo.transform:SetParent(ManagerContainer.LuaModelMgr.ModelRoot.transform)
- end
- if self.modelPos then
- self.modelGo.transform.localPosition = self.modelPos
- end
- if self.modelRot then
- self.modelGo.transform.localRotation = self.modelRot
- end
- end
- function UIGuildHuntView:DisposeModel()
- if self.seqId then
- ManagerContainer.ResMgr:ClearUIAsyncLoadReqsBySeqId(self.seqId)
- end
- self.seqId = nil
- if self.modelGo then
- ManagerContainer.ResMgr:RecycleGO(Constants.ModelPath, self.modelPath, self.modelGo)
- if self.previewSystem then
- self.previewSystem:RemoveGo(self.modelGo)
- end
- end
- self.modelPath = nil
- self.modelGo = nil
- end
- function UIGuildHuntView:StartRefreshTimer()
- local timer = self.refreshTimer
- if not timer then
- timer = Timer.New(function()
- self:RefreshTimer()
- end, 1, -1)
- self.refreshTimer = timer
- end
- if not timer.running then
- timer:Start()
- end
- end
- function UIGuildHuntView:StopRefreshTimer()
- if self.refreshTimer then
- self.refreshTimer:Stop()
- end
- end
- function UIGuildHuntView:DisposeRefreshTimer()
- self:StopRefreshTimer()
- self.refreshTimer = nil
- end
- function UIGuildHuntView:RefreshTimer()
- local bossCfgData, bossData = self.controller:GetCurBossInfo()
- if not bossCfgData or not bossData then
- self:StopRefreshTimer()
- return
- end
- local remainTime = nil
- if bossData.fightTime and bossData.fightTime > 0 then
- remainTime = ManagerContainer.LuaTimerMgr:GetRemainSecondsWithUInt64(bossData.fightTime)
- self.timeTxt.text.text = I18N.SetLanguageValue('OutTime1', DateTimeUtil.convertSeconds2TimeStr1(remainTime, true, true, false))
- elseif bossData.fightCdTime and bossData.fightCdTime > 0 then
- remainTime = ManagerContainer.LuaTimerMgr:GetRemainSecondsWithUInt64(bossData.fightCdTime)
- self.timeTxt.text.text = I18N.SetLanguageValue('GuildInfo_039', DateTimeUtil.convertSeconds2TimeStr1(remainTime, true, true, false))
- else
- self.timeTxt.text.text = ''
- end
- if not remainTime or remainTime <= 0 then
- self:StopRefreshTimer()
- else
- if self.refreshTimer then
- local validTime = nil
- if remainTime >= 86400 then
- validTime = remainTime % 3600
- if validTime == 0 then validTime = 3600 end
- elseif remainTime >= 3600 then
- validTime = remainTime % 60
- if validTime == 0 then validTime = 60 end
- else
- validTime = 1
- end
- if validTime then
- self.refreshTimer.duration = validTime
- else
- self:StopRefreshTimer()
- end
- end
- end
- end
- function UIGuildHuntView:StartRefreshInfoTimer()
- -- 获得最近倒计时要结束的时间
- local remainTime = self.controller:GetNearNeedUpdateRemainTime()
- if not remainTime or remainTime <= 0 then
- self:StopRefreshInfoTimer()
- return
- end
- local timer = self.refreshInfoTimer
- if not timer then
- timer = Timer.New(function()
- self:RefreshInfoTimer()
- end, remainTime)
- self.refreshInfoTimer = timer
- else
- timer.duration = remainTime
- timer.time = remainTime
- end
- if not timer.running then
- timer:Start()
- end
- end
- function UIGuildHuntView:StopRefreshInfoTimer()
- if self.refreshInfoTimer then
- self.refreshInfoTimer:Stop()
- end
- end
- function UIGuildHuntView:RefreshInfoTimer()
- self.controller:SendGuildHuntBossListInfoReq()
- end
- function UIGuildHuntView:DisposeRefreshInfoTimer()
- self:StopRefreshInfoTimer()
- self.refreshInfoTimer = nil
- end
- return UIGuildHuntView
|