miduo_client/Assets/ManagedResources/~Lua/Modules/Expedition/ExpeditionSelectHalidomPane...

158 lines
7.0 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")
ExpeditionSelectHalidomPanel = Inherit(BasePanel)
local fun
local curSelectHalidom
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"},
}
local isOpenPanel = false
local curSelectNodeData = {}
--初始化组件(用于子类重写)
function ExpeditionSelectHalidomPanel: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.selectImage = Util.GetGameObject(self.gameObject, "selectImage")
self.ScrollView = SubUIManager.Open(SubUIConfig.ScrollCycleView, self.grid.transform,
self.cardPre, nil, Vector2.New(902.6, 726.3), 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
self.ScrollView.elastic = false
end
--绑定事件(用于子类重写)
function ExpeditionSelectHalidomPanel:BindEvent()
Util.AddClick(self.BtnBack, function()
self:ClosePanel()
Game.GlobalEvent:DispatchEvent(GameEvent.Expedition.RefreshMainPanel)
end)
Util.AddClick(self.BtnSure, function()
if curSelectHalidom then
--Log(" ExpeditionManager.GetCurNodeInfo().sortId,curSelectHalidom "..ExpeditionManager.GetCurNodeInfo().sortId.." "..curSelectHalidom)
NetManager.TakeHolyEquipRequest(curSelectNodeData.sortId,curSelectHalidom, function(msg)
-- Log("msg.equipId "..msg.equipId)
--UIManager.OpenPanel(UIName.ExpeditionMainPanel)
Game.GlobalEvent:DispatchEvent(GameEvent.Expedition.RefreshPlayAniMainPanel)
end)
self:ClosePanel()
else
PopupTipPanel.ShowTip(Language[10554])
end
end)
end
--添加事件监听(用于子类重写)
function ExpeditionSelectHalidomPanel:AddListener()
end
--移除事件监听(用于子类重写)
function ExpeditionSelectHalidomPanel:RemoveListener()
end
--界面打开时调用(用于子类重写)
function ExpeditionSelectHalidomPanel:OnOpen(_isOpenPanel,_fun)
isOpenPanel = _isOpenPanel
fun = _fun
end
--界面打开或者重新打开后,界面刷新时调用(用于子类重写)
function ExpeditionSelectHalidomPanel:OnShow()
curSelectHalidom = nil
self:OnshowPanelData()
end
function ExpeditionSelectHalidomPanel:OnshowPanelData()
local allHoly = {}
self.selectImage:SetActive(false)
curSelectNodeData = ExpeditionManager.curAttackNodeInfo
allHoly = curSelectNodeData.holyEquipID
self.noOneImage:SetActive(#allHoly <= 0)
self.ScrollView:SetData(allHoly, function(index, go)
self:OnShowSingleHolyData(go, allHoly[index])
end)
end
function ExpeditionSelectHalidomPanel:OnShowSingleHolyData(go,singleHoly)
local configData
configData = ConfigManager.GetConfigData(ConfigName.ExpeditionHolyConfig,singleHoly)
--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))-- 报错资源表里找不到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 posImage = Util.GetGameObject(go, "posImage")
local proImage = Util.GetGameObject(go, "proImage")
local heroImage = Util.GetGameObject(go, "Hero")
local newImage = Util.GetGameObject(go, "newImage")
posImage:SetActive(false)
proImage:SetActive(false)
heroImage:SetActive(false)
newImage:SetActive(not ExpeditionManager.allSHoly[configData.Id])
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(GetProStrImageByProNum(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
local click = Util.GetGameObject(go, "click")
click:GetComponent("Button").enabled = true
Util.AddOnceClick(click, function()
self:SelectImageSetParent(Util.GetGameObject(go, "selectRoot"), configData)
curSelectHalidom = singleHoly
end)
Util.AddOnceClick(Util.GetGameObject(go, "infoRect/infoText"), function()
self:SelectImageSetParent(Util.GetGameObject(go, "selectRoot"), configData)
curSelectHalidom = singleHoly
end)
end
--选择图片设置父级
function ExpeditionSelectHalidomPanel:SelectImageSetParent(_objPoint, configData)
self.selectImage:SetActive(true)
self.selectImage.transform:SetParent(_objPoint.transform)
self.selectImage.transform.localScale = Vector3.one
self.selectImage.transform.localPosition = Vector3.zero
self.selectImage:GetComponent("Image").sprite = self.spLoader:LoadSprite(_HalidomQualityConfig[configData.type].selectImg)
end
--界面关闭时调用(用于子类重写)
function ExpeditionSelectHalidomPanel:OnClose()
if fun then
fun()
fun = nil
end
end
--界面销毁时调用(用于子类重写)
function ExpeditionSelectHalidomPanel:OnDestroy()
self.spLoader:Destroy()
end
return ExpeditionSelectHalidomPanel