171 lines
5.7 KiB
Lua
171 lines
5.7 KiB
Lua
QiJieShiLianManager = {}
|
||
local this = QiJieShiLianManager
|
||
local QijieHolyConfig = ConfigManager.GetConfig(ConfigName.QijieHolyConfig)
|
||
local QijieRanking = ConfigManager.GetConfig(ConfigName.QijieRanking)
|
||
local QijieStage = ConfigManager.GetConfig(ConfigName.QijieStage)
|
||
local QijieStageBuff = ConfigManager.GetConfig(ConfigName.QijieStageBuff)
|
||
local QijieTreasure = ConfigManager.GetConfig(ConfigName.QijieTreasure)
|
||
local QijieUpgrade = ConfigManager.GetConfig(ConfigName.QijieUpgrade)
|
||
local HeroConfig = ConfigManager.GetConfig(ConfigName.HeroConfig)
|
||
|
||
function this.Initialize()
|
||
this.curLevelId = 3004
|
||
this.curRank = 999
|
||
this.curScore = 1
|
||
this.QijieType = 1
|
||
this.curProgress = 0
|
||
|
||
this.treasureList = {}
|
||
this.InitTreasureData()
|
||
end
|
||
|
||
function this.InitTreasureData()
|
||
for _, configInfo in ConfigPairs(QijieHolyConfig) do
|
||
if configInfo.Id ~= 0 then
|
||
local data = {}
|
||
data.Id = configInfo.Id
|
||
data.Name = configInfo.Name
|
||
data.Quality = configInfo.Quality
|
||
data.Icon = configInfo.Icon
|
||
data.Position = configInfo.Position
|
||
data.Attri = configInfo.Attri
|
||
data.Cost = configInfo.Cost
|
||
data.Addition = configInfo.Addition
|
||
data.state = 2 --0未激活,1已激活,2未购买
|
||
this.treasureList[data.Id] = data
|
||
end
|
||
end
|
||
end
|
||
|
||
--界面获取信息
|
||
function this.GetQiJieData(targetLevel)
|
||
--上阵列表赋值
|
||
local curFormation = FormationManager.GetFormationByID(FormationTypeDef.FORMATION_NORMAL)
|
||
if FormationManager.GetFormationByID(FormationTypeDef.FORMATION_QIJIESHILIAN) then
|
||
curFormation = FormationManager.GetFormationByID(FormationTypeDef.FORMATION_QIJIESHILIAN)
|
||
end
|
||
this.formationList ={}
|
||
for j = 1, #curFormation.teamHeroInfos do
|
||
if curFormation.teamHeroInfos[j] then
|
||
table.insert(this.formationList,HeroManager.GetSingleHeroData(curFormation.teamHeroInfos[j].heroId).heroConfig)
|
||
end
|
||
end
|
||
--界面信息
|
||
local data = {}
|
||
data.curLevelId = this.curLevelId
|
||
data.curRank = this.curRank
|
||
data.curScore = this.curScore
|
||
data.curProgress = this.curProgress
|
||
data.curStageData = QijieStage[this.curLevelId]
|
||
return data
|
||
end
|
||
|
||
--获取服务器信息
|
||
function this.GetServerData(msg)
|
||
this.curLevelId = msg.id
|
||
this.curRank = msg.ranking
|
||
this.curScore = msg.integral
|
||
this.curProgress = msg.totalTier
|
||
end
|
||
|
||
function this.CheckCurStageNum()
|
||
local data = ConfigManager.GetAllConfigsDataByKey(ConfigName.QijieStage,"QijieType",this.QijieType)
|
||
LogGreen(tostring(#data)..LengthOfTable(data))
|
||
-- return ConfigManager.GetAllConfigsDataByKey(ConfigName.QijieStage,"QijieType",this.QijieType)
|
||
end
|
||
|
||
--获取下方滑动条数据
|
||
function this.GetTabList()
|
||
local tabList = {}
|
||
for _, configInfo in ConfigPairs(QijieStage) do
|
||
if not tabList[configInfo.QijieType] then
|
||
tabList[configInfo.QijieType] = configInfo
|
||
end
|
||
end
|
||
return tabList
|
||
end
|
||
|
||
--检测该条目是否达成
|
||
function this.CheckGoalIsFinish(_dataId,_obj)
|
||
local goalData = QijieUpgrade[_dataId]
|
||
local tempList = {}
|
||
local final = true
|
||
for i = 1, #this.formationList do
|
||
table.insert(tempList,this.formationList[i])
|
||
end
|
||
-- LogGreen("Id:"..tostring(goalData.Id).." Describe:"..tostring(goalData.Describe).." PropertyName:"..tostring(goalData.PropertyName).." Profession:"..tostring(goalData.Profession).." Min:"..tostring(goalData.Min).." Max:"..tostring(goalData.Max))
|
||
if goalData.PropertyName and goalData.PropertyName > 0 then
|
||
for i = #tempList, 1,-1 do
|
||
if goalData.PropertyName ~= tempList[i].PropertyName then
|
||
table.remove(tempList,i)
|
||
end
|
||
end
|
||
end
|
||
-- LogGreen("#tempList1:"..tostring(#tempList))
|
||
if goalData.Profession and goalData.Profession > 0 then
|
||
for i = #tempList, 1,-1 do
|
||
if goalData.Profession ~= tempList[i].Profession then
|
||
table.remove(tempList,i)
|
||
end
|
||
end
|
||
end
|
||
-- LogGreen("#tempList1:"..tostring(#tempList))
|
||
if goalData.Min and goalData.Min >= 0 then
|
||
if #tempList < goalData.Min then
|
||
-- LogYellow("final = false1")
|
||
final = false
|
||
end
|
||
end
|
||
if goalData.Max and goalData.Max >= 0 then
|
||
if #tempList > goalData.Max then
|
||
-- LogYellow("final = false2")
|
||
final = false
|
||
end
|
||
end
|
||
_obj.text = string.format( "<color=#BAAF98>%s</color>",goalData.Describe)
|
||
if final then
|
||
_obj.text = string.format( "<color=#27DD65>%s</color>",goalData.Describe)
|
||
end
|
||
return final
|
||
end
|
||
|
||
--把服务器发来的遗物数据加到本地数据中
|
||
function this.MixTreasureServerAndLocalData(msg)
|
||
for k,v in pairs(msg.info) do
|
||
if this.treasureList[v.id] then
|
||
this.treasureList[v.id].state = v.status
|
||
else
|
||
LogError("服务器发来了前端不存在的遗物Id:"..tostring(v.id))
|
||
end
|
||
end
|
||
end
|
||
|
||
--把1维的List换成2维的。并且增加稀有度条件
|
||
function this.FormatTreasureData(_tabNum)
|
||
local list = {}
|
||
for k,v in pairs(this.treasureList) do
|
||
list[k] = v
|
||
end
|
||
if _tabNum and _tabNum ~= 0 then
|
||
for k,v in pairs(list) do
|
||
if v.Quality ~= _tabNum then
|
||
table.remove(list,k)
|
||
end
|
||
end
|
||
end
|
||
local num = math.ceil( LengthOfTable(list)/4 )
|
||
local dataList = {}
|
||
for i = 1, num do
|
||
dataList[i] = {}
|
||
for j = 1, 4 do
|
||
if list[(i-1)*4+j] then
|
||
dataList[i][j] = list[(i-1)*4+j]
|
||
else
|
||
return dataList
|
||
end
|
||
end
|
||
end
|
||
return dataList
|
||
end
|
||
|
||
return QiJieShiLianManager |