| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389 |
- local UIExpeditionDungeonInfoView = require("UIExpedition/UIExpeditionDungeonInfoView_Generate")
- function UIExpeditionDungeonInfoView:OnAwake(data)
- self.controller = require("UIExpedition/UIExpeditionDungeonInfoCtr"):new()
- self.controller:Init(self)
- self.controller:SetData(data)
- end
- function UIExpeditionDungeonInfoView:AddEventListener()
- ManagerContainer.LuaEventMgr:RegisterUIEvent(self.uiData.name, UIEventNames.EID_Expedition_RefreshData,self,self.RefreshData)
- ManagerContainer.LuaEventMgr:RegisterUIEvent(self.uiData.name, UIEventNames.EID_Expedition_ResetData,self,self.OnExpeditionResetData)
- end
- function UIExpeditionDungeonInfoView: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 UIExpeditionDungeonInfoView:Init()
- self:InitListView()
- self:ShowLevelBg()
- self:SetLevelData()
- self:ShowLevelRewards()
- self:RefreshTeamHPStatus()
- end
- function UIExpeditionDungeonInfoView:InitListView()
- self.boxScrollList.loopGridView:InitGridView(0, function(gridView, itemIndex, row, column)
- return self:GetItemByRowColumn(gridView, itemIndex, row, column)
- end, nil)
- end
- function UIExpeditionDungeonInfoView:RemoveEventListener()
- ManagerContainer.LuaEventMgr:Unregister(self.uiData.name)
- end
- function UIExpeditionDungeonInfoView:AddUIEventListener()
- self.uiBase:AddButtonEventListener(self.AnyBtn.button,self, self.OnClickCloseBtn)
- self.uiBase:AddButtonEventListener(self.closeBtn.button,self, self.OnClickCloseBtn)
- self.uiBase:AddButtonEventListener(self.nextLevelBtn.button,self, self.OnClickNextLevel)
- self.uiBase:AddButtonEventListener(self.lastLevelBtn.button,self, self.OnClickLastLevel)
- self.uiBase:AddButtonEventListener(self.getAllRewardBtn.button,self, self.OnClickGetAllReward)
- self.uiBase:AddButtonEventListener(self.arrangeBtn.button,self, self.OnClickArrangeBtn)
- self.uiBase:AddButtonEventListener(self.skillBtn.button,self, self.OnClickSkillBtn)
- self.uiBase:AddButtonEventListener(self.petBtn.button,self, self.OnClickPetBtn)
- self.uiBase:AddButtonEventListener(self.blessBtn.button,self, self.OnClickBlessBtn)
- end
- function UIExpeditionDungeonInfoView:OnHide()
- --self.boxScrollList.loopGridView:Dispose()
- end
- function UIExpeditionDungeonInfoView:OnShow(data)
- self.controller:SetData(data)
- end
- function UIExpeditionDungeonInfoView:OnClose()
- self.boxScrollList.loopGridView:Dispose()
- self.levelDatas = nil
- end
- function UIExpeditionDungeonInfoView:OnDispose()
- self.controller:OnDispose()
- end
- function UIExpeditionDungeonInfoView:RefreshData(isSingleReward)
- self:SetLevelData()
- self:ShowLevelRewards(isSingleReward)
- self:RefreshTeamHPStatus()
- end
- function UIExpeditionDungeonInfoView:ShowLevelBg()
- local mapData = self.controller:GetMapData()
- if mapData.levelBg ~= nil and mapData.levelBg ~= "" then
- CommonUtil.LoadIcon(self, mapData.levelBg, function (sprite)
- self.levelBg.image.sprite = sprite
- end)
- end
- end
- function UIExpeditionDungeonInfoView:OnExpeditionResetData()
- ManagerContainer.LuaUIMgr:ClosePage(Enum.UIPageName.UIExpeditionArrange)
- ManagerContainer.LuaUIMgr:ClosePage(Enum.UIPageName.UISkillSettings)
- ManagerContainer.LuaUIMgr:ClosePage(Enum.UIPageName.UIPetBattle)
- ManagerContainer.LuaUIMgr:ClosePage(Enum.UIPageName.UIExpeditionBless)
- self:UIClose()
- end
- function UIExpeditionDungeonInfoView:RefreshTeamHPStatus()
- local totalHPPercent = 0
- local hasDead = false
- local heroIds = ManagerContainer.DataMgr.ExpeditionDataMgr:GetCurrBattleTeamMembers()
- if #heroIds > 0 then
- for i = 1, #heroIds do
- local hpPercent,spPercent = ManagerContainer.DataMgr.ExpeditionDataMgr:GetHeroHPAndSP(heroIds[i])
- if hpPercent == 0 then
- hasDead = true
- end
- totalHPPercent = totalHPPercent + hpPercent
- end
- totalHPPercent = totalHPPercent / #heroIds
- end
- self.arrangeBtn.hpTipsNode.tips.text.text = string.format('%.1f', totalHPPercent) .. "%"
- if hasDead then
- self.arrangeBtn.hpTipsNode.healthFlag:SetActive(false)
- self.arrangeBtn.hpTipsNode.warningFlag:SetActive(false)
- self.arrangeBtn.hpTipsNode.deadFlag:SetActive(true)
- self.arrangeBtn.hpTipsNode.tips:SetActive(false)
- else
- if totalHPPercent >= 90 then
- self.arrangeBtn.hpTipsNode.healthFlag:SetActive(true)
- self.arrangeBtn.hpTipsNode.warningFlag:SetActive(false)
- self.arrangeBtn.hpTipsNode.deadFlag:SetActive(false)
- self.arrangeBtn.hpTipsNode.tips:SetActive(true)
- self.arrangeBtn.hpTipsNode.tips.text.color = Color.New(0, 177/255, 101/255, 1)
- else
- self.arrangeBtn.hpTipsNode.healthFlag:SetActive(false)
- self.arrangeBtn.hpTipsNode.warningFlag:SetActive(true)
- self.arrangeBtn.hpTipsNode.deadFlag:SetActive(false)
- self.arrangeBtn.hpTipsNode.tips:SetActive(true)
- self.arrangeBtn.hpTipsNode.tips.text.color = Color.New(1, 150/255, 0, 1)
- end
- end
- end
- function UIExpeditionDungeonInfoView:SetLevelData()
- local mapData = self.controller:GetMapData()
- local curLevelId = ManagerContainer.DataMgr.ExpeditionDataMgr:GetCurLevelId()
- if mapData.isPassed then
- curLevelId = mapData.maxLevelNum
- end
-
- local bossList = ManagerContainer.DataMgr.ExpeditionDataMgr:GetBossList()
- local challengeBossSlot = ManagerContainer.DataMgr.ExpeditionDataMgr:ChanllengeSlotIdx()
- local levelData = mapData:FindLevelByLevelId(curLevelId)
- local deltaLevel = mapData:GetNextGoodRewardLevel(curLevelId)
- if deltaLevel > 0 then
- self.tipsTxt.text.text = string.formatbykey("ExpeditionBox",deltaLevel)
- else
- self.tipsTxt.text.text = string.formatbykey("ExpeditionBigBox")
- end
- self.title.text.text = I18N.T( mapData.name)
- self.curLevelTxt.text.text = tostring(curLevelId) .. "/" .. mapData.maxLevelNum
-
- local CurScore = ManagerContainer.DataMgr.ExpeditionDataMgr:GetCurScore()
- local MaxScore = ManagerContainer.DataMgr.ExpeditionDataMgr:GetMaxScore()
- local CurLevelScore = levelData:GetScore()
- self.score1.number.text.text = tostring(CurLevelScore)
- self.score2.number.text.text = tostring(MaxScore)
- self.score3.number.text.text = tostring(CurScore)
- for i = 1, 3 do
- local bossItem = self:GetBossItem(i)
- bossItem:SetActive(false)
- end
- if mapData.isPassed then
- self.passedNode:SetActive(true)
- else
- self.passedNode:SetActive(false)
- if challengeBossSlot>= 1 and challengeBossSlot<=3 then
- local bossMaxHP,bossMaxSp = levelData:GetBossMaxHPAndSp(bossList[challengeBossSlot].id)
- local bossCfg = ManagerContainer.CfgMgr:GetNpcCfgById(bossList[challengeBossSlot].id)
- if bossCfg ~= nil then
- local hpPercent = bossList[challengeBossSlot].hp / bossMaxHP
- self:SetBossData(self:GetBossItem(challengeBossSlot),bossCfg,hpPercent,challengeBossSlot,bossList[challengeBossSlot].id)
- end
- else
- for i = 1, #bossList do
- local bossInfo = bossList[i]
- local bossCfg = ManagerContainer.CfgMgr:GetNpcCfgById(bossInfo.id)
- if bossCfg ~= nil then
- self:SetBossData(self:GetBossItem(i),bossCfg,1,i,bossInfo.id)
- end
- end
- end
- end
- end
- function UIExpeditionDungeonInfoView:SetBossData(bossItemLua,bossCfg,hpPercent,bossSlotIdx,BossId)
- bossItemLua.bossName.text.text = I18N.T(bossCfg.Name)
- bossItemLua.hpProgress.slider.value = hpPercent
- --boss 积分
- local CurBossScore = ManagerContainer.DataMgr.ExpeditionDataMgr:GetCurBossScore(BossId)
- bossItemLua.scoreTxt.text.text = "+"..tostring(CurBossScore)
- if bossCfg.Icon~= nil then
- CommonUtil.LoadIcon(self, bossCfg.Icon, function (sprite)
- bossItemLua.bossImg.image.sprite = sprite
- bossItemLua.bossImg.image:SetNativeSize()
- if bossCfg.IconOffset~= nil then
- local offset = Vector2(bossCfg.IconOffset[1],bossCfg.IconOffset[2])
- bossItemLua.bossImg.rectTransform.anchoredPosition = offset
- end
- end)
- end
-
- local natureCfg = ManagerContainer.CfgMgr:GetNatureDataById(bossCfg.NatureId)
- if natureCfg ~= nil and natureCfg.Icon~=nil then
- CommonUtil.LoadIcon(self, natureCfg.Icon, function (sprite)
- bossItemLua.natureImg.image.sprite = sprite
- end)
- end
- self.uiBase:AddButtonUniqueEventListener(bossItemLua.challengeBtn.button,self, self.OnClickChallengeBoss,bossSlotIdx)
- self.uiBase:AddButtonUniqueEventListener(bossItemLua.bossImg.button,self, self.OnClickViewBossDetail,bossSlotIdx)
- bossItemLua:SetActive(true)
- end
- function UIExpeditionDungeonInfoView:OnClickViewBossDetail(btn,params)
- local bossList = ManagerContainer.DataMgr.ExpeditionDataMgr:GetBossList()
- local bossSlotIdx = params[0]
- local bossData = bossList[bossSlotIdx]
- local bossActor = ActorData.CreateNpcPlayerActor(0,bossData.id,bossData.level)
- ManagerContainer.LuaUIMgr:Open(Enum.UIPageName.UIBattleBossTips,bossActor)
- end
- function UIExpeditionDungeonInfoView:GetBossItem(idx)
- if idx == 1 then
- return self.bossItem1
- elseif idx == 2 then
- return self.bossItem2
- else
- return self.bossItem3
- end
- end
- function UIExpeditionDungeonInfoView:RefreshRewards(isSingleReward)
- self.controller:RefreshMapData()
- local mapData = self.controller:GetMapData()
- if self.levelDatas == nil then
- self.levelDatas = {}
- end
- if mapData.allLevels ~= nil then
- for _,v in pairs(mapData.allLevels) do
- self.levelDatas[v.levelId] = v
- end
- end
- local loopGridView = self.boxScrollList.loopGridView
- local length = #self.levelDatas
- if not isSingleReward then
- loopGridView:SetListItemCount(length, true)
- else
- loopGridView:RefreshListByIndex(length)
- end
- loopGridView:RefreshAllShownItem()
- self.onekeyRP:SetActive(mapData:HasRedPoint())
- end
- function UIExpeditionDungeonInfoView:ShowLevelRewards(isSingleReward)
- local curLevelId = self.controller:GetCurLevelId()
- local mapData = self.controller:GetMapData()
- --local startLevelId = curLevelId
- --if (curLevelId+5) > mapData.maxLevelNum then
- -- startLevelId = mapData.maxLevelNum - 5
- --else
- -- if math.fmod(curLevelId, 5) > 0 then
- -- startLevelId = curLevelId - math.fmod(curLevelId, 5) + 1
- -- else
- -- if curLevelId == 5 then
- -- startLevelId = 0
- -- else
- -- startLevelId = curLevelId - 4
- -- end
- -- end
- --end
- self:RefreshRewards(isSingleReward)
- if not isSingleReward then
- local curIdx = curLevelId < #mapData.allLevels - 4 and curLevelId - 1 or #mapData.allLevels - 5
- self.boxScrollList.loopGridView:MovePanelToItemByIndex(curIdx)
- end
- end
- function UIExpeditionDungeonInfoView:GetItemByRowColumn(gridView, itemIndex, row, column)
- local levelData = self.levelDatas[itemIndex + 1]
- local item
- if levelData then
- item = gridView:NewListViewItem('DungeonRewardBox')
- local rewardLua = CommonUtil.BindGridViewItem2Lua(self, 'DungeonRewardBox', item.gameObject)
- local levelData = self.levelDatas[itemIndex + 1]
- local idx = itemIndex
- CommonUtil.LoadIcon(self, levelData.closeRewardBoxImg, function (sprite)
- rewardLua.closeNode.image.sprite = sprite
- end,rewardLua,"CloseRewardBoxIdx")
- CommonUtil.LoadIcon(self, levelData.openRewardBoxImg, function (sprite)
- rewardLua.openNode.image.sprite = sprite
- end,rewardLua,"OpenRewardBoxIdx")
- rewardLua.currentNode:SetActive(not levelData.isPassed and (idx+1) == self.controller:GetCurLevelId())
- rewardLua.levelNum.text.text =I18N.SetLanguageValue('DiNGuan',idx+1)
- if levelData.isGotReward then
- rewardLua.openNode:SetActive(true)
- rewardLua.closeNode:SetActive(false)
- rewardLua.activeNode:SetActive(false)
- self.uiBase:AddButtonUniqueEventListener(rewardLua.button,self, self.OnClickViewRewardBox,levelData.levelId)
- elseif levelData.isPassed then
- rewardLua.openNode:SetActive(false)
- rewardLua.closeNode:SetActive(true)
- rewardLua.activeNode:SetActive(true)
- self.uiBase:AddButtonUniqueEventListener(rewardLua.button,self, self.OnClickGetRewardBox,levelData.levelId)
- else
- rewardLua.openNode:SetActive(false)
- rewardLua.closeNode:SetActive(true)
- rewardLua.activeNode:SetActive(false)
- self.uiBase:AddButtonUniqueEventListener(rewardLua.button,self, self.OnClickViewRewardBox,levelData.levelId)
- end
- end
- return item
- end
- function UIExpeditionDungeonInfoView:OnClickViewRewardBox(btn,params)
- local mapData = self.controller:GetMapData()
- local levelId = params[0]
- local levelData = mapData:FindLevelByLevelId(levelId)
- if levelData ~= nil and levelData.rewards ~= nil and #levelData.rewards > 0 then
- ManagerContainer.LuaUIMgr:ShowMinRewardTips(levelData.rewards)
- end
- end
- function UIExpeditionDungeonInfoView:OnClickGetRewardBox(btn,params)
- local levelId = params[0]
- local mapData = self.controller:GetMapData()
- ManagerContainer.DataMgr.ExpeditionDataMgr:SendGotRewardReq(mapData.mapId,levelId)
- end
- function UIExpeditionDungeonInfoView:OnClickCloseBtn()
- self:UIClose()
- end
- function UIExpeditionDungeonInfoView:OnClickNextLevel()
- local idx = self.boxScrollList.loopGridView:FindNearestItemIndex()
- local startPos = idx + 5
- self.boxScrollList.loopGridView:MovePanelToItemByIndex(startPos)
- end
- function UIExpeditionDungeonInfoView:OnClickLastLevel()
- local idx = self.boxScrollList.loopGridView:FindNearestItemIndex()
- local startPos = idx - 5
- if startPos < 0 then
- self.boxScrollList.loopGridView:MovePanelToItemByIndex(0)
- return
- end
- self.boxScrollList.loopGridView:MovePanelToItemByIndex(startPos)
- end
- function UIExpeditionDungeonInfoView:OnClickGetAllReward()
- local mapData = self.controller:GetMapData()
- ManagerContainer.DataMgr.ExpeditionDataMgr:SendGotRewardReq(mapData.mapId,0)
- end
- function UIExpeditionDungeonInfoView:OnClickArrangeBtn()
- ManagerContainer.LuaUIMgr:Open(Enum.UIPageName.UIExpeditionArrange)
- end
- function UIExpeditionDungeonInfoView:OnClickSkillBtn()
- ManagerContainer.LuaUIMgr:Hide(self.uiData.id)
- ManagerContainer.LuaUIMgr:Open(Enum.UIPageName.UISkillSettings,{1},self.uiData.id)
- end
- function UIExpeditionDungeonInfoView:OnClickPetBtn()
- ManagerContainer.LuaUIMgr:Hide(self.uiData.id)
- local data = {list = ManagerContainer.DataMgr.ExpeditionDataMgr:GetCurrBattleTeamMembers()}
- ManagerContainer.LuaUIMgr:Open(Enum.UIPageName.UIPetBattle,data,self.uiData.id)
- end
- function UIExpeditionDungeonInfoView:OnClickBlessBtn()
- ManagerContainer.LuaUIMgr:Open(Enum.UIPageName.UIExpeditionBless)
- end
- function UIExpeditionDungeonInfoView:OnClickChallengeBoss(btn,params)
- local bossSlotIdx = params[0]
- ManagerContainer.DataMgr.ExpeditionDataMgr:SendChallengeBossStart(bossSlotIdx)
- end
- return UIExpeditionDungeonInfoView
|