updated code
This commit is contained in:
parent
b096007b10
commit
8d8dc93d47
@ -94,7 +94,7 @@ function takeCardIntoThreatArea(playerColor, hoveredObject)
|
|||||||
local data = {
|
local data = {
|
||||||
object = obj,
|
object = obj,
|
||||||
localPos = hoveredObject.positionToLocal(obj.getPosition()),
|
localPos = hoveredObject.positionToLocal(obj.getPosition()),
|
||||||
localRotY = cardRot.y - obj.getRotation().y
|
localRot = obj.getRotation() - cardRot
|
||||||
}
|
}
|
||||||
table.insert(additionalObjects, data)
|
table.insert(additionalObjects, data)
|
||||||
end
|
end
|
||||||
@ -109,7 +109,7 @@ function takeCardIntoThreatArea(playerColor, hoveredObject)
|
|||||||
|
|
||||||
-- work out the new rotation
|
-- work out the new rotation
|
||||||
local matRotation = playermatApi.returnRotation(matColor)
|
local matRotation = playermatApi.returnRotation(matColor)
|
||||||
local newCardRot = cardRot:setAt("y", matRotation.y + ownerRotation.y - cardRot.y)
|
local newCardRot = cardRot:setAt("y", matRotation.y + cardRot.y - ownerRotation.y)
|
||||||
|
|
||||||
-- move the main card to threat area
|
-- move the main card to threat area
|
||||||
hoveredObject.setRotation(newCardRot)
|
hoveredObject.setRotation(newCardRot)
|
||||||
@ -118,7 +118,10 @@ function takeCardIntoThreatArea(playerColor, hoveredObject)
|
|||||||
-- move tokens/tiles (to new global position)
|
-- move tokens/tiles (to new global position)
|
||||||
for _, data in ipairs(additionalObjects) do
|
for _, data in ipairs(additionalObjects) do
|
||||||
data.object.setPosition(hoveredObject.positionToWorld(data.localPos))
|
data.object.setPosition(hoveredObject.positionToWorld(data.localPos))
|
||||||
data.object.setRotation(newCardRot.y + data.localRotY)
|
|
||||||
|
local newRot = data.localRot + Vector(0, newCardRot.y, 0)
|
||||||
|
newRot.y = roundToMultiple(newRot.y, 45)
|
||||||
|
data.object.setRotation(newRot)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- contruct feedback message (hide name when face-down + enabled setting)
|
-- contruct feedback message (hide name when face-down + enabled setting)
|
||||||
@ -576,3 +579,7 @@ function getFirstSeatedPlayer()
|
|||||||
return color
|
return color
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function roundToMultiple(num, mult)
|
||||||
|
return math.floor((num + mult / 2) / mult) * mult
|
||||||
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user