Esempio n. 1
0
 public AttackContext GetCurrentContext(APCharacterController character)
 {
     if (m_useAimAnimations)
     {
         // Check inputs and update animation according to this
         AttackContext ctx    = m_contextAimFront;
         bool          bFront = Mathf.Abs(character.m_inputs.m_axisX.GetValue()) > 0f;
         bool          bUp    = character.m_inputs.m_axisY.GetValue() > 0f;
         bool          bDown  = character.m_inputs.m_axisY.GetValue() < 0f;
         if (bFront)
         {
             if (bUp)
             {
                 ctx = m_contextAimFrontUp;
             }
             else if (bDown)
             {
                 ctx = m_contextAimFrontDown;
             }
         }
         else if (bUp)
         {
             ctx = m_contextAimUp;
         }
         else if (bDown)
         {
             ctx = m_contextAimDown;
         }
         return(ctx);
     }
     else
     {
         bool bCrouched = character.IsCrouched();
         if (bCrouched)
         {
             return(m_contextCrouched);
         }
         else if (character.IsOnGround())
         {
             if (!character.IsRunning())
             {
                 return(m_contextStand);
             }
             else
             {
                 return(m_contextRun);
             }
         }
         else
         {
             return(m_contextInAir);
         }
     }
 }
Esempio n. 2
0
    void Update()
    {
        // Early exits
        if (!m_player || !m_player.enabled || m_player.IsControlled)
        {
            return;
        }

        // Check if player is in valid state
        if (m_player.GetState() != APCharacterController.State.Standard)
        {
            return;
        }

        // Check inputs and update animation according to this
        APAnimation anim   = m_targetFront;
        bool        bFront = Mathf.Abs(m_player.m_inputs.m_axisX.GetValue()) > 0f;
        bool        bUp    = m_player.m_inputs.m_axisY.GetValue() > 0f;
        bool        bDown  = m_player.m_inputs.m_axisY.GetValue() < 0f;

        if (bFront)
        {
            if (bUp)
            {
                anim = m_targetFrontUp;
            }
            else if (bDown)
            {
                anim = m_targetFrontDown;
            }
        }
        else if (bUp)
        {
            anim = m_targetUp;
        }
        else if (bDown)
        {
            anim = m_targetDown;
        }

        // Use front running animation if needed
        if ((anim == m_targetFront) && m_player.IsRunning() && (m_targetFrontRun.GetAnimHash() != 0))
        {
            anim = m_targetFrontRun;
        }

        m_player.PlayAnim(anim);
    }
Esempio n. 3
0
    public void RefreshAnimations(APCharacterController character)
    {
        AttackContext ctx = GetCurrentContext(character);

        if (ctx != null && ctx.m_enabled)
        {
            // Handle aim sub context properly
            AttackContextAim ctxAim = ctx as AttackContextAim;
            if (ctxAim != null)
            {
                character.PlayAnim(character.IsRunning() && ctxAim.m_animRun.IsValid() ? ctxAim.m_animRun : ctxAim.m_anim);
            }
            else
            {
                // keep default set of animation if not overrided by each attack
                if (ctx.m_anim.IsValid())
                {
                    character.PlayAnim(ctx.m_anim);
                }
            }
        }
    }