Files
SL1900 7363298dc1 Update - 1.15.0.134
EN: 1.15.0.134
CN: 1.15.0.133
JP: 1.15.0.137
KR: 1.15.0.139
2026-09-08 12:00:00 +09:00

316 lines
12 KiB
Lua

local PenguinCardInfoCtrl = class("PenguinCardInfoCtrl", BaseCtrl)
local PenguinCardUtils = require("Game.UI.Play_PenguinCard.PenguinCardUtils")
local _, NotMaxLevel = ColorUtility.TryParseHtmlString("#FFF7EA")
local _, MaxLevel = ColorUtility.TryParseHtmlString("#ffe075")
PenguinCardInfoCtrl._mapNodeConfig = {
blur = {
sNodeName = "t_fullscreen_blur_blue"
},
aniBlur = {
sNodeName = "t_fullscreen_blur_blue",
sComponentName = "Animator"
},
goInfo = {},
imgIcon = {sComponentName = "Image"},
txtLevel = {sComponentName = "TMP_Text"},
txtName = {sComponentName = "TMP_Text"},
imgUp = {},
txtDesc = {sComponentName = "TMP_Text"},
srDesc = {sComponentName = "ScrollRect"},
aniInfo = {sNodeName = "goInfo", sComponentName = "Animator"},
btnRight = {
sComponentName = "UIButton",
callback = "OnBtnClick_Right"
},
btnLeft = {
sComponentName = "UIButton",
callback = "OnBtnClick_Left"
},
btnSale = {
sComponentName = "UIButton",
callback = "OnBtnClick_Sale"
},
btnBack = {
sComponentName = "UIButton",
callback = "OnBtnClick_Back"
},
btnAide = {
sComponentName = "UIButton",
callback = "OnBtnClick_Aide"
},
txtBtnAide = {sComponentName = "TMP_Text"},
txtBtnBack = {
sComponentName = "TMP_Text",
sLanguageId = "PenguinCard_Btn_Back"
},
btnSelect = {
sComponentName = "UIButton",
callback = "OnBtnClick_Select"
},
txtBtnSelect = {sComponentName = "TMP_Text"},
txtAideLevel = {sComponentName = "TMP_Text"},
imgAideHead = {sComponentName = "Image"},
imgAideUp = {},
imgAideUpEmpty = {}
}
PenguinCardInfoCtrl._mapEventConfig = {
PenguinCard_OpenInfo = "Open",
PenguinCard_SelectPenguinCard = "OnEvent_Select",
PenguinCard_SalePenguinCard = "OnEvent_Sale",
PenguinCard_UpgradeAide = "OnEvent_UpgradeAide"
}
function PenguinCardInfoCtrl:Open(mapCard, nSelectIndex)
self._panel.mapLevel:Pause()
self.mapCard = clone(mapCard)
self.bSelect = nSelectIndex ~= nil
self.nSelectIndex = nSelectIndex
if self.bSelect then
local nMax = #self._panel.mapLevel.tbSelectablePenguinCard
self._mapNode.btnRight.gameObject:SetActive(1 < nMax)
self._mapNode.btnLeft.gameObject:SetActive(1 < nMax)
self._mapNode.btnSale.gameObject:SetActive(false)
self._mapNode.btnSelect.gameObject:SetActive(true)
self._mapNode.imgUp:SetActive(false)
else
self.tbHasIndex = {}
for i = 1, 6 do
if self._panel.mapLevel.tbPenguinCard[i] ~= 0 then
table.insert(self.tbHasIndex, i)
end
end
local nMax = #self.tbHasIndex
self._mapNode.btnRight.gameObject:SetActive(1 < nMax)
self._mapNode.btnLeft.gameObject:SetActive(1 < nMax)
self._mapNode.btnSale.gameObject:SetActive(self._panel.mapLevel.nGameState == PenguinCardUtils.GameState.Prepare)
self._mapNode.btnSelect.gameObject:SetActive(false)
self._mapNode.imgUp:SetActive(false)
end
self:PlayInAni()
self:Refresh()
end
function PenguinCardInfoCtrl:Refresh()
NovaAPI.SetTMPText(self._mapNode.txtName, self.mapCard.sName)
self:SetSprite(self._mapNode.imgIcon, "UI/Play_PenguinCard/SpriteAtlas/Sprite/" .. self.mapCard.sIcon)
self.nAideIndex = self._panel.mapLevel:CheckAideUpgrade(self.mapCard.nGroupId)
local bShowAide = self.nAideIndex ~= nil and self.bSelect
self._mapNode.btnAide.gameObject:SetActive(bShowAide)
if bShowAide then
local mapAide = self._panel.mapLevel.tbAide[self.nAideIndex]
if mapAide ~= 0 then
self:SetPngSprite(self._mapNode.imgAideHead, mapAide.sIcon .. AllEnum.CharHeadIconSurfix.QSS)
local nNeed = mapAide.mapUpgradeNeed[self.mapCard.nGroupId]
local nHas = mapAide.mapUpgradeCount[tostring(self.mapCard.nGroupId)]
NovaAPI.SetTMPText(self._mapNode.txtBtnAide, orderedFormat(ConfigTable.GetUIText("PenguinCard_Btn_Send"), nHas, nNeed))
if nHas + 1 == nNeed then
local nAfter = mapAide.nLevel + 1
if nAfter >= mapAide.nMaxLevel then
nAfter = mapAide.nMaxLevel
end
NovaAPI.SetTMPText(self._mapNode.txtAideLevel, orderedFormat(ConfigTable.GetUIText("PenguinCard_CardLevel"), nAfter))
NovaAPI.SetTMPColor(self._mapNode.txtAideLevel, nAfter == mapAide.nMaxLevel and MaxLevel or NotMaxLevel)
self._mapNode.imgAideUp:SetActive(true)
self._mapNode.imgAideUpEmpty:SetActive(false)
else
NovaAPI.SetTMPText(self._mapNode.txtAideLevel, orderedFormat(ConfigTable.GetUIText("PenguinCard_CardLevel"), mapAide.nLevel))
NovaAPI.SetTMPColor(self._mapNode.txtAideLevel, mapAide.nLevel == mapAide.nMaxLevel and MaxLevel or NotMaxLevel)
self._mapNode.imgAideUp:SetActive(false)
self._mapNode.imgAideUpEmpty:SetActive(true)
end
end
end
if self.bSelect then
local mapSelectCard = self._panel.mapLevel.tbSelectablePenguinCard[self.nSelectIndex]
local bUpgrade, nAimIndex = self._panel.mapLevel:CheckUpgradePenguinCard(mapSelectCard)
if bUpgrade then
self._mapNode.imgUp:SetActive(true)
local mapUpgradeCard = self._panel.mapLevel.tbPenguinCard[nAimIndex]
local nAfter = mapUpgradeCard.nLevel + mapSelectCard.nLevel
nAfter = nAfter > mapUpgradeCard.nMaxLevel and mapUpgradeCard.nMaxLevel or nAfter
NovaAPI.SetTMPText(self._mapNode.txtLevel, orderedFormat(ConfigTable.GetUIText(nAfter == mapUpgradeCard.nMaxLevel and "PenguinCard_CardLevelMax" or "PenguinCard_CardLevel"), nAfter))
NovaAPI.SetTMPColor(self._mapNode.txtLevel, nAfter == mapUpgradeCard.nMaxLevel and MaxLevel or NotMaxLevel)
local nId = mapUpgradeCard:GetIdByLevel(mapUpgradeCard.nGroupId, nAfter)
local mapCfg = ConfigTable.GetData("PenguinCard", nId)
if mapCfg then
local sDesc = ""
if mapCfg.UpgradeResetGrowth then
sDesc = PenguinCardUtils.SetEffectDesc(mapCfg)
else
sDesc = PenguinCardUtils.SetEffectDesc(mapCfg, mapUpgradeCard.nGrowthLayer)
end
NovaAPI.SetTMPText(self._mapNode.txtDesc, sDesc)
end
NovaAPI.SetTMPText(self._mapNode.txtBtnSelect, ConfigTable.GetUIText("PenguinCard_Btn_Upgrade"))
else
self._mapNode.imgUp:SetActive(false)
NovaAPI.SetTMPText(self._mapNode.txtLevel, orderedFormat(ConfigTable.GetUIText(self.mapCard.nLevel == self.mapCard.nMaxLevel and "PenguinCard_CardLevelMax" or "PenguinCard_CardLevel"), self.mapCard.nLevel))
NovaAPI.SetTMPColor(self._mapNode.txtLevel, self.mapCard.nLevel == self.mapCard.nMaxLevel and MaxLevel or NotMaxLevel)
NovaAPI.SetTMPText(self._mapNode.txtDesc, self.mapCard:GetDesc())
if self._panel.mapLevel:CheckMaxLevelPenguinCard(self.mapCard.nGroupId) then
NovaAPI.SetTMPText(self._mapNode.txtBtnSelect, ConfigTable.GetUIText("PenguinCard_Btn_MaxLevel"))
else
NovaAPI.SetTMPText(self._mapNode.txtBtnSelect, ConfigTable.GetUIText("PenguinCard_Btn_Select"))
end
end
else
NovaAPI.SetTMPText(self._mapNode.txtLevel, orderedFormat(ConfigTable.GetUIText(self.mapCard.nLevel == self.mapCard.nMaxLevel and "PenguinCard_CardLevelMax" or "PenguinCard_CardLevel"), self.mapCard.nLevel))
NovaAPI.SetTMPColor(self._mapNode.txtLevel, self.mapCard.nLevel == self.mapCard.nMaxLevel and MaxLevel or NotMaxLevel)
NovaAPI.SetTMPText(self._mapNode.txtDesc, self.mapCard:GetDesc())
end
NovaAPI.SetVerticalNormalizedPosition(self._mapNode.srDesc, 1)
end
function PenguinCardInfoCtrl:PlayInAni()
self.gameObject:SetActive(true)
self._mapNode.blur:SetActive(true)
local wait = function()
coroutine.yield(CS.UnityEngine.WaitForEndOfFrame())
self._mapNode.goInfo:SetActive(true)
end
cs_coroutine.start(wait)
EventManager.Hit(EventId.TemporaryBlockInput, 0.3)
end
function PenguinCardInfoCtrl:Close(bBuy)
self.animator:Play("PengUinCard_CardInfo_out")
if bBuy == true then
self._mapNode.aniInfo:Play("PengUinCard_CardInfo_Card_Give", 0, 0)
else
self._mapNode.aniInfo:Play("PengUinCard_CardInfo_Card_out", 0, 0)
end
self._mapNode.aniBlur:SetTrigger("tOut")
EventManager.Hit(EventId.TemporaryBlockInput, 0.4)
self:AddTimer(1, 0.4, function()
self._mapNode.goInfo:SetActive(false)
self.gameObject:SetActive(false)
self._panel.mapLevel:Resume()
end, true, true, true)
end
function PenguinCardInfoCtrl:Awake()
self._mapNode.goInfo:SetActive(false)
self.animator = self.gameObject:GetComponent("Animator")
end
function PenguinCardInfoCtrl:OnEnable()
end
function PenguinCardInfoCtrl:OnDisable()
end
function PenguinCardInfoCtrl:OnBtnClick_Right()
local switch = function(callback)
self._mapNode.aniInfo:Play("PengUinCard_CardInfo_Card_out_l", 0, 0)
local nAnimTime = NovaAPI.GetAnimClipLength(self._mapNode.aniInfo, {
"PengUinCard_CardInfo_Card_out_l"
})
self:AddTimer(1, nAnimTime, function()
callback()
self._mapNode.aniInfo:Play("PengUinCard_CardInfo_Card_in_r", 0, 0)
end, true, true, true)
end
if self.bSelect then
local callback = function()
local nMax = #self._panel.mapLevel.tbSelectablePenguinCard
if nMax > self.nSelectIndex then
self.nSelectIndex = self.nSelectIndex + 1
else
self.nSelectIndex = 1
end
self.mapCard = clone(self._panel.mapLevel.tbSelectablePenguinCard[self.nSelectIndex])
self:Refresh()
end
switch(callback)
else
local callback = function()
local nMax = #self.tbHasIndex
local nIndex = table.indexof(self.tbHasIndex, self.mapCard.nSlotIndex)
if nMax > nIndex then
nIndex = nIndex + 1
else
nIndex = 1
end
if self._panel.mapLevel.tbPenguinCard[self.tbHasIndex[nIndex]] == 0 then
return
end
self.mapCard = clone(self._panel.mapLevel.tbPenguinCard[self.tbHasIndex[nIndex]])
self:Refresh()
end
switch(callback)
end
end
function PenguinCardInfoCtrl:OnBtnClick_Left()
local switch = function(callback)
self._mapNode.aniInfo:Play("PengUinCard_CardInfo_Card_out_r", 0, 0)
local nAnimTime = NovaAPI.GetAnimClipLength(self._mapNode.aniInfo, {
"PengUinCard_CardInfo_Card_out_r"
})
self:AddTimer(1, nAnimTime, function()
callback()
self._mapNode.aniInfo:Play("PengUinCard_CardInfo_Card_in_l", 0, 0)
end, true, true, true)
end
if self.bSelect then
local callback = function()
local nMax = #self._panel.mapLevel.tbSelectablePenguinCard
if self.nSelectIndex > 1 then
self.nSelectIndex = self.nSelectIndex - 1
else
self.nSelectIndex = nMax
end
self.mapCard = clone(self._panel.mapLevel.tbSelectablePenguinCard[self.nSelectIndex])
self:Refresh()
end
switch(callback)
else
local callback = function()
local nMax = #self.tbHasIndex
local nIndex = table.indexof(self.tbHasIndex, self.mapCard.nSlotIndex)
if 1 < nIndex then
nIndex = nIndex - 1
else
nIndex = nMax
end
if self._panel.mapLevel.tbPenguinCard[self.tbHasIndex[nIndex]] == 0 then
return
end
self.mapCard = clone(self._panel.mapLevel.tbPenguinCard[self.tbHasIndex[nIndex]])
self:Refresh()
end
switch(callback)
end
end
function PenguinCardInfoCtrl:OnBtnClick_Sale()
if not self.mapCard.nSlotIndex then
return
end
self._panel.mapLevel:SalePenguinCard(self.mapCard.nSlotIndex)
end
function PenguinCardInfoCtrl:OnBtnClick_Back()
self:Close()
EventManager.Hit("PenguinCard_CloseCardInfo")
end
function PenguinCardInfoCtrl:OnBtnClick_Aide()
if not self.nSelectIndex then
return
end
self._panel.mapLevel:UpgradeAide(self.nAideIndex, self.mapCard.nGroupId)
end
function PenguinCardInfoCtrl:OnBtnClick_Select()
if not self.nSelectIndex then
return
end
if self._panel.mapLevel:CheckMaxLevelPenguinCard(self.mapCard.nGroupId) then
EventManager.Hit(EventId.OpenMessageBox, {
nType = AllEnum.MessageBox.Tips,
sSound = "Mode_Card_refresh_falied",
sContent = ConfigTable.GetUIText("PenguinCard_SelectMaxLevelCard")
})
return
end
self._panel.mapLevel:SelectPenguinCard(self.nSelectIndex)
end
function PenguinCardInfoCtrl:OnEvent_Select()
self:Close(true)
end
function PenguinCardInfoCtrl:OnEvent_Sale()
self:Close(false)
end
function PenguinCardInfoCtrl:OnEvent_UpgradeAide()
self:Close(true)
end
return PenguinCardInfoCtrl