miduo_client/Assets/ManagedResources/~Lua/Modules/GeneralPanel/View/GeneralBigPopup_WishTailsma...

184 lines
8.1 KiB
Lua

----- 神应属性弹窗 -----
local this = {}
local PropertyConfig = ConfigManager.GetConfig(ConfigName.PropertyConfig)
--传入父脚本模块
local parent
local sortingOrder = 0
local itemList = {}
function this:InitComponent(gameObject)
self.grid = Util.GetGameObject(gameObject, "grid")
self.itemPre = Util.GetGameObject(gameObject, "itemPre")
self.sureBtn = Util.GetGameObject(gameObject, "sureBtn")
self.cancelBtn = Util.GetGameObject(gameObject, "cancelBtn")
end
function this:BindEvent()
Util.AddOnceClick(self.sureBtn, function()
if LengthOfTable(self.selectData) < 4 then
PopupTipPanel.ShowTip(Language[11087])
return
end
NetManager.SendRefreshTailsmanSoulData(self.selectData, function()
parent:ClosePanel()
end)
end)
Util.AddOnceClick(self.cancelBtn, function()
parent:ClosePanel()
end)
end
function this:AddListener()
end
function this:RemoveListener()
end
function this:OnShow(_parent)
RecruitManager.GetIsUpTailsManSoulChip()
parent = _parent
sortingOrder = _parent.sortingOrder
self.selectData = RecruitManager.GetWishTailsManSoulChips()
local data1 = TailsManSoulManager.GetTailsmanSoulDatas1(6)
local data2 = TailsManSoulManager.GetTailsmanSoulDatas1(7)
self.curData = {}
for index, value in ipairs(data1) do
table.insert(self.curData, value)
end
for index, value in ipairs(data2) do
table.insert(self.curData, value)
end
this:RefreshData()
end
function this:RefreshData()
for i = 1, math.max(#itemList, #self.curData) do
if not self.curData[i] then
itemList[i].go.gameObject:SetActive(false)
else
if not itemList[i] then
itemList[i] = {}
itemList[i].go = newObjToParent(self.itemPre, self.grid)
itemList[i].title = Util.GetGameObject(itemList[i].go, "titleDi/Text"):GetComponent("Text")
itemList[i].lookBtn = Util.GetGameObject(itemList[i].go, "lookBtn")
itemList[i].selectBtn = Util.GetGameObject(itemList[i].go, "selectBtn")
itemList[i].itemGrid = Util.GetGameObject(itemList[i].go, "itemGrid")
itemList[i].items = {}
for j = 1, 4 do
itemList[i].items[j] = {}
itemList[i].items[j].go = Util.GetGameObject(itemList[i].go, "ItemPos" .. j)
itemList[i].items[j].pos = Util.GetGameObject(itemList[i].items[j].go.transform, "pos")
itemList[i].items[j].item = SubUIManager.Open(SubUIConfig.ItemView,
itemList[i].items[j].pos.transform)
itemList[i].items[j].item.frame:GetComponent("Button").enabled = false
itemList[i].items[j].item.transform:GetComponent("RectTransform").anchoredPosition3D = Vector3.zero
itemList[i].items[j].lv = Util.GetGameObject(itemList[i].items[j].go, "lvDi/Text"):GetComponent(
"Text")
itemList[i].items[j].select = Util.GetGameObject(itemList[i].items[j].go, "select")
itemList[i].items[j].go.gameObject:SetActive(false)
end
end
itemList[i].go.gameObject:SetActive(true)
itemList[i].title.text = GetLanguageStrById(self.curData[i].name)
Util.AddOnceClick(itemList[i].lookBtn, function()
UIManager.OpenPanel(UIName.TailsmanSoulMainPanel, self.curData[i].id)
end)
Util.AddOnceClick(itemList[i].selectBtn, function()
MsgPanel.ShowTwo(string.format(Language[11088], self.curData[i].name), function() end, function()
self.selectData = {}
for j = 1, #self.curData[i].trumpChipList do
if self.curData[i].trumpList[j].config.CanUp and self.curData[i].trumpList[j].config.CanUp == 1 then
table.insert(self.selectData, self.curData[i].trumpChipList[j])
end
end
this:RefreshData()
end, Language[10685], Language[11089], Language[11030], false, "")
end)
local isShow = false
--除了要判断是否up 以外还要判断是否在奖池里面
for j = 1, math.max(#itemList[i].items, #self.curData[i].trumpChipList) do
if not self.curData[i].trumpChipList[j] or not self.curData[i].trumpList[j].config.CanUp or self.curData[i].trumpList[j].config.CanUp == 0 then
itemList[i].items[j].go.gameObject:SetActive(false)
elseif not RecruitManager.CheckIsUpTailsManSoulChip(self.curData[i].trumpChipList[j]) then
itemList[i].items[j].go.gameObject:SetActive(false)
else
isShow = true
if not itemList[i].items[j] then
itemList[i].items[j] = {}
itemList[i].items[j].go = newObjToParent(itemList[i].items[1].go, itemList[i].itemGrid)
itemList[i].items[j].pos = Util.GetGameObject(itemList[i].items[j].go, "pos")
itemList[i].items[j].item = SubUIManager.Open(SubUIConfig.ItemView,
itemList[i].items[j].pos.transform)
itemList[i].items[j].item.frame:GetComponent("Button").enabled = false
itemList[i].items[j].item.transform.localPosition = Vector3.zero
itemList[i].items[j].lv = Util.GetGameObject(itemList[i].items[j].go, "lvDi/Text"):GetComponent(
"Text")
itemList[i].items[j].select = Util.GetGameObject(itemList[i].items[j].go, "select")
end
itemList[i].items[j].go.gameObject:SetActive(true)
itemList[i].items[j].item:OnOpen(false, { self.curData[i].trumpChipList[j], 0 }, 1, true, false,
false, sortingOrder + 1)
local color = "FFFFFF"
if self.curData[i].trumpList[j].lv == self.curData[i].trumpList[j].config.LvMax then
color = "00FF00"
end
itemList[i].items[j].lv.text = string.format(Language[11090], color, self.curData[i].trumpList[j].lv)
itemList[i].items[j].select.gameObject:SetActive(this:CheckIsSelect(self.curData[i].trumpChipList[j]))
Util.AddOnceClick(itemList[i].items[j].pos, function()
if this:CheckIsSelect(self.curData[i].trumpChipList[j]) then
this:SetIsSelect(self.curData[i].trumpChipList[j])
itemList[i].items[j].select.gameObject:SetActive(this:CheckIsSelect(self.curData[i]
.trumpChipList[j]))
else
if LengthOfTable(self.selectData) >= 4 then
PopupTipPanel.ShowTip(Language[11091])
else
this:SetIsSelect(self.curData[i].trumpChipList[j])
itemList[i].items[j].select.gameObject:SetActive(this:CheckIsSelect(self.curData[i]
.trumpChipList[j]))
end
end
end)
end
end
if isShow then
itemList[i].go.gameObject:SetActive(true)
else
itemList[i].go.gameObject:SetActive(false)
end
end
end
end
function this:SetIsSelect(id)
local isAdd = true
for k, v in pairs(self.selectData) do
if v == id then
table.remove(self.selectData, k)
isAdd = false
end
end
if isAdd then
table.insert(self.selectData, id)
end
end
function this:CheckIsSelect(id)
for k, v in pairs(self.selectData) do
if v == id then
return true
end
end
return false
end
function this:OnClose()
end
function this:OnDestroy()
itemList = {}
end
return this