CommonActPageManager = {} local this = CommonActPageManager local dataList = {} this.TaSuiLingXiaoMsg = nil this.TaSuiLingXiaoHistoryDmg = 0 function this.Initialize() end --初始化活动的特殊数据 local TypeUpdateFunc = { [ActivityTypeDef.YunYouShangRen] = function () local curData = dataList[ActivityTypeDef.YunYouShangRen] local configData = ConfigManager.GetAllConfigsDataByKey(ConfigName.ComposeActivity,"ActivityId",curData.activityId) for i = 1, #curData.rewards do for j = 1, #configData do if curData.rewards[i].missionId == configData[j].Id then curData.rewards[i].otherData.needItems = configData[j].NeedItems curData.rewards[i].otherData.count = configData[j].Count curData.rewards[i].otherData.composeType = configData[j].ComposeType curData.rewards[i].otherData.selectId = 0 end end end table.sort(dataList[ActivityTypeDef.YunYouShangRen].rewards,function (a,b) if a.progress == 0 and b.progress > 0 then return false end if a.progress > 0 and b.progress == 0 then return true end return a.missionId < b.missionId -- if a.progress == b.progress then -- else -- return a.progress > b.progress -- end end) end, [ActivityTypeDef.ContinuityRecharge] = function () this.GetExpertData(3,ActivityTypeDef.ContinuityRecharge) end, [ActivityTypeDef.UpStarExper] = function ()--进阶达人 this.GetExpertData(1,ActivityTypeDef.UpStarExper) end, [ActivityTypeDef.Talisman] = function ()--法宝达人 this.GetExpertData(1,ActivityTypeDef.Talisman) end, [ActivityTypeDef.SoulPrint] = function ()--魂印达人 this.GetExpertData(1,ActivityTypeDef.SoulPrint) end, [ActivityTypeDef.EquipExper] = function ()--装备达人 this.GetExpertData(1,ActivityTypeDef.EquipExper) end, [ActivityTypeDef.EnergyExper] = function ()--体力达人 this.GetExpertData(2,ActivityTypeDef.EnergyExper) end, [ActivityTypeDef.FindTreasureExper] = function ()--寻宝达人 this.GetExpertData(1,ActivityTypeDef.FindTreasureExper) end, [ActivityTypeDef.ExpeditionExper] = function ()--天宫达人 this.GetExpertData(1,ActivityTypeDef.ExpeditionExper) end, [ActivityTypeDef.FastExplore] = function ()--极速达人 this.GetExpertData(2,ActivityTypeDef.FastExplore) end, [ActivityTypeDef.GoldExper] = function ()--点金达人 this.GetExpertData(2,ActivityTypeDef.GoldExper) end, [ActivityTypeDef.FightExper] = function ()--副本达人 this.GetExpertData(2,ActivityTypeDef.FightExper) end, [ActivityTypeDef.AreaExper] = function () this.GetExpertData(2,ActivityTypeDef.AreaExper) end, [ActivityTypeDef.slhjExper] = function ()--森罗幻境达人 this.GetExpertData(2,ActivityTypeDef.slhjExper) end, [ActivityTypeDef.LuckyTurnExper] = function ()--探宝达人 this.GetExpertData(2,ActivityTypeDef.LuckyTurnExper) end, [ActivityTypeDef.RecruitExper] = function ()--征募达人 this.GetExpertData(2,ActivityTypeDef.RecruitExper) end, [ActivityTypeDef.SecretBoxExper] = function ()--秘宝达人 this.GetExpertData(2,ActivityTypeDef.SecretBoxExper) end, [ActivityTypeDef.AccumulativeRechargeExper] = function ()---日累计充值 local curData = dataList[ActivityTypeDef.AccumulativeRechargeExper] local configData = ConfigManager.GetConfigData(ConfigName.GlobalActivity,curData.activityId) if configData.ShowArt == FUNCTION_OPEN_TYPE.EXPERT then this.GetExpertData(2,ActivityTypeDef.AccumulativeRechargeExper) else this.GetMissionData(1,ActivityTypeDef.AccumulativeRechargeExper) end end, [ActivityTypeDef.UpLvAct] = function ()---升级限时 this.GetExpertData(4,ActivityTypeDef.UpLvAct) end, [ActivityTypeDef.DynamicAct_recharge] = function ()---周累计充值 this.GetMissionData(1,ActivityTypeDef.DynamicAct_recharge) end, [ActivityTypeDef.TaSuiLingXiao] = function ()--踏碎凌霄 local curData = dataList[ActivityTypeDef.TaSuiLingXiao] local configData = ConfigManager.GetAllConfigsDataByKey(ConfigName.ActivityRewardConfig,"ActivityId",curData.activityId) for i = 1, #curData.rewards do for j = 1, #configData do if curData.rewards[i].missionId == configData[j].Id then curData.rewards[i].otherData.Values = configData[j].Values curData.rewards[i].otherData.Reward = configData[j].Reward curData.rewards[i].otherData.Sort = configData[j].Sort end end end table.sort(curData.rewards,function (a,b) if a.state == b.state then return a.missionId < b.missionId else return a.state < b.state end end) end, [ActivityTypeDef.DynamicAct] = function ()--主题活动任务 local curData = dataList[ActivityTypeDef.DynamicAct] this.InitTaskData(curData,TaskTypeDef.DynamicActTask,ConfigName.ThemeActivityTaskConfig) end, [ActivityTypeDef.SurpriseBox] = function ()--惊喜礼盒 local curData = dataList[ActivityTypeDef.SurpriseBox] local configData = ConfigManager.GetAllConfigsDataByKey(ConfigName.SurpriseBoxConfig,"ActivityId",curData.activityId) local rechargeConfig = ConfigManager.GetConfig(ConfigName.RechargeCommodityConfig) for i = 1, #curData.rewards do for j = 1, #configData do if curData.rewards[i].missionId == configData[j].Id then curData.rewards[i].otherData.PackId = configData[j].PackId curData.rewards[i].otherData.BuyDay = configData[j].BuyDay curData.rewards[i].otherData.Name = rechargeConfig[configData[j].PackId].Name curData.rewards[i].otherData.Reward = rechargeConfig[configData[j].PackId].RewardShow curData.rewards[i].otherData.Price = rechargeConfig[configData[j].PackId].Price curData.rewards[i].otherData.Warning = configData[j].Warning end end end for i = #curData.rewards, 1,-1 do if curData.rewards[i].progress == 5 then table.remove(curData.rewards,i) end end end, } function this.InitTaskData(curData,taskType,configName) local allListData = ConfigManager.GetAllConfigsDataByKey(configName, "ActivityId", curData.activityId) local allMissionData = TaskManager.GetTypeTaskList(taskType) for i=1,#allListData do for j=1,#allMissionData do if allListData[i].Id == allMissionData[j].missionId then local data = {} data.missionId = allMissionData[j].missionId data.taskType = taskType local strs = string.split(GetLanguageStrById(allListData[i].Show),"#") data.progress = allMissionData[j].progress data.value = allListData[i].TaskValue[2][1] data.state = allMissionData[j].state if data.state == 2 or data.state == 1 then data.itemName = string.format("%s(%s/%s)",strs[1],data.value,data.value) else data.itemName = string.format("%s(%s/%s)",strs[1],(data.progress > data.value and data.value or data.progress),data.value) end data.content = strs[2] data.shows = { [1] = { allListData[i].Integral[1][1], allListData[i].Integral[1][2] }, } data.type = allListData[i].Type data.jump = allListData[i].Jump[1] table.insert(curData.rewards,data) end end end local typeIndex = { [0] = 1, [1] = 0, [2] = 2, } table.sort(curData.rewards, function(a,b) if typeIndex[a.state] == typeIndex[b.state] then if a.type == b.type then return a.missionId < b.missionId else return a.type < b.type end else return typeIndex[a.state] < typeIndex[b.state] end end) end function this.GetMissionData(indexType,actType) local curData = dataList[actType] local actId = ActivityGiftManager.GetActivityIdByType(actType) local actRewardConfigs = ConfigManager.GetAllConfigsDataByKey(ConfigName.ActivityRewardConfig,"ActivityId", actId) for i = 1, #curData.rewards do for j = 1, #actRewardConfigs do if curData.rewards[i].missionId == actRewardConfigs[j].Id then if indexType == 2 then curData.rewards[i].progress = curData.rewards[i].progress else curData.rewards[i].progress = curData.value end if actType == ActivityTypeDef.DynamicAct_recharge or actType == ActivityTypeDef.AccumulativeRechargeExper then curData.rewards[i].value = actRewardConfigs[j].Values[1][1] else curData.rewards[i].value = actRewardConfigs[j].Values[2][1] end if curData.rewards[i].state == 1 then curData.rewards[i].state = 2 else if curData.rewards[i].progress < curData.rewards[i].value then curData.rewards[i].state = 0 else curData.rewards[i].state = 1 end end curData.rewards[i].title = string.format("累计充值金额:%s元",curData.rewards[i].value) curData.rewards[i].buyInfo = string.format("(%s/%s)",curData.rewards[i].progress,curData.rewards[i].value) curData.rewards[i].shows = actRewardConfigs[j].Reward curData.rewards[i].jump = actRewardConfigs[j].Jump[1] end end end local typeIndex = { [0] = 1, [1] = 0, [2] = 2, } table.sort(dataList[actType].rewards,function (a,b) if typeIndex[a.state] == typeIndex[b.state] then return a.missionId < b.missionId else return typeIndex[a.state] < typeIndex[b.state] end end) end function this.GetExpertData(indexType,actType) local curData = dataList[actType] local actId = ActivityGiftManager.GetActivityIdByType(actType) local actRewardConfigs = ConfigManager.GetAllConfigsDataByKey(ConfigName.ActivityRewardConfig,"ActivityId", actId) for i = 1, #curData.rewards do for j = 1, #actRewardConfigs do if curData.rewards[i].missionId == actRewardConfigs[j].Id then if indexType == 3 then -- 3 积天豪礼 curData.rewards[i].otherData.Values = actRewardConfigs[j].Values[1][2] curData.rewards[i].otherData.info = "" if curData.rewards[i].state == 1 then curData.rewards[i].otherData.state = 2 elseif curData.rewards[i].progress == 1 then curData.rewards[i].otherData.state = 0 else curData.rewards[i].otherData.state = 1 end elseif indexType == 4 then --升级限量豪礼 curData.rewards[i].otherData.Values = actRewardConfigs[j].Values[2][1] curData.rewards[i].otherData.info = "" if curData.rewards[i].state == 1 then curData.rewards[i].otherData.state = 2 else if curData.rewards[i].progress > 0 then if PlayerManager.level >= curData.rewards[i].otherData.Values then curData.rewards[i].otherData.state = 0 else curData.rewards[i].otherData.state = 1 end else curData.rewards[i].otherData.state = 3 end if PlayerManager.level >= curData.rewards[i].otherData.Values then curData.rewards[i].otherData.info = string.format("%s/%s",curData.rewards[i].otherData.Values,curData.rewards[i].otherData.Values) else curData.rewards[i].otherData.info = string.format("%s/%s",PlayerManager.level,curData.rewards[i].otherData.Values) end end else --日累计充值 达人 if actType == ActivityTypeDef.AccumulativeRechargeExper or actType == ActivityTypeDef.DynamicAct_recharge then curData.rewards[i].otherData.Values = actRewardConfigs[j].Values[1][1] else curData.rewards[i].otherData.Values = actRewardConfigs[j].Values[2][1] end if curData.rewards[i].state == 1 then curData.rewards[i].otherData.state = 2 curData.rewards[i].otherData.info = string.format("%s/%s",curData.rewards[i].otherData.Values,curData.rewards[i].otherData.Values) else if indexType == 1 then if curData.rewards[i].progress < curData.rewards[i].otherData.Values then curData.rewards[i].otherData.state = 1 else curData.rewards[i].otherData.state = 0 end curData.rewards[i].otherData.info = string.format("%s/%s",curData.rewards[i].progress,curData.rewards[i].otherData.Values) if curData.rewards[i].progress > curData.rewards[i].otherData.Values then curData.rewards[i].otherData.info = string.format("%s/%s",curData.rewards[i].otherData.Values,curData.rewards[i].otherData.Values) end elseif indexType == 2 then -- LogPink("curData.value:"..tostring(curData.value).." "..tostring(curData.rewards[i].otherData.Values)) if curData.value < curData.rewards[i].otherData.Values then curData.rewards[i].otherData.state = 1 else curData.rewards[i].otherData.state = 0 end curData.rewards[i].otherData.info = string.format("%s/%s",curData.value,curData.rewards[i].otherData.Values) if curData.value > curData.rewards[i].otherData.Values then curData.rewards[i].otherData.info = string.format("%s/%s",curData.rewards[i].otherData.Values,curData.rewards[i].otherData.Values) end end end end curData.rewards[i].otherData.Reward = actRewardConfigs[j].Reward curData.rewards[i].otherData.ContentsShow = actRewardConfigs[j].ContentsShow curData.rewards[i].otherData.Sort = actRewardConfigs[j].Sort if actRewardConfigs[j].Jump then curData.rewards[i].otherData.Jump = actRewardConfigs[j].Jump[1] end end end end table.sort(dataList[actType].rewards,function (a,b) if a.state == b.state then return a.missionId < b.missionId else return a.state < b.state end end) end function this.GetData(actType) if dataList[actType] then dataList[actType] = nil end dataList[actType] = this.InitSingleTypeData(actType) if TypeUpdateFunc[actType] and dataList[actType] then TypeUpdateFunc[actType]() end return dataList[actType] end function this.InitSingleTypeData(actType) local singleTypeData = nil local data = ActivityGiftManager.GetActivityTypeInfo(actType) if data then singleTypeData = {} Log("InitData activityId:"..tostring(data.activityId).." value:"..tostring(data.value).." startTime:"..tostring(data.startTime).." endTime:"..tostring(data.endTime).." mission:"..tostring(#data.mission)) singleTypeData.activityId = data.activityId singleTypeData.value = data.value singleTypeData.startTime = data.startTime singleTypeData.endTime = data.endTime singleTypeData.rewards = {} if data.mission and #data.mission > 0 then for i = 1, #data.mission do local reward = {} reward.missionId = data.mission[i].missionId or 0 reward.progress = data.mission[i].progress or 0 reward.state = data.mission[i].state or 0 reward.otherData = {} table.insert(singleTypeData.rewards,reward) end end end return singleTypeData end function this.CheckSingleRed(data) local NeedCost = ConfigManager.GetConfigData(ConfigName.ComposeBook,data.otherData.needItems[1]).NeedCost if data.progress > 0 then if BagManager.GetTotalItemNum(NeedCost[1][1]) >= NeedCost[1][2] then local list = BagManager.GetBagItemDataByItemType(ItemBaseType.Equip) local EquipedEquipList = HeroManager.GetEquipedEquipList() for i = 1, #data.otherData.needItems do for j = 1, #list do if data.otherData.needItems[i] == list[j].itemConfig.Id then return true end end end for i = 1, #data.otherData.needItems do for j = 1, #EquipedEquipList do if data.otherData.needItems[i] == EquipedEquipList[j] then return true end end end end end return false end return CommonActPageManager