Esempio n. 1
0
        /// <summary>
        /// Constantly check to enter or leave ability
        /// </summary>
        protected virtual void FixedUpdate()
        {
            if (Blocked)
            {
                if (Active)
                {
                    m_System.ExitAbility(this);
                }

                return;
            }

            // Check if it's active
            if (Active)
            {
                if (m_System.enabled == false)
                {
                    m_System.ExitAbility(this);
                    return;
                }

                // Check animation finish condition
                if (m_FinishOnAnimationEnd && m_AnimatorManager.HasFinishedAnimation(m_CurrentStatePlaying))
                {
                    m_System.ExitAbility(this); // Exit ability in the end of the animation
                    return;
                }

                // check conditions to exit ability
                if (TryExitAbility())
                {
                    m_System.ExitAbility(this); // Exit ability from controller
                }
            }
            else
            {
                if (ForceEnterAbility())
                {
                    m_System.OnTryEnterAbility(this); // enter ability
                }
                else
                {
                    // check condition to enter this ability
                    if (m_InputStateSet)
                    {
                        if (TryEnterAbility())
                        {
                            m_System.OnTryEnterAbility(this); // enter ability
                        }
                    }
                }
            }

            m_InputStateSet = false;
        }