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

182 lines
6.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 DeathPosRewardPopup = Inherit(BasePanel)
local this = DeathPosRewardPopup
2024-09-06 10:38:56 +08:00
local itemViewList = {}
local tempData = {}
2020-06-03 19:09:01 +08:00
2020-05-09 13:31:21 +08:00
function DeathPosRewardPopup:InitComponent()
2021-04-21 13:12:04 +08:00
this.spLoader = SpriteLoader.New()
2024-09-06 10:38:56 +08:00
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)) --生成滚动条,设置属性
2020-05-09 13:31:21 +08:00
--设置滚动条
2024-09-06 10:38:56 +08:00
this.scrollView.gameObject:GetComponent("RectTransform").anchoredPosition = Vector2.New(0, 0)
2020-05-09 13:31:21 +08:00
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
2020-05-25 19:16:23 +08:00
2024-09-06 10:38:56 +08:00
this.empty = Util.GetGameObject(this.panel, "Empty")
this.timeTip = Util.GetGameObject(this.panel, "TimeTip"):GetComponent("Text")
2020-05-09 13:31:21 +08:00
end
function DeathPosRewardPopup:BindEvent()
2024-09-06 10:38:56 +08:00
Util.AddClick(this.backBtn, function()
2020-05-09 13:31:21 +08:00
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
2024-09-06 10:38:56 +08:00
2020-05-09 13:31:21 +08:00
function DeathPosRewardPopup:OnOpen(...)
this.SetIndicationData()
2020-05-09 13:31:21 +08:00
end
function DeathPosRewardPopup:OnShow()
2024-09-06 10:38:56 +08:00
if DeathPosManager.status == DeathPosStatus.Close then
2020-05-15 16:52:35 +08:00
this:ClosePanel()
return
end
2024-09-06 10:38:56 +08:00
if DeathPosManager.status == DeathPosStatus.Fight then
2020-05-15 16:52:35 +08:00
return
end
2020-05-25 19:16:23 +08:00
this.empty:SetActive(false)
2024-09-06 10:38:56 +08:00
this.timeTip.gameObject:SetActive(DeathPosManager.status == DeathPosStatus.Reward)
2020-05-15 16:52:35 +08:00
NetManager.GetAllDeathPathRewardInfoResponse(function(msg)
2020-06-03 19:09:01 +08:00
DeathPosManager.SetRewardData(msg.info)
2024-09-06 10:38:56 +08:00
this.RefreshPanel(DeathPosManager.GetRewardData(), false)
2020-05-15 16:52:35 +08:00
end)
2020-05-09 13:31:21 +08:00
end
function DeathPosRewardPopup:OnClose()
2024-09-06 10:38:56 +08:00
tempData = {}
2020-06-03 19:09:01 +08:00
CheckRedPointStatus(RedPointType.Guild_DeathPos)
2020-05-09 13:31:21 +08:00
end
function DeathPosRewardPopup:OnDestroy()
2021-04-21 13:12:04 +08:00
this.spLoader:Destroy()
2024-09-06 10:38:56 +08:00
this.scrollView = nil
2020-05-09 13:31:21 +08:00
end
2020-05-15 16:52:35 +08:00
--其他玩家点击领取奖励的indication推送
function this.SetIndicationData()
2024-09-06 10:38:56 +08:00
local data = DeathPosManager.GetDoRewardData()
this.RefreshPanel(data, true)
2020-05-15 16:52:35 +08:00
end
2020-05-09 13:31:21 +08:00
2020-05-15 16:52:35 +08:00
--刷新面板 isI 是否是Indication推送
2024-09-06 10:38:56 +08:00
function this.RefreshPanel(data, isI)
LogRed("刷新面板")
2024-09-06 10:38:56 +08:00
this.timeTip.text = DeathPosManager.rewardTimeTip
2020-05-15 16:52:35 +08:00
if isI then --indication推送 只翻牌单一数据
2020-06-03 19:09:01 +08:00
for i = 1, #tempData do
2024-09-06 10:38:56 +08:00
if tempData[i].position == data.position then
tempData[i] = data
2020-05-15 16:52:35 +08:00
end
end
else --上来主动获取数据
for i = 1, #data do
2024-09-06 10:38:56 +08:00
Log("uid " ..
data[i].uid ..
" itemId " ..
data[i].itemId ..
" itemCount " .. data[i].itemCount .. " position " .. data[i].position ..
" username " .. data[i].username)
2020-05-15 16:52:35 +08:00
local isHave = false
2024-09-06 10:38:56 +08:00
for j = 1, #data do
if data[j].position > 0 and data[j].position == i then
2020-05-15 16:52:35 +08:00
-- if not data[j] then
2024-09-06 10:38:56 +08:00
isHave = true
table.insert(tempData, data[j])
2020-05-15 16:52:35 +08:00
-- end
end
end
if not isHave then
2024-09-06 10:38:56 +08:00
table.insert(tempData, { uid = 0, username = "", position = i })
2020-05-15 16:52:35 +08:00
end
end
2020-05-11 09:38:52 +08:00
end
2020-06-03 19:09:01 +08:00
DeathPosManager.SetMyRewardData(tempData)
2024-09-06 10:38:56 +08:00
this.scrollView:SetData(tempData, function(index, root)
this.SetScrollPre(root, tempData[index], index)
2020-05-09 13:31:21 +08:00
end)
2020-05-15 16:52:35 +08:00
this.scrollView:SetIndex(1)
2020-06-28 17:48:49 +08:00
this.empty:SetActive(#tempData <= 0)
2020-05-09 13:31:21 +08:00
end
--设置每个预设
2024-09-06 10:38:56 +08:00
function this.SetScrollPre(root, data, index)
local itemRoot = Util.GetGameObject(root, "Root")
local lock = Util.GetGameObject(itemRoot, "Lock")
local name = Util.GetGameObject(root, "Name"):GetComponent("Text")
local btn = Util.GetGameObject(root, "Bg")
if data.username ~= "" then
LogBlue("uid " ..
data.uid ..
" itemId " ..
data.itemId .. " itemCount " .. data.itemCount .. " position " ..
data.position .. " username " .. data.username)
2020-05-15 16:52:35 +08:00
else
2024-09-06 10:38:56 +08:00
LogBlue("uid " .. data.uid .. " position " .. data.position .. " username " .. data.username)
2020-05-15 16:52:35 +08:00
end
2024-09-06 10:38:56 +08:00
lock:SetActive(data.username == "")
if data.username == "" then
name.text = Language[11461]
2020-05-15 16:52:35 +08:00
else
2024-09-06 10:38:56 +08:00
name.text = data.uid == PlayerManager.uid and "<color=#FF8345>" .. data.username .. "</color>" or
"<color=#FFBB62>" .. data.username .. "</color>"
2020-05-15 16:52:35 +08:00
end
2024-09-06 10:38:56 +08:00
name.text = data.username == "" and Language[11462] or data.username
btn:GetComponent("Button").interactable = data.username == ""
2020-05-25 19:16:23 +08:00
2024-09-06 10:38:56 +08:00
Util.AddOnceClick(btn, function()
2020-06-03 19:09:01 +08:00
if DeathPosManager.GetIsGeted(tempData) then
2024-08-29 21:36:51 +08:00
PopupTipPanel.ShowTip(Language[11463])
2020-05-15 16:52:35 +08:00
return
end
2024-09-06 10:38:56 +08:00
if DeathPosManager.GetIsTakeIn() == false then
2024-08-29 21:36:51 +08:00
PopupTipPanel.ShowTip(Language[11464])
2020-06-03 19:09:01 +08:00
return
2020-05-25 19:16:23 +08:00
end
2024-09-06 10:38:56 +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()
2024-09-06 10:38:56 +08:00
LogRed("msg.drop" .. #msg.drop)
2020-05-11 09:38:52 +08:00
end)
end)
end)
2024-09-06 10:38:56 +08:00
if data.username == "" then
if itemViewList[root] then
itemViewList[root].gameObject:SetActive(false)
end
2020-05-15 16:52:35 +08:00
return
end
if not itemViewList[root] then
2024-09-06 10:38:56 +08:00
itemViewList[root] = SubUIManager.Open(SubUIConfig.ItemView, itemRoot.transform)
2020-05-15 16:52:35 +08:00
end
2024-09-06 10:38:56 +08:00
itemViewList[root]:OnOpen(false, { data.itemId, data.itemCount }, 1.1, false, false, false)
itemViewList[root].gameObject:SetActive(true)
2020-05-15 16:52:35 +08:00
if data.username then
2024-09-06 10:38:56 +08:00
name.text = data.username
2020-05-15 16:52:35 +08:00
end
end
2024-09-06 10:38:56 +08:00
return DeathPosRewardPopup