章节障碍物和棋盘地图

This commit is contained in:
xiekaidong 2023-04-25 18:38:49 +08:00
parent f8044eb0de
commit c30fe950b2
7 changed files with 71 additions and 7 deletions

View File

@ -161,6 +161,15 @@ function BattleController:onEliminationBegin()
end
---- 障碍格子图片
function BattleController:getBlockIcon()
return "battle_hinder_4"
end
function BattleController:getChessBoardBgName()
return "chessboard_1"
end
-- *************各个子模块的战斗需要重写的方法 END*************
function BattleController:ctor()
@ -258,6 +267,7 @@ function BattleController:prepareFight()
self.battleUI:getBattleNumberBlue())
self:initAtkUnits(onPreloadFinished)
self:initDefUnits(onPreloadFinished)
self.battleUI:refreshChessBoard(self:getChessBoardBgName())
end)
BattleHelper:setBaseOrder(self.battleUI:getUIOrder())
self:loadOtherRes(onPreloadFinished)
@ -1145,7 +1155,7 @@ function BattleController:generateBoard(isFirst)
self.curBoardIndex = (self.curBoardIndex or 0) + 1
local board = boardList[self.curBoardIndex]
self.battleUI:switchBoard(function()
self.battleData:refreshBoard(board)
self.battleData:refreshBoard(board, self:getBlockIcon())
self.battleUI:initGridCell()
end, function()
-- self:enterRoundBegin()

View File

@ -8,11 +8,30 @@ function BattleControllerStage:getChapterId()
end
function BattleControllerStage:getMaxWave()
local chapterId = DataManager.ChapterData:getChapterId()
local chapterInfo = ConfigManager:getConfig("chapter")[chapterId]
local chapterInfo = ConfigManager:getConfig("chapter")[self.chapterId]
if not chapterInfo then
return 0
end
return #chapterInfo.monster
end
function BattleControllerStage:getBlockIcon()
local chapterInfo = ConfigManager:getConfig("chapter")[self.chapterId]
if not chapterInfo then
return "battle_hinder_4"
end
return chapterInfo.block_icon
end
function BattleControllerStage:getChessBoardBgName()
local chapterInfo = ConfigManager:getConfig("chapter")[self.chapterId]
if not chapterInfo then
return "chessboard_1"
end
return chapterInfo.chess_board
end
function BattleController:initOther()
end

View File

@ -1,6 +1,7 @@
local BattleSkillSelectUI = class("BattleSkillSelectUI", BaseUI)
local SELECT_SKILL_CELL = "app/ui/battle/cell/battle_select_skill_cell"
local BATTLE_COMMON_PATH = "assets/arts/textures/background/battle_common/%s.png"
local SKILL_ICON_POS = {
{x =-240, y= 165},
@ -32,7 +33,16 @@ end
function BattleSkillSelectUI:_display()
local uiMap = self.root:genAllChildren()
uiMap["battle_skill_select_ui.skill_node.ad_btn.tx"]:setText(I18N:getGlobalText(I18N.GlobalConst.BATTLE_DESC_3))
uiMap["battle_skill_select_ui.bg_1"]:setVisible(true)
local bg = uiMap["battle_skill_select_ui.bg_1"]
if ModuleManager.BattleManager.battleController then
bg:setVisible(false)
bg:setTexture(string.format(BATTLE_COMMON_PATH, ModuleManager.BattleManager.battleController:getChessBoardBgName() .. "_1"), function()
bg:setVisible(true)
end)
else
bg:setVisible(true)
end
self:refreshRogueSkill()
end

View File

@ -1,5 +1,4 @@
local UIPrefabObject = require "app/bf/unity/uiprefab_object"
local BattleUI = class("BattleUI", BaseUI)
local GRID_CELL = "app/ui/battle/cell/grid_cell"
local GRID_CELL_PATH = "assets/prefabs/ui/battle/cell/grid_cell.prefab"
@ -14,6 +13,7 @@ local CacheVector2 = CS.UnityEngine.Vector2(0, 0)
local CACHE_SKILL_POS_1 = {x = 0, y = 360}
local CACHE_SKILL_POS_2 = {x = 0, y = 420}
local BATTLE_COMMON_PATH = "assets/arts/textures/background/battle_common/%s.png"
function BattleUI:getPrefabPath()
return "assets/prefabs/ui/battle/battle_ui.prefab"
@ -38,6 +38,7 @@ function BattleUI:_display()
self.uiMap = uiMap
self.gridNode = uiMap["battle_ui.bg_2.board_node.grid_node"]
self.boardNode = uiMap["battle_ui.bg_2.board_node"]
self.boardNode:setAnchoredPositionX(DEFAULT_X)
self.boardMask2D = self.gridNode:getComponent(GConst.TYPEOF_UNITY_CLASS.UI_RECT_MASK_2D)
self.boardMask = uiMap["battle_ui.bg_2.board_node.grid_node.board_mask"]
self.boardMask:setVisible(false)
@ -85,6 +86,12 @@ function BattleUI:initBg()
self.bg:setAnchoredPositionX(width/4)
end
function BattleUI:refreshChessBoard(boardBg)
self.boardNode:setTexture(string.format(BATTLE_COMMON_PATH, boardBg), function()
self.boardNode:setAnchoredPositionX(0)
end)
end
function BattleUI:loadBg(bgName)
self.bg:setTexture(string.format(BG_PATH, bgName), function()
self.bg:setLocalScale(1, 1, 1)

View File

@ -20,7 +20,12 @@ function GridCell:refresh(gridEntity, curElement, skillPosId)
self.curElement = curElement
uiMap["grid_cell.touch_node.ani_node.obstacle"]:setVisible(gridEntity:isObstacleType())
local obstacleObj = uiMap["grid_cell.touch_node.ani_node.obstacle"]
obstacleObj:setVisible(gridEntity:isObstacleType())
if self.lastObstacleIcon ~= gridEntity:getObstacleIcon() then
self.lastObstacleIcon = gridEntity:getObstacleIcon()
obstacleObj:setSprite(GConst.ATLAS_PATH.BATTLE, self.lastObstacleIcon)
end
if self.lastGridType ~= gridEntity:getGridType() then
self.lastGridType = gridEntity:getGridType()

View File

@ -116,7 +116,7 @@ function BattleData:initRogueSkills()
end
end
function BattleData:refreshBoard(board)
function BattleData:refreshBoard(board, blockIcon)
self.elementTypeMap = {}
for i, info in ipairs(board) do
local r = 1
@ -148,6 +148,7 @@ function BattleData:refreshBoard(board)
self.elementTypeMap[data.elementType] = (self.elementTypeMap[data.elementType] or 0) + 1
end
self.gridEntities[data.posId]:determineIdleStatus()
self.gridEntities[data.posId]:setObstacleIcon(blockIcon)
end
end

View File

@ -226,4 +226,16 @@ function BattleGridEntity:determineIdleStatus()
end
end
function BattleGridEntity:getObstacleIcon()
if not self.obstacleIcon then
return "battle_hinder_1"
end
return self.obstacleIcon
end
function BattleGridEntity:setObstacleIcon(icon)
self.obstacleIcon = icon
end
return BattleGridEntity