miduo_client/Assets/ManagedResources/~Lua/Modules/Expedition/ExpeditionHalidomPanel.lua

130 lines
5.5 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.

require("Base/BasePanel")
ExpeditionHalidomPanel = Inherit(BasePanel)
local _HalidomQualityConfig = {
[3] = {bg = "l_lieyaozhilu_chuanshuo_zh", selectImg = "l_lieyaozhilu_chuanshuo1"},
[2] = {bg = "l_lieyaozhilu_shishi_zh", selectImg = "l_lieyaozhilu_shishi1"},
[1] = {bg = "l_lieyaozhilu_xiyou_zh", selectImg = "l_lieyaozhilu_xiyou1"},
[7] = {bg = "l_lieyaozhilu_chuanshuo_zh", selectImg = "l_lieyaozhilu_chuanshuo1"},
[6] = {bg = "l_lieyaozhilu_shishi_zh", selectImg = "l_lieyaozhilu_shishi1"},
[5] = {bg = "l_lieyaozhilu_xiyou_zh", selectImg = "l_lieyaozhilu_xiyou1"},
}
--初始化组件(用于子类重写)
function ExpeditionHalidomPanel:InitComponent()
self.spLoader = SpriteLoader.New()
self.BtnBack = Util.GetGameObject(self.transform, "maskBtn")
self.BtnSure = Util.GetGameObject(self.transform, "btnSure")
self.cardPre = Util.GetGameObject(self.gameObject, "cardPre")
self.grid = Util.GetGameObject(self.gameObject, "RewardRect")
self.noOneImage = Util.GetGameObject(self.gameObject, "noOneImage")
self.ScrollView = SubUIManager.Open(SubUIConfig.ScrollCycleView, self.grid.transform,
self.cardPre, nil, Vector2.New(902.6, 972.5), 1, 1, Vector2.New(19.32,0))
self.ScrollView.gameObject:GetComponent("RectTransform").anchoredPosition = Vector2.New(0, 0)
self.ScrollView.gameObject:GetComponent("RectTransform").anchorMin = Vector2.New(0.5, 0.5)
self.ScrollView.gameObject:GetComponent("RectTransform").anchorMax = Vector2.New(0.5, 0.5)
self.ScrollView.moveTween.MomentumAmount = 1
self.ScrollView.moveTween.Strength = 1
Util.GetGameObject(self.gameObject,"cardPre/bg"):GetComponent("Image").sprite=self.spLoader:LoadSprite("l_lieyaozhilu_chuanshuo_zh")
end
--绑定事件(用于子类重写)
function ExpeditionHalidomPanel:BindEvent()
Util.AddClick(self.BtnBack, function()
self:ClosePanel()
end)
Util.AddClick(self.BtnSure, function()
self:ClosePanel()
end)
end
--添加事件监听(用于子类重写)
function ExpeditionHalidomPanel:AddListener()
end
--移除事件监听(用于子类重写)
function ExpeditionHalidomPanel:RemoveListener()
end
--界面打开时调用(用于子类重写)
function ExpeditionHalidomPanel:OnOpen()
end
--界面打开或者重新打开后,界面刷新时调用(用于子类重写)
function ExpeditionHalidomPanel:OnShow()
self:OnshowPanelData()
end
function ExpeditionHalidomPanel:OnshowPanelData()
local allHoly = {}
for i, v in pairs(ExpeditionManager.allHoly) do
local configData = ConfigManager.GetConfigData(ConfigName.ExpeditionHolyConfig,v.equiptId)
v.configData = configData
table.insert(allHoly,v)
end
self:SortDatas(allHoly)
self.noOneImage:SetActive(#allHoly <= 0)
self.ScrollView:SetData(allHoly, function(index, go)
self:OnShowSingleHolyData(go, allHoly[index])
end)
end
function ExpeditionHalidomPanel:OnShowSingleHolyData(go,singleHoly)
local configData = ConfigManager.GetConfigData(ConfigName.ExpeditionHolyConfig,singleHoly.equiptId)
--Log(configData.Icon)
Util.GetGameObject(go, "bg"):GetComponent("Image").sprite = self.spLoader:LoadSprite(_HalidomQualityConfig[configData.type].bg)
Util.GetGameObject(go, "quaImage"):GetComponent("Image").sprite = self.spLoader:LoadSprite(GetHeroQuantityImageByquality(configData.type + 3))
Util.GetGameObject(go, "iconImage"):GetComponent("Image").sprite = self.spLoader:LoadSprite(GetResourcePath(configData.Icon))
Util.GetGameObject(go, "nameText"):GetComponent("Text").text = GetLanguageStrById(configData.Name)
Util.GetGameObject(go, "infoRect/infoText"):GetComponent("Text").text = GetLanguageStrById(configData.Describe)
local click = Util.GetGameObject(go, "click")
click:GetComponent("Button").enabled = false
local posImage = Util.GetGameObject(go, "posImage")
local proImage = Util.GetGameObject(go, "proImage")
local heroImage = Util.GetGameObject(go, "Hero")
posImage:SetActive(false)
proImage:SetActive(false)
heroImage:SetActive(false)
if configData.SpecialIcon then
if configData.SpecialIcon[1] == 1 then--属性
proImage:SetActive(true)
proImage:GetComponent("Image").sprite = self.spLoader:LoadSprite(GetProStrImageByProNum(configData.SpecialIcon[2]))
elseif configData.SpecialIcon[1] == 2 then--职业
posImage:SetActive(true)
Util.GetGameObject(go, "posImage/posImage"):GetComponent("Image").sprite = self.spLoader:LoadSprite(GetJobSpriteStrByJobNum(configData.SpecialIcon[2]))
elseif configData.SpecialIcon[1] == 3 then--英雄
heroImage:SetActive(true)
Util.GetGameObject(heroImage, "Icon"):GetComponent("Image").sprite=self.spLoader:LoadSprite(GetResourcePath(ConfigManager.GetConfigData(HeroManager,configData.SpecialIcon[2]).Icon))
end
end
end
--界面关闭时调用(用于子类重写)
function ExpeditionHalidomPanel:OnClose()
end
--界面销毁时调用(用于子类重写)
function ExpeditionHalidomPanel:OnDestroy()
self.spLoader:Destroy()
end
--排序
function ExpeditionHalidomPanel:SortDatas(allHoly)
--上阵最优先星级优先同星级等级优先同星级同等级按sortId排序。排序时降序排序。
table.sort(allHoly, function(a, b)
if a.configData.type == b.configData.type then
return a.equiptId < b.equiptId
else
return a.configData.type > b.configData.type
end
end)
end
return ExpeditionHalidomPanel