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

158 lines
7.2 KiB
Lua
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

----- 神应属性弹窗 -----
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()
parent:ClosePanel()
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)
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 = 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("确认选择%s作为心愿",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, "取消", "确认", "提示",false,"")
end)
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)
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)
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("<color=#%s>%s星</color>",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("心愿碎片最多为4个")
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
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