コード例 #1
0
        GameObject SetupCollider(string name, int layer, Vector2 position, Vector2 size)
        {
            var go        = GameObjectHelpers.Create(name, layer);
            var transform = go.GetComponent <Transform>();

            transform.position = position;
            go.AddComponent <Rigidbody2D>();
            var boxCollider = go.AddComponent <BoxCollider2D>();

            boxCollider.size = size;
            return(go);
        }
コード例 #2
0
        public void ItReturnsSameHitOnNextGetUniqueCall()
        {
            var gameObject   = GameObjectHelpers.Create("factory");
            var omitCollider = gameObject.GetComponent <Collider2D>();
            var factory      = CollisionMoveHitsFactory.Create(omitCollider);

            var hitGameObject = GameObjectHelpers.CreateCollider("collider", Vector2.zero, Vector2.one);
            var collider      = hitGameObject.GetComponent <Collider2D>();
            var point         = Vector2.one;
            var normal        = Vector2.up;
            var distance      = 1;

            var hits = new RaycastHit2D[1] {
                RaycastHitHelpers.MockHit(collider, point, normal, distance)
            };
            var count            = 1;
            var firstCallResult  = factory.GetUnique(hits, count);
            var secondCallResult = factory.GetUnique(hits, count);

            Assert.That(firstCallResult[0].collider, Is.EqualTo(secondCallResult[0].collider));
        }
コード例 #3
0
        public void ItFiltersHitsWithSameCollider()
        {
            var gameObject   = GameObjectHelpers.Create("factory");
            var omitCollider = gameObject.GetComponent <Collider2D>();
            var factory      = CollisionMoveHitsFactory.Create(omitCollider);

            var hitGameObject = GameObjectHelpers.CreateCollider("collider", Vector2.zero, Vector2.one);
            var collider      = hitGameObject.GetComponent <Collider2D>();
            var point         = Vector2.one;
            var normal        = Vector2.up;
            var distance      = 1;

            var hits = new RaycastHit2D[2] {
                RaycastHitHelpers.MockHit(collider, point, normal, distance),
                RaycastHitHelpers.MockHit(collider, point, normal, distance)
            };
            var count  = 2;
            var result = factory.GetUnique(hits, count);

            Assert.That(result.Count, Is.EqualTo(1));
        }
コード例 #4
0
 public void TearDown()
 {
     GameObjectHelpers.Clear();
 }