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,90 @@
local Camera = CS.UnityEngine.Camera
local Light = CS.UnityEngine.Light
local NovaAPI = NovaAPI
local Animator = CS.UnityEngine.Animator
local ClientManager = CS.ClientManager
local CustomModelMaterialVariantComponent = CS.CustomModelMaterialVariantComponent
local typeof = typeof
local BaseFormationItem = class("BaseFormationItem", BaseCtrl)
function BaseFormationItem:Awake()
self.mIndex = 0
self.mData = nil
self.mActive = true
self.mRole3DData = {}
self:buildData()
end
function BaseFormationItem:OnDestroy()
self.mIndex = 0
self.mData = nil
if self.mRole3DData.role ~= nil then
destroy(self.mRole3DData.role)
self.mRole3DData.role = nil
end
if self.mRole3DData.cameraRT ~= nil then
self.mRole3DData.camera.targetTexture = nil
GameUIUtils.ReleaseRenderTexture(self.mRole3DData.cameraRT)
self.mRole3DData.cameraRT = nil
end
if self.mRole3DData.gameObject ~= nil then
destroy(self.mRole3DData.gameObject)
self.mRole3DData.gameObject = nil
end
self.mRole3DData = {}
end
function BaseFormationItem:buildData()
local layerName = "Cam_Layer_4"
local layerIndex = NovaAPI.LayerMaskName2Layer(layerName)
local layerMask = NovaAPI.LayerMaskGetMask(layerName)
local windowResolution = ClientManager.Instance.currentWindowResolution
local texSize = windowResolution.y
if NovaAPI.IsMobilePlatform() then
texSize = math.round(texSize * 1.333)
else
texSize = math.round(texSize * 2)
end
local imgSize = 1150
local go = self:CreatePrefabInstance("UI/MainlineFormationEx/SelectRolePrefab.prefab", self._mapNode.trParent)
go.transform.position = Vector3(100, 0, 0)
go.transform:SetLayerRecursively(layerIndex)
self.mRole3DData.gameObject = go
self.mRole3DData.camera = go.transform:Find("Camera"):GetComponent(typeof(Camera))
self.mRole3DData.camera.cullingMask = layerMask
self.mRole3DData.camera:SetCameraVolumeLayerMask(layerMask)
local n = math.floor(texSize * Settings.RENDERTEXTURE_SIZE_FACTOR)
self.mRole3DData.cameraRT = GameUIUtils.GenerateRenderTextureFor3D(n, n)
self.mRole3DData.camera.targetTexture = self.mRole3DData.cameraRT
self.mRole3DData.light = go.transform:Find("Light"):GetComponent(typeof(Light))
self.mRole3DData.light.cullingMask = layerMask
self.mRole3DData.node = go.transform:Find("RoleSpawnPosition")
self.mRole3DData.role = nil
NovaAPI.SetTexture(self._mapNode.rimg_role, self.mRole3DData.cameraRT)
self._mapNode.rimg_role:GetComponent(typeof(RectTransform)).sizeDelta = Vector2(imgSize, imgSize)
end
function BaseFormationItem:showModel(modelPrefab)
if self.mData == nil then
return
end
local skinId = PlayerData.Char:GetCharSkinId(self.mData.CharId)
self.mRole3DData.gameObject.transform.position = Vector3(100 * self.mIndex, 0, 0)
self.mRole3DData.role = instantiate(modelPrefab, self.mRole3DData.node)
self.mRole3DData.role.transform.localPosition = Vector3(0, 0.03, 0)
self.mRole3DData.role.transform.localScale = Vector3.one * (ConfigTable.GetData_CharacterSkin(skinId).ModelShowScale / 10000)
self.mRole3DData.role.transform.localRotation = Quaternion.identity
self.mRole3DData.rolePath = self.mData.Model
local animator = self.mRole3DData.role:GetComponent(typeof(Animator))
if animator ~= nil then
animator:SetBool("standby", true)
end
local matVariantComp = self.mRole3DData.role:GetComponent(typeof(CustomModelMaterialVariantComponent))
if matVariantComp ~= nil then
matVariantComp:SetVariant(CS.CustomModelMaterialVariantComponent.VariantNames.FormationView)
end
local layerName = "Cam_Layer_" .. self.mIndex
local layerIndex = NovaAPI.LayerMaskName2Layer(layerName)
local layerMask = NovaAPI.LayerMaskGetMask(layerName)
self.mRole3DData.gameObject.transform:SetLayerRecursively(layerIndex)
self.mRole3DData.camera.cullingMask = layerMask
self.mRole3DData.camera:SetCameraVolumeLayerMask(layerMask)
self.mRole3DData.light.cullingMask = layerMask
end
return BaseFormationItem
@@ -0,0 +1,165 @@
local FormationCharCtrl = class("FormationCharCtrl", BaseCtrl)
local GameResourceLoader = require("Game.Common.Resource.GameResourceLoader")
local ResType = GameResourceLoader.ResType
FormationCharCtrl._mapNodeConfig = {
trParent = {sComponentName = "Transform"},
rtInfo = {
sCtrlName = "Game.UI.TemplateEx.TemplateCharInfoCtrl"
},
btnSelect = {
sComponentName = "UIButton",
callback = "OnBtnClick_Select"
},
btnAdd = {
sComponentName = "UIButton",
callback = "OnBtnClick_SelectAdd"
},
btnAddAnim = {sNodeName = "btnAdd", sComponentName = "Animator"},
Animator = {sNodeName = "rtInfo", sComponentName = "Animator"},
btnDetail = {
sComponentName = "UIButton",
callback = "OnBtnClick_Detail"
},
btnDown = {
sComponentName = "UIButton",
callback = "OnBtnClick_Down"
},
rtBtnDownParent = {},
txtBtnDetail = {
sComponentName = "TMP_Text",
sLanguageId = "Formation_Btn_Info"
},
fxChange = {},
goArrow = {},
txtLeader = {
sComponentName = "TMP_Text",
sLanguageId = "Build_Leader"
},
txtSub = {sComponentName = "TMP_Text", sLanguageId = "Build_Sub"},
AnimationRoot = {sComponentName = "Animator"},
eventDrag = {
sNodeName = "btnSelect",
sComponentName = "UIDrag",
callback = "OnUIDrag_Drag"
},
txtBtnEmpty = {
sComponentName = "TMP_Text",
sLanguageId = "MainlineFormationDisc_HintEmpty"
}
}
FormationCharCtrl._mapEventConfig = {
Guide_FormationChar_OpenList = "OnEvent_FormationChar_OpenList"
}
function FormationCharCtrl:OnRender(tbTeamMemberId, index, bTrialLevel, nDirection)
self.mIndex = index
self.bTrialLevel = bTrialLevel
self.tbTeamId = tbTeamMemberId
local nCharId = tbTeamMemberId[index]
self._mapNode.btnDetail.gameObject:SetActive(not self.bTrialLevel and 0 < nCharId)
self._mapNode.AnimationRoot.enabled = 0 < nCharId
if 0 < nCharId then
local mapCharCfgData, mapCharData
if bTrialLevel then
mapCharData = PlayerData.Char:GetTrialCharById(nCharId)
mapCharCfgData = ConfigTable.GetData_Character(mapCharData.nId)
else
mapCharData = PlayerData.Char:GetCharDataByTid(nCharId)
mapCharCfgData = ConfigTable.GetData_Character(nCharId)
end
self._mapNode.rtInfo:Refresh(mapCharData, mapCharCfgData)
end
if 0 < nCharId then
if nDirection ~= nil then
local sStateName = nDirection == 1 and "rtInfo_left" or "rtInfo_right"
self._mapNode.Animator:Play(sStateName)
elseif self.nCharId ~= nCharId and self.nCharId ~= nil then
self._mapNode.Animator:Play("rtInfo_up")
end
self._mapNode.btnAdd.gameObject:SetActive(false)
self._mapNode.btnDown.gameObject:SetActive(true)
else
self._mapNode.btnDown.gameObject:SetActive(false)
self._mapNode.btnAdd.gameObject:SetActive(not bTrialLevel)
if self.nCharId ~= nil and nDirection == nil and self.nCharId ~= 0 then
self._mapNode.Animator:Play("rtInfo_down")
self._mapNode.btnAddAnim:Play("btnAdd_in")
else
self._mapNode.Animator:Play("rtInfo_hide")
end
end
self.nCharId = nCharId
end
function FormationCharCtrl:PlayChangeFx()
GameUIUtils.RestartParticle(self._mapNode.fxChange)
end
function FormationCharCtrl:SetSelectedChar(rtSelectedChar)
self.rtSelectedChar = rtSelectedChar
end
function FormationCharCtrl:OnEnable()
self.mActive = true
self._mapNode.btnDown.gameObject:SetActive(false)
end
function FormationCharCtrl:OnDisable()
self.mActive = false
end
function FormationCharCtrl:OnBtnClick_Select(btn)
if not self.bTrialLevel then
if btn.Operate_Type == 0 then
EventManager.Hit("OnEvent_OpenSelectTeamMemberList", self.mIndex)
end
else
local sTip = ConfigTable.GetUIText("RegionBoss_Member_CannotBeChanged")
EventManager.Hit(EventId.OpenMessageBox, sTip)
end
end
function FormationCharCtrl:SetItemPos(dragPos)
local localPos = GameUIUtils.ScreenPointToLocalPointInRectangle(dragPos, self.rtSelectedChar.parent.transform)
self.rtSelectedChar.localPosition = Vector3(localPos.x, self.rtSelectedChar.anchoredPosition.y, 0)
end
function FormationCharCtrl:OnUIDrag_Drag(mDrag)
if mDrag.DragEventType == AllEnum.UIDragType.DragStart then
EventManager.Hit("OnEvent_OpenSwapTeamMember", self.mIndex)
self:SetItemPos(mDrag.EventData.position)
elseif mDrag.DragEventType == AllEnum.UIDragType.Drag then
self:SetItemPos(mDrag.EventData.position)
elseif mDrag.DragEventType == AllEnum.UIDragType.DragEnd then
EventManager.Hit("CloseSwap")
end
end
function FormationCharCtrl:OnBtnClick_SelectAdd(btn)
if not self.bTrialLevel then
EventManager.Hit("OnEvent_OpenSelectTeamMemberList", self.mIndex)
else
local sTip = ConfigTable.GetUIText("RegionBoss_Member_CannotBeChanged")
EventManager.Hit(EventId.OpenMessageBox, sTip)
end
end
function FormationCharCtrl:SetArrowShow(bShow)
self._mapNode.goArrow:SetActive(bShow)
end
function FormationCharCtrl:OnBtnClick_Detail(btn)
if not self.bTrialLevel then
local tbChar = {}
for _, v in pairs(self.tbTeamId) do
if v ~= 0 then
table.insert(tbChar, v)
end
end
EventManager.Hit(EventId.OpenPanel, PanelId.CharBgPanel, PanelId.CharInfo, self.nCharId, tbChar, false)
end
end
function FormationCharCtrl:OnBtnClick_Down()
EventManager.Hit("ForamtionDown", self.mIndex)
end
function FormationCharCtrl:OpenList(bOpen)
self._mapNode.btnSelect.gameObject:SetActive(not bOpen)
self._mapNode.rtBtnDownParent:SetActive(bOpen)
self._mapNode.btnAdd.enabled = not bOpen
end
function FormationCharCtrl:OnEvent_FormationChar_OpenList(index, bOpen)
if index == self.mIndex then
self._mapNode.btnSelect.enabled = bOpen
self._mapNode.btnAdd.enabled = bOpen
end
end
return FormationCharCtrl
@@ -0,0 +1,81 @@
local FormationCharInfoCtrl = class("FormationCharInfoCtrl", BaseCtrl)
FormationCharInfoCtrl._mapNodeConfig = {
imgCharColor = {sComponentName = "Image"},
txtPowerCn = {
sComponentName = "TMP_Text",
sLanguageId = "Template_Power"
},
txtPower = {sComponentName = "TMP_Text"},
goElement = {
sCtrlName = "Game.UI.TemplateEx.TemplateElementCtrl"
},
txtRankCn = {
sComponentName = "TMP_Text",
sLanguageId = "Template_CharRank"
},
txtLevel = {sComponentName = "TMP_Text"},
imgRareName = {sComponentName = "Image"},
txtName = {sComponentName = "TMP_Text"},
txtLv = {sComponentName = "TMP_Text", sLanguageId = "Lv"},
btnDetail = {
sComponentName = "UIButton",
callback = "OnBtnClick_Detail"
},
txtBtnDetail = {
sComponentName = "TMP_Text",
sLanguageId = "Formation_Btn_Info"
}
}
FormationCharInfoCtrl._mapEventConfig = {}
function FormationCharInfoCtrl:Refresh(nCharId, tbTeamId, bTrialLevel)
self.bTrialLevel = bTrialLevel
self._mapNode.btnDetail.gameObject:SetActive(not bTrialLevel)
if bTrialLevel then
local mapTrialChar = PlayerData.Char:GetTrialCharById(nCharId)
self.nCharId = mapTrialChar.nId
self.tbTeamId = tbTeamId
local mapChar = ConfigTable.GetData_Character(self.nCharId)
local mapCharDescCfg = ConfigTable.GetData("CharacterDes", nCharId)
local _, colorChar = ColorUtility.TryParseHtmlString(mapCharDescCfg.CharColor)
NovaAPI.SetImageColor(self._mapNode.imgCharColor, colorChar)
self._mapNode.goElement:Refresh(mapChar.EET)
NovaAPI.SetTMPText(self._mapNode.txtLevel, mapTrialChar.nLevel)
self:SetSprite_FrameColor(self._mapNode.imgRareName, mapChar.Grade, AllEnum.FrameType_New.Text)
NovaAPI.SetImageNativeSize(self._mapNode.imgRareName)
NovaAPI.SetTMPText(self._mapNode.txtName, mapTrialChar.sCharacterName)
else
self.nCharId = nCharId
self.tbTeamId = tbTeamId
local mapChar = ConfigTable.GetData_Character(nCharId)
local mapCharDescCfg = ConfigTable.GetData("CharacterDes", nCharId)
local _, colorChar = ColorUtility.TryParseHtmlString(mapCharDescCfg.CharColor)
NovaAPI.SetImageColor(self._mapNode.imgCharColor, colorChar)
self._mapNode.goElement:Refresh(mapChar.EET)
NovaAPI.SetTMPText(self._mapNode.txtLevel, PlayerData.Char:GetCharLv(self.nCharId))
self:SetSprite_FrameColor(self._mapNode.imgRareName, mapChar.Grade, AllEnum.FrameType_New.Text)
NovaAPI.SetImageNativeSize(self._mapNode.imgRareName)
NovaAPI.SetTMPText(self._mapNode.txtName, mapChar.Name)
end
end
function FormationCharInfoCtrl:RefreshShow(nCharId, nLevel)
self.nCharId = nCharId
self.tbTeamId = nil
local mapChar = ConfigTable.GetData_Character(nCharId)
local mapCharDescCfg = ConfigTable.GetData("CharacterDes", nCharId)
local _, colorChar = ColorUtility.TryParseHtmlString(mapCharDescCfg.CharColor)
NovaAPI.SetImageColor(self._mapNode.imgCharColor, colorChar)
self._mapNode.goElement:Refresh(mapChar.EET)
NovaAPI.SetTMPText(self._mapNode.txtLevel, nLevel)
self:SetSprite_FrameColor(self._mapNode.imgRareName, mapChar.Grade, AllEnum.FrameType_New.Text)
NovaAPI.SetImageNativeSize(self._mapNode.imgRareName)
NovaAPI.SetTMPText(self._mapNode.txtName, mapChar.Name)
end
function FormationCharInfoCtrl:OnBtnClick_Detail(btn)
if self.tbTeamId == nil then
return
end
if not self.bTrialLevel then
EventManager.Hit(EventId.OpenPanel, PanelId.CharBgPanel, PanelId.CharInfo, self.nCharId, self.tbTeamId, false)
end
end
return FormationCharInfoCtrl
@@ -0,0 +1,379 @@
local FormationCharListCtrl = class("FormationCharListCtrl", BaseCtrl)
local LocalData = require("GameCore.Data.LocalData")
local newDayTime = UTILS.GetDayRefreshTimeOffset()
FormationCharListCtrl._mapNodeConfig = {
sv = {
sComponentName = "LoopScrollView"
},
labEmpty = {
sComponentName = "TMP_Text",
sLanguageId = "Filter_NoAim"
},
btnCloseList = {
sComponentName = "UIButton",
callback = "OnBtnClick_Clear"
},
btnConfirm = {
sComponentName = "UIButton",
callback = "OnBtnClick_Confirm"
},
rtCharListContent = {sComponentName = "Transform"},
btnFilter = {
sComponentName = "UIButton",
callback = "OnBtnClick_Filter"
},
imgFilterChoose = {},
txtBtnListConifrm = {
sComponentName = "TMP_Text",
sLanguageId = "MainLine_Select_Btn_Confirm"
},
txtBtnListClose = {
sComponentName = "TMP_Text",
sLanguageId = "ClearFormation"
},
btnOrder = {
sComponentName = "UIButton",
callback = "OnBtnClick_Order"
},
goSortDropdown = {
sCtrlName = "Game.UI.TemplateEx.TemplateDropdownCtrl"
},
imgArrowUpEnable = {},
imgArrowUpDisable = {},
imgArrowDownEnable = {},
imgArrowDownDisable = {}
}
FormationCharListCtrl._mapEventConfig = {
[EventId.FilterConfirm] = "RefreshByFilter",
Guide_PositionCharPos = "OnEvent_PositionCharPos",
ForamtionDown = "OnEvent_ForamtionDown",
SelectTemplateDD = "OnEvent_SortRuleChange"
}
function FormationCharListCtrl:Awake()
self._mapNode.goSortDropdown:SetList(PlayerData.Char:GetCharSortNameTextCfg(), 0)
self.tbSortCfg = {
nSortType = AllEnum.SortType.Level,
bOrder = false
}
end
function FormationCharListCtrl:FadeIn()
end
function FormationCharListCtrl:FadeOut()
end
function FormationCharListCtrl:OnEnable()
self.mapGridCtrl = {}
self.gameObject:SetActive(false)
local isDirty = PlayerData.Filter:IsDirty(AllEnum.OptionType.Char)
self._mapNode.imgFilterChoose:SetActive(isDirty)
end
function FormationCharListCtrl:OnDisable()
self:CloseList()
end
function FormationCharListCtrl:OnDestroy()
end
function FormationCharListCtrl:OnRelease()
end
function FormationCharListCtrl:ShowList(tbCurSelectChar, bFastSelect, nIdx)
self.tbOriginChar = clone(tbCurSelectChar)
self.gameObject:SetActive(true)
self.tbAllChar = PlayerData.Char:GetDataForCharList()
self.bFastSelect = bFastSelect == true
self.nIdx = not self.bFastSelect and nIdx or 0
self.curChar = tbCurSelectChar
self.mapGridCtrl = {}
self.tbFilterCfg = {}
self:RefreshOrderState()
self:FilterChar()
self:SortChar()
self._mapNode.sv:Init(#self.tbSortedChar, self, self.OnGridRefresh, self.OnGridBtnClick)
self._mapNode.btnConfirm.gameObject:SetActive(true)
self._mapNode.btnCloseList.gameObject:SetActive(true)
end
function FormationCharListCtrl:Refresh()
local isDirty = PlayerData.Filter:IsDirty(AllEnum.OptionType.Char)
self._mapNode.imgFilterChoose:SetActive(isDirty)
self:FilterChar()
self:SortChar()
self:RefreshOrderState()
local nCurCount = #self.tbSortedChar
if 0 < nCurCount then
self._mapNode.labEmpty.gameObject:SetActive(false)
self._mapNode.sv.gameObject:SetActive(true)
self._mapNode.sv:Init(#self.tbSortedChar, self, self.OnGridRefresh, self.OnGridBtnClick)
else
self._mapNode.sv.gameObject:SetActive(false)
self._mapNode.labEmpty.gameObject:SetActive(true)
end
end
function FormationCharListCtrl:CloseList()
self.tbFilterCfg = {}
for nInstanceId, mapCtrl in pairs(self.mapGridCtrl) do
self:UnbindCtrlByNode(mapCtrl)
self.mapGridCtrl[nInstanceId] = nil
end
self.mapGridCtrl = {}
self.gameObject:SetActive(false)
end
function FormationCharListCtrl:OnGridRefresh(goGrid, gridIndex)
local nInstanceId = goGrid:GetInstanceID()
if not self.mapGridCtrl[nInstanceId] then
self.mapGridCtrl[nInstanceId] = self:BindCtrlByNode(goGrid, "Game.UI.FormationEx.FormationCharListItem")
end
local nIndex = gridIndex + 1
local nCharId = self.tbSortedChar[nIndex]
local selectIdx = table.indexof(self.curChar, nCharId)
local nMark = self.bFastSelect == true and selectIdx or 0 < selectIdx
local bBaned = false
if self.bFastSelect ~= true then
bBaned = 0 < selectIdx and selectIdx ~= self.nIdx
end
self.mapGridCtrl[nInstanceId]:RefreshItem(0 < selectIdx, nMark, nCharId, bBaned, self.tbSortCfg.nSortType)
end
function FormationCharListCtrl:OnGridBtnClick(goGrid, gridIndex)
local nIndex = gridIndex + 1
local nCharId = self.tbSortedChar[nIndex]
local nTeamIdx = table.indexof(self.curChar, nCharId)
if self.bFastSelect then
if 0 < nTeamIdx then
self.curChar[nTeamIdx] = 0
self:SetGridIndex(nCharId, 0)
for idx, CharId in ipairs(self.curChar) do
self:SetGridIndex(CharId, idx)
end
else
local nPos = table.indexof(self.curChar, 0)
if 0 < nPos then
self.curChar[nPos] = nCharId
for idx, CharId in ipairs(self.curChar) do
self:SetGridIndex(CharId, idx)
end
PlayerData.Voice:PlayCharVoice("swap", nCharId)
else
EventManager.Hit(EventId.OpenMessageBox, ConfigTable.GetUIText("Formation_FullTeam") or "")
end
end
elseif self.curChar[self.nIdx] ~= 0 then
self:SetGridIndex(self.curChar[self.nIdx], 0)
if self.curChar[self.nIdx] ~= nCharId then
self.curChar[self.nIdx] = nCharId
self:SetGridIndex(nCharId, self.nIdx)
else
self.curChar[self.nIdx] = 0
end
else
self.curChar[self.nIdx] = nCharId
self:SetGridIndex(nCharId, self.nIdx)
PlayerData.Voice:PlayCharVoice("swap", nCharId)
end
EventManager.Hit("OnEvent_ChangeTeamModel", self.curChar)
end
function FormationCharListCtrl:SetGridIndex(nCharId, nIdx)
local nGirdIdx = table.indexof(self.tbSortedChar, nCharId)
local trGrid = self._mapNode.rtCharListContent:Find(tostring(nGirdIdx - 1))
if trGrid ~= nil then
local nInstanceId = trGrid.gameObject:GetInstanceID()
if self.bFastSelect then
self.mapGridCtrl[nInstanceId]:SetSelect(0 < nIdx, nIdx)
else
self.mapGridCtrl[nInstanceId]:SetSelect(0 < nIdx, nIdx)
end
end
end
function FormationCharListCtrl:FilterChar()
self.tbSortedChar = {}
for _, data in pairs(self.tbAllChar) do
local mapCharCfgData = ConfigTable.GetData_Character(data.nId)
local bAvailable = mapCharCfgData.Available
if bAvailable then
local isFilter = PlayerData.Filter:CheckFilterByChar(data.nId)
local bCur = table.indexof(self.curChar, data.nId) > 0
if isFilter or bCur then
local mapSkill = PlayerData.Char:GetCharSkillUpgradeData(data.nId)
local nSkillLevelSum = 0
for k, v in pairs(mapSkill) do
nSkillLevelSum = nSkillLevelSum + v.nLv
end
data.SkillLevel = nSkillLevelSum
table.insert(self.tbSortedChar, data)
end
end
end
print("过滤后 charCount:" .. #self.tbSortedChar)
end
function FormationCharListCtrl:SyncFormation()
local tbBefireTeamMemberId = PlayerData.Team:GetTeamCharId(self._panel.nTeamIndex)
local tbDiscId = PlayerData.Team:GetTeamDiscData(self._panel.nTeamIndex)
local bChange = false
for i = 1, 3 do
if tbBefireTeamMemberId[i] ~= self.curChar[i] then
bChange = true
break
end
end
if not bChange then
return
end
PlayerData.Team:UpdateFormationInfo(self._panel.nTeamIndex, self.curChar, tbDiscId)
end
function FormationCharListCtrl:SortChar()
local tbCharId = {}
UTILS.SortByPriority(self.tbSortedChar, {
AllEnum.CharSortField[self.tbSortCfg.nSortType]
}, PlayerData.Char:GetCharSortField(), self.tbSortCfg.bOrder)
self.tbSortedChar = self:MoveElementsToFront(self.tbSortedChar, self.curChar)
for _, mapCharId in ipairs(self.tbSortedChar) do
table.insert(tbCharId, mapCharId.nId)
end
self.tbSortedChar = tbCharId
end
function FormationCharListCtrl:MoveElementsToFront(sortedList, elementsToMove)
local lookup = {}
for _, v in ipairs(elementsToMove) do
lookup[v] = true
end
local moved, rest = {}, {}
for _, v in ipairs(sortedList) do
if lookup[v.nId] then
table.insert(moved, v)
else
table.insert(rest, v)
end
end
for _, v in ipairs(rest) do
table.insert(moved, v)
end
return moved
end
function FormationCharListCtrl:RefreshOrderState()
self._mapNode.imgArrowUpEnable:SetActive(self.tbSortCfg.bOrder)
self._mapNode.imgArrowUpDisable:SetActive(not self.tbSortCfg.bOrder)
self._mapNode.imgArrowDownEnable:SetActive(not self.tbSortCfg.bOrder)
self._mapNode.imgArrowDownDisable:SetActive(self.tbSortCfg.bOrder)
end
function FormationCharListCtrl:RefreshByFilter()
self:Refresh()
end
function FormationCharListCtrl:OnEvent_ForamtionDown(nIdx)
local nCurCharId = self.curChar[nIdx]
self.curChar[nIdx] = 0
local nGridIdx = table.indexof(self.tbSortedChar, nCurCharId)
local trGrid = self._mapNode.rtCharListContent:Find(tostring(nGridIdx - 1))
if trGrid ~= nil then
local nInstanceId = trGrid.gameObject:GetInstanceID()
self.mapGridCtrl[nInstanceId]:SetSelect(false, nIdx)
end
EventManager.Hit("OnEvent_ChangeTeamModel", self.curChar)
end
function FormationCharListCtrl:OnEvent_SortRuleChange(nValue)
local nV = nValue + 1
self.tbSortCfg.nSortType = PlayerData.Char:GetCharSortType()[nV]
self.tbSortCfg.bOrder = false
self:Refresh()
end
function FormationCharListCtrl:OnBtnClick_Order(btn)
self.tbSortCfg.bOrder = not self.tbSortCfg.bOrder
self:Refresh()
end
function FormationCharListCtrl:OnBtnClick_Close(btn)
local bChange = false
for i = 1, 3 do
if self.curChar[i] ~= self.tbOriginChar[i] then
bChange = true
end
end
local isSelectAgain = false
local cancelCallback = 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("FormationListTipDay", tostring(_nowD))
end
self:OnBtnClick_Confirm()
end
local confirmCallback = function()
EventManager.Hit("OnEvent_CloseTeamList", false, self.curChar)
self._mapNode.btnConfirm.gameObject:SetActive(false)
self._mapNode.btnCloseList.gameObject:SetActive(false)
end
if bChange then
local TipsTime = LocalData.GetPlayerLocalData("FormationListTipDay")
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 confirmTipCallback = 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("FormationListTipDay", tostring(_nowD))
end
confirmCallback()
end
local againCallback = function(isSelect)
isSelectAgain = isSelect
end
local msg = {
nType = AllEnum.MessageBox.Confirm,
sContent = orderedFormat(ConfigTable.GetUIText("FormationChangeTips")),
callbackConfirm = confirmTipCallback,
callbackAgain = againCallback,
callbackCancel = cancelCallback,
bDisableSnap = true
}
EventManager.Hit(EventId.OpenMessageBox, msg)
end
else
cancelCallback()
end
end
function FormationCharListCtrl:OnBtnClick_Clear(btn)
for i = 1, 3 do
if self.curChar[i] ~= 0 then
self:SetGridIndex(self.curChar[i], 0)
self.curChar[i] = 0
end
end
EventManager.Hit("OnEvent_ChangeTeamModel", self.curChar)
end
function FormationCharListCtrl:OnBtnClick_Confirm(btn)
EventManager.Hit("OnEvent_CloseTeamList", true, self.curChar)
self._mapNode.btnConfirm.gameObject:SetActive(false)
self._mapNode.btnCloseList.gameObject:SetActive(false)
end
function FormationCharListCtrl:OnBtnClick_Filter()
local tbOption = {
AllEnum.ChooseOption.Char_Element,
AllEnum.ChooseOption.Char_Rarity,
AllEnum.ChooseOption.Char_PowerStyle,
AllEnum.ChooseOption.Char_TacticalStyle,
AllEnum.ChooseOption.Char_AffiliatedForces
}
EventManager.Hit(EventId.OpenPanel, PanelId.FilterPopupPanel, tbOption)
end
function FormationCharListCtrl:OnEvent_PositionCharPos(_tmpChar)
for i, v in pairs(self.tbSortedChar) do
if v == _tmpChar then
self._mapNode.sv:SetScrollGridPos(i - 1, 0, 0)
EventManager.Hit("Positioning_Char_Grid", _tmpChar, i - 1)
break
end
end
end
return FormationCharListCtrl
@@ -0,0 +1,98 @@
local FormationCharListItem = class("FormationCharListItem", BaseCtrl)
FormationCharListItem._mapNodeConfig = {
Mask = {},
TMPHint = {
sComponentName = "TMP_Text",
sLanguageId = "In_Formation"
},
TMPSelectIdx = {sComponentName = "TMP_Text"},
imgSelectIcon = {},
imgSelect = {},
goChar = {
sCtrlName = "Game.UI.TemplateEx.TemplateCharCtrl"
},
btnGrid = {sComponentName = "UIButton"},
btnMask = {
sNodeName = "Mask",
sComponentName = "Button",
callback = "OnBtnClick_Mask"
},
t_team_leader = {},
t_team_sub = {},
txtLeader = {
sComponentName = "TMP_Text",
sLanguageId = "Build_Leader"
},
txtSub = {sComponentName = "TMP_Text", sLanguageId = "Build_Sub"},
TMPSelectTitle = {
sComponentName = "TMP_Text",
sLanguageId = "RoguelikeBuild_Manage_SelectedTitle"
},
btnDetail = {
sComponentName = "UIButton",
callback = "OnBtnClick_Detail"
}
}
FormationCharListItem._mapEventConfig = {}
function FormationCharListItem:Awake()
end
function FormationCharListItem:FadeIn()
end
function FormationCharListItem:FadeOut()
end
function FormationCharListItem:OnEnable()
end
function FormationCharListItem:OnDisable()
end
function FormationCharListItem:OnDestroy()
end
function FormationCharListItem:OnRelease()
end
function FormationCharListItem:RefreshItem(bSelect, nIdx, nCharId, bBanned, nSortType)
self.nCharId = nCharId
self._mapNode.goChar:SetChar(nCharId, false, false, nil, nSortType)
self._mapNode.goChar:SetSelect(bSelect and not bBanned)
self._mapNode.Mask:SetActive(bBanned)
self._mapNode.imgSelect:SetActive(bSelect and not bBanned)
self._mapNode.btnGrid.interactable = not bBanned
if type(nIdx) == "number" then
NovaAPI.SetTMPText(self._mapNode.TMPSelectIdx, "")
self._mapNode.imgSelectIcon:SetActive(true)
self._mapNode.t_team_leader:SetActive(nIdx == 1)
self._mapNode.t_team_sub:SetActive(nIdx ~= 1)
else
NovaAPI.SetTMPText(self._mapNode.TMPSelectIdx, "")
self._mapNode.imgSelectIcon:SetActive(true)
self._mapNode.t_team_leader:SetActive(false)
self._mapNode.t_team_sub:SetActive(false)
end
end
function FormationCharListItem:SetSelect(bSelect, nIdx)
self._mapNode.imgSelect:SetActive(bSelect)
self._mapNode.goChar:SetSelect(bSelect)
if nIdx ~= nil then
NovaAPI.SetTMPText(self._mapNode.TMPSelectIdx, "")
self._mapNode.imgSelectIcon:SetActive(true)
self._mapNode.t_team_leader:SetActive(nIdx == 1)
self._mapNode.t_team_sub:SetActive(nIdx ~= 1)
else
NovaAPI.SetTMPText(self._mapNode.TMPSelectIdx, "")
self._mapNode.imgSelectIcon:SetActive(true)
self._mapNode.t_team_leader:SetActive(false)
self._mapNode.t_team_sub:SetActive(false)
end
end
function FormationCharListItem:OnBtnClick_Mask(btn)
EventManager.Hit(EventId.OpenMessageBox, ConfigTable.GetUIText("Formation_Selected"))
end
function FormationCharListItem:OnBtnClick_Detail(btn)
if PlayerData.Guide:GetGuideState() then
return
end
if self.nCharId ~= nil then
EventManager.Hit(EventId.OpenPanel, PanelId.CharBgPanel, PanelId.CharInfo, self.nCharId, {
self.nCharId
}, false)
end
end
return FormationCharListItem
+874
View File
@@ -0,0 +1,874 @@
local FormationCtrl = class("FormationCtrl", BaseCtrl)
local Animator = CS.UnityEngine.Animator
local CustomModelMaterialVariantComponent = CS.CustomModelMaterialVariantComponent
local GameCameraStackManager = CS.GameCameraStackManager
local GameResourceLoader = require("Game.Common.Resource.GameResourceLoader")
local ResType = GameResourceLoader.ResType
local typeof = typeof
FormationCtrl._mapNodeConfig = {
TopBar = {
sNodeName = "TopBarPanel",
sCtrlName = "Game.UI.TopBarEx.TopBarCtrl"
},
goChar = {
nCount = 3,
sCtrlName = "Game.UI.FormationEx.FormationCharCtrl"
},
btnLeft = {
sComponentName = "UIButton",
callback = "OnBtnClick_Left"
},
btnRight = {
sComponentName = "UIButton",
callback = "OnBtnClick_Right"
},
txtTeamNane = {sComponentName = "TMP_Text"},
btnRename = {
sComponentName = "UIButton",
callback = "OnBtnClick_Rename"
},
goPoint = {nCount = 6},
Mask = {},
btnStartBattle = {
sComponentName = "UIButton",
callback = "OnBtnClick_Start"
},
txtStartBattle = {
sComponentName = "TMP_Text",
sLanguageId = "Mainline_Formation_Go"
},
TMPHintTrial = {
sComponentName = "TMP_Text",
sLanguageId = "Formation_Trial_Hint"
},
UIParallax3DStage = {
sComponentName = "UIParallaxStageCameraController"
},
BGbackup = {
sNodeName = "----BGbackup----"
},
CharList = {
sNodeName = "--CharList--",
sCtrlName = "Game.UI.FormationEx.FormationCharListCtrl"
},
btnFastFormation = {
sComponentName = "UIButton",
callback = "OnBtnClick_FastFormation"
},
rt_TeamName = {},
rt_TeamNameAlpha = {
sNodeName = "rt_TeamName",
sComponentName = "CanvasGroup"
},
t_arrow_01 = {},
SwapCharPanel = {
sCtrlName = "Game.UI.FormationEx.SwapCharCtrl"
},
charCanvasGroup = {
sNodeName = "----Char----",
sComponentName = "CanvasGroup"
},
txtBtnFastFormation = {
sComponentName = "TMP_Text",
sLanguageId = "Auto_Formation"
},
goLoadMask = {},
SwapBlock = {},
rtThemePrevRoot = {},
rtSlectedChar = {
sComponentName = "RectTransform"
}
}
FormationCtrl._mapEventConfig = {
[EventId.FormationLoadModel] = "OnEvent_LoadModel",
OnEvent_SelectRefresh = "Refresh",
OnEvent_OpenSelectTeamMemberList = "OnEvent_OpenSelectTeamMemberList",
OnEvent_OpenSwapTeamMember = "OnEvent_OpenSwapChar",
[EventId.UIBackConfirm] = "OnEvent_Back",
[EventId.UIHomeConfirm] = "OnEvent_BackHome",
OnEvent_CloseTeamList = "OnEvent_CloseList",
OnEvent_ChangeTeamModel = "OnEvent_ChangeTeamModel"
}
function FormationCtrl:Refresh(nDirection)
NovaAPI.SetTMPText(self._mapNode.txtTeamNane, orderedFormat(ConfigTable.GetUIText("Formation_DefaultName"), self._panel.nTeamIndex))
local _, tbTeamMemberId
if not self.bTrialLevel then
_, tbTeamMemberId = PlayerData.Team:GetTeamData(self._panel.nTeamIndex)
self.curTeam = {}
for _, value in ipairs(tbTeamMemberId) do
table.insert(self.curTeam, value)
end
self:RefreshPoint(self._panel.nTeamIndex)
else
local mapSelectedMainlineId = PlayerData.Mainline._nSelectId
local mapMainline = ConfigTable.GetData_Mainline(mapSelectedMainlineId)
self.curTeam = mapMainline.TrialCharacter
end
self:RefreshChar(nDirection)
end
function FormationCtrl:RefreshPoint(nIndex)
for i = 1, 6 do
self._mapNode.goPoint[i].transform:Find("imgOn").gameObject:SetActive(i == nIndex)
self._mapNode.goPoint[i].transform:Find("imgOff").gameObject:SetActive(i ~= nIndex)
end
end
function FormationCtrl:RefreshChar(nDirection)
for i = 1, 3 do
if self.curTeam[i] == nil then
self.curTeam[i] = 0
end
self._mapNode.goChar[i]:OnRender(self.curTeam, i, self.bTrialLevel, nDirection)
if self.curTeam[i] ~= 0 then
if self.mapCurModel[i] == nil or self.mapCurModel[i].nCharId ~= self.curTeam[i] then
self:LoadCharacter(self.curTeam[i], self.bOpen or nDirection ~= nil)
end
elseif self.mapCurModel[i] ~= nil then
NovaAPI.UnbindUIParallaxStageCameraControllerModel(self._mapNode.UIParallax3DStage, i - 1)
destroy(self.mapCurModel[i].model)
self.mapCurModel[i] = nil
end
end
end
function FormationCtrl:CheckBannedChar(bIsAwake)
local bHasBannedChar = false
local tbBannedChar = PlayerData.Mainline:GetBanedCharId()
local _, tbTeamMemberId = PlayerData.Team:GetTeamData(self._panel.nTeamIndex)
local sBannedChar = ""
if tbBannedChar ~= nil then
for _, nCharID in ipairs(tbTeamMemberId) do
if table.indexof(tbBannedChar, nCharID) > 0 then
bHasBannedChar = true
local mapChar = ConfigTable.GetData_Character(nCharID)
local sCharName = mapChar.Name
sBannedChar = sBannedChar .. string.format(" %s", sCharName)
end
end
end
if bHasBannedChar then
local sHint = orderedFormat(ConfigTable.GetUIText("SelectTeam_HasBannedChar"), sBannedChar)
if bIsAwake then
local callBack = function()
EventManager.Hit("OnEvent_OpenSelectTeamMemberNode")
end
EventManager.Hit(EventId.OpenMessageBox, {
nType = AllEnum.MessageBox.Alert,
sContent = sHint,
callbackConfirm = callBack
})
else
EventManager.Hit(EventId.OpenMessageBox, {
nType = AllEnum.MessageBox.Alert,
sContent = sHint
})
end
end
return bHasBannedChar
end
function FormationCtrl:EnterMainline()
PlayerData.Mainline.nCurTeamIndex = self._panel.nTeamIndex
if self:CheckBannedChar(false) then
self._mapNode.btnStartBattle.enabled = true
return
end
if not self.bTrialLevel and PlayerData.Team:CheckTeamValid(self._panel.nTeamIndex) == false then
EventManager.Hit(EventId.OpenMessageBox, ConfigTable.GetUIText("FRFORMATION_02"))
self._mapNode.btnStartBattle.enabled = true
return
end
local CheckItemCountExceededLimitCb = function(isExceeded)
if not isExceeded then
EventManager.Hit(EventId.SendMsgEnterBattle, self._panel.nTeamIndex)
end
end
PlayerData.Item:CheckItemCountExceededLimit(CheckItemCountExceededLimitCb)
end
function FormationCtrl:EnterStarTower()
local nTeamIdx = self._panel.nTeamIndex
local CheckBuildCountCallBack = function(nBuildCount)
local nMaxBuildCount = ConfigTable.GetConfigNumber("StarTowerBuildNumberMax")
if nBuildCount >= nMaxBuildCount then
local confirmCallback = function()
EventManager.Hit(EventId.OpenPanel, PanelId.StarTowerBuildBriefList)
self._mapNode.btnStartBattle.enabled = true
end
local cancelCallback = function()
EventManager.Hit(EventId.OpenPanel, PanelId.MainlineFormationDisc, self.curRoguelikeId, self._panel.nTeamIndex, self.bSweep)
end
local msg = {
nType = AllEnum.MessageBox.Confirm,
sContent = ConfigTable.GetUIText("BUILD_04"),
sConfirm = ConfigTable.GetUIText("RoguelikeBuild_BuildCount_BtnManage"),
sCancel = ConfigTable.GetUIText("RoguelikeBuild_BuildCount_BtnCancle"),
callbackConfirm = confirmCallback,
callbackCancel = cancelCallback
}
EventManager.Hit(EventId.OpenMessageBox, msg)
return
else
local teamIDs = {}
local _, tbTeamMemberId = PlayerData.Team:GetTeamData(nTeamIdx)
for i = 1, #tbTeamMemberId do
if tbTeamMemberId[i] ~= nil and 0 < tbTeamMemberId[i] then
table.insert(teamIDs, tbTeamMemberId[i])
end
end
if #teamIDs == 3 then
EventManager.Hit(EventId.OpenPanel, PanelId.MainlineFormationDisc, self.curRoguelikeId, self._panel.nTeamIndex, self.bSweep)
self:SetLocalData()
else
EventManager.Hit(EventId.OpenMessageBox, ConfigTable.GetUIText("FRFORMATION_01"))
self._mapNode.btnStartBattle.enabled = true
end
end
end
PlayerData.Build:GetBuildCount(CheckBuildCountCallBack)
end
function FormationCtrl:Awake()
local LocalData = require("GameCore.Data.LocalData")
local nIdx = LocalData.GetPlayerLocalData("SavedTeamIdx")
if nIdx == nil then
nIdx = 1
end
self._panel.nTeamIndex = nIdx
self.isOpenTeamMember = false
self:CheckBannedChar(true)
end
function FormationCtrl:OnEnable()
local mapSelectedMainlineId = PlayerData.Mainline._nSelectId
self._mapNode.goLoadMask:SetActive(true)
self._Animator = self.gameObject:GetComponent("Animator")
self.bTrialLevel = false
local tbParam = self:GetPanelParam()
self.nFRType = tbParam[1] or AllEnum.FormationEnterType.MainLine
self.curRoguelikeId = tbParam[2]
self.bSweep = tbParam[4]
self._mapNode.btnStartBattle.enabled = true
if self.nFRType == AllEnum.FormationEnterType.MainLine then
local mapMainline = ConfigTable.GetData_Mainline(mapSelectedMainlineId)
local tbTeamMemberId, nCaptain
if mapMainline.TrialCharacter ~= nil and #mapMainline.TrialCharacter > 0 then
tbTeamMemberId = mapMainline.TrialCharacter
self.mapTrialChar = PlayerData.Char:CreateTrialChar(tbTeamMemberId)
self.bTrialLevel = true
end
end
self._mapNode.btnLeft.gameObject:SetActive(not self.bTrialLevel)
self._mapNode.btnRight.gameObject:SetActive(not self.bTrialLevel)
self._mapNode.btnFastFormation.gameObject:SetActive(not self.bTrialLevel)
self._mapNode.rt_TeamName.gameObject:SetActive(not self.bTrialLevel)
self._mapNode.TMPHintTrial.gameObject:SetActive(self.bTrialLevel)
self._mapNode.t_arrow_01:SetActive(not self.bTrialLevel)
local sSceneName = self.nFRType ~= AllEnum.FormationEnterType.MainLine and ConfigTable.GetConfigValue("SelectRole_Rogue") or ConfigTable.GetConfigValue("SelectRole_Main")
self.mapCurModel = {}
local callbak = function(bSuccess)
self.bOpen = true
if bSuccess == true then
local sceneRoot = CS.MainMenuModuleHelper.GetMainMenuSceneRoot(sSceneName)
self.rtSceneOriginPos = sceneRoot.transform:Find("==== Scene ====")
self.goSelectRolePrefab = self:CreatePrefabInstance("UI/MainlineFormationEx/SelectRolePrefab.prefab", self.rtSceneOriginPos)
local goSelectRoleCam = self.goSelectRolePrefab.transform:Find("Camera"):GetComponent("Camera")
NovaAPI.SetupUIParallaxStageCameraControllerForModelView(self._mapNode.UIParallax3DStage, goSelectRoleCam)
self:Refresh()
if self.curTeam[1] ~= 0 then
PlayerData.Voice:PlayCharVoice("swap", self.curTeam[1])
end
local wait = function()
coroutine.yield(CS.UnityEngine.WaitForEndOfFrame())
self._mapNode.goLoadMask:SetActive(false)
if PlayerData.Guide:GetGuideState() then
EventManager.Hit("Guide_LoadFormationSuccess")
end
end
cs_coroutine.start(wait)
else
self._mapNode.goLoadMask:SetActive(false)
self._mapNode.UIParallax3DStage.gameObject:SetActive(false)
self._mapNode.BGbackup:SetActive(true)
end
if tbParam[3] and self.nFRType ~= AllEnum.FormationEnterType.MainLine then
self._mapNode.goLoadMask:SetActive(false)
else
EventManager.Hit(EventId.SetTransition)
end
for i = 1, 3 do
self._mapNode.goChar[i]:OpenList(false)
self._mapNode.goChar[i]:SetSelectedChar(self._mapNode.rtSlectedChar)
end
self._mapNode.btnStartBattle.transform.localScale = Vector3.one
self.bOpen = false
if self._panel.bList then
self:OnEvent_OpenSelectTeamMemberList()
end
end
CS.MainMenuModuleHelper.GetActiveScene(sSceneName, callbak)
self.bOpenTransition = false
end
function FormationCtrl:OnDisable()
if self._panel.bList then
self._mapNode.CharList:SyncFormation()
end
local sSceneName = self.nFRType ~= AllEnum.FormationEnterType.MainLine and ConfigTable.GetConfigValue("SelectRole_Rogue") or ConfigTable.GetConfigValue("SelectRole_Main")
local callback1 = function()
EventManager.Hit(EventId.SetTransition)
end
local callback2 = function()
end
CS.MainMenuModuleHelper.DeActiveScene(sSceneName, self.bOpenTransition == true and callback1 or callback2)
for i, mapModel in pairs(self.mapCurModel) do
if mapModel.model ~= nil then
NovaAPI.UnbindUIParallaxStageCameraControllerModel(self._mapNode.UIParallax3DStage, i - 1)
destroy(mapModel.model)
end
end
for i = 1, 3 do
self._mapNode.goChar[i].nCharId = nil
end
if self.goSelectRolePrefab ~= nil then
destroy(self.goSelectRolePrefab)
end
self.mapCurModel = {}
end
function FormationCtrl:OnDestroy()
end
function FormationCtrl:LoadCharacter(nCharId, bOpen)
local mapSkin
if self.bTrialLevel and self.mapTrialChar ~= nil then
local nSkinId = self.mapTrialChar[nCharId].nSkinId
mapSkin = ConfigTable.GetData_CharacterSkin(nSkinId)
else
mapSkin = ConfigTable.GetData_CharacterSkin(PlayerData.Char:GetCharSkinId(nCharId))
end
if not mapSkin then
printLog("没有找到皮肤配置" .. nCharId)
return
end
local sFullPath = string.format("%s.prefab", mapSkin.Model_Show)
local LoadModelCallback = function(obj)
if self._mapNode == nil then
return
end
local idx = table.indexof(self.curTeam, nCharId)
if 0 < idx then
if self.mapCurModel[idx] ~= nil then
NovaAPI.UnbindUIParallaxStageCameraControllerModel(self._mapNode.UIParallax3DStage, idx - 1)
destroy(self.mapCurModel[idx].model)
self.mapCurModel[idx] = nil
end
local go = instantiate(obj, self.rtSceneOriginPos)
self.mapCurModel[idx] = {nCharId = nCharId, model = go}
NovaAPI.BindUIParallaxStageCameraControllerModel(self._mapNode.UIParallax3DStage, idx - 1, go)
if self.rtSceneOriginPos ~= nil then
go.transform.position = self.rtSceneOriginPos.position
go.transform.localEulerAngles = Vector3(0, 180, 0)
go.transform.localScale = Vector3.one * (mapSkin.ModelShowScale / 10000)
local animator = go:GetComponent(typeof(Animator))
if animator ~= nil and animator:IsNull() == false then
animator:SetBool("standby", true)
end
GameUIUtils.SetCustomModelMaterialVariant(go, CS.CustomModelMaterialVariantComponent.VariantNames.FormationView)
end
if not bOpen then
self._mapNode.goChar[idx]:PlayChangeFx()
end
if PlayerData.Guide:GetGuideState() then
EventManager.Hit("Guide_LoadCharacterSuccess")
end
end
end
self:LoadAssetAsync(sFullPath, typeof(GameObject), LoadModelCallback)
end
function FormationCtrl:SetModelPos(nCharId, objModel, nPos)
local mapSkin = ConfigTable.GetData_CharacterSkin(PlayerData.Char:GetCharSkinId(nCharId))
if not mapSkin then
printLog("没有找到皮肤配置" .. nCharId)
return
end
if self.mapCurModel[nPos] ~= nil then
NovaAPI.UnbindUIParallaxStageCameraControllerModel(self._mapNode.UIParallax3DStage, nPos - 1)
destroy(self.mapCurModel[nPos].model)
self.mapCurModel[nPos] = nil
end
self.mapCurModel[nPos] = {nCharId = nCharId, model = objModel}
if self.rtSceneOriginPos ~= nil then
objModel.transform.position = self.rtSceneOriginPos.position
objModel.transform.localScale = Vector3.one * (mapSkin.ModelShowScale / 10000)
local animator = objModel:GetComponent(typeof(Animator))
if animator ~= nil then
animator:SetBool("standby", true)
end
local matVariantComp = objModel:GetComponent(typeof(CustomModelMaterialVariantComponent))
if matVariantComp ~= nil then
matVariantComp:SetVariant(CS.CustomModelMaterialVariantComponent.VariantNames.FormationView)
end
end
end
function FormationCtrl:CheckFormationChanged()
local bChange = false
local nTeamIndex = self._panel.nTeamIndex
local _, teamMemberid = PlayerData.Team:GetTeamData(nTeamIndex)
for i = 1, #teamMemberid do
if teamMemberid[i] ~= self.curTeam[i] then
return true
end
end
return bChange
end
function FormationCtrl.filterUnfinish(tbAllChar)
local tbAvailable = {}
for _, mapChar in ipairs(tbAllChar) do
local mapCharCfgData = ConfigTable.GetData_Character(mapChar.nId)
if mapCharCfgData.Available then
table.insert(tbAvailable, mapChar)
end
end
return tbAvailable
end
function FormationCtrl.filterLevel(tbAllChar, tbSelectedChar, nLevel)
local retLevel = {}
for _, mapChar in ipairs(tbAllChar) do
if nLevel <= mapChar.nLevel and table.indexof(tbSelectedChar, mapChar.nId) < 1 then
table.insert(retLevel, mapChar)
end
end
return retLevel
end
function FormationCtrl.filterEET(tbAllChar, tbSelectedChar, tbEET)
local retEET = {}
for _, mapChar in ipairs(tbAllChar) do
local mapCharCfgData = ConfigTable.GetData_Character(mapChar.nId)
if table.indexof(tbEET, mapCharCfgData.EET) >= 1 and table.indexof(tbSelectedChar, mapChar.nId) < 1 then
table.insert(retEET, mapChar)
end
end
return retEET
end
function FormationCtrl.filterEETNotrecommend(tbAllChar, tbSelectedChar, tbEET)
local retEET = {}
for _, mapChar in ipairs(tbAllChar) do
local mapCharCfgData = ConfigTable.GetData_Character(mapChar.nId)
if table.indexof(tbEET, mapCharCfgData.EET) < 1 and table.indexof(tbSelectedChar, mapChar.nId) < 1 then
table.insert(retEET, mapChar)
end
end
return retEET
end
function FormationCtrl.filterMain(tbAllChar, tbSelectedChar)
local tbMain = {}
for _, mapChar in ipairs(tbAllChar) do
local mapCharCfgData = ConfigTable.GetData_Character(mapChar.nId)
if mapCharCfgData ~= nil and mapCharCfgData.Class == GameEnum.characterJobClass.Vanguard and table.indexof(tbSelectedChar, mapChar.nId) < 1 then
table.insert(tbMain, mapChar)
end
end
if #tbMain == 0 then
for _, mapChar in ipairs(tbAllChar) do
local mapCharCfgData = ConfigTable.GetData_Character(mapChar.nId)
if mapCharCfgData ~= nil and mapCharCfgData.Class == GameEnum.characterJobClass.Balance and table.indexof(tbSelectedChar, mapChar.nId) < 1 then
table.insert(tbMain, mapChar)
end
end
end
return tbMain
end
function FormationCtrl.filterSub(tbAllChar, tbSelectedChar)
local tbRet = {}
for _, mapChar in ipairs(tbAllChar) do
local mapCharCfgData = ConfigTable.GetData_Character(mapChar.nId)
if mapCharCfgData ~= nil and mapCharCfgData.Class == GameEnum.characterJobClass.Support and table.indexof(tbSelectedChar, mapChar.nId) < 1 then
table.insert(tbRet, mapChar)
end
end
if #tbRet == 0 then
for _, mapChar in ipairs(tbAllChar) do
local mapCharCfgData = ConfigTable.GetData_Character(mapChar.nId)
if mapCharCfgData ~= nil and mapCharCfgData.Class == GameEnum.characterJobClass.Balance and table.indexof(tbSelectedChar, mapChar.nId) < 1 then
table.insert(tbRet, mapChar)
end
end
end
return tbRet
end
function FormationCtrl.filterBalance(tbAllChar, tbSelectedChar)
local tbRet = {}
for _, mapChar in ipairs(tbAllChar) do
local mapCharCfgData = ConfigTable.GetData_Character(mapChar.nId)
if mapCharCfgData ~= nil and mapCharCfgData.Class == GameEnum.characterJobClass.Balance and table.indexof(tbSelectedChar, mapChar.nId) < 1 then
table.insert(tbRet, mapChar)
end
end
if #tbRet == 0 then
for _, mapChar in ipairs(tbAllChar) do
local mapCharCfgData = ConfigTable.GetData_Character(mapChar.nId)
if mapCharCfgData ~= nil and mapCharCfgData.Class == GameEnum.characterJobClass.Support and table.indexof(tbSelectedChar, mapChar.nId) < 1 then
table.insert(tbRet, mapChar)
end
end
end
return tbRet
end
function FormationCtrl.selectAtk(tbAllChar, tbSelectedChar)
local CharacterAttrData = require("GameCore.Data.DataClass.CharacterAttrData")
local charAttrData = CharacterAttrData.new()
local maxAtk = 0
local selCharId = 0
for _, mapChar in ipairs(tbAllChar) do
charAttrData:SetCharacter(mapChar.nId)
local attrList = charAttrData:GetAttrList()
if maxAtk < attrList[2].totalValue and table.indexof(tbSelectedChar, mapChar.nId) < 1 then
maxAtk = attrList[2].totalValue
selCharId = mapChar.nId
end
end
return selCharId
end
function FormationCtrl:AutoSelectMainline()
local ret = {}
local mapSelectedMainlineId = PlayerData.Mainline._nSelectId
local mapMainline = ConfigTable.GetData_Mainline(mapSelectedMainlineId)
local nLevelOffset = ConfigTable.GetConfigNumber("AutoFormationLevel")
local nRecommendLevel = mapMainline.Recommend - nLevelOffset
local tbChar = self.filterUnfinish(PlayerData.Char:GetCharIdList())
if #tbChar < 3 then
EventManager.Hit(EventId.OpenMessageBox, ConfigTable.GetUIText("Formation_NeedMoreChar"))
return ret
end
local retLevel = self.filterLevel(tbChar, ret, nRecommendLevel)
if #retLevel == 0 then
retLevel = tbChar
end
local retMain = self.filterMain(retLevel, ret)
if #retMain == 0 then
retMain = tbChar
end
local nCharId = self.selectAtk(retMain, ret)
if nCharId == 0 then
nCharId = tbChar[1].nId
end
table.insert(ret, nCharId)
local cfgDataMain = DataTable.Character[ret[1]]
local mainEET = {
cfgDataMain.EET
}
local retEET
retLevel = self.filterLevel(tbChar, ret, nRecommendLevel)
if #retLevel == 0 then
retLevel = tbChar
end
retEET = self.filterEET(retLevel, ret, mainEET)
if #retEET == 0 then
retEET = retLevel
end
nCharId = self.selectAtk(retEET, ret)
if nCharId == 0 then
nCharId = tbChar[2].nId
end
table.insert(ret, nCharId)
retLevel = self.filterLevel(tbChar, ret, nRecommendLevel)
if #retLevel == 0 then
retLevel = tbChar
end
retEET = self.filterEET(retLevel, ret, mainEET)
if #retEET == 0 then
retEET = retLevel
end
nCharId = self.selectAtk(retEET, ret)
if nCharId == 0 then
nCharId = tbChar[3].nId
end
table.insert(ret, nCharId)
return ret
end
function FormationCtrl:AutoSelectStarTower()
local ret = {}
local mapFR = ConfigTable.GetData("StarTower", self.curRoguelikeId)
local nLevelOffset = ConfigTable.GetConfigNumber("AutoFormationLevel")
local nRecommendLevel = mapFR.Recommend - nLevelOffset
local tbEET = mapFR.EET
local tbEETNotrecommend = mapFR.NotEET
local retEET
local tbChar = self.filterUnfinish(PlayerData.Char:GetCharIdList())
if #tbChar < 3 then
EventManager.Hit(EventId.OpenMessageBox, ConfigTable.GetUIText("Formation_NeedMoreChar"))
return ret
end
local retLevel = self.filterLevel(tbChar, ret, nRecommendLevel)
if #retLevel == 0 then
retLevel = tbChar
end
retEET = self.filterEET(retLevel, ret, tbEET)
if #retEET == 0 then
retEET = self.filterEETNotrecommend(retLevel, ret, tbEETNotrecommend)
if #retEET == 0 then
retEET = retLevel
end
end
local retMain = self.filterMain(retEET, ret)
if #retMain < 1 then
retMain = retEET
end
local nCharId = self.selectAtk(retMain, ret)
if nCharId == 0 then
nCharId = tbChar[1].nId
end
table.insert(ret, nCharId)
local cfgDataMain = DataTable.Character[ret[1]]
local tbEETMain = {
cfgDataMain.EET
}
retLevel = self.filterLevel(tbChar, ret, nRecommendLevel)
if #retLevel == 0 then
retLevel = tbChar
end
retEET = self.filterEET(retLevel, ret, tbEETMain)
if #retEET == 0 then
retEET = self.filterEET(retLevel, ret, tbEET)
if #retEET == 0 then
retEET = self.filterEETNotrecommend(retLevel, ret, tbEETNotrecommend)
if #retEET == 0 then
retEET = retLevel
end
end
end
local retSub1 = self.filterSub(retEET, ret)
if #retSub1 < 1 then
retSub1 = retEET
end
nCharId = self.selectAtk(retSub1, ret)
if nCharId == 0 then
nCharId = tbChar[2].nId
end
table.insert(ret, nCharId)
retLevel = self.filterLevel(tbChar, ret, nRecommendLevel)
if #retLevel == 0 then
retLevel = tbChar
end
retEET = self.filterEET(retLevel, ret, tbEETMain)
if #retEET == 0 then
retEET = self.filterEET(retLevel, ret, tbEET)
if #retEET == 0 then
retEET = self.filterEETNotrecommend(retLevel, ret, tbEETNotrecommend)
if #retEET == 0 then
retEET = retLevel
end
end
end
local retBalance = self.filterBalance(retEET, ret)
if #retBalance < 1 then
retBalance = retEET
end
nCharId = self.selectAtk(retBalance, ret)
if nCharId == 0 then
nCharId = tbChar[3].nId
end
table.insert(ret, nCharId)
return ret
end
function FormationCtrl:OnBtnClick_Left(btn)
if self._panel.bList then
return
end
if self._panel.nTeamIndex == 1 then
self._panel.nTeamIndex = 6
else
self._panel.nTeamIndex = self._panel.nTeamIndex - 1
end
self:Refresh(2)
if self.curTeam[1] ~= 0 then
PlayerData.Voice:PlayCharVoice("swap", self.curTeam[1])
end
end
function FormationCtrl:OnBtnClick_Right(btn)
if self._panel.bList then
return
end
if self._panel.nTeamIndex == 6 then
self._panel.nTeamIndex = 1
else
self._panel.nTeamIndex = self._panel.nTeamIndex + 1
end
self:Refresh(1)
if self.curTeam[1] ~= 0 then
PlayerData.Voice:PlayCharVoice("swap", self.curTeam[1])
end
end
function FormationCtrl:OnBtnClick_Rename(btn)
end
function FormationCtrl:OnBtnClick_FastFormation(btn)
local confirmCallback = function()
local retTeam
if self.nFRType == AllEnum.FormationEnterType.MainLine then
retTeam = self:AutoSelectMainline()
elseif self.nFRType == AllEnum.FormationEnterType.StarTower then
retTeam = self:AutoSelectStarTower()
else
printError("不再支持老遗迹跳转")
end
self.curTeam = retTeam
EventManager.Hit(EventId.OpenMessageBox, {
nType = AllEnum.MessageBox.Tips,
bPositive = true,
sContent = ConfigTable.GetUIText("Auto_FormationTips")
})
if self:CheckFormationChanged() then
local Callback = function()
self:Refresh()
if self.curTeam[1] ~= 0 then
PlayerData.Voice:PlayCharVoice("swap", self.curTeam[1])
end
end
local tmpDisc = PlayerData.Team:GetTeamDiscData(self._panel.nTeamIndex)
PlayerData.Team:UpdateFormationInfo(self._panel.nTeamIndex, self.curTeam, tmpDisc, Callback)
end
end
local cancelCallback = function()
end
local msg = {
nType = AllEnum.MessageBox.Confirm,
sContent = ConfigTable.GetUIText("Auto_FormationNotice"),
callbackConfirm = confirmCallback,
callbackCancel = cancelCallback
}
for _, nId in ipairs(self.curTeam) do
if 0 < nId then
if not PlayerData.Guide:CheckInGuideGroup(12) then
EventManager.Hit(EventId.OpenMessageBox, msg)
else
confirmCallback()
end
return
end
end
confirmCallback()
end
function FormationCtrl:SetLocalData()
local LocalData = require("GameCore.Data.LocalData")
LocalData.SetPlayerLocalData("SavedTeamIdx", self._panel.nTeamIndex)
end
function FormationCtrl:OnBtnClick_Start(btn)
self._mapNode.btnStartBattle.enabled = false
if self.nFRType == AllEnum.FormationEnterType.MainLine then
self:EnterMainline()
elseif self.nFRType == AllEnum.FormationEnterType.FixedRoguelike then
printError("不再支持进入老遗迹")
elseif self.nFRType == AllEnum.FormationEnterType.StarTower then
self:EnterStarTower()
end
NovaAPI.SetEntryLevelFade(true)
end
function FormationCtrl:OnEvent_LoadModel(bLoadFinish)
self._mapNode.Mask:SetActive(not bLoadFinish)
end
function FormationCtrl:OnEvent_Back(nPanelId)
if self._panel._nPanelId ~= nPanelId then
return
end
if self._panel.bList == true then
self._mapNode.CharList:OnBtnClick_Close()
else
CS.AdventureModuleHelper.ExitSelectTeam()
PlayerData.Char:DeleteTrialChar()
local OpenCallback = function()
EventManager.Hit(EventId.CloesCurPanel)
end
EventManager.Hit(EventId.SetTransition, 5, OpenCallback)
self.bOpenTransition = true
end
end
function FormationCtrl:OnEvent_BackHome(nPanelId)
if self._panel._nPanelId ~= nPanelId then
return
end
CS.AdventureModuleHelper.ExitSelectTeam()
PlayerData.Char:DeleteTrialChar()
local OpenCallback = function()
PanelManager.Home()
end
EventManager.Hit(EventId.SetTransition, 5, OpenCallback)
self.bOpenTransition = true
end
function FormationCtrl:OnEvent_OpenSelectTeamMemberList(nIdx)
self._mapNode.btnFastFormation.gameObject:SetActive(false)
self._mapNode.btnStartBattle.transform.localScale = Vector3.zero
self._mapNode.t_arrow_01.gameObject:SetActive(false)
NovaAPI.SetCanvasGroupAlpha(self._mapNode.rt_TeamNameAlpha, 0)
self._mapNode.CharList:ShowList(self.curTeam, true)
self._panel.bList = true
self._Animator:Play("CharList_in")
self._mapNode.goChar[1]:OpenList(true)
self._mapNode.goChar[2]:OpenList(true)
self._mapNode.goChar[3]:OpenList(true)
end
function FormationCtrl:OnEvent_CloseList(bConfirm, tbList)
if bConfirm then
local Callback = function()
self:Refresh()
end
self.curTeam = tbList
if self:CheckFormationChanged() then
local tmpDisc = PlayerData.Team:GetTeamDiscData(self._panel.nTeamIndex)
PlayerData.Team:UpdateFormationInfo(self._panel.nTeamIndex, self.curTeam, tmpDisc, Callback)
end
else
self:Refresh()
end
local callback = function()
self._mapNode.btnFastFormation.gameObject:SetActive(true)
self._mapNode.btnStartBattle.transform.localScale = Vector3.one
self._mapNode.t_arrow_01.gameObject:SetActive(true)
NovaAPI.SetCanvasGroupAlpha(self._mapNode.rt_TeamNameAlpha, 1)
self._mapNode.CharList:CloseList()
end
self._Animator:Play("CharList_out")
self:AddTimer(1, 0.34, callback, true, true)
for i = 1, 3 do
self._mapNode.goChar[i]:SetArrowShow(false)
end
self._panel.bList = false
self._mapNode.goChar[1]:OpenList(false)
self._mapNode.goChar[2]:OpenList(false)
self._mapNode.goChar[3]:OpenList(false)
end
function FormationCtrl:OnEvent_ChangeTeamModel(tbList)
self.curTeam = tbList
self:RefreshChar()
end
function FormationCtrl:OnEvent_OpenSwapChar(nIdx)
local callback = function(nSwapIdx)
if nSwapIdx ~= 0 then
local ntemp = self.curTeam[nIdx]
self.curTeam[nIdx] = self.curTeam[nSwapIdx]
self.curTeam[nSwapIdx] = ntemp
end
local Callback = function()
self:Refresh()
if nSwapIdx == 1 or nIdx == 1 then
local nCharId = self.curTeam[1]
PlayerData.Voice:PlayCharVoice("swap", nCharId)
end
end
NovaAPI.SetCanvasGroupAlpha(self._mapNode.charCanvasGroup, 1)
self._mapNode.SwapBlock:SetActive(false)
for i = 1, 3 do
if self.mapCurModel[i] ~= nil then
self.mapCurModel[i].model:SetActive(true)
end
end
if self:CheckFormationChanged() then
local tmpDisc = PlayerData.Team:GetTeamDiscData(self._panel.nTeamIndex)
PlayerData.Team:UpdateFormationInfo(self._panel.nTeamIndex, self.curTeam, tmpDisc, Callback)
end
end
local nCurSelectChar = self.curTeam[nIdx]
if nCurSelectChar == 0 then
return
end
for i = 1, 3 do
if self.mapCurModel[i] ~= nil then
self.mapCurModel[i].model:SetActive(false)
end
end
NovaAPI.SetCanvasGroupAlpha(self._mapNode.charCanvasGroup, 0)
self._mapNode.SwapCharPanel:ShowSwapChar(self.curTeam, nCurSelectChar, callback)
self._mapNode.SwapBlock:SetActive(true)
end
return FormationCtrl
@@ -0,0 +1,23 @@
local FormationPanel = class("FormationPanel", BasePanel)
FormationPanel._tbDefine = {
{
sPrefabPath = "MainlineFormationEx/MainlineFormationScenePanel.prefab",
sCtrlName = "Game.UI.FormationEx.FormationCtrl"
}
}
function FormationPanel:Awake()
EventManager.Add("EnterModule", self, self.OnEvent_EnterModule)
end
function FormationPanel:OnEnable(bPlayFadeIn)
end
function FormationPanel:OnDisable()
end
function FormationPanel:OnDestroy()
EventManager.Remove("EnterModule", self, self.OnEvent_EnterModule)
end
function FormationPanel:OnEvent_EnterModule(moduleMgr, sExitModuleName, sEnterModuleName)
if sEnterModuleName == "AdventureModuleScene" then
self.bAddBuild = false
end
end
return FormationPanel
+91
View File
@@ -0,0 +1,91 @@
local SwapCharCtrl = class("SwapCharCtrl", BaseCtrl)
SwapCharCtrl._mapNodeConfig = {
imgHeadSelectSwap = {sComponentName = "Image"},
imgCharBgSwap = {nCount = 3},
imgProhibit = {nCount = 3},
imgHead = {sComponentName = "Image", nCount = 3},
imgMask = {nCount = 3}
}
SwapCharCtrl._mapEventConfig = {
SwapCharIn = "OnEvent_SwapIn",
SwapCharOut = "OnEvent_SwapOut",
CloseSwap = "OnEvent_ClosePanel"
}
function SwapCharCtrl:Awake()
self.canvasGroup = self.gameObject:GetComponent("CanvasGroup")
end
function SwapCharCtrl:FadeIn()
end
function SwapCharCtrl:FadeOut()
end
function SwapCharCtrl:OnEnable()
NovaAPI.SetCanvasGroupAlpha(self.canvasGroup, 0)
self.gameObject:SetActive(false)
end
function SwapCharCtrl:OnDisable()
end
function SwapCharCtrl:OnDestroy()
end
function SwapCharCtrl:OnRelease()
end
function SwapCharCtrl:ShowSwapChar(tbChar, nSelectCharId, callback)
self.gameObject:SetActive(true)
self.tbChar = tbChar
self.nSelectCharId = nSelectCharId
self.nSelectedIdx = table.indexof(self.tbChar, self.nSelectCharId)
self.nCurSwapIdx = 0
self.callback = callback
for i = 1, 3 do
if i == self.nSelectedIdx or self.tbChar[i] == 0 then
self._mapNode.imgCharBgSwap[i]:SetActive(false)
self._mapNode.imgProhibit[i]:SetActive(true)
else
local mapCharCfg = ConfigTable.GetData_Character(self.tbChar[i])
local nSkinId = PlayerData.Char:GetCharSkinId(self.tbChar[i])
local mapCharSkin = ConfigTable.GetData_CharacterSkin(nSkinId)
self:SetPngSprite(self._mapNode.imgHead[i], mapCharSkin.Icon .. AllEnum.CharHeadIconSurfix.S)
self._mapNode.imgCharBgSwap[i]:SetActive(true)
self._mapNode.imgProhibit[i]:SetActive(false)
self._mapNode.imgMask[i]:SetActive(false)
end
end
local mapCharCfg = ConfigTable.GetData_Character(nSelectCharId)
local nSkinId = PlayerData.Char:GetCharSkinId(nSelectCharId)
local mapCharSkin = ConfigTable.GetData_CharacterSkin(nSkinId)
self:SetPngSprite(self._mapNode.imgHeadSelectSwap, mapCharSkin.Icon .. AllEnum.CharHeadIconSurfix.S)
local wait = function()
coroutine.yield(CS.UnityEngine.WaitForEndOfFrame())
NovaAPI.SetCanvasGroupAlpha(self.canvasGroup, 1)
end
cs_coroutine.start(wait)
end
function SwapCharCtrl:OnEvent_ClosePanel()
self.gameObject:SetActive(false)
NovaAPI.SetCanvasGroupAlpha(self.canvasGroup, 0)
if self.callback ~= nil then
self.callback(self.nCurSwapIdx)
end
end
function SwapCharCtrl:OnEvent_SwapIn(nIdx)
if nIdx == self.nSelectCharId then
return
end
if nIdx == self.nCurSwapIdx then
return
end
if 0 == self.tbChar[nIdx] then
return
end
if self.nCurSwapIdx ~= 0 then
self._mapNode.imgMask[self.nCurSwapIdx]:SetActive(false)
end
self.nCurSwapIdx = nIdx
self._mapNode.imgMask[nIdx]:SetActive(true)
end
function SwapCharCtrl:OnEvent_SwapOut()
if self.nCurSwapIdx ~= 0 then
self._mapNode.imgMask[self.nCurSwapIdx]:SetActive(false)
end
self.nCurSwapIdx = 0
end
return SwapCharCtrl