Пример #1
0
 IEnumerator UnequipItemRoutine(EquipPoint equipPoint, Item item)
 {
     if (!inEquip)
     {
         inventory.canEquip = false;
         inEquip            = true;
         if (equipPoint != null && equipPoint.equipmentReference != null && equipPoint.equipmentReference.equipedObject != null)
         {
             var equipment = equipPoint.equipmentReference.equipedObject.GetComponent <IEquipment>();
             if (equipment != null)
             {
                 equipment.OnUnequip(item);
             }
             if (!inventory.isOpen)
             {
                 while (equipTimer > 0)
                 {
                     equipTimer -= Time.deltaTime;
                     yield return(new WaitForEndOfFrame());
                 }
             }
             Destroy(equipPoint.equipmentReference.equipedObject);
             equipPoint.equipmentReference.item = null;
         }
         inEquip            = false;
         inventory.canEquip = true;
     }
 }
Пример #2
0
        void HandleNockPositioning(EquipPoint oppositeEquipPoint)           //, float nockDistance) {
        // If there's an arrow spawned in the hand and it's not nocked yet
        {
            if (!nocked)
            {
                float distanceToNockPosition = Vector3.Distance(oppositeEquipPoint.transform.position, nockTransform.position);

                // Allow nocking the arrow when controller is close enough
                if (distanceToNockPosition < nockDistance)
                {
                    if (!inNockRange)
                    {
                        arrowHand.arrowNockTransform.position = nockRestTransform.position;
                        arrowHand.arrowNockTransform.rotation = nockRestTransform.rotation;

                        // linkedInventory hand.TriggerHapticPulse( 500 );
                        ArrowInPosition();

                        inNockRange = true;
                    }
                }
                else
                {
                    if (inNockRange)
                    {
                        inNockRange = false;
                    }
                }
            }
        }
Пример #3
0
    void CheckTwoHandItem(EquipPoint equipPoint, Item item)
    {
        if (item == null)
        {
            return;
        }
        var opposite = equipPoints.Find(ePoint => ePoint.area != null && ePoint.equipPointName.Equals("LeftArm") && ePoint.area.currentEquipedItem != null);

        if (equipPoint.equipPointName.Equals("LeftArm"))
        {
            opposite = equipPoints.Find(ePoint => ePoint.area != null && ePoint.equipPointName.Equals("RightArm") && ePoint.area.currentEquipedItem != null);
        }
        else if (!equipPoint.equipPointName.Equals("RightArm"))
        {
            return;
        }
        if (opposite != null && (item.twoHandWeapon || opposite.area.currentEquipedItem.twoHandWeapon))
        {
            opposite.area.RemoveCurrentItem();
        }
    }
Пример #4
0
    IEnumerator EquipItemRoutine(EquipPoint equipPoint, Item item)
    {
        if (!inEquip)
        {
            inventory.canEquip = false;
            inEquip            = true;

            if (equipPoint != null)
            {
                if (item.originalObject)
                {
                    if (equipPoint.equipmentReference != null && equipPoint.equipmentReference.equipedObject != null)
                    {
                        var _equipment = equipPoint.equipmentReference.equipedObject.GetComponent <IEquipment>();
                        if (_equipment != null)
                        {
                            _equipment.OnUnequip(equipPoint.equipmentReference.item);
                        }
                        Destroy(equipPoint.equipmentReference.equipedObject);
                    }
                    if (!inventory.isOpen)
                    {
                        while (equipTimer > 0)
                        {
                            if (item == null)
                            {
                                break;
                            }
                            yield return(null);

                            equipTimer -= Time.deltaTime;
                        }
                    }
                    var point          = equipPoint.handler.customHandlers.Find(p => p.name == item.customEquipPoint);
                    var equipTransform = point != null ? point : equipPoint.handler.defaultHandler;
                    var equipedObject  = Instantiate(item.originalObject, equipTransform.position, equipTransform.rotation) as GameObject;

                    equipedObject.transform.parent = equipTransform;

                    if (equipPoint.equipPointName.Contains("Left"))
                    {
                        var scale = equipedObject.transform.localScale;
                        scale.x *= -1;
                        equipedObject.transform.localScale = scale;
                    }

                    equipPoint.equipmentReference.item          = item;
                    equipPoint.equipmentReference.equipedObject = equipedObject;
                    var equipment = equipedObject.GetComponent <IEquipment>();
                    if (equipment != null)
                    {
                        equipment.OnEquip(item);
                    }
                    equipPoint.onInstantiateEquiment.Invoke(equipedObject);
                }
                else if (equipPoint.equipmentReference != null && equipPoint.equipmentReference.equipedObject != null)
                {
                    var _equipment = equipPoint.equipmentReference.equipedObject.GetComponent <IEquipment>();
                    if (_equipment != null)
                    {
                        _equipment.OnUnequip(equipPoint.equipmentReference.item);
                    }
                    Destroy(equipPoint.equipmentReference.equipedObject);
                    equipPoint.equipmentReference.item = null;
                }
            }
            inEquip            = false;
            inventory.canEquip = true;
            if (equipPoint != null)
            {
                CheckTwoHandItem(equipPoint, item);
            }
        }
    }
Пример #5
0
    static void CreateShooterPoints(vItemManager itemManager, vShooterManager shooterManager)
    {
        if (!shooterManager)
        {
            return;
        }
        var animator = itemManager.GetComponent <Animator>();

        #region LeftEquipPoint

        var equipPointL = itemManager.equipPoints.Find(p => p.equipPointName == "LeftArm");
        if (equipPointL == null)
        {
            EquipPoint pointL = new EquipPoint();
            pointL.equipPointName = "LeftArm";
            if (shooterManager)
            {
#if UNITY_EDITOR
                UnityEventTools.AddPersistentListener <GameObject>(pointL.onInstantiateEquiment, shooterManager.SetLeftWeapon);
#else
                pointL.onInstantiateEquiment.AddListener(shooterManager.SetLeftWeapon);
#endif
            }

            if (animator)
            {
                var defaultEquipPointL = new GameObject("defaultEquipPoint");
                var parent             = animator.GetBoneTransform(HumanBodyBones.LeftHand);
                defaultEquipPointL.transform.SetParent(parent);
                defaultEquipPointL.transform.localPosition = Vector3.zero;
                defaultEquipPointL.transform.forward       = itemManager.transform.forward;
                defaultEquipPointL.gameObject.tag          = "Ignore Ragdoll";
                pointL.handler = new vHandler();
                pointL.handler.defaultHandler = defaultEquipPointL.transform;
            }
            itemManager.equipPoints.Add(pointL);
        }
        else
        {
            if (equipPointL.handler.defaultHandler == null)
            {
                if (animator)
                {
                    var parent       = animator.GetBoneTransform(HumanBodyBones.LeftHand);
                    var defaultPoint = parent.Find("defaultEquipPoint");

                    if (defaultPoint)
                    {
                        equipPointL.handler.defaultHandler = defaultPoint;
                    }
                    else
                    {
                        var _defaultPoint = new GameObject("defaultEquipPoint");
                        _defaultPoint.transform.SetParent(parent);
                        _defaultPoint.transform.localPosition = Vector3.zero;
                        _defaultPoint.transform.forward       = itemManager.transform.forward;
                        _defaultPoint.gameObject.tag          = "Ignore Ragdoll";
                        equipPointL.handler.defaultHandler    = _defaultPoint.transform;
                    }
                }
            }

            bool containsListener = false;
            for (int i = 0; i < equipPointL.onInstantiateEquiment.GetPersistentEventCount(); i++)
            {
                if (equipPointL.onInstantiateEquiment.GetPersistentTarget(i).GetType().Equals(typeof(vShooterManager)) && equipPointL.onInstantiateEquiment.GetPersistentMethodName(i).Equals("SetLeftWeapon"))
                {
                    containsListener = true;
                    break;
                }
            }

            if (!containsListener && shooterManager)
            {
#if UNITY_EDITOR
                UnityEventTools.AddPersistentListener <GameObject>(equipPointL.onInstantiateEquiment, shooterManager.SetLeftWeapon);
#else
                equipPointL.onInstantiateEquiment.AddListener(shooterManager.SetLeftWeapon);
#endif
            }
        }
        #endregion

        #region RightEquipPoint

        var equipPointR = itemManager.equipPoints.Find(p => p.equipPointName == "RightArm");
        if (equipPointR == null)
        {
            EquipPoint pointR = new EquipPoint();
            pointR.equipPointName = "RightArm";
            if (shooterManager)
            {
#if UNITY_EDITOR
                UnityEventTools.AddPersistentListener <GameObject>(pointR.onInstantiateEquiment, shooterManager.SetRightWeapon);
#else
                pointR.onInstantiateEquiment.AddListener(shooterManager.SetRightWeapon);
#endif
            }

            if (animator)
            {
                var defaultEquipPointR = new GameObject("defaultEquipPoint");
                var parent             = animator.GetBoneTransform(HumanBodyBones.RightHand);
                defaultEquipPointR.transform.SetParent(parent);
                defaultEquipPointR.transform.localPosition = Vector3.zero;
                defaultEquipPointR.transform.forward       = itemManager.transform.forward;
                defaultEquipPointR.gameObject.tag          = "Ignore Ragdoll";
                pointR.handler = new vHandler();
                pointR.handler.defaultHandler = defaultEquipPointR.transform;
            }
            itemManager.equipPoints.Add(pointR);
        }
        else
        {
            if (equipPointR.handler.defaultHandler == null)
            {
                if (animator)
                {
                    var parent       = animator.GetBoneTransform(HumanBodyBones.RightHand);
                    var defaultPoint = parent.Find("defaultEquipPoint");
                    if (defaultPoint)
                    {
                        equipPointR.handler.defaultHandler = defaultPoint;
                    }
                    else
                    {
                        var _defaultPoint = new GameObject("defaultEquipPoint");
                        _defaultPoint.transform.SetParent(parent);
                        _defaultPoint.transform.localPosition = Vector3.zero;
                        _defaultPoint.transform.forward       = itemManager.transform.forward;
                        _defaultPoint.gameObject.tag          = "Ignore Ragdoll";
                        equipPointR.handler.defaultHandler    = _defaultPoint.transform;
                    }
                }
            }

            bool containsListener = false;
            for (int i = 0; i < equipPointR.onInstantiateEquiment.GetPersistentEventCount(); i++)
            {
                if (equipPointR.onInstantiateEquiment.GetPersistentTarget(i).GetType().Equals(typeof(vShooterManager)) && equipPointR.onInstantiateEquiment.GetPersistentMethodName(i).Equals("SetRightWeapon"))
                {
                    containsListener = true;
                    break;
                }
            }

            if (!containsListener && shooterManager)
            {
#if UNITY_EDITOR
                UnityEventTools.AddPersistentListener <GameObject>(equipPointR.onInstantiateEquiment, shooterManager.SetRightWeapon);
#else
                equipPointR.onInstantiateEquiment.AddListener(shooterManager.SetRightWeapon);
#endif
            }
        }
        #endregion
    }
Пример #6
0
    }                                                                 // 0x009BC350-0x009BC380

    public void ClearEquip(EquipPoint point, bool bMotionUpdate)
    {
    }                                                                   // 0x009BC380-0x009BC4F0