miduo_client/Assets/ManagedResources/~Lua/Modules/LingMaiMiJing/LingMaiMiJingManager.lua

157 lines
6.7 KiB
Lua
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

LingMaiMiJingManager = {}
local this = LingMaiMiJingManager
local lodeConfig = ConfigManager.GetConfig(ConfigName.LodeConfig)
local monsterGroup = ConfigManager.GetConfig(ConfigName.MonsterGroup)
local monsterConfig = ConfigManager.GetConfig(ConfigName.MonsterConfig)
function this.Initialize()
this.state = 1--当前状态
this.startTime = 0--我开始占领此矿脉的时间
this.endTime = 1638460800--结束时间
this.myPlaceId = 1--当前我占领的矿脉的id
this.fightTime = 0--我的剩余挑战次数
this.curPage = 0
this.lingmaiData = {}
this.battleResult = {}
this.recordData = {}
end
--获取manager中的信息
function this.GetData()
local data = {}
data.state = this.state
data.startTime = this.startTime
data.endTime = this.endTime
data.myPlaceId = this.myPlaceId
data.lingmaiData = {}
for i = 1, 5 do
data.lingmaiData[i] = {}
-- LogGreen("placeId:"..tostring(this.lingmaiData[i].id).." playerId:"..tostring(this.lingmaiData[i].uid).." Name:"..tostring(this.lingmaiData[i].name))
if not this.lingmaiData[i] then
LogError("服务器发来的灵脉Id为0")
-- Game.GlobalEvent:DispatchEvent(GameEvent.LingMaiMiJing.ClosePanel)
return nil
end
data.lingmaiData[i].Id = this.lingmaiData[i].lingmaiId
local curId = data.lingmaiData[i].Id
data.lingmaiData[i].No = lodeConfig[curId].No
data.lingmaiData[i].PageNo = lodeConfig[curId].PageNo
data.lingmaiData[i].Group = lodeConfig[curId].Group
data.lingmaiData[i].Quality = lodeConfig[curId].Quality
data.lingmaiData[i].RewardList = lodeConfig[curId].RewardList
data.lingmaiData[i].Guard = lodeConfig[curId].Guard
data.lingmaiData[i].veinName = lodeConfig[curId].Name
local monsterGroupData = monsterGroup[data.lingmaiData[i].Guard].Contents
--拼接玩家数据
if this.lingmaiData[i].uid ~= 0 then
data.lingmaiData[i].uid = this.lingmaiData[i].uid
data.lingmaiData[i].name = this.lingmaiData[i].name
data.lingmaiData[i].servername = this.lingmaiData[i].servername
data.lingmaiData[i].head = this.lingmaiData[i].head
data.lingmaiData[i].headFrame = this.lingmaiData[i].headFrame
else
data.lingmaiData[i].uid = 0
data.lingmaiData[i].name = "灵脉守护者"
data.lingmaiData[i].servername = ""
data.lingmaiData[i].head = 0
data.lingmaiData[i].headFrame = 0
data.lingmaiData[i].level = 100
data.lingmaiData[i].teamInfo = {}
data.lingmaiData[i].teamInfo.totalForce = lodeConfig[curId].GuardCombatNum
data.lingmaiData[i].teamInfo.team = {}
for j = 1, 6 do
if monsterGroupData[1] then
local monsterData = monsterConfig[monsterGroupData[1][j]]
local herodata = {}
-- LogBlue(data.lingmaiData[i].Guard.." "..monsterGroupData[1][j].." "..monsterData.MonsterId.." "..monsterData.Star.." "..monsterData.Level)
herodata.heroTid = monsterData.MonsterId
herodata.star = monsterData.Star
herodata.level = monsterData.Level
herodata.position = j
herodata.skinId = 0
herodata.godSoulLv = 0
table.insert(data.lingmaiData[i].teamInfo.team,herodata)
end
end
end
end
return data
end
--获取服务器发来的信息
function this.GetLingMaiServerData(msg,func)
this.state = msg.state
this.myPlaceId = msg.myOccupyId
this.startTime = msg.myOccupyTime
this.fightTime = msg.remainChangeTimes
this.endTime = msg.timePoint
this.lingmaiData = msg.lingmaiData
for i = 1, #msg.lingmaiData do
this.curPage = lodeConfig[msg.lingmaiData[i].lingmaiId].PageNo
LogYellow("id:"..tostring(msg.lingmaiData[i].lingmaiId).." uid:"..tostring(msg.lingmaiData[i].uid).." name:"..tostring(msg.lingmaiData[i].name)
.." practiceLevel:"..tostring(msg.lingmaiData[i].practiceLevel).." servername:"..tostring(msg.lingmaiData[i].servername))
msg.lingmaiData[i].name = PracticeManager.SetNameColor(msg.lingmaiData[i].name,msg.lingmaiData[i].practiceLevel)
end
LogGreen("state:"..tostring(msg.state).." myPlaceId:"..tostring(msg.myOccupyId).." startTime:"..tostring(msg.myOccupyTime)
.." fightTime:"..tostring(msg.remainChangeTimes).." lingmaiData:"..tostring(#msg.lingmaiData).." curPage:"..tostring(this.curPage).." timePoint:"..tostring(msg.timePoint))
-- Game.GlobalEvent:DispatchEvent(GameEvent.LingMaiMiJing.RefreshPanel)
if func then
func()
end
end
function this.OpenRecord()
NetManager.LingMaiRecordRequest(function ()
UIManager.OpenPanel(UIName.GeneralBigPopup,GENERAL_POPUP_TYPE.LingMaiRecord)
end)
end
function this.CheckPrivilage(func)
-- LogBlue("特权2030"..tostring(PrivilegeManager.GetPrivilegeRemainValue(2030)).." 特权2031"..tostring(PrivilegeManager.GetPrivilegeRemainValue(2031)))
if PrivilegeManager.GetPrivilegeRemainValue(2030) <= 0 then
if PrivilegeManager.GetPrivilegeRemainValue(2031) > 0 then
local costId, finalNum, oriCostNum = ShopManager.calculateBuyCost(SHOP_TYPE.FUNCTION_SHOP,10044, 1)
local itemName = ConfigManager.GetConfigData(ConfigName.ItemConfig,costId).Name
MsgPanel.ShowTwo(string.format( Language[10516],finalNum,itemName), nil, function()
--买东西
ShopManager.RequestBuyShopItem(SHOP_TYPE.FUNCTION_SHOP,10044,1,function()
PopupTipPanel.ShowTip(Language[10517])
PrivilegeManager.RefreshPrivilegeUsedTimes(2031, 1)--更新特权
func()
end,0)
end)
else
PopupTipPanel.ShowTip("<color=red>今日已无挑战次数!</color>")
end
else
func()
end
end
function this.CheckRedPoint()
if this.state ~= 1 then
return false
end
if PrivilegeManager.GetPrivilegeRemainValue(2030) > 0 then
return true
end
if #this.recordData > 0 then
if not PlayerPrefs.GetString(PlayerManager.uid.."LingMai") then
PlayerPrefs.SetString(PlayerManager.uid.."LingMai", "")
end
if PlayerPrefs.GetString(PlayerManager.uid.."LingMai") ~= tostring(this.recordData[1].time) then
return true
end
end
return false
end
function this.CheckRecord()
if this.recordData[1] then
return PlayerPrefs.GetString(PlayerManager.uid.."LingMai") ~= tostring(this.recordData[1].time)
end
return false
end
return LingMaiMiJingManager