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

239 lines
9.6 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")
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()
this.spLoader = SpriteLoader.New()
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()
UIManager.OpenPanel(UIName.HelpPopup,HELP_TYPE.GuildFete,this.helpPosition.x,this.helpPosition.y)
end)
end
function GuildFetePopup:AddListener()
Game.GlobalEvent:AddEvent(GameEvent.Guild.OnRefreshFeteProcess, this.RefreshCurValue)
Game.GlobalEvent:AddEvent(GameEvent.FiveAMRefresh.ServerNotifyRefresh, this.RefreshPanel)
end
function GuildFetePopup:RemoveListener()
Game.GlobalEvent:RemoveEvent(GameEvent.Guild.OnRefreshFeteProcess, this.RefreshCurValue)
Game.GlobalEvent:RemoveEvent(GameEvent.FiveAMRefresh.ServerNotifyRefresh, this.RefreshPanel)
end
function GuildFetePopup:OnSortingOrderChange()
sortingOrder = self.sortingOrder
this.rewardBox:GetComponent("Canvas").sortingOrder = sortingOrder + 1
end
function GuildFetePopup:OnOpen(...)
end
function GuildFetePopup:OnShow()
CheckRedPointStatus(RedPointType.Guild_Fete)
-- MyGuildManager.MyFeteInfo.score= MyGuildManager.MyGuildInfo.fete--登录时的奖励进度信息 后续数据刷新由MyGuildManager.MyFeteInfo.score操作
curValue=MyGuildManager.MyFeteInfo.score
this.RefreshPanel()
end
function GuildFetePopup:OnClose()
CheckRedPointStatus(RedPointType.Guild_Fete)
end
function GuildFetePopup:OnDestroy()
this.spLoader:Destroy()
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
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")
local getFinish=Util.GetGameObject(this.s_reward[i],"GetFinish")
local redPoint=Util.GetGameObject(this.s_reward[i],"redPoint")
this.s_reward[i].transform:DOAnchorPosX(guildSacrificeRewardConfig[i].Pos,0)
value.text=guildSacrificeRewardConfig[i].Score
--是否已领取
local isBuy=false
for key, v in ipairs(MyGuildManager.MyFeteInfo.takeFeteReward) do
if v==i and MyGuildManager.MyGuildInfo.id==MyGuildManager.MyFeteInfo.lastFeteGuildId then
isBuy=true
end
end
getFinish:SetActive(isBuy)
if curValue>=guildSacrificeRewardConfig[i].Score and isBuy==false then --领取
if MyGuildManager.MyFeteInfo.lastFeteType>0
and MyGuildManager.MyGuildInfo.id==MyGuildManager.MyFeteInfo.lastFeteGuildId then
redPoint:SetActive(true)
end
value.text=Language[10477]
Util.AddOnceClick(this.s_reward[i],function()
if MyGuildManager.MyFeteInfo.lastFeteType==0 then
PopupTipPanel.ShowTip(Language[10849])
return
end
if MyGuildManager.MyGuildInfo.id~=MyGuildManager.MyFeteInfo.lastFeteGuildId then
PopupTipPanel.ShowTip(Language[10850])
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
redPoint:SetActive(false)
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
local panel = UIManager.OpenPanel(UIName.RewardPreviewPopupPanel,{title=Language[10763],reward=guildSacrificeRewardConfig[i].RewardPreview})
panel:SetPosition(Vector2.New(0,300))
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")--已祭祀
title.text=GetLanguageStrById(guildSacrificeConfig[i].Name)
--奖励预览
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
_ItemViewList[o][index]:OnOpen(false,v,0.85,false,false,false,this.selfsortingOrder)
_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]--消耗数量
coinImage.sprite=this.spLoader:LoadSprite(GetResourcePath(itemConfig[_needId].ResourceID))
--已有金币<消耗金币 变红
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)
buyText.text= _isClick and Language[10851] or Language[10852]
--(当前祭祀)
-- buyBtn:SetActive(i~=feteType)
-- coin:SetActive(i~=feteType)
goed:SetActive(i==feteType)
Util.AddOnceClick(buyBtn,function()
if BagManager.GetItemCountById(_needId)<_needNum then
PopupTipPanel.ShowTip(string.format(Language[10298],GetLanguageStrById(itemConfig[_needId].Name)))
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 ()
PopupTipPanel.ShowTip(Language[10853])
this.RefreshPanel()
end)
end)
end)
end
end
return GuildFetePopup