129 lines
4.5 KiB
Lua
129 lines
4.5 KiB
Lua
----- 献祭弹窗 -----
|
|
local this = {}
|
|
--传入父脚本模块
|
|
local parent
|
|
--传入特效层级
|
|
local sortingOrder=0
|
|
--item容器
|
|
local itemList = {}
|
|
--传入选择英雄
|
|
local itemConfig=ConfigManager.GetConfig(ConfigName.ItemConfig)
|
|
local selectChip = {}
|
|
local isSendMassage = true
|
|
local myguildHelpInfo
|
|
local fun = nil
|
|
function this:InitComponent(gameObject)
|
|
this.aidBtn=Util.GetGameObject(gameObject,"aidBtn")
|
|
this.btnSelect=Util.GetGameObject(gameObject,"btnSelect")
|
|
this.SelectImage=Util.GetGameObject(gameObject,"btnSelect/SelectImage")
|
|
for i = 1, 4 do
|
|
itemList[i] = Util.GetGameObject(gameObject, "Root/frame (".. i ..")")
|
|
end
|
|
end
|
|
|
|
function this:BindEvent()
|
|
Util.AddClick(this.btnSelect,function()
|
|
isSendMassage = not isSendMassage
|
|
this.SelectImage:SetActive(isSendMassage)
|
|
end)
|
|
Util.AddClick(this.aidBtn,function()
|
|
local aidChips = {}
|
|
for i, v in pairs(selectChip) do
|
|
local isAdd = true
|
|
if myguildHelpInfo and #myguildHelpInfo > 0 then
|
|
for j = 1, #myguildHelpInfo do
|
|
if myguildHelpInfo[j].type == v then
|
|
isAdd = false
|
|
end
|
|
end
|
|
end
|
|
if isAdd then
|
|
LogError("v "..v)
|
|
table.insert(aidChips,v)
|
|
end
|
|
end
|
|
if aidChips and #aidChips > 0 then
|
|
--请选择需要援助的碎片
|
|
local itemId1 = nil
|
|
local itemId2 = nil
|
|
if not itemId1 and aidChips[1] then
|
|
itemId1 = aidChips[1]
|
|
end
|
|
if not itemId2 and aidChips[2] then
|
|
itemId2 = aidChips[2]
|
|
end
|
|
NetManager.GuildSendHelpRequest(aidChips,isSendMassage,function(msg)
|
|
if msg.sendMessage then
|
|
ChatManager.RequestSendGuildAid(itemId1,itemId2,function()
|
|
PopupTipPanel.ShowTip("求助发送成功!")
|
|
MyGuildManager._GuildAidTimeStamp = GetTimeStamp()
|
|
end)
|
|
else
|
|
--PopupTipPanel.ShowTip("不可发送援助信息!")
|
|
MyGuildManager.ShowGuildAidCdTime()
|
|
end
|
|
if fun then
|
|
fun()
|
|
fun = nil
|
|
end
|
|
end)
|
|
parent:ClosePanel()
|
|
else
|
|
PopupTipPanel.ShowTip("请选择需要援助的碎片!")
|
|
end
|
|
end)
|
|
end
|
|
function this:AddListener()
|
|
end
|
|
|
|
function this:RemoveListener()
|
|
end
|
|
function this:OnShow(...)
|
|
isSendMassage = true
|
|
this.SelectImage:SetActive(isSendMassage)
|
|
local args = {...}
|
|
parent=args[1]
|
|
fun=args[2][2]
|
|
sortingOrder = parent.sortingOrder
|
|
local items = ConfigManager.GetConfigData(ConfigName.GuildHelpConfig,1).RecourseReward
|
|
myguildHelpInfo = MyGuildManager.MyFeteInfo.guildHelpInfo
|
|
for i = 1, #items do
|
|
itemList[i]:GetComponent("Image").sprite = Util.LoadSprite(GetHeroQuantityImageByquality(itemConfig[items[i][2]].Quantity))
|
|
--Util.GetGameObject(itemList[i], "icon"):GetComponent("Image").sprite = Util.LoadSprite(GetResourcePath(itemConfig[items[i][2]].ResourceID))
|
|
Util.GetGameObject(itemList[i], "chipImage"):GetComponent("Image").sprite = Util.LoadSprite(GetHeroChipQuantityImageByquality(itemConfig[items[i][2]].Quantity))
|
|
Util.GetGameObject(itemList[i], "lock"):SetActive(false)
|
|
local choosed = Util.GetGameObject(itemList[i], "selectImage")
|
|
choosed:SetActive(false)
|
|
if myguildHelpInfo and #myguildHelpInfo > 0 then
|
|
for j = 1, #myguildHelpInfo do
|
|
if myguildHelpInfo[j].type == items[i][2] then
|
|
Util.GetGameObject(itemList[i], "lock"):SetActive(true)
|
|
selectChip[items[i][2]] = items[i][2]
|
|
choosed:SetActive(true)
|
|
end
|
|
end
|
|
end
|
|
Util.AddOnceClick(Util.GetGameObject(itemList[i], "Icon"), function()
|
|
if selectChip[items[i][2]] then
|
|
choosed:SetActive(false)
|
|
selectChip[items[i][2]]=nil
|
|
return
|
|
end
|
|
if LengthOfTable(selectChip)>=ConfigManager.GetConfigData(ConfigName.GuildHelpConfig,1).RecourseTime[1] then
|
|
PopupTipPanel.ShowTip("已达最大选择数量")
|
|
return
|
|
end
|
|
selectChip[items[i][2]] = items[i][2]
|
|
choosed:SetActive(true)
|
|
end)
|
|
end
|
|
end
|
|
|
|
function this:OnClose()
|
|
end
|
|
|
|
function this:OnDestroy()
|
|
end
|
|
|
|
return this
|