miduo_client/Assets/ManagedResources/~Lua/Modules/Practice/PracticeManager.lua

753 lines
26 KiB
Lua
Raw Normal View History

2021-05-11 17:23:19 +08:00
PracticeManager = {}
local this = PracticeManager
2021-05-13 17:37:47 +08:00
local XiuXianConfig = ConfigManager.GetConfig(ConfigName.XiuXianConfig)
2021-05-12 17:40:38 +08:00
local PropertyConfig = ConfigManager.GetConfig(ConfigName.PropertyConfig)
2021-05-13 17:37:47 +08:00
local XiuXianSkillConfig = ConfigManager.GetConfig(ConfigName.XiuXianSkillConfig)
2021-10-20 21:33:37 +08:00
local SkillBaseConfig= ConfigManager.GetConfig(ConfigName.PlayerSkillBasicTable)
2021-10-22 10:21:07 +08:00
local skillSystemConfig = ConfigManager.GetConfigData(ConfigName.GlobalSystemConfig,FUNCTION_OPEN_TYPE.PLAYER_SKILL)
2021-05-11 17:23:19 +08:00
function this.Initialize()
2021-05-13 17:37:47 +08:00
this.PracticeLevel = 1--小境界id
this.PracticeBigLevel = 1--大境界数
this.StarNum = 0--星星的数量
-- this.PracticeConfigData = {}
this.ImprintServerData = {}--服务器发来的神印信息
this.BigLevelImprintList = {}--大境界对应的神印
2021-05-18 20:04:52 +08:00
this.HeroWithImprintList = {}--英雄身上的神印
2021-05-19 14:46:51 +08:00
this.PointsData = {}
this.LinesData = {}
2021-09-09 20:45:12 +08:00
this.FourQuadrantData={}--四象心法数据
this.fourQuadrantUpStarPropMap={}--四象心法进阶属性加成职业id<属性id属性值>
2021-10-20 21:33:37 +08:00
this.playerSkillList={} --主角技能列表
2021-10-19 18:34:10 +08:00
this.CultivationLevel = 0
2021-10-20 21:33:37 +08:00
for key, value in ConfigPairs(SkillBaseConfig) do
this.playerSkillList[value.Id]=0
end
end
2021-10-22 11:56:46 +08:00
--=========================主角技能
2021-10-20 21:33:37 +08:00
function this.GetSkillInfo()
return this.playerSkillList
end
--更新角色技能
function this.UpdataPlayerSkill(msg)
for i = 1, #msg do
if this.playerSkillList[msg[i].skillId] then
this.playerSkillList[msg[i].skillId]=msg[i].skillLv
end
end
2021-10-22 10:21:07 +08:00
2021-10-20 21:33:37 +08:00
end
--设置角色技能等级
function this.SetPlayerSkill(id,lv)
if this.playerSkillList[id] then
this.playerSkillList[id]=lv
end
end
--设置角色技能等级
function this.AddPlayerSkill(lv)
if XiuXianConfig[lv].PlayerSkill then
for i = 1, #XiuXianConfig[lv].PlayerSkill do
this.playerSkillList[XiuXianConfig[lv].PlayerSkill[i]]=1
PlayerPrefs.SetInt(PlayerManager.uid.."playerSkillRed",XiuXianConfig[lv].PlayerSkill[i])
2021-10-20 21:33:37 +08:00
end
end
2021-05-11 17:23:19 +08:00
end
--检测主角技能红点
function this.CheckPlayerSkillRed(redType)
2021-10-22 10:21:07 +08:00
if skillSystemConfig.IsOpen==0 then
return false
end
local id=redType-5000
local lv=this.playerSkillList[id]
local openId=PlayerPrefs.GetInt(PlayerManager.uid.."playerSkillRed")
if openId==id then
return true
end
if lv~=0 then
local currData=ConfigManager.TryGetConfigDataByDoubleKey(ConfigName.PlayerSkill,"SkillID",id,"Level",lv)
local nextData=ConfigManager.TryGetConfigDataByDoubleKey(ConfigName.PlayerSkill,"SkillID",id,"Level",lv+1)
if nextData then
2021-10-22 11:56:46 +08:00
local config=this.GetCurConfigData()
if config and nextData.Level>config.PlayerSkillLvMax then
return false
end
local isShow=true
for i = 1, #currData.LvupCost do
if BagManager.GetItemCountById(currData.LvupCost[i][1])<currData.LvupCost[i][2] then
isShow=false
end
end
return isShow
else
return false
end
end
return false
end
2021-10-20 21:33:37 +08:00
2021-05-12 10:35:58 +08:00
--从服务器更新当前修行等级
2021-05-12 20:53:34 +08:00
function this.UpdataFromServer(_level)
this.PracticeLevel = _level
this.PracticeLevel = this.PracticeLevel > 0 and this.PracticeLevel or 1
2021-05-13 17:37:47 +08:00
this.PracticeBigLevel = XiuXianConfig[this.PracticeLevel].RealmId
2021-10-21 10:58:09 +08:00
this.StarNum = FightLevelManager.GetAllChapterStars()
HeroPropManager.SetFuncPropDirty(Func_Prop_Type.Practice)
2021-10-21 10:58:09 +08:00
HeroPropManager.SetFuncPropDirty(Func_Prop_Type.Cultivation)
2021-05-11 17:23:19 +08:00
end
2021-05-12 10:35:58 +08:00
--获取当前等级表数据
function this.GetCurConfigData()
2021-05-13 17:37:47 +08:00
return XiuXianConfig[this.PracticeLevel]
2021-05-12 10:35:58 +08:00
end
2021-05-12 20:53:34 +08:00
function this.BuildAddTemplate()
local TemplateList = {}
for _, configInfo in ConfigPairs(PropertyConfig) do
if configInfo.IfShow == 1 or configInfo.IfShow == 2 then
TemplateList[configInfo.PropertyId] = 0
end
end
return TemplateList
end
2021-05-12 10:35:58 +08:00
--获取每一小点属性加成
function this.GetSinglePointAdd()
local singlePointAddList = {}
2021-05-13 17:37:47 +08:00
local TotalPros = XiuXianConfig[this.PracticeLevel].TotalPros
2021-05-12 10:35:58 +08:00
for i = 1, #TotalPros do
if not singlePointAddList[TotalPros[i][1]] then
singlePointAddList[TotalPros[i][1]] = 0
end
singlePointAddList[TotalPros[i][1]] = TotalPros[i][2]
end
return singlePointAddList
end
2021-05-17 19:49:48 +08:00
--获取当前获得的所有属性相加(用于计算战力)
2021-05-12 10:35:58 +08:00
function this.GetCurAllGetAdd()
2021-05-14 17:48:47 +08:00
local PropertyList = this.BuildAddTemplate()
for i = 1, this.PracticeLevel do
-- LogPink("i:"..tostring(i))
if XiuXianConfig[i].TotalPros then
local Pros = XiuXianConfig[i].TotalPros
-- LogGreen("#Pros:"..tostring(#Pros))
for i = 1, #Pros do
-- LogBlue("ProsId:"..tostring(Pros[i][1]).." ProsNum:"..tostring(Pros[i][2]))
if PropertyConfig[Pros[i][1]].Style == 1 then
PropertyList[Pros[i][1]] = PropertyList[Pros[i][1]] + Pros[i][2]
elseif PropertyConfig[Pros[i][1]].Style == 2 then
PropertyList[Pros[i][1]] = PropertyList[Pros[i][1]] + Pros[i][2]
end
end
end
end
return PropertyList
end
--获取当前获得的所有属性相加(用于界面展示)
function this.GetCurAllGetAddForShow()
2021-05-12 20:53:34 +08:00
local PropertyList = this.BuildAddTemplate()
2021-05-12 10:35:58 +08:00
for i = 1, this.PracticeLevel do
2021-05-13 17:37:47 +08:00
-- LogPink("i:"..tostring(i))
if XiuXianConfig[i].TotalPros then
local Pros = XiuXianConfig[i].TotalPros
-- LogGreen("#Pros:"..tostring(#Pros))
2021-05-12 20:53:34 +08:00
for i = 1, #Pros do
2021-05-13 17:37:47 +08:00
-- LogBlue("ProsId:"..tostring(Pros[i][1]).." ProsNum:"..tostring(Pros[i][2]))
2021-05-13 21:03:27 +08:00
if PropertyConfig[Pros[i][1]].Style == 1 then
PropertyList[Pros[i][1]] = PropertyList[Pros[i][1]] + Pros[i][2]
elseif PropertyConfig[Pros[i][1]].Style == 2 then
PropertyList[Pros[i][1]] = PropertyList[Pros[i][1]] + Pros[i][2]/100
end
2021-05-12 20:53:34 +08:00
end
end
end
return PropertyList
end
2021-05-13 17:37:47 +08:00
--获取各个大境界中所有小属性加成的总和 +模板的
2021-05-12 20:53:34 +08:00
function this.GetAddsListWithTemplate()
local PropertyList = this.BuildAddTemplate()
local addsList = {}
2021-05-13 17:37:47 +08:00
for i, v in ConfigPairs(XiuXianConfig) do
2021-05-12 20:53:34 +08:00
if v.TotalPros then
local Pros = v.TotalPros
for i = 1, #Pros do
2021-05-13 21:03:27 +08:00
if PropertyConfig[Pros[i][1]].Style == 1 then
PropertyList[Pros[i][1]] = PropertyList[Pros[i][1]] + Pros[i][2]
elseif PropertyConfig[Pros[i][1]].Style == 2 then
2021-05-14 17:48:47 +08:00
PropertyList[Pros[i][1]] = PropertyList[Pros[i][1]] + Pros[i][2]
2021-05-13 21:03:27 +08:00
end
2021-05-12 10:35:58 +08:00
end
end
end
2021-05-12 20:53:34 +08:00
return PropertyList
2021-05-12 10:35:58 +08:00
end
2021-05-13 17:37:47 +08:00
--获取各个大境界中所有小属性加成的总和 不加模板的
2021-05-12 20:53:34 +08:00
function this.GetAddsListWithOutTemplate()
2021-05-12 10:35:58 +08:00
local addsList = {}
2021-05-13 17:37:47 +08:00
for i, v in ConfigPairs(XiuXianConfig) do
2021-05-12 10:35:58 +08:00
if not addsList[v.RealmId] then
addsList[v.RealmId] = {}
end
2021-05-12 17:40:38 +08:00
if v.TotalPros then
local Pros = v.TotalPros
for i = 1, #Pros do
if not addsList[v.RealmId][Pros[i][1]] then
addsList[v.RealmId][Pros[i][1]] = 0
end
2021-05-13 21:03:27 +08:00
if PropertyConfig[Pros[i][1]].Style == 1 then
addsList[v.RealmId][Pros[i][1]] = addsList[v.RealmId][Pros[i][1]] + Pros[i][2]
elseif PropertyConfig[Pros[i][1]].Style == 2 then
addsList[v.RealmId][Pros[i][1]] = addsList[v.RealmId][Pros[i][1]] + Pros[i][2]/100
end
2021-05-12 10:35:58 +08:00
end
end
end
return addsList
end
2021-05-12 17:40:38 +08:00
--获取预览界面数据
function this.GetPreViewData()
2021-05-12 20:53:34 +08:00
local AddListData = this.GetAddsListWithOutTemplate()
2021-05-12 17:40:38 +08:00
local previewList = {}
2021-05-24 16:38:30 +08:00
for i = 1, #AddListData do
2021-05-12 17:40:38 +08:00
local data = {}
local configData = ConfigManager.GetConfigDataByKey(ConfigName.XiuXianConfig,"RealmId",i)
data.RealmName = configData.RealmName
2021-08-13 13:37:24 +08:00
data.NeedStarNum = configData.NeedStarNum
2021-05-24 16:38:30 +08:00
if configData.RealmDesc then
data.RealmDesc = configData.RealmDesc
end
2021-05-25 11:06:20 +08:00
if this.PracticeBigLevel > i then
data.IsActive = 2--完全激活
elseif this.PracticeBigLevel == i then
data.IsActive = 1
elseif this.PracticeBigLevel < i then
data.IsActive = 0
end
2021-05-12 17:40:38 +08:00
data.AddList = AddListData[i]
table.insert(previewList,data)
end
return previewList
end
2021-05-13 17:37:47 +08:00
--返回预览界面文字
2021-05-12 17:40:38 +08:00
function this.GetPreviewSingleText(id,value)
2021-05-13 21:03:27 +08:00
if PropertyConfig[id].Style == 1 then
2021-05-22 18:52:49 +08:00
return string.format("全体神将%s",PropertyConfig[id].Info),string.format("+%s",value)
2021-05-13 21:03:27 +08:00
elseif PropertyConfig[id].Style == 2 then
2021-05-22 18:52:49 +08:00
return string.format("全体神将%s",PropertyConfig[id].Info),string.format("+%s",value).."%"
2021-05-13 21:03:27 +08:00
end
2021-05-12 17:40:38 +08:00
end
2021-05-13 17:37:47 +08:00
--获取所有神印信息
function this.GetAllImprintData()
local AllImprintList = {}
for i, v in ConfigPairs(XiuXianConfig) do
if v.TeamSkill then
table.insert(AllImprintList,v)
end
end
return AllImprintList
end
--服务器发来的神印信息
function this.UpdataImprintDataFromServer(_imprintList)
2021-05-18 20:04:52 +08:00
this.BigLevelWithImprint()--初始化大境界/英雄对应的神印
2021-05-13 17:37:47 +08:00
for key, value in pairs(_imprintList) do
if value and value.id then
if not this.ImprintServerData[value.id] then
this.ImprintServerData[value.id] = {}
end
2021-05-14 13:21:38 +08:00
this.ImprintServerData[value.id].id = value.id
2021-05-13 17:37:47 +08:00
this.ImprintServerData[value.id].type = value.type
this.ImprintServerData[value.id].subId = value.subId
this.ImprintServerData[value.id].state = value.state
2021-05-19 16:14:09 +08:00
-- LogBlue("value.id:"..tostring(value.id).." value.type:"..tostring(value.type).." value.subId:"..tostring(value.subId).." value.state:"..tostring(value.state))
2021-05-13 17:37:47 +08:00
if value.state == 1 then
this.BigLevelImprintList[XiuXianSkillConfig[value.id].UnlockId] = value.id
2021-05-18 20:04:52 +08:00
if value.subId ~= nil and value.subId ~= "" and value.subId ~= "nil" then
this.HeroWithImprintList[value.subId] = value.id
end
2021-05-13 17:37:47 +08:00
end
end
end
end
2021-05-18 20:04:52 +08:00
--初始化大境界/英雄对应的神印
2021-05-13 17:37:47 +08:00
function this.BigLevelWithImprint()
for i, v in ConfigPairs(XiuXianSkillConfig) do
if v.UnlockId > 0 then
2021-05-14 14:54:57 +08:00
this.BigLevelImprintList[v.UnlockId] = 0
2021-05-13 17:37:47 +08:00
end
end
2021-05-18 20:04:52 +08:00
this.HeroWithImprintList = {}
2021-05-13 17:37:47 +08:00
end
--获取单个神印的信息(服务器+表)
function this.GetSingleImprintData(id)
if this.ImprintServerData[id] then
return this.ImprintServerData[id],XiuXianSkillConfig[id]
else
return nil,XiuXianSkillConfig[id]
end
end
2021-05-17 14:15:55 +08:00
function this.SetNameColor(name,level)
if level == 0 then
level = 1
end
local clr = ""
clr = XiuXianConfig[level].NameFontColor
2021-05-17 17:28:37 +08:00
-- LogYellow("name:"..tostring(name).." clr:"..tostring(clr))
2021-05-17 14:15:55 +08:00
return "<color=#"..clr..">"..name.."</color>"
end
2021-10-20 21:33:37 +08:00
--获取大境界对应的段位名称
function this.GetRankNameByLv(lv)
for i, v in ConfigPairs(XiuXianConfig) do
if v.RealmId==lv then
return "<color=#"..v.NameFontColor..">"..v.RealmName.."".."</color>"
end
end
return nil
end
2021-05-19 14:46:51 +08:00
--查找英雄对应的神印
2021-05-18 20:04:52 +08:00
function this.CheckHeroWearImprint(heroDid)
if this.HeroWithImprintList[heroDid] then
return this.HeroWithImprintList[heroDid]
end
2021-05-18 20:04:52 +08:00
return false
end
2021-05-19 14:46:51 +08:00
--获取小境界点信息
function this.GetPointsData(parentObj)
this.PointsData = {}
local width = 880--parentObj.transform.rect.width
for i, v in ConfigPairs(XiuXianConfig) do
if v.RealmId == this.PracticeBigLevel and v.RealmLevel > 0 then
local data = {}
data.Id = v.Id--Id
data.RealmName = string.format("%s·%s",v.RealmName,v.RealmLevelName)--名字
data.RealmLevel = v.RealmLevel--小境界等级
data.TotalPros = v.TotalPros--属性
data.Pos = Vector3.zero--位置
-- data.Updown = 0--1下0上
data.State = this.PracticeLevel >= v.Id and 1 or 0--是否已经激活该点
data.Img = this.PracticeLevel >= v.Id and "x_xiuxing_dian_01" or "x_xiuxing_dian_02"--图片名字
table.insert(this.PointsData,data)
end
end
--设置点的位置
if (#this.PointsData)%2 == 0 then--双数点
local perSpace = width/#this.PointsData
local mid = #this.PointsData/2
for i = 1, #this.PointsData do
if i <= mid then
local x = (i - mid) * perSpace - perSpace/2
2021-05-19 16:14:09 +08:00
local y = math.pow(-1,i) * 60
2021-05-19 14:46:51 +08:00
this.PointsData[i].Pos = Vector3.New(x,y,0)
elseif i > mid then
local x = (i - mid -1) * perSpace + perSpace/2
2021-05-19 16:14:09 +08:00
local y = math.pow(-1,i) * 60
2021-05-19 14:46:51 +08:00
this.PointsData[i].Pos = Vector3.New(x,y,0)
end
end
elseif (#this.PointsData)%2 == 1 then--单数点
local perSpace = width/#this.PointsData
local mid = math.ceil(#this.PointsData/2)
for i = 1, #this.PointsData do
if i < mid then
local x = (i - mid) * perSpace
2021-05-19 16:14:09 +08:00
local y = math.pow(-1,i) * 60
2021-05-19 14:46:51 +08:00
this.PointsData[i].Pos = Vector3.New(x,y,0)
elseif i > mid then
local x = (i - mid) * perSpace
2021-05-19 16:14:09 +08:00
local y = math.pow(-1,i) * 60
2021-05-19 14:46:51 +08:00
this.PointsData[i].Pos = Vector3.New(x,y,0)
elseif i == mid then
2021-05-19 16:14:09 +08:00
local y = math.pow(-1,i) * 60
2021-05-19 14:46:51 +08:00
this.PointsData[i].Pos = Vector3.New(0,y,0)
end
end
end
return this.PointsData
end
--获取境界点间的线的位置和角度
function this.GetLinesData()
this.LinesData = {}
for i = 1, #this.PointsData do
if this.PointsData[i + 1] then
local data = {}
local x = (this.PointsData[i].Pos.x + this.PointsData[i + 1].Pos.x)/2
data.Pos = Vector3.New(x,0,0)
local r = math.acos((this.PointsData[i + 1].Pos.x - this.PointsData[i].Pos.x)/(this.PointsData[i + 1].Pos.y - this.PointsData[i].Pos.y))
2021-05-19 16:14:09 +08:00
if (r/math.pi)* 180 > 90 then
data.Rota = Vector3.New(0,0,(r/math.pi)* 180 - 10)
else
data.Rota = Vector3.New(0,0,(r/math.pi)* 180 + 10)
end
2021-05-19 14:46:51 +08:00
data.State = this.PointsData[i + 1].State
table.insert(this.LinesData,data)
end
end
return this.LinesData
end
function this.CalculateWorldPos(...)
local _args = {...}
local pos = Vector3.New(0,0,0)
for i = 1, #_args do
local objPos = _args[i]:GetComponent("RectTransform").localPosition
pos.x = pos.x + objPos.x
pos.y = pos.y + objPos.y
end
return pos
end
2021-05-19 16:14:09 +08:00
function this.GetSingleAddition(_data)
local data = PropertyConfig[_data[1]]
if data.Style == 2 then
return string.format("全体%s+%s",data.Info,_data[2]/100).."%"
elseif data.Style == 1 then
return string.format("全体%s+%s",data.Info,_data[2])
end
end
2021-05-24 11:21:56 +08:00
--升级红点检测
function this.PracticeCheckUpgrade()
if not XiuXianConfig[this.PracticeLevel] then
return false
end
2021-05-24 11:21:56 +08:00
local configData = XiuXianConfig[this.PracticeLevel]
if this.StarNum >= configData.NeedStarNum then
2021-05-24 14:58:00 +08:00
if configData.LevelUpCost then
for i = 1, #configData.LevelUpCost do
local data = configData.LevelUpCost[i]
if BagManager.GetTotalItemNum(data[1]) < data[2] then
2021-05-26 10:42:19 +08:00
-- LogRed("return false Upgrade 1")
2021-05-24 14:58:00 +08:00
return false
end
2021-05-24 11:21:56 +08:00
end
end
2021-05-26 10:42:19 +08:00
-- LogGreen("return true Upgrade")
2021-05-24 11:21:56 +08:00
return true
end
2021-05-26 10:42:19 +08:00
-- LogRed("return false Upgrade 2")
2021-05-24 11:21:56 +08:00
return false
end
--神印红点检测
function this.PracticeCheckImprint()
for i, v in ConfigPairs(XiuXianSkillConfig) do
2021-05-24 11:34:50 +08:00
if this.ImprintServerData[v.Id] then
local str = PlayerPrefs.GetInt(PlayerManager.uid.."Imprint"..v.Id)
if str == 0 then
2021-05-26 10:42:19 +08:00
-- LogGreen("return true Imprint")
2021-05-24 11:34:50 +08:00
return true
end
2021-05-24 11:21:56 +08:00
end
end
2021-05-26 10:42:19 +08:00
-- LogRed("return false Imprint")
2021-05-24 11:21:56 +08:00
return false
end
2021-05-24 16:38:30 +08:00
--检测英雄是否附身中并且神印已激活
function this.CheckHeroHaveImprintAndActive(heroDid)
if this.HeroWithImprintList[heroDid] then
if this.ImprintServerData[this.HeroWithImprintList[heroDid]] then
if this.ImprintServerData[this.HeroWithImprintList[heroDid]].state == 1 then
return true
end
end
end
return false
end
2021-05-29 18:06:15 +08:00
function this.SetPracticeIcon(obj,level)
local spLoader = SpriteLoader.New()
local BigLevel = XiuXianConfig[level].RealmId
local name = "x_xiuxing_xiaobiao_00"..BigLevel
obj:GetComponent("Image").sprite = spLoader:LoadSprite(name)
end
2021-06-01 13:54:21 +08:00
--每次升级小境界弹出tips
function this.ShowTipsOnUpgrade()
local prosData = XiuXianConfig[this.PracticeLevel].TotalPros
if prosData then
2021-06-02 11:34:11 +08:00
PopupTipPanel.ShowTip("突破成功!")
2021-06-01 13:54:21 +08:00
AttriTips.ShowAttriTip(prosData)
end
end
2021-10-20 13:15:31 +08:00
--=====================四象心法部分的代码===============================
2021-09-09 20:45:12 +08:00
--初始化四象心法数据
function this.InitFourQuadrantData(_dataList)
for i = 1, #_dataList do
local professionInfo={}
professionInfo.level=_dataList[i].level
professionInfo.propertyList=_dataList[i].propertyInfoList
this.FourQuadrantData[_dataList[i].professionId]=professionInfo
end
2021-09-10 11:22:08 +08:00
for i = 1, 4 do
if this.FourQuadrantData[i]==nil then
2021-09-09 20:45:12 +08:00
local professionInfo={}
professionInfo.level=0
2021-09-10 11:22:08 +08:00
this.FourQuadrantData[i]=professionInfo
2021-09-09 20:45:12 +08:00
end
2021-09-10 11:22:08 +08:00
2021-09-09 20:45:12 +08:00
end
this.UpdateUpStarProperty()
-- 设置四象心法脏数据
HeroPropManager.SetFuncPropDirty(Func_Prop_Type.FourQua)
2021-09-09 20:45:12 +08:00
end
--更新进阶属性数据
function this.UpdateUpStarProperty()
for professionId,professionInfo in pairs(this.FourQuadrantData) do
local upStarProperty={}
for i = 0,professionInfo.level-1 do
local fourQuadConfig = ConfigManager.GetConfigDataByKey(ConfigName.FourQuadrantConfig,"Star",i)
for j = 1, #fourQuadConfig.PropStar do
local propArr=fourQuadConfig.PropStar[j]
if upStarProperty[propArr[1]] then
upStarProperty[propArr[1]]=upStarProperty[propArr[1]]+propArr[2]
else
upStarProperty[propArr[1]]=propArr[2]
end
end
end
this.fourQuadrantUpStarPropMap[professionId]=upStarProperty
end
end
2021-09-10 11:22:08 +08:00
--获取四象心法共鸣等级
2021-09-09 20:45:12 +08:00
function this.GetFourQuadrantGongmingLv()
local lv=0
if this.FourQuadrantData[1] then
lv=this.FourQuadrantData[1].level
end
for i = 1, 4 do
if not this.FourQuadrantData[i] then
return 0
end
if lv>this.FourQuadrantData[i].level then
lv=this.FourQuadrantData[i].level
end
end
return lv
end
---刷新四象心法对应职业相关属性
function this.UpdateFourQuadrantProperty(_professionId,_propertyList)
if this.FourQuadrantData[_professionId] then
this.FourQuadrantData[_professionId].propertyList=_propertyList
else
local professionInfo={}
professionInfo.level=0
professionInfo.propertyList=_propertyList
this.FourQuadrantData[_professionId]=professionInfo
end
-- 设置四象心法脏数据
HeroPropManager.SetFuncPropDirty(Func_Prop_Type.FourQua)
2021-09-09 20:45:12 +08:00
end
--进阶刷新本地数据
function this.UpStarUpdateFourQuadrantData(_professionId,_msg)
this.FourQuadrantData[_professionId].level=_msg.starLv
this.FourQuadrantData[_professionId].propertyList=_msg.infoList
this.UpdateUpStarProperty()
-- 设置四象心法脏数据
HeroPropManager.SetFuncPropDirty(Func_Prop_Type.FourQua)
2021-09-09 20:45:12 +08:00
end
--四象心法计算指定职业的属性加成
function this.HeroCalculateFourQuaWarForce(_professionId)
local addAllProVal={}
local professionInfo=this.FourQuadrantData[_professionId]
2021-09-29 09:19:53 +08:00
if not professionInfo then
return addAllProVal
end
2021-09-10 11:22:08 +08:00
if professionInfo.propertyList then
2021-09-09 20:45:12 +08:00
---计算强化属性
for i = 1, #professionInfo.propertyList do
local propertyInfo = professionInfo.propertyList[i]
if propertyInfo.propertyNum > 0 then
if addAllProVal[propertyInfo.propertyId] then
addAllProVal[propertyInfo.propertyId]=addAllProVal[propertyInfo.propertyId]+propertyInfo.propertyNum
else
addAllProVal[propertyInfo.propertyId]=propertyInfo.propertyNum
end
end
end
---计算进阶属性
if this.fourQuadrantUpStarPropMap[_professionId] then
local upStarProp=this.fourQuadrantUpStarPropMap[_professionId]
for propertyId,propertyNum in ipairs(upStarProp)do
addAllProVal[propertyId]=addAllProVal[propertyId]+propertyNum
end
end
end
--计算共鸣属性加成
2021-09-11 13:37:26 +08:00
if this.GetFourQuadrantGongmingLv()>0 then
local fourQuadConfig = ConfigManager.GetConfigDataByKey(ConfigName.FourQuadrantConfig,"Star",this.GetFourQuadrantGongmingLv())
for i = 1, #fourQuadConfig.PropResonance do
local propAdd=fourQuadConfig.PropResonance[i]
if addAllProVal[propAdd[1]] then
addAllProVal[propAdd[1]]=addAllProVal[propAdd[1]]+propAdd[2]
else
addAllProVal[propAdd[1]]=propAdd[2]
end
end
end
-- 计算技能属性加成
for key,value in pairs(this.FourQuadrantData) do
if value.level>0 then
local fourQuadConfig = ConfigManager.GetConfigDataByKey(ConfigName.FourQuadrantConfig,"Star",value.level)
local professionSkillAdd=fourQuadConfig.Skill[key]
addAllProVal[professionSkillAdd[1]]=professionSkillAdd[2]
end
end
2021-09-09 20:45:12 +08:00
return addAllProVal
end
2021-09-10 11:22:08 +08:00
--检测四象心法红点
2021-09-09 20:45:12 +08:00
function this.CheckFourQuadrantRed()
for professionId,professionInfo in pairs(this.FourQuadrantData) do
if this.CheckIsUpStarCondition(professionId) then
if this.CheckIsUpStarByProfessionId(professionId) then
return true
end
else
if this.CheckIsUpByProfessionId(professionId) then
return true
end
end
end
return false
end
2021-09-10 11:22:08 +08:00
---检测四象心法指定职业进阶条件是否满足
2021-09-09 20:45:12 +08:00
function this.CheckIsUpStarByProfessionId(_professionId)
local professionInfo=PracticeManager.FourQuadrantData[_professionId]
if not professionInfo then
return false
end
2021-09-11 17:50:21 +08:00
if professionInfo.level>=5 then
return false
end
2021-09-09 20:45:12 +08:00
local fourQuadConfig = ConfigManager.GetConfigDataByKey(ConfigName.FourQuadrantConfig,"Star",professionInfo.level)
for i = 1, #fourQuadConfig.PropLimit do
local propLimitArr=fourQuadConfig.PropLimit[i]
local propertyInfo= professionInfo.propertyList[propLimitArr[1]]
if not propertyInfo then
return false
end
if propertyInfo.propertyNum<propLimitArr[2] then
return false
end
end
local nextLv= professionInfo.level+1
local nextConfig=ConfigManager.GetConfigDataByKey(ConfigName.FourQuadrantConfig,"Star",nextLv)
if not nextConfig then
return false
end
local xiuxingConfig= ConfigManager.GetConfigData(ConfigName.XiuXianConfig,nextConfig.XiuxianLimit)
if this.PracticeBigLevel<xiuxingConfig.RealmId then
return false
end
local costArr=fourQuadConfig.RankupCost
for i = 1, #costArr do
if BagManager.GetTotalItemNum(costArr[i][1])<costArr[i][2]then
return false
end
end
return true
end
2021-09-10 11:22:08 +08:00
---检测四象心法指定职业强化材料是否足够
2021-09-09 20:45:12 +08:00
function this.CheckIsUpByProfessionId(_professionId)
local professionInfo=PracticeManager.FourQuadrantData[_professionId]
local fourQuadConfig = ConfigManager.GetConfigDataByKey(ConfigName.FourQuadrantConfig,"Star",professionInfo.level)
local costArr=fourQuadConfig.LvupCost
for i = 1, #costArr do
if BagManager.GetTotalItemNum(costArr[i][1])<costArr[i][2]then
return false
end
end
return true
end
2021-09-10 11:22:08 +08:00
--检测四象心法指定职业强化进度是否可以进阶
2021-09-09 20:45:12 +08:00
function this.CheckIsUpStarCondition(_professionId)
local professionInfo=PracticeManager.FourQuadrantData[_professionId]
if not professionInfo then
return false
end
local fourQuadConfig = ConfigManager.GetConfigDataByKey(ConfigName.FourQuadrantConfig,"Star",professionInfo.level)
if not professionInfo.propertyList then
return false
end
for i = 1, #fourQuadConfig.PropLimit do
local propLimitInfo= fourQuadConfig.PropLimit[i]
local propertyInfo=professionInfo.propertyList[i]
if not propertyInfo then
return false
end
if propertyInfo.propertyNum<propLimitInfo[2] then
return false
end
end
return true
end
2021-10-20 13:15:31 +08:00
--============================主角修为部分的代码===========================================
2021-10-19 18:34:10 +08:00
function this.SetCultivationLevel(_level,func)
this.CultivationLevel = _level
if func then
func()
end
end
2021-10-20 13:15:31 +08:00
function this.CheckPlayerCultivetionRed()
local maxLevel = tonumber(ConfigManager.GetConfigData(ConfigName.SpecialConfig,133).Value)
local statePower = tonumber(ConfigManager.GetConfigData(ConfigName.SpecialConfig,134).Value)
if maxLevel > this.CultivationLevel then
FormationManager.UserPowerChanged()
if (PlayerManager.maxForce - statePower*this.CultivationLevel) > statePower then
return true
end
end
return false
end
function this.GetCultivationPros()
local allPros = {}
local data1 = this.GetCurConfigData().ProRank
local data2 = this.GetCurConfigData().ProLevel
for i = 1, #data1 do
2021-10-20 15:09:59 +08:00
if this.CultivationLevel == 0 then
allPros[data1[i][1]] = 0
else
allPros[data1[i][1]] = data1[i][2] + data2[i][2]*this.CultivationLevel
2021-10-21 10:58:09 +08:00
LogRed("Id:"..tostring(data1[i][1]).." value:"..tostring(allPros[data1[i][1]]))
2021-10-20 15:09:59 +08:00
end
2021-10-20 13:15:31 +08:00
end
return allPros
end
2021-05-11 17:23:19 +08:00
return PracticeManager