2021-11-11 16:48:15 +08:00
|
|
|
|
IncarnationManager = {}
|
|
|
|
|
local this = IncarnationManager
|
2021-11-16 15:24:17 +08:00
|
|
|
|
local itemConfig = ConfigManager.GetConfig(ConfigName.ItemConfig)
|
2021-11-18 11:55:26 +08:00
|
|
|
|
local ChangingCard = ConfigManager.GetConfig(ConfigName.ChangingCard)
|
2021-11-26 11:08:48 +08:00
|
|
|
|
local PassiveSkillConfig = ConfigManager.GetConfig(ConfigName.PlayerSkill)
|
2021-11-18 11:55:26 +08:00
|
|
|
|
local PropertyConfig = ConfigManager.GetConfig(ConfigName.PropertyConfig)
|
2021-11-16 15:24:17 +08:00
|
|
|
|
this.itemDataList = {} --state -1 未拥有 0 已有未激活 1激活未上阵 2上阵
|
2021-11-18 15:39:00 +08:00
|
|
|
|
this.SingleIncarnationPro = {}
|
|
|
|
|
this.SingleIncarnationProDes = ""
|
2022-04-24 16:50:24 +08:00
|
|
|
|
this.incarnationForceLv=1 --化身之力等级id
|
2021-11-11 16:48:15 +08:00
|
|
|
|
function this.Initialize()
|
2021-11-16 15:24:17 +08:00
|
|
|
|
this.InitItemDataList()
|
2021-11-11 16:48:15 +08:00
|
|
|
|
end
|
|
|
|
|
|
2021-11-16 15:24:17 +08:00
|
|
|
|
function this.InitItemDataList()
|
2021-11-18 11:55:26 +08:00
|
|
|
|
for k,v in ConfigPairs(ChangingCard) do
|
2022-04-22 18:24:33 +08:00
|
|
|
|
this.CreatEmptyItemData(v.Id)
|
2021-11-16 15:24:17 +08:00
|
|
|
|
end
|
2021-11-18 15:39:00 +08:00
|
|
|
|
local config = ConfigManager.GetConfigData(ConfigName.SpecialConfig,138)
|
|
|
|
|
local strs = string.split(config.Value,"|")
|
|
|
|
|
for i = 1,#strs do
|
|
|
|
|
local str = string.split(strs[i],"#")
|
|
|
|
|
local proId = tonumber(str[1])
|
|
|
|
|
local proNum = tonumber(str[2])
|
|
|
|
|
if not this.SingleIncarnationPro[proId] then
|
|
|
|
|
this.SingleIncarnationPro[proId] = 0
|
|
|
|
|
end
|
|
|
|
|
this.SingleIncarnationPro[proId] = this.SingleIncarnationPro[proId] + proNum
|
|
|
|
|
end
|
|
|
|
|
this.SingleIncarnationProDes = ""
|
|
|
|
|
this.SingleIncarnationProDes = this.GetproDesStr(this.SingleIncarnationProDes,this.SingleIncarnationPro)
|
2021-12-06 14:51:13 +08:00
|
|
|
|
Game.GlobalEvent:AddEvent(GameEvent.Bag.GetNewItemIncarnation, this.GetbagIncarnationData)
|
2021-11-16 15:24:17 +08:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function this.CreatEmptyItemData(id)
|
2022-04-22 13:17:58 +08:00
|
|
|
|
if id==nil then
|
|
|
|
|
return
|
|
|
|
|
end
|
2021-11-18 11:55:26 +08:00
|
|
|
|
if ChangingCard[id].IsOpen == 0 then
|
|
|
|
|
return
|
|
|
|
|
end
|
|
|
|
|
--以state字段来判断状态 pos 字段只是位置,不做判断
|
2021-11-16 15:24:17 +08:00
|
|
|
|
if not this.itemDataList[id] then
|
|
|
|
|
this.itemDataList[id] = {}
|
2021-11-18 11:55:26 +08:00
|
|
|
|
this.itemDataList[id].id = id
|
2022-04-24 16:50:24 +08:00
|
|
|
|
this.itemDataList[id].level=1
|
|
|
|
|
this.itemDataList[id].star=0
|
2021-11-18 11:55:26 +08:00
|
|
|
|
this.itemDataList[id].itemId = ChangingCard[id].CardId
|
|
|
|
|
this.itemDataList[id].name = itemConfig[ChangingCard[id].CardId].Name
|
2021-11-16 15:24:17 +08:00
|
|
|
|
this.itemDataList[id].state = -1
|
2021-11-18 11:55:26 +08:00
|
|
|
|
this.itemDataList[id].pos = 0
|
|
|
|
|
this.itemDataList[id].property = itemConfig[ChangingCard[id].CardId].PropertyName
|
|
|
|
|
this.itemDataList[id].quality = itemConfig[ChangingCard[id].CardId].Quantity
|
|
|
|
|
this.itemDataList[id].icon = itemConfig[ChangingCard[id].CardId].ResourceID
|
2021-11-26 11:08:48 +08:00
|
|
|
|
this.itemDataList[id].heroId = ChangingCard[id].desc2
|
2022-04-24 16:50:24 +08:00
|
|
|
|
this.itemDataList[id].proDatas =this.GetChangeCardProperty(id)
|
|
|
|
|
this.itemDataList[id].skillDatas = ChangingCard[id].Skill[1]
|
|
|
|
|
|
2021-11-16 15:24:17 +08:00
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
2021-11-18 15:39:00 +08:00
|
|
|
|
function this.GetproDesStr(_str,dataList)
|
|
|
|
|
local str = _str
|
|
|
|
|
for k,v in pairs(dataList) do
|
2021-11-26 14:11:23 +08:00
|
|
|
|
str = str..PropertyConfig[k].Info.."+"..GetPropertyFormatStrOne(PropertyConfig[k].Style,v).." "
|
2021-11-18 15:39:00 +08:00
|
|
|
|
end
|
|
|
|
|
return str
|
|
|
|
|
end
|
2022-04-26 14:21:24 +08:00
|
|
|
|
--获取化身卡指定星级的技能描述
|
2022-04-24 16:50:24 +08:00
|
|
|
|
function this.GetSkillDesStr(id,Star)
|
|
|
|
|
local skillId= ChangingCard[id].Skill[Star+1]
|
|
|
|
|
local skillDes= PassiveSkillConfig[skillId].Desc
|
|
|
|
|
return skillDes
|
|
|
|
|
end
|
|
|
|
|
---获取属性信息和技能信息
|
|
|
|
|
function this.GetCardPropDesStr(id)
|
|
|
|
|
local proDesList = {}
|
|
|
|
|
local str = "激活属性:"
|
|
|
|
|
str = this.GetproDesStr(str,this.itemDataList[id].proDatas)
|
|
|
|
|
table.insert(proDesList,str)
|
|
|
|
|
local skillDes = PassiveSkillConfig[this.itemDataList[id].skillDatas].Desc
|
|
|
|
|
table.insert(proDesList,skillDes)
|
|
|
|
|
return proDesList
|
|
|
|
|
end
|
|
|
|
|
|
2021-11-18 15:39:00 +08:00
|
|
|
|
function this.GetproDesLst(dataList,_color)
|
2021-11-29 14:45:23 +08:00
|
|
|
|
local lis1 = {}
|
2021-11-18 15:39:00 +08:00
|
|
|
|
for k,v in pairs(dataList) do
|
2021-11-29 14:45:23 +08:00
|
|
|
|
table.insert(lis1,{str = string.format("<color=#%s>%s+%s</color>",_color,PropertyConfig[k].Info,GetPropertyFormatStrOne(PropertyConfig[k].Style,v)) ,sort = PropertyConfig[k].SortId})
|
|
|
|
|
end
|
|
|
|
|
table.sort(lis1,function(a,b)
|
|
|
|
|
return a.sort < b.sort
|
|
|
|
|
end)
|
|
|
|
|
local list = {}
|
|
|
|
|
for i = 1,#lis1 do
|
|
|
|
|
table.insert(list,lis1[i].str)
|
2021-11-18 15:39:00 +08:00
|
|
|
|
end
|
|
|
|
|
return list
|
|
|
|
|
end
|
|
|
|
|
|
2022-04-24 16:50:24 +08:00
|
|
|
|
-- 初始化赋值操作 _incarnationForceLv化身之力等级id
|
|
|
|
|
function this.SetItemDataList(dataList,_incarnationForceLv)
|
2021-11-16 15:24:17 +08:00
|
|
|
|
for i = 1,#dataList do
|
2021-11-18 11:55:26 +08:00
|
|
|
|
local state = dataList[i].status
|
2022-04-24 16:50:24 +08:00
|
|
|
|
if dataList[i].status == 0 then
|
|
|
|
|
state = 1
|
|
|
|
|
elseif dataList[i].status == 1 then
|
|
|
|
|
state = 2
|
2021-11-18 11:55:26 +08:00
|
|
|
|
end
|
|
|
|
|
this.SetItemDataByid(dataList[i].id,state,dataList[i].index)
|
2022-04-22 18:24:33 +08:00
|
|
|
|
this.SetLevel(dataList[i].id,dataList[i].level)
|
|
|
|
|
this.SetStar(dataList[i].id,dataList[i].star)
|
2022-04-24 16:50:24 +08:00
|
|
|
|
this.SetSkillData(dataList[i].id)
|
2022-04-26 14:21:24 +08:00
|
|
|
|
this.SetPropDatas(dataList[i].id)
|
2022-04-24 16:50:24 +08:00
|
|
|
|
this.incarnationForceLv=_incarnationForceLv
|
2021-11-18 11:55:26 +08:00
|
|
|
|
end
|
|
|
|
|
HeroPropManager.SetFuncPropDirty(Func_Prop_Type.Incarnation)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function this.GetbagIncarnationData()
|
|
|
|
|
local data = BagManager.GetDataByItemType(ItemType.Incarnation)
|
|
|
|
|
for i = 1,#data do
|
|
|
|
|
this.SetItemDataByCardId(data[i].id)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function this.SetItemDataByCardId(id)
|
|
|
|
|
local config = ConfigManager.TryGetConfigDataByKey(ConfigName.ChangingCard,"CardId",id)
|
|
|
|
|
if config then
|
2022-04-22 18:24:33 +08:00
|
|
|
|
if this.itemDataList[config.Id] and this.itemDataList[config.Id].state < 1 then
|
2021-12-06 14:05:43 +08:00
|
|
|
|
if BagManager.GetItemCountById(id) > 0 then
|
2022-04-22 18:24:33 +08:00
|
|
|
|
this.SetItemDataByid(config.Id,0,0)
|
2021-12-06 14:05:43 +08:00
|
|
|
|
else
|
2022-04-22 18:24:33 +08:00
|
|
|
|
this.SetItemDataByid(config.Id,-1,0)
|
2021-12-06 14:05:43 +08:00
|
|
|
|
end
|
2021-11-18 11:55:26 +08:00
|
|
|
|
end
|
2021-11-16 15:24:17 +08:00
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
2021-11-18 11:55:26 +08:00
|
|
|
|
function this.SetItemDataByid(id,state,pos)
|
2021-11-16 15:24:17 +08:00
|
|
|
|
if not this.itemDataList[id] then
|
|
|
|
|
this.CreatEmptyItemData(id)
|
|
|
|
|
end
|
|
|
|
|
this.itemDataList[id].state = state
|
2021-11-18 11:55:26 +08:00
|
|
|
|
this.itemDataList[id].pos = pos
|
|
|
|
|
CheckRedPointStatus(this.itemDataList[id].property + 43801)
|
2021-11-16 15:24:17 +08:00
|
|
|
|
end
|
|
|
|
|
|
2022-04-22 18:24:33 +08:00
|
|
|
|
function this.SetLevel(id,level)
|
|
|
|
|
if level<=0 then
|
|
|
|
|
this.itemDataList[id].level=1
|
|
|
|
|
else
|
|
|
|
|
this.itemDataList[id].level=level
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function this.SetStar(id,star)
|
|
|
|
|
this.itemDataList[id].star=star
|
|
|
|
|
end
|
2022-04-26 14:21:24 +08:00
|
|
|
|
--设置激活技能数据
|
2022-04-24 16:50:24 +08:00
|
|
|
|
function this.SetSkillData(id)
|
|
|
|
|
local changeCardData=this.itemDataList[id]
|
|
|
|
|
changeCardData.skillDatas = ChangingCard[id].Skill[changeCardData.star+1]
|
|
|
|
|
end
|
2022-04-26 14:21:24 +08:00
|
|
|
|
--设置变身卡所有属性加成
|
2022-04-24 16:50:24 +08:00
|
|
|
|
function this.SetPropDatas(id)
|
|
|
|
|
this.itemDataList[id].proDatas =this.GetChangeCardProperty(id)
|
|
|
|
|
end
|
|
|
|
|
|
2021-12-06 15:43:05 +08:00
|
|
|
|
function this.GetStatusByItemId(id)
|
|
|
|
|
local config = ConfigManager.TryGetConfigDataByKey(ConfigName.ChangingCard,"CardId",id)
|
|
|
|
|
if config then
|
2022-04-26 10:14:52 +08:00
|
|
|
|
return this.itemDataList[config.Id].state
|
2021-12-06 15:43:05 +08:00
|
|
|
|
end
|
|
|
|
|
return -1
|
|
|
|
|
end
|
|
|
|
|
|
2022-04-24 16:50:24 +08:00
|
|
|
|
|
|
|
|
|
|
2021-11-18 11:55:26 +08:00
|
|
|
|
local sortData = {
|
|
|
|
|
[-1] = 0,
|
|
|
|
|
[0] = 2,
|
|
|
|
|
[1] = 1,
|
|
|
|
|
[2] = 1,
|
|
|
|
|
}
|
|
|
|
|
|
2021-11-16 15:24:17 +08:00
|
|
|
|
--根据属性获取化身数据
|
|
|
|
|
function this.GetItemDataListByPro(property)
|
|
|
|
|
local datas = {}
|
|
|
|
|
for k,v in pairs(this.itemDataList) do
|
|
|
|
|
if v.property == property then
|
|
|
|
|
table.insert(datas,v)
|
|
|
|
|
end
|
|
|
|
|
end
|
2021-11-18 11:55:26 +08:00
|
|
|
|
table.sort(datas,function(a,b)
|
|
|
|
|
if sortData[a.state] == sortData[b.state] then
|
|
|
|
|
if a.quality == b.quality then
|
|
|
|
|
return a.id < b.id
|
|
|
|
|
else
|
|
|
|
|
return a.quality > b.quality
|
|
|
|
|
end
|
|
|
|
|
else
|
|
|
|
|
return sortData[a.state] > sortData[b.state]
|
|
|
|
|
end
|
|
|
|
|
end)
|
2021-11-16 15:24:17 +08:00
|
|
|
|
return datas
|
|
|
|
|
end
|
|
|
|
|
|
2022-04-24 16:50:24 +08:00
|
|
|
|
--获取化身之力属性加成
|
2021-11-18 15:39:00 +08:00
|
|
|
|
function this.GetIncarnationPower()
|
2022-04-24 16:50:24 +08:00
|
|
|
|
local id =this.incarnationForceLv
|
|
|
|
|
local lvConfig=ConfigManager.GetConfigData(ConfigName.ChangingForce,id)
|
|
|
|
|
local proList=lvConfig.PropList
|
2021-11-18 15:39:00 +08:00
|
|
|
|
return proList
|
|
|
|
|
end
|
2022-04-24 16:50:24 +08:00
|
|
|
|
---获取身外化身所有属性加成
|
2021-11-18 11:55:26 +08:00
|
|
|
|
function this.GetIncarnationTotalPro()
|
|
|
|
|
local proList = {}
|
|
|
|
|
for k,v in pairs(this.itemDataList) do
|
|
|
|
|
if v.state > 0 then
|
|
|
|
|
for k,v in pairs(v.proDatas) do
|
|
|
|
|
if not proList[k] then
|
|
|
|
|
proList[k] = 0
|
|
|
|
|
end
|
|
|
|
|
proList[k] = proList[k] + v
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
2021-11-18 15:39:00 +08:00
|
|
|
|
local proList1 = this.GetIncarnationPower()
|
|
|
|
|
for k,v in pairs(proList1) do
|
2022-04-24 16:50:24 +08:00
|
|
|
|
if not proList[v[1]] then
|
|
|
|
|
proList[v[1]] = 0
|
2021-11-18 15:39:00 +08:00
|
|
|
|
end
|
2022-04-24 16:50:24 +08:00
|
|
|
|
proList[v[1]] = proList[v[1]] + v[2]
|
2021-11-18 15:39:00 +08:00
|
|
|
|
end
|
2021-11-18 11:55:26 +08:00
|
|
|
|
return proList
|
2021-11-16 15:24:17 +08:00
|
|
|
|
end
|
|
|
|
|
|
2021-11-18 11:55:26 +08:00
|
|
|
|
--获取已上阵的变身卡 --界面获取
|
|
|
|
|
function this.GetIncarnationData1()
|
|
|
|
|
local datas = {}
|
|
|
|
|
for k,v in pairs(this.itemDataList) do
|
|
|
|
|
if v.state == 2 then
|
|
|
|
|
datas[v.pos] = v
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
return datas
|
|
|
|
|
end
|
2021-11-16 15:24:17 +08:00
|
|
|
|
|
2021-11-18 11:55:26 +08:00
|
|
|
|
--获取已上阵的变身卡 --战斗获取
|
2021-11-16 15:24:17 +08:00
|
|
|
|
function this.GetIncarnationData()
|
|
|
|
|
local datas = {}
|
|
|
|
|
for k,v in pairs(this.itemDataList) do
|
|
|
|
|
if v.state == 2 then
|
2021-11-18 11:55:26 +08:00
|
|
|
|
table.insert(datas,v.id)
|
2021-11-16 15:24:17 +08:00
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
return datas
|
2021-11-11 16:48:15 +08:00
|
|
|
|
end
|
|
|
|
|
|
2021-11-26 19:36:20 +08:00
|
|
|
|
--获取已上阵的变身卡 --战斗获取
|
|
|
|
|
function this.GetIncarnationDataById(id)
|
|
|
|
|
for k,v in pairs(this.itemDataList) do
|
|
|
|
|
if v.itemId == id then
|
|
|
|
|
return v
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
return nil
|
|
|
|
|
end
|
|
|
|
|
|
2021-11-18 11:55:26 +08:00
|
|
|
|
function this.CheckRedData(red)
|
|
|
|
|
local list = {}
|
|
|
|
|
if red == RedPointType.incarnation_people then
|
|
|
|
|
list = this.GetItemDataListByPro(1)
|
|
|
|
|
elseif red == RedPointType.incarnation_buddish then
|
|
|
|
|
list = this.GetItemDataListByPro(2)
|
|
|
|
|
elseif red == RedPointType.incarnation_demon then
|
|
|
|
|
list = this.GetItemDataListByPro(3)
|
|
|
|
|
else
|
|
|
|
|
list = this.GetItemDataListByPro(4)
|
|
|
|
|
end
|
|
|
|
|
for k,v in pairs(list) do
|
|
|
|
|
if v.state == 0 then
|
|
|
|
|
return true
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
return false
|
|
|
|
|
end
|
|
|
|
|
|
2022-04-25 14:42:17 +08:00
|
|
|
|
---检测化身之力红点
|
|
|
|
|
function this.CheckPowerBtnRedData(red)
|
|
|
|
|
this.configData = ConfigManager.GetConfigData(ConfigName.ChangingForce,this.incarnationForceLv)
|
|
|
|
|
local curHaveItemNum=BagManager.GetItemCountById(this.configData.ExpCost[1])
|
|
|
|
|
local curCostItemNum=this.configData.ExpCost[2]
|
|
|
|
|
if curHaveItemNum >=curCostItemNum then
|
|
|
|
|
return true
|
|
|
|
|
end
|
|
|
|
|
return false
|
|
|
|
|
end
|
2022-04-22 18:24:33 +08:00
|
|
|
|
|
|
|
|
|
function this.GetChangeCardProperty(cardId,isNextLv,isNextStar)
|
|
|
|
|
local changeCardInfo=this.itemDataList[cardId]
|
|
|
|
|
local star=changeCardInfo.star
|
|
|
|
|
local level=changeCardInfo.level
|
|
|
|
|
if isNextStar then
|
|
|
|
|
star=star+1
|
|
|
|
|
end
|
|
|
|
|
if isNextLv then
|
|
|
|
|
level=level+1
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
if changeCardInfo then
|
|
|
|
|
local cardConfig=ConfigManager.GetConfigData(ConfigName.ChangingCard,cardId)
|
|
|
|
|
local propList={}
|
|
|
|
|
for k,v in pairs(cardConfig.PropList) do
|
|
|
|
|
propList[v[1]]=v[2]
|
|
|
|
|
end
|
|
|
|
|
if changeCardInfo then
|
|
|
|
|
if star>0 then
|
|
|
|
|
local startProp
|
|
|
|
|
if star==1 then
|
|
|
|
|
startProp=cardConfig.Star1UpProps
|
|
|
|
|
elseif star==2 then
|
|
|
|
|
startProp=cardConfig.Star2UpProps
|
|
|
|
|
elseif star==3 then
|
|
|
|
|
startProp=cardConfig.Star3UpProps
|
|
|
|
|
end
|
|
|
|
|
for k,v in pairs(startProp) do
|
|
|
|
|
if propList[v[1]] then
|
|
|
|
|
propList[v[1]]=propList[v[1]]+v[2]
|
|
|
|
|
else
|
|
|
|
|
propList[v[1]]=v[2]
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
if level>0 then
|
|
|
|
|
local cardLvConfig=ConfigManager.GetConfigDataByDoubleKey(ConfigName.ChangingCardLevel,"Level",level,"PoolId",cardConfig.LevelUpPool)
|
|
|
|
|
for k,v in pairs(cardLvConfig.PropList) do
|
|
|
|
|
if propList[v[1]] then
|
|
|
|
|
propList[v[1]]=propList[v[1]]+v[2]
|
|
|
|
|
else
|
|
|
|
|
propList[v[1]]=v[2]
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
return propList
|
|
|
|
|
end
|
|
|
|
|
return nil
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2021-11-11 16:48:15 +08:00
|
|
|
|
return this
|