Esempio n. 1
0
 /// <summary>
 /// Initializes any values that require on other components to first initialize.
 /// </summary>
 protected virtual void Start()
 {
     if (m_ActivePerspectiveProperties == null)
     {
         var characterLocomotion = m_Character.GetCachedComponent <UltimateCharacterLocomotion>();
         m_ActivePerspectiveProperties = characterLocomotion.FirstPersonPerspective ? m_FirstPersonPerspectiveProperties : m_ThirdPersonPerspectiveProperties;
     }
 }
Esempio n. 2
0
        /// <summary>
        /// Initialize the default values.
        /// </summary>
        protected override void Awake()
        {
            base.Awake();

            m_GameObject = gameObject;
            m_Item       = m_GameObject.GetCachedComponent <Item>();
            var characterLocomotion = m_GameObject.GetCachedParentComponent <UltimateCharacterLocomotion>();

            m_Character = characterLocomotion.gameObject;
            m_Inventory = m_Character.GetCachedComponent <InventoryBase>();
#if ULTIMATE_CHARACTER_CONTROLLER_MULTIPLAYER
            m_NetworkInfo      = m_Character.GetCachedComponent <INetworkInfo>();
            m_NetworkCharacter = m_Character.GetCachedComponent <INetworkCharacter>();
            if (m_NetworkInfo != null && m_NetworkCharacter == null)
            {
                Debug.LogError("Error: The character " + m_Character.name + " must have a NetworkCharacter component.");
            }
#endif

            var perspectiveProperties = GetComponents <ItemPerspectiveProperties>();
            for (int i = 0; i < perspectiveProperties.Length; ++i)
            {
                // The perspective properties Action ID must match. The ID allows multiple ItemActions/PerpsectiveProperties to be added to the same item.
                // An action ID of -1 can be used with any action.
                if (m_ID != perspectiveProperties[i].ActionID && perspectiveProperties[i].ActionID != -1)
                {
                    continue;
                }
                if (perspectiveProperties[i].FirstPersonItem)
                {
                    m_FirstPersonPerspectiveProperties = perspectiveProperties[i];
                }
                else
                {
                    m_ThirdPersonPerspectiveProperties = perspectiveProperties[i];
                }
            }
            m_ActivePerspectiveProperties = characterLocomotion.FirstPersonPerspective ? m_FirstPersonPerspectiveProperties : m_ThirdPersonPerspectiveProperties;

            EventHandler.RegisterEvent <bool>(m_Character, "OnCharacterChangePerspectives", OnChangePerspectives);
        }
Esempio n. 3
0
 /// <summary>
 /// The camera perspective between first and third person has changed.
 /// </summary>
 /// <param name="inFirstPerson">Is the camera in a first person view?</param>
 protected virtual void OnChangePerspectives(bool firstPersonPerspective)
 {
     m_ActivePerspectiveProperties = firstPersonPerspective ? m_FirstPersonPerspectiveProperties : m_ThirdPersonPerspectiveProperties;
 }