Exemple #1
0
        public IEnumerator HandleInteraction(ILightInteractor interactor)
        {
            var hist = interactor.Behaviour.GetComponent <LightInteractionTracker>().History;

            if (hist != null && hist.Count > 0)
            {
                if (hist[0].Type == GetType() &&
                    hist[0].InteractableSnappedPosition == transform.position.Snapped())
                {
                    yield break;
                }
            }

            while (Vector3.Distance(transform.position, interactor.Behaviour.transform.position) > .01f)
            {
                yield return(new WaitForEndOfFrame());

                // case where something spawned too close and entered this coroutine
                if (Vector3.Distance(transform.position, interactor.Behaviour.transform.position) > 1.5f)
                {
                    yield break;
                }
            }

            SpawnLight(interactor);

            interactor.HandleDeactivation(this);
        }
Exemple #2
0
        // when a light's history is updated, it needs to search discarded interaction...
        // if type -- nonpersistentgate, fire off event to remove light from currentInteractors
        public IEnumerator HandleInteraction(ILightInteractor interactor)
        {
            interactorPos = interactor.Behaviour.transform.position.Snapped();
            collisionPos  = Helpers.GetMultiCellSnappedCollisionPos(interactor.Behaviour.transform, boxCollider2D);

            while (Vector3.Distance(interactor.Behaviour.transform.position, collisionPos) > .05f)
            {
                yield return(new WaitForEndOfFrame());
            }

            if (!gameObject.activeSelf)
            {
                yield break;
            }

            if (!currentInteractors.Contains(interactor))
            {
                currentInteractors.Add(interactor);
            }

            if (!IsUnlocked())
            {
                interactor.HandleBlockedInteraction();
                yield break;
            }

            DisableGate();
        }
Exemple #3
0
        public IEnumerator HandleInteraction(ILightInteractor interactor)
        {
            var collisionPos = Helpers.GetMultiCellSnappedCollisionPos(interactor.Behaviour.transform, boxCollider2D);

            while (Vector3.Distance(interactor.Behaviour.transform.position, collisionPos) > .05f)
            {
                yield return(new WaitForEndOfFrame());
            }

            if (!gameObject.activeSelf)
            {
                yield break;
            }

            if (!interactors.Contains(interactor))
            {
                interactors.Add(interactor);
            }

            if (!HasBeenUnlockd())
            {
                GetMovement(interactor).enabled = false;
                yield break;
            }

            foreach (var lightInteractor in interactors)
            {
                GetMovement(lightInteractor).enabled = true;
            }

            gameObject.SetActive(false);
        }
Exemple #4
0
        public IEnumerator HandleInteraction(ILightInteractor interactor)
        {
            var collisionPos = Helpers.GetMultiCellSnappedCollisionPos(interactor.Behaviour.transform, boxCollider2D);

            while (Vector3.Distance(interactor.Behaviour.transform.position, collisionPos) > .05f)
            {
                yield return(new WaitForEndOfFrame());
            }
            interactor.HandleBlockedInteraction();
            yield break;
        }
Exemple #5
0
        public IEnumerator HandleInteraction(ILightInteractor interactor)
        {
            print("Handling Wall Interaction");
            var collisionPos = Helpers.GetMultiCellSnappedCollisionPos(interactor.Behaviour.transform, tilemapCollider2D);

            colPos   = collisionPos;
            interPos = interactor.Behaviour.transform.position;

            while (Vector3.Distance(interactor.Behaviour.transform.position, collisionPos) > .1f)
            {
                yield return(new WaitForEndOfFrame());
            }

            interactor.HandleBlockedInteraction();
        }
Exemple #6
0
        private void SpawnLight(ILightInteractor interactor)
        {
            var lightHistory = interactor.Behaviour.GetComponent <IInteractionTracker>().History;
            var lightColor   = interactor.Behaviour.GetComponent <ILightColor>().LightColor;

            var lightInstance = Instantiate(lightPrefab, transform.position, GetLightRotationPositive());

            lightInstance.transform.SetParent(transform);
            lightInstance.GetComponent <IInteractionTracker>().InitializeHistory(lightHistory);
            lightInstance.GetComponent <ILightColor>().UpdateLightColor(lightColor);

            var otherLightInstance = Instantiate(lightPrefab, transform.position, GetLightRotationNegative());

            otherLightInstance.transform.SetParent(transform);
            otherLightInstance.GetComponent <IInteractionTracker>().InitializeHistory(lightHistory);
            otherLightInstance.GetComponent <ILightColor>().UpdateLightColor(lightColor);
        }
Exemple #7
0
        private void HandleInteractionRemoved(Vector3 interactableSnappedPos, ILightInteractor interactor)
        {
            if (interactableSnappedPos.Snapped() != transform.position.Snapped())
            {
                return;
            }

            if (currentInteractors.Contains(interactor))
            {
                currentInteractors.Remove(interactor);
                interactor.HandleUnblockedInteraction();
            }

            if (IsUnlocked())
            {
                return;
            }
            ReEnableGate();
        }
Exemple #8
0
        public IEnumerator HandleInteraction(ILightInteractor interactor)
        {
            currentInteractor = interactor;
            while (Vector3.Distance(interactor.Behaviour.transform.position, transform.position) > .05f)
            {
                yield return(new WaitForEndOfFrame());
            }

            if (rotationInteraction != null)
            {
                // stop movement if mirror is currently rotating
                interactor.Behaviour.GetComponent <LightMovement>().enabled = false;
                while (rotationInteraction.Rotating)
                {
                    yield return(new WaitForEndOfFrame());
                }
            }

            interactor.Behaviour.transform.SetPositionAndRotation(transform.position.Snapped(), transform.rotation);
            interactor.HandleUnblockedInteraction();
            interactor.HandleReactivation();
            currentInteractor = null;
        }
Exemple #9
0
 private void HandleInteractionRemoved(Vector3 interactableSnappedPos, ILightInteractor interactor)
 {
     // if(interactableSnappedPos == transform.position.Snapped())
     //     interactor.HandleReactivation(this);
 }
Exemple #10
0
 private LightMovement GetMovement(ILightInteractor interactor) =>
 interactor.Behaviour.GetComponent <LightMovement>();
Exemple #11
0
 public IEnumerator HandleInteraction(ILightInteractor interactor)
 {
     LevelManager.Instance.LoadNext();
     yield break;
 }