コード例 #1
0
    public override void OnInspectorGUI()
    {
        serializedObject.Update();
        EditorGUILayout.BeginVertical("box");
        DrawDefaultInspector();
        EditorGUILayout.HelpBox("Add a reference to an EquippableSlotTypes Scriptable Object if you are going to equip this item.", MessageType.Info);
        EditorGUILayout.Space();

        EquippableSlot _equippableSlot = (EquippableSlot)target;

        EditorGUILayout.Space();
        EditorGUILayout.Space();
        EditorGUILayout.Space();

        if (_equippableSlot.equippableSlotTypeSO != null)
        {
            equippableSlotTypeIndexProp.intValue = EditorGUILayout.Popup(equippableSlotTypeIndexProp.intValue, _equippableSlot.equippableSlotTypeSO.equippableSlotTypes);
            equippableSlotTypeProp.stringValue   = _equippableSlot.equippableSlotTypeSO.equippableSlotTypes[equippableSlotTypeIndexProp.intValue];
        }

        EditorGUILayout.Space();
        EditorGUILayout.EndVertical();

        serializedObject.ApplyModifiedProperties();
    }
コード例 #2
0
        public override void NotifyItemEquipped(EquippableSlot equipSlot, uint amountEquipped)
        {
            base.NotifyItemEquipped(equipSlot, amountEquipped);

            AddAmmo(amountEquipped);
            ufpsEventHandler.Register(this); // Enable UFPS events
        }
コード例 #3
0
        public override void NotifyItemEquipped(EquippableSlot equipSlot, uint amountEquipped)
        {
            base.NotifyItemEquipped(equipSlot, amountEquipped);

            foreach (var umaEquipSlot in equipSlotsData)
            {
                SlotData slot = GetUMASlot(umaEquipSlot.umaEquipSlot.slotName);
                if (slot == null && umaEquipSlot.umaSlotDataAsset == null)
                {
                    Debug.LogWarning("No suitable UMA slot found for " + umaEquipSlot.umaEquipSlot.slotName);
                    return; // No visual eqipment
                }

                if (umaEquipSlot.umaSlotDataAsset != null)
                {
                    slot = UMAReplaceSlot(umaEquipSlot);
                    UMAMarkAllDirty();
                }

                if (slot != null)
                {
                    UMAAddOverlay(umaEquipSlot, slot, umaEquipSlot.umaOverlayDataAsset.overlayName);
                }
            }

            umaData.isTextureDirty = true;
            umaData.isAtlasDirty   = true;
            umaData.Dirty();
        }
コード例 #4
0
        private void UpdateAttach()
        {
            if (!this.m_nview.IsOwner())
            {
                return;
            }
            this.CancelInvoke("UpdateAttach");
            Player player = Player.m_localPlayer;

            if (equipmentSlotManager.hasQueuedItem() && player != null && (player.GetInventory().ContainsItem(equipmentSlotManager.queuedItem)) && this.CanAttach(equipmentSlotManager.queuedItem))
            {
                // Users can queue one item at a time, but depending on its type is what slot it belongs to. If the slot is already filled it should
                // drop the item first.

                ItemDrop.ItemData itemData = equipmentSlotManager.queuedItem.Clone();
                itemData.m_stack = 1;

                if (equipmentSlotManager.slots.ContainsKey(itemData.m_shared.m_itemType))
                {
                    EquippableSlot unfilledSlot = null;

                    var slot = equipmentSlotManager.slots[itemData.m_shared.m_itemType];
                    if (slot.isFilled() || slot.exclusiveSlotFilled(equipmentSlotManager))
                    {
                        foreach (var secondarySlot in slot.secondarySlots)
                        {
                            var fallbackSlot = equipmentSlotManager.slots[secondarySlot];
                            if (!fallbackSlot.isFilled() && !fallbackSlot.exclusiveSlotFilled(equipmentSlotManager))
                            {
                                unfilledSlot = fallbackSlot;
                                break;
                            }
                        }
                    }
                    else
                    {
                        unfilledSlot = slot;
                    }

                    if (unfilledSlot == null)
                    {
                        player.Message(MessageHud.MessageType.Center, "$ceko_piece_slot_filled", 0, null);
                    }
                    else
                    {
                        unfilledSlot.equip(itemData);
                        player.UnequipItem(equipmentSlotManager.queuedItem, true);
                        player.GetInventory().RemoveOneItem(equipmentSlotManager.queuedItem);
                        this.m_nview.InvokeRPC(ZNetView.Everybody, "SetVisualItems");
                        this.m_effects.Create(this.GetAttach(equipmentSlotManager.queuedItem).transform.position, Quaternion.identity, null, 1f);
                    }
                }
                else
                {
                    ZLog.Log("Queued item didn't map to a slot.");
                }
            }
            equipmentSlotManager.queuedItem = null;
        }
コード例 #5
0
        public override void NotifyItemEquipped(EquippableSlot equipSlot, uint amountEquipped)
        {
            m_Handler = (equipSlot.characterCollection.character as MonoBehaviour).GetComponent <NeoInventoryFirstPersonItemHandler>();
            if (m_Handler != null)
            {
                m_Handler.EquipItem(this);
            }

            base.NotifyItemEquipped(equipSlot, amountEquipped);
        }
コード例 #6
0
        public virtual void Start()
        {
            outline         = GetComponent <Outline>();
            outline.enabled = false;

            slot           = GetComponent <ItemCollectionSlotUIBase>();
            equippableSlot = GetComponent <EquippableSlot>();

            InventoryUIDragUtility.OnStartDragging += InventoryUiDragUtilityOnOnStartDragging;
            InventoryUIDragUtility.OnEndDragging   += InventoryUiDragUtilityOnOnEndDragging;
        }
コード例 #7
0
    public override void NotifyItemEquipped(EquippableSlot equipSlot, uint amountEquipped)
    {
        base.NotifyItemEquipped(equipSlot, amountEquipped);

        uConstructInventoryPlacer placer = PlayerManager.instance.currentPlayer.transform.GetComponentInParent <uConstructInventoryPlacer>();

        if (placer == null)
        {
            Debug.LogError("uConstruct Inventory placer cant be found on the player!");
            return;
        }

        placer.onEquip(building, this);
    }
コード例 #8
0
    public void AddItem(Item itemToAdd)
    {
        for (int i = 0; i < equippableSlots.Count; i++)
        {
            if (itemToAdd.equippableSlotType == equippableSlots[i].equippableSlotType)
            {
                inventory.RemoveItem(itemToAdd);
                equippableSlots[i].UpdateItem(itemToAdd);
                characterCustomization.EquipItem(itemToAdd);
                print(" ES Count  " + equippableSlots.Count + " ES index" + equippableSlots[i]);

                EquippableSlot tempSlot = equippableSlots[i];
                equippableSlots[i].button.onClick.AddListener(delegate { RemoveItem(tempSlot.item); });
            }
        }
    }
コード例 #9
0
 public void RemoveItem(Item itemToRemove)
 {
     if (!itemToRemove)
     {
         return;
     }
     for (int i = 0; i < equippableSlots.Count; i++)
     {
         if (itemToRemove.equippableSlotType == equippableSlots[i].equippableSlotType)
         {
             inventory.AddItem(itemToRemove);
             characterCustomization.EquipDefaultItem(itemToRemove.equippableSlotType);
             EquippableSlot tempSlot = equippableSlots[i];
             equippableSlots[i].button.onClick.RemoveListener(delegate { RemoveItem(tempSlot.item); });
             equippableSlots[i].RemoveItem();
         }
     }
 }
コード例 #10
0
        private void resolveSlot(EquippableSlot slot)
        {
            var wantedItem = slot.equippedItem;

            ZLog.Log("Resolving slot: " + wantedItem);

            if (slot.shouldRemoveVisual())
            {
                slot.removeVisual();
                return;
            }

            if (slot.rendered())
            {
                return;
            }

            GameObject wantedPrefab = ObjectDB.instance.GetItemPrefab(wantedItem);

            if (wantedPrefab == null)
            {
                ZLog.LogWarning("Missing item prefab " + wantedItem);
            }
            else
            {
                ItemDrop component = wantedPrefab.GetComponent <ItemDrop>();
                //ZLog.Log("Running onCreateVisual");
                slot.OnCreateVisual(slot, component);

                // This is the gameobject in the prefab that gets instantiated and attached to the stand
                GameObject wantedAttachPrefab = this.GetAttachPrefab(wantedPrefab);
                if (wantedAttachPrefab == null)
                {
                    // Can happen if a gameobject is not found with attach or attach_skin name, sometimes prefabs just change
                    // the player's textures and don't add any new geometry.
                    ZLog.LogWarning("Failed to get attach prefab for item " + wantedPrefab);
                    slot.visualObject = new VisualEquipment {
                        prefabName = wantedItem,
                        drop       = wantedPrefab.GetComponent <ItemDrop>(),
                        gameObject = new GameObject()
                    };
                }
                else
                {
                    Transform attach      = this.GetAttach(component.m_itemData);
                    var       attachPoint = this.chestStand.transform;
                    if (slot.GetAttachPoint(slot) != null)
                    {
                        attachPoint = slot.GetAttachPoint(slot).transform;
                    }
                    var attachedEquipment = UnityEngine.Object.Instantiate <GameObject>(wantedAttachPrefab, attachPoint.position, attachPoint.parent.rotation, attachPoint.parent);

                    slot.visualObject = new VisualEquipment {
                        prefabName = wantedItem,
                        drop       = wantedPrefab.GetComponent <ItemDrop>(),
                        gameObject = attachedEquipment
                    };

                    var skinned = slot.bindSkeletonToStand();

                    if (!skinned)
                    {
                        // if it's not skinned, make it look the same way as the attached point
                        attachedEquipment.transform.SetPositionAndRotation(
                            attachPoint.position,
                            attachPoint.rotation
                            );
                    }

                    foreach (Cloth cloth in attachedEquipment.GetComponentsInChildren <Cloth>())
                    {
                        //ZLog.Log("Setting cloth colliders");

                        if (this.m_clothColliders.Length != 0)
                        {
                            if (cloth.capsuleColliders.Length != 0)
                            {
                                List <CapsuleCollider> list2 = new List <CapsuleCollider>(m_clothColliders);
                                list2.AddRange(cloth.capsuleColliders);
                                cloth.capsuleColliders = list2.ToArray();
                            }
                            else
                            {
                                cloth.capsuleColliders = this.m_clothColliders;
                            }
                        }
                    }

                    // attach may be disabled.
                    attachedEquipment.SetActive(true);

                    // may be item variants
                    ItemStyle componentInChildren = attachedEquipment.GetComponentInChildren <ItemStyle>();
                    if (componentInChildren == null)
                    {
                        return;
                    }
                    componentInChildren.Setup(slot.equippedVariant);
                }
            }
        }
コード例 #11
0
        public override void NotifyItemEquipped(EquippableSlot equipSlot, uint amountEquipped)
        {
            base.NotifyItemEquipped(equipSlot, amountEquipped);

            itemPickup.TryGiveToPlayer(PlayerManager.instance.currentPlayer.GetComponentInChildren <Collider>(), (int)currentClipCount);
        }
コード例 #12
0
 public override void NotifyItemEquipped(EquippableSlot equipSlot, uint amountEquipped)
 {
     base.NotifyItemEquipped(equipSlot, amountEquipped);
     SetPlyGameValues(1.0f);
 }