---@class KLArcWeapActivityPanel:UIKmlLuaPanelBase ---@field view KLArcWeapActivityPanelView local KLArcWeapActivityPanel = class(UIKmlLuaPanelBase) local this =KLArcWeapActivityPanel function this:AsyncLoadUI() end ---创建时调用一次 function this:Init() self.showSmallList = {} GUI:DataListInitData(self.view.showInfoList, function() return self:GetAllShowGoods() end,function() end,function() end, function(realIndex) self:ItemUpdateFun(realIndex) end) end function this:GetAllShowGoods() return table.count(self.showSmallList) end function this:ItemUpdateFun(realIndex) local data = self.showSmallList[realIndex + 1] local item1 = GUI:GetChildControl(self.view.showInfoList, realIndex, 'item1') local txt_count1 = GUI:GetChildControl(self.view.showInfoList, realIndex, 'txt_count1') local img_jia1 = GUI:GetChildControl(self.view.showInfoList, realIndex, 'img_jia1') local item2 = GUI:GetChildControl(self.view.showInfoList, realIndex, 'item2') local txt_count2 = GUI:GetChildControl(self.view.showInfoList, realIndex, 'txt_count2') local img_jia2 = GUI:GetChildControl(self.view.showInfoList, realIndex, 'img_jia2') local item3 = GUI:GetChildControl(self.view.showInfoList, realIndex, 'item3') local txt_count3 = GUI:GetChildControl(self.view.showInfoList, realIndex, 'txt_count3') local item4 = GUI:GetChildControl(self.view.showInfoList, realIndex, 'item4') local txt_count4 = GUI:GetChildControl(self.view.showInfoList, realIndex, 'txt_count4') local btn_GoOrGet = GUI:GetChildControl(self.view.showInfoList, realIndex, 'btn_GoOrGet') local txt_alreadyGet = GUI:GetChildControl(self.view.showInfoList, realIndex, 'txt_alreadyGet') --获取所有消耗道具 local reward = data.weapCdgData.angelWeaponTask local tmpReward = data.itemList local showReward = {} for _, v1 in pairs(reward) do local cfg = {} cfg.itemId = v1[1] cfg.needCount = v1[2] cfg.ownerCount = 0 for k, v2 in pairs(tmpReward) do if v1[1] == tonumber(k) then cfg.ownerCount = v2 end end table.insert(showReward,cfg) end item1.kmlControl:HideAllChilds() local itemData1 = showReward[1] local data1 = {width = "70",height = "70",itemid = itemData1.itemId,mfixsize = "70,70",itemcount = nil,bgtype = "0",raycast="1",} self.item1 = GUI:Item_Create(item1, data1) GUI:AddOnClickEvent(self.item1, self, function() SL:OpenTips(nil, itemData1.itemId) end) item4.kmlControl:HideAllChilds() local itemData4 = data.weapCdgData.angelWeaponReward[1] --奖励展示 local data4 = {width = "70",height = "70",itemid = itemData4[1],mfixsize = "70,70",itemcount = nil,bgtype = "0",raycast="1",} self.item4 = GUI:Item_Create(item4, data4) GUI:AddOnClickEvent(self.item4, self, function() SL:OpenTips(nil, itemData4[1]) end) local color1 = itemData1.ownerCount >= itemData1.needCount and EColor[EGradColor.green] or EColor[EGradColor.red] local str1 = string.format("%s/%s", color1, itemData1.ownerCount, itemData1.needCount) GUI:Text_setString(txt_count1, str1) GUI:Text_setString(txt_count4, tostring(itemData4[2])) GUI:SetActive(img_jia1,false) GUI:SetActive(item2,false) GUI:SetActive(txt_count2,false) if table.count(showReward) >= 2 then GUI:SetActive(img_jia1,true) GUI:SetActive(item2,true) GUI:SetActive(txt_count2,true) item2.kmlControl:HideAllChilds() local itemData2 = showReward[2] local data2 = {width = "70",height = "70",itemid = itemData2.itemId,mfixsize = "70,70",itemcount = nil,bgtype = "0",raycast="1",} self.item2 = GUI:Item_Create(item2, data2) GUI:AddOnClickEvent(self.item2, self, function() SL:OpenTips(nil, itemData2.itemId) end) local color2 = itemData2.ownerCount >= itemData2.needCount and EColor[EGradColor.green] or EColor[EGradColor.red] local str2 = string.format("%s/%s", color2, itemData2.ownerCount, itemData2.needCount) GUI:Text_setString(txt_count2, str2) end GUI:SetActive(img_jia2,false) GUI:SetActive(item3,false) GUI:SetActive(txt_count3,false) if table.count(showReward) >= 3 then GUI:SetActive(img_jia2,true) GUI:SetActive(item3,true) GUI:SetActive(txt_count3,true) item3.kmlControl:HideAllChilds() local itemData3 = showReward[3] local data3 = {width = "70",height = "70",itemid = itemData3.itemId,mfixsize = "70,70",itemcount = nil,bgtype = "0",raycast="1",} self.item3 = GUI:Item_Create(item3, data3) GUI:AddOnClickEvent(self.item3, self, function() SL:OpenTips(nil, itemData3.itemId) end) local color3 = itemData3.ownerCount >= itemData3.needCount and EColor[EGradColor.green] or EColor[EGradColor.red] local str3 = string.format("%s/%s", color3, itemData3.ownerCount, itemData3.needCount) GUI:Text_setString(txt_count3, str3) end GUI:SetActive(btn_GoOrGet,false) GUI:SetActive(txt_alreadyGet,false) if data.giftState == E_RechargeState.CanGet then GUI:Button_setBright(btn_GoOrGet,true) GUI:SetActive(btn_GoOrGet,true) GUI:Button_setGrey(btn_GoOrGet,false) GUI:Button_setTitleText(btn_GoOrGet, "领取") elseif data.giftState == E_RechargeState.NotComplete then GUI:Button_setBright(btn_GoOrGet,false) GUI:SetActive(btn_GoOrGet,true) GUI:Button_setGrey(btn_GoOrGet,true) GUI:Button_setTitleText(btn_GoOrGet, "未达成") elseif data.giftState == E_RechargeState.AlreadyGet then GUI:SetActive(txt_alreadyGet,true) end GUI:AddOnClickEvent(btn_GoOrGet,self,self.GoOrGetOnClick,{giftState = data.giftState,cfgId = data.weapCdgData.id}) end function this:GoOrGetOnClick(_,eventData) if eventData.giftState == E_RechargeState.CanGet then --请求领奖 SL:SendLuaNetMsg(LuaMessageIdToSever.REQ_RECEIVE_ANGEL_WEAPON_REWARD, {taskId = eventData.cfgId}) end end ---注册UI事件和服务器消息 function this:RegistEvents() SL:RegisterLUAEvent(LUA_ARCWEAPON_ACTIVITY_CHANGE, self.RefreshPanelData, self) GUI:AddOnClickEvent(self.view.btn_getBigReward,self,self.OnClickGetBigReward) end function this:OnClickGetBigReward() local bigData = InfoManager.arcWeapActivityInfo.arcWeapBigGiftDataTbl[1] if bigData.giftState == E_RechargeState.CanGet then --请求领奖 SL:SendLuaNetMsg(LuaMessageIdToSever.REQ_RECEIVE_ANGEL_WEAPON_REWARD, {taskId = bigData.id}) end end function this:RefreshBigTask() self:ShowDJSFunc() local bigData = InfoManager.arcWeapActivityInfo.arcWeapBigGiftDataTbl[1] local itemId = bigData.weapCdgData.angelWeaponReward[1][1] local count = bigData.weapCdgData.angelWeaponReward[1][2] local data = { width = "70",height = "70",itemid = itemId,mfixsize = "70,70",itemcount = count,bgtype = "0",raycast="1",} if self.item then GUI:Item_UpdataData(self.item, data) else self.item = GUI:Item_Create(self.view.model, data) end GUI:AddOnClickEvent(self.item, self, function() SL:OpenTips(nil, itemId) end) local giftState = bigData.giftState if giftState == E_RechargeState.CanGet then GUI:Button_setBright(self.view.btn_getBigReward,true) GUI:Button_setGrey(self.view.btn_getBigReward,false) GUI:Button_setTitleText(self.view.btn_getBigReward, "领取") elseif giftState == E_RechargeState.NotComplete then GUI:Button_setBright(self.view.btn_getBigReward,false) GUI:Button_setGrey(self.view.btn_getBigReward,true) GUI:Button_setTitleText(self.view.btn_getBigReward, "未达成") elseif giftState == E_RechargeState.AlreadyGet then GUI:Button_setBright(self.view.btn_getBigReward,true) GUI:Button_setGrey(self.view.btn_getBigReward,true) GUI:Button_setTitleText(self.view.btn_getBigReward, "已领取") end end function this:ClearDJSFunc() if self.sectimer then SL:UnSchedule(self.sectimer) self.sectimer = nil end end function this:ShowDJSFunc() self:ClearDJSFunc() local taskGroup = InfoManager.arcWeapActivityInfo.arcWeapGroup local timeTbl = SL:GetConfigMultiKeys("cfg_activity_angelWeaponTime",taskGroup,"taskGroup") local endDay = string.split(timeTbl.condition,"&") endDay = string.split(endDay[2],"#") endDay = tonumber(endDay[2]) local countdown = InfoManager.mainActivityInfo:ShowActivityDJSFunc(endDay,0) self.sectimer = SL:Schedule(self.sectimer, 0, 1, countdown, function() countdown = countdown - 1 if countdown > 0 then GUI:SetActive(self.view.txt_showTime,true) GUI:Text_setString(self.view.txt_showTime, GUIUtil.FormatTimeDHM(countdown)) else GUI:SetActive(self.view.txt_showTime,false) self:ClearDJSFunc() GUI:UIPanel_Close("dev/outui/MainActivity/Panel/KLMainActivity/KLMainActivityPanel") end end) end function this:RefreshPanelData() --刷新大奖任务 self:RefreshBigTask() --刷新穿戴任务 self.showSmallList = {} self.showSmallList = InfoManager.arcWeapActivityInfo.arcWeapSmallGiftDataTbl table.sort(self.showSmallList,function(a,b) if a.giftState == b.giftState then return a.weapCdgData.sortId < b.weapCdgData.sortId else return a.giftState < b.giftState end end) GUI:DataListUpdateData(self.view.showInfoList) end ---界面显示时调用一次 function this:Show() end ---创建或者刷新界面数据时调用 function this:Refresh() self:RefreshPanelData() end function this:Close() self:ClearDJSFunc() end return this