예제 #1
0
 public void UnequipItemModels(EquipmentSlotProfile equipmentSlot)
 {
     if (currentEquipmentPhysicalObjects.ContainsKey(equipmentSlot))
     {
         // LOOP THOUGH THEM INSTEAD
         foreach (KeyValuePair <AttachmentNode, GameObject> holdableObjectReference in currentEquipmentPhysicalObjects[equipmentSlot])
         {
             //GameObject destroyObject = holdableObjectReference.Value;
             //Debug.Log("equipment manager trying to unequip item in slot " + equipmentSlot.ToString() + "; destroying object: " + holdableObjectReference.Value.name);
             objectPooler.ReturnObjectToPool(holdableObjectReference.Value);
         }
     }
 }
        public override void Equip(Equipment newItem, EquipmentSlotProfile equipmentSlotProfile = null)
        {
            //Debug.Log(gameObject.name + ".PlayerEquipmentManager.Equip(" + (newItem == null ? "null" : newItem.MyName)+ ", " + (equipmentSlotProfile == null ? "null" : equipmentSlotProfile.MyName) + ")");
            if (newItem == null)
            {
                Debug.Log("Instructed to Equip a null item!");
                return;
            }
            base.Equip(newItem, equipmentSlotProfile);

            // DO THIS LAST OR YOU WILL SAVE THE UMA DATA BEFORE ANYTHING IS EQUIPPED!
            // updated oldItem to null here because this call is already done in Unequip.
            // having it here also was leading to duplicate stat removal when gear was changed.
            SystemEventManager.MyInstance.NotifyOnEquipmentChanged(newItem, null);
        }
        public override Equipment Unequip(EquipmentSlotProfile equipmentSlotProfile, int slotIndex = -1)
        {
            //Debug.Log("equipment manager trying to unequip item in slot " + equipmentSlot.ToString());
            Equipment returnValue = base.Unequip(equipmentSlotProfile, slotIndex);

            if (returnValue != null)
            {
                if (PlayerManager.MyInstance.MyPlayerUnitSpawned)
                {
                    if (slotIndex != -1)
                    {
                        InventoryManager.MyInstance.AddItem(returnValue, slotIndex);
                    }
                    else
                    {
                        InventoryManager.MyInstance.AddItem(returnValue);
                    }
                    SystemEventManager.MyInstance.NotifyOnEquipmentChanged(null, returnValue);
                }
            }
            return(returnValue);
        }
예제 #4
0
        public void SpawnEquipmentObjects(EquipmentSlotProfile equipmentSlotProfile, Equipment newEquipment)
        {
            //Debug.Log(unitController.gameObject.name + ".MecanimModelController.SpawnEquipmentObjects()");
            if (newEquipment == null || newEquipment.HoldableObjectList == null || newEquipment.HoldableObjectList.Count == 0 || equipmentSlotProfile == null)
            {
                //Debug.Log("CharacterEquipmentManager.SpawnEquipmentObjects() : FAILED TO SPAWN OBJECTS");
                return;
            }
            //Dictionary<PrefabProfile, GameObject> holdableObjects = new Dictionary<PrefabProfile, GameObject>();
            Dictionary <AttachmentNode, GameObject> holdableObjects = new Dictionary <AttachmentNode, GameObject>();

            foreach (HoldableObjectAttachment holdableObjectAttachment in newEquipment.HoldableObjectList)
            {
                if (holdableObjectAttachment != null && holdableObjectAttachment.MyAttachmentNodes != null)
                {
                    foreach (AttachmentNode attachmentNode in holdableObjectAttachment.MyAttachmentNodes)
                    {
                        if (attachmentNode != null && attachmentNode.MyEquipmentSlotProfile != null && equipmentSlotProfile == attachmentNode.MyEquipmentSlotProfile)
                        {
                            //CreateComponentReferences();
                            if (attachmentNode.HoldableObject != null && attachmentNode.HoldableObject.Prefab != null)
                            {
                                //Debug.Log("EquipmentManager.HandleWeaponSlot(): " + newItem.name + " has a physical prefab");
                                // attach a mesh to a bone for weapons

                                AttachmentPointNode attachmentPointNode = GetSheathedAttachmentPointNode(attachmentNode);
                                if (attachmentPointNode != null)
                                {
                                    Transform targetBone = unitController.gameObject.transform.FindChildByRecursive(attachmentPointNode.TargetBone);

                                    if (targetBone != null)
                                    {
                                        //Debug.Log(unitController.gameObject.name + ".MecanimModelController.SpawnEquipmentObjects(): " + newEquipment.name + " has a physical prefab. targetbone is not null: equipSlot: " + newEquipment.EquipmentSlotType.DisplayName);
                                        GameObject newEquipmentPrefab = objectPooler.GetPooledObject(attachmentNode.HoldableObject.Prefab, targetBone);
                                        //holdableObjects.Add(attachmentNode.MyHoldableObject, newEquipmentPrefab);
                                        holdableObjects.Add(attachmentNode, newEquipmentPrefab);
                                        //currentEquipmentPhysicalObjects[equipmentSlotProfile] = newEquipmentPrefab;

                                        newEquipmentPrefab.transform.localScale = attachmentNode.HoldableObject.Scale;
                                        if (unitController?.CharacterUnit?.BaseCharacter.CharacterCombat != null && unitController?.CharacterUnit?.BaseCharacter.CharacterCombat.GetInCombat() == true)
                                        {
                                            HoldObject(newEquipmentPrefab, attachmentNode, unitController.gameObject);
                                        }
                                        else
                                        {
                                            SheathObject(newEquipmentPrefab, attachmentNode, unitController.gameObject);
                                        }
                                    }
                                    else
                                    {
                                        Debug.Log("CharacterEquipmentManager.SpawnEquipmentObjects(). We could not find the target bone " + attachmentPointNode.TargetBone + " when trying to Equip " + newEquipment.DisplayName);
                                    }
                                }
                            }
                        }
                    }
                }
            }
            if (holdableObjects.Count > 0)
            {
                currentEquipmentPhysicalObjects[equipmentSlotProfile] = holdableObjects;
            }
        }
예제 #5
0
        public void EquipItemModels(CharacterEquipmentManager characterEquipmentManager, EquipmentSlotProfile equipmentSlotProfile, Equipment equipment)
        {
            //Debug.Log(unitController.gameObject.name + ".MecanimModelController.EquipItemModels()");

            SpawnEquipmentObjects(equipmentSlotProfile, equipment);
            if (unitController?.UnitAnimator != null)
            {
                unitController.UnitAnimator.HandleEquipmentChanged(equipment, null);
            }
        }