162 lines
5.3 KiB
Lua
162 lines
5.3 KiB
Lua
require("Base/BasePanel")
|
|
EnergyBaseLoot = Inherit(BasePanel)
|
|
local this = EnergyBaseLoot
|
|
local BaseResourceConfig = ConfigManager.GetConfig(ConfigName.BaseResourceConfig)
|
|
local itemList = {}
|
|
local headList = {}
|
|
|
|
function this:InitComponent()
|
|
this.btnBack = Util.GetGameObject(this.gameObject, "bg/btnBack")
|
|
this.btnRefresh = Util.GetGameObject(this.gameObject, "bg/btnRefresh")
|
|
this.refreshTime = Util.GetGameObject(this.gameObject, "bg/btnRefresh/time"):GetComponent("Text")
|
|
this.prefab = Util.GetGameObject(this.gameObject, "bg/pre")
|
|
|
|
this.targetScroll = Util.GetGameObject(this.gameObject, "bg/targetScroll")
|
|
local v2 = this.targetScroll.transform.rect
|
|
this.targetScrollView = SubUIManager.Open(SubUIConfig.ScrollCycleView, this.targetScroll.transform,
|
|
this.prefab, nil, Vector2.New(v2.width, v2.height), 1, 1, Vector2.New(0, 10))
|
|
this.targetScrollView.moveTween.MomentumAmount = 1
|
|
this.targetScrollView.moveTween.Strength = 2
|
|
|
|
this.enemyScroll = Util.GetGameObject(this.gameObject, "bg/enemyScroll")
|
|
local v2 = this.enemyScroll.transform.rect
|
|
this.enemyScrollView = SubUIManager.Open(SubUIConfig.ScrollCycleView, this.enemyScroll.transform,
|
|
this.prefab, nil, Vector2.New(v2.width, v2.height), 1, 1, Vector2.New(0, 10))
|
|
this.enemyScrollView.moveTween.MomentumAmount = 1
|
|
this.enemyScrollView.moveTween.Strength = 2
|
|
end
|
|
|
|
function this:BindEvent()
|
|
Util.AddClick(this.btnBack, function()
|
|
self:ClosePanel()
|
|
end)
|
|
Util.AddClick(this.btnRefresh, function()
|
|
if not EnergyBaseManager.isCanplunderRefresh then
|
|
PopupTipPanel.ShowTip(GetLanguageStrById(50480))
|
|
return
|
|
end
|
|
EnergyBaseManager.BaseSnatchRefresh(function (msg)
|
|
this.SetTargetScroll(msg)
|
|
local time = GetTimeStamp()-EnergyBaseManager.lastPlunderRefreshTime
|
|
this.refreshTime.text = GetLanguageStrById(50481)..TimeToHMS(time)
|
|
this.PlunderRefreshTimer()
|
|
end)
|
|
end)
|
|
end
|
|
|
|
function this:AddListener()
|
|
end
|
|
|
|
function this:RemoveListener()
|
|
end
|
|
|
|
function this:OnOpen()
|
|
end
|
|
|
|
function this:OnShow()
|
|
local time = EnergyBaseManager.plunderRefreshCD+EnergyBaseManager.lastPlunderRefreshTime-GetTimeStamp()
|
|
if time <= 0 then
|
|
this.refreshTime.text = ""
|
|
else
|
|
this.refreshTime.text = GetLanguageStrById(50481)..TimeToHMS(time)
|
|
this.PlunderRefreshTimer()
|
|
end
|
|
|
|
EnergyBaseManager.BasePlunderList(function (msg)
|
|
this.SetTargetScroll(msg)
|
|
end)
|
|
|
|
EnergyBaseManager.GetBaseEnemyList(function (msg)
|
|
this.SetEnemyScroll(msg)
|
|
end)
|
|
end
|
|
|
|
function this:OnSortingOrderChange()
|
|
end
|
|
|
|
function this:OnClose()
|
|
if this.timer then
|
|
this.timer:Stop()
|
|
this.timer = nil
|
|
end
|
|
end
|
|
|
|
function this:OnDestroy()
|
|
itemList = {}
|
|
headList = {}
|
|
if this.timer then
|
|
this.timer:Stop()
|
|
this.timer = nil
|
|
end
|
|
end
|
|
|
|
function this.SetTargetScroll(data)
|
|
this.targetScrollView:SetData(data, function(index, go)
|
|
this.SetScroll(go, data[index])
|
|
end)
|
|
end
|
|
|
|
function this.SetEnemyScroll(data)
|
|
this.enemyScrollView:SetData(data, function(index, go)
|
|
this.SetScroll(go, data[index])
|
|
end)
|
|
end
|
|
|
|
function this.SetScroll(go, data)
|
|
local head = Util.GetGameObject(go, "head")
|
|
local name = Util.GetGameObject(go, "name"):GetComponent("Text")
|
|
local btnGo = Util.GetGameObject(go, "btnGo")
|
|
local content = Util.GetGameObject(go, "Scroll View/Viewport/content")
|
|
local tip = Util.GetGameObject(go, "tip")
|
|
|
|
name.text = data.baseUserInfo.nickName
|
|
tip:SetActive(#data.baseResourceDetails == 0)
|
|
if not headList[go] then
|
|
headList[go] = SubUIManager.Open(SubUIConfig.PlayerHeadView, head.transform)
|
|
end
|
|
headList[go]:SetHead(data.baseUserInfo.head)
|
|
headList[go]:SetLevel(data.baseUserInfo.level)
|
|
headList[go]:SetFrame(data.baseUserInfo.frame)
|
|
headList[go]:SetScale(0.6)
|
|
if not itemList[go] then
|
|
itemList[go] = {}
|
|
end
|
|
for i = 1, #itemList[go] do
|
|
itemList[go][i].gameObject:SetActive(false)
|
|
end
|
|
for i = 1, #data.baseResourceDetails do
|
|
local resourceInfo = data.baseResourceDetails[i]
|
|
local resourceConfig = BaseResourceConfig[resourceInfo.resourceId]
|
|
if not itemList[go][i] then
|
|
itemList[go][i] = SubUIManager.Open(SubUIConfig.ItemView, content.transform)
|
|
end
|
|
itemList[go][i]:OnOpen(false, resourceConfig.Reward, 0.55)
|
|
itemList[go][i]:ShowNum(false)
|
|
itemList[go][i].gameObject:SetActive(true)
|
|
end
|
|
Util.AddOnceClick(btnGo, function ()
|
|
UIManager.OpenPanel(UIName.EnergyBaseMainPanel, 2, {id = data.baseUserInfo.uid, name = data.baseUserInfo.nickName})
|
|
this:ClosePanel()
|
|
end)
|
|
end
|
|
|
|
function this.PlunderRefreshTimer()
|
|
if this.timer then
|
|
this.timer:Stop()
|
|
this.timer = nil
|
|
end
|
|
this.timer = Timer.New(function ()
|
|
local time = EnergyBaseManager.plunderRefreshCD+EnergyBaseManager.lastPlunderRefreshTime-GetTimeStamp()
|
|
this.refreshTime.text = GetLanguageStrById(50481)..TimeToHMS(time)
|
|
if time <= 0 then
|
|
this.refreshTime.text = ""
|
|
if this.timer then
|
|
this.timer:Stop()
|
|
this.timer = nil
|
|
end
|
|
end
|
|
end, 1, -1, true)
|
|
this.timer:Start()
|
|
end
|
|
|
|
return EnergyBaseLoot |