210 lines
6.5 KiB
Lua
210 lines
6.5 KiB
Lua
|
--法灵管理
|
||
|
FaLingManager = {}
|
||
|
local this = FaLingManager
|
||
|
local itemConfig=ConfigManager.GetConfig(ConfigName.ItemConfig)
|
||
|
local equipConfig=ConfigManager.GetConfig(ConfigName.EquipConfig)
|
||
|
function this.Initialize()
|
||
|
--所有法灵数据
|
||
|
this.allEquipData={}
|
||
|
--所有作为庇护法灵的id列表
|
||
|
this.allBlessIds={}
|
||
|
end
|
||
|
|
||
|
--初始化所有数据
|
||
|
function this.InitAllEquipData(_list)
|
||
|
for i=1,#_list do
|
||
|
local data=this.initSingleData(_list[i])
|
||
|
LogError("data.did======================="..data.did)
|
||
|
this.allEquipData[data.did]=data
|
||
|
if data.belongHero~=nil and data.belongHero~="" then
|
||
|
LogError("计算当前英雄的法灵添加的属性================="..data.belongHero)
|
||
|
HeroPropManager.SetDirtyByType(data.belongHero, Hero_Prop_Type.Talisman)
|
||
|
end
|
||
|
end
|
||
|
LogError("法灵 this.allEquipData len=========================="..#this.allEquipData)
|
||
|
end
|
||
|
|
||
|
--初始化单个法灵数据
|
||
|
function this.initSingleData(_data)
|
||
|
local data={}
|
||
|
data.did=_data.id
|
||
|
data.staticId=_data.equipId
|
||
|
data.lv=_data.exp
|
||
|
data.itemConfig=itemConfig[data.staticId]
|
||
|
data.frame=GetQuantityImageByquality(data.itemConfig.Quantity)
|
||
|
data.icon=GetResourcePath(data.itemConfig.ResourceID)
|
||
|
LogError("_data.heroId=====================".._data.heroId)
|
||
|
data.belongHero = _data.heroId
|
||
|
data.bless={}
|
||
|
if _data.bless and #_data.bless>0 then
|
||
|
for i=1,#_data.bless do
|
||
|
local single=this.initSingleData(_data.bless[i])
|
||
|
--data.bless[single.did]=single
|
||
|
table.insert(data.bless,single)
|
||
|
LogError("护佑id======================="..single.did.." 被忽悠的法灵"..data.itemConfig.Name.." "..data.lv)
|
||
|
table.insert(this.allBlessIds,single.did)
|
||
|
end
|
||
|
end
|
||
|
return data
|
||
|
end
|
||
|
--获取所有没有庇护的法灵,没有穿戴的法灵
|
||
|
function this.GetAllEquipDataNoBless()
|
||
|
local list={}
|
||
|
for k, v in pairs(this.allEquipData) do
|
||
|
if CheckListIsContainValue1(this.allBlessIds,k)==false and (v.belongHero==nil or v.belongHero=="") then
|
||
|
table.insert(list,v)
|
||
|
end
|
||
|
end
|
||
|
table.sort(list,function(a,b)
|
||
|
return a.lv>b.lv
|
||
|
end)
|
||
|
return list
|
||
|
end
|
||
|
--获取升级升星需要的材料
|
||
|
function this.GetAllUpListNoBless(_id)
|
||
|
local list={}
|
||
|
for k, v in pairs(this.allEquipData) do
|
||
|
if CheckListIsContainValue1(this.allBlessIds,k)==false and (v.belongHero==nil or v.belongHero=="") and v.staticId==_id then
|
||
|
table.insert(list,v)
|
||
|
end
|
||
|
end
|
||
|
return list
|
||
|
end
|
||
|
|
||
|
--获取可以护佑法灵集合
|
||
|
function this.GetCanBlessEquipList()
|
||
|
local list={}
|
||
|
local canLv=this.GetBlessOpenLv()
|
||
|
for k, v in pairs(this.allEquipData) do
|
||
|
if CheckListIsContainValue1(this.allBlessIds,k)==false and (v.belongHero==nil or v.belongHero=="") and v.lv>=canLv then
|
||
|
table.insert(list,v)
|
||
|
end
|
||
|
end
|
||
|
return list
|
||
|
end
|
||
|
|
||
|
|
||
|
|
||
|
--获取护佑开启等级
|
||
|
function this.GetBlessOpenLv()
|
||
|
local config = ConfigManager.GetConfigData(ConfigName.SpecialConfig, 166)
|
||
|
return tonumber(config.Value)
|
||
|
end
|
||
|
--获取护佑增加属性
|
||
|
function this.GetBlessEquipAddPro()
|
||
|
local config = ConfigManager.GetConfigData(ConfigName.SpecialConfig, 167)
|
||
|
return tonumber(config.Value)
|
||
|
end
|
||
|
--获取护佑法宝数量
|
||
|
function this.GetBlessEquipNum()
|
||
|
local config = ConfigManager.GetConfigData(ConfigName.SpecialConfig, 168)
|
||
|
return tonumber(config.Value)
|
||
|
end
|
||
|
|
||
|
|
||
|
--获取法灵增加的属性
|
||
|
function this.GetEquipAddPropByDid(_did)
|
||
|
local addProp={}
|
||
|
if _did then
|
||
|
LogError("英雄穿戴法灵 did====".._did)
|
||
|
end
|
||
|
|
||
|
if this.allEquipData[_did] then
|
||
|
LogError("1111111111111111111111".._did)
|
||
|
local data=ConfigManager.TryGetConfigDataByDoubleKey(ConfigName.EquipTalismana,"TalismanaId",this.allEquipData[_did].staticId,"Level",this.allEquipData[_did].lv)
|
||
|
if data then
|
||
|
LogError("2222222222222222222222222222222".._did)
|
||
|
local blessNum=#this.allEquipData[_did].bless
|
||
|
local add=this.GetBlessEquipAddPro()*blessNum
|
||
|
if data.Property and #data.Property>0 then
|
||
|
for i=1, #data.Property do
|
||
|
local key=data.Property[i][1]
|
||
|
local value = data.Property[i][2]
|
||
|
value=value+add
|
||
|
addProp[key]=value
|
||
|
--LogError("法灵add key================"..key.." value==========="..value)
|
||
|
end
|
||
|
end
|
||
|
end
|
||
|
end
|
||
|
return addProp
|
||
|
end
|
||
|
|
||
|
|
||
|
|
||
|
function this.SetEquipBelongHero(_did,_heroId)
|
||
|
if this.allEquipData[_did] then
|
||
|
this.allEquipData[_did].belongHero=_heroId
|
||
|
end
|
||
|
end
|
||
|
|
||
|
--设置法灵等级
|
||
|
function this.SetEquipLv(_did,_lv)
|
||
|
if this.allEquipData[_did] then
|
||
|
this.allEquipData[_did].lv=_lv
|
||
|
end
|
||
|
end
|
||
|
|
||
|
|
||
|
--
|
||
|
function this.AddEquipToList(_data)
|
||
|
local single=this.initSingleData(_data)
|
||
|
this.allEquipData[single.did]=single
|
||
|
end
|
||
|
|
||
|
function this.RemoveEquip(_did)
|
||
|
if this.allEquipData[_did] then
|
||
|
this.allEquipData[_did]=nil
|
||
|
end
|
||
|
end
|
||
|
|
||
|
|
||
|
--获取所有没有庇护的法灵
|
||
|
function this.GetAllEquipData()
|
||
|
return this.allEquipData
|
||
|
end
|
||
|
|
||
|
--获取法灵数据
|
||
|
function this.GetEquipDataByDid(_did)
|
||
|
LogError("_did=========================".._did)
|
||
|
if this.allEquipData[_did] then
|
||
|
return this.allEquipData[_did]
|
||
|
end
|
||
|
return nil
|
||
|
end
|
||
|
|
||
|
|
||
|
|
||
|
--设置法灵的庇护法灵
|
||
|
function this.SetEquipBlessEquip(_did,_blessId)
|
||
|
if this.allEquipData[_did] and this.allEquipData[_blessId] then
|
||
|
if #this.allEquipData[_blessId].bless>0 then
|
||
|
LogError("作为庇护的法灵已有庇护")
|
||
|
return
|
||
|
end
|
||
|
--[_blessId]=this.allEquipData[_blessId]
|
||
|
LogError("建立护佑关系--------------------------------")
|
||
|
table.insert(this.allEquipData[_did].bless,this.allEquipData[_blessId])
|
||
|
table.insert(this.allBlessIds,_blessId)
|
||
|
end
|
||
|
end
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
--移除法灵的庇护法灵
|
||
|
function this.RemoveEquipBlessEquip(_did,_blessId)
|
||
|
if this.allEquipData[_did] and this.allEquipData[_blessId] then
|
||
|
LogError("数据厘米11111111111111111111111111111111111")
|
||
|
--table.removebyvalue(this.allEquipData[_did].bless,this.allEquipData[_blessId])
|
||
|
for k, v in pairs(this.allEquipData[_did].bless) do
|
||
|
if v.did==_blessId then
|
||
|
LogError("移除成功")
|
||
|
table.removebyvalue(this.allEquipData[_did].bless,v)
|
||
|
end
|
||
|
end
|
||
|
table.removebyvalue(this.allBlessIds,_blessId)
|
||
|
end
|
||
|
end
|
||
|
|
||
|
return this
|