void LookForCombinables()
    {
        if (m_combinables.Count != 0)
        {
            m_closestCombinable = null;
            float distance = 0;

            foreach (ICombinable combinable in m_combinables)
            {
                if (m_closestCombinable == null)
                {
                    m_closestCombinable = combinable;
                    distance            = Vector3.Distance(transform.position, m_closestCombinable.GetTransform().position);
                }
                else if (Vector3.Distance(transform.position, combinable.GetTransform().position) < distance)
                {
                    m_closestCombinable = combinable;
                    distance            = Vector3.Distance(transform.position, m_closestCombinable.GetTransform().position);
                }
            }

            EventSystem.InteractionEvents.SetInteractionPopup(true, m_closestCombinable.GetTransform(), m_ClosestCombinable.GetPopupOffset(), m_closestCombinable.GetCombinationMessage());

            if (Vector3.Distance(transform.position, m_closestCombinable.GetTransform().position) > m_radius)
            {
                EventSystem.InteractionEvents.SetInteractionPopup(false, null, Vector3.zero, string.Empty);
                m_closestCombinable = null;
            }
        }
        else
        {
            m_closestCombinable = null;
        }
    }
示例#2
0
    public GrabbableData(IGrabbable grabbable, Transform transform)
    {
        this.grabbable = grabbable;
        this.transform = transform;

        combinable    = transform.GetComponent <ICombinable>();
        canBeCombined = combinable == null ? false : true;
        shakable      = transform.GetComponent <IShakable>();
    }
    void OnTriggerExit(Collider other)
    {
        IInteractable interactable = other.GetComponent <IInteractable>();

        if (interactable != null && m_interactables.Contains(interactable))
        {
            m_interactables.Remove(interactable);
        }

        ICombinable combinable = other.GetComponent <ICombinable>();

        if (combinable != null)
        {
            m_combinables.Remove(combinable);
        }
    }
    void OnTriggerEnter(Collider other)
    {
        IInteractable interactable = other.GetComponent <IInteractable>();

        if (interactable != null)
        {
            m_interactables.Add(interactable);
        }

        ICombinable combinable = other.GetComponent <ICombinable>();

        if (combinable != null)
        {
            m_combinables.Add(combinable);
        }
    }
示例#5
0
    void Interact()
    {
        if (m_HoldingObject)
        {
            ICombinable combinable = m_InteractableSensor.m_ClosestCombinable;

            if (combinable != null)
            {
                combinable.Combine(m_HeldRigidbody);
                DropHeldObject();
            }
        }
        else
        {
            IInteractable interactable = m_InteractableSensor.m_ClosestInteractable;

            if (interactable != null)
            {
                interactable.Interact();
            }
        }
    }
示例#6
0
 public SectionCombiner AddSection(ICombinable section)
 {
     images.AddRange(section.GetImages());
     fonts.AddRange(section.GetFonts());
     return(this);
 }
示例#7
0
 public void CombinableDestroyed(ICombinable combinable)
 {
     OnCombinableDestroyed(combinable);
 }
 public void RemoveCombinableObject(ICombinable combinable)
 {
     m_combinables.Remove(combinable);
 }