Update - 1.4.0.73

EN: 1.4.0.73
CN: 1.4.0.74
JP: 1.4.0.77
KR: 1.4.0.80
This commit is contained in:
SL1900
2025-12-25 19:00:00 +09:00
parent 5f417fbe9d
commit 35c8d87e86
1183 changed files with 893278 additions and 92778 deletions
@@ -16,7 +16,8 @@ PlayerHudCtrl._mapEventConfig = {
ResetEnergy = "OnEvent_UpdateEnergy",
TowerDefenseShowFullScreenPanel = "OnEvent_PauseEnergy",
TowerDefenseShowHideScreenPanel = "OnEvent_ResumeEnergy",
TowerDefenseFuncShow = "OnEvent_FuncShow"
TowerDefenseFuncShow = "OnEvent_FuncShow",
TowerDefenseCheckTips = "OnEvent_CheckTips"
}
PlayerHudCtrl._mapRedDotConfig = {}
function PlayerHudCtrl:Awake()
@@ -139,4 +140,7 @@ function PlayerHudCtrl:OnEvent_FuncShow(bIsShow, characterId)
self:CheckTips()
end
end
function PlayerHudCtrl:OnEvent_CheckTips()
self:CheckTips()
end
return PlayerHudCtrl
@@ -81,9 +81,8 @@ function TowerDefenseCharacterDetailCtrl:Awake()
nSelectIndex = 1
end
self.nSelectedId = self.characterList[nSelectIndex]
self.nActId = param[3]
self.TowerdefenseLevelData = param[3]
end
self.TowerDefenseData = PlayerData.Activity:GetActivityDataById(self.nActId)
self.selectedGrid = nil
self:InitData()
end
@@ -104,11 +103,11 @@ function TowerDefenseCharacterDetailCtrl:InitData()
self:OnTabSelected(1)
end
function TowerDefenseCharacterDetailCtrl:RefreshInfoData()
local nEntityId = self.TowerDefenseData.TowerDefenseLevelData:GetCharacterEntityId(self.nSelectedId)
local nEntityId = self.TowerdefenseLevelData:GetCharacterEntityId(self.nSelectedId)
local Info = AdventureModuleHelper.GetEntityInfo(nEntityId)
local atk = Info ~= nil and Info.atk:AsInt() or 0
local atk = Info ~= nil and Info.atk or 0
NovaAPI.SetTMPText(self._mapNode.txt_attackValue, tostring(atk))
local atkSpeed = Info ~= nil and Info.normalAttackSpd:AsFloat() or 0
local atkSpeed = Info ~= nil and Info.normalAttackSpd or 0
atkSpeed = clearFloat(atkSpeed)
NovaAPI.SetTMPText(self._mapNode.txt_AttackSpeedValue, FormatEffectValue(atkSpeed, true, GameEnum.ValueFormat.TDP))
local config = ConfigTable.GetData("TowerDefenseCharacter", self.nSelectedId)
@@ -116,12 +115,12 @@ function TowerDefenseCharacterDetailCtrl:RefreshInfoData()
return
end
NovaAPI.SetTMPText(self._mapNode.txt_detailName, config.Name)
local nCD = self.TowerDefenseData.TowerDefenseLevelData:GetCharSkillCD(self.nSelectedId)
local nCD = self.TowerdefenseLevelData:GetCharSkillCD(self.nSelectedId)
NovaAPI.SetTMPText(self._mapNode.txt_cdValue, string.format("%.1f", nCD) .. ConfigTable.GetUIText("TowerDef_Text_Sec"))
if config.Icon ~= nil and config.Icon ~= "" then
self:SetPngSprite(self._mapNode.img_char, config.Icon .. AllEnum.CharHeadIconSurfix.Q)
end
local level = self.TowerDefenseData.TowerDefenseLevelData:GetCharacterLevel(self.nSelectedId)
local level = self.TowerdefenseLevelData:GetCharacterLevel(self.nSelectedId)
NovaAPI.SetTMPText(self._mapNode.txtLevel, tostring(level))
self:SetSkillDes()
self:SetPotentialDes()
@@ -183,7 +182,7 @@ function TowerDefenseCharacterDetailCtrl:SetSkillDes()
cs_coroutine.start(wait)
end
function TowerDefenseCharacterDetailCtrl:SetPotentialDes()
local tbPotentialList = self.TowerDefenseData.TowerDefenseLevelData:GetPotentialByChar(self.nSelectedId)
local tbPotentialList = self.TowerdefenseLevelData:GetPotentialByChar(self.nSelectedId)
self._mapNode.go_potential1:SetActive(false)
self._mapNode.go_potential2:SetActive(false)
if tbPotentialList == nil then
@@ -287,7 +286,7 @@ function TowerDefenseCharacterDetailCtrl:OnTabSelected(nIndex)
self._mapNode.skill_sv:SetActive(nIndex == 2)
local bShowPotential = false
if nIndex == 1 then
local tbPotentialList = self.TowerDefenseData.TowerDefenseLevelData:GetPotentialByChar(self.nSelectedId)
local tbPotentialList = self.TowerdefenseLevelData:GetPotentialByChar(self.nSelectedId)
if tbPotentialList ~= nil then
for _, potentialId in pairs(tbPotentialList) do
local config = ConfigTable.GetData("TowerDefensePotential", potentialId)
@@ -28,8 +28,8 @@ end
function TowerDefenseCharacterFuncCtrl:SetLevelBtnState(bIsShow)
self.bIsShowLevelBtn = bIsShow
end
function TowerDefenseCharacterFuncCtrl:SetData(nActId)
self.TowerDefenseData = PlayerData.Activity:GetActivityDataById(nActId)
function TowerDefenseCharacterFuncCtrl:SetData(levelData)
self.TowerDefenseLevelData = levelData
end
function TowerDefenseCharacterFuncCtrl:BindFuncIcon(characterId, uiPos, detailCallback, levelupCallback)
if self.UseFuncGo[characterId] ~= nil then
@@ -89,7 +89,10 @@ function TowerDefenseCharacterFuncCtrl:ShowIcon(characterId)
end
local go = self.UseFuncGo[characterId]
local btn_LevelUp = go.transform:Find("btn_levelUp")
local level = self.TowerDefenseData.TowerDefenseLevelData:GetCharacterLevel(self.nCharacterId)
local level = self.TowerDefenseLevelData:GetCharacterLevel(self.nCharacterId)
if level == nil then
return
end
local config = ConfigTable.GetData("TowerDefenseCharacter", self.nCharacterId)
if config == nil then
return
@@ -131,7 +134,7 @@ function TowerDefenseCharacterFuncCtrl:ShowIcon(characterId)
EventManager.Hit("TowerDefenseFuncShow", true, self.nCharacterId)
end
function TowerDefenseCharacterFuncCtrl:UpdateFunc(characterId, go)
local level = self.TowerDefenseData.TowerDefenseLevelData:GetCharacterLevel(characterId)
local level = self.TowerDefenseLevelData:GetCharacterLevel(characterId)
local config = ConfigTable.GetData("TowerDefenseCharacter", characterId)
if config == nil then
return
+196 -84
View File
@@ -12,7 +12,18 @@ local cardAnimCD = 0.1
local ItemType = {
CD = 1,
Count = 2,
Charge = 3
Charge = 3,
CD_And_Count = 4
}
local DragType = {
None = 1,
Char = 2,
Item = 3
}
local CardDragType = {
None = 1,
Drag = 2,
Pointer = 3
}
local colorWhite = Color(0.792156862745098, 0.8274509803921568, 0.8666666666666667)
local colorRed = Color(0.7411764705882353, 0.18823529411764706, 0.34901960784313724)
@@ -35,6 +46,15 @@ TowerDefenseCtrl._mapNodeConfig = {
callback = "OnBtnClick_ChangeSpeed",
sAction = "TowerDefFast"
},
btn_dic = {
sComponentName = "NaviButton",
callback = "OnBtnClick_OpenDic",
sAction = "Depot"
},
txt_dic1 = {
sComponentName = "TMP_Text",
sLanguageId = "Tutorial_DicTitle"
},
btn_release = {
sComponentName = "NaviButton",
callback = "OnBtnClick_Release"
@@ -77,6 +97,7 @@ TowerDefenseCtrl._mapNodeConfig = {
txt_cd = {sComponentName = "TMP_Text"},
go_item = {},
cd_mask = {},
img_disable = {},
item_bar = {
sComponentName = "RectTransform"
},
@@ -101,6 +122,7 @@ TowerDefenseCtrl._mapNodeConfig = {
},
go_backupCard = {nCount = 3},
drag_area = {
sNodeName = "Char_Item",
sComponentName = "RectTransform"
},
img_item_null = {},
@@ -234,6 +256,9 @@ function TowerDefenseCtrl:Awake()
self.tempCharCardList = {}
self._mapNode.bg_skill:SetActive(false)
self.bHasDic = false
self.nDicId = 0
self.nDragType = DragType.None
self._mapNode.btn_dic.gameObject:SetActive(false)
end
function TowerDefenseCtrl:OnEnable()
self:BindHander()
@@ -267,7 +292,7 @@ function TowerDefenseCtrl:InitData()
self._mapNode.img_cd.gameObject:SetActive(false)
self._mapNode.cd_mask.gameObject:SetActive(false)
self._mapNode.go_item:SetActive(false)
self._mapNode.go_characterFunc:SetData(self.nActId)
self._mapNode.go_characterFunc:SetData(self.TowerDefenseData.TowerDefenseLevelData)
self._mapNode.potentialSelectPanel:SetData(self.nActId)
self:InitDragAreaThreshold()
self.point = 0
@@ -492,7 +517,11 @@ function TowerDefenseCtrl:ShowSkillDes(bIsShow, nCharId)
end
function TowerDefenseCtrl:ChangeGamepadUI(bEnable)
for _, v in pairs(self.tbGamepadUINode) do
v.mapNode.gameObject:SetActive(bEnable)
if v.mapNode.gameObject.name == "btn_dic" then
v.mapNode.gameObject:SetActive(bEnable and self.nDicId ~= 0)
else
v.mapNode.gameObject:SetActive(bEnable)
end
end
end
function TowerDefenseCtrl:BindHander()
@@ -537,48 +566,39 @@ function TowerDefenseCtrl:OnPointerExit_Item(go)
NovaAPI.DispatchEventWithData("TOWERDEFENSE_CARDPOINTEXIT")
end
function TowerDefenseCtrl:OnPointerDown_CharacterCard(go, nIndex)
if self.bPointItem then
self._mapNode.drag_itemIcon.gameObject:SetActive(false)
NovaAPI.DispatchEventWithData("TOWERDEFENSE_CANCEL_DRAG_STATE")
self.bPointItem = false
return
end
if self.goPointChar and self.dragCharacterId ~= 0 then
if self.goPointChar and self.dragCharacterId ~= 0 and self.CardDragType == CardDragType.Pointer then
NovaAPI.DispatchEventWithData("TOWERDEFENSE_CANCEL_DRAG_STATE")
self.goPointChar = nil
self:SetSlowSpeed(false)
WwiseAudioMgr:PostEvent("mode_TD_card_drag_end")
self:ShowSkillDes(false)
self:SetDragState(DragType.None)
self.CardDragType = CardDragType.None
return
end
self.goPointChar = go.gameObject
self:HideFuncIcon()
end
function TowerDefenseCtrl:OnPointerDown_Item(go)
if self.bPointItem then
if self.bPointItem and self.CardDragType == CardDragType.Pointer then
self._mapNode.drag_itemIcon.gameObject:SetActive(false)
NovaAPI.DispatchEventWithData("TOWERDEFENSE_CANCEL_DRAG_STATE")
self.bPointItem = false
return
end
if self.goPointChar then
local go_drag = self.goPointChar
local index = table.indexof(self.tbCardIndex, go_drag)
self:ShowCard(index)
NovaAPI.DispatchEventWithData("TOWERDEFENSE_CANCEL_DRAG_STATE")
self:SetSlowSpeed(false)
WwiseAudioMgr:PostEvent("mode_TD_item_drag_end")
self.goPointChar = nil
self:ShowSkillDes(false)
self:SetDragState(DragType.None)
self.CardDragType = CardDragType.None
return
end
self.bPointItem = true
self:HideFuncIcon()
end
function TowerDefenseCtrl:OnEvent_HoldCard(pos)
if self.goPointChar then
if self.CardDragType ~= CardDragType.Pointer then
return
end
if self.nDragType == DragType.Char and self.goPointChar then
local go_drag = self.goPointChar
local index = table.indexof(self.tbCardIndex, go_drag)
self:SetDragState(DragType.Char, index)
self.dragCharacterId = self.tbCharacterId[index]
local uipos = GameUIUtils.ScreenPointToLocalPointInRectangle(pos, self.goPointChar.transform.parent.transform.parent.transform)
if not self.bOutArea and (uipos.x < self.DragThresholdMinX or uipos.x > self.DragThresholdMaxX or uipos.y < self.DragThresholdMinY or uipos.y > self.DragThresholdMaxY) then
@@ -593,10 +613,11 @@ function TowerDefenseCtrl:OnEvent_HoldCard(pos)
rectTra.anchoredPosition = Vector2(new_uipos.x, new_uipos.y)
return
end
if self.bPointItem then
if self.ItemType == ItemType.Count and self.nItemCount == 0 then
if self.nDragType == DragType.Item and self.bPointItem then
if self.ItemType == ItemType.Count or self.ItemType == ItemType.CD_And_Count and self.nItemCount == 0 then
return
end
self:SetDragState(DragType.Item)
self._mapNode.drag_itemIcon.gameObject:SetActive(true)
local uipos = GameUIUtils.ScreenPointToLocalPointInRectangle(pos, self._mapNode.drag_itemIcon.gameObject.transform.parent.transform)
local rectTra = self._mapNode.drag_itemIcon.gameObject:GetComponent("RectTransform")
@@ -606,50 +627,61 @@ function TowerDefenseCtrl:OnEvent_HoldCard(pos)
end
end
function TowerDefenseCtrl:OnEvent_HoldCardChange(bHold)
if self.goPointChar == nil and not self.bPointItem then
return
end
self.bHoldCard = bHold
if bHold then
self.bOutArea = false
if self.goPointChar then
WwiseAudioMgr:PostEvent("mode_TD_card_drag")
local index = table.indexof(self.tbCardIndex, self.goPointChar)
self:ShowSkillDes(true, self.tbCharacterId[index])
if self.nDragType == DragType.None then
if self.goPointChar ~= nil then
WwiseAudioMgr:PostEvent("mode_TD_card_drag")
local index = table.indexof(self.tbCardIndex, self.goPointChar)
self:SetDragState(DragType.Char, index)
self:ShowSkillDes(true, self.tbCharacterId[index])
self:SetSlowSpeed(true)
self.CardDragType = CardDragType.Pointer
end
if self.bPointItem then
WwiseAudioMgr:PostEvent("mode_TD_item_drag")
self:SetDragState(DragType.Item)
self:SetSlowSpeed(true)
self.CardDragType = CardDragType.Pointer
end
end
if self.bPointItem then
WwiseAudioMgr:PostEvent("mode_TD_item_drag")
end
self:SetSlowSpeed(true)
elseif not self.bOutArea then
if self.goPointChar then
else
if not self.bOutArea and self.nDragType == DragType.Char then
local go_drag = self.goPointChar
local index = table.indexof(self.tbCardIndex, go_drag)
self:ShowCard(index)
WwiseAudioMgr:PostEvent("mode_TD_card_drag_end")
self:SetSlowSpeed(false)
self:ShowSkillDes(false)
self:SetDragState(DragType.None)
self.CardDragType = CardDragType.None
end
if self.bPointItem then
if self.nDragType == DragType.Item then
self._mapNode.drag_itemIcon.gameObject:SetActive(false)
WwiseAudioMgr:PostEvent("mode_TD_item_drag_end")
self:SetSlowSpeed(false)
self:SetDragState(DragType.None)
self.CardDragType = CardDragType.None
self.bPointItem = false
NovaAPI.DispatchEventWithData("TOWERDEFENSE_CANCEL_DRAG_STATE")
end
end
end
function TowerDefenseCtrl:OnDrag_CharacterCard(mDrag)
if self.CardDragType == CardDragType.Pointer then
return
end
if mDrag.DragEventType == AllEnum.UIDragType.DragStart then
self.CardDragType = CardDragType.Drag
self:HideFuncIcon()
self.goPointChar = nil
self.bDrag = true
self.bOutArea = false
local go_drag = mDrag.gameObject
self.goPointChar = mDrag.gameObject
local index = table.indexof(self.tbCardIndex, go_drag)
self.dragCharacterId = self.tbCharacterId[index]
WwiseAudioMgr:PostEvent("mode_TD_card_drag")
self:SetSlowSpeed(true)
self:ShowSkillDes(true, self.dragCharacterId)
self:SetDragState(DragType.Char, index)
elseif mDrag.DragEventType == AllEnum.UIDragType.Drag then
local uipos = GameUIUtils.ScreenPointToLocalPointInRectangle(mDrag.EventData.position, mDrag.gameObject.transform.parent.transform.parent.transform)
if not self.bOutArea and (uipos.x < self.DragThresholdMinX or uipos.x > self.DragThresholdMaxX or uipos.y < self.DragThresholdMinY or uipos.y > self.DragThresholdMaxY) then
@@ -665,30 +697,28 @@ function TowerDefenseCtrl:OnDrag_CharacterCard(mDrag)
local rectTra = mDrag.gameObject:GetComponent("RectTransform")
rectTra.anchoredPosition = Vector2(new_uipos.x, new_uipos.y)
elseif mDrag.DragEventType == AllEnum.UIDragType.DragEnd then
self.bDrag = false
if not self.bOutArea then
local go_drag = mDrag.gameObject
local index = table.indexof(self.tbCardIndex, go_drag)
self:ShowCard(index)
WwiseAudioMgr:PostEvent("mode_TD_card_drag_end")
end
if self.goPointChar == nil then
self:SetSlowSpeed(false)
self:ShowSkillDes(false)
elseif self.bHoldCard then
self:SetSlowSpeed(false)
self:ShowSkillDes(false)
end
self:SetSlowSpeed(false)
self:ShowSkillDes(false)
self:SetDragState(DragType.None)
self.CardDragType = CardDragType.None
end
end
function TowerDefenseCtrl:OnDrag_Item(mDrag)
if self.ItemType == ItemType.Count and self.nItemCount == 0 then
if self.ItemType == ItemType.Count or self.ItemType == ItemType.CD_And_Count and self.nItemCount == 0 then
return
end
if self.CardDragType == CardDragType.Pointer then
return
end
if mDrag.DragEventType == AllEnum.UIDragType.DragStart then
self.CardDragType = CardDragType.Drag
self:HideFuncIcon()
self.bDrag = true
self.bPointItem = true
self._mapNode.drag_itemIcon.gameObject:SetActive(true)
local uipos = GameUIUtils.ScreenPointToLocalPointInRectangle(mDrag.EventData.position, mDrag.gameObject.transform.parent.transform)
local rectTra = self._mapNode.drag_itemIcon.gameObject:GetComponent("RectTransform")
@@ -696,18 +726,16 @@ function TowerDefenseCtrl:OnDrag_Item(mDrag)
NovaAPI.DispatchEventWithData("TOWERDEFENSE_DRAG_ITEMCARD_BEGIN")
self:SetSlowSpeed(true)
WwiseAudioMgr:PostEvent("mode_TD_item_drag")
self:SetDragState(DragType.Item)
elseif mDrag.DragEventType == AllEnum.UIDragType.Drag then
local uipos = GameUIUtils.ScreenPointToLocalPointInRectangle(mDrag.EventData.position, mDrag.gameObject.transform.parent.transform)
local rectTra = self._mapNode.drag_itemIcon.gameObject:GetComponent("RectTransform")
rectTra.anchoredPosition = Vector2(uipos.x, uipos.y)
elseif mDrag.DragEventType == AllEnum.UIDragType.DragEnd then
self.bDrag = false
self._mapNode.drag_itemIcon.gameObject:SetActive(false)
if not self.bPointItem then
self:SetSlowSpeed(false)
elseif self.bHoldCard then
self:SetSlowSpeed(false)
end
self:SetSlowSpeed(false)
self:SetDragState(DragType.None)
self.CardDragType = CardDragType.None
end
end
function TowerDefenseCtrl:CharacterLevelUp(characterId)
@@ -760,7 +788,7 @@ function TowerDefenseCtrl:ShowCharacterDetail(characterId)
table.insert(tbChar, data.nCharacterId)
end
self:PauseLogic()
EventManager.Hit(EventId.OpenPanel, PanelId.TowerDefenseCharacterDetailPanel, tbChar, characterId, self.nActId)
EventManager.Hit(EventId.OpenPanel, PanelId.TowerDefenseCharacterDetailPanel, tbChar, characterId, self.TowerDefenseData.TowerDefenseLevelData)
end
function TowerDefenseCtrl:PauseLogic()
PanelManager.InputDisable()
@@ -792,6 +820,32 @@ function TowerDefenseCtrl:SetPointText(value)
NovaAPI.SetTMPColor(self._mapNode.txt_point, colorWhite)
end
end
function TowerDefenseCtrl:SetDragState(nType, nCharIndex)
self.nDragType = nType
if nType == DragType.None then
for _, go_card in ipairs(self.tbCardIndex) do
local canvasGroup = go_card:GetComponent("CanvasGroup")
NovaAPI.SetCanvasGroupBlocksRaycasts(canvasGroup, true)
end
local itemCanvasGroup = self._mapNode.go_item:GetComponent("CanvasGroup")
NovaAPI.SetCanvasGroupBlocksRaycasts(itemCanvasGroup, true)
elseif nType == DragType.Char then
for index, go_card in ipairs(self.tbCardIndex) do
local canvasGroup = go_card:GetComponent("CanvasGroup")
if index == nCharIndex then
else
NovaAPI.SetCanvasGroupBlocksRaycasts(canvasGroup, false)
end
end
local itemCanvasGroup = self._mapNode.go_item:GetComponent("CanvasGroup")
NovaAPI.SetCanvasGroupBlocksRaycasts(itemCanvasGroup, false)
elseif nType == DragType.Item then
for _, go_card in ipairs(self.tbCardIndex) do
local canvasGroup = go_card:GetComponent("CanvasGroup")
NovaAPI.SetCanvasGroupBlocksRaycasts(canvasGroup, false)
end
end
end
function TowerDefenseCtrl:HideFuncIcon()
self.ShowFuncCharId = -1
self._mapNode.go_characterFunc:HideIcon()
@@ -808,7 +862,6 @@ function TowerDefenseCtrl:OnEvent_GetCharacterCard(nCharacterId, bShowTips)
end
end
function TowerDefenseCtrl:OnEvent_UseCharacterCard(bUse, nEntityId, nCharacterId, screenPos)
print("OnEvent_UseCharacterCard:" .. tostring(bUse) .. " " .. tostring(nCharacterId))
self:SetSlowSpeed(false)
self:ShowSkillDes(false)
if bUse then
@@ -823,11 +876,14 @@ function TowerDefenseCtrl:OnEvent_UseCharacterCard(bUse, nEntityId, nCharacterId
EventManager.Hit("TowerDefensePointChange", self.point)
else
local nIndex = table.indexof(self.tbCharacterId, self.dragCharacterId)
print("OnEvent_UseCharacterCard:" .. tostring(self.dragCharacterId))
self:ShowCard(nIndex, true)
WwiseAudioMgr:PostEvent("mode_TD_card_drag_end")
end
self.dragCharacterId = 0
self.bPointItem = false
self.goPointChar = nil
self.CardDragType = CardDragType.None
self:SetDragState(DragType.None)
end
function TowerDefenseCtrl:OnEvent_ExpChange(curExp, maxExp)
self:UpdateExp(curExp, maxExp)
@@ -878,9 +934,15 @@ function TowerDefenseCtrl:OnEvent_FinishGame(bResult)
EventManager.Hit(EventId.OpenPanel, PanelId.TowerDefenseResultPanel, bResult, sLevelName, tbTarget, cb, msgData)
end
self.TowerDefenseData:RequestFinishLevel(self.nLevelId, bResult, self.nCurHp, requestCb)
WwiseAudioMgr:PostEvent("ui_roguelike_challenge_firework")
if bResult then
WwiseAudioMgr:PostEvent("ui_roguelike_challenge_firework")
end
end
function TowerDefenseCtrl:OnEvent_ShowCharacterIcon(characterId, bIsShow)
local characterData = self.TowerDefenseData.TowerDefenseLevelData:GetCharacterData(characterId)
if bIsShow and characterData == nil then
return
end
if bIsShow then
self.ShowFuncCharId = characterId
self._mapNode.btn_release.gameObject:SetActive(false)
@@ -901,6 +963,7 @@ function TowerDefenseCtrl:OnEvent_UpdateItemCard(nItemId, nCount)
self.nItemId = nItemId
self.nItemCount = nCount
self._mapNode.drag_itemIcon.gameObject:SetActive(false)
self._mapNode.img_disable:SetActive(false)
if nItemId == 0 then
self._mapNode.go_item:SetActive(false)
return
@@ -910,12 +973,14 @@ function TowerDefenseCtrl:OnEvent_UpdateItemCard(nItemId, nCount)
if itemConfig == nil then
return
end
if 0 < itemConfig.Amount then
if 0 < itemConfig.Amount and 0 < itemConfig.Cd then
self.ItemType = ItemType.CD_And_Count
elseif 0 < itemConfig.Amount then
self.ItemType = ItemType.Count
elseif 0 < itemConfig.Cd then
self.ItemType = ItemType.CD
else
self.ItemType = ItemType.Charge
self.ItemType = ItemType.None
end
if itemConfig.CardIcon ~= nil and itemConfig.CardIcon ~= "" then
for _, icon in pairs(self._mapNode.icon_item) do
@@ -925,7 +990,20 @@ function TowerDefenseCtrl:OnEvent_UpdateItemCard(nItemId, nCount)
if itemConfig.Head ~= nil and itemConfig.Head ~= "" then
self:SetPngSprite(self._mapNode.drag_itemIcon, itemConfig.Head)
end
self._mapNode.txt_itemValue.gameObject:SetActive(0 < nCount)
if self.ItemType == ItemType.CD_And_Count or self.ItemType == ItemType.Count then
self._mapNode.txt_itemValue.gameObject:SetActive(true)
self._mapNode.img_disable:SetActive(nCount <= 0)
if nCount <= 0 then
if self.tweener ~= nil then
self.tweener:Kill()
end
self._mapNode.txt_cd.gameObject:SetActive(false)
self._mapNode.img_cd.gameObject:SetActive(false)
self._mapNode.cd_mask.gameObject:SetActive(false)
end
else
self._mapNode.txt_itemValue.gameObject:SetActive(0 < nCount)
end
NovaAPI.SetTMPText(self._mapNode.txt_itemValue, "x" .. tostring(nCount))
self._mapNode.go_item:SetActive(true)
end
@@ -938,33 +1016,57 @@ function TowerDefenseCtrl:OnEvent_UseItemCard(bResult)
if self.tweener ~= nil then
self.tweener:Kill()
end
self.tweener = DOTween.To(function()
return itemConfig.Cd
end, function(v)
NovaAPI.SetTMPText(self._mapNode.txt_cd, string.format("%.1f", v))
self._mapNode.img_cd.sizeDelta = Vector2(self._mapNode.img_cd.sizeDelta.x, 259 * (v / itemConfig.Cd))
end, 0, itemConfig.Cd):OnComplete(function()
self._mapNode.txt_cd.gameObject:SetActive(false)
self._mapNode.img_cd.gameObject:SetActive(false)
self._mapNode.cd_mask.gameObject:SetActive(false)
end)
self._mapNode.txt_cd.gameObject:SetActive(true)
self._mapNode.img_cd.gameObject:SetActive(true)
self._mapNode.cd_mask.gameObject:SetActive(true)
self.nItemCD = itemConfig.Cd
EventManager.Hit("TowerDefenseGM_QueryFastCD", self)
if self.ItemType == ItemType.CD_And_Count or self.ItemType == ItemType.CD and self.nItemCD > 0 then
self.tweener = DOTween.To(function()
return self.nItemCD
end, function(v)
NovaAPI.SetTMPText(self._mapNode.txt_cd, string.format("%.1f", v))
self._mapNode.img_cd.sizeDelta = Vector2(self._mapNode.img_cd.sizeDelta.x, 259 * (v / self.nItemCD))
end, 0, self.nItemCD):OnComplete(function()
self._mapNode.txt_cd.gameObject:SetActive(false)
self._mapNode.img_cd.gameObject:SetActive(false)
self._mapNode.cd_mask.gameObject:SetActive(false)
end)
self._mapNode.txt_cd.gameObject:SetActive(true)
self._mapNode.img_cd.gameObject:SetActive(true)
self._mapNode.cd_mask.gameObject:SetActive(true)
end
else
WwiseAudioMgr:PostEvent("mode_TD_item_drag_end")
end
self:SetSlowSpeed(false)
self:SetDragState(DragType.None)
self.CardDragType = CardDragType.None
self.bPointItem = false
self.goPointChar = nil
self._mapNode.drag_itemIcon.gameObject:SetActive(false)
end
function TowerDefenseCtrl:OnEvent_Exit()
local confirmCallback = function()
self._mapNode.pauseCtrl:Close()
self:SetTimeScale(false)
EventManager.Hit(EventId.ClosePanel, PanelId.TowerDefenseHUD)
self:ResumeLogic(true)
CS.AdventureModuleHelper.LevelStateChanged(true, 0, true)
self.TowerDefenseData:RequestFinishLevel(self.nLevelId, false, 0, nil)
local requestCb = function(star, newStar, msgData)
local cb = function()
EventManager.Hit(EventId.ClosePanel, PanelId.TowerDefenseHUD)
self:ResumeLogic(true)
end
local config = ConfigTable.GetData("TowerDefenseLevel", self.nLevelId)
if config == nil then
return
end
local sLevelName = config.LevelName
local tbTarget = {}
for i = 1, 3 do
table.insert(tbTarget, {
sTargetDes = config["Des" .. i],
bResult = false
})
end
EventManager.Hit(EventId.OpenPanel, PanelId.TowerDefenseResultPanel, false, sLevelName, tbTarget, cb, nil)
end
self.TowerDefenseData:RequestFinishLevel(self.nLevelId, false, 0, requestCb)
end
local sTip = ConfigTable.GetUIText("TowerDef_Exit_Confirm")
local msg = {
@@ -978,6 +1080,13 @@ function TowerDefenseCtrl:OnBtnClick_Pause()
self._mapNode.pauseCtrl:Open()
self:PauseLogic()
end
function TowerDefenseCtrl:OnBtnClick_OpenDic()
if self.nDicId == 0 then
return
end
self:PauseLogic()
EventManager.Hit(EventId.OpenPanel, PanelId.DictionaryEntry, self.nDicId, true)
end
function TowerDefenseCtrl:OnBtnClick_SwitchPosNext()
NovaAPI.DispatchEventWithData("TOWERDEFENSE_HANDLE_CONTROL_L1R1", nil, {1})
end
@@ -1072,6 +1181,8 @@ function TowerDefenseCtrl:OnEvent_OpenDic(dicId)
end
self:PauseLogic()
EventManager.Hit(EventId.OpenPanel, PanelId.DictionaryEntry, dicId, true)
self.nDicId = dicId
self._mapNode.btn_dic.gameObject:SetActive(true)
end
function TowerDefenseCtrl:OnEvent_CloseDic(panelId)
if panelId == PanelId.DictionaryEntry then
@@ -1081,6 +1192,7 @@ end
function TowerDefenseCtrl:OnEvent_CharLevelCallback(characterId)
local nLevel = self.TowerDefenseData.TowerDefenseLevelData:GetCharacterLevel(characterId)
EventManager.Hit("TowerDefense_character_levelUp", characterId, nLevel)
EventManager.Hit("TowerDefenseCheckTips")
end
function TowerDefenseCtrl:OnEvent_HasDic()
self.bHasDic = true
@@ -1,5 +1,7 @@
local TowerDefenseGuideCtrl = class("TowerDefenseGuideCtrl", BaseCtrl)
local iconPath = "UI/Play_TowerDefence/SpriteAtlas/Sprite/"
TowerDefenseGuideCtrl._mapNodeConfig = {
anim = {sNodeName = "Root", sComponentName = "Animator"},
txt_Guide_window = {
sComponentName = "TMP_Text",
sLanguageId = "TowerDef_Guide"
@@ -37,18 +39,19 @@ TowerDefenseGuideCtrl._mapNodeConfig = {
item_detail = {},
txt_itemName = {sComponentName = "TMP_Text"},
txt_itemCD = {sComponentName = "TMP_Text"},
txt_des = {sComponentName = "TMP_Text"}
txt_des = {sComponentName = "TMP_Text"},
btnAllClose = {
sComponentName = "UIButton",
callback = "OnBtnClick_Close"
}
}
TowerDefenseGuideCtrl._mapEventConfig = {
TowerDefenseGuideCellOnSelected = "OnEvent_CellOnSelected"
}
TowerDefenseGuideCtrl._mapRedDotConfig = {}
local SelectType = {Char = 1, Item = 2}
function TowerDefenseGuideCtrl:Awake()
self.animator = self.gameObject:GetComponent("Animator")
end
function TowerDefenseGuideCtrl:SetData(nActId)
self.animator:Play("t_window_04_t_in")
self._mapNode.anim:Play("t_window_04_t_in")
EventManager.Hit(EventId.TemporaryBlockInput, 0.2)
self.tbCharacterIds = {}
self.tbItemIds = {}
@@ -56,7 +59,7 @@ function TowerDefenseGuideCtrl:SetData(nActId)
self.selectedGridGo = nil
self.TowerDefenseData = PlayerData.Activity:GetActivityDataById(self.nActId)
local forEachFunction = function(config)
if config.ActivityId == nActId then
if config.ActivityId == nActId and config.IsShow then
if config.GuideType == GameEnum.TowerDefGuideType.Character then
table.insert(self.tbCharacterIds, config.Id)
elseif config.GuideType == GameEnum.TowerDefGuideType.Item then
@@ -113,6 +116,13 @@ function TowerDefenseGuideCtrl:CreateChar()
local icon = go.transform:Find("btn_grid/AnimRoot/img_icon/icon_char"):GetComponent("Image")
local lock = go.transform:Find("btn_grid/AnimRoot/img_icon/bg_Lock")
local txt_name = go.transform:Find("btn_grid/AnimRoot/img_icon/txt_name"):GetComponent("TMP_Text")
local img_new = go.transform:Find("btn_grid/AnimRoot/img_icon/img_New"):GetComponent("Image")
if guide_config.iconPath == "" then
img_new.gameObject:SetActive(false)
else
img_new.gameObject:SetActive(true)
self:SetPngSprite(img_new, iconPath .. guide_config.iconPath)
end
local bUnLock = true
if guide_config ~= nil then
bUnLock = self.TowerDefenseData:IsLevelUnlock(guide_config.LevelId) and self.TowerDefenseData:IsPreLevelPass(guide_config.LevelId)
@@ -156,6 +166,13 @@ function TowerDefenseGuideCtrl:CreateItem()
local icon = go.transform:Find("btn_grid/AnimRoot/img_icon"):GetComponent("Image")
local lock = go.transform:Find("btn_grid/AnimRoot/bg_Lock")
local txt_lock = go.transform:Find("btn_grid/AnimRoot/txt_lock"):GetComponent("TMP_Text")
local img_new = go.transform:Find("btn_grid/AnimRoot/img_New"):GetComponent("Image")
if guide_config.iconPath == "" then
img_new.gameObject:SetActive(false)
else
img_new.gameObject:SetActive(true)
self:SetPngSprite(img_new, iconPath .. guide_config.iconPath)
end
local bUnLock = true
if guide_config ~= nil then
bUnLock = self.TowerDefenseData:IsLevelUnlock(guide_config.LevelId) and self.TowerDefenseData:IsPreLevelPass(guide_config.LevelId)
@@ -287,7 +304,7 @@ function TowerDefenseGuideCtrl:UpdateDetail()
end
function TowerDefenseGuideCtrl:OnBtnClick_Close()
EventManager.Hit(EventId.TemporaryBlockInput, 0.2)
self.animator:Play("t_window_04_t_out")
self._mapNode.anim:Play("t_window_04_t_out")
self:AddTimer(1, 0.2, function()
self.selectedGridGo = nil
EventManager.Hit("CloseTowerDefenseGuidePanel")
@@ -70,7 +70,7 @@ TowerDefenseLevelDetailCtrl._mapNodeConfig = {
team_character = {nCount = 6},
special_item = {},
animator = {
sNodeName = "----SafeAreaRoot---",
sNodeName = "----SafeAreaRoot_Detail---",
sComponentName = "Animator"
},
teamCtrl = {
@@ -393,7 +393,46 @@ function TowerDefenseLevelDetailCtrl:OnBtnClick_Reward(btn, index)
end
end
function TowerDefenseLevelDetailCtrl:OnBtnClick_Go()
self:GoToPlay()
if self.levelConfig.Skip then
local CancelCallback = function()
local tbChar = {}
local itemId = 0
if self.nItemGuideId ~= 0 then
local itemGuidConfig = ConfigTable.GetData("TowerDefenseGuide", self.nItemGuideId)
if itemGuidConfig ~= nil then
itemId = itemGuidConfig.ObjectId
end
end
for index, id in ipairs(self.tbCharGuideId) do
local charGuidConfig = ConfigTable.GetData("TowerDefenseGuide", id)
if charGuidConfig ~= nil then
table.insert(tbChar, charGuidConfig.ObjectId)
end
end
local cb = function()
self:UpdateQuestInfo()
self:UpdateItem()
end
self.TowerDefenseData:SkipLevel(self.nLevelId, tbChar, itemId, cb)
end
local ConfirmCallback = function()
self:GoToPlay()
end
local data = {
nType = AllEnum.MessageBox.Confirm,
sTitle = ConfigTable.GetUIText("TowerDef_SkipTitle"),
sContent = ConfigTable.GetUIText("TowerDef_SkipTips"),
sContentSub = orderedFormat(ConfigTable.GetUIText("TowerDef_SkipSubTips"), self.levelConfig.LevelName),
sConfirm = ConfigTable.GetUIText("TowerDef_Skip_Go"),
sCancel = ConfigTable.GetUIText("TowerDef_Skip"),
callbackConfirm = ConfirmCallback,
callbackCancel = CancelCallback,
bCloseNoHandler = true
}
EventManager.Hit(EventId.OpenMessageBox, data)
else
self:GoToPlay()
end
end
function TowerDefenseLevelDetailCtrl:OnBtnClick_EditorTeam()
if self.bInEditorPanel then
@@ -183,10 +183,7 @@ function TowerDefenseMonsterInfoCtrl:RefreshMonsterInfo(nMonsterId)
end
NovaAPI.SetTMPText(self._mapNode.txtStory, monsterManual.Desc)
LayoutRebuilder.ForceRebuildLayoutImmediate(self._mapNode.goStory)
local eets = {}
if monsterAdjust.EET ~= GameEnum.elementType.NONE then
table.insert(eets, monsterAdjust.EET)
end
local eets = monsterAdjust.EET
self:RefreshAbility(monsterManual)
LayoutRebuilder.ForceRebuildLayoutImmediate(self._mapNode.rtContent)
end
@@ -89,7 +89,7 @@ function TowerDefenseQuestCtrl:SetData(nActId, bIsSubPanel)
self.tbGroup = {}
self.tbGroupConfig = {}
local foreachQuestGroup = function(data)
if data.ActivityId then
if data.ActivityId == self.nActId then
table.insert(self.tbGroup, data.Id)
self.tbGroupConfig[data.Id] = data
end
@@ -1,16 +1,23 @@
local TowerDefenseResultCtrl = class("TowerDefenseResultCtrl", BaseCtrl)
local WwiseManger = CS.WwiseAudioManager.Instance
TowerDefenseResultCtrl._mapNodeConfig = {
txt_level = {sComponentName = "TMP_Text"},
db_target = {nCount = 3},
ButtonClose = {
sComponentName = "UIButton",
callback = "OnBtnClick_Close"
},
imgBlurredBg = {},
SuccessRoot = {},
txt_level = {sComponentName = "TMP_Text"},
db_target = {nCount = 3},
Mask = {
sComponentName = "CanvasGroup"
}
},
FailRoot = {},
Mask_fail = {
sComponentName = "CanvasGroup"
},
txt_level_fail = {sComponentName = "TMP_Text"},
db_target_fail = {nCount = 3}
}
TowerDefenseResultCtrl._mapEventConfig = {}
TowerDefenseResultCtrl._mapRedDotConfig = {}
@@ -23,6 +30,8 @@ function TowerDefenseResultCtrl:Awake()
self.callback = param[4]
self.msgData = param[5]
end
self._mapNode.SuccessRoot:SetActive(self.bResult)
self._mapNode.FailRoot:SetActive(not self.bResult)
self:SetContent()
self.bProcessingClose = false
end
@@ -30,31 +39,44 @@ function TowerDefenseResultCtrl:SetContent()
EventManager.Hit(EventId.TemporaryBlockInput, 1)
WwiseManger:PostEvent("ui_loading_combatSFX_mute", nil, false)
WwiseManger:PlaySound("ui_roguelike_victory")
for _, target in pairs(self._mapNode.db_target) do
target:SetActive(false)
end
NovaAPI.SetTMPText(self._mapNode.txt_level, self.sLevelName)
for i = 1, math.min(#self.tbTarget, #self._mapNode.db_target) do
local target = self._mapNode.db_target[i]
local star = target.transform:Find("star_get")
local txt_target = target.transform:Find("txt_target")
star.gameObject:SetActive(self.tbTarget[i].bResult)
NovaAPI.SetTMPText(txt_target:GetComponent("TMP_Text"), self.tbTarget[i].sTargetDes)
target:SetActive(true)
end
self:AddTimer(1, 0.5, function()
local mapReward = PlayerData.Item:ProcessRewardChangeInfo(self.msgData)
local tbItem = {}
for _, v in ipairs(mapReward.tbReward) do
local item = {
Tid = v.id,
Qty = v.count,
rewardType = AllEnum.RewardType.First
}
table.insert(tbItem, item)
if self.bResult then
for _, target in pairs(self._mapNode.db_target) do
target:SetActive(false)
end
UTILS.OpenReceiveByDisplayItem(tbItem, self.msgData)
end, true, true, true)
NovaAPI.SetTMPText(self._mapNode.txt_level, self.sLevelName)
for i = 1, math.min(#self.tbTarget, #self._mapNode.db_target) do
local target = self._mapNode.db_target[i]
local star = target.transform:Find("star_get")
local txt_target = target.transform:Find("txt_target")
star.gameObject:SetActive(self.tbTarget[i].bResult)
NovaAPI.SetTMPText(txt_target:GetComponent("TMP_Text"), self.tbTarget[i].sTargetDes)
target:SetActive(true)
end
self:AddTimer(1, 0.5, function()
local mapReward = PlayerData.Item:ProcessRewardChangeInfo(self.msgData)
local tbItem = {}
for _, v in ipairs(mapReward.tbReward) do
local item = {
Tid = v.id,
Qty = v.count,
rewardType = AllEnum.RewardType.First
}
table.insert(tbItem, item)
end
UTILS.OpenReceiveByDisplayItem(tbItem, self.msgData)
end, true, true, true)
else
for _, target in pairs(self._mapNode.db_target_fail) do
target:SetActive(false)
end
NovaAPI.SetTMPText(self._mapNode.txt_level_fail, self.sLevelName)
for i = 1, math.min(#self.tbTarget, #self._mapNode.db_target_fail) do
local target = self._mapNode.db_target_fail[i]
local txt_target = target.transform:Find("txt_target")
NovaAPI.SetTMPText(txt_target:GetComponent("TMP_Text"), self.tbTarget[i].sTargetDes)
target:SetActive(true)
end
end
end
function TowerDefenseResultCtrl:OnBtnClick_Close()
if self.bProcessingClose then
@@ -70,11 +92,17 @@ function TowerDefenseResultCtrl:OnBtnClick_Close()
PlayerData.Base:OnBackToMainMenuModule()
else
EventManager.Hit(EventId.ClosePanel, PanelId.TowerDefensePanel)
NovaAPI.SetCanvasGroupAlpha(self._mapNode.Mask, 0)
self._mapNode.Mask.gameObject:SetActive(true)
local mask
if self.bResult then
mask = self._mapNode.Mask
else
mask = self._mapNode.Mask_fail
end
NovaAPI.SetCanvasGroupAlpha(mask, 0)
mask.gameObject:SetActive(true)
EventManager.Hit(EventId.TemporaryBlockInput, 0.5)
local sequence = DOTween.Sequence()
sequence:Append(self._mapNode.Mask:DOFade(1, 0.5):SetUpdate(true))
sequence:Append(mask:DOFade(1, 0.5):SetUpdate(true))
sequence:AppendCallback(function()
CS.AdventureModuleHelper.LevelStateChanged(true, 0, false)
end)
@@ -1,6 +1,7 @@
local TowerDefenseSelectCtrl = class("TowerDefenseSelectCtrl", BaseCtrl)
local barMinX = -365
local barMaxX = 0
local scrollType = {levelIndex = 1, pos = 2}
TowerDefenseSelectCtrl._mapNodeConfig = {
TopBar = {
sNodeName = "TopBarPanel",
@@ -105,11 +106,35 @@ function TowerDefenseSelectCtrl:Awake()
self._mapNode.blur.gameObject:SetActive(false)
self._mapNode.animator:Play("TowerDefenseSelectBg_in")
self.nSelectedTabIndex = 0
self.scrollType = scrollType.pos
self.nlevelId = 0
self.nScrollIndex = 0
self.scrollPos = 1
end
function TowerDefenseSelectCtrl:OnEnable()
if self.nSelectedTabIndex == 0 then
self.nSelectedTabIndex = 1
end
if self.nlevelId ~= 0 then
local tempData = self.TowerDefenseData:GetTempData()
if tempData ~= nil and tempData.nLevelId == self.nlevelId and tempData.bResult then
for index, value in ipairs(self.tbLevel) do
if value.nLevelId == self.nlevelId then
self.nScrollIndex = index
break
end
end
if self.nScrollIndex == #self.tbLevel and self.nSelectedTabIndex == 1 then
self.nSelectedTabIndex = 2
self.nScrollIndex = 0
self.scrollType = scrollType.pos
self.scrollPos = 1
else
self.scrollType = scrollType.levelIndex
end
self.TowerDefenseData:ClearTempData()
end
end
self:Init()
end
function TowerDefenseSelectCtrl:OnDisable()
@@ -162,8 +187,17 @@ function TowerDefenseSelectCtrl:UpdateLevel()
self:UnbindCtrlByNode(objCtrl)
self.tbGridCtrl[nInstanceId] = nil
end
self._mapNode.loopSv:SetAnim(0.1)
self._mapNode.loopSv:Init(#self.tbLevel, self, self.OnRefreshGrid)
if self.scrollType == scrollType.levelIndex then
self._mapNode.loopSv:SetScrollGridPos(self.nScrollIndex, 0)
elseif self.scrollType == scrollType.pos then
self._mapNode.loopSv:SetScrollPos(self.scrollPos, 0)
end
local wait = function()
coroutine.yield(CS.UnityEngine.WaitForEndOfFrame())
self:PlayGridAnim()
end
cs_coroutine.start(wait)
end
function TowerDefenseSelectCtrl:OnRefreshGrid(goGrid, gridIndex)
local nIndex = gridIndex + 1
@@ -173,6 +207,27 @@ function TowerDefenseSelectCtrl:OnRefreshGrid(goGrid, gridIndex)
end
self.tbGridCtrl[nInstanceId]:SetData(self.nActId, self.tbLevel[nIndex])
end
function TowerDefenseSelectCtrl:PlayGridAnim()
local listInUse = {}
listInUse = self._mapNode.loopSv:GetInUseGridIndex()
local tbGridInUse = {}
for i = 0, listInUse.Count - 1 do
table.insert(tbGridInUse, listInUse[i])
end
for k, v in ipairs(tbGridInUse) do
local goGrid = self._mapNode.loopSv.transform:Find("Viewport/Content/" .. v)
local animRoot = goGrid:GetComponent("Animator")
local delayTime = (k - 1) * 0.1
animRoot:Play("ready")
if 0 < delayTime then
self:AddTimer(1, delayTime, function()
animRoot:Play("go")
end, true, true, true)
else
animRoot:Play("go")
end
end
end
function TowerDefenseSelectCtrl:OnBtnClick_Guide()
self._mapNode.blur.gameObject:SetActive(true)
self._mapNode.guidPanel.gameObject:SetActive(true)
@@ -182,6 +237,9 @@ function TowerDefenseSelectCtrl:OnBtnClick_LevelTab1()
if self.nSelectedTabIndex == 1 then
return
end
self.scrollPos = 1
self.nlevelId = 0
self.scrollType = self.scrollPos
self.TowerDefenseData:RefreshRedDotbyTab(self.nSelectedTabIndex)
self.nSelectedTabIndex = 1
self:SetTabUI()
@@ -191,6 +249,9 @@ function TowerDefenseSelectCtrl:OnBtnClick_LevelTab2()
if self.nSelectedTabIndex == 2 then
return
end
self.scrollPos = 1
self.nlevelId = 0
self.scrollType = self.scrollPos
self.TowerDefenseData:RefreshRedDotbyTab(self.nSelectedTabIndex)
self.nSelectedTabIndex = 2
self:SetTabUI()
@@ -214,6 +275,8 @@ function TowerDefenseSelectCtrl:OnEvent_LevelSelected(nLevelId)
if not self.TowerDefenseData:IsPreLevelPass(nLevelId) then
return
end
self.scrollPos = self._mapNode.loopSv:GetScrollPos()
self.nlevelId = nLevelId
self.TowerDefenseData:EnterLevelSelect(nLevelId)
EventManager.Hit(EventId.OpenPanel, PanelId.TowerDefenseLevelDetailPanel, self.nActId, nLevelId)
end
@@ -16,16 +16,18 @@ TowerDefenseTeamCtrl._mapNodeConfig = {
sComponentName = "TMP_Text",
sLanguageId = "TowerDef_TeamEditor_Char"
},
character_loopSv = {
sComponentName = "LoopScrollView"
char_teamContent = {
sComponentName = "RectTransform"
},
char_cell = {},
txt_sv_item_title = {
sComponentName = "TMP_Text",
sLanguageId = "TowerDef_TeamEditor_Item"
},
item_loopSv = {
sComponentName = "LoopScrollView"
item_teamContent = {
sComponentName = "RectTransform"
},
item_cell = {},
txt_guide = {
sComponentName = "TMP_Text",
sLanguageId = "TowerDef_Guide"
@@ -55,8 +57,14 @@ function TowerDefenseTeamCtrl:OnDisable()
self.tbGridCtrl[nInstanceId] = nil
end
self.tbGridCtrl = {}
delChildren(self._mapNode.char_teamContent.transform)
delChildren(self._mapNode.item_teamContent.transform)
end
function TowerDefenseTeamCtrl:SetData(nActId, nLevelId, tbChracter, nItemId)
for nInstanceId, objCtrl in pairs(self.tbGridCtrl) do
self:UnbindCtrlByNode(objCtrl)
self.tbGridCtrl[nInstanceId] = nil
end
self.tbGridCtrl = {}
self.nActId = nActId
self.tbSelectedCharGuideIds = tbChracter
@@ -69,52 +77,77 @@ function TowerDefenseTeamCtrl:SetData(nActId, nLevelId, tbChracter, nItemId)
self.tbCharGuideIds = {}
self.tbItemIds = {}
local forEachFunction = function(config)
if config.ActivityId == nActId and self.TowerDefenseData:IsLevelUnlock(config.LevelId) and self.TowerDefenseData:IsPreLevelPass(config.LevelId) then
if config.ActivityId == nActId and config.IsShow == true and self.TowerDefenseData:IsLevelUnlock(config.LevelId) and self.TowerDefenseData:IsPreLevelPass(config.LevelId) then
if config.GuideType == GameEnum.TowerDefGuideType.Character then
table.insert(self.tbCharGuideIds, config.Id)
if #floorConfig.CharPoolGroup == 0 then
table.insert(self.tbCharGuideIds, config.Id)
elseif 0 < table.indexof(floorConfig.CharPoolGroup, config.ObjectId) then
table.insert(self.tbCharGuideIds, config.Id)
end
elseif config.GuideType == GameEnum.TowerDefGuideType.Item then
table.insert(self.tbItemIds, config.Id)
end
end
end
ForEachTableLine(DataTable.TowerDefenseGuide, forEachFunction)
self._mapNode.character_loopSv:Init(#self.tbCharGuideIds, self, self.OnRefreshGrid_Character, self.OnCharacterGridBtnClick)
self._mapNode.item_loopSv:Init(#self.tbItemIds, self, self.OnRefreshGrid_Item, self.OnItemGridBtnClick)
self:CreateChar()
self:CreateItem()
end
function TowerDefenseTeamCtrl:OnRefreshGrid_Character(goGrid, gridIndex)
local nIndex = gridIndex + 1
local nInstanceId = goGrid:GetInstanceID()
if not self.tbGridCtrl[nInstanceId] then
self.tbGridCtrl[nInstanceId] = self:BindCtrlByNode(goGrid, "Game.UI.TowerDefense.TowerDefenseTeamCharCtrl")
function TowerDefenseTeamCtrl:CreateChar()
delChildren(self._mapNode.char_teamContent.transform)
for i = 1, #self.tbCharGuideIds do
do
local go = instantiate(self._mapNode.char_cell, self._mapNode.char_teamContent.transform)
local index = i
local nInstanceId = go:GetInstanceID()
if not self.tbGridCtrl[nInstanceId] then
self.tbGridCtrl[nInstanceId] = self:BindCtrlByNode(go, "Game.UI.TowerDefense.TowerDefenseTeamCharCtrl")
end
local charIndex = table.indexof(self.tbSelectedCharGuideIds, self.tbCharGuideIds[index])
self.tbGridCtrl[nInstanceId]:SetData(self.tbCharGuideIds[index], charIndex)
local btn = go:GetComponent("UIButton")
btn.onClick:AddListener(function()
self:OnCharacterGridBtnClick(index)
end)
go:SetActive(true)
end
end
local charIndex = table.indexof(self.tbSelectedCharGuideIds, self.tbCharGuideIds[nIndex])
self.tbGridCtrl[nInstanceId]:SetData(self.tbCharGuideIds[nIndex], charIndex)
end
function TowerDefenseTeamCtrl:OnRefreshGrid_Item(goGrid, gridIndex)
local nIndex = gridIndex + 1
local icon = goGrid.transform:Find("btn_grid/AnimRoot/img_icon")
local guideConfig = ConfigTable.GetData("TowerDefenseGuide", self.tbItemIds[nIndex])
if guideConfig == nil then
return
function TowerDefenseTeamCtrl:CreateItem()
delChildren(self._mapNode.item_teamContent.transform)
for i = 1, #self.tbItemIds do
do
local go = instantiate(self._mapNode.item_cell, self._mapNode.item_teamContent.transform)
local nIndex = i
local icon = go.transform:Find("AnimRoot/img_icon")
local guideConfig = ConfigTable.GetData("TowerDefenseGuide", self.tbItemIds[nIndex])
if guideConfig == nil then
return
end
local itemConfig = ConfigTable.GetData("TowerDefenseItem", guideConfig.ObjectId)
if itemConfig == nil then
return
end
if itemConfig.CardIcon ~= "" then
self:SetPngSprite(icon.gameObject:GetComponent("Image"), itemConfig.CardIcon)
end
local selected = go.transform:Find("AnimRoot/go_select")
selected.gameObject:SetActive(self.nItemId == self.tbItemIds[nIndex])
local go_selectMask = go.transform:Find("AnimRoot/go_selectMask")
go_selectMask.gameObject:SetActive(self.nItemId == self.tbItemIds[nIndex])
local selected_tips = go.transform:Find("AnimRoot/selected_tips")
selected_tips.gameObject:SetActive(self.nItemId == self.tbItemIds[nIndex])
local txt_selected = go.transform:Find("AnimRoot/selected_tips/txt_selected")
NovaAPI:SetTMPText(txt_selected:GetComponent("TMP_Text"), ConfigTable.GetUIText("TowerDef_TeamEditor_Selected"))
local btn = go:GetComponent("UIButton")
btn.onClick:AddListener(function()
self:OnItemGridBtnClick(go, nIndex)
end)
go:SetActive(true)
end
end
local itemConfig = ConfigTable.GetData("TowerDefenseItem", guideConfig.ObjectId)
if itemConfig == nil then
return
end
if itemConfig.CardIcon ~= "" then
self:SetPngSprite(icon.gameObject:GetComponent("Image"), itemConfig.CardIcon)
end
local selected = goGrid.transform:Find("btn_grid/AnimRoot/go_select")
selected.gameObject:SetActive(self.nItemId == self.tbItemIds[nIndex])
local go_selectMask = goGrid.transform:Find("btn_grid/AnimRoot/go_selectMask")
go_selectMask.gameObject:SetActive(self.nItemId == self.tbItemIds[nIndex])
local selected_tips = goGrid.transform:Find("btn_grid/AnimRoot/selected_tips")
selected_tips.gameObject:SetActive(self.nItemId == self.tbItemIds[nIndex])
local txt_selected = goGrid.transform:Find("btn_grid/AnimRoot/selected_tips/txt_selected")
NovaAPI:SetTMPText(txt_selected:GetComponent("TMP_Text"), ConfigTable.GetUIText("TowerDef_TeamEditor_Selected"))
end
function TowerDefenseTeamCtrl:OnCharacterGridBtnClick(goGrid, gridIndex)
local nIndex = gridIndex + 1
function TowerDefenseTeamCtrl:OnCharacterGridBtnClick(nIndex)
local charIndex = table.indexof(self.tbSelectedCharGuideIds, self.tbCharGuideIds[nIndex])
if 0 < charIndex then
table.remove(self.tbSelectedCharGuideIds, charIndex)
@@ -126,8 +159,7 @@ function TowerDefenseTeamCtrl:OnCharacterGridBtnClick(goGrid, gridIndex)
EventManager.Hit("TowerDefense_CharUpdate", self.tbSelectedCharGuideIds)
end
end
function TowerDefenseTeamCtrl:OnItemGridBtnClick(goGrid, gridIndex)
local nIndex = gridIndex + 1
function TowerDefenseTeamCtrl:OnItemGridBtnClick(goGrid, nIndex)
local selectItemId = self.tbItemIds[nIndex]
if self.nSelectedItemId == selectItemId then
local selected = goGrid.transform:Find("btn_grid/AnimRoot/selected")
@@ -34,6 +34,9 @@ function TowerDefTipsCtrl:FadeOut()
end
function TowerDefTipsCtrl:OnEnable()
self:EnableGamepadUI(self._mapNode.btnShortcutClose)
self.sortingOrder = NovaAPI.GetCanvasSortingOrder(self.gameObject:GetComponent("Canvas"))
NovaAPI.SetComponentEnableByName(self.rtTarget.gameObject, "TopGridCanvas", true)
NovaAPI.SetTopGridCanvasSorting(self.rtTarget.gameObject, self.sortingOrder)
NovaAPI.SetTMPText(self._mapNode.txtName, self.name)
NovaAPI.SetTMPText(self._mapNode.txtDesc, self.des)
self._mapNode.rtContent.gameObject:SetActive(false)
@@ -53,6 +56,7 @@ end
function TowerDefTipsCtrl:OnRelease()
end
function TowerDefTipsCtrl:OnBtnClick_ClosePanel(btn)
NovaAPI.SetComponentEnableByName(self.rtTarget.gameObject, "TopGridCanvas", false)
EventManager.Hit(EventId.ClosePanel, PanelId.TowerDefenseTipsPanel)
end
return TowerDefTipsCtrl