66 lines
1.7 KiB
Lua
66 lines
1.7 KiB
Lua
IncarnationManager = {}
|
|
local this = IncarnationManager
|
|
local itemConfig = ConfigManager.GetConfig(ConfigName.ItemConfig)
|
|
|
|
this.itemDataList = {} --state -1 未拥有 0 已有未激活 1激活未上阵 2上阵
|
|
function this.Initialize()
|
|
this.InitItemDataList()
|
|
end
|
|
|
|
function this.InitItemDataList()
|
|
local configs = ConfigManager.GetAllConfigsDataByKey(ConfigName.ItemConfig,"Type",ItemType.Incarnation)
|
|
for i = 1,#configs do
|
|
this.CreatEmptyItemData(configs[i].Id)
|
|
end
|
|
end
|
|
|
|
function this.CreatEmptyItemData(id)
|
|
if not this.itemDataList[id] then
|
|
this.itemDataList[id] = {}
|
|
this.itemDataList[id].itemId = id
|
|
this.itemDataList[id].state = -1
|
|
this.itemDataList[id].property = itemConfig[id].PropertyName
|
|
end
|
|
end
|
|
|
|
function this.SetItemDataList(dataList)
|
|
for i = 1,#dataList do
|
|
this.SetItemDataByid(dataList[i].id,dataList[i].state)
|
|
end
|
|
end
|
|
|
|
function this.SetItemDataByid(id,state)
|
|
if not this.itemDataList[id] then
|
|
this.CreatEmptyItemData(id)
|
|
end
|
|
this.itemDataList[id].state = state
|
|
end
|
|
|
|
--根据属性获取化身数据
|
|
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
|
|
return datas
|
|
end
|
|
|
|
function this.GetPropertyData()
|
|
end
|
|
|
|
|
|
|
|
--获取已上阵的变身卡
|
|
function this.GetIncarnationData()
|
|
local datas = {}
|
|
for k,v in pairs(this.itemDataList) do
|
|
if v.state == 2 then
|
|
table.insert(datas,v.Id)
|
|
end
|
|
end
|
|
return datas
|
|
end
|
|
|
|
return this |