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:
SL1900
2025-12-03 01:00:00 +09:00
commit 5e0d58cfad
3595 changed files with 9373562 additions and 0 deletions
@@ -0,0 +1,399 @@
local CharacterInfoCtrl = class("CharacterInfoCtrl", BaseCtrl)
local CharacterAttrData = require("GameCore.Data.DataClass.CharacterAttrData")
local Actor2DManager = require("Game.Actor2D.Actor2DManager")
local LayoutRebuilder = CS.UnityEngine.UI.LayoutRebuilder
local typeof = typeof
local PropertyIndexList = {
Simple = {
1,
2,
3
},
Detail = {
1,
2,
3,
4,
5,
6,
13,
7,
8,
9,
10,
11,
12
}
}
local talent_skill_bg_fold = 76
local talent_skill_bg_unFold = 351.6
CharacterInfoCtrl._mapNodeConfig = {
safeAreaRoot = {
sNodeName = "----SafeAreaRoot----",
sComponentName = "RectTransform"
},
Drag = {},
txtCharLevel = {sComponentName = "TMP_Text"},
txtTitleRank = {
sComponentName = "TMP_Text",
sLanguageId = "Template_CharRank"
},
txtLevelMax = {sComponentName = "TMP_Text"},
goStarAdvance = {
sNodeName = "tc_star_advance",
sCtrlName = "Game.UI.TemplateEx.TemplateStarAdvanceCtrl"
},
goProperty = {
nCount = 3,
sCtrlName = "Game.UI.TemplateEx.TemplatePropertyCtrl"
},
txtTitleProperty = {
sComponentName = "TMP_Text",
sLanguageId = "CharacterInfo_Property"
},
txtBtnProperty = {
sComponentName = "TMP_Text",
sLanguageId = "CharacterInfo_Btn_Property"
},
btnProperty = {
sComponentName = "UIButton",
callback = "OnBtnClick_Property"
},
btnDevelopment = {
sComponentName = "UIButton",
callback = "OnBtnClick_Development"
},
txtBtnDevelopment = {
sComponentName = "TMP_Text",
sLanguageId = "CharacterInfo_Btn_Development"
},
txtCharDesc = {sComponentName = "TMP_Text"},
ScrollView = {sComponentName = "ScrollRect"},
txtFavorCn = {
sComponentName = "TMP_Text",
sLanguageId = "CharacterInfo_Favor"
},
tc_affinity_level = {
sCtrlName = "Game.UI.TemplateEx.TemplateAffinityLevelCtrl"
},
txtName = {sComponentName = "TMP_Text"},
imgRareName = {sComponentName = "Image"},
imgCharColor = {sComponentName = "Image"},
imgTag = {nCount = 3},
txtTag = {nCount = 3, sComponentName = "TMP_Text"},
txtElement = {sComponentName = "TMP_Text"},
imgElementIcon = {sComponentName = "Image"},
btnSkin = {
sComponentName = "UIButton",
callback = "OnBtnClick_OpenSkinPanel"
},
btnCloseWordTip = {
sComponentName = "Button",
callback = "OnBtnClick_CloseWordTip"
},
imgWordTipBg = {},
TMPWordDesc = {sComponentName = "TMP_Text"},
TMPWordTipsTitle = {sComponentName = "TMP_Text"},
reddot = {}
}
CharacterInfoCtrl._mapEventConfig = {
[EventId.ShowCharacterSkillTips] = "ShowCharacterSkillTips",
[EventId.CharBgRefresh] = "OnEvent_RefreshPanel",
[EventId.CharRelatePanelAdvance] = "OnEvent_PanelAdvance",
[EventId.CharRelatePanelBack] = "OnEvent_PanelBack"
}
function CharacterInfoCtrl:PlayOpenAnim(nClosePanelId)
if nClosePanelId == PanelId.CharUpPanel then
self.ani:Play("CharacterInfoPanel_out", 0, 0)
else
self.ani:Play("CharacterInfoPanel_in", 0, 0)
end
EventManager.Hit(EventId.TemporaryBlockInput, 0.4)
end
function CharacterInfoCtrl:PlayCloseAnim()
end
function CharacterInfoCtrl:RefreshContent()
local nCurPanelId = self._panel.nPanelId
if nCurPanelId ~= PanelId.CharInfo then
return
end
self.characterId = self._panel.nCharId
self.characterIdList = self._panel.tbCharList
local tempCharacterId = PlayerData.Char:TempGetCharInfoData()
if type(tempCharacterId) == "number" then
self.characterId = tempCharacterId
PlayerData.Char:TempClearCharInfoData()
end
if type(self.characterId) ~= "number" then
return
end
self.configData = ConfigTable.GetData_Character(self.characterId)
for index, characterId in ipairs(self.characterIdList) do
if self.characterId == characterId then
self.curCharacterIndex = index
break
end
end
self.showDetail = false
self:RefreshShow()
end
function CharacterInfoCtrl:InitBg()
EventManager.Hit(EventId.CharBgRefresh, PanelId.CharInfo, self.characterId)
end
function CharacterInfoCtrl:RefreshShow()
self:CalculateCharacterInfo()
self:RefreshCharacterInfo()
self:RefreshProperty()
self:RefreshActor2D()
end
function CharacterInfoCtrl:CalculateCharacterInfo()
self:CalculateProperty()
end
function CharacterInfoCtrl:CalculateProperty()
if not self.attrData then
self.attrData = CharacterAttrData.new(self.characterId)
else
self.attrData:SetCharacter(self.characterId)
end
end
function CharacterInfoCtrl:RefreshCharacterInfo()
local data = PlayerData.Char._mapChar[self.characterId]
local rankLevel = PlayerData.Char:GetCharLv(data.nId)
local MaxLevel = PlayerData.Char:CalCharMaxLevel(data.nId)
NovaAPI.SetTMPText(self._mapNode.txtCharLevel, rankLevel)
NovaAPI.SetTMPText(self._mapNode.txtLevelMax, "/" .. MaxLevel)
local tbAdvanceLevel = PlayerData.Char:GetAdvanceLevelTable()
local nMaxAdvance = #tbAdvanceLevel[self.configData.Grade] - 1
self._mapNode.goStarAdvance:SetStar(data.nAdvance, nMaxAdvance)
local mapConfigDesc = ConfigTable.GetData("CharacterDes", self.configData.Id)
local sDesc
if mapConfigDesc ~= nil then
sDesc = mapConfigDesc.CharDes
else
sDesc = ""
end
NovaAPI.SetTMPText(self._mapNode.txtCharDesc, sDesc)
NovaAPI.SetVerticalNormalizedPosition(self._mapNode.ScrollView, 1)
local affinityData = PlayerData.Char:GetCharAffinityData(self.characterId)
self._mapNode.tc_affinity_level:SetInfo(affinityData.Level)
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)
local mapCharDescCfg = ConfigTable.GetData("CharacterDes", self.characterId)
local sColor, tbTag
if mapCharDescCfg ~= nil then
sColor = mapCharDescCfg.CharColor
tbTag = mapCharDescCfg.Tag
else
sColor = ""
tbTag = {}
end
local _, colorChar = ColorUtility.TryParseHtmlString(sColor)
NovaAPI.SetImageColor(self._mapNode.imgCharColor, colorChar)
for i = 1, 3 do
local nTag = tbTag[i]
if nTag then
self._mapNode.imgTag[i]:SetActive(true)
NovaAPI.SetTMPText(self._mapNode.txtTag[i], ConfigTable.GetData("CharacterTag", nTag).Title)
else
self._mapNode.imgTag[i]:SetActive(false)
end
end
local sName = AllEnum.ElementIconType.Icon .. self.configData.EET
self:SetAtlasSprite(self._mapNode.imgElementIcon, "12_rare", sName)
NovaAPI.SetTMPColor(self._mapNode.txtElement, AllEnum.ElementColor[self.configData.EET])
NovaAPI.SetTMPText(self._mapNode.txtElement, ConfigTable.GetUIText("T_Element_Attr_" .. self.configData.EET))
end
function CharacterInfoCtrl:RefreshProperty()
local attrList = self.attrData:GetAttrList()
for i = 1, #PropertyIndexList.Simple do
local index = PropertyIndexList.Simple[i]
local mapCharAttr = AllEnum.CharAttr[index]
self._mapNode.goProperty[i]:SetCharProperty(mapCharAttr, attrList[index], true)
end
end
function CharacterInfoCtrl:RefreshActor2D()
EventManager.Hit(EventId.CharBgRefresh, PanelId.CharInfo, self.characterId)
end
function CharacterInfoCtrl:PlaySwitchAnim(nClosePanelId, nOpenPanelId, bBack)
if nClosePanelId == PanelId.CharInfo then
self._mapNode.safeAreaRoot.gameObject:SetActive(false)
end
if nOpenPanelId == PanelId.CharInfo then
self._mapNode.safeAreaRoot.gameObject:SetActive(true)
self:PlayOpenAnim(nClosePanelId)
end
end
function CharacterInfoCtrl:AddEventTrigger()
local EventTrigger = CS.UnityEngine.EventSystems.EventTrigger
local EventTriggerType = CS.UnityEngine.EventSystems.EventTriggerType
local et = self._mapNode.Drag:GetComponent(typeof(EventTrigger))
local cb_Begin = ui_handler(self, self.OnEventTrigger_BeginDrag, et)
local entryBegin = EventTrigger.Entry()
entryBegin.eventID = EventTriggerType.BeginDrag
entryBegin.callback:AddListener(cb_Begin)
et.triggers:Add(entryBegin)
local cb_End = ui_handler(self, self.OnEvnetTrigger_EndDrag, et)
local entryEnd = EventTrigger.Entry()
entryEnd.eventID = EventTriggerType.EndDrag
entryEnd.callback:AddListener(cb_End)
et.triggers:Add(entryEnd)
self.tbTestEventTrigger = {
et,
cb_Begin,
cb_End
}
end
function CharacterInfoCtrl:RemoveEventTrigger()
if type(self.tbTestEventTrigger) == "table" then
local EventTriggerType = CS.UnityEngine.EventSystems.EventTriggerType
local et = self.tbTestEventTrigger[1]
local cb_Begin = self.tbTestEventTrigger[2]
local cb_End = self.tbTestEventTrigger[3]
local nCount = et.triggers.Count - 1
for i = nCount, 0, -1 do
local entry = et.triggers[i]
if entry.eventID == EventTriggerType.BeginDrag then
entry.callback:RemoveListener(cb_Begin)
elseif entry.eventID == EventTriggerType.EndDrag then
entry.callback:RemoveListener(cb_End)
end
et.triggers:Remove(entry)
end
self.tbTestEventTrigger = nil
end
end
function CharacterInfoCtrl:RegisterRedDot()
RedDotManager.RegisterNode(RedDotDefine.Role_Upgrade, self.characterId, self._mapNode.reddot)
end
function CharacterInfoCtrl:FadeIn()
end
function CharacterInfoCtrl:Awake()
self.ani = self.gameObject:GetComponent("Animator")
self.characterId = nil
self.configData = nil
self.characterIdList = nil
self.curCharacterIndex = nil
self.attrData = nil
self.attrList = nil
self.skillLevelList = nil
self.skillIdList = nil
self.power = nil
self.playEnterAnim = true
self.showDetail = false
end
function CharacterInfoCtrl:OnEnable()
self:RefreshContent()
if self._panel.nPanelId == PanelId.CharInfo then
self:PlayOpenAnim()
else
self._mapNode.safeAreaRoot.gameObject:SetActive(false)
end
self:AddEventTrigger()
self:RegisterRedDot()
end
function CharacterInfoCtrl:OnDisable()
self:RemoveEventTrigger()
end
function CharacterInfoCtrl:OnDestroy()
end
function CharacterInfoCtrl:OnBtnClick_Left()
if #self.characterIdList <= 1 then
return
end
self.curCharacterIndex = self.curCharacterIndex - 1
if 1 > self.curCharacterIndex then
self.curCharacterIndex = #self.characterIdList
end
self.characterId = self.characterIdList[self.curCharacterIndex]
self.configData = ConfigTable.GetData_Character(self.characterId)
self:RefreshShow()
end
function CharacterInfoCtrl:OnBtnClick_Right()
if #self.characterIdList <= 1 then
return
end
self.curCharacterIndex = self.curCharacterIndex + 1
if self.curCharacterIndex > #self.characterIdList then
self.curCharacterIndex = 1
end
self.characterId = self.characterIdList[self.curCharacterIndex]
self.configData = ConfigTable.GetData_Character(self.characterId)
self:RefreshShow()
end
function CharacterInfoCtrl:OnBtnClick_Property()
local attrList = self.attrData:GetAttrList()
local mapCfg = ConfigTable.GetData_Character(self.characterId)
if not mapCfg then
return
end
EventManager.Hit(EventId.OpenPanel, PanelId.CharAttrDetail, attrList, mapCfg.EET)
end
function CharacterInfoCtrl:OnBtnClick_TempSwitchSkin()
local mapCfgData_Char = ConfigTable.GetData_Character(self.characterId)
local nCurCharAdvance = PlayerData.Char:GetCharAdvance(self.characterId)
local bCanSwitch = nCurCharAdvance >= mapCfgData_Char.AdvanceSkinUnlockLevel
if bCanSwitch == true then
local nSkinId = PlayerData.Char:GetCharSkinId(self.characterId)
if nSkinId == mapCfgData_Char.DefaultSkinId then
nSkinId = mapCfgData_Char.AdvanceSkinId
elseif nSkinId == mapCfgData_Char.AdvanceSkinId then
nSkinId = mapCfgData_Char.DefaultSkinId
else
return
end
local func_callback = function()
PlayerData.Char:SetCharSkinId(self.characterId, nSkinId)
end
local msgSend = {}
msgSend.CharId = self.characterId
msgSend.SkinId = nSkinId
HttpNetHandler.SendMsg(NetMsgId.Id.char_skin_set_req, msgSend, nil, func_callback)
end
end
function CharacterInfoCtrl:OnBtnClick_OpenSkinPanel()
local func = function()
EventManager.Hit(EventId.OpenPanel, PanelId.CharacterSkinPanel, self.characterId)
end
EventManager.Hit(EventId.SetTransition, 5, func)
end
function CharacterInfoCtrl:OnBtnClick_CloseWordTip()
self._mapNode.btnCloseWordTip.gameObject:SetActive(false)
self._mapNode.imgWordTipBg:SetActive(false)
end
function CharacterInfoCtrl:OnBtnClick_Development()
EventManager.Hit(EventId.CharRelatePanelOpen, PanelId.CharUpPanel, self._panel.nCharId)
end
function CharacterInfoCtrl:OnEvent_RefreshPanel()
if self._panel.nPanelId ~= PanelId.CharInfo then
return
end
self:RefreshContent()
self:RegisterRedDot()
end
function CharacterInfoCtrl:OnEvent_PanelAdvance(nClosePanelId, nOpenPanelId)
self:PlaySwitchAnim(nClosePanelId, nOpenPanelId, false)
self:RefreshContent()
end
function CharacterInfoCtrl:OnEvent_PanelBack(nClosePanelId, nOpenPanelId)
self:PlaySwitchAnim(nClosePanelId, nOpenPanelId, true)
self:RefreshContent()
end
function CharacterInfoCtrl:OnEventTrigger_BeginDrag(eventTrigger, eventData)
self.nBeginX = eventData.position.x
self.nBeginTS = CS.UnityEngine.Time.time
end
function CharacterInfoCtrl:OnEvnetTrigger_EndDrag(eventTrigger, eventData)
if type(self.nBeginTS) == "number" and type(self.nBeginX) == "number" then
local nDelX = eventData.position.x - self.nBeginX
local nDelTS = CS.UnityEngine.Time.time - self.nBeginTS
if nDelTS < 0.3 then
if nDelX < 0 then
self:OnBtnClick_Right()
elseif 0 < nDelX then
self:OnBtnClick_Left()
end
end
end
end
return CharacterInfoCtrl
@@ -0,0 +1,10 @@
local CharacterInfoPanel = class("CharacterInfoPanel", BasePanel)
CharacterInfoPanel._nFADEINTYPE = 1
CharacterInfoPanel._nFadeInType = 0
CharacterInfoPanel._tbDefine = {
{
sPrefabPath = "CharacterInfoEx/CharacterInfoPanel.prefab",
sCtrlName = "Game.UI.CharacterInfoEx.CharacterInfoCtrl"
}
}
return CharacterInfoPanel
@@ -0,0 +1,98 @@
local BaseCtrl = require("GameCore.UI.BaseCtrl")
local CharacterRelationCtrl = class("CharacterRelationCtrl", BaseCtrl)
CharacterRelationCtrl._mapNodeConfig = {
safeAreaRoot = {
sNodeName = "----SafeAreaRoot----",
sComponentName = "GameObject"
},
favourPanel = {
sNodeName = "Favorability",
sCtrlName = "Game.UI.CharacterFavour.CharacterFavourCtrl"
},
recordPanel = {
sNodeName = "CharRecordInfoRoot",
sCtrlName = "Game.UI.CharacterRecord.CharacterRecordCtrl"
},
Reddot = {nCount = 1},
txtDub = {sComponentName = "TMP_Text"},
txtDubLabel = {sComponentName = "TMP_Text"},
txtName = {sComponentName = "TMP_Text"},
imgRareName = {sComponentName = "Image"}
}
CharacterRelationCtrl._mapEventConfig = {
[EventId.CharRelatePanelAdvance] = "OnEvent_PanelAdvance",
[EventId.CharRelatePanelBack] = "OnEvent_PanelBack",
[EventId.CharBgRefresh] = "OnEvent_RefreshPanel"
}
function CharacterRelationCtrl:Awake()
end
function CharacterRelationCtrl:RegisterRedDot(nCharId)
RedDotManager.RegisterNode(RedDotDefine.Role_AffinityTask, nCharId, self._mapNode.Reddot[1])
end
function CharacterRelationCtrl:OnEnable()
if self._panel.nPanelId ~= PanelId.CharacterRelation then
self._mapNode.safeAreaRoot.gameObject:SetActive(false)
else
self._mapNode.safeAreaRoot.gameObject:SetActive(true)
self:OnRefreshPanel()
end
end
function CharacterRelationCtrl:OnDisable()
end
function CharacterRelationCtrl:OnEvent_PanelAdvance(nClosePanelId, nOpenPanelId)
self:PlaySwitchAnim(nClosePanelId, nOpenPanelId)
end
function CharacterRelationCtrl:OnEvent_PanelBack(nClosePanelId, nOpenPanelId)
self:PlaySwitchAnim(nClosePanelId, nOpenPanelId)
end
function CharacterRelationCtrl:OnEvent_RefreshPanel()
if self._panel.nPanelId ~= PanelId.CharacterRelation then
return
end
self:OnRefreshPanel()
end
function CharacterRelationCtrl:OnRefreshPanel()
self.nCharId = self._panel.nCharId
self._mapNode.favourPanel:Refresh(self.nCharId)
self._mapNode.recordPanel:Refresh(self.nCharId)
local mapCfg = ConfigTable.GetData_Character(self.nCharId)
NovaAPI.SetTMPText(self._mapNode.txtName, mapCfg.Name)
self:SetSprite_FrameColor(self._mapNode.imgRareName, mapCfg.Grade, AllEnum.FrameType_New.Text)
NovaAPI.SetImageNativeSize(self._mapNode.imgRareName)
local mapCharDescCfg = ConfigTable.GetData("CharacterDes", self.nCharId)
local sColor, sCnCv, sCvDesc
local sCurrentVoLanguage = NovaAPI.GetCur_VoiceLanguage()
if mapCharDescCfg ~= nil then
sColor = mapCharDescCfg.CharColor
if sCurrentVoLanguage == "zh_CN" then
sCnCv = mapCharDescCfg.CnCv
sCvDesc = ConfigTable.GetUIText("ZN_CV")
elseif sCurrentVoLanguage == "ja_JP" then
sCnCv = mapCharDescCfg.JpCv
sCvDesc = ConfigTable.GetUIText("JP_CV")
end
else
sColor = ""
sCnCv = ""
sCvDesc = ""
end
NovaAPI.SetTMPText(self._mapNode.txtDub, sCnCv)
NovaAPI.SetTMPText(self._mapNode.txtDubLabel, sCvDesc)
self:RegisterRedDot(self.nCharId)
EventManager.Hit("Guide_PassiveCheck_Msg", "Guide_CharacterRelation")
end
function CharacterRelationCtrl:PlaySwitchAnim(nClosePanelId, nOpenPanelId)
if nClosePanelId == PanelId.CharacterRelation then
self._mapNode.safeAreaRoot.gameObject:SetActive(false)
self:ResetData()
end
if nOpenPanelId == PanelId.CharacterRelation then
self._mapNode.safeAreaRoot.gameObject:SetActive(true)
self:OnRefreshPanel()
end
end
function CharacterRelationCtrl:ResetData()
self._mapNode.favourPanel:ResetData()
self._mapNode.favourPanel:ResetData()
end
return CharacterRelationCtrl
@@ -0,0 +1,19 @@
local BasePanel = require("GameCore.UI.BasePanel")
local CharacterRelationPanel = class("CharacterRelationPanel", BasePanel)
CharacterRelationPanel._tbDefine = {
{
sPrefabPath = "CharacterInfoEx/CharacterRelationPanel.prefab",
sCtrlName = "Game.UI.CharacterInfoEx.CharacterRelationCtrl"
}
}
function CharacterRelationPanel:Awake()
end
function CharacterRelationPanel:OnEnable()
end
function CharacterRelationPanel:OnDisable()
end
function CharacterRelationPanel:OnDestroy()
end
function CharacterRelationPanel:OnRelease()
end
return CharacterRelationPanel
@@ -0,0 +1,280 @@
local CharAdvanceCtrl = class("CharAdvanceCtrl", BaseCtrl)
local LayoutRebuilder = CS.UnityEngine.UI.LayoutRebuilder
CharAdvanceCtrl._mapNodeConfig = {
txtTitleRank = {
sComponentName = "TMP_Text",
sLanguageId = "Template_CharRank"
},
txtLv = {sComponentName = "TMP_Text"},
txtLvMax = {nCount = 2, sComponentName = "TMP_Text"},
goAdvanceStar = {
sCtrlName = "Game.UI.TemplateEx.TemplateStarAdvanceCtrl"
},
goProperty = {},
trProperty = {sComponentName = "Transform"},
AdvanceBuffList = {
sNodeName = "AdvanceBuffList",
sComponentName = "LoopScrollView"
},
goMat = {
nCount = 4,
sCtrlName = "Game.UI.TemplateEx.TemplateMatCtrl"
},
btnAdd = {
nCount = 4,
sComponentName = "UIButton",
callback = "OnBtnClick_Tips"
},
btnAdvance = {
sComponentName = "UIButton",
callback = "OnBtnClick_Advance"
},
txtBtnAdvance = {
sComponentName = "TMP_Text",
sLanguageId = "Btn_AdvanceUp"
},
txtAdvanceTips = {sComponentName = "TMP_Text"},
imgCostIcon = {sComponentName = "Image"},
txtCostCount = {sComponentName = "TMP_Text"},
btnAutoFill = {
sComponentName = "UIButton",
callback = "OnBtnClick_AutoFill"
},
txtBtnAutoFill = {
sComponentName = "TMP_Text",
sLanguageId = "AutoDevelopment_Btn_Fill"
},
txtBuffHeight = {sComponentName = "TMP_Text"},
rtTxtBuffHeight = {
sNodeName = "txtBuffHeight",
sComponentName = "RectTransform"
},
txtBuffHeightAfter = {sComponentName = "TMP_Text"},
rtTxtBuffHeightAfter = {
sNodeName = "txtBuffHeightAfter",
sComponentName = "RectTransform"
}
}
CharAdvanceCtrl._mapEventConfig = {}
function CharAdvanceCtrl:_CalcGridHeight(sContent)
NovaAPI.SetTMPText(self._mapNode.txtBuffHeight, sContent)
LayoutRebuilder.ForceRebuildLayoutImmediate(self._mapNode.rtTxtBuffHeight)
local nH = self._mapNode.rtTxtBuffHeight.rect.height
return nH
end
function CharAdvanceCtrl:_CalcGridHeightAfter(sContent)
NovaAPI.SetTMPText(self._mapNode.txtBuffHeightAfter, sContent)
LayoutRebuilder.ForceRebuildLayoutImmediate(self._mapNode.rtTxtBuffHeightAfter)
local nH = self._mapNode.rtTxtBuffHeightAfter.rect.height + 14
return nH
end
function CharAdvanceCtrl:InitData(nCharId, mapCurLevel, nMaxAdvance)
self.nCharId = nCharId
self.mapLevel = mapCurLevel
self.nMaxAdvance = nMaxAdvance
self.mapChar = PlayerData.Char:GetCharDataByTid(self.nCharId)
self.mapAttrBefore = nil
self.mapAttrAfter = nil
self.tbMat = {}
self.nAdvanceGold = 0
local nAdvanceId = 100 * self.nCharId + self.mapChar.nAdvance + 1
local mapCfgData = ConfigTable.GetData("CharacterAdvance", nAdvanceId)
self.AdvanceUpData = mapCfgData
if type(mapCfgData) == "table" then
for i = 1, 4 do
local item = {}
local nItemId = mapCfgData["Tid" .. i]
local nItemNum = mapCfgData["Qty" .. i]
if type(nItemId) == "number" and type(nItemNum) == "number" and 0 < nItemId and 0 < nItemNum then
item.nItemId = nItemId
item.nItemNum = nItemNum
table.insert(self.tbMat, item)
end
end
self.nAdvanceGold = mapCfgData.GoldQty
end
local nAdvance = self.mapChar.nAdvance
if self.nMaxAdvance ~= nAdvance then
local nGrade = ConfigTable.GetData_Character(nCharId).Grade
local mapData = CacheTable.GetData("_CharRaritySequence", nGrade)
if mapData ~= nil and mapData[nAdvance] ~= nil then
local tbNeedMat = {}
for _, v in ipairs(self.tbMat) do
table.insert(tbNeedMat, {
nId = v.nItemId,
nCount = v.nItemNum
})
end
self.tbFillStep, self.tbUseItem, self.tbShowNeedItem = PlayerData.Item:AutoFillMat(tbNeedMat)
local nHasCoin = PlayerData.Coin:GetCoinCount(AllEnum.CoinItemId.Gold)
local bAbleAutoFill = next(self.tbUseItem) ~= nil and nHasCoin >= self.nAdvanceGold
self.nNeedWorldClass = mapData[nAdvance + 1].WorldClassLimit
local nCurWorldClass = PlayerData.Base:GetWorldClass()
self._mapNode.btnAdvance.gameObject:SetActive(nCurWorldClass >= self.nNeedWorldClass and not bAbleAutoFill)
self._mapNode.btnAutoFill.gameObject:SetActive(nCurWorldClass >= self.nNeedWorldClass and bAbleAutoFill)
self._mapNode.txtAdvanceTips.gameObject:SetActive(nCurWorldClass < self.nNeedWorldClass)
if nCurWorldClass < self.nNeedWorldClass then
NovaAPI.SetTMPText(self._mapNode.txtAdvanceTips, orderedFormat(ConfigTable.GetUIText("Char_Advance_WorldClass_Limit"), self.nNeedWorldClass))
end
end
end
end
function CharAdvanceCtrl:Refresh(nCharId, mapCurLevel, nMaxAdvance)
self:InitData(nCharId, mapCurLevel, nMaxAdvance)
self:RefreshLv()
self:RefreshAttr()
self:RefreshBuffInfo()
self:RefreshCoin()
self:RefreshMat()
end
function CharAdvanceCtrl:RefreshLv()
NovaAPI.SetTMPText(self._mapNode.txtLv, self.mapLevel.nLevel)
NovaAPI.SetTMPText(self._mapNode.txtLvMax[1], "/" .. self.mapLevel.nMaxLevel)
NovaAPI.SetTMPText(self._mapNode.txtLvMax[2], orderedFormat(ConfigTable.GetUIText("CharDev_UnlockLVDesc"), self.mapLevel.nNextMaxLv))
self._mapNode.goAdvanceStar:SetStar(self.mapChar.nAdvance, self.nMaxAdvance, self.mapChar.nAdvance + 1)
end
function CharAdvanceCtrl:RefreshAttr()
self.mapAttrBefore = PlayerData.Char:GetCharCfgAttr({1, 2}, self.nCharId, self.mapChar.nAdvance, self.mapChar.nLevel)
self.mapAttrAfter = PlayerData.Char:GetCharCfgAttr({1, 2}, self.nCharId, self.mapChar.nAdvance + 1, self.mapChar.nLevel)
delChildren(self._mapNode.trProperty)
for _, mapAttachAttr in ipairs(AllEnum.AttachAttr) do
local mapAttr = self.mapAttrBefore[mapAttachAttr.sKey]
if mapAttr and mapAttr.Value > 0 then
local goItemObj = instantiate(self._mapNode.goProperty, self._mapNode.trProperty)
goItemObj:SetActive(true)
local ctrlItem = self:BindCtrlByNode(goItemObj, "Game.UI.TemplateEx.TemplatePropertyCtrl")
local bValueChanged = self.mapAttrAfter[mapAttachAttr.sKey].Value ~= mapAttr.Value
if bValueChanged then
ctrlItem:SetItemProperty(mapAttr.Key, mapAttr.Value, self.mapAttrAfter[mapAttachAttr.sKey].Value)
else
ctrlItem:SetItemProperty(mapAttr.Key, mapAttr.Value)
end
end
end
end
function CharAdvanceCtrl:RefreshBuffInfo()
local buffCount = 0
self.tbGridHeight = {}
local mapAllPreview = PlayerData.Char:GetCharAdvancePreview(self.nCharId, self.mapChar.nAdvance + 1)
local mapPreview = {}
for _, v in ipairs(mapAllPreview) do
if v.nType ~= AllEnum.CharAdvancePreview.LevelMax then
table.insert(mapPreview, v)
end
end
self.mapPreviewDesc = {}
for _, v in ipairs(mapPreview) do
local AdvanceDescFront, AdvanceDescAfter = "", ""
if v.nType == AllEnum.CharAdvancePreview.SkillLevelMax then
AdvanceDescFront = ConfigTable.GetUIText("CharAdvance_Preview_Skill_LevelMax")
AdvanceDescAfter = orderedFormat(ConfigTable.GetUIText("CharAdvance_Preview_Level"), v.nMaxSkillLevel)
elseif v.nType == AllEnum.CharAdvancePreview.SkinUnlock then
AdvanceDescFront = ConfigTable.GetUIText("CharAdvance_Preview_SkinUnlock_1")
AdvanceDescAfter = ConfigTable.GetUIText("CharAdvance_Preview_SkinUnlock_2")
end
if AdvanceDescFront ~= "" or AdvanceDescAfter ~= "" then
buffCount = buffCount + 1
local nMaxHeight = math.max(self:_CalcGridHeight(AdvanceDescFront), self:_CalcGridHeightAfter(AdvanceDescAfter))
table.insert(self.tbGridHeight, nMaxHeight)
table.insert(self.mapPreviewDesc, {sFront = AdvanceDescFront, sAfter = AdvanceDescAfter})
end
end
if 0 < buffCount then
self._mapNode.AdvanceBuffList:InitEx(self.tbGridHeight, self, self.OnGridRefresh)
end
self._mapNode.AdvanceBuffList.gameObject:SetActive(0 < buffCount)
end
function CharAdvanceCtrl:OnGridRefresh(goGrid, gridIndex)
local index = gridIndex + 1
if self.mapPreviewDesc[index] ~= nil then
local txtBuff = goGrid.transform:Find("txtBuff")
if txtBuff ~= nil then
NovaAPI.SetTMPText(txtBuff:GetComponent("TMP_Text"), self.mapPreviewDesc[index].sFront)
end
local txtBuffContent = goGrid.transform:Find("txtBuffContent")
if txtBuffContent ~= nil then
NovaAPI.SetTMPText(txtBuffContent:GetComponent("TMP_Text"), self.mapPreviewDesc[index].sAfter)
end
end
local imageBar = goGrid.transform:Find("Image")
imageBar.gameObject:SetActive(1 < index)
local bOpen = false
local goLock = goGrid.transform:Find("goIconlock")
if goLock ~= nil then
goLock.gameObject:SetActive(not bOpen)
end
local goUnlock = goGrid.transform:Find("goIconOpen")
if goUnlock ~= nil then
goUnlock.gameObject:SetActive(bOpen)
end
end
function CharAdvanceCtrl:RefreshCoin()
self:SetSprite_Coin(self._mapNode.imgCostIcon, AllEnum.CoinItemId.Gold)
local nHasCoin = PlayerData.Coin:GetCoinCount(AllEnum.CoinItemId.Gold)
NovaAPI.SetTMPText(self._mapNode.txtCostCount, math.ceil(self.nAdvanceGold))
NovaAPI.SetTMPColor(self._mapNode.txtCostCount, nHasCoin >= self.nAdvanceGold and Blue_Normal or Red_Unable)
end
function CharAdvanceCtrl:RefreshMat()
local nMatCount = #self.tbMat
for i = 1, 4 do
self._mapNode.btnAdd[i].interactable = i <= nMatCount
if i <= nMatCount then
self._mapNode.goMat[i]:SetMat(self.tbMat[i].nItemId, self.tbMat[i].nItemNum)
else
self._mapNode.goMat[i]:SetMat(0)
end
end
end
function CharAdvanceCtrl:Awake()
end
function CharAdvanceCtrl:OnEnable()
end
function CharAdvanceCtrl:OnDisable()
end
function CharAdvanceCtrl:OnDestroy()
end
function CharAdvanceCtrl:OnBtnClick_Advance(btn)
for _, mapMat in pairs(self.tbMat) do
local nHas = PlayerData.Item:GetItemCountByID(mapMat.nItemId)
if nHas < mapMat.nItemNum then
EventManager.Hit(EventId.OpenMessageBox, ConfigTable.GetUIText("CHARUP_03"))
return
end
end
if self.nAdvanceGold > PlayerData.Coin:GetCoinCount(AllEnum.CoinItemId.Gold) then
EventManager.Hit(EventId.OpenMessageBox, ConfigTable.GetUIText("CHARUP_04"))
return
end
local callback = function()
local mapData = {
nLevel = self.mapLevel.nLevel,
nLevelMax = self.mapLevel.nNextMaxLv,
mapAttrBefore = self.mapAttrBefore,
mapAttrAfter = self.mapAttrAfter,
tbDesc = self.mapPreviewDesc,
nAdvance = self.mapChar.nAdvance,
nMaxAdvance = self.nMaxAdvance
}
EventManager.Hit(EventId.OpenPanel, PanelId.CharSucBar, mapData, false)
EventManager.Hit("CharDevelopmentRefresh")
if not PlayerData.CharSkin:CheckNewSkin() then
PlayerData.Voice:PlayCharVoice("exCharUp", self.nCharId)
end
end
PlayerData.Char:CharAdvance(self.nCharId, callback)
end
function CharAdvanceCtrl:OnBtnClick_AutoFill()
EventManager.Hit(EventId.OpenPanel, PanelId.FillMaterial, self.tbFillStep, self.tbUseItem, self.tbShowNeedItem)
end
function CharAdvanceCtrl:OnBtnClick_Tips(btn, nIndex)
if self.tbMat[nIndex] and self.tbMat[nIndex].nItemId > 0 then
local mapData = {
nTid = self.tbMat[nIndex].nItemId,
nNeedCount = self.tbMat[nIndex].nItemNum,
bShowDepot = true,
bShowJumpto = true
}
EventManager.Hit(EventId.OpenPanel, PanelId.ItemTips, btn.transform, mapData)
end
end
return CharAdvanceCtrl
@@ -0,0 +1,79 @@
local CharAdvanceNodeItemCtrl = class("CharAdvanceNodeItemCtrl", BaseCtrl)
CharAdvanceNodeItemCtrl._mapNodeConfig = {
advanceNodeAnim = {sNodeName = "adNode", sComponentName = "Animator"},
btnNode = {
sComponentName = "UIButton",
callback = "OnBtn_SelectNode"
},
advanceNode_gray = {},
txtAD = {nCount = 2, sComponentName = "TMP_Text"},
txtAdNode = {
sComponentName = "TMP_Text",
sLanguageId = "Advance_Name"
},
txtAdNodeGray = {
sComponentName = "TMP_Text",
sLanguageId = "Advance_Name"
},
Select = {},
redDotNode = {}
}
CharAdvanceNodeItemCtrl._mapEventConfig = {
SelectAdvanceNode = "OnSelectAdvanceNode"
}
function CharAdvanceNodeItemCtrl:RegisterRedDot()
RedDotManager.RegisterNode(RedDotDefine.Role_AdvanceReward, {
self.nCharId,
self.nAdvance
}, self._mapNode.redDotNode)
end
function CharAdvanceNodeItemCtrl:UnRegisterRedDot()
end
function CharAdvanceNodeItemCtrl:RefreshNode(nCharId, nAdvance, nCurAdvance, bZero, bSelect)
self.bSelect = false
self.nCharId = nCharId
self.nAdvance = nAdvance
self.nCurAdvance = nCurAdvance
self._mapNode.Select.gameObject:SetActive(false)
self._mapNode.advanceNode_gray.gameObject:SetActive(nCurAdvance < nAdvance or bZero)
for _, v in ipairs(self._mapNode.txtAD) do
NovaAPI.SetTMPText(v, nAdvance)
end
if bSelect ~= nil and bSelect == true then
self.bSelect = true
self._mapNode.Select.gameObject:SetActive(true)
self:PlayAnim("Node_idle")
self.animState = "Node_idle"
end
self:RegisterRedDot()
end
function CharAdvanceNodeItemCtrl:PlayAnim(sAnimName)
self._mapNode.advanceNodeAnim:Play(sAnimName)
end
function CharAdvanceNodeItemCtrl:SetSelect(bSelect)
if self.bSelect and not bSelect then
self:PlayAnim("Node_out")
self.animState = "Node_out"
end
self.bSelect = bSelect
self._mapNode.Select.gameObject:SetActive(bSelect)
if bSelect and self.animState ~= "Node_idle" then
self:PlayAnim("Node_in")
self.animState = "Node_idle"
if self.nAdvance <= self.nCurAdvance then
CS.WwiseAudioManager.Instance:PlaySound("ui_charinfo_levelup_select_button")
end
end
end
function CharAdvanceNodeItemCtrl:OnSelectAdvanceNode(nSelectAdvance)
self:SetSelect(nSelectAdvance == self.nAdvance)
end
function CharAdvanceNodeItemCtrl:OnBtn_SelectNode()
if self.bSelect then
return
end
EventManager.Hit("SelectAdvanceNode", self.nAdvance)
end
function CharAdvanceNodeItemCtrl:OnDisable()
end
return CharAdvanceNodeItemCtrl
@@ -0,0 +1,347 @@
local BaseCtrl = require("GameCore.UI.BaseCtrl")
local CharAdvancePreviewInfoCtrl = class("CharAdvancePreviewInfoCtrl", BaseCtrl)
local LayoutRebuilder = CS.UnityEngine.UI.LayoutRebuilder
CharAdvancePreviewInfoCtrl._mapNodeConfig = {
txtWindowTitle = {
sComponentName = "TMP_Text",
sLanguageId = "Advance_Preview_Title"
},
got_fullscreen_blur_blue1 = {
sNodeName = "t_fullscreen_blur_blue1",
sComponentName = "GameObject"
},
btnsnapshot = {
sNodeName = "snapshot",
sComponentName = "Button",
callback = "OnClosePanel"
},
aniadvancePreviewInfo = {
sNodeName = "advancePreviewInfo",
sComponentName = "Animator"
},
btnClose = {
sComponentName = "UIButton",
callback = "OnClosePanel"
},
loopAdNodeScrollView = {
sNodeName = "AdNodeScrollView",
sComponentName = "LoopScrollView"
},
txtNeedLv = {sComponentName = "TMP_Text"},
btnbtnAdReward = {
sNodeName = "btnAdReward",
sComponentName = "UIButton",
callback = "OnBtn_AdvanceReward"
},
txtbtnAdReward = {
sComponentName = "TMP_Text",
sLanguageId = "Btn_EarnReward"
},
goadvanceReward = {
sNodeName = "advanceRewardRoot",
sComponentName = "GameObject"
},
loopAdPre = {
sNodeName = "AdPre",
sComponentName = "LoopScrollView"
},
txttxtAdRewCoin = {
sNodeName = "txtAdRewCoin",
sComponentName = "TMP_Text"
},
loopUpgradeMaterial = {
sNodeName = "PreviewUpgradeMaterial",
sComponentName = "LoopScrollView"
},
loopUpgradeReward = {
sNodeName = "UpgradeReward",
sComponentName = "LoopScrollView"
},
goadvanceRewardRoot = {
sNodeName = "advanceRewardRoot",
sComponentName = "GameObject"
},
txtAdvanceMat = {
sComponentName = "TMP_Text",
sLanguageId = "Advance_Need_Mat"
},
txtAdvanceReward = {
sComponentName = "TMP_Text",
sLanguageId = "Advance_Preview_Title"
},
txtWaitPicked = {sComponentName = "TMP_Text"},
txtBuffHeight = {sComponentName = "TMP_Text"},
rtTxtBuffHeight = {
sNodeName = "txtBuffHeight",
sComponentName = "RectTransform"
},
txtBuffHeightAfter = {sComponentName = "TMP_Text"},
rtTxtBuffHeightAfter = {
sNodeName = "txtBuffHeightAfter",
sComponentName = "RectTransform"
}
}
CharAdvancePreviewInfoCtrl._mapEventConfig = {
SelectAdvanceNode = "OnEvent_RefreshAdInfo"
}
function CharAdvancePreviewInfoCtrl:_CalcGridHeight(sContent)
NovaAPI.SetTMPText(self._mapNode.txtBuffHeight, sContent)
LayoutRebuilder.ForceRebuildLayoutImmediate(self._mapNode.rtTxtBuffHeight)
local nH = self._mapNode.rtTxtBuffHeight.rect.height + 14
return nH
end
function CharAdvancePreviewInfoCtrl:_CalcGridHeightAfter(sContent)
NovaAPI.SetTMPText(self._mapNode.txtBuffHeightAfter, sContent)
LayoutRebuilder.ForceRebuildLayoutImmediate(self._mapNode.rtTxtBuffHeightAfter)
local nH = self._mapNode.rtTxtBuffHeightAfter.rect.height + 14
return nH
end
function CharAdvancePreviewInfoCtrl:Awake()
end
function CharAdvancePreviewInfoCtrl:OnEnable()
local tbParam = self:GetPanelParam()
if type(tbParam) == "table" then
self:ResetData(tbParam[1], tbParam[2], tbParam[3])
end
end
function CharAdvancePreviewInfoCtrl:OnDisable()
if self.AdvanceNodeList then
for k, v in pairs(self.AdvanceNodeList) do
self:UnbindCtrlByNode(v)
end
self.AdvanceNodeList = {}
end
end
function CharAdvancePreviewInfoCtrl:OnClosePanel()
self._mapNode.aniadvancePreviewInfo:Play("t_window_04_t_out")
self._mapNode.got_fullscreen_blur_blue1:SetActive(false)
EventManager.Hit(EventId.TemporaryBlockInput, 0.3)
self:AddTimer(1, 0.3, "OnCloseAnimFinish", true, true, true)
end
function CharAdvancePreviewInfoCtrl:OnCloseAnimFinish()
EventManager.Hit(EventId.ClosePanel, PanelId.CharAdvancePreview)
end
function CharAdvancePreviewInfoCtrl:ResetData(maxAdvance, charId, curGradeLevelArr)
self.maxAdvance = maxAdvance
self.charId = charId
self.curGradeLevelArr = curGradeLevelArr
self._mapNode.got_fullscreen_blur_blue1:SetActive(true)
self._mapNode.aniadvancePreviewInfo:Play("t_window_04_t_in")
if self.charId ~= nil then
self.playerCharData = PlayerData.Char:GetCharDataByTid(self.charId)
end
if self.maxAdvance ~= nil then
self:RefreshAdvanceNode()
else
self:OnClosePanel()
end
end
function CharAdvancePreviewInfoCtrl:RefreshAdvanceNode()
local nAdvance = self.playerCharData.nAdvance
local nCharAdvance = nAdvance
local canPickReward = PlayerData.State:GetCanPickedAdvanceRewards(self.charId, self.maxAdvance)
if canPickReward ~= nil and canPickReward ~= 0 then
nAdvance = canPickReward
end
self.bZero = false
if nAdvance == 0 then
nAdvance = 1
self.bZero = true
end
self.defaultAdvance = nCharAdvance
if self.AdvanceNodeList == nil then
self.AdvanceNodeList = {}
end
for k, v in pairs(self.AdvanceNodeList) do
self:UnbindCtrlByNode(v)
end
self.AdvanceNodeList = {}
self.curSelectAdvance = nAdvance
self._mapNode.loopAdNodeScrollView:Init(self.maxAdvance, self, self.RefreshAdvanceNodeGridItem)
local movePos = 0 < nAdvance - 2 and nAdvance - 2 or 0
self._mapNode.loopAdNodeScrollView:SetScrollGridPos(movePos, 0.05)
EventManager.Hit("SelectAdvanceNode", nAdvance)
end
function CharAdvancePreviewInfoCtrl:RefreshAdvanceNodeGridItem(go)
local index = tonumber(go.name) + 1
if self.AdvanceNodeList[go] ~= nil then
self:UnbindCtrlByNode(self.AdvanceNodeList[go])
self.AdvanceNodeList[go] = nil
end
local ctrlItem = self:BindCtrlByNode(go, "Game.UI.CharacterInfoEx.CharAdvanceNodeItemCtrl")
self.AdvanceNodeList[go] = ctrlItem
ctrlItem:RefreshNode(self.charId, index, self.playerCharData.nAdvance, self.bZero, index == self.curSelectAdvance)
end
function CharAdvancePreviewInfoCtrl:RefreshAdvanceBuffs()
local buffCount = 0
self.tbGridHeight = {}
local mapPreview = PlayerData.Char:GetCharAdvancePreview(self.charId, self.curSelectAdvance)
self.mapPreviewDesc = {}
for _, v in ipairs(mapPreview) do
local AdvanceDescFront, AdvanceDescAfter = "", ""
if v.nType == AllEnum.CharAdvancePreview.LevelMax then
AdvanceDescFront = ConfigTable.GetUIText("CharAdvance_Preview_LevelMax")
AdvanceDescAfter = orderedFormat(ConfigTable.GetUIText("CharAdvance_Preview_Level"), v.nMaxLevel)
elseif v.nType == AllEnum.CharAdvancePreview.SkillLevelMax then
AdvanceDescFront = ConfigTable.GetUIText("CharAdvance_Preview_Skill_LevelMax")
AdvanceDescAfter = orderedFormat(ConfigTable.GetUIText("CharAdvance_Preview_Level"), v.nMaxSkillLevel)
elseif v.nType == AllEnum.CharAdvancePreview.SkinUnlock then
AdvanceDescFront = ConfigTable.GetUIText("CharAdvance_Preview_SkinUnlock_1")
AdvanceDescAfter = ConfigTable.GetUIText("CharAdvance_Preview_SkinUnlock_2")
end
if AdvanceDescFront ~= "" or AdvanceDescAfter ~= "" then
buffCount = buffCount + 1
local nMaxHeight = math.max(self:_CalcGridHeight(AdvanceDescFront), self:_CalcGridHeightAfter(AdvanceDescAfter))
table.insert(self.tbGridHeight, nMaxHeight)
table.insert(self.mapPreviewDesc, {sFront = AdvanceDescFront, sAfter = AdvanceDescAfter})
end
end
if 0 < buffCount then
self._mapNode.loopAdPre:InitEx(self.tbGridHeight, self, self.RefreshPreAdvanceBuffsGridItem)
end
self._mapNode.loopAdPre.gameObject:SetActive(0 < buffCount)
end
function CharAdvancePreviewInfoCtrl:RefreshPreAdvanceBuffsGridItem(go)
local index = tonumber(go.name) + 1
if self.mapPreviewDesc[index] ~= nil then
local txtBuff = go.transform:Find("txtBuff")
if txtBuff ~= nil then
NovaAPI.SetTMPText(txtBuff:GetComponent("TMP_Text"), self.mapPreviewDesc[index].sFront)
end
local txtBuffContent = go.transform:Find("txtBuffContent")
if txtBuffContent ~= nil then
NovaAPI.SetTMPText(txtBuffContent:GetComponent("TMP_Text"), self.mapPreviewDesc[index].sAfter)
end
end
local imageBar = go.transform:Find("Image")
imageBar.gameObject:SetActive(1 < index)
local bOpen = self.playerCharData.nAdvance >= self.curSelectAdvance
local goLock = go.transform:Find("goIconlock")
if goLock ~= nil then
goLock.gameObject:SetActive(not bOpen)
end
local goUnlock = go.transform:Find("goIconOpen")
if goUnlock ~= nil then
goUnlock.gameObject:SetActive(bOpen)
end
end
function CharAdvancePreviewInfoCtrl:RefreshPreAdvanceMaterials()
local index = 1
self.AdvanceMaterialData = {}
while self.AdvanceUpData["Tid" .. index] ~= nil do
local tid = self.AdvanceUpData["Tid" .. index]
if tid ~= 0 then
local Rarity = AllEnum.FrameColor_New[ConfigTable.GetData_Item(tid).Rarity]
table.insert(self.AdvanceMaterialData, {
id = tid,
count = self.AdvanceUpData["Qty" .. index],
tid = index,
nRarity = Rarity
})
end
index = index + 1
end
NovaAPI.SetTMPText(self._mapNode.txttxtAdRewCoin, self.AdvanceUpData.GoldQty)
if #self.AdvanceMaterialData > 0 then
table.sort(self.AdvanceMaterialData, function(a, b)
if a.nRarity ~= b.nRarity then
return a.nRarity < b.nRarity
else
return a.tid < b.tid
end
end)
self._mapNode.loopUpgradeMaterial:Init(#self.AdvanceMaterialData, self, self.RefreshPreAdvanceMaterialsGridItem, self.BtnMaterialInfoGridClick)
end
end
function CharAdvancePreviewInfoCtrl:RefreshPreAdvanceMaterialsGridItem(go)
local index = tonumber(go.name) + 1
local itemCtrl = self:BindCtrlByNode(go, "Game.UI.TemplateEx.TemplateItemCtrl")
local data = self.AdvanceMaterialData[index]
itemCtrl:SetItem(data.id, nil, data.count, nil, false, nil, nil, true)
end
function CharAdvancePreviewInfoCtrl:BtnMaterialInfoGridClick(goGrid, gridIndex)
local nIndex = gridIndex + 1
local data = self.AdvanceMaterialData[nIndex]
if nil == data then
return
end
local item = goGrid.transform:Find("AnimRoot/item")
UTILS.ClickItemGridWithTips(data.id, item.transform, true, true, false)
end
function CharAdvancePreviewInfoCtrl:RefreshRewardInfo()
local CanPickupReward = PlayerData.State:GetCharAdvanceRewards(self.charId, self.curSelectAdvance)
self._mapNode.btnbtnAdReward.gameObject:SetActive(CanPickupReward)
local index = 1
self.AdvanceRewardData = {}
while self.AdvanceUpData["AwardTid" .. index] ~= nil do
local awardTid = self.AdvanceUpData["AwardTid" .. index]
if awardTid ~= 0 then
table.insert(self.AdvanceRewardData, {
id = awardTid,
count = self.AdvanceUpData["AwardQty" .. index],
tid = index
})
end
index = index + 1
end
self._mapNode.goadvanceReward.gameObject:SetActive(#self.AdvanceRewardData > 0)
if #self.AdvanceRewardData <= 0 then
return
end
self._mapNode.txtWaitPicked.gameObject:SetActive(self.playerCharData.nAdvance < self.curSelectAdvance)
if self.playerCharData.nAdvance < self.curSelectAdvance then
NovaAPI.SetTMPText(self._mapNode.txtWaitPicked, orderedFormat(ConfigTable.GetUIText("Advance_Waiting_Picked"), self.curSelectAdvance - self.playerCharData.nAdvance))
end
self._mapNode.txtWaitPicked.gameObject:SetActive(self.playerCharData.nAdvance < self.curSelectAdvance)
if #self.AdvanceRewardData > 0 then
table.sort(self.AdvanceRewardData, function(a, b)
if not a and not b then
if AllEnum.FrameColor_New[ConfigTable.GetData_Item(a.id).Rarity] > AllEnum.FrameColor_New[ConfigTable.GetData_Item(b.id).Rarity] then
return true
elseif AllEnum.FrameColor_New[ConfigTable.GetData_Item(a.id).Rarity] == AllEnum.FrameColor_New[ConfigTable.GetData_Item(b.id).Rarity] then
return a.tid < b.tid
else
return false
end
end
return true
end)
self._mapNode.loopUpgradeReward:Init(#self.AdvanceRewardData, self, self.RefreshRewardInfoGridItem, self.BtnRewardInfoGridClick)
end
end
function CharAdvancePreviewInfoCtrl:RefreshRewardInfoGridItem(go)
local index = tonumber(go.name) + 1
local ctrl = self:BindCtrlByNode(go, "Game.UI.TemplateEx.TemplateItemCtrl")
local data = self.AdvanceRewardData[index]
local CanPickupReward = PlayerData.State:GetCharAdvanceRewards(self.charId, self.curSelectAdvance)
if CanPickupReward or self.playerCharData.nAdvance < self.curSelectAdvance then
ctrl:SetItem(data.id, nil, data.count, nil, false, nil, nil, true)
else
ctrl:SetItem(data.id, nil, data.count, nil, true, nil, nil, true)
end
end
function CharAdvancePreviewInfoCtrl:BtnRewardInfoGridClick(goGrid, gridIndex)
local nIndex = gridIndex + 1
local data = self.AdvanceRewardData[nIndex]
if nil == data then
return
end
local item = goGrid.transform:Find("AnimRoot/item")
UTILS.ClickItemGridWithTips(data.id, item.transform, true, true, false)
end
function CharAdvancePreviewInfoCtrl:OnBtn_AdvanceReward(btn)
local callback = function()
self:RefreshAdvanceNode()
end
PlayerData.Char:CharAdvanceReward(self.charId, self.curSelectAdvance, callback)
end
function CharAdvancePreviewInfoCtrl:OnEvent_RefreshAdInfo(nSelectAdvance)
NovaAPI.SetTMPText(self._mapNode.txtNeedLv, orderedFormat(ConfigTable.GetUIText("Advance_Need_Level"), self.curGradeLevelArr[nSelectAdvance]))
local AdvanceUpId = 100 * self.charId + nSelectAdvance
self.AdvanceUpData = ConfigTable.GetData("CharacterAdvance", AdvanceUpId)
self.curSelectAdvance = nSelectAdvance
self:RefreshAdvanceBuffs()
self:RefreshPreAdvanceMaterials()
self:RefreshRewardInfo()
end
return CharAdvancePreviewInfoCtrl
@@ -0,0 +1,20 @@
local BasePanel = require("GameCore.UI.BasePanel")
local CharAdvancePreviewInfoPanel = class("CharAdvancePreviewInfoPanel", BasePanel)
CharAdvancePreviewInfoPanel._bIsMainPanel = false
CharAdvancePreviewInfoPanel._tbDefine = {
{
sPrefabPath = "CharacterInfoEx/CharAdvancePreviewInfoPanel.prefab",
sCtrlName = "Game.UI.CharacterInfoEx.CharAdvancePreviewInfoCtrl"
}
}
function CharAdvancePreviewInfoPanel:Awake()
end
function CharAdvancePreviewInfoPanel:OnEnable()
end
function CharAdvancePreviewInfoPanel:OnDisable()
end
function CharAdvancePreviewInfoPanel:OnDestroy()
end
function CharAdvancePreviewInfoPanel:OnRelease()
end
return CharAdvancePreviewInfoPanel
@@ -0,0 +1,106 @@
local CharAttrDetailCtrl = class("CharAttrDetailCtrl", BaseCtrl)
local GamepadUIManager = require("GameCore.Module.GamepadUIManager")
CharAttrDetailCtrl._mapNodeConfig = {
aniBlur = {sComponentName = "Animator"},
btnBlur = {
sNodeName = "snapshot",
sComponentName = "Button",
callback = "OnBtnClick_Close"
},
goProperty = {nCount = 3},
Content = {sComponentName = "Transform"},
aniBox = {
sNodeName = "t_window_04",
sComponentName = "Animator"
},
btnClose = {
sComponentName = "UIButton",
callback = "OnBtnClick_Close"
},
txtWindowTitle = {
sComponentName = "TMP_Text",
sLanguageId = "Char_AttrDetail"
},
ActionBar = {
sCtrlName = "Game.UI.ActionBar.ActionBarCtrl"
},
btnShortcutClose = {
sComponentName = "NaviButton",
callback = "OnBtnClick_Close"
}
}
CharAttrDetailCtrl._mapEventConfig = {}
function CharAttrDetailCtrl:InitData(attrList, eet)
self.tbAttr = {}
for i = 1, 29 do
local nEET = AllEnum.CharAttr[i].nEET
if not nEET or eet == nEET then
local nGroup = AllEnum.CharAttr[i].nGroup
if not self.tbAttr[nGroup] then
self.tbAttr[nGroup] = {}
end
table.insert(self.tbAttr[nGroup], {
mapCharAttr = AllEnum.CharAttr[i],
mapAttrData = attrList[i],
bSimple = i <= 3
})
end
end
end
function CharAttrDetailCtrl:Refresh()
delChildren(self._mapNode.Content)
for _, tbGroup in pairs(self.tbAttr) do
local nGroupCount = #tbGroup
local goItemObj = instantiate(self._mapNode.goProperty[nGroupCount], self._mapNode.Content)
goItemObj:SetActive(true)
for i = 1, nGroupCount do
local goBar = goItemObj.transform:Find("goBar" .. i).gameObject
local ctrlItem = self:BindCtrlByNode(goBar, "Game.UI.CharacterInfoEx.CharAttrDetailPropertyCtrl")
ctrlItem:SetProperty(tbGroup[i].mapCharAttr, tbGroup[i].mapAttrData, i == 1, tbGroup[i].bSimple)
end
end
end
function CharAttrDetailCtrl:Awake()
local tbParam = self:GetPanelParam()
local attrList, eet
if type(tbParam) == "table" then
attrList = tbParam[1]
eet = tbParam[2]
end
self:InitData(attrList, eet)
self._mapNode.btnShortcutClose.gameObject:SetActive(GamepadUIManager.GetInputState())
if GamepadUIManager.GetInputState() then
local tbConfig = {
{
sAction = "Back",
sLang = "ActionBar_Back"
}
}
self._mapNode.ActionBar:InitActionBar(tbConfig)
end
end
function CharAttrDetailCtrl:OnEnable()
if GamepadUIManager.GetInputState() then
GamepadUIManager.EnableGamepadUI("CharAttrDetailCtrl", self:GetGamepadUINode(), nil, true)
end
self._mapNode.aniBlur.gameObject:SetActive(true)
self._mapNode.aniBox:Play("t_window_04_t_in")
EventManager.Hit(EventId.TemporaryBlockInput, 0.3)
self:Refresh()
end
function CharAttrDetailCtrl:OnDisable()
if GamepadUIManager.GetInputState() then
GamepadUIManager.DisableGamepadUI("CharAttrDetailCtrl")
end
end
function CharAttrDetailCtrl:OnDestroy()
end
function CharAttrDetailCtrl:OnBtnClick_Close()
self._mapNode.aniBlur:SetTrigger("tOut")
self._mapNode.aniBox:Play("t_window_04_t_out")
EventManager.Hit(EventId.TemporaryBlockInput, 0.2)
self:AddTimer(1, 0.2, function()
EventManager.Hit(EventId.ClosePanel, PanelId.CharAttrDetail)
end, true, true, true)
end
return CharAttrDetailCtrl
@@ -0,0 +1,9 @@
local CharAttrDetailPanel = class("CharAttrDetailPanel", BasePanel)
CharAttrDetailPanel._bIsMainPanel = false
CharAttrDetailPanel._tbDefine = {
{
sPrefabPath = "CharacterInfoEx/CharAttrDetailPanel.prefab",
sCtrlName = "Game.UI.CharacterInfoEx.CharAttrDetailCtrl"
}
}
return CharAttrDetailPanel
@@ -0,0 +1,76 @@
local CharAttrDetailPropertyCtrl = class("CharAttrDetailPropertyCtrl", BaseCtrl)
CharAttrDetailPropertyCtrl._mapNodeConfig = {
imgIcon = {sComponentName = "Image"},
txtProperty = {sComponentName = "TMP_Text"},
txtValue1 = {sComponentName = "TMP_Text"},
txtValue2 = {sComponentName = "TMP_Text"},
btnTip = {
sComponentName = "UIButton",
callback = "OnBtnClick_Tip"
}
}
CharAttrDetailPropertyCtrl._mapEventConfig = {}
function CharAttrDetailPropertyCtrl:SetProperty(mapCharAttr, mapAttrData, bMain, bSimple)
self._mapNode.imgIcon.gameObject:SetActive(bMain)
local mapAttributeDesc = self:_GetAttributeDesc(mapCharAttr.sKey)
if not mapAttributeDesc then
return
end
local sValue, sValueAdd = "", ""
local nBaseValue = mapAttrData.baseValue
local nAddValue = mapAttrData.totalValue - mapAttrData.baseValue
sValue = self:_TransValueFormat(nBaseValue, mapCharAttr.bPercent, mapAttributeDesc.Format)
sValueAdd = self:_TransValueFormat(nAddValue, mapCharAttr.bPercent, mapAttributeDesc.Format, true)
if nAddValue <= 0.01 then
sValueAdd = ""
end
if bSimple then
self:_RefreshContent(mapAttributeDesc.Icon, ConfigTable.GetUIText(mapCharAttr.sLanguageId_Simple), sValue, sValueAdd, mapAttributeDesc.WordID)
else
self:_RefreshContent(mapAttributeDesc.Icon, mapAttributeDesc.Desc, sValue, sValueAdd, mapAttributeDesc.WordID)
end
end
function CharAttrDetailPropertyCtrl:_GetAttributeDesc(sKey)
local mapAttributeDesc = CacheTable.GetData("_AttributeDesc", sKey)
if mapAttributeDesc == nil then
printError("EffectType未配置:" .. sKey)
self:_RefreshContent(nil, "", "")
return false
else
return mapAttributeDesc
end
end
function CharAttrDetailPropertyCtrl:_RefreshContent(sIcon, sName, sValue1, sValue2, nWord)
if sIcon and sIcon ~= "" then
self:SetPngSprite(self._mapNode.imgIcon, sIcon)
end
NovaAPI.SetTMPText(self._mapNode.txtProperty, sName)
if sValue2 and sValue2 ~= "" then
self._mapNode.txtValue2.gameObject:SetActive(true)
NovaAPI.SetTMPText(self._mapNode.txtValue1, sValue1)
NovaAPI.SetTMPText(self._mapNode.txtValue2, sValue2)
else
NovaAPI.SetTMPText(self._mapNode.txtValue1, sValue1)
self._mapNode.txtValue2.gameObject:SetActive(false)
end
if nWord and nWord ~= 0 then
self._mapNode.btnTip.gameObject:SetActive(true)
self.sWord = tostring(nWord)
else
self._mapNode.btnTip.gameObject:SetActive(false)
end
end
function CharAttrDetailPropertyCtrl:_TransValueFormat(nValue, bPercent, nFormat, bAdd)
if bPercent then
nValue = nValue / 100
end
local sValue = FormatEffectValue(nValue, bPercent, nFormat)
if bAdd then
sValue = "+" .. sValue
end
return sValue
end
function CharAttrDetailPropertyCtrl:OnBtnClick_Tip(btn)
UTILS.ClickWordLink(btn, self.sWord)
end
return CharAttrDetailPropertyCtrl
+349
View File
@@ -0,0 +1,349 @@
local CharBgCtrl = class("CharBgCtrl", BaseCtrl)
local PlayerCharData = PlayerData.Char
local GameResourceLoader = require("Game.Common.Resource.GameResourceLoader")
local Actor2DManager = require("Game.Actor2D.Actor2DManager")
local Path = require("path")
local LocalSettingData = require("GameCore.Data.LocalSettingData")
local ResTypeAny = GameResourceLoader.ResType.Any
local LayerMask = CS.UnityEngine.LayerMask
local RendererProjectionModifier = CS.RendererProjectionModifier
local typeof = typeof
CharBgCtrl._mapNodeConfig = {
imgBgRT = {
sNodeName = "----Actor2D----",
sComponentName = "RawImage"
},
UIDrag = {
sComponentName = "UIDrag",
callback = "OnDrag_Character"
},
rtBgRoot = {sNodeName = "----bg----", sComponentName = "Transform"},
animBgLeft = {sNodeName = "bgLeft", sComponentName = "Animator"},
animBgMiddle = {sNodeName = "bgMiddle", sComponentName = "Animator"},
rtOffScreenRoot = {
sNodeName = "Char_OffScreen_Renderer",
sComponentName = "Transform"
},
trCamera = {
sNodeName = "OffScreen3DCamera",
sComponentName = "Camera"
},
bgRight = {
sComponentName = "SpriteRenderer"
},
trCharacter = {sNodeName = "animator", sComponentName = "Transform"},
trPanelOffsetL2D = {
sNodeName = "panel_offset",
sComponentName = "Transform"
},
trActorOffsetL2d = {
sNodeName = "actor_offset",
sComponentName = "Transform"
},
trPng = {sNodeName = "PNG", sComponentName = "Transform"},
trL2D = {sNodeName = "L2D", sComponentName = "Transform"},
spr_body = {
sNodeName = "sp_body",
sComponentName = "SpriteRenderer"
},
spr_face = {
sNodeName = "sp_face",
sComponentName = "SpriteRenderer"
},
actor2dNode = {
sNodeName = "----Actor2D_Node----",
sComponentName = "Transform"
}
}
CharBgCtrl._mapEventConfig = {
[EventId.CharBgRefresh] = "OnEvent_RefreshPanel",
[EventId.CharRelatePanelAdvance] = "OnEvent_PanelSwitch",
[EventId.CharRelatePanelBack] = "OnEvent_PanelSwitch",
[EventId.HideCharBgActor] = "OnEvent_HideCharBgActor",
[EventId.RevertCharBgActor] = "OnEvent_RevertCharBgActor",
PlayCharL2DAnim = "PlayCharL2DAnim",
PlayCharBgLeftAnim = "PlayCharBgLeftAnim",
ChangeCharBgDrag = "OnEvent_ChangeDrag",
SwitchCurChar = "OnEvent_SwitchCurChar"
}
function CharBgCtrl:CreateRT()
end
function CharBgCtrl:ReleaseRT()
self._mapNode.trCamera.targetTexture = nil
NovaAPI.SetTexture(self._mapNode.imgBgRT, nil)
if self.rtPanel ~= nil then
GameUIUtils.ReleaseRenderTexture(self.rtPanel)
self.rtPanel = nil
end
end
function CharBgCtrl:GetOffsetData(sOffset)
local objOffset
if nil == self.mapOffsetObj[sOffset] then
objOffset = self:LoadAsset(sOffset, typeof(CS.Actor2DOffsetData))
self.mapOffsetObj[sOffset] = objOffset
else
objOffset = self.mapOffsetObj[sOffset]
end
local nShowPanelId = self:GetOffsetPanelId()
if nil == objOffset then
printError(string.format("角色关联界面 加载偏移数据失败!!!panelId = %s, 加载路径[%s]", nShowPanelId, sOffset))
return Vector3.zero, Vector3.one
end
local nX, nY = 0, 0
local s, x, y = objOffset:GetOffsetData(nShowPanelId, indexOfPose("a"), true, nX, nY)
local vPos = Vector3(x, y, 0)
local vScale = Vector3(s, s, 1)
return vPos, vScale
end
function CharBgCtrl:GetOffsetPanelId()
local nShowPanelId = self._panel.nPanelId
local tbConfig = Actor2DManager.GetMapPanelConfig(self._panel.nPanelId)
if nil ~= tbConfig and tbConfig.nReuse > 0 then
nShowPanelId = tbConfig.nReuse
end
return nShowPanelId
end
function CharBgCtrl:CheckUseL2D()
local bL2D = false
local tbConfig = Actor2DManager.GetMapPanelConfig(self._panel.nPanelId)
if nil ~= tbConfig then
bL2D = tbConfig.bL2D and LocalSettingData.mapData.UseLive2D
end
return bL2D
end
function CharBgCtrl:GetName(sPortrait, sFace)
local sFileFullName = Path.basename(sPortrait)
local sFileExtName = Path.extension(sPortrait)
local sFileName = string.gsub(sFileFullName, sFileExtName, "")
sFileName = string.gsub(sFileName, "_a", "")
local sBodyName = string.format("%s_%s", sFileName, "001")
local sFaceName = string.format("%s_%s", sFileName, sFace)
return sBodyName, sFaceName
end
function CharBgCtrl:SetCharacterPng(nSkinId, nType)
local bSetSuccess, nT, nAnimLength, tbRenderer = Actor2DManager.SetActor2DWithRender(self._panel.nPanelId, self._mapNode.imgBgRT, self.nCharId, nSkinId, nil, self._mapNode.actor2dNode)
if bSetSuccess and self.lasttrPanelOffsetL2DPos ~= nil then
self._mapNode.trPanelOffsetL2D:DOLocalMoveX(self.lasttrPanelOffsetL2DPos, 0):SetUpdate(true)
end
end
function CharBgCtrl:SetCharacterL2D(nSkinId, nType)
if nil ~= self.tbRenderer then
if self.tbRenderer.nSkinId == nSkinId then
return
end
self:RecycleCharacter()
end
local bSetSuccess, nT, nAnimLength, tbRenderer = Actor2DManager.SetActor2DWithRender(self._panel.nPanelId, self._mapNode.imgBgRT, self.nCharId, nSkinId, nil, self._mapNode.actor2dNode)
if bSetSuccess then
self.tbRenderer = {}
self.tbRenderer.nSkinId = nSkinId
self.tbRenderer.tbRenderer = tbRenderer
self.mapCharacter[nSkinId] = self.tbRenderer
Actor2DManager.PlayL2DAnim(self.tbRenderer.tbRenderer.trL2DIns, "idle", true, true)
if self.lasttrPanelOffsetL2DPos ~= nil then
self._mapNode.trPanelOffsetL2D:DOLocalMoveX(self.lasttrPanelOffsetL2DPos, 0):SetUpdate(true)
end
end
local skinCfgData = ConfigTable.GetData_CharacterSkin(nSkinId)
NovaAPI.SetSpriteRendererSprite(self._mapNode.bgRight, self:LoadAsset(skinCfgData.Bg .. ".png", typeof(Sprite)))
end
function CharBgCtrl:SetCharacter(nCharId)
if nil ~= nCharId and nCharId ~= self.nCharId then
self.nCharId = nCharId
end
local nSkinId = PlayerCharData:GetCharSkinId(self.nCharId)
local bL2D = self:CheckUseL2D()
local nType = AllEnum.Actor2DType.Normal
if bL2D then
self:SetCharacterL2D(nSkinId, nType)
else
self:SetCharacterPng(nSkinId, nType)
end
self._mapNode.trL2D.gameObject:SetActive(bL2D)
self._mapNode.trPng.gameObject:SetActive(not bL2D)
local skinCfgData = ConfigTable.GetData_CharacterSkin(nSkinId)
local vPos, vScale = self:GetOffsetData(skinCfgData.Offset)
self._mapNode.trActorOffsetL2d.localPosition = vPos
self._mapNode.trActorOffsetL2d.localScale = vScale
end
function CharBgCtrl:PlayCharL2DAnim(animName, bLoop, bForcePlay)
if self.tbRenderer ~= nil and self.tbRenderer.trL2DIns ~= nil then
Actor2DManager.PlayL2DAnim(self.tbRenderer.tbRenderer.trL2DIns.transform, animName, bLoop, bForcePlay)
end
end
function CharBgCtrl:PlayCharBgLeftAnim(bIn)
if bIn then
self._mapNode.animBgLeft:Play("CharBgPanelBg_in")
else
self._mapNode.animBgLeft:Play("CharBgPanelBg_out")
end
end
function CharBgCtrl:RecycleCharacter()
self.mapCharacter[self.tbRenderer.nSkinId] = self.tbRenderer
Actor2DManager.UnSetActor2DWithRender(self.tbRenderer.tbRenderer)
end
function CharBgCtrl:ClearCharacter()
for k, v in pairs(self.mapCharacter) do
Actor2DManager.UnSetActor2DWithRender(v.tbRenderer)
end
self.mapCharacter = {}
self.tbRenderer = nil
self._mapNode.trPanelOffsetL2D.localPosition = Vector3.zero
self._mapNode.trPanelOffsetL2D.localScale = Vector3.one
self._mapNode.trActorOffsetL2d.localPosition = Vector3.zero
self._mapNode.trActorOffsetL2d.localScale = Vector3.one
end
function CharBgCtrl:RefreshBgShow()
local nPanelId = self._panel.nPanelId
local panelCfg = self.tbPanelCfg[nPanelId]
if nil == panelCfg then
return
end
self.nType = panelCfg.type
if self.nType == AllEnum.CharBgPanelShowType.L2D then
self:SetCharacter(self._panel.nCharId)
end
end
function CharBgCtrl:InitBgPos()
local panelAnimCfg = self.tbPanelCfg[self._panel.nPanelId]
if nil ~= panelAnimCfg then
self._mapNode.rtBgRoot:DOLocalMoveX(panelAnimCfg.bgPosX, 0)
self._mapNode.trPanelOffsetL2D:DOLocalMoveX(panelAnimCfg.L2DPosX, 0)
end
if self._panel.nPanelId == PanelId.CharEquipment then
self._mapNode.animBgMiddle:Play("CharBgPanelBgMiddle_out")
end
end
function CharBgCtrl:Awake()
self.charInfoCtrl = nil
self.charSkillCtrl = nil
self.mapOffsetObj = {}
self.tbRenderer = nil
self.mapCharacter = {}
self.nDragStartPosX = nil
self.nDragThreshold = ConfigTable.GetConfigNumber("CharDragThreshold")
self.bgTweener = nil
self.l2dTweener = nil
end
function CharBgCtrl:OnEnable()
self:CreateRT()
self.tbPanelCfg = self._panel:GetPanelShowCfg()
if nil == self.uiRoot then
self.uiRoot = PanelManager.GetUIRoot(self._panel._sSortingLayerName)
end
if nil ~= self.uiRoot then
self._mapNode.rtOffScreenRoot:SetParent(self.uiRoot)
self._mapNode.rtOffScreenRoot.localScale = Vector3.one
self._mapNode.rtOffScreenRoot:SetParent(self.gameObject.transform)
end
self.nCharId = self._panel.nCharId
self.characterIdList = self._panel.tbCharList
self.curCharacterIndex = 1
for index, characterId in ipairs(self.characterIdList) do
if self.nCharId == characterId then
self.curCharacterIndex = index
break
end
end
self:RefreshBgShow()
self:InitBgPos()
self.tbSelectedCharList = {}
end
function CharBgCtrl:OnDisable()
self.mapOffsetObj = {}
self.charInfoCtrl = nil
self.charSkillCtrl = nil
self:ClearCharacter()
self:ReleaseRT()
end
function CharBgCtrl:OnDestroy()
end
function CharBgCtrl:OnDrag_Character(mDrag)
if #self.characterIdList <= 1 then
return
end
if mDrag.DragEventType == AllEnum.UIDragType.DragStart then
self.nDragStartPosX = mDrag.EventData.position.x
elseif mDrag.DragEventType == AllEnum.UIDragType.DragEnd then
local dragEndPosX = mDrag.EventData.position.x
if dragEndPosX - self.nDragStartPosX > self.nDragThreshold then
self:OnEvent_SwitchCurChar(true)
elseif dragEndPosX - self.nDragStartPosX < -self.nDragThreshold then
self:OnEvent_SwitchCurChar(false)
end
end
end
function CharBgCtrl:OnEvent_SwitchCurChar(bLeft)
if #self.characterIdList <= 1 then
return
end
if bLeft then
local bUnlock = false
while not bUnlock do
self.curCharacterIndex = self.curCharacterIndex - 1
if 1 > self.curCharacterIndex then
self.curCharacterIndex = #self.characterIdList
end
bUnlock = PlayerData.Char:CheckCharUnlock(self.characterIdList[self.curCharacterIndex])
end
local nCharId = self.characterIdList[self.curCharacterIndex]
EventManager.Hit(EventId.CharBgRefresh, self._panel.nPanelId, nCharId)
else
local bUnlock = false
while not bUnlock do
self.curCharacterIndex = self.curCharacterIndex + 1
if self.curCharacterIndex > #self.characterIdList then
self.curCharacterIndex = 1
end
bUnlock = PlayerData.Char:CheckCharUnlock(self.characterIdList[self.curCharacterIndex])
end
local nCharId = self.characterIdList[self.curCharacterIndex]
EventManager.Hit(EventId.CharBgRefresh, self._panel.nPanelId, nCharId)
end
end
function CharBgCtrl:OnEvent_RefreshPanel(nPanelId, nCharId)
self._panel.nPanelId = nPanelId
self._panel.nCharId = nCharId
EventManager.Hit("RefreshCharTopBar")
self:RefreshBgShow()
EventManager.Hit("RefreshCharFg")
end
function CharBgCtrl:OnEvent_PanelSwitch(nClosePanelId, nOpenPanelId)
self:RefreshBgShow()
EventManager.Hit("RefreshCharTopBar")
self._mapNode.UIDrag.gameObject:SetActive(true)
local panelAnimCfg = self.tbPanelCfg[nOpenPanelId]
if nil ~= panelAnimCfg then
local nBgTime, nL2dTime = self._panel:GetPanelAnimTime(nClosePanelId, nOpenPanelId)
if nil == nBgTime or nil == nL2dTime then
return
end
local tbCfg = self._panel:GetPanelAnimCfg(nClosePanelId, nOpenPanelId)
if nil ~= tbCfg then
if self.bgTweener ~= nil then
self.bgTweener:Kill()
end
if self.l2dTweener ~= nil then
self.l2dTweener:Kill()
end
self.bgTweener = self._mapNode.rtBgRoot:DOLocalMoveX(panelAnimCfg.bgPosX, nBgTime):SetUpdate(true)
self.l2dTweener = self._mapNode.trPanelOffsetL2D:DOLocalMoveX(panelAnimCfg.L2DPosX, nL2dTime):SetUpdate(true)
self.lasttrPanelOffsetL2DPos = panelAnimCfg.L2DPosX
if nil ~= tbCfg.bgEaseType then
self.bgTweener:SetEase(tbCfg.bgEaseType)
self.l2dTweener:SetEase(tbCfg.bgEaseType)
end
end
end
end
function CharBgCtrl:OnEvent_HideCharBgActor()
self.curPanelOffsetL2D = self._mapNode.trPanelOffsetL2D.localPosition.x
self._mapNode.trPanelOffsetL2D:DOLocalMoveX(-100, 0):SetUpdate(true)
end
function CharBgCtrl:OnEvent_RevertCharBgActor()
self._mapNode.trPanelOffsetL2D:DOLocalMoveX(self.curPanelOffsetL2D, 0):SetUpdate(true)
end
function CharBgCtrl:OnEvent_ChangeDrag(bAble)
self._mapNode.UIDrag.gameObject:SetActive(bAble)
end
return CharBgCtrl
+263
View File
@@ -0,0 +1,263 @@
local CharBgPanel = class("CharBgPanel", BasePanel)
CharBgPanel._tbDefine = {
{
sPrefabPath = "CharacterInfoEx/CharBgPanel.prefab",
sCtrlName = "Game.UI.CharacterInfoEx.CharBgCtrl"
},
{
sPrefabPath = "CharacterInfoEx/CharacterInfoPanel.prefab",
sCtrlName = "Game.UI.CharacterInfoEx.CharacterInfoCtrl"
},
{
sPrefabPath = "CharacterInfoEx/CharDevelopmentPanel.prefab",
sCtrlName = "Game.UI.CharacterInfoEx.CharDevelopmentCtrl"
},
{
sPrefabPath = "CharSkill/CharSkillPanel.prefab",
sCtrlName = "Game.UI.CharSkill.CharSkillCtrl"
},
{
sPrefabPath = "CharacterInfoEx/CharPotentialPanel.prefab",
sCtrlName = "Game.UI.CharacterInfoEx.CharPotentialCtrl"
},
{
sPrefabPath = "CharacterInfoEx/CharTalentPanel.prefab",
sCtrlName = "Game.UI.CharacterInfoEx.CharTalentCtrl"
},
{
sPrefabPath = "CharacterInfoEx/CharEquipmentPanel.prefab",
sCtrlName = "Game.UI.CharacterInfoEx.CharEquipmentCtrl"
},
{
sPrefabPath = "CharacterInfoEx/CharFgPanel.prefab",
sCtrlName = "Game.UI.CharacterInfoEx.CharFgCtrl"
},
{
sPrefabPath = "CharacterInfoEx/CharacterRelationPanel.prefab",
sCtrlName = "Game.UI.CharacterInfoEx.CharacterRelationCtrl"
}
}
CharBgPanel._mapEventConfig = {
[EventId.CharRelatePanelOpen] = "OnEvent_CharRelatePanelOpen",
[EventId.CharRelatePanelClose] = "OnEvent_CharRelatePanelClose"
}
local char_panel_show_cfg = {
[PanelId.CharInfo] = {
bShowTopBar = true,
type = AllEnum.CharBgPanelShowType.L2D,
bgPosX = 0,
L2DPosX = 0,
weaponPosX = 28
},
[PanelId.CharUpPanel] = {
bShowTopBar = true,
type = AllEnum.CharBgPanelShowType.L2D,
bgPosX = 0,
L2DPosX = -0.92,
weaponPosX = 28
},
[PanelId.CharSkill] = {
bShowTopBar = true,
type = AllEnum.CharBgPanelShowType.L2D,
bgPosX = -26.8,
L2DPosX = -0.62,
weaponPosX = 28
},
[PanelId.CharEquipment] = {
bShowTopBar = true,
type = AllEnum.CharBgPanelShowType.L2D,
bgPosX = -29.1,
L2DPosX = -4,
weaponPosX = 28
},
[PanelId.CharPotential] = {
bShowTopBar = true,
type = AllEnum.CharBgPanelShowType.L2D,
bgPosX = -31.4,
L2DPosX = -6.8,
weaponPosX = 28
},
[PanelId.CharTalent] = {
bShowTopBar = true,
type = AllEnum.CharBgPanelShowType.None,
bgPosX = -33.8,
L2DPosX = -26,
weaponPosX = 28
},
[PanelId.CharacterRelation] = {
bShowTopBar = true,
type = AllEnum.CharBgPanelShowType.L2D,
bgPosX = -60,
L2DPosX = -3,
weaponPosX = 28
},
[PanelId.CharFavourGift] = {
bShowTopBar = true,
type = AllEnum.CharBgPanelShowType.L2D,
bgPosX = -60,
L2DPosX = -3,
weaponPosX = 28
}
}
local char_sub_panel = {
[PanelId.CharUpPanel] = true,
[PanelId.CharFavourGift] = true
}
local panel_switch_anim_cfg = {
[PanelId.CharUpPanel] = {
[PanelId.CharInfo] = {nL2dTime = 0.3, nBgTime = 0}
},
[PanelId.CharInfo] = {
[PanelId.CharUpPanel] = {nL2dTime = 0.3, nBgTime = 0},
[PanelId.CharSkill] = {nL2dTime = 0.2, nBgTime = 0},
[PanelId.CharEquipment] = {
nL2dTime = 0.4,
nBgTime = 0,
uiEaseType = Ease.InOutSine,
bgEaseType = Ease.InOutCubic
},
[PanelId.CharacterRelation] = {nL2dTime = 0, nBgTime = 0},
[PanelId.CharPotential] = {nL2dTime = 0.3, nBgTime = 0},
[PanelId.CharTalent] = {nL2dTime = 0, nBgTime = 0}
},
[PanelId.CharSkill] = {
[PanelId.CharInfo] = {nL2dTime = 0.3, nBgTime = 0},
[PanelId.CharEquipment] = {nL2dTime = 0.25, nBgTime = 0.25},
[PanelId.CharacterRelation] = {nL2dTime = 0, nBgTime = 0},
[PanelId.CharPotential] = {nL2dTime = 0.3, nBgTime = 0.3},
[PanelId.CharTalent] = {nL2dTime = 0.3, nBgTime = 0.3}
},
[PanelId.CharEquipment] = {
[PanelId.CharInfo] = {
nL2dTime = 0.4,
nBgTime = 0,
uiEaseType = Ease.InOutSine,
bgEaseType = Ease.InOutCubic
},
[PanelId.CharSkill] = {nL2dTime = 0.25, nBgTime = 0.25},
[PanelId.CharacterRelation] = {nL2dTime = 0, nBgTime = 0},
[PanelId.CharPotential] = {nL2dTime = 0.3, nBgTime = 0.3},
[PanelId.CharTalent] = {nL2dTime = 0.3, nBgTime = 0.3}
},
[PanelId.CharacterRelation] = {
[PanelId.CharInfo] = {nL2dTime = 0, nBgTime = 0},
[PanelId.CharEquipment] = {nL2dTime = 0, nBgTime = 0},
[PanelId.CharSkill] = {nL2dTime = 0, nBgTime = 0},
[PanelId.CharPotential] = {nL2dTime = 0, nBgTime = 0},
[PanelId.CharTalent] = {nL2dTime = 0, nBgTime = 0}
},
[PanelId.CharPotential] = {
[PanelId.CharInfo] = {nL2dTime = 0.3, nBgTime = 0},
[PanelId.CharEquipment] = {nL2dTime = 0.3, nBgTime = 0.3},
[PanelId.CharSkill] = {nL2dTime = 0.3, nBgTime = 0.3},
[PanelId.CharacterRelation] = {nL2dTime = 0, nBgTime = 0},
[PanelId.CharTalent] = {nL2dTime = 0.3, nBgTime = 0.3}
},
[PanelId.CharTalent] = {
[PanelId.CharInfo] = {nL2dTime = 0, nBgTime = 0},
[PanelId.CharEquipment] = {nL2dTime = 0, nBgTime = 0.3},
[PanelId.CharSkill] = {nL2dTime = 0, nBgTime = 0.3},
[PanelId.CharacterRelation] = {nL2dTime = 0, nBgTime = 0},
[PanelId.CharPotential] = {nL2dTime = 0, nBgTime = 0.3}
}
}
function CharBgPanel:Close()
EventManager.Hit(EventId.ClosePanel, PanelId.CharBgPanel)
end
function CharBgPanel:GetPanelAnimCfg(nClosePanelId, nOpenPanelId)
if nil == panel_switch_anim_cfg[nClosePanelId] then
return
end
if nil == panel_switch_anim_cfg[nClosePanelId][nOpenPanelId] then
return
end
return panel_switch_anim_cfg[nClosePanelId][nOpenPanelId]
end
function CharBgPanel:GetPanelAnimTime(nClosePanelId, nOpenPanelId)
local tbCfg = self:GetPanelAnimCfg(nClosePanelId, nOpenPanelId)
if nil ~= tbCfg then
return tbCfg.nBgTime, tbCfg.nL2dTime
end
end
function CharBgPanel:PlayPanelSwitchAnim(trContent, nWidth, nTime)
EventManager.Hit(EventId.TemporaryBlockInput, nTime)
local tweener = trContent:DOAnchorPosX(nWidth, nTime):SetUpdate(true)
local tbCfg = self:GetPanelAnimCfg(self.nClosePanelId, self.nPanelId)
if nil ~= tbCfg and nil ~= tbCfg.uiEaseType then
tweener:SetEase(tbCfg.uiEaseType)
end
return tweener
end
function CharBgPanel:GetPanelShowCfg()
return char_panel_show_cfg
end
function CharBgPanel:GetSubPanel()
return char_sub_panel
end
function CharBgPanel:Awake()
self.nPanelId = 0
self.nCharId = 0
self.tbCharList = {}
self.panelStack = {}
self.bSecondPanel = false
local tbParam = self._tbParam
if type(tbParam) == "table" then
self.nPanelId = tbParam[1]
if nil ~= tbParam[2] then
self.nCharId = tbParam[2]
end
if nil ~= tbParam[3] then
self.tbCharList = tbParam[3]
end
if nil ~= tbParam[4] then
self.param1 = tbParam[4]
end
end
table.insert(self.panelStack, self.nPanelId)
end
function CharBgPanel:OnEnable()
end
function CharBgPanel:OnDisable()
end
function CharBgPanel:OnEvent_CharRelatePanelOpen(nPanelId, ncharId, tbCharList, param1)
self.nClosePanelId = self.nPanelId
self.nPanelId = nPanelId
self.bSecondPanel = false
if nil ~= ncharId then
self.ncharId = ncharId
end
if nil ~= tbCharList then
self.tbCharList = tbCharList
end
if nil ~= param1 then
self.param1 = param1
end
if char_sub_panel[nPanelId] then
table.insert(self.panelStack, nPanelId)
elseif self.panelStack[#self.panelStack] == self.nClosePanelId then
table.remove(self.panelStack, #self.panelStack)
table.insert(self.panelStack, nPanelId)
end
EventManager.Hit(EventId.CharRelatePanelAdvance, self.nClosePanelId, nPanelId)
end
function CharBgPanel:OnEvent_CharRelatePanelClose(bForceClose)
if #self.panelStack <= 1 or bForceClose then
self:Close()
return
end
self.nClosePanelId = self.nPanelId
local nLastPanelId = self.panelStack[#self.panelStack]
if self.nClosePanelId ~= nLastPanelId then
self:Close()
return
end
local nOpenPanelId = self.panelStack[#self.panelStack - 1]
table.remove(self.panelStack, #self.panelStack)
self.nPanelId = nOpenPanelId
self.bSecondPanel = false
local panelCfg = char_panel_show_cfg[self.nClosePanelId]
if nil ~= panelCfg then
EventManager.Hit(EventId.CharRelatePanelBack, self.nClosePanelId, nOpenPanelId)
end
end
return CharBgPanel
@@ -0,0 +1,247 @@
local CharDevelopmentCtrl = class("CharDevelopmentCtrl", BaseCtrl)
local CharState = {
Upgrade = 1,
Advance = 2,
Max = 3
}
CharDevelopmentCtrl._mapNodeConfig = {
txtName = {sComponentName = "TMP_Text"},
imgRareName = {sComponentName = "Image"},
imgCharColor = {sComponentName = "Image"},
imgTag = {nCount = 3},
txtTag = {nCount = 3, sComponentName = "TMP_Text"},
txtElement = {sComponentName = "TMP_Text"},
imgElementIcon = {sComponentName = "Image"},
Upgrade = {
sNodeName = "---Upgrade---",
sCtrlName = "Game.UI.CharacterInfoEx.CharUpgradeCtrl"
},
Advance = {
sNodeName = "---Advance---",
sCtrlName = "Game.UI.CharacterInfoEx.CharAdvanceCtrl"
},
aniRoot = {
sNodeName = "----SafeAreaRoot----",
sComponentName = "Animator"
},
safeAreaRoot = {
sNodeName = "----SafeAreaRoot----"
},
redDotAdInfo = {nCount = 3},
btnOpenAdInfo = {
nCount = 3,
sComponentName = "UIButton",
callback = "OnBtnClick_OpenPreview"
}
}
CharDevelopmentCtrl._mapEventConfig = {
CharDevelopmentRefresh = "OnEvent_Refresh",
[EventId.CharBgRefresh] = "OnEvent_RefreshPanel",
[EventId.CharRelatePanelAdvance] = "OnEvent_PanelAdvance",
[EventId.CharRelatePanelBack] = "OnEvent_PanelBack",
[EventId.UIBackConfirm] = "OnEvent_UIBack",
[EventId.UIHomeConfirm] = "OnEvent_Home",
CraftingSuccess = "OnEvent_ItemChanged",
ConsumableUsed = "OnEvent_ItemChanged",
AutoFillSuccess = "OnEvent_ItemChanged",
CharRefreshActor2D = "OnEvent_RefreshActor2D",
[EventId.ClosePanel] = "OnEvent_ClosePanel"
}
function CharDevelopmentCtrl:RefreshContent()
if self._panel.nPanelId ~= PanelId.CharUpPanel then
return
end
self.nCharId = self._panel.nCharId
self:RegisterRedDot(self.nCharId)
self:RefreshData()
self:RefreshInfo()
self:SwitchState()
end
function CharDevelopmentCtrl:RefreshData()
self.playerCharData = PlayerData.Char:GetCharDataByTid(self.nCharId)
local nLevel = self.playerCharData.nLevel
local nAdvance = self.playerCharData.nAdvance
local nGrade = ConfigTable.GetData_Character(self.nCharId).Grade
self.State = CharState.Upgrade
local tbAdvanceLevel = PlayerData.Char:GetAdvanceLevelTable()
self.curGradeLevelArr = tbAdvanceLevel[nGrade]
local curGradeLevelArr = self.curGradeLevelArr
self.maxAdvance = -1
for i = 1, #curGradeLevelArr do
self.maxAdvance = self.maxAdvance + 1
if nAdvance + 1 == i then
self.MaxLevel = curGradeLevelArr[nAdvance + 1]
if nLevel == self.MaxLevel then
self.State = CharState.Advance
elseif nLevel < self.MaxLevel then
self.State = CharState.Upgrade
end
end
end
if self.MaxLevel == nil then
self.MaxLevel = nLevel
end
if nAdvance == self.maxAdvance and self.State == CharState.Advance then
self.State = CharState.Max
end
local nUpgradeId = 10000 + nGrade * 1000 + nLevel + 1
local mapUpgrade = ConfigTable.GetData("CharacterUpgrade", nUpgradeId, true)
local maxExp = 9999
if mapUpgrade ~= nil then
maxExp = mapUpgrade.Exp
end
self.mapCurLevel = {
nLevel = nLevel,
nExp = self.playerCharData.nRankExp,
nMaxLevel = self.MaxLevel,
nMaxExp = maxExp,
nMatExp = 0,
nNextMaxLv = curGradeLevelArr[nAdvance + 2] or self.MaxLevel
}
end
function CharDevelopmentCtrl:RefreshInfo()
local mapCfg = ConfigTable.GetData_Character(self.nCharId)
NovaAPI.SetTMPText(self._mapNode.txtName, mapCfg.Name)
self:SetSprite_FrameColor(self._mapNode.imgRareName, mapCfg.Grade, AllEnum.FrameType_New.Text)
NovaAPI.SetImageNativeSize(self._mapNode.imgRareName)
local mapCharDescCfg = ConfigTable.GetData("CharacterDes", self.nCharId)
local sColor, tbTag
if mapCharDescCfg ~= nil then
sColor = mapCharDescCfg.CharColor
tbTag = mapCharDescCfg.Tag
else
sColor = ""
tbTag = {}
end
local _, colorChar = ColorUtility.TryParseHtmlString(sColor)
NovaAPI.SetImageColor(self._mapNode.imgCharColor, colorChar)
for i = 1, 3 do
local nTag = tbTag[i]
if nTag then
self._mapNode.imgTag[i]:SetActive(true)
NovaAPI.SetTMPText(self._mapNode.txtTag[i], ConfigTable.GetData("CharacterTag", nTag).Title)
else
self._mapNode.imgTag[i]:SetActive(false)
end
end
local sName = AllEnum.ElementIconType.Icon .. mapCfg.EET
self:SetAtlasSprite(self._mapNode.imgElementIcon, "12_rare", sName)
NovaAPI.SetTMPColor(self._mapNode.txtElement, AllEnum.ElementColor[mapCfg.EET])
NovaAPI.SetTMPText(self._mapNode.txtElement, ConfigTable.GetUIText("T_Element_Attr_" .. mapCfg.EET))
end
function CharDevelopmentCtrl:SwitchState()
self.isCanSendAdvance = false
self.isCanSendAdvanceNext = false
self._mapNode.Upgrade.gameObject:SetActive(self.State ~= CharState.Advance)
self._mapNode.Advance.gameObject:SetActive(self.State == CharState.Advance)
if self.State == CharState.Advance then
EventManager.Hit("RefreshCharTopBarText", ConfigTable.GetUIText("UITitle_CharUp2"))
self._mapNode.Advance:Refresh(self.nCharId, self.mapCurLevel, self.maxAdvance)
if PanelManager.CheckPanelOpen(PanelId.CharSucBar) then
self.isCanSendAdvance = true
else
EventManager.Hit("Guide_PassiveCheck_Msg", "Guide_CharDevelopmentAdvance")
end
else
EventManager.Hit("RefreshCharTopBarText", ConfigTable.GetUIText("UITitle_CharUp1"))
self._mapNode.Upgrade:Refresh(self.nCharId, self.mapCurLevel, self.maxAdvance, self.State == CharState.Max)
if self.mapCurLevel.nLevel >= 10 and self.mapCurLevel.nMaxLevel == 20 then
if PanelManager.CheckPanelOpen(PanelId.CharSucBar) then
self.isCanSendAdvanceNext = true
else
EventManager.Hit("Guide_PassiveCheck_Msg", "Guide_CharDevelopmentAdvanceNext")
end
end
end
end
function CharDevelopmentCtrl:RegisterRedDot(nCharId)
if nil == nCharId then
return
end
for _, v in ipairs(self._mapNode.redDotAdInfo) do
RedDotManager.RegisterNode(RedDotDefine.Role_AdvanceReward, nCharId, v)
end
end
function CharDevelopmentCtrl:PlaySwitchAnim(nClosePanelId, nOpenPanelId, bBack)
if nClosePanelId == PanelId.CharUpPanel then
self._mapNode.safeAreaRoot.gameObject:SetActive(false)
end
if nOpenPanelId == PanelId.CharUpPanel then
self._mapNode.safeAreaRoot.gameObject:SetActive(true)
EventManager.Hit("ChangeCharFgTab", false)
EventManager.Hit("PlayCharBgLeftAnim", true)
end
end
function CharDevelopmentCtrl:RefreshActor2D()
if self._panel.nPanelId == PanelId.CharUpPanel then
EventManager.Hit(EventId.CharBgRefresh, PanelId.CharUpPanel, self.nCharId)
end
end
function CharDevelopmentCtrl:FadeIn()
end
function CharDevelopmentCtrl:Awake()
end
function CharDevelopmentCtrl:OnEnable()
self:RefreshContent()
if self._panel.nPanelId ~= PanelId.CharUpPanel then
self._mapNode.safeAreaRoot.gameObject:SetActive(false)
end
end
function CharDevelopmentCtrl:OnDisable()
end
function CharDevelopmentCtrl:OnDestroy()
end
function CharDevelopmentCtrl:OnBtnClick_OpenPreview()
EventManager.Hit(EventId.OpenPanel, PanelId.CharAdvancePreview, self.maxAdvance, self.nCharId, self.curGradeLevelArr)
end
function CharDevelopmentCtrl:OnEvent_Refresh()
self:RefreshData()
self:SwitchState()
end
function CharDevelopmentCtrl:OnEvent_RefreshPanel()
self:RefreshContent()
end
function CharDevelopmentCtrl:OnEvent_PanelAdvance(nClosePanelId, nOpenPanelId)
self:PlaySwitchAnim(nClosePanelId, nOpenPanelId, false)
self:RefreshContent()
end
function CharDevelopmentCtrl:OnEvent_PanelBack(nClosePanelId, nOpenPanelId)
self:PlaySwitchAnim(nClosePanelId, nOpenPanelId, true)
self:RefreshContent()
end
function CharDevelopmentCtrl:OnEvent_UIBack(nPanelId)
if self._panel._nPanelId ~= nPanelId or self._panel.nPanelId ~= PanelId.CharUpPanel then
return
end
EventManager.Hit(EventId.CharRelatePanelClose)
EventManager.Hit("ChangeCharFgTab", true)
EventManager.Hit("PlayCharBgLeftAnim", false)
end
function CharDevelopmentCtrl:OnEvent_Home(nPanelId)
if self._panel._nPanelId ~= nPanelId or self._panel.nPanelId ~= PanelId.CharUpPanel then
return
end
PanelManager.Home()
end
function CharDevelopmentCtrl:OnEvent_ItemChanged()
if self._panel.nPanelId ~= PanelId.CharUpPanel then
return
end
self:RefreshData()
self:SwitchState()
end
function CharDevelopmentCtrl:OnEvent_RefreshActor2D()
self:RefreshActor2D()
end
function CharDevelopmentCtrl:OnEvent_ClosePanel(nPanelId)
if type(nPanelId) == "number" and nPanelId == PanelId.CharSucBar then
if self.isCanSendAdvance then
EventManager.Hit("Guide_PassiveCheck_Msg", "Guide_CharDevelopmentAdvance")
self.isCanSendAdvance = false
elseif self.isCanSendAdvanceNext then
EventManager.Hit("Guide_PassiveCheck_Msg", "Guide_CharDevelopmentAdvanceNext")
self.isCanSendAdvanceNext = false
end
end
end
return CharDevelopmentCtrl
@@ -0,0 +1,16 @@
local CharDevelopmentPanel = class("CharDevelopmentPanel", BasePanel)
CharDevelopmentPanel._tbDefine = {
{
sPrefabPath = "CharacterInfoEx/CharDevelopmentPanel.prefab",
sCtrlName = "Game.UI.CharacterInfoEx.CharDevelopmentPanel"
}
}
function CharDevelopmentPanel:Awake()
end
function CharDevelopmentPanel:OnEnable()
end
function CharDevelopmentPanel:OnDisable()
end
function CharDevelopmentPanel:OnDestroy()
end
return CharDevelopmentPanel
@@ -0,0 +1,202 @@
local BaseCtrl = require("GameCore.UI.BaseCtrl")
local CharEquipmentCtrl = class("CharEquipmentCtrl", BaseCtrl)
CharEquipmentCtrl._mapNodeConfig = {
animRoot = {
sNodeName = "----FunctionPanel----",
sComponentName = "Animator"
},
safeAreaRoot = {
sNodeName = "----SafeAreaRoot----",
sComponentName = "GameObject"
},
EquipmentSlot = {},
goEquipmentSlotItem = {
nCount = 3,
sCtrlName = "Game.UI.Equipment.EquipmentSlotItemCtrl"
},
btnEquipmentSlot = {
nCount = 3,
sComponentName = "UIButton",
callback = "OnBtnClick_EquipmentSlot"
},
ctrlDropdown = {
sNodeName = "tc_dropdown_01",
sCtrlName = "Game.UI.TemplateEx.TemplateDropdownCtrl"
},
btnRename = {
sComponentName = "UIButton",
callback = "OnBtnClick_Rename"
},
btnPreview = {
sComponentName = "UIButton",
callback = "OnBtnClick_Preview"
},
txtBtnPreview = {
sComponentName = "TMP_Text",
sLanguageId = "Equipment_Btn_TotalAttrPreview"
},
txtName = {sComponentName = "TMP_Text"},
imgRareName = {sComponentName = "Image"},
imgCharColor = {sComponentName = "Image"},
imgTag = {nCount = 3},
txtTag = {nCount = 3, sComponentName = "TMP_Text"},
txtElement = {sComponentName = "TMP_Text"},
imgElementIcon = {sComponentName = "Image"}
}
CharEquipmentCtrl._mapEventConfig = {
[EventId.CharRelatePanelAdvance] = "OnEvent_PanelAdvance",
[EventId.CharRelatePanelBack] = "OnEvent_PanelBack",
[EventId.CharBgRefresh] = "OnEvent_RefreshPanel",
SelectTemplateDD = "OnEvent_PresetSelect",
EquipmentSlotChanged = "RefreshPresetSlot"
}
function CharEquipmentCtrl:OnRefreshPanel()
self.nCharId = self._panel.nCharId
self:RefreshCharInfo()
self:RefreshPresetSlot()
self:RefreshPresetDD()
end
function CharEquipmentCtrl:RefreshCharInfo()
local mapCfg = ConfigTable.GetData_Character(self.nCharId)
if not mapCfg then
return
end
NovaAPI.SetTMPText(self._mapNode.txtName, mapCfg.Name)
self:SetSprite_FrameColor(self._mapNode.imgRareName, mapCfg.Grade, AllEnum.FrameType_New.Text)
NovaAPI.SetImageNativeSize(self._mapNode.imgRareName)
local mapCharDescCfg = ConfigTable.GetData("CharacterDes", self.nCharId)
local sColor, tbTag
if mapCharDescCfg ~= nil then
sColor = mapCharDescCfg.CharColor
tbTag = mapCharDescCfg.Tag
else
sColor = ""
tbTag = {}
end
local _, colorChar = ColorUtility.TryParseHtmlString(sColor)
NovaAPI.SetImageColor(self._mapNode.imgCharColor, colorChar)
for i = 1, 3 do
local nTag = tbTag[i]
if nTag then
self._mapNode.imgTag[i]:SetActive(true)
NovaAPI.SetTMPText(self._mapNode.txtTag[i], ConfigTable.GetData("CharacterTag", nTag).Title)
else
self._mapNode.imgTag[i]:SetActive(false)
end
end
local sName = AllEnum.ElementIconType.Icon .. mapCfg.EET
self:SetAtlasSprite(self._mapNode.imgElementIcon, "12_rare", sName)
NovaAPI.SetTMPText(self._mapNode.txtElement, ConfigTable.GetUIText("T_Element_Attr_" .. mapCfg.EET))
NovaAPI.SetTMPColor(self._mapNode.txtElement, AllEnum.ElementColor[mapCfg.EET])
end
function CharEquipmentCtrl:RefreshPresetDD()
local nSelect = PlayerData.Equipment:GetSelectPreset(self.nCharId)
self.tbName = PlayerData.Equipment:GetAllPresetName(self.nCharId)
self._mapNode.ctrlDropdown:SetList(self.tbName, nSelect - 1, true)
end
function CharEquipmentCtrl:RefreshPresetSlot()
local nSelect = PlayerData.Equipment:GetSelectPreset(self.nCharId)
self.tbSlot = PlayerData.Equipment:GetSlotWithIndex(self.nCharId, nSelect)
for k, v in ipairs(self._mapNode.goEquipmentSlotItem) do
v:Init(self.tbSlot[k], self.nCharId)
end
end
function CharEquipmentCtrl:PlaySwitchAnim(nClosePanelId, nOpenPanelId)
if nClosePanelId == PanelId.CharEquipment then
self._mapNode.safeAreaRoot.gameObject:SetActive(false)
end
if nOpenPanelId == PanelId.CharEquipment then
self._mapNode.safeAreaRoot.gameObject:SetActive(true)
CS.WwiseAudioManager.Instance:PostEvent("ui_charInfo_equipment_open")
self:OnRefreshPanel()
end
end
function CharEquipmentCtrl:OnEnable()
local bHasLastIndex = false
if self._panel.nPanelId ~= PanelId.CharEquipment then
self._mapNode.safeAreaRoot.gameObject:SetActive(false)
else
self._mapNode.safeAreaRoot.gameObject:SetActive(true)
CS.WwiseAudioManager.Instance:PostEvent("ui_charInfo_equipment_open")
self:OnRefreshPanel()
if self.nLastIndex and self.tbSlot and self.nLastIndex > 0 and self.tbSlot[self.nLastIndex].bUnlock then
bHasLastIndex = true
local nIndex = self.nLastIndex
local nAnimTime = NovaAPI.GetAnimClipLength(self._mapNode.animRoot, {
"CharEquipmentPanel_in"
})
local ani = function()
if not PlayerData.Guide:CheckInGuideGroup(50) then
EventManager.Hit(EventId.OpenPanel, PanelId.EquipmentInfo, self.nCharId, self.tbSlot[nIndex].nSlotId, self.tbSlot[nIndex].nGemIndex)
end
end
self:AddTimer(1, nAnimTime, ani, true, true, true)
EventManager.Hit(EventId.TemporaryBlockInput, nAnimTime)
end
end
if not bHasLastIndex then
self.nLastIndex = 0
end
end
function CharEquipmentCtrl:OnDestroy()
self.nLastIndex = 0
end
function CharEquipmentCtrl:OnBtnClick_EquipmentSlot(_, nIndex)
if self.tbSlot[nIndex].bUnlock then
EventManager.Hit(EventId.OpenPanel, PanelId.EquipmentInfo, self.nCharId, self.tbSlot[nIndex].nSlotId, self.tbSlot[nIndex].nGemIndex)
else
EventManager.Hit(EventId.OpenMessageBox, orderedFormat(ConfigTable.GetUIText("Equipment_SlotLock"), self.tbSlot[nIndex].nLevel))
end
if nIndex == self.nLastIndex then
return
end
if nil ~= self._mapNode.goEquipmentSlotItem[nIndex] then
self._mapNode.goEquipmentSlotItem[nIndex]:SetChooseState(true)
end
if 0 ~= self.nLastIndex and nil ~= self._mapNode.goEquipmentSlotItem[self.nLastIndex] then
self._mapNode.goEquipmentSlotItem[self.nLastIndex]:SetChooseState(false)
end
self.nLastIndex = nIndex
end
function CharEquipmentCtrl:OnBtnClick_Rename()
local nSelect = PlayerData.Equipment:GetSelectPreset(self.nCharId)
local callback = function()
self:RefreshPresetDD()
end
EventManager.Hit(EventId.OpenPanel, PanelId.EquipmentRename, self.nCharId, self.tbName[nSelect], callback)
end
function CharEquipmentCtrl:OnBtnClick_Preview()
local tbEquipment = PlayerData.Equipment:GetEquipedGem(self.nCharId)
if next(tbEquipment) == nil then
EventManager.Hit(EventId.OpenMessageBox, ConfigTable.GetUIText("Equipment_CharEquipNone"))
else
EventManager.Hit(EventId.OpenPanel, PanelId.EquipmentAttrPreview, self.nCharId)
end
end
function CharEquipmentCtrl:OnEvent_PresetSelect(nValue)
local nIndex = nValue + 1
local nSelect = PlayerData.Equipment:GetSelectPreset(self.nCharId)
if nSelect == nIndex then
return
end
local callback = function()
self:RefreshPresetSlot()
if self.nLastIndex and self.nLastIndex > 0 and nil ~= self._mapNode.goEquipmentSlotItem[self.nLastIndex] then
self._mapNode.goEquipmentSlotItem[self.nLastIndex]:SetChooseState(true)
end
end
PlayerData.Equipment:SendCharGemUsePresetReq(self.nCharId, nIndex, callback)
end
function CharEquipmentCtrl:OnEvent_PanelAdvance(nClosePanelId, nOpenPanelId)
self:PlaySwitchAnim(nClosePanelId, nOpenPanelId)
end
function CharEquipmentCtrl:OnEvent_PanelBack(nClosePanelId, nOpenPanelId)
self:PlaySwitchAnim(nClosePanelId, nOpenPanelId)
end
function CharEquipmentCtrl:OnEvent_RefreshPanel()
if self._panel.nPanelId ~= PanelId.CharEquipment then
return
end
self:OnRefreshPanel()
end
return CharEquipmentCtrl
@@ -0,0 +1,23 @@
local BasePanel = require("GameCore.UI.BasePanel")
local CharEquipmentPanel = class("CharEquipmentPanel", BasePanel)
CharEquipmentPanel._tbDefine = {
{
sPrefabPath = "CharacterInfoEx/CharEquipmentPanel.prefab",
sCtrlName = "Game.UI.CharacterInfoEx.CharEquipmentCtrl"
}
}
function CharEquipmentPanel:Awake()
local tbParam = self:GetPanelParam()
if type(tbParam) == "table" then
self.nCharId = tbParam[1]
end
end
function CharEquipmentPanel:OnEnable()
end
function CharEquipmentPanel:OnDisable()
end
function CharEquipmentPanel:OnDestroy()
end
function CharEquipmentPanel:OnRelease()
end
return CharEquipmentPanel
+180
View File
@@ -0,0 +1,180 @@
local CharFgCtrl = class("CharFgCtrl", BaseCtrl)
local MoveBarPos = {
-805.2,
-483.6,
-162,
159.6,
481.2,
802.8
}
local PanelToTab = {
[PanelId.CharInfo] = 1,
[PanelId.CharSkill] = 2,
[PanelId.CharEquipment] = 3,
[PanelId.CharPotential] = 4,
[PanelId.CharTalent] = 5,
[PanelId.CharacterRelation] = 6,
[PanelId.CharUpPanel] = 1
}
CharFgCtrl._mapNodeConfig = {
TopBar = {
sNodeName = "TopBarPanel",
sCtrlName = "Game.UI.TopBarEx.TopBarCtrl"
},
goBack = {},
goResBarAnimRoot = {},
btnTab = {
nCount = 6,
sComponentName = "UIButton",
callback = "OnBtnClick_Tab"
},
imgOn = {nCount = 6},
txtTabOn = {nCount = 6, sComponentName = "TMP_Text"},
txtTabOff = {nCount = 6, sComponentName = "TMP_Text"},
layoutOff = {nCount = 6},
reddot = {nCount = 6},
imgMoveBar = {sComponentName = "Transform"},
Tab = {sNodeName = "--Tab--"},
aniSafeRoot = {
sNodeName = "----SafeAreaRoot----",
sComponentName = "Animator"
},
btnTabSwitchLeft = {
sComponentName = "NaviButton",
callback = "OnBtnClick_SwitchLeft"
},
btnTabSwitchRight = {
sComponentName = "NaviButton",
callback = "OnBtnClick_SwitchRight"
},
goTabSwitch = {}
}
CharFgCtrl._mapEventConfig = {
RefreshCharFg = "OnEvent_RefreshFg",
RefreshCharTopBar = "RefreshTopBar",
RefreshCharTopBarText = "OnEvent_SetTopBarText",
ChangeCharFgTab = "OnEvent_ChangeTab",
ChangeCharTopBar = "OnEvent_ChangeTopBar"
}
function CharFgCtrl:InitTab()
self.nTab = PanelToTab[self._panel.nPanelId]
self._mapNode.imgMoveBar.localPosition = Vector3(MoveBarPos[self.nTab], 4.5, 0)
for i = 1, 6 do
NovaAPI.SetTMPText(self._mapNode.txtTabOn[i], ConfigTable.GetUIText("CharacterInfo_Tab" .. i))
NovaAPI.SetTMPText(self._mapNode.txtTabOff[i], ConfigTable.GetUIText("CharacterInfo_Tab" .. i))
self._mapNode.imgOn[i]:SetActive(PanelToTab[self._panel.nPanelId] == i)
self._mapNode.txtTabOn[i].gameObject:SetActive(PanelToTab[self._panel.nPanelId] == i)
self._mapNode.layoutOff[i].gameObject:SetActive(PanelToTab[self._panel.nPanelId] ~= i)
end
end
function CharFgCtrl:RegisterRedDot()
RedDotManager.RegisterNode(RedDotDefine.Role_Upgrade, self._panel.nCharId, self._mapNode.reddot[1])
RedDotManager.RegisterNode(RedDotDefine.Role_Talent, self._panel.nCharId, self._mapNode.reddot[5])
RedDotManager.RegisterNode(RedDotDefine.Role_Relation, self._panel.nCharId, self._mapNode.reddot[6])
end
function CharFgCtrl:RefreshTopBar()
local nPanelId = self._panel.nPanelId
local panelCfg = self.tbPanelCfg[nPanelId]
if nil ~= panelCfg then
if panelCfg.bShowTopBar then
self._mapNode.TopBar.gameObject:SetActive(true)
self._mapNode.TopBar:InitTopBar(nPanelId)
if nPanelId == PanelId.CharTalent then
local mapCharCfg = ConfigTable.GetData_Character(self._panel.nCharId)
self._mapNode.TopBar:CreateCoin({
mapCharCfg.FragmentsId
})
elseif nPanelId == PanelId.CharUpPanel then
local nGrade = ConfigTable.GetData_Character(self._panel.nCharId).Grade
local tbAdvanceLevel = PlayerData.Char:GetAdvanceLevelTable()
local curGradeLevelArr = tbAdvanceLevel[nGrade]
local playerCharData = PlayerData.Char:GetCharDataByTid(self._panel.nCharId)
local nLevel = playerCharData.nLevel
local nAdvance = playerCharData.nAdvance
local maxAdvance = -1
for i = 1, #curGradeLevelArr do
maxAdvance = maxAdvance + 1
if nAdvance + 1 == i then
local MaxLevel = curGradeLevelArr[nAdvance + 1]
if nLevel == MaxLevel then
self._mapNode.TopBar:SetTitleTxt(ConfigTable.GetUIText("UITitle_CharUp2"))
elseif nLevel < MaxLevel then
self._mapNode.TopBar:SetTitleTxt(ConfigTable.GetUIText("UITitle_CharUp1"))
end
end
end
end
else
self._mapNode.TopBar.gameObject:SetActive(false)
end
end
if self._panel.bSecondPanel then
self:OnEvent_ChangeTopBar(false, true)
end
end
function CharFgCtrl:Awake()
self:InitTab()
end
function CharFgCtrl:OnEnable()
self.tbPanelCfg = self._panel:GetPanelShowCfg()
local tbSubPanel = self._panel:GetSubPanel()
if tbSubPanel[self._panel.nPanelId] or self._panel.bSecondPanel then
self._mapNode.aniSafeRoot:Play("CharFgPanel_out", 0, 1)
else
self._mapNode.aniSafeRoot:Play("CharFgPanel_in")
end
self:RegisterRedDot()
if self._panel.tbCharList ~= nil then
self._mapNode.goTabSwitch.gameObject:SetActive(1 < #self._panel.tbCharList)
end
local wait = function()
coroutine.yield(CS.UnityEngine.WaitForEndOfFrame())
self:RefreshTopBar()
end
cs_coroutine.start(wait)
end
function CharFgCtrl:OnDisable()
end
function CharFgCtrl:OnDestroy()
end
function CharFgCtrl:OnEvent_RefreshFg()
self:RegisterRedDot()
end
function CharFgCtrl:OnEvent_ChangeTab(bOpen)
if bOpen then
self._mapNode.aniSafeRoot:Play("CharFgPanel_in")
else
self._mapNode.aniSafeRoot:Play("CharFgPanel_out")
end
end
function CharFgCtrl:OnEvent_ChangeTopBar(bShowBack, bShowRes)
self._mapNode.goBack:SetActive(bShowBack)
self._mapNode.goResBarAnimRoot:SetActive(bShowRes)
end
function CharFgCtrl:OnBtnClick_Tab(btn, nIndex)
if self.nTab == nIndex then
return
end
local nNextPanel = table.keyof(PanelToTab, nIndex)
self._mapNode.imgMoveBar:DOLocalMoveX(MoveBarPos[nIndex], 0.1):SetUpdate(true)
self._mapNode.imgOn[self.nTab]:SetActive(false)
self._mapNode.txtTabOn[self.nTab].gameObject:SetActive(false)
self._mapNode.layoutOff[self.nTab].gameObject:SetActive(true)
self._mapNode.imgOn[nIndex]:SetActive(true)
self._mapNode.txtTabOn[nIndex].gameObject:SetActive(true)
self._mapNode.layoutOff[nIndex].gameObject:SetActive(false)
self.nTab = nIndex
if nNextPanel then
EventManager.Hit(EventId.CharRelatePanelOpen, nNextPanel, self._panel.nCharId)
end
end
function CharFgCtrl:OnEvent_SetTopBarText(sTitle)
self._mapNode.TopBar:SetTitleTxt(sTitle)
end
function CharFgCtrl:OnBtnClick_SwitchLeft()
EventManager.Hit("SwitchCurChar", true)
end
function CharFgCtrl:OnBtnClick_SwitchRight()
EventManager.Hit("SwitchCurChar", false)
end
return CharFgCtrl
@@ -0,0 +1,364 @@
local CharPotentialCtrl = class("CharPotentialCtrl", BaseCtrl)
CharPotentialCtrl._mapNodeConfig = {
safeAreaRoot = {
sNodeName = "----SafeAreaRoot----"
},
rtRoot = {
sNodeName = "----SafeAreaRoot----",
sComponentName = "RectTransform"
},
animRoot = {
sNodeName = "----SafeAreaRoot----",
sComponentName = "Animator"
},
animCard = {
sNodeName = "PotentialCardRoot",
sComponentName = "Animator"
},
PotentialCard = {
sCtrlName = "Game.UI.StarTower.Potential.PotentialCardItemCtrl"
},
PotentialCard2 = {
sCtrlName = "Game.UI.StarTower.Potential.PotentialCardItemCtrl"
},
svPotential = {sComponentName = "ScrollRect"},
btnSwitch = {
nCount = 2,
sComponentName = "UIButton",
callback = "OnBtnClick_Switch"
},
SwitchOn = {
sComponentName = "TMP_Text",
sLanguageId = "Shop_Sample_SwithOn"
},
SwitchOff = {
sComponentName = "TMP_Text",
sLanguageId = "Shop_Sample_SwithOff"
},
tab = {
nCount = 2,
sCtrlName = "Game.UI.TemplateEx.TemplateTabCtrl"
},
btnTab = {
nCount = 2,
sComponentName = "UIButton",
callback = "OnBtnClick_Tab"
},
PotentialList = {nCount = 3},
rtPotential = {nCount = 3, sComponentName = "Transform"},
PotentialDepotItem = {},
txtPotentialTitle = {nCount = 2, sComponentName = "TMP_Text"},
txtPotentialTitle3 = {
sComponentName = "TMP_Text",
sLanguageId = "Potential_Build_Common"
},
txtPotentialDesc = {nCount = 2, sComponentName = "TMP_Text"},
switch_des = {},
switch_img_bg = {
sComponentName = "RectTransform"
},
switch_nameRect = {
sNodeName = "switch_name",
sComponentName = "RectTransform"
},
switch_name = {
sComponentName = "TMP_Text",
sLanguageId = "Potential_Change_Desc"
},
btnSwitch_on = {
sComponentName = "UIButton",
callback = "OnBtnClick_SetDes"
},
btnSwitch_off = {
sComponentName = "UIButton",
callback = "OnBtnClick_SetSimpleDes"
}
}
CharPotentialCtrl._mapEventConfig = {
[EventId.CharBgRefresh] = "OnEvent_RefreshPanel",
[EventId.CharRelatePanelAdvance] = "OnEvent_PanelAdvance",
[EventId.CharRelatePanelBack] = "OnEvent_PanelBack",
SelectDepotPotential = "OnEvent_Select"
}
function CharPotentialCtrl:ClearData()
self.bMax = false
self.nTab = 1
self.nSelectId = nil
self.MasterSpecificIds = nil
self.MasterNormalIds = nil
self.AssistSpecificIds = nil
self.AssistNormalIds = nil
end
function CharPotentialCtrl:RefreshData()
self.nCharId = self._panel.nCharId
self.bMax = false
self.nTab = 1
self.tbPotentialList = PlayerData.Char:GetCharPotentialList(self.nCharId)
if self.tbBuild1GridCtrl == nil then
self.tbBuild1GridCtrl = {}
end
if self.tbBuild2GridCtrl == nil then
self.tbBuild2GridCtrl = {}
end
if self.tbBuildCommonGirdCtrl == nil then
self.tbBuildCommonGirdCtrl = {}
end
if self.tbPotentialList and self.tbPotentialList.master then
for type = 1, 3 do
if self.tbPotentialList.master[type] ~= nil and #self.tbPotentialList.master[type] > 0 then
self.nSelectId = self.tbPotentialList.master[type][1].nId
break
end
end
end
end
function CharPotentialCtrl:Reselect()
NovaAPI.SetVerticalNormalizedPosition(self._mapNode.svPotential, 1)
if self.nTab == 1 then
if self.tbPotentialList and self.tbPotentialList.master then
for type = 1, 3 do
if self.tbPotentialList.master[type] ~= nil and #self.tbPotentialList.master[type] > 0 then
self.nSelectId = self.tbPotentialList.master[type][1].nId
break
end
end
end
elseif self.tbPotentialList and self.tbPotentialList.assist then
for type = 1, 3 do
if self.tbPotentialList.assist[type] ~= nil and 0 < #self.tbPotentialList.assist[type] then
self.nSelectId = self.tbPotentialList.assist[type][1].nId
break
end
end
end
end
function CharPotentialCtrl:RefreshContent()
if self._panel.nPanelId ~= PanelId.CharPotential then
return
end
self:RefreshData()
if not self.nSelectId then
printError("CharPotential表没配这个角色:" .. self.nCharId)
return
end
self:RefreshTab()
self:RefreshSwitch()
self:RefreshList()
self:SetPotentialBuildName()
self:RefreshMaxLevelSwitch()
end
function CharPotentialCtrl:RefreshTab()
self._mapNode.tab[1]:SetSelect(1 == self.nTab, 1)
self._mapNode.tab[2]:SetSelect(2 == self.nTab, 3)
end
function CharPotentialCtrl:SetPotentialBuildName()
local charDescCfg = ConfigTable.GetData("CharacterDes", self.nCharId)
if charDescCfg ~= nil then
for i = 1, 2 do
do
NovaAPI.SetTMPText(self._mapNode.txtPotentialTitle[i], self.nTab == 1 and charDescCfg["PotentialMain" .. i] or charDescCfg["PotentialAssistant" .. i])
local titleLayoutElement = self._mapNode.txtPotentialTitle[i].gameObject:GetComponent("LayoutElement")
local tr = self._mapNode.txtPotentialTitle[i].gameObject:GetComponent("RectTransform")
local wait = function()
coroutine.yield(CS.UnityEngine.WaitForEndOfFrame())
self:SetTitleWidth(titleLayoutElement, tr)
end
cs_coroutine.start(wait)
NovaAPI.SetTMPText(self._mapNode.txtPotentialDesc[i], self.nTab == 1 and charDescCfg["PotentialMainContent" .. i] or charDescCfg["PotentialAssistantContent" .. i])
end
end
end
end
function CharPotentialCtrl:SetTitleWidth(nTitleLayout, tr)
local minWidth = nTitleLayout.minWidth
local preferredWidth = tr.rect.width
if minWidth == preferredWidth then
return
else
nTitleLayout.minWidth = preferredWidth
end
end
function CharPotentialCtrl:RefreshMaxLevelSwitch()
self._mapNode.btnSwitch[1].gameObject:SetActive(not self.bMax)
self._mapNode.btnSwitch[2].gameObject:SetActive(self.bMax)
end
function CharPotentialCtrl:RefreshList(bChangeTab)
local tbPotential = self.nTab == 1 and self.tbPotentialList.master or self.tbPotentialList.assist
local tbBuild1 = tbPotential[GameEnum.potentialBuild.PotentialBuild1] or {}
local tbBuild2 = tbPotential[GameEnum.potentialBuild.PotentialBuild2] or {}
local tbBuildCommon = tbPotential[GameEnum.potentialBuild.PotentialBuildCommon] or {}
self._mapNode.PotentialList[1]:SetActive(0 < #tbBuild1)
self._mapNode.PotentialList[2]:SetActive(0 < #tbBuild2)
self._mapNode.PotentialList[3]:SetActive(0 < #tbBuildCommon)
local createPotentialItem = function(tbPotential, tbGrid, rtContent)
if 0 < #tbPotential then
for k, v in ipairs(tbPotential) do
local nMaxLevel = PlayerData.StarTower:GetPotentialMaxLevelWithCurGrowth(v.nId)
local nLv = self.bMax and nMaxLevel or 1
if nil == tbGrid[k] then
local itemObj = instantiate(self._mapNode.PotentialDepotItem, rtContent)
itemObj.gameObject:SetActive(true)
local itemCtrl = self:BindCtrlByNode(itemObj, "Game.UI.StarTower.Depot.DepotPotentialItemCtrl")
itemCtrl:InitItem(v.nId, nLv, 0, false)
table.insert(tbGrid, itemCtrl)
else
tbGrid[k]:InitItem(v.nId, nLv, 0, false)
end
EventManager.Hit("SelectDepotPotential", self.nSelectId)
end
if #tbGrid > #tbPotential then
for i = #tbPotential + 1, #tbGrid do
tbGrid[i].gameObject:SetActive(false)
end
end
end
end
createPotentialItem(tbBuild1, self.tbBuild1GridCtrl, self._mapNode.rtPotential[1])
createPotentialItem(tbBuild2, self.tbBuild2GridCtrl, self._mapNode.rtPotential[2])
createPotentialItem(tbBuildCommon, self.tbBuildCommonGirdCtrl, self._mapNode.rtPotential[3])
local nLevel = PlayerData.StarTower:GetPotentialMaxLevelWithCurGrowth(self.nSelectId)
local bSimple = PlayerData.StarTower:GetPotentialDescSimple()
if bChangeTab then
self._mapNode.animCard:Play("PotentialCardRoot_switch", 0, 0)
self._mapNode.PotentialCard2:SetPotentialItem(self.nSelectId, self.bMax and nLevel or 1, nil, bSimple)
self:AddTimer(1, 0.2, function()
self._mapNode.PotentialCard:SetPotentialItem(self.nSelectId, self.bMax and nLevel or 1, nil, bSimple)
self._mapNode.PotentialCard:ChangeWordRaycast(true)
end, true, true, true)
else
self._mapNode.PotentialCard:SetPotentialItem(self.nSelectId, self.bMax and nLevel or 1, nil, bSimple)
self._mapNode.PotentialCard:ChangeWordRaycast(true)
end
end
function CharPotentialCtrl:SetTabText()
self._mapNode.tab[1]:SetText(ConfigTable.GetUIText("Build_Leader"))
self._mapNode.tab[2]:SetText(ConfigTable.GetUIText("Build_Sub"))
end
function CharPotentialCtrl:PlayOpenAnim()
end
function CharPotentialCtrl:PlaySwitchAnim(nClosePanelId, nOpenPanelId, bBack)
if nClosePanelId == PanelId.CharPotential then
NovaAPI.SetVerticalNormalizedPosition(self._mapNode.svPotential, 1)
self._mapNode.safeAreaRoot.gameObject:SetActive(false)
self:ClearData()
end
if nOpenPanelId == PanelId.CharPotential then
self._mapNode.safeAreaRoot.gameObject:SetActive(true)
self:PlayOpenAnim()
end
end
function CharPotentialCtrl:InitSwitch()
local bSimple = PlayerData.StarTower:GetPotentialDescSimple()
self._mapNode.btnSwitch_on.gameObject:SetActive(bSimple)
self._mapNode.btnSwitch_off.gameObject:SetActive(not bSimple)
self:AddTimer(1, 0.5, "RefreshSwitch", true, true, false)
end
function CharPotentialCtrl:RefreshSwitch()
CS.UnityEngine.UI.LayoutRebuilder.ForceRebuildLayoutImmediate(self._mapNode.switch_nameRect)
self._mapNode.switch_img_bg.sizeDelta = Vector2(100 + self._mapNode.switch_nameRect.sizeDelta.x + 30, self._mapNode.switch_img_bg.sizeDelta.y)
end
function CharPotentialCtrl:Awake()
self:ClearData()
self:SetTabText()
end
function CharPotentialCtrl:OnEnable()
self._mapNode.safeAreaRoot.gameObject:SetActive(false)
local callback = function()
self:RefreshContent()
if self._panel.nPanelId == PanelId.CharPotential then
self._mapNode.safeAreaRoot.gameObject:SetActive(true)
self:PlayOpenAnim()
else
self._mapNode.safeAreaRoot.gameObject:SetActive(false)
end
self:InitSwitch()
self:RefreshMaxLevelSwitch()
end
PlayerData.StarTower:SendTowerGrowthDetailReq(callback)
end
function CharPotentialCtrl:OnDisable()
if self.tbBuildCommonGirdCtrl then
for k, objCtrl in pairs(self.tbBuildCommonGirdCtrl) do
local obj = objCtrl.gameObject
self:UnbindCtrlByNode(objCtrl)
self.tbBuildCommonGirdCtrl[k] = nil
destroyImmediate(obj)
end
self.tbBuildCommonGirdCtrl = {}
end
if self.tbBuild2GridCtrl then
for k, objCtrl in pairs(self.tbBuild2GridCtrl) do
local obj = objCtrl.gameObject
self:UnbindCtrlByNode(objCtrl)
self.tbBuild2GridCtrl[k] = nil
destroyImmediate(obj)
end
self.tbBuild2GridCtrl = {}
end
if self.tbBuild1GridCtrl then
for k, objCtrl in pairs(self.tbBuild1GridCtrl) do
local obj = objCtrl.gameObject
self:UnbindCtrlByNode(objCtrl)
self.tbBuild1GridCtrl[k] = nil
destroyImmediate(obj)
end
self.tbBuild1GridCtrl = {}
end
end
function CharPotentialCtrl:OnDestroy()
end
function CharPotentialCtrl:OnBtnClick_Tab(btn, nIndex)
if nIndex == self.nTab then
return
end
self.nTab = nIndex
self:RefreshTab()
self:Reselect()
self:RefreshList(true)
self:SetPotentialBuildName()
end
function CharPotentialCtrl:OnBtnClick_Switch(btn, nIndex)
self.bMax = not self.bMax
self:RefreshMaxLevelSwitch()
self:RefreshList()
end
function CharPotentialCtrl:OnBtnClick_SetSimpleDes(...)
PlayerData.StarTower:SetPotentialDescSimple(true)
self:RefreshList()
self._mapNode.btnSwitch_on.gameObject:SetActive(true)
self._mapNode.btnSwitch_off.gameObject:SetActive(false)
end
function CharPotentialCtrl:OnBtnClick_SetDes(...)
PlayerData.StarTower:SetPotentialDescSimple(false)
self:RefreshList()
self._mapNode.btnSwitch_on.gameObject:SetActive(false)
self._mapNode.btnSwitch_off.gameObject:SetActive(true)
end
function CharPotentialCtrl:OnEvent_Select(nPotentialId)
if self.nSelectId == nPotentialId then
return
end
self.nSelectId = nPotentialId
local nMaxLevel = PlayerData.StarTower:GetPotentialMaxLevelWithCurGrowth(self.nSelectId)
local nLevel = self.bMax and nMaxLevel or 1
self._mapNode.animCard:Play("PotentialCardRoot_switch", 0, 0)
self._mapNode.switch_des:SetActive(true)
local bSimple = PlayerData.StarTower:GetPotentialDescSimple()
self._mapNode.PotentialCard2:SetPotentialItem(nPotentialId, nLevel, nil, bSimple)
self:AddTimer(1, 0.2, function()
self._mapNode.PotentialCard:SetPotentialItem(nPotentialId, nLevel, nil, bSimple)
self._mapNode.PotentialCard:ChangeWordRaycast(true)
end, true, true, true)
end
function CharPotentialCtrl:OnEvent_RefreshPanel()
self:RefreshContent()
end
function CharPotentialCtrl:OnEvent_PanelAdvance(nClosePanelId, nOpenPanelId)
self:PlaySwitchAnim(nClosePanelId, nOpenPanelId, false)
self:RefreshContent()
end
function CharPotentialCtrl:OnEvent_PanelBack(nClosePanelId, nOpenPanelId)
self:PlaySwitchAnim(nClosePanelId, nOpenPanelId, true)
self:RefreshContent()
end
return CharPotentialCtrl
@@ -0,0 +1,16 @@
local CharPotentialPanel = class("CharPotentialPanel", BasePanel)
CharPotentialPanel._tbDefine = {
{
sPrefabPath = "CharacterInfoEx/CharPotentialPanel.prefab",
sCtrlName = "Game.UI.CharacterInfoEx.CharPotentialCtrl"
}
}
function CharPotentialPanel:Awake()
end
function CharPotentialPanel:OnEnable()
end
function CharPotentialPanel:OnDisable()
end
function CharPotentialPanel:OnDestroy()
end
return CharPotentialPanel
@@ -0,0 +1,702 @@
local Actor2DManager = require("Game.Actor2D.Actor2DManager")
local CharTalentCtrl = class("CharTalentCtrl", BaseCtrl)
local LayoutRebuilder = CS.UnityEngine.UI.LayoutRebuilder
local WwiseAudioManager = CS.WwiseAudioManager.Instance
local LocalData = require("GameCore.Data.LocalData")
local newDayTime = UTILS.GetDayRefreshTimeOffset()
CharTalentCtrl._mapNodeConfig = {
root_canvas_group = {
sComponentName = "CanvasGroup"
},
anim = {
sNodeName = "root_canvas_group",
sComponentName = "Animator"
},
rawImg = {
sNodeName = "----Actor2D----",
sComponentName = "RawImage"
},
btn_FullScreen_PlayBtnUIShowAnim = {},
btnUIShow = {
sComponentName = "UIButton",
callback = "OnBtnClick_UIShow"
},
btnUIHide = {
sComponentName = "UIButton",
callback = "OnBtnClick_UIHide"
},
tmpUIShow = {
sComponentName = "TMP_Text",
sLanguageId = "MainView_ShowUI"
},
KeyNode = {
nCount = 5,
sCtrlName = "Game.UI.CharacterInfoEx.TalentKeyNodeCtrl"
},
btnKey = {
nCount = 5,
sComponentName = "UIButton",
callback = "OnBtnClick_Key"
},
btnBack = {
sComponentName = "UIButton",
callback = "OnBtnClick_Back"
},
btnBackBlank = {
sComponentName = "UIButton",
callback = "OnBtnClick_Back"
},
btnHome = {
sComponentName = "UIButton",
callback = "OnBtnClick_Home"
},
animRoot = {sNodeName = "root", sComponentName = "Animator"},
tmpGroupName = {sComponentName = "TMP_Text"},
tmpGroupDesc = {sComponentName = "TMP_Text"},
tmpGroupDesc_Link = {
sNodeName = "tmpGroupDesc",
sComponentName = "TMPHyperLink",
callback = "OnBtnClick_Word"
},
animGroupNode = {sComponentName = "Animator"},
imgGroupNode = {sComponentName = "Image"},
tbImgNode = {
sNodeName = "imgNode",
nCount = 10,
sComponentName = "Image"
},
tbAnimNode = {
sNodeName = "imgNode",
nCount = 10,
sComponentName = "Animator"
},
btnPrev = {
sComponentName = "UIButton",
callback = "OnBtnClick_PrevGroup"
},
btnNext = {
sComponentName = "UIButton",
callback = "OnBtnClick_NextGroup"
},
animDetailText = {
sNodeName = "DetailTextAnim",
sComponentName = "Animator"
},
tmpProgress = {sComponentName = "TMP_Text"},
goNext = {
sNodeName = "imgNextDescDb"
},
tmpNextDesc = {sComponentName = "TMP_Text"},
tmpNextDesc_Link = {
sNodeName = "tmpNextDesc",
sComponentName = "TMPHyperLink",
callback = "OnBtnClick_Word"
},
btnMoreInfo = {
sComponentName = "UIButton",
callback = "OnBtnClick_MoreInfo"
},
btnRequireItem = {
sComponentName = "UIButton",
callback = "OnBtnClick_RequireItem"
},
rtBtnRequireItem = {
sNodeName = "btnRequireItem",
sComponentName = "RectTransform"
},
imgItemRare = {sComponentName = "Image"},
imgItemIcon = {sComponentName = "Image"},
tmpNum_Has_Require = {sComponentName = "TMP_Text"},
tmpAllDone = {
sComponentName = "TMP_Text",
sLanguageId = "CharTalent_Actived"
},
rtTmpAllDone = {
sNodeName = "tmpAllDone",
sComponentName = "RectTransform"
},
btnActivate = {
sComponentName = "UIButton",
callback = "OnBtnClick_Activate"
},
imgActivateDb = {sComponentName = "Image"},
tmpActivate = {
sComponentName = "TMP_Text",
sLanguageId = "CharTalent_Btn_Active"
},
tmpWindowTitle = {
sComponentName = "TMP_Text",
sLanguageId = "CharTalent_MoreInfoWindowTitle"
},
tbBtnTab = {
nCount = 6,
sNodeName = "btnTab",
sComponentName = "UIButton",
callback = "OnBtnClick_Tab"
},
tbImgIconDb = {
nCount = 6,
sNodeName = "imgIconDb",
sComponentName = "Image"
},
tbTmpTalentGroupName = {
nCount = 6,
sNodeName = "tmpTalentGroupName",
sComponentName = "TMP_Text"
},
tbSelect = {
nCount = 6,
sNodeName = "select",
sComponentName = "GameObject"
},
canvasGroup_All = {
sNodeName = "goRight_All",
sComponentName = "CanvasGroup"
},
tmpTitleAll = {
sComponentName = "TMP_Text",
sLanguageId = "CharTalentMoreInfo_AllGroupOn"
},
grid_all = {},
trContentAll = {sComponentName = "Transform"},
canvasGroup_TalentGroup = {
sNodeName = "goRight_TalentGroup",
sComponentName = "CanvasGroup"
},
tmpTitleGroup = {sComponentName = "TMP_Text"},
trListOn = {sNodeName = "list_on", sComponentName = "Transform"},
tmpTitleGroup_On = {
sComponentName = "TMP_Text",
sLanguageId = "CharTalentMoreInfo_SingleGroupOn"
},
tmpGroupProgress = {sComponentName = "TMP_Text"},
grid_on = {},
goSplitLine = {},
trListOff = {sNodeName = "list_off", sComponentName = "Transform"},
tmpTitleGroup_Off = {
sComponentName = "TMP_Text",
sLanguageId = "CharTalentMoreInfo_SingleGroupOff"
},
grid_off = {}
}
CharTalentCtrl._mapEventConfig = {
[EventId.CharRelatePanelOpen] = "OnEvent_CharRelatePanelOpen",
[EventId.CharBgRefresh] = "OnEvent_SwitchCurChar"
}
function CharTalentCtrl:Awake()
self:SetAllVisibale(false)
self.bUIVisible = true
self.nCurGroupIndex = 1
self.nGroupNum = #self._mapNode.KeyNode
end
function CharTalentCtrl:OnDisable()
Actor2DManager.UnsetActor2D(false, 2, true)
end
function CharTalentCtrl:SetAllVisibale(bVisible)
NovaAPI.SetCanvasGroupAlpha(self._mapNode.root_canvas_group, bVisible == true and 1 or 0)
NovaAPI.SetCanvasGroupBlocksRaycasts(self._mapNode.root_canvas_group, bVisible == true)
NovaAPI.SetCanvasGroupInteractable(self._mapNode.root_canvas_group, bVisible == true)
end
function CharTalentCtrl:BuildUIData()
self.nCharId = self._panel.nCharId
self.tbGroup = PlayerData.Talent:GetSortedTalentGroup(self.nCharId)
local mapCfgData_Character = ConfigTable.GetData("Character", self.nCharId)
local mapCfgData_CharGrade = ConfigTable.GetData("CharGrade", mapCfgData_Character.Grade)
self.nItemId = mapCfgData_Character.FragmentsId
self.nItemNum = mapCfgData_CharGrade.FragmentsQty
self.tbAttr = {}
for i, v in ipairs(self.tbGroup) do
local nGroupId = v.nId
local nActivated = v.nNormalCount
local tbTalent = {}
local mapTalent = CacheTable.GetData("_Talent", nGroupId)
for kk, vv in pairs(mapTalent) do
if vv.Type == GameEnum.talentType.OrdinaryNode then
table.insert(tbTalent, {
nId = vv.Id,
nSort = vv.Sort
})
end
end
table.sort(tbTalent, function(a, b)
return a.nSort < b.nSort
end)
local tbTalentAttr_On, tbTalentAttr_Off = {}, {}
local mapTalentAttr_On, mapTalentAttr_Off = {}, {}
for iii, vvv in ipairs(tbTalent) do
local tbTalentEffectDesc = PlayerData.Talent:GetTalentAttributeDesc(vvv.nId)
local mapTalentAttr = nActivated >= iii and mapTalentAttr_On or mapTalentAttr_Off
for _, mapDesc in ipairs(tbTalentEffectDesc) do
if mapTalentAttr[mapDesc.nEftDescId] == nil then
mapTalentAttr[mapDesc.nEftDescId] = {
nEftDescId = mapDesc.nEftDescId,
nValueNum = mapDesc.nValueNum
}
else
mapTalentAttr[mapDesc.nEftDescId].nValueNum = mapTalentAttr[mapDesc.nEftDescId].nValueNum + mapDesc.nValueNum
end
end
end
for nEftDescId, mapAttr in pairs(mapTalentAttr_On) do
table.insert(tbTalentAttr_On, {
nEftDescId = mapAttr.nEftDescId,
nValueNum = mapAttr.nValueNum
})
end
for nEftDescId, mapAttr in pairs(mapTalentAttr_Off) do
table.insert(tbTalentAttr_Off, {
nEftDescId = mapAttr.nEftDescId,
nValueNum = mapAttr.nValueNum
})
end
table.sort(tbTalentAttr_On, function(a, b)
return a.nEftDescId < b.nEftDescId
end)
table.sort(tbTalentAttr_Off, function(a, b)
return a.nEftDescId < b.nEftDescId
end)
table.insert(self.tbAttr, {tbTalentAttr_On, tbTalentAttr_Off})
end
self:CheckL2DStatus()
end
function CharTalentCtrl:RefreshAll(nUIState)
self:SetL2D()
self:SetBtnUIShowHide()
self:SetOverview()
self:SetDetail(nUIState)
self:SetMoreInfo()
end
function CharTalentCtrl:CheckGroupState(bLock, nNormalCount, nNodeLimit)
local nState = 1
if bLock == true then
nState = 1
else
nState = nNodeLimit <= nNormalCount and 3 or 2
end
return nState
end
function CharTalentCtrl:GetCurTalentId(nGroupId, nNormalCount)
local tbTalent = {}
local mapTalent = CacheTable.GetData("_Talent", nGroupId)
for k, v in pairs(mapTalent) do
if v.Type == GameEnum.talentType.OrdinaryNode then
table.insert(tbTalent, {
nId = v.Id,
nSort = v.Sort
})
end
end
table.sort(tbTalent, function(a, b)
return a.nSort < b.nSort
end)
local mapTempTalentData = tbTalent[nNormalCount + 1]
if mapTempTalentData ~= nil then
return mapTempTalentData.nId
else
return nil
end
end
function CharTalentCtrl:CheckL2DStatus()
self.nL2DStatus = 0
for i, v in ipairs(self.tbGroup) do
local mapCfgData_TalentGroup = ConfigTable.GetData("TalentGroup", v.nId)
if v.nNormalCount == mapCfgData_TalentGroup.NodeLimit then
self.nL2DStatus = self.nL2DStatus + 1
end
end
end
function CharTalentCtrl:OnEvent_CharRelatePanelOpen(nNextPanel, nCharId)
local bIsThis = nNextPanel == PanelId.CharTalent
self:SetAllVisibale(bIsThis == true)
if bIsThis == true then
self._mapNode.anim:Play(bIsThis == true and "CharTalent_Root_in" or "CharTalent_Root_out")
self:BuildUIData()
self:RefreshAll()
end
end
function CharTalentCtrl:SetL2D()
Actor2DManager.SetActor2D(self:GetPanelId(), self._mapNode.rawImg, self.nCharId, nil, {
"TalentL2D",
self.nL2DStatus
}, 2)
end
function CharTalentCtrl:OnEvent_SwitchCurChar(nPanelId, nCharId)
if nPanelId == PanelId.CharTalent then
self:BuildUIData()
self:RefreshAll()
end
end
function CharTalentCtrl:SetBtnUIShowHide()
self._mapNode.btn_FullScreen_PlayBtnUIShowAnim:SetActive(self.bUIVisible == false)
self._mapNode.btnUIShow.gameObject:SetActive(self.bUIVisible == false)
self._mapNode.btnUIHide.gameObject:SetActive(self.bUIVisible == true)
end
function CharTalentCtrl:OnBtnClick_UIShow(btn)
if self.bUIVisible == false then
self.bUIVisible = true
self:SetBtnUIShowHide()
EventManager.Hit("ChangeCharTopBar", true, false)
EventManager.Hit("ChangeCharFgTab", true)
self._mapNode.anim:Play("CharTalent_Root_show")
EventManager.Hit(EventId.TemporaryBlockInput, 1)
end
end
function CharTalentCtrl:OnBtnClick_UIHide(btn)
if self.bUIVisible == true then
self.bUIVisible = false
self:SetBtnUIShowHide()
EventManager.Hit("ChangeCharTopBar", false, false)
EventManager.Hit("ChangeCharFgTab", false)
self._mapNode.anim:Play("CharTalent_Root_hide")
EventManager.Hit(EventId.TemporaryBlockInput, 1)
end
end
function CharTalentCtrl:SetOverview()
for i = 1, self.nGroupNum do
local mapGroupData = self.tbGroup[i]
local mapCfgData_TalentGroup = ConfigTable.GetData("TalentGroup", mapGroupData.nId)
local objCtrlKeyNode = self._mapNode.KeyNode[i]
if mapGroupData ~= nil and mapCfgData_TalentGroup ~= nil and objCtrlKeyNode ~= nil then
local nState = self:CheckGroupState(mapGroupData.bLock, mapGroupData.nNormalCount, mapCfgData_TalentGroup.NodeLimit)
objCtrlKeyNode:Refresh(mapGroupData.nId, i, nState)
end
end
end
function CharTalentCtrl:OnBtnClick_Key(btn, nIndex)
self.nCurGroupIndex = nIndex
self:SetDetail()
EventManager.Hit("ChangeCharFgTab", false)
EventManager.Hit("ChangeCharTopBar", false, false)
self._mapNode.anim:Play("CharTalent_Root_o2d")
end
function CharTalentCtrl:SetDetail(nUIState)
local mapGroupData = self.tbGroup[self.nCurGroupIndex]
self.nCurGroupId = mapGroupData.nId
local mapCfgData_TalentGroup = ConfigTable.GetData("TalentGroup", self.nCurGroupId)
local nHasNum = PlayerData.Item:GetItemCountByID(self.nItemId)
self.bEnoughNum = nHasNum >= self.nItemNum
local _n = math.floor(nHasNum / self.nItemNum)
if _n > mapCfgData_TalentGroup.NodeLimit - mapGroupData.nNormalCount then
_n = mapCfgData_TalentGroup.NodeLimit - mapGroupData.nNormalCount
end
local nCanActivateNum = self.bEnoughNum == true and _n or 1
local nAsPossibleAsCan = self.bEnoughNum == true and _n * self.nItemNum or self.nItemNum
self.nConsumeNum = nAsPossibleAsCan
if mapGroupData.bLock == true then
nAsPossibleAsCan = self.nItemNum * mapCfgData_TalentGroup.NodeLimit
end
NovaAPI.SetTMPText(self._mapNode.tmpGroupName, string.format("%02d %s", self.nCurGroupIndex, mapCfgData_TalentGroup.Title))
local nState = self:CheckGroupState(mapGroupData.bLock, mapGroupData.nNormalCount, mapCfgData_TalentGroup.NodeLimit)
self:SetAtlasSprite(self._mapNode.imgGroupNode, "11_ico", "zs_talent_star_l_" .. tostring(nState))
if nUIState ~= 1 then
self._mapNode.animGroupNode:Play("empty")
self._mapNode.imgGroupNode.transform:GetChild(0).localScale = Vector3.zero
end
for i = 1, mapCfgData_TalentGroup.NodeLimit do
if self._mapNode.tbImgNode[i] ~= nil then
local _name = "zs_talent_progress_1"
if mapGroupData.bLock ~= true then
if i <= mapGroupData.nNormalCount then
_name = "zs_talent_progress_3"
elseif nCanActivateNum >= i - mapGroupData.nNormalCount then
_name = "zs_talent_progress_2"
end
end
self:SetAtlasSprite(self._mapNode.tbImgNode[i], "11_ico", _name)
if nUIState ~= 1 then
self._mapNode.tbAnimNode[i]:Play("empty")
self._mapNode.tbImgNode[i].transform:GetChild(0).localScale = Vector3.zero
end
end
end
local mapCfgData_Talent = ConfigTable.GetData("Talent", mapGroupData.nKeyTalent)
NovaAPI.SetTMPText(self._mapNode.tmpGroupDesc, UTILS.ParseDesc(mapCfgData_Talent))
local s = string.format(" %s/%s", tostring(mapGroupData.nNormalCount), tostring(mapCfgData_TalentGroup.NodeLimit))
NovaAPI.SetTMPText(self._mapNode.tmpProgress, ConfigTable.GetUIText("CharTalent_ConditionDesc") .. s)
self._mapNode.goNext:SetActive(nState == 2)
self._mapNode.btnRequireItem.gameObject:SetActive(nState ~= 3)
self._mapNode.btnActivate.gameObject:SetActive(nState == 2)
if nState ~= 3 then
self.nCurTalentId = self:GetCurTalentId(self.nCurGroupId, mapGroupData.nNormalCount)
if self.nCurTalentId ~= nil then
mapCfgData_Talent = ConfigTable.GetData("Talent", self.nCurTalentId)
NovaAPI.SetTMPText(self._mapNode.tmpNextDesc, ConfigTable.GetUIText("CharTalent_NextNode") .. UTILS.ParseDesc(mapCfgData_Talent))
end
end
local mapCfgData_Item = ConfigTable.GetData("Item", self.nItemId)
self:SetSprite_FrameColor(self._mapNode.imgItemRare, mapCfgData_Item.Rarity, AllEnum.FrameType_New.Item, false)
self:SetPngSprite(self._mapNode.imgItemIcon, mapCfgData_Item.Icon)
if mapGroupData.bLock == true then
NovaAPI.SetTMPText(self._mapNode.tmpNum_Has_Require, tostring(self.nItemNum * mapCfgData_TalentGroup.NodeLimit))
else
local sItemNumFormat = self.bEnoughNum == true and "%s/%s" or "<color=#BD3059>%s</color>/%s"
NovaAPI.SetTMPText(self._mapNode.tmpNum_Has_Require, string.format(sItemNumFormat, tostring(nHasNum), tostring(self.nItemNum)))
end
local sBtnDb = mapGroupData.bLock ~= true and self.bEnoughNum == true and "btn_common_db_m_1" or "btn_common_db_m_2"
self:SetAtlasSprite(self._mapNode.imgActivateDb, "06_btn", sBtnDb)
local _, color = ColorUtility.TryParseHtmlString(mapGroupData.bLock ~= true and self.bEnoughNum == true and "#FFFFFF" or "#94AAC0")
NovaAPI.SetTMPColor(self._mapNode.tmpActivate, color)
NovaAPI.SetTMPText(self._mapNode.tmpAllDone, ConfigTable.GetUIText(nState == 1 and "CharTalent_PreNodeLocked" or "CharTalent_Actived"))
self._mapNode.rtTmpAllDone.anchoredPosition = nState == 1 and Vector2(12, -282) or Vector2(0, -438)
self._mapNode.rtBtnRequireItem.anchoredPosition = nState == 1 and Vector2(0, -406) or Vector2(0, -293)
self._mapNode.tmpAllDone.transform.localScale = nState ~= 2 and Vector3.one or Vector3.zero
if nUIState == 1 then
self._mapNode.animDetailText:Play("CharTalent_Text_in")
end
if nUIState == 2 then
self._mapNode.animRoot:Play("CharTalent_Switch_in")
end
end
function CharTalentCtrl:PlaySwitchGroupPrevNxtAnim()
local sequence = DOTween.Sequence()
sequence:AppendInterval(0.1)
sequence:AppendCallback(dotween_callback_handler(self, self._PlayFX, self._mapNode.animRoot, 4))
sequence:AppendInterval(0.1)
sequence:AppendCallback(dotween_callback_handler(self, self.SetDetail, 2))
EventManager.Hit(EventId.TemporaryBlockInput, 0.2)
end
function CharTalentCtrl:OnBtnClick_Back(btn)
EventManager.Hit("ChangeCharFgTab", true)
EventManager.Hit("ChangeCharTopBar", true, false)
self._mapNode.anim:Play("CharTalent_Root_d2o")
end
function CharTalentCtrl:OnBtnClick_Home(btn)
PanelManager.Home()
end
function CharTalentCtrl:OnBtnClick_PrevGroup(btn)
self.nCurGroupIndex = self.nCurGroupIndex - 1
if self.nCurGroupIndex < 1 then
self.nCurGroupIndex = self.nGroupNum
end
self:PlaySwitchGroupPrevNxtAnim()
end
function CharTalentCtrl:OnBtnClick_NextGroup(btn)
self.nCurGroupIndex = self.nCurGroupIndex + 1
if self.nCurGroupIndex > self.nGroupNum then
self.nCurGroupIndex = 1
end
self:PlaySwitchGroupPrevNxtAnim()
end
function CharTalentCtrl:SetMoreInfo()
for i = 1, 6 do
if i == 1 then
NovaAPI.SetTMPText(self._mapNode.tbTmpTalentGroupName[i], ConfigTable.GetUIText("Filter_All"))
else
local mapGroupData = self.tbGroup[i - 1]
local mapCfgData_TalentGroup = ConfigTable.GetData("TalentGroup", mapGroupData.nId)
self:SetAtlasSprite(self._mapNode.tbImgIconDb[i], "11_ico", mapGroupData.bLock == true and "zs_talent info_title_dis" or "zs_talent info_title")
NovaAPI.SetTMPText(self._mapNode.tbTmpTalentGroupName[i], mapCfgData_TalentGroup.Title)
end
end
self:OnBtnClick_Tab(nil, 1)
end
function CharTalentCtrl:_DelChildFromTheLast(tr, nEndIdx)
local nChildCount = tr.childCount - 1
for i = nChildCount, nEndIdx, -1 do
destroy(tr:GetChild(i).gameObject)
end
end
function CharTalentCtrl:_SetGridAttr(goTemplate, trParent, mapAttr)
local go = instantiate(goTemplate, trParent)
local tr = go.transform
tr:SetAsLastSibling()
local mapCfgData_EffectDesc = ConfigTable.GetData("EffectDesc", mapAttr.nEftDescId)
local sValue = FormatEffectValue(mapAttr.nValueNum, mapCfgData_EffectDesc.isPercent, mapCfgData_EffectDesc.Format)
if mapAttr.nValueNum > 0 then
sValue = "+" .. sValue
end
self:SetPngSprite(tr:Find("imgIcon"):GetComponent("Image"), mapCfgData_EffectDesc.Icon)
NovaAPI.SetTMPText(tr:Find("tmpName"):GetComponent("TMP_Text"), mapCfgData_EffectDesc.Desc)
NovaAPI.SetTMPText(tr:Find("tmpValue"):GetComponent("TMP_Text"), sValue)
go:SetActive(true)
end
function CharTalentCtrl:OnBtnClick_MoreInfo(btn)
self:OnBtnClick_Tab(nil, 1)
end
function CharTalentCtrl:OnBtnClick_Tab(btn, nIndex)
for i = 1, 6 do
self._mapNode.tbSelect[i]:SetActive(i == nIndex)
end
if self.tw ~= nil then
self.tw:Kill()
self.tw = nil
end
NovaAPI.SetCanvasGroupAlpha(self._mapNode.canvasGroup_All, 0)
NovaAPI.SetCanvasGroupAlpha(self._mapNode.canvasGroup_TalentGroup, 0)
self.tw = NovaAPI.SetCanvasGroupDoFade(nIndex == 1 and self._mapNode.canvasGroup_All or self._mapNode.canvasGroup_TalentGroup, 1, 0.5, true)
local tbAttrOn, tbAttrOff, mapAttrOn, mapAttrOff = {}, {}, {}, {}
if nIndex == 1 then
for nGroupIndex, tbOnOff in ipairs(self.tbAttr) do
local tbTalentAttr_On = tbOnOff[1]
for nEftIndex, mapEftData in ipairs(tbTalentAttr_On) do
if mapAttrOn[mapEftData.nEftDescId] == nil then
mapAttrOn[mapEftData.nEftDescId] = {
nEftDescId = mapEftData.nEftDescId,
nValueNum = mapEftData.nValueNum
}
else
mapAttrOn[mapEftData.nEftDescId].nValueNum = mapAttrOn[mapEftData.nEftDescId].nValueNum + mapEftData.nValueNum
end
end
local tbTalentAttr_Off = tbOnOff[2]
for nEftIndex, mapEftData in ipairs(tbTalentAttr_Off) do
if mapAttrOn[mapEftData.nEftDescId] == nil then
mapAttrOff[mapEftData.nEftDescId] = {
nEftDescId = mapEftData.nEftDescId,
nValueNum = 0
}
end
end
end
for nEftDescId, mapEftData in pairs(mapAttrOn) do
table.insert(tbAttrOn, mapEftData)
end
table.sort(tbAttrOn, function(a, b)
return a.nEftDescId < b.nEftDescId
end)
for nEftDescId, mapEftData in pairs(mapAttrOff) do
table.insert(tbAttrOff, mapEftData)
end
table.sort(tbAttrOff, function(a, b)
return a.nEftDescId < b.nEftDescId
end)
for _nOffIdx, _mapOffData in ipairs(tbAttrOff) do
table.insert(tbAttrOn, _mapOffData)
end
self:_DelChildFromTheLast(self._mapNode.trContentAll, 0)
for _, mapAttr in ipairs(tbAttrOn) do
self:_SetGridAttr(self._mapNode.grid_all, self._mapNode.trContentAll, mapAttr)
end
LayoutRebuilder.ForceRebuildLayoutImmediate(self._mapNode.trContentAll)
else
local mapGroupData = self.tbGroup[nIndex - 1]
local mapCfgData_TalentGroup = ConfigTable.GetData("TalentGroup", mapGroupData.nId)
NovaAPI.SetTMPText(self._mapNode.tmpTitleGroup, mapCfgData_TalentGroup.Title)
local s = string.format(" %s/%s", tostring(mapGroupData.nNormalCount), tostring(mapCfgData_TalentGroup.NodeLimit))
NovaAPI.SetTMPText(self._mapNode.tmpGroupProgress, ConfigTable.GetUIText("CharTalent_ConditionDesc") .. s)
tbAttrOn = self.tbAttr[nIndex - 1][1]
tbAttrOff = self.tbAttr[nIndex - 1][2]
self:_DelChildFromTheLast(self._mapNode.trListOn, 2)
self:_DelChildFromTheLast(self._mapNode.trListOff, 2)
for _, mapAttr in ipairs(tbAttrOn) do
self:_SetGridAttr(self._mapNode.grid_on, self._mapNode.trListOn, mapAttr)
end
for _, mapAttr in ipairs(tbAttrOff) do
self:_SetGridAttr(self._mapNode.grid_off, self._mapNode.trListOff, mapAttr)
end
LayoutRebuilder.ForceRebuildLayoutImmediate(self._mapNode.trListOn)
LayoutRebuilder.ForceRebuildLayoutImmediate(self._mapNode.trListOff)
self._mapNode.trListOn.gameObject:SetActive(0 < #tbAttrOn)
self._mapNode.goSplitLine:SetActive(0 < #tbAttrOn and 0 < #tbAttrOff)
self._mapNode.trListOff.gameObject:SetActive(0 < #tbAttrOff)
end
end
function CharTalentCtrl:OnBtnClick_Word(link, sWordId)
UTILS.ClickWordLink(link, sWordId)
end
function CharTalentCtrl:OnBtnClick_RequireItem(btn)
UTILS.ClickItemGridWithTips(self.nItemId, self._mapNode.btnRequireItem.transform, true)
end
function CharTalentCtrl:OnBtnClick_Activate(btn)
local mapGroupData = self.tbGroup[self.nCurGroupIndex]
if mapGroupData == nil then
printLog("Talent group data error.")
return
end
if mapGroupData.bLock == true then
printLog("This talent group need unlock.")
return
end
local mapCfgData_Item = ConfigTable.GetData("Item", self.nItemId)
if self.bEnoughNum ~= true then
WwiseAudioManager:PostEvent("ui_common_button_error")
EventManager.Hit(EventId.OpenMessageBox, orderedFormat(ConfigTable.GetUIText("CharTalent_NotEnoughItem"), mapCfgData_Item.Title))
printLog("Not enough item number.")
return
end
local mapCfgData_TalentGroup = ConfigTable.GetData("TalentGroup", self.nCurGroupId)
WwiseAudioManager:PostEvent("ui_charInfo_talent_click")
local nPlayFxFrom = mapGroupData.nNormalCount + 1
local confirmCallback = function()
local callback = function()
self:BuildUIData()
self._mapNode.btnActivate.gameObject:SetActive(false)
local nPlayFxTo = self.tbGroup[self.nCurGroupIndex].nNormalCount
local nDuration = 0
local nInterval = 0.1
local sequence = DOTween.Sequence()
sequence:AppendInterval(nInterval)
WwiseAudioManager:PostEvent(nPlayFxTo >= mapCfgData_TalentGroup.NodeLimit and "ui_charInfo_talent_active_large_part1" or "ui_charInfo_talent_active_small")
for i = nPlayFxFrom, nPlayFxTo do
sequence:AppendCallback(dotween_callback_handler(self, self._PlayFX, self._mapNode.tbAnimNode[i], 1))
sequence:AppendInterval(nInterval)
nDuration = nDuration + nInterval
end
sequence:AppendCallback(dotween_callback_handler(self, self._PlayFX, self._mapNode.animDetailText, 3))
if nPlayFxTo >= mapCfgData_TalentGroup.NodeLimit then
sequence:AppendCallback(dotween_callback_handler(self, self._PlayFX, self._mapNode.animGroupNode, 2))
end
sequence:AppendInterval(0.7)
nDuration = nDuration + 0.7
sequence:AppendCallback(dotween_callback_handler(self, self.RefreshAll, 1))
EventManager.Hit(EventId.TemporaryBlockInput, nDuration)
end
PlayerData.Talent:SendTalentGroupUnlockSetReq(self.nCharId, mapGroupData.nId, callback)
end
if self.nConsumeNum == self.nItemNum then
confirmCallback()
return
end
local TipsTime = LocalData.GetPlayerLocalData("CharTalentActivate")
local _tipDay = 0
if TipsTime ~= nil then
_tipDay = tonumber(TipsTime)
end
local curTimeStamp = CS.ClientManager.Instance.serverTimeStampWithTimeZone
local fixedTimeStamp = curTimeStamp + newDayTime * 3600
local nYear = tonumber(os.date("!%Y", fixedTimeStamp))
local nMonth = tonumber(os.date("!%m", fixedTimeStamp))
local nDay = tonumber(os.date("!%d", fixedTimeStamp))
local nowD = nYear * 366 + nMonth * 31 + nDay
if nowD == _tipDay then
confirmCallback()
else
local isSelectAgain = false
local _tempCallback = function()
if isSelectAgain then
local _curTimeStamp = CS.ClientManager.Instance.serverTimeStampWithTimeZone
local _fixedTimeStamp = _curTimeStamp + newDayTime * 3600
local _nYear = tonumber(os.date("!%Y", _fixedTimeStamp))
local _nMonth = tonumber(os.date("!%m", _fixedTimeStamp))
local _nDay = tonumber(os.date("!%d", _fixedTimeStamp))
local _nowD = _nYear * 366 + _nMonth * 31 + _nDay
LocalData.SetPlayerLocalData("CharTalentActivate", tostring(_nowD))
end
confirmCallback()
end
local againCallback = function(isSelect)
isSelectAgain = isSelect
end
local msg = {
nType = AllEnum.MessageBox.Confirm,
sContent = orderedFormat(ConfigTable.GetUIText("CharTalent_ActivateConfirm"), tostring(self.nConsumeNum), mapCfgData_Item.Title, mapCfgData_TalentGroup.Title),
callbackConfirm = _tempCallback,
sAgain = ConfigTable.GetUIText("MessageBox_TodayWarning"),
callbackAgain = againCallback
}
EventManager.Hit(EventId.OpenMessageBox, msg)
end
end
function CharTalentCtrl:_PlayFX(anim, n)
local tbAnimName = {
"TalentNode_Unlock",
"TalentGroupNode_Unlock",
"CharTalent_Text_out",
"CharTalent_Switch_out"
}
anim:Play(tbAnimName[n])
if n == 2 then
WwiseAudioManager:PostEvent("ui_charInfo_talent_active_large_part2")
end
end
return CharTalentCtrl
@@ -0,0 +1,8 @@
local CharTalentPanel = class("CharTalentPanel", BasePanel)
CharTalentPanel._tbDefine = {
{
sPrefabPath = "CharacterInfoEx/CharTalentPanel.prefab",
sCtrlName = "Game.UI.CharacterInfoEx.CharTalentCtrl"
}
}
return CharTalentPanel
@@ -0,0 +1,305 @@
local CharUpgradeCtrl = class("CharUpgradeCtrl", BaseCtrl)
CharUpgradeCtrl._mapNodeConfig = {
NotMax = {},
txtTitleRank = {
nCount = 2,
sComponentName = "TMP_Text",
sLanguageId = "Template_CharRank"
},
txtCurLv = {nCount = 2, sComponentName = "TMP_Text"},
goAdvanceStar = {
nCount = 2,
sCtrlName = "Game.UI.TemplateEx.TemplateStarAdvanceCtrl"
},
txtMaxLevel = {sComponentName = "TMP_Text"},
goExpbar = {
nCount = 2,
sCtrlName = "Game.UI.TemplateEx.TemplateExpBarCtrl"
},
goProperty = {},
goPropertyLong = {},
trProperty = {sComponentName = "Transform"},
goMat = {
nCount = 4,
sCtrlName = "Game.UI.TemplateEx.TemplateMatGridCtrl"
},
btnMaxLv = {
sComponentName = "UIButton",
callback = "OnBtnClick_MaxLv"
},
btnNextLv = {
sComponentName = "UIButton",
callback = "OnBtnClick_NextLv"
},
txtBtnNextLv = {
sComponentName = "TMP_Text",
sLanguageId = "Btn_UpOneLevel"
},
txtBtnMaxLv = {
sComponentName = "TMP_Text",
sLanguageId = "Btn_UpMaxLevel"
},
btnAdd = {
nCount = 4,
sComponentName = "UIButton",
callback = "OnBtnClick_Add"
},
btnReduce = {
nCount = 4,
sComponentName = "UIButton",
callback = "OnBtnClick_Reduce"
},
btnUpgrade = {
sComponentName = "UIButton",
callback = "OnBtnClick_Upgrade"
},
txtBtnUpgrade = {
sComponentName = "TMP_Text",
sLanguageId = "Btn_LevelUp"
},
imgCostIcon = {sComponentName = "Image"},
txtCostCount = {sComponentName = "TMP_Text"},
Max = {},
txtMaxLv = {nCount = 2, sComponentName = "TMP_Text"},
trMaxProperty = {sComponentName = "Transform"},
txtLvMax = {
sComponentName = "TMP_Text",
sLanguageId = "Tip_MaxLevel"
}
}
CharUpgradeCtrl._mapEventConfig = {}
function CharUpgradeCtrl:InitData(nCharId, mapCurLevel)
self.nCharId = nCharId
self.mapChar = PlayerData.Char:GetCharDataByTid(self.nCharId)
self.mapBeforeLevel = mapCurLevel
self.mapAfterLevel = nil
self.tbMat = nil
self.nGoldCost = 0
self.mapAttrBefore = nil
self.mapAttrAfter = nil
end
function CharUpgradeCtrl:Refresh(nCharId, mapCurLevel, nMaxAdvance, bMax)
self:InitData(nCharId, mapCurLevel)
self._mapNode.NotMax:SetActive(not bMax)
self._mapNode.Max:SetActive(bMax)
if bMax then
self:RefreshMax()
else
self:RefreshNotMax()
end
self:RefreshStar(nMaxAdvance)
end
function CharUpgradeCtrl:RefreshMax()
NovaAPI.SetTMPText(self._mapNode.txtMaxLv[1], self.mapBeforeLevel.nLevel)
NovaAPI.SetTMPText(self._mapNode.txtMaxLv[2], "/" .. self.mapBeforeLevel.nLevel)
self._mapNode.goExpbar[2]:Refresh(self.mapBeforeLevel)
local mapAttrBase = PlayerData.Char:GetCharCfgAttr({1, 2}, self.nCharId, self.mapChar.nAdvance, self.mapChar.nLevel)
delChildren(self._mapNode.trMaxProperty)
for _, mapAttachAttr in ipairs(AllEnum.AttachAttr) do
local mapAttr = mapAttrBase[mapAttachAttr.sKey]
if mapAttr and mapAttr.Value > 0 then
local goItemObj = instantiate(self._mapNode.goProperty, self._mapNode.trMaxProperty)
goItemObj:SetActive(true)
local ctrlItem = self:BindCtrlByNode(goItemObj, "Game.UI.TemplateEx.TemplatePropertyCtrl")
ctrlItem:SetItemProperty(mapAttr.Key, mapAttr.Value)
end
end
end
function CharUpgradeCtrl:RefreshNotMax()
self.mapAfterLevel = {
nLevel = self.mapBeforeLevel.nLevel,
nExp = self.mapBeforeLevel.nExp,
nMaxLevel = self.mapBeforeLevel.nMaxLevel,
nMaxExp = self.mapBeforeLevel.nMaxExp,
nMatExp = self.mapBeforeLevel.nMatExp
}
self:RefreshInfo()
end
function CharUpgradeCtrl:RefreshInfo()
self:RefreshLvAndExp(self.mapBeforeLevel, self.mapAfterLevel)
self:RefreshAttr()
self:RefreshCoin()
self:RefreshMat(true)
end
function CharUpgradeCtrl:RefreshLvAndExp(mapBeforeLevel, mapAfterLevel)
self._mapNode.txtCurLv[1].gameObject:SetActive(mapAfterLevel.nLevel <= mapBeforeLevel.nLevel)
self._mapNode.txtCurLv[2].gameObject:SetActive(mapAfterLevel.nLevel > mapBeforeLevel.nLevel)
for i = 1, 2 do
NovaAPI.SetTMPText(self._mapNode.txtCurLv[i], mapAfterLevel.nLevel)
end
NovaAPI.SetTMPText(self._mapNode.txtMaxLevel, "/" .. mapAfterLevel.nMaxLevel)
self._mapNode.goExpbar[1]:Refresh(mapBeforeLevel, mapAfterLevel)
end
function CharUpgradeCtrl:RefreshAttr()
local bExpChanged = true
if self.mapAfterLevel.nLevel == self.mapBeforeLevel.nLevel and self.mapAfterLevel.nExp == self.mapBeforeLevel.nExp then
bExpChanged = false
end
self.mapAttrBefore = PlayerData.Char:GetCharCfgAttr({1, 2}, self.nCharId, self.mapChar.nAdvance, self.mapChar.nLevel)
self.mapAttrAfter = PlayerData.Char:GetCharCfgAttr({1, 2}, self.nCharId, self.mapChar.nAdvance, self.mapAfterLevel.nLevel)
delChildren(self._mapNode.trProperty)
for _, mapAttachAttr in ipairs(AllEnum.AttachAttr) do
local mapAttr = self.mapAttrBefore[mapAttachAttr.sKey]
if mapAttr and mapAttr.Value > 0 then
local goItemObj = instantiate(self._mapNode.goPropertyLong, self._mapNode.trProperty)
goItemObj:SetActive(true)
local ctrlItem = self:BindCtrlByNode(goItemObj, "Game.UI.TemplateEx.TemplatePropertyCtrl")
local bValueChanged = self.mapAttrAfter[mapAttachAttr.sKey].Value ~= mapAttr.Value
if bExpChanged and bValueChanged then
ctrlItem:SetItemProperty(mapAttr.Key, mapAttr.Value, self.mapAttrAfter[mapAttachAttr.sKey].Value)
else
ctrlItem:SetItemProperty(mapAttr.Key, mapAttr.Value)
end
end
end
end
function CharUpgradeCtrl:RefreshStar(nMaxAdvance)
self._mapNode.goAdvanceStar[1]:SetStar(self.mapChar.nAdvance, nMaxAdvance)
self._mapNode.goAdvanceStar[2]:SetStar(self.mapChar.nAdvance, nMaxAdvance)
end
function CharUpgradeCtrl:RefreshCoin()
self:SetSprite_Coin(self._mapNode.imgCostIcon, AllEnum.CoinItemId.Gold)
local nHasCoin = PlayerData.Coin:GetCoinCount(AllEnum.CoinItemId.Gold)
NovaAPI.SetTMPText(self._mapNode.txtCostCount, math.ceil(self.nGoldCost))
NovaAPI.SetTMPColor(self._mapNode.txtCostCount, nHasCoin < self.nGoldCost and Red_Unable or Blue_Normal)
end
function CharUpgradeCtrl:RefreshMat(bInit)
if bInit then
self.tbMat = PlayerData.Char:GetUpgradeMatList()
for i = 1, 4 do
self._mapNode.goMat[i]:RerfeshGrid({
nId = self.tbMat[i].nItemId
})
end
else
for i = 1, 4 do
self._mapNode.goMat[i]:SetGridCount(self.tbMat[i].nCost)
end
end
end
function CharUpgradeCtrl:ChangeMat()
self.mapAfterLevel, self.nGoldCost = PlayerData.Char:GetLevelDataAndCostByMat(self.nCharId, self.tbMat, self.mapBeforeLevel.nMaxLevel)
self:RefreshLvAndExp(self.mapBeforeLevel, self.mapAfterLevel)
self:RefreshAttr()
self:RefreshCoin()
self:RefreshMat()
end
function CharUpgradeCtrl:Awake()
end
function CharUpgradeCtrl:OnEnable()
end
function CharUpgradeCtrl:OnDisable()
end
function CharUpgradeCtrl:OnDestroy()
end
function CharUpgradeCtrl:OnBtnClick_MaxLv(btn)
if self.mapAfterLevel.nLevel == self.mapAfterLevel.nMaxLevel then
return
end
self.mapAfterLevel, self.tbMat, self.nGoldCost = PlayerData.Char:GetMaxLevelDataAndCost(self.nCharId, self.mapBeforeLevel.nMaxLevel)
if self.nGoldCost == 0 then
EventManager.Hit(EventId.OpenMessageBox, ConfigTable.GetUIText("Upgrade_NoneMat"))
return
end
self:ChangeMat()
end
function CharUpgradeCtrl:OnBtnClick_NextLv(btn)
if self.mapAfterLevel.nLevel == self.mapAfterLevel.nMaxLevel then
return
end
self.mapAfterLevel, self.tbMat, self.nGoldCost = PlayerData.Char:GetCustomizeLevelDataAndCost(self.nCharId, self.mapAfterLevel.nLevel + 1, self.mapBeforeLevel.nMaxLevel)
if self.nGoldCost == 0 then
EventManager.Hit(EventId.OpenMessageBox, ConfigTable.GetUIText("Upgrade_NoneMat"))
return
end
self:ChangeMat()
end
function CharUpgradeCtrl:OnBtnClick_Upgrade()
if self.nGoldCost == 0 then
EventManager.Hit(EventId.OpenMessageBox, ConfigTable.GetUIText("Upgrade_NoneMat"))
return
end
if self.nGoldCost > PlayerData.Coin:GetCoinCount(AllEnum.CoinItemId.Gold) then
EventManager.Hit(EventId.OpenMessageBox, ConfigTable.GetUIText("Upgrade_GoinNotEnough"))
return
end
local callback = function()
local ani_end = function()
self.nGoldCost = 0
local mapData = {
nLevel = self.mapAfterLevel.nLevel,
mapAttrBefore = self.mapAttrBefore,
mapAttrAfter = self.mapAttrAfter
}
if self.mapAfterLevel.nLevel > self.mapBeforeLevel.nLevel then
EventManager.Hit(EventId.OpenPanel, PanelId.CharSucBar, mapData, true)
end
EventManager.Hit("CharDevelopmentRefresh")
end
self:RefreshLvAndExp(self.mapBeforeLevel, self.mapBeforeLevel)
self._mapNode.goExpbar[1]:PlayAni(self.mapBeforeLevel, self.mapAfterLevel, ani_end, self._mapNode.txtCurLv[1])
PlayerData.Voice:PlayCharVoice("charUp", self.nCharId)
end
PlayerData.Char:CharUpgrade(self.nCharId, self.tbMat, self.mapAfterLevel, callback)
end
function CharUpgradeCtrl:OnBtnClick_Add(btn, nIndex)
local func_tips = function()
local mapData = {
nTid = self.tbMat[nIndex].nItemId,
bShowDepot = true,
bShowJumpto = true
}
EventManager.Hit(EventId.OpenPanel, PanelId.ItemTips, btn.transform, mapData)
end
if self.mapAfterLevel.nLevel == self.mapAfterLevel.nMaxLevel then
if btn.Operate_Type == 0 then
func_tips()
end
return
end
local nHas = PlayerData.Item:GetItemCountByID(self.tbMat[nIndex].nItemId)
if nHas <= 0 then
func_tips()
return
end
local nHasRemain = nHas - self.tbMat[nIndex].nCost
if nHasRemain <= 0 then
func_tips()
return
end
if btn.Operate_Type == 0 then
self.tbMat[nIndex].nCost = self.tbMat[nIndex].nCost + 1
elseif btn.Operate_Type == 3 then
if btn.CurrentGear == 0 then
self.nRemain = PlayerData.Char:GetMaxMatCost(self.nCharId, self.tbMat, self.tbMat[nIndex], self.mapBeforeLevel.nMaxLevel)
if nHasRemain < self.nRemain then
self.nRemain = nHasRemain
end
end
local nGear, _ = math.modf(btn.CurrentGear / 3)
local nAdd = 2 ^ nGear
local nRemain = self.nRemain - nAdd
if nRemain < 0 then
nAdd = self.nRemain
self.nRemain = 0
else
self.nRemain = nRemain
end
self.tbMat[nIndex].nCost = math.floor(self.tbMat[nIndex].nCost + nAdd)
end
self.mapAfterLevel, self.nGoldCost = PlayerData.Char:GetLevelDataAndCostByMat(self.nCharId, self.tbMat, self.mapBeforeLevel.nMaxLevel)
self:ChangeMat()
end
function CharUpgradeCtrl:OnBtnClick_Reduce(btn, nIndex)
if btn.Operate_Type == 0 then
self.tbMat[nIndex].nCost = self.tbMat[nIndex].nCost - 1
elseif btn.Operate_Type == 3 then
self.tbMat[nIndex].nCost = math.floor(self.tbMat[nIndex].nCost - 2 ^ btn.CurrentGear)
end
if 0 > self.tbMat[nIndex].nCost then
self.tbMat[nIndex].nCost = 0
end
self.mapAfterLevel, self.nGoldCost = PlayerData.Char:GetLevelDataAndCostByMat(self.nCharId, self.tbMat, self.mapBeforeLevel.nMaxLevel)
self:ChangeMat()
end
return CharUpgradeCtrl
@@ -0,0 +1,48 @@
local TalentKeyNodeCtrl = class("TalentKeyNodeCtrl", BaseCtrl)
local NodeState = {
Lock = 1,
Ready = 2,
Active = 3
}
TalentKeyNodeCtrl._mapNodeConfig = {
goKeyReady = {nCount = 2},
goKeyOff = {nCount = 2},
goKeyOn = {nCount = 2},
redKey = {},
txtNameReady = {sComponentName = "TMP_Text"},
txtIndexReady = {sComponentName = "TMP_Text"},
txtNameOff = {sComponentName = "TMP_Text"},
txtIndexOff = {sComponentName = "TMP_Text"},
txtNameOn = {sComponentName = "TMP_Text"},
txtIndexOn = {sComponentName = "TMP_Text"}
}
TalentKeyNodeCtrl._mapEventConfig = {}
function TalentKeyNodeCtrl:Refresh(nId, nIndex, nState)
self.nId = nId
local mapCfg = ConfigTable.GetData("TalentGroup", nId)
if not mapCfg then
return
end
for i = 1, 2 do
self._mapNode.goKeyReady[i]:SetActive(nState == NodeState.Ready)
self._mapNode.goKeyOff[i]:SetActive(nState == NodeState.Lock)
self._mapNode.goKeyOn[i]:SetActive(nState == NodeState.Active)
end
if nState == NodeState.Lock then
NovaAPI.SetTMPText(self._mapNode.txtIndexOff, ConfigTable.GetUIText("CharTalent_NodeIndex" .. nIndex))
NovaAPI.SetTMPText(self._mapNode.txtNameOff, mapCfg.Title)
elseif nState == NodeState.Ready then
NovaAPI.SetTMPText(self._mapNode.txtIndexReady, ConfigTable.GetUIText("CharTalent_NodeIndex" .. nIndex))
NovaAPI.SetTMPText(self._mapNode.txtNameReady, mapCfg.Title)
elseif nState == NodeState.Active then
NovaAPI.SetTMPText(self._mapNode.txtIndexOn, ConfigTable.GetUIText("CharTalent_NodeIndex" .. nIndex))
NovaAPI.SetTMPText(self._mapNode.txtNameOn, mapCfg.Title)
end
self:RegisterRedDot()
end
function TalentKeyNodeCtrl:RegisterRedDot()
if self.nId ~= nil then
RedDotManager.RegisterNode(RedDotDefine.Role_Talent, self._panel.nCharId, self._mapNode.redKey)
end
end
return TalentKeyNodeCtrl