317 lines
11 KiB
Lua
317 lines
11 KiB
Lua
BecomeAGodManager = {};
|
|
local this = BecomeAGodManager
|
|
local duoDuiHeroConfig = ConfigManager.GetConfig(ConfigName.DuoDuiTowerHero)
|
|
local BecomeAGodLevel = ConfigManager.GetConfig(ConfigName.BecomeAGodLevel)
|
|
this.playerGodLevel = 0
|
|
this.playerGodTowerNum = 0
|
|
this.playerMeridiansLevel = { 0, 0, 0, 0, 0, 0, 0 }
|
|
function this.Initialize()
|
|
|
|
end
|
|
|
|
function this.Init(msg)
|
|
--LogError("=====================")
|
|
--LogError("ddddddddddddd" .. msg.playerGodLevel)
|
|
--LogError("ddddddddddddd" .. msg.playerGodTowerNum)
|
|
--for i = 1, #msg.playerMeridiansLevel do
|
|
--LogError("ddddddddddd" .. msg.playerMeridiansLevel[i])
|
|
--end
|
|
--LogError("=====================")
|
|
this.playerGodLevel = msg.playerGodLevel
|
|
this.playerGodTowerNum = msg.playerGodTowerNum
|
|
this.playerMeridiansLevel = msg.playerMeridiansLevel
|
|
end
|
|
|
|
function this.GetPlayerMeridiansLevel(index)
|
|
return this.playerMeridiansLevel[index]
|
|
end
|
|
|
|
function this.IsCouldUpgrade()
|
|
local becomAGodLevelData = BecomeAGodLevel[this.playerGodLevel + 1]
|
|
if becomAGodLevelData then
|
|
--LogError("xxxxxxxxxxxxxxxxxxxxx"..HeroManager.GetHeroNumByStar(becomAGodLevelData.HeroConfine[2]).."/"..becomAGodLevelData.HeroConfine[1])
|
|
if HeroManager.GetHeroNumByStar(becomAGodLevelData.HeroConfine[2]) < becomAGodLevelData.HeroConfine[1] then
|
|
return false
|
|
end
|
|
for i = 1, #this.playerMeridiansLevel do
|
|
if this.playerMeridiansLevel[i] < becomAGodLevelData.LevelConfine then
|
|
return false
|
|
end
|
|
end
|
|
return true
|
|
else
|
|
return false
|
|
end
|
|
end
|
|
|
|
function this.GetTowerDataByType(_type)
|
|
local floor = this.GetTowerFloorByType(_type)
|
|
local towerList = {}
|
|
--ConfigManager.TryGetAllConfigsDataByDoubleKey(ConfigName.DuoDuiTower,"Type",_type,)
|
|
if floor < 0 then
|
|
floor = 0
|
|
end
|
|
if floor >= 300 - 10 then
|
|
floor = 300 - 10
|
|
end
|
|
for i = floor + 1, floor + 10 do
|
|
local data = this.GetFourMonsterInfoByWave(_type, i)
|
|
if data then
|
|
table.insert(towerList, data)
|
|
end
|
|
end
|
|
return towerList
|
|
end
|
|
|
|
function this.GetCurrFloorRewardByType(_type)
|
|
local floor = this.GetTowerFloorByType(_type)
|
|
--如果一层都没打显示第一层的奖励
|
|
if floor <= 0 then
|
|
floor = 1
|
|
end
|
|
LogError("floor======" .. floor)
|
|
local config = ConfigManager.TryGetConfigDataByDoubleKey(ConfigName.DuoDuiTower, "Type", _type, "TowerNumber", floor)
|
|
if config then
|
|
return config.Income
|
|
end
|
|
return nil
|
|
end
|
|
|
|
function this.SetSingleMonster(id)
|
|
local herodata = {}
|
|
local _configData = ConfigManager.GetConfigData(ConfigName.HeroConfig, id)
|
|
herodata.heroConfig = _configData
|
|
herodata.heroViewConfig = _configData
|
|
herodata.live = GetResourcePath(_configData.Live)
|
|
herodata.painting = GetResourcePath(_configData.Painting)
|
|
herodata.icon = GetResourcePath(_configData.Icon)
|
|
herodata.scale = _configData.Scale
|
|
herodata.position = _configData.Position
|
|
herodata.profession = _configData.Profession
|
|
herodata.ProfessionResourceId = _configData.ProfessionResourceId
|
|
if GetJobSpriteStrByJobNum(_configData.Profession) then
|
|
herodata.professionIcon = GetJobSpriteStrByJobNum(_configData.Profession)
|
|
else
|
|
herodata.professionIcon = GetJobSpriteStrByJobNum(1)
|
|
end
|
|
herodata.name = _configData.ReadingName
|
|
herodata.property = _configData.PropertyName
|
|
return herodata
|
|
end
|
|
|
|
function this.GetFourMonsterInfoByWave(curType, wave)
|
|
LogError("curtype==" .. curType .. " wave==" .. wave)
|
|
local tempConfigs = ConfigManager.TryGetAllConfigsDataByDoubleKey(ConfigName.DuoDuiTower, "Type", curType,
|
|
"TowerNumber", wave)
|
|
if not tempConfigs then
|
|
return nil
|
|
end
|
|
local data = {}
|
|
data.wave = wave
|
|
data.firstReward = {}
|
|
data.herodatas = {}
|
|
data.monsterConfig = {}
|
|
for i = 1, #tempConfigs do
|
|
--奖励
|
|
local tempConfig = tempConfigs[i]
|
|
if tempConfig.Item and #tempConfig.Item > 0 and tempConfig.TowerWave1 == 1 then
|
|
for j = 1, #tempConfig.Item do
|
|
if tempConfig.Item[j][1] ~= nil and tempConfig.Item[j][1] ~= 0 then
|
|
--LogError("tempConfig.Item[j][1]=="..tempConfig.Item[j][1].." tempConfig.Item[j][2]=="..tempConfig.Item[j][2])
|
|
table.insert(data.firstReward, { id = tempConfig.Item[j][1], num = tempConfig.Item[j][2] })
|
|
end
|
|
end
|
|
end
|
|
--LogError("tempConfig.id=="..tempConfig.id)
|
|
data.id = tempConfig.TowerNumber
|
|
data.power = tempConfig.Force
|
|
local id = tempConfig.Hero[5]
|
|
local aaa = this.SetSingleMonster(duoDuiHeroConfig[id].Hero)
|
|
table.insert(data.monsterConfig, tempConfig)
|
|
table.insert(data.herodatas, aaa)
|
|
end
|
|
|
|
-- local monsterGroupId = tempConfig.Monster
|
|
-- -- 默认显示第一只怪
|
|
-- local id = monsterGroupConfig[monsterGroupId].Contents[1][1]
|
|
-- data.monster = monsterGroupConfig[monsterGroupId].Contents[1]
|
|
-- data.monsterConfig = monsterConfig[id]
|
|
-- data.herodata = this.SetSingleMonster(data.monsterConfig.MonsterId)
|
|
return data
|
|
end
|
|
|
|
function this.GetTowerFloorByType(_type)
|
|
if towerInfos[_type] then
|
|
return towerInfos[_type].floor
|
|
end
|
|
return 0
|
|
end
|
|
|
|
function this.GetTowerTimeByType(_type)
|
|
if towerInfos[_type] then
|
|
return towerInfos[_type].time
|
|
end
|
|
return 0
|
|
end
|
|
|
|
function this.SetTowerTimeByType(_type, _time)
|
|
if towerInfos[_type] then
|
|
towerInfos[_type].time = _time
|
|
end
|
|
end
|
|
|
|
function this.GetTowerBuyIdByType(_type)
|
|
if towerInfos[_type] then
|
|
return towerInfos[_type].buyId
|
|
end
|
|
return 0
|
|
end
|
|
|
|
function this.GetTowerFreeIdByType(_type)
|
|
if towerInfos[_type] then
|
|
return towerInfos[_type].freeId
|
|
end
|
|
return 0
|
|
end
|
|
|
|
--获取当前等级和下一级的数据
|
|
function this.GetPropText(_treeLv, _type)
|
|
local data = {}
|
|
local level = _treeLv
|
|
local becomAGodSettingData = ConfigManager.TryGetConfigDataByDoubleKey(ConfigName.BecomeAGodSetting, "Type", _type)
|
|
local isMax = false
|
|
for k = 1, #becomAGodSettingData.PropertyGit do
|
|
local configData = ConfigManager.TryGetConfigDataByDoubleKey(ConfigName.BecomeAGodPropertyGit, "Type",
|
|
becomAGodSettingData.PropertyGit[k], "Level",
|
|
level)
|
|
local configNextData = ConfigManager.TryGetConfigDataByDoubleKey(ConfigName.BecomeAGodPropertyGit, "Type",
|
|
becomAGodSettingData.PropertyGit[k],
|
|
"Level",
|
|
level + 1)
|
|
--if configNextData then --如果当前神树等级超出魂灵宝所能达到的最大等级就取最大
|
|
--configNextData = nil
|
|
--end
|
|
for i = 1, #configData.Property do
|
|
local propArr = configData.Property[i]
|
|
local propId = propArr[1]
|
|
data[propId] = {}
|
|
data[propId].currValue = propArr[2]
|
|
data[propId].floor = becomAGodSettingData.Floor[k]
|
|
if configNextData then
|
|
local nextPropArr = configNextData.Property[i]
|
|
data[propId].nextValue = nextPropArr[2]
|
|
else
|
|
local color = not bool and "A0A0A0" or "F3D98F"
|
|
data[propId].nextValue = string.format(Language[12789], color)
|
|
isMax = true
|
|
end
|
|
end
|
|
end
|
|
return data, isMax
|
|
end
|
|
|
|
--计算 属性加成
|
|
function this.CalculateBecomAGodProAddVal()
|
|
local addAllProVal = {}
|
|
for _type = 1, 6 do
|
|
local becomAGodSettingData = ConfigManager.TryGetConfigDataByDoubleKey(ConfigName.BecomeAGodSetting, "Type",
|
|
_type)
|
|
for k = 1, #becomAGodSettingData.PropertyGit do
|
|
local configData = ConfigManager.TryGetConfigDataByDoubleKey(ConfigName.BecomeAGodPropertyGit, "Type",
|
|
becomAGodSettingData.PropertyGit[k], "Level",
|
|
this.playerMeridiansLevel[_type])
|
|
for i = 1, #configData.Property do
|
|
local propArr = configData.Property[i]
|
|
if addAllProVal[propArr[1]] then
|
|
addAllProVal[propArr[1]] = addAllProVal[propArr[1]] + propArr[2]
|
|
else
|
|
addAllProVal[propArr[1]] = propArr[2]
|
|
end
|
|
end
|
|
end
|
|
end
|
|
return addAllProVal
|
|
end
|
|
|
|
function this.GetBecomeAGodProAddRate(_type)
|
|
local addRate = 0
|
|
for _type = 1, 6 do
|
|
local becomAGodSettingData = ConfigManager.TryGetConfigDataByDoubleKey(ConfigName.BecomeAGodSetting, "Type",
|
|
_type)
|
|
for k = 1, #becomAGodSettingData.PropertyGit do
|
|
local configData = ConfigManager.TryGetConfigDataByDoubleKey(ConfigName.BecomeAGodPropertyGit, "Type",
|
|
becomAGodSettingData.PropertyGit[k], "Level",
|
|
this.playerMeridiansLevel[_type])
|
|
for i = 1, #configData.SystemProperty do
|
|
if configData.SystemProperty[1] == _type then
|
|
addRate = addRate + configData.SystemProperty[2]
|
|
end
|
|
end
|
|
end
|
|
end
|
|
if this.playerGodLevel > 0 then
|
|
local jinjieData = ConfigManager.TryGetConfigData(ConfigName.BecomeAGodLevel, this.playerGodLevel)
|
|
addRate = addRate + jinjieData.Property[2]
|
|
end
|
|
return addRate
|
|
end
|
|
|
|
function this.GetTimeTip(_type)
|
|
--local config=ConfigManager.GetConfigData(ConfigName.DuoDuiTowerConfig,type)
|
|
local buyTime = 0
|
|
local freeTime = 0
|
|
if towerInfos[_type] then
|
|
buyTime = PrivilegeManager.GetPrivilegeRemainValue(towerInfos[_type].buyId)
|
|
freeTime = PrivilegeManager.GetPrivilegeRemainValue(towerInfos[_type].freeId)
|
|
end
|
|
--免费次数
|
|
return freeTime, buyTime
|
|
end
|
|
|
|
function this.GetCost(campId)
|
|
local buyTimeId = towerInfos[campId].buyId
|
|
LogError("campId==" .. campId .. " buytimeid===" .. buyTimeId)
|
|
local storeData = ConfigManager.GetConfigDataByDoubleKey(ConfigName.StoreConfig, "StoreId", 7, "Limit", buyTimeId)
|
|
--商店表数据
|
|
local buyTimes = (PrivilegeManager.GetPrivilegeUsedTimes(buyTimeId) + 1) >
|
|
PrivilegeManager.GetPrivilegeNumber(buyTimeId)
|
|
and PrivilegeManager.GetPrivilegeNumber(buyTimeId) or (PrivilegeManager.GetPrivilegeUsedTimes(buyTimeId) + 1)
|
|
return storeData.Id, storeData.Cost[1][1], storeData.Cost[2][buyTimes]
|
|
end
|
|
|
|
-- function this.SetTowerFloorByType(_type)
|
|
-- if towerInfos[_type] then
|
|
-- towerInfos[_type].floor=towerInfos[_type].floor+1
|
|
-- end
|
|
-- return 0
|
|
-- end
|
|
|
|
--检测红点状态
|
|
function this.CheckRedPointStatus()
|
|
local towers = ConfigManager.GetConfig(ConfigName.DuoDuiTowerConfig)
|
|
if towers then
|
|
for i, v in ConfigPairs(towers) do
|
|
local isOpen = CheckFunctionOpen(i + 138)
|
|
if isOpen then
|
|
local freeTime = PrivilegeManager.GetPrivilegeRemainValue(v.PrivilegeType)
|
|
if freeTime > 0 then
|
|
return true
|
|
end
|
|
end
|
|
end
|
|
end
|
|
return false
|
|
end
|
|
|
|
function this.SetTowerFloorByType(_type, _num)
|
|
if towerInfos[_type] then
|
|
towerInfos[_type].floor = towerInfos[_type].floor + _num
|
|
end
|
|
end
|
|
|
|
function this.Destroy()
|
|
towerInfos = nil
|
|
end
|
|
|
|
return this
|