local UISoloFightPanel = UIViewClass() local DelayTime = 0.1 local SweepLevel = DataSheetManager.ConstData:GetDataByID("OfflineSoloSweepUnlockLevel").IntValue local EventSystem = require('Event/EventSystem') local ConstShowParams = { [1] = { posX = 1.6, posY = -0.7, scale = 0.55 }, [2] = { posX = 0.7, posY = -0.7, scale = 0.55 }, [3] = { posX = -0.2, posY = -0.7, scale = 0.55 }, [4] = { posX = -1.1, posY = -0.7, scale = 0.55 }, [5] = { posX = -2, posY = -0.7, scale = 0.55 }, } local ConstShowParams_RatioPad4_3 = { [1] = { posX = 1.2, posY = -0.65, scale = 0.45 }, [2] = { posX = 0.5, posY = -0.65, scale = 0.45 }, [3] = { posX = -0.2, posY = -0.65, scale = 0.45 }, [4] = { posX = -0.9, posY = -0.65, scale = 0.45 }, [5] = { posX = -1.6, posY = -0.65, scale = 0.45 }, } local ConstShowParams_RatioPadOther = { [1] = { posX = 1.5, posY = -0.65, scale = 0.45 }, [2] = { posX = 0.7, posY = -0.65, scale = 0.45 }, [3] = { posX = -0.2, posY = -0.65, scale = 0.45 }, [4] = { posX = -1, posY = -0.65, scale = 0.45 }, [5] = { posX = -1.9, posY = -0.65, scale = 0.45 }, } local ConstLightPath = ConstAssetPathConfig.LightLeft function UISoloFightPanel:OnCreated() self.offlineSoloRewardNum = DataSheetManager.ConstData:GetDataByID("OfflineSoloRewardNum").IntValue self.offlineSoloReward = DataSheetManager.ConstData:GetDataByID("OfflineSoloReward").IntListValue self:RegistSystemEvent(EventID.UI_Solofight_RankDetail_Refresh,self.RefreshPlayer) self:RegistSystemEvent(EventID.UI_PurchaseNumsSuccess, self.RefreshEnterTimes) self:RegistSystemEvent(EventID.UI_Solofight_EventInfo_Refresh,self.OnEventRefresh) self:RegistSystemEvent(EventID.EnterFuben_RespError,self.OnRankChange) self:RegistSystemEvent(EventID.UI_RefreshOfficialPositionInfo,self.OnOfficialPositionInfoRefresh) self:RegistSystemEvent(EventID.UI_Solofight_RewardProgress_Refresh, self.RefreshRewardProgress) end function UISoloFightPanel:OnOpened(context) -- 界面标题 UIUtils.SetLabelText(self.UITemplateTitlePanel.lab_Title, Const_IDS["IDS_OfflineSoloFight_ActivetyName"]) self:InitScene() self:RefreshPromotionData() if context then MDL.SoloFight.SoloFightRankDetailsReq(context.index) else MDL.SoloFight.SoloFightRankDetailsReq() end MDL.SoloFight.EventInfoReq() self:RefreshEnterTimes() self:InitRewardProgress() self.btn_Sweep:SetGray(true,true) if MDL.HeroSelect.GetTeamLevel() >= SweepLevel then UIUtils.SetGray(self.img_sweep, false) else UIUtils.SetGray(self.img_sweep, true) end UIManager.ActiveUIModle(false, "UISoloFightPanel") end function UISoloFightPanel:InitScene() self.modelComponentDataHandle = UTL.UIRender.CreateModelComponentDatas(self.obj_Model) UTL.UIRender.Create2DSceneTrans(self.modelComponentDataHandle, ConstAssetPathConfig.Common2DScenePrefab, 1600, 0, 1600, ConstAssetPathConfig.SoloFightBg, true) UTL.UIRender.SetHeroParentPos(self.modelComponentDataHandle, 0.2, 0, 0) -- 设置模型位移信息 end function UISoloFightPanel:LoadHeroModel() self.loadModelIndex = self.loadModelIndex + 1 local showInfo = self.showInfos[self.loadModelIndex] if showInfo then local resolutionRatio = UIUtils.GetScreenResolutionRatio() if resolutionRatio == LuaConst.ScreenResolutionRatio.RatioPad4_3 then UTL.UIRender.DelayLoadMultiBattleModel(self.modelComponentDataHandle, showInfo, ConstShowParams_RatioPad4_3[self.loadModelIndex], ConstLightPath) elseif resolutionRatio == LuaConst.ScreenResolutionRatio.RatioPadOther then UTL.UIRender.DelayLoadMultiBattleModel(self.modelComponentDataHandle, showInfo, ConstShowParams_RatioPadOther[self.loadModelIndex], ConstLightPath) else UTL.UIRender.DelayLoadMultiBattleModel(self.modelComponentDataHandle, showInfo, ConstShowParams[self.loadModelIndex], ConstLightPath) end else self:StopRepeatFunc(self.LoadHeroModel) end end function UISoloFightPanel:RefreshPromotionData() local titleData = MDL.OfficialPosition.GetCurTitleData() local officialPVPGradeID = DataSheetManager.ConstData:GetDataByID("OfficialPVPGradeID").IntValue if titleData and titleData.GradeID < officialPVPGradeID then self.PromotionData = DataSheetManager.OfficialPositionPromotion:GetDataByGradeID(titleData.GradeID) end end function UISoloFightPanel:OnOfficialPositionInfoRefresh() self:RefreshPromotionData() MDL.SoloFight.SoloFightRankDetailsReq(self.arrayIdList and self.arrayIdList[1].rankIdx) end function UISoloFightPanel:OnBackButtonPressed() self:OnButtonClicked(self.UITemplateTitlePanel.btn_close) end function UISoloFightPanel:OnButtonClicked(comp) if comp == self.btn_Rank then CTL.OfficialPosition.OpenSoloRank() elseif comp == self.btn_Reward then UIManager.OpenView(Const_UI_Lua.UIEnum.UISoloFightReward) elseif comp == self.btn_Shop then --商店跳转 UIManager.OpenAndPushAll(Const_UI_Lua.UIEnum.UIShopMain,{TabEnum = CTL.PayMall.ShopMainTabEnum.YanWu}) elseif comp == self.btn_Msg then -- 事件按钮 UIManager.OpenView(Const_UI_Lua.UIEnum.UISoloFightMsg,self.eventList) self.btn_Msg:SetRedPoint(false) elseif comp == self.btn_EnterTeam then self.context = {index = self.arrayIdList[1].rankIdx} UIManager.OpenAndPush(Const_UI_Lua.UIEnum.UICommonLineUpView, {functionType = MDL.Unlock.FunctionType.SoloFight}, Const_UI_Lua.UIEnum.UIArray, Const_UI_Lua.UIEnum.UISoloFightPanel) elseif comp == self.btn_Click then CTL.SoloFight.OpenTimeUpView() elseif comp == self.UITemplateTitlePanel.btn_Info then local timeStr = UTL.Time.GetDiffLocalStrById(1503) UIManager.OpenView(Const_UI_Lua.UIEnum.UICommonNoteView, {id = LuaConst.NoteID.OfflineSolo, params = {timeStr}}) elseif comp == self.UITemplateTitlePanel.btn_close then self:CloseView(true) elseif comp == self.UITemplateTitlePanel.btn_Home then CTL.HomeMain.CloseViewBackHomeMain() elseif comp == self.btn_ArrowLeft then self:ShowPre() elseif comp == self.btn_ArrowRight then self:ShowNext() elseif comp == self.group_Gift.btn_Close then UIUtils.SetActive(self.group_Gift.obj_Reward, false) elseif comp == self.btn_Sweep then if MDL.HeroSelect.GetTeamLevel() >= SweepLevel then MDL.SoloFight.SoleFightSweepReq() else local tlData = DataSheetManager.TeamLevelData:GetDataByTeamLevel(SweepLevel) if tlData ~= nil then local _levelStr = UTL.Item.GetNobilityByTeamLevel(tlData.TeamLevel) -- 爵位转换 local teamLevelName = string.FormatByIdsId(Const_IDS[tlData.TeamLevelName], _levelStr) CTL.Tips.AddTipsMsg(string.FormatByIdsId(Const_IDS.IDS_DemonGod_UI_51, teamLevelName)) end end else -- 奖励列表 local rewardNum = MDL.SoloFight.GetSoloFightRewardNum() for i, v in ipairs(self.group_Gift.group_Chest) do if comp == v.event_Reward then if i <= rewardNum and not MDL.SoloFight.HasReceiveRewardByIndex(i) then MDL.SoloFight.SoleFightRewardReq(i) else UIUtils.SetActive(self.group_Gift.obj_Reward, true) self.group_Gift.ChestRewardScroll:ClearCells() for i = 1, #self.offlineSoloReward, 2 do self.group_Gift.ChestRewardScroll:AddData({itemId = self.offlineSoloReward[i], itemNum = self.offlineSoloReward[i + 1]} , 0) end self.group_Gift.info_Reward.transform:SetPosition(v.obj_showRewardPos:GetPosition()) end end end -- 英雄点位 for i,v in ipairs(self.group_Position) do if v.btn_Challenge == comp then local acid, rankIndex = self:GetFightReqInfo(i) MDL.SoloFight.FightReq(acid, rankIndex) elseif v.btn_Details == comp then local accId = self:GetFightReqInfo(i) CTL.PlayerInteract.OpenFriendInteractView(accId) end end end end function UISoloFightPanel:OnCellInit(scrollRect, index, cellTable, data) if scrollRect == self.group_Gift.ChestRewardScroll then UTL.Item.SetItemCell(cellTable.item, data.itemId, data.itemNum) end end function UISoloFightPanel:OnCellClicked(scrollRect, index, cellTable, target, data) if scrollRect == self.group_Gift.ChestRewardScroll then UTL.ItemTips.ShowCommonTipsById(data.itemId) end end function UISoloFightPanel:GetFightReqInfo(index) local info = self.arrayIdList[index] return info.modelInfo.acid, info.rankIdx end function UISoloFightPanel:RefreshEnterTimes() local totalTimes = DataSheetManager.ActivityData:GetDataByID(LuaConst.ActivityType.OffLineSoloFight).DailyRefreshTimes --只显示基础次数 local leftTimes = MDL.SoloFight.GetSoloFightLeftTimes() local str if leftTimes == 0 then str = UTL.Color.FormatRedColor(0) .. "/" .. totalTimes else str = leftTimes .. "/" .. totalTimes end UIUtils.SetLabel(self.txt_Times, str) end function UISoloFightPanel:SetPlayerInfo(index,data) self.group_Position[index].lab_Rank.text = data.rank self.group_Position[index].lab_Name.text = data.name self.group_Position[index].txt_CE.text = data.gs end function UISoloFightPanel:ShowPre() MDL.SoloFight.SoloFightRankDetailsReq(self.arrayIdList[1].rankIdx-5) end function UISoloFightPanel:ShowNext() MDL.SoloFight.SoloFightRankDetailsReq(self.arrayIdList[5].rankIdx+1) end function UISoloFightPanel:LoadHeroModel() self.loadIndex = self.loadIndex + 1 local data = self.arrayIdList[self.loadIndex] if data then local modelInfo = data.modelInfo if modelInfo.acid == BattleDataGetter.GetAcID() then -- 实时刷新自己最新数据 更新服务器结构数据 local heroInfo = MDL.HeroSelect.GetHeroInfo(MDL.Player.GetCurShowId()) modelInfo.HeroBreakNums = heroInfo.starLevel modelInfo.IsActiveMagicWeapon = heroInfo.isMagicWeaponActive modelInfo.MagicWeaponBreak = heroInfo.magicWeaponLevel modelInfo.mainHeroId = MDL.Player.GetCurShowId() modelInfo.gsSum = MDL.Player.GetLineUpGs() modelInfo.HeroAppearanceID = heroInfo.curAppearanceId modelInfo.WeaponAppearanceID = heroInfo.curWeaponAppearanceId end self:SetPlayeInfo(self.group_Position[self.loadIndex], data) local resolutionRatio = UIUtils.GetScreenResolutionRatio() if resolutionRatio == LuaConst.ScreenResolutionRatio.RatioPad4_3 then UTL.UIRender.DelayLoadMultiBattleModel(self.modelComponentDataHandle, modelInfo, ConstShowParams_RatioPad4_3[self.loadIndex], ConstLightPath) elseif resolutionRatio == LuaConst.ScreenResolutionRatio.RatioPadOther then UTL.UIRender.DelayLoadMultiBattleModel(self.modelComponentDataHandle, modelInfo, ConstShowParams_RatioPadOther[self.loadIndex], ConstLightPath) else UTL.UIRender.DelayLoadMultiBattleModel(self.modelComponentDataHandle, modelInfo, ConstShowParams[self.loadIndex], ConstLightPath) end else self:StopRepeatFunc(self.LoadHeroModel) end end function UISoloFightPanel:RefreshPlayer(msg) self.arrayIdList = msg.rankDetailInfo --MDL.Player.GetHeroLinUpIds() self.selfRankIdx = msg.selfRankIdx self:StopRepeatFunc(self.LoadHeroModel) if self.modelComponentDataHandle then UTL.UIRender.DisposePlayerModel(self.modelComponentDataHandle) end self.loadIndex = 0 self:StartRepeatFunc(self.LoadHeroModel, DelayTime, -1) UIUtils.SetActive(self.btn_ArrowLeft, self.arrayIdList[1].rankIdx ~= 1) UIUtils.SetActive(self.btn_ArrowRight, self.arrayIdList[#self.arrayIdList].rankIdx ~= msg.totalNum) for i=#self.arrayIdList + 1,5 do UIUtils.SetActive(self.group_Position[i].gameObject,false) end --官职相关 if self.PromotionData == nil or self.PromotionData.DegradationNum == -1 then self.txt_TimeDesc.text = nil self.txt_conditionDesc.text = nil else --结算倒计时 local leftTime = 0 for _, v in ipairs(self.PromotionData.DegradationTime) do local offsetTime = UTL.Time.GetServerIntervalNextTimeByTimeId(v) if leftTime == 0 then leftTime = offsetTime else if leftTime > offsetTime then leftTime = offsetTime end end end local timeFormat = UTL.Color.FormatRedColor("{0}:{1}:{2}") local content = UIUtils.GetLocalizedTxt(Const_IDS.IDS_OfficialPosition_CdOfQualityReduction) .. timeFormat self.cdTime:ResetAndBeginCustomTimer(false, leftTime, 0, content, 1) --降品条件 if self.PromotionData.DegradationNum == 0 then self.txt_conditionDesc.text = UIUtils.GetLocalizedTxt(Const_IDS.IDS_OfficialPosition_ConditionOfQualityReduction1) .. UIUtils.GetLocalizedTxt(Const_IDS.IDS_OfficialPosition_Everyone) else self.txt_conditionDesc.text = UIUtils.GetLocalizedTxt(Const_IDS.IDS_OfficialPosition_ConditionOfQualityReduction1) .. string.FormatByIdsId(Const_IDS.IDS_OfficialPosition_ConditionOfQualityReduction2, self.PromotionData.DegradationNum) end end end function UISoloFightPanel:SetPlayeInfo(collection,info) UIUtils.SetActive(collection.gameObject,true) collection.lab_Rank.text = info.rankIdx collection.lab_Name.text = info.modelInfo.name collection.txt_CE.text = info.modelInfo.gsSum --logging.log(LTAG.LOG," SetPlayeInfo ", info.modelInfo.acid == BattleDataGetter.GetAcID()) if info.modelInfo.acid == BattleDataGetter.GetAcID() then UIUtils.SetActive(collection.btn_Challenge, false) else local isBattle = CTL.SoloFight.CanBattleByRankAndOffline(info.rankIdx, self.selfRankIdx) and not (info.modelInfo.acid == BattleDataGetter.GetAcID()) UIUtils.SetActive(collection.btn_Challenge, isBattle) collection.obj_challengeState:SetState(0) end if info.modelInfo.acid == BattleDataGetter.GetAcID() then collection.state:SetState(1) else collection.state:SetState(0) end --降品标识 if self.PromotionData == nil or self.PromotionData.DegradationNum == -1 then UIUtils.SetActive(collection.img_Jiang, false) else UIUtils.SetActive(collection.img_Jiang, info.rankIdx > self.PromotionData.DegradationNum) end --势力显示 local guildName = info.modelInfo.guildName if string.isNilOrEmpty(guildName) then UIUtils.SetActive(collection.group_Guild.gameObject, false) else UIUtils.SetActive(collection.group_Guild.gameObject, true) CTL.Guild.SetGuildEmblem(collection.group_Guild.img_Guild, collection.group_Guild.txt_Guild, info.modelInfo.EmblemFrame, info.modelInfo.EmblemContent) collection.group_Guild.txt_Name.text = CTL.Guild.GetColorGuildName(info.modelInfo.guildId, guildName) end end function UISoloFightPanel:OnEventRefresh(list,isRed) self.eventList = list self.btn_Msg:SetRedPoint(isRed) end function UISoloFightPanel:OnRankChange() MDL.SoloFight.SoloFightRankDetailsReq(self.arrayIdList[1].rankIdx) end function UISoloFightPanel:GetHeroModelTransform(index) local parent = UnityEngine.GameObject.Find(ConstAssetPathConfig.Path37) parent = parent.transform:Find("Hero"..index) return parent end function UISoloFightPanel:InitRewardProgress() UIUtils.SetActive(self.group_Gift.obj_Reward, false) for i = 1, self.offlineSoloRewardNum do local item = self.group_Gift.group_Chest[i] if not item then item = self:InstantiateCollection(self.group_Gift.group_Chest, self.group_Gift.template_Chest.gameObject) end UIUtils.SetActive(item.gameObject, true) UIUtils.SetLabel(item.lab_Reward, i) end for i = self.offlineSoloRewardNum + 1, #self.group_Gift.group_Chest do UIUtils.SetActive(self.group_Gift.group_Chest[i].gameObject, false) end self:RefreshRewardProgress() end function UISoloFightPanel:RefreshRewardProgress() local rewardNum = MDL.SoloFight.GetSoloFightRewardNum() -- 领奖进度 UIUtils.SetLabel(self.group_Gift.txt_TotalPoint, string.FormatByIdsId(Const_IDS.IDS_OfflineSolo_RewardNum, math.max(0, self.offlineSoloRewardNum - rewardNum), self.offlineSoloRewardNum)) UIUtils.SetAtlasImageFillAmount(self.group_Gift.Fill, rewardNum / self.offlineSoloRewardNum) -- 领奖状态 for i, item in ipairs(self.group_Gift.group_Chest) do if rewardNum < i then item.effect_Chest:StopUIEffect() item.state_Chest:SetState(0) else if MDL.SoloFight.HasReceiveRewardByIndex(i) then item.effect_Chest:StopUIEffect() item.state_Chest:SetState(2) else item.effect_Chest:PlayUIEffect() item.state_Chest:SetState(1) end end end end function UISoloFightPanel:OnClosed() if self.modelComponentDataHandle then UTL.UIRender.DisposeModelComponentData(self.modelComponentDataHandle) end EventSystem.Dispatch(EventID.UI_Activity_Refresh_ListOrder) UIManager.ActiveUIModle(true, "UISoloFightPanel") end return UISoloFightPanel