修改格子计算方式

This commit is contained in:
xiekaidong 2023-06-26 11:13:13 +08:00
parent 68f9a47e00
commit eb7d04a5dc
2 changed files with 12 additions and 56 deletions

View File

@ -2,6 +2,7 @@ local BattleConst = {}
BattleConst.ROW_COUNT = 7
BattleConst.COLUMN_COUNT = 7
BattleConst.PVP_COLUMN_COUNT = 10
BattleConst.HALF_ROW_COUNT = 4 -- 计算偏移 math.ceil(ROW_COUNT / 2)
BattleConst.HALF_COLUMN_COUNT = 4 -- 计算偏移 math.ceil(COLUMN_COUNT / 2)
BattleConst.GRID_STEP_H = 94
@ -81,6 +82,7 @@ BattleConst.BATTLE_TYPE = {
DAILY_CHALLENGE = "2",
DUNGEON_GOLD = "3",
DUNGEON_SHARDS = "4",
ARENA = "5",
}
BattleConst.TYPEOF_LUA_COMP = {
@ -494,57 +496,7 @@ BattleConst.POS_ID_2_RC = {}
BattleConst.RC_2_POS_ID = {}
---- 格子位置
BattleConst.GRID_POS = {
[11] = {x = -282, y = 282},
[12] = {x = -188, y = 282},
[13] = {x = -94, y = 282},
[14] = {x = 0, y = 282},
[15] = {x = 94, y = 282},
[16] = {x = 188, y = 282},
[17] = {x = 282, y = 282},
[21] = {x = -282, y = 188},
[22] = {x = -188, y = 188},
[23] = {x = -94, y = 188},
[24] = {x = 0, y = 188},
[25] = {x = 94, y = 188},
[26] = {x = 188, y = 188},
[27] = {x = 282, y = 188},
[31] = {x = -282, y = 94},
[32] = {x = -188, y = 94},
[33] = {x = -94, y = 94},
[34] = {x = 0, y = 94},
[35] = {x = 94, y = 94},
[36] = {x = 188, y = 94},
[37] = {x = 282, y = 94},
[41] = {x = -282, y = 0},
[42] = {x = -188, y = 0},
[43] = {x = -94, y = 0},
[44] = {x = 0, y = 0},
[45] = {x = 94, y = 0},
[46] = {x = 188, y = 0},
[47] = {x = 282, y = 0},
[51] = {x = -282, y = -94},
[52] = {x = -188, y = -94},
[53] = {x = -94, y = -94},
[54] = {x = 0, y = -94},
[55] = {x = 94, y = -94},
[56] = {x = 188, y = -94},
[57] = {x = 282, y = -94},
[61] = {x = -282, y = -188},
[62] = {x = -188, y = -188},
[63] = {x = -94, y = -188},
[64] = {x = 0, y = -188},
[65] = {x = 94, y = -188},
[66] = {x = 188, y = -188},
[67] = {x = 282, y = -188},
[71] = {x = -282, y = -282},
[72] = {x = -188, y = -282},
[73] = {x = -94, y = -282},
[74] = {x = 0, y = -282},
[75] = {x = 94, y = -282},
[76] = {x = 188, y = -282},
[77] = {x = 282, y = -282},
}
BattleConst.GRID_POS = {}
---- 每个格子外围一格距离的格子
BattleConst.GRID_OUT_LINE_POS_ID = {

View File

@ -113,18 +113,22 @@ end
----------------------- start 一些公共相关的方法 -----------------------------
function BattleManager:getPosInfo(posId)
local posInfo = GConst.BattleConst.GRID_POS[posId]
function BattleManager:getPosInfo(posId, rowCount)
rowCount = rowCount or BattleConst.ROW_COUNT
if not GConst.BattleConst.GRID_POS[rowCount] then
GConst.BattleConst.GRID_POS[rowCount] = {}
end
local posInfo = GConst.BattleConst.GRID_POS[rowCount][posId]
if not posInfo then
local r = self:getPosRC(posId).r
local c = self:getPosRC(posId).c
local offsetC = c - BattleConst.HALF_COLUMN_COUNT
local offsetC = c - (rowCount + 1) / 2
local offsetR = BattleConst.HALF_ROW_COUNT - r
local info = {x = offsetC * BattleConst.GRID_STEP_H, y = offsetR * BattleConst.GRID_STEP_H}
GConst.BattleConst.GRID_POS[posId] = info
posInfo = GConst.BattleConst.GRID_POS[posId]
GConst.BattleConst.GRID_POS[rowCount][posId] = info
posInfo = GConst.BattleConst.GRID_POS[rowCount][posId]
end
return posInfo
end