Example #1
0
        /// <summary>
        /// The item is no longer equipped.
        /// </summary>
        protected override void ItemDeactivated()
        {
            TryStopUse();

            // The animation states should begin fresh.
            m_UseStates.ResetNextState();

            base.ItemDeactivated();
        }
Example #2
0
        /// <summary>
        /// The item is no longer equipped.
        /// </summary>
        protected override void ItemDeactivated()
        {
            base.ItemDeactivated();

            // The animation states should begin fresh.
            m_RecoilStates.ResetNextState();

            EventHandler.UnregisterEvent(m_Character, "OnAnimatorItemEndRecoil", EndRecoil);
        }
Example #3
0
        /// <summary>
        /// The item is no longer equipped.
        /// </summary>
        protected override void ItemDeactivated()
        {
            // The effect may still be playing if the character died while the animation is playing.
            EndUse();

            base.ItemDeactivated();

            // The animation states should begin fresh.
            m_UseStates.ResetNextState();

            EventHandler.UnregisterEvent <Transform, Vector3, Vector3>(gameObject, "OnItemAddCastHitEffects", AddCastHitEffects);
            EventHandler.UnregisterEvent(gameObject, "OnItemAddCastEffects", AddCastEffects);
            // The character may be null if Init hasn't been called yet.
            if (m_Character != null)
            {
                EventHandler.UnregisterEvent <bool>(m_Character, "OnControllerAim", OnAim);
                if (m_WaitForEndUseEvent)
                {
                    EventHandler.UnregisterEvent(m_Character, "OnAnimatorItemEndUse", EndUse);
                }
            }
        }
Example #4
0
        /// <summary>
        /// The item extension has been unequipped.
        /// </summary>
        public override void ItemExtensionDeactivated()
        {
            base.ItemExtensionDeactivated();

            // The animation states should begin fresh.
            m_RecoilStates.ResetNextState();

#if ENABLE_MULTIPLAYER
            EventHandler.UnregisterEvent <Transform, Vector3, Vector3>(m_GameObject, "OnItemAddMeleeEffects", AddMeleeEffects);
            EventHandler.UnregisterEvent(m_GameObject, "OnItemAddAttackEffects", AddAttackEffects);
#endif
            EventHandler.UnregisterEvent(m_Character, "OnAnimatorItemEndUse", EndUse);
            EventHandler.UnregisterEvent(m_Character, "OnAnimatorItemEndRecoil", EndRecoil);
            if (m_CanInterruptAttack)
            {
                EventHandler.UnregisterEvent(m_Character, "OnAnimatorItemAllowInterruption", AllowInterruption);
            }

            for (int i = 0; i < m_AttackHitboxes.Length; ++i)
            {
                m_AttackHitboxes[i].gameObject.SetActive(false);
            }
        }
Example #5
0
        /// <summary>
        /// The item is no longer equipped.
        /// </summary>
        protected virtual void ItemDeactivated()
        {
            // The aim states should begin fresh.
            m_AimStates.ResetNextState();

            // Unregister for any events that the item is only interested in while equipped.
            EventHandler.UnregisterEvent <bool>(m_Character, "OnControllerAim", OnAim);
            EventHandler.UnregisterEvent(m_Character, "OnControllerStartAim", OnStartAim);

            // The collider shouldn't affect the item.
            for (int i = 0; i < m_Colliders.Length; ++i)
            {
                m_Colliders[i].enabled = false;
            }

            // Disable the flashlight/laser sight.
            if (this is IFlashlightUseable)
            {
                (this as IFlashlightUseable).ActivateFlashlightOnAim(false);
            }
            if (this is ILaserSightUseable)
            {
                (this as ILaserSightUseable).ActivateLaserSightOnAim(false);
            }

            // The camera's aim state should no longer play when the item is deactivated.
            if (!string.IsNullOrEmpty(m_AimCameraState) && m_ChangeCameraState != null)
            {
                m_ChangeCameraState.Invoke(m_AimCameraState, false);
            }

            // Notify the extension items.
            for (int i = 0; i < m_ItemExtensions.Length; ++i)
            {
                m_ItemExtensions[i].ItemExtensionDeactivated();
            }
        }
Example #6
0
        /// <summary>
        /// Returns the state in the array.
        /// </summary>
        /// <param name="layer">The layer to get the state of.</param>
        /// <returns>The state in the array.</returns>
        public AnimatorItemStateData GetState(int layer)
        {
            var nextStateIndex = m_StateOrder == Order.Random ? m_NextStateIndex : m_ParentCollection.NextStateIndex % m_States.Length;

            if (m_StateOrder == Order.Combo && m_ParentCollection.LastComboRetirevalTime + m_ComboTimeout < Time.time)
            {
                // Reset the state index if the retrieval time of the next state isn't faster than the timeout. This will force
                // the combo to reset back to the start.
                nextStateIndex = 0;
                m_ParentCollection.ResetNextState();
            }

            var itemState = m_States[nextStateIndex];

            if (itemState != null && itemState.IsStateWithinLayer(layer))
            {
                return(itemState);
            }
            return(null);
        }
Example #7
0
 /// <summary>
 /// Perform any cleanup when the item extension is disabled.
 /// </summary>
 protected virtual void OnDisable()
 {
     // The animation states should begin fresh.
     m_UseStates.ResetNextState();
 }