miduo_client/Assets/ManagedResources/~Lua/Modules/Guild/DeathPos/DeathPosRewardPopup.lua

160 lines
5.6 KiB
Lua
Raw Normal View History

2020-05-09 13:31:21 +08:00
----- 公会十绝阵奖励弹窗 -----
require("Base/BasePanel")
local DeathPosRewardPopup = Inherit(BasePanel)
local this = DeathPosRewardPopup
2020-05-15 16:52:35 +08:00
local itemViewList={}
local myData={}
2020-05-09 13:31:21 +08:00
function DeathPosRewardPopup:InitComponent()
this.panel=Util.GetGameObject(this.gameObject,"Panel")
this.backBtn=Util.GetGameObject(this.panel,"BackBtn")
this.scroll=Util.GetGameObject(this.panel,"Scroll")
this.pre=Util.GetGameObject(this.scroll,"Pre")
this.scrollView=SubUIManager.Open(SubUIConfig.ScrollCycleView,this.scroll.transform,
this.pre,nil,Vector2.New(this.scroll.transform.rect.width,this.scroll.transform.rect.height),1,3,Vector2.New(10,5))--生成滚动条,设置属性
--设置滚动条
this.scrollView.gameObject:GetComponent("RectTransform").anchoredPosition= Vector2.New(0,0)
this.scrollView.gameObject:GetComponent("RectTransform").anchorMin = Vector2.New(0.5, 0.5)
this.scrollView.gameObject:GetComponent("RectTransform").anchorMax = Vector2.New(0.5, 0.5)
this.scrollView.gameObject:GetComponent("RectTransform").pivot = Vector2.New(0.5, 0.5)
this.scrollView.moveTween.MomentumAmount = 1
this.scrollView.moveTween.Strength = 2
end
function DeathPosRewardPopup:BindEvent()
Util.AddClick(this.backBtn,function()
PlaySoundWithoutClick(SoundConfig.Sound_UICancel)
self:ClosePanel()
end)
end
function DeathPosRewardPopup:AddListener()
2020-05-11 09:38:52 +08:00
Game.GlobalEvent:AddEvent(GameEvent.Guild.RefreshDeathPosStatus, this.RefreshPanel)
2020-05-15 16:52:35 +08:00
Game.GlobalEvent:AddEvent(GameEvent.Guild.RefreshDeathPosReward, this.SetIndicationData)
2020-05-09 13:31:21 +08:00
end
function DeathPosRewardPopup:RemoveListener()
2020-05-11 09:38:52 +08:00
Game.GlobalEvent:RemoveEvent(GameEvent.Guild.RefreshDeathPosStatus, this.RefreshPanel)
2020-05-15 16:52:35 +08:00
Game.GlobalEvent:RemoveEvent(GameEvent.Guild.RefreshDeathPosReward, this.SetIndicationData)
2020-05-09 13:31:21 +08:00
end
function DeathPosRewardPopup:OnOpen(...)
end
function DeathPosRewardPopup:OnShow()
2020-05-15 16:52:35 +08:00
if DeathPosManager.status==DeathPosStatus.Close then
this:ClosePanel()
return
end
if DeathPosManager.status== DeathPosStatus.Fight then
return
end
NetManager.GetAllDeathPathRewardInfoResponse(function(msg)
local data=msg.info
this.RefreshPanel(data,false)
end)
2020-05-09 13:31:21 +08:00
end
function DeathPosRewardPopup:OnClose()
2020-05-15 16:52:35 +08:00
myData={}
2020-05-09 13:31:21 +08:00
end
function DeathPosRewardPopup:OnDestroy()
this.scrollView=nil
end
2020-05-15 16:52:35 +08:00
--其他玩家点击领取奖励的indication推送
function this.SetIndicationData()
local data=DeathPosManager.doRewardData
this.RefreshPanel(data,true)
end
2020-05-09 13:31:21 +08:00
2020-05-15 16:52:35 +08:00
--刷新面板 isI 是否是Indication推送
function this.RefreshPanel(data,isI)
if isI then --indication推送 只翻牌单一数据
for i = 1, #myData do
if myData[i].position==data.position then
myData[i]=data
end
end
else --上来主动获取数据
for i = 1, #data do
Log("uid "..data[i].username.." itemId "..data[i].itemId.." itemCount "..data[i].itemCount.." position "..data[i].position.." username "..data[i].username)
local isHave = false
for j=1, #data do
if data[j].position>0 and data[j].position==i then
-- if not data[j] then
isHave = true
table.insert(myData,data[j])
-- end
end
end
if not isHave then
table.insert(myData,{uid=0,username = "",position=i})
end
end
2020-05-11 09:38:52 +08:00
end
2020-05-15 16:52:35 +08:00
this.scrollView:SetData(myData,function(index,root)
this.SetScrollPre(root,myData[index],index)
2020-05-09 13:31:21 +08:00
end)
2020-05-15 16:52:35 +08:00
this.scrollView:SetIndex(1)
2020-05-09 13:31:21 +08:00
end
--设置每个预设
2020-05-11 09:38:52 +08:00
function this.SetScrollPre(root,data,index)
2020-05-09 13:31:21 +08:00
local itemRoot=Util.GetGameObject(root,"Root")
2020-05-15 16:52:35 +08:00
local lock=Util.GetGameObject(itemRoot,"Lock")
2020-05-09 13:31:21 +08:00
local name=Util.GetGameObject(root,"Name"):GetComponent("Text")
2020-05-11 09:38:52 +08:00
local btn=Util.GetGameObject(root,"Button")
2020-05-15 16:52:35 +08:00
if data.username~="" then
LogBlue("uid "..data.username.." itemId "..data.itemId.." itemCount "..data.itemCount.." position "..data.position.." username "..data.username)
else
LogBlue("uid "..data.username.." position "..data.position.." username "..data.username)
end
lock:SetActive(data.username=="")
if data.username=="" then
name.text="<color=#8B7B5C>点击领取宝箱</color>"
else
name.text=data.uid==PlayerManager.uid and "<color=#FF8345>"..data.username.."</color>" or "<color=#FFBB62>"..data.username.."</color>"
end
name.text=data.username=="" and "点击领取宝箱" or data.username
btn:GetComponent("Button").interactable=data.username==""
2020-05-11 09:38:52 +08:00
Util.AddOnceClick(btn,function()
2020-05-15 16:52:35 +08:00
if this.IsGeted() then
PopupTipPanel.ShowTip("每个玩家只能领取1个宝箱")
return
end
2020-05-11 09:38:52 +08:00
NetManager.DoRewardDeathPathRequest(index,function(msg)
2020-05-15 16:52:35 +08:00
UIManager.OpenPanel(UIName.RewardItemPopup, msg.drop, 1, function()
2020-05-11 09:38:52 +08:00
-- this.RefreshPanel()
2020-05-15 16:52:35 +08:00
LogRed("msg.drop"..#msg.drop)
2020-05-11 09:38:52 +08:00
end)
end)
end)
2020-05-15 16:52:35 +08:00
if data.username=="" then
return
end
if not itemViewList[root] then
itemViewList[root]=SubUIManager.Open(SubUIConfig.ItemView,itemRoot.transform)
end
itemViewList[root]:OnOpen(false,{data.itemId,data.itemCount},1.1,false,false,false)
if data.username then
name.text=data.username
end
end
--是否领取过奖励
function this.IsGeted()
for i = 1, #myData do
if myData[i].uid==PlayerManager.uid then
return true
end
end
return false
2020-05-09 13:31:21 +08:00
end
return DeathPosRewardPopup