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

312 lines
15 KiB
Lua
Raw Normal View History

2020-08-18 19:33:31 +08:00
require("Base/BasePanel")
GuildTranscriptMainPopup = Inherit(BasePanel)
local this = GuildTranscriptMainPopup
2020-08-19 17:28:17 +08:00
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
2020-08-18 19:33:31 +08:00
--初始化组件(用于子类重写)
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.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后失效
2020-08-20 20:05:38 +08:00
this.endNumText = Util.GetGameObject(self.gameObject,"middleGo/endNumBtn/endNumBuyText"):GetComponent("Text")--剩余购买次数:3
this.endNumBuyText = Util.GetGameObject(self.gameObject,"middleGo/endNumBtn/endNumText"):GetComponent("Text")--剩余次数:22
2020-08-18 19:33:31 +08:00
--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")
2020-08-19 17:28:17 +08:00
--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")
2020-08-20 20:05:38 +08:00
this.Empty = Util.GetGameObject(self.gameObject, "endGo/Empty")
Util.GetGameObject(self.gameObject, "endGo/Empty/Bg/Text"):GetComponent("Text").text = "还未有人挑战过此首领"
2020-08-19 17:28:17 +08:00
end
2020-08-18 19:33:31 +08:00
--绑定事件(用于子类重写)
function GuildTranscriptMainPopup:BindEvent()
Util.AddClick(this.helpBtn,function()
2020-08-20 20:05:38 +08:00
UIManager.OpenPanel(UIName.HelpPopup,HELP_TYPE.GuildTranscripe,this.helpPos.x,this.helpPos.y)
2020-08-18 19:33:31 +08:00
end)
Util.AddClick(this.backBtn,function()
self:ClosePanel()
end)
2020-08-19 17:28:17 +08:00
Util.AddClick(this.warbtn,function()
2020-08-20 20:05:38 +08:00
-- 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)
-- MsgPanel.ShowTwo(string.format( "是否花费%s%s购买1次挑战次数并发起挑战",finalNum,ConfigManager.GetConfigData(ConfigName.ItemConfig,costId).Name), 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
2020-08-19 17:28:17 +08:00
end)
Util.AddClick(this.quickWarbtn,function()
2020-08-20 20:05:38 +08:00
-- 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)
-- MsgPanel.ShowTwo(string.format( "是否花费%s%s购买1次挑战次数并发起扫荡",finalNum,ConfigManager.GetConfigData(ConfigName.ItemConfig,costId).Name), 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()
MsgPanel.ShowTwo(string.format( "是否花费%s%s购买1次挑战次数",finalNum,ConfigManager.GetConfigData(ConfigName.ItemConfig,costId).Name), nil, function()
--买东西
ShopManager.RequestBuyShopItem(SHOP_TYPE.FUNCTION_SHOP,GuildTranscriptManager.shopGoodId,1,function()
PopupTipPanel.ShowTip("成功购买1次扫荡次数")
this.ShowEndNumInfo()
end)
end)
2020-08-19 17:28:17 +08:00
end)
-- GuildTranscriptRewardSortPanel
Util.AddClick(this.rankBun,function()
2020-08-20 20:05:38 +08:00
-- UIManager.OpenPanel(UIName.GuildTranscriptRewardSortPanel,cutOpenIndex)
end)
Util.AddClick(this.sendBtn,function()
local pos = MyGuildManager.GetMyPositionInGuild()
if pos ~= GUILD_GRANT.MEMBER then
PopupTipPanel.ShowTip("只有会长和副会长才可使用此功能!")
return
end
if cutOpenIndex ~= GuildTranscriptManager.GetCurBoss() then
PopupTipPanel.ShowTip("该首领已被击败!")
return
end
NetManager.GuildSendHelpMessageRequest(function (msg)
if msg.sendMessage then
ChatManager.RequestSendGuildTranscript(function()
-- PopupTipPanel.ShowTip("")
end)
else
PopupTipPanel.ShowTip("XX分XX秒后才可再次使用此功能")
end
end)
2020-08-19 17:28:17 +08:00
end)
2020-08-18 19:33:31 +08:00
end
function GuildTranscriptMainPopup:AddListener()
2020-08-19 17:28:17 +08:00
Game.GlobalEvent:AddEvent(GameEvent.Guild.RefreshGuildTranscript, this.ShowPanelData)
2020-08-18 19:33:31 +08:00
end
--移除事件监听(用于子类重写)
function GuildTranscriptMainPopup:RemoveListener()
2020-08-19 17:28:17 +08:00
Game.GlobalEvent:RemoveEvent(GameEvent.Guild.RefreshGuildTranscript, this.ShowPanelData)
2020-08-18 19:33:31 +08:00
end
--界面打开时调用(用于子类重写)
function GuildTranscriptMainPopup:OnOpen(_curIndex)
2020-08-19 17:28:17 +08:00
GuildTranscriptManager.GetGuildChallengeInfoRequest()
2020-08-18 19:33:31 +08:00
end
--界面打开或者重新打开后,界面刷新时调用(用于子类重写)
function GuildTranscriptMainPopup:OnShow()
2020-08-20 20:05:38 +08:00
this.ShowBossInfo()
this.ShowEndNumInfo()
2020-08-19 17:28:17 +08:00
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)
local canSweep = GuildTranscriptManager.GetCanSweep() == 1 and true or false
local isEqualityChapter = cutOpenIndex == GuildTranscriptManager.GetCurBoss() and true or false
2020-08-20 20:05:38 +08:00
LogGreen("canSweep "..tostring(canSweep).." isEqualityChapter "..tostring(isEqualityChapter))
2020-08-19 17:28:17 +08:00
this.quickWarbtn:GetComponent("Button").enabled = canSweep and isEqualityChapter
this.warbtn:GetComponent("Button").enabled = isEqualityChapter
2020-08-20 20:05:38 +08:00
-- local isShowQuick = false
-- if canSweep and
Util.SetGray(this.quickWarbtn,not (canSweep and isEqualityChapter))
2020-08-19 17:28:17 +08:00
Util.SetGray(this.warbtn,not isEqualityChapter)
2020-08-20 20:05:38 +08:00
this.ShowEndNumInfo()
2020-08-19 17:28:17 +08:00
cutOpenIndex = chapterId
cutOpenIndexConFig = guildCheckpointConfig[cutOpenIndex]
cutOpenIndexMonsterConFig =this.GetMonsterConfigDataById(guildCheckpointConfig[cutOpenIndex].MonsterId)
this.ShowBossInfo()
this.ShowRewardInfo()
2020-08-18 19:33:31 +08:00
end
--显示boss立绘信息
function this.ShowBossInfo()
2020-08-19 17:28:17 +08:00
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)
2020-08-18 19:33:31 +08:00
local scale = roleConfig.play_liveScale
local livePos = Vector3.New(roleConfig.offset[1], roleConfig.offset[2], 0)
2020-08-19 17:28:17 +08:00
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
2020-08-18 19:33:31 +08:00
2020-08-19 17:28:17 +08:00
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
2020-08-20 20:05:38 +08:00
--96
reward2Data[2] = {96,cutOpenIndexConFig.LegionExp}
2020-08-19 17:28:17 +08:00
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
2020-08-20 20:05:38 +08:00
LogGreen("#reward2Data "..#reward2Data)
2020-08-19 17:28:17 +08:00
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
2020-08-18 19:33:31 +08:00
end
2020-08-19 17:28:17 +08:00
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
2020-08-20 20:05:38 +08:00
function this.ShowEndNumInfo()
this.endNumText.text = "剩余购买次数:" .. GuildTranscriptManager.GetCanBattleCount()
this.endNumBuyText.text = "剩余次数:" .. GuildTranscriptManager.GetCanBuyBattleCount()
end
function this.QuickWar()
GuildTranscriptManager.GuildChallengeRequest(1,function()
this.ShowPanelData()
end)
end
function this.ShowRanking()
this.Empty:SetActive(true)
end
2020-08-18 19:33:31 +08:00
--界面关闭时调用(用于子类重写)
function GuildTranscriptMainPopup:OnClose()
end
--界面销毁时调用(用于子类重写)
function GuildTranscriptMainPopup:OnDestroy()
2020-08-19 17:28:17 +08:00
itemList = {}
2020-08-18 19:33:31 +08:00
end
return GuildTranscriptMainPopup