Initial version - 1.2.0.60
EN: 1.2.0.60 CN: 1.2.0.61 JP: 1.2.0.63 KR: 1.2.0.67
This commit is contained in:
@@ -0,0 +1,121 @@
|
||||
local BaseCtrl = require("GameCore.UI.BaseCtrl")
|
||||
local CharacterFavourCtrl = class("CharacterFavourCtrl", BaseCtrl)
|
||||
CharacterFavourCtrl._mapNodeConfig = {
|
||||
txtFavourLevel = {
|
||||
sNodeName = "txtFavourLevel",
|
||||
sComponentName = "TMP_Text"
|
||||
},
|
||||
transFavourBarCenter = {
|
||||
sNodeName = "FavourBarCenter",
|
||||
sComponentName = "Transform"
|
||||
},
|
||||
txtFavourNum = {sNodeName = "txtFavour", sComponentName = "TMP_Text"},
|
||||
txtFavourBubble = {
|
||||
sNodeName = "txtFavourBubble",
|
||||
sComponentName = "TMP_Text"
|
||||
},
|
||||
btnFavourTask = {
|
||||
sNodeName = "btnFavourTask",
|
||||
sComponentName = "UIButton",
|
||||
callback = "OnBtn_ClickOpenTask"
|
||||
},
|
||||
txtFavourTask = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "CharacterRelation_Favour_Task"
|
||||
},
|
||||
btnFavourReward = {
|
||||
sNodeName = "btnFavourReward",
|
||||
sComponentName = "UIButton",
|
||||
callback = "OnBtn_ClickOpenRewardPreview"
|
||||
},
|
||||
txtFavourReward = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "CharacterRelation_Favour_Reward"
|
||||
},
|
||||
btnFavourGift = {
|
||||
sNodeName = "btnFavourGift",
|
||||
sComponentName = "UIButton",
|
||||
callback = "OnBtn_ClickOpenGiftPanel"
|
||||
},
|
||||
imgHeart = {sNodeName = "imgHeart", sComponentName = "Image"},
|
||||
aniFavour = {
|
||||
sNodeName = "aniFavourRoot",
|
||||
sComponentName = "Animator"
|
||||
},
|
||||
rectImgFavourBar = {
|
||||
sNodeName = "imgFavourBar",
|
||||
sComponentName = "RectTransform"
|
||||
},
|
||||
txtFavourTitle = {
|
||||
sNodeName = "txtFavourTitle",
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "CharacterRelation_Favour_Title"
|
||||
}
|
||||
}
|
||||
CharacterFavourCtrl._mapEventConfig = {
|
||||
[EventId.AffinityChange] = "OnEvent_AffinityChange"
|
||||
}
|
||||
function CharacterFavourCtrl:Awake()
|
||||
self.progressBarWidth = 162
|
||||
self.progressBarMinWidth = 0
|
||||
end
|
||||
function CharacterFavourCtrl:OnEnable()
|
||||
end
|
||||
function CharacterFavourCtrl:OnBtn_ClickOpenTask()
|
||||
EventManager.Hit(EventId.OpenPanel, PanelId.CharFavourTask, self.curCharId)
|
||||
end
|
||||
function CharacterFavourCtrl:OnBtn_ClickOpenRewardPreview()
|
||||
EventManager.Hit(EventId.OpenPanel, PanelId.CharFavourReward, self.curCharId)
|
||||
end
|
||||
function CharacterFavourCtrl:OnBtn_ClickOpenGiftPanel()
|
||||
EventManager.Hit(EventId.CharRelatePanelOpen, PanelId.CharFavourGift, self.curCharId)
|
||||
end
|
||||
function CharacterFavourCtrl:Refresh(nCharId)
|
||||
self.curCharId = nCharId
|
||||
local affinityData = PlayerData.Char:GetCharAffinityData(nCharId)
|
||||
self.curFavourLevel = affinityData.Level
|
||||
self.curFavourExp = affinityData.Exp
|
||||
local data = {}
|
||||
local needExp = 0
|
||||
local forEachAffinityLevel = function(mapData)
|
||||
if mapData.AffinityLevel == self.curFavourLevel then
|
||||
data = mapData
|
||||
elseif mapData.AffinityLevel == self.curFavourLevel + 1 then
|
||||
needExp = mapData.NeedExp
|
||||
end
|
||||
end
|
||||
ForEachTableLine(DataTable.AffinityLevel, forEachAffinityLevel)
|
||||
NovaAPI.SetTMPText(self._mapNode.txtFavourLevel, self.curFavourLevel)
|
||||
NovaAPI.SetTMPText(self._mapNode.txtFavourNum, self.curFavourExp .. "/" .. needExp)
|
||||
self._mapNode.txtFavourNum.gameObject:SetActive(needExp ~= 0)
|
||||
NovaAPI.SetTMPText(self._mapNode.txtFavourBubble, data.AffinityLevelName)
|
||||
if data.AffinityLevelIcon ~= "" then
|
||||
end
|
||||
self._mapNode.aniFavour.gameObject:SetActive(false)
|
||||
self._mapNode.aniFavour.gameObject:SetActive(true)
|
||||
self._mapNode.aniFavour:SetInteger("affinity_lv", data.AffinityLevelStage)
|
||||
local percent = 0
|
||||
if needExp ~= 0 then
|
||||
percent = self.curFavourExp / needExp
|
||||
else
|
||||
percent = 1
|
||||
end
|
||||
self:RefreshProgressBar(percent, 0)
|
||||
end
|
||||
function CharacterFavourCtrl:RefreshProgressBar(nPercent, nDuration)
|
||||
local sizeDelta = self._mapNode.rectImgFavourBar.sizeDelta
|
||||
local nWidth = self.progressBarWidth * nPercent < self.progressBarMinWidth and self.progressBarMinWidth or self.progressBarWidth * nPercent
|
||||
self._mapNode.rectImgFavourBar.sizeDelta = Vector2(nWidth, sizeDelta.y)
|
||||
end
|
||||
function CharacterFavourCtrl:ResetData()
|
||||
self._mapNode.transFavourBarCenter.localEulerAngles = Vector3(0, 0, 0)
|
||||
end
|
||||
function CharacterFavourCtrl:OnEvent_AffinityChange(charId, curLevel, lastFavourLevel, curExp, lastExp)
|
||||
if self._panel.nPanelId == PanelId.CharacterRelation then
|
||||
self:Refresh(self.curCharId)
|
||||
if lastFavourLevel < curLevel and charId == self.curCharId then
|
||||
EventManager.Hit(EventId.OpenPanel, PanelId.CharFavourLevelUp, charId, curLevel, lastFavourLevel, curExp, lastExp)
|
||||
end
|
||||
end
|
||||
end
|
||||
return CharacterFavourCtrl
|
||||
@@ -0,0 +1,82 @@
|
||||
local BaseCtrl = require("GameCore.UI.BaseCtrl")
|
||||
local CharFavourExpUpCtrl = class("CharFavourExpUpCtrl", BaseCtrl)
|
||||
CharFavourExpUpCtrl._mapNodeConfig = {
|
||||
loopExpUpRoot = {
|
||||
sNodeName = "ExpUpRoot",
|
||||
sComponentName = "LoopScrollView"
|
||||
}
|
||||
}
|
||||
CharFavourExpUpCtrl._mapEventConfig = {}
|
||||
function CharFavourExpUpCtrl:Awake()
|
||||
local tbParam = self:GetPanelParam()
|
||||
self.charData = tbParam[1]
|
||||
end
|
||||
function CharFavourExpUpCtrl:OnEnable()
|
||||
self.tbLevelUpList = {}
|
||||
self:OnRefresh()
|
||||
end
|
||||
function CharFavourExpUpCtrl:OnRefresh()
|
||||
local count = #self.charData
|
||||
for i = count, 1, -1 do
|
||||
local affinityLevel = PlayerData.Char:GetIsNeedShowAffinityLevelUp(self.charData[i])
|
||||
if affinityLevel < 0 and not PlayerData.Char:GetIsAffinityExpUp(self.charData[i]) then
|
||||
table.remove(self.charData, i)
|
||||
end
|
||||
end
|
||||
self._mapNode.loopExpUpRoot:Init(#self.charData, self, self.OnRefreshGrid)
|
||||
self:AddTimer(1, 0.1, "OpenLevelUpPanel", true, true, true)
|
||||
end
|
||||
function CharFavourExpUpCtrl:OnRefreshGrid(goGrid, gridIndex)
|
||||
local index = gridIndex + 1
|
||||
local data = self.charData[index]
|
||||
local rootTrans = goGrid.transform:Find("Root")
|
||||
local animRoot = rootTrans:GetComponent("Animator")
|
||||
local imgHead = rootTrans:Find("imgHead"):GetComponent("Image")
|
||||
local txtFavourLevel = rootTrans:Find("imgHead/txtFavourLevel"):GetComponent("TMP_Text")
|
||||
local txtName = rootTrans:Find("txtName"):GetComponent("TMP_Text")
|
||||
local imgHeart = rootTrans:Find("imgHead/imgHeart"):GetComponent("Image")
|
||||
local nSkinId = PlayerData.Char:GetCharSkinId(data)
|
||||
local mapCfgData_Skin = ConfigTable.GetData_CharacterSkin(nSkinId)
|
||||
self:SetPngSprite(imgHead, mapCfgData_Skin.Icon .. AllEnum.CharHeadIconSurfix.L)
|
||||
local mapData = PlayerData.Char:GetCharAffinityData(data)
|
||||
local level = 0
|
||||
local exp = 0
|
||||
if mapData ~= nil then
|
||||
level = mapData.Level
|
||||
exp = mapData.Exp
|
||||
end
|
||||
NovaAPI.SetTMPText(txtFavourLevel, level)
|
||||
local mapCharCfg = ConfigTable.GetData_Character(data)
|
||||
NovaAPI.SetTMPText(txtName, mapCharCfg.Name)
|
||||
local mapAffinity = {}
|
||||
local templateId = ConfigTable.GetData("CharAffinityTemplate", data).TemplateId
|
||||
local forEachAffinityLevel = function(mapData)
|
||||
if mapData.TemplateId == templateId and mapData.AffinityLevel == level then
|
||||
mapAffinity = mapData
|
||||
end
|
||||
end
|
||||
ForEachTableLine(DataTable.AffinityLevel, forEachAffinityLevel)
|
||||
if mapAffinity.AffinityLevelIcon ~= "" then
|
||||
self:SetPngSprite(imgHeart, mapAffinity.AffinityLevelIcon)
|
||||
end
|
||||
local affinityLevel, affinityExp = PlayerData.Char:GetIsNeedShowAffinityLevelUp(data)
|
||||
if 0 <= affinityLevel then
|
||||
table.insert(self.tbLevelUpList, {
|
||||
charID = data,
|
||||
curLevel = level,
|
||||
lastLevel = affinityLevel,
|
||||
curExp = exp,
|
||||
lastExp = affinityExp
|
||||
})
|
||||
end
|
||||
self:AddTimer(1, 0.8, function()
|
||||
animRoot:SetTrigger("out")
|
||||
end, true, true, true)
|
||||
end
|
||||
function CharFavourExpUpCtrl:OpenLevelUpPanel()
|
||||
if #self.tbLevelUpList <= 0 then
|
||||
return
|
||||
end
|
||||
EventManager.Hit(EventId.OpenPanel, PanelId.CharFavourLevelUp, self.tbLevelUpList)
|
||||
end
|
||||
return CharFavourExpUpCtrl
|
||||
@@ -0,0 +1,21 @@
|
||||
local BasePanel = require("GameCore.UI.BasePanel")
|
||||
local CharFavourExpUpPanel = class("CharFavourExpUpPanel", BasePanel)
|
||||
CharFavourExpUpPanel._bIsMainPanel = false
|
||||
CharFavourExpUpPanel._sSortingLayerName = AllEnum.SortingLayerName.UI_Top
|
||||
CharFavourExpUpPanel._tbDefine = {
|
||||
{
|
||||
sPrefabPath = "CharacterFavour/CharFavourExpUpPanel.prefab",
|
||||
sCtrlName = "Game.UI.CharacterFavour.CharFavourExpUpCtrl"
|
||||
}
|
||||
}
|
||||
function CharFavourExpUpPanel:Awake()
|
||||
end
|
||||
function CharFavourExpUpPanel:OnEnable()
|
||||
end
|
||||
function CharFavourExpUpPanel:OnDisable()
|
||||
end
|
||||
function CharFavourExpUpPanel:OnDestroy()
|
||||
end
|
||||
function CharFavourExpUpPanel:OnRelease()
|
||||
end
|
||||
return CharFavourExpUpPanel
|
||||
@@ -0,0 +1,542 @@
|
||||
local BaseCtrl = require("GameCore.UI.BaseCtrl")
|
||||
local CharFavourGiftCtrl = class("CharFavourGiftCtrl", BaseCtrl)
|
||||
local Actor2DManager = require("Game.Actor2D.Actor2DManager")
|
||||
local WwiseAudioMgr = CS.WwiseAudioManager.Instance
|
||||
CharFavourGiftCtrl._mapNodeConfig = {
|
||||
loopsvGiftList = {
|
||||
sNodeName = "svGiftList",
|
||||
sComponentName = "LoopScrollView"
|
||||
},
|
||||
goEmpty = {sNodeName = "Empty", sComponentName = "GameObject"},
|
||||
txtGiftCount = {
|
||||
sNodeName = "txtGiftCount",
|
||||
sComponentName = "TMP_Text"
|
||||
},
|
||||
rectPreProgress = {
|
||||
sNodeName = "imgPreProgress",
|
||||
sComponentName = "RectTransform"
|
||||
},
|
||||
rectProgress = {
|
||||
sNodeName = "imgProgress",
|
||||
sComponentName = "RectTransform"
|
||||
},
|
||||
goAffinityInfo = {
|
||||
sNodeName = "goAffinityinfo",
|
||||
sComponentName = "GameObject"
|
||||
},
|
||||
goAffinityChangeInfo = {
|
||||
sNodeName = "goAffinityChangeInfo",
|
||||
sComponentName = "GameObject"
|
||||
},
|
||||
txtDub = {sNodeName = "txtDub", sComponentName = "TMP_Text"},
|
||||
imgCharColor = {
|
||||
sNodeName = "imgCharColor",
|
||||
sComponentName = "Image"
|
||||
},
|
||||
imgRareName = {
|
||||
sNodeName = "imgRareName",
|
||||
sComponentName = "Image"
|
||||
},
|
||||
txtName = {sNodeName = "txtName", sComponentName = "TMP_Text"},
|
||||
safeAreaRoot = {
|
||||
sNodeName = "----SafeAreaRoot----",
|
||||
sComponentName = "GameObject"
|
||||
},
|
||||
TopBar = {
|
||||
sNodeName = "TopBarPanel",
|
||||
sCtrlName = "Game.UI.TopBarEx.TopBarCtrl"
|
||||
},
|
||||
btnPresent = {
|
||||
sComponentName = "UIButton",
|
||||
callback = "OnBtn_ClickSendGift"
|
||||
},
|
||||
txtProgress = {
|
||||
sNodeName = "txtProgress",
|
||||
sComponentName = "TMP_Text"
|
||||
},
|
||||
goAffinityinfoBefore = {},
|
||||
goAffinityinfoAfter = {},
|
||||
goFavourBubble = {
|
||||
sNodeName = "imgFavourBubble",
|
||||
sComponentName = "GameObject"
|
||||
},
|
||||
txtFavourBubble = {
|
||||
sNodeName = "txtFavourBubble",
|
||||
sComponentName = "TMP_Text"
|
||||
},
|
||||
aniFavour = {
|
||||
sNodeName = "aniFavourRoot",
|
||||
sComponentName = "Animator"
|
||||
},
|
||||
t_common_04 = {}
|
||||
}
|
||||
CharFavourGiftCtrl._mapEventConfig = {
|
||||
[EventId.CharRelatePanelAdvance] = "OnEvent_PanelAdvance",
|
||||
[EventId.CharRelatePanelBack] = "OnEvent_PanelBack",
|
||||
[EventId.UIBackConfirm] = "OnEvent_Back",
|
||||
[EventId.UIHomeConfirm] = "OnEvent_Home",
|
||||
[EventId.AffinityChange] = "OnEvent_AffinityChange",
|
||||
[EventId.ShowBubbleVoiceText] = "OnEvent_ShowBubbleVoiceText",
|
||||
[EventId.IsNewDay] = "OnEvent_NewDay"
|
||||
}
|
||||
function CharFavourGiftCtrl:Awake()
|
||||
self.progressBarWidth = 552
|
||||
self.progressBarMinWidth = 23
|
||||
self.progressFixBarWidth = 159
|
||||
self.L2dAnimInterval = ConfigTable.GetConfigNumber("AffinityL2dPlayInterval")
|
||||
self.tbGridCtrl = {}
|
||||
end
|
||||
function CharFavourGiftCtrl:OnEnable()
|
||||
if self._panel.nPanelId ~= PanelId.CharFavourGift then
|
||||
self._mapNode.safeAreaRoot.gameObject:SetActive(false)
|
||||
else
|
||||
self._mapNode.safeAreaRoot.gameObject:SetActive(true)
|
||||
end
|
||||
end
|
||||
function CharFavourGiftCtrl:OnDisable()
|
||||
if self.tbGridCtrl then
|
||||
for k, v in pairs(self.tbGridCtrl) do
|
||||
self:UnbindCtrlByNode(v)
|
||||
end
|
||||
end
|
||||
self.tbGridCtrl = {}
|
||||
end
|
||||
function CharFavourGiftCtrl:Refresh()
|
||||
self.curChosenItem = nil
|
||||
self.curChosenItemGrid = nil
|
||||
self._mapNode.goAffinityInfo:SetActive(true)
|
||||
self._mapNode.goAffinityChangeInfo:SetActive(false)
|
||||
self._mapNode.rectPreProgress.gameObject:SetActive(false)
|
||||
self.curCharId = self._panel.nCharId
|
||||
local affinityData = PlayerData.Char:GetCharAffinityData(self.curCharId)
|
||||
self.curFavourLevel = affinityData.Level
|
||||
self.curFavourExp = affinityData.Exp
|
||||
self.configData = ConfigTable.GetData_Character(self.curCharId)
|
||||
local mapCharDescCfg = ConfigTable.GetData("CharacterDes", self.curCharId)
|
||||
local sCncv = ""
|
||||
local nCurLanguageIdx = GetLanguageIndex(Settings.sCurrentTxtLanguage)
|
||||
if mapCharDescCfg ~= nil then
|
||||
if nCurLanguageIdx == 1 then
|
||||
sCncv = mapCharDescCfg.CnCv
|
||||
elseif nCurLanguageIdx == 3 then
|
||||
sCncv = mapCharDescCfg.JpCv
|
||||
end
|
||||
end
|
||||
local mapCharDescCfg = ConfigTable.GetData("CharacterDes", self.curCharId)
|
||||
local sColor
|
||||
if mapCharDescCfg ~= nil then
|
||||
sColor = mapCharDescCfg.CharColor
|
||||
else
|
||||
sColor = ""
|
||||
end
|
||||
local _, colorChar = ColorUtility.TryParseHtmlString(sColor)
|
||||
NovaAPI.SetImageColor(self._mapNode.imgCharColor, colorChar)
|
||||
NovaAPI.SetTMPText(self._mapNode.txtName, self.configData.Name)
|
||||
self:SetSprite_FrameColor(self._mapNode.imgRareName, self.configData.Grade, AllEnum.FrameType_New.Text)
|
||||
NovaAPI.SetImageNativeSize(self._mapNode.imgRareName)
|
||||
NovaAPI.SetTMPText(self._mapNode.txtDub, sCncv)
|
||||
local templateId = ConfigTable.GetData("CharAffinityTemplate", self.curCharId).TemplateId
|
||||
self.MaxAffintiyLevel = PlayerData.Char:GetMaxAffinityLevel(templateId)
|
||||
local percent = 0
|
||||
local level = self.curFavourLevel >= self.MaxAffintiyLevel and self.MaxAffintiyLevel or self.curFavourLevel + 1
|
||||
local data = CacheTable.GetData("_AffinityLevel", templateId)[level]
|
||||
if self.curFavourLevel >= self.MaxAffintiyLevel then
|
||||
percent = 1
|
||||
else
|
||||
percent = self.curFavourExp / data.NeedExp
|
||||
end
|
||||
local sizeDelta = self._mapNode.rectProgress.sizeDelta
|
||||
sizeDelta.x = self.progressBarWidth * percent < self.progressBarMinWidth and self.progressBarMinWidth or self.progressBarWidth * percent
|
||||
self._mapNode.rectProgress.sizeDelta = sizeDelta
|
||||
NovaAPI.SetTMPText(self._mapNode.txtProgress, string.format("%d/%d", self.curFavourExp, data.NeedExp))
|
||||
self._mapNode.rectProgress.gameObject:SetActive(self.curFavourExp > 0)
|
||||
local totalCount = ConfigTable.GetConfigValue("AffinityGiftSendCount")
|
||||
local curCount = PlayerData.Base:GetSendGiftCount()
|
||||
NovaAPI.SetTMPText(self._mapNode.txtGiftCount, string.format("今日赠礼次数<color=#0abec5>%d</color>/%s", curCount, totalCount))
|
||||
self.PreferenceData = ConfigTable.GetData("CharacterDes", self.curCharId)
|
||||
self:RefreshAffinityInfo(self._mapNode.goAffinityInfo.transform, self.curFavourLevel)
|
||||
self._mapNode.aniFavour:SetInteger("affinity_lv", CacheTable.GetData("_AffinityLevel", templateId)[self.curFavourLevel].AffinityLevelStage)
|
||||
self:RefreshItemList()
|
||||
end
|
||||
function CharFavourGiftCtrl:RefreshAffinityInfo(goAffinity, nAffinityLevel)
|
||||
local templateId = ConfigTable.GetData("CharAffinityTemplate", self.curCharId).TemplateId
|
||||
local mapAffinity = CacheTable.GetData("_AffinityLevel", templateId)[nAffinityLevel]
|
||||
if mapAffinity == nil then
|
||||
return
|
||||
end
|
||||
local imgHeart = goAffinity:Find("imgHeart"):GetComponent("Image")
|
||||
local txtLevel = goAffinity:Find("txtLevel"):GetComponent("TMP_Text")
|
||||
local txtBubble = goAffinity:Find("txtBubble"):GetComponent("TMP_Text")
|
||||
self:SetPngSprite(imgHeart, mapAffinity.AffinityLevelIcon)
|
||||
NovaAPI.SetTMPText(txtLevel, nAffinityLevel .. ConfigTable.GetUIText("Advance_Level_Name"))
|
||||
NovaAPI.SetTMPText(txtBubble, mapAffinity.AffinityLevelName)
|
||||
end
|
||||
function CharFavourGiftCtrl:RefreshItemList()
|
||||
self.tbItemData = {}
|
||||
local listCount = 0
|
||||
local foreachAffinityGift = function(mapData)
|
||||
local count = PlayerData.Item:GetItemCountByID(mapData.Id)
|
||||
if 0 < count then
|
||||
listCount = listCount + 1
|
||||
local itemData = ConfigTable.GetData_Item(mapData.Id)
|
||||
table.insert(self.tbItemData, {
|
||||
nTid = itemData.Id,
|
||||
nRarity = itemData.Rarity,
|
||||
nCount = count,
|
||||
nExpire = itemData.ExpireType,
|
||||
favourLevel = self:GetGiftFavourLevel(itemData.Id)
|
||||
})
|
||||
end
|
||||
end
|
||||
ForEachTableLine(DataTable.AffinityGift, foreachAffinityGift)
|
||||
self._mapNode.goEmpty:SetActive(listCount == 0)
|
||||
self._mapNode.t_common_04:SetActive(0 < listCount)
|
||||
self._mapNode.loopsvGiftList.gameObject:SetActive(0 < listCount)
|
||||
if 0 < listCount then
|
||||
table.sort(self.tbItemData, function(a, b)
|
||||
if a.favourLevel == b.favourLevel then
|
||||
if a.nRarity == b.nRarity then
|
||||
return a.nTid < b.nTid
|
||||
end
|
||||
return a.nRarity < b.nRarity
|
||||
end
|
||||
return a.favourLevel < b.favourLevel
|
||||
end)
|
||||
self._mapNode.loopsvGiftList:Init(listCount, self, self.RefreshItemGrid, self.OnBtn_ClickItemGrid)
|
||||
end
|
||||
end
|
||||
function CharFavourGiftCtrl:RefreshItemGrid(grid)
|
||||
local nIndex = tonumber(grid.name) + 1
|
||||
local mapItem = self.tbItemData[nIndex]
|
||||
local nInstanceID = grid:GetInstanceID()
|
||||
if not self.tbGridCtrl[nInstanceID] then
|
||||
local itemObj = grid.transform:Find("btnGrid/AnimRoot/tc_item_02")
|
||||
self.tbGridCtrl[nInstanceID] = self:BindCtrlByNode(itemObj, "Game.UI.TemplateEx.TemplateItemCtrl")
|
||||
end
|
||||
self.tbGridCtrl[nInstanceID]:SetItem(mapItem.nTid, mapItem.nRarity, mapItem.nCount, mapItem.nExpire)
|
||||
local imgAffinityLevel = grid.transform:Find("btnGrid/AnimRoot/tc_item_02/imgAffinityGiftLevel"):GetComponent("Image")
|
||||
local level = mapItem.favourLevel
|
||||
self:SetAtlasSprite(imgAffinityLevel, "11_ico", "zs_present_heart_" .. level)
|
||||
if self.lastChosenItem ~= nil and self.lastChosenItem == mapItem.nTid then
|
||||
self:OnBtn_ClickItemGrid(grid)
|
||||
self.lastChosenItem = nil
|
||||
end
|
||||
end
|
||||
function CharFavourGiftCtrl:GetGiftFavourLevel(itemId)
|
||||
if self.PreferenceData == nil then
|
||||
return 2
|
||||
end
|
||||
local itemData = ConfigTable.GetData("AffinityGift", itemId)
|
||||
for k, v in ipairs(itemData.Tags) do
|
||||
for k1, v1 in ipairs(self.PreferenceData.PreferTags) do
|
||||
if v == v1 then
|
||||
return 1
|
||||
end
|
||||
end
|
||||
end
|
||||
for k, v in ipairs(itemData.Tags) do
|
||||
for k1, v1 in ipairs(self.PreferenceData.HateTags) do
|
||||
if v == v1 then
|
||||
return 3
|
||||
end
|
||||
end
|
||||
end
|
||||
return 2
|
||||
end
|
||||
function CharFavourGiftCtrl:GetGiftFeedbackLevel(itemId)
|
||||
local level = self:GetGiftFavourLevel(itemId)
|
||||
if 1 < level then
|
||||
return 3
|
||||
end
|
||||
local itemData = ConfigTable.GetData_Item(itemId)
|
||||
if itemData.Rarity == GameEnum.itemRarity.SSR then
|
||||
return 1
|
||||
else
|
||||
return 2
|
||||
end
|
||||
end
|
||||
function CharFavourGiftCtrl:OnItemChosen()
|
||||
local templateId = ConfigTable.GetData("CharAffinityTemplate", self.curCharId).TemplateId
|
||||
if self.curChosenItem == nil then
|
||||
self._mapNode.goAffinityChangeInfo:SetActive(false)
|
||||
self._mapNode.goAffinityInfo:SetActive(true)
|
||||
self._mapNode.rectPreProgress.gameObject:SetActive(false)
|
||||
self._mapNode.rectProgress.gameObject:SetActive(self.curFavourExp > 0)
|
||||
self:RefreshAffinityInfo(self._mapNode.goAffinityInfo.transform, self.curFavourLevel)
|
||||
local data = CacheTable.GetData("_AffinityLevel", templateId)[self.curFavourLevel + 1 > self.MaxAffintiyLevel and self.MaxAffintiyLevel or self.curFavourLevel + 1]
|
||||
NovaAPI.SetTMPText(self._mapNode.txtProgress, string.format("%d/%d", self.curFavourExp, data.NeedExp))
|
||||
self._mapNode.aniFavour:SetInteger("affinity_lv", CacheTable.GetData("_AffinityLevel", templateId)[self.curFavourLevel].AffinityLevelStage)
|
||||
return
|
||||
end
|
||||
local addedExp = 0
|
||||
local data = ConfigTable.GetData("AffinityGift", self.curChosenItem)
|
||||
local level = self:GetGiftFavourLevel(self.curChosenItem)
|
||||
local AffinityGiftPreferenceProp = ConfigTable.GetConfigNumberArray("AffinityGiftPreferenceProp")
|
||||
addedExp = data.BaseAffinity * (AffinityGiftPreferenceProp[level] / 100 + 1)
|
||||
local addedLevel = self.curFavourLevel
|
||||
if 0 < addedExp then
|
||||
local Exp = addedExp
|
||||
self:RefreshAffinityInfo(self._mapNode.goAffinityinfoBefore.transform, self.curFavourLevel)
|
||||
while 0 < Exp and not (addedLevel >= self.MaxAffintiyLevel) do
|
||||
local needExp = CacheTable.GetData("_AffinityLevel", templateId)[addedLevel + 1].NeedExp
|
||||
if addedLevel == self.curFavourLevel then
|
||||
needExp = needExp - self.curFavourExp
|
||||
end
|
||||
Exp = Exp - needExp
|
||||
if 0 < Exp then
|
||||
addedLevel = addedLevel + 1
|
||||
if addedLevel >= self.MaxAffintiyLevel then
|
||||
Exp = CacheTable.GetData("_AffinityLevel", templateId)[self.MaxAffintiyLevel].NeedExp
|
||||
break
|
||||
end
|
||||
else
|
||||
Exp = Exp + needExp
|
||||
break
|
||||
end
|
||||
end
|
||||
self:RefreshAffinityInfo(self._mapNode.goAffinityinfoAfter.transform, addedLevel)
|
||||
local sizeDelta = self._mapNode.rectPreProgress.sizeDelta
|
||||
local percent = 0
|
||||
if addedLevel > self.curFavourLevel then
|
||||
self._mapNode.rectProgress.gameObject:SetActive(false)
|
||||
percent = Exp / CacheTable.GetData("_AffinityLevel", templateId)[addedLevel + 1 > self.MaxAffintiyLevel and self.MaxAffintiyLevel or addedLevel + 1].NeedExp
|
||||
else
|
||||
self._mapNode.rectProgress.gameObject:SetActive(true)
|
||||
percent = (self.curFavourExp + addedExp) / CacheTable.GetData("_AffinityLevel", templateId)[addedLevel + 1 > self.MaxAffintiyLevel and self.MaxAffintiyLevel or addedLevel + 1].NeedExp
|
||||
end
|
||||
if 1 <= percent then
|
||||
percent = 1
|
||||
end
|
||||
sizeDelta.x = self.progressBarWidth * percent
|
||||
self._mapNode.rectPreProgress.sizeDelta = sizeDelta
|
||||
NovaAPI.SetTMPText(self._mapNode.txtProgress, string.format("%d/%d", self.curFavourExp + addedExp, CacheTable.GetData("_AffinityLevel", templateId)[addedLevel + 1 > self.MaxAffintiyLevel and self.MaxAffintiyLevel or addedLevel + 1].NeedExp))
|
||||
end
|
||||
self._mapNode.goAffinityInfo:SetActive(addedLevel == self.curFavourLevel)
|
||||
if addedLevel == self.curFavourLevel then
|
||||
self._mapNode.aniFavour:SetInteger("affinity_lv", CacheTable.GetData("_AffinityLevel", templateId)[self.curFavourLevel].AffinityLevelStage)
|
||||
end
|
||||
self._mapNode.rectPreProgress.gameObject:SetActive(0 < addedExp)
|
||||
self._mapNode.goAffinityChangeInfo:SetActive(addedLevel > self.curFavourLevel)
|
||||
end
|
||||
function CharFavourGiftCtrl:PlayCharAnim(level)
|
||||
if self.PreferenceData == nil or self.bPlayCharAnim then
|
||||
return
|
||||
end
|
||||
local bPlay = true
|
||||
if self.nLastFavourLevel ~= nil and self.nCurLevel ~= nil then
|
||||
bPlay = PlayerData.Voice:CheckPlayGiftVoice(self.nCurLevel, self.nLastFavourLevel)
|
||||
end
|
||||
if not bPlay then
|
||||
return
|
||||
end
|
||||
local mapData
|
||||
if level == 1 then
|
||||
mapData = "thankEx"
|
||||
elseif level == 2 then
|
||||
mapData = "thank"
|
||||
elseif level == 3 then
|
||||
mapData = "thankSmall"
|
||||
end
|
||||
if mapData == nil or #mapData == 0 then
|
||||
return
|
||||
end
|
||||
local nIndex = math.random(1, #mapData)
|
||||
local sVoKey = mapData[nIndex]
|
||||
if sVoKey ~= "" then
|
||||
self.charVoiceTimer = self:AddTimer(1, tonumber(self.L2dAnimInterval), "ResetPlayCharAnimState", true, true, true)
|
||||
local key = PlayerData.Voice:PlayCharVoice(sVoKey, self.curCharId)
|
||||
local data = ConfigTable.GetData("VoDirectory", key)
|
||||
if data ~= nil then
|
||||
EventManager.Hit("PlayCharL2DAnim", data.motion, false, true)
|
||||
end
|
||||
self.bPlayCharAnim = true
|
||||
end
|
||||
end
|
||||
function CharFavourGiftCtrl:ResetPlayCharAnimState()
|
||||
self.bPlayCharAnim = false
|
||||
self._mapNode.goFavourBubble:SetActive(false)
|
||||
end
|
||||
function CharFavourGiftCtrl:PlayProgressAnim(mapBefore, mapAfter, callback)
|
||||
local bMaxLv = mapAfter.nLevel == mapAfter.nMaxLevel
|
||||
local nAddLevel = mapAfter.nLevel - mapBefore.nLevel
|
||||
local nAddCount = 0
|
||||
if nAddLevel == 0 then
|
||||
nAddCount = 1
|
||||
elseif 0 < mapAfter.nExp then
|
||||
nAddCount = nAddLevel + 1
|
||||
else
|
||||
nAddCount = nAddLevel
|
||||
end
|
||||
local nAniTime = 0.2
|
||||
if nAddCount < 6 then
|
||||
nAniTime = 0.2
|
||||
elseif 6 <= nAddCount then
|
||||
nAniTime = 0.1
|
||||
end
|
||||
local nBeforeToMaxTime = nAniTime * (1 - mapBefore.nExp / mapBefore.nMaxExp)
|
||||
local nBeforeToAfterTime = nAniTime * ((mapAfter.nExp - mapBefore.nExp) / mapAfter.nMaxExp)
|
||||
local nZeroToAfterTime = nAniTime * mapAfter.nExp / mapAfter.nMaxExp
|
||||
local nAllTime = 0
|
||||
local heigth = self._mapNode.rectPreProgress.sizeDelta.y
|
||||
local sequence = DOTween.Sequence()
|
||||
for i = 1, nAddCount - 1 do
|
||||
local nTime = i == 1 and nBeforeToMaxTime or nAniTime
|
||||
nAllTime = nAllTime + nTime
|
||||
sequence:AppendCallback(function()
|
||||
WwiseAudioMgr:PlaySound("ui_common_levelUp")
|
||||
end)
|
||||
sequence:Append(self._mapNode.rectProgress:DOSizeDelta(Vector2(self.progressBarWidth, heigth), nTime))
|
||||
sequence:AppendCallback(function()
|
||||
self._mapNode.rectProgress.sizeDelta = Vector2(0, heigth)
|
||||
end)
|
||||
end
|
||||
if bMaxLv then
|
||||
local nTime = 1 < nAddCount and nAniTime or nBeforeToMaxTime
|
||||
nAllTime = nAllTime + nTime
|
||||
sequence:AppendCallback(function()
|
||||
WwiseAudioMgr:PlaySound("ui_common_levelUp")
|
||||
end)
|
||||
sequence:Append(self._mapNode.rectProgress:DOSizeDelta(Vector2(self.progressBarWidth, heigth), nTime))
|
||||
elseif mapAfter.nExp > 0 then
|
||||
local nTime = 1 < nAddCount and nZeroToAfterTime or nBeforeToAfterTime
|
||||
nAllTime = nAllTime + nTime
|
||||
sequence:AppendCallback(function()
|
||||
WwiseAudioMgr:PlaySound("ui_common_levelUp")
|
||||
end)
|
||||
local width = self.progressBarWidth * mapAfter.nExp / mapAfter.nMaxExp
|
||||
sequence:Append(self._mapNode.rectProgress:DOSizeDelta(Vector2(width, heigth), nTime))
|
||||
elseif mapAfter.nExp == 0 then
|
||||
local nTime = 1 < nAddCount and nAniTime or nBeforeToMaxTime
|
||||
nAllTime = nAllTime + nTime
|
||||
sequence:AppendCallback(function()
|
||||
WwiseAudioMgr:PlaySound("ui_common_levelUp")
|
||||
end)
|
||||
sequence:Append(self._mapNode.rectProgress:DOSizeDelta(Vector2(self.progressBarWidth, heigth), nTime))
|
||||
sequence:AppendCallback(function()
|
||||
self._mapNode.rectProgress.sizeDelta = Vector2(0, heigth)
|
||||
end)
|
||||
end
|
||||
sequence:SetUpdate(true)
|
||||
nAllTime = nAllTime + 0.2
|
||||
EventManager.Hit(EventId.TemporaryBlockInput, nAllTime)
|
||||
self:AddTimer(1, nAllTime, callback, true, true, true)
|
||||
end
|
||||
function CharFavourGiftCtrl:OnBtn_ClickSendGift()
|
||||
if self.curChosenItem == nil then
|
||||
return
|
||||
end
|
||||
local totalCount = ConfigTable.GetConfigNumber("AffinityGiftSendCount")
|
||||
local sendCount = PlayerData.Base:GetSendGiftCount()
|
||||
if sendCount >= tonumber(totalCount) then
|
||||
local tips = orderedFormat(ConfigTable.GetUIText("SendGift_Count_Limit"), sendCount)
|
||||
EventManager.Hit(EventId.OpenMessageBox, tips)
|
||||
return
|
||||
end
|
||||
local itemId = self.curChosenItem
|
||||
local mapMsg = {
|
||||
CharId = self.curCharId,
|
||||
GiftId = itemId
|
||||
}
|
||||
local successCallback = function(_, mapMainData)
|
||||
local level = self:GetGiftFeedbackLevel(itemId)
|
||||
self:PlayCharAnim(level)
|
||||
if mapMainData ~= nil then
|
||||
NovaAPI.SetTMPText(self._mapNode.txtGiftCount, string.format("今日赠礼次数<color=#0abec5>%d</color>/%s", mapMainData.SendGiftCnt, totalCount))
|
||||
end
|
||||
end
|
||||
HttpNetHandler.SendMsg(NetMsgId.Id.char_affinity_gift_send_req, mapMsg, nil, successCallback)
|
||||
end
|
||||
function CharFavourGiftCtrl:OnBtn_ClickItemGrid(grid)
|
||||
local nInstanceID = grid:GetInstanceID()
|
||||
if not self.tbGridCtrl[nInstanceID] then
|
||||
return
|
||||
end
|
||||
local nIndex = tonumber(grid.name) + 1
|
||||
local mapItem = self.tbItemData[nIndex]
|
||||
local itemCtrl = self.tbGridCtrl[nInstanceID]
|
||||
if self.curChosenItem ~= nil and self.curChosenItem == mapItem.nTid then
|
||||
itemCtrl:SetMultiSelected_Blue(false)
|
||||
self.curChosenItem = nil
|
||||
self.curChosenItemGrid = nil
|
||||
else
|
||||
self.curChosenItem = mapItem.nTid
|
||||
itemCtrl:SetMultiSelected_Blue(true)
|
||||
if self.curChosenItemGrid ~= nil then
|
||||
self.curChosenItemGrid:SetMultiSelected_Blue(false)
|
||||
end
|
||||
self.curChosenItemGrid = itemCtrl
|
||||
end
|
||||
self:OnItemChosen()
|
||||
end
|
||||
function CharFavourGiftCtrl:OnEvent_PanelAdvance(nClosePanelId, nOpenPanelId)
|
||||
self:PlaySwitchAnim(nClosePanelId, nOpenPanelId)
|
||||
end
|
||||
function CharFavourGiftCtrl:OnEvent_PanelBack(nClosePanelId, nOpenPanelId)
|
||||
self:PlaySwitchAnim(nClosePanelId, nOpenPanelId)
|
||||
end
|
||||
function CharFavourGiftCtrl:OnEvent_Back(nPanelId)
|
||||
if self._panel._nPanelId == nPanelId and self._panel.nPanelId == PanelId.CharFavourGift then
|
||||
EventManager.Hit(EventId.CharRelatePanelClose)
|
||||
PlayerData.Voice:StopCharVoice()
|
||||
EventManager.Hit("PlayCharL2DAnim", "idle", true, true)
|
||||
EventManager.Hit(EventId.CharRelatePanelOpen, PanelId.CharacterRelation, self.curCharId)
|
||||
end
|
||||
end
|
||||
function CharFavourGiftCtrl:OnEvent_Home(nPanelId)
|
||||
if self._panel == nil or self._panel._nPanelId ~= nPanelId or self._panel.nPanelId ~= PanelId.CharFavourGift then
|
||||
return
|
||||
end
|
||||
PanelManager.Home()
|
||||
end
|
||||
function CharFavourGiftCtrl:OnEvent_AffinityChange(charId, curLevel, lastFavourLevel, curExp, lastExp)
|
||||
if self._panel.nPanelId ~= PanelId.CharFavourGift then
|
||||
return
|
||||
end
|
||||
self.lastChosenItem = self.curChosenItem
|
||||
local laseExp = self.curFavourExp
|
||||
local affinityData = PlayerData.Char:GetCharAffinityData(self.curCharId)
|
||||
self.curFavourExp = affinityData.Exp
|
||||
self.nLastFavourLevel = lastFavourLevel
|
||||
self.nCurLevel = curLevel
|
||||
local templateId = ConfigTable.GetData("CharAffinityTemplate", self.curCharId).TemplateId
|
||||
local mapLevelBefore = {
|
||||
nLevel = lastFavourLevel,
|
||||
nMaxLevel = self.MaxAffintiyLevel,
|
||||
nExp = laseExp,
|
||||
nMaxExp = CacheTable.GetData("_AffinityLevel", templateId)[lastFavourLevel + 1 > self.MaxAffintiyLevel and self.MaxAffintiyLevel or lastFavourLevel + 1].NeedExp
|
||||
}
|
||||
local mapLevelAfter = {
|
||||
nLevel = curLevel,
|
||||
nMaxLevel = self.MaxAffintiyLevel,
|
||||
nExp = self.curFavourExp,
|
||||
nMaxExp = CacheTable.GetData("_AffinityLevel", templateId)[curLevel + 1 > self.MaxAffintiyLevel and self.MaxAffintiyLevel or curLevel + 1].NeedExp
|
||||
}
|
||||
local callback = function()
|
||||
self:Refresh()
|
||||
if curLevel > lastFavourLevel then
|
||||
EventManager.Hit(EventId.OpenPanel, PanelId.CharFavourLevelUp, charId, curLevel, lastFavourLevel, curExp, lastExp)
|
||||
end
|
||||
end
|
||||
self._mapNode.rectProgress.gameObject:SetActive(true)
|
||||
self._mapNode.rectPreProgress.gameObject:SetActive(false)
|
||||
self:PlayProgressAnim(mapLevelBefore, mapLevelAfter, callback)
|
||||
end
|
||||
function CharFavourGiftCtrl:OnEvent_ShowBubbleVoiceText(nCharId, nId)
|
||||
end
|
||||
function CharFavourGiftCtrl:OnEvent_NewDay()
|
||||
local totalCount = ConfigTable.GetConfigValue("AffinityGiftSendCount")
|
||||
local curCount = 0
|
||||
NovaAPI.SetTMPText(self._mapNode.txtGiftCount, string.format("今日赠礼次数<color=#0abec5>%d</color>/%s", curCount, totalCount))
|
||||
end
|
||||
function CharFavourGiftCtrl:PlaySwitchAnim(nClosePanelId, nOpenPanelId)
|
||||
if nClosePanelId == PanelId.CharFavourGift then
|
||||
self._mapNode.safeAreaRoot.gameObject:SetActive(false)
|
||||
EventManager.Hit("ChangeCharFgTab", true)
|
||||
end
|
||||
if nOpenPanelId == PanelId.CharFavourGift then
|
||||
self._mapNode.safeAreaRoot.gameObject:SetActive(true)
|
||||
self:Refresh()
|
||||
EventManager.Hit("ChangeCharFgTab", false)
|
||||
end
|
||||
end
|
||||
return CharFavourGiftCtrl
|
||||
@@ -0,0 +1,19 @@
|
||||
local BasePanel = require("GameCore.UI.BasePanel")
|
||||
local CharFavourGiftPanel = class("CharFavourGiftPanel", BasePanel)
|
||||
CharFavourGiftPanel._tbDefine = {
|
||||
{
|
||||
sPrefabPath = "CharacterFavour/CharFavourGiftPanel.prefab",
|
||||
sCtrlName = "Game.UI.CharacterFavour.CharFavourGiftCtrl"
|
||||
}
|
||||
}
|
||||
function CharFavourGiftPanel:Awake()
|
||||
end
|
||||
function CharFavourGiftPanel:OnEnable()
|
||||
end
|
||||
function CharFavourGiftPanel:OnDisable()
|
||||
end
|
||||
function CharFavourGiftPanel:OnDestroy()
|
||||
end
|
||||
function CharFavourGiftPanel:OnRelease()
|
||||
end
|
||||
return CharFavourGiftPanel
|
||||
@@ -0,0 +1,469 @@
|
||||
local BaseCtrl = require("GameCore.UI.BaseCtrl")
|
||||
local CharFavourLevelUpCtrl = class("CharFavourLevelUpCtrl", BaseCtrl)
|
||||
local Actor2DManager = require("Game.Actor2D.Actor2DManager")
|
||||
local WwiseAudioMgr = CS.WwiseAudioManager.Instance
|
||||
local GridHeight = 51
|
||||
local LayoutRebuilder = CS.UnityEngine.UI.LayoutRebuilder
|
||||
CharFavourLevelUpCtrl._mapNodeConfig = {
|
||||
trActor2D_PNG = {
|
||||
sNodeName = "----Actor2D_PNG----",
|
||||
sComponentName = "Transform"
|
||||
},
|
||||
aniActor2D_PNG = {
|
||||
sNodeName = "----Actor2D_PNG----",
|
||||
sComponentName = "Animator"
|
||||
},
|
||||
got_fullscreen_blur_black = {
|
||||
sNodeName = "t_fullscreen_blur_black",
|
||||
sComponentName = "GameObject"
|
||||
},
|
||||
btnsnapshot = {
|
||||
sNodeName = "snapshot",
|
||||
sComponentName = "Button",
|
||||
callback = "OnBtn_ClickClose"
|
||||
},
|
||||
rtBg = {
|
||||
sNodeName = "goBg",
|
||||
sComponentName = "RectTransform"
|
||||
},
|
||||
goLevelUp = {},
|
||||
loopAdPre = {
|
||||
sNodeName = "AdPre",
|
||||
sComponentName = "LoopScrollView"
|
||||
},
|
||||
affinityLevel = {
|
||||
sCtrlName = "Game.UI.TemplateEx.TemplateAffinityLevelCtrl"
|
||||
},
|
||||
affinityLevelBefore = {
|
||||
sCtrlName = "Game.UI.TemplateEx.TemplateAffinityLevelCtrl"
|
||||
},
|
||||
trContent = {
|
||||
sNodeName = "--Content--",
|
||||
sComponentName = "RectTransform"
|
||||
},
|
||||
btnSkipAnim = {
|
||||
sNodeName = "btnSkipAnim",
|
||||
sComponentName = "UIButton",
|
||||
callback = "OnBtn_SkipAnim"
|
||||
},
|
||||
aniSafeRoot = {
|
||||
sNodeName = "----SafeRoot----",
|
||||
sComponentName = "Animator"
|
||||
},
|
||||
goSafeRoot = {
|
||||
sNodeName = "----SafeRoot----",
|
||||
sComponentName = "GameObject"
|
||||
},
|
||||
goNormal = {},
|
||||
affinityLevelNormal = {
|
||||
sCtrlName = "Game.UI.TemplateEx.TemplateAffinityLevelCtrl"
|
||||
},
|
||||
rectProgress = {
|
||||
sNodeName = "imgProgress",
|
||||
sComponentName = "RectTransform"
|
||||
},
|
||||
rectPreProgress = {
|
||||
sNodeName = "imgPreProgress",
|
||||
sComponentName = "RectTransform"
|
||||
},
|
||||
txtProgress = {
|
||||
sNodeName = "txtProgress",
|
||||
sComponentName = "TMP_Text"
|
||||
},
|
||||
txtCalHeight = {nCount = 2, sComponentName = "TMP_Text"},
|
||||
rtCalHeight = {
|
||||
nCount = 2,
|
||||
sNodeName = "txtCalHeight",
|
||||
sComponentName = "RectTransform"
|
||||
}
|
||||
}
|
||||
CharFavourLevelUpCtrl._mapEventConfig = {}
|
||||
function CharFavourLevelUpCtrl:Awake()
|
||||
local tbParam = self:GetPanelParam()
|
||||
if type(tbParam[1]) == "table" then
|
||||
self.tbLevelUpList = tbParam[1]
|
||||
else
|
||||
self.curCharId = tbParam[1]
|
||||
self.curFavourLevel = tbParam[2]
|
||||
self.lastFavourLevel = tbParam[3]
|
||||
self.curExp = tbParam[4]
|
||||
self.lastExp = tbParam[5]
|
||||
if tbParam[6] ~= nil then
|
||||
self.CloseCallBack = tbParam[6]
|
||||
end
|
||||
end
|
||||
EventManager.Hit(EventId.HideCharBgActor)
|
||||
self.progressBarWidth = 552
|
||||
self.progressBarMinWidth = 0
|
||||
self._mapNode.goLevelUp.gameObject:SetActive(false)
|
||||
self._mapNode.goNormal.gameObject:SetActive(false)
|
||||
self._mapNode.rectPreProgress.sizeDelta = Vector2(0, self._mapNode.rectPreProgress.sizeDelta.y)
|
||||
end
|
||||
function CharFavourLevelUpCtrl:OnEnable()
|
||||
self._mapNode.got_fullscreen_blur_black:SetActive(true)
|
||||
self:RefreshPanel()
|
||||
if self.lastFavourLevel < self.curFavourLevel then
|
||||
PlayerData.Voice:PlayCharFavourUpVoice(self.curCharId, self.lastFavourLevel)
|
||||
end
|
||||
end
|
||||
function CharFavourLevelUpCtrl:RefreshPanel()
|
||||
if self.tbLevelUpList ~= nil and #self.tbLevelUpList > 0 then
|
||||
local data = table.remove(self.tbLevelUpList, 1)
|
||||
self.curCharId = data.charID
|
||||
self.curFavourLevel = data.curLevel
|
||||
self.lastFavourLevel = data.lastLevel
|
||||
self.curExp = data.curExp
|
||||
self.lastExp = data.lastExp
|
||||
end
|
||||
self._mapNode.aniSafeRoot.speed = 1
|
||||
self._mapNode.aniActor2D_PNG.speed = 1
|
||||
self._mapNode.goSafeRoot:SetActive(true)
|
||||
CS.WwiseAudioManager.Instance:PostEvent("ui_charInfo_favour_up")
|
||||
local nSkinId = ConfigTable.GetData_Character(self.curCharId).DefaultSkinId
|
||||
self.DefaultHeight = self._mapNode.trContent.sizeDelta.y
|
||||
self._mapNode.aniSafeRoot:Play("CharFavourLevelUpPanel_in")
|
||||
local nAnimLen = NovaAPI.GetAnimClipLength(self._mapNode.aniSafeRoot, {
|
||||
"CharFavourLevelUpPanel_in"
|
||||
})
|
||||
self.delayRefresh = self:AddTimer(1, nAnimLen, "Refresh", true, true, true)
|
||||
PlayerData.Char:ChangeShowAffinityLevelUpState(self.curCharId)
|
||||
local wait = function()
|
||||
coroutine.yield(CS.UnityEngine.WaitForEndOfFrame())
|
||||
Actor2DManager.SetActor2D_PNG(self._mapNode.trActor2D_PNG, self:GetPanelId(), self.curCharId, nSkinId)
|
||||
self._mapNode.aniActor2D_PNG:Play("Actor2D_PNG_CharFavour")
|
||||
end
|
||||
cs_coroutine.start(wait)
|
||||
self.tbAttributeList = {}
|
||||
self.tbRewardList = {}
|
||||
self.tbDescList = {}
|
||||
self.tbAllList = {}
|
||||
local templateId = ConfigTable.GetData("CharAffinityTemplate", self.curCharId).TemplateId
|
||||
local nMaxAffinityLevel = PlayerData.Char:GetMaxAffinityLevel(templateId)
|
||||
self._mapNode.affinityLevelNormal:SetInfo(self.lastFavourLevel)
|
||||
local lastData = CacheTable.GetData("_AffinityLevel", templateId)[nMaxAffinityLevel < self.lastFavourLevel + 1 and nMaxAffinityLevel or self.lastFavourLevel + 1]
|
||||
local nLastPercent
|
||||
if nMaxAffinityLevel <= self.lastFavourLevel then
|
||||
nLastPercent = 1
|
||||
else
|
||||
nLastPercent = self.lastExp / lastData.NeedExp
|
||||
end
|
||||
local sizeDelta = self._mapNode.rectProgress.sizeDelta
|
||||
sizeDelta.x = self.progressBarWidth * nLastPercent < self.progressBarMinWidth and self.progressBarMinWidth or self.progressBarWidth * nLastPercent
|
||||
self._mapNode.rectProgress.sizeDelta = sizeDelta
|
||||
NovaAPI.SetTMPText(self._mapNode.txtProgress, string.format("%d/%d", self.lastExp, lastData.NeedExp))
|
||||
if self.curFavourLevel == self.lastFavourLevel then
|
||||
local preData = CacheTable.GetData("_AffinityLevel", templateId)[nMaxAffinityLevel < self.curFavourLevel + 1 and nMaxAffinityLevel or self.curFavourLevel + 1]
|
||||
local nPrePercent = self.curExp / preData.NeedExp
|
||||
local nWidth = self.progressBarWidth * nPrePercent < self.progressBarMinWidth and self.progressBarMinWidth or self.progressBarWidth * nPrePercent
|
||||
self._mapNode.rectPreProgress.sizeDelta = Vector2(nWidth, sizeDelta.y)
|
||||
else
|
||||
self._mapNode.rectPreProgress.sizeDelta = Vector2(self.progressBarWidth, sizeDelta.y)
|
||||
self:RefreshAllDataList()
|
||||
local count = self:GetAllListCount()
|
||||
if 1 < count then
|
||||
local heightCount = 3 < count and 3 or count
|
||||
self._mapNode.trContent.sizeDelta = Vector2(self._mapNode.trContent.sizeDelta.x, self.DefaultHeight + (heightCount - 1) * GridHeight)
|
||||
end
|
||||
end
|
||||
end
|
||||
function CharFavourLevelUpCtrl:CalTextHeight(sContent, nIndex)
|
||||
NovaAPI.SetTMPText(self._mapNode.txtCalHeight[nIndex], sContent)
|
||||
LayoutRebuilder.ForceRebuildLayoutImmediate(self._mapNode.rtCalHeight[nIndex])
|
||||
return self._mapNode.rtCalHeight[nIndex].rect.height
|
||||
end
|
||||
function CharFavourLevelUpCtrl:Refresh()
|
||||
local templateId = ConfigTable.GetData("CharAffinityTemplate", self.curCharId).TemplateId
|
||||
local nMaxAffinityLevel = PlayerData.Char:GetMaxAffinityLevel(templateId)
|
||||
local nAniTime = 0.2
|
||||
if self.curFavourLevel - self.lastFavourLevel < 6 then
|
||||
nAniTime = 0.2
|
||||
elseif self.curFavourLevel - self.lastFavourLevel >= 6 then
|
||||
nAniTime = 0.1
|
||||
end
|
||||
local nBeforeMaxExp = CacheTable.GetData("_AffinityLevel", templateId)[nMaxAffinityLevel < self.lastFavourLevel + 1 and nMaxAffinityLevel or self.lastFavourLevel + 1].NeedExp
|
||||
local nMaxExp = CacheTable.GetData("_AffinityLevel", templateId)[nMaxAffinityLevel < self.curFavourLevel + 1 and nMaxAffinityLevel or self.curFavourLevel + 1].NeedExp
|
||||
local nBeforeToMaxTime = nAniTime * (1 - self.lastExp / nBeforeMaxExp)
|
||||
local nBeforeToAfterTime = nAniTime * ((self.curExp - self.lastExp) / nMaxExp)
|
||||
local nZeroToAfterTime = nAniTime * self.curExp / nMaxExp
|
||||
local nAddCount = self.curFavourLevel - self.lastFavourLevel
|
||||
local sizeDelta = self._mapNode.rectProgress.sizeDelta
|
||||
local nAllTime = 0
|
||||
local sequence = DOTween.Sequence()
|
||||
for i = self.lastFavourLevel, self.curFavourLevel - 1 do
|
||||
local nTime = i == 1 and nBeforeToMaxTime or nAniTime
|
||||
nAllTime = nAllTime + nTime
|
||||
sequence:AppendCallback(function()
|
||||
WwiseAudioMgr:PlaySound("ui_common_levelUp")
|
||||
end)
|
||||
sequence:Append(self._mapNode.rectProgress:DOSizeDelta(Vector2(self.progressBarWidth, sizeDelta.y), nTime))
|
||||
sequence:AppendCallback(function()
|
||||
local data = CacheTable.GetData("_AffinityLevel", templateId)[i + 1 > nMaxAffinityLevel and nMaxAffinityLevel or i + 1]
|
||||
NovaAPI.SetTMPText(self._mapNode.txtProgress, string.format("%d/%d", data.NeedExp, data.NeedExp))
|
||||
self._mapNode.affinityLevelNormal:SetInfo(i + 1)
|
||||
self._mapNode.rectPreProgress.sizeDelta = Vector2(self.progressBarWidth, sizeDelta.y)
|
||||
self._mapNode.rectProgress.sizeDelta = Vector2(0, sizeDelta.y)
|
||||
end)
|
||||
end
|
||||
sequence:AppendCallback(function()
|
||||
local data = CacheTable.GetData("_AffinityLevel", templateId)[self.curFavourLevel + 1 > nMaxAffinityLevel and nMaxAffinityLevel or self.curFavourLevel + 1]
|
||||
NovaAPI.SetTMPText(self._mapNode.txtProgress, string.format("%d/%d", self.curExp, data.NeedExp))
|
||||
end)
|
||||
if self.curFavourLevel == nMaxAffinityLevel then
|
||||
local nTime = 1 < nAddCount and nAniTime or nBeforeToMaxTime
|
||||
nAllTime = nAllTime + nTime
|
||||
sequence:Append(self._mapNode.rectProgress:DOSizeDelta(Vector2(self.progressBarWidth, sizeDelta.y), nTime))
|
||||
elseif self.curExp > 0 then
|
||||
local nTime = 1 < nAddCount and nZeroToAfterTime or nBeforeToAfterTime
|
||||
nAllTime = nAllTime + nTime
|
||||
sequence:AppendCallback(function()
|
||||
local preData = CacheTable.GetData("_AffinityLevel", templateId)[self.curFavourLevel + 1 > nMaxAffinityLevel and nMaxAffinityLevel or self.curFavourLevel + 1]
|
||||
local nPrePercent = self.curExp / preData.NeedExp
|
||||
local nWidth = self.progressBarWidth * nPrePercent < self.progressBarMinWidth and self.progressBarMinWidth or self.progressBarWidth * nPrePercent
|
||||
self._mapNode.rectPreProgress.sizeDelta = Vector2(nWidth, sizeDelta.y)
|
||||
end)
|
||||
local width = self.progressBarWidth * self.curExp / nMaxExp
|
||||
sequence:Append(self._mapNode.rectProgress:DOSizeDelta(Vector2(width, sizeDelta.y), nTime))
|
||||
elseif self.curExp == 0 then
|
||||
local nTime = 1 < nAddCount and nAniTime or nBeforeToMaxTime
|
||||
nAllTime = nAllTime + nTime
|
||||
self._mapNode.rectPreProgress.sizeDelta = Vector2(0, sizeDelta.y)
|
||||
sequence:Append(self._mapNode.rectProgress:DOSizeDelta(Vector2(self.progressBarWidth, sizeDelta.y), nTime))
|
||||
sequence:AppendCallback(function()
|
||||
self._mapNode.rectProgress.sizeDelta = Vector2(0, sizeDelta.y)
|
||||
end)
|
||||
end
|
||||
sequence:AppendInterval(0.05)
|
||||
sequence:AppendCallback(function()
|
||||
if self.curFavourLevel ~= self.lastFavourLevel then
|
||||
self._mapNode.aniSafeRoot:Play("CharFavourLevelUpPanel_up")
|
||||
end
|
||||
local count = self:GetAllListCount()
|
||||
self._mapNode.loopAdPre.gameObject:SetActive(true)
|
||||
if 0 < count then
|
||||
self.tbGridHeight = {}
|
||||
for _, v in ipairs(self.tbAllList) do
|
||||
local nHeight1, nHeight2 = 0
|
||||
if v.rewardType == "Desc" then
|
||||
nHeight1 = self:CalTextHeight(v.rewardData.sFront, 1)
|
||||
nHeight2 = self:CalTextHeight(v.rewardData.sAfter, 2)
|
||||
elseif v.rewardType == "Attribute" then
|
||||
nHeight1 = self:CalTextHeight(ConfigTable.GetUIText("Attribute_Up"), 1)
|
||||
local descData = ConfigTable.GetData("EffectDesc", v.rewardData[1])
|
||||
local addTxt = FormatEffectValue(v.rewardData[2], descData.isPercent, descData.Format)
|
||||
nHeight2 = self:CalTextHeight(descData.Desc .. " +" .. addTxt, 2)
|
||||
end
|
||||
local nHeight = math.max(nHeight1, nHeight2) + 15
|
||||
table.insert(self.tbGridHeight, nHeight)
|
||||
end
|
||||
self._mapNode.loopAdPre:SetAnim(0.07)
|
||||
self._mapNode.loopAdPre:InitEx(self.tbGridHeight, self, self.RefreshPreAdvanceBuffsGridItem)
|
||||
else
|
||||
self._mapNode.loopAdPre.gameObject:SetActive(false)
|
||||
end
|
||||
self._mapNode.affinityLevel:SetInfo(self.curFavourLevel)
|
||||
self._mapNode.affinityLevelBefore:SetInfo(self.lastFavourLevel)
|
||||
end)
|
||||
sequence:SetUpdate(true)
|
||||
self._mapNode.btnSkipAnim.gameObject:SetActive(false)
|
||||
EventManager.Hit(EventId.TemporaryBlockInput, nAllTime)
|
||||
end
|
||||
function CharFavourLevelUpCtrl:RefreshPreAdvanceBuffsGridItem(go)
|
||||
local index = tonumber(go.name) + 1
|
||||
local data = self:GetGridData(index)
|
||||
go = go.transform:Find("AnimRoot")
|
||||
local goReward = go.transform:Find("goReward")
|
||||
local goDesc = go.transform:Find("goDesc")
|
||||
local imgLine = go.transform:Find("imgLine")
|
||||
imgLine.gameObject:SetActive(1 < index)
|
||||
goReward.gameObject:SetActive(data.rewardType == "Reward")
|
||||
goDesc.gameObject:SetActive(data.rewardType ~= "Reward")
|
||||
if data.rewardType == "Reward" then
|
||||
local goContent = goReward:Find("goTxtContent")
|
||||
local imgRewardIcon = goContent:Find("goImgReward/imgReward"):GetComponent("Image")
|
||||
local item = ConfigTable.GetData_Item(data.rewardData[1])
|
||||
self:SetPngSprite(imgRewardIcon, item.Icon2)
|
||||
local txtReward = goContent:Find("txtReward"):GetComponent("TMP_Text")
|
||||
NovaAPI.SetTMPText(txtReward, data.rewardData[2])
|
||||
else
|
||||
local goImgLock = goDesc:Find("imgLock")
|
||||
local goImgAttribute = goDesc:Find("imgAttribute")
|
||||
goImgLock.gameObject:SetActive(data.rewardType == "Desc")
|
||||
goImgAttribute.gameObject:SetActive(data.rewardType == "Attribute")
|
||||
local txtFront = goDesc:Find("txtFront"):GetComponent("TMP_Text")
|
||||
local txtAfter = goDesc:Find("txtAfter"):GetComponent("TMP_Text")
|
||||
if data.rewardType == "Desc" then
|
||||
NovaAPI.SetTMPText(txtFront, data.rewardData.sFront)
|
||||
NovaAPI.SetTMPText(txtAfter, data.rewardData.sAfter)
|
||||
else
|
||||
NovaAPI.SetTMPText(txtFront, ConfigTable.GetUIText("Attribute_Up"))
|
||||
local descData = ConfigTable.GetData("EffectDesc", data.rewardData[1])
|
||||
local addTxt = FormatEffectValue(data.rewardData[2], descData.isPercent, descData.Format)
|
||||
NovaAPI.SetTMPText(txtAfter, descData.Desc .. " +" .. addTxt)
|
||||
end
|
||||
end
|
||||
end
|
||||
function CharFavourLevelUpCtrl:RefreshAllDataList()
|
||||
local templateId = ConfigTable.GetData("CharAffinityTemplate", self.curCharId).TemplateId
|
||||
local lastEffectData = {}
|
||||
local curEffectData = {}
|
||||
local forEachAffinityLevelReward = function(mapData)
|
||||
if mapData.TemplateId == templateId then
|
||||
if mapData.AffinityLevel == self.lastFavourLevel then
|
||||
lastEffectData = mapData.Effect
|
||||
end
|
||||
if mapData.AffinityLevel == self.curFavourLevel then
|
||||
curEffectData = mapData.Effect
|
||||
end
|
||||
end
|
||||
end
|
||||
ForEachTableLine(DataTable.AffinityLevel, forEachAffinityLevelReward)
|
||||
self:RefreshAttributeList(lastEffectData, curEffectData)
|
||||
local forEachAffinityUpReward = function(mapData)
|
||||
if mapData.CharId == self.curCharId and mapData.RewardLevel > self.lastFavourLevel and mapData.RewardLevel <= self.curFavourLevel then
|
||||
self:RefreshRewardList(mapData)
|
||||
end
|
||||
end
|
||||
ForEachTableLine(DataTable.AffinityUpReward, forEachAffinityUpReward)
|
||||
table.sort(self.tbDescList, function(a, b)
|
||||
if a.nId == b.nId then
|
||||
return a.nIndex < b.nIndex
|
||||
end
|
||||
return a.nId < b.nId
|
||||
end)
|
||||
for k, v in ipairs(self.tbDescList) do
|
||||
table.insert(self.tbAllList, {
|
||||
rewardType = "Desc",
|
||||
rewardData = self.tbDescList[k]
|
||||
})
|
||||
end
|
||||
for k, v in pairs(self.tbAttributeList) do
|
||||
table.insert(self.tbAllList, {
|
||||
rewardType = "Attribute",
|
||||
rewardData = {k, v}
|
||||
})
|
||||
end
|
||||
for k, v in pairs(self.tbRewardList) do
|
||||
table.insert(self.tbAllList, {
|
||||
rewardType = "Reward",
|
||||
rewardData = {k, v}
|
||||
})
|
||||
end
|
||||
end
|
||||
function CharFavourLevelUpCtrl:RefreshRewardList(rewardData)
|
||||
local index = 1
|
||||
while rewardData ~= nil and (rewardData["DescFront" .. index] ~= nil or rewardData["Reward" .. index] ~= nil) do
|
||||
if rewardData["DescFront" .. index] ~= nil and rewardData["DescFront" .. index] ~= "" then
|
||||
table.insert(self.tbDescList, {
|
||||
nId = rewardData.Id,
|
||||
nIndex = index,
|
||||
sFront = rewardData["DescFront" .. index],
|
||||
sAfter = rewardData["DescAfter" .. index]
|
||||
})
|
||||
end
|
||||
index = index + 1
|
||||
end
|
||||
end
|
||||
function CharFavourLevelUpCtrl:GetAllListCount()
|
||||
local count = 0
|
||||
count = count + #self.tbDescList
|
||||
for k, v in pairs(self.tbAttributeList) do
|
||||
count = count + 1
|
||||
end
|
||||
for k, v in pairs(self.tbRewardList) do
|
||||
count = count + 1
|
||||
end
|
||||
return count
|
||||
end
|
||||
function CharFavourLevelUpCtrl:GetGridData(index)
|
||||
local count = 0
|
||||
if index <= #self.tbDescList then
|
||||
return {
|
||||
rewardType = "Desc",
|
||||
rewardData = self.tbDescList[index]
|
||||
}
|
||||
end
|
||||
index = index - #self.tbDescList
|
||||
for k, v in pairs(self.tbAttributeList) do
|
||||
index = index - 1
|
||||
if index == 0 then
|
||||
return {
|
||||
rewardType = "Attribute",
|
||||
rewardData = {k, v}
|
||||
}
|
||||
end
|
||||
end
|
||||
for k, v in pairs(self.tbRewardList) do
|
||||
index = index - 1
|
||||
if index == 0 then
|
||||
return {
|
||||
rewardType = "Reward",
|
||||
rewardData = {k, v}
|
||||
}
|
||||
end
|
||||
end
|
||||
end
|
||||
function CharFavourLevelUpCtrl:RefreshAttributeList(levelDataBefore, levelDataAfter)
|
||||
local tbBeforeValue = {}
|
||||
local tbAfterValue = {}
|
||||
if levelDataBefore ~= nil then
|
||||
for i = 1, #levelDataBefore do
|
||||
local effectData = ConfigTable.GetData("EffectValue", levelDataBefore[i])
|
||||
local descId = self:GetEffectDescId(effectData.EffectTypeFirstSubtype, effectData.EffectTypeSecondSubtype)
|
||||
if tbBeforeValue[descId] ~= nil then
|
||||
tbBeforeValue[descId] = tbBeforeValue[descId] + effectData.EffectTypeParam1
|
||||
else
|
||||
tbBeforeValue[descId] = effectData.EffectTypeParam1
|
||||
end
|
||||
end
|
||||
end
|
||||
if levelDataAfter ~= nil then
|
||||
for i = 1, #levelDataAfter do
|
||||
local effectData = ConfigTable.GetData("EffectValue", levelDataAfter[i])
|
||||
local descId = self:GetEffectDescId(effectData.EffectTypeFirstSubtype, effectData.EffectTypeSecondSubtype)
|
||||
if tbAfterValue[descId] ~= nil then
|
||||
tbAfterValue[descId] = tbAfterValue[descId] + effectData.EffectTypeParam1
|
||||
else
|
||||
tbAfterValue[descId] = effectData.EffectTypeParam1
|
||||
end
|
||||
end
|
||||
end
|
||||
for k, v in pairs(tbAfterValue) do
|
||||
if tbBeforeValue[k] ~= nil then
|
||||
local beforeValue = tonumber(tbBeforeValue[k])
|
||||
local afterValue = tonumber(v)
|
||||
if beforeValue < afterValue then
|
||||
self.tbAttributeList[k] = afterValue - beforeValue
|
||||
end
|
||||
else
|
||||
self.tbAttributeList[k] = v
|
||||
end
|
||||
end
|
||||
end
|
||||
function CharFavourLevelUpCtrl:GetEffectDescId(attributeType, numType)
|
||||
return GameEnum.effectType.ATTR_FIX * 10000 + attributeType * 10 + numType
|
||||
end
|
||||
function CharFavourLevelUpCtrl:OnBtn_SkipAnim()
|
||||
self._mapNode.aniSafeRoot.speed = 1000
|
||||
self._mapNode.aniActor2D_PNG.speed = 1000
|
||||
if self.delayRefresh ~= nil then
|
||||
self.delayRefresh:Cancel()
|
||||
self.delayRefresh = nil
|
||||
end
|
||||
self:Refresh()
|
||||
end
|
||||
function CharFavourLevelUpCtrl:OnBtn_ClickClose()
|
||||
PlayerData.Char:ChangeShowAffinityLevelUpState(self.curCharId)
|
||||
if self.tbLevelUpList ~= nil and #self.tbLevelUpList > 0 then
|
||||
self._mapNode.goSafeRoot:SetActive(false)
|
||||
self._mapNode.loopAdPre.gameObject:SetActive(false)
|
||||
self:RefreshPanel()
|
||||
return
|
||||
end
|
||||
EventManager.Hit(EventId.RevertCharBgActor)
|
||||
if self.CloseCallBack ~= nil then
|
||||
self.CloseCallBack()
|
||||
end
|
||||
EventManager.Hit(EventId.ClosePanel, PanelId.CharFavourLevelUp)
|
||||
PlayerData.Phone:CheckNewChat()
|
||||
end
|
||||
return CharFavourLevelUpCtrl
|
||||
@@ -0,0 +1,21 @@
|
||||
local BasePanel = require("GameCore.UI.BasePanel")
|
||||
local CharFavourLevelUpPanel = class("CharFavourLevelUpPanel", BasePanel)
|
||||
CharFavourLevelUpPanel._bIsMainPanel = false
|
||||
CharFavourLevelUpPanel._sSortingLayerName = AllEnum.SortingLayerName.UI_Top
|
||||
CharFavourLevelUpPanel._tbDefine = {
|
||||
{
|
||||
sPrefabPath = "CharacterFavour/CharFavourLevelUpPanel.prefab",
|
||||
sCtrlName = "Game.UI.CharacterFavour.CharFavourLevelUpCtrl"
|
||||
}
|
||||
}
|
||||
function CharFavourLevelUpPanel:Awake()
|
||||
end
|
||||
function CharFavourLevelUpPanel:OnEnable()
|
||||
end
|
||||
function CharFavourLevelUpPanel:OnDisable()
|
||||
end
|
||||
function CharFavourLevelUpPanel:OnDestroy()
|
||||
end
|
||||
function CharFavourLevelUpPanel:OnRelease()
|
||||
end
|
||||
return CharFavourLevelUpPanel
|
||||
@@ -0,0 +1,461 @@
|
||||
local BaseCtrl = require("GameCore.UI.BaseCtrl")
|
||||
local CharFavourRewardCtrl = class("CharFavourRewardCtrl", BaseCtrl)
|
||||
local GridNormalHeight = 77
|
||||
local AttributeSizeGroup = {
|
||||
74,
|
||||
123,
|
||||
172,
|
||||
221
|
||||
}
|
||||
local RewardType = {
|
||||
DescContent = 1,
|
||||
Attribute = 2,
|
||||
Reward = 3
|
||||
}
|
||||
CharFavourRewardCtrl._mapNodeConfig = {
|
||||
goblur = {
|
||||
sNodeName = "t_fullscreen_blur_blue1",
|
||||
sComponentName = "GameObject"
|
||||
},
|
||||
txtWindowTitle = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "CharPlot_Favour_Reward_Title"
|
||||
},
|
||||
txtTitle = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "CharPlot_Favour_Preview"
|
||||
},
|
||||
txtTitleNextLevel = {sComponentName = "TMP_Text"},
|
||||
btnsnapshot = {
|
||||
sNodeName = "snapshot",
|
||||
sComponentName = "Button",
|
||||
callback = "OnBtn_ClickClose"
|
||||
},
|
||||
anigoRewardRoot = {
|
||||
sNodeName = "goRewardRoot",
|
||||
sComponentName = "Animator"
|
||||
},
|
||||
loopsvReward = {
|
||||
sNodeName = "svReward",
|
||||
sComponentName = "LoopScrollView"
|
||||
},
|
||||
loopsvAttribute = {
|
||||
sNodeName = "svAttribute",
|
||||
sComponentName = "LoopScrollView"
|
||||
},
|
||||
loopsvAttributeNextLevel = {
|
||||
sNodeName = "svAttributeNextLevel",
|
||||
sComponentName = "LoopScrollView"
|
||||
},
|
||||
btnClose = {
|
||||
sNodeName = "btnClose",
|
||||
sComponentName = "UIButton",
|
||||
callback = "OnBtn_ClickClose"
|
||||
}
|
||||
}
|
||||
CharFavourRewardCtrl._mapEventConfig = {}
|
||||
function CharFavourRewardCtrl:Awake()
|
||||
local tbParam = self:GetPanelParam()
|
||||
self.curCharId = tbParam[1]
|
||||
self.tbDefualtShowAttribute = {
|
||||
self:GetEffectDescId(GameEnum.effectAttributeType.MAXHP, GameEnum.parameterType.BASE_VALUE),
|
||||
self:GetEffectDescId(GameEnum.effectAttributeType.ATK, GameEnum.parameterType.BASE_VALUE)
|
||||
}
|
||||
end
|
||||
function CharFavourRewardCtrl:OnEnable()
|
||||
self._mapNode.anigoRewardRoot:Play("t_window_04_t_in")
|
||||
self._mapNode.goblur:SetActive(true)
|
||||
local affinityData = PlayerData.Char:GetCharAffinityData(self.curCharId)
|
||||
self.curFavourLevel = affinityData.Level
|
||||
self:CacheLevelRewardData()
|
||||
self:OnRefreshPanel()
|
||||
end
|
||||
function CharFavourRewardCtrl:OnRefreshPanel()
|
||||
self.tbAffinityHeight = {}
|
||||
self.AffinityLevelData = {}
|
||||
local mapCharAffinity = ConfigTable.GetData("CharAffinityTemplate", self.curCharId)
|
||||
if mapCharAffinity == nil then
|
||||
return
|
||||
end
|
||||
local templateId = mapCharAffinity.TemplateId
|
||||
local forEachAffinityLevelReward = function(mapData)
|
||||
if mapData.TemplateId == templateId then
|
||||
if self.curFavourLevel == mapData.AffinityLevel then
|
||||
self.curAffinityData = mapData
|
||||
end
|
||||
local data = self.tbLevelRewardData[mapData.AffinityLevel]
|
||||
if data ~= nil then
|
||||
local height = self:CalGridHeight(data, mapData)
|
||||
if 0 < height then
|
||||
table.insert(self.AffinityLevelData, {
|
||||
levelData = mapData,
|
||||
rewardData = data,
|
||||
height = height
|
||||
})
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
ForEachTableLine(DataTable.AffinityLevel, forEachAffinityLevelReward)
|
||||
table.sort(self.AffinityLevelData, function(a, b)
|
||||
return a.levelData.AffinityLevel < b.levelData.AffinityLevel
|
||||
end)
|
||||
for k, v in ipairs(self.AffinityLevelData) do
|
||||
if self.initSelectAdvance == nil and v.levelData.AffinityLevel > self.curFavourLevel then
|
||||
self.initSelectAdvance = #self.tbAffinityHeight
|
||||
end
|
||||
table.insert(self.tbAffinityHeight, v.height)
|
||||
end
|
||||
if self.initSelectAdvance == nil then
|
||||
self.initSelectAdvance = #self.tbAffinityHeight
|
||||
end
|
||||
self.initSelectAdvance = self.initSelectAdvance == 0 and 1 or self.initSelectAdvance
|
||||
self._mapNode.loopsvReward:SetAnim(0.07)
|
||||
self._mapNode.loopsvReward:InitEx(self.tbAffinityHeight, self, self.OnRefreshAffinityGrid)
|
||||
self._mapNode.loopsvReward:SetScrollGridPosEx(self.tbAffinityHeight, self.initSelectAdvance, 0.1, 0)
|
||||
self:OnRefreshAttributeList()
|
||||
self:OnRefreshNextLevelAttributeList()
|
||||
end
|
||||
function CharFavourRewardCtrl:OnRefreshAffinityGrid(go, gridIndex)
|
||||
local index = gridIndex + 1
|
||||
local data = self.AffinityLevelData[index]
|
||||
local trans = go.transform:Find("AnimRoot")
|
||||
local goTitle = trans:Find("goTitle")
|
||||
local goUnlock = goTitle:Find("goUnlock")
|
||||
local goLock = goTitle:Find("goLock")
|
||||
local txtLevel = goUnlock:Find("txtLevel"):GetComponent("TMP_Text")
|
||||
local txtLevelName1 = goUnlock:Find("txtLevelName"):GetComponent("TMP_Text")
|
||||
local imgHead = goUnlock:Find("imgHead"):GetComponent("Image")
|
||||
local txtLevel_Lock = goLock:Find("txtLevelName/txtLevel_Lock"):GetComponent("TMP_Text")
|
||||
local txtLevelName2 = goLock.gameObject.transform:Find("txtLevelName"):GetComponent("TMP_Text")
|
||||
NovaAPI.SetTMPText(txtLevelName1, ConfigTable.GetUIText("CharPlot_Favour_Reward_Level"))
|
||||
NovaAPI.SetTMPText(txtLevelName2, ConfigTable.GetUIText("CharPlot_Favour_Reward_Level"))
|
||||
NovaAPI.SetTMPText(txtLevel, data.levelData.AffinityLevel)
|
||||
NovaAPI.SetTMPText(txtLevel_Lock, data.levelData.AffinityLevel)
|
||||
goLock.gameObject:SetActive(data.levelData.AffinityLevel > self.curFavourLevel)
|
||||
goUnlock.gameObject:SetActive(data.levelData.AffinityLevel <= self.curFavourLevel)
|
||||
NovaAPI.SetComponentEnable(imgHead, data.levelData.AffinityLevel <= self.curFavourLevel)
|
||||
if data.levelData.AffinityLevel <= self.curFavourLevel then
|
||||
self:SetPngSprite(imgHead, data.levelData.AffinityLevelIcon)
|
||||
end
|
||||
local goRewardRoot = trans:Find("goRewardInfoList")
|
||||
local rewardInfoList = self:GetRewardInfoList(data.rewardData, data.levelData)
|
||||
if #rewardInfoList <= 0 then
|
||||
goRewardRoot.gameObject:SetActive(false)
|
||||
return
|
||||
end
|
||||
goRewardRoot.gameObject:SetActive(true)
|
||||
table.sort(rewardInfoList, function(a, b)
|
||||
return a.rewardType < b.rewardType
|
||||
end)
|
||||
for i = 1, 4 do
|
||||
local goReward = goRewardRoot:Find("goRewardInfo_" .. i)
|
||||
local cgGoReward = goReward:GetComponent("CanvasGroup")
|
||||
local goLine = 1 < i and goRewardRoot:Find("goLine_" .. i - 1) or nil
|
||||
if goLine ~= nil then
|
||||
goLine.gameObject:SetActive(rewardInfoList[i] ~= nil)
|
||||
end
|
||||
goReward.gameObject:SetActive(rewardInfoList[i] ~= nil)
|
||||
if rewardInfoList[i] ~= nil then
|
||||
self:SetGridRewardInfoList(goReward, rewardInfoList[i])
|
||||
end
|
||||
NovaAPI.SetCanvasGroupAlpha(cgGoReward, data.levelData.AffinityLevel > self.curFavourLevel and 0.4 or 1)
|
||||
end
|
||||
end
|
||||
function CharFavourRewardCtrl:SetGridRewardInfoList(goRewardRoot, rewardInfoList)
|
||||
local goReward = goRewardRoot:Find("goReward")
|
||||
local goDesc = goRewardRoot:Find("goDesc")
|
||||
goReward.gameObject:SetActive(rewardInfoList.rewardType == RewardType.Reward)
|
||||
goDesc.gameObject:SetActive(rewardInfoList.rewardType ~= RewardType.Reward)
|
||||
if rewardInfoList.rewardType == RewardType.Reward then
|
||||
local imgRewardIcon = goReward:Find("goRewardTxtContent/goImgReward/imgReward"):GetComponent("Image")
|
||||
local item = ConfigTable.GetData_Item(rewardInfoList.rewardData[1])
|
||||
self:SetPngSprite(imgRewardIcon, item.Icon2)
|
||||
local txtReward = goReward:Find("goRewardTxtContent/txtReward"):GetComponent("TMP_Text")
|
||||
NovaAPI.SetTMPText(txtReward, rewardInfoList.rewardData[2])
|
||||
else
|
||||
local imgLock = goDesc:Find("imgLock")
|
||||
local imgAttribute = goDesc:Find("imgAttribute")
|
||||
local txtFront = goDesc:Find("txtFront"):GetComponent("TMP_Text")
|
||||
local txtAfter = goDesc:Find("txtAfter"):GetComponent("TMP_Text")
|
||||
if rewardInfoList.rewardType == RewardType.DescContent then
|
||||
imgLock.gameObject:SetActive(true)
|
||||
imgAttribute.gameObject:SetActive(false)
|
||||
NovaAPI.SetTMPText(txtFront, rewardInfoList.rewardData.front)
|
||||
NovaAPI.SetTMPText(txtAfter, rewardInfoList.rewardData.after)
|
||||
elseif rewardInfoList.rewardType == RewardType.Attribute then
|
||||
imgLock.gameObject:SetActive(false)
|
||||
imgAttribute.gameObject:SetActive(true)
|
||||
NovaAPI.SetTMPText(txtFront, ConfigTable.GetUIText("Attribute_Up"))
|
||||
local addTxt = FormatEffectValue(rewardInfoList.attributeData.value, rewardInfoList.attributeData.descData.isPercent, rewardInfoList.attributeData.descData.Format)
|
||||
NovaAPI.SetTMPText(txtAfter, rewardInfoList.attributeData.descData.Desc .. " +" .. addTxt)
|
||||
end
|
||||
end
|
||||
end
|
||||
function CharFavourRewardCtrl:OnRefreshAttributeList()
|
||||
self.tbAttributeList = {}
|
||||
local count = 0
|
||||
for k, v in ipairs(self.tbDefualtShowAttribute) do
|
||||
self.tbAttributeList[v] = {sort = k, value = 0}
|
||||
count = count + 1
|
||||
end
|
||||
if self.curAffinityData ~= nil then
|
||||
for i = 1, #self.curAffinityData.Effect do
|
||||
local effectData = self:GetEffectData(self.curAffinityData.Effect[i])
|
||||
local descId = effectData.descData.Id
|
||||
if self.tbAttributeList[descId] ~= nil then
|
||||
self.tbAttributeList[descId].value = self.tbAttributeList[descId].value + effectData.value
|
||||
else
|
||||
self.tbAttributeList[descId] = {
|
||||
sort = count + 1,
|
||||
value = effectData.value
|
||||
}
|
||||
count = count + 1
|
||||
end
|
||||
end
|
||||
end
|
||||
self._mapNode.loopsvAttribute:Init(count, self, self.OnRefreshAttributeGrid)
|
||||
end
|
||||
function CharFavourRewardCtrl:OnRefreshAttributeGrid(go, index)
|
||||
local index = index + 1
|
||||
local data = {}
|
||||
local descId = 0
|
||||
for k, v in pairs(self.tbAttributeList) do
|
||||
if index == v.sort then
|
||||
data = v
|
||||
descId = k
|
||||
break
|
||||
end
|
||||
end
|
||||
if descId <= 0 then
|
||||
go:SetActive(false)
|
||||
return
|
||||
end
|
||||
local trans = go.transform
|
||||
local imgIcon = trans:Find("imgIcon"):GetComponent("Image")
|
||||
local txtAttributeName = trans:Find("txtAttributeName"):GetComponent("TMP_Text")
|
||||
local txtAttributeNum = trans:Find("txtAttributeNum"):GetComponent("TMP_Text")
|
||||
local effectDescData = ConfigTable.GetData("EffectDesc", descId)
|
||||
self:SetPngSprite(imgIcon, effectDescData.Icon)
|
||||
NovaAPI.SetTMPText(txtAttributeName, effectDescData.Desc)
|
||||
local sValue = FormatEffectValue(data.value, effectDescData.isPercent, effectDescData.Format)
|
||||
NovaAPI.SetTMPText(txtAttributeNum, sValue)
|
||||
end
|
||||
function CharFavourRewardCtrl:OnRefreshNextLevelAttributeList()
|
||||
self.tbNextLevelAttributeList = {}
|
||||
local count = 0
|
||||
for k, v in ipairs(self.tbDefualtShowAttribute) do
|
||||
self.tbNextLevelAttributeList[v] = {sort = k, value = 0}
|
||||
count = count + 1
|
||||
end
|
||||
local nextLevelData = self:GetTargetLevelData(self.curAffinityData.AffinityLevel + 1, self.curAffinityData.TemplateId)
|
||||
if nextLevelData ~= nil then
|
||||
local effectData = self:GetEffectDataSubValue(self.curAffinityData.Effect, nextLevelData.Effect)
|
||||
if effectData ~= nil then
|
||||
for i = 1, #effectData do
|
||||
local descId = effectData[i].descData.Id
|
||||
if self.tbNextLevelAttributeList[descId] ~= nil then
|
||||
self.tbNextLevelAttributeList[descId].value = self.tbNextLevelAttributeList[descId].value + effectData[i].value
|
||||
else
|
||||
self.tbNextLevelAttributeList[descId] = {
|
||||
sort = count + 1,
|
||||
value = effectData[i].value
|
||||
}
|
||||
count = count + 1
|
||||
end
|
||||
end
|
||||
NovaAPI.SetTMPText(self._mapNode.txtTitleNextLevel, ConfigTable.GetUIText("Affinity_Next_Level"))
|
||||
end
|
||||
local ShowData = {}
|
||||
for k, v in pairs(self.tbNextLevelAttributeList) do
|
||||
if 0 < tonumber(v.value) then
|
||||
table.insert(ShowData, {
|
||||
sort = v.sort,
|
||||
value = v.value,
|
||||
id = k
|
||||
})
|
||||
end
|
||||
end
|
||||
table.sort(ShowData, function(a, b)
|
||||
return a.sort < b.sort
|
||||
end)
|
||||
self.tbNextLevelAttributeList = {}
|
||||
for i = 1, #ShowData do
|
||||
ShowData[i].sort = i
|
||||
self.tbNextLevelAttributeList[ShowData[i].id] = {
|
||||
sort = i,
|
||||
value = ShowData[i].value
|
||||
}
|
||||
end
|
||||
count = #ShowData
|
||||
else
|
||||
count = 0
|
||||
NovaAPI.SetTMPText(self._mapNode.txtTitleNextLevel, ConfigTable.GetUIText("Affinity_Max_Level"))
|
||||
end
|
||||
self._mapNode.loopsvAttributeNextLevel:Init(count, self, self.OnRefreshNextLevelAttributeGrid)
|
||||
end
|
||||
function CharFavourRewardCtrl:OnRefreshNextLevelAttributeGrid(go, index)
|
||||
local index = index + 1
|
||||
local data = {}
|
||||
local descId = 0
|
||||
for k, v in pairs(self.tbNextLevelAttributeList) do
|
||||
if index == v.sort then
|
||||
data = v
|
||||
descId = k
|
||||
break
|
||||
end
|
||||
end
|
||||
if descId <= 0 then
|
||||
go:SetActive(false)
|
||||
return
|
||||
end
|
||||
local trans = go.transform
|
||||
local imgIcon = trans:Find("imgIcon"):GetComponent("Image")
|
||||
local txtAttributeName = trans:Find("txtAttributeName"):GetComponent("TMP_Text")
|
||||
local txtAttributeNum = trans:Find("txtAttributeNum"):GetComponent("TMP_Text")
|
||||
local effectDescData = ConfigTable.GetData("EffectDesc", descId)
|
||||
self:SetPngSprite(imgIcon, effectDescData.Icon)
|
||||
NovaAPI.SetTMPText(txtAttributeName, effectDescData.Desc)
|
||||
local sValue = FormatEffectValue(data.value, effectDescData.isPercent, effectDescData.Format)
|
||||
NovaAPI.SetTMPText(txtAttributeNum, sValue)
|
||||
end
|
||||
function CharFavourRewardCtrl:CacheLevelRewardData()
|
||||
self.tbLevelRewardData = {}
|
||||
local forEachAffinityUpReward = function(mapData)
|
||||
if mapData.CharId == self.curCharId then
|
||||
self.tbLevelRewardData[mapData.RewardLevel] = mapData
|
||||
end
|
||||
end
|
||||
ForEachTableLine(DataTable.AffinityUpReward, forEachAffinityUpReward)
|
||||
end
|
||||
function CharFavourRewardCtrl:GetEffectData(effectId)
|
||||
local data
|
||||
local effectData = ConfigTable.GetData("EffectValue", effectId)
|
||||
if effectData == nil then
|
||||
printError("属性配置错误,不存在的属性:" .. effectId)
|
||||
end
|
||||
local descId = self:GetEffectDescId(effectData.EffectTypeFirstSubtype, effectData.EffectTypeSecondSubtype)
|
||||
local mapEffectDesc = ConfigTable.GetData("EffectDesc", descId)
|
||||
if mapEffectDesc ~= nil then
|
||||
data = {
|
||||
descData = mapEffectDesc,
|
||||
value = effectData.EffectTypeParam1
|
||||
}
|
||||
end
|
||||
return data
|
||||
end
|
||||
function CharFavourRewardCtrl:GetEffectDataSubValue(levelDataBefore, levelDataAfter)
|
||||
local tbBeforeValue = {}
|
||||
local tbAfterValue = {}
|
||||
local data
|
||||
if levelDataBefore ~= nil then
|
||||
for i = 1, #levelDataBefore do
|
||||
local data = self:GetEffectData(levelDataBefore[i])
|
||||
if data ~= nil then
|
||||
tbBeforeValue[data.descData.Id] = data
|
||||
end
|
||||
end
|
||||
end
|
||||
if levelDataAfter ~= nil then
|
||||
for i = 1, #levelDataAfter do
|
||||
local data = self:GetEffectData(levelDataAfter[i])
|
||||
if data ~= nil then
|
||||
tbAfterValue[data.descData.Id] = data
|
||||
end
|
||||
end
|
||||
end
|
||||
for k, v in pairs(tbAfterValue) do
|
||||
if tbBeforeValue[k] ~= nil then
|
||||
local beforeValue = tonumber(tbBeforeValue[k].value)
|
||||
local afterValue = tonumber(v.value)
|
||||
if beforeValue < afterValue then
|
||||
if data == nil then
|
||||
data = {}
|
||||
end
|
||||
v.value = afterValue - beforeValue
|
||||
table.insert(data, v)
|
||||
end
|
||||
else
|
||||
if data == nil then
|
||||
data = {}
|
||||
end
|
||||
table.insert(data, v)
|
||||
end
|
||||
end
|
||||
return data
|
||||
end
|
||||
function CharFavourRewardCtrl:CalGridHeight(rewardData, levelData)
|
||||
local data = self:GetRewardInfoList(rewardData, levelData)
|
||||
if #data <= 0 then
|
||||
return 0
|
||||
end
|
||||
if 4 < #data then
|
||||
printError("好感度配置有误,奖励词条超过上限,错误等级:" .. levelData.AffinityLevel)
|
||||
end
|
||||
return AttributeSizeGroup[#data] + GridNormalHeight
|
||||
end
|
||||
function CharFavourRewardCtrl:GetRewardInfoList(rewardData, levelData)
|
||||
local rewardInfoList = {}
|
||||
local index = 1
|
||||
while rewardData ~= nil and (rewardData["DescFront" .. index] ~= nil or rewardData["Reward" .. index] ~= nil) do
|
||||
if rewardData["DescFront" .. index] ~= "" then
|
||||
local data = {}
|
||||
data.rewardType = RewardType.DescContent
|
||||
data.rewardData = {
|
||||
front = rewardData["DescFront" .. index],
|
||||
after = rewardData["DescAfter" .. index]
|
||||
}
|
||||
table.insert(rewardInfoList, data)
|
||||
end
|
||||
index = index + 1
|
||||
end
|
||||
if levelData.IsKeyAffinityLevel == true and levelData.Effect ~= nil then
|
||||
local lastData = self:GetTargetLevelData(levelData.AffinityLevel - 1, levelData.TemplateId)
|
||||
if lastData == nil then
|
||||
for i = 1, #levelData.Effect do
|
||||
local data = {}
|
||||
local effectData = self:GetEffectData(levelData.Effect[i])
|
||||
if effectData ~= nil then
|
||||
data.rewardType = RewardType.Attribute
|
||||
data.attributeData = effectData
|
||||
table.insert(rewardInfoList, data)
|
||||
end
|
||||
end
|
||||
else
|
||||
local effectData = self:GetEffectDataSubValue(lastData.Effect, levelData.Effect)
|
||||
if effectData ~= nil then
|
||||
for i = 1, #effectData do
|
||||
local data = {}
|
||||
if effectData[i] ~= nil then
|
||||
data.rewardType = RewardType.Attribute
|
||||
data.attributeData = effectData[i]
|
||||
table.insert(rewardInfoList, data)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
return rewardInfoList
|
||||
end
|
||||
function CharFavourRewardCtrl:GetEffectDescId(attributeType, numType)
|
||||
return GameEnum.effectType.ATTR_FIX * 10000 + attributeType * 10 + numType
|
||||
end
|
||||
function CharFavourRewardCtrl:GetTargetLevelData(affinityLevel, templateId)
|
||||
local data
|
||||
local forEachAffinityLevelReward = function(mapData)
|
||||
if mapData.TemplateId == templateId and affinityLevel == mapData.AffinityLevel then
|
||||
data = mapData
|
||||
end
|
||||
end
|
||||
ForEachTableLine(DataTable.AffinityLevel, forEachAffinityLevelReward)
|
||||
return data
|
||||
end
|
||||
function CharFavourRewardCtrl:OnBtn_ClickClose()
|
||||
self._mapNode.anigoRewardRoot:Play("t_window_04_t_out")
|
||||
self._mapNode.goblur:SetActive(false)
|
||||
self:AddTimer(1, 0.3, "OnCloseAnimFinish", true, true, true)
|
||||
end
|
||||
function CharFavourRewardCtrl:OnCloseAnimFinish()
|
||||
EventManager.Hit(EventId.ClosePanel, PanelId.CharFavourReward)
|
||||
end
|
||||
return CharFavourRewardCtrl
|
||||
@@ -0,0 +1,20 @@
|
||||
local BasePanel = require("GameCore.UI.BasePanel")
|
||||
local CharFavourRewardPanel = class("CharFavourRewardPanel", BasePanel)
|
||||
CharFavourRewardPanel._bIsMainPanel = false
|
||||
CharFavourRewardPanel._tbDefine = {
|
||||
{
|
||||
sPrefabPath = "CharacterFavour/CharFavourRewardPanel.prefab",
|
||||
sCtrlName = "Game.UI.CharacterFavour.CharFavourRewardCtrl"
|
||||
}
|
||||
}
|
||||
function CharFavourRewardPanel:Awake()
|
||||
end
|
||||
function CharFavourRewardPanel:OnEnable()
|
||||
end
|
||||
function CharFavourRewardPanel:OnDisable()
|
||||
end
|
||||
function CharFavourRewardPanel:OnDestroy()
|
||||
end
|
||||
function CharFavourRewardPanel:OnRelease()
|
||||
end
|
||||
return CharFavourRewardPanel
|
||||
@@ -0,0 +1,171 @@
|
||||
local BaseCtrl = require("GameCore.UI.BaseCtrl")
|
||||
local CharFavourTaskCtrl = class("CharFavourTaskCtrl", BaseCtrl)
|
||||
local FavourTaskState = {
|
||||
Complete = 1,
|
||||
NotComplete = 2,
|
||||
Received = 3
|
||||
}
|
||||
CharFavourTaskCtrl._mapNodeConfig = {
|
||||
anit_window_01 = {
|
||||
sNodeName = "t_window_01",
|
||||
sComponentName = "Animator"
|
||||
},
|
||||
got_fullscreen_blur_black = {
|
||||
sNodeName = "t_fullscreen_blur_black",
|
||||
sComponentName = "GameObject"
|
||||
},
|
||||
btnsnapshot = {
|
||||
sNodeName = "snapshot",
|
||||
sComponentName = "Button",
|
||||
callback = "OnBtn_ClickClose"
|
||||
},
|
||||
loopTaskList = {
|
||||
sNodeName = "TaskList",
|
||||
sComponentName = "LoopScrollView"
|
||||
},
|
||||
btnClose = {
|
||||
sNodeName = "btnClose",
|
||||
sComponentName = "UIButton",
|
||||
callback = "OnBtn_ClickClose"
|
||||
},
|
||||
btnReceive = {
|
||||
sComponentName = "UIButton",
|
||||
callback = "OnBtn_ClickGetReward"
|
||||
},
|
||||
btnReceived = {
|
||||
sComponentName = "UIButton",
|
||||
callback = "OnBtn_ClickCantReward"
|
||||
},
|
||||
txtBtnReceive = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "Affinity_Task_Receive"
|
||||
},
|
||||
txtBtnReceived = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "Affinity_Task_Receive"
|
||||
},
|
||||
txtWindowTitle = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "Affinity_Task_Title"
|
||||
},
|
||||
imgCharIcon = {sComponentName = "Image"}
|
||||
}
|
||||
CharFavourTaskCtrl._mapEventConfig = {
|
||||
[EventId.AffinityQuestReceived] = "OnEvent_AffinityQuestReceived",
|
||||
[EventId.AffinityChange] = "OnEvent_AffinityChange"
|
||||
}
|
||||
function CharFavourTaskCtrl:Awake()
|
||||
local tbParam = self:GetPanelParam()
|
||||
self.curCharId = tbParam[1]
|
||||
end
|
||||
function CharFavourTaskCtrl:OnEnable()
|
||||
self._mapNode.anit_window_01:Play("t_window_04_t_in")
|
||||
self._mapNode.got_fullscreen_blur_black:SetActive(true)
|
||||
local nCharSkinId = PlayerData.Char:GetCharUsedSkinId(self.curCharId)
|
||||
local mapCharSkin = ConfigTable.GetData_CharacterSkin(nCharSkinId)
|
||||
if mapCharSkin ~= nil then
|
||||
self:SetPngSprite(self._mapNode.imgCharIcon, mapCharSkin.Icon .. AllEnum.CharHeadIconSurfix.S)
|
||||
end
|
||||
self:OnRefreshTaskList()
|
||||
end
|
||||
function CharFavourTaskCtrl:OnRefreshTaskList()
|
||||
self.bHasCompleteTask = false
|
||||
self.TaskData = {}
|
||||
local affinityData = PlayerData.Char:GetCharAffinityData(self.curCharId)
|
||||
for k, v in pairs(affinityData.Quest.List) do
|
||||
local questData = PlayerData.Quest:GetAffinityQuestData(v.Id)
|
||||
local state = questData ~= nil and questData.nStatus or v.Status
|
||||
if state == 0 then
|
||||
state = FavourTaskState.NotComplete
|
||||
elseif state == 1 then
|
||||
state = FavourTaskState.Complete
|
||||
self.bHasCompleteTask = true
|
||||
else
|
||||
state = FavourTaskState.Received
|
||||
end
|
||||
local progressData = {}
|
||||
if state ~= FavourTaskState.Received then
|
||||
progressData.Cur = questData ~= nil and questData.nCurProgress or v.Progress[1].Cur
|
||||
progressData.Max = questData ~= nil and questData.nGoal or v.Progress[1].Max
|
||||
else
|
||||
progressData.Cur = 1
|
||||
progressData.Max = 1
|
||||
end
|
||||
local data = {
|
||||
taskData = ConfigTable.GetData("AffinityQuest", v.Id),
|
||||
progress = progressData,
|
||||
taskState = state
|
||||
}
|
||||
table.insert(self.TaskData, data)
|
||||
end
|
||||
self._mapNode.btnReceived.gameObject:SetActive(not self.bHasCompleteTask)
|
||||
self._mapNode.btnReceive.gameObject:SetActive(self.bHasCompleteTask)
|
||||
table.sort(self.TaskData, function(a, b)
|
||||
if a.taskState ~= b.taskState then
|
||||
return a.taskState < b.taskState
|
||||
else
|
||||
return a.taskData.SortId < b.taskData.SortId
|
||||
end
|
||||
end)
|
||||
self._mapNode.loopTaskList:SetAnim(0.07)
|
||||
self._mapNode.loopTaskList:Init(#self.TaskData, self, self.OnRefreshTaskGrid)
|
||||
end
|
||||
function CharFavourTaskCtrl:OnRefreshTaskGrid(goGrid, gridIndex)
|
||||
local index = gridIndex + 1
|
||||
local goGridTrans = goGrid.transform:Find("AnimRoot/Root")
|
||||
local txtRewardCount = goGridTrans:Find("txtHeartCount"):GetComponent("TMP_Text")
|
||||
local goReceived = goGrid.transform:Find("AnimRoot/imgReceived")
|
||||
local txtReceived = goReceived:Find("txtReceived"):GetComponent("TMP_Text")
|
||||
NovaAPI.SetTMPText(txtReceived, ConfigTable.GetUIText("CharPlot_Task_Received"))
|
||||
local imgReceiveMask = goGrid.transform:Find("AnimRoot/imgReceiveMask")
|
||||
local txtTaskDescReceived = goGridTrans:Find("txtTaskDescReceived"):GetComponent("TMP_Text")
|
||||
local txtTaskDesc = goGridTrans:Find("txtTaskDesc"):GetComponent("TMP_Text")
|
||||
local sldTask = goGridTrans:Find("sldTask"):GetComponent("Slider")
|
||||
local txtTaskProgress = goGridTrans:Find("sldTask/txtTaskProgress"):GetComponent("TMP_Text")
|
||||
local imgTaskState1 = goGridTrans:Find("imgTaskState1")
|
||||
local imgTaskState2 = goGridTrans:Find("imgTaskState2")
|
||||
local imgTaskState3 = goGridTrans:Find("imgTaskState3")
|
||||
local data = self.TaskData[index]
|
||||
imgTaskState1.gameObject:SetActive(data.taskState == FavourTaskState.NotComplete)
|
||||
imgTaskState2.gameObject:SetActive(data.taskState == FavourTaskState.Complete)
|
||||
imgTaskState3.gameObject:SetActive(data.taskState == FavourTaskState.Received)
|
||||
NovaAPI.SetSliderValue(sldTask, data.taskState == FavourTaskState.NotComplete and data.progress.Cur / data.progress.Max or 1)
|
||||
local progressTxt = data.progress.Cur .. "/" .. data.progress.Max
|
||||
NovaAPI.SetTMPText(txtTaskProgress, data.taskState == FavourTaskState.NotComplete and progressTxt or ConfigTable.GetUIText("Quest_Complete"))
|
||||
NovaAPI.SetTMPText(txtRewardCount, data.taskData.AffinityExp)
|
||||
NovaAPI.SetTMPText(txtTaskDescReceived, UTILS.ParseParamDesc(data.taskData.Desc, data.taskData))
|
||||
NovaAPI.SetTMPText(txtTaskDesc, UTILS.ParseParamDesc(data.taskData.Desc, data.taskData))
|
||||
txtTaskDesc.gameObject:SetActive(data.taskState ~= FavourTaskState.Received)
|
||||
txtTaskDescReceived.gameObject:SetActive(data.taskState == FavourTaskState.Received)
|
||||
goReceived.gameObject:SetActive(data.taskState == FavourTaskState.Received)
|
||||
imgReceiveMask.gameObject:SetActive(data.taskState == FavourTaskState.Received)
|
||||
end
|
||||
function CharFavourTaskCtrl:OnBtn_ClickCantReward()
|
||||
EventManager.Hit(EventId.OpenMessageBox, ConfigTable.GetUIText("Affinity_Reward_Tips"))
|
||||
end
|
||||
function CharFavourTaskCtrl:OnBtn_ClickGetReward()
|
||||
local data = {}
|
||||
for k, v in ipairs(self.TaskData) do
|
||||
if v.taskState == FavourTaskState.Complete then
|
||||
table.insert(data, v.taskData.Id)
|
||||
end
|
||||
end
|
||||
PlayerData.Quest:ReceiveAffinityReward(data, self.curCharId)
|
||||
end
|
||||
function CharFavourTaskCtrl:OnBtn_ClickClose()
|
||||
self._mapNode.anit_window_01:Play("t_window_04_t_out")
|
||||
self._mapNode.got_fullscreen_blur_black:SetActive(false)
|
||||
self:AddTimer(1, 0.3, "OnCloseAnimFinish", true, true, true)
|
||||
end
|
||||
function CharFavourTaskCtrl:OnCloseAnimFinish()
|
||||
EventManager.Hit(EventId.ClosePanel, PanelId.CharFavourTask)
|
||||
end
|
||||
function CharFavourTaskCtrl:OnEvent_AffinityQuestReceived()
|
||||
self:OnRefreshTaskList()
|
||||
end
|
||||
function CharFavourTaskCtrl:OnEvent_AffinityChange(charId, curLevel, lastFavourLevel, curExp, lastExp)
|
||||
if lastFavourLevel < curLevel then
|
||||
EventManager.Hit(EventId.OpenPanel, PanelId.CharFavourLevelUp, charId, curLevel, lastFavourLevel, curExp, lastExp)
|
||||
end
|
||||
end
|
||||
return CharFavourTaskCtrl
|
||||
@@ -0,0 +1,20 @@
|
||||
local BasePanel = require("GameCore.UI.BasePanel")
|
||||
local CharFavourTaskPanel = class("CharFavourTaskPanel", BasePanel)
|
||||
CharFavourTaskPanel._bIsMainPanel = false
|
||||
CharFavourTaskPanel._tbDefine = {
|
||||
{
|
||||
sPrefabPath = "CharacterFavour/CharFavourTaskPanel.prefab",
|
||||
sCtrlName = "Game.UI.CharacterFavour.CharFavourTaskCtrl"
|
||||
}
|
||||
}
|
||||
function CharFavourTaskPanel:Awake()
|
||||
end
|
||||
function CharFavourTaskPanel:OnEnable()
|
||||
end
|
||||
function CharFavourTaskPanel:OnDisable()
|
||||
end
|
||||
function CharFavourTaskPanel:OnDestroy()
|
||||
end
|
||||
function CharFavourTaskPanel:OnRelease()
|
||||
end
|
||||
return CharFavourTaskPanel
|
||||
Reference in New Issue
Block a user