Merge pull request #824 from argonui/token-spawning
Updated token offsets for 2 / 3 / 4 tokens
This commit is contained in:
commit
ee95af53d1
@ -1995,32 +1995,36 @@ end
|
|||||||
-- Generates the offsets for tokens on a card (clues on locations are different and have their own function)
|
-- Generates the offsets for tokens on a card (clues on locations are different and have their own function)
|
||||||
---@param maxTokens number Maximum amount of tokens on a card
|
---@param maxTokens number Maximum amount of tokens on a card
|
||||||
function TokenManager.generateOffsets(maxTokens)
|
function TokenManager.generateOffsets(maxTokens)
|
||||||
tokenOffsets = {}
|
tokenOffsets = {
|
||||||
for numTokens = 1, maxTokens do
|
[1] = { Vector(0, 3, -0.2) },
|
||||||
if numTokens == 1 then
|
[2] = { Vector(0.4, 3, -0.2), Vector(-0.4, 3, -0.2) },
|
||||||
tokenOffsets[1] = { Vector(0, 3, -0.2) }
|
[3] = { Vector(0, 3, -0.9), Vector(0.4, 3, -0.2), Vector(-0.4, 3, -0.2) },
|
||||||
else
|
[4] = { Vector(0.4, 3, -0.9), Vector(-0.4, 3, -0.9), Vector(0.4, 3, -0.2), Vector(-0.4, 3, -0.2) }
|
||||||
local offsets = {}
|
}
|
||||||
local rows = math.min(4, math.ceil(numTokens / 3))
|
|
||||||
local tokensPlaced = 0
|
-- generate offsets for numTokens > 4 dynamically
|
||||||
for row = 1, rows do
|
for numTokens = 5, maxTokens do
|
||||||
local y = 3
|
local offsets = {}
|
||||||
local z = -0.9 + (row - 1) * 0.7
|
local rows = math.min(4, math.ceil(numTokens / 3))
|
||||||
local tokensInRow = math.min(3, numTokens - tokensPlaced)
|
local tokensPlaced = 0
|
||||||
for col = 1, tokensInRow do
|
for row = 1, rows do
|
||||||
local x = 0
|
local y = 3
|
||||||
if tokensInRow == 2 then
|
local z = -0.9 + (row - 1) * 0.7
|
||||||
x = col == 1 and -0.4 or 0.4
|
local tokensInRow = math.min(3, numTokens - tokensPlaced)
|
||||||
elseif tokensInRow == 3 then
|
for col = 1, tokensInRow do
|
||||||
x = (col - 2) * 0.7
|
local x = 0
|
||||||
end
|
if tokensInRow == 2 then
|
||||||
table.insert(offsets, Vector(x, y, z))
|
x = col == 1 and -0.4 or 0.4
|
||||||
tokensPlaced = tokensPlaced + 1
|
elseif tokensInRow == 3 then
|
||||||
|
x = (col - 2) * 0.7
|
||||||
end
|
end
|
||||||
|
table.insert(offsets, Vector(x, y, z))
|
||||||
|
tokensPlaced = tokensPlaced + 1
|
||||||
end
|
end
|
||||||
tokenOffsets[numTokens] = offsets
|
|
||||||
end
|
end
|
||||||
|
tokenOffsets[numTokens] = offsets
|
||||||
end
|
end
|
||||||
|
return tokenOffsets
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Spawns tokens for the card. This function is built to just throw a card at it and let it do
|
-- Spawns tokens for the card. This function is built to just throw a card at it and let it do
|
||||||
|
Loading…
x
Reference in New Issue
Block a user