miduo_client/Assets/ManagedResources/~Lua/Modules/GodWeapon/GodWeaponManager.lua

436 lines
14 KiB
Lua
Raw Normal View History

2023-03-24 11:08:03 +08:00
GodWeaponManager = {};
local this = GodWeaponManager
2023-03-28 13:57:59 +08:00
local shenBingConfig=ConfigManager.GetConfig(ConfigName.ShenBing)
local itemConfig=ConfigManager.GetConfig(ConfigName.ItemConfig)
local allGodWeapons={}
local godWeaponTeamInfo={}
local handBook={}
2023-03-24 11:08:03 +08:00
function this.Initialize()
2023-03-28 13:57:59 +08:00
end
function this.InitAllGodWeaponData(msg)
--LogError("#msg.infos============"..#msg.infos)
2023-03-28 13:57:59 +08:00
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)
2023-03-28 13:57:59 +08:00
godWeaponTeamInfo[pos]=GodWeapon
end
--LogError("static=="..staticId)
2023-03-28 13:57:59 +08:00
end
for i = 1, #msg.book do
2023-04-11 14:41:36 +08:00
LogError("msg.book[i]====="..msg.book[i])
2023-03-28 13:57:59 +08:00
handBook[msg.book[i]]=msg.book[i]
end
HeroPropManager.SetFuncPropDirty(Func_Prop_Type.Weapon)
2023-03-28 13:57:59 +08:00
end
function this.AddHandBook(id)
handBook[id]=id
end
function this.GetAllHandData()
return handBook
end
2023-03-28 13:57:59 +08:00
function this.GetAllWeapon()
return allGodWeapons
end
function this.GetAllTeamWeapon()
return godWeaponTeamInfo
end
--移除多个灵兽数据
function this.RemoveWeaponData(ids)
if not ids then
return
end
for i = 1,#ids do
local id=ids[i]
this.RemoveSingleWeaponData(id)
end
end
--获取所有灵兽羁绊总和属性 (羁绊属性直接加在团队属性上)
function this.GetAllWeaponFetterAddPros()
return TianShuMiJuanManger.GetAllFetterAddProsBy(5)
end
--移除灵兽数据
function this.RemoveSingleWeaponData(_did)
if not _did then return end
if allGodWeapons[_did] then
allGodWeapons[_did] = nil
end
end
2023-04-11 14:41:36 +08:00
2023-03-28 13:57:59 +08:00
function this.GetAllTeamWeaponId()
local list={}
for key, value in pairs(godWeaponTeamInfo) do
table.insert(list,value.staticId)
end
return list
end
2023-04-06 15:28:55 +08:00
---获取所有已上阵的位置
function this.GetAllTeamWeaponPos()
local list={}
for key, value in pairs(godWeaponTeamInfo) do
table.insert(list,value.point)
end
return list
end
2023-03-28 13:57:59 +08:00
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
2023-04-11 14:41:36 +08:00
if handBook[staticId]==nil then
handBook[staticId]=staticId
LogError("神兵字典加入新神兵========"..staticId)
TianShuMiJuanManger.CheckFetterStatus(5)
end
--Game.GlobalEvent:DispatchEvent(GameEvent.Pokemon.PokemonUpZhenRefresh)
--LogError("single static=="..staticId)
2023-03-28 13:57:59 +08:00
end
function this.GetSingleWeaponData(_id)
if allGodWeapons[_id] then
return allGodWeapons[_id]
end
return nil
end
2023-03-31 17:52:12 +08:00
---神兵升星刷新数据
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
2023-03-28 13:57:59 +08:00
2023-03-31 17:52:12 +08:00
---神兵升级刷新数据
function this.SetGodWeaponLv(_Did,_upLv)
if allGodWeapons[_Did] then
allGodWeapons[_Did].lv=allGodWeapons[_Did].lv+_upLv
end
end
2023-03-24 11:08:03 +08:00
2023-04-07 10:29:10 +08:00
function this.ResetGodWeapon(_Did,_lv,_star)
if allGodWeapons[_Did] then
allGodWeapons[_Did].lv=_lv
allGodWeapons[_Did].star=_star
end
end
2023-03-24 11:08:03 +08:00
2023-03-28 13:57:59 +08:00
--获取当前可上阵的所有灵兽数据 curUpZhenPokemonData 如果不为空就时替换上阵操作
2023-04-03 11:18:04 +08:00
function this.GetCanUpZhenWeapons(_curUpZhenGodWeapon)
2023-03-28 13:57:59 +08:00
local upZhenSidList = this.GetAllTeamWeaponId()
local curAllPokemonList = {}
for key, value in pairs(allGodWeapons) do
2023-04-03 11:18:04 +08:00
if _curUpZhenGodWeapon then
if value.Did~=_curUpZhenGodWeapon.Did then
--如果跟当前的是同一个神兵 并且
if CheckListIsContainValue1(upZhenSidList, value.staticId) then
if value.staticId==_curUpZhenGodWeapon.staticId then
table.insert(curAllPokemonList,value)
end
else
table.insert(curAllPokemonList,value)
end
2023-04-03 11:18:04 +08:00
end
else
if not CheckListIsContainValue1(upZhenSidList,value.staticId) then
table.insert(curAllPokemonList,value)
end
2023-03-28 13:57:59 +08:00
end
2023-04-03 11:18:04 +08:00
2023-03-28 13:57:59 +08:00
end
return curAllPokemonList
2023-03-24 11:08:03 +08:00
end
2023-03-29 10:48:35 +08:00
function this.GetNoUpZhenWeapons()
local list={}
for i = 1, #allGodWeapons do
--LogError("allGodWeapons[i].point=="..allGodWeapons[i].point)
2023-03-29 10:48:35 +08:00
end
for key, value in pairs(allGodWeapons) do
if value.point==0 then
table.insert(list,value)
end
end
return list
end
2023-03-28 13:57:59 +08:00
--碎片可以合成红点
function this.WeaponChipCompoundRedPoint()
2023-04-12 11:31:04 +08:00
-- local isOpen = ActTimeCtrlManager.SingleFuncState(FUNCTION_OPEN_TYPE.POKEMON)
-- if not isOpen then
-- return false
-- end
local isOpen=CheckFunctionOpen(FUNCTION_OPEN_TYPE.GodWeapon)
2023-03-28 13:57:59 +08:00
if not isOpen then
2023-04-12 11:31:04 +08:00
LogError("神兵功能未开启-------------------")
return false
2023-03-28 13:57:59 +08:00
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
2023-04-12 11:31:04 +08:00
LogError("神兵碎片可以合成红点true")
2023-03-28 13:57:59 +08:00
return true
end
end
end
-- LogPink("碎片可以合成红点false")
return false
end
--设置神兵上阵下阵
function this.SetWeaponUpZhen(id,pos)
if allGodWeapons[id] then
2023-04-03 11:18:04 +08:00
local point1=allGodWeapons[id].point
2023-03-28 13:57:59 +08:00
if pos~=0 then
2023-03-28 17:51:43 +08:00
if point1~=0 then
godWeaponTeamInfo[point1]=nil
end
2023-03-28 13:57:59 +08:00
allGodWeapons[id].point=pos
godWeaponTeamInfo[pos]=allGodWeapons[id]
else
allGodWeapons[id].point=pos
2023-04-03 11:18:04 +08:00
godWeaponTeamInfo[point1]=nil
2023-03-28 13:57:59 +08:00
end
HeroPropManager.SetFuncPropDirty(Func_Prop_Type.Weapon)
2023-03-28 13:57:59 +08:00
end
end
2023-03-28 17:51:43 +08:00
--改变神兵位置
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
2023-03-28 13:57:59 +08:00
--获取灵兽编队属性
function this.GetPokemonFormationAddPro()
local allPro = {}
--LogError("获取神兵编对属性-----------------------")
2023-03-28 13:57:59 +08:00
for key, value in pairs(godWeaponTeamInfo) do
if key and allGodWeapons[value.Did] then
--LogError("value.did=================="..value.Did)
2023-03-28 13:57:59 +08:00
local curPokemonAddPro = this.GetSinglePokemonAddProData(value.Did)
HeroManager.DoubleTableCompound(allPro, curPokemonAddPro)
end
end
return allPro
end
--获取神兵编队属性 在编队中的团队属性加成 除以英雄编队人数
function this.GetWeaponFormationTeamAddPro(heroFormationNum)
local allPro = this.GetPokemonFormationAddPro()
-- local formationHeros = FormationManager.GetWuJinFormationHeroIds(formationIndex)
-- local heroFormationNum = #formationHeros
for key, value in pairs(allPro) do
--LogError("key====="..key.." value=="..value/heroFormationNum)
allPro[key] = math.floor(value)
end
return allPro
end
2023-03-28 13:57:59 +08:00
--获取单个神兵属性 (灵兽属性/编队人数 神兵属性会平分给上阵的所有神将)
2023-03-30 13:16:11 +08:00
function this.GetSinglePokemonAddProData(_did,_star,_lv)--_star 传值的话就用此星级计算属性
2023-03-28 13:57:59 +08:00
-- 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)
2023-03-30 13:16:11 +08:00
local curPokemonLvConFig = ConfigManager.GetConfigDataByDoubleKey(ConfigName.ShenBingLevel,"Quality",curPokemonConFig.Quality,"Level",_lv and _lv or curPokeonData.lv)
2023-03-28 13:57:59 +08:00
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
2023-04-07 18:40:50 +08:00
--获取单个神兵属性 (灵兽属性/编队人数 神兵属性会平分给上阵的所有神将)
function this.GetSinglePokemonAddProData2(_did,_star,_lv)--_star 传值的话就用此星级计算属性
-- LogPink("_did 1 ".._did)
local addAllProVal = {}
local curPokemonConFig = ConfigManager.GetConfigData(ConfigName.ShenBing,_did)
local curPokemonLvConFig = ConfigManager.GetConfigDataByDoubleKey(ConfigName.ShenBingLevel,"Quality",curPokemonConFig.Quality,"Level",_lv )
local curPokemonStarConFig = ConfigManager.GetConfigDataByDoubleKey(ConfigName.ShenbingStar,"Quality",curPokemonConFig.Quality,"Star",_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
2023-03-30 13:16:11 +08:00
--获取技能信息(名字,描述)
2023-03-30 16:27:13 +08:00
function this.GetSingleGodWeaponSkillDes(_did,_star)
2023-03-30 13:16:11 +08:00
if not allGodWeapons[_did] then return end
local _data = allGodWeapons[_did]
2023-03-30 16:27:13 +08:00
local shenBingSkills=ConfigManager.GetAllConfigsDataByDoubleKey(ConfigName.ShenBingSkill,"SpiritAnimalMatch",_data.id,"StarMatch",_star and _star or _data.star)
2023-03-30 13:16:11 +08:00
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
2023-04-04 15:38:45 +08:00
skillInfos[i].icon=GetResourcePath(shenBingSkills[i].Icon)
2023-03-30 13:16:11 +08:00
end
return skillInfos
end
2023-04-04 14:54:14 +08:00
----获取升星可使用材料
2023-03-31 17:52:12 +08:00
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
2023-04-04 14:54:14 +08:00
--检测升级红点
function this.CheckUpLvRedPoint(_curData)
local levelConfig=ConfigManager.GetConfigDataByDoubleKey(ConfigName.ShenBingLevel,"Level",_curData.lv,"Quality",_curData.config.Quality)
if not levelConfig.Consume[1][2] then
return false
end
for i = 1, #levelConfig.Consume do
local haveCount=BagManager.GetItemCountById(levelConfig.Consume[i][1])
if haveCount<levelConfig.Consume[i][2] then
return false
end
end
return true
end
2023-03-31 17:52:12 +08:00
2023-04-04 14:54:14 +08:00
---检测升星红点
function this.CheckUpStarRedPoint(_curData)
local starConfig=ConfigManager.GetConfigDataByDoubleKey(ConfigName.ShenbingStar,"Star",_curData.star,"Quality",_curData.config.Quality)
if starConfig.ConsumeItemNum<=0 then
return false
end
local costList=this.GetUpStarCost(_curData)
return #costList>starConfig.ConsumeItemNum
end
2023-04-04 18:21:14 +08:00
--检测主城神兵红点
function this.CheckGodWeaponRedPoint()
2023-04-12 11:31:04 +08:00
LogError("====================================检测主城神兵红点")
--检测可上阵
2023-04-11 14:41:36 +08:00
local list=GodWeaponManager.GetCanUpZhenWeapons()
if #list>0 then
return true
end
2023-04-12 11:31:04 +08:00
--检测上阵可升级升星
2023-04-04 18:21:14 +08:00
for key, value in pairs(godWeaponTeamInfo) do
if value then
if this.CheckUpLvRedPoint(value) or this.CheckUpStarRedPoint(value) then
return true
end
end
end
2023-04-12 11:31:04 +08:00
--检测可合成
2023-04-11 14:41:36 +08:00
local isCanHe=this.WeaponChipCompoundRedPoint()
if isCanHe then
return true
end
2023-04-12 11:31:04 +08:00
local jiban=TianShuMiJuanManger.CheckRedPoint(5)
if jiban then
return true
end
2023-04-04 18:21:14 +08:00
return false
end
2023-03-24 11:08:03 +08:00
return this