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

158 lines
7.2 KiB
Lua
Raw Normal View History

2021-11-25 18:55:20 +08:00
----- 神应属性弹窗 -----
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("请选择4个法宝之灵碎片作为心愿")
return
end
NetManager.SendRefreshTailsmanSoulData(self.selectData,function()
parent:ClosePanel()
end)
end)
Util.AddOnceClick(self.cancelBtn,function()
2021-11-25 19:06:20 +08:00
parent:ClosePanel()
2021-11-25 18:55:20 +08:00
end)
end
function this:AddListener()
end
function this:RemoveListener()
end
function this:OnShow(_parent)
parent=_parent
sortingOrder = _parent.sortingOrder
self.selectData = RecruitManager.GetWishTailsManSoulChips()
self.curData = TailsManSoulManager.GetTailsmanSoulDatas1(6)
2021-11-26 17:04:54 +08:00
this:RefreshData()
end
function this:RefreshData()
2021-11-25 18:55:20 +08:00
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 = {}
2021-11-26 17:04:54 +08:00
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)
2021-11-26 17:54:35 +08:00
itemList[i].items[j].item.frame:GetComponent("Button").enabled = false
2021-11-26 17:04:54 +08:00
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)
2021-11-25 18:55:20 +08:00
end
end
itemList[i].go.gameObject:SetActive(true)
2021-11-26 18:30:08 +08:00
itemList[i].title.text = self.curData[i].name
2021-11-25 18:55:20 +08:00
Util.AddOnceClick(itemList[i].lookBtn,function()
2021-11-26 18:30:08 +08:00
UIManager.OpenPanel(UIName.TailsmanSoulMainPanel,self.curData[i].id)
2021-11-25 18:55:20 +08:00
end)
Util.AddOnceClick(itemList[i].selectBtn,function()
MsgPanel.ShowTwo(string.format("确认选择%s作为心愿",self.curData[i].name), function()end, function()
2021-11-26 17:04:54 +08:00
self.selectData = {}
for j = 1,#self.curData[i].trumpChipList do
2021-11-29 16:35:23 +08:00
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
2021-11-26 17:04:54 +08:00
end
this:RefreshData()
2021-11-25 18:55:20 +08:00
end, "取消", "确认", "提示",false,"")
end)
2021-11-26 17:04:54 +08:00
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
2021-11-25 18:55:20 +08:00
itemList[i].items[j].go.gameObject:SetActive(false)
else
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)
2021-11-26 17:54:35 +08:00
itemList[i].items[j].item.frame:GetComponent("Button").enabled = false
2021-11-25 18:55:20 +08:00
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)
2021-11-29 16:35:23 +08:00
itemList[i].items[j].item:OnOpen(false,{self.curData[i].trumpChipList[j],0}, 1, true, false, false, sortingOrder + 1)
2021-11-27 18:12:37 +08:00
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("<color=#%s>%s星</color>",color,self.curData[i].trumpList[j].lv)
2021-11-26 17:04:54 +08:00
itemList[i].items[j].select.gameObject:SetActive(this:CheckIsSelect(self.curData[i].trumpChipList[j]))
Util.AddOnceClick(itemList[i].items[j].pos,function()
2021-11-26 17:54:35 +08:00
if this:CheckIsSelect(self.curData[i].trumpChipList[j]) then
2021-11-26 17:04:54 +08:00
this:SetIsSelect(self.curData[i].trumpChipList[j])
itemList[i].items[j].select.gameObject:SetActive(this:CheckIsSelect(self.curData[i].trumpChipList[j]))
2021-11-26 17:54:35 +08:00
else
if LengthOfTable(self.selectData) >= 4 then
PopupTipPanel.ShowTip("心愿碎片最多为4个")
else
this:SetIsSelect(self.curData[i].trumpChipList[j])
itemList[i].items[j].select.gameObject:SetActive(this:CheckIsSelect(self.curData[i].trumpChipList[j]))
end
2021-11-29 16:35:23 +08:00
end
2021-11-25 18:55:20 +08:00
end)
end
end
end
end
end
function this:SetIsSelect(id)
local isAdd = true
for k,v in pairs(self.selectData) do
if v == id then
2021-11-26 17:54:35 +08:00
table.remove(self.selectData,k)
2021-11-25 18:55:20 +08:00
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