331 lines
12 KiB
Lua
331 lines
12 KiB
Lua
PracticeManager = {}
|
|
local this = PracticeManager
|
|
local XiuXianConfig = ConfigManager.GetConfig(ConfigName.XiuXianConfig)
|
|
local PropertyConfig = ConfigManager.GetConfig(ConfigName.PropertyConfig)
|
|
local XiuXianSkillConfig = ConfigManager.GetConfig(ConfigName.XiuXianSkillConfig)
|
|
local PropertyConfig = ConfigManager.GetConfig(ConfigName.PropertyConfig)
|
|
|
|
function this.Initialize()
|
|
this.PracticeLevel = 1--小境界id
|
|
this.PracticeBigLevel = 1--大境界数
|
|
this.StarNum = 0--星星的数量
|
|
-- this.PracticeConfigData = {}
|
|
this.ImprintServerData = {}--服务器发来的神印信息
|
|
this.BigLevelImprintList = {}--大境界对应的神印
|
|
this.HeroWithImprintList = {}--英雄身上的神印
|
|
this.PointsData = {}
|
|
this.LinesData = {}
|
|
end
|
|
--从服务器更新当前修行等级
|
|
function this.UpdataFromServer(_level)
|
|
this.PracticeLevel = _level
|
|
this.PracticeLevel = this.PracticeLevel > 0 and this.PracticeLevel or 1
|
|
this.PracticeBigLevel = XiuXianConfig[this.PracticeLevel].RealmId
|
|
this.StarNum = PlayerManager.level-- FightLevelManager.GetAllChapterStars()
|
|
end
|
|
|
|
--获取当前等级表数据
|
|
function this.GetCurConfigData()
|
|
return XiuXianConfig[this.PracticeLevel]
|
|
end
|
|
|
|
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
|
|
|
|
--获取每一小点属性加成
|
|
function this.GetSinglePointAdd()
|
|
local singlePointAddList = {}
|
|
local TotalPros = XiuXianConfig[this.PracticeLevel].TotalPros
|
|
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
|
|
|
|
--获取当前获得的所有属性相加(用于计算战力)
|
|
function this.GetCurAllGetAdd()
|
|
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()
|
|
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]/100
|
|
end
|
|
end
|
|
end
|
|
end
|
|
return PropertyList
|
|
end
|
|
|
|
--获取各个大境界中所有小属性加成的总和 +模板的
|
|
function this.GetAddsListWithTemplate()
|
|
local PropertyList = this.BuildAddTemplate()
|
|
local addsList = {}
|
|
for i, v in ConfigPairs(XiuXianConfig) do
|
|
if v.TotalPros then
|
|
local Pros = v.TotalPros
|
|
for i = 1, #Pros do
|
|
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.GetAddsListWithOutTemplate()
|
|
local addsList = {}
|
|
for i, v in ConfigPairs(XiuXianConfig) do
|
|
if not addsList[v.RealmId] then
|
|
addsList[v.RealmId] = {}
|
|
end
|
|
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
|
|
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
|
|
end
|
|
end
|
|
end
|
|
return addsList
|
|
end
|
|
|
|
--获取预览界面数据
|
|
function this.GetPreViewData()
|
|
local AddListData = this.GetAddsListWithOutTemplate()
|
|
local previewList = {}
|
|
for i = 2, #AddListData do
|
|
local data = {}
|
|
local configData = ConfigManager.GetConfigDataByKey(ConfigName.XiuXianConfig,"RealmId",i)
|
|
data.RealmName = configData.RealmName
|
|
data.RealmDesc = configData.RealmDesc
|
|
data.IsActive = this.PracticeBigLevel >= i
|
|
data.AddList = AddListData[i]
|
|
table.insert(previewList,data)
|
|
end
|
|
return previewList
|
|
end
|
|
|
|
--返回预览界面文字
|
|
function this.GetPreviewSingleText(id,value)
|
|
if PropertyConfig[id].Style == 1 then
|
|
return string.format("全体神将%s+%s",PropertyConfig[id].Info,value)
|
|
elseif PropertyConfig[id].Style == 2 then
|
|
return string.format("全体神将%s+%s",PropertyConfig[id].Info,value).."%"
|
|
end
|
|
end
|
|
|
|
--获取所有神印信息
|
|
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)
|
|
this.BigLevelWithImprint()--初始化大境界/英雄对应的神印
|
|
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
|
|
this.ImprintServerData[value.id].id = value.id
|
|
this.ImprintServerData[value.id].type = value.type
|
|
this.ImprintServerData[value.id].subId = value.subId
|
|
this.ImprintServerData[value.id].state = value.state
|
|
-- LogBlue("value.id:"..tostring(value.id).." value.type:"..tostring(value.type).." value.subId:"..tostring(value.subId).." value.state:"..tostring(value.state))
|
|
if value.state == 1 then
|
|
this.BigLevelImprintList[XiuXianSkillConfig[value.id].UnlockId] = value.id
|
|
if value.subId ~= nil and value.subId ~= "" and value.subId ~= "nil" then
|
|
this.HeroWithImprintList[value.subId] = value.id
|
|
end
|
|
end
|
|
end
|
|
end
|
|
end
|
|
|
|
--初始化大境界/英雄对应的神印
|
|
function this.BigLevelWithImprint()
|
|
for i, v in ConfigPairs(XiuXianSkillConfig) do
|
|
if v.UnlockId > 0 then
|
|
this.BigLevelImprintList[v.UnlockId] = 0
|
|
end
|
|
end
|
|
this.HeroWithImprintList = {}
|
|
end
|
|
|
|
--获取单个神印的信息(服务器+表)
|
|
function this.GetSingleImprintData(id)
|
|
if this.ImprintServerData[id] then
|
|
return this.ImprintServerData[id],XiuXianSkillConfig[id]
|
|
else
|
|
return nil,XiuXianSkillConfig[id]
|
|
end
|
|
end
|
|
|
|
function this.SetNameColor(name,level)
|
|
if level == 0 then
|
|
level = 1
|
|
end
|
|
local clr = ""
|
|
clr = XiuXianConfig[level].NameFontColor
|
|
-- LogYellow("name:"..tostring(name).." clr:"..tostring(clr))
|
|
return "<color=#"..clr..">"..name.."</color>"
|
|
end
|
|
--查找英雄对应的神印
|
|
function this.CheckHeroWearImprint(heroDid)
|
|
if this.HeroWithImprintList[heroDid] then
|
|
return this.HeroWithImprintList[heroDid]
|
|
end
|
|
return false
|
|
end
|
|
|
|
--获取小境界点信息
|
|
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
|
|
local y = math.pow(-1,i) * 60
|
|
this.PointsData[i].Pos = Vector3.New(x,y,0)
|
|
elseif i > mid then
|
|
local x = (i - mid -1) * perSpace + perSpace/2
|
|
local y = math.pow(-1,i) * 60
|
|
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
|
|
local y = math.pow(-1,i) * 60
|
|
this.PointsData[i].Pos = Vector3.New(x,y,0)
|
|
elseif i > mid then
|
|
local x = (i - mid) * perSpace
|
|
local y = math.pow(-1,i) * 60
|
|
this.PointsData[i].Pos = Vector3.New(x,y,0)
|
|
elseif i == mid then
|
|
local y = math.pow(-1,i) * 60
|
|
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))
|
|
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
|
|
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
|
|
|
|
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
|
|
|
|
return PracticeManager |