diff --git a/lua/app/module/battle/component/battle_unit_comp.lua b/lua/app/module/battle/component/battle_unit_comp.lua index 810ecec7..07fbc5f6 100644 --- a/lua/app/module/battle/component/battle_unit_comp.lua +++ b/lua/app/module/battle/component/battle_unit_comp.lua @@ -1001,6 +1001,13 @@ function BattleUnitComp:onSkillTakeEffect(skill) end if succ and skill:getIsNormalType() then -- 普攻攻击成功的话 self:checkPassiveEvent(PASSIVE_EVENT.USE_NORMAL_SKILL, target) + local shakeType = skill:getShakeType() + if shakeType then + local shakeTime = skill:getShakeTime() or 0 + if shakeTime > 0 then + self.battleController:shakeScreen(shakeType, shakeTime/TIME_FACTOR) + end + end end end diff --git a/lua/app/module/battle/controller/battle_controller.lua b/lua/app/module/battle/controller/battle_controller.lua index a5f5d7fa..92ce3d4f 100644 --- a/lua/app/module/battle/controller/battle_controller.lua +++ b/lua/app/module/battle/controller/battle_controller.lua @@ -1715,6 +1715,10 @@ function BattleController:getFxNode() return self.battleUI:getFxNode() end +function BattleController:shakeScreen(shakeType, duration) + self.battleUI:shakeScreen(shakeType, duration) +end + local function _addCurRoundAttr(self, instruction, callback) if instruction.effectList then local defComp = self:getOtherSideMainUnit(BattleConst.SIDE_ATK) diff --git a/lua/app/ui/battle/battle_ui.lua b/lua/app/ui/battle/battle_ui.lua index f8d695f7..03dcb2f2 100644 --- a/lua/app/ui/battle/battle_ui.lua +++ b/lua/app/ui/battle/battle_ui.lua @@ -10,6 +10,7 @@ local BOARD_POS_UP = BF.Vector2(0, 47) local BOARD_POS_DOWN = BF.Vector2(0, -740) local BG_PATH = "assets/arts/textures/background/battle/%s.png" local CacheVector2 = CS.UnityEngine.Vector2(0, 0) +local CacheVector3 = CS.UnityEngine.Vector3(0, 0, 0) function BattleUI:getPrefabPath() return "assets/prefabs/ui/battle/battle_ui.prefab" @@ -31,11 +32,12 @@ function BattleUI:_display() self.gridNode = uiMap["battle_ui.bg_2.board_node.grid_node"] self.boardNode = uiMap["battle_ui.bg_2.board_node"] self.boardMask2D = self.gridNode:getComponent(GConst.TYPEOF_UNITY_CLASS.UI_RECT_MASK_2D) - self.boardMask = uiMap["battle_ui.bg_2.board_mask"] + self.boardMask = uiMap["battle_ui.bg_2.board_node.grid_node.board_mask"] self.boardMask:setVisible(false) self.boardCacheNode = uiMap["battle_ui.bg_2.board_cache_node"] self.boardCacheNode:setVisible(false) self.boardCacheBox = uiMap["battle_ui.bg_2.board_cache_node.skill_box"] + self.battleRoot = uiMap["battle_ui.battle_root"] self:initBg() self:initSkill() self:initBuff() @@ -49,7 +51,7 @@ end function BattleUI:_addListeners() local uiMap = self.root:genAllChildren() - uiMap["battle_ui.close_btn"]:addClickListener(function() + uiMap["battle_ui.top_node.close_btn"]:addClickListener(function() ModuleManager.BattleManager:showPauseUI() end) @@ -65,7 +67,7 @@ function BattleUI:_bind() end function BattleUI:initBg() - self.bg = self.uiMap["battle_ui.bg"] + self.bg = self.uiMap["battle_ui.battle_root.bg"] self.bg:setLocalScale(0, 0, 0) local width = self.bg:fastGetSizeDelta() self.bg:setAnchoredPositionX(width/4) @@ -330,7 +332,7 @@ function BattleUI:getBattleBuffTipsObj(index) end function BattleUI:initBattlefield() - self.battleNode = self.uiMap["battle_ui.battle_node"] + self.battleNode = self.uiMap["battle_ui.battle_root.battle_node"] end function BattleUI:getBattleNode() @@ -338,7 +340,7 @@ function BattleUI:getBattleNode() end function BattleUI:initNumberNode() - self.battleNumberNode = self.uiMap["battle_ui.battle_number_node"] + self.battleNumberNode = self.uiMap["battle_ui.battle_root.battle_number_node"] self.battleNumber = self.uiMap["battle_ui.cache_node.battle_number"] self.battleNumberRed = self.uiMap["battle_ui.cache_node.battle_number_red"] self.battleNumberGreen = self.uiMap["battle_ui.cache_node.battle_number_green"] @@ -366,7 +368,7 @@ function BattleUI:getBattleNumberYellow() end function BattleUI:initFxNode() - self.fxNode = self.uiMap["battle_ui.batttle_fx_node"] + self.fxNode = self.uiMap["battle_ui.battle_root.batttle_fx_node"] end function BattleUI:getFxNode() @@ -534,6 +536,46 @@ function BattleUI:refreshSkill(elementMap) end end +-- shakeType: 奇数是水平震动 偶数是垂直震动 +function BattleUI:shakeScreen(shakeType, duration) + self.battleRoot:setLocalPosition(0, 0, 0) + if self.shakeTween == nil then + local length = ConfigManager:getConfig("const")["shake_level_" .. math.ceil(shakeType / 2)].value + if shakeType % 2 == 0 then + CacheVector2.x = 0 + CacheVector2.y = length + self.shakeTween = self.battleRoot:getTransform():DOShakeAnchorPos(duration, CacheVector2, 100, 90, false, false) + else + CacheVector2.x = length + CacheVector2.y = 0 + self.shakeTween = self.battleRoot:getTransform():DOShakeAnchorPos(duration, CacheVector2, 100, 90, false, false) + end + self.shakeTween:SetIntId(GConst.DOTWEEN_IDS.BATTLE) + self.shakeTween:SetAutoKill(false) + self.shakeType = shakeType + self.shakeDuration = duration + elseif self.shakeType == shakeType and self.shakeDuration == duration then + self.shakeTween:Restart() + else + self.shakeTween:Kill() + local length = ConfigManager:getConfig("config")["shake_level_" .. math.ceil(shakeType / 2)].value / 100 + if shakeType % 2 == 0 then + CacheVector2.x = 0 + CacheVector2.y = length + self.shakeTween = self.battleRoot:getTransform():DOShakeAnchorPos(duration, CacheVector2, 100, 90, false, false) + else + CacheVector2.x = length + CacheVector2.y = 0 + self.shakeTween = self.battleRoot:getTransform():DOShakeAnchorPos(duration, CacheVector2, 100, 90, false, false) + end + self.shakeTween:SetIntId(GConst.DOTWEEN_IDS.BATTLE) + self.shakeTween:SetAutoKill(false) + self.shakeType = shakeType + self.shakeDuration = duration + end + self.shakeTween.timeScale = DataManager.BattleData:getTimeScale() +end + function BattleUI:initGridCell() if self.root.gridCells then self.gridCells = self.root.gridCells @@ -1160,6 +1202,10 @@ function BattleUI:clear() self.bgMoveTween:Kill() self.bgMoveTween = nil end + if self.shakeTween then + self.shakeTween:Kill() + self.shakeTween = nil + end if self.battleNumberNode then self.battleNumberNode:removeAllChildren() end diff --git a/lua/app/userdata/battle/skill/battle_skill_entity.lua b/lua/app/userdata/battle/skill/battle_skill_entity.lua index 38d464e5..109af92a 100644 --- a/lua/app/userdata/battle/skill/battle_skill_entity.lua +++ b/lua/app/userdata/battle/skill/battle_skill_entity.lua @@ -184,6 +184,14 @@ function BattleSkillEntity:getFxTargetDelay() return self.skillInfo.fx_target_delay end +function BattleSkillEntity:getShakeType() + return self.skillInfo.shake_type +end + +function BattleSkillEntity:getShakeTime() + return self.skillInfo.shake_time +end + function BattleSkillEntity:getRecordData(name) if self.recordData == nil then self.recordData = {}