local UINobilityContentPicture = UIViewClass() function UINobilityContentPicture:OnOpened(context) self:RegistSystemEvent(EventID.UI_Nobility_RefreshSecondStageActive,self.RefreshActivity) self:RegistSystemEvent(EventID.UI_Nobility_RefreshStageUp, self.RefreshUI) self:RegistSystemEvent(EventID.UI_Nobility_RefreshPanel, self.RefreshUI) self:RefreshUI() end function UINobilityContentPicture:OnButtonClicked(comp) if self.btn_Activate == comp then local curCount, configCount = MDL.Nobility.GetProgress() if curCount < configCount then CTL.Tips.AddTipsMsg(Const_IDS.IDS_Nobility_Tips2) else MDL.Nobility.NobilityStageUpRequest(MDL.Nobility.Enum_Stage.First) end elseif self.btn_NextPhase == comp then local curCount, configCount = MDL.Nobility.GetProgress() if curCount < configCount then CTL.Tips.AddTipsMsg(Const_IDS.IDS_Nobility_Tips6) else MDL.Nobility.NobilityStageUpRequest(MDL.Nobility.Enum_Stage.second) end else for k,v in ipairs(self.array_Activity) do if v.btn_Train == comp then if MDL.Player.GetRoleLevelExp() >= self.activityConfig[k].UseExp then if k == 1 or (k > 1 and self.stateList[k - 1]) then MDL.Nobility.NobilitySecondStageActiveRequest(self.activityConfig[k].SubStageID) else CTL.Tips.AddTipsMsg(Const_IDS.IDS_Nobility_Tips5) end else CTL.Tips.AddTipsMsg(Const_IDS.IDS_Nobility_ActivationNotEnough) end end end end end function UINobilityContentPicture:OnCellInit(scrollRect, index, cellTable, data) if scrollRect == self.loop_Goals then local curCount, configCount if data.triggerData.UnlockCondition == LuaConst.TriggerType.Team_Level then curCount = UTL.Item.GetNobilityByTeamLevel(data.param) -- 爵位转换 configCount = UTL.Item.GetNobilityByTeamLevel(tonumber(data.triggerData.UnlockConditionParamA)) -- 爵位转换 else curCount, configCount = data.param, data.triggerData.UnlockConditionParamA end UIUtils.SetLabel(cellTable.txt_Goal, MDL.Unlock.GetDesByTriggerID(data.triggerData)..string.format(" (%s/%s)", curCount, configCount)) local isPass = data.param >= tonumber(data.triggerData.UnlockConditionParamA) UIUtils.SetActive(cellTable.img_Mark.gameObject, isPass) UIUtils.SetActive(cellTable.btn_Go.gameObject, (not isPass) and data.triggerData.ItemSourceID > 0) cellTable.stateSwitch:SetState(isPass and 1 or 0) end end function UINobilityContentPicture:OnCellClicked(scrollRect, index, cellTable, target, data) if scrollRect == self.loop_Goals then if target == cellTable.btn_Go then --处理一个前往的逻辑 local unlockId = DataSheetManager.ItemSource:GetDataByID(data.triggerData.ItemSourceID).UnlockID if unlockId > 0 and not MDL.Unlock.IsUnlock(unlockId) then CTL.Tips.AddTipsMsg(Const_IDS["IDS_7DayActivity_Hint_6"]) return end CTL.ItemSources.ExecuteSourceFunctionById(data.triggerData.ItemSourceID) end end end function UINobilityContentPicture:RefreshUI() self.currentStage = MDL.Nobility.GetStage() if self.currentStage == 0 then self.stateSwitch_group:SetState(0) self:RefreshGoals() elseif self.currentStage == 1 then self.stateSwitch_group:SetState(1) self:RefreshActivity() else self:CloseView() end end local function taskSort(a,b) if a.state == b.state then return a.index < b.index end return a.state < b.state end -- 进爵第一阶段 function UINobilityContentPicture:RefreshGoals() local stage1Config, triggerIDConfig = MDL.Nobility.GetStage1Config() local AttributeList = stage1Config.Attr_Table for i = 1, #self.group_Attribute do if AttributeList[i] then UIUtils.SetLabelText(self.group_Attribute[i].txt_Feature, Const_IDS[DataSheetManager.AttrData:GetDataByID(AttributeList[i].AttrType).Name]) UIUtils.SetLabel(self.group_Attribute[i].txt_Number, "+"..AttributeList[i].AttrNum) UIUtils.SetActive(self.group_Attribute[i].gameObject, true) else UIUtils.SetActive(self.group_Attribute[i].gameObject, false) end end local itemData = {} local params = MDL.Nobility.GetStageParams() for i = 1, #triggerIDConfig do table.insert(itemData, {index = i, triggerData = triggerIDConfig[i], param = params[i], state = params[i] >= tonumber(triggerIDConfig[i].UnlockConditionParamA) and 1 or 0}) end table.sort(itemData, taskSort) if self.loop_Goals.Count > 0 then self.loop_Goals:ClearCells() end for i, v in ipairs(itemData) do self.loop_Goals:AddData(v, 0) end if #triggerIDConfig <= 3 then -- 小于6个不能滑动 self.loop_Goals:SetMovementType(3) else self.loop_Goals:SetMovementType(1) end self.btn_Activate:SetRedPoint(MDL.Nobility.GetRedPoint()) end -- 进爵第二阶段 function UINobilityContentPicture:RefreshActivity() local curExp = MDL.Player.GetRoleLevelExp() UIUtils.SetLabel(self.txt_CurrentEXP, string.format(UIUtils.GetLocalizedTxt(Const_IDS.IDS_Nobility_CurrentTeamExp), curExp)) -- 当前经验 self.activityConfig = MDL.Nobility.GetStage2Config() local state2Param = MDL.Nobility.GetStageParams() self.stateList = {} for _, Cfg in ipairs(self.activityConfig) do self.stateList[Cfg.SubStage] = false for _,id in ipairs(state2Param) do if Cfg.SubStageID == id then self.stateList[Cfg.SubStage] = true end end end for k,v in ipairs(self.array_Activity) do UIUtils.SetLabelText(v.txt_AttitudeName_1, Const_IDS[DataSheetManager.AttrData:GetDataByID(self.activityConfig[k].Attr_Table[1].AttrType).Name]) UIUtils.SetLabel(v.txt_AttitudeNumber_1, "+"..tostring(self.activityConfig[k].Attr_Table[1].AttrNum)) UIUtils.SetLabelText(v.txt_AttitudeName_2, Const_IDS[DataSheetManager.AttrData:GetDataByID(self.activityConfig[k].Attr_Table[2].AttrType).Name]) UIUtils.SetLabel(v.txt_AttitudeNumber_2, "+"..tostring(self.activityConfig[k].Attr_Table[2].AttrNum)) local exp = self.activityConfig[k].UseExp if curExp < exp then exp = UTL.Color.FormatRedColor(exp) else exp = UTL.Color.FormatWhiteColor(exp) end UIUtils.SetLabel(v.txt_ExpNumber, exp) UIUtils.SetActive(v.group_Exp.gameObject, false) UIUtils.SetActive(v.img_Icon, true) if #state2Param == 0 then v.stateSwitch_txt:SetState(0) if k == 1 then v.stateSwitch_Icon:SetState(2) UIUtils.SetActive(v.group_Exp.gameObject, true) else v.stateSwitch_Icon:SetState(1) end elseif #state2Param > 0 then if k == 1 and not self.stateList[k] then v.stateSwitch_Icon:SetState(2) UIUtils.SetActive(v.group_Exp.gameObject, true) else if self.stateList[k] then v.stateSwitch_txt:SetState(1) v.stateSwitch_Icon:SetState(0) UIUtils.SetActive(v.img_Icon, false) else v.stateSwitch_txt:SetState(0) if k > 1 and self.stateList[k - 1] then v.stateSwitch_Icon:SetState(2) UIUtils.SetActive(v.group_Exp.gameObject, true) else v.stateSwitch_Icon:SetState(1) end end end end end local currentCont, configCount = MDL.Nobility.GetProgress() self.btn_NextPhase:SetRedPoint(currentCont >= configCount) end return UINobilityContentPicture