|
|
|
|
|
|
Vector3Int gridSize, |
|
|
|
bool rotateWithAgent, |
|
|
|
LayerMask colliderMask, |
|
|
|
GameObject rootReference, |
|
|
|
GameObject centerObject, |
|
|
|
GameObject agentGameObject, |
|
|
|
string[] detectableTags, |
|
|
|
int initialColliderBufferSize, |
|
|
|
int maxColliderBufferSize |
|
|
|
|
|
|
rotateWithAgent, |
|
|
|
colliderMask, |
|
|
|
rootReference, |
|
|
|
centerObject, |
|
|
|
agentGameObject, |
|
|
|
detectableTags, |
|
|
|
initialColliderBufferSize, |
|
|
|
maxColliderBufferSize) |
|
|
|
|
|
|
int gridSizeX = 10, |
|
|
|
int gridSizeZ = 10, |
|
|
|
bool rotateWithAgent = true, |
|
|
|
GameObject rootReference = null, |
|
|
|
GameObject centerObject = null, |
|
|
|
GameObject agentGameObject = null, |
|
|
|
string[] detectableTags = null, |
|
|
|
int initialColliderBufferSize = 4, |
|
|
|
int maxColliderBufferSize = 500) |
|
|
|
|
|
|
new Vector3Int(gridSizeX, 1, gridSizeZ), |
|
|
|
rotateWithAgent, |
|
|
|
LayerMask.GetMask("Default"), |
|
|
|
rootReference, |
|
|
|
centerObject, |
|
|
|
agentGameObject, |
|
|
|
detectableTags, |
|
|
|
initialColliderBufferSize, |
|
|
|
maxColliderBufferSize); |
|
|
|
|
|
|
{ |
|
|
|
var testGo = new GameObject("test"); |
|
|
|
testGo.transform.position = Vector3.zero; |
|
|
|
var boxOverlapSquare = TestBoxOverlapChecker.CreateChecker(gridSizeX: 10, gridSizeZ: 10, rotateWithAgent: false, rootReference: testGo); |
|
|
|
var boxOverlapSquare = TestBoxOverlapChecker.CreateChecker(gridSizeX: 10, gridSizeZ: 10, rotateWithAgent: false, agentGameObject: testGo); |
|
|
|
|
|
|
|
var localPos = boxOverlapSquare.CellLocalPositions; |
|
|
|
Assert.AreEqual(new Vector3(-4.5f, 0, -4.5f), localPos[0]); |
|
|
|
|
|
|
|
|
|
|
var testGo2 = new GameObject("test"); |
|
|
|
testGo2.transform.position = new Vector3(3.5f, 8f, 17f); // random, should have no effect on local positions
|
|
|
|
var boxOverlapRect = TestBoxOverlapChecker.CreateChecker(gridSizeX: 5, gridSizeZ: 15, rotateWithAgent: true, rootReference: testGo); |
|
|
|
var boxOverlapRect = TestBoxOverlapChecker.CreateChecker(gridSizeX: 5, gridSizeZ: 15, rotateWithAgent: true, agentGameObject: testGo); |
|
|
|
|
|
|
|
localPos = boxOverlapRect.CellLocalPositions; |
|
|
|
Assert.AreEqual(new Vector3(-2f, 0, -7f), localPos[0]); |
|
|
|
|
|
|
var testGo = new GameObject("test"); |
|
|
|
var position = new Vector3(3.5f, 8f, 17f); |
|
|
|
testGo.transform.position = position; |
|
|
|
var boxOverlap = TestBoxOverlapChecker.CreateChecker(gridSizeX: 10, gridSizeZ: 10, rotateWithAgent: false, rootReference: testGo); |
|
|
|
var boxOverlap = TestBoxOverlapChecker.CreateChecker(gridSizeX: 10, gridSizeZ: 10, rotateWithAgent: false, agentGameObject: testGo, centerObject: testGo); |
|
|
|
|
|
|
|
Assert.AreEqual(new Vector3(-4.5f, 0, -4.5f) + position, boxOverlap.GetCellGlobalPosition(0)); |
|
|
|
Assert.AreEqual(new Vector3(-4.5f, 0, 4.5f) + position, boxOverlap.GetCellGlobalPosition(9)); |
|
|
|
|
|
|
var testGo = new GameObject("test"); |
|
|
|
var position = new Vector3(15f, 6f, 13f); |
|
|
|
testGo.transform.position = position; |
|
|
|
var boxOverlap = TestBoxOverlapChecker.CreateChecker(gridSizeX: 5, gridSizeZ: 15, rotateWithAgent: true, rootReference: testGo); |
|
|
|
var boxOverlap = TestBoxOverlapChecker.CreateChecker(gridSizeX: 5, gridSizeZ: 15, rotateWithAgent: true, agentGameObject: testGo, centerObject: testGo); |
|
|
|
|
|
|
|
Assert.AreEqual(new Vector3(-2f, 0, -7f) + position, boxOverlap.GetCellGlobalPosition(0)); |
|
|
|
Assert.AreEqual(new Vector3(-2f, 0, 7f) + position, boxOverlap.GetCellGlobalPosition(14)); |
|
|
|
|
|
|
var testGo = new GameObject("test"); |
|
|
|
testGo.transform.position = Vector3.zero; |
|
|
|
testObjects.Add(testGo); |
|
|
|
var boxOverlap = TestBoxOverlapChecker.CreateChecker(rootReference: testGo, initialColliderBufferSize: 2, maxColliderBufferSize: 5); |
|
|
|
var boxOverlap = TestBoxOverlapChecker.CreateChecker(agentGameObject: testGo, centerObject: testGo, initialColliderBufferSize: 2, maxColliderBufferSize: 5); |
|
|
|
boxOverlap.Update(); |
|
|
|
Assert.AreEqual(2, boxOverlap.ColliderBuffer.Length); |
|
|
|
|
|
|
|
|
|
|
cellScaleZ: 10f, |
|
|
|
gridSizeX: 2, |
|
|
|
gridSizeZ: 2, |
|
|
|
rootReference: testGo, |
|
|
|
agentGameObject: testGo, |
|
|
|
centerObject: testGo, |
|
|
|
detectableTags: new [] { tag1 }); |
|
|
|
var helper = new VerifyParseCollidersHelper(); |
|
|
|
boxOverlap.GridOverlapDetectedClosest += helper.DetectedAction; |
|
|
|
|
|
|
cellScaleZ: 10f, |
|
|
|
gridSizeX: 2, |
|
|
|
gridSizeZ: 2, |
|
|
|
rootReference: testGo, |
|
|
|
agentGameObject: testGo, |
|
|
|
centerObject: testGo, |
|
|
|
detectableTags: new [] { tag1 }); |
|
|
|
var helper = new VerifyParseCollidersHelper(); |
|
|
|
boxOverlap.GridOverlapDetectedAll += helper.DetectedAction; |
|
|
|