示例#1
0
        /// <summary>
        /// Initialize the default values.
        /// </summary>
        protected virtual void Awake()
        {
            m_GameObject = gameObject;
#if ULTIMATE_CHARACTER_CONTROLLER_MULTIPLAYER
            m_NetworkInfo      = m_GameObject.GetCachedComponent <INetworkInfo>();
            m_NetworkCharacter = m_GameObject.GetCachedComponent <INetworkCharacter>();
#endif

            DetermineSlotCount();

            EventHandler.RegisterEvent <Vector3, Vector3, GameObject>(m_GameObject, "OnDeath", OnDeath);
            EventHandler.RegisterEvent(m_GameObject, "OnRespawn", OnRespawn);
        }
示例#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);
        }
        /// <summary>
        /// Initialize the default values.
        /// </summary>
        public override void Awake()
        {
            base.Awake();

            m_NetworkCharacter = m_GameObject.GetCachedComponent <INetworkCharacter>();
        }