225 lines
7.1 KiB
Lua
225 lines
7.1 KiB
Lua
GodsWayTowerManager = {};
|
|
local this = GodsWayTowerManager
|
|
local towerInfos = nil
|
|
local duoDuiHeroConfig = ConfigManager.GetConfig(ConfigName.DuoDuiTowerHero)
|
|
function this.Initialize()
|
|
towerInfos = {}
|
|
end
|
|
|
|
function this.Init(msg)
|
|
local infos = msg.info
|
|
--LogError("================多队塔试炼:"..#infos)
|
|
for i = 1, #infos do
|
|
local config = ConfigManager.GetConfigData(ConfigName.DuoDuiTowerConfig, infos[i].type)
|
|
local needFloor
|
|
if infos[i].tier < 0 then
|
|
needFloor = 0
|
|
else
|
|
needFloor = infos[i].tier
|
|
end
|
|
--LogError("================多队塔试炼:"..needFloor)
|
|
towerInfos[i] = {
|
|
time = infos[i].time,
|
|
type = infos[i].type,
|
|
floor = needFloor,
|
|
rank = infos[i].rank,
|
|
freeId =
|
|
config.PrivilegeType,
|
|
buyId = config.PrivilegeType1
|
|
}
|
|
end
|
|
end
|
|
|
|
function this.GetTowerData()
|
|
return towerInfos
|
|
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.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
|