miduo_client/Assets/ManagedResources/~Lua/Modules/Harmony/Manager/HarmonyManager.lua

660 lines
19 KiB
Lua
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

HarmonyManager = {}
local this = HarmonyManager
--
-- 第一阶段 鸿蒙阵数据
this.hongmengGuards = {}
this.hongmengHeroInfos = {}
this.hongmengTablet = 0
this.hongmengAdditions = {}
this.GuardList = {}
local SelectId = nil
HarmonyManager.GongMingBox = 0;
HarmonyManager.UnLoadGongMing = 0
--判断是否鸿蒙共享数据
local equipConfig = ConfigManager.GetConfig(ConfigName.EquipConfig)
local heroConfig = ConfigManager.GetConfig(ConfigName.HeroConfig)
this.tab=ConfigManager.GetConfig(ConfigName.Hongmeng)
HarmonyManager.TowerStartLimit = 0
HarmonyManager.equipCount = 0
this.hongmengGongMingList = {}
this.ChooseDataList = {}
-- 第二阶段 鸿蒙塔 数据
--330 鸿蒙使者 数据
-- 鸿蒙塔升级数据表
local HongmengUp = ConfigManager.GetConfig(ConfigName.HongmengUp)
local keys = nil
function this.InitHongMengData(hongmengGuards, hongmengHeroInfos, hongmengTablet, hongmengAdditions)
-- body
this.hongmengGuards = hongmengGuards
--LogGreen("hongmengGuards",#this.hongmengGuards)
-- LogGreen("TowerStartLimit"..HarmonyManager.TowerStartLimit)
this.hongmengHeroInfos = hongmengHeroInfos
keys = GameDataBase.SheetBase.GetKeys(this.tab)
for i = 1, #this.hongmengGuards do
this.hongmengGuards[i].time = this.hongmengGuards[i].time + GetTimeStamp()
end
--LogBlue("hongmengTablet "..hongmengTablet)
for i = 1, #this.hongmengHeroInfos do
this.hongmengHeroInfos[i].time = this.hongmengHeroInfos[i].time + GetTimeStamp()
end
this.hongmengTablet = hongmengTablet
this.hongmengAdditions = hongmengAdditions
end
function this.UpdateHongMengDataGuards(hongmengGuards)
this.TowerStartLimit = tonumber(string.split(ConfigManager.GetConfigData(ConfigName.SpecialConfig,101).Value,"#")[2])
this.hongmengGuards = hongmengGuards
LogGreen("hongmengGuards "..#this.hongmengGuards)
for i = 1, #this.hongmengGuards do
if this.hongmengGuards[i].time ~= 0 then
-- body
this.hongmengGuards[i].time = this.hongmengGuards[i].time + GetTimeStamp()
--print(this.hongmengGuards[i].value)
end
end
if this.hongmengAdditions[1] then
-- body
if this.hongmengAdditions[1].heroTid == 0 then
-- body
this:SetTowerInit()
elseif this.hongmengAdditions[1].heroTid == -1 then
-- body
else
this:SetInitList()
end
end
end
function this.UpdateHongMengDataHeroInfos(hongmengHeroInfos)
this.hongmengHeroInfos = hongmengHeroInfos
LogGreen("hongmengHeroInfos "..#this.hongmengHeroInfos)
for i = 1, #this.hongmengHeroInfos do
if this.hongmengHeroInfos[i].time ~= 0 then
-- body
this.hongmengHeroInfos[i].time = this.hongmengHeroInfos[i].time + GetTimeStamp()
end
-- print(HeroManager.)
end
if this.hongmengAdditions[1] then
-- body
if this.hongmengAdditions[1].heroTid == 0 then
-- body
this:SetTowerInit()
elseif this.hongmengAdditions[1].heroTid == -1 then
-- body
else
this:SetInitList()
end
end
end
function this.UpdateHongMengDataAdditions(hongmengAdditions)
this.hongmengAdditions = hongmengAdditions
-- for i = 1, #this.hongmengAdditions do
-- print(this.hongmengAdditions[i].heroTid)
-- print(this.hongmengAdditions[i].value)
-- end
LogGreen("hongmengAdditions "..#this.hongmengAdditions)
for i = 1, #this.hongmengAdditions do
if this.hongmengAdditions[i].additionType == HarmonyAddType.AddEquip then
if this.hongmengAdditions[i].value > 0 then
local curEquipIdList = {}
local curEquipConfigs = ConfigManager.GetAllConfigsDataByKey(ConfigName.EquipConfig,"Star",this.hongmengAdditions[i].value)
for i = 1, #curEquipConfigs do
table.insert(curEquipIdList,curEquipConfigs[i].Id)
end
this.HarmonyUpdateEquipData(curEquipIdList, "")
end
end
end
if this.hongmengAdditions[1] then
-- body
if this.hongmengAdditions[1].heroTid == 0 then
-- body
this:SetTowerInit()
elseif this.hongmengAdditions[1].heroTid == -1 then
-- body
else
this:SetInitList()
end
end
-- if this.hongmengTablet < this.TowerStartLimit then
-- -- body
-- else
-- end
end
--初始化共鸣列表数据
function this:InitGongMingDataList()
for i = 1, #this.hongmengHeroInfos do
local data = HeroManager.GetSingleHeroData(this.hongmengHeroInfos[i].heroId)
if data then
this.hongmengGongMingList[i] = data
else
this.hongmengGongMingList[i] = nil
end
end
end
--鸿蒙塔上限
local len = 0
function this:SetHongMengTowerUpLimit(limit)
len = limit
end
function this:HongMengTowerUpLimit()
return len
end
function this.IsInfo(did)
if did ~= "" then
for i = 1, #this.hongmengHeroInfos do
if did == this.hongmengHeroInfos[i].heroId and this.hongmengHeroInfos[i].heroId ~= "" then
return true
end
end
end
return false
end
--共鸣神将
function this.IsChangeColor(did)
for i = 1, #this.hongmengHeroInfos do
if did == this.hongmengHeroInfos[i].heroId then
return true
end
end
return false
end
function this.IsGongMing(did)
for i = 1, #this.hongmengHeroInfos do
-- body
if did == this.hongmengHeroInfos[i].heroId then
PopupTipPanel.ShowTip(Language[12191])
return
end
end
-- body
end
--初始化选人列表的长度
function this:SetInitList()
local heroDataList = HeroManager.GetAllHeroDatas(1)
local list = {}
local count = 0;
--LogBlue("this.GuardList长度"..LengthOfTable(this.GuardList))
for key, value in pairs(this.hongmengGuards) do
if value.heroId ~= "" then
local singleHero = HeroManager.GetSingleHeroData(value.heroId)
table.insert(list,singleHero)
end
end
for i = 1, #this.hongmengHeroInfos do
if this.hongmengHeroInfos[i].heroId ~= "" then
-- LogYellow("是否有数据:"..i)
local data = HeroManager.GetSingleHeroData(this.hongmengHeroInfos[i].heroId)
table.insert(list,data)
end
end
table.sort(list,function(a,b)
return a.dynamicId < b.dynamicId
end)
--LogBlue("#list长度:"..#list)
local newList = {}
local index = 0
local flag = true
local tempTable = {}
for i = 1, #heroDataList do
table.insert(tempTable,heroDataList[i])
end
for i = #heroDataList, 1,-1 do
for k2, v2 in pairs(list) do
if v2.dynamicId == heroDataList[i].dynamicId then
--LogPink("第几个:"..i.." k2"..k2)
table.remove(tempTable,i)
end
end
end
this.ChooseDataList = tempTable
LogBlue("#this.ChooseDataList长度:"..#this.ChooseDataList)
end
--初始化 鸿蒙塔的数据
function this:SetTowerInit()
local heroDataList = HeroManager.GetAllHeroDatas(1)
local list = {}
local count = 0;
for key, value in pairs(this.hongmengGuards) do
if value.heroId ~= "" then
local singleHero = HeroManager.GetSingleHeroData(value.heroId)
table.insert(list,singleHero)
end
end
--LogBlue("#this.hongmengHeroInfos"..#this.hongmengHeroInfos)
for i = 1, #this.hongmengHeroInfos do
if this.hongmengHeroInfos[i].heroId ~= "" then
--LogYellow("是否有数据:"..i)
local data = HeroManager.GetSingleHeroData(this.hongmengHeroInfos[i].heroId)
table.insert(list,data)
end
end
table.sort(list,function(a,b)
return a.dynamicId < b.dynamicId
end)
--LogBlue("#list长度:"..#list)
local newList = {}
local index = 0
local flag = true
local tempTable = {}
for i = 1, #heroDataList do
table.insert(tempTable,heroDataList[i])
end
for i = #heroDataList, 1,-1 do
for k2, v2 in pairs(list) do
if v2.dynamicId == heroDataList[i].dynamicId then
-- LogPink("第几个:"..i.." k2"..k2)
table.remove(tempTable,i)
end
end
end
this.ChooseDataList = tempTable
--LogBlue("#this.ChooseDataList长度:"..#this.ChooseDataList)
end
--判断鸿蒙 使者/守卫 是否够6位
function this:IsEnvoyCount()
-- body
local count = 1
--print("228 ",#this.hongmengGuards)
for i = 1, #this.hongmengGuards do
-- body
if this.hongmengGuards[i].heroId ~= "" then
count =count + 1
end
end
return count
end
--初始化鸿蒙使者的数据
--是否是鸿蒙使者
function this:IsEnvoy(did)
if this:HongMengTowerUpLimit() == 0 then
-- body
return false
end
-- body
for i = 1, #this.hongmengGuards do
-- body
if this.hongmengGuards[i].heroId == did then
-- body
return true
end
end
return false
end
-- 设置、获取鸿蒙守卫的列表
function this:SetGuardList(list,count)
for key, value in pairs(list) do
if key<=count then
-- body
this.GuardList[value.dynamicId] = value
end
end
end
function this:GetGuardList()
return this.GuardList
-- body
end
function this:SetGongMingList(Id)
local data = HeroManager.GetSingleHeroData(Id)
table.insert(this.hongmengGongMingList,data)
end
function this:RemoveGongMingList(Id)
local data = HeroManager.GetSingleHeroData(Id)
for key, value in pairs(this.hongmengGongMingList) do
if value then
-- body
if value==data then
-- body
value = nil
break
end
end
end
end
function this:GetGongMingListSingle(Id)
local data = HeroManager.GetSingleHeroData(Id)
--return data
--print(data.dynamicId,"~~~",Id)
for key, value in pairs(this.hongmengGongMingList) do
if value.dynamicId==data.dynamicId then
return value
end
end
end
function this:SetChooseId(id)
SelectId = id
end
-- 设置、获取卸载的数据
function this:SetMingListIndexData(index)
SelectId = this.hongmengHeroInfos[index].heroId
end
function this:GetUnLoadData()
-- body
return SelectId
end
--获取加成
function this:GetAdditions()
return this.hongmengAdditions
end
function this.GetSingleAdditions(type)
if this.hongmengAdditions then
-- body
for i = 1, #this.hongmengAdditions do
if this.hongmengAdditions[i].additionType == type then
return this.hongmengAdditions[i].value
end
end
end
return 0
end
function this.GetSingleAdditionsData(type)
if this.hongmengAdditions then
-- body
for i = 1, #this.hongmengAdditions do
if this.hongmengAdditions[i].additionType == type then
return this.hongmengAdditions[i]
end
end
end
return nil
end
function this.GetHongMengUpData()
for i = 1, #this.hongmengAdditions do
-- body
if this.hongmengAdditions[i].additionType == 1 then
-- body
if this.hongmengAdditions[i].value < 330 then
-- body
LogBlue("服务器数据为"..this.hongmengAdditions[i].value)
return nil
end
LogGreen("服务器数据为"..this.hongmengAdditions[i].value)
for key, value in ConfigPairs(HongmengUp) do
-- body
if value.HongmengLevel == this.hongmengAdditions[i].value + 1 then
-- body
return ConfigManager.TryGetConfigData(ConfigName.HongmengUp,key)
end
end
end
end
return nil
end
--鸿蒙共享装备临时数据
local itemConfig = ConfigManager.GetConfig(ConfigName.ItemConfig)
local equipStarsConfig = ConfigManager.GetConfig(ConfigName.EquipStarsConfig)
local propertyConfig = ConfigManager.GetConfig(ConfigName.PropertyConfig)
function this.InitUpdateEquipData(id, upHeroDid)
if not this.equipDatas then
this.equipDatas = {}
end
id = tonumber(id)
if this.equipDatas[id] then
if not this.equipDatas[id].upHeroDidList then
this.equipDatas[id].upHeroDidList = {}
end
if upHeroDid and upHeroDid ~= "0" then
this.equipDatas[id].upHeroDidList[upHeroDid] = upHeroDid
end
else
local equipdata = {}
equipdata.equipConfig = equipConfig[id]
equipdata.itemConfig = itemConfig[id]
equipdata.id = id
if itemConfig[equipdata.id] then
equipdata.icon = GetResourcePath(itemConfig[equipdata.id].ResourceID)
else
Log("装备表找不到此id " .. equipdata.id)
return
end
equipdata.frame = GetQuantityImageByquality(equipdata.equipConfig.Quality)
equipdata.quality = equipdata.equipConfig.Quality
equipdata.position = equipdata.equipConfig.Position
equipdata.mainAttribute = this.GetMainProList(equipdata.equipConfig)
equipdata.backData = equipdata
equipdata.star = equipStarsConfig[equipdata.equipConfig.Star].Stars
this.equipDatas[id] = equipdata
if not this.equipDatas[id].upHeroDidList then
this.equipDatas[id].upHeroDidList = {}
end
if upHeroDid and upHeroDid ~= "0" and not this.equipDatas[id].upHeroDidList[upHeroDid] then
this.equipDatas[id].upHeroDidList[upHeroDid] = upHeroDid
end
end
end
function this.HarmonyUpdateEquipData(idlist, heroDid)
for i = 1, #idlist do
this.InitUpdateEquipData(idlist[i], heroDid, false)
end
end
--判断神将的装备是否共鸣
function this:IsShowGongMingEqiup(id)
for i = 1, #this.hongmengHeroInfos do
-- body
if id == this.hongmengHeroInfos[i].heroId then
return true
end
end
return false
end
function this.GetMainProList(equipConfig)
local propList = {}
for index, prop in ipairs(equipConfig.Property) do
propList[index] = {}
propList[index].propertyId = prop[1]
propList[index].propertyValue = prop[2]
propList[index].PropertyConfig = propertyConfig[prop[1]]
end
return propList
end
function this.RefreshOpenBoxPoint()
local tab = ConfigManager.GetConfig(ConfigName.Hongmeng)
local keys = GameDataBase.SheetBase.GetKeys(this.tab)
local Gold = BagManager.GetTotalItemNum(UpViewRechargeType.XuanHuangZhiQi)
-- local DemonCrystal = BagManager.GetTotalItemNum(UpViewRechargeType.DemonCrystal) or DemonCrystal > tab[#this.hongmengHeroInfos].MoneyPrice[2]
if #this.hongmengHeroInfos<=0 then
-- body
return false
end
if tab[#this.hongmengHeroInfos + 1] and Gold > tab[#this.hongmengHeroInfos + 1].PropPrice[2] and #this.hongmengHeroInfos < #keys then
return true
else
return false
end
end
function this.RefreshEnvoyPoint()
-- body
local data = this.GetSingleAdditionsData(HarmonyAddType.AddLv)
if data then
-- body
if data.heroTid == 0 then
-- body
local sum = this:HongMengTowerUpLimit()
if data.value <= sum then
-- body
for i = 1, #this.hongmengGuards do
-- body
if data.heroId == "" and data.time == 0 then
-- body
return true
end
end
end
end
end
return false
end
function this.RefreshUpTowerPoint()
-- body
if len == 0 then
return false
end
local data = this.GetSingleAdditionsData(HarmonyAddType.AddLv)
if data then
-- body
if data.heroTid == 0 then
-- body
local sum = this:HongMengTowerUpLimit()
print(sum,data.value)
if data.value >= sum then
-- body
return false
else
local prop = this.GetHongMengUpData()
-- LogGreen(data.LevelUp[1][2].." "..data.LevelUp[2][2])
-- LogYellow(BagManager.GetTotalItemNum(UpViewRechargeType.Gold))
if prop and BagManager.GetTotalItemNum(UpViewRechargeType.Gold) >= prop.LevelUp[1][2] then
-- body
if BagManager.GetTotalItemNum(UpViewRechargeType.GrowthAmulet) >= prop.LevelUp[2][2] then
return true
end
end
return false
end
else
return false
end
end
return false
end
--检测主城红点
function this.CheckRedPoinStatusUpTowerMainCityRed()
CheckRedPointStatus(RedPointType.HongMeng_UpTower)
CheckRedPointStatus(RedPointType.HongMeng_Evory)
CheckRedPointStatus(RedPointType.HongMeng_OpenBox)
end
--票战力
local oldPowerNum = 0
function this.SetOldPowerNum(did)
local isCalculate = true
if did then
local heros = FormationManager.GetAllMainFormationHeroId()
if not heros[did] then
isCalculate = false
end
end
if isCalculate then
oldPowerNum = FormationManager.GetFormationPower(FormationTypeDef.FORMATION_NORMAL)
end
end
function this.WarPowerChangeNotify(did)
local isCalculate = true
if did then
local heros = FormationManager.GetAllMainFormationHeroId()
if not heros[did] then
isCalculate = false
end
end
if oldPowerNum ~= 0 and isCalculate then
local newPowerNum = FormationManager.GetFormationPower(FormationTypeDef.FORMATION_NORMAL)
if oldPowerNum ~= newPowerNum then
UIManager.OpenPanel(UIName.WarPowerChangeNotifyPanelV2,{oldValue = oldPowerNum,newValue = newPowerNum})
if did then
FormationManager.CheckHeroIdExist(did)--如果是主线阵容发生变化 会通知后端 更新任务刷新
end
end
end
end
return HarmonyManager