miduo_client/Assets/ManagedResources/~Lua/Modules/Popup/RewardRideShowPopup.lua

235 lines
10 KiB
Lua

require("Base/BasePanel")
local RewardRideShowPopup = Inherit(BasePanel)
local itemConfig = ConfigManager.GetConfig(ConfigName.ItemConfig)
local propertyConfig = ConfigManager.GetConfig(ConfigName.PropertyConfig)
local PlayerHeadIcon = ConfigManager.GetConfig(ConfigName.PlayerHeadIcon)
local PassiveSkillConfig = ConfigManager.GetConfig(ConfigName.PassiveSkillConfig)
local _BaseProList = {} --基础属性对象
local _superProList = {} --白金属性对象
--初始化组件(用于子类重写)
function RewardRideShowPopup:InitComponent()
self.spLoader = SpriteLoader.New()
self.mask = Util.GetGameObject(self.transform, "mask")
self.content = Util.GetGameObject(self.transform, "Content")
--装备详情--topBar
self.topBar = Util.GetGameObject(self.transform, "Content/topBar")
self.topBarBg = Util.GetGameObject(self.transform, "Content/topBar/bg2")
self.topBarBgColor = Util.GetGameObject(self.transform, "Content/topBar/bg1"):GetComponent("Image")
self.eqiopName = Util.GetGameObject(self.topBar, "name"):GetComponent("Text")
self.icon = Util.GetGameObject(self.topBar, "icon"):GetComponent("Image")
self.frame = Util.GetGameObject(self.topBar, "frame"):GetComponent("Image")
self.rideType = Util.GetGameObject(self.topBar, "equipType"):GetComponent("Text")
self.rideQuaText = Util.GetGameObject(self.topBar, "equipQuaText"):GetComponent("Text")
self.rideInfoText = Util.GetGameObject(self.topBar, "equipInfoText"):GetComponent("Text")
self.effectbaijin = Util.GetGameObject(self.topBar, "fx_zhuangbeijiemian")
--装备属性--midBar
--basePro
self.midBar = Util.GetGameObject(self.transform, "Content/midBar")
self.basePro = Util.GetGameObject(self.midBar, "basePro")
self.baseProName = Util.GetGameObject(self.basePro, "PropertyName"):GetComponent("Text")
self.baseProGrid = Util.GetGameObject(self.basePro, "grid")
self.baseProPre = Util.GetGameObject(self.basePro, "grid/curProName")
self.baseProPre:SetActive(false)
--superPro
self.superPro = Util.GetGameObject(self.midBar, "superPro")
self.superProGrid = Util.GetGameObject(self.superPro, "proGrid")
self.superProPre = Util.GetGameObject(self.superPro, "proGrid/Desc")
self.superProPre:SetActive(false)
--装备获取途径--btmBar
self.btmBar = Util.GetGameObject(self.transform, "Content/btmBar/howGet")
self.btnGrid = Util.GetGameObject(self.transform, "Content/btmBar/btnGrid")
self.btnJump = Util.GetGameObject(self.btnGrid, "btnJump")
self.canGetPre = Util.GetGameObject(self.btmBar, "scroll/canGetPre")
self.canGetGrid = Util.GetGameObject(self.btmBar, "scroll")
self.canGetScrollView = SubUIManager.Open(SubUIConfig.ScrollCycleView, self.canGetGrid.transform, self.canGetPre, nil,
Vector2.New(self.canGetGrid.transform.rect.width, self.canGetGrid.transform.rect.height), 1, 1, Vector2.New(0, 0))
self.canGetScrollView.moveTween.MomentumAmount = 1
self.canGetScrollView.moveTween.Strength = 2
self.canGetScrollView.elastic = false
self.jumpViewList = {}
end
--绑定事件(用于子类重写)
function RewardRideShowPopup:BindEvent()
Util.AddClick(self.mask, function()
PlaySoundWithoutClick(SoundConfig.Sound_UICancel)
self:ClosePanel()
end)
Util.AddClick(self.btnJump, function()
local oldPowerNum = FormationManager.GetFormationPower(FormationTypeDef.FORMATION_NORMAL)
if PlayerManager.userMountList[self.rideData] then
MsgPanel.ShowTwo(Language[12217], nil, function()
NetManager.ActiveUserMountRequest(self.rideData, function(msg)
PlayerManager.SetPlayerMountTime(self.rideData, msg.validTime)
self:ClosePanel()
PopupTipPanel.ShowTip(Language[12218])
self:WarPowerChange(oldPowerNum, PowerChangeJumpType.ride)
-- 设置新坐骑
PlayerSetTitleRideSkinManager.SetNewRide(self.rideData)
end)
end)
else
NetManager.ActiveUserMountRequest(self.rideData, function(msg)
PlayerManager.SetPlayerMountTime(self.rideData, msg.validTime)
self:ClosePanel()
PopupTipPanel.ShowTip(Language[12218])
self:WarPowerChange(oldPowerNum, PowerChangeJumpType.ride)
-- 设置新坐骑
PlayerSetTitleRideSkinManager.SetNewRide(self.rideData)
end)
end
self:ClosePanel()
end)
end
--添加事件监听(用于子类重写)
function RewardRideShowPopup:AddListener()
end
--移除事件监听(用于子类重写)
function RewardRideShowPopup:RemoveListener()
end
--界面打开时调用(用于子类重写)
function RewardRideShowPopup:OnOpen(_rideData, _func)
if not _rideData then
return
end
self.rideData = _rideData --当前装备数据
self.func = _func
end
function RewardRideShowPopup:OnShow()
local rideConfigData = PlayerHeadIcon[self.rideData]
local rideItemData = ConfigManager.GetConfigData(ConfigName.ItemConfig, self.rideData)
--self.topBar:GetComponent("Image").sprite = self.spLoader:LoadSprite("t_tongyong_di_" .. rideItemData.Quantity)
self.topBarBg:GetComponent("Image").sprite = self.spLoader:LoadSprite("t_tongyong_di_" .. rideItemData.Quantity)
if rideItemData.Quantity == 1 then
self.topBarBgColor.color = Color.New(0.81, 0.81, 0.81, 1)
elseif rideItemData.Quantity == 2 then
self.topBarBgColor.color = Color.New(0.24, 0.34, 0.21, 1)
elseif rideItemData.Quantity == 3 then
self.topBarBgColor.color = Color.New(0.22, 0.42, 0.63, 1)
elseif rideItemData.Quantity == 4 then
self.topBarBgColor.color = Color.New(0.29, 0.14, 0.26, 1)
elseif rideItemData.Quantity == 5 then
self.topBarBgColor.color = Color.New(0.26, 0.14, 0.06, 1)
elseif rideItemData.Quantity == 6 then
self.topBarBgColor.color = Color.New(0.25, 0.02, 0.02, 1)
elseif rideItemData.Quantity == 7 then
self.topBarBgColor.color = Color.New(0.32, 0.32, 0.32, 1)
elseif rideItemData.Quantity == 8 then
self.topBarBgColor.color = Color.New(0.32, 0.32, 0.32, 1)
end
self.rideQuaText.text = GetStringByEquipQua(rideItemData.Quantity, GetQuaStringByEquipQua(rideItemData.Quantity))
self.eqiopName.text = GetStringByEquipQua(rideItemData.Quantity, GetLanguageStrById(rideItemData.Name))
self.frame.sprite = self.spLoader:LoadSprite(GetQuantityImageByquality(rideItemData.Quantity))
self.icon.sprite = self.spLoader:LoadSprite(GetResourcePath(rideItemData.ResourceID))
self.rideInfoText.text = GetLanguageStrById(rideItemData.ItemDescribe)
self.rideType.text = ""
--下部按钮信息
self.effectbaijin:SetActive(rideItemData.Quantity == 7)
Util.SetParticleSortLayer(self.effectbaijin, self.sortingOrder + 1)
self.btnGrid:SetActive(BagManager.isBagPanel)
--basePro基础属性
if rideConfigData.UnlockProperty then
self.basePro:SetActive(true)
for _, pro in ipairs(_BaseProList) do
pro:SetActive(false)
end
for index, value in ipairs(rideConfigData.UnlockProperty) do
local proConfigData = ConfigManager.GetConfigData(ConfigName.PropertyConfig, value[1])
if not _BaseProList[index] then
_BaseProList[index] = newObjToParent(self.baseProPre, self.baseProGrid)
end
_BaseProList[index]:SetActive(true)
_BaseProList[index]:GetComponent("Text").text = GetLanguageStrById(proConfigData.Info)
local vText = Util.GetGameObject(_BaseProList[index], "curProVale"):GetComponent("Text")
if value[2] > 0 then
vText.text = "+" .. GetPropertyFormatStr(proConfigData.Style, value[2])
else
vText.text = GetPropertyFormatStr(proConfigData.Style, value[2])
end
end
else
self.basePro:SetActive(false)
end
--零售技能
if rideConfigData.SkillEffect then
self.superPro:SetActive(true)
if not _superProList[1] then
_superProList[1] = newObjToParent(self.superProPre, self.superProGrid)
end
_superProList[1].gameObject:SetActive(true)
local str = string.split(rideConfigData.SkillEffect, "#")
_superProList[1]:GetComponent("Text").text = GetLanguageStrById(str[2])
Util.GetGameObject(_superProList[1], "Name"):GetComponent("Text").text = GetLanguageStrById(str[1]) .. ":"
else
self.superPro:SetActive(false)
end
--获取途径
if self.jumpViewList and #self.jumpViewList > 0 then
for i = 1, #self.jumpViewList do
SubUIManager.Close(self.jumpViewList[i])
end
end
local curitemData = itemConfig[tonumber(self.rideData)]
if curitemData and curitemData.Jump then
if curitemData.Jump and #curitemData.Jump > 0 then
self.canGetScrollView:SetData(curitemData.Jump, function(index, item)
local tempView = nil
if self.isShowGo then
tempView = SubUIManager.Open(SubUIConfig.JumpView, item.transform, curitemData.Jump[index], true)
else
tempView = SubUIManager.Open(SubUIConfig.JumpView, item.transform, curitemData.Jump[index], false)
end
table.insert(self.jumpViewList, tempView)
end, true, true)
end
end
--(此处需要三遍才能完全打开)
ForceRebuildLayout(self.midBar.transform)
ForceRebuildLayout(self.midBar.transform)
ForceRebuildLayout(self.midBar.transform)
if self.func then
self.func()
end
end
function RewardRideShowPopup:WarPowerChange(oldPowerNum, type)
-- 设置脏数据
HeroPropManager.SetFuncPropDirty(Func_Prop_Type.PlayerExtra)
Game.GlobalEvent:DispatchEvent(GameEvent.Bag.OnBagShowWarPowerChange, oldPowerNum, type)
local newPowerNum = FormationManager.GetFormationPower(FormationTypeDef.FORMATION_NORMAL)
if oldPowerNum ~= newPowerNum then
UIManager.OpenPanel(UIName.WarPowerChangeNotifyPanelV2, { oldValue = oldPowerNum, newValue = newPowerNum })
end
end
--界面关闭时调用(用于子类重写)
function RewardRideShowPopup:OnClose()
for i = 1, #self.jumpViewList do
destroy(self.jumpViewList[i].gameObject)
end
end
--界面销毁时调用(用于子类重写)
function RewardRideShowPopup:OnDestroy()
self.spLoader:Destroy()
_BaseProList = {}
_superProList = {}
self.jumpViewList = {}
end
return RewardRideShowPopup