--[[ 神兽福地界面 ]]-- local UIGodBeastParadise = UIViewClass() local PARADISE_BG_IMG = ConstAssetPathConfig.PARADISE_BG_IMG local PARADISE_LIVE_IMG_SCALE = 0.2 local PARADISE_SCENE_EFFECT = ConstAssetPathConfig.PARADISE_SCENE_EFFECT --region ------------------------------------------- 系统函数 ----------------------------------------------- function UIGodBeastParadise:OnCreated() self.modelComponentDataHandle = UTL.UIRender.CreateModelComponentDatas(self.renderModel) self.sceneEffectID = 0 end function UIGodBeastParadise:OnOpened(context) self:RegistSystemEvent(EventID.UI_GodBeast_ParadiseRefresh, self.RefreshPanel) self:InitClickHeadBubbleInfo() UIUtils.SetLabelText(self.UITemplateTitlePanel.lab_Title, Const_IDS.IDS_Godbeast_Paradise) UIManager.ActiveUIModle(false, "UIGodBeastParadise") -- 创建场景 UTL.UIRender.Create2DTextureBgScene(self.modelComponentDataHandle, PARADISE_BG_IMG, nil, nil) UTL.UIRender.SetHeroParentRot(self.modelComponentDataHandle, 0, 0, 0) self.sceneEffectID = UTL.UIRender.PlayScenePSEffect(self.modelComponentDataHandle, PARADISE_SCENE_EFFECT) CTL.GodBeast.SetParadiseFixedResolutionFov(self.modelComponentDataHandle) self:RefreshPanel() end function UIGodBeastParadise:InitClickHeadBubbleInfo() self.bubbleList = {} for i, v in ipairs(self.group_BeastHead) do table.insert(self.bubbleList, false) end end function UIGodBeastParadise:OnClosed() UIManager.CloseView(Const_UI_Lua.UIEnum.UIGodBeastRewardInfoPanel) UIManager.ActiveUIModle(true, "UIGodBeastParadise") if self.sceneEffectID ~= 0 then AuxUtil.StopDynamicObject(self.sceneEffectID) end UTL.UIRender.DisposeModelComponentData(self.modelComponentDataHandle) end function UIGodBeastParadise:OnBackButtonPressed() self:OnButtonClicked(self.UITemplateTitlePanel.btn_close) end function UIGodBeastParadise:OnButtonClicked(comp) if comp == self.UITemplateTitlePanel.btn_close then self:CloseView(true) elseif comp == self.UITemplateTitlePanel.btn_Info then local TIMER_REFRESH_ID_ARR = DataSheetManager.ConstData:GetDataByID("GodBeastParadiseTimeRefresh").IntListValue local time1 = UTL.Time.GetLocalTimeDesc(TIMER_REFRESH_ID_ARR[1]) local time2 = UTL.Time.GetLocalTimeDesc(TIMER_REFRESH_ID_ARR[2]) UIManager.OpenView(Const_UI_Lua.UIEnum.UICommonNoteView, { id = LuaConst.NoteID.GodBeastParadise, params = { time1, time2 } }) elseif comp == self.btn_Info then UIManager.OpenView(Const_UI_Lua.UIEnum.UIGodBeastRewardInfoPanel) elseif comp == self.btn_Get then if not MDL.GodBeast.IsParadiseHasDropItem() and MDL.GodBeast.GetDropRound() == 0 then CTL.Tips.AddTipsMsg(Const_IDS["IDS_RankOptimization_Tip_NoReward"]) return end MDL.GodBeast.GetParadiseDropReq() elseif comp == self.UITemplateTitlePanel.btn_Home then CTL.HomeMain.CloseViewBackHomeMain() elseif comp == self.btn_AddInfo then UIManager.OpenView(Const_UI_Lua.UIEnum.UICommonNoteView, { id = LuaConst.NoteID.GodBeastAdditionInfo }) else for idx, collection in ipairs(self.group_BeastHead) do if comp == collection.btn_Reward then self.bubbleList[idx] = not self.bubbleList[idx] self:RefreshBubbleList() return end end end end function UIGodBeastParadise:OnCellInit(scrollRect, index, cellTable, data) if scrollRect == self.LoopScroll_Reward then -- 右侧掉落图标 UIUtils.SetActive(cellTable.txt_probability, data.possibility < 10000) UIUtils.SetLabelText(cellTable.txt_probability, Const_IDS.IDS_RewardClientShow_Probability) UTL.Item.ItemSquareIcon(cellTable.img_Item, cellTable.img_ItemBG, data.ItemID) end end function UIGodBeastParadise:OnCellClicked(scrollRect, index, cellTable, target, data) if scrollRect == self.LoopScroll_Reward then UTL.ItemTips.ShowCommonTipsById(data.ItemID) end end --endregion ------------------------------------------------------------------------------------------ function UIGodBeastParadise:RefreshBubbleList() for i, collection in ipairs(self.group_BeastHead) do UIUtils.SetActive(collection.group_Reward.gameObject, self.bubbleList[i]) end end function UIGodBeastParadise:RefreshPanel() self.paradiseInfo = MDL.GodBeast.GetParadiseDropInfo() -- 设置下次产宝时间 self.txt_CountDown:SetCustomString(UIUtils.GetLocalizedTxt(Const_IDS.IDS_Godbeast_ParadiseTime2), 1, 2) self.txt_CountDown:ResetAndBeginTimer(false, CTL.GodBeast.GetParadiseNextRefreshTimestamp(), 0) self:UpdateBeast() -- 左侧属性 self:UpdateAttrInfo() -- 右侧神兽产宝掉落预览 self.LoopScroll_Reward:ReloadAll(MDL.GodBeast.GetParadiseDropItemDic()) -- 可领取红点 self.btn_Get:SetRedPoint(MDL.GodBeast.IsParadiseHasDropItem()) end function UIGodBeastParadise:UpdateBeast() UTL.UIRender.RemoveModelObj(self.modelComponentDataHandle) local activeBeastList = MDL.GodBeast.GetActiveBeastInfoDic() local dropDic = MDL.GodBeast.GetParadiseDropInfo() for idx, collection in ipairs(self.group_BeastHead) do local isSlotShow, godBeastData = self:IsSlotActive(idx) if isSlotShow then collection.headIcon_State:SetState(1) UIUtils.SetActive(collection.gameObject, true) UIUtils.SetLabel(collection.txt_Title, string.FormatByIdsId( Const_IDS.IDS_Godbeast_FateWheelLevel10, UIUtils.GetLocalizedTxt(Const_IDS[godBeastData.GodBeastName]), MDL.GodBeast.GetStarLevel(godBeastData.ID) ) ) if activeBeastList[godBeastData.ID] ~= nil then UIUtils.SetActive(collection.img_Unactive.gameObject, false) collection.headIcon_State:SetState(0) -- 更新每个神兽的物品掉落展示 local activeCount = 0 for i, itemCollection in ipairs(collection.group_Reward) do if dropDic[godBeastData.ID] == nil or dropDic[godBeastData.ID][i] == nil then UIUtils.SetActive(itemCollection.gameObject, false) else activeCount = activeCount + 1 local dropItemData = dropDic[godBeastData.ID][i] UIUtils.SetActive(itemCollection.gameObject, true) local itemData = DataSheetManager.ItemData:GetDataByID(dropItemData.itemID) UTL.Item.ItemCircleIcon(itemCollection.img_Item, itemCollection.img_ItemBG, dropItemData.itemID) UTL.Color.SetQualityImageByType(itemCollection.img_ItemBG, itemData.Color, UTL.Color.QualityType.StoreGoodsIconBase) end end -- 气泡弹出框 UIUtils.SetActive(collection.group_Reward.gameObject, self.bubbleList[idx] and activeCount > 0) collection.btn_Reward:SetRedPoint(activeCount > 0) collection.btn_Reward:SetGray(activeCount <= 0) -- 已激活 UTL.UIRender.AddModelObj( self.modelComponentDataHandle, godBeastData.GodBeastParadiseLiveImage, nil, godBeastData.GodBeastPosition[1], -- x godBeastData.GodBeastPosition[2], -- y godBeastData.GodBeastPosition[3], -- z PARADISE_LIVE_IMG_SCALE ) else -- 未激活 UIUtils.SetActive(collection.img_Unactive.gameObject, true) UIUtils.SetImageByAssetBundle(collection.img_Unactive, godBeastData.GodBeastParadiseStillImage) UIUtils.SetGray(collection.img_Unactive, true) collection.btn_Reward:SetRedPoint(false) UIUtils.SetActive(collection.group_Reward.gameObject, false) collection.btn_Reward:SetGray(true) end else -- 禁用按钮 collection.btn_Reward:SetGray(true) end end end function UIGodBeastParadise:IsSlotActive(idx) for _, godBeastData in DataSheetManager.GodBeastData:GetEnumerator() do if idx == godBeastData.GodBeastParadiseCoordinate then return true, godBeastData end end return false end function UIGodBeastParadise:UpdateAttrInfo() local totalGS = 0 local tempAttrResult = {} for i, v in pairs(MDL.GodBeast.GetActiveBeastInfoDic()) do local spaceData = DataSheetManager.GodBeastSpace:GetDataByGodBeastID_GodBeastStar(v.godBeastId, v.starLevel) local improveRatio = spaceData.AttrImprove / 10000 -- 属性 for attrType, attrNum in ipairs(v.attr) do if attrNum > 0 then if tempAttrResult[attrType] then tempAttrResult[attrType] = tempAttrResult[attrType] + attrNum * improveRatio else tempAttrResult[attrType] = attrNum * improveRatio end end end end -- 属性列表 local index = 0 UIUtils.SetActive(self.group_Attr.gameObject, next(tempAttrResult) ~= nil) for attrType, attrNum in pairs(tempAttrResult) do index = index + 1 local attrObj = self.Content_Attr[index] if not attrObj then attrObj = self:InstantiateCollection(self.Content_Attr, self.Content_Attr[1].gameObject) end UIUtils.SetActive(attrObj.gameObject, true) UTL.Attr.SetAttrItemByCompName(attrObj, attrType, math.floor(attrNum + 0.5), nil, true) -- 战力 totalGS = totalGS + math.floor(UTL.Attr.CalculateSingleFight(attrType, attrNum) + 0.5) * 6 end UIUtils.SetLabel(self.txt_PowerNum, string.FormatByIdsId(Const_IDS.IDS_TreasureSoul_ZhanLi, totalGS)) end return UIGodBeastParadise