miduo_client/Assets/ManagedResources/~Lua/Modules/Guild/GuildFetePopup.lua

239 lines
9.6 KiB
Lua
Raw Normal View History

2021-04-21 13:12:04 +08:00
----- 公会祭祀弹窗 -----
2020-05-09 13:31:21 +08:00
require("Base/BasePanel")
local GuildFetePopup = Inherit(BasePanel)
local this = GuildFetePopup
local itemConfig=ConfigManager.GetConfig(ConfigName.ItemConfig)
local guildSacrificeConfig=ConfigManager.GetConfig(ConfigName.GuildSacrificeConfig)
local guildSacrificeRewardConfig=ConfigManager.GetConfig(ConfigName.GuildSacrificeRewardConfig)
local _ItemViewList={}--reward itemview容器
local sortingOrder=0 --层级
local triggerCallBack --回调
local _isClick=false --是否已祭祀
local feteType=0--祭祀类型
local curValue=0
function GuildFetePopup:InitComponent()
2021-04-21 13:12:04 +08:00
this.spLoader = SpriteLoader.New()
2020-05-09 13:31:21 +08:00
this.panel=Util.GetGameObject(this.gameObject,"Panel")
this.backBtn = Util.GetGameObject(this.panel, "BackBtn")
this.helpBtn=Util.GetGameObject(this.panel,"HelpBtn")
this.helpPosition=this.helpBtn:GetComponent("RectTransform").localPosition
this.title=Util.GetGameObject(this.panel,"Title"):GetComponent("Text")
this.tip=Util.GetGameObject(this.panel,"Tip"):GetComponent("Text")
this.sliderRoot=Util.GetGameObject(this.panel,"SliderRoot")
this.slider = Util.GetGameObject(this.sliderRoot, "Slider"):GetComponent("Slider")
this.sliderValueNum=Util.GetGameObject(this.sliderRoot,"Value/Num"):GetComponent("Text")--祭祀进度值
this.rewardBox=Util.GetGameObject(this.sliderRoot,"RewardBox")--奖励盒根节点
this.s_reward={} --进度条奖励组预设
for i = 1, 3 do
this.s_reward[i]=Util.GetGameObject(this.rewardBox,"Item"..i)
end
this.rewardPanel=Util.GetGameObject(this.panel,"RewardPanel")
this.rewardPanelBtn=Util.GetGameObject(this.rewardPanel,"CloseBtn")--奖励面板关闭按钮
this.content=Util.GetGameObject(this.panel,"Content")
this.feteList={}--祭祀项预设
for j = 1, 3 do
this.feteList[j]=Util.GetGameObject(this.content,"Item"..j)
end
end
function GuildFetePopup:BindEvent()
Util.AddClick(this.backBtn, function()
PlaySoundWithoutClick(SoundConfig.Sound_UICancel)
this:ClosePanel()
end)
Util.AddClick(this.helpBtn,function()
2020-05-15 16:52:35 +08:00
UIManager.OpenPanel(UIName.HelpPopup,HELP_TYPE.GuildFete,this.helpPosition.x,this.helpPosition.y)
2020-05-09 13:31:21 +08:00
end)
end
function GuildFetePopup:AddListener()
2020-05-11 09:38:52 +08:00
Game.GlobalEvent:AddEvent(GameEvent.Guild.OnRefreshFeteProcess, this.RefreshCurValue)
2020-05-09 13:31:21 +08:00
Game.GlobalEvent:AddEvent(GameEvent.FiveAMRefresh.ServerNotifyRefresh, this.RefreshPanel)
end
function GuildFetePopup:RemoveListener()
2020-05-11 09:38:52 +08:00
Game.GlobalEvent:RemoveEvent(GameEvent.Guild.OnRefreshFeteProcess, this.RefreshCurValue)
2020-05-09 13:31:21 +08:00
Game.GlobalEvent:RemoveEvent(GameEvent.FiveAMRefresh.ServerNotifyRefresh, this.RefreshPanel)
end
function GuildFetePopup:OnSortingOrderChange()
sortingOrder = self.sortingOrder
2020-05-25 19:16:23 +08:00
this.rewardBox:GetComponent("Canvas").sortingOrder = sortingOrder + 1
2020-05-09 13:31:21 +08:00
end
function GuildFetePopup:OnOpen(...)
end
function GuildFetePopup:OnShow()
2020-05-15 16:52:35 +08:00
CheckRedPointStatus(RedPointType.Guild_Fete)
-- MyGuildManager.MyFeteInfo.score= MyGuildManager.MyGuildInfo.fete--登录时的奖励进度信息 后续数据刷新由MyGuildManager.MyFeteInfo.score操作
curValue=MyGuildManager.MyFeteInfo.score
2020-05-09 13:31:21 +08:00
this.RefreshPanel()
end
function GuildFetePopup:OnClose()
2020-05-15 16:52:35 +08:00
CheckRedPointStatus(RedPointType.Guild_Fete)
2020-05-09 13:31:21 +08:00
end
function GuildFetePopup:OnDestroy()
2021-04-21 13:12:04 +08:00
this.spLoader:Destroy()
2020-05-09 13:31:21 +08:00
this.s_reward={}
this.feteList={}
end
function this.RefreshCurValue()
curValue=MyGuildManager.MyFeteInfo.score
this.RefreshSlider()
end
--刷新面板
function this.RefreshPanel()
feteType=MyGuildManager.MyFeteInfo.lastFeteType
_isClick=feteType~=0 --不为0为已祭祀了
this.RefreshSlider()
this.RefreshContent()
end
--刷新进度条
function this.RefreshSlider()
local maxValue=guildSacrificeRewardConfig[3].Score --最大进度
this.slider.value = curValue/maxValue
2020-05-09 13:31:21 +08:00
this.sliderValueNum.text=curValue
this.rewardBox:GetComponent("Canvas").sortingOrder = sortingOrder + 1
for i = 1, #this.s_reward do
local value=Util.GetGameObject(this.s_reward[i],"Value"):GetComponent("Text")
2020-05-11 09:38:52 +08:00
local getFinish=Util.GetGameObject(this.s_reward[i],"GetFinish")
2020-05-15 16:52:35 +08:00
local redPoint=Util.GetGameObject(this.s_reward[i],"redPoint")
2020-05-09 13:31:21 +08:00
2020-05-11 09:38:52 +08:00
this.s_reward[i].transform:DOAnchorPosX(guildSacrificeRewardConfig[i].Pos,0)
value.text=guildSacrificeRewardConfig[i].Score
2020-05-09 13:31:21 +08:00
--是否已领取
local isBuy=false
2020-05-15 16:52:35 +08:00
for key, v in ipairs(MyGuildManager.MyFeteInfo.takeFeteReward) do
2020-05-09 13:31:21 +08:00
if v==i and MyGuildManager.MyGuildInfo.id==MyGuildManager.MyFeteInfo.lastFeteGuildId then
isBuy=true
end
end
2020-05-11 09:38:52 +08:00
getFinish:SetActive(isBuy)
2020-05-09 13:31:21 +08:00
if curValue>=guildSacrificeRewardConfig[i].Score and isBuy==false then --领取
if MyGuildManager.MyFeteInfo.lastFeteType>0
and MyGuildManager.MyGuildInfo.id==MyGuildManager.MyFeteInfo.lastFeteGuildId then
2020-05-15 16:52:35 +08:00
redPoint:SetActive(true)
end
2021-03-02 16:53:12 +08:00
value.text=Language[10477]
2020-05-09 13:31:21 +08:00
Util.AddOnceClick(this.s_reward[i],function()
if MyGuildManager.MyFeteInfo.lastFeteType==0 then
2021-03-02 16:53:12 +08:00
PopupTipPanel.ShowTip(Language[10849])
2020-05-09 13:31:21 +08:00
return
end
if MyGuildManager.MyGuildInfo.id~=MyGuildManager.MyFeteInfo.lastFeteGuildId then
2021-03-02 16:53:12 +08:00
PopupTipPanel.ShowTip(Language[10850])
2020-05-09 13:31:21 +08:00
return
end
NetManager.FamilyGetFeteRewardRequest(i,function(msg)
table.insert(MyGuildManager.MyFeteInfo.takeFeteReward,i)
UIManager.OpenPanel(UIName.RewardItemPopup, msg.drop, 1, function ()
this.RefreshPanel()
end)
end)
end)
else
2020-05-15 16:52:35 +08:00
redPoint:SetActive(false)
2020-05-09 13:31:21 +08:00
Util.AddOnceClick(this.s_reward[i],function()--打开奖励弹窗
this.SetRewardPanel(i)
end)
end
end
end
--设置奖励面板
function this.SetRewardPanel(i)
if Game.GlobalEvent:HasEvent(GameEvent.UI.OnClose, triggerCallBack) then
Game.GlobalEvent:RemoveEvent(GameEvent.UI.OnClose, triggerCallBack)
end
2021-03-02 16:53:12 +08:00
local panel = UIManager.OpenPanel(UIName.RewardPreviewPopupPanel,{title=Language[10763],reward=guildSacrificeRewardConfig[i].RewardPreview})
2024-01-17 11:14:38 +08:00
panel:SetPosition(Vector2.New(0,300))
2020-05-09 13:31:21 +08:00
this.rewardBox:GetComponent("Canvas").sortingOrder = panel.sortingOrder + 1
triggerCallBack = function (panelType, p)
if panelType == UIName.RewardPreviewPopupPanel and panel == p then --监听到SkillInfoPopup关闭把层级设回去
this.rewardBox:GetComponent("Canvas").sortingOrder =sortingOrder + 1
Game.GlobalEvent:RemoveEvent(GameEvent.UI.OnClose, triggerCallBack)
end
end
Game.GlobalEvent:AddEvent(GameEvent.UI.OnClose, triggerCallBack)
end
--刷新祭祀内容
function this.RefreshContent()
for i = 1, #this.feteList do
local o=this.feteList[i]
local title=Util.GetGameObject(o,"Title"):GetComponent("Text")
local reward=Util.GetGameObject(o,"Reward")
local coin=Util.GetGameObject(o,"Coin")
local coinImage=Util.GetGameObject(o,"Coin/Image"):GetComponent("Image")
local coinNum=Util.GetGameObject(o,"Coin/Num"):GetComponent("Text")
local buyBtn=Util.GetGameObject(o,"BuyBtn")
local buyText=Util.GetGameObject(o,"BuyBtn/Text"):GetComponent("Text")
local goed=Util.GetGameObject(o,"Goed")--已祭祀
2021-01-26 17:08:39 +08:00
title.text=GetLanguageStrById(guildSacrificeConfig[i].Name)
2020-05-09 13:31:21 +08:00
--奖励预览
for index, v in pairs(guildSacrificeConfig[i].Reward) do
if not _ItemViewList[o] then
_ItemViewList[o] = {}
end
if not _ItemViewList[o][index] then
_ItemViewList[o][index] = SubUIManager.Open(SubUIConfig.ItemView, reward.transform)
end
2020-05-11 09:38:52 +08:00
_ItemViewList[o][index]:OnOpen(false,v,0.85,false,false,false,this.selfsortingOrder)
2020-05-09 13:31:21 +08:00
_ItemViewList[o][index].gameObject:GetComponent("RectTransform").pivot = Vector2.New(0.5, 0.5)
end
local _needId=guildSacrificeConfig[i].Expend[1][1]--消耗物品Id
local _needNum=guildSacrificeConfig[i].Expend[1][2]--消耗数量
2021-04-21 13:12:04 +08:00
coinImage.sprite=this.spLoader:LoadSprite(GetResourcePath(itemConfig[_needId].ResourceID))
2020-05-09 13:31:21 +08:00
--已有金币<消耗金币 变红
if BagManager.GetItemCountById(_needId)<_needNum then
coinNum.text="<color=red>".._needNum.."</color>"
else
coinNum.text=_needNum
end
--已祭祀表现(其它祭祀)
buyBtn:GetComponent("Button").interactable=not _isClick
Util.SetGray(buyBtn,_isClick)
2021-03-02 16:53:12 +08:00
buyText.text= _isClick and Language[10851] or Language[10852]
2020-05-09 13:31:21 +08:00
--(当前祭祀)
2020-05-11 09:38:52 +08:00
-- buyBtn:SetActive(i~=feteType)
-- coin:SetActive(i~=feteType)
2020-05-09 13:31:21 +08:00
goed:SetActive(i==feteType)
Util.AddOnceClick(buyBtn,function()
if BagManager.GetItemCountById(_needId)<_needNum then
2021-03-02 16:53:12 +08:00
PopupTipPanel.ShowTip(string.format(Language[10298],GetLanguageStrById(itemConfig[_needId].Name)))
2020-05-09 13:31:21 +08:00
return
end
NetManager.FamilyFeteRequest(i,function(msg)
MyGuildManager.MyFeteInfo.lastFeteType=i
MyGuildManager.MyFeteInfo.lastFeteGuildId=MyGuildManager.MyGuildInfo.id
UIManager.OpenPanel(UIName.RewardItemPopup, msg.drop, 1, function ()
2021-03-02 16:53:12 +08:00
PopupTipPanel.ShowTip(Language[10853])
2020-05-09 13:31:21 +08:00
this.RefreshPanel()
end)
end)
end)
end
end
2020-06-23 18:36:24 +08:00
return GuildFetePopup