Пример #1
0
        protected virtual void OnInteractableAdded(GameObject interactable)
        {
            offsetDistanceComparator.source  = interactable;
            offsetDistanceComparator.target  = interactable;
            offsetDistanceComparator.enabled = interactable != null;
            offsetDistanceComparator.SavePosition();

            if (interactable != null)
            {
                facade.bodyRepresentationFacade.Interest = BodyRepresentationInternalSetup.MovementInterest.CharacterController;
            }
        }
Пример #2
0
        public void ProcessSourceTargetEquals()
        {
            UnityEventListenerMock thresholdExceededMock = new UnityEventListenerMock();
            UnityEventListenerMock thresholdResumedMock  = new UnityEventListenerMock();

            subject.ThresholdExceeded.AddListener(thresholdExceededMock.Listen);
            subject.ThresholdResumed.AddListener(thresholdResumedMock.Listen);

            GameObject target = new GameObject();

            subject.Source            = target;
            subject.Target            = target;
            subject.DistanceThreshold = 0.5f;

            target.transform.position = Vector3.zero;

            subject.Process();

            Assert.IsFalse(thresholdExceededMock.Received);
            Assert.IsFalse(thresholdResumedMock.Received);
            Assert.IsFalse(subject.Exceeding);
            Assert.AreEqual(Vector3.zero, subject.Difference);
            Assert.AreEqual(0f, subject.Distance);

            target.transform.position = Vector3.forward * 1f;

            subject.Process();

            Assert.IsTrue(thresholdExceededMock.Received);
            Assert.IsFalse(thresholdResumedMock.Received);
            Assert.IsTrue(subject.Exceeding);
            Assert.AreEqual(Vector3.forward * 1f, subject.Difference);
            Assert.AreEqual(1f, subject.Distance);

            thresholdExceededMock.Reset();
            thresholdResumedMock.Reset();
            subject.SavePosition();

            target.transform.position = Vector3.zero;

            subject.Process();

            Assert.IsTrue(thresholdExceededMock.Received);
            Assert.IsFalse(thresholdResumedMock.Received);
            Assert.IsTrue(subject.Exceeding);
            Assert.AreEqual(Vector3.forward * -1f, subject.Difference);
            Assert.AreEqual(1f, subject.Distance);

            Object.DestroyImmediate(target);
        }