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

128 lines
5.4 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
ExpeditionHalidomPanel = Inherit(BasePanel)
local _HalidomQualityConfig = {
2021-01-26 17:08:39 +08:00
[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"},
2020-05-09 13:31:21 +08:00
2021-01-26 17:08:39 +08:00
[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"},
2020-05-09 13:31:21 +08:00
}
--初始化组件(用于子类重写)
function ExpeditionHalidomPanel:InitComponent()
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
2021-01-26 17:08:39 +08:00
Util.GetGameObject(self.gameObject,"cardPre/bg"):GetComponent("Image").sprite=Util.LoadSprite("l_lieyaozhilu_chuanshuo_zh")
2020-05-09 13:31:21 +08:00
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 = Util.LoadSprite(_HalidomQualityConfig[configData.type].bg)
Util.GetGameObject(go, "quaImage"):GetComponent("Image").sprite = Util.LoadSprite(GetHeroQuantityImageByquality(configData.type))
Util.GetGameObject(go, "iconImage"):GetComponent("Image").sprite = Util.LoadSprite(GetResourcePath(configData.Icon))
2021-01-29 14:09:52 +08:00
Util.GetGameObject(go, "nameText"):GetComponent("Text").text = GetLanguageStrById(configData.Name)
2021-01-26 17:08:39 +08:00
Util.GetGameObject(go, "infoText"):GetComponent("Text").text = GetLanguageStrById(configData.Describe)
2020-05-09 13:31:21 +08:00
local click = Util.GetGameObject(go, "click")
click:GetComponent("Button").enabled = false
local posImage = Util.GetGameObject(go, "posImage")
local proImage = Util.GetGameObject(go, "proImage")
2020-06-18 20:39:29 +08:00
local heroImage = Util.GetGameObject(go, "Hero")
2020-05-09 13:31:21 +08:00
posImage:SetActive(false)
proImage:SetActive(false)
2020-06-18 20:39:29 +08:00
heroImage:SetActive(false)
2020-05-09 13:31:21 +08:00
if configData.SpecialIcon then
2020-06-18 20:39:29 +08:00
if configData.SpecialIcon[1] == 1 then--属性
2020-05-09 13:31:21 +08:00
proImage:SetActive(true)
2020-06-18 20:39:29 +08:00
proImage:GetComponent("Image").sprite = Util.LoadSprite(GetProStrImageByProNum(configData.SpecialIcon[2]))
elseif configData.SpecialIcon[1] == 2 then--职业
2020-05-09 13:31:21 +08:00
posImage:SetActive(true)
2020-06-18 20:39:29 +08:00
Util.GetGameObject(go, "posImage/posImage"):GetComponent("Image").sprite = Util.LoadSprite(GetJobSpriteStrByJobNum(configData.SpecialIcon[2]))
elseif configData.SpecialIcon[1] == 3 then--英雄
heroImage:SetActive(true)
Util.GetGameObject(heroImage, "Icon"):GetComponent("Image").sprite=Util.LoadSprite(GetResourcePath(ConfigManager.GetConfigData(HeroManager,configData.SpecialIcon[2]).Icon))
2020-05-09 13:31:21 +08:00
end
end
end
--界面关闭时调用(用于子类重写)
function ExpeditionHalidomPanel:OnClose()
end
--界面销毁时调用(用于子类重写)
function ExpeditionHalidomPanel:OnDestroy()
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
2020-06-23 18:36:24 +08:00
return ExpeditionHalidomPanel