349 lines
13 KiB
Lua
349 lines
13 KiB
Lua
require("Base/BasePanel")
|
|
HongMengEnvoyPanel = Inherit(BasePanel)
|
|
|
|
HongMengEnvoyPanel.contents = {
|
|
[1] = {view = require("Modules/Harmony/View/HarmonyScrllow"), panelName = " HongMengEnvoyPanel"}
|
|
}
|
|
HongMengEnvoyPanel.prefab = {}
|
|
|
|
HongMengEnvoyPanel.EnvoyItemList = {}
|
|
local Item = require("Modules/Harmony/EnvoyItem/EnvoyItem")
|
|
|
|
local Gold = 0
|
|
local GrowthAmulet = 0
|
|
HongMengEnvoyPanel.timerEffect = nil
|
|
--初始化组件(用于子类重写)
|
|
function HongMengEnvoyPanel:InitComponent()
|
|
self.UpView = SubUIManager.Open(SubUIConfig.UpView, self.gameObject.transform, {showType = UpViewOpenType.ShowLeft})
|
|
self.btnBack = Util.GetGameObject(self.gameObject, "Back/BackBtn")
|
|
self.helpBtn = Util.GetGameObject(self.gameObject, "HelpBtn")
|
|
self.AddBtn = Util.GetGameObject(self.gameObject, "Panel/HarmonyPanel/AddBtn")
|
|
self.GongMingBtn = Util.GetGameObject(self.gameObject, "Panel/HarmonyPanel/KnowGongMing")
|
|
self.helpPosition = self.helpBtn:GetComponent("RectTransform").localPosition
|
|
self.panel = Util.GetGameObject(self.gameObject, "Panel")
|
|
|
|
self.towerText = Util.GetGameObject(self.gameObject, "Panel/HarmonyPanel/GradeText")
|
|
self.NumText = Util.GetGameObject(self.gameObject, "Panel/HarmonyPanel/itemNumText"):GetComponent("Text")
|
|
self.GradeText = Util.GetGameObject(self.gameObject, "Panel/HarmonyPanel/GradeText"):GetComponent("Text")
|
|
|
|
self.imageGame = Util.GetGameObject(self.gameObject, "GameObject/imageGame")
|
|
self.TextGame = Util.GetGameObject(self.gameObject, "GameObject/TextGame")
|
|
self.UnShowText = Util.GetGameObject(self.gameObject, "GameObject/UnShowText")
|
|
|
|
self.TextGold = Util.GetGameObject(self.gameObject, "GameObject/TextGame/TextGold"):GetComponent("Text")
|
|
self.TextGrowthAmulet = Util.GetGameObject(self.gameObject, "GameObject/TextGame/TextHuFu"):GetComponent("Text")
|
|
|
|
self.UpBtn = Util.GetGameObject(self.gameObject, "UpBtn")
|
|
self.UpBtnRedPoint = Util.GetGameObject(self.gameObject,"UpBtn/RedPoint")
|
|
|
|
local parent = Util.GetGameObject(self.gameObject, "Panel/HongMeng")
|
|
local ItemPfb = Util.GetGameObject(self.gameObject, "Panel/HarmonyPanel/item")
|
|
--初始化格子中的数据
|
|
HarmonyManager:InitGongMingDataList()
|
|
HarmonyManager:SetTowerInit()
|
|
|
|
self:InitEnvoyItemList(ItemPfb, parent)
|
|
|
|
|
|
end
|
|
|
|
function HongMengEnvoyPanel:InitEnvoyItemList(ItemPfb, parent)
|
|
for i = 1, #HarmonyManager.hongmengGuards do
|
|
-- bodys
|
|
|
|
self.EnvoyItemList[i] = Item:New(newObject(ItemPfb))
|
|
|
|
self.EnvoyItemList[i]:InitComponent(parent, HarmonyManager.hongmengGuards[i])
|
|
end
|
|
|
|
for i = 1, #self.contents do
|
|
self.prefab[i] = Util.GetGameObject(self.panel, self.contents[i].panelName)
|
|
self.contents[i].view:InitComponent(
|
|
self.panel,
|
|
BagManager.GetTotalItemNum(UpViewRechargeType.XuanHuangZhiQi),
|
|
BagManager.GetTotalItemNum(UpViewRechargeType.DemonCrystal),
|
|
2
|
|
)
|
|
end
|
|
end
|
|
--绑定事件(用于子类重写)
|
|
function HongMengEnvoyPanel:BindEvent()
|
|
Util.AddClick(self.btnBack,function()
|
|
self:ClosePanel()
|
|
end)
|
|
Util.AddClick(self.helpBtn,function()
|
|
UIManager.OpenPanel(UIName.HelpPopup, HELP_TYPE.HongMengZhen, self.helpPosition.x, self.helpPosition.y+1100)
|
|
end)
|
|
|
|
Util.AddClick(self.AddBtn,function()
|
|
Game.GlobalEvent:DispatchEvent(GameEvent.HongMeng.OpenBoxTips)
|
|
end)
|
|
--共鸣按钮
|
|
Util.AddClick(self.GongMingBtn,function()
|
|
local count = HarmonyManager:IsEnvoyCount()
|
|
LogGreen(count)
|
|
if count > 6 then
|
|
UIManager.OpenPanel(UIName.GongMingResultTips)
|
|
else
|
|
PopupTipPanel.ShowTip(Language[12200])
|
|
end
|
|
end)
|
|
|
|
Util.AddClick(self.UpBtn,function()
|
|
if HarmonyManager.GetSingleAdditionsData(HarmonyAddType.AddLv).value >= HarmonyManager:HongMengTowerUpLimit() then
|
|
PopupTipPanel.ShowTip(Language[12201])
|
|
else
|
|
local data = HarmonyManager:GetHongMengUpData()
|
|
--print(data.LevelUp[1][2].." "..data.LevelUp[2][2])
|
|
if data == nil then
|
|
return
|
|
end
|
|
Gold = BagManager.GetTotalItemNum(UpViewRechargeType.Gold)
|
|
GrowthAmulet = BagManager.GetTotalItemNum(UpViewRechargeType.GrowthAmulet)
|
|
if Gold >= data.LevelUp[1][2] then
|
|
if GrowthAmulet >= data.LevelUp[2][2] then
|
|
HarmonyManager.SetOldPowerNum()
|
|
NetManager.UpHongMengGrade(function()
|
|
local sum = HarmonyManager:HongMengTowerUpLimit()
|
|
HarmonyManager.GetSingleAdditionsData(HarmonyAddType.AddLv).value = HarmonyManager.GetSingleAdditionsData(HarmonyAddType.AddLv).value + 1
|
|
if HarmonyManager.GetSingleAdditionsData(HarmonyAddType.AddLv).value >= sum then
|
|
Util.SetGray(self.UpBtn, true)
|
|
self.imageGame:SetActive(false)
|
|
self.TextGame:SetActive(false)
|
|
self.UnShowText:SetActive(true)
|
|
self.UpBtnRedPoint:SetActive(false)
|
|
end
|
|
self.GradeText.text = Language[12202]..string.format("%d/%d", HarmonyManager.GetSingleAdditionsData(HarmonyAddType.AddLv).value, sum)
|
|
for i = 1, #self.EnvoyItemList do
|
|
self.EnvoyItemList[i]:UpdateFun()
|
|
end
|
|
Game.GlobalEvent:DispatchEvent(GameEvent.HongMeng.UpdateGongMingLv)
|
|
CheckRedPointStatus(RedPointType.HongMeng_UpTower)
|
|
|
|
HarmonyManager.WarPowerChangeNotify()
|
|
end)
|
|
else
|
|
PopupTipPanel.ShowTip(Language[12203])
|
|
end
|
|
else
|
|
PopupTipPanel.ShowTip(Language[11771])
|
|
end
|
|
end
|
|
end)
|
|
BindRedPointObject(RedPointType.HongMeng_UpTower,self.UpBtnRedPoint)
|
|
end
|
|
function HongMengEnvoyPanel:RunTimerFun()
|
|
local refreshFunc = function()
|
|
for key, value in pairs(self.EnvoyItemList) do
|
|
if HarmonyManager.hongmengGuards[key].time - GetTimeStamp() > 0 then
|
|
if value.Empty.activeSelf == false then
|
|
-- body
|
|
value.Empty:SetActive(true)
|
|
end
|
|
local time_content = TimeToFelaxible(HarmonyManager.hongmengGuards[key].time - GetTimeStamp())
|
|
value.timer_text.text = string.format(Language[12204], time_content)
|
|
else
|
|
if not value.AddImage.activeSelf then
|
|
value.AddImage:SetActive(true)
|
|
value.timer_text.text = ""
|
|
end
|
|
end
|
|
end
|
|
end
|
|
if self.timerEffect == nil then
|
|
self.timerEffect = Timer.New(refreshFunc, 1, -1, true)
|
|
end
|
|
self.timerEffect:Start()
|
|
refreshFunc()
|
|
end
|
|
function HongMengEnvoyPanel:IsUpBtnGray()
|
|
local sum = HarmonyManager:HongMengTowerUpLimit()
|
|
if HarmonyManager.GetSingleAdditionsData(HarmonyAddType.AddLv).value >= sum then
|
|
Util.SetGray(self.UpBtn, true)
|
|
self.imageGame:SetActive(false)
|
|
self.TextGame:SetActive(false)
|
|
self.UnShowText:SetActive(true)
|
|
-- self.UpBtnRedPoint:SetActive(false)
|
|
else
|
|
Util.SetGray(self.UpBtn, false)
|
|
self.imageGame:SetActive(true)
|
|
self.TextGame:SetActive(true)
|
|
self.UnShowText:SetActive(false)
|
|
end
|
|
--检测一次红点
|
|
CheckRedPointStatus(RedPointType.HongMeng_UpTower)
|
|
end
|
|
function HongMengEnvoyPanel:RefeshRedPoint()
|
|
-- body
|
|
|
|
end
|
|
function HongMengEnvoyPanel:UpdateShow(list)
|
|
|
|
for i = 1, #list do
|
|
--LogBlue("执行刷新"..list[i].heroId)
|
|
self.EnvoyItemList[i]:SetItemData(list[i])
|
|
self.EnvoyItemList[i]:SetItem(self.EnvoyItemList[i].gameObject, list[i])
|
|
end
|
|
|
|
local Box = #HarmonyManager.hongmengGuards + #HarmonyManager.hongmengHeroInfos
|
|
local HeroCount = 0
|
|
for i = 1, #HarmonyManager.hongmengGuards do
|
|
if HarmonyManager.hongmengGuards[i].heroId ~= "" then
|
|
HeroCount = HeroCount + 1
|
|
end
|
|
end
|
|
for i = 1, #HarmonyManager.hongmengHeroInfos do
|
|
if HarmonyManager.hongmengHeroInfos[i].heroId ~= "" then
|
|
HeroCount = HeroCount + 1
|
|
end
|
|
end
|
|
self:ReFeshTextFun({HeroCount,Box})
|
|
end
|
|
|
|
function HongMengEnvoyPanel:UpdateFun(data)
|
|
|
|
self:RunTimerFun()
|
|
|
|
self:UpdateShow(HarmonyManager.hongmengGuards)
|
|
-- HeroManager.UpdateSingleHeroDatas(data.dynamicId,1,data.star,data.breakId,data.upStarId)
|
|
end
|
|
function HongMengEnvoyPanel:ReFeshTextFun(data)
|
|
local HeroCount = data[1]
|
|
local Box = data[2]
|
|
self.NumText.text = string.format("%d/%d", HeroCount, Box)
|
|
end
|
|
function HongMengEnvoyPanel:UpdateTextColor()
|
|
Gold = BagManager.GetTotalItemNum(UpViewRechargeType.Gold)
|
|
GrowthAmulet = BagManager.GetTotalItemNum(UpViewRechargeType.GrowthAmulet)
|
|
--获取当前需要道具数量的数据
|
|
local data = HarmonyManager:GetHongMengUpData()
|
|
if Gold >= data.LevelUp[1][2] then
|
|
-- 是否变色
|
|
self.TextGold.text = string.format("<color=#F1E7E7>%d</color>",data.LevelUp[1][2])
|
|
else
|
|
self.TextGold.text = string.format("<color=#E15558>%d</color>",data.LevelUp[1][2])
|
|
end
|
|
if GrowthAmulet >= data.LevelUp[2][2] then
|
|
self.TextGrowthAmulet.text = string.format("<color=#F1E7E7>%d</color>",data.LevelUp[2][2])
|
|
else
|
|
self.TextGrowthAmulet.text = string.format("<color=#E15558>%d</color>",data.LevelUp[2][2])
|
|
end
|
|
end
|
|
function HongMengEnvoyPanel:UpdateGoldVal()
|
|
self:UpdateTextColor()
|
|
|
|
end
|
|
--添加事件监听(用于子类重写)
|
|
function HongMengEnvoyPanel:AddListener()
|
|
for i = 1, #self.contents do
|
|
self.contents[i].view:AddListener()
|
|
end
|
|
Game.GlobalEvent:AddEvent(GameEvent.HongMeng.UnLoadHongMengEnvoy, self.UpdateFun, self)
|
|
Game.GlobalEvent:AddEvent(GameEvent.HongMeng.OnlyRefeshText, self.ReFeshTextFun, self)
|
|
Game.GlobalEvent:AddEvent(GameEvent.HongMeng.UpHongMengEnvoy, self.UpdateFun, self)
|
|
Game.GlobalEvent:AddEvent(GameEvent.Bag.BagGold, self.UpdateGoldVal, self)
|
|
end
|
|
|
|
--移除事件监听(用于子类重写)
|
|
function HongMengEnvoyPanel:RemoveListener()
|
|
for i = 1, #self.contents do
|
|
self.contents[i].view:RemoveListener()
|
|
end
|
|
Game.GlobalEvent:RemoveEvent(GameEvent.HongMeng.UnLoadHongMengEnvoy, self.UpdateFun, self)
|
|
Game.GlobalEvent:RemoveEvent(GameEvent.HongMeng.OnlyRefeshText, self.ReFeshTextFun, self)
|
|
Game.GlobalEvent:RemoveEvent(GameEvent.HongMeng.UpHongMengEnvoy, self.UpdateFun, self)
|
|
|
|
end
|
|
|
|
--界面打开时调用(用于子类重写)
|
|
function HongMengEnvoyPanel:OnOpen(equipSId)
|
|
--NetManager.PlayerInfoRequest(LoadingPanel.OnStep)
|
|
|
|
for i = 1, #self.EnvoyItemList do
|
|
self.EnvoyItemList[i]:OnOpen()
|
|
end
|
|
|
|
for i = 1, #self.contents do
|
|
self.contents[i].view:OnOpen()
|
|
end
|
|
local data = HarmonyManager:GetHongMengUpData()
|
|
if data then
|
|
self:UpdateTextColor()
|
|
else
|
|
LogGreen(" error: data is nil ")
|
|
end
|
|
|
|
|
|
local sum = HarmonyManager:HongMengTowerUpLimit()
|
|
self.GradeText.text = Language[12202]..string.format("%d/%d", HarmonyManager.GetSingleAdditionsData(HarmonyAddType.AddLv).value, sum)
|
|
self:IsUpBtnGray()
|
|
self:InitTextMum()
|
|
self:CheckEvoyEquip()
|
|
self:RunTimerFun()
|
|
-- self.timerEffect:Start()
|
|
end
|
|
--检测鸿蒙守卫装备是否够24件
|
|
function HongMengEnvoyPanel:CheckEvoyEquip()
|
|
-- body
|
|
local list= {}
|
|
HarmonyManager.equipCount = 0
|
|
for i = 1, #HarmonyManager.hongmengGuards do
|
|
if HarmonyManager.hongmengGuards[i].heroId ~= "" then
|
|
local singleHero = HeroManager.GetSingleHeroData(HarmonyManager.hongmengGuards[i].heroId)
|
|
table.insert(list,singleHero)
|
|
end
|
|
end
|
|
for i = 1, #list do
|
|
if list[i].equipIdList then
|
|
for i = 1, #list[i].equipIdList do
|
|
HarmonyManager.equipCount = HarmonyManager.equipCount + 1
|
|
end
|
|
end
|
|
end
|
|
|
|
end
|
|
|
|
function HongMengEnvoyPanel:InitTextMum()
|
|
local HeroCount = 0
|
|
local Box = #HarmonyManager.hongmengHeroInfos + #HarmonyManager.hongmengGuards
|
|
for i = 1, #HarmonyManager.hongmengHeroInfos do
|
|
if HarmonyManager.hongmengHeroInfos[i].heroId ~= "" then
|
|
HeroCount = HeroCount + 1
|
|
end
|
|
end
|
|
|
|
for i = 1, #HarmonyManager.hongmengGuards do
|
|
if HarmonyManager.hongmengGuards[i].heroId ~= "" then
|
|
HeroCount = HeroCount + 1
|
|
end
|
|
end
|
|
|
|
self.NumText.text = string.format("%d/%d", HeroCount, Box)
|
|
end
|
|
--界面打开或者重新打开后,界面刷新时调用(用于子类重写)
|
|
function HongMengEnvoyPanel:OnShow()
|
|
self.UpView:OnOpen({ showType = UpViewOpenType.ShowLeft, panelType = PanelType.HongMengTower})
|
|
end
|
|
|
|
--界面关闭时调用(用于子类重写)
|
|
function HongMengEnvoyPanel:OnClose()
|
|
for i = 1, #self.contents do
|
|
self.contents[i].view:OnClose()
|
|
end
|
|
if self.timerEffect then
|
|
self.timerEffect:Stop()
|
|
self.timerEffect = nil
|
|
end
|
|
end
|
|
|
|
--界面销毁时调用(用于子类重写)
|
|
function HongMengEnvoyPanel:OnDestroy()
|
|
SubUIManager.Close(self.UpView)
|
|
if self.timerEffect then
|
|
self.timerEffect:Stop()
|
|
self.timerEffect = nil
|
|
end
|
|
ClearRedPointObject(RedPointType.HongMeng_UpTower,self.UpBtnRedPoint)
|
|
end
|
|
|
|
return HongMengEnvoyPanel |