Exemple #1
0
 private void DeselectInteractable()
 {
     if (_selectedInteractable != null)
     {
         OnDeselectInteractable.Invoke(Master, _selectedInteractable);
         _selectedInteractable = null;
     }
 }
Exemple #2
0
 private void SelectInteractable(ITInteractable interactable)
 {
     if (_selectedInteractable != interactable)
     {
         if (_selectedInteractable != null)
         {
             OnDeselectInteractable.Invoke(Master, _selectedInteractable);
         }
         _selectedInteractable = interactable;
         OnSelectInteractable?.Invoke(Master, _selectedInteractable);
     }
 }
            private void OnDeselectInteractable(TEntity master, ITInteractable interactable)
            {
                interactable.Widget.SetActive(false);

                //I would have not done that on a true project.
                for (int i = 0; i < interactable.SpriteRenderers.Length; i++)
                {
                    Transform t = interactable.SpriteRenderers[i].transform.Find(SELECTION_DISPLAYER_NAME);
                    if (t != null)
                    {
                        Destroy(t.gameObject);
                    }
                }
            }
            private void OnSelectInteractable(TEntity master, ITInteractable interactable)
            {
                interactable.Widget.SetActive(true);

                //I would never have not done that on a true project.
                for (int i = 0; i < interactable.SpriteRenderers.Length; i++)
                {
                    GameObject selectionDisplay = new GameObject(SELECTION_DISPLAYER_NAME);
                    selectionDisplay.transform.SetParent(interactable.SpriteRenderers[i].transform);
                    selectionDisplay.transform.localPosition = default;
                    selectionDisplay.transform.localRotation = default;
                    selectionDisplay.transform.localScale    = Vector3.one * 1.05f;
                    SpriteRenderer rend = selectionDisplay.AddComponent <SpriteRenderer>();
                    rend.sprite = interactable.SpriteRenderers[i].sprite;
                    rend.color  = Color.black;
                    TSpriteOrderer orderer = selectionDisplay.AddComponent <TSpriteOrderer>();
                    orderer.SetOrderInLayerForcedOffset(-1);
                }
            }
Exemple #5
0
            private void HandleComputeNearestInteractable()
            {
                Collider2D coll = Physics2D.OverlapCircle(Position, _data._interactionDistance, _data._whatIsInteractable);

                if (coll == null)
                {
                    DeselectInteractable();
                    return;
                }

                ITInteractable interactable = coll.GetComponentInParent <ITInteractable>();

                if (interactable != null)
                {
                    SelectInteractable(interactable);
                }
                else
                {
                    DeselectInteractable();
                }
            }
Exemple #6
0
 private void OnStartInteract(TEntity master, ITInteractable interactable)
 {
     References.Rigidbody.velocity = Vector2.zero;
     _movementDirection            = TMovementDirection.None;
 }
Exemple #7
0
 private void OnInteractableStopInteraction(ITInteractable interactable)
 {
     _interactionState            = TInteractionState.None;
     interactable.OnStopInteract -= OnInteractableStopInteraction;
     OnStopInteract?.Invoke(Master, interactable);
 }