miduo_client/Assets/ManagedResources/~Lua/Modules/Guild/Transcript/GuildTranscriptMainPopup.lua

418 lines
20 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.

require("Base/BasePanel")
GuildTranscriptMainPopup = Inherit(BasePanel)
local this = GuildTranscriptMainPopup
local guildCheckpointConfig = ConfigManager.GetConfig(ConfigName.GuildCheckpointConfig)
local heroConfig = ConfigManager.GetConfig(ConfigName.HeroConfig)
local cutOpenIndex = 0
local cutOpenIndexConFig
local cutOpenIndexMonsterConFig
local itemList = {}--优化itemView使用
local sorting = 0
local curBuyIndex = 0
--初始化组件(用于子类重写)
function GuildTranscriptMainPopup:InitComponent()
--btn
this.backBtn = Util.GetGameObject(self.gameObject, "btnBack")
this.helpBtn = Util.GetGameObject(self.gameObject,"HelpBtn")
this.helpPos = this.helpBtn:GetComponent("RectTransform").localPosition
this.quickWarbtn = Util.GetGameObject(self.gameObject,"quickWarbtn")
this.warbtn = Util.GetGameObject(self.gameObject,"warbtn")
this.rankBun = Util.GetGameObject(self.gameObject,"middleGo/rankBun")
this.sendBtn = Util.GetGameObject(self.gameObject,"middleGo/sendBtn")
this.endNumBtn = Util.GetGameObject(self.gameObject,"middleGo/endNumBtn")
--text
this.name = Util.GetGameObject(self.gameObject,"middleGo/endNumBtn"):GetComponent("Text")--军团副本
this.rewardGoText1 = Util.GetGameObject(self.gameObject,"middleGo/rewardGo/tip/Text1"):GetComponent("Text")--单次奖励
this.rewardGoText2 = Util.GetGameObject(self.gameObject,"middleGo/rewardGo/tip/Text2"):GetComponent("Text")--击杀奖励
this.attackInfoBtn = Util.GetGameObject(self.gameObject,"middleGo/attackInfo")
this.attackInfoText = Util.GetGameObject(self.gameObject,"middleGo/attackInfo/attackInfoText"):GetComponent("Text")--全军团成员攻击力+16%
this.attackInfoTime = Util.GetGameObject(self.gameObject,"middleGo/attackInfo/attackInfoTime"):GetComponent("Text")--08:52:24后失效
this.attackInfoTextGo = Util.GetGameObject(self.gameObject,"middleGo/attackInfo/attackInfoText")
this.attackInfoTimeGO = Util.GetGameObject(self.gameObject,"middleGo/attackInfo/attackInfoTime")
this.endNumText = Util.GetGameObject(self.gameObject,"middleGo/endNumBtn/endNumBuyText"):GetComponent("Text")--剩余购买次数:3
this.endNumBuyText = Util.GetGameObject(self.gameObject,"middleGo/endNumBtn/endNumText"):GetComponent("Text")--剩余次数:22
--boss
this.boss = Util.GetGameObject(self.gameObject,"middleGo/boss")
this.bossHerobg=Util.GetGameObject(this.boss,"Bg1"):GetComponent("Image")
this.bossHerolive = Util.GetGameObject(this.boss, "Mask/icon"):GetComponent("RawImage")
this.bossHerohpPass = Util.GetGameObject(this.boss,"hpPass"):GetComponent("Image")
this.bossHerohpPassText = Util.GetGameObject(this.boss,"hpText"):GetComponent("Text")
--titlechapter
local v2 = Util.GetGameObject(self.gameObject, "upChapterGo/upChapter"):GetComponent("RectTransform").rect
this.titleScrollView = SubUIManager.Open(SubUIConfig.ScrollCycleView, Util.GetGameObject(self.gameObject, "upChapterGo/upChapter").transform,
Util.GetGameObject(self.gameObject, "upChapterGo/singleChapterPre"), nil, Vector2.New(-v2.x*2, -v2.y*2), 2, 1, Vector2.New(10,10))
this.titleScrollView.moveTween.MomentumAmount = 1
this.titleScrollView.moveTween.Strength = 1
this.reward1 = Util.GetGameObject(self.gameObject, "middleGo/rewardGo/reward1")
this.reward2 = Util.GetGameObject(self.gameObject, "middleGo/rewardGo/reward2")
this.Empty = Util.GetGameObject(self.gameObject, "endGo/Empty")
Util.GetGameObject(self.gameObject, "endGo/Empty/Bg/Text"):GetComponent("Text").text = "还未有人挑战过此首领"
end
--绑定事件(用于子类重写)
function GuildTranscriptMainPopup:BindEvent()
Util.AddClick(this.helpBtn,function()
UIManager.OpenPanel(UIName.HelpPopup,HELP_TYPE.GuildTranscripe,this.helpPos.x,this.helpPos.y)
end)
Util.AddClick(this.backBtn,function()
self:ClosePanel()
end)
Util.AddClick(this.warbtn,function()
-- if GuildTranscriptManager.GetCanBattleCount() <=0 then --今日已无剩余次数!
-- if GuildTranscriptManager.GetCanBuyBattleCount() <= 0 then
-- PopupTipPanel.ShowTip("今日已无剩余次数!")
-- else--是否花费XX妖晶购买1次挑战次数并发起挑战
-- local costId, finalNum, oriCostNum = ShopManager.calculateBuyCost(SHOP_TYPE.FUNCTION_SHOP, GuildTranscriptManager.shopGoodId, 1)
-- local itemName = ConfigManager.GetConfigData(ConfigName.ItemConfig,costId).Name
-- if finalNum > BagManager.GetItemCountById(costId) then
-- PopupTipPanel.ShowTip(string.format("%s数量不足",itemName) )
-- return
-- end
-- MsgPanel.ShowTwo(string.format( "是否花费%s%s购买1次挑战次数并发起挑战",finalNum,itemName), nil, function()
-- --买东西
-- ShopManager.RequestBuyShopItem(SHOP_TYPE.FUNCTION_SHOP,GuildTranscriptManager.shopGoodId,1,function()
-- PopupTipPanel.ShowTip("成功购买1次挑战次数")
-- UIManager.OpenPanel(UIName.FormationPanelV2, FORMATION_TYPE.GUILD_TRANSCRIPT)
-- this.ShowEndNumInfo()
-- end)
-- end)
-- end
-- else
UIManager.OpenPanel(UIName.FormationPanelV2, FORMATION_TYPE.GUILD_TRANSCRIPT)
-- end
end)
Util.AddClick(this.quickWarbtn,function()
-- if GuildTranscriptManager.GetCanBattleCount() <=0 then --今日已无剩余次数!
-- if GuildTranscriptManager.GetCanBuyBattleCount() <= 0 then
-- PopupTipPanel.ShowTip("今日已无剩余次数!")
-- else--是否花费XX妖晶购买1次挑战次数并发起挑战
-- local costId, finalNum, oriCostNum = ShopManager.calculateBuyCost(SHOP_TYPE.FUNCTION_SHOP, GuildTranscriptManager.shopGoodId, 1)
-- local itemName = ConfigManager.GetConfigData(ConfigName.ItemConfig,costId).Name
-- if finalNum > BagManager.GetItemCountById(costId) then
-- PopupTipPanel.ShowTip(string.format("%s数量不足",itemName) )
-- return
-- end
-- MsgPanel.ShowTwo(string.format( "是否花费%s%s购买1次挑战次数并发起扫荡",finalNum,itemName), nil, function()
-- --买东西
-- ShopManager.RequestBuyShopItem(SHOP_TYPE.FUNCTION_SHOP,GuildTranscriptManager.shopGoodId,1,function()
-- PopupTipPanel.ShowTip("成功购买1次扫荡次数")
-- this.QuickWar()
-- this.ShowEndNumInfo()
-- end)
-- end)
-- end
-- else
-- MsgPanel.ShowTwo(string.format( "确定以上次挑战的%s伤害进行挑战吗",GuildTranscriptManager.damage), nil, function()
this.QuickWar()
-- end)
-- end
end)
Util.AddClick(this.endNumBtn,function()
local costId, finalNum, oriCostNum = ShopManager.calculateBuyCost(SHOP_TYPE.FUNCTION_SHOP, GuildTranscriptManager.shopGoodId, 1)
local itemName = ConfigManager.GetConfigData(ConfigName.ItemConfig,costId).Name
if finalNum > BagManager.GetItemCountById(costId) then
PopupTipPanel.ShowTip(string.format("%s数量不足",itemName) )
return
end
MsgPanel.ShowTwo(string.format( "是否花费%s%s购买1次挑战次数",finalNum,itemName), nil, function()
--买东西
ShopManager.RequestBuyShopItem(SHOP_TYPE.FUNCTION_SHOP,GuildTranscriptManager.shopGoodId,1,function()
PopupTipPanel.ShowTip("成功购买1次扫荡次数")
PrivilegeManager.RefreshPrivilegeUsedTimes(PRIVILEGE_TYPE.GUILDTRANSCRIPT_BUY_BATTLENUM, 1)--更新特权
this.ShowEndNumInfo()
end)
end)
end)
-- GuildTranscriptRewardSortPanel
Util.AddClick(this.rankBun,function()
UIManager.OpenPanel(UIName.GuildTranscriptRewardSortPanel,cutOpenIndex)
end)
Util.AddClick(this.sendBtn,function()
local pos = MyGuildManager.GetMyPositionInGuild()
LogGreen("pos "..pos)
if pos == GUILD_GRANT.MEMBER then
PopupTipPanel.ShowTip("只有会长和副会长才可使用此功能!")
return
end
if cutOpenIndex ~= GuildTranscriptManager.GetCurBoss() then
PopupTipPanel.ShowTip("该首领已被击败!")
return
end
NetManager.GuildChallengeMessageResponse(function (msg)
if msg.nextTime <= 0 then
ChatManager.RequestSendGuildTranscript(function()
-- PopupTipPanel.ShowTip("")
end)
else
local timeStar = os.date("%Y时%m分%d", msg.nextTime)
PopupTipPanel.ShowTip(string.format("%s后才可再次使用此功能",timeStar) "XX分XX秒后才可再次使用此功能")
end
end)
end)
Util.AddClick(this.attackInfoBtn,function()
local curguildCheckpointConfig = guildCheckpointConfig[GuildTranscriptManager.GetCurBoss()]
local nextBuyIndex = curBuyIndex + 1
if curguildCheckpointConfig.AttributePromotePrice[2][nextBuyIndex] then
local addNum = ConfigManager.GetConfigData(ConfigName.FoodsConfig,curguildCheckpointConfig.AttributePromote[nextBuyIndex]).EffectPara
MsgPanel.ShowTwo(string.format("是否消耗%s%s购买一次强攻效果购买后攻击力加成提升至%s",curguildCheckpointConfig.AttributePromotePrice[2][nextBuyIndex]
,ConfigManager.GetConfigData(ConfigName.ItemConfig,curguildCheckpointConfig.AttributePromotePrice[1][1]).Name,math.floor(addNum[1][2]/100) ).."%", nil, function()
--买东西
NetManager.GuildChallengeBuyBuffRequest()
end)
else
PopupTipPanel.ShowTip("强攻效果已到达最高")
end
end)
end
function GuildTranscriptMainPopup:AddListener()
Game.GlobalEvent:AddEvent(GameEvent.Guild.RefreshGuildTranscript, this.ShowPanelData)
Game.GlobalEvent:AddEvent(GameEvent.Guild.RefreshGuildTranscriptBuff, this.ShowBuffData)
Game.GlobalEvent:AddEvent(GameEvent.Guild.RefreshGuildTranscripQuickBtn, this.ShowQuickBtnData)
end
--移除事件监听(用于子类重写)
function GuildTranscriptMainPopup:RemoveListener()
Game.GlobalEvent:RemoveEvent(GameEvent.Guild.RefreshGuildTranscript, this.ShowPanelData)
Game.GlobalEvent:RemoveEvent(GameEvent.Guild.RefreshGuildTranscriptBuff, this.ShowBuffData)
Game.GlobalEvent:RemoveEvent(GameEvent.Guild.RefreshGuildTranscripQuickBtn, this.ShowQuickBtnData)
end
--界面打开时调用(用于子类重写)
function GuildTranscriptMainPopup:OnOpen(_curIndex)
GuildTranscriptManager.GetGuildChallengeInfoRequest()
end
--界面打开或者重新打开后,界面刷新时调用(用于子类重写)
function GuildTranscriptMainPopup:OnShow()
this.ShowBossInfo()
this.ShowEndNumInfo()
end
function this.ShowPanelData()
cutOpenIndex = GuildTranscriptManager.GetCurBoss()
this.ShowTitleChapterInfo()
this.ShowPanelInfo(cutOpenIndex)
end
function GuildTranscriptMainPopup:OnSortingOrderChange()
for i, v in pairs(itemList) do
for j = 1, #v do
v[j]:SetEffectLayer(self.sortingOrder)
end
end
sorting = self.sortingOrder
end
function this.ShowTitleChapterInfo()
local allConFigData = GuildTranscriptManager.GetAllConFigData()
this.titleScrollView:SetData(allConFigData, function (index, go)
this.SingleChapterDataShow(go, allConFigData[index])
end)
this.titleScrollView:SetIndex(cutOpenIndex)
end
function this.SingleChapterDataShow(go,data)
Util.GetGameObject(go,"title/Text"):GetComponent("Text").text = data.Remarks
local lock = Util.GetGameObject(go,"lock")
local mask = Util.GetGameObject(go,"mask")
local monsterData = this.GetMonsterConfigDataById(data.MonsterId)
if not monsterData then return end
Util.GetGameObject(go,"icon"):GetComponent("Image").sprite = Util.LoadSprite(GetResourcePath(heroConfig[monsterData.MonsterId].Icon))
if cutOpenIndex > data.Id then--已打过
Util.SetGray(go, true)
lock:SetActive(false)
mask:SetActive(false)
elseif cutOpenIndex == data.Id then--已开启
Util.SetGray(go, false)
lock:SetActive(false)
mask:SetActive(false)
else--未开启
Util.SetGray(go, false)
lock:SetActive(true)
mask:SetActive(true)
end
Util.AddOnceClick(Util.GetGameObject(go,"click"),function()
if data.Id > GuildTranscriptManager.GetCurBoss() then
return PopupTipPanel.ShowTip("击败前一个首领方可解锁!")
end
this.ShowPanelInfo(data.Id)
end)
end
function this.ShowPanelInfo(chapterId)
this.ShowQuickBtnData()
this.ShowEndNumInfo()
cutOpenIndex = chapterId
cutOpenIndexConFig = guildCheckpointConfig[cutOpenIndex]
cutOpenIndexMonsterConFig =this.GetMonsterConfigDataById(guildCheckpointConfig[cutOpenIndex].MonsterId)
this.ShowBossInfo()
this.ShowRewardInfo()
end
function this.ShowQuickBtnData()
local canSweep = GuildTranscriptManager.GetCanSweep() == 1 and true or false
local isEqualityChapter = cutOpenIndex == GuildTranscriptManager.GetCurBoss() and true or false
LogGreen("canSweep "..tostring(canSweep).." isEqualityChapter "..tostring(isEqualityChapter))
this.quickWarbtn:GetComponent("Button").enabled = canSweep and isEqualityChapter
this.warbtn:GetComponent("Button").enabled = isEqualityChapter
Util.SetGray(this.quickWarbtn,not (canSweep and isEqualityChapter))
Util.SetGray(this.warbtn,not isEqualityChapter)
end
--显示boss立绘信息
function this.ShowBossInfo()
if not cutOpenIndexMonsterConFig then return end
local curheroConfig = heroConfig[cutOpenIndexMonsterConFig.MonsterId]
this.bossHerobg.sprite = Util.LoadSprite(GetHeroCardStarBg[curheroConfig.Star])
this.bossHerohpPass.fillAmount = GuildTranscriptManager.GetBlood()/10000
this.bossHerohpPassText.text = GuildTranscriptManager.GetBlood()/100 .."%"
local liveName = GetResourcePath(curheroConfig.Live)
local roleConfig = ConfigManager.GetConfigData(ConfigName.RoleConfig, curheroConfig.Id)
local scale = roleConfig.play_liveScale
local livePos = Vector3.New(roleConfig.offset[1], roleConfig.offset[2], 0)
this.bossHerolive.texture = CardRendererManager.GetSpineTexture(1, liveName, Vector3.one * scale, livePos, true)
this.bossHerolive.transform.localScale = Vector3.one
this.bossHerolive.transform.localPosition = Vector3.zero * 0.6
end
function this.ShowRewardInfo()
-- guildCheckpointConfig[cutOpenIndex]
if not itemList[this.reward1.name] then
itemList[this.reward1.name] = {}
end
if not itemList[this.reward2.name] then
itemList[this.reward2.name] = {}
end
for i = 1, #itemList[this.reward1.name] do
itemList[this.reward1.name][i].gameObject:SetActive(false)
end
for i = 1, #itemList[this.reward1.name] do
itemList[this.reward1.name][i].gameObject:SetActive(false)
end
local reward1Data = ConfigManager.GetConfigData(ConfigName.RewardGroup,cutOpenIndexConFig.Reward).ShowItem
local reward2Data = ConfigManager.GetConfigData(ConfigName.RewardGroup,cutOpenIndexConFig.KillReward).ShowItem
--96
reward2Data[2] = {96,cutOpenIndexConFig.LegionExp}
for i = 1, #reward1Data do
if itemList[this.reward1.name][i] then
itemList[this.reward1.name][i]:OnOpen(false, reward1Data[i], 0.6,false,false,false,sorting)
else
itemList[this.reward1.name][i] = SubUIManager.Open(SubUIConfig.ItemView, this.reward1.transform)
itemList[this.reward1.name][i]:OnOpen(false, reward1Data[i], 0.6,false,false,false,sorting)
end
itemList[this.reward1.name][i].gameObject:SetActive(true)
end
LogGreen("#reward2Data "..#reward2Data)
for i = 1, #reward2Data do
if itemList[this.reward2.name][i] then
itemList[this.reward2.name][i]:OnOpen(false, reward2Data[i], 0.6,false,false,false,sorting)
else
itemList[this.reward2.name][i] = SubUIManager.Open(SubUIConfig.ItemView, this.reward2.transform)
itemList[this.reward2.name][i]:OnOpen(false, reward2Data[i], 0.6,false,false,false,sorting)
end
itemList[this.reward2.name][i].gameObject:SetActive(true)
end
end
function this.GetMonsterConfigDataById(MonsterId)
local monsterConFig = nil
local monsterGrip = ConfigManager.GetConfigData(ConfigName.MonsterGroup,MonsterId)
if not monsterGrip then return nil end
local monsterId = 0
for i = 1, #monsterGrip.Contents do
if monsterId <= 0 then
for j = 1, #monsterGrip.Contents[i] do
if monsterGrip.Contents[i][j] > 0 then
monsterId = monsterGrip.Contents[i][j]
break
end
end
end
end
if monsterId <= 0 then return nil end
local monsterData = ConfigManager.GetConfigData(ConfigName.MonsterConfig,monsterId)
return monsterData
end
function this.ShowEndNumInfo()
this.endNumText.text = "剩余购买次数:" .. GuildTranscriptManager.GetCanBattleCount()
this.endNumBuyText.text = "剩余次数:" .. GuildTranscriptManager.GetCanBuyBattleCount()
end
function this.QuickWar()
GuildTranscriptManager.GuildChallengeRequest(1,function()
this.ShowPanelData()
this.ShowEndNumInfo()
end)
end
function this.ShowRanking()
this.Empty:SetActive(true)
end
function this.ShowBuffData()
curBuyIndex = GuildTranscriptManager.GetbuffCount()
local curguildCheckpointConfig = guildCheckpointConfig[GuildTranscriptManager.GetCurBoss()]
local attackBuffNum = 0
if curBuyIndex > 0 then
local addNum = ConfigManager.GetConfigData(ConfigName.FoodsConfig,curguildCheckpointConfig.AttributePromote[curBuyIndex]).EffectPara
attackBuffNum = math.floor(addNum[1][2]/100)
end
local GetbuffTime = GuildTranscriptManager.GetbuffTime() > 0 and GuildTranscriptManager.GetbuffTime() - PlayerManager.serverTime or 0
Util.SetGray(this.attackInfoTextGo,attackBuffNum == 0)
LogGreen("attackBuffNum "..GetbuffTime)
this.attackInfoText.text = string.format("全军团成员攻击力+ %s ",attackBuffNum).."%"
this.RemainTimeDown(this.attackInfoTime, GetbuffTime)
end
this.timer = Timer.New()
--刷新倒计时显示
function this.RemainTimeDown(_timeTextExpert,timeDown)
if timeDown > 0 then
if this.attackInfoTimeGo then
this.attackInfoTimeGo:SetActive(true)
end
if _timeTextExpert then
_timeTextExpert.text = this.TimeStampToDateString(timeDown)
end
if this.timer then
this.timer:Stop()
this.timer = nil
end
this.timer = Timer.New(function()
if _timeTextExpert then
_timeTextExpert.text = this.TimeStampToDateString(timeDown)
end
if timeDown < 0 then
if this.attackInfoTimeGo then
this.attackInfoTimeGo:SetActive(false)
end
this.timer:Stop()
this.timer = nil
end
timeDown = timeDown - 1
end, 1, -1, true)
this.timer:Start()
else
LogGreen("ssssssssss")
if this.attackInfoTimeGo then
LogGreen("ssssssssss2")
this.attackInfoTimeGo:SetActive(false)
end
end
end
function this.TimeStampToDateString(second)
local day = math.floor(second / (24 * 3600))
local minute = math.floor(second / 60) % 60
local sec = math.floor( second % 60)
local hour = math.floor(math.floor(second - day * 24 * 3600 - sec - minute * 60) / 3600)
return string.format("(%s:%s:%s:后失效)", hour, minute, sec)
end
--界面关闭时调用(用于子类重写)
function GuildTranscriptMainPopup:OnClose()
end
--界面销毁时调用(用于子类重写)
function GuildTranscriptMainPopup:OnDestroy()
itemList = {}
if this.timer then
this.timer:Stop()
this.timer = nil
end
end
return GuildTranscriptMainPopup