示例#1
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;
            }
        }
示例#2
0
 public void NotifyOnEquipmentChanged(Equipment newEquipment, Equipment oldEquipment)
 {
     OnEquipmentChanged(newEquipment, oldEquipment);
 }
示例#3
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);
            }
        }