local UISuperGoldHonorOrderMain = UIViewClass() function UISuperGoldHonorOrderMain:OnOpened(context) self.activityId = context.activityId self.heroType = context.heroType self:RegistSystemEvent(EventID.UI_OperationActivity_CloseView, self.OnCloseActivitySelf) self:RegistSystemEvent(EventID.UI_SuperGoldHonorOrder_RefreshReward, self.UpdateSuperGoldLevelInfo) -- 领奖后刷新界面 self:RegistSystemEvent(EventID.UI_OACommon_TaskRewardClaim, self.UpdateSuperGoldLevelInfo) -- 任务领奖后刷新界面 self:RegistSystemEvent(EventID.UI_SuperGoldHonorOrder_IsSeniorPlayUIEffect, self.ShowIsSeniorEffect) local modeData = DataSheetManager.SuperGoldActivityModeData:GetDataByHeroType(self.heroType) UIUtils.SetLabelText(self.UITemplateTitlePanel.lab_Title, Const_IDS[modeData.HonorOrderName]) -- 界面标题 self:UpdateSuperGoldLevelInfo() CTL.SuperGoldMain.SetIsOpenedActivity(self.activityId, true) end function UISuperGoldHonorOrderMain:OnCloseActivitySelf(viewClassPath, activityId) if viewClassPath == self.__viewClassPath then if self.activityId and activityId == self.activityId then self:CloseView(true) end end end function UISuperGoldHonorOrderMain: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 -- 玩法说明 UIManager.OpenView(Const_UI_Lua.UIEnum.UICommonNoteView, {id = LuaConst.NoteID.SuperGoldHonorOrder}) elseif comp == self.btn_Task or comp == self.btn_TaskLoc then -- 活动任务 CTL.SuperGoldHonorOrder.OpenSuperGoldHonorOrderTaskView(self.activityId, self.curHonorOrderInfo.HonorOrderId) elseif comp == self.btn_NormalClick then -- 普通奖励 UTL.ItemTips.ShowCommonTipsById(self.seniorItemData.OrdinaryItem) elseif comp == self.btn_HonorClick then -- 节点奖励 UTL.ItemTips.ShowCommonTipsById(self.seniorItemData.SeniorItem) else if MDL.SuperGoldHonorOrder.GetCurHonorOrderIsOpen(self.activityId) then if comp == self.btn_Get then -- 一键领取 if MDL.SuperGoldHonorOrder.CheckCanReceive(self.activityId) then MDL.SuperGoldHonorOrder.ClaimAllSubOrderRewardRequest(self.activityId) else CTL.Tips.AddTipsMsg(Const_IDS["IDS_HonorOrder_ZanWuJiangLi"]) -- 暂无可领奖励 end elseif comp == self.btn_Gold then -- 购买战令 if not self.isSenior then CTL.SuperGoldHonorOrder.OpenSuperGoldHonorOrderPurchaseView(self.activityId, self.heroType) end end else CTL.Tips.AddTipsMsg(Const_IDS["IDS_ERRORCODE_174_WarnCode_Activity_EndWrongHint"]) -- 活动已结束 end end end function UISuperGoldHonorOrderMain:UpdateSuperGoldLevelInfo() self.curHonorOrderInfo = MDL.SuperGoldHonorOrder.GetServerInfoByActivityID(self.activityId) self.curHonorOrderConstData = MDL.SuperGoldHonorOrder.GetCurHonorOrderConstData(self.curHonorOrderInfo.HonorOrderId) self.isSenior = self.curHonorOrderInfo.IsSenior self.isOpen = MDL.SuperGoldHonorOrder.GetCurHonorOrderIsOpen(self.activityId) UIUtils.SetLabel(self.txt_Progress, self.curHonorOrderInfo.HonorExp) -- 战令经验 UIUtils.SetActive(self.img_Lock, not self.isSenior) -- 是否购买战令 UIUtils.SetActive(self.btn_Get, self.isOpen and MDL.SuperGoldHonorOrder.CheckCanReceive(self.activityId)) -- 奖励领取完毕隐藏一键领取按钮 self.btn_Get:SetRedPoint(self.isOpen and MDL.SuperGoldHonorOrder.CheckCanReceive(self.activityId)) self.btn_Get:SetGray(not self.isOpen) self.btn_Task:SetRedPoint(self.isOpen and CTL.OACommon.IsHasTaskRedPoint(self.activityId)) self.btn_TaskLoc:SetRedPoint(self.isOpen and CTL.OACommon.IsHasTaskRedPoint(self.activityId)) self:RefreshLevelList() end function UISuperGoldHonorOrderMain:RefreshLevelList() self.loop_Reward:ClearCells() self.MaxRewardCount = DataSheetManager.SuperGoldHonorOrderReward[self.curHonorOrderInfo.HonorOrderId]:GetDataCount() for k,v in DataSheetManager.SuperGoldHonorOrderReward[self.curHonorOrderInfo.HonorOrderId]:GetEnumerator() do self.loop_Reward:AddData(v, 0) if v.Node == 1 then self:ShowSeniorItem(v) end end self.loop_Reward:MoveIndex(MDL.SuperGoldHonorOrder.GetMoveIndex(self.activityId) - 2) end --region ************************ Loop ******************************** function UISuperGoldHonorOrderMain:OnCellInit(scrollRect, index, cellTable, data) local isShowEffect = false -- 普通奖励 self:SetOrdinaryReward(cellTable, data) cellTable.effect_Normal:SetSortingCanvas(self.goup_SubCanvas) if self.isOpen and MDL.SuperGoldHonorOrder.IsCanReceiveByRewardType_Level(self.activityId, MDL.HonorOrder.RewardType.Ordinary, data.RewardID) then --cellTable.effect_Normal:PlayUIEffect() isShowEffect = true else --cellTable.effect_Normal:StopUIEffect() end -- 升阶奖励 self:SetAdvancedReward(cellTable, data) cellTable.effect_Honor:SetSortingCanvas(self.goup_SubCanvas) if self.isOpen and self.isSenior and MDL.SuperGoldHonorOrder.IsCanReceiveByRewardType_Level(self.activityId, MDL.HonorOrder.RewardType.Advanced, data.RewardID) then --cellTable.effect_Honor:PlayUIEffect() isShowEffect = true else --cellTable.effect_Honor:StopUIEffect() end cellTable.effect_Get:SetSortingCanvas(self.goup_SubCanvas) if isShowEffect then cellTable.effect_Get:PlayUIEffect() else cellTable.effect_Get:StopUIEffect() end self:ShowProgressBar(cellTable, data, isShowEffect) end function UISuperGoldHonorOrderMain:OnCellClicked(scrollRect, index, cellTable, target, data) if cellTable.btn_NormalClick == target then if MDL.SuperGoldHonorOrder.IsCanReceiveByRewardType_Level(self.activityId, MDL.HonorOrder.RewardType.Ordinary, data.RewardID) and (not MDL.SuperGoldHonorOrder.IsAlreadyReceivedByRewardType_Level(self.activityId, MDL.HonorOrder.RewardType.Ordinary, data.RewardID)) then if not MDL.SuperGoldHonorOrder.GetCurHonorOrderIsOpen(self.activityId) then UTL.ItemTips.ShowCommonTipsById(data.OrdinaryItem) return end MDL.SuperGoldHonorOrder.ClaimSubOrderRewardRequest(self.activityId, MDL.HonorOrder.RewardType.Ordinary, data.Exp) else UTL.ItemTips.ShowCommonTipsById(data.OrdinaryItem) end elseif cellTable.btn_HonorClick == target then if self.isSenior and MDL.SuperGoldHonorOrder.IsCanReceiveByRewardType_Level(self.activityId, MDL.HonorOrder.RewardType.Advanced, data.RewardID) and (not MDL.SuperGoldHonorOrder.IsAlreadyReceivedByRewardType_Level(self.activityId, MDL.HonorOrder.RewardType.Advanced, data.RewardID)) then if not MDL.SuperGoldHonorOrder.GetCurHonorOrderIsOpen(self.activityId) then UTL.ItemTips.ShowCommonTipsById(data.SeniorItem) return end MDL.SuperGoldHonorOrder.ClaimSubOrderRewardRequest(self.activityId, MDL.HonorOrder.RewardType.Advanced, data.Exp) else UTL.ItemTips.ShowCommonTipsById(data.SeniorItem) end end end --endregion ************************ Loop ******************************** function UISuperGoldHonorOrderMain:ShowSeniorItem(data) self.seniorItemData = data self:SetOrdinaryReward(self, data) self:SetAdvancedReward(self, data) end function UISuperGoldHonorOrderMain:SetOrdinaryReward(cellTable, data) UTL.Item.SetStoreGoodsQualityImg(data.OrdinaryItem, cellTable.img_NormalItem, nil, cellTable.img_NormalBg) -- 普通奖励图标 UIUtils.SetLabel(cellTable.txt_NormalCount, data.OrdinaryNum) -- 普通奖励数量 local commonRewardIsGet = MDL.SuperGoldHonorOrder.IsAlreadyReceivedByRewardType_Level(self.activityId, MDL.HonorOrder.RewardType.Ordinary, data.RewardID) if commonRewardIsGet then cellTable.UIState_Nor:SetState(0) -- 已领取 else if data.RewardID > self.curHonorOrderInfo.HonorLv then cellTable.UIState_Nor:SetState(1) -- 未解锁 else cellTable.UIState_Nor:SetState(2) -- 可领取 end end end function UISuperGoldHonorOrderMain:SetAdvancedReward(cellTable, data) UTL.Item.SetStoreGoodsQualityImg(data.SeniorItem, cellTable.img_HonorItem, nil, cellTable.img_HonorBg) -- 高级奖励图标 UIUtils.SetLabel(cellTable.txt_HonorCount, data.SeniorNum) -- 高级奖励数量 if self.isSenior then local seniorRewardIsGet = MDL.SuperGoldHonorOrder.IsAlreadyReceivedByRewardType_Level(self.activityId, MDL.HonorOrder.RewardType.Advanced, data.RewardID) if seniorRewardIsGet then cellTable.UIState_Hon:SetState(0) else if data.RewardID > self.curHonorOrderInfo.HonorLv then cellTable.UIState_Hon:SetState(1) else cellTable.UIState_Hon:SetState(3) end end else cellTable.UIState_Hon:SetState(2) end end function UISuperGoldHonorOrderMain:ShowProgressBar(cellTable, data, isShowEffect) -- 经验和进度条 UIUtils.SetLabel(cellTable.txt_Title, data.Exp) -- 战令经验 if isShowEffect then cellTable.effect_Reward:PlayUIEffect() else cellTable.effect_Reward:StopUIEffect() end if self.curHonorOrderInfo.HonorLv == self.MaxRewardCount then -- 最大等级了 cellTable.Fill01.fillAmount = 1 cellTable.Fill02.fillAmount = 1 elseif self.curHonorOrderInfo.HonorLv == 0 then -- 没有等级 if data.RewardID == 1 then cellTable.Fill01.fillAmount = self.curHonorOrderInfo.HonorExp / data.Exp else cellTable.Fill01.fillAmount = 0 end cellTable.Fill02.fillAmount = 0 else if self.curHonorOrderInfo.HonorLv >= data.RewardID then -- 当前战令等级大于cell等级 cellTable.Fill01.fillAmount = 1 if self.curHonorOrderInfo.HonorExp > data.Exp then local nextRewardInfo = DataSheetManager.SuperGoldHonorOrderReward[self.curHonorOrderInfo.HonorOrderId]:GetDataByRewardID(data.RewardID + 1) local difference = (nextRewardInfo.Exp - data.Exp) / 2 if self.curHonorOrderInfo.HonorExp >= (difference + data.Exp) then cellTable.Fill02.fillAmount = 1 else cellTable.Fill02.fillAmount = (difference + data.Exp - self.curHonorOrderInfo.HonorExp) / difference end else cellTable.Fill02.fillAmount = 0 end else local lastRewardInfo = DataSheetManager.SuperGoldHonorOrderReward[self.curHonorOrderInfo.HonorOrderId]:GetDataByRewardID(data.RewardID - 1) local difference = (data.Exp - lastRewardInfo.Exp) / 2 if self.curHonorOrderInfo.HonorExp <= (difference + lastRewardInfo.Exp) then cellTable.Fill01.fillAmount = 0 else cellTable.Fill01.fillAmount = (self.curHonorOrderInfo.HonorExp - (difference + lastRewardInfo.Exp)) / difference end cellTable.Fill02.fillAmount = 0 end end cellTable.State_Fill:SetState(self.curHonorOrderInfo.HonorLv >= data.RewardID and 1 or 0) end function UISuperGoldHonorOrderMain:ShowIsSeniorEffect() self.effect_IsSenior:PlayUIEffect() end return UISuperGoldHonorOrderMain