示例#1
0
        /// <summary>
        /// Performs the interaction.
        /// </summary>
        /// <param name="character">The character that wants to interactact with the target.</param>
        public void Interact(GameObject character)
        {
#if ULTIMATE_CHARACTER_CONTROLLER_MULTIPLAYER
            if (m_NetworkInfo != null)
            {
                if (m_NetworkInfo.IsLocalPlayer())
                {
                    m_NetworkInteractable.Interact(character);
                }
                else
                {
                    // The event may have been sent multiple times for remoate players. Ensure the object is only interacted with once.
                    if (!CanInteract(character))
                    {
                        return;
                    }
                }
            }
#endif

            for (int i = 0; i < m_InteractableTargets.Length; ++i)
            {
                m_InteractableTargets[i].Interact(character);
            }
        }
示例#2
0
        /// <summary>
        /// Performs the interaction.
        /// </summary>
        /// <param name="character">The character that wants to interactact with the target.</param>
        public virtual void Interact(GameObject character)
        {
#if ULTIMATE_CHARACTER_CONTROLLER_MULTIPLAYER
            var characterNetworkInfo = character.GetCachedComponent <INetworkInfo>();
            if (characterNetworkInfo != null && characterNetworkInfo.IsLocalPlayer())
            {
#if UNITY_EDITOR
                if (m_NetworkInteractable == null)
                {
                    Debug.LogError("Error: The object " + gameObject.name + " must have a NetworkInteractable component.");
                }
#endif
                m_NetworkInteractable.Interact(character);
            }
#endif

            for (int i = 0; i < m_InteractableTargets.Length; ++i)
            {
                m_InteractableTargets[i].Interact(character);
            }
        }