Exemple #1
0
        /// <summary>
        /// Initializes the AttributeModifier from another AttributeModifier.
        /// </summary>
        /// <param name="other">The AttributeModifier to copy.</param>
        /// <param name="attributeManager">The AttributeManager that the modifier is attached to.</param>
        /// <returns>True if the AttributeModifier was initialized.</returns>
        public bool Initialize(AttributeModifier other, AttributeManager attributeManager)
        {
            if (string.IsNullOrEmpty(other.AttributeName) || attributeManager == null)
            {
                return(false);
            }

            m_AttributeName        = other.AttributeName;
            m_Amount               = other.Amount;
            m_AutoUpdate           = other.AutoUpdate;
            m_AutoUpdateStartDelay = other.AutoUpdateStartDelay;
            m_AutoUpdateInterval   = other.m_AutoUpdateInterval;
            m_AutoUpdateDuration   = other.AutoUpdateDuration;

            m_Attribute = attributeManager.GetAttribute(m_AttributeName);
            return(m_Attribute != null);
        }
Exemple #2
0
        /// <summary>
        /// Initialize the default values.
        /// </summary>
        protected override void Awake()
        {
            base.Awake();

            m_GameObject       = gameObject;
            m_Transform        = transform;
            m_ForceObject      = m_GameObject.GetCachedComponent <IForceObject>();
            m_Rigidbody        = m_GameObject.GetCachedComponent <Rigidbody>();
            m_AttributeManager = GetComponent <AttributeManager>();
            if (!string.IsNullOrEmpty(m_HealthAttributeName))
            {
                m_HealthAttribute = m_AttributeManager.GetAttribute(m_HealthAttributeName);
            }
            if (!string.IsNullOrEmpty(m_ShieldAttributeName))
            {
                m_ShieldAttribute = m_AttributeManager.GetAttribute(m_ShieldAttributeName);
            }
            m_AliveLayer = m_GameObject.layer;
#if ULTIMATE_CHARACTER_CONTROLLER_MULTIPLAYER
            m_NetworkInfo          = m_GameObject.GetCachedComponent <INetworkInfo>();
            m_NetworkHealthMonitor = m_GameObject.GetCachedComponent <INetworkHealthMonitor>();
            if (m_NetworkInfo != null && m_NetworkHealthMonitor == null)
            {
                Debug.LogError("Error: The object " + m_GameObject.name + " must have a NetworkHealthMonitor component.");
            }
#endif

            if (m_Hitboxes != null && m_Hitboxes.Length > 0)
            {
                m_ColliderHitboxMap = new Dictionary <Collider, Hitbox>();
                for (int i = 0; i < m_Hitboxes.Length; ++i)
                {
                    m_ColliderHitboxMap.Add(m_Hitboxes[i].Collider, m_Hitboxes[i]);
                }
                m_RaycastHits        = new RaycastHit[m_MaxHitboxCollisionCount];
                m_RaycastHitComparer = new Utility.UnityEngineUtility.RaycastHitComparer();
            }

            EventHandler.RegisterEvent(m_GameObject, "OnRespawn", OnRespawn);
        }