Update - 1.7.0.88

EN: 1.7.0.88
CN: 1.7.0.90
JP: 1.7.0.91
KR: 1.7.0.94
This commit is contained in:
SL1900
2026-02-24 22:00:00 +09:00
parent d0c0a3870c
commit 86d82306fe
666 changed files with 920582 additions and 7496 deletions
@@ -4,25 +4,23 @@ PenguinCardActCtrl._mapNodeConfig = {
svItem = {
sComponentName = "LoopScrollView"
},
txt_time = {sComponentName = "TMP_Text"},
txt_des = {
txtTime = {sComponentName = "TMP_Text"},
txtBtnDetail = {
sComponentName = "TMP_Text",
sLanguageId = "Activity_Btn_Detail"
},
btn_des = {
btnDetail = {
sComponentName = "UIButton",
callback = "OnBtnClick_Detail"
},
txt_go = {
txtBtnGo = {
sComponentName = "TMP_Text",
sLanguageId = "Activity_TowerAllOpen_Go"
sLanguageId = "PenguinCard_Activity_Goto"
},
btn_go = {
btnGo = {
sComponentName = "UIButton",
callback = "OnBtnClick_Go"
},
go_nextLevel = {},
txt_nextLevelTime = {sComponentName = "TMP_Text"},
txtRewardTitle = {
sComponentName = "TMP_Text",
sLanguageId = "MessageBox_Reward"
@@ -34,7 +32,7 @@ function PenguinCardActCtrl:Awake()
end
function PenguinCardActCtrl:RefreshRemainTime()
if self.actData.actCfg.EndType == GameEnum.activityEndType.NoLimit then
self._mapNode.txt_time.transform.parent.gameObject:SetActive(false)
self._mapNode.txtTime.transform.parent.gameObject:SetActive(false)
else
local endTime = self.actData:GetActEndTime()
local curTime = CS.ClientManager.Instance.serverTimeStamp
@@ -51,17 +49,7 @@ function PenguinCardActCtrl:RefreshRemainTime()
})
end
local sTimeStr = self:GetTimeText(remainTime)
NovaAPI.SetTMPText(self._mapNode.txt_time, orderedFormat(ConfigTable.GetUIText("PerActivity_Remain_Time") or "", sTimeStr))
end
local nextLevelTime = self.actData:GetNextLevelUnlockTime()
if nextLevelTime == 0 then
self._mapNode.go_nextLevel:SetActive(false)
else
self._mapNode.go_nextLevel:SetActive(true)
local curTime = CS.ClientManager.Instance.serverTimeStamp
local nextLevelRemainTime = nextLevelTime - curTime
local sNextLevelTime = self:GetTimeText(nextLevelRemainTime)
NovaAPI.SetTMPText(self._mapNode.txt_nextLevelTime, orderedFormat(ConfigTable.GetUIText("TowerDef_LevelPreTime") or "", sNextLevelTime))
NovaAPI.SetTMPText(self._mapNode.txtTime, orderedFormat(ConfigTable.GetUIText("PerActivity_Remain_Time") or "", sTimeStr))
end
end
function PenguinCardActCtrl:GetTimeText(remainTime)
@@ -107,7 +95,7 @@ end
function PenguinCardActCtrl:OnGridBtnClick(go, nIndex)
local nDataIndex = nIndex + 1
local itemId = self.tbReward[nDataIndex]
UTILS.ClickItemGridWithTips(itemId, go.transform:Find("btnGrid"), true, false, false)
UTILS.ClickItemGridWithTips(itemId, go.transform:Find("btnGrid"), true, true, false)
end
function PenguinCardActCtrl:InitActData(actData)
self.actData = actData
@@ -1,9 +1,10 @@
local ThrowGiftItemSelectCtrl = class("ThrowGiftItemSelectCtrl", BaseCtrl)
local WwiseAudioMgr = CS.WwiseAudioManager.Instance
local GamepadUIManager = require("GameCore.Module.GamepadUIManager")
ThrowGiftItemSelectCtrl._mapNodeConfig = {
btnItemSelect = {
nCount = 2,
sComponentName = "UIButton",
sComponentName = "NaviButton",
callback = "OnBtnClick_Item"
},
btnItemSelectCtrl = {
@@ -14,10 +15,12 @@ ThrowGiftItemSelectCtrl._mapNodeConfig = {
rtPos = {nCount = 2}
}
ThrowGiftItemSelectCtrl._mapEventConfig = {
ThrowGiftItemSelectConfirmClick = "OnEvent_ThrowGiftItemSelectConfirmClick"
ThrowGiftItemSelectConfirmClick = "OnEvent_ThrowGiftItemSelectConfirmClick",
GamepadUIChange = "OnEvent_GamepadUIChange"
}
ThrowGiftItemSelectCtrl._mapRedDotConfig = {}
function ThrowGiftItemSelectCtrl:Awake()
self.tbGamepadUINode = self:GetGamepadUINode()
end
function ThrowGiftItemSelectCtrl:FadeIn()
end
@@ -29,14 +32,23 @@ function ThrowGiftItemSelectCtrl:OnEnable()
self.tbOriginPos = {}
self.tbOriginPos[1] = self._mapNode.btnItemSelectCtrl[1].gameObject.transform.position
self.tbOriginPos[2] = self._mapNode.btnItemSelectCtrl[2].gameObject.transform.position
self.handler = {}
for k, v in ipairs(self._mapNode.btnItemSelect) do
self.handler[k] = ui_handler(self, self.OnBtnSelect_Item, v, k)
v.onSelect:AddListener(self.handler[k])
end
end
function ThrowGiftItemSelectCtrl:OnDisable()
for k, v in ipairs(self._mapNode.btnItemSelect) do
v.onSelect:RemoveListener(self.handler[k])
end
end
function ThrowGiftItemSelectCtrl:OnDestroy()
end
function ThrowGiftItemSelectCtrl:OnRelease()
end
function ThrowGiftItemSelectCtrl:OpenPanel(tbItem, callback, curIdx)
GamepadUIManager.EnableGamepadUI("ThrowGiftItemSelectCtrl", self.tbGamepadUINode)
self.curPosIdx = curIdx
self.gameObject:SetActive(true)
self.callback = callback
@@ -50,7 +62,25 @@ function ThrowGiftItemSelectCtrl:OpenPanel(tbItem, callback, curIdx)
self._mapNode.btnItemSelectCtrl[2].gameObject.transform.position = self.tbOriginPos[2]
self._mapNode.btnItemSelectCtrl[1].gameObject.transform.localEulerAngles = Vector3(0, 0, 0)
self._mapNode.btnItemSelectCtrl[2].gameObject.transform.localEulerAngles = Vector3(0, 0, 0)
self._mapNode.btnItemSelectCtrl[1].gameObject:SetActive(true)
self._mapNode.btnItemSelectCtrl[2].gameObject:SetActive(true)
WwiseAudioMgr:PostEvent("Mode_Present_intensify")
self:ResetSelect(self._mapNode.btnItemSelect)
end
function ThrowGiftItemSelectCtrl:ResetSelect(tbUI)
self.curIdx = 0
GamepadUIManager.SetNavigation(tbUI)
local animTime = 0.4
self:AddTimer(1, animTime, function()
if self.curIdx == 0 then
local nSelect = 1
GamepadUIManager.ClearSelectedUI()
GamepadUIManager.SetSelectedUI(self._mapNode.btnItemSelect[nSelect].gameObject)
if GamepadUIManager.GetCurUIType() == AllEnum.GamepadUIType.Mouse then
self:OnBtnClick_Item(self._mapNode.btnItemSelect[nSelect].gameObject, nSelect)
end
end
end, true, true, true)
end
function ThrowGiftItemSelectCtrl:OnBtnClick_Item(btn, nIdx)
WwiseAudioMgr:PostEvent("Mode_Present_intensify_choose")
@@ -64,6 +94,12 @@ function ThrowGiftItemSelectCtrl:OnBtnClick_Item(btn, nIdx)
self._mapNode.btnItemSelectCtrl[2]:SetSelect(nIdx == 2)
self.curIdx = nIdx
end
function ThrowGiftItemSelectCtrl:OnBtnSelect_Item(btn, nIndex)
local nUIType = GamepadUIManager.GetCurUIType()
if nUIType ~= AllEnum.GamepadUIType.Other and nUIType ~= AllEnum.GamepadUIType.Mouse then
self:OnBtnClick_Item(btn, nIndex)
end
end
function ThrowGiftItemSelectCtrl:OnEvent_ThrowGiftItemSelectConfirmClick()
if self.bSelected then
return
@@ -77,6 +113,9 @@ function ThrowGiftItemSelectCtrl:OnEvent_ThrowGiftItemSelectConfirmClick()
local endPos = self._mapNode.rtPos[self.curPosIdx].transform.position
local beginPos = self._mapNode.btnItemSelectCtrl[self.curIdx].gameObject.transform.position
local controlPos = Vector3(3, 5, 0)
for i = 1, 2 do
self._mapNode.btnItemSelectCtrl[i].gameObject:SetActive(i == self.curIdx)
end
local wait = function()
local totalMoveTime = 0.3
local moveTime = 0
@@ -86,7 +125,7 @@ function ThrowGiftItemSelectCtrl:OnEvent_ThrowGiftItemSelectConfirmClick()
normalizedTime = moveTime / totalMoveTime
normalizedTime = normalizedTime <= 1 and normalizedTime or 1
local x, y, z = UTILS.GetBezierPointByT(beginPos, controlPos, endPos, normalizedTime)
local angleZ = 100 * normalizedTime * 2
local angleZ = -180 * normalizedTime
self._mapNode.btnItemSelectCtrl[self.curIdx].gameObject.transform.localEulerAngles = Vector3(0, 0, angleZ)
self._mapNode.btnItemSelectCtrl[self.curIdx].gameObject.transform.position = Vector3(x, y, z)
coroutine.yield(CS.UnityEngine.WaitForEndOfFrame())
@@ -95,7 +134,18 @@ function ThrowGiftItemSelectCtrl:OnEvent_ThrowGiftItemSelectConfirmClick()
self.callback(self.curIdx)
end
self.gameObject:SetActive(false)
GamepadUIManager.DisableGamepadUI("ThrowGiftItemSelectCtrl")
end
cs_coroutine.start(wait)
end
function ThrowGiftItemSelectCtrl:OnEvent_GamepadUIChange(sName, nBeforeType, nAfterType)
if sName ~= "ThrowGiftItemSelectCtrl" then
return
end
if nBeforeType == AllEnum.GamepadUIType.Other or nBeforeType == AllEnum.GamepadUIType.Mouse then
local nSelect = self.curIdx ~= 0 and self.curIdx or 1
GamepadUIManager.ClearSelectedUI()
GamepadUIManager.SetSelectedUI(self._mapNode.btnItemSelect[nSelect].gameObject)
end
end
return ThrowGiftItemSelectCtrl
@@ -1,8 +1,11 @@
local ThrowGiftItemSelectGridCtrl = class("ThrowGiftItemSelectGridCtrl", BaseCtrl)
ThrowGiftItemSelectGridCtrl._mapNodeConfig = {
txtBtnConfirm = {sComponentName = "TMP_Text"},
txtBtnConfirm = {
sComponentName = "TMP_Text",
sLanguageId = "ThrowGift_GetCard"
},
btnConfirm = {
sComponentName = "UIButton",
sComponentName = "NaviButton",
callback = "OnBtnClick_Confirm"
},
imgBgSelect = {},
@@ -25,6 +28,7 @@ end
function ThrowGiftItemSelectGridCtrl:OnEnable()
self.Idx = 0
self.animator = self.gameObject:GetComponent("Animator")
self._mapNode.btnConfirm.interactable = false
end
function ThrowGiftItemSelectGridCtrl:OnDisable()
end
@@ -43,12 +47,15 @@ function ThrowGiftItemSelectGridCtrl:Refresh(nItemId)
NovaAPI.SetTMPText(self._mapNode.TMPItemName, mapItemCfgData.Name)
NovaAPI.SetTMPText(self._mapNode.TMPItemDesc, mapItemCfgData.Desc)
self:SetPngSprite(self._mapNode.imgItemIcon, mapItemCfgData.Icon)
self._mapNode.btnConfirm.interactable = false
end
function ThrowGiftItemSelectGridCtrl:SetSelect(bSelect)
if bSelect then
self._mapNode.AnimRoot:Play("btnItemSelect_in")
self._mapNode.btnConfirm.interactable = true
else
self._mapNode.AnimRoot:Play("btnItemSelect_out")
self._mapNode.btnConfirm.interactable = false
end
self._mapNode.imgBgSelect:SetActive(bSelect)
end
+112 -21
View File
@@ -3,6 +3,7 @@ local rootPath = "UI_Activity/%s.prefab"
local GameResourceLoader = require("Game.Common.Resource.GameResourceLoader")
local ResTypeAny = GameResourceLoader.ResType.Any
local WwiseAudioMgr = CS.WwiseAudioManager.Instance
local GamepadUIManager = require("GameCore.Module.GamepadUIManager")
ThrowGiftCtrl._mapNodeConfig = {
TMPLevelScoreTitle = {
sComponentName = "TMP_Text",
@@ -17,15 +18,27 @@ ThrowGiftCtrl._mapNodeConfig = {
},
rtLevelRoot = {sComponentName = "Transform"},
btnPause = {
sComponentName = "UIButton",
callback = "OnBtnClick_Pause"
sComponentName = "NaviButton",
callback = "OnBtnClick_Pause",
sAction = "Map"
},
TMPLevelTime = {sComponentName = "TMP_Text"},
TMPLevelScore = {sComponentName = "TMP_Text"},
TMPTarget = {sComponentName = "TMP_Text"},
imgItemDescBg = {sComponentName = "Animator"},
TMPLevelTimeAdd = {sComponentName = "Animator"},
TMPItemDescBottom = {sComponentName = "TMP_Text"},
imgTimeBg = {},
btnRight = {
sComponentName = "NaviButton",
callback = "OnBtnClick_btnRight",
sAction = "ThrowGiftChangeViewLeft"
},
btnLeft = {
sComponentName = "NaviButton",
callback = "OnBtnClick_btnLeft",
sAction = "ThrowGiftChangeViewRight"
},
rtItemSelect = {
sCtrlName = "Game.UI.Activity.ThrowGifts.ItemSelect.ThrowGiftItemSelectCtrl"
},
@@ -38,15 +51,23 @@ ThrowGiftCtrl._mapNodeConfig = {
sComponentName = "Animator"
},
TMPTargetHint = {sComponentName = "TMP_Text"},
TMPTitleTargetHint = {sComponentName = "TMP_Text"},
TMPTitleTargetHint = {
sComponentName = "TMP_Text",
sLanguageId = "Activity_ThrowGifts_WinCond"
},
rtBuff = {nCount = 4},
rtBuffAnim = {
nCount = 4,
sNodeName = "rtBuff",
sComponentName = "Animator"
},
TMPBuffTime = {nCount = 4, sComponentName = "TMP_Text"},
rtColorAnim = {sComponentName = "Animator"},
FX_Star = {},
FX_Snow = {}
}
ThrowGiftCtrl._mapEventConfig = {
ThrowGift_Exit_OnClick = "OnEvent_ThrowGift_Exit",
ThrowGift_Exit_OnClick = "OnEvent_ThrowGift_Giveup",
ThrowGift_Restart_OnClick = "OnEvent_ThrowGift_Restart",
ThrowGift_Continue_OnClick = "OnEvent_ThrowGift_Continue",
ThrowGiftSettle_Exit = "OnEvent_ThrowGift_Exit",
@@ -58,17 +79,27 @@ ThrowGiftCtrl._mapEventConfig = {
ThrowGiftCtrl._mapRedDotConfig = {}
function ThrowGiftCtrl:Awake()
self.nCurTime = 0
self._mapNode.rtItem[1]:SetAction(1)
self._mapNode.rtItem[2]:SetAction(2)
self.tbGamepadUINode = self:GetGamepadUINode()
GamepadUIManager.AddGamepadUINode("ThrowGiftPanel", self.tbGamepadUINode)
end
function ThrowGiftCtrl:FadeIn()
end
function ThrowGiftCtrl:FadeOut()
end
function ThrowGiftCtrl:OnEnable()
self:SetViewBtn(0)
self._mapNode.rtItemSelect.gameObject:SetActive(false)
self._mapNode.imgItemDescBg.gameObject:SetActive(false)
self._mapNode.rtSettle.gameObject:SetActive(false)
self.nCurItem = {0, 0}
self.tbItemIdx = {0, 0}
self.nCurSelectItemIdx = 0
local param = self:GetPanelParam()
if type(param) == "table" then
self.nLevelId = param[1]
self.nOpenTime = param[2]
end
local mapLevelCfgData = ConfigTable.GetData("ThrowGiftLevel", self.nLevelId)
if mapLevelCfgData == nil then
@@ -85,8 +116,8 @@ function ThrowGiftCtrl:OnEnable()
self.mapRecordItemData = {}
if self.actData ~= nil then
local mapCachedData = self.actData:GetActivityData()
self.mapRecordLevelData = mapCachedData.tbLevels
self.mapRecordItemData = mapCachedData.tbItems
self.mapRecordLevelData = mapCachedData.mapLevels
self.mapRecordItemData = mapCachedData.mapItems
end
local sPath = string.format(rootPath, self.mapFloorCfgData.SceneName)
local goLevelPerfab = GameResourceLoader.LoadAsset(ResTypeAny, Settings.AB_ROOT_PATH .. sPath, typeof(Object))
@@ -114,6 +145,8 @@ function ThrowGiftCtrl:OnEnable()
self._mapNode.rtBuff[2]:SetActive(false)
self._mapNode.rtBuff[3]:SetActive(false)
self._mapNode.rtBuff[4]:SetActive(false)
self._mapNode.TMPLevelTimeAdd.gameObject:SetActive(false)
self:SetFx({})
EventManager.Hit(EventId.SetTransition)
local waitTransion = function()
self._mapNode.rtTargetHint:SetActive(true)
@@ -145,14 +178,28 @@ end
function ThrowGiftCtrl:SetScore(nScore)
NovaAPI.SetTMPText(self._mapNode.TMPLevelScore, tostring(nScore))
end
function ThrowGiftCtrl:AddTimeAnim()
if self.AddTimeAnimTimer ~= nil then
return
end
local callback = function()
self._mapNode.TMPLevelTimeAdd.gameObject:SetActive(false)
self.AddTimeAnimTimer = nil
end
self._mapNode.TMPLevelTimeAdd.gameObject:SetActive(true)
self._mapNode.TMPLevelTimeAdd:Play("TMPLevelTimeAdd_in")
self.AddTimeAnimTimer = self:AddTimer(1, 1, callback, true, true, true)
end
function ThrowGiftCtrl:SetTime(nTime)
if math.floor(nTime) ~= self.nCurTime then
self.nCurTime = math.floor(nTime)
NovaAPI.SetTMPText(self._mapNode.TMPLevelTime, tostring(self.nCurTime))
local m = math.floor(self.nCurTime / 60)
local s = math.floor(self.nCurTime % 60)
NovaAPI.SetTMPText(self._mapNode.TMPLevelTime, string.format("%d:%02d", m, s))
end
end
function ThrowGiftCtrl:SetTarget(nCur)
NovaAPI.SetTMPText(self._mapNode.TMPTarget, string.format(self.mapLevelCfgData.ThrowGiftLevelCondDesc .. "(%d/%d)", nCur, self.mapLevelCfgData.throwGiftLevelParams))
NovaAPI.SetTMPText(self._mapNode.TMPTarget, string.format(self.mapLevelCfgData.ThrowGiftLevelCondDesc .. " (<color=#08d3d4>%d</color>/%d)", nCur, self.mapLevelCfgData.throwGiftLevelParams))
end
function ThrowGiftCtrl:OpenItemSelect(tbItem, selectCallback)
local pos = 1
@@ -160,26 +207,27 @@ function ThrowGiftCtrl:OpenItemSelect(tbItem, selectCallback)
pos = 1
elseif self.nCurItem[2] == 0 or self.nCurItem[2] == nil then
pos = 2
else
pos = 1
elseif self.tbItemIdx[1] > self.tbItemIdx[2] then
pos = 2
end
local callback = function(nIdx)
if selectCallback ~= nil and type(selectCallback) == "function" then
selectCallback(nIdx)
end
self.nCurItem[pos] = tbItem[nIdx]
self.tbItemIdx[pos] = math.max(self.tbItemIdx[1], self.tbItemIdx[2]) + 1
self._mapNode.rtItem[pos]:SetItem(tbItem[nIdx])
self._mapNode.rtItem[pos]:PlayAnim(3)
end
self._mapNode.rtItemSelect:OpenPanel(tbItem, callback, pos)
end
function ThrowGiftCtrl:OpenSettle(bWin, nScore, nGift)
function ThrowGiftCtrl:OpenSettle(bWin, nScore, nGift, nPenguin, bShowPenguin, changeInfo)
self.mapRecordLevelData = {}
self.mapRecordItemData = {}
if self.actData ~= nil then
local mapCachedData = self.actData:GetActivityData()
self.mapRecordLevelData = mapCachedData.tbLevels
self.mapRecordItemData = mapCachedData.tbItems
self.mapRecordLevelData = mapCachedData.mapLevels
self.mapRecordItemData = mapCachedData.mapItems
end
local bShowNextLevel = false
local nNextLevelId = self.nLevelId + 1
@@ -187,7 +235,7 @@ function ThrowGiftCtrl:OpenSettle(bWin, nScore, nGift)
if mapNextCfgData ~= nil then
bShowNextLevel = self:GetLevelUnlock(nNextLevelId)
end
self._mapNode.rtSettle:ShowSettle(bWin, nScore, nGift, bShowNextLevel)
self._mapNode.rtSettle:ShowSettle(bWin, nScore, nGift, nPenguin, bShowPenguin, bShowNextLevel, changeInfo, self.nLevelId)
end
function ThrowGiftCtrl:SetFx(mapState)
local bShowSnow = mapState[103] ~= nil
@@ -204,12 +252,15 @@ function ThrowGiftCtrl:SetFx(mapState)
end
end
function ThrowGiftCtrl:ChangeLevel(nLevelId)
self.levelCtrl:Pause(true)
self:LevelEnd()
local callback = function()
self.levelCtrl:ClearTrackLine()
local goLevelBefore = self.levelCtrl.gameObject
self:UnbindCtrlByNode(self.levelCtrl)
destroy(goLevelBefore)
self.nCurItem = {0, 0}
self.tbItemIdx = {0, 0}
self.nCurSelectItemIdx = 0
self.nLevelId = nLevelId
local mapLevelCfgData = ConfigTable.GetData("ThrowGiftLevel", self.nLevelId)
@@ -227,8 +278,8 @@ function ThrowGiftCtrl:ChangeLevel(nLevelId)
self.mapRecordItemData = {}
if self.actData ~= nil then
local mapCachedData = self.actData:GetActivityData()
self.mapRecordLevelData = mapCachedData.tbLevels
self.mapRecordItemData = mapCachedData.tbItems
self.mapRecordLevelData = mapCachedData.mapLevels
self.mapRecordItemData = mapCachedData.mapItems
end
local sPath = string.format(rootPath, self.mapFloorCfgData.SceneName)
local goLevelPerfab = GameResourceLoader.LoadAsset(ResTypeAny, Settings.AB_ROOT_PATH .. sPath, typeof(Object))
@@ -256,6 +307,8 @@ function ThrowGiftCtrl:ChangeLevel(nLevelId)
self._mapNode.rtBuff[2]:SetActive(false)
self._mapNode.rtBuff[3]:SetActive(false)
self._mapNode.rtBuff[4]:SetActive(false)
self._mapNode.TMPLevelTimeAdd.gameObject:SetActive(false)
self:SetFx({})
self:SetTarget(0, self.mapLevelCfgData.throwGiftLevelParams)
local waitTransion = function()
self._mapNode.rtTargetHint:SetActive(true)
@@ -285,6 +338,14 @@ function ThrowGiftCtrl:GetLevelUnlock(nLevelId)
if mapLevelCfgData == nil then
return false
end
if mapLevelCfgData.DayOpen ~= 0 and mapLevelCfgData.DayOpen ~= nil and self.nOpenTime ~= 0 then
local nServerTimeStamp = CS.ClientManager.Instance.serverTimeStamp
local openTime = CS.ClientManager.Instance:GetNextRefreshTime(self.nOpenTime) - 86400
local remainTime = openTime + mapLevelCfgData.DayOpen * 86400 - nServerTimeStamp
if 0 < remainTime then
return false
end
end
if mapLevelCfgData.PreLevelId ~= 0 then
return self.mapRecordLevelData[mapLevelCfgData.PreLevelId] ~= nil and self.mapRecordLevelData[mapLevelCfgData.PreLevelId].FirstComplete
else
@@ -294,12 +355,16 @@ end
function ThrowGiftCtrl:SetBuffShow(nBuffId, bShow)
if nBuffId == 102 then
self._mapNode.rtBuff[1]:SetActive(bShow)
self._mapNode.rtBuffAnim[1]:Play("rtBuff_in")
elseif nBuffId == 103 then
self._mapNode.rtBuff[2]:SetActive(bShow)
self._mapNode.rtBuffAnim[2]:Play("rtBuff_in")
elseif nBuffId == 104 then
self._mapNode.rtBuff[3]:SetActive(bShow)
self._mapNode.rtBuffAnim[3]:Play("rtBuff_in")
elseif nBuffId == 105 then
self._mapNode.rtBuff[4]:SetActive(bShow)
self._mapNode.rtBuffAnim[4]:Play("rtBuff_in")
end
end
function ThrowGiftCtrl:SetBuffTime(nBuffId, nTime)
@@ -319,18 +384,34 @@ function ThrowGiftCtrl:SetBuffTime(nBuffId, nTime)
NovaAPI.SetTMPText(self._mapNode.TMPBuffTime[4], formatTime(nTime))
end
end
function ThrowGiftCtrl:SetViewBtn(nType)
self._mapNode.btnRight.gameObject:SetActive(nType == 1)
self._mapNode.btnLeft.gameObject:SetActive(nType == 2)
end
function ThrowGiftCtrl:LevelEnd()
self:SetViewBtn(0)
self._mapNode.rtItemSelect.gameObject:SetActive(false)
self._mapNode.imgItemDescBg.gameObject:SetActive(false)
self._mapNode.rtSettle.gameObject:SetActive(false)
end
function ThrowGiftCtrl:OnEvent_ThrowGift_Exit()
if self.levelCtrl ~= nil then
self.levelCtrl:Pause(false)
self._mapNode.PausePanel.gameObject:SetActive(false)
self._mapNode.PausePanel:Close()
end
WwiseAudioMgr:PostEvent("Mode_Present_all_stop")
EventManager.Hit(EventId.ClosePanel, PanelId.ThrowGiftLevelPanel)
end
function ThrowGiftCtrl:OnEvent_ThrowGift_Giveup()
if self.levelCtrl ~= nil then
self.levelCtrl:LevelEnd(false)
self._mapNode.PausePanel:Close()
end
end
function ThrowGiftCtrl:OnEvent_ThrowGift_Restart()
if self.levelCtrl ~= nil then
self.levelCtrl:Pause(false)
self._mapNode.PausePanel.gameObject:SetActive(false)
self._mapNode.PausePanel:Close()
end
WwiseAudioMgr:PostEvent("Mode_Present_all_stop")
self:ChangeLevel(self.nLevelId)
@@ -338,7 +419,7 @@ end
function ThrowGiftCtrl:OnEvent_ThrowGift_Continue()
if self.levelCtrl ~= nil then
self.levelCtrl:Pause(false)
self._mapNode.PausePanel.gameObject:SetActive(false)
self._mapNode.PausePanel:Close()
end
end
function ThrowGiftCtrl:OnEvent_ThrowGiftItemUseBtn(nIdx, nItemId)
@@ -388,9 +469,19 @@ function ThrowGiftCtrl:OnEvent_ThrowGift_NextLevel()
end
end
function ThrowGiftCtrl:OnBtnClick_Pause()
if self.levelCtrl ~= nil then
if self.levelCtrl ~= nil and not self.levelCtrl.bProcessing then
self.levelCtrl:Pause(true)
self._mapNode.PausePanel.gameObject:SetActive(true)
self._mapNode.PausePanel:Open(self.mapFloorCfgData.DictionaryID)
end
end
function ThrowGiftCtrl:OnBtnClick_btnRight()
if self.levelCtrl ~= nil then
self.levelCtrl:ChangeView(true)
end
end
function ThrowGiftCtrl:OnBtnClick_btnLeft()
if self.levelCtrl ~= nil then
self.levelCtrl:ChangeView(false)
end
end
return ThrowGiftCtrl
@@ -18,6 +18,10 @@ ThrowGiftItemDicCtrl._mapNodeConfig = {
sComponentName = "NaviButton",
callback = "OnBtnClick_CloseDesc"
},
txtTips2 = {
sComponentName = "TMP_Text",
sLanguageId = "Tips_Continue"
},
rtCardInfo = {},
rtCardInfoAnim = {sNodeName = "rtCardInfo", sComponentName = "Animator"},
AnimRootItemInfo = {sComponentName = "Animator"},
@@ -34,6 +38,17 @@ end
function ThrowGiftItemDicCtrl:FadeOut()
end
function ThrowGiftItemDicCtrl:OnEnable()
self.nActivityId = 0
local param = self:GetPanelParam()
if type(param) == "table" then
self.nActivityId = param[1]
end
self.actData = PlayerData.Activity:GetActivityDataById(self.nActivityId)
self.mapRecordItemData = {}
if self.actData ~= nil then
local mapCachedData = self.actData:GetActivityData()
self.mapRecordItemData = mapCachedData.mapItems
end
self.tbItem = {}
local forEachItem = function(mapData)
table.insert(self.tbItem, mapData)
@@ -46,7 +61,7 @@ function ThrowGiftItemDicCtrl:OnEnable()
for i = 1, 8 do
if self.tbItem[i] ~= nil then
self._mapNode.btnItem[i].gameObject:SetActive(true)
self._mapNode.btnItemCtrl[i]:SetItem(self.tbItem[i].Id)
self._mapNode.btnItemCtrl[i]:SetItem(self.tbItem[i].Id, self.mapRecordItemData[self.tbItem[i].Id] ~= nil and 0 < self.mapRecordItemData[self.tbItem[i].Id])
else
self._mapNode.btnItem[i].gameObject:SetActive(false)
end
@@ -66,10 +81,12 @@ function ThrowGiftItemDicCtrl:OnBtnClick_Item(btn, nIdx)
if mapConfig == nil then
return
end
NovaAPI.SetTMPText(self._mapNode.TMPItemNameInfo, mapConfig.Name)
NovaAPI.SetTMPText(self._mapNode.TMPItemDescInfo, mapConfig.Desc)
self:SetPngSprite(self._mapNode.imgItemIconInfo, mapConfig.Icon)
self._mapNode.rtCardInfo:SetActive(true)
if self.mapRecordItemData[mapConfig.Id] ~= nil and self.mapRecordItemData[mapConfig.Id] > 0 then
NovaAPI.SetTMPText(self._mapNode.TMPItemNameInfo, mapConfig.Name)
NovaAPI.SetTMPText(self._mapNode.TMPItemDescInfo, mapConfig.Desc)
self:SetPngSprite(self._mapNode.imgItemIconInfo, mapConfig.Icon)
self._mapNode.rtCardInfo:SetActive(true)
end
end
function ThrowGiftItemDicCtrl:OnBtnClick_CloseDesc(btn)
self._mapNode.rtCardInfoAnim:Play("rtCardInfo_out")
@@ -2,7 +2,9 @@ local ThrowGiftItemDicGridCtrl = class("ThrowGiftItemDicGridCtrl", BaseCtrl)
ThrowGiftItemDicGridCtrl._mapNodeConfig = {
imgBgItemNormal = {sComponentName = "Image"},
imgItemIcon = {sComponentName = "Image"},
TMPItemName = {sComponentName = "TMP_Text"}
TMPItemName = {sComponentName = "TMP_Text"},
rtUnlock = {},
rtLock = {}
}
ThrowGiftItemDicGridCtrl._mapEventConfig = {}
ThrowGiftItemDicGridCtrl._mapRedDotConfig = {}
@@ -20,7 +22,7 @@ function ThrowGiftItemDicGridCtrl:OnDestroy()
end
function ThrowGiftItemDicGridCtrl:OnRelease()
end
function ThrowGiftItemDicGridCtrl:SetItem(nItemId)
function ThrowGiftItemDicGridCtrl:SetItem(nItemId, bUnlock)
local mapItemCfgData = ConfigTable.GetData("ThrowGiftItem", nItemId)
if mapItemCfgData == nil then
self.gameObject:SetActive(false)
@@ -29,5 +31,7 @@ function ThrowGiftItemDicGridCtrl:SetItem(nItemId)
self.gameObject:SetActive(true)
NovaAPI.SetTMPText(self._mapNode.TMPItemName, mapItemCfgData.Name)
self:SetPngSprite(self._mapNode.imgItemIcon, mapItemCfgData.Icon)
self._mapNode.rtUnlock:SetActive(bUnlock)
self._mapNode.rtLock:SetActive(not bUnlock)
end
return ThrowGiftItemDicGridCtrl
@@ -1,22 +1,28 @@
local ThrowGiftItemUseBtnCtrl = class("ThrowGiftItemUseBtnCtrl", BaseCtrl)
local WwiseAudioMgr = CS.WwiseAudioManager.Instance
local GamepadUIManager = require("GameCore.Module.GamepadUIManager")
ThrowGiftItemUseBtnCtrl._mapNodeConfig = {
txtBtn = {
sComponentName = "TMP_Text",
sLanguageId = "ThrowGift_UseItem"
},
btnUseItem1 = {
sComponentName = "UIButton",
callback = "OnBtnClick_Confirm"
sComponentName = "NaviButton",
callback = "OnBtnClick_Confirm",
sAction = "ThrowGiftItemConfirm"
},
btnItem1 = {
sComponentName = "UIButton",
sComponentName = "NaviButton",
callback = "OnBtnClick_Item"
},
imgBgItemInuse = {sComponentName = "Image"},
imgItemIconEmpty = {},
imgItemIcon1 = {sComponentName = "Image"},
rtParent = {sComponentName = "Animator"}
rtParent = {sComponentName = "Animator"},
cgParent = {
sNodeName = "rtParent",
sComponentName = "CanvasGroup"
}
}
ThrowGiftItemUseBtnCtrl._mapEventConfig = {}
ThrowGiftItemUseBtnCtrl._mapRedDotConfig = {}
@@ -28,6 +34,7 @@ end
function ThrowGiftItemUseBtnCtrl:FadeOut()
end
function ThrowGiftItemUseBtnCtrl:OnEnable()
self._mapNode.btnUseItem1.interactable = false
end
function ThrowGiftItemUseBtnCtrl:OnDisable()
end
@@ -53,8 +60,10 @@ function ThrowGiftItemUseBtnCtrl:SetItem(nId)
if nId == 0 then
self._mapNode.imgItemIcon1.gameObject:SetActive(false)
self._mapNode.imgItemIconEmpty.gameObject:SetActive(true)
NovaAPI.SetCanvasGroupAlpha(self._mapNode.cgParent, 0.5)
return
end
NovaAPI.SetCanvasGroupAlpha(self._mapNode.cgParent, 1)
self._mapNode.imgItemIcon1.gameObject:SetActive(true)
self._mapNode.imgItemIconEmpty.gameObject:SetActive(false)
local mapItemCfgData = ConfigTable.GetData("ThrowGiftItem", nId)
@@ -68,11 +77,19 @@ end
function ThrowGiftItemUseBtnCtrl:PlayAnim(nType)
if nType == 1 then
self._mapNode.rtParent:Play("rtParent_in")
self._mapNode.btnUseItem1.interactable = true
elseif nType == 2 then
self._mapNode.rtParent:Play("rtParent_out")
self._mapNode.btnUseItem1.interactable = false
else
self._mapNode.rtParent:Play("rtParent_switch")
self._mapNode.btnUseItem1.interactable = false
end
self._mapNode.imgBgItemInuse.gameObject:SetActive(nType == 1)
end
function ThrowGiftItemUseBtnCtrl:SetAction(nIdx)
self._mapNodeConfig.btnItem1.sAction = "ThrowGiftItem" .. nIdx
self.tbGamepadUINode = self:GetGamepadUINode()
GamepadUIManager.AddGamepadUINode("ThrowGiftPanel", self.tbGamepadUINode)
end
return ThrowGiftItemUseBtnCtrl
@@ -0,0 +1,107 @@
local ThrowGiftLevelTrackLineCtrl = class("ThrowGiftLevelTrackLineCtrl", BaseCtrl)
local nHeight = 210
local ConfigData = require("GameCore.Data.ConfigData")
ThrowGiftLevelTrackLineCtrl._mapNodeConfig = {
TemplateDot = {},
rtPool = {sComponentName = "Transform"}
}
ThrowGiftLevelTrackLineCtrl._mapEventConfig = {}
ThrowGiftLevelTrackLineCtrl._mapRedDotConfig = {}
function ThrowGiftLevelTrackLineCtrl:Awake()
self.tbCurDot = {}
self.tbPool = {}
self.nPrevTimer = 0
self.bActive = false
end
function ThrowGiftLevelTrackLineCtrl:FadeIn()
end
function ThrowGiftLevelTrackLineCtrl:FadeOut()
end
function ThrowGiftLevelTrackLineCtrl:OnEnable()
self._mapNode.TemplateDot:SetActive(false)
end
function ThrowGiftLevelTrackLineCtrl:OnDisable()
self:DestroyAll()
end
function ThrowGiftLevelTrackLineCtrl:OnDestroy()
end
function ThrowGiftLevelTrackLineCtrl:OnRelease()
end
function ThrowGiftLevelTrackLineCtrl:DestroyAll()
for _, tbDot in ipairs(self.tbCurDot) do
destroy(tbDot[1].gameObject)
end
for _, rtDot in ipairs(self.tbPool) do
destroy(rtDot.gameObject)
end
self.tbCurDot = {}
self.tbPool = {}
end
function ThrowGiftLevelTrackLineCtrl:Reset()
for _, tbDot in ipairs(self.tbCurDot) do
table.insert(self.tbPool, tbDot[1])
tbDot[1]:SetParent(self._mapNode.rtPool)
end
self.tbCurDot = {}
self.nPrevTimer = 0
end
function ThrowGiftLevelTrackLineCtrl:GetDot()
if #self.tbPool > 0 then
local rtDot = table.remove(self.tbPool)
rtDot:SetParent(self.gameObject.transform)
local goOn = rtDot:Find("on")
table.insert(self.tbCurDot, {rtDot, goOn})
return rtDot
end
local goDot = instantiate(self._mapNode.TemplateDot, self.gameObject.transform)
goDot:SetActive(true)
local rtDot = goDot:GetComponent("RectTransform")
local goOn = rtDot:Find("on")
table.insert(self.tbCurDot, {rtDot, goOn})
return rtDot
end
function ThrowGiftLevelTrackLineCtrl:AddDot(v2Pos, nAngle)
local rtDot = self:GetDot()
rtDot.anchoredPosition = v2Pos
rtDot.localEulerAngles = Vector3(0, 0, nAngle - 90)
end
function ThrowGiftLevelTrackLineCtrl:SetLineActive(nAngle, nSpeed)
local nConfigAngle = self.mapData.Angle
local nConfigSpeed = self.mapData.Speed
local nSpeedRangeMax = nConfigSpeed + self.mapData.SpeedThreshold
local nSpeedRangeMin = nConfigSpeed - self.mapData.SpeedThreshold
local nAngleRangeMax = nConfigAngle + self.mapData.AngleThreshold
local nAngleRangeMin = nConfigAngle - self.mapData.AngleThreshold
local bActive = nAngle >= nAngleRangeMin and nAngle <= nAngleRangeMax and nSpeed >= nSpeedRangeMin and nSpeed <= nSpeedRangeMax
if bActive ~= self.bActive then
self.bActive = bActive
for _, tbCurDots in ipairs(self.tbCurDot) do
tbCurDots[2].gameObject:SetActive(self.bActive)
end
end
end
function ThrowGiftLevelTrackLineCtrl:InitLine(mapData, v2Pos, nAG, nMaxSpeed)
if mapData == nil then
return
end
self.mapData = mapData
local nAngle = mapData.Angle
local nSpeed = mapData.Speed
local sumScale = nSpeed / nMaxSpeed * 0.2
local nInterval = mapData.GuideLinePointInterval * ConfigData.IntFloatPrecision
local nStartTime = mapData.StartPointTime * ConfigData.IntFloatPrecision
local nEndTime = mapData.EndPointTime * ConfigData.IntFloatPrecision
local nBenginingX = v2Pos.x + math.cos(math.rad(nAngle)) * (nHeight * (1 - sumScale))
local nBenginingY = v2Pos.y + math.sin(math.rad(nAngle)) * (nHeight * (1 - sumScale)) - 34
local vX = nSpeed * math.cos(math.rad(nAngle))
local vY = nSpeed * math.sin(math.rad(nAngle))
local nDotCount = math.floor((nEndTime - nStartTime) / nInterval)
for i = 0, nDotCount do
local dotx = (nInterval * i + nStartTime) * vX
local dotY = (nInterval * i + nStartTime) * vY - 0.5 * nAG * (nInterval * i + nStartTime) * (nInterval * i + nStartTime)
local curVy = vY - (nInterval * i + nStartTime) * nAG
local nFlyAngle = math.deg(math.atan(curVy, vX))
self:AddDot(Vector2(nBenginingX + dotx, nBenginingY + dotY), nFlyAngle)
end
end
return ThrowGiftLevelTrackLineCtrl
@@ -6,7 +6,10 @@ local tbColor = {
"#d255ed"
}
ThrowGiftLevelInfoGridCtrl._mapNodeConfig = {
TMPScoreTitle = {sComponentName = "TMP_Text"},
TMPScoreTitle = {
sComponentName = "TMP_Text",
sLanguageId = "Activity_ThrowGifts_BestScore"
},
TMPUnlock = {
sComponentName = "TMP_Text",
sLanguageId = "ThrowGift_LevelInfo_Unlock"
@@ -35,7 +38,8 @@ ThrowGiftLevelInfoGridCtrl._mapNodeConfig = {
imgDifficutly = {
sNodeName = "rtDifficutly",
sComponentName = "Image"
}
},
imgNew = {}
}
ThrowGiftLevelInfoGridCtrl._mapEventConfig = {}
ThrowGiftLevelInfoGridCtrl._mapRedDotConfig = {}
@@ -53,8 +57,9 @@ function ThrowGiftLevelInfoGridCtrl:OnDestroy()
end
function ThrowGiftLevelInfoGridCtrl:OnRelease()
end
function ThrowGiftLevelInfoGridCtrl:Refresh(nLevelId, bUnlock, nMaxScore, bPass)
function ThrowGiftLevelInfoGridCtrl:Refresh(nLevelId, bUnlock, nMaxScore, bPass, bShowRedDot, nOpenTime)
self.nLevelId = nLevelId
self.nOpenTime = nOpenTime
local mapLevelCfgData = ConfigTable.GetData("ThrowGiftLevel", nLevelId)
if mapLevelCfgData == nil then
self.gameObject:SetActive(false)
@@ -91,11 +96,12 @@ function ThrowGiftLevelInfoGridCtrl:Refresh(nLevelId, bUnlock, nMaxScore, bPass)
else
self._mapNode.rtItemReward[2].gameObject:SetActive(false)
end
self._mapNode.imgNew:SetActive(bShowRedDot)
end
function ThrowGiftLevelInfoGridCtrl:OnBtnClick_Go()
EventManager.Hit("ThrowGiftStartBtnClick")
local callback = function()
EventManager.Hit(EventId.OpenPanel, PanelId.ThrowGiftLevelPanel, self.nLevelId)
EventManager.Hit(EventId.OpenPanel, PanelId.ThrowGiftLevelPanel, self.nLevelId, self.nOpenTime)
end
EventManager.Hit(EventId.SetTransition, 37, callback)
end
@@ -33,6 +33,10 @@ ThrowGiftLevelSelectCtrl._mapNodeConfig = {
sComponentName = "UIButton",
callback = "OnBtnClick_ItemDic"
},
btnTarget = {
sComponentName = "UIButton",
callback = "OnBtnClick_Target"
},
btnLevelCtrl = {
sNodeName = "btnLevel",
nCount = 4,
@@ -54,10 +58,13 @@ ThrowGiftLevelSelectCtrl._mapNodeConfig = {
sComponentName = "UIButton",
callback = "OnBtnClick_Next"
},
imgGroupLockIcon = {},
TopBar = {
sNodeName = "TopBarPanel",
sCtrlName = "Game.UI.TopBarEx.TopBarCtrl"
}
},
goRedDotTarget = {},
rtBottom = {sComponentName = "Transform"}
}
ThrowGiftLevelSelectCtrl._mapEventConfig = {}
ThrowGiftLevelSelectCtrl._mapRedDotConfig = {}
@@ -69,8 +76,10 @@ end
function ThrowGiftLevelSelectCtrl:FadeOut()
end
function ThrowGiftLevelSelectCtrl:OnEnable()
self.redDotBottom = self._mapNode.rtBottom:Find("imgNew")
self._mapNode.rtPenguin.speed = 1
self._mapNode.DecoRoot.speed = 1
EventManager.Hit(EventId.SetTransition)
local param = self:GetPanelParam()
if type(param) == "table" then
self.nActivityId = param[1]
@@ -81,10 +90,12 @@ function ThrowGiftLevelSelectCtrl:OnEnable()
self.actData = PlayerData.Activity:GetActivityDataById(self.nActivityId)
self.mapRecordLevelData = {}
self.mapRecordItemData = {}
self.nOpenTime = 0
if self.actData ~= nil then
local mapCachedData = self.actData:GetActivityData()
self.mapRecordLevelData = mapCachedData.tbLevels
self.mapRecordItemData = mapCachedData.tbItems
self.mapRecordLevelData = mapCachedData.mapLevels
self.mapRecordItemData = mapCachedData.mapItems
self.nOpenTime = self.actData:GetActOpenTime() or 0
end
local foreachLevel = function(mapData)
if mapData.ActivityId == self.nActivityId then
@@ -106,7 +117,7 @@ function ThrowGiftLevelSelectCtrl:OnEnable()
local nCurIdx = 1
for i = 1, 4 do
local enumDifficulty = mapDifficultyBtn[i]
local bUnlock = table.indexof(self.tbUnlockedGroup, enumDifficulty) > 0
local bUnlock = 0 < table.indexof(self.tbUnlockedGroup, enumDifficulty)
local bClear = 0 < table.indexof(self.tbClearedGroup, enumDifficulty)
self._mapNode.btnLevelCtrl[i]:SetBtnState(bUnlock, bClear)
self._mapNode.btnLevelCtrl[i]:SetBtnCurState(enumDifficulty == self.curGroup)
@@ -117,6 +128,27 @@ function ThrowGiftLevelSelectCtrl:OnEnable()
end
self._mapNode.imgBgAnim:Play("ThrowGiftsBgSwitch_in" .. nCurIdx)
NovaAPI.SetImageFillAmount(self._mapNode.imgLineTop, tbProgress[nCurIdx])
local mapActivityData = ConfigTable.GetData("Activity", self.nActivityId)
if mapActivityData ~= nil then
local nGroupId = mapActivityData.MidGroupId
local mapGroupData = PlayerData.Activity:GetActivityGroupDataById(nGroupId)
if mapGroupData ~= nil then
local actData = mapGroupData:GetActivityDataByIndex(AllEnum.ActivityThemeFuncIndex.Task)
if actData ~= nil then
RedDotManager.RegisterNode(RedDotDefine.Activity_Group_Task_Group, {
nGroupId,
actData.ActivityId,
mapActivityData.MiniGameRedDot
}, self._mapNode.goRedDotTarget)
else
self._mapNode.goRedDotTarget:SetActive(false)
end
else
self._mapNode.goRedDotTarget:SetActive(false)
end
else
self._mapNode.goRedDotTarget:SetActive(false)
end
end
function ThrowGiftLevelSelectCtrl:OnDisable()
end
@@ -130,8 +162,8 @@ function ThrowGiftLevelSelectCtrl:RefreshLevelInfo()
self.mapRecordItemData = {}
if self.actData ~= nil then
local mapCachedData = self.actData:GetActivityData()
self.mapRecordLevelData = mapCachedData.tbLevels
self.mapRecordItemData = mapCachedData.tbItems
self.mapRecordLevelData = mapCachedData.mapLevels
self.mapRecordItemData = mapCachedData.mapItems
end
self.tbUnlockedGroup = {}
self.tbClearedGroup = {}
@@ -161,14 +193,76 @@ function ThrowGiftLevelSelectCtrl:RefreshLevelInfo()
end
function ThrowGiftLevelSelectCtrl:RefreshLevelInfoGrid()
local tbCurGroup = self.mapLevelGroup[self.curGroup]
local bShowBottomNew = false
local tbNewLevel = {}
if self.actData ~= nil then
tbNewLevel = self.actData:GetNewLevels()
end
for _, nLevelId in ipairs(tbNewLevel) do
if nLevelId > tbCurGroup[2].Id then
bShowBottomNew = true
break
end
end
self.redDotBottom.gameObject:SetActive(bShowBottomNew)
for i = 1, 2 do
local nLevelId = tbCurGroup[i].Id
local bUnlock = tbCurGroup[i].PreLevelId > 0 and self.mapRecordLevelData[tbCurGroup[i].PreLevelId] ~= nil and self.mapRecordLevelData[tbCurGroup[i].PreLevelId].FirstComplete or true
local bUnlock = self:GetLevelUnlock(nLevelId)
local nMaxScore = self.mapRecordLevelData[nLevelId] == nil and 0 or self.mapRecordLevelData[nLevelId].MaxScore
local bPass = self.mapRecordLevelData[nLevelId] ~= nil and self.mapRecordLevelData[nLevelId].FirstComplete or false
self._mapNode.rtLevelInfo[i]:Refresh(nLevelId, bUnlock, nMaxScore, bPass)
local bShowRedDot = false
if self.actData ~= nil then
self.actData:GetLevelNewState(nLevelId)
if bShowRedDot then
self.actData:SetLevelNew(nLevelId)
end
end
self._mapNode.rtLevelInfo[i]:Refresh(nLevelId, bUnlock, nMaxScore, bPass, bShowRedDot, self.nOpenTime)
end
NovaAPI.SetTMPText(self._mapNode.TMPGroupName, ConfigTable.GetUIText("ThrowGift_Difficulty" .. self.curGroup) or "")
local bUnlock = 1 <= table.indexof(self.tbUnlockedGroup, self.curGroup)
self._mapNode.imgGroupLockIcon:SetActive(not bUnlock)
if bUnlock then
NovaAPI.SetTMPText(self._mapNode.TMPGroupName, ConfigTable.GetUIText("ThrowGift_Difficulty" .. self.curGroup) or "")
else
local nCond = 0
local nTime
for _, mapLevelCfgData in ipairs(tbCurGroup) do
local bUnlock, nLevelCond, nTimeLevel = self:GetLevelUnlock(mapLevelCfgData.Id)
if not bUnlock then
nCond = math.max(nCond, nLevelCond)
end
if nTimeLevel ~= nil then
nTime = nTime == nil and nTimeLevel or math.min(nTimeLevel, nTime)
end
end
if nCond == 2 then
NovaAPI.SetTMPText(self._mapNode.TMPGroupName, ConfigTable.GetUIText("ThrowGift_GroupLockHint") or "")
elseif nCond == 1 then
NovaAPI.SetTMPText(self._mapNode.TMPGroupName, self:GetRemainTimeStr(nTime))
else
NovaAPI.SetTMPText(self._mapNode.TMPGroupName, "")
end
end
end
function ThrowGiftLevelSelectCtrl:GetRemainTimeStr(nRemainTime)
if nRemainTime == nil then
return ""
end
local timeStr = ""
local day = math.floor(nRemainTime / 86400)
local hour = math.floor(nRemainTime / 3600)
local min = math.floor((nRemainTime - hour * 3600) / 60)
local sec = nRemainTime - hour * 3600 - min * 60
if 0 < day then
timeStr = orderedFormat(ConfigTable.GetUIText("ActivityLevels_Lock_Day_Color"), day)
elseif 0 < hour then
timeStr = orderedFormat(ConfigTable.GetUIText("ActivityLevels_Lock_Hour_Color"), hour)
elseif 0 < min then
timeStr = orderedFormat(ConfigTable.GetUIText("ActivityLevels_Lock_Min_Color"), min)
elseif 0 < sec then
timeStr = orderedFormat(ConfigTable.GetUIText("ActivityLevels_Lock_Sec_Color"), sec)
end
return timeStr, 0 < nRemainTime
end
function ThrowGiftLevelSelectCtrl:GetLevelPass(nLevelId)
if self.mapRecordLevelData[nLevelId] ~= nil and self.mapRecordLevelData[nLevelId].FirstComplete then
@@ -179,10 +273,22 @@ end
function ThrowGiftLevelSelectCtrl:GetLevelUnlock(nLevelId)
local mapLevelCfgData = ConfigTable.GetData("ThrowGiftLevel", nLevelId)
if mapLevelCfgData == nil then
return false
return false, 0
end
if mapLevelCfgData.DayOpen ~= 0 and mapLevelCfgData.DayOpen ~= nil and self.nOpenTime ~= 0 then
local curTime = CS.ClientManager.Instance.serverTimeStamp
local openTime = CS.ClientManager.Instance:GetNextRefreshTime(self.nOpenTime) - 86400
local remainTime = openTime + mapLevelCfgData.DayOpen * 86400 - curTime
if 0 < remainTime then
return false, 1, remainTime
end
end
if mapLevelCfgData.PreLevelId ~= 0 then
return self.mapRecordLevelData[mapLevelCfgData.PreLevelId] ~= nil and self.mapRecordLevelData[mapLevelCfgData.PreLevelId].FirstComplete
if self.mapRecordLevelData[mapLevelCfgData.PreLevelId] ~= nil and self.mapRecordLevelData[mapLevelCfgData.PreLevelId].FirstComplete then
return true
else
return false, 2
end
else
return true
end
@@ -192,22 +298,23 @@ function ThrowGiftLevelSelectCtrl:OnBtnClick_GroupBtn(btn, nIdx)
if self.curGroup == enumDifficulty then
return
end
if table.indexof(self.tbUnlockedGroup, enumDifficulty) < 1 then
EventManager.Hit(EventId.OpenMessageBox, ConfigTable.GetUIText("ThrowGift_GroupLockHint") or "")
return
end
self.curGroup = enumDifficulty
self:RefreshLevelInfoGrid()
local nCurIdx = 1
local nMaxIdx = 1
for i = 1, 4 do
local enumDifficulty = mapDifficultyBtn[i]
local bUnlock = 1 <= table.indexof(self.tbUnlockedGroup, enumDifficulty)
self._mapNode.btnLevelCtrl[i]:SetBtnCurState(enumDifficulty == self.curGroup)
self._mapNode.btnLevelCtrl[i]:SetBtnSelectState(enumDifficulty <= self.curGroup)
self._mapNode.btnLevelCtrl[i]:SetBtnSelectState(enumDifficulty <= self.curGroup and bUnlock)
if enumDifficulty == self.curGroup then
nCurIdx = i
end
if bUnlock then
nMaxIdx = math.max(nMaxIdx, i)
end
end
NovaAPI.SetImageFillAmount(self._mapNode.imgLineTop, tbProgress[nCurIdx])
NovaAPI.SetImageFillAmount(self._mapNode.imgLineTop, tbProgress[math.min(nCurIdx, nMaxIdx)])
self._mapNode.imgBgAnim:Play("ThrowGiftsBgSwitch_in" .. nCurIdx)
self.rootAnim:Play("ThrowGiftsLevelSelectPanel_switch")
local wait = function()
@@ -236,22 +343,23 @@ function ThrowGiftLevelSelectCtrl:OnBtnClick_Next()
nCurIdx = nCurIdx + 1
end
local enumDifficulty = mapDifficultyBtn[nCurIdx]
if 1 > table.indexof(self.tbUnlockedGroup, enumDifficulty) then
EventManager.Hit(EventId.OpenMessageBox, ConfigTable.GetUIText("ThrowGift_GroupLockHint") or "")
return
end
self.curGroup = enumDifficulty
self:RefreshLevelInfoGrid()
local nCurIdx = 1
local nMaxIdx = 1
for i = 1, 4 do
local enumDifficulty = mapDifficultyBtn[i]
local bUnlock = 1 <= table.indexof(self.tbUnlockedGroup, enumDifficulty)
self._mapNode.btnLevelCtrl[i]:SetBtnCurState(enumDifficulty == self.curGroup)
self._mapNode.btnLevelCtrl[i]:SetBtnSelectState(enumDifficulty <= self.curGroup)
self._mapNode.btnLevelCtrl[i]:SetBtnSelectState(enumDifficulty <= self.curGroup and bUnlock)
if enumDifficulty == self.curGroup then
nCurIdx = i
end
if bUnlock then
nMaxIdx = math.max(nMaxIdx, i)
end
end
NovaAPI.SetImageFillAmount(self._mapNode.imgLineTop, tbProgress[nCurIdx])
NovaAPI.SetImageFillAmount(self._mapNode.imgLineTop, tbProgress[math.min(nCurIdx, nMaxIdx)])
self._mapNode.imgBgAnim:Play("ThrowGiftsBgSwitch_in" .. nCurIdx)
self.rootAnim:Play("ThrowGiftsLevelSelectPanel_switch")
local wait = function()
@@ -280,22 +388,23 @@ function ThrowGiftLevelSelectCtrl:OnBtnClick_Prev()
nCurIdx = nCurIdx - 1
end
local enumDifficulty = mapDifficultyBtn[nCurIdx]
if 1 > table.indexof(self.tbUnlockedGroup, enumDifficulty) then
EventManager.Hit(EventId.OpenMessageBox, ConfigTable.GetUIText("ThrowGift_GroupLockHint") or "")
return
end
self.curGroup = enumDifficulty
self:RefreshLevelInfoGrid()
local nCurIdx = 1
local nMaxIdx = 1
for i = 1, 4 do
local enumDifficulty = mapDifficultyBtn[i]
local bUnlock = 1 <= table.indexof(self.tbUnlockedGroup, enumDifficulty)
self._mapNode.btnLevelCtrl[i]:SetBtnCurState(enumDifficulty == self.curGroup)
self._mapNode.btnLevelCtrl[i]:SetBtnSelectState(enumDifficulty <= self.curGroup)
self._mapNode.btnLevelCtrl[i]:SetBtnSelectState(enumDifficulty <= self.curGroup and bUnlock)
if enumDifficulty == self.curGroup then
nCurIdx = i
end
if bUnlock then
nMaxIdx = math.max(nMaxIdx, i)
end
end
NovaAPI.SetImageFillAmount(self._mapNode.imgLineTop, tbProgress[nCurIdx])
NovaAPI.SetImageFillAmount(self._mapNode.imgLineTop, tbProgress[math.min(nCurIdx, nMaxIdx)])
self._mapNode.imgBgAnim:Play("ThrowGiftsBgSwitch_in" .. nCurIdx)
self.rootAnim:Play("ThrowGiftsLevelSelectPanel_switch")
local wait = function()
@@ -314,4 +423,17 @@ end
function ThrowGiftLevelSelectCtrl:OnBtnClick_ItemDic()
self._mapNode.rtItemInfo:OpenPanel()
end
function ThrowGiftLevelSelectCtrl:OnBtnClick_Target()
local mapActivityData = ConfigTable.GetData("Activity", self.nActivityId)
if mapActivityData ~= nil then
local nGroupId = mapActivityData.MidGroupId
local mapGroupData = PlayerData.Activity:GetActivityGroupDataById(nGroupId)
if mapGroupData ~= nil then
local actData = mapGroupData:GetActivityDataByIndex(AllEnum.ActivityThemeFuncIndex.Task)
if actData ~= nil then
EventManager.Hit(EventId.OpenPanel, PanelId.Task_10105, actData.ActivityId, 4)
end
end
end
end
return ThrowGiftLevelSelectCtrl
@@ -1,5 +1,6 @@
local ThrowGiftPanel = class("ThrowGiftPanel", BasePanel)
ThrowGiftPanel._sUIResRootPath = "UI_Activity/"
local GamepadUIManager = require("GameCore.Module.GamepadUIManager")
ThrowGiftPanel._tbDefine = {
{
sPrefabPath = "_400005/ThrowGiftsPanel.prefab",
@@ -7,6 +8,8 @@ ThrowGiftPanel._tbDefine = {
}
}
function ThrowGiftPanel:Awake()
GamepadUIManager.EnterAdventure(true)
GamepadUIManager.EnableGamepadUI("ThrowGiftPanel", {}, nil, true)
end
function ThrowGiftPanel:OnEnable()
end
@@ -15,6 +18,8 @@ end
function ThrowGiftPanel:OnDisable()
end
function ThrowGiftPanel:OnDestroy()
GamepadUIManager.DisableGamepadUI("ThrowGiftPanel")
GamepadUIManager.QuitAdventure()
end
function ThrowGiftPanel:OnRelease()
end
@@ -4,7 +4,7 @@ ThrowGiftPauseCtrl._mapNodeConfig = {
blur = {},
txt_title = {
sComponentName = "TMP_Text",
sLanguageId = "TowerDef_Text_Pause"
sLanguageId = "Activity_ThrowGifts_Text_Pause"
},
txt_exit = {
nCount = 2,
@@ -35,6 +35,16 @@ ThrowGiftPauseCtrl._mapNodeConfig = {
sComponentName = "NaviButton",
callback = "OnBtnClick_Continue",
sAction = "Back"
},
txt_dic = {
nCount = 2,
sComponentName = "TMP_Text",
sLanguageId = "Tutorial_DicTitle"
},
btn_dic = {
sComponentName = "NaviButton",
callback = "OnBtnClick_Dic",
sAction = "Depot"
}
}
ThrowGiftPauseCtrl._mapEventConfig = {}
@@ -42,8 +52,10 @@ ThrowGiftPauseCtrl._mapRedDotConfig = {}
function ThrowGiftPauseCtrl:Awake()
self.tbGamepadUINode = self:GetGamepadUINode()
end
function ThrowGiftPauseCtrl:Open()
function ThrowGiftPauseCtrl:Open(DictionaryID)
self.gameObject:SetActive(true)
self.DictionaryID = DictionaryID
self._mapNode.btn_dic.gameObject:SetActive(self.DictionaryID > 0)
GamepadUIManager.EnableGamepadUI("ThrowGiftPauseCtrl", self.tbGamepadUINode)
end
function ThrowGiftPauseCtrl:Close()
@@ -59,4 +71,9 @@ end
function ThrowGiftPauseCtrl:OnBtnClick_Continue()
EventManager.Hit("ThrowGift_Continue_OnClick")
end
function ThrowGiftPauseCtrl:OnBtnClick_Dic()
if self.DictionaryID > 0 then
EventManager.Hit(EventId.OpenPanel, PanelId.DictionaryEntry, self.DictionaryID, true)
end
end
return ThrowGiftPauseCtrl
@@ -23,7 +23,21 @@ ThrowGiftSettleCtrl._mapNodeConfig = {
sComponentName = "TMP_Text",
sLanguageId = "ThrowGift_Settle_GiftCount"
},
TMPSettleGift = {sComponentName = "TMP_Text"}
TMPSettleGift = {sComponentName = "TMP_Text"},
TMPPenguinTitle = {
sComponentName = "TMP_Text",
sLanguageId = "ThrowGift_Settle_RemainCount"
},
TMPPenguin = {sComponentName = "TMP_Text"},
TMPVictoryTitle = {
sComponentName = "TMP_Text",
sLanguageId = "Activity_ThrowGifts_Win"
},
TMPFailTitle = {
sComponentName = "TMP_Text",
sLanguageId = "Activity_ThrowGifts_Fail"
},
imgPenguinBg = {}
}
ThrowGiftSettleCtrl._mapEventConfig = {}
ThrowGiftSettleCtrl._mapRedDotConfig = {}
@@ -43,7 +57,7 @@ function ThrowGiftSettleCtrl:OnDestroy()
end
function ThrowGiftSettleCtrl:OnRelease()
end
function ThrowGiftSettleCtrl:ShowSettle(bWin, nScore, nGift, bNextUnlock)
function ThrowGiftSettleCtrl:ShowSettle(bWin, nScore, nGift, nPenguin, bShowPenguin, bNextUnlock, changeInfo, nLevelId)
self.bWin = bWin
NovaAPI.SetTMPText(self._mapNode.txtBtnConfirm, self.bWin and ConfigTable.GetUIText("ThrowGift_Settle_NextLevel") or ConfigTable.GetUIText("ThrowGift_Settle_Restart"))
local wait = function()
@@ -55,15 +69,41 @@ function ThrowGiftSettleCtrl:ShowSettle(bWin, nScore, nGift, bNextUnlock)
self.gameObject:SetActive(true)
NovaAPI.SetTMPText(self._mapNode.TMPSettleScore, nScore)
NovaAPI.SetTMPText(self._mapNode.TMPSettleGift, nGift)
NovaAPI.SetTMPText(self._mapNode.TMPPenguin, nPenguin)
self._mapNode.imgPenguinBg:SetActive(bShowPenguin)
local nAnimLength = 0
if bWin then
WwiseAudioMgr:PostEvent("Mode_Present_compelete")
self.animator:Play("rtSettle_Victory")
nAnimLength = NovaAPI.GetAnimClipLength(self.animator, {
"rtSettle_Victory"
})
self._mapNode.btnConfirm2.gameObject:SetActive(bNextUnlock)
else
WwiseAudioMgr:PostEvent("Mode_Present_failed")
self._mapNode.btnConfirm2.gameObject:SetActive(true)
self.animator:Play("rtSettle_Fail")
nAnimLength = NovaAPI.GetAnimClipLength(self.animator, {
"rtSettle_Fail"
})
end
EventManager.Hit(EventId.TemporaryBlockInput, nAnimLength)
local timerCb = function()
if changeInfo ~= nil and #changeInfo.Props > 0 then
local mapLevelData = ConfigTable.GetData("ThrowGiftLevel", nLevelId)
local i = 1
local tbItem = {}
while mapLevelData["FirstCompleteReward" .. i .. "Tid"] ~= nil do
local nItemId = mapLevelData["FirstCompleteReward" .. i .. "Tid"]
local nCount = mapLevelData["FirstCompleteReward" .. i .. "Qty"]
table.insert(tbItem, {Tid = nItemId, Qty = nCount})
i = i + 1
end
UTILS.OpenReceiveByDisplayItem(tbItem, changeInfo, nil)
end
EventManager.Hit(EventId.BlockInput, false)
end
self:AddTimer(1, nAnimLength, timerCb, true, true, true)
end
function ThrowGiftSettleCtrl:OnBtnClick_Confirm1()
self.gameObject:SetActive(false)
@@ -43,6 +43,13 @@ ThrowGiftsLevelCtrl._mapNodeConfig = {
TMPBeginningCountHint = {sComponentName = "TMP_Text"},
imgBeginningHint = {},
rtPenguinBeginningHint = {sComponentName = "Transform"},
rtPenguinBeginningHintAnim = {
sNodeName = "rtPenguinBeginningHint",
sComponentName = "Animator"
},
imgInfinite = {},
penguinRoot = {},
rtTemplateGuideTrack = {},
rtDebug = {},
DebugDot = {
sComponentName = "RectTransform",
@@ -75,6 +82,7 @@ function ThrowGiftsLevelCtrl:Awake()
self.nTotalHitGoalCount = 0
self.nTotalUseItemCount = 0
self.mapItemUseCount = {}
self.bProcessing = false
self.mapExObstacleOrigin = {}
self.tbExObstacleCur = {}
self.bFlying = false
@@ -90,6 +98,7 @@ function ThrowGiftsLevelCtrl:Awake()
self.nCurActiveItem = 0
self.mapCurActiveState = {}
self.tbItemTrackCtrl = {}
self.tbGuideTrackCtrl = {}
self.curDragBeginPos = nil
self.dragState = false
self._mapNode.rtBeginningLine.gameObject:SetActive(false)
@@ -112,9 +121,15 @@ function ThrowGiftsLevelCtrl:FadeOut()
end
function ThrowGiftsLevelCtrl:OnEnable()
EventManager.Hit("ThrowGiftSetSpeacialFunc", self)
self._mapNode.BeginningPenguinRoot.gameObject:SetActive(false)
self._mapNode.penguinRoot:SetActive(false)
self._mapNode.rtBottleAnim:Play("rtBottle_Empty")
end
function ThrowGiftsLevelCtrl:OnDisable()
self:ClearTrackLine()
if self.tbGuideTrackCtrl ~= nil and #self.tbGuideTrackCtrl ~= 0 then
self:ClearGuideLine()
end
end
function ThrowGiftsLevelCtrl:OnDestroy()
end
@@ -128,6 +143,13 @@ function ThrowGiftsLevelCtrl:ClearTrackLine()
self._mapNode.rtBlindLevelTrack:DestroyAll()
self.tbItemTrackCtrl = {}
end
function ThrowGiftsLevelCtrl:ClearGuideLine()
for _, mapCtrl in ipairs(self.tbGuideTrackCtrl) do
mapCtrl:DestroyAll()
self:UnbindCtrlByNode(mapCtrl)
end
self.tbGuideTrackCtrl = {}
end
function ThrowGiftsLevelCtrl:SetLevel(parent, nLevelId, mapActData)
self.nLevelScore = 0
self.parent = parent
@@ -143,6 +165,10 @@ function ThrowGiftsLevelCtrl:SetLevel(parent, nLevelId, mapActData)
if mapFloorCfgData == nil then
return
end
self.maxVelocity = mapFloorCfgData.SpeedMax
self.minVelovity = mapFloorCfgData.SpeedMin
self.nAngleMin = mapFloorCfgData.AngelMin
self.nAG = mapFloorCfgData.Gravity
if self.mapLevelCfgData.Difficulty == GameEnum.ThrowGiftDifficulty.Blind then
self._mapNode.rtBlindLevelTrack.gameObject:SetActive(true)
end
@@ -246,63 +272,24 @@ function ThrowGiftsLevelCtrl:SetLevel(parent, nLevelId, mapActData)
self.mapUpdateTimer = nil
end
self.mapUpdateTimer = self:AddTimer(0, 0, "OnUpdate", true, true, true)
if self.nTotalPenguinCount ~= 0 then
if 0 < self.nTotalPenguinCount then
self.nTotalPenguinCount = self.nTotalPenguinCount - 1
end
if 0 <= self.nTotalPenguinCount then
NovaAPI.SetTMPText(self._mapNode.TMPBeginningCountHint, self.nTotalPenguinCount + 1)
else
NovaAPI.SetTMPText(self._mapNode.TMPBeginningCountHint, "")
end
if self.curPenguinIdx > #self.mapFloorCfgData.InitialGiftSort then
if 0 < #self.mapFloorCfgData.GiftRandom then
self.curPenguinType = self.mapFloorCfgData.GiftRandom[math.random(#self.mapFloorCfgData.GiftRandom)]
else
self.curPenguinType = 1
if 0 < #mapFloorCfgData.GuideLine then
for _, nGuideLineId in ipairs(mapFloorCfgData.GuideLine) do
local mapGuideLineData = ConfigTable.GetData("ThrowGiftGuideLine", nGuideLineId)
if mapGuideLineData ~= nil then
local rtTrack = instantiate(self._mapNode.rtTemplateGuideTrack, self._mapNode.rtScene)
rtTrack.transform:SetAsFirstSibling()
rtTrack:SetActive(true)
local mapTrackCtrl = self:BindCtrlByNode(rtTrack.gameObject, "Game.UI.Activity.ThrowGifts.ThrowGiftLevelGuideTrackLineCtrl")
mapTrackCtrl:InitLine(mapGuideLineData, self._mapNode.rtBeginning.anchoredPosition, self.nAG, self.maxVelocity)
table.insert(self.tbGuideTrackCtrl, mapTrackCtrl)
end
else
self.curPenguinType = self.mapFloorCfgData.InitialGiftSort[self.curPenguinIdx]
end
self.curPenguinIdx = self.curPenguinIdx + 1
self._mapNode.BeginningPenguinRoot.gameObject:SetActive(true)
self._mapNode.rtBottleAnim:Play("rtBottle_in")
self._mapNode.BeginningPenguinRoot:Play("penguinRoot_jump")
WwiseAudioMgr:PostEvent("Mode_Present_shylock_jump")
self:SetPenguinType(self._mapNode.BeginningPenguinRoot.transform, self.curPenguinType)
self:SetPenguinType(self._mapNode.rtBottle:Find("AnimRoot/penguinRoot"), self.curPenguinType)
self:SetBeginningAngle(0, 0)
local wait = function()
if self.nTotalPenguinCount ~= 0 then
self._mapNode.BeginningPenguinRoot.gameObject:SetActive(true)
self._mapNode.BeginningPenguinRoot:Play("penguinRoot_in")
WwiseAudioMgr:PostEvent("Mode_Present_shylock")
self.nNextPenguinType = 1
if self.curPenguinIdx > #self.mapFloorCfgData.InitialGiftSort then
if 0 < #self.mapFloorCfgData.GiftRandom then
self.nNextPenguinType = self.mapFloorCfgData.GiftRandom[math.random(#self.mapFloorCfgData.GiftRandom)]
else
self.nNextPenguinType = 1
end
else
self.nNextPenguinType = self.mapFloorCfgData.InitialGiftSort[self.curPenguinIdx]
end
self:SetPenguinType(self._mapNode.BeginningPenguinRoot.transform, self.nNextPenguinType)
else
self._mapNode.BeginningPenguinRoot.gameObject:SetActive(false)
end
self._mapNode.imgBeginningHint:SetActive(true)
self:SetPenguinType(self._mapNode.rtPenguinBeginningHint, self.curPenguinType)
end
wait()
else
self._mapNode.BeginningPenguinRoot.gameObject:SetActive(false)
self:LevelEnd()
end
end
function ThrowGiftsLevelCtrl:FlyOver(nDelayTime, HitGoalId)
self.nLevelType = 0
self.bProcessing = true
local waitAnim = function()
self.nLevelType = 0
if self.mapLevelCfgData.ThrowGiftLevelCond == GameEnum.ThrowGiftLevelCond.ThrowCount or self.mapLevelCfgData.ThrowGiftLevelCond == GameEnum.ThrowGiftLevelCond.ThrowCountAfterTime then
self.parent:SetTarget(self.nTotalThrowGiftCount)
elseif self.mapLevelCfgData.ThrowGiftLevelCond == GameEnum.ThrowGiftLevelCond.Score or self.mapLevelCfgData.ThrowGiftLevelCond == GameEnum.ThrowGiftLevelCond.ScoreAfterTime then
@@ -336,14 +323,7 @@ function ThrowGiftsLevelCtrl:FlyOver(nDelayTime, HitGoalId)
self._mapNode.rtBottle.localEulerAngles = Vector3(0, 0, v)
end, 0, 0.5):OnComplete(function()
self:SetBeginningAngle(0, 0)
if 0 < self.nTotalPenguinCount and self.mapCurActiveState[102] == nil then
self.nTotalPenguinCount = self.nTotalPenguinCount - 1
end
if 0 <= self.nTotalPenguinCount then
NovaAPI.SetTMPText(self._mapNode.TMPBeginningCountHint, self.nTotalPenguinCount + 1)
else
NovaAPI.SetTMPText(self._mapNode.TMPBeginningCountHint, "")
end
NovaAPI.SetTMPText(self._mapNode.TMPBeginningCountHint, self.nTotalPenguinCount)
if self.curPenguinIdx > #self.mapFloorCfgData.InitialGiftSort then
if 0 < #self.mapFloorCfgData.GiftRandom then
self.curPenguinType = self.nNextPenguinType
@@ -358,13 +338,12 @@ function ThrowGiftsLevelCtrl:FlyOver(nDelayTime, HitGoalId)
self._mapNode.rtBottleAnim:Play("rtBottle_in")
self._mapNode.BeginningPenguinRoot:Play("penguinRoot_jump")
WwiseAudioMgr:PostEvent("Mode_Present_shylock_jump")
self:SetPenguinType(self._mapNode.BeginningPenguinRoot.transform, self.curPenguinType)
self:SetPenguinType(self._mapNode.rtBottle:Find("AnimRoot/penguinRoot"), self.curPenguinType)
self:SetPenguinType(self._mapNode.BeginningPenguinRoot.transform, self.curPenguinType, self.curPenguinSpecialType)
self:SetPenguinType(self._mapNode.rtBottle:Find("AnimRoot/penguinRoot"), self.curPenguinType, self.curPenguinSpecialType)
self:SetBeginningAngle(0, 0)
local wait = function()
self.nLevelType = 1
self._mapNode.imgBeginningHint:SetActive(true)
self:SetPenguinType(self._mapNode.rtPenguinBeginningHint, self.curPenguinType)
self:SetPenguinType(self._mapNode.rtPenguinBeginningHint, self.curPenguinType, self.curPenguinSpecialType)
if self.nTotalPenguinCount ~= 0 then
self._mapNode.BeginningPenguinRoot.gameObject:SetActive(true)
self._mapNode.BeginningPenguinRoot:Play("penguinRoot_in")
@@ -379,18 +358,26 @@ function ThrowGiftsLevelCtrl:FlyOver(nDelayTime, HitGoalId)
else
self.nNextPenguinType = self.mapFloorCfgData.InitialGiftSort[self.curPenguinIdx]
end
self:SetPenguinType(self._mapNode.BeginningPenguinRoot.transform, self.nNextPenguinType)
self:SetPenguinType(self._mapNode.BeginningPenguinRoot.transform, self.nNextPenguinType, 0)
else
self._mapNode.BeginningPenguinRoot.gameObject:SetActive(false)
end
end
local waitAnimEnd = function()
self.nLevelType = 1
if self.mapLevelCfgData.Difficulty == GameEnum.ThrowGiftDifficulty.Blind then
self.parent:SetViewBtn(1)
end
end
self:AddTimer(1, 0.5, wait, true, true, true)
self:AddTimer(1, 1, waitAnimEnd, true, true, true)
end)
else
self._mapNode.BeginningPenguinRoot.gameObject:SetActive(false)
self:LevelEnd(false, 1)
return
end
local bNeedProcessingItem = false
if HitGoalId ~= nil then
local mapSpawnPointData = self.mapGoal[HitGoalId]
if mapSpawnPointData ~= nil and #mapSpawnPointData.tbOrginPool > 0 then
@@ -435,15 +422,20 @@ function ThrowGiftsLevelCtrl:FlyOver(nDelayTime, HitGoalId)
end
local callback = function(nIdx)
self:Pause(false)
self.bProcessing = false
if mapSpawnPointData.mapConfig.PoolType then
table.insert(mapSpawnPointData.tbExtractedItems, tbItems[nIdx])
end
end
bNeedProcessingItem = true
self.parent:OpenItemSelect(tbItems, callback)
self:Pause(true)
end
end
end
if not bNeedProcessingItem then
self.bProcessing = false
end
local rtScenePos = self._mapNode.rtScene.anchoredPosition
self._mapNode.rtScene.anchoredPosition = Vector2(0, rtScenePos.y)
for nInstanceId, mapConfig in pairs(self.mapExObstacleOrigin) do
@@ -464,8 +456,14 @@ function ThrowGiftsLevelCtrl:LevelEnd(bPass, nCond)
self.mapUpdateTimer:Cancel()
self.mapUpdateTimer = nil
end
local openSettle = function()
self.parent:OpenSettle(bPass, self.nLevelScore, self.nTotalHitGoalCount)
self.parent:LevelEnd()
local bShowPenguin = false
if bPass and self.mapFloorCfgData.GiftNum > 0 then
self.nLevelScore = self.nLevelScore + 20 * math.max(0, self.nTotalPenguinCount)
bShowPenguin = true
end
local openSettle = function(changeInfo)
self.parent:OpenSettle(bPass, self.nLevelScore, self.nTotalHitGoalCount, self.nTotalPenguinCount, bShowPenguin, changeInfo)
end
if self.actData ~= nil then
local tbUseItems = {}
@@ -478,6 +476,11 @@ function ThrowGiftsLevelCtrl:LevelEnd(bPass, nCond)
end
end
function ThrowGiftsLevelCtrl:Pause(bPause)
if bPause then
WwiseAudioMgr:PostEvent("Mode_Present_sidechain_in")
else
WwiseAudioMgr:PostEvent("Mode_Present_sidechain_out")
end
if self.mapUpdateTimer ~= nil then
self.mapUpdateTimer:Pause(bPause)
end
@@ -489,37 +492,119 @@ function ThrowGiftsLevelCtrl:ActiveItem(nItemId)
self.mapItemUseCount[nItemId] = self.mapItemUseCount[nItemId] + 1
if nItemId == 101 then
if 0 < self.nLevelTime then
self.nLevelTime = self.nLevelTime + 3
self.nLevelTime = self.nLevelTime + 11
self.parent:AddTimeAnim()
WwiseAudioMgr:PostEvent("Mode_Present_prop_overtime")
end
elseif 106 <= nItemId and nItemId <= 108 then
self.curPenguinSpecialType = nItemId
if not self.bFlying then
self._mapNode.rtPenguinBeginningHintAnim:Play("imgBeginningHint_in")
if not self.bFlying and self.nLevelType == 1 or self.nLevelType == 3 then
if nItemId == 108 then
WwiseAudioMgr:PostEvent("Mode_Present_prop_anteena")
else
WwiseAudioMgr:PostEvent("Mode_Present_prop_gear")
end
self:SetPenguinType(self._mapNode.rtBottle:Find("AnimRoot/penguinRoot"), nItemId)
self:SetPenguinType(self._mapNode.rtPenguinBeginningHint, nItemId)
self:SetPenguinType(self._mapNode.rtBottle:Find("AnimRoot/penguinRoot"), self.curPenguinType, nItemId)
self:SetPenguinType(self._mapNode.rtPenguinBeginningHint, self.curPenguinType, nItemId)
self._mapNode.rtBottleAnim:Play("rtBottle_switch")
self._mapNode.rtPenguinBeginningHintAnim:Play("imgBeginningHint_in")
end
else
self.mapCurActiveState[nItemId] = 10
self.mapCurActiveState[nItemId] = 16
self.parent:SetFx(self.mapCurActiveState)
if nItemId == 105 then
WwiseAudioMgr:PostEvent("Mode_Present_prop_power")
self:SetPenguinType(self._mapNode.BeginningPenguinRoot.transform, self.nNextPenguinType)
self:SetPenguinType(self._mapNode.rtBottle:Find("AnimRoot/penguinRoot"), self.curPenguinType)
self:SetPenguinType(self._mapNode.rtPenguinBeginningHint, self.curPenguinType)
self:SetPenguinType(self._mapNode.BeginningPenguinRoot.transform, self.nNextPenguinType, 0)
self:SetPenguinType(self._mapNode.rtBottle:Find("AnimRoot/penguinRoot"), self.curPenguinType, self.curPenguinSpecialType)
self:SetPenguinType(self._mapNode.rtPenguinBeginningHint, self.curPenguinType, self.curPenguinSpecialType)
elseif nItemId == 102 then
self._mapNode.imgInfinite:SetActive(true)
WwiseAudioMgr:PostEvent("Mode_Present_prop_infinite")
self._mapNode.TMPBeginningCountHint.gameObject:SetActive(false)
elseif nItemId == 103 then
WwiseAudioMgr:PostEvent("Mode_Present_lowtime_lp")
elseif nItemId == 104 then
WwiseAudioMgr:PostEvent("Mode_Present_doubletime_lp")
end
self.parent:SetBuffShow(nItemId, true)
self.parent:SetBuffTime(nItemId, 10)
self.parent:SetBuffTime(nItemId, 15)
end
end
function ThrowGiftsLevelCtrl:LevelStart()
self.nLevelType = 0
local GuideCallback = function()
self.nLevelType = 1
self._mapNode.penguinRoot:SetActive(true)
if self.nTotalPenguinCount ~= 0 then
if self.nTotalPenguinCount >= 0 then
NovaAPI.SetTMPText(self._mapNode.TMPBeginningCountHint, self.nTotalPenguinCount)
self._mapNode.TMPBeginningCountHint.gameObject:SetActive(true)
self._mapNode.imgInfinite:SetActive(false)
else
self._mapNode.TMPBeginningCountHint.gameObject:SetActive(false)
self._mapNode.imgInfinite:SetActive(true)
end
if self.curPenguinIdx > #self.mapFloorCfgData.InitialGiftSort then
if 0 < #self.mapFloorCfgData.GiftRandom then
self.curPenguinType = self.mapFloorCfgData.GiftRandom[math.random(#self.mapFloorCfgData.GiftRandom)]
else
self.curPenguinType = 1
end
else
self.curPenguinType = self.mapFloorCfgData.InitialGiftSort[self.curPenguinIdx]
end
self.curPenguinIdx = self.curPenguinIdx + 1
self._mapNode.BeginningPenguinRoot.gameObject:SetActive(true)
self._mapNode.rtBottleAnim:Play("rtBottle_in")
self._mapNode.BeginningPenguinRoot:Play("penguinRoot_jump")
WwiseAudioMgr:PostEvent("Mode_Present_shylock_jump")
self:SetPenguinType(self._mapNode.BeginningPenguinRoot.transform, self.curPenguinType, self.curPenguinSpecialType)
self:SetPenguinType(self._mapNode.rtBottle:Find("AnimRoot/penguinRoot"), self.curPenguinType, self.curPenguinSpecialType)
self:SetBeginningAngle(0, 0)
local wait = function()
if self.nTotalPenguinCount ~= 0 then
self._mapNode.BeginningPenguinRoot.gameObject:SetActive(true)
self._mapNode.BeginningPenguinRoot:Play("penguinRoot_in")
WwiseAudioMgr:PostEvent("Mode_Present_shylock")
self.nNextPenguinType = 1
if self.curPenguinIdx > #self.mapFloorCfgData.InitialGiftSort then
if 0 < #self.mapFloorCfgData.GiftRandom then
self.nNextPenguinType = self.mapFloorCfgData.GiftRandom[math.random(#self.mapFloorCfgData.GiftRandom)]
else
self.nNextPenguinType = 1
end
else
self.nNextPenguinType = self.mapFloorCfgData.InitialGiftSort[self.curPenguinIdx]
end
self:SetPenguinType(self._mapNode.BeginningPenguinRoot.transform, self.nNextPenguinType, 0)
else
self._mapNode.BeginningPenguinRoot.gameObject:SetActive(false)
end
self._mapNode.imgBeginningHint:SetActive(true)
self:SetPenguinType(self._mapNode.rtPenguinBeginningHint, self.curPenguinType, self.curPenguinSpecialType)
self.nLevelType = 1
if self.mapLevelCfgData.Difficulty == GameEnum.ThrowGiftDifficulty.Blind then
self.parent:SetViewBtn(1)
end
end
wait()
else
self._mapNode.BeginningPenguinRoot.gameObject:SetActive(false)
self:LevelEnd()
end
end
local completeCallback = function()
if self.actData ~= nil then
if self.mapFloorCfgData.DictionaryID > 0 and self.actData:GetDicFirstIn(self.mapFloorCfgData.DictionaryID) then
EventManager.Hit(EventId.OpenPanel, PanelId.DictionaryEntry, self.mapFloorCfgData.DictionaryID, true, GuideCallback)
else
GuideCallback()
end
else
GuideCallback()
end
end
if self.mapLevelCfgData.Difficulty == GameEnum.ThrowGiftDifficulty.Blind then
self.nLevelType = 3
local maxScenePosX = -math.abs((1 - self.scenePivot[1]) * self.sceneSize[1])
@@ -531,10 +616,47 @@ function ThrowGiftsLevelCtrl:LevelStart()
local rtScenePos = self._mapNode.rtScene.anchoredPosition
self._mapNode.rtScene.anchoredPosition = Vector2(posX, rtScenePos.y)
end, 3, 3):OnComplete(function()
self.nLevelType = 1
completeCallback()
end)
else
self.nLevelType = 1
completeCallback()
end
end
function ThrowGiftsLevelCtrl:ChangeView(bShow)
if bShow then
if self.nLevelType == 3 then
return
end
self.nLevelType = 3
local maxScenePosX = -math.abs((1 - self.scenePivot[1]) * self.sceneSize[1])
self.beginningTweener = DOTween.To(function()
return 0
end, function(v)
local sum = v <= 0.5 and v or v <= 2.5 and 0.5 or 3 - v
local posX = math.sin(math.pi * sum) * maxScenePosX
local rtScenePos = self._mapNode.rtScene.anchoredPosition
self._mapNode.rtScene.anchoredPosition = Vector2(posX, rtScenePos.y)
end, 0.5, 0.5):OnComplete(function()
self.parent:SetViewBtn(2)
end)
else
if self.nLevelType ~= 3 then
return
end
local maxScenePosX = -math.abs((1 - self.scenePivot[1]) * self.sceneSize[1])
self.beginningTweener = DOTween.To(function()
return 2.5
end, function(v)
local sum = v <= 0.5 and v or v <= 2.5 and 0.5 or 3 - v
local posX = math.sin(math.pi * sum) * maxScenePosX
local rtScenePos = self._mapNode.rtScene.anchoredPosition
self._mapNode.rtScene.anchoredPosition = Vector2(posX, rtScenePos.y)
end, 3, 0.5):OnComplete(function()
if self.mapLevelCfgData.Difficulty == GameEnum.ThrowGiftDifficulty.Blind then
self.parent:SetViewBtn(1)
end
self.nLevelType = 1
end)
end
end
function ThrowGiftsLevelCtrl:CheckAABB(bounds1, bounds2)
@@ -584,9 +706,9 @@ function ThrowGiftsLevelCtrl:OnUpdate()
if self.mapUpdateTimer == nil then
return
end
local nDeltaTime = self.mapUpdateTimer:GetDelTime()
local nDeltaTime = math.min(self.mapUpdateTimer:GetDelTime(), 0.032)
if self.nLevelTime > 0 then
if self.nLevelType ~= 3 then
if self.nLevelType == 1 then
if self.mapCurActiveState[103] ~= nil then
self.nLevelTime = self.nLevelTime - nDeltaTime * 0.5
else
@@ -633,9 +755,9 @@ function ThrowGiftsLevelCtrl:OnUpdate()
for _, nState in ipairs(tbRemovedState) do
self.mapCurActiveState[nState] = nil
if nState == 105 then
self:SetPenguinType(self._mapNode.BeginningPenguinRoot.transform, self.nNextPenguinType)
self:SetPenguinType(self._mapNode.rtBottle:Find("AnimRoot/penguinRoot"), self.curPenguinType)
self:SetPenguinType(self._mapNode.rtPenguinBeginningHint, self.curPenguinType)
self:SetPenguinType(self._mapNode.BeginningPenguinRoot.transform, self.nNextPenguinType, 0)
self:SetPenguinType(self._mapNode.rtBottle:Find("AnimRoot/penguinRoot"), self.curPenguinType, self.curPenguinSpecialType)
self:SetPenguinType(self._mapNode.rtPenguinBeginningHint, self.curPenguinType, self.curPenguinSpecialType)
if self.bFlying and self.curGiftPenguin ~= nil then
local goPenguin = self.curGiftPenguin.goGiftPenguin
local rtPenguin = goPenguin:GetComponent("RectTransform")
@@ -647,6 +769,9 @@ function ThrowGiftsLevelCtrl:OnUpdate()
WwiseAudioMgr:PostEvent("Mode_Present_lowtime_lp_stop")
elseif nState == 104 then
WwiseAudioMgr:PostEvent("Mode_Present_doubletime_lp_stop")
elseif nState == 102 and 0 <= self.nTotalPenguinCount then
self._mapNode.imgInfinite:SetActive(false)
self._mapNode.TMPBeginningCountHint.gameObject:SetActive(true)
end
end
if bChange then
@@ -709,7 +834,7 @@ function ThrowGiftsLevelCtrl:OnUpdate()
nCurPosX, nCurPosY, curGiftPenguinBounds = self:NormalPenguinUpdate(nDeltaTime)
end
if not self.bFlying then
self:FlyOver()
self:FlyOver(0.5)
return
end
if self.mapLevelCfgData.Difficulty == GameEnum.ThrowGiftDifficulty.Blind and self.nFlyingTime - self._mapNode.rtBlindLevelTrack.nPrevTimer >= self.nLinePointInterval * 2 then
@@ -725,7 +850,7 @@ function ThrowGiftsLevelCtrl:OnUpdate()
local curVy = self.curGiftPenguin.nStartVelocityY - self.nFlyingTime * self.nAG
if 0 < curVy and self.curGiftPenguin.nSpecialType ~= 106 and self.curGiftPenguin.nSpecialType ~= 107 then
print("hit goal edge")
destroy(self.curGiftPenguin.goGiftPenguin.gameObject)
self:DestroyPenguin()
self.curGiftPenguin = nil
self.bFlying = false
break
@@ -754,7 +879,7 @@ function ThrowGiftsLevelCtrl:OnUpdate()
return
end
if not self.bFlying then
self:FlyOver()
self:FlyOver(0.5)
return
end
if nCurPosX > 0.5 * self.sceneSize[1] or nCurPosX < -0.5 * self.sceneSize[1] or nCurPosY > 0.5 * self.sceneSize[2] or nCurPosY < -0.5 * self.sceneSize[2] then
@@ -763,7 +888,7 @@ function ThrowGiftsLevelCtrl:OnUpdate()
self.bFlying = false
end
if not self.bFlying then
self:FlyOver()
self:FlyOver(0.5)
return
end
local rtScenePos = self._mapNode.rtScene.anchoredPosition
@@ -909,15 +1034,19 @@ function ThrowGiftsLevelCtrl:NavigationPenguinUpdate(nDeltaTime)
end
self.nFlyingTime = self.nFlyingTime + nDeltaTime
local t_stop = self.curGiftPenguin.nStartVelocityY / self.nAG
if t_stop < 0 then
t_stop = 0
end
local nCurPosY = 0
local nCurPosX = 0
if self.curGiftPenguin.targetGoal == nil then
if t_stop >= self.nFlyingTime then
nCurPosY = self.curGiftPenguin.mapStartPos.y + self.nFlyingTime * self.curGiftPenguin.nStartVelocityY - 0.5 * self.nAG * self.nFlyingTime * self.nFlyingTime
nCurPosX = self.curGiftPenguin.mapStartPos.x + self.nFlyingTime * self.curGiftPenguin.nStartVelocityX
else
nCurPosY = self.curGiftPenguin.mapStartPos.y + t_stop * self.curGiftPenguin.nStartVelocityY - 0.5 * self.nAG * t_stop * t_stop
nCurPosX = self.curGiftPenguin.mapStartPos.x + t_stop * self.curGiftPenguin.nStartVelocityX + (self.nFlyingTime - t_stop) * math.max(self.maxVelocity * 0.2, self.curGiftPenguin.nStartVelocityX)
end
nCurPosX = self.curGiftPenguin.mapStartPos.x + self.nFlyingTime * self.curGiftPenguin.nStartVelocityX
local checkGoal = checkGetGoal(nCurPosX, nCurPosY)
if checkGoal ~= nil then
self.curGiftPenguin.targetGoal = checkGoal
@@ -954,7 +1083,7 @@ function ThrowGiftsLevelCtrl:NavigationPenguinUpdate(nDeltaTime)
local bHit = self:CheckAABB(curGiftPenguinBounds, tbBounds)
if bHit then
print("hit Obstacle")
destroy(self.curGiftPenguin.goGiftPenguin.gameObject)
self:DestroyPenguin()
self.curGiftPenguin = nil
self.bFlying = false
break
@@ -1000,6 +1129,9 @@ function ThrowGiftsLevelCtrl:SetBeginningLine(nAngle, nVelocity)
local vX = nVelocity * math.cos(math.rad(nAngle))
local vY = nVelocity * math.sin(math.rad(nAngle))
local t_stop = vY / self.nAG
if t_stop < 0 then
t_stop = 0
end
for i = 1, 30 do
if i <= 10 then
local dotx = self.nLinePointInterval * i * vX
@@ -1069,12 +1201,12 @@ function ThrowGiftsLevelCtrl:HitSpecialObstacle(nSpecialId)
end
function ThrowGiftsLevelCtrl:AddScore(nScore)
self.nLevelScore = self.nLevelScore + nScore
if self.mapCurActiveState[105] ~= nil then
if self.mapCurActiveState[104] ~= nil then
self.nLevelScore = self.nLevelScore + nScore
end
self.parent:SetScore(self.nLevelScore)
end
function ThrowGiftsLevelCtrl:SetPenguinType(rtPenguinRoot, nType)
function ThrowGiftsLevelCtrl:SetPenguinType(rtPenguinRoot, nType, nSpecialType)
if rtPenguinRoot == nil then
return
end
@@ -1088,9 +1220,9 @@ function ThrowGiftsLevelCtrl:SetPenguinType(rtPenguinRoot, nType)
rtRed.gameObject:SetActive(nType == 2)
rtYellow.gameObject:SetActive(nType == 3)
rtGreen.gameObject:SetActive(nType == 1)
rtGoggles.gameObject:SetActive(nType == 106)
rtAntenna.gameObject:SetActive(nType == 108)
rtHelmet.gameObject:SetActive(nType == 107)
rtGoggles.gameObject:SetActive(nSpecialType == 106)
rtAntenna.gameObject:SetActive(nSpecialType == 108)
rtHelmet.gameObject:SetActive(nSpecialType == 107)
imgFx.gameObject:SetActive(self.mapCurActiveState[105] ~= nil)
end
function ThrowGiftsLevelCtrl:CreateGoal(nSpawnPointId, mapConfig)
@@ -1117,18 +1249,25 @@ function ThrowGiftsLevelCtrl:CreateGoal(nSpawnPointId, mapConfig)
self.activeGoal[nSpawnPointId].rtGoal = nil
self.activeGoal[nSpawnPointId].rtHitArea = nil
self.activeGoal[nSpawnPointId].rtObstacle = nil
self.activeGoal[nSpawnPointId].nType = 0
self.activeGoal[nSpawnPointId].TMPScore = nil
end
self.activeGoal[nSpawnPointId] = {}
local rtGoal = goGoal:GetComponent("RectTransform")
rtGoal.anchoredPosition = Vector2(pointOriginPosX + randomX, pointOriginPosY + randomY)
local rtHitArea = rtGoal:Find("HitArea")
local rtObstacle = rtGoal:Find("Obstacle")
local rtItemBuff = rtGoal:Find("AnimRoot/imgItembuff")
if rtItemBuff ~= nil then
rtItemBuff.gameObject:SetActive(0 < mapConfig.mapConfig.ItemPool)
end
if rtHitArea == nil or rtObstacle == nil then
printError("预制体结构错误:" .. sPath)
destroy(goGoal)
return
end
self.activeGoal[nSpawnPointId].rtGoal = rtGoal
self.activeGoal[nSpawnPointId].nType = nType
local rtCompHitArea = rtHitArea:GetComponent("RectTransform")
local rtCompObstacle = rtObstacle:GetComponent("RectTransform")
local xMinOffsetrtHitArea = rtCompHitArea.anchoredPosition.x - rtCompHitArea.pivot.x * rtCompHitArea.rect.width
@@ -1151,6 +1290,12 @@ function ThrowGiftsLevelCtrl:CreateGoal(nSpawnPointId, mapConfig)
yMinOffsetObstacle,
yMaxOffsetObstacle
}
local TMPNode
local rtTMPScore = rtGoal:Find("AnimRoot/TMPLevelScoreAdd")
if rtTMPScore ~= nil then
TMPNode = rtTMPScore:GetComponent("TMP_Text")
end
self.activeGoal[nSpawnPointId].TMPScore = TMPNode
end
end
function ThrowGiftsLevelCtrl:CreateThrowPenguin(nAngle, nVelocity, initPos, nType, nSpecialType)
@@ -1215,16 +1360,23 @@ function ThrowGiftsLevelCtrl:HitGoal(hitPos, hitGoalId)
if mapCurGoalCfg == nil then
return
end
if self.tbGuideTrackCtrl ~= nil and #self.tbGuideTrackCtrl ~= 0 then
self:ClearGuideLine()
end
local nType = self.activeGoal[hitGoalId].nType % 10
local nScore = (self.curPenguinType == nType or self.mapCurActiveState[105] ~= nil) and 200 or 100
self:AddScore(nScore)
if self.activeGoal[hitGoalId].TMPScore ~= nil then
if self.mapCurActiveState[104] ~= nil then
nScore = nScore * 2
end
NovaAPI.SetTMPText(self.activeGoal[hitGoalId].TMPScore, string.format("+%d", nScore))
end
self.nTotalHitGoalCount = self.nTotalHitGoalCount + 1
WwiseAudioMgr:PostEvent("Mode_Present_in")
self.activeGoal[hitGoalId] = nil
local AfterAnim = function()
destroy(mapCurGoalCfg.rtGoal.gameObject)
self.activeGoal[hitGoalId] = nil
if self.curPenguinType == mapSpawnPointData.mapConfig.Type then
self:AddScore(200)
else
self:AddScore(100)
end
if mapSpawnPointData.mapConfig.ActiveCond == GameEnum.ThrowGiftSpawnCond.Random then
local tbRandom = {}
for _, nCondSpawnId in ipairs(mapSpawnPointData.mapConfig.SpawnParam) do
@@ -1267,6 +1419,10 @@ function ThrowGiftsLevelCtrl:HitGoal(hitPos, hitGoalId)
end
end
local rtAnimRoot = mapCurGoalCfg.rtGoal:Find("AnimRoot")
local rtItemBuff = mapCurGoalCfg.rtGoal:Find("AnimRoot/imgItembuff")
if rtItemBuff ~= nil then
rtItemBuff.gameObject:SetActive(false)
end
if rtAnimRoot == nil then
AfterAnim()
else
@@ -1301,40 +1457,31 @@ function ThrowGiftsLevelCtrl:OnDrag_Beginning(mDrag)
return
end
if mDrag.DragEventType == AllEnum.UIDragType.DragStart then
local uipos = GameUIUtils.ScreenPointToLocalPointInRectangle(mDrag.EventData.position, mDrag.gameObject.transform.parent.transform)
local a = self.sceneSize[1] * self.scenePivot[1]
local b = self.sceneSize[1] / 2
local c = a - b
self.curDragBeginPos = {
x = uipos.x,
y = uipos.y
x = self._mapNode.rtBeginning.anchoredPosition.x - c,
y = self._mapNode.rtBeginning.anchoredPosition.y
}
local nAngle = 0
local nVelocity = 0
self:SetBeginningAngle(nAngle, nVelocity)
self:SetBeginningLine(nAngle, nVelocity)
self.nCurAngle = nAngle
self.nCurVelocity = nVelocity
WwiseAudioMgr:PostEvent("Mode_Present_pre_lp")
elseif mDrag.DragEventType == AllEnum.UIDragType.Drag then
if self.curDragBeginPos == nil then
return
end
local uipos = GameUIUtils.ScreenPointToLocalPointInRectangle(mDrag.EventData.position, mDrag.gameObject.transform.parent.transform)
local uipos = GameUIUtils.ScreenPointToLocalPoint(mDrag.EventData.position, self._mapNode.rtScene)
local nSumX = self.curDragBeginPos.x - uipos.x
local nSumY = self._mapNode.rtBeginning.anchoredPosition.y - uipos.y
local nAngle = nSumY * 0.2
if nAngle > self.nAngelMax then
nAngle = self.nAngelMax
elseif nAngle < self.nAngleMin then
nAngle = self.nAngleMin
end
local nSumY = self.curDragBeginPos.y - uipos.y
local nVelocity = 0
if 0 < nSumX then
nVelocity = math.sqrt(nSumY * nSumY + nSumX * nSumX) * 2
nVelocity = math.sqrt(nSumY * nSumY + nSumX * nSumX) * 2.5
if nVelocity > self.maxVelocity then
nVelocity = self.maxVelocity
elseif nVelocity < 10 then
nVelocity = 0
end
end
local nAngle = math.atan(nSumY, nSumX) * 180 / math.pi
if nAngle > self.nAngelMax then
nAngle = self.nAngelMax
elseif nAngle < self.nAngleMin then
nAngle = self.nAngleMin
end
self.nCurAngle = nAngle
if nVelocity < self.minVelovity then
nVelocity = self.minVelovity
@@ -1342,13 +1489,54 @@ function ThrowGiftsLevelCtrl:OnDrag_Beginning(mDrag)
self.nCurVelocity = nVelocity
self:SetBeginningAngle(nAngle, nVelocity)
self:SetBeginningLine(nAngle, nVelocity)
WwiseAudioMgr:PostEvent("Mode_Present_pre_lp")
self.parent:SetViewBtn(0)
elseif mDrag.DragEventType == AllEnum.UIDragType.Drag then
if self.curDragBeginPos == nil then
return
end
local uipos = GameUIUtils.ScreenPointToLocalPoint(mDrag.EventData.position, self._mapNode.rtScene)
local nSumX = self.curDragBeginPos.x - uipos.x
local nSumY = self.curDragBeginPos.y - uipos.y
local nVelocity = 0
if 0 < nSumX then
nVelocity = math.min(1, math.sqrt(nSumY * nSumY + nSumX * nSumX) / 400) * self.maxVelocity
if nVelocity > self.maxVelocity then
nVelocity = self.maxVelocity
elseif nVelocity < 10 then
nVelocity = 0
end
end
local nAngle = math.atan(nSumY, nSumX) * 180 / math.pi
if nAngle > self.nAngelMax then
nAngle = self.nAngelMax
elseif nAngle < self.nAngleMin then
nAngle = self.nAngleMin
end
self.nCurAngle = nAngle
if nVelocity < self.minVelovity then
nVelocity = self.minVelovity
end
self.nCurVelocity = nVelocity
self:SetBeginningAngle(nAngle, nVelocity)
self:SetBeginningLine(nAngle, nVelocity)
if self.tbGuideTrackCtrl ~= nil then
for _, mapLineCtrl in ipairs(self.tbGuideTrackCtrl) do
mapLineCtrl:SetLineActive(nAngle, nVelocity)
end
end
elseif mDrag.DragEventType == AllEnum.UIDragType.DragEnd then
if self.curDragBeginPos == nil then
return
end
if self.nCurVelocity == 0 then
if self.mapLevelCfgData.Difficulty == GameEnum.ThrowGiftDifficulty.Blind then
self.parent:SetViewBtn(1)
end
self.curDragBeginPos = nil
return
end
self.nTotalThrowGiftCount = self.nTotalThrowGiftCount + 1
self.curDragBeginPos = nil
self.bFlying = true
self.nFlyingTime = 0
@@ -1368,7 +1556,10 @@ function ThrowGiftsLevelCtrl:OnDrag_Beginning(mDrag)
local mapGiftPenguin = self:CreateThrowPenguin(nStartAngle, nStartVelocity, Vector2(beginningPos.x + sumPos.x, beginningPos.y + sumPos.y), self.curPenguinType, self.curPenguinSpecialType)
self.curPenguinSpecialType = 0
self.curGiftPenguin = mapGiftPenguin
self.nTotalThrowGiftCount = self.nTotalThrowGiftCount + 1
if 0 < self.nTotalPenguinCount and self.mapCurActiveState[102] == nil then
self.nTotalPenguinCount = self.nTotalPenguinCount - 1
end
NovaAPI.SetTMPText(self._mapNode.TMPBeginningCountHint, self.nTotalPenguinCount)
end
self:AddTimer(1, 0.12, wait, true, true, true)
end