miduo_client/Assets/ManagedResources/~Lua/Modules/Carbon/XuanYuanMirrorManager.lua

274 lines
9.3 KiB
Lua
Raw Normal View History

2021-04-20 13:58:00 +08:00
XuanYuanMirrorManager = {};
2020-08-11 09:48:21 +08:00
local raceTowerConfig
local raceTowerRewardConfig
2020-07-16 20:24:28 +08:00
local this = XuanYuanMirrorManager
2020-08-11 09:48:21 +08:00
this.levelData = {}
this.buyTime = 0
this.freeTime = 0
2020-08-12 13:34:07 +08:00
this.buyTimeId = 0
this.freeTimeId = 0
2020-08-11 09:48:21 +08:00
this.curType = 0
2020-07-16 20:24:28 +08:00
function this.Initialize()
2020-08-11 09:48:21 +08:00
raceTowerConfig = ConfigManager.GetConfig(ConfigName.RaceTowerConfig)
raceTowerRewardConfig = ConfigManager.GetConfig(ConfigName.RaceTowerRewardConfig)
2020-08-12 13:34:07 +08:00
local config = raceTowerConfig[1].Privilege
this.buyTimeId= config[2]
this.freeTimeId = config[1]
2020-08-06 17:37:07 +08:00
this.InitMirrorData()
end
2020-07-21 10:42:20 +08:00
function this.InitMirrorData()
2020-08-11 09:48:21 +08:00
this.levelData = {}
for k,v in ConfigPairs(raceTowerConfig) do
if not this.levelData[v.Type] then
this.levelData[v.Type] = {}
this.levelData[v.Type].data = {}
--0未开启 1开启
this.levelData[v.Type].state = 0
this.levelData[v.Type].endingTime = 0
end
2020-07-20 19:46:08 +08:00
local data={}
data.id = v.Id
data.type = v.Type
2020-08-11 09:48:21 +08:00
data.openLevel = v.IsShow
2020-07-20 19:46:08 +08:00
data.difficulity = v.Quality
data.teamRules = v.TeamRules
2020-08-11 09:48:21 +08:00
--组队条件
2021-10-27 13:45:05 +08:00
data.condition = string.format("上阵<color=#00FF66>%s名%s系</color>神将",data.teamRules[1][2],this.PropertyName(data.teamRules[1][1]))
2020-08-11 09:48:21 +08:00
--战力
2020-07-21 10:42:20 +08:00
data.power = v.FightForce
data.rewardList = {}
2020-07-20 19:46:08 +08:00
--概率奖励
2020-08-11 09:48:21 +08:00
local tempConfig = ConfigManager.GetConfigData(ConfigName.RewardGroup,v.Reward[1])
if tempConfig.ShowItem then
for i=1, #tempConfig.ShowItem do
table.insert(data.rewardList,{id = tempConfig.ShowItem[i][1],num = tempConfig.ShowItem[i][2],israte = 0})
end
2020-07-20 19:46:08 +08:00
end
--扫荡奖励
2020-08-11 09:48:21 +08:00
tempConfig = ConfigManager.GetConfigData(ConfigName.RewardGroup,v.Reward[2])
if tempConfig.ShowItem then
for i=1, #tempConfig.ShowItem do
table.insert(data.rewardList,{id = tempConfig.ShowItem[i][1],num = tempConfig.ShowItem[i][2],israte = 1})
end
2020-07-20 19:46:08 +08:00
end
--首通奖励
2020-08-11 09:48:21 +08:00
tempConfig = ConfigManager.GetConfigData(ConfigName.RewardGroup,v.FirstReward[2])
if tempConfig.ShowItem then
for i=1, #tempConfig.ShowItem do
table.insert(data.rewardList,{id = tempConfig.ShowItem[i][1],num = tempConfig.ShowItem[i][2],israte = 2})
end
2020-07-20 19:46:08 +08:00
end
2020-08-11 09:48:21 +08:00
-- -1不显示 --0未开启 1挑战 2扫荡
2020-07-21 10:42:20 +08:00
data.state = -1
2020-08-11 09:48:21 +08:00
table.insert(this.levelData[v.Type].data,data)
2020-07-20 19:46:08 +08:00
end
end
2020-08-12 21:07:13 +08:00
function this.CarbonRedCheck()
2020-08-28 17:29:38 +08:00
if not ActTimeCtrlManager.IsQualifiled(FUNCTION_OPEN_TYPE.PEOPLE_MIRROR) then
2020-08-13 14:43:44 +08:00
return false
end
2020-08-12 21:07:13 +08:00
this.GetTimeTip()
if this.freeTime > 0 then
return true
end
return false
end
2020-08-11 09:48:21 +08:00
function this.UpdateMirrorState(msg)
2020-08-12 19:17:05 +08:00
if not msg.infos or #msg.infos < 1 then
2020-08-11 09:48:21 +08:00
LogBlue("")
return
end
for k,v in pairs(this.levelData) do
v.state = 0
end
for k,v in ipairs(msg.infos) do
if this.levelData[v.id] then
this.levelData[v.id].state = 1
this.levelData[v.id].endingTime = v.overTime
this.levelData[v.id].passId = v.passId or 0
this.UpdateLevelState(v.id)
end
end
2020-08-12 13:34:07 +08:00
-- for k,v in pairs(this.levelData) do
-- LogYellow("v.id:"..k.." state:"..v.state.." v.overTime:"..v.endingTime.." v.data:"..#v.data)
-- for n,m in ipairs(v.data) do
-- --LogGreen("m.id:"..m.id.." state:"..m.state.." 组队条件:"..m.condition.. " 奖励预览:"..#m.rewardList)
2020-08-12 13:34:07 +08:00
-- end
-- end
2020-08-11 09:48:21 +08:00
end
function this.UpdateLevelState(type)
if this.levelData[type] then
table.sort(this.levelData[type].data,function(a,b)
2020-08-14 20:41:07 +08:00
return a.difficulity < b.difficulity
2020-08-11 09:48:21 +08:00
end)
local openLevel = 3
for k,v in ipairs(this.levelData[type].data) do
if v.id <= this.levelData[type].passId then
v.state = 2
if v.id == this.levelData[type].passId then
openLevel = v.openLevel
end
2020-08-14 20:41:07 +08:00
else
v.state = -1
2020-08-11 09:48:21 +08:00
end
if v.difficulity <= openLevel then
if v.state == -1 then
v.state = 0
end
if this.levelData[type].passId == 0 then
if v.difficulity == (this.levelData[type].passId + 1) then
v.state = 1
end
else
if v.id == (this.levelData[type].passId + 1) then
v.state = 1
end
end
end
end
end
2020-07-20 19:46:08 +08:00
end
function this.PropertyName(_type)
_type = tonumber(_type)
if _type == 1 then
2021-03-02 16:53:12 +08:00
return Language[10327]
2020-07-20 19:46:08 +08:00
elseif _type == 2 then
2021-03-02 16:53:12 +08:00
return Language[10328]
2020-07-20 19:46:08 +08:00
elseif _type == 3 then
2021-03-02 16:53:12 +08:00
return Language[10329]
2020-07-20 19:46:08 +08:00
elseif _type == 4 then
2021-03-02 16:53:12 +08:00
return Language[10330]
2020-07-20 19:46:08 +08:00
else
2021-03-02 16:53:12 +08:00
return Language[10327]
2020-07-20 19:46:08 +08:00
end
end
2020-08-11 09:48:21 +08:00
--设置剩余次数
2020-08-12 13:34:07 +08:00
function this.GetTimeTip()
-- LogBlue("购买总次数:"..PrivilegeManager.GetPrivilegeNumber(this.buyTimeId))
-- LogBlue("购买使用的次数:"..PrivilegeManager.GetPrivilegeUsedTimes(this.buyTimeId))
-- LogBlue("免费总次数:"..PrivilegeManager.GetPrivilegeNumber(this.freeTimeId))
-- LogBlue("免费使用次数:"..PrivilegeManager.GetPrivilegeUsedTimes(this.freeTimeId))
this.buyTime = PrivilegeManager.GetPrivilegeRemainValue(this.buyTimeId)
--LogBlue("购买剩余次数:"..this.buyTime)
this.freeTime= PrivilegeManager.GetPrivilegeRemainValue(this.freeTimeId) --免费次数
--LogBlue("免费剩余次数:"..this.buyTime)
2020-08-11 09:48:21 +08:00
local str=""
2020-08-12 13:34:07 +08:00
if this.freeTime > 0 then
2021-03-02 16:53:12 +08:00
str=string.format(Language[10299],tostring(this.freeTime))
2020-08-11 09:48:21 +08:00
else
2021-03-02 16:53:12 +08:00
str=string.format(Language[10300],tostring(this.buyTime))
2020-08-11 09:48:21 +08:00
end
return str
end
2021-07-07 17:05:32 +08:00
function this.RetrunFreeAndBuyTimes()
return PrivilegeManager.GetPrivilegeRemainValue(this.freeTimeId),PrivilegeManager.GetPrivilegeRemainValue(this.buyTimeId)
end
2020-08-12 13:34:07 +08:00
function this.GetBuyTimesTip()
local config = raceTowerConfig[1].Privilege
2020-08-18 10:33:19 +08:00
local rechargeCommodityConfig=ConfigManager.GetConfigData(ConfigName.RechargeCommodityConfig,4003)
2020-09-27 20:20:04 +08:00
local rechargeId =tonumber(rechargeCommodityConfig.OpenPrivilege[3])
2020-08-12 13:34:07 +08:00
return PrivilegeManager.GetPrivilegeOpenStatusById(rechargeId)
end
2020-08-11 09:48:21 +08:00
function this.GetMirrorLevelData(_type)
if this.levelData[_type] then
local temp = {}
for k,v in ipairs(this.levelData[_type].data) do
if v.state ~= -1 then
table.insert(temp,v)
end
end
table.sort(temp,function(a,b)
return a.id < b.id
end)
return temp
end
return nil
end
function this.GetMirroData(_type)
if this.levelData[_type] then
return this.levelData[_type]
end
return nil
end
function this.GetMirrorState(_type)
if this.levelData[_type] then
return this.levelData[_type].state
end
return 0
end
function this.GetMirrorEndTime(_type)
if this.levelData[_type] then
return this.levelData[_type].endingTime
end
return 0
2020-07-16 20:24:28 +08:00
end
2020-07-20 19:46:08 +08:00
function this.GetRewardView()
local dataList = {}
2020-08-11 09:48:21 +08:00
for k,v in ConfigPairs(raceTowerRewardConfig) do
2020-07-20 19:46:08 +08:00
local data = {}
if v.Section[1] == v.Section[2] then
data.rank = v.Section[1]
elseif v.Section[2] ~= -1 then
data.rank = v.Section[1] - v.Section[2]
else
end
end
end
2020-08-11 09:48:21 +08:00
--开始战斗
function this.ExecuteFightBattle(id,type,func)
-- TODO: 没有战斗结果校验
2020-08-12 19:17:05 +08:00
NetManager.StartSituationChallengeRequest(id,type,function(msg)
2020-08-11 09:48:21 +08:00
if type == 1 then
local fightData = BattleManager.GetBattleServerData(msg,0)
UIManager.OpenPanel(UIName.BattlePanel, fightData, BATTLE_TYPE.DAILY_CHALLENGE,function(result)
if func then
func()
end
2020-08-12 19:58:09 +08:00
if result.result == 0 then
if this.levelData[this.curType].state == 1 then
UIManager.OpenPanel(UIName.XuanYuanMirrorPanelList,this.curType)
else
UIManager.OpenPanel(UIName.XuanYuanMirrorPanel)
end
2020-08-12 19:17:05 +08:00
elseif result.result == 1 then
2020-08-12 19:58:09 +08:00
this.levelData[this.curType].passId = id
this.UpdateLevelState(this.curType)
PrivilegeManager.RefreshPrivilegeUsedTimes(XuanYuanMirrorManager.freeTimeId, 1)
2020-08-12 21:07:13 +08:00
CheckRedPointStatus(RedPointType.People_Mirror)
2020-08-12 19:58:09 +08:00
if this.levelData[this.curType].state == 1 then
UIManager.OpenPanel(UIName.XuanYuanMirrorPanelList,this.curType)
else
UIManager.OpenPanel(UIName.XuanYuanMirrorPanel)
end
UIManager.OpenPanel(UIName.RewardItemPopup,msg.drop,1,function()
2020-08-11 09:48:21 +08:00
end)
end
2020-08-12 19:58:09 +08:00
2020-08-11 09:48:21 +08:00
end)
else
UIManager.OpenPanel(UIName.RewardItemPopup,msg.drop,1,function()
if func then
func()
end
end)
end
end)
end
2020-07-20 19:46:08 +08:00
2020-07-16 20:24:28 +08:00
return this