Initial version - 1.2.0.60
EN: 1.2.0.60 CN: 1.2.0.61 JP: 1.2.0.63 KR: 1.2.0.67
This commit is contained in:
@@ -0,0 +1,330 @@
|
||||
local DepotCharInfoCtrl = class("DepotCharInfoCtrl", BaseCtrl)
|
||||
local AdventureModuleHelper = CS.AdventureModuleHelper
|
||||
local CharacterAttrData = require("GameCore.Data.DataClass.CharacterAttrData")
|
||||
DepotCharInfoCtrl._mapNodeConfig = {
|
||||
goProperty = {
|
||||
nCount = 5,
|
||||
sCtrlName = "Game.UI.TemplateEx.TemplatePropertyCtrl"
|
||||
},
|
||||
txtTitleAttr = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "StarTower_Depot_Info_Property"
|
||||
},
|
||||
btnChar = {
|
||||
nCount = 3,
|
||||
sComponentName = "UIButton",
|
||||
callback = "OnBtnClick_Char"
|
||||
},
|
||||
imgHead = {nCount = 3, sComponentName = "Image"},
|
||||
goSelect = {nCount = 3},
|
||||
txtLeaderCn = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "Build_Leader"
|
||||
},
|
||||
txtSubCn = {
|
||||
nCount = 2,
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "Build_Sub"
|
||||
},
|
||||
btnPopSkill = {
|
||||
sComponentName = "UIButton",
|
||||
callback = "OnBtnClick_Skill"
|
||||
},
|
||||
btnAttrDetail = {
|
||||
sComponentName = "UIButton",
|
||||
callback = "OnBtnClick_Detail"
|
||||
},
|
||||
rtInfo = {
|
||||
sCtrlName = "Game.UI.TemplateEx.TemplateCharInfoCtrl"
|
||||
},
|
||||
txtBtnSkill = {sComponentName = "TMP_Text", sLanguageId = "SkillCn"},
|
||||
rtEquipment = {},
|
||||
txtTitleEquipment = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "StarTower_Depot_Info_Equipment"
|
||||
},
|
||||
btnEquipment = {
|
||||
nCount = 2,
|
||||
sComponentName = "UIButton",
|
||||
callback = "OnBtnClick_Equipment"
|
||||
},
|
||||
imgEquipment = {nCount = 3, sComponentName = "Image"},
|
||||
goEquipment = {nCount = 3},
|
||||
txtEquipmentLock = {nCount = 3, sComponentName = "TMP_Text"}
|
||||
}
|
||||
DepotCharInfoCtrl._mapEventConfig = {}
|
||||
DepotCharInfoCtrl._mapRedDotConfig = {}
|
||||
function DepotCharInfoCtrl:RefreshCharInfo(tbTeam, mapCharaData)
|
||||
self.tbTeam = tbTeam
|
||||
self.mapCharData = mapCharaData
|
||||
if not (self.nCharId and self.nSelectIndex) or self.nCharId ~= self.tbTeam[self.nSelectIndex] then
|
||||
self.nCharId = self.tbTeam[1]
|
||||
self.nSelectIndex = 1
|
||||
end
|
||||
self:RefreshActorId()
|
||||
self:SwitchChar()
|
||||
self:RefreshChoose()
|
||||
end
|
||||
function DepotCharInfoCtrl:SwitchChar()
|
||||
if not self.attrData then
|
||||
self.attrData = CharacterAttrData.new(self.nCharId)
|
||||
else
|
||||
self.attrData:SetCharacter(self.nCharId)
|
||||
end
|
||||
self:RefreshActor2D()
|
||||
self:RefreshAttribute()
|
||||
self:RefreshInfo()
|
||||
end
|
||||
function DepotCharInfoCtrl:RefreshChoose()
|
||||
for i = 1, 3 do
|
||||
local nCharId = self.tbTeam[i]
|
||||
local charData = self.mapCharData[nCharId]
|
||||
if charData ~= nil then
|
||||
local nCharSkinId = charData.nSkinId
|
||||
local mapCharSkin = ConfigTable.GetData_CharacterSkin(nCharSkinId)
|
||||
self:SetPngSprite(self._mapNode.imgHead[i], mapCharSkin.Icon .. AllEnum.CharHeadIconSurfix.L)
|
||||
self._mapNode.goSelect[i]:SetActive(self.nSelectIndex == i)
|
||||
end
|
||||
end
|
||||
end
|
||||
function DepotCharInfoCtrl:RefreshActor2D()
|
||||
EventManager.Hit("RefreshActor2D_Depot", self.nCharId)
|
||||
end
|
||||
function DepotCharInfoCtrl:RefreshAttribute()
|
||||
local HealthInfo = self.tbActorHealthInfo[self.nCharId]
|
||||
local Info = self.tbActorInfo[self.nCharId]
|
||||
local tbAttr = {}
|
||||
if self.nSelectIndex == 1 then
|
||||
local hp = HealthInfo ~= nil and HealthInfo.hp:AsInt() or 0
|
||||
local hpMax = HealthInfo ~= nil and HealthInfo.hpMax:AsInt() or 0
|
||||
tbAttr = {totalValue = hp, baseValue = hp}
|
||||
self._mapNode.goProperty[1]:SetCharProperty(AllEnum.CharAttr[1], tbAttr, true, hpMax)
|
||||
self._mapNode.goProperty[1].gameObject:SetActive(true)
|
||||
else
|
||||
local hpMax = HealthInfo ~= nil and HealthInfo.hpMax:AsInt() or 0
|
||||
tbAttr = {totalValue = hpMax, baseValue = hpMax}
|
||||
self._mapNode.goProperty[1]:SetCharProperty(AllEnum.CharAttr[1], tbAttr, true)
|
||||
self._mapNode.goProperty[1].gameObject:SetActive(true)
|
||||
end
|
||||
local atk = Info ~= nil and Info.atk:AsInt() or 0
|
||||
tbAttr = {totalValue = atk, baseValue = atk}
|
||||
self._mapNode.goProperty[2]:SetCharProperty(AllEnum.CharAttr[2], tbAttr, true)
|
||||
local def = Info ~= nil and Info.def:AsInt() or 0
|
||||
tbAttr = {totalValue = def, baseValue = def}
|
||||
self._mapNode.goProperty[3]:SetCharProperty(AllEnum.CharAttr[3], tbAttr, true)
|
||||
local critRate = Info ~= nil and Info.critRate:AsFloat() or 0
|
||||
tbAttr = {
|
||||
totalValue = critRate * 100,
|
||||
baseValue = critRate * 100
|
||||
}
|
||||
self._mapNode.goProperty[4]:SetCharProperty(AllEnum.CharAttr[4], tbAttr, false)
|
||||
local critPower = Info ~= nil and Info.critPower:AsFloat() or 0
|
||||
tbAttr = {
|
||||
totalValue = critPower * 100,
|
||||
baseValue = critPower * 100
|
||||
}
|
||||
self._mapNode.goProperty[5]:SetCharProperty(AllEnum.CharAttr[5], tbAttr, false)
|
||||
end
|
||||
function DepotCharInfoCtrl:RefreshActorId()
|
||||
local actorIdCSList = AdventureModuleHelper.GetCurrentGroupPlayers()
|
||||
self.tbActorInfo, self.tbActorHealthInfo, self.tbElementInfo, self.tbSkillCd, self.tbEnergyEfficiency, self.tbEnergyConvRatio = {}, {}, {}, {}, {}, {}
|
||||
for i = 0, actorIdCSList.Count - 1 do
|
||||
local characterId = AdventureModuleHelper.GetCharacterId(actorIdCSList[i])
|
||||
if characterId and 0 < characterId then
|
||||
self.tbActorInfo[characterId] = AdventureModuleHelper.GetEntityInfo(actorIdCSList[i])
|
||||
self.tbActorHealthInfo[characterId] = AdventureModuleHelper.GetEntityHealthInfo(actorIdCSList[i])
|
||||
self.tbElementInfo[characterId] = AdventureModuleHelper.GetEntityElementInfo(actorIdCSList[i])
|
||||
self.tbSkillCd[characterId] = AdventureModuleHelper.GetPlayerSkillCd(actorIdCSList[i])
|
||||
self.tbEnergyEfficiency[characterId] = AdventureModuleHelper.GetPlayerAttributeValue(characterId, GameEnum.playerAttributeType.FRONT_ADD_ENERGY)
|
||||
self.tbEnergyConvRatio[characterId] = AdventureModuleHelper.GetPlayerAttributeValue(characterId, GameEnum.playerAttributeType.ADD_ENERGY)
|
||||
end
|
||||
end
|
||||
end
|
||||
function DepotCharInfoCtrl:RefreshInfo()
|
||||
local mapCfg = ConfigTable.GetData_Character(self.nCharId)
|
||||
local mapChar = self.mapCharData[self.nCharId]
|
||||
if mapChar ~= nil then
|
||||
self._mapNode.rtInfo:Refresh(mapChar, mapCfg)
|
||||
self:RefreshEquipment(mapChar)
|
||||
end
|
||||
end
|
||||
function DepotCharInfoCtrl:RefreshEquipment()
|
||||
local nSelect = PlayerData.Equipment:GetSelectPreset(self.nCharId)
|
||||
local tbSlot = PlayerData.Equipment:GetSlotWithIndex(self.nCharId, nSelect)
|
||||
for i, mapSlot in ipairs(tbSlot) do
|
||||
local bEmpty = mapSlot.nGemIndex == 0
|
||||
self._mapNode.imgEquipment[i].gameObject:SetActive(not bEmpty)
|
||||
self._mapNode.goEquipment[i].gameObject:SetActive(bEmpty)
|
||||
if bEmpty then
|
||||
if not mapSlot.bUnlock then
|
||||
NovaAPI.SetTMPText(self._mapNode.txtEquipmentLock[i], orderedFormat(ConfigTable.GetUIText("Equipment_SlotActiveLevel"), mapSlot.nLevel))
|
||||
else
|
||||
NovaAPI.SetTMPText(self._mapNode.txtEquipmentLock[i], ConfigTable.GetUIText("CharEquipment_UnEquip"))
|
||||
end
|
||||
else
|
||||
local nGemId = PlayerData.Equipment:GetGemIdBySlot(self.nCharId, mapSlot.nSlotId)
|
||||
local mapGemCfg = ConfigTable.GetData("CharGem", nGemId)
|
||||
if mapGemCfg then
|
||||
self:SetPngSprite(self._mapNode.imgEquipment[i], mapGemCfg.Icon)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
function DepotCharInfoCtrl:Clear()
|
||||
end
|
||||
function DepotCharInfoCtrl:Awake()
|
||||
self.nCharId = nil
|
||||
self.nSelectIndex = nil
|
||||
end
|
||||
function DepotCharInfoCtrl:OnEnable()
|
||||
end
|
||||
function DepotCharInfoCtrl:OnDisable()
|
||||
end
|
||||
function DepotCharInfoCtrl:OnDestroy()
|
||||
end
|
||||
function DepotCharInfoCtrl:OnBtnClick_Char(btn, nIndex)
|
||||
if nIndex == self.nSelectIndex then
|
||||
return
|
||||
end
|
||||
self._mapNode.goSelect[self.nSelectIndex]:SetActive(false)
|
||||
self._mapNode.goSelect[nIndex]:SetActive(true)
|
||||
self.nCharId = self.tbTeam[nIndex]
|
||||
self.nSelectIndex = nIndex
|
||||
self:SwitchChar()
|
||||
end
|
||||
function DepotCharInfoCtrl:OnBtnClick_Skill(btn)
|
||||
EventManager.Hit(EventId.OpenPanel, PanelId.PopupSkillPanel, self.tbTeam, false, {}, self.mapCharData)
|
||||
end
|
||||
function DepotCharInfoCtrl:OnBtnClick_Detail()
|
||||
local HealthInfo = self.tbActorHealthInfo[self.nCharId]
|
||||
local Info = self.tbActorInfo[self.nCharId]
|
||||
local ElementInfo = self.tbElementInfo[self.nCharId]
|
||||
local SkillCd = self.tbSkillCd[self.nCharId]
|
||||
local EnergyEfficiency = self.tbEnergyEfficiency[self.nCharId]
|
||||
local EnergyConvRatio = self.tbEnergyConvRatio[self.nCharId]
|
||||
local attrList = self.attrData:GetAttrList()
|
||||
for k, v in pairs(AllEnum.CharAttr) do
|
||||
local total, base
|
||||
if v.sKey == "Hp" then
|
||||
total = HealthInfo ~= nil and HealthInfo.hpMax:AsInt() or 0
|
||||
elseif v.sKey == "Atk" then
|
||||
total = Info ~= nil and Info.atk:AsInt() or 0
|
||||
elseif v.sKey == "Def" then
|
||||
total = Info ~= nil and Info.def:AsInt() or 0
|
||||
elseif v.sKey == "CritRate" then
|
||||
total = Info ~= nil and Info.critRate:AsFloat() or 0
|
||||
total = total * 100
|
||||
elseif v.sKey == "CritPower" then
|
||||
total = Info ~= nil and Info.critPower:AsFloat() or 0
|
||||
total = total * 100
|
||||
elseif v.sKey == "Suppress" then
|
||||
total = Info ~= nil and Info.suppressRatio:AsFloat() or 0
|
||||
total = total * 100
|
||||
base = total
|
||||
elseif v.sKey == "UltraEnergy" then
|
||||
total = SkillCd and SkillCd:GetTotalEnergy() or 0
|
||||
base = total
|
||||
elseif v.sKey == "EnergyEfficiency" then
|
||||
total = EnergyEfficiency
|
||||
total = total * 100
|
||||
base = total
|
||||
elseif v.sKey == "EnergyConvRatio" then
|
||||
total = EnergyConvRatio
|
||||
total = total * 100
|
||||
base = total
|
||||
elseif v.sKey == "DefPierce" then
|
||||
total = Info ~= nil and Info.defPenetrate:AsInt() or 0
|
||||
base = total
|
||||
elseif v.sKey == "DefIgnore" then
|
||||
total = Info ~= nil and Info.defIgnore:AsFloat() or 0
|
||||
total = total * 100
|
||||
base = total
|
||||
elseif v.sKey == "WEE" then
|
||||
total = ElementInfo ~= nil and ElementInfo.WEE:AsFloat() or 0
|
||||
total = total * 100
|
||||
base = total
|
||||
elseif v.sKey == "WEP" then
|
||||
total = ElementInfo ~= nil and ElementInfo.WEP:AsInt() or 0
|
||||
base = total
|
||||
elseif v.sKey == "WEI" then
|
||||
total = ElementInfo ~= nil and ElementInfo.WEI:AsFloat() or 0
|
||||
total = total * 100
|
||||
base = total
|
||||
elseif v.sKey == "FEE" then
|
||||
total = ElementInfo ~= nil and ElementInfo.FEE:AsFloat() or 0
|
||||
total = total * 100
|
||||
base = total
|
||||
elseif v.sKey == "FEP" then
|
||||
total = ElementInfo ~= nil and ElementInfo.FEP:AsInt() or 0
|
||||
base = total
|
||||
elseif v.sKey == "FEI" then
|
||||
total = ElementInfo ~= nil and ElementInfo.FEI:AsFloat() or 0
|
||||
total = total * 100
|
||||
base = total
|
||||
elseif v.sKey == "SEE" then
|
||||
total = ElementInfo ~= nil and ElementInfo.SEE:AsFloat() or 0
|
||||
total = total * 100
|
||||
base = total
|
||||
elseif v.sKey == "SEP" then
|
||||
total = ElementInfo ~= nil and ElementInfo.SEP:AsInt() or 0
|
||||
base = total
|
||||
elseif v.sKey == "SEI" then
|
||||
total = ElementInfo ~= nil and ElementInfo.SEI:AsFloat() or 0
|
||||
total = total * 100
|
||||
base = total
|
||||
elseif v.sKey == "AEE" then
|
||||
total = ElementInfo ~= nil and ElementInfo.AEE:AsFloat() or 0
|
||||
total = total * 100
|
||||
base = total
|
||||
elseif v.sKey == "AEP" then
|
||||
total = ElementInfo ~= nil and ElementInfo.AEP:AsInt() or 0
|
||||
base = total
|
||||
elseif v.sKey == "AEI" then
|
||||
total = ElementInfo ~= nil and ElementInfo.AEI:AsFloat() or 0
|
||||
total = total * 100
|
||||
base = total
|
||||
elseif v.sKey == "LEE" then
|
||||
total = ElementInfo ~= nil and ElementInfo.LEE:AsFloat() or 0
|
||||
total = total * 100
|
||||
base = total
|
||||
elseif v.sKey == "LEP" then
|
||||
total = ElementInfo ~= nil and ElementInfo.LEP:AsInt() or 0
|
||||
base = total
|
||||
elseif v.sKey == "LEI" then
|
||||
total = ElementInfo ~= nil and ElementInfo.LEI:AsFloat() or 0
|
||||
total = total * 100
|
||||
base = total
|
||||
elseif v.sKey == "DEE" then
|
||||
total = ElementInfo ~= nil and ElementInfo.DEE:AsFloat() or 0
|
||||
total = total * 100
|
||||
base = total
|
||||
elseif v.sKey == "DEP" then
|
||||
total = ElementInfo ~= nil and ElementInfo.DEP:AsInt() or 0
|
||||
base = total
|
||||
elseif v.sKey == "DEI" then
|
||||
total = ElementInfo ~= nil and ElementInfo.DEI:AsFloat() or 0
|
||||
total = total * 100
|
||||
base = total
|
||||
end
|
||||
if total then
|
||||
attrList[k].totalValue = total
|
||||
end
|
||||
if base then
|
||||
attrList[k].baseValue = base
|
||||
end
|
||||
end
|
||||
local mapCfg = ConfigTable.GetData_Character(self.nCharId)
|
||||
if not mapCfg then
|
||||
return
|
||||
end
|
||||
EventManager.Hit(EventId.OpenPanel, PanelId.CharAttrDetail, attrList, mapCfg.EET)
|
||||
end
|
||||
function DepotCharInfoCtrl:OnBtnClick_Equipment(btn)
|
||||
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
|
||||
return DepotCharInfoCtrl
|
||||
@@ -0,0 +1,299 @@
|
||||
local DepotFateCardCtrl = class("DepotFateCardCtrl", BaseCtrl)
|
||||
local LayoutRebuilder = CS.UnityEngine.UI.LayoutRebuilder
|
||||
DepotFateCardCtrl._mapNodeConfig = {
|
||||
rtItemListContent = {
|
||||
sComponentName = "RectTransform"
|
||||
},
|
||||
goFateCardItem = {},
|
||||
goDepotItem = {},
|
||||
goItemList = {},
|
||||
FateCardList = {
|
||||
sNodeName = "FateCardList_",
|
||||
nCount = 5
|
||||
},
|
||||
txtFateCard = {
|
||||
sComponentName = "TMP_Text",
|
||||
nCount = 5,
|
||||
sNodeName = "txtFateCard_"
|
||||
},
|
||||
txtHas = {
|
||||
sComponentName = "TMP_Text",
|
||||
nCount = 5,
|
||||
sNodeName = "txtHas_"
|
||||
},
|
||||
txtAll = {
|
||||
sComponentName = "TMP_Text",
|
||||
nCount = 5,
|
||||
sNodeName = "txtAll_"
|
||||
},
|
||||
imgPackageIcon = {
|
||||
sComponentName = "Image",
|
||||
nCount = 5,
|
||||
sNodeName = "imgPackageIcon_"
|
||||
},
|
||||
imgSubIcon = {
|
||||
sComponentName = "Image",
|
||||
nCount = 5,
|
||||
sNodeName = "imgSubIcon_"
|
||||
},
|
||||
rtFateCard = {
|
||||
sComponentName = "Transform",
|
||||
nCount = 5,
|
||||
sNodeName = "rtFateCard_"
|
||||
},
|
||||
ItemInfo = {
|
||||
sNodeName = "---ItemInfo---"
|
||||
},
|
||||
goItemL = {
|
||||
sCtrlName = "Game.UI.TemplateEx.TemplateItemCtrl"
|
||||
},
|
||||
txtItemName = {sComponentName = "TMP_Text"},
|
||||
txtCountCn = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "StarTower_Depot_Info_QTY"
|
||||
},
|
||||
txtItemCount = {sComponentName = "TMP_Text"},
|
||||
txtDescribeTitle1 = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "StarTower_Depot_Info_Desc"
|
||||
},
|
||||
txtItemDesc = {sComponentName = "TMP_Text"},
|
||||
Content = {
|
||||
sComponentName = "RectTransform"
|
||||
},
|
||||
FateCardInfo = {
|
||||
sNodeName = "---FateCardInfo---"
|
||||
},
|
||||
goFateCardInfo = {
|
||||
sCtrlName = "Game.UI.VampireSurvivor.Depot.DepotFateCardItemCtrl"
|
||||
},
|
||||
txtFateCardName = {sComponentName = "TMP_Text"},
|
||||
imgEffect = {nCount = 3},
|
||||
txtEffect1 = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "VampireDepot_ReminTime"
|
||||
},
|
||||
txtEffect2 = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "VampireDepot_ReminTime_None"
|
||||
},
|
||||
txtEffect3 = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "StarTower_FateCard_Unable"
|
||||
},
|
||||
txtEffectCount = {sComponentName = "TMP_Text"},
|
||||
txtDescribeTitle2 = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "Depot_Describe"
|
||||
},
|
||||
txtFateCardDesc = {sComponentName = "TMP_Text"},
|
||||
imgEmpty = {},
|
||||
txt_EmptyTitle = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "StarTower_Item_List_Empty"
|
||||
}
|
||||
}
|
||||
DepotFateCardCtrl._mapEventConfig = {}
|
||||
DepotFateCardCtrl._mapRedDotConfig = {}
|
||||
local item_type = {FateCard = 1, Item = 2}
|
||||
function DepotFateCardCtrl:InitPackage(nLevelId)
|
||||
self.nLevelId = nLevelId
|
||||
local mapLevelData = ConfigTable.GetData("VampireSurvivor", nLevelId)
|
||||
if mapLevelData == nil then
|
||||
return
|
||||
end
|
||||
local tbBundle = mapLevelData.FateCardBundle
|
||||
self.tbBundle = clone(tbBundle)
|
||||
self.tbExFateCard = decodeJson(mapLevelData.SpeciaFateCard)
|
||||
if self.tbExFateCard == nil then
|
||||
self.tbExFateCard = {}
|
||||
end
|
||||
for i = 1, 5 do
|
||||
if self.tbBundle[i] == nil then
|
||||
self._mapNode.FateCardList[i].gameObject:SetActive(false)
|
||||
else
|
||||
local mapBundleCfgData = ConfigTable.GetData("StarTowerBookFateCardBundle", self.tbBundle[i])
|
||||
self.tbFateCardCtrl[i] = {}
|
||||
if mapBundleCfgData ~= nil then
|
||||
NovaAPI.SetTMPText(self._mapNode.txtFateCard[i], mapBundleCfgData.Name)
|
||||
self:SetPngSprite(self._mapNode.imgPackageIcon[i], mapBundleCfgData.Icon .. AllEnum.FateCardBundleIcon.S)
|
||||
self:SetAtlasSprite(self._mapNode.imgSubIcon[i], "05_language", mapBundleCfgData.Text)
|
||||
NovaAPI.SetImageNativeSize(self._mapNode.imgSubIcon[i])
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
function DepotFateCardCtrl:RefreshFateCard(mapFateCard)
|
||||
self.mapFateCard = {}
|
||||
for nId, v in pairs(mapFateCard) do
|
||||
local mapBundleCfgData = ConfigTable.GetData("StarTowerBookFateCard", nId)
|
||||
local nBundleIdx = 0
|
||||
local bEx = false
|
||||
if mapBundleCfgData ~= nil then
|
||||
local nBundleId = mapBundleCfgData.BundleId
|
||||
nBundleIdx = table.indexof(self.tbBundle, nBundleId)
|
||||
end
|
||||
if nBundleIdx < 1 then
|
||||
bEx, nBundleIdx = self:isExFateCard(nId)
|
||||
end
|
||||
if 5 < nBundleIdx or nBundleIdx < 1 then
|
||||
printError("无法获取Bundle索引")
|
||||
nBundleIdx = 1
|
||||
end
|
||||
table.insert(self.mapFateCard, {
|
||||
nTid = nId,
|
||||
nCount = v,
|
||||
bEx = bEx,
|
||||
nBundleIdx = nBundleIdx
|
||||
})
|
||||
end
|
||||
local tbCount = {
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
}
|
||||
if #self.mapFateCard == 0 then
|
||||
self._mapNode.ItemInfo.gameObject:SetActive(false)
|
||||
self._mapNode.FateCardInfo.gameObject:SetActive(false)
|
||||
self._mapNode.imgEmpty:SetActive(true)
|
||||
self._mapNode.goItemList:SetActive(false)
|
||||
return
|
||||
end
|
||||
self._mapNode.imgEmpty:SetActive(false)
|
||||
self._mapNode.goItemList:SetActive(true)
|
||||
table.sort(self.mapFateCard, function(a, b)
|
||||
if a.nBundleIdx ~= b.nBundleIdx then
|
||||
return a.nBundleIdx < b.nBundleIdx
|
||||
end
|
||||
if a.nCount * b.nCount == 0 and a.nCount + b.nCount ~= 0 then
|
||||
return a.nCount ~= 0
|
||||
end
|
||||
if a.bEx ~= b.bEx then
|
||||
return a.bEx
|
||||
end
|
||||
return a.nTid < b.nTid
|
||||
end)
|
||||
local nFirstId = 0
|
||||
if #self.mapFateCard > 0 then
|
||||
nFirstId = self.mapFateCard[1].nTid
|
||||
end
|
||||
for _, tbItemCtrl in ipairs(self.tbFateCardCtrl) do
|
||||
for _, v in ipairs(tbItemCtrl) do
|
||||
v.gameObject:SetActive(false)
|
||||
end
|
||||
end
|
||||
for k, v in ipairs(self.mapFateCard) do
|
||||
local itemObj
|
||||
local nBundleIdx = v.nBundleIdx
|
||||
local bEx = v.bEx
|
||||
tbCount[nBundleIdx] = tbCount[nBundleIdx] + 1
|
||||
if nil == self.tbFateCardCtrl[nBundleIdx] then
|
||||
self.tbFateCardCtrl[nBundleIdx] = {}
|
||||
end
|
||||
local nIdx = tbCount[nBundleIdx]
|
||||
if self.tbFateCardCtrl[nBundleIdx][nIdx] == nil then
|
||||
itemObj = instantiate(self._mapNode.goFateCardItem, self._mapNode.rtFateCard[nBundleIdx])
|
||||
itemObj.gameObject:SetActive(true)
|
||||
local itemCtrl = self:BindCtrlByNode(itemObj, "Game.UI.VampireSurvivor.Depot.DepotFateCardItemCtrl")
|
||||
itemCtrl:InitFateCard(v.nTid, v.nCount, bEx)
|
||||
table.insert(self.tbFateCardCtrl[nBundleIdx], itemCtrl)
|
||||
else
|
||||
itemObj = self.tbFateCardCtrl[nBundleIdx][nIdx].gameObject
|
||||
itemObj:SetActive(true)
|
||||
self.tbFateCardCtrl[nBundleIdx][nIdx]:InitFateCard(v.nTid, v.nCount)
|
||||
end
|
||||
local btnSelect = itemObj.transform:Find("btnItem"):GetComponent("UIButton")
|
||||
btnSelect.onClick:RemoveAllListeners()
|
||||
local func_select = function()
|
||||
self:SelectItem(item_type.FateCard, nBundleIdx, nIdx, k)
|
||||
end
|
||||
btnSelect.onClick:AddListener(func_select)
|
||||
if nFirstId == v.nTid then
|
||||
self:SelectItem(item_type.FateCard, nBundleIdx, nIdx, k)
|
||||
end
|
||||
end
|
||||
for nIdx, tbItem in pairs(self.tbFateCardCtrl) do
|
||||
self._mapNode.FateCardList[nIdx]:SetActive(0 < tbCount[nIdx])
|
||||
NovaAPI.SetTMPText(self._mapNode.txtHas[nIdx], tbCount[nIdx])
|
||||
end
|
||||
end
|
||||
function DepotFateCardCtrl:SelectItem(nType, nBundleIdx, nIndex, nIdx)
|
||||
self._mapNode.ItemInfo.gameObject:SetActive(false)
|
||||
self._mapNode.FateCardInfo.gameObject:SetActive(false)
|
||||
if nil ~= self.nSelectIndex and self.nSelectType == item_type.FateCard then
|
||||
self.tbFateCardCtrl[self.nSelectBundleIdx][self.nSelectIndex]:SetChoose(false)
|
||||
end
|
||||
self.nSelectType = nType
|
||||
self.nSelectBundleIdx = nBundleIdx
|
||||
self.nSelectIndex = nIndex
|
||||
if self.nSelectType == item_type.FateCard then
|
||||
self._mapNode.FateCardInfo.gameObject:SetActive(true)
|
||||
self.tbFateCardCtrl[self.nSelectBundleIdx][self.nSelectIndex]:SetChoose(true)
|
||||
self:SetFateCardInfo(nIdx)
|
||||
end
|
||||
end
|
||||
function DepotFateCardCtrl:SetItemInfo()
|
||||
local mapSelect = self.mapItem[self.nSelectIndex]
|
||||
local mapCfg = ConfigTable.GetData_Item(mapSelect.nTid)
|
||||
self._mapNode.goItemL:SetItem(mapSelect.nTid)
|
||||
NovaAPI.SetTMPText(self._mapNode.txtItemCount, mapSelect.nCount)
|
||||
if mapCfg ~= nil then
|
||||
NovaAPI.SetTMPText(self._mapNode.txtItemName, mapCfg.Title)
|
||||
NovaAPI.SetTMPText(self._mapNode.txtItemDesc, mapCfg.Desc)
|
||||
end
|
||||
end
|
||||
function DepotFateCardCtrl:SetFateCardInfo(nIdx)
|
||||
local mapSelect = self.mapFateCard[nIdx]
|
||||
if nil ~= mapSelect then
|
||||
local itemCfg = ConfigTable.GetData_Item(mapSelect.nTid)
|
||||
local fateCardCfg = ConfigTable.GetData("FateCard", mapSelect.nTid)
|
||||
if nil == fateCardCfg then
|
||||
printError(string.format("获取FateCard表格配置失败!!!id = [%s]", mapSelect.nTid))
|
||||
return
|
||||
end
|
||||
NovaAPI.SetTMPText(self._mapNode.txtFateCardName, fateCardCfg.Name)
|
||||
local sDesc = UTILS.ParseParamDesc(fateCardCfg.Desc2, fateCardCfg)
|
||||
NovaAPI.SetTMPText(self._mapNode.txtFateCardDesc, sDesc)
|
||||
self._mapNode.goFateCardInfo:InitFateCard(mapSelect.nTid, mapSelect.nCount, false)
|
||||
for _, v in ipairs(self._mapNode.imgEffect) do
|
||||
v.gameObject:SetActive(false)
|
||||
end
|
||||
if mapSelect.nCount == 0 then
|
||||
self._mapNode.imgEffect[3].gameObject:SetActive(true)
|
||||
elseif mapSelect.nCount < 0 then
|
||||
self._mapNode.imgEffect[2].gameObject:SetActive(true)
|
||||
else
|
||||
self._mapNode.imgEffect[1].gameObject:SetActive(true)
|
||||
NovaAPI.SetTMPText(self._mapNode.txtEffectCount, orderedFormat(ConfigTable.GetUIText("VampireDepot_ReminTime_Sec"), mapSelect.nCount))
|
||||
end
|
||||
end
|
||||
end
|
||||
function DepotFateCardCtrl:Awake()
|
||||
self.tbFateCardCtrl = {}
|
||||
self.nSelectIndex = nil
|
||||
self.nSelectType = 0
|
||||
self._mapNode.goFateCardItem.gameObject:SetActive(false)
|
||||
self._mapNode.goDepotItem.gameObject:SetActive(false)
|
||||
end
|
||||
function DepotFateCardCtrl:ClearFateCard()
|
||||
for _, tbItemCtrl in ipairs(self.tbFateCardCtrl) do
|
||||
for _, v in ipairs(tbItemCtrl) do
|
||||
self:UnbindCtrlByNode(v)
|
||||
end
|
||||
end
|
||||
self.tbFateCardCtrl = {}
|
||||
end
|
||||
function DepotFateCardCtrl:OnDestroy()
|
||||
self:ClearFateCard()
|
||||
end
|
||||
function DepotFateCardCtrl:isExFateCard(nFateCardId)
|
||||
for i, tbExFateCard in ipairs(self.tbExFateCard) do
|
||||
if table.indexof(tbExFateCard, nFateCardId) > 0 then
|
||||
return true, i
|
||||
end
|
||||
end
|
||||
return false, 0
|
||||
end
|
||||
return DepotFateCardCtrl
|
||||
@@ -0,0 +1,52 @@
|
||||
local DepotFateCardItemCtrl = class("DepotFateCardItemCtrl", BaseCtrl)
|
||||
DepotFateCardItemCtrl._mapNodeConfig = {
|
||||
imgRare = {sComponentName = "Image"},
|
||||
imgIcon = {sComponentName = "Image"},
|
||||
txtCount = {sComponentName = "TMP_Text"},
|
||||
imgChoose = {},
|
||||
imgUnable = {},
|
||||
txtUnable = {
|
||||
sComponentName = "TMP_Text",
|
||||
sLanguageId = "StarTower_FateCard_Unable"
|
||||
},
|
||||
ImgMark = {}
|
||||
}
|
||||
DepotFateCardItemCtrl._mapEventConfig = {}
|
||||
DepotFateCardItemCtrl._mapRedDotConfig = {}
|
||||
function DepotFateCardItemCtrl:InitFateCard(nId, nTime, bEx)
|
||||
self.nId = nId
|
||||
local itemCfg = ConfigTable.GetData_Item(nId)
|
||||
if nil == itemCfg then
|
||||
printError(string.format("获取Item表格配置失败!!!id = [%s]", nId))
|
||||
return
|
||||
end
|
||||
local sFrame = AllEnum.FrameType_New.FateCardS .. AllEnum.FrameColor_New[itemCfg.Rarity]
|
||||
self:SetAtlasSprite(self._mapNode.imgRare, "12_rare", sFrame)
|
||||
self:SetPngSprite(self._mapNode.imgIcon, itemCfg.Icon2)
|
||||
self._mapNode.imgUnable.gameObject:SetActive(nTime == 0)
|
||||
self._mapNode.txtCount.gameObject:SetActive(false)
|
||||
self._mapNode.imgChoose.gameObject:SetActive(false)
|
||||
self._mapNode.ImgMark:SetActive(bEx)
|
||||
end
|
||||
function DepotFateCardItemCtrl:SetChoose(bChoose)
|
||||
self._mapNode.imgChoose.gameObject:SetActive(bChoose)
|
||||
end
|
||||
function DepotFateCardItemCtrl:Awake()
|
||||
end
|
||||
function DepotFateCardItemCtrl:FadeIn()
|
||||
end
|
||||
function DepotFateCardItemCtrl:FadeOut()
|
||||
end
|
||||
function DepotFateCardItemCtrl:OnEnable()
|
||||
end
|
||||
function DepotFateCardItemCtrl:OnDisable()
|
||||
end
|
||||
function DepotFateCardItemCtrl:OnDestroy()
|
||||
end
|
||||
function DepotFateCardItemCtrl:OnRelease()
|
||||
end
|
||||
function DepotFateCardItemCtrl:OnBtnClick_AAA()
|
||||
end
|
||||
function DepotFateCardItemCtrl:OnEvent_AAA()
|
||||
end
|
||||
return DepotFateCardItemCtrl
|
||||
Reference in New Issue
Block a user