260 lines
8.3 KiB
Lua
260 lines
8.3 KiB
Lua
GodWeaponManager = {};
|
||
local this = GodWeaponManager
|
||
local shenBingConfig=ConfigManager.GetConfig(ConfigName.ShenBing)
|
||
local itemConfig=ConfigManager.GetConfig(ConfigName.ItemConfig)
|
||
local allGodWeapons={}
|
||
local godWeaponTeamInfo={}
|
||
local handBook={}
|
||
|
||
function this.Initialize()
|
||
|
||
end
|
||
|
||
function this.InitAllGodWeaponData(msg)
|
||
|
||
LogError("#msg.infos============"..#msg.infos)
|
||
for i = 1, #msg.infos do
|
||
local GodWeapon={}
|
||
GodWeapon.Did=msg.infos[i].id
|
||
local staticId=msg.infos[i].tmpId
|
||
GodWeapon.id=staticId
|
||
GodWeapon.staticId=staticId
|
||
GodWeapon.dynamicId=msg.infos[i].id
|
||
GodWeapon.lv=msg.infos[i].level
|
||
GodWeapon.star=msg.infos[i].star
|
||
local pos=msg.infos[i].point
|
||
GodWeapon.point=pos
|
||
GodWeapon.live=shenBingConfig[staticId].Painting
|
||
GodWeapon.scale=shenBingConfig[staticId].Scale
|
||
GodWeapon.position=shenBingConfig[staticId].Position
|
||
GodWeapon.config=shenBingConfig[staticId]
|
||
allGodWeapons[GodWeapon.Did]=GodWeapon
|
||
if pos~=0 then
|
||
LogError("pos============================="..pos)
|
||
godWeaponTeamInfo[pos]=GodWeapon
|
||
end
|
||
LogError("static=="..staticId)
|
||
end
|
||
for i = 1, #msg.book do
|
||
LogError("msg.book[i]====="..msg.book[i])
|
||
handBook[msg.book[i]]=msg.book[i]
|
||
end
|
||
end
|
||
function this.GetAllWeapon()
|
||
return allGodWeapons
|
||
end
|
||
|
||
function this.GetAllTeamWeapon()
|
||
return godWeaponTeamInfo
|
||
end
|
||
|
||
function this.GetAllTeamWeaponId()
|
||
local list={}
|
||
for key, value in pairs(godWeaponTeamInfo) do
|
||
table.insert(list,value.staticId)
|
||
end
|
||
return list
|
||
end
|
||
|
||
function this.InitSingleGodWeaponData(data)
|
||
local GodWeapon={}
|
||
local GodWeapon={}
|
||
GodWeapon.Did=data.id
|
||
local staticId=data.tmpId
|
||
GodWeapon.id=staticId
|
||
GodWeapon.staticId=staticId
|
||
GodWeapon.dynamicId=data.id
|
||
GodWeapon.lv=data.level
|
||
GodWeapon.star=data.star
|
||
local pos=data.point
|
||
GodWeapon.point=pos
|
||
GodWeapon.live=shenBingConfig[staticId].Painting
|
||
GodWeapon.scale=shenBingConfig[staticId].Scale
|
||
GodWeapon.position=shenBingConfig[staticId].Position
|
||
GodWeapon.config=shenBingConfig[staticId]
|
||
allGodWeapons[GodWeapon.Did]=GodWeapon
|
||
handBook[staticId]=staticId
|
||
LogError("single static=="..staticId)
|
||
end
|
||
|
||
function this.GetSingleWeaponData(_id)
|
||
if allGodWeapons[_id] then
|
||
return allGodWeapons[_id]
|
||
end
|
||
return nil
|
||
end
|
||
---神兵升星刷新数据
|
||
function this.SetGodWeaponStar(_Did)
|
||
if allGodWeapons[_Did] then
|
||
allGodWeapons[_Did].star=allGodWeapons[_Did].star+1
|
||
end
|
||
end
|
||
|
||
---升星消耗更新消耗数据
|
||
function this.SetGodWeaponUpStarCost(_costDids)
|
||
for i = 1, #_costDids do
|
||
if allGodWeapons[_costDids[i]] then
|
||
allGodWeapons[_costDids[i]]=nil
|
||
end
|
||
end
|
||
end
|
||
|
||
---神兵升级刷新数据
|
||
function this.SetGodWeaponLv(_Did,_upLv)
|
||
if allGodWeapons[_Did] then
|
||
allGodWeapons[_Did].lv=allGodWeapons[_Did].lv+_upLv
|
||
end
|
||
end
|
||
|
||
|
||
--获取当前可上阵的所有灵兽数据 curUpZhenPokemonData 如果不为空就时替换上阵操作
|
||
function this.GetCanUpZhenWeapons()
|
||
local upZhenSidList = this.GetAllTeamWeaponId()
|
||
local curAllPokemonList = {}
|
||
for key, value in pairs(allGodWeapons) do
|
||
if not CheckListIsContainValue1(upZhenSidList,value.staticId) then
|
||
table.insert(curAllPokemonList,value)
|
||
end
|
||
end
|
||
return curAllPokemonList
|
||
end
|
||
|
||
function this.GetNoUpZhenWeapons()
|
||
local list={}
|
||
for i = 1, #allGodWeapons do
|
||
LogError("allGodWeapons[i].point=="..allGodWeapons[i].point)
|
||
|
||
end
|
||
for key, value in pairs(allGodWeapons) do
|
||
if value.point==0 then
|
||
table.insert(list,value)
|
||
end
|
||
end
|
||
return list
|
||
end
|
||
|
||
|
||
--碎片可以合成红点
|
||
function this.WeaponChipCompoundRedPoint()
|
||
local isOpen = ActTimeCtrlManager.SingleFuncState(FUNCTION_OPEN_TYPE.POKEMON)
|
||
if not isOpen then
|
||
return false
|
||
end
|
||
local pokemonChipList = BagManager.GetDataByItemType(ItemType.GodWeaponChip)
|
||
if #pokemonChipList > 0 then
|
||
for i = 1, #pokemonChipList do
|
||
if BagManager.GetItemCountById(pokemonChipList[i].id) >= itemConfig[pokemonChipList[i].id].UsePerCount then
|
||
-- LogPink("碎片可以合成红点true")
|
||
return true
|
||
end
|
||
end
|
||
end
|
||
-- LogPink("碎片可以合成红点false")
|
||
return false
|
||
end
|
||
|
||
--设置神兵上阵下阵
|
||
function this.SetWeaponUpZhen(id,pos)
|
||
if allGodWeapons[id] then
|
||
if pos~=0 then
|
||
local point1=allGodWeapons[id].point
|
||
if point1~=0 then
|
||
godWeaponTeamInfo[point1]=nil
|
||
end
|
||
allGodWeapons[id].point=pos
|
||
godWeaponTeamInfo[pos]=allGodWeapons[id]
|
||
else
|
||
allGodWeapons[id].point=pos
|
||
godWeaponTeamInfo[pos]=nil
|
||
end
|
||
end
|
||
end
|
||
|
||
--改变神兵位置
|
||
function this.ChangeWeaponPos(id1,id2)
|
||
if allGodWeapons[id1] and allGodWeapons[id2] then
|
||
local pos1=allGodWeapons[id1].point
|
||
local pos2=allGodWeapons[id2].point
|
||
allGodWeapons[id1].point=pos2
|
||
allGodWeapons[id2].point=pos1
|
||
godWeaponTeamInfo[pos1]=allGodWeapons[id2]
|
||
godWeaponTeamInfo[pos2]=allGodWeapons[id1]
|
||
end
|
||
end
|
||
|
||
|
||
|
||
--获取灵兽编队属性
|
||
function this.GetPokemonFormationAddPro()
|
||
local allPro = {}
|
||
for key, value in pairs(godWeaponTeamInfo) do
|
||
if key and allGodWeapons[value.Did] then
|
||
local curPokemonAddPro = this.GetSinglePokemonAddProData(value.Did)
|
||
HeroManager.DoubleTableCompound(allPro, curPokemonAddPro)
|
||
end
|
||
end
|
||
return allPro
|
||
end
|
||
|
||
--获取单个神兵属性 (灵兽属性/编队人数 神兵属性会平分给上阵的所有神将)
|
||
function this.GetSinglePokemonAddProData(_did,_star,_lv)--_star 传值的话就用此星级计算属性
|
||
-- LogPink("_did 1 ".._did)
|
||
if not allGodWeapons[_did] then return end
|
||
local addAllProVal = {}
|
||
local curPokeonData = allGodWeapons[_did]
|
||
local curPokemonConFig = ConfigManager.GetConfigData(ConfigName.ShenBing,curPokeonData.id)
|
||
local curPokemonLvConFig = ConfigManager.GetConfigDataByDoubleKey(ConfigName.ShenBingLevel,"Quality",curPokemonConFig.Quality,"Level",_lv and _lv or curPokeonData.lv)
|
||
local curPokemonStarConFig = ConfigManager.GetConfigDataByDoubleKey(ConfigName.ShenbingStar,"Quality",curPokemonConFig.Quality,"Star",_star and _star or curPokeonData.star)
|
||
--基础
|
||
addAllProVal[HeroProType.Hp] = curPokemonConFig.Hp
|
||
addAllProVal[HeroProType.Attack] = curPokemonConFig.Attack
|
||
addAllProVal[HeroProType.PhysicalDefence] = curPokemonConFig.PhysicalDefence
|
||
addAllProVal[HeroProType.MagicDefence] = curPokemonConFig.MagicDefence
|
||
--升级
|
||
for i = 1, #curPokemonLvConFig.CharacterLevelPara do
|
||
local curPro = curPokemonLvConFig.CharacterLevelPara[i]
|
||
if curPro[2] > 0 then
|
||
if addAllProVal[curPro[1]] then
|
||
addAllProVal[curPro[1]]=addAllProVal[curPro[1]]+curPro[2]
|
||
else
|
||
addAllProVal[curPro[1]]=curPro[2]
|
||
end
|
||
end
|
||
end
|
||
--升星 属性=(基础属性+等级属性)*(1+星级倍率)
|
||
local StarPara = curPokemonStarConFig.StarPara/10000
|
||
local addEndAllProVal = {}
|
||
for key, value in pairs(addAllProVal) do
|
||
addEndAllProVal[key] = math.floor(value * (1 + StarPara))
|
||
end
|
||
return addEndAllProVal
|
||
end
|
||
|
||
|
||
--获取技能信息(名字,描述)
|
||
function this.GetSingleGodWeaponSkillDes(_did,_star)
|
||
if not allGodWeapons[_did] then return end
|
||
local _data = allGodWeapons[_did]
|
||
local shenBingSkills=ConfigManager.GetAllConfigsDataByDoubleKey(ConfigName.ShenBingSkill,"SpiritAnimalMatch",_data.id,"StarMatch",_star and _star or _data.star)
|
||
local skillInfos={}
|
||
for i = 1, #shenBingSkills do
|
||
skillInfos[i]={}
|
||
skillInfos[i].title=shenBingSkills[i].Name
|
||
skillInfos[i].des=shenBingSkills[i].Desc
|
||
skillInfos[i].skillPanDuan=shenBingSkills[i].SkillPanDuan
|
||
end
|
||
return skillInfos
|
||
end
|
||
|
||
----获取升星需要材料
|
||
function this.GetUpStarCost(_curData)
|
||
local costList={}
|
||
for key, value in pairs(allGodWeapons) do
|
||
if value.id==_curData.id and value.Did~=_curData.Did and value.lv<=1 and value.star<=0 then
|
||
table.insert(costList,value.Did)
|
||
end
|
||
end
|
||
return costList
|
||
end
|
||
|
||
return this |