miduo_client/Assets/ManagedResources/~Lua/Modules/Popup/RewardTalismanSingleShowPop...

389 lines
17 KiB
Lua
Raw Normal View History

2020-08-25 15:46:38 +08:00
require("Base/BasePanel")
2020-05-09 13:31:21 +08:00
RewardTalismanSingleShowPopup = Inherit(BasePanel)
local propertyConfig = ConfigManager.GetConfig(ConfigName.PropertyConfig)
2020-05-09 13:31:21 +08:00
local type
local dId
local sId
local lv
local refineLv
2020-12-15 17:27:16 +08:00
local treeLv
2020-05-09 13:31:21 +08:00
local func
local itemConfig = {}
local curBasePropertyList={}
local curRefinePropertyList={}
local curTreePropertyList={}
2020-05-09 13:31:21 +08:00
--初始化组件(用于子类重写)
function RewardTalismanSingleShowPopup:InitComponent()
self.btnBack= Util.GetGameObject(self.transform, "Content/bg/btnBack")
self.curEquipName=Util.GetGameObject(self.transform, "Content/bg/Text"):GetComponent("Text")
self.curEquipDesc1= Util.GetGameObject(self.transform, "Content/bg/armorInfo/infoText"):GetComponent("Text")
self.curEquipFrame=Util.GetGameObject(self.transform, "Content/bg/armorInfo/frame"):GetComponent("Image")
self.curEquipIcon=Util.GetGameObject(self.transform, "Content/bg/armorInfo/icon"):GetComponent("Image")
2020-06-13 11:47:13 +08:00
self.proIcon=Util.GetGameObject(self.transform, "Content/bg/armorInfo/proIcon"):GetComponent("Image")
2020-05-09 13:31:21 +08:00
self.qualityText=Util.GetGameObject(self.transform, "Content/bg/armorInfo/equipQuaText"):GetComponent("Text")
self.powerNum1=Util.GetGameObject(self.transform, "Content/bg/armorInfo/powerNum"):GetComponent("Text")
self.lv=Util.GetGameObject(self.transform, "Content/bg/armorInfo/lv"):GetComponent("Text")
self.refineLv=Util.GetGameObject(self.transform, "Content/bg/armorInfo/refineLv"):GetComponent("Text")
self.treeImg=Util.GetGameObject(self.transform, "Content/bg/armorInfo/treeImg")
self.treeLv=Util.GetGameObject(self.transform, "Content/bg/armorInfo/treeImg/treeTxt"):GetComponent("Text")
2020-05-09 13:31:21 +08:00
self.curMainProscroll=Util.GetGameObject(self.transform, "Content/mainProScroll")
self.curMainProGrid=Util.GetGameObject(self.transform, "Content/mainProScroll/proGrid")
self.curotherProscroll=Util.GetGameObject(self.transform, "Content/otherProScroll")
self.otherProPre=Util.GetGameObject(self.transform, "Content/proPre")
self.otherProGrid=Util.GetGameObject(self.transform, "Content/otherProScroll/proGrid")
self.curCastInfo=Util.GetGameObject(self.transform, "Content/skillObject/skillInfo"):GetComponent("Text")
self.castInfoObject=Util.GetGameObject(self.transform, "Content/skillObject")
self.castInfoObject:SetActive(false)
self.btnSure=Util.GetGameObject(self.transform, "Content/bg/btnGrid/btnSure")
self.btnJump=Util.GetGameObject(self.transform, "Content/bg/btnGrid/btnJump")
self.bg1Scroll = Util.GetGameObject(self.transform, "Content/Scroll")
self.baseAttri = Util.GetGameObject(self.bg1Scroll, "grid/baseAttri")
self.baseAttriNum = Util.GetGameObject(self.baseAttri, "name/attriNum"):GetComponent("Text")
self.baseAttriGrid = Util.GetGameObject(self.baseAttri, "grid")
self.refineAttri = Util.GetGameObject(self.transform, "grid/refineAttri")
self.refineAttriNum = Util.GetGameObject(self.refineAttri, "name/attriNum"):GetComponent("Text")
self.refineAttriGrid = Util.GetGameObject(self.refineAttri, "grid")
self.treeAttri = Util.GetGameObject(self.transform, "grid/treeAttri")
self.treeAttriNum = Util.GetGameObject(self.treeAttri, "name/attriNum"):GetComponent("Text")
self.treeAttriGrid = Util.GetGameObject(self.treeAttri, "grid")
self.TextPre=Util.GetGameObject(self.transform, "TextPre")
2020-05-09 13:31:21 +08:00
--装备获取途径
--this.getTuPre=Util.GetGameObject(self.transform, "Content/bg/getTuPre")
self.getTuGrid=Util.GetGameObject(self.transform, "Content/bg/scroll/grid")
end
--绑定事件(用于子类重写)
function RewardTalismanSingleShowPopup:BindEvent()
Util.AddClick(self.btnBack, function()
PlaySoundWithoutClick(SoundConfig.Sound_UICancel)
self:ClosePanel()
end)
Util.AddClick(self.btnJump, function()
if itemConfig then
JumpManager.GoJump(itemConfig.UseJump)
end
end)
Util.AddClick(self.btnSure, function()
local curResolveAllItemList={}
table.insert(curResolveAllItemList,dId)
local isPopUp = RedPointManager.PlayerPrefsGetStr(PlayerManager.uid .. "isTalismanShowSure")
local currentTime = os.date("%Y%m%d", PlayerManager.serverTime)
local haveHighQuality=false
local data = TalismanManager.GetSingleTalismanData(dId)
local itemConfig = data.itemConfig
if(itemConfig.Quantity>=4) then
haveHighQuality=true
end
if (isPopUp ~= currentTime and haveHighQuality) then
2020-06-23 18:36:24 +08:00
MsgPanel.ShowTwo(Language[11596], nil, function(isShow)
2020-05-09 13:31:21 +08:00
if (isShow) then
local currentTime = os.date("%Y%m%d", PlayerManager.serverTime)
RedPointManager.PlayerPrefsSetStr(PlayerManager.uid .. "isTalismanShowSure", currentTime)
end
NetManager.UseAndPriceItemRequest(4,curResolveAllItemList,function (drop)
self:SendBackResolveReCallBack(drop)
end)
end, nil, nil, nil, true)
else
NetManager.UseAndPriceItemRequest(4,curResolveAllItemList,function (drop)
self:SendBackResolveReCallBack(drop)
end)
end
end)
end
--添加事件监听(用于子类重写)
function RewardTalismanSingleShowPopup:AddListener()
end
--移除事件监听(用于子类重写)
function RewardTalismanSingleShowPopup:RemoveListener()
end
--界面打开时调用(用于子类重写)
2020-12-15 17:27:16 +08:00
function RewardTalismanSingleShowPopup:OnOpen(_type,_did,_sId,_lv,_refineLv,_treeLv,_func)
2020-05-09 13:31:21 +08:00
type = _type
dId = _did
sId = _sId
lv = _lv
refineLv = _refineLv
2020-12-15 17:27:16 +08:00
treeLv = _treeLv
2020-05-09 13:31:21 +08:00
func = _func
end
--界面打开或者重新打开后,界面刷新时调用(用于子类重写)
function RewardTalismanSingleShowPopup:OnShow()
if type == 1 then
self.btnSure:SetActive(true)
else
self.btnSure:SetActive(false)
end
self:OnShowPanelData()
end
function RewardTalismanSingleShowPopup:OnShowPanelData()
local curEquipTreasureFigData = {}
local curEquipTreasureStrongFigData = {}
local curEquipTreasureSefineFigData = {}
local curEquipTreasureTreeFigData = {}
local data = EquipTreasureManager.GetSingleTreasureByIdDyn(dId)
2020-05-09 13:31:21 +08:00
if type == 1 then
self.powerNum1.text=EquipTreasureManager.CalculateWarForce(dId)
itemConfig = data.itemConfig
curEquipTreasureFigData = ConfigManager.GetConfigData(ConfigName.JewelConfig, data.id)
curEquipTreasureStrongFigData,curEquipTreasureSefineFigData,curEquipTreasureTreeFigData = self:GetStrongAndRefineConFig(curEquipTreasureFigData,data.lv,data.refineLv,data.treeLv)
2020-05-09 13:31:21 +08:00
else
2020-12-15 17:27:16 +08:00
self.powerNum1.text=EquipTreasureManager.CalculateWarForceBySid(sId,lv,refineLv,treeLv)
2020-05-09 13:31:21 +08:00
itemConfig = ConfigManager.GetConfigData(ConfigName.ItemConfig,sId)
curEquipTreasureFigData = ConfigManager.GetConfigData(ConfigName.JewelConfig, sId)
curEquipTreasureStrongFigData,curEquipTreasureSefineFigData,curEquipTreasureTreeFigData = self:GetStrongAndRefineConFig(curEquipTreasureFigData,lv,refineLv,treeLv)
2020-05-09 13:31:21 +08:00
end
self.curEquipDesc1.text=itemConfig.ItemDescribe
self.qualityText.text=GetStringByEquipQua(itemConfig.Quantity,GetQuaStringByEquipQua(itemConfig.Quantity))
self.curEquipName.text=GetStringByEquipQua(itemConfig.Quantity,itemConfig.Name)
2020-05-25 19:16:23 +08:00
if lv>0 then
self.lv.gameObject:SetActive(true)
self.lv.text = lv
2020-05-25 19:16:23 +08:00
else
self.lv.gameObject:SetActive(false)
end
if refineLv>0 then
self.refineLv.gameObject:SetActive(true)
self.refineLv.text = "+".. refineLv
2020-05-25 19:16:23 +08:00
else
self.refineLv.gameObject:SetActive(false)
end
if data.upHeroDid == "" or data.upHeroDid == "0" or treeLv == 0 then
self.treeImg:SetActive(false)
else
self.treeImg:SetActive(true)
self.treeLv.text=treeLv
end
2020-05-09 13:31:21 +08:00
self.curEquipFrame.sprite = Util.LoadSprite(GetQuantityImageByquality(itemConfig.Quantity))
self.curEquipIcon.sprite = Util.LoadSprite(GetResourcePath(itemConfig.ResourceID))
2020-06-13 11:47:13 +08:00
self.proIcon.sprite = Util.LoadSprite(GetProStrImageByProNum(itemConfig.PropertyName))
2020-05-09 13:31:21 +08:00
self.btnJump:SetActive(itemConfig.UseJump and itemConfig.UseJump > 0 and BagManager.isBagPanel)
--(基础属性)
self.bg1Scroll:GetComponent("RectTransform").sizeDelta = Vector2.New(800,100)
local baseInfo=EquipTreasureManager.GetCurLvPropertyValue(1,data.levelPool,data.lv)
self.baseAttriNum.text = "[强化等级:"..data.lv.."/"..data.maxLv.."]"
self:SetPropertyShow1(baseInfo,curBasePropertyList,self.baseAttriGrid)
--(精炼属性)
local refineInfo=EquipTreasureManager.GetCurLvPropertyValue(2,data.refinePool,data.refineLv)
self.refineAttriNum.text = "[精炼等级:"..data.refineLv.."/"..data.maxRefineLv.."]"
if LengthOfTable(refineInfo)==0 or refineInfo==nil then
self.refineAttri:SetActive(false)
2020-05-09 13:31:21 +08:00
else
self.refineAttri:SetActive(true)
self.bg1Scroll:GetComponent("RectTransform").sizeDelta = Vector2.New(800,250)
self:SetPropertyShow1(refineInfo,curRefinePropertyList,self.refineAttriGrid)
2020-05-09 13:31:21 +08:00
end
--(神应属性)
local treeInfo=EquipTreasureManager.GetCurLvPropertyValue(3,data.treePool,data.treeLv)
self.treeAttriNum.text = "[神应等级:"..data.treeLv.."/"..data.maxTreeLv.."]"
if data.upHeroDid == "" or data.upHeroDid == "0" or treeLv == 0 then
self.treeAttri:SetActive(false)
2020-05-09 13:31:21 +08:00
else
self.treeAttri:SetActive(true)
self.bg1Scroll:GetComponent("RectTransform").sizeDelta = Vector2.New(800,500)
self:SetPropertyShow2(treeInfo,curTreePropertyList,self.treeAttriGrid)
2020-05-09 13:31:21 +08:00
end
--强化属性
-- Util.ClearChild(self.curMainProGrid.transform)
-- if #curEquipTreasureStrongFigData.Property>0 then --
-- self.curMainProscroll:SetActive(true)
-- for i = 1, #curEquipTreasureStrongFigData.Property do
-- local go = newObject(self.otherProPre)
-- go.transform:SetParent(self.curMainProGrid.transform)
-- go.transform.localScale = Vector3.one
-- go.transform.localPosition = Vector3.zero
-- go:SetActive(true)
-- local proConFig = ConfigManager.GetConfigData(ConfigName.PropertyConfig,curEquipTreasureStrongFigData.Property[i][1])
-- if proConFig then
-- Util.GetGameObject(go.transform, "proName"):GetComponent("Text").text =proConFig.Info
-- Util.GetGameObject(go.transform, "proVale"):GetComponent("Text").text = "+"..GetEquipPropertyFormatStr(proConFig.Style,curEquipTreasureStrongFigData.Property[i][2])
-- end
-- end
-- else
-- self.curMainProscroll:SetActive(false)
-- end
-- --精炼属性
-- Util.ClearChild(self.otherProGrid.transform)
-- if curEquipTreasureSefineFigData.Property and #curEquipTreasureSefineFigData.Property>0 then --
-- self.curotherProscroll:SetActive(true)
-- for i = 1, #curEquipTreasureSefineFigData.Property do
-- local go = newObject(self.otherProPre)
-- go.transform:SetParent(self.otherProGrid.transform)
-- go.transform.localScale = Vector3.one
-- go.transform.localPosition = Vector3.zero
-- go:SetActive(true)
-- local proConFig = ConfigManager.GetConfigData(ConfigName.PropertyConfig,curEquipTreasureSefineFigData.Property[i][1])
-- if proConFig then
-- Util.GetGameObject(go.transform, "proName"):GetComponent("Text").text =proConFig.Info
-- if curEquipTreasureSefineFigData.Property[i][2]==0 and proConFig.Style~=1 then
-- Util.GetGameObject(go.transform, "proVale"):GetComponent("Text").text = "+0%"
-- else
-- Util.GetGameObject(go.transform, "proVale"):GetComponent("Text").text = "+"..GetEquipPropertyFormatStr(proConFig.Style,curEquipTreasureSefineFigData.Property[i][2])
-- end
-- end
-- end
-- else
-- self.curotherProscroll:SetActive(false)
-- end
2020-05-09 13:31:21 +08:00
--装备获得途径
Util.ClearChild(self.getTuGrid.transform)
local curitemData = itemConfig
if curitemData and curitemData.Jump then
if curitemData.Jump and #curitemData.Jump>0 then
for i = 1, #curitemData.Jump do
SubUIManager.Open(SubUIConfig.JumpView, self.getTuGrid.transform, curitemData.Jump[i])
end
end
end
end
--道具 和 装备分解 发送请求后 回调
function RewardTalismanSingleShowPopup:SendBackResolveReCallBack(drop)
local isShowReward=false
if drop.itemlist~=nil and #drop.itemlist>0 then
for i = 1, #drop.itemlist do
if drop.itemlist[i].itemNum>0 then
isShowReward=true
break
end
end
end
if isShowReward then
UIManager.OpenPanel(UIName.RewardItemPopup,drop,1,function ()
BagManager.OnShowTipDropNumZero(drop)
end)
else
BagManager.OnShowTipDropNumZero(drop)
end
EquipTreasureManager.RemoveTreasureByIdDyn(dId)
self:ClosePanel()
end
--界面关闭时调用(用于子类重写)
function RewardTalismanSingleShowPopup:OnClose()
if func then
func()
end
func = nil
end
function RewardTalismanSingleShowPopup:GetStrongAndRefineConFig(curEuipTreaSureConfig,lv,rlv,tlv)
2020-05-09 13:31:21 +08:00
local curEquipTreasureStrongFigData = {}
local curEquipTreasureSefineFigData = {}
local curEquipTreasureTreeFigData = {}
2020-05-09 13:31:21 +08:00
for _, configInfo in ConfigPairs(ConfigManager.GetConfig(ConfigName.JewelRankupConfig)) do
--强化的属性
if configInfo.PoolID == curEuipTreaSureConfig.LevelupPool and configInfo.Type == 1 and configInfo.Level == lv then
curEquipTreasureStrongFigData = configInfo
end
--精炼的属性
if configInfo.PoolID == curEuipTreaSureConfig.RankupPool and configInfo.Type == 2 and configInfo.Level == rlv then
curEquipTreasureSefineFigData = configInfo
end
--神应的属性
if configInfo.PoolID == curEuipTreaSureConfig.GodHoodPool and configInfo.Type == 3 and configInfo.Level == tlv then
curEquipTreasureTreeFigData = configInfo
end
end
return curEquipTreasureStrongFigData,curEquipTreasureSefineFigData,curEquipTreasureTreeFigData
end
--神应专用
function RewardTalismanSingleShowPopup:SetPropertyShow2(_infos,_preList,_grid)
local curTree = SacredTreeManager.CulAttri()
local attriConfig = ConfigManager.GetConfigDataByKey(ConfigName.GodHoodTreeSetting,"Id",0).PropertyUnlcokLevelForClient
local dataCount=LengthOfTable(_infos)
local preCount=#_preList
for i = 1, dataCount-preCount do
local go = newObject(self.TextPre)
go.transform:SetParent(_grid.transform)
go.transform.localScale = Vector3.one
go.transform.localPosition = Vector3.zero
go.gameObject:SetActive(false)
table.insert(_preList,go)
end
local index=1
for key, value in pairs(attriConfig) do
local obj=_preList[index]
local proper=propertyConfig[value[1]]
local string
if proper.Style==1 then
string = proper.Info.."+".._infos[value[1]].currValue--value.currValue
else
string = proper.Info.."+".._infos[value[1]].currValue/100 .."%"
end
if index <= curTree then
string = "<color=#3CD200>"..string.."</color>"
else
string = "<color=#828282>"..string.."\n".."<size=25>(四灵试炼"..attriConfig[index][2].."层解锁)</size></color>"
end
obj.transform:GetComponent("Text").text = string
obj.gameObject:SetActive(true)
index=index+1
end
for i = 1, #_preList do
if i>=index then
_preList[i]:SetActive(false)
end
end
end
function RewardTalismanSingleShowPopup:SetPropertyShow1(_infos,_preList,_grid)
local dataCount=LengthOfTable(_infos)
local preCount=#_preList
for i = 1, dataCount-preCount do
local go = newObject(self.TextPre)
go.transform:SetParent(_grid.transform)
go.transform.localScale = Vector3.one
go.transform.localPosition = Vector3.zero
go.gameObject:SetActive(false)
table.insert(_preList,go)
end
local index=1
for key, value in pairs(_infos) do
local obj=_preList[index]
local proper=propertyConfig[key]
if proper.Style==1 then
obj.transform:GetComponent("Text").text = proper.Info.."+".. value.currValue
else
obj.transform:GetComponent("Text").text=proper.Info.."+"..value.currValue/100 .."%"
end
obj.gameObject:SetActive(true)
index=index+1
end
for i = 1, #_preList do
if i>=index then
_preList[i]:SetActive(false)
end
2020-05-09 13:31:21 +08:00
end
end
--界面销毁时调用(用于子类重写)
function RewardTalismanSingleShowPopup:OnDestroy()
curBasePropertyList={}
curRefinePropertyList={}
curTreePropertyList={}
2020-05-09 13:31:21 +08:00
end
2020-06-23 18:36:24 +08:00
return RewardTalismanSingleShowPopup