local UISuperGoldBossMain = UIViewClass() local SuperGoldBossDisMaxLevel = DataSheetManager.ConstData:GetDataByID("SuperGoldBossDisMaxLevel").IntValue local RankReqFrequency = 5 function UISuperGoldBossMain:OnOpened(context) self.heroType = context.heroType self.activityId = context.activityId self.activityType = MDL.OperationActivity.ActivityType.SuperGold self:RegistSystemEvent(EventID.UI_SuperGoldBoss_InfoRefresh, self.RefreshInfo) self:RegistSystemEvent(CTL.SuperGoldMain.RpEventId[self.activityId].BossTrailHasReward, self.RefreshRewardRp) -- 奖励可领 self:RegistSystemEvent(CTL.SuperGoldMain.RpEventId[self.activityId].BossTrailItemEnough, self.RefreshItemEnoughRp) -- 有物品可以挑战 self:RegistSystemEvent(EventID.UI_OperationActivity_CloseView, self.OnCloseActivitySelf) self:RefreshRewardRp(MDL.RedPoint.GetNodeStateByLogicParams(CTL.SuperGoldMain.RpEventId[self.activityId].TownHome, CTL.SuperGoldMain.RpEventId[self.activityId].BossTrailHasReward)) --奖励可领 self:RefreshItemEnoughRp(MDL.RedPoint.GetNodeStateByLogicParams(CTL.SuperGoldMain.RpEventId[self.activityId].TownHome, CTL.SuperGoldMain.RpEventId[self.activityId].BossTrailItemEnough)) --奖励可领 local bossData = DataSheetManager.SuperGoldBossData:GetDataByHeroType(self.heroType) self.gsGroupId = bossData.GSGroupID self.modeData = DataSheetManager.SuperGoldActivityModeData:GetDataByHeroType(self.heroType) --标题 UIUtils.SetLabelText(self.UITemplateTitlePanel.lab_Title, Const_IDS[self.modeData.BossName]) self:RefreshEndTime() self:ShowAddHeroBasicInfo() self:ShowAddHeroDetailInfo(false) self:RefreshCostItem() self:ShowBossModel(bossData) self.isInit = false self.context = context --请求排名协议 --定时请求排名,刷新数据 self:SendRankReq() self:StartRepeatFunc(self.SendRankReq, RankReqFrequency, -1) CTL.SuperGoldMain.OpenCurrencyPanel(self.heroType, self.__viewClassPath, self.currency_Info, {activityType = self.activityType, activityId = self.activityId, title = "IDS_DrawCard_Title_QuickBuy"}) UIManager.ActiveUIModle(false, "UISuperGoldBossMain") end function UISuperGoldBossMain:RefreshEndTime() local timeId = self.modeData.DailyRankEndTime self.txt_TimeHint.text = string.FormatByIdsKey("IDS_SuperGoldHeroActivity_NewHint_2", UTL.Time.GetDiffLocalStrById(timeId)) local deltaTime = UTL.Time.GetServerIntervalTimeByTimeId(timeId) if UTL.Time.IsServerInOpeningTime(1, timeId) then self:StartRepeatFunc(self.RefreshEndTime, math.abs(deltaTime), 1) self.state_Btn:SetState(0) else self.state_Btn:SetState(1) end end function UISuperGoldBossMain:SendRankReq() MDL.SuperGoldBoss.SuperGoldTrialOpenReq(self.activityId, MDL.SuperGoldBoss.GetRecommendGsDifficult(self.gsGroupId)) end function UISuperGoldBossMain:RefreshInfo() if not self.isInit then self.isInit = true self.difficultLevel = self.context.difficult or MDL.SuperGoldBoss.GetDefaultDifficult(self.activityId, self.gsGroupId) self:RefreshDifficultList() self:RefreshDifficultLevelInfo(DataSheetManager.SuperGoldBossGS:GetDataByGSGroupID_BossLevel(self.gsGroupId, self.difficultLevel)) end self:ShowRankInfo() self:RefreshItemEnoughRp(MDL.RedPoint.GetNodeStateByLogicParams(CTL.SuperGoldMain.RpEventId[self.activityId].TownHome, CTL.SuperGoldMain.RpEventId[self.activityId].BossTrailItemEnough)) --奖励可领 end function UISuperGoldBossMain:OnCloseActivitySelf(viewClassPath, activityId) if viewClassPath == self.__viewClassPath then if self.activityId and activityId == self.activityId then self:CloseView(true) end end end function UISuperGoldBossMain:OnClosed() MDL.SuperGoldBoss.SaveTempDifficult(self.activityId, self.difficultLevel) UIManager.ActiveUIModle(true, "UISuperGoldBossMain") end function UISuperGoldBossMain:OnBackButtonPressed() self:OnButtonClicked(self.UITemplateTitlePanel.btn_close) end function UISuperGoldBossMain:OnButtonClicked(comp) if comp == self.UITemplateTitlePanel.btn_close then self:CloseView(true) elseif comp == self.UITemplateTitlePanel.btn_Home then CTL.HomeMain.CloseViewBackHomeMain() elseif comp == self.UITemplateTitlePanel.btn_Info then local params = {} local bossData = DataSheetManager.SuperGoldBossData:GetDataByHeroType(self.heroType) local itemName = UIUtils.GetLocalizedTxt(Const_IDS[DataSheetManager.ItemData:GetDataByID(bossData.EnergyItem).Name]) table.insert(params, itemName) local _,timeStr = UTL.Time.GetDateDescAndTime({1}) table.insert(params, timeStr) local limitSec = self.modeData.RankLimitTime * UTL.Time.TotalSecondsOneMinute local value, timeZoneType = UTL.Time.GetDiffLocalTimeZoneById(1) table.insert(params, UTL.Time.OsDateOriginal("!%H:%M", value - limitSec)) table.insert(params, UTL.Time.OsDateOriginal("!%H:%M", value + limitSec)) UIManager.OpenView(Const_UI_Lua.UIEnum.UICommonNoteView, {id = LuaConst.NoteID.SuperGoldBoss, params = params}) elseif comp == self.btn_Rank then UIManager.OpenView(Const_UI_Lua.UIEnum.UISuperGoldBossRank, {activityId = self.activityId, heroType = self.heroType}) elseif comp == self.btn_RankReward then local bossData = DataSheetManager.SuperGoldBossData:GetDataByHeroType(self.heroType) UIManager.OpenView(Const_UI_Lua.UIEnum.UISuperGoldBossRankReward, {activityId = self.activityId, groupId = bossData.RankRewardGroup}) elseif comp == self.btn_TimesReward then local bossData = DataSheetManager.SuperGoldBossData:GetDataByHeroType(self.heroType) UIManager.OpenView(Const_UI_Lua.UIEnum.UISuperGoldBossTimesReward, {activityId = self.activityId, groupId = bossData.DailyRewardGroup}) elseif comp == self.btn_Fight then local bossData = DataSheetManager.SuperGoldBossData:GetDataByHeroType(self.heroType) if CTL.SuperGoldBoss.IsItemEnough(self.activityId) then MDL.SuperGoldBoss.EnterSuperGoldBoss(self.activityId, self.difficultLevel, bossData.BossLevelID) else if not MDL.SuperGoldBoss.OpenEnergyBuyView(self.activityId) then CTL.Tips.AddTipsMsg(string.FormatByIdsId(Const_IDS.IDS_GoldHeroActivity_ActivityLevel_WrongHint1, UIUtils.GetLocalizedTxt(Const_IDS[DataSheetManager.ItemData:GetDataByID(bossData.EnergyItem).Name]))) end end elseif comp == self.btn_Sweep then if MDL.SuperGoldBoss.GetMaxScore(self.activityId) > 0 then if CTL.SuperGoldBoss.IsItemEnough(self.activityId) then MDL.SuperGoldBoss.SuperGoldTrialSweepReq(self.activityId) else if not MDL.SuperGoldBoss.OpenEnergyBuyView(self.activityId) then local bossData = DataSheetManager.SuperGoldBossData:GetDataByHeroType(self.heroType) CTL.Tips.AddTipsMsg(string.FormatByIdsId(Const_IDS.IDS_GoldHeroActivity_ActivityLevel_WrongHint1, UIUtils.GetLocalizedTxt(Const_IDS[DataSheetManager.ItemData:GetDataByID(bossData.EnergyItem).Name]))) end end else CTL.Tips.AddTipsMsg(Const_IDS.IDS_SuperGoldHeroActivity_HeroTrial_ClickHint1) end elseif comp == self.btn_DifficultListBg then self:ShowDifficultList(false) CTL.Sound.PlayGameSound("UI_fold") elseif comp == self.btn_DifficultList then local state = not self.group_DifficultList.gameObject.activeSelf self:ShowDifficultList(state) if state then CTL.Sound.PlayGameSound("UI_expand") else CTL.Sound.PlayGameSound("UI_fold") end elseif comp == self.btn_HeroAddBg then self:ShowAddHeroDetailInfo(false) elseif comp == self.btn_HeroAdd then self:ShowAddHeroDetailInfo(not self.group_HeroAddInfo.gameObject.activeSelf) end end function UISuperGoldBossMain:ShowRankInfo() local maxScore = MDL.SuperGoldBoss.GetMaxScore(self.activityId) UIUtils.SetActive(self.mask_Sweep, maxScore <= 0) self.txt_HighestScore.text = maxScore self.txt_TotalScore.text = MDL.SuperGoldBoss.GetTodayScore(self.activityId) local rank = MDL.SuperGoldBoss.GetMyRankByName(self.activityId, MDL.SuperGoldBoss.BossRankName.TotalScoreRank) self.txt_TotalScoreRank.text = rank > 0 and rank or UIUtils.GetLocalizedTxt(Const_IDS.IDS_Rank_Unranked) self.txt_Challenge.text = MDL.SuperGoldBoss.GetParticipateTimes(self.activityId) local bossData = DataSheetManager.SuperGoldBossData:GetDataByHeroType(self.heroType) local rewardLevel, isScoreEnough = MDL.SuperGoldBoss.GetCurrentIndexOfRewardRank(self.activityId, MDL.SuperGoldBoss.BossRankName.TotalScoreRank) local _, rewardData = DataSheetManager.SuperGoldBossTotalRank[bossData.RankRewardGroup]:TryGetDataByRankID(rewardLevel) if rewardData then if self.loop_RankReward.Count > 0 then self.loop_RankReward:ClearCells() end self.state_RankReward:SetState(rewardLevel >= 0 and 0 or 1) for i, v in ipairs(rewardData.Reward_Table) do self.loop_RankReward:AddData(v, 0) end end end function UISuperGoldBossMain:ShowBossModel(bossData) local equipTable = {} if bossData.ShowEquipmentID and bossData.ShowEquipmentID > 0 then local equipData = DataSheetManager.EquipPartsData:GetDataByID(bossData.ShowEquipmentID) for i, v in ipairs(equipData.EquipPart_Table) do local data = {} data.Prefeb = v.Prefeb data.EquipSlotStr = v.EquipSlotStr table.insert(equipTable, data) end end -- 加载模型和设置2D背景图 self.BossShowScene:Show2DBGModel(bossData.BossShow, equipTable, bossData.ModelScale, bossData.ModelLight) -- 加载模型 local modelPos = bossData.ModelOffset self.BossShowScene:SetNodePos(modelPos[1], modelPos[2], modelPos[3]) -- 设置模型位移信息 self.BossShowScene:SetNodeRot(0, -10, 0) -- 设置模型旋转角度 self.BossShowScene:SetSceneShadowPlane(true) -- 设置阴影面开关 self.BossShowScene:SetSceneTexture(ConstAssetPathConfig.DefaultImage) end function UISuperGoldBossMain:RefreshCostItem() --显示boss消耗货币数 local bossData = DataSheetManager.SuperGoldBossData:GetDataByHeroType(self.heroType) self.txt_CostNum.text = bossData.EnergyNum UTL.Item.ItemIconWithoutBg(self.img_CostIcon, bossData.EnergyItem) end function UISuperGoldBossMain:ShowAddHeroBasicInfo() local addHeroId = self.modeData.HeroID CTL.HeroSelect.SetHeroName(addHeroId, self.loc_BossName, self.img_BossName, self.txt_BossName) UTL.Item.SetHeroIconByHeroId(self.img_HeroAddHead, addHeroId, MDL.HeroAwaken.GetIsHeroAwaken(addHeroId)) UTL.Item.SetHeroIconByHeroId(self.img_AddHero, addHeroId, MDL.HeroAwaken.GetIsHeroAwaken(addHeroId)) local level = MDL.SuperGoldBoss.GetAddHeroAddLevel(addHeroId) local isUnlock = level > 0 self.state_Unlock:SetState(isUnlock and 1 or 0) UIUtils.SetGray(self.img_HeroAddHead, not isUnlock) UIUtils.SetGray(self.img_AddHero, not isUnlock) UIUtils.SetActive(self.group_AddNum, isUnlock) level = isUnlock and level or 1 --如果该武将突破等级不满足则置成1,找到初始数据进行显示 local addHeroData = DataSheetManager.SuperGoldBossHero:GetDataByHeroID_LevelID(addHeroId, level) local addNum = UTL.Attr.FormatNumberToPercentage(addHeroData.BossHeroNum, 0) self.txt_HeroAddNum.text = "+" .. addNum UIUtils.SetLabelText(self.txt_SkillName, Const_IDS[addHeroData.SkillName]) self.txt_Lv.text = level local firstAddHeroData = DataSheetManager.SuperGoldBossHero:GetDataByHeroID_LevelID(addHeroId, 1) local heroName = UIUtils.GetLocalizedTxt(Const_IDS[DataSheetManager.HeroNum:GetDataByID(addHeroId).NameIDS]) self.txt_SkillInfo.text = string.FormatByIdsId(Const_IDS[firstAddHeroData.SkillDes], heroName, UTL.Attr.FormatNumberToPercentage(firstAddHeroData.BossHeroNum, 0)) end function UISuperGoldBossMain:ShowAddHeroDetailInfo(isShow) UIUtils.SetActive(self.btn_HeroAddBg, isShow) UIUtils.SetActive(self.group_HeroAddInfo, isShow) if isShow then local loopScroll = self.loop_HeroAddInfo if loopScroll.Count > 0 then loopScroll:ClearCells() end local addHeroId = self.modeData.HeroID for i, v in DataSheetManager.SuperGoldBossHero:GetDataByHeroID_LevelID(addHeroId) do if i > 1 then loopScroll:AddData(v, 0) end end end end function UISuperGoldBossMain:ShowDifficultList(active) self.state_Arrow:SetState(active and 0 or 1) self.loop_DifficultList:RefreshCells(false) UIUtils.SetActive(self.group_DifficultList, active) if active then self.loop_DifficultList:SelectIndex(self.difficultLevel - 1, true) self.loop_DifficultList:MoveIndex(self.difficultLevel - 1) end end function UISuperGoldBossMain:RefreshDifficultList() if self.loop_DifficultList.Count > 0 then self.loop_DifficultList:ClearCells() end local defaultDifficult = MDL.SuperGoldBoss.GetRecommendDifficult(self.activityId, self.gsGroupId) for i, v in DataSheetManager.SuperGoldBossGS:GetDataByGSGroupID_BossLevel(self.gsGroupId) do if v.BossLevel > SuperGoldBossDisMaxLevel + defaultDifficult then break end self.loop_DifficultList:AddData(v, 0) end end function UISuperGoldBossMain:OnCellInit(scrollRect, index, cellTable, data) if scrollRect == self.loop_HeroAddInfo then local heroId = data.HeroID local level = MDL.SuperGoldBoss.GetAddHeroAddLevel(heroId) local isUnlock = level >= data.LevelID cellTable.txt_Level.text = string.FormatByIdsId(Const_IDS.IDS_BreakThrough_Level, data.LevelID) cellTable.state_Unlock:SetState(isUnlock and 1 or 0) cellTable.txt_Desc.text = string.FormatByIdsId(Const_IDS[data.SkillDes], UTL.Attr.FormatNumberToPercentage(data.BossHeroNum, 0)) if not isUnlock then local heroName = DataSheetManager.HeroNum:GetDataByID(heroId).NameIDS cellTable.txt_Unlock.text = string.FormatByIdsId(Const_IDS.IDS_GoldHeroActivity_SynergyBoss_SkillLock, UIUtils.GetLocalizedTxt(Const_IDS[heroName]), data.HeroStar) end elseif scrollRect == self.loop_DifficultList then cellTable.txt_DifficultLevel.text = data.BossLevel cellTable.state_Btn:SetState(data.BossLevel == self.difficultLevel and 1 or 0) elseif scrollRect == self.loop_RankReward then UTL.Item.SetItemCell(cellTable.item, data.Item, data.ItemNum) end end function UISuperGoldBossMain:OnCellSelect(scrollRect, index, cellTable, data) if scrollRect == self.loop_DifficultList then cellTable.state_Btn:SetState(data.BossLevel == self.difficultLevel and 1 or 0) end end function UISuperGoldBossMain:OnCellClicked(scrollRect, index, cellTable, target, data) if scrollRect == self.loop_DifficultList then if target == cellTable.btn_DifficultLevel then self:RefreshDifficultLevelInfo(data) end elseif scrollRect == self.loop_RankReward then if target == cellTable.item.event_Click then UTL.ItemTips.ShowCommonTipsById(data.Item) end end end function UISuperGoldBossMain:RefreshDifficultLevelInfo(data) self.difficultLevel = data.BossLevel self.txt_Power.text = CTL.GoldenHeroBoss.GetSubjugateGsText(data.RecommendGS) self.txt_DifficultLevel.text = data.BossLevel self:ShowDifficultList(false) end function UISuperGoldBossMain:RefreshRewardRp(active) self.btn_TimesReward:SetRedPoint(active) end function UISuperGoldBossMain:RefreshItemEnoughRp(active) self.btn_Fight:SetRedPoint(active) self.btn_Sweep:SetRedPoint(active and MDL.SuperGoldBoss.GetMaxScore(self.activityId) > 0) end return UISuperGoldBossMain