Exemplo n.º 1
0
 private void AttachToHand(ItemLogic item, CharacterItemAnimator itemScript, ref ItemLogic itemInHand)
 {
     if (itemScript != null)
     {
         if (item.ItemAnimations)
         {
             m_isHoldingWeapon = item.ItemAnimations.IsWeapon;
         }
         itemScript.SetHolding(true, m_isHoldingWeapon);
         itemInHand = item;
     }
 }
Exemplo n.º 2
0
    private void SetLeftHandItemAnimations(CharacterItemAnimator itemScript, ItemAnimationsObject itemAnimations, bool useBothHands)
    {
        SetLoopingConfigStanding(itemScript, itemAnimations.InteractionLeftLoop, itemAnimations.InteractionLeftStart, itemAnimations.InteractionLeftLoopTime);
        SetLoopingConfigCrouching(itemScript, itemAnimations.CrouchingInteractionLeftLoop, itemAnimations.CrouchingInteractionLeftStart, itemAnimations.CrouchingInteractionLeftLoopTime);

        SetInteractionAnimations(AnimationKey.Hand.Left, false, itemAnimations.InteractionLeftStart, itemAnimations.InteractionLeftLoop, itemAnimations.InteractionLeftEnd);
        SetInteractionAnimations(AnimationKey.Hand.Left, true, itemAnimations.CrouchingInteractionLeftStart, itemAnimations.CrouchingInteractionLeftLoop, itemAnimations.CrouchingInteractionLeftEnd);
        SetHoldingAnimations(AnimationKey.Hand.Left, itemAnimations.HoldingLeft, itemAnimations.CrouchingHoldingLeft, itemAnimations.EquipLeft, itemAnimations.UnEquipLeft);

        if (useBothHands)
        {
            SetInteractionAnimations(AnimationKey.Hand.Right, false, itemAnimations.InteractionLeftStart, itemAnimations.InteractionLeftLoop, itemAnimations.InteractionLeftEnd);
            SetInteractionAnimations(AnimationKey.Hand.Right, true, itemAnimations.CrouchingInteractionLeftStart, itemAnimations.CrouchingInteractionLeftLoop, itemAnimations.CrouchingInteractionLeftEnd);
            SetHoldingAnimations(AnimationKey.Hand.Both, itemAnimations.HoldingLeft, itemAnimations.CrouchingHoldingLeft, itemAnimations.EquipLeft, itemAnimations.UnEquipLeft);
        }
    }
Exemplo n.º 3
0
 private void SetLoopingConfigStanding(CharacterItemAnimator itemScript, AnimationClip interactionLoop, AnimationClip interactionStart, float interactionLoopTime)
 {
     if (interactionLoop != null)
     {
         itemScript.LoopingAnimationStanding = true;
         if (interactionStart != null)
         {
             itemScript.InteractionStandingStartDuration = interactionStart.length;
             itemScript.LoopingDuration = interactionLoopTime;
         }
     }
     else
     {
         itemScript.LoopingAnimationStanding = false;
     }
 }
Exemplo n.º 4
0
 private void SetLoopingConfigCrouching(CharacterItemAnimator itemScript, AnimationClip interactionLoop, AnimationClip interactionStart, float interactionLoopTime)
 {
     if (interactionLoop != null)
     {
         itemScript.LoopingAnimationCrouching = true;
         if (interactionStart != null)
         {
             itemScript.InteractionCrouchingStartDuration = interactionStart.length;
             itemScript.LoopingDuration = interactionLoopTime; //TODO: a potential problem where this overrides the looping duration for standing
         }
     }
     else
     {
         itemScript.LoopingAnimationCrouching = false;
     }
 }
Exemplo n.º 5
0
    public void SetCorrectAnimations(AnimatorOverrideController animator, ItemLogic itemInHandR, ItemLogic itemInHandL, CharacterItemAnimator itemScriptR, CharacterItemAnimator itemScriptL)
    {
        if (m_getOverridesCache == null)
        {
            m_getOverridesCache = new List <KeyValuePair <AnimationClip, AnimationClip> >(animator.overridesCount);
        }
        else
        {
            m_getOverridesCache.Clear();
        }

        animator.GetOverrides(m_getOverridesCache);
        PopulateOverrides(m_getOverridesCache);

        if (itemInHandR)
        {
            if (itemInHandR.ItemAnimations)
            {
                ItemAnimationsObject itemAnimations = itemInHandR.ItemAnimations;
                SetRightHandItemAnimations(itemScriptR, itemAnimations, itemInHandR.UseBothHands);
            }
            else
            {
                ClearAnimations(AnimationKey.Hand.Right);
            }
        }

        if (itemInHandL)
        {
            if (itemInHandL.ItemAnimations)
            {
                ItemAnimationsObject itemAnimations = itemInHandL.ItemAnimations;
                SetLeftHandItemAnimations(itemScriptL, itemAnimations, itemInHandL.UseBothHands);
            }
            else
            {
                ClearAnimations(AnimationKey.Hand.Left);
            }
        }

        animator.ApplyOverrides(new List <KeyValuePair <AnimationClip, AnimationClip> >(m_overrides.Values));
    }
Exemplo n.º 6
0
    public void SetCorrectAnimations(AnimatorOverrideController animator, ItemLogic itemInHandR, ItemLogic itemInHandL, CharacterItemAnimator itemScriptR, CharacterItemAnimator itemScriptL)
    {
        if (m_getOverridesCache == null)
        {
            m_getOverridesCache = new List <KeyValuePair <AnimationClip, AnimationClip> >(animator.overridesCount);
        }
        else
        {
            m_getOverridesCache.Clear();
        }

        //TODO: These two can most likely be cached if we assume that the animator is still the same and overrides aren't modified by anything else
        animator.GetOverrides(m_getOverridesCache);
        PopulateOverrides(m_getOverridesCache);

        if (itemInHandR)
        {
            if (itemInHandR.ItemAnimations)
            {
                ItemAnimationsObject itemAnimations = itemInHandR.ItemAnimations;
                SetRightHandItemAnimations(itemScriptR, itemAnimations, itemInHandR.m_useBothHands);
            }
            else
            {
                ClearAnimations(AnimationKey.Hand.Right);
            }
        }

        if (itemInHandL)
        {
            if (itemInHandL.ItemAnimations)
            {
                ItemAnimationsObject itemAnimations = itemInHandL.ItemAnimations;
                SetLeftHandItemAnimations(itemScriptL, itemAnimations, itemInHandL.m_useBothHands);
            }
            else
            {
                ClearAnimations(AnimationKey.Hand.Left);
            }
        }

        animator.ApplyOverrides(new List <KeyValuePair <AnimationClip, AnimationClip> >(m_overrides.Values));
    }