コード例 #1
0
 public void Drop(CharacterItemAnimator.Hand hand)
 {
     if (hand == CharacterItemAnimator.Hand.Right)
     {
         ItemLogic itemLogic = m_itemInHandR.GetComponent <ItemLogic>();
         if (m_itemInHandR.transform.parent == HandBoneR)
         {
             //Only null parent if actually attached to hand - this allows accessories to stay on if they are animated by item logic
             m_itemInHandR.transform.parent = null;
         }
         m_itemInHandR = null;
         if (itemLogic)
         {
             itemLogic.OnDrop();
         }
     }
     else if (hand == CharacterItemAnimator.Hand.Left)
     {
         ItemLogic itemLogic = m_itemInHandL.GetComponent <ItemLogic>();
         if (m_itemInHandL.transform.parent == HandBoneL)
         {
             //Only null parent if actually attached to hand - this allows accessories to stay on if they are animated by item logic
             m_itemInHandL.transform.parent = null;
         }
         m_itemInHandL = null;
         if (itemLogic)
         {
             itemLogic.OnDrop();
         }
     }
 }
コード例 #2
0
 public void Toggle(CharacterItemAnimator.Hand hand)
 {
     if (hand == CharacterItemAnimator.Hand.Right)
     {
         if (m_itemInHandR.gameObject.activeSelf)
         {
             m_itemInHandR.gameObject.SetActive(false);
         }
         else
         {
             ItemLogic item = m_itemInHandR;
             item.gameObject.SetActive(true);
             m_itemInHandR = null;
             AttachItem(item, hand);
         }
     }
     else if (hand == CharacterItemAnimator.Hand.Left)
     {
         if (m_itemInHandL.gameObject.activeSelf)
         {
             m_itemInHandL.gameObject.SetActive(false);
         }
         else
         {
             ItemLogic item = m_itemInHandL;
             item.gameObject.SetActive(true);
             m_itemInHandL = null;
             AttachItem(item, hand);
         }
     }
 }
コード例 #3
0
    public void Drop(CharacterItemAnimator.Hand hand)
    {
        //TODO: potential bug - if a weapon is dropped m_isHoldingWeapon gets stuck to being true

        if (hand == CharacterItemAnimator.Hand.Right)
        {
            ItemLogic itemLogic = m_itemInHandR.GetComponent <ItemLogic>();
            m_itemInHandR.transform.parent = null;
            m_itemInHandR = null;
            if (itemLogic)
            {
                itemLogic.OnDrop();
            }
        }
        else if (hand == CharacterItemAnimator.Hand.Left)
        {
            ItemLogic itemLogic = m_itemInHandL.GetComponent <ItemLogic>();
            m_itemInHandL.transform.parent = null;
            m_itemInHandL = null;
            if (itemLogic)
            {
                itemLogic.OnDrop();
            }
        }
    }
コード例 #4
0
 public void Drop(CharacterItemAnimator.Hand hand)
 {
     if (hand == CharacterItemAnimator.Hand.Right)
     {
         ItemLogic itemLogic = m_itemInHandR.GetComponent <ItemLogic>();
         m_itemInHandR.transform.parent = null;
         m_itemInHandR = null;
         if (itemLogic)
         {
             itemLogic.OnDrop();
         }
     }
     else if (hand == CharacterItemAnimator.Hand.Left)
     {
         ItemLogic itemLogic = m_itemInHandL.GetComponent <ItemLogic>();
         m_itemInHandL.transform.parent = null;
         m_itemInHandL = null;
         if (itemLogic)
         {
             itemLogic.OnDrop();
         }
     }
 }
コード例 #5
0
    public void AttachItem(ItemLogic item, CharacterItemAnimator.Hand handToAttach)
    {
        if (item.PreferredHand == ItemLogic.HandPreference.Left)
        {
            handToAttach = CharacterItemAnimator.Hand.Left;
        }
        else if (item.PreferredHand == ItemLogic.HandPreference.Right)
        {
            handToAttach = CharacterItemAnimator.Hand.Right;
        }

        if (m_itemUsesBothHands || item.UseBothHands)
        {
            if (m_itemInHandL && m_itemInHandL != item)
            {
                Drop(CharacterItemAnimator.Hand.Left);
            }
            if (m_itemInHandR && m_itemInHandR != item)
            {
                Drop(CharacterItemAnimator.Hand.Right);
            }
        }

        if (item == m_itemInHandL && handToAttach == CharacterItemAnimator.Hand.Left)
        {
            m_itemInHandL = item;
        }
        else if (item == m_itemInHandR && handToAttach == CharacterItemAnimator.Hand.Right)
        {
            m_itemInHandR = item;
        }
        else if (m_itemInHandL == null && handToAttach == CharacterItemAnimator.Hand.Left)
        {
            m_itemInHandL = item;
        }
        else if (m_itemInHandR == null && handToAttach == CharacterItemAnimator.Hand.Right)
        {
            m_itemInHandR = item;
        }
        else if (item.PreferredHand == ItemLogic.HandPreference.Right)
        {
            if (m_itemInHandR)
            {
                Drop(CharacterItemAnimator.Hand.Right);
            }
            m_itemInHandR = item;
        }
        else if (item.PreferredHand == ItemLogic.HandPreference.Left ||
                 item.PreferredHand == ItemLogic.HandPreference.Either)
        {
            if (m_itemInHandL)
            {
                Drop(CharacterItemAnimator.Hand.Left);
            }
            m_itemInHandL = item;
        }
        CheckHands();

        bool isWeapon = false;

        if (item.ItemAnimations)
        {
            isWeapon = item.ItemAnimations.IsWeapon;
        }

        m_itemUsesBothHands = item.UseBothHands;
        if (m_itemScriptR != null && item == m_itemInHandR)
        {
            m_itemScriptR.UseBothHands = m_itemUsesBothHands;
        }
        else if (m_itemScriptL != null && item == m_itemInHandL)
        {
            m_itemScriptL.UseBothHands = m_itemUsesBothHands;
        }

        if (item == m_itemInHandR)
        {
            Attach(item, m_handBoneR);
        }
        else if (item == m_itemInHandL)
        {
            Attach(item, m_handBoneL);
        }

        if (m_aimScript)
        {
            if (item.ItemTypeID <= 2)
            {
                m_aimScript.SetGunInHand(true, item.ItemTypeID);
            }
            else
            {
                m_aimScript.SetGunInHand(false, -1);
            }
        }

        if (m_itemScriptL || m_itemScriptR)
        {
            m_animatorOverridesApplier.SetCorrectAnimations(m_animator, m_itemInHandR, m_itemInHandL, m_itemScriptR, m_itemScriptL);
        }
    }
コード例 #6
0
    public void AttachItem(ItemLogic item, CharacterItemAnimator.Hand handToAttach)
    {
        if (item.m_PreferredHand == ItemLogic.PreferredHand.Left)
        {
            handToAttach = CharacterItemAnimator.Hand.Left;
        }
        else if (item.m_PreferredHand == ItemLogic.PreferredHand.Right)
        {
            handToAttach = CharacterItemAnimator.Hand.Right;
        }

        if (m_itemUsesBothHands || item.m_useBothHands)
        {
            if (m_itemInHandL && m_itemInHandL != item)
            {
                Drop(CharacterItemAnimator.Hand.Left);
            }
            if (m_itemInHandR && m_itemInHandR != item)
            {
                Drop(CharacterItemAnimator.Hand.Right);
            }
        }

        if (item == m_itemInHandL && handToAttach == CharacterItemAnimator.Hand.Left)
        {
            m_itemInHandL = item;
        }
        else if (item == m_itemInHandR && handToAttach == CharacterItemAnimator.Hand.Right)
        {
            m_itemInHandR = item;
        }
        else if (m_itemInHandL == null && handToAttach == CharacterItemAnimator.Hand.Left)
        {
            m_itemInHandL = item;
        }
        else if (m_itemInHandR == null && handToAttach == CharacterItemAnimator.Hand.Right)
        {
            m_itemInHandR = item;
        }
        else if (item.m_PreferredHand == ItemLogic.PreferredHand.Right)
        {
            if (m_itemInHandR)
            {
                Drop(CharacterItemAnimator.Hand.Right);
            }
            m_itemInHandR = item;
        }
        else if (item.m_PreferredHand == ItemLogic.PreferredHand.Left ||
                 item.m_PreferredHand == ItemLogic.PreferredHand.Either)
        {
            if (m_itemInHandL)
            {
                Drop(CharacterItemAnimator.Hand.Left);
            }
            m_itemInHandL = item;
        }
        CheckHands();

        Transform dummyPoint = null;

        if (item.DummyPoint != null)
        {
            dummyPoint = item.DummyPoint;
        }

        bool isWeapon = false;

        if (item.ItemAnimations)
        {
            isWeapon = item.ItemAnimations.IsWeapon;
        }

        m_itemUsesBothHands = item.m_useBothHands;
        if (m_itemScriptR != null && item == m_itemInHandR)
        {
            m_itemScriptR.UseBothHands = m_itemUsesBothHands;
        }
        else if (m_itemScriptL != null && item == m_itemInHandL)
        {
            m_itemScriptL.UseBothHands = m_itemUsesBothHands;
        }

        if (item == m_itemInHandR)
        {
            Attach(item, m_handBoneR, dummyPoint);
        }
        else if (item == m_itemInHandL)
        {
            Attach(item, m_handBoneL, dummyPoint);
        }

        if (m_aimScript)
        {
            if (item.ItemTypeID <= 2)
            {
                m_aimScript.SetGunInHand(true, item.ItemTypeID);
            }
            else
            {
                m_aimScript.SetGunInHand(false, -1);
            }
        }

        if (m_itemScriptL || m_itemScriptR)
        {
            SetCorrectAnimations();
        }
    }
コード例 #7
0
ファイル: CharacterMakerWizard.cs プロジェクト: underleg/Home
    private static void AttachItem(GameObject character, AccessoryWearLogic accessoryWearLogic, ItemObject itemObject, ItemHoldLogic itemHoldLogic, CharacterItemAnimator.Hand hand, bool keepPrefabConnection)
    {
        if (itemObject != null)
        {
            if (itemObject.Item == null)
            {
                Debug.LogError("Null prefab in " + itemObject);
                return;
            }

            ItemLogic item = Instantiate(itemObject.Item, keepPrefabConnection);
            if (hand == CharacterItemAnimator.Hand.Left)
            {
                itemHoldLogic.m_itemInHandL = item;
            }
            else if (hand == CharacterItemAnimator.Hand.Right)
            {
                itemHoldLogic.m_itemInHandR = item;
            }

            if (itemObject.Item.AccessoryLogic)
            {
                item.transform.parent = character.transform;
                accessoryWearLogic.Attach(item.AccessoryLogic);
            }
            else
            {
                if (hand == CharacterItemAnimator.Hand.Left)
                {
                    item.transform.parent = itemHoldLogic.HandBoneL;
                }
                else if (hand == CharacterItemAnimator.Hand.Right)
                {
                    item.transform.parent = itemHoldLogic.HandBoneR;
                }

                item.transform.localPosition = Vector3.zero;
                item.transform.localRotation = Quaternion.identity;
            }
        }
    }