特训管理类提交
parent
b624bc17b5
commit
8b59fae009
|
@ -0,0 +1,194 @@
|
|||
TrainBuildManager = {}
|
||||
local this = TrainBuildManager
|
||||
local HomeLand = ConfigManager.GetConfig(ConfigName.TrainBuild)
|
||||
local HomeLandLevel = ConfigManager.GetConfig(ConfigName.TrainBuildLevel)
|
||||
local ItemConfig = ConfigManager.GetConfig(ConfigName.ItemConfig)
|
||||
|
||||
function this.Initialize()
|
||||
this.BuildData = {}
|
||||
for _, configData in ConfigPairs(HomeLand) do
|
||||
this.BuildData[configData.Id] = {}
|
||||
this.BuildData[configData.Id].dataMain = configData--HomeLand中数据
|
||||
if configData.LvupCostPool > 0 then
|
||||
this.BuildData[configData.Id].level = 1 --等级
|
||||
local singledata = ConfigManager.GetConfigDataByDoubleKey(ConfigName.TrainBuildLevel,"PoolID",configData.Id,"level",this.BuildData[configData.Id].level)
|
||||
this.BuildData[configData.Id].dataSingle = singledata--HomeLandLevel中数据
|
||||
this.BuildData[configData.Id].startTime = 0 --资源开始积攒的时间
|
||||
this.BuildData[configData.Id].endTime = 0 --建筑升级的结束时间
|
||||
this.BuildData[configData.Id].heroId =nil --特训英雄
|
||||
this.BuildData[configData.Id].heroStarTime =0
|
||||
this.BuildData[configData.Id].isOpen = this.CheckBuildIsOpen(configData.UnlockLevel)
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
---检测功能开启方法
|
||||
function this.CheckBuildIsOpen(str)
|
||||
if not str then
|
||||
return false
|
||||
end
|
||||
local type=str[1]
|
||||
local value=str[2]
|
||||
if type==1 then
|
||||
return PlayerManager.level>=value
|
||||
elseif type==2 then
|
||||
return this.BuildData[1].level>=value
|
||||
end
|
||||
return true
|
||||
end
|
||||
|
||||
--接收服务器信息
|
||||
function this.GetServerData(msg,func)
|
||||
if msg.infos and #msg.infos > 0 then
|
||||
for index, value in ipairs(msg.infos) do
|
||||
-- LogGreen("Id:"..tostring(value.id).." startTime:"..tostring(TimeStampToDateStr4(value.productionStartTime)).." endTime:"..tostring(TimeStampToDateStr4(value.upLvEndTime)))
|
||||
if value.id and value.id > 0 then
|
||||
local data = HomeLandLevel[value.id]
|
||||
if data then
|
||||
this.BuildData[data.PoolID].level = data.level
|
||||
this.BuildData[data.PoolID].startTime = value.productionStartTime
|
||||
this.BuildData[data.PoolID].endTime = value.upLvEndTime
|
||||
this.BuildData[data.PoolID].dataSingle = HomeLandLevel[value.id]
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
if msg.drop then
|
||||
UIManager.OpenPanel(UIName.RewardItemPopup, msg.drop, 1)
|
||||
end
|
||||
if func then
|
||||
func()
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
--升级材料和前置浮生殿等级检测
|
||||
function this.ResumeCost(_data,_str,func)
|
||||
if _data.Rule and #_data.Rule>0 and type(_data.Rule[1])~="userdata" and this.BuildData[_data.Rule[1]].level < _data.Rule[2] then
|
||||
PopupTipPanel.ShowTip(string.format("%s到达%s级可升级!",this.BuildData[_data.Rule[1]].dataMain.Name,_data.Rule[2]))
|
||||
return
|
||||
end
|
||||
|
||||
local data = {}
|
||||
for i = 1, #_data.Cost do
|
||||
if not data[_data.Cost[i][1]] then
|
||||
data[_data.Cost[i][1]] = 0
|
||||
end
|
||||
data[_data.Cost[i][1]] = data[_data.Cost[i][1]] + _data.Cost[i][2]
|
||||
end
|
||||
if _str then--立即完成
|
||||
-- LogGreen(tostring(_data.Time).." "..tostring(tonumber(_str[1])).." "..tonumber(_str[3]))
|
||||
data[16] = math.ceil(_data.Time/tonumber(_str[1]))*tonumber(_str[3])
|
||||
end
|
||||
for key, value in pairs(data) do
|
||||
-- LogGreen(string.format("需要%s: %s,现有:%s",key,value,BagManager.GetTotalItemNum(key)))
|
||||
if BagManager.GetTotalItemNum(key) < value then
|
||||
PopupTipPanel.ShowTip(string.format("%s不足!",ItemConfig[key].Name))
|
||||
return
|
||||
end
|
||||
end
|
||||
func(data[16])
|
||||
end
|
||||
--检测当前停留
|
||||
function this.GetCurIndex()
|
||||
for i = 1, 4 do
|
||||
if this.EquipData[i].configData.Limit2 == EquipRankUp[this.levelProId].Level then
|
||||
if this.EquipData[i].configData.Cost and this.EquipData[i].configData.Cost[1][2] <= BagManager.GetTotalItemNum(this.EquipData[i].configData.Cost[1][1]) then
|
||||
this.curEquip = i
|
||||
return
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
--检测按钮显示
|
||||
function this.GetCurIndexBtnsShow()
|
||||
return this.EquipData[this.curEquip].configData.Limit2 == EquipRankUp[this.levelProId].Level
|
||||
end
|
||||
|
||||
--==============================红点检测==============================
|
||||
--烦人的红点检测(我决定1-4写一个、5写一个,6写一个、任务写一个、7移植过来,然后写个总的检测跑一遍所有)
|
||||
function this.CheckRedMain()
|
||||
if this.Check1to5Building() then
|
||||
return true
|
||||
end
|
||||
if this.CheckMission() then
|
||||
return true
|
||||
end
|
||||
if this.CheckEquipUpgrade() then
|
||||
return true
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
function this.Check1to5Building()
|
||||
local data = this.BuildData
|
||||
for i = 1, 5 do
|
||||
if data[i].dataMain.IsOpen == 1 and (this.singleUpgrade(i) or this.singleGet(i)) then
|
||||
return true
|
||||
end
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
--1-5建筑的单个升级
|
||||
function this.singleUpgrade(id)
|
||||
local data = this.BuildData[id].dataSingle
|
||||
if HomeLand[id].UnlockLevel[1] == 1 and PlayerManager.level < HomeLand[id].UnlockLevel[2] then
|
||||
elseif HomeLand[id].UnlockLevel[1] == 2 and HomeLandManager.BuildData[5].level < HomeLand[id].UnlockLevel[2] then
|
||||
elseif HomeLand[id].UnlockLevel[1] == 3 and PlayerManager.level < GlobalSystemConfig[HomeLand[id].UnlockLevel[2]].OpenRules[2] then
|
||||
else
|
||||
if data.Cost and BagManager.GetTotalItemNum(data.Cost[1][1]) >= data.Cost[1][2] then--所需材料够
|
||||
if not data.Rule or (this.BuildData[data.Rule[1]].level >= data.Rule[2]) then--到达升级条件
|
||||
if this.BuildData[id].endTime <= GetTimeStamp() then
|
||||
return true
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
--1-4建筑的单个领取
|
||||
function this.singleGet(id)
|
||||
local data = this.BuildData[id]
|
||||
if data.dataMain.Type == 1 and data.dataSingle.Gain and this.BuildData[5].level > data.dataMain.UnlockLevel[2] then
|
||||
return (GetTimeStamp() - data.startTime)/60*data.dataSingle.Gain[2] >= data.dataSingle.Storage[1][2]
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
--检测任务
|
||||
function this.CheckMission()
|
||||
local data = this.SetRewardData()
|
||||
for index, value in ipairs(data) do
|
||||
if value.state == 1 then
|
||||
return true
|
||||
end
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
--===============设置按钮位置=================
|
||||
local POS = {
|
||||
[1] = {Vector3.New(0,110,0)},
|
||||
[2] = {Vector3.New(-75,80,0),Vector3.New(75,80,0)},
|
||||
[3] = {Vector3.New(0,110,0),Vector3.New(-100,30,0),Vector3.New(100,30,0)},
|
||||
[4] = {Vector3.New(55,90,0),Vector3.New(110,0,0),Vector3.New(-55,90,0),Vector3.New(-110,0,0)},
|
||||
}
|
||||
function this.SetButtonPosition(Obj)
|
||||
local objList = {}
|
||||
for i = 1, Obj.transform.childCount do
|
||||
-- LogRed(tostring(Obj.transform:GetChild(i-1).gameObject.activeInHierarchy))
|
||||
if Obj.transform:GetChild(i-1).gameObject.activeInHierarchy then
|
||||
table.insert(objList,Obj.transform:GetChild(i-1).gameObject)
|
||||
end
|
||||
end
|
||||
-- LogError("#objList"..tostring(#objList))
|
||||
for index, value in ipairs(objList) do
|
||||
value:GetComponent("RectTransform").localPosition = POS[#objList][index]
|
||||
end
|
||||
end
|
||||
|
||||
return TrainBuildManager
|
|
@ -0,0 +1,7 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 27644bbaa54f67a4eb8418002be42d51
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Loading…
Reference in New Issue