sk-client/Assets/ManagedResources/~Lua/Modules/SeasonalActivity/SeasonalSkillPreviewPanel.lua

110 lines
3.9 KiB
Lua

require("Base/BasePanel")
SeasonalSkillPreviewPanel = Inherit(BasePanel)
local this = SeasonalSkillPreviewPanel
local PassiveSkillConfig = ConfigManager.GetConfig(ConfigName.PassiveSkillConfig)
local PassiveSkillLogicConfig = ConfigManager.GetConfig(ConfigName.PassiveSkillLogicConfig)
function this:InitComponent()
this.btnBack = Util.GetGameObject(this.gameObject, "btnBack")
local scroll = Util.GetGameObject(this.gameObject, "scroll").transform
local pre = Util.GetGameObject(this.gameObject, "scroll/pre")
local v = scroll:GetComponent("RectTransform").rect
this.scrollView = SubUIManager.Open(SubUIConfig.ScrollCycleView, scroll,
pre, nil, Vector2.New(v.width, v.height), 1, 1, Vector2.New(0, 7))
this.scrollView.moveTween.MomentumAmount = 1
this.scrollView.moveTween.Strength = 1
end
function this:BindEvent()
Util.AddClick(this.btnBack, function()
this:ClosePanel()
end)
end
function this:AddListener()
end
function this:RemoveListener()
end
function this:OnOpen()
local activityId = ActivityGiftManager.IsActivityTypeOpen(ActivityTypeDef.SeasonalActivity)
local allData = ConfigManager.GetAllConfigsDataByKey(ConfigName.SeasonConfig, "ActivityId", activityId)
local skillGroups = {}
for i = 1, #allData do
if allData[i].FreeSkill > 0 then
local config = PassiveSkillLogicConfig[allData[i].FreeSkill]
if config.Level == 1 then
local state = true
for k = 1, #skillGroups do
if skillGroups[k] == config.Group then
state = false
end
end
if state then
table.insert(skillGroups, config.Group)
end
end
end
if allData[i].PaySkill > 0 then
local config = PassiveSkillLogicConfig[allData[i].PaySkill]
if config.Level == 1 then
local state = true
for k = 1, #skillGroups do
if skillGroups[k] == config.Group then
state = false
end
end
if state then
table.insert(skillGroups, config.Group)
end
end
end
end
NetManager.GetSeasonSkill(function (msg)
local allData = {}
for i = 1, #msg.skillIds do
for k = 1, #skillGroups do
if PassiveSkillLogicConfig[msg.skillIds[i]].Group == skillGroups[k] then
table.insert(allData, {id = msg.skillIds[i], state = true})
table.remove(skillGroups, k)
end
end
end
for i = 1, #skillGroups do
local config = ConfigManager.TryGetConfigDataByDoubleKey(ConfigName.PassiveSkillLogicConfig, "Group", skillGroups[i], "Level", 1)
table.insert(allData, {id = config.Id, state = false})
end
this.scrollView:SetData(allData, function (index, go)
this.SetItemPre(go, allData[index])
end)
end)
end
function this:OnShow()
end
function this:OnSortingOrderChange()
end
function this:OnClose()
end
function this:OnDestroy()
end
function this.SetItemPre(go, data)
local name = Util.GetGameObject(go, "Text"):GetComponent("Text")
local lv = Util.GetGameObject(go, "Text/lv"):GetComponent("Text")
local desc = Util.GetGameObject(go, "desc"):GetComponent("Text")
local icon = Util.GetGameObject(go, "icon"):GetComponent("Image")
local mask = Util.GetGameObject(go, "mask")
name.text = GetLanguageStrById(PassiveSkillConfig[data.id].Name)
-- lv.text = "Lv"..PassiveSkillLogicConfig[data.id].Level
desc.text = GetLanguageStrById(PassiveSkillConfig[data.id].Desc)
icon.sprite = Util.LoadSprite(GetResourcePath(PassiveSkillConfig[data.id].Icon))
mask:SetActive(not data.state)
end
return SeasonalSkillPreviewPanel