miduo_client/Assets/ManagedResources/~Lua/Modules/HelpFight/HelpFightPanel.lua

182 lines
7.2 KiB
Lua

require("Base/BasePanel")
HelpFightPanel = Inherit(BasePanel)
local assConfig = ConfigManager.GetConfig(ConfigName.AssistanceConfig)
--初始化组件(用于子类重写)
function HelpFightPanel:InitComponent()
self.spLoader = SpriteLoader.New()
self.UpView = SubUIManager.Open(SubUIConfig.UpView, self.gameObject.transform, { showType = UpViewOpenType.ShowLeft })
self.btnBack = Util.GetGameObject(self.gameObject, "Back/BackBtn")
self.AddProTxt = Util.GetGameObject(self.gameObject, "AddProTxt"):GetComponent("Text")
self.helpBtn = Util.GetGameObject(self.gameObject, "HelpBtn")
self.scrollRect = Util.GetGameObject(self.gameObject, "scroll")
self.prefab = Util.GetGameObject(self.gameObject, "item")
self.tipInfo = Util.GetGameObject(self.gameObject, "tipInfo"):GetComponent("Text")
self.ScrollBar = Util.GetGameObject(self.gameObject, "Scrollbar"):GetComponent("Scrollbar")
local v2 = self.scrollRect:GetComponent("RectTransform").rect
self.ScrollView = SubUIManager.Open(SubUIConfig.ScrollCycleView, self.scrollRect.transform, self.prefab,
self.ScrollBar, Vector2.New(v2.width, v2.height), 1, 4, Vector2.New(70, 20))
self.ScrollView.moveTween.MomentumAmount = 1
self.ScrollView.moveTween.Strength = 1
end
--绑定事件(用于子类重写)
function HelpFightPanel:BindEvent()
Util.AddClick(self.btnBack, function()
self:ClosePanel()
end)
Util.AddClick(self.helpBtn, function()
UIManager.OpenPanel(UIName.HelpPopup, 146, 0, 0)
end)
end
--添加事件监听(用于子类重写)
function HelpFightPanel:AddListener()
end
--移除事件监听(用于子类重写)
function HelpFightPanel:RemoveListener()
end
--界面打开时调用(用于子类重写)
function HelpFightPanel:OnOpen()
end
function HelpFightPanel:OnSortingOrderChange()
end
--界面打开或者重新打开后,界面刷新时调用(用于子类重写)
function HelpFightPanel:OnShow()
self.UpView:OnOpen({ showType = UpViewOpenType.ShowLeft, panelType = PanelType.HongMengTower })
local list = {}
local heroList = HelpFightManager.HelpFightList
for key, v in ConfigPairs(assConfig) do
--LogError("id=="..v.Id)
local data = {}
data.config = v
if heroList[key].heroId ~= "" and heroList[key].heroId ~= nil then
data.hero = HeroManager.GetSingleHeroData(heroList[key].heroId)
end
data.state = heroList[key].state
list[key] = data
end
LogError("list len===============" .. #list)
self.ScrollView:SetData(list, function(index, go)
self:SingleItemDataShow(go, list[index], index)
end)
local addProList, addNum = HelpFightManager.GetAllAddPro()
if #addProList == 0 then
local aaa = { 1, 2, 3, 4 }
for i = 1, #aaa do
addProList[aaa[i]] = 0
end
end
local str = ""
for k, v in pairs(addProList) do
str = str ..
GetLanguageStrById(ConfigManager.GetConfigData(ConfigName.PropertyConfig, k).Info) ..
" +" .. v .. " " .. string.format(Language[11565], addNum / 100)
end
self.AddProTxt.text = str
--self.tipInfo.text=""
end
function HelpFightPanel:SingleItemDataShow(_go, _data, _index)
LogError("_data.id================================" .. _data.config.Id)
local frame = Util.GetGameObject(_go, "Box/Empty/frame"):GetComponent("Image")
local infoTxt = Util.GetGameObject(_go, "infoTxt"):GetComponent("Text")
local lockObj = Util.GetGameObject(_go, "Box/Empty/lock")
local tipObj = Util.GetGameObject(_go, "Box/Empty/tipInfo")
local heroObj = Util.GetGameObject(_go, "GameObject")
local frame1 = Util.GetGameObject(heroObj, "frame"):GetComponent("Image")
local lvGo = Util.GetGameObject(heroObj, "lv")
local icon = Util.GetGameObject(heroObj, "icon"):GetComponent("Image")
local proIcon = Util.GetGameObject(heroObj, "proIcon")
local redPoint = Util.GetGameObject(_go, "redPoint")
--local name = Util.GetGameObject(heroObj, "name"):GetComponent("Text")
local starGrid = Util.GetGameObject(heroObj, "star")
local tipTxt = Util.GetGameObject(_go, "Box/Empty/tipInfo/Text"):GetComponent("Text")
local proTxt = Util.GetGameObject(_go, "proList/pro1"):GetComponent("Text")
frame.sprite = self.spLoader:LoadSprite(GetBgByHeroNatural(_data.config.Quality))
local title = GetHeroNaturalStrByNatural(_data.config.Quality) ..
" " .. HeroElementDef[_data.config.ProfessionLimit]
redPoint:SetActive(HelpFightManager.CheckRedPointByPosition(_index))
infoTxt.text = title
lockObj:SetActive(_data.state == 0)
tipObj:SetActive(_data.state == 0)
local curTime = GetTimeStamp()
local nowTime = math.floor((PlayerManager.userCreateTime + _data.config.Experience * 86400 - curTime) / 86400 + 1)
tipTxt.text = string.format(Language[11331], nowTime)
local proList = {}
if _data.hero then
heroObj:SetActive(true)
frame1.sprite = self.spLoader:LoadSprite(GetHeroQuantityImageByquality(_data.hero.heroConfig.Natural))
lvGo:SetActive(true)
Util.GetGameObject(lvGo.transform, "Text"):GetComponent("Text").text = _data.hero.lv
icon.sprite = self.spLoader:LoadSprite(_data.hero.icon)
proIcon:GetComponent("Image").sprite = self.spLoader:LoadSprite(GetProStrImageByProNum(_data.hero.changeProId))
--name.text = SubString2(GetLanguageStrById(_data.hero.heroConfig.ReadingName),8)
local star, starType = _data.hero.GetStar(1)
SetHeroStars(self.spLoader, starGrid, star, starType, nil, nil, Vector2.New(0, 1))
Util.SetParticleSortLayer(starGrid, self.sortingOrder + 1)
local config = ConfigManager.TryGetConfigDataByDoubleKey(ConfigName.AssistanceProperty, "Quality",
_data.hero.heroConfig.Natural, "Star", _data.hero.star)
if config then
proList = config.Property
end
Util.AddClick(icon.gameObject, function()
local data = {}
data.title = title
data.hero = _data.hero
data.limitQua = _data.config.Quality
data.limitPro = _data.config.ProfessionLimit
data.pos = _index
UIManager.OpenPanel(UIName.HelpFightListPanel, data, self)
end)
else
proList = { { 1, 0 }, { 2, 0 }, { 3, 0 }, { 4, 0 } }
heroObj:SetActive(false)
end
--显示属性
local str = ""
for i = 1, #proList do
local k = proList[i][1]
local v = proList[i][2]
str = str .. GetLanguageStrById(ConfigManager.GetConfigData(ConfigName.PropertyConfig, i).Info) .. " +" ..
v .. "\n"
end
proTxt.text = str
Util.AddClick(frame.gameObject, function()
local data = {}
data.title = title
data.hero = nil
data.limitQua = _data.config.Quality
data.limitPro = _data.config.ProfessionLimit
data.pos = _index
UIManager.OpenPanel(UIName.HelpFightListPanel, data, self)
end)
end
--界面关闭时调用(用于子类重写)
function HelpFightPanel:OnClose()
end
--界面销毁时调用(用于子类重写)
function HelpFightPanel:OnDestroy()
self.spLoader:Destroy()
SubUIManager.Close(self.UpView)
end
return HelpFightPanel